mojohaus / maven-native

https://www.mojohaus.org/maven-native/
MIT License
18 stars 12 forks source link

JavahExecutable fails on Java10 #17

Open hendriks73 opened 6 years ago

hendriks73 commented 6 years ago

Java 10 got rid of the javah executable and replaced it with javac -h.

hendriks73 commented 6 years ago

Looks like the regular maven compiler plugin (v3.7.0) can be configured to spit out the headers like so:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <compilerArgs>
                    <arg>-h</arg>
                    <arg>${project.build.directory}/native/include</arg>
                </compilerArgs>
            </configuration>
        </plugin>
hendriks73 commented 6 years ago

But... to use the plugin on Java9/10, a dependency definitely needs to be updated. Please see https://github.com/mojohaus/maven-native/pull/18.

ctubbsii commented 6 years ago

The 1.0-alpha-9 version was released. That milestone should be closed and this issue bumped to the next milestone (unless it was already fixed).

dantran commented 6 years ago

@hendriks73 is this fixed in alpha-9?

hendriks73 commented 6 years ago

No, it's not.

Java9 and 10 do not have a javah executable anymore. So the native plugin should either

That aside, users can use the regular compiler plugin to produce header files, as shown above.

ghost commented 6 years ago

There is one project - https://github.com/Glavo/gjavah it looks like an implementation of javah in pure java. It is mit licensed. Maybe it can be used instead of javah?

ctubbsii commented 6 years ago

Given that javac -h works even better than javah, I don't really see why this even needs to be maintained anymore. It's easy enough to update the maven-compiler-plugin to use -h and, if necessary, it's not too difficult to use profiles to support different Java versions to support pre- and post-Java8, which added the -h flag to javac.

svby commented 5 years ago

This is true but javac -h becomes useless when working with other JVM languages as it only operates on .java source files 😕

ryantheseer commented 4 years ago

Given that javac -h works even better than javah, I don't really see why this even needs to be maintained anymore. It's easy enough to update the maven-compiler-plugin to use -h and, if necessary, it's not too difficult to use profiles to support different Java versions to support pre- and post-Java8, which added the -h flag to javac.

I see that we can change org.codehaus.mojo.natives.javah.JavahExecutable to use javac -h instead of javah, but I believe the command-line changed from referring to the class file with its package name to using the .java file. Let's say I successfully branch this project, make that small change, build and install the plugin for maven, how would I call the plugin differently?

ryantheseer commented 4 years ago

Also, if I understand correctly, this plugin allows you to define a build artifact that builds the JNI header and the native library (.so, .dll, .dylib) in the same build call. Do I have to separate those into two steps if I use the maven-compiler-plugin as noted above?

ryantheseer commented 4 years ago

What I've done for now is to hack the org.codehaus.mojo.natives.javah.JavahExecutable to use javac -h instead of javah, and modified my pom.xml to use the .java source path for the <javahClassName> property instead of using the dot-separated package and class name. I can build it with JDK8 that way. Next step is to try with a newer JDK. image

mizapf commented 3 years ago

Is this fix for JavahExecutable already available? I'm having an issue with another project that relies on the maven-native plugin.

jbescos commented 3 years ago

I am also interested in this fix.