Java 类com.badlogic.gdx.jnigen.JniGenSharedLibraryLoader 实例源码

项目:libgdxcn    文件:MyJniClass.java   
public static void main(String[] args) throws Exception {
    // generate C/C++ code
    new NativeCodeGenerator().generate("src", "bin", "jni", new String[] { "**/MyJniClass.java" }, null);

    // generate build scripts, for win32 only
    BuildConfig buildConfig = new BuildConfig("test");
    BuildTarget win32 = BuildTarget.newDefaultTarget(TargetOs.Windows, false);
    win32.compilerPrefix = "";
    win32.cppFlags += " -g";
    new AntScriptGenerator().generate(buildConfig, win32);

    // build natives
    BuildExecutor.executeAnt("jni/build.xml", "clean all -v");

    // load the test-natives.jar and from it the shared library, then execute the test. 
    new JniGenSharedLibraryLoader("libs/test-natives.jar").load("test");
    ByteBuffer buffer = ByteBuffer.allocateDirect(1);
    buffer.put(0, (byte)8);
    MyJniClass.test(true, (byte)1, (char)2, (short)3, 4, 5, 6, 7, buffer, new boolean[] { false }, new char[] { 9 }, new short[] { 10 }, new int[] { 11 }, new long[] { 12 }, new float[] { 13 }, new double[] { 14 }, null, "Hurray");
}