小编bra*_*aag的帖子

从Java 9访问com.sun.tools.javac.util

我正试图从中访问List该类com.sun.tools.javac.util.这适用于Java 8,但是当切换到Java 9时,我收到以下错误:Package 'com.sun.tools.javac.util' is declared in module "jdk.compiler", which does not export it to the unnamed module".

我尝试添加requires jdk.compiler;到我的module-info文件,但这并没有解决问题.

java sun java-8 java-9

10
推荐指数
1
解决办法
4793
查看次数

java.lang.AssertionError thrown by compiler when adding generated method with parameters

I am modifying an existing class using internal sun APIs (com.sun.tools.javac) with an annotation processor. I am able to generate and add a MethodDecl to a ClassDecl using the following code:

JCTree.JCClassDecl classDecl = ...
JCTree.JCMethodDecl methodDecl = ...
JCTree[] trees = new JCTree[classDecl.defs.length() + 1];
trees[classDecl.defs.length()] = methodDecl;
classDecl.defs = List.from(trees);
Run Code Online (Sandbox Code Playgroud)

This works fine until I try to add parameters to the method declaration. I use the following code to generate a new MethodDecl:

Map<String, Class<?>> …
Run Code Online (Sandbox Code Playgroud)

java code-generation sun

7
推荐指数
2
解决办法
975
查看次数

标签 统计

java ×2

sun ×2

code-generation ×1

java-8 ×1

java-9 ×1