libgdx / gdx-jnigen

jnigen is a small library that can be used with or without libGDX which allows C/C++ code to be written inline with Java source code.
Apache License 2.0
60 stars 25 forks source link

Jnigen: javah is deprecated, add support for javac -h #7

Closed AAstroPhysiCS closed 4 years ago

AAstroPhysiCS commented 4 years ago

Issue details

Javah has been removed since java 10. It would be very nice to see, if jnigen supported javac -h instead of javah, or maybe both by checking the current java version. Article about the removal: https://openjdk.java.net/jeps/313

Reproduction steps/code

public static void main(String[] args) throws Exception {
        NativeCodeGenerator jnigen = new NativeCodeGenerator();
        jnigen.generate("X/src/main/java", "X/target/classes", "jni", new String[
        {"**/X.java"}, null);
}

Version of LibGDX and/or relevant dependencies

Jnigen: 1.9.8

Stacktrace

Exception in thread "main" java.io.IOException: Cannot run program "javah": CreateProcess error=2, The system cannot find the file specified

Here is the method from the "NativeCodeGenerator" class.

private void generateHFile(FileDescriptor file) throws Exception {
        String className = this.getFullyQualifiedClassName(file);
        String command = "javah -classpath " + this.classpath + " -o " + this.jniDir.path() + "/" + className + ".h " + className;
        Process process = Runtime.getRuntime().exec(command);
        process.waitFor();
        if (process.exitValue() != 0) {
            System.out.println();
            System.out.println("Command: " + command);
            InputStream errorStream = process.getErrorStream();
            boolean var6 = false;

            int c;
            while((c = errorStream.read()) != -1) {
                System.out.print((char)c);
            }
        }
    }
gviznyuk commented 4 years ago

I concur, I need this change as well.