diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2020-11-13 04:37:27 +0100 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2020-11-13 04:44:39 +0100 |
commit | 3aace094f336393330ed275e1fb6d6c1f9187e14 (patch) | |
tree | 3c235a645f057a393194bf789fc4ce4bfaaef340 /src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java | |
parent | 219bb4bea5035c370614474f630dac454cfe4223 (diff) | |
download | lombok-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/PatchExtensionMethodPortal.java')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java index 90a23c20..82df71f6 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethodPortal.java @@ -54,7 +54,7 @@ public class PatchExtensionMethodPortal { //do anything useful here. } } - + public static void invalidMethod(Object problemReporter, Object messageSend, Object method) { try { Reflection.invalidMethod.invoke(null, problemReporter, messageSend, method); @@ -62,23 +62,37 @@ public class PatchExtensionMethodPortal { //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly //do anything useful here. } catch (IllegalAccessException e) { + handleReflectionDebug(e); throw Lombok.sneakyThrow(e); } catch (InvocationTargetException e) { + handleReflectionDebug(e.getCause()); throw Lombok.sneakyThrow(e.getCause()); } catch (NullPointerException e) { - if (!"false".equals(System.getProperty("lombok.debug.reflection", "false"))) { - e.initCause(Reflection.problem); - throw e; - } + handleReflectionDebug(e); //ignore, we don't have access to the correct ECJ classes, so lombok can't possibly //do anything useful here. } } - + + public static boolean isDebugReflection() { + return !"false".equals(System.getProperty("lombok.debug.reflection", "false")); + } + + public static void handleReflectionDebug(Throwable t) { + if (!isDebugReflection()) return; + + System.err.println("** LOMBOK REFLECTION exception: " + t.getClass() + ": " + (t.getMessage() == null ? "(no message)" : t.getMessage())); + t.printStackTrace(System.err); + if (Reflection.problem != null) { + System.err.println("*** ADDITIONALLY, exception occurred setting up reflection: "); + Reflection.problem.printStackTrace(System.err); + } + } + private static final class Reflection { public static final Method resolveType, errorNoMethodFor, invalidMethod; public static final Throwable problem; - + static { Method m = null, n = null, o = null; Throwable problem_ = null; |