aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/lombok/core/JavaIdentifiers.java11
-rw-r--r--src/utils/lombok/core/SpiLoadUtil.java4
-rw-r--r--src/utils/lombok/eclipse/Eclipse.java7
-rw-r--r--src/utils/lombok/javac/Javac.java19
-rw-r--r--src/utils/lombok/javac/JavacTreeMaker.java5
-rw-r--r--src/utils/lombok/javac/java8/CommentCollectingTokenizer.java4
-rw-r--r--src/utils/lombok/permit/Permit.java1
7 files changed, 28 insertions, 23 deletions
diff --git a/src/utils/lombok/core/JavaIdentifiers.java b/src/utils/lombok/core/JavaIdentifiers.java
index cbe90eed..906ae0e1 100644
--- a/src/utils/lombok/core/JavaIdentifiers.java
+++ b/src/utils/lombok/core/JavaIdentifiers.java
@@ -21,6 +21,8 @@
*/
package lombok.core;
+import java.util.regex.Pattern;
+
/**
* Utility functions for validating potential java verifiers.
*/
@@ -54,4 +56,13 @@ public class JavaIdentifiers {
public static boolean isKeyword(String keyword) {
return KEYWORDS.contains(keyword);
}
+
+ /** Matches any of the 8 primitive names, such as {@code boolean}. */
+ private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile("^(?:boolean|byte|short|int|long|float|double|char)$");
+
+ public static boolean isPrimitive(String typeName) {
+ return PRIMITIVE_TYPE_NAME_PATTERN.matcher(typeName).matches();
+ }
+
+
}
diff --git a/src/utils/lombok/core/SpiLoadUtil.java b/src/utils/lombok/core/SpiLoadUtil.java
index e685acd6..0feb7f12 100644
--- a/src/utils/lombok/core/SpiLoadUtil.java
+++ b/src/utils/lombok/core/SpiLoadUtil.java
@@ -129,9 +129,10 @@ public class SpiLoadUtil {
private static void readServicesFromUrl(Collection<String> list, URL url) throws IOException {
InputStream in = url.openStream();
+ BufferedReader r = null;
try {
if (in == null) return;
- BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF-8"));
+ r = new BufferedReader(new InputStreamReader(in, "UTF-8"));
while (true) {
String line = r.readLine();
if (line == null) break;
@@ -143,6 +144,7 @@ public class SpiLoadUtil {
}
} finally {
try {
+ if (r != null) r.close();
if (in != null) in.close();
} catch (Throwable ignore) {}
}
diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java
index 31f2518a..31979955 100644
--- a/src/utils/lombok/eclipse/Eclipse.java
+++ b/src/utils/lombok/eclipse/Eclipse.java
@@ -29,6 +29,7 @@ import java.util.regex.Pattern;
import lombok.core.ClassLiteral;
import lombok.core.FieldSelect;
+import lombok.core.JavaIdentifiers;
import lombok.permit.Permit;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
@@ -158,16 +159,12 @@ public class Eclipse {
return result.toArray(EMPTY_ANNOTATIONS_ARRAY);
}
- /** Matches any of the 8 primitive names, such as {@code boolean}. */
- private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile(
- "^(boolean|byte|short|int|long|float|double|char)$");
-
/**
* Checks if the given type reference represents a primitive type.
*/
public static boolean isPrimitive(TypeReference ref) {
if (ref.dimensions() > 0) return false;
- return PRIMITIVE_TYPE_NAME_PATTERN.matcher(toQualifiedName(ref.getTypeName())).matches();
+ return JavaIdentifiers.isPrimitive(toQualifiedName(ref.getTypeName()));
}
/**
diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java
index 3cc72f4e..cec43705 100644
--- a/src/utils/lombok/javac/Javac.java
+++ b/src/utils/lombok/javac/Javac.java
@@ -37,12 +37,6 @@ import javax.lang.model.type.NoType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeVisitor;
-import lombok.core.ClassLiteral;
-import lombok.core.FieldSelect;
-import lombok.javac.JavacTreeMaker.TreeTag;
-import lombok.javac.JavacTreeMaker.TypeTag;
-import lombok.permit.Permit;
-
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.code.Symtab;
@@ -61,6 +55,13 @@ import com.sun.tools.javac.tree.JCTree.JCLiteral;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import lombok.core.ClassLiteral;
+import lombok.core.FieldSelect;
+import lombok.core.JavaIdentifiers;
+import lombok.javac.JavacTreeMaker.TreeTag;
+import lombok.javac.JavacTreeMaker.TypeTag;
+import lombok.permit.Permit;
+
/**
* Container for static utility methods relevant to lombok's operation on javac.
*/
@@ -69,9 +70,6 @@ public class Javac {
// prevent instantiation
}
- /** Matches any of the 8 primitive names, such as {@code boolean}. */
- private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile("^(boolean|byte|short|int|long|float|double|char)$");
-
private static final Pattern VERSION_PARSER = Pattern.compile("^(\\d{1,6})\\.?(\\d{1,6})?.*$");
private static final Pattern SOURCE_PARSER = Pattern.compile("^JDK(\\d{1,6})_?(\\d{1,6})?.*$");
@@ -135,8 +133,7 @@ public class Javac {
* expression) represents a primitive type.
*/
public static boolean isPrimitive(JCExpression ref) {
- String typeName = ref.toString();
- return PRIMITIVE_TYPE_NAME_PATTERN.matcher(typeName).matches();
+ return JavaIdentifiers.isPrimitive(ref.toString());
}
/**
diff --git a/src/utils/lombok/javac/JavacTreeMaker.java b/src/utils/lombok/javac/JavacTreeMaker.java
index 20f4b66d..15a11151 100644
--- a/src/utils/lombok/javac/JavacTreeMaker.java
+++ b/src/utils/lombok/javac/JavacTreeMaker.java
@@ -343,10 +343,7 @@ public class JavacTreeMaker {
Method method = getFromCache(m);
try {
if (m.returnType.isPrimitive()) {
- Object res = method.invoke(owner, args);
- String sn = res.getClass().getSimpleName().toLowerCase();
- if (!sn.startsWith(m.returnType.getSimpleName())) throw new ClassCastException(res.getClass() + " to " + m.returnType);
- return (J) res;
+ return (J) method.invoke(owner, args);
}
return m.returnType.cast(method.invoke(owner, args));
} catch (InvocationTargetException e) {
diff --git a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java
index 08477e61..d7b1d569 100644
--- a/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java
+++ b/src/utils/lombok/javac/java8/CommentCollectingTokenizer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2019 The Project Lombok Authors.
+ * Copyright (C) 2013-2020 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -59,7 +59,7 @@ class CommentCollectingTokenizer extends JavaTokenizer {
@Override public Token readToken() {
Token token = super.readToken();
prevEndPosition = pos();
- if (textBlockStarts != null && (prevEndPosition - token.pos > 5) && token.getClass().getSimpleName().equals("StringToken")) {
+ if (textBlockStarts != null && (prevEndPosition - token.pos > 5) && token.getClass().getName().endsWith("$StringToken")) {
char[] start = reader.getRawCharacters(token.pos, token.pos + 3);
if (start[0] == '"' && start[1] == '"' && start[2] == '"') textBlockStarts.add(token.pos);
}
diff --git a/src/utils/lombok/permit/Permit.java b/src/utils/lombok/permit/Permit.java
index b7c5f0d9..407c3922 100644
--- a/src/utils/lombok/permit/Permit.java
+++ b/src/utils/lombok/permit/Permit.java
@@ -95,6 +95,7 @@ public class Permit {
static class Fake {
boolean override;
+ Object accessCheckCache;
}
public static Method getMethod(Class<?> c, String mName, Class<?>... parameterTypes) throws NoSuchMethodException {