Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavahExecutable fails on Java10 #17

Open
hendriks73 opened this issue Apr 3, 2018 · 13 comments
Open

JavahExecutable fails on Java10 #17

hendriks73 opened this issue Apr 3, 2018 · 13 comments
Labels
Milestone

Comments

@hendriks73
Copy link
Contributor

hendriks73 commented Apr 3, 2018

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

@hendriks73
Copy link
Contributor Author

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
Copy link
Contributor Author

But... to use the plugin on Java9/10, a dependency definitely needs to be updated. Please see #18.

@dantran dantran added this to the 1.0-alpha-9 milestone May 4, 2018
@ctubbsii
Copy link
Contributor

ctubbsii commented May 4, 2018

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
Copy link
Contributor

dantran commented May 4, 2018

@hendriks73 is this fixed in alpha-9?

@hendriks73
Copy link
Contributor Author

No, it's not.

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

  • somehow execute javac with the appropriate flags (not sure, if that's possible)
  • show a warning that javah is not supported anymore
  • find some other programmatic way to generate headers

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

@dantran dantran modified the milestones: 1.0-alpha-9, 1.0-alpha-10 May 7, 2018
@ghost
Copy link

ghost commented Jun 21, 2018

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
Copy link
Contributor

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.

@stuhlmeier
Copy link

stuhlmeier commented Jan 23, 2019

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

@ryantheseer
Copy link

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
Copy link

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
Copy link

ryantheseer commented Dec 24, 2019

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
Copy link

mizapf commented Sep 10, 2020

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

@jbescos
Copy link

jbescos commented Mar 26, 2021

I am also interested in this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants