You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to run the provided example, but it gives me errors.
My code-
import com.netflix.rewrite.ast.*;
import com.netflix.rewrite.parse.*;
import com.netflix.rewrite.refactor.*;
public class MainClass {
public static void main(String[] args) {
new MainClass().refactorMethodName();
}
public void refactorMethodName() {
Parser parser = new OracleJdkParser();
String a = "class A {{ B.foo(0); }}";
String b = "class B { static void foo(int n) {} }";
Tr.CompilationUnit cu = parser.parse(a, /* which depends on */ b);
Refactor refactor = cu.refactor()
.changeMethodName(cu.findMethodCalls("B foo(int)"), "bar");
Tr.CompilationUnit fixed = refactor.fix();
}
}
The Error I got is -
521 [main] WARN com.netflix.rewrite.parse.OracleJdkParser - Failed symbol entering or attribution
java.lang.NullPointerException
at jdk.compiler/com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:340)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:529)
at jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:286)
at jdk.compiler/com.sun.tools.javac.comp.Enter.classEnter(Enter.java:301)
at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:576)
at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:560)
at com.netflix.rewrite.parse.OracleJdkParser.enterAll(OracleJdkParser.kt:122)
at com.netflix.rewrite.parse.OracleJdkParser.parse(OracleJdkParser.kt:101)
at com.netflix.rewrite.parse.AbstractParser.parse(Parser.kt:69)
at com.netflix.rewrite.parse.Parser$DefaultImpls.parse(Parser.kt:58)
at com.netflix.rewrite.parse.AbstractParser.parse(Parser.kt:65)
at com.netflix.rewrite.parse.Parser$DefaultImpls.parse(Parser.kt:38)
at com.netflix.rewrite.parse.AbstractParser.parse(Parser.kt:65)
at com.netflix.rewrite.parse.Parser$DefaultImpls.parse(Parser.kt:35)
at com.netflix.rewrite.parse.AbstractParser.parse(Parser.kt:65)
at MainClass.refactorMethodName(MainClass.java:23)
at MainClass.main(MainClass.java:15)
Exception in thread "main" java.lang.NoSuchMethodError: com.sun.tools.javac.tree.JCTree$JCCompilationUnit.getPackageName()Lcom/sun/tools/javac/tree/JCTree$JCExpression;
at com.netflix.rewrite.parse.OracleJdkParserVisitor.visitCompilationUnit(OracleJdkParserVisitor.kt:304)
at com.netflix.rewrite.parse.OracleJdkParserVisitor.visitCompilationUnit(OracleJdkParserVisitor.kt:40)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.netflix.rewrite.parse.OracleJdkParser.parse(OracleJdkParser.kt:112)
at com.netflix.rewrite.parse.AbstractParser.parse(Parser.kt:69)
at com.netflix.rewrite.parse.Parser$DefaultImpls.parse(Parser.kt:58)
at com.netflix.rewrite.parse.AbstractParser.parse(Parser.kt:65)
at com.netflix.rewrite.parse.Parser$DefaultImpls.parse(Parser.kt:38)
at com.netflix.rewrite.parse.AbstractParser.parse(Parser.kt:65)
at com.netflix.rewrite.parse.Parser$DefaultImpls.parse(Parser.kt:35)
at com.netflix.rewrite.parse.AbstractParser.parse(Parser.kt:65)
at MainClass.refactorMethodName(MainClass.java:23)
at MainClass.main(MainClass.java:15)
This may be a bit old but i recently stumbled over this problem as well.
rewrite:rewrite-core:1.2.0 is the version without the jdk parts rewrite:rewrite-core:1.2.0:jdkbundle is the version containing the jdk parts (shaded)
specifying both doesn't seem helpful. I would suggest you only need the latter. But apparently there is a newer version in the repos than what is documented here.
My dependencies are:
I tried to run the provided example, but it gives me errors.
My code-
The Error I got is -
My gradle script contains following dependencies-
The text was updated successfully, but these errors were encountered: