diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-05-31 01:03:38 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-05-31 01:03:38 +0200 |
commit | 5a3e9bd8049469169410107011ad0e26b3b629e3 (patch) | |
tree | a299ccfa863901639679e165f29cc775cb14abd0 /src/utils | |
parent | 7bbb7cf3ca25cb8727a6ec226de1ed1fc5bf47e9 (diff) | |
download | lombok-5a3e9bd8049469169410107011ad0e26b3b629e3.tar.gz lombok-5a3e9bd8049469169410107011ad0e26b3b629e3.tar.bz2 lombok-5a3e9bd8049469169410107011ad0e26b3b629e3.zip |
Added @NonNull on parameters feature (issue 514),
including docs and changelog.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/lombok/javac/Javac.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index b4e58b8f..08c7c957 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -21,6 +21,8 @@ */ package lombok.javac; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -129,4 +131,34 @@ public class Javac { throw new RuntimeException(e); } } + + private static final Field JCTREE_TAG; + private static final Method JCTREE_GETTAG; + static { + Field f = null; + try { + f = JCTree.class.getDeclaredField("tag"); + } catch (NoSuchFieldException e) {} + JCTREE_TAG = f; + + Method m = null; + try { + m = JCTree.class.getDeclaredMethod("getTag"); + } catch (NoSuchMethodException e) {} + JCTREE_GETTAG = m; + } + + public static int getTag(JCTree node) { + if (JCTREE_GETTAG != null) { + try { + return (Integer) JCTREE_GETTAG.invoke(node); + } catch (Exception e) {} + } + try { + return (Integer) JCTREE_TAG.get(node); + } catch (Exception e) { + throw new IllegalStateException("Can't get node tag"); + } + } + } |