From 7ec068e0c95a230101450cc80031f76770a0cd49 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 19 Aug 2019 13:14:24 +0200 Subject: Bug 1363: Java 11: Resolve unsupported JAWTUtil.getMonitorDisplayID(..) Previous commits removed access to OSX's GraphicsDevice.getCGDisplayID() on Java9+, avoiding illegal reflective access. Here we JAWTUtil.getMonitorDisplayID(..) simply returns null if Java9 or !OSX, so the sole NewtFactory caller falls back to the alternative working solution. Orig patch Wade Walker: This was used on Mac OS only to create a MonitorDevice in NewtFactoryAWT. But there was a fallback method for creating MonitorDevice, and testing with TestGearsES2GLJPanelAWT shows that the fallback method seems to give identical results on Mac, so changed to just use the fallback method (which is now the only method) everywhere. This gets rid of an illegal reflective access. --- .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/nativewindow/classes') diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 3eb5328bd..d2dc8f91b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -557,19 +557,25 @@ public class JAWTUtil { return jawtToolkitLock; } - public static final int getMonitorDisplayID(final GraphicsDevice device) { - int displayID = 0; + /** + * Queries the Monitor's display ID of the given device + *

+ * Currently only supported for OSX on Java<9 + *

+ * @param device for which the display id is being queried + * @return {@code null} if not supported (Java9+ or !OSX), otherwise the monitor displayID + */ + public static final Integer getMonitorDisplayID(final GraphicsDevice device) { if( null != getCGDisplayIDMethodOnOSX ) { // OSX specific for Java<9 try { final Object res = getCGDisplayIDMethodOnOSX.invoke(device); if (res instanceof Integer) { - displayID = ((Integer)res).intValue(); + return (Integer)res; } } catch (final Throwable t) {} } - // TODO: Needs non-reflective Java9+ solution for all platforms - return displayID; + return null; } /** -- cgit v1.2.3