--- old/./build.gradle 2018-06-13 12:21:42.011784100 +0530 +++ new/./build.gradle 2018-06-13 12:21:41.238739900 +0530 @@ -1731,12 +1731,6 @@ // Qualified exports needed by javafx.swing def qualExportsSwing = [ - "--add-exports=java.desktop/java.awt.dnd.peer=javafx.swing", - "--add-exports=java.desktop/sun.awt=javafx.swing", - "--add-exports=java.desktop/sun.awt.dnd=javafx.swing", - "--add-exports=java.desktop/sun.awt.image=javafx.swing", - "--add-exports=java.desktop/sun.java2d=javafx.swing", - "--add-exports=java.desktop/sun.swing=javafx.swing", ] // These strings define the module-source-path to be used in compilation. --- old/modules/javafx.swing/src/main/java/module-info.java 2018-06-13 12:21:46.614047400 +0530 +++ new/modules/javafx.swing/src/main/java/module-info.java 2018-06-13 12:21:45.819001900 +0530 @@ -38,6 +38,7 @@ requires javafx.base; requires transitive java.desktop; + requires static jdk.unsupported.desktop; requires transitive javafx.graphics; exports javafx.embed.swing; --- old/modules/javafx.swing/src/main/java/javafx/embed/swing/SwingNode.java 2018-06-13 12:21:51.113304700 +0530 +++ new/modules/javafx.swing/src/main/java/javafx/embed/swing/SwingNode.java 2018-06-13 12:21:50.167250600 +0530 @@ -53,7 +53,6 @@ import java.awt.dnd.DragSource; import java.awt.dnd.DropTarget; import java.awt.dnd.InvalidDnDOperationException; -import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.event.InputEvent; import java.awt.event.MouseWheelEvent; import java.awt.event.WindowEvent; @@ -80,9 +79,12 @@ import com.sun.javafx.PlatformUtil; import com.sun.javafx.embed.swing.SwingNodeHelper; import com.sun.javafx.scene.NodeHelper; -import sun.awt.UngrabEvent; -import sun.swing.JLightweightFrame; -import sun.swing.LightweightContent; + +import com.sun.javafx.util.Utils; + +import jdk.swing.interop.LightweightFrameWrapper; +import jdk.swing.interop.LightweightContentWrapper; +import jdk.swing.interop.DragSourceContextWrapper; import static javafx.stage.WindowEvent.WINDOW_HIDDEN; @@ -176,8 +178,8 @@ private int swingMinHeight; private volatile JComponent content; - private volatile JLightweightFrame lwFrame; - final JLightweightFrame getLightweightFrame() { return lwFrame; } + private volatile LightweightFrameWrapper lwFrame; + final LightweightFrameWrapper getLightweightFrame() { return lwFrame; } private NGExternalNode peer; @@ -216,14 +218,14 @@ TKStage tk = WindowHelper.getPeer(w); if (tk != null) { if (isThreadMerged) { - jlfOverrideNativeWindowHandle.invoke(lwFrame, 0L, null); + overrideNativeWindowHandle(lwFrameWrapperClass, 0L, null); } else { // Postpone actual window closing to ensure that // a native window handler is valid on a Swing side tk.postponeClose(); SwingFXUtils.runOnEDT(() -> { - jlfOverrideNativeWindowHandle.invoke(lwFrame, 0L, - (Runnable) () -> SwingFXUtils.runOnFxThread( + overrideNativeWindowHandle(lwFrameWrapperClass, 0L, + (Runnable) () -> SwingFXUtils.runOnFxThread( () -> tk.closePostponed())); }); } @@ -252,7 +254,7 @@ rawHandle = tkStage.getRawHandle(); } } - jlfOverrideNativeWindowHandle.invoke(lwFrame, rawHandle, null); + overrideNativeWindowHandle(lwFrameWrapperClass, rawHandle, null); } } @@ -331,23 +333,27 @@ } /** - * Calls JLightweightFrame.notifyDisplayChanged. + * Calls LightweightFrameWrapper.notifyDisplayChanged. * Must be called on EDT only. */ - private static OptionalMethod jlfNotifyDisplayChanged; - private static OptionalMethod jlfOverrideNativeWindowHandle; + private static OptionalMethod jlfNotifyDisplayChanged; + private static Class lwFrameWrapperClass = null; + private static native void overrideNativeWindowHandle(Class lwFrameWrapperClass, long handle, + Runnable closeWindow); static { - jlfNotifyDisplayChanged = new OptionalMethod<>(JLightweightFrame.class, + jlfNotifyDisplayChanged = new OptionalMethod<>(LightweightFrameWrapper.class, "notifyDisplayChanged", Double.TYPE, Double.TYPE); if (!jlfNotifyDisplayChanged.isSupported()) { jlfNotifyDisplayChanged = new OptionalMethod<>( - JLightweightFrame.class,"notifyDisplayChanged", Integer.TYPE); + LightweightFrameWrapper.class,"notifyDisplayChanged", Integer.TYPE); } - jlfOverrideNativeWindowHandle = new OptionalMethod<>(JLightweightFrame.class, - "overrideNativeWindowHandle", Long.TYPE, Runnable.class); + try { + lwFrameWrapperClass = Class.forName("jdk.swing.interop.LightweightFrameWrapper"); + } catch (Throwable t) {} + Utils.loadNativeSwingLibrary(); } /* @@ -359,7 +365,7 @@ lwFrame = null; } if (content != null) { - lwFrame = new JLightweightFrame(); + lwFrame = new LightweightFrameWrapper(); SwingNodeWindowFocusListener snfListener = new SwingNodeWindowFocusListener(this); @@ -559,7 +565,8 @@ private final EventHandler ungrabHandler = event -> { if (!skipBackwardUnrgabNotification) { if (lwFrame != null) { - AccessController.doPrivileged(new PostEventAction(new UngrabEvent(lwFrame))); + AccessController.doPrivileged(new PostEventAction( + lwFrame.createUngrabEvent(lwFrame))); } } }; @@ -673,11 +680,11 @@ } /** - * Calls JLightweightFrame.setHostBounds. + * Calls LightweightFrameWrapper.setHostBounds. * Must be called on EDT only. */ - private static final OptionalMethod jlfSetHostBounds = - new OptionalMethod<>(JLightweightFrame.class, "setHostBounds", + private static final OptionalMethod jlfSetHostBounds = + new OptionalMethod<>(LightweightFrameWrapper.class, "setHostBounds", Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE); private void locateLwFrame() { @@ -797,9 +804,9 @@ } private static class SwingNodeDisposer implements DisposerRecord { - JLightweightFrame lwFrame; + LightweightFrameWrapper lwFrame; - SwingNodeDisposer(JLightweightFrame ref) { + SwingNodeDisposer(LightweightFrameWrapper ref) { this.lwFrame = ref; } public void dispose() { @@ -838,7 +845,7 @@ } } - private static class SwingNodeContent implements LightweightContent { + private static class SwingNodeContent extends LightweightContentWrapper { private JComponent comp; private volatile FXDnD dnd; private WeakReference swingNodeRef; @@ -866,9 +873,7 @@ } } - // Note: we skip @Override annotation and implement both pre-hiDPI and post-hiDPI versions - // of the method for compatibility. - //@Override + @Override public void imageBufferReset(int[] data, int x, int y, int width, int height, int linestride) { imageBufferReset(data, x, y, width, height, linestride, 1); } @@ -879,7 +884,7 @@ swingNode.setImageBuffer(data, x, y, width, height, linestride, scale, scale); } } - //@Override + @Override public void imageBufferReset(int[] data, int x, int y, int width, int height, int linestride, double scaleX, double scaleY) { SwingNode swingNode = swingNodeRef.get(); if (swingNode != null) { @@ -984,7 +989,7 @@ } } - //@Override + @Override public synchronized T createDragGestureRecognizer( Class abstractRecognizerClass, DragSource ds, Component c, int srcActions, @@ -994,20 +999,20 @@ return dnd.createDragGestureRecognizer(abstractRecognizerClass, ds, c, srcActions, dgl); } - //@Override - public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException + @Override + public DragSourceContextWrapper createDragSourceContext(DragGestureEvent dge) throws InvalidDnDOperationException { initDnD(); - return dnd.createDragSourceContextPeer(dge); + return dnd.createDragSourceContext(dge); } - //@Override + @Override public void addDropTarget(DropTarget dt) { initDnD(); dnd.addDropTarget(dt); } - //@Override + @Override public void removeDropTarget(DropTarget dt) { initDnD(); dnd.removeDropTarget(dt); @@ -1049,7 +1054,7 @@ @Override public void handle(MouseEvent event) { - JLightweightFrame frame = lwFrame; + LightweightFrameWrapper frame = lwFrame; if (frame == null) { return; } @@ -1087,7 +1092,7 @@ int absX = (int) Math.round(event.getScreenX()); int absY = (int) Math.round(event.getScreenY()); java.awt.event.MouseEvent mouseEvent = - new java.awt.event.MouseEvent( + frame.createMouseEvent( frame, swingID, swingWhen, swingModifiers, relX, relY, absX, absY, event.getClickCount(), swingPopupTrigger, swingButton); @@ -1098,7 +1103,7 @@ private class SwingScrollEventHandler implements EventHandler { @Override public void handle(ScrollEvent event) { - JLightweightFrame frame = lwFrame; + LightweightFrameWrapper frame = lwFrame; if (frame == null) { return; } @@ -1122,7 +1127,7 @@ } } - private void sendMouseWheelEvent(Component source, double fxX, double fxY, int swingModifiers, double delta) { + private void sendMouseWheelEvent(LightweightFrameWrapper source, double fxX, double fxY, int swingModifiers, double delta) { int wheelRotation = (int) delta; int signum = (int) Math.signum(delta); if (signum * delta < 1) { @@ -1131,9 +1136,7 @@ int x = (int) Math.round(fxX); int y = (int) Math.round(fxY); MouseWheelEvent mouseWheelEvent = - new MouseWheelEvent(source, java.awt.event.MouseEvent.MOUSE_WHEEL, - System.currentTimeMillis(), swingModifiers, x, y, 0, 0, - 0, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1 , -wheelRotation); + lwFrame.createMouseWheelEvent(source, swingModifiers, x, y, -wheelRotation); AccessController.doPrivileged(new PostEventAction(mouseWheelEvent)); } } @@ -1141,7 +1144,7 @@ private class SwingKeyEventHandler implements EventHandler { @Override public void handle(KeyEvent event) { - JLightweightFrame frame = lwFrame; + LightweightFrameWrapper frame = lwFrame; if (frame == null) { return; } @@ -1176,9 +1179,9 @@ } } long swingWhen = System.currentTimeMillis(); - java.awt.event.KeyEvent keyEvent = new java.awt.event.KeyEvent( - frame, swingID, swingWhen, swingModifiers, - swingKeyCode, swingChar); + java.awt.event.KeyEvent keyEvent = frame.createKeyEvent(frame, + swingID, swingWhen, swingModifiers, swingKeyCode, + swingChar); AccessController.doPrivileged(new PostEventAction(keyEvent)); } } --- old/modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java 2018-06-13 12:21:55.392549500 +0530 +++ new/modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java 2018-06-13 12:21:54.573502600 +0530 @@ -38,6 +38,7 @@ import java.awt.Insets; import java.awt.EventQueue; import java.awt.SecondaryLoop; +import java.awt.GraphicsEnvironment; import java.awt.event.AWTEventListener; import java.awt.event.ComponentEvent; import java.awt.event.FocusEvent; @@ -77,13 +78,12 @@ import java.lang.reflect.Method; import java.util.concurrent.atomic.AtomicInteger; -import sun.awt.AppContext; -import sun.awt.SunToolkit; -import sun.java2d.SunGraphics2D; -import sun.java2d.SurfaceData; + import com.sun.javafx.logging.PlatformLogger; import com.sun.javafx.logging.PlatformLogger.Level; +import jdk.swing.interop.SwingInterOpUtils; + /** * {@code JFXPanel} is a component to embed JavaFX content into * Swing applications. The content to be displayed is specified @@ -450,10 +450,7 @@ // component. Fire the same MOUSE_PRESSED event after // requestFocus() so that 2nd mouse press will be honoured // since now fx have focus - AppContext context = SunToolkit.targetToAppContext(this); - if (context != null) { - SunToolkit.postEvent(context, e); - } + SwingInterOpUtils.postEvent(this, e); } } @@ -570,11 +567,12 @@ double newScaleFactorX = scaleFactorX; double newScaleFactorY = scaleFactorY; Graphics g = getGraphics(); - if (g instanceof SunGraphics2D) { - SurfaceData sd = ((SunGraphics2D) g).surfaceData; - newScaleFactorX = sd.getDefaultScaleX(); - newScaleFactorY = sd.getDefaultScaleY(); - } + newScaleFactorX = GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(). + getDefaultTransform().getScaleX(); + newScaleFactorY = GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(). + getDefaultTransform().getScaleY(); if (oldWidth != pWidth || oldHeight != pHeight || newScaleFactorX != scaleFactorX || newScaleFactorY != scaleFactorY) { @@ -765,11 +763,12 @@ double newScaleFactorX = scaleFactorX; double newScaleFactorY = scaleFactorY; - if (g instanceof SunGraphics2D) { - SurfaceData sd = ((SunGraphics2D)g).surfaceData; - newScaleFactorX = sd.getDefaultScaleX(); - newScaleFactorY = sd.getDefaultScaleY(); - } + newScaleFactorX = GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(). + getDefaultTransform().getScaleX(); + newScaleFactorY = GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration(). + getDefaultTransform().getScaleY(); if (scaleFactorX != newScaleFactorX || scaleFactorY != newScaleFactorY) { createResizePixelBuffer(newScaleFactorX, newScaleFactorY); // The scene will request repaint. @@ -828,7 +827,7 @@ } private transient AWTEventListener ungrabListener = event -> { - if (event instanceof sun.awt.UngrabEvent) { + if (SwingInterOpUtils.isUngrabEvent(event)) { SwingFXUtils.runOnFxThread(() -> { if (JFXPanel.this.stagePeer != null && getScene() != null && @@ -877,7 +876,7 @@ AccessController.doPrivileged((PrivilegedAction) () -> { JFXPanel.this.getToolkit().addAWTEventListener(ungrabListener, - SunToolkit.GRAB_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); + SwingInterOpUtils.GRAB_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); return null; }); updateComponentSize(); // see RT-23603 @@ -928,12 +927,7 @@ } private void invokeOnClientEDT(Runnable r) { - AppContext context = SunToolkit.targetToAppContext(this); - if (context == null) { - if (log.isLoggable(Level.FINE)) log.fine("null AppContext encountered!"); - return; - } - SunToolkit.postEvent(context, new InvocationEvent(this, r)); + SwingInterOpUtils.postEvent(this, new InvocationEvent(this, r)); } private class HostContainer implements HostInterface { @@ -1054,9 +1048,7 @@ invokeOnClientEDT(() -> { Window window = SwingUtilities.getWindowAncestor(JFXPanel.this); if (window != null) { - if (JFXPanel.this.getToolkit() instanceof SunToolkit) { - ((SunToolkit)JFXPanel.this.getToolkit()).grab(window); - } + SwingInterOpUtils.grab(JFXPanel.this.getToolkit(), window); } }); @@ -1072,9 +1064,7 @@ invokeOnClientEDT(() -> { Window window = SwingUtilities.getWindowAncestor(JFXPanel.this); if (window != null) { - if (JFXPanel.this.getToolkit() instanceof SunToolkit) { - ((SunToolkit)JFXPanel.this.getToolkit()).ungrab(window); - } + SwingInterOpUtils.ungrab(JFXPanel.this.getToolkit(), window); } }); } --- old/modules/javafx.swing/src/main/java/javafx/embed/swing/FXDnD.java 2018-06-13 12:21:59.756799100 +0530 +++ new/modules/javafx.swing/src/main/java/javafx/embed/swing/FXDnD.java 2018-06-13 12:21:58.782743400 +0530 @@ -44,8 +44,6 @@ import java.awt.dnd.DropTargetListener; import java.awt.dnd.InvalidDnDOperationException; import java.awt.dnd.MouseDragGestureRecognizer; -import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.dnd.peer.DropTargetContextPeer; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; @@ -58,10 +56,11 @@ import javafx.scene.input.Dragboard; import javafx.scene.input.MouseEvent; import javafx.scene.input.TransferMode; -import sun.awt.AWTAccessor; -import sun.awt.dnd.SunDragSourceContextPeer; -import sun.swing.JLightweightFrame; +import jdk.swing.interop.LightweightFrameWrapper; +import jdk.swing.interop.SwingInterOpUtils; +import jdk.swing.interop.DragSourceContextWrapper; +import jdk.swing.interop.DropTargetContextWrapper; /** * A utility class to connect DnD mechanism of Swing and FX. @@ -99,9 +98,8 @@ this.x = xArg; this.y = yArg; - final JLightweightFrame lwFrame = node.getLightweightFrame(); - Component c = AWTAccessor.getContainerAccessor().findComponentAt( - lwFrame, x, y, false); + final LightweightFrameWrapper lwFrame = node.getLightweightFrame(); + Component c = lwFrame.findComponentAt(lwFrame, x, y, false); if (c == null) return; synchronized (c.getTreeLock()) { @@ -114,7 +112,7 @@ //assert c == object.getComponent(); // Translate x, y from lwFrame to component coordinates - while (c != lwFrame && c != null) { + while ((lwFrame.isCompEqual(c,lwFrame)) && c != null) { x -= c.getX(); y -= c.getY(); c = c.getParent(); @@ -197,7 +195,7 @@ // Also, the modifiers here should've actually come from the last known mouse event (last MOVE or DRAG). // But we're OK with using the initial PRESS modifiers for now - int initialAction = SunDragSourceContextPeer.convertModifiersToDropAction( + int initialAction = DragSourceContextWrapper.convertModifiersToDropAction( modifiers, getSourceActions()); fireDragGestureRecognized(initialAction, new java.awt.Point(x, y)); @@ -281,7 +279,7 @@ }; - private final class FXDragSourceContextPeer extends SunDragSourceContextPeer { + private final class FXDragSourceContextPeer extends DragSourceContextWrapper { private volatile int sourceActions = 0; private final CachingTransferable transferable = new CachingTransferable(); @@ -294,7 +292,7 @@ Platform.runLater(() -> Toolkit.getToolkit().exitNestedEventLoop(FXDragSourceContextPeer.this, null)); } - @Override protected void setNativeCursor(long nativeCtxt, Cursor c, int cType) { + @Override protected void setNativeCursor(Cursor c, int cType) { //TODO } @@ -345,7 +343,7 @@ return (T) new FXDragGestureRecognizer(ds, c, srcActions, dgl); } - public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException + public DragSourceContextWrapper createDragSourceContext(DragGestureEvent dge) throws InvalidDnDOperationException { return new FXDragSourceContextPeer(dge); } @@ -418,7 +416,7 @@ activeDTContextPeer = null; }; - private final class FXDropTargetContextPeer implements DropTargetContextPeer { + private final class FXDropTargetContextPeer extends DropTargetContextWrapper { private int targetActions = DnDConstants.ACTION_NONE; private int currentAction = DnDConstants.ACTION_NONE; @@ -469,7 +467,7 @@ SwingFXUtils.runOnEDTAndWait(FXDnD.this, () -> { if (target != dt) { if (ctx != null) { - AWTAccessor.getDropTargetContextAccessor().reset(ctx); + this.reset(ctx); } ctx = null; @@ -479,8 +477,8 @@ if (target != null) { if (ctx == null) { ctx = target.getDropTargetContext(); - AWTAccessor.getDropTargetContextAccessor() - .setDropTargetContextPeer(ctx, FXDropTargetContextPeer.this); + this.setDropTargetContext(ctx, + FXDropTargetContextPeer.this); } DropTargetListener dtl = (DropTargetListener)target; --- old/modules/javafx.swing/src/main/java/javafx/embed/swing/SwingFXUtils.java 2018-06-13 12:22:04.060045200 +0530 +++ new/modules/javafx.swing/src/main/java/javafx/embed/swing/SwingFXUtils.java 2018-06-13 12:22:03.311002400 +0530 @@ -28,6 +28,9 @@ import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.awt.image.SampleModel; +import java.awt.image.SinglePixelPackedSampleModel; import java.nio.IntBuffer; import java.util.Set; import java.util.HashSet; @@ -41,7 +44,8 @@ import javafx.scene.paint.Color; import com.sun.javafx.tk.Toolkit; import javax.swing.SwingUtilities; -import sun.awt.image.IntegerComponentRaster; + +import jdk.swing.interop.SwingInterOpUtils; /** * This class provides utility methods for converting data types between @@ -111,10 +115,16 @@ wimg = new WritableImage(bw, bh); } PixelWriter pw = wimg.getPixelWriter(); - IntegerComponentRaster icr = (IntegerComponentRaster) bimg.getRaster(); - int data[] = icr.getDataStorage(); - int offset = icr.getDataOffset(0); - int scan = icr.getScanlineStride(); + int data[]; + DataBufferInt db = (DataBufferInt)bimg.getRaster().getDataBuffer(); + data = db.getData(); + int offset = bimg.getRaster().getDataBuffer().getOffset(); + int scan = 0; + SampleModel sm = bimg.getRaster().getSampleModel(); + if (sm instanceof SinglePixelPackedSampleModel) { + scan = ((SinglePixelPackedSampleModel)sm).getScanlineStride(); + } + PixelFormat pf = (bimg.isAlphaPremultiplied() ? PixelFormat.getIntArgbPreInstance() : PixelFormat.getIntArgbInstance()); @@ -281,10 +291,15 @@ if (bimg == null) { bimg = new BufferedImage(iw, ih, prefBimgType); } - IntegerComponentRaster icr = (IntegerComponentRaster) bimg.getRaster(); - int offset = icr.getDataOffset(0); - int scan = icr.getScanlineStride(); - int data[] = icr.getDataStorage(); + DataBufferInt db = (DataBufferInt)bimg.getRaster().getDataBuffer(); + int data[] = db.getData(); + int offset = bimg.getRaster().getDataBuffer().getOffset(); + int scan = 0; + SampleModel sm = bimg.getRaster().getSampleModel(); + if (sm instanceof SinglePixelPackedSampleModel) { + scan = ((SinglePixelPackedSampleModel)sm).getScanlineStride(); + } + WritablePixelFormat pf = getAssociatedPixelFormat(bimg); pr.getPixels(0, 0, iw, ih, pf, data, offset, scan); return bimg; --- old/modules/javafx.swing/src/main/java/com/sun/javafx/embed/swing/SwingFXUtilsImpl.java 2018-06-13 12:22:08.266285800 +0530 +++ new/modules/javafx.swing/src/main/java/com/sun/javafx/embed/swing/SwingFXUtilsImpl.java 2018-06-13 12:22:07.497241800 +0530 @@ -33,8 +33,7 @@ import java.security.PrivilegedAction; import java.util.concurrent.atomic.AtomicBoolean; import javafx.application.Platform; -import sun.awt.AWTAccessor; -import sun.awt.FwDispatcher; +import jdk.swing.interop.DispatcherWrapper; public class SwingFXUtilsImpl { @@ -65,7 +64,7 @@ } } - private static class FXDispatcher implements FwDispatcher { + private static class FXDispatcher extends DispatcherWrapper { @Override public boolean isDispatchThread() { @@ -90,11 +89,11 @@ //Called with reflection from PlatformImpl to avoid dependency public static void installFwEventQueue() { - AWTAccessor.getEventQueueAccessor().setFwDispatcher(getEventQueue(), new FXDispatcher()); + DispatcherWrapper.setFwDispatcher(getEventQueue(), new FXDispatcher()); } //Called with reflection from PlatformImpl to avoid dependency public static void removeFwEventQueue() { - AWTAccessor.getEventQueueAccessor().setFwDispatcher(getEventQueue(), null); + DispatcherWrapper.setFwDispatcher(getEventQueue(), null); } } --- old/modules/javafx.graphics/src/main/java/com/sun/javafx/util/Utils.java 2018-06-13 12:22:12.820546300 +0530 +++ new/modules/javafx.graphics/src/main/java/com/sun/javafx/util/Utils.java 2018-06-13 12:22:11.990498800 +0530 @@ -44,6 +44,8 @@ import com.sun.javafx.PlatformUtil; import java.security.AccessController; import java.security.PrivilegedAction; +import com.sun.glass.utils.NativeLibLoader; +import com.sun.prism.impl.PrismSettings; /** * Some basic utilities which need to be in java (for shifting operations or @@ -961,4 +963,19 @@ return new String(dst, 0, dstIndex); } + + public static synchronized void loadNativeSwingLibrary() { + AccessController.doPrivileged((PrivilegedAction) () -> { + String libName = "prism_common"; + + if (PrismSettings.verbose) { + System.out.println("Loading Prism common native library ..."); + } + NativeLibLoader.loadLibrary(libName); + if (PrismSettings.verbose) { + System.out.println("\tsucceeded."); + } + return null; + }); + } } --- /dev/null 2018-06-13 12:22:17.000000000 +0530 +++ new/modules/javafx.graphics/src/main/native-prism/SwingInterop.c 2018-06-13 12:22:16.076732500 +0530 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include + +/* + * Class javafx_embed_swing_SwingNode + * Method: overrideNativeWindowHandle + * Signature (Ljava/lang/Class;JLjava/lang/Runnable)Ljdk.swing.interop.LightweightFrameWrapper; + */ +JNIEXPORT jobject +Java_javafx_embed_swing_SwingNode_overrideNativeWindowHandle( + JNIEnv *env, jclass cls, jclass ownerClass, jlong id, jclass runnable) { + + jmethodID cons; + if (ownerClass == NULL) { + return NULL; + } + cons = (*env)->GetMethodID(env, ownerClass, "overrideNativeWindowHandle", + "(JLjava/lang/Runnable;)V"); + if (cons == NULL || (*env)->ExceptionCheck(env)) { + return NULL; + } + return (*env)->NewObject(env, ownerClass, cons, id, runnable); +} + +