Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8307193

Several Swing jtreg tests use class.forName on L&F classes

XMLWordPrintable

        I've just spotted that some Swing jtreg tests use this pattern

             protected static boolean isAvailableLookAndFeel(String classname) {
                 try { // Try to create a L&F given a String
                     Class lnfClass = Class.forName(classname);
                     LookAndFeel newLAF = (LookAndFeel)(lnfClass.newInstance());
                     return newLAF.isSupportedLookAndFeel();
                 } catch(Exception e) { // If ANYTHING weird happens, return false
                     return false;
                 }
             }

        This is BAD and can't have worked since JDK 9 - the module system restricted access to these classes since they don't have any "opens ..." clause

        But the right thing to do is make them instead call
        UIManager.createLookAndFeel(name);

              psadhukhan Prasanta Sadhukhan
              prr Philip Race
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: