diff -r 87d53f13f4d4 javafx-ui-controls/src/javafx/scene/control/Control.java --- a/javafx-ui-controls/src/javafx/scene/control/Control.java Thu May 31 13:21:24 2012 -0700 +++ b/javafx-ui-controls/src/javafx/scene/control/Control.java Fri Jun 01 10:30:24 2012 +0200 @@ -966,15 +966,36 @@ } try { - Class skinClass; - // RT-17525 : Use context class loader only if Class.forName fails. + Class skinClass = null; + final String className = skinClassName.get(); try { - skinClass = Class.forName(skinClassName.get()); - } catch (ClassNotFoundException clne) { - if (Thread.currentThread().getContextClassLoader() != null) { - skinClass = Thread.currentThread().getContextClassLoader().loadClass(skinClassName.get()); - } else { - throw clne; + // Try just loading the class + skinClass = Class.forName(className); + } catch (ClassNotFoundException ex) { + try { + // RT-17525 : Use context class loader only if Class.forName fails. + if (skinClass == null && Thread.currentThread().getContextClassLoader() != null) { + skinClass = Thread.currentThread().getContextClassLoader().loadClass(skinClassName.get()); + } + // RT-14177: Try looking up the class using the class loader of the + // current class, walking up the list of superclasses + // and checking each of them, before bailing and using + // the context class loader. + Class currentType = getClass(); + while (skinClass == null && currentType != null) { + try { + skinClass = currentType.getClassLoader().loadClass(className); + } catch (ClassNotFoundException ex2) { + currentType = currentType.getSuperclass(); + } + } + } catch(ClassNotFoundException ex3) { + } + + // We failed to find the class using any of the above means, so we're going + // to just throw the ClassNotFoundException that we caught earlier + if (skinClass == null) { + throw ex; } } @@ -1038,8 +1059,6 @@ } - - /*************************************************************************** * * * StyleSheet Handling *