Understanding the com.sun.* APIs being (ab)used by the community

Kevin Rushforth kevin.rushforth at oracle.com
Fri Jun 5 15:28:02 UTC 2015

Yes, this will still work, although dipping into non-public state 
continues to be something we wouldn't recommend that an application rely 

-- Kevin

Dr. Michael Paus wrote:
> As nobody has stated it explicitly so far I would like to ask what 
> will happen
> to classes in Java9 which access methods that are within the javafx 
> namespace but
> are declared private? Will code like this still work or not?
>     public static double getPixelScale(Screen screen) throws 
> NoSuchMethodException, SecurityException, IllegalAccessException, 
> IllegalArgumentException, InvocationTargetException {
>         Method m = Screen.class.getDeclaredMethod("getScale");
>         m.setAccessible(true);
>         return ((Float) m.invoke(screen)).doubleValue();
>     }
> This hack for example is currently necessary because there is no other 
> way to get at
> the current pixel scale of a HiDPI screen.

More information about the openjfx-dev mailing list