diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-01-19 21:36:01 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-01-19 21:53:04 +0100 |
commit | 19d0b8d018877d6121a2c855e830c0472f6c518f (patch) | |
tree | b5a9a17109acc20d0649acf4262cbe410e4b6b00 /src/utils/lombok | |
parent | b867f81b8a251a8a32e42f53c2be34d520938bd7 (diff) | |
download | lombok-19d0b8d018877d6121a2c855e830c0472f6c518f.tar.gz lombok-19d0b8d018877d6121a2c855e830c0472f6c518f.tar.bz2 lombok-19d0b8d018877d6121a2c855e830c0472f6c518f.zip |
refactor of how creating void types works, also cleaned up some syntax.
Diffstat (limited to 'src/utils/lombok')
-rw-r--r-- | src/utils/lombok/javac/Javac.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index 003281ad..6f99463b 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -40,6 +40,7 @@ import lombok.javac.JavacTreeMaker.TreeTag; import lombok.javac.JavacTreeMaker.TypeTag; import com.sun.tools.javac.code.Source; +import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.tree.JCTree; @@ -309,7 +310,21 @@ public class Javac { JC_NO_TYPE = c; } - public static Type createVoidType(JavacTreeMaker maker, TypeTag tag) { + private static final Field symtabVoidType = getFieldIfExists(Symtab.class, "voidType"); + + private static Field getFieldIfExists(Class<?> c, String fieldName) { + try { + return c.getField("voidType"); + } catch (Exception e) { + return null; + } + } + + public static Type createVoidType(Symtab symbolTable, TypeTag tag) { + if (symtabVoidType != null) try { + return (Type) symtabVoidType.get(symbolTable); + } catch (IllegalAccessException ignore) {} + if (Javac.getJavaCompilerVersion() < 8) { return new JCNoType(((Integer) tag.value).intValue()); } else { |