aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/JavacResolution.java
diff options
context:
space:
mode:
authorRobbert Jan Grootjans <grootjans@gmail.com>2013-03-22 18:23:44 +0100
committerRobbert Jan Grootjans <grootjans@gmail.com>2013-03-22 18:23:44 +0100
commit0b100f22071236907142e4c0fb85ffa50102818d (patch)
tree65a34c1a246a85211bb2d361bd73d4dd16287e63 /src/core/lombok/javac/JavacResolution.java
parent4be46113e81292a88cd5fdb3a5ce18fbcffd570d (diff)
downloadlombok-0b100f22071236907142e4c0fb85ffa50102818d.tar.gz
lombok-0b100f22071236907142e4c0fb85ffa50102818d.tar.bz2
lombok-0b100f22071236907142e4c0fb85ffa50102818d.zip
Refactored out references to TypeTags.
Instead they are retrieved dynamically, with a pinch of caching during runtime. We already had some fixes to make sure that compile time constanst were not inlined, but we need to take into account that a lot of the Integer-based enums have been replaced with actual enums. Also, certain TreeMaker methods needed to be invoked dynamically with reflection. This needs to be reviewed, and if it turns out that these changes are too dramatic, we should fork out a larger part of our code for specific JVM versions.
Diffstat (limited to 'src/core/lombok/javac/JavacResolution.java')
-rw-r--r--src/core/lombok/javac/JavacResolution.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index 0a21aa58..e5d8ed38 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -43,7 +43,6 @@ import com.sun.tools.javac.code.Type.ArrayType;
import com.sun.tools.javac.code.Type.CapturedType;
import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.code.Type.WildcardType;
-import com.sun.tools.javac.code.TypeTags;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
@@ -419,8 +418,8 @@ public class JavacResolution {
TreeMaker maker = ast.getTreeMaker();
- if (type.tag == CTC_BOT) return createJavaLangObject(ast);
- if (type.tag == CTC_VOID) return allowVoid ? primitiveToJCTree(type.getKind(), maker) : createJavaLangObject(ast);
+ if (Javac.compareCTC(type.tag, CTC_BOT)) return createJavaLangObject(ast);
+ if (Javac.compareCTC(type.tag, CTC_VOID)) return allowVoid ? primitiveToJCTree(type.getKind(), maker) : createJavaLangObject(ast);
if (type.isPrimitive()) return primitiveToJCTree(type.getKind(), maker);
if (type.isErroneous()) throw new TypeNotConvertibleException("Type cannot be resolved");
@@ -454,7 +453,7 @@ public class JavacResolution {
upper = type.getUpperBound();
}
if (allowCompound) {
- if (lower == null || lower.tag == CTC_BOT) {
+ if (lower == null || Javac.compareCTC(lower.tag, CTC_BOT)) {
if (upper == null || upper.toString().equals("java.lang.Object")) {
return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
}
@@ -479,7 +478,7 @@ public class JavacResolution {
String qName;
if (symbol.isLocal()) {
qName = symbol.getSimpleName().toString();
- } else if (symbol.type != null && symbol.type.getEnclosingType() != null && symbol.type.getEnclosingType().tag == TypeTags.CLASS) {
+ } else if (symbol.type != null && symbol.type.getEnclosingType() != null && Javac.compareCTC(symbol.type.getEnclosingType().tag, Javac.getTypeTag("CLASS"))) {
replacement = typeToJCTree0(type.getEnclosingType(), ast, false, false);
qName = symbol.getSimpleName().toString();
} else {
@@ -515,23 +514,23 @@ public class JavacResolution {
private static JCExpression primitiveToJCTree(TypeKind kind, TreeMaker maker) throws TypeNotConvertibleException {
switch (kind) {
case BYTE:
- return maker.TypeIdent(CTC_BYTE);
+ return Javac.makeTypeIdent(maker, CTC_BYTE);
case CHAR:
- return maker.TypeIdent(CTC_CHAR);
+ return Javac.makeTypeIdent(maker, CTC_CHAR);
case SHORT:
- return maker.TypeIdent(CTC_SHORT);
+ return Javac.makeTypeIdent(maker, CTC_SHORT);
case INT:
- return maker.TypeIdent(CTC_INT);
+ return Javac.makeTypeIdent(maker, CTC_INT);
case LONG:
- return maker.TypeIdent(CTC_LONG);
+ return Javac.makeTypeIdent(maker, CTC_LONG);
case FLOAT:
- return maker.TypeIdent(CTC_FLOAT);
+ return Javac.makeTypeIdent(maker, CTC_FLOAT);
case DOUBLE:
- return maker.TypeIdent(CTC_DOUBLE);
+ return Javac.makeTypeIdent(maker, CTC_DOUBLE);
case BOOLEAN:
- return maker.TypeIdent(CTC_BOOLEAN);
+ return Javac.makeTypeIdent(maker, CTC_BOOLEAN);
case VOID:
- return maker.TypeIdent(CTC_VOID);
+ return Javac.makeTypeIdent(maker, CTC_VOID);
case NULL:
case NONE:
case OTHER: