aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2017-11-28 00:59:37 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2017-11-28 00:59:52 +0100
commit15c44f54ccd7cc4502d12b79e6f91074e4e916bc (patch)
treea8edc6e4eacd56473b8ac7a4866c7ccad0666172 /src/core/lombok/javac
parentb1b49e062e5d64877891ecd327c1ffbd00df5636 (diff)
downloadlombok-15c44f54ccd7cc4502d12b79e6f91074e4e916bc.tar.gz
lombok-15c44f54ccd7cc4502d12b79e6f91074e4e916bc.tar.bz2
lombok-15c44f54ccd7cc4502d12b79e6f91074e4e916bc.zip
JDK9 support for delombok (and thus, for running the tests under JDK9).
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/Javac8BasedLombokOptions.java4
-rw-r--r--src/core/lombok/javac/Javac9BasedLombokOptions.java47
-rw-r--r--src/core/lombok/javac/JavacAST.java23
-rw-r--r--src/core/lombok/javac/JavacImportList.java1
4 files changed, 49 insertions, 26 deletions
diff --git a/src/core/lombok/javac/Javac8BasedLombokOptions.java b/src/core/lombok/javac/Javac8BasedLombokOptions.java
index 3fdea890..9a662490 100644
--- a/src/core/lombok/javac/Javac8BasedLombokOptions.java
+++ b/src/core/lombok/javac/Javac8BasedLombokOptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The Project Lombok Authors.
+ * Copyright (C) 2013-2017 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -28,7 +28,7 @@ import com.sun.tools.javac.util.Options;
public class Javac8BasedLombokOptions extends LombokOptions {
public static Javac8BasedLombokOptions replaceWithDelombokOptions(Context context) {
Options options = Options.instance(context);
- context.put(optionsKey, (Options)null);
+ context.put(optionsKey, (Options) null);
Javac8BasedLombokOptions result = new Javac8BasedLombokOptions(context);
result.putAll(options);
return result;
diff --git a/src/core/lombok/javac/Javac9BasedLombokOptions.java b/src/core/lombok/javac/Javac9BasedLombokOptions.java
new file mode 100644
index 00000000..95bfff77
--- /dev/null
+++ b/src/core/lombok/javac/Javac9BasedLombokOptions.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 The Project Lombok Authors.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package lombok.javac;
+
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Options;
+
+public class Javac9BasedLombokOptions extends LombokOptions {
+ public static Javac9BasedLombokOptions replaceWithDelombokOptions(Context context) {
+ Options options = Options.instance(context);
+ context.put(optionsKey, (Options) null);
+ Javac9BasedLombokOptions result = new Javac9BasedLombokOptions(context);
+ result.putAll(options);
+ return result;
+ }
+
+ private Javac9BasedLombokOptions(Context context) {
+ super(context);
+ }
+
+ @Override public void putJavacOption(String optionName, String value) {
+ if (optionName.equals("SOURCEPATH")) optionName = "SOURCE_PATH";
+ if (optionName.equals("BOOTCLASSPATH")) optionName = "BOOT_CLASS_PATH";
+ String optionText = Option.valueOf(optionName).primaryName;
+ put(optionText, value);
+ }
+}
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java
index 91ed325f..bda649fa 100644
--- a/src/core/lombok/javac/JavacAST.java
+++ b/src/core/lombok/javac/JavacAST.java
@@ -48,8 +48,6 @@ import com.sun.tools.javac.tree.JCTree.JCCatch;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.JCExpression;
-import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
-import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCTry;
@@ -106,27 +104,6 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
return cu.sourcefile == null ? null : cu.sourcefile.toString();
}
- // jdk9 support, types have changed, names stay the same
- static class PackageName {
- private static final Method packageNameMethod;
-
- static {
- Method m = null;
- try {
- m = JCCompilationUnit.class.getDeclaredMethod("getPackageName");
- } catch (Exception e) {}
- packageNameMethod = m;
- }
-
- static String getPackageName(JCCompilationUnit cu) {
- try {
- Object pkg = packageNameMethod.invoke(cu);
- return (pkg instanceof JCFieldAccess || pkg instanceof JCIdent) ? pkg.toString() : null;
- } catch (Exception e) {}
- return null;
- }
- }
-
public Context getContext() {
return context;
}
diff --git a/src/core/lombok/javac/JavacImportList.java b/src/core/lombok/javac/JavacImportList.java
index 0f789f45..468d8c7b 100644
--- a/src/core/lombok/javac/JavacImportList.java
+++ b/src/core/lombok/javac/JavacImportList.java
@@ -26,7 +26,6 @@ import java.util.Collection;
import lombok.core.ImportList;
import lombok.core.LombokInternalAliasing;
-import lombok.javac.JavacAST.PackageName;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;