mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 02:17:12 +00:00
Some small fixes for Java 7
This commit is contained in:
1 parent
2658b1ba42
commit
172202add2
2 files changed
+11
-15
No files matched your search
@@ -1281,9 +1281,9 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
|
||||
private int isOwnPrec(JCExpression tree) {
|
||||
try {
|
||||
if (JavaCompiler.version().startsWith("1.8")) {
|
||||
return (Integer)TreeInfo.class.getMethod("opPrec", Class.forName("com.sun.tools.javac.code.TypeTag")).invoke(tree, getTag(tree));
|
||||
return (Integer)TreeInfo.class.getMethod("opPrec", Class.forName("com.sun.tools.javac.code.TypeTag")).invoke(null, getTag(tree));
|
||||
} else {
|
||||
return (Integer)TreeInfo.class.getMethod("opPrec", Integer.TYPE).invoke(tree, getTag(tree));
|
||||
return (Integer)TreeInfo.class.getMethod("opPrec", Integer.TYPE).invoke(null, getTag(tree));
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
package lombok.javac;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.sun.tools.javac.main.JavaCompiler;
|
||||
@@ -31,6 +32,7 @@ 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.JCLiteral;
|
||||
import com.sun.tools.javac.tree.JCTree.JCPrimitiveTypeTree;
|
||||
import com.sun.tools.javac.tree.JCTree.JCUnary;
|
||||
import com.sun.tools.javac.tree.TreeMaker;
|
||||
|
||||
@@ -137,7 +139,7 @@ public class Javac {
|
||||
|
||||
|
||||
public static boolean compareCTC(Object ctc1, Object ctc2) {
|
||||
return ctc1.equals(ctc2);
|
||||
return Objects.equals(ctc1, ctc2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,20 +189,14 @@ public class Javac {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Object getTreeTypeTag(JCTree tree) {
|
||||
try {
|
||||
return TreeMaker.class.getField("typetag").get(tree);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof RuntimeException) throw (RuntimeException) e;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
public static Object getTreeTypeTag(JCPrimitiveTypeTree tree) {
|
||||
return tree.typetag;
|
||||
}
|
||||
|
||||
public static Object getTreeTypeTag(JCLiteral tree) {
|
||||
return tree.typetag;
|
||||
}
|
||||
|
||||
public static JCExpression makeTypeIdent(TreeMaker maker, Object ctc) {
|
||||
try {
|
||||
Method createIdent;
|
||||
|
||||
Reference in new issue
Block a user