diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-05-06 18:45:09 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-05-06 18:45:09 +0200 |
commit | d330649b1567cb016d6cc0421959fbf6a90733f5 (patch) | |
tree | 9ced45df55c43819295947b346ced989e28f1554 | |
parent | 5c3adb77373a6688dcbe09bfba080c467d9081ca (diff) | |
download | lombok-d330649b1567cb016d6cc0421959fbf6a90733f5.tar.gz lombok-d330649b1567cb016d6cc0421959fbf6a90733f5.tar.bz2 lombok-d330649b1567cb016d6cc0421959fbf6a90733f5.zip |
more work on JDK8 support: val on generified lub types now works a little better.
-rw-r--r-- | src/core/lombok/javac/Javac6BasedLombokOptions.java | 27 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleVal.java | 2 |
2 files changed, 26 insertions, 3 deletions
diff --git a/src/core/lombok/javac/Javac6BasedLombokOptions.java b/src/core/lombok/javac/Javac6BasedLombokOptions.java index 871e41c4..cefb89ff 100644 --- a/src/core/lombok/javac/Javac6BasedLombokOptions.java +++ b/src/core/lombok/javac/Javac6BasedLombokOptions.java @@ -21,11 +21,28 @@ */ package lombok.javac; -import com.sun.tools.javac.main.OptionName; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import lombok.Lombok; + import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Options; public class Javac6BasedLombokOptions extends LombokOptions { + private static final Method optionName_valueOf; + private static final Method options_put; + + static { + try { + Class<?> optionNameClass = Class.forName("com.sun.tools.javac.main.OptionName"); + optionName_valueOf = optionNameClass.getMethod("valueOf", String.class); + options_put = Class.forName("com.sun.tools.javac.util.Options").getMethod("put", optionNameClass, String.class); + } catch (Exception e) { + throw new IllegalArgumentException("Can't initialize Javac6-based lombok options due to reflection issue.", e); + } + } + public static Javac6BasedLombokOptions replaceWithDelombokOptions(Context context) { Options options = Options.instance(context); context.put(optionsKey, (Options)null); @@ -39,6 +56,12 @@ public class Javac6BasedLombokOptions extends LombokOptions { } @Override public void putJavacOption(String optionName, String value) { - put(OptionName.valueOf(optionName), value); + try { + options_put.invoke(this, optionName_valueOf.invoke(null, optionName), value); + } catch (IllegalAccessException e) { + throw new IllegalArgumentException("Can't initialize Javac6-based lombok options due to reflection issue.", e); + } catch (InvocationTargetException e) { + throw Lombok.sneakyThrow(e.getCause()); + } } } diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java index 75464195..eb3a2f46 100644 --- a/src/core/lombok/javac/handlers/HandleVal.java +++ b/src/core/lombok/javac/handlers/HandleVal.java @@ -91,7 +91,7 @@ public class HandleVal extends JavacASTAdapter { local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation); } - local.vartype = JavacResolution.createJavaLangObject(localNode.getAst()); + local.vartype = localNode.getAst().getTreeMaker().Ident(localNode.getAst().toName("___Lombok_VAL_Attrib__")); Type type; try { |