mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 15:29:22 +00:00
remove Class.forName from javacInternals
This commit is contained in:
parent
decf8f7dfe
commit
5a81ff7286
@ -2452,11 +2452,11 @@ public class Util {
|
|||||||
|
|
||||||
private JavacInternals(Types types) {
|
private JavacInternals(Types types) {
|
||||||
try {
|
try {
|
||||||
typesClass = Class.forName("com.sun.tools.javac.code.Types");
|
typesClass = this.getClass().getClassLoader().loadClass("com.sun.tools.javac.code.Types");
|
||||||
typeClass = Class.forName("com.sun.tools.javac.code.Type");
|
typeClass = this.getClass().getClassLoader().loadClass("com.sun.tools.javac.code.Type");
|
||||||
typesErasureRecursiveMethod = typesClass.getMethod("erasureRecursive", typeClass);
|
typesErasureRecursiveMethod = typesClass.getMethod("erasureRecursive", typeClass);
|
||||||
|
|
||||||
Class<?> JCTreeClass = Class.forName("com.sun.tools.javac.tree.JCTree");
|
Class<?> JCTreeClass = this.getClass().getClassLoader().loadClass("com.sun.tools.javac.tree.JCTree");
|
||||||
|
|
||||||
binaryTreeOperatorField = Stream.of(JCTreeClass.getDeclaredClasses())
|
binaryTreeOperatorField = Stream.of(JCTreeClass.getDeclaredClasses())
|
||||||
.filter(innerClass -> innerClass.getSimpleName().equals("JCBinary")) //
|
.filter(innerClass -> innerClass.getSimpleName().equals("JCBinary")) //
|
||||||
@ -2480,7 +2480,7 @@ public class Util {
|
|||||||
.findFirst().get();
|
.findFirst().get();
|
||||||
modifiersAnnotationsField = JCModifiersClass.getDeclaredField("annotations");
|
modifiersAnnotationsField = JCModifiersClass.getDeclaredField("annotations");
|
||||||
|
|
||||||
Class<?> listClass = Class.forName("com.sun.tools.javac.util.List");
|
Class<?> listClass = this.getClass().getClassLoader().loadClass("com.sun.tools.javac.util.List");
|
||||||
listAppendMethod = listClass.getMethod("append", Object.class);
|
listAppendMethod = listClass.getMethod("append", Object.class);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -2517,9 +2517,10 @@ public class Util {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
typeField = Class.forName("com.sun.tools.javac.tree.JCTree").getDeclaredField("type");
|
var classLoader = JavacInternals.class.getClassLoader();
|
||||||
|
typeField = classLoader.loadClass("com.sun.tools.javac.tree.JCTree").getDeclaredField("type");
|
||||||
typeField.setAccessible(true);
|
typeField.setAccessible(true);
|
||||||
tsymField = Class.forName("com.sun.tools.javac.code.Type").getDeclaredField("tsym");
|
tsymField = classLoader.loadClass("com.sun.tools.javac.code.Type").getDeclaredField("tsym");
|
||||||
tsymField.setAccessible(true);
|
tsymField.setAccessible(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Fatal error - cannot access legacy Javac API", e);
|
throw new RuntimeException("Fatal error - cannot access legacy Javac API", e);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user