JDK-8166231 : use @Native annotation in web classes
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-09-17
  • Updated: 2017-01-30
  • Resolved: 2016-10-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u131Fixed 9Fixed
Description
The javac tool now provides the ability to generate native headers as needed. This removes the need to run the javah tool as a separate step in the build pipeline. The feature is enabled in javac by using the new -h option, which is used to specify a directory in which the header files should be written. Header files will be generated for any class which has either native methods, or constant fields annotated with a new annotation of type java.lang.annotation.Native.

This should ease the transition to a modular build by allowing us to remove one extra javah step. 
Comments
Changeset: b0f8f513f3a9 Author: ddhill Date: 2016-10-04 14:39 -0400 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/b0f8f513f3a9 8166231: use @Native annotation in web classes Reviewed-by: kcr
04-10-2016

[~ddhill] you are right , Those two files are not really used.
04-10-2016

I don't think we should add the @Native tag unless needed.
04-10-2016

and this grep seems to say that the other is not used in native either: ddhill@ddhill-pad:~/sb/9/graphics/rt$ grep -r COMPOSITE_CLEAR modules/javafx.web/ modules/javafx.web/src/main/java/com/sun/webkit/graphics/WCGraphicsContext.java: @Native public static final int COMPOSITE_CLEAR = 0; modules/javafx.web/src/main/java/com/sun/javafx/webkit/prism/WCGraphicsPrismContext.java: case COMPOSITE_CLEAR: // same as xor I am willing to add the @Native tag but doing so should probably be done when we need the value in native. ( or are planning on doing so).
04-10-2016

Guru, TextBreakIteratorShim.java is a test class - are these constants really used in native code ? modules/javafx.web/src/test/java/com/sun/webkit/text/TextBreakIteratorShim.java: @Native public static final int CHARACTER_ITERATOR = TextBreakIterator.CHARACTER_ITERATOR; modules/javafx.web/src/main/java/com/sun/webkit/text/TextBreakIterator.java: @Native static final int CHARACTER_ITERATOR = 0; says that the shim code is really not used in native.
04-10-2016

+1, Please consider these two files and its constants. WCGraphicsContext.java -- COMPOSITE_CLEAR ... TextBreakIteratorShim.java -- CHARACTER_ITERATOR ...
04-10-2016

+1
26-09-2016

updated: http://cr.openjdk.java.net/~ddhill/8166231.2
20-09-2016

and one last one on Linux diff --git a/modules/javafx.web/src/main/native/Source/WebCore/platform/java/PasteboardJava.cpp b/modules/javafx.web/src/main/native/Source/WebCore/platform/java/PasteboardJava.cpp --- a/modules/javafx.web/src/main/native/Source/WebCore/platform/java/PasteboardJava.cpp +++ b/modules/javafx.web/src/main/native/Source/WebCore/platform/java/PasteboardJava.cpp @@ -25,7 +25,6 @@ #include "Attr.h" #include "HTMLNames.h" #include "HTMLParserIdioms.h" -#include "com_sun_webkit_WCPasteboard.h" #include "wtf/Ref.h"
20-09-2016

adding - one is an empty include diff --git a/modules/javafx.web/src/main/java/com/sun/webkit/graphics/WCRenderQueue.java b/modules/javafx.web/src/main/java/com/sun/webkit/graphics/WCRenderQueue.java --- a/modules/javafx.web/src/main/java/com/sun/webkit/graphics/WCRenderQueue.java +++ b/modules/javafx.web/src/main/java/com/sun/webkit/graphics/WCRenderQueue.java @@ -25,6 +25,7 @@ package com.sun.webkit.graphics; +import java.lang.annotation.Native; import com.sun.webkit.Invoker; import java.nio.ByteBuffer; import java.util.HashMap; @@ -37,7 +38,7 @@ private final static AtomicInteger idCountObj = new AtomicInteger(0); private final static Logger log = Logger.getLogger(WCRenderQueue.class.getName()); - public final static int MAX_QUEUE_SIZE = 0x80000; + @Native public final static int MAX_QUEUE_SIZE = 0x80000; private final LinkedList<BufferData> buffers = new LinkedList<BufferData>(); private BufferData currentBuffer = new BufferData(); diff --git a/modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/WatchdogJava.cpp b/modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/WatchdogJava.cpp --- a/modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/WatchdogJava.cpp +++ b/modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/WatchdogJava.cpp @@ -5,8 +5,6 @@ #include "config.h" #include "Watchdog.h" -#include "com_sun_webkit_WatchdogTimer.h" - namespace JSC { static jclass GetWatchdogTimerClass(JNIEnv* env)
20-09-2016

webrev: http://cr.openjdk.java.net/~ddhill/8166231
17-09-2016