Blame |
Last modification |
View Log
| RSS feed
package com.gebauz.PonPonChun;
import com.gebauz.Bauzoid.app.JNITestInterface;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.lwjgl.opengl.Display;
public class JNITest
implements JNITestInterface
{
static {
// load library
System.
loadLibrary("JNI Library");
}
static public class Feedback
{
public int x =
0;
public String test =
"bla";
public float y = 0.0f
;
public Feedback
(int i
)
{
x = i
;
}
public void out
()
{
System.
out.
println(test + x +
" " + y
);
}
}
static public class WMTouchEvent
{
public int x
;
public int y
;
}
// native method signature
public native void hello
(String name
);
public native void test
(long hwnd
);
public void callBack
(Feedback test
)
{
test.
out();
}
@
Override
public void doSomething
()
{
try
{
long hwnd = -
1;
Object displayImpl =
null;
Method[] displayMethods = Display.
class.
getDeclaredMethods();
for (Method m : displayMethods
)
{
if (m.
getName().
equals("getImplementation"))
{
m.
setAccessible(true);
displayImpl = m.
invoke(null,
null);
break;
}
}
Field[] windowsDisplayFields = displayImpl.
getClass().
getDeclaredFields();
for (Field f : windowsDisplayFields
)
{
if (f.
getName().
equals("hwnd"))
{
f.
setAccessible(true);
hwnd =
(Long) f.
get(displayImpl
);
continue;
}
}
System.
out.
println("Address of hWnd: " + hwnd
);
new JNITest
().
test(hwnd
);
}
catch (Exception e
)
{
e.
printStackTrace();
}
}
}