From d2d97539d26f6023ffc4565286f08427c4e8b41c Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Mon, 8 Nov 2021 14:39:53 +0100 Subject: Add support for eclipse feature tests --- src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/eclipseAgent/lombok/eclipse/agent') diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index d893b724..c0bfbe09 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -109,6 +109,8 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { patchRenameField(sm); patchNullCheck(sm); + patchForTests(sm); + if (reloadExistingClasses) sm.reloadClasses(instrumentation); } @@ -1007,5 +1009,13 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .transplant() .build()); } + + private static void patchForTests(ScriptManager sm) { + sm.addScriptIfWitness(new String[] {"lombok/eclipse/EclipseTests"}, ScriptBuilder.wrapReturnValue() + .target(new MethodTarget("org.osgi.framework.FrameworkUtil", "getBundle", "org.osgi.framework.Bundle", "java.lang.Class")) + .request(StackRequest.RETURN_VALUE, StackRequest.PARAM1) + .wrapMethod(new Hook("lombok.launch.PatchFixesHider$Tests", "getBundle", "java.lang.Object", "java.lang.Object", "java.lang.Class")) + .build()); + } } -- cgit