Netflix-Skunkworks / rewrite

Distributed code search and refactoring for Java
Apache License 2.0
290 stars 30 forks source link

[question] how to use, example is empty #7

Closed foxundermoon closed 7 years ago

foxundermoon commented 7 years ago

i'am try to use but failure

when run to new OracleJdkParser(); occur this error Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context

os: mac 10.12.4 java:jdk1.8.0.0_112 gradle: 3.4.1

Connected to the target VM, address: '127.0.0.1:51141', transport: 'socket'
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: com/sun/tools/javac/util/Context
    at com.netflix.rewrite.parse.OracleJdkParser.<init>(OracleJdkParser.kt:41)
    at com.netflix.rewrite.parse.OracleJdkParser.<init>(OracleJdkParser.kt:40)
    at com.netflix.rewrite.parse.OracleJdkParser.<init>(OracleJdkParser.kt)
    at MethodRenameTest.test(MethodRenameTest.java:16)
    at Launch.lambda$main$0(Launch.java:7)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 6 more
foxundermoon commented 7 years ago

compileShaded files("${System.getProperty('java.home')}/../lib/tools.jar") can resolve it

jkschneider commented 7 years ago

We publish two artifacts to Maven Central, one with and without the jdk shaded:

This one does NOT bundle the JDK and assumes you will be running your parser from a class launched from a JDK and not a JRE:

compile 'com.netflix.devinsight.rewrite:rewrite-core:0.18.4'

This shades and bundles the relevant parts of the JDK so you can run anywhere:

compile 'com.netflix.devinsight.rewrite:rewrite-core:0.18.4:jdkbundle'