aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2021-03-19 02:48:05 +0100
committerRoel Spilker <r.spilker@gmail.com>2021-03-19 02:48:16 +0100
commit2ed5077cae63cb193b4c7d1f8aa1ad3e9e6c2652 (patch)
tree3a5609b92c8c70b0626d2b47d217b7dc79624ee0 /src
parent420d09f99de34fc1303656aafc498bb1188b52ed (diff)
downloadlombok-2ed5077cae63cb193b4c7d1f8aa1ad3e9e6c2652.tar.gz
lombok-2ed5077cae63cb193b4c7d1f8aa1ad3e9e6c2652.tar.bz2
lombok-2ed5077cae63cb193b4c7d1f8aa1ad3e9e6c2652.zip
[jdk16] TypeSymbol.isLocal has been renamed
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/javac/JavacResolution.java21
-rw-r--r--src/utils/lombok/permit/Permit.java8
2 files changed, 28 insertions, 1 deletions
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index 63ca69dd..e96079e0 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -71,6 +71,16 @@ public class JavacResolution {
private final Attr attr;
private final CompilerMessageSuppressor messageSuppressor;
+ private static final Method isLocal;
+
+ static {
+ Method local = Permit.permissiveGetMethod(TypeSymbol.class, "isLocal");
+ if (local == null) {
+ local = Permit.permissiveGetMethod(TypeSymbol.class, "isDirectlyOrIndirectlyLocal");
+ }
+ isLocal = local;
+ }
+
public JavacResolution(Context context) {
attr = Attr.instance(context);
messageSuppressor = new CompilerMessageSuppressor(context);
@@ -352,6 +362,15 @@ public class JavacResolution {
return a.compareTo(b);
}
+ private static boolean isLocalType(TypeSymbol symbol) {
+ try {
+ return (Boolean) Permit.invoke(isLocal, symbol);
+ }
+ catch (Exception e) {
+ return false;
+ }
+ }
+
private static JCExpression typeToJCTree0(Type type, JavacAST ast, boolean allowCompound, boolean allowVoid, boolean allowCapture) throws TypeNotConvertibleException {
// NB: There's such a thing as maker.Type(type), but this doesn't work very well; it screws up anonymous classes, captures, and adds an extra prefix dot for some reason too.
// -- so we write our own take on that here.
@@ -450,7 +469,7 @@ public class JavacResolution {
}
String qName;
- if (symbol.isLocal()) {
+ if (isLocalType(symbol)) {
qName = symbol.getSimpleName().toString();
} else if (symbol.type != null && symbol.type.getEnclosingType() != null && typeTag(symbol.type.getEnclosingType()).equals(typeTag("CLASS"))) {
replacement = typeToJCTree0(type.getEnclosingType(), ast, false, false, false);
diff --git a/src/utils/lombok/permit/Permit.java b/src/utils/lombok/permit/Permit.java
index edcc36b2..2854706e 100644
--- a/src/utils/lombok/permit/Permit.java
+++ b/src/utils/lombok/permit/Permit.java
@@ -122,6 +122,14 @@ public class Permit {
return setAccessible(m);
}
+ public static Method permissiveGetMethod(Class<?> c, String mName, Class<?>... parameterTypes) {
+ try {
+ return getMethod(c, mName, parameterTypes);
+ } catch (Exception ignore) {
+ return null;
+ }
+ }
+
public static Field getField(Class<?> c, String fName) throws NoSuchFieldException {
Field f = null;
Class<?> oc = c;