Skip to content

Functions.java needs annotation for java 9+ javac -h vs javah #902

@wltjr

Description

@wltjr
  1. 4.5.1/GIT
  2. Oracle JDK 9.0.1 (there is no javah on EA 10)
  3. Gentoo Linux
  4. amd64/64bit
  5. If I do javac -h on Functions.java I get no output. I do not get generated C/jni headers for Functions.java. I do get generated headers from Native.java. Its either a bug in javac -h handling, and/or Functions.java needs annotations since not inheriting Native stuff that triggers generation of headers in Java 9+. For the time being using javah in Java 9 for Funtions.java, but javah is no longer as of EA 10. Thus need to fix Functions.java to work with 9+ javac -h.
  6. Steps to reproduce
    a. Install JDK 9+
    b. javac -h -cp jna.jar com/sun/jna/Function.java
    c. No headers are generated

Repeat A & B using Native.java you get generated headers.

Seems to be either not having annotations or not containing native methods. Something causes Native.java to generate its headers, and prevents Function.java's headers from being generated. The following command only works for Native.java. Using javah on the same works for both.

Does not generate com_sun_jna_Function.h but does generate com_sun_jna_Native.h
javac -h native -cp ${PN}.jar src/com/sun/jna/{Function,Native}.java

Generates both via legacy javah
javah -d native -cp ${PN}.jar com.sun.jna.{Function,Native}

From Java 9 javac man page
"-h directory

Specifies where to place generated native header files.

When you specify this option, a native header file is generated for each class that contains native methods or that has one or more constants annotated with the java.lang.annotation.Native annotation."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions