diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/delombok/lombok/delombok/PrettyCommentsPrinter.java | 4 | ||||
-rw-r--r-- | src/utils/lombok/javac/Javac.java | 22 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index d0f38a62..745aea79 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -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); diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index cbbd6730..b766630f 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -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; |