< prev index next >
src/java.desktop/share/classes/java/awt/Toolkit.java
Print this page
@@ -466,11 +466,11 @@
* @param atName the name of the class to be loaded
*/
private static void fallbackToLoadClassForAT(String atName) {
try {
Class<?> c = Class.forName(atName, false, ClassLoader.getSystemClassLoader());
- c.newInstance();
+ c.getConstructor().newInstance();
} catch (ClassNotFoundException e) {
newAWTError(e, "Assistive Technology not found: " + atName);
} catch (InstantiationException e) {
newAWTError(e, "Could not instantiate Assistive Technology: " + atName);
} catch (IllegalAccessException e) {
@@ -581,19 +581,17 @@
}
}
}
try {
if (cls != null) {
- toolkit = (Toolkit)cls.newInstance();
+ toolkit = (Toolkit)cls.getConstructor().newInstance();
if (GraphicsEnvironment.isHeadless()) {
toolkit = new HeadlessToolkit(toolkit);
}
}
- } catch (final InstantiationException ignored) {
- throw new AWTError("Could not instantiate Toolkit: " + nm);
- } catch (final IllegalAccessException ignored) {
- throw new AWTError("Could not access Toolkit: " + nm);
+ } catch (final ReflectiveOperationException ignored) {
+ throw new AWTError("Could not create Toolkit: " + nm);
}
return null;
}
});
if (!GraphicsEnvironment.isHeadless()) {
< prev index next >