diff options
author | Roel Spilker <r.spilker@gmail.com> | 2017-10-25 23:22:12 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2017-10-25 23:22:12 +0200 |
commit | 033660088bc9f184de7afb512fa752c4ccc70f83 (patch) | |
tree | 801f1776ab2b5a0e437ef5db49096f7917ea0aa3 /src/core | |
parent | 949507a23a2ba6d5bc13401b97f97510aa640bd4 (diff) | |
download | lombok-033660088bc9f184de7afb512fa752c4ccc70f83.tar.gz lombok-033660088bc9f184de7afb512fa752c4ccc70f83.tar.bz2 lombok-033660088bc9f184de7afb512fa752c4ccc70f83.zip |
add support for Netbeans on jdk9
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/javac/apt/LombokFileObjects.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/core/lombok/javac/apt/LombokFileObjects.java b/src/core/lombok/javac/apt/LombokFileObjects.java index d0d67b17..960ebfd5 100644 --- a/src/core/lombok/javac/apt/LombokFileObjects.java +++ b/src/core/lombok/javac/apt/LombokFileObjects.java @@ -23,12 +23,13 @@ package lombok.javac.apt; import java.io.IOException; -import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; @@ -100,13 +101,18 @@ final class LombokFileObjects { private LombokFileObjects() {} + private static final List<String> KNOWN_JAVA9_FILE_MANAGERS = Arrays.asList( + "com.google.errorprone.MaskedClassLoader$MaskedFileManager", + "com.google.devtools.build.buildjar.javac.BlazeJavacMain$ClassloaderMaskingFileManager", + "org.netbeans.modules.java.source.parsing.ProxyFileManager", + "com.sun.tools.javac.api.ClientCodeWrapper$WrappedStandardJavaFileManager" + ); + static Compiler getCompiler(JavaFileManager jfm) { String jfmClassName = jfm != null ? jfm.getClass().getName() : "null"; if (jfmClassName.equals("com.sun.tools.javac.util.DefaultFileManager")) return Compiler.JAVAC6; if (jfmClassName.equals("com.sun.tools.javac.util.JavacFileManager")) return Compiler.JAVAC6; - if (jfmClassName.equals("com.sun.tools.javac.file.JavacFileManager") || - jfmClassName.equals("com.google.errorprone.MaskedClassLoader$MaskedFileManager") || - jfmClassName.equals("com.google.devtools.build.buildjar.javac.BlazeJavacMain$ClassloaderMaskingFileManager")) { + if (jfmClassName.equals("com.sun.tools.javac.file.JavacFileManager")) { try { Class<?> superType = Class.forName("com.sun.tools.javac.file.BaseFileManager"); if (superType.isInstance(jfm)) { @@ -116,12 +122,9 @@ final class LombokFileObjects { catch (Exception e) {} return Compiler.JAVAC7; } - if (jfmClassName.equals("com.sun.tools.javac.api.ClientCodeWrapper$WrappedStandardJavaFileManager")) { + if (KNOWN_JAVA9_FILE_MANAGERS.contains(jfmClassName)) { try { - Field wrappedField = Class.forName("com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager").getDeclaredField("clientJavaFileManager"); - wrappedField.setAccessible(true); - JavaFileManager wrappedManager = (JavaFileManager) wrappedField.get(jfm); - return new Java9Compiler(wrappedManager); + return new Java9Compiler(jfm); } catch (Exception e) {} } |