--- old/src/java.desktop/share/classes/java/beans/Introspector.java 2016-11-07 10:47:20.815786438 -0800 +++ new/src/java.desktop/share/classes/java/beans/Introspector.java 2016-11-07 10:47:20.691786438 -0800 @@ -36,6 +36,7 @@ import java.lang.ref.Reference; import java.lang.ref.SoftReference; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; @@ -1280,11 +1281,12 @@ */ static Object instantiate(Class sibling, String className) throws InstantiationException, IllegalAccessException, + NoSuchMethodException, InvocationTargetException, ClassNotFoundException { // First check with sibling's classloader (if any). ClassLoader cl = sibling.getClassLoader(); Class cls = ClassFinder.findClass(className, cl); - return cls.newInstance(); + return cls.getDeclaredConstructor().newInstance(); } } // end class Introspector --- old/src/java.desktop/share/classes/java/beans/MetaData.java 2016-11-07 10:47:21.231786436 -0800 +++ new/src/java.desktop/share/classes/java/beans/MetaData.java 2016-11-07 10:47:21.103786437 -0800 @@ -1261,9 +1261,9 @@ internalPersistenceDelegates.put(typeName, defaultPersistenceDelegate); try { String name = type.getName(); - Class c = Class.forName("java.beans.MetaData$" + name.replace('.', '_') + Class c = Class.forName("java.beans.MetaData$" + name.replace('.', '_') + "_PersistenceDelegate"); - pd = (PersistenceDelegate)c.newInstance(); + pd = (PersistenceDelegate)c.getDeclaredConstructor().newInstance(); internalPersistenceDelegates.put(typeName, pd); } catch (ClassNotFoundException e) { --- old/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java 2016-11-07 10:47:21.643786435 -0800 +++ new/src/java.desktop/share/classes/java/beans/PropertyDescriptor.java 2016-11-07 10:47:21.479786436 -0800 @@ -470,14 +470,14 @@ Constructor ctor = null; if (bean != null) { try { - ctor = cls.getConstructor(new Class[] { Object.class }); + ctor = cls.getDeclaredConstructor(new Class[] { Object.class }); } catch (Exception ex) { // Fall through } } try { if (ctor == null) { - editor = cls.newInstance(); + editor = cls.getDeclaredConstructor().newInstance(); } else { editor = ctor.newInstance(new Object[] { bean }); } --- old/src/java.desktop/share/classes/com/sun/beans/decoder/DocumentHandler.java 2016-11-07 10:47:22.003786434 -0800 +++ new/src/java.desktop/share/classes/com/sun/beans/decoder/DocumentHandler.java 2016-11-07 10:47:21.879786434 -0800 @@ -280,7 +280,8 @@ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { ElementHandler parent = this.handler; try { - this.handler = getElementHandler(qName).newInstance(); + this.handler = + getElementHandler(qName).getDeclaredConstructor().newInstance(); this.handler.setOwner(this); this.handler.setParent(parent); } --- old/src/java.desktop/share/classes/com/sun/beans/finder/InstanceFinder.java 2016-11-07 10:47:22.407786432 -0800 +++ new/src/java.desktop/share/classes/com/sun/beans/finder/InstanceFinder.java 2016-11-07 10:47:22.251786433 -0800 @@ -94,7 +94,7 @@ } if (this.type.isAssignableFrom(type)) { @SuppressWarnings("unchecked") - T tmp = (T) type.newInstance(); + T tmp = (T) type.getDeclaredConstructor().newInstance(); return tmp; } } --- old/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java 2016-11-07 10:47:22.815786431 -0800 +++ new/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java 2016-11-07 10:47:22.671786431 -0800 @@ -90,12 +90,10 @@ Class c = Class.forName(line.trim(), false, ucl); if (Soundbank.class.isAssignableFrom(c)) { ReflectUtil.checkPackageAccess(c); - Object o = c.newInstance(); + Object o = c.getDeclaredConstructor().newInstance(); soundbanks.add((Soundbank) o); } - } catch (ClassNotFoundException ignored) { - } catch (InstantiationException ignored) { - } catch (IllegalAccessException ignored) { + } catch (ReflectiveOperationException ignored) { } } line = r.readLine(); --- old/src/java.desktop/share/classes/com/sun/media/sound/ModelAbstractOscillator.java 2016-11-07 10:47:23.187786429 -0800 +++ new/src/java.desktop/share/classes/com/sun/media/sound/ModelAbstractOscillator.java 2016-11-07 10:47:23.063786430 -0800 @@ -137,10 +137,8 @@ public ModelOscillatorStream open(float samplerate) { ModelAbstractOscillator oscs; try { - oscs = this.getClass().newInstance(); - } catch (InstantiationException e) { - throw new IllegalArgumentException(e); - } catch (IllegalAccessException e) { + oscs = this.getClass().getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { throw new IllegalArgumentException(e); } oscs.setSampleRate(samplerate); --- old/src/java.desktop/share/classes/javax/swing/UIManager.java 2016-11-07 10:47:23.551786428 -0800 +++ new/src/java.desktop/share/classes/javax/swing/UIManager.java 2016-11-07 10:47:23.427786429 -0800 @@ -526,14 +526,16 @@ 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); @@ -625,7 +627,16 @@ } 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; + } } } @@ -1093,7 +1104,8 @@ 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); } @@ -1427,7 +1439,8 @@ 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); } --- old/src/java.desktop/share/classes/javax/swing/JEditorPane.java 2016-11-07 10:47:23.971786427 -0800 +++ new/src/java.desktop/share/classes/javax/swing/JEditorPane.java 2016-11-07 10:47:23.843786427 -0800 @@ -1196,7 +1196,7 @@ // registerEditorKitForContentType(type, class, null). c = SwingUtilities.loadSystemClass(classname); } - k = (EditorKit) c.newInstance(); + k = (EditorKit) c.getDeclaredConstructor().newInstance(); kitRegistry.put(type, k); } catch (Throwable e) { k = null; --- old/src/java.desktop/share/classes/javax/swing/text/html/ObjectView.java 2016-11-07 10:47:24.407786425 -0800 +++ new/src/java.desktop/share/classes/javax/swing/text/html/ObjectView.java 2016-11-07 10:47:24.259786426 -0800 @@ -46,7 +46,7 @@ *

* If the class can successfully be loaded, an attempt will * be made to create an instance of it by calling - * Class.newInstance. An attempt will be made + * Class.getDeclaredConstructor().newInstance. An attempt will be made * to narrow the instance to type java.awt.Component * to display the object. *

@@ -92,7 +92,7 @@ ReflectUtil.checkPackageAccess(classname); Class c = Class.forName(classname, true,Thread.currentThread(). getContextClassLoader()); - Object o = c.newInstance(); + Object o = c.getDeclaredConstructor().newInstance(); if (o instanceof Component) { Component comp = (Component) o; setParameters(comp, attr); --- old/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java 2016-11-07 10:47:24.767786424 -0800 +++ new/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java 2016-11-07 10:47:24.643786424 -0800 @@ -179,8 +179,8 @@ T getInstance() { try { ReflectUtil.checkPackageAccess(clazz); - return clazz.newInstance(); - } catch (InstantiationException | IllegalAccessException ignored) { + return clazz.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ignored) { } return null; } --- old/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java 2016-11-07 10:47:25.179786422 -0800 +++ new/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java 2016-11-07 10:47:25.051786423 -0800 @@ -1131,16 +1131,12 @@ getContextClassLoader()); if (methodName == null) { - return c.newInstance(); + return c.getDeclaredConstructor().newInstance(); } Method m = c.getMethod(methodName, (Class[])null); return m.invoke(c, (Object[])null); - } catch (ClassNotFoundException cnfe) { - } catch (IllegalAccessException iae) { - } catch (InvocationTargetException ite) { - } catch (NoSuchMethodException nsme) { - } catch (InstantiationException ie) { + } catch (ReflectiveOperationException e) { } return null; } --- old/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java 2016-11-07 10:47:25.623786421 -0800 +++ new/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java 2016-11-07 10:47:25.463786421 -0800 @@ -226,13 +226,10 @@ } try { shellFolderManager = - (ShellFolderManager)managerClass.newInstance(); - } catch (InstantiationException e) { + (ShellFolderManager)managerClass.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { throw new Error("Could not instantiate Shell Folder Manager: " + managerClass.getName()); - } catch (IllegalAccessException e) { - throw new Error ("Could not access Shell Folder Manager: " - + managerClass.getName()); } invoker = shellFolderManager.createInvoker(); --- old/src/java.desktop/share/classes/java/awt/Toolkit.java 2016-11-07 10:47:26.043786419 -0800 +++ new/src/java.desktop/share/classes/java/awt/Toolkit.java 2016-11-07 10:47:25.895786420 -0800 @@ -468,7 +468,7 @@ 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) { @@ -583,15 +583,13 @@ } 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; } --- old/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java 2016-11-07 10:47:26.439786418 -0800 +++ new/src/java.desktop/share/classes/java/awt/GraphicsEnvironment.java 2016-11-07 10:47:26.291786418 -0800 @@ -108,7 +108,7 @@ ClassLoader cl = ClassLoader.getSystemClassLoader(); geCls = Class.forName(nm, true, cl); } - ge = (GraphicsEnvironment)geCls.newInstance(); + ge = (GraphicsEnvironment)geCls.getConstructor().newInstance(); // long t1 = System.currentTimeMillis(); // System.out.println("GE creation took " + (t1-t0)+ "ms."); if (isHeadless()) { @@ -116,12 +116,9 @@ } } catch (ClassNotFoundException e) { throw new Error("Could not find class: "+nm); - } catch (InstantiationException e) { + } catch (ReflectiveOperationException | IllegalArgumentException e) { throw new Error("Could not instantiate Graphics Environment: " + nm); - } catch (IllegalAccessException e) { - throw new Error ("Could not access Graphics Environment: " - + nm); } return ge; } --- old/src/java.desktop/share/classes/java/awt/print/PrinterJob.java 2016-11-07 10:47:26.823786416 -0800 +++ new/src/java.desktop/share/classes/java/awt/print/PrinterJob.java 2016-11-07 10:47:26.695786417 -0800 @@ -79,13 +79,12 @@ public PrinterJob run() { String nm = System.getProperty("java.awt.printerjob", null); try { - return (PrinterJob)Class.forName(nm).newInstance(); + return (PrinterJob)Class.forName(nm). + getConstructor().newInstance(); } catch (ClassNotFoundException e) { throw new AWTError("PrinterJob not found: " + nm); - } catch (InstantiationException e) { + } catch (ReflectiveOperationException e) { throw new AWTError("Could not instantiate PrinterJob: " + nm); - } catch (IllegalAccessException e) { - throw new AWTError("Could not access PrinterJob: " + nm); } } }); --- old/src/java.desktop/share/classes/sun/java2d/cmm/CMSManager.java 2016-11-07 10:47:27.227786415 -0800 +++ new/src/java.desktop/share/classes/sun/java2d/cmm/CMSManager.java 2016-11-07 10:47:27.099786415 -0800 @@ -57,7 +57,7 @@ if (cmmProviderClass != null) { try { Class cls = Class.forName(cmmProviderClass); - provider = (CMMServiceProvider)cls.newInstance(); + provider = (CMMServiceProvider)cls.getConstructor().newInstance(); } catch (ReflectiveOperationException e) { } } --- old/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitiveProxy.java 2016-11-07 10:47:27.639786413 -0800 +++ new/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitiveProxy.java 2016-11-07 10:47:27.511786414 -0800 @@ -81,18 +81,15 @@ + relativeClassName; try { Class clazz = Class.forName(name); - GraphicsPrimitive p = (GraphicsPrimitive) clazz.newInstance(); + GraphicsPrimitive p = + (GraphicsPrimitive) clazz.getDeclaredConstructor().newInstance(); if (!satisfiesSameAs(p)) { throw new RuntimeException("Primitive " + p + " incompatible with proxy for " + name); } return p; - } catch (ClassNotFoundException ex) { - throw new RuntimeException(ex.toString()); - } catch (InstantiationException ex) { - throw new RuntimeException(ex.toString()); - } catch (IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new RuntimeException(ex.toString()); } // A RuntimeException should never happen in a deployed JDK, because --- old/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java 2016-11-07 10:47:28.011786412 -0800 +++ new/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java 2016-11-07 10:47:27.875786412 -0800 @@ -127,7 +127,7 @@ if (reClass != null) { try { Class cls = Class.forName(reClass); - reImpl = (RenderingEngine) cls.newInstance(); + reImpl = (RenderingEngine) cls.getConstructor().newInstance(); } catch (ReflectiveOperationException ignored0) { } } @@ -135,7 +135,7 @@ final String marlinREClass = "sun.java2d.marlin.MarlinRenderingEngine"; try { Class cls = Class.forName(marlinREClass); - reImpl = (RenderingEngine) cls.newInstance(); + reImpl = (RenderingEngine) cls.getConstructor().newInstance(); } catch (ReflectiveOperationException ignored1) { } } --- old/src/java.desktop/share/classes/sun/awt/FontConfiguration.java 2016-11-07 10:47:28.407786411 -0800 +++ new/src/java.desktop/share/classes/sun/awt/FontConfiguration.java 2016-11-07 10:47:28.275786411 -0800 @@ -971,7 +971,7 @@ if (fcc != null) { try { - fc = (Charset) fcc.newInstance(); + fc = (Charset) fcc.getDeclaredConstructor().newInstance(); } catch (Exception e) { } } --- old/src/java.desktop/share/classes/sun/font/FontManagerFactory.java 2016-11-07 10:47:29.139786408 -0800 +++ new/src/java.desktop/share/classes/sun/font/FontManagerFactory.java 2016-11-07 10:47:28.963786409 -0800 @@ -80,10 +80,9 @@ DEFAULT_CLASS); ClassLoader cl = ClassLoader.getSystemClassLoader(); Class fmClass = Class.forName(fmClassName, true, cl); - instance = (FontManager) fmClass.newInstance(); - } catch (ClassNotFoundException | - InstantiationException | - IllegalAccessException ex) { + instance = + (FontManager) fmClass.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ex) { throw new InternalError(ex); } --- old/src/java.desktop/unix/classes/sun/font/XMap.java 2016-11-07 10:47:29.527786407 -0800 +++ new/src/java.desktop/unix/classes/sun/font/XMap.java 2016-11-07 10:47:29.399786407 -0800 @@ -172,7 +172,8 @@ if (className != null) { try { if (className.startsWith("sun.awt")) { - enc = ((Charset)Class.forName(className).newInstance()).newEncoder(); + enc = ((Charset)Class.forName(className).getDeclaredConstructor(). + newInstance()).newEncoder(); } else { enc = Charset.forName(className).newEncoder(); }