JDK-8138899 : Toolkit needs to try the current classloader before trying the app classloader
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 9-repo-jigsaw
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-10-05
  • Updated: 2015-10-05
  • Resolved: 2015-10-05
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 9
9-repo-jigsawFixed
Related Reports
Blocks :  
Description
In Toolkit, we need to cascade the classloader tried when we -Djavafx.toolkit is processed. Some tests need:
    Toolkit.class.getClassLoader();
others: 
    Thread.currentThread().getContextClassLoader();

This is Jake specific at this point.
Comments
Changeset: ec7da52ede4c Author: ddhill Date: 2015-10-05 12:41 -0400 URL: http://hg.openjdk.java.net/openjfx/sandbox-9-jake/rt/rev/ec7da52ede4c 8138899: Toolkit needs to try the current classloader before trying the app classloader Reviewed-by: kcr
05-10-2015

+1
05-10-2015

diff -r bac7052d631f modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java --- a/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java Fri Oct 02 15:12:20 2015 -0700 +++ b/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java Mon Oct 05 11:35:44 2015 -0400 @@ -195,8 +195,17 @@ || (userSpecifiedToolkit && !forcedToolkit.endsWith("StubToolkit")); try { - final ClassLoader loader = Thread.currentThread().getContextClassLoader(); - final Class clz = Class.forName(forcedToolkit, true, loader); + Class clz = null; + + try { + // try our priveledged loader first + final ClassLoader loader = Toolkit.class.getClassLoader(); + clz = Class.forName(forcedToolkit, true, loader); + } catch (ClassNotFoundException e) { + // fall back and try the application class loader + final ClassLoader loader = Thread.currentThread().getContextClassLoader(); + clz = Class.forName(forcedToolkit, true, loader); + } Object thisModule = ModuleHelper.getModule(Toolkit.class); ModuleHelper.addReads(thisModule, ModuleHelper.getModule(clz));
05-10-2015