mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 03:24:38 +02:00
8155516: Suppress warnings from uses of deprecated Class.newInstance langtools
Reviewed-by: jjg
This commit is contained in:
parent
325a065aff
commit
ae6a62a6c8
5 changed files with 13 additions and 5 deletions
|
@ -123,7 +123,9 @@ public class ToolProvider {
|
||||||
private static <T> T getSystemTool(Class<T> clazz, String moduleName, String className) {
|
private static <T> T getSystemTool(Class<T> clazz, String moduleName, String className) {
|
||||||
if (useLegacy) {
|
if (useLegacy) {
|
||||||
try {
|
try {
|
||||||
return Class.forName(className, true, ClassLoader.getSystemClassLoader()).asSubclass(clazz).newInstance();
|
@SuppressWarnings("deprecation")
|
||||||
|
T result = Class.forName(className, true, ClassLoader.getSystemClassLoader()).asSubclass(clazz).newInstance();
|
||||||
|
return result;
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
throw new Error(e);
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,6 +282,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||||
|
|
||||||
if (options.isSet(XPRINT)) {
|
if (options.isSet(XPRINT)) {
|
||||||
try {
|
try {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
Processor processor = PrintingProcessor.class.newInstance();
|
Processor processor = PrintingProcessor.class.newInstance();
|
||||||
processorIterator = List.of(processor).iterator();
|
processorIterator = List.of(processor).iterator();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -549,8 +550,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
|
||||||
try {
|
try {
|
||||||
Class<?> processorClass = processorCL.loadClass(processorName);
|
Class<?> processorClass = processorCL.loadClass(processorName);
|
||||||
ensureReadable(processorClass);
|
ensureReadable(processorClass);
|
||||||
processor =
|
@SuppressWarnings("deprecation")
|
||||||
(Processor) (processorClass.newInstance());
|
Object tmp = processorClass.newInstance();
|
||||||
|
processor = (Processor) tmp;
|
||||||
} catch (ClassNotFoundException cnfe) {
|
} catch (ClassNotFoundException cnfe) {
|
||||||
log.error("proc.processor.not.found", processorName);
|
log.error("proc.processor.not.found", processorName);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -151,6 +151,7 @@ public enum Option {
|
||||||
// Construct transformer
|
// Construct transformer
|
||||||
try {
|
try {
|
||||||
Class<?> trCls = Class.forName(classname);
|
Class<?> trCls = Class.forName(classname);
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
Transformer transformer = (Transformer) trCls.newInstance();
|
Transformer transformer = (Transformer) trCls.newInstance();
|
||||||
transformer.setExtra(extra);
|
transformer.setExtra(extra);
|
||||||
helper.addTransformer(suffix, transformer);
|
helper.addTransformer(suffix, transformer);
|
||||||
|
|
|
@ -246,6 +246,7 @@ public class TagletManager {
|
||||||
}
|
}
|
||||||
tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
|
tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
|
||||||
Class<?> customTagClass = tagClassLoader.loadClass(classname);
|
Class<?> customTagClass = tagClassLoader.loadClass(classname);
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
Object instance = customTagClass.newInstance();
|
Object instance = customTagClass.newInstance();
|
||||||
Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.taglet.Taglet)instance);
|
Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.taglet.Taglet)instance);
|
||||||
String tname = newLegacy.getName();
|
String tname = newLegacy.getName();
|
||||||
|
|
|
@ -270,7 +270,9 @@ public class Start extends ToolOption.Helper {
|
||||||
initMessager();
|
initMessager();
|
||||||
messager.setLocale(locale);
|
messager.setLocale(locale);
|
||||||
try {
|
try {
|
||||||
doclet = (Doclet) docletClass.newInstance();
|
@SuppressWarnings("deprecation")
|
||||||
|
Object o = docletClass.newInstance();
|
||||||
|
doclet = (Doclet) o;
|
||||||
} catch (InstantiationException | IllegalAccessException exc) {
|
} catch (InstantiationException | IllegalAccessException exc) {
|
||||||
exc.printStackTrace();
|
exc.printStackTrace();
|
||||||
if (!apiMode) {
|
if (!apiMode) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue