aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2020-11-13 04:37:27 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2020-11-13 04:44:39 +0100
commit3aace094f336393330ed275e1fb6d6c1f9187e14 (patch)
tree3c235a645f057a393194bf789fc4ce4bfaaef340 /src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
parent219bb4bea5035c370614474f630dac454cfe4223 (diff)
downloadlombok-3aace094f336393330ed275e1fb6d6c1f9187e14.tar.gz
lombok-3aace094f336393330ed275e1fb6d6c1f9187e14.tar.bz2
lombok-3aace094f336393330ed275e1fb6d6c1f9187e14.zip
[refactor] reflection code streamlined by sending it through the Permit class
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
index b90d5762..99367a22 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
@@ -101,6 +101,7 @@ import lombok.eclipse.EclipseNode;
import lombok.eclipse.TransformEclipseAST;
import lombok.eclipse.handlers.SetGeneratedByVisitor;
import lombok.patcher.Symbols;
+import lombok.permit.Permit;
public class PatchDelegate {
@@ -846,18 +847,20 @@ public class PatchDelegate {
private static final class Reflection {
public static final Method classScopeBuildFieldsAndMethodsMethod;
-
+ public static final Throwable initCause;
static {
Method m = null;
+ Throwable c = null;
try {
- m = ClassScope.class.getDeclaredMethod("buildFieldsAndMethods");
- m.setAccessible(true);
+ m = Permit.getMethod(ClassScope.class, "buildFieldsAndMethods");
} catch (Throwable t) {
+ c = t;
// That's problematic, but as long as no local classes are used we don't actually need it.
// Better fail on local classes than crash altogether.
}
classScopeBuildFieldsAndMethodsMethod = m;
+ initCause = c;
}
}
@@ -894,16 +897,14 @@ public class PatchDelegate {
ClassScope cs = ((SourceTypeBinding)inner).scope;
if (cs != null) {
try {
- Reflection.classScopeBuildFieldsAndMethodsMethod.invoke(cs);
+ Permit.invoke(Reflection.initCause, Reflection.classScopeBuildFieldsAndMethodsMethod, cs);
} catch (Exception e) {
// See 'Reflection' class for why we ignore this exception.
}
}
}
- if (!(binding instanceof ReferenceBinding)) {
- return;
- }
+ if (!(binding instanceof ReferenceBinding)) return;
ReferenceBinding rb = (ReferenceBinding) binding;
MethodBinding[] availableMethods = rb.availableMethods();