Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8170730

javac always generates JNI header regardless of source change

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P3
    • tbd
    • 8, 9
    • tools
    • None

    Description

      Recently we have switched from "javah" to "javac -h" for JavaFX build. After the migration we encountered a huge impact in the build time. See JDK-8170591.

      In short, the behaviour of "javah" and "javac -h" seems to be different. "javac -h" generates header file(with new timestamp) regardless of any change in the given source file, but "javah" seems to be intelligent enough to avoid generating a header unless there is change in the class file. Try the below test,

      echo "class Foo {native void foo();}" > Foo.java && javac Foo.java -h . && javah -o Foo_javah.h Foo && ls -lh Foo.class Foo.h Foo_javah.h

      You will see something like below,

      -rw-r--r-- 1 ARAJKUMA wheel 200B Dec 2 17:12 Foo.class
      -rw-r--r-- 1 ARAJKUMA wheel 338B Dec 2 17:12 Foo.h
      -rw-r--r-- 1 ARAJKUMA wheel 338B Dec 2 17:04 Foo_javah.h

      Look at the timestamp of generated file, timestamp of "Foo.h" which is generated by "javac -h" is close to timestamp of "Foo.class", but timestamp of "Foo_javah.h" never changes unless there is a change the class file related to JNI.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              arajkumar Arunprasad Rajkumar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: