diff -r e1eced12249a javafx-ui-controls/src/javafx/scene/control/Control.java --- a/javafx-ui-controls/src/javafx/scene/control/Control.java Wed May 30 17:35:57 2012 -0700 +++ b/javafx-ui-controls/src/javafx/scene/control/Control.java Thu May 31 20:02:00 2012 -0700 @@ -966,15 +966,32 @@ } 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) { + // Try just loading the class + skinClass = Class.forName(className); + } catch (ClassNotFoundException ex) { + // RT-14177: Try looking up the class using the class loader of the + // current class first, 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(); + } + } + // 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()); - } else { - throw clne; + } + // 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 +1055,6 @@ } - - /*************************************************************************** * * * StyleSheet Handling *