8155880: Fix langtools usage of the deprecated Class.newInstance method

Reviewed-by: mcimadamore
This commit is contained in:
Joe Darcy 2016-06-13 09:12:35 -07:00
parent 2c8f465c47
commit c52bd6ba1d
5 changed files with 39 additions and 40 deletions

View file

@ -125,9 +125,8 @@ public class ToolProvider {
private static <T> T getSystemTool(Class<T> clazz, String moduleName, String className) {
if (useLegacy) {
try {
@SuppressWarnings("deprecation")
T result = Class.forName(className, true, ClassLoader.getSystemClassLoader()).asSubclass(clazz).newInstance();
return result;
return Class.forName(className, true, ClassLoader.getSystemClassLoader()).
asSubclass(clazz).getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new Error(e);
}