< prev index next >
src/java.desktop/share/classes/javax/swing/UIManager.java
Print this page
@@ -524,18 +524,20 @@
try {
for (LookAndFeelInfo info : installedLAFs) {
if (info.getName().equals(name)) {
Class<?> cls = Class.forName(UIManager.class.getModule(),
info.getClassName());
- LookAndFeel laf = (LookAndFeel) cls.newInstance();
+ LookAndFeel laf =
+ (LookAndFeel) cls.getDeclaredConstructor().newInstance();
if (!laf.isSupportedLookAndFeel()) {
break;
}
return laf;
}
}
- } catch (InstantiationException | IllegalAccessException ignore) {
+ } catch (ReflectiveOperationException |
+ IllegalArgumentException ignore) {
}
throw new UnsupportedLookAndFeelException(name);
}
@@ -623,11 +625,20 @@
// Avoid reflection for the common case of metal.
setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
}
else {
Class<?> lnfClass = SwingUtilities.loadSystemClass(className);
- setLookAndFeel((LookAndFeel)(lnfClass.newInstance()));
+ try {
+ LookAndFeel laf =
+ (LookAndFeel)lnfClass.getDeclaredConstructor().newInstance();
+ setLookAndFeel(laf);
+ } catch (ReflectiveOperationException | IllegalArgumentException e) {
+ InstantiationException ex =
+ new InstantiationException("Wrapped Exception");
+ ex.initCause(e);
+ throw ex;
+ }
}
}
/**
* Returns the name of the <code>LookAndFeel</code> class that implements
@@ -1091,11 +1102,12 @@
if (multiLookAndFeel == null) {
String defaultName = "javax.swing.plaf.multi.MultiLookAndFeel";
String className = getLAFState().swingProps.getProperty(multiplexingLAFKey, defaultName);
try {
Class<?> lnfClass = SwingUtilities.loadSystemClass(className);
- multiLookAndFeel = (LookAndFeel)lnfClass.newInstance();
+ multiLookAndFeel =
+ (LookAndFeel)lnfClass.getDeclaredConstructor().newInstance();
} catch (Exception exc) {
System.err.println("UIManager: failed loading " + className);
}
}
return multiLookAndFeel;
@@ -1425,11 +1437,12 @@
while (p.hasMoreTokens()) {
String className = p.nextToken();
try {
Class<?> lnfClass = SwingUtilities.loadSystemClass(className);
- LookAndFeel newLAF = (LookAndFeel)lnfClass.newInstance();
+ LookAndFeel newLAF =
+ (LookAndFeel)lnfClass.getDeclaredConstructor().newInstance();
newLAF.initialize();
auxLookAndFeels.addElement(newLAF);
}
catch (Exception e) {
System.err.println("UIManager: failed loading auxiliary look and feel " + className);
< prev index next >