aboutsummaryrefslogtreecommitdiff
path: root/src/netbeansAgent/lombok
diff options
context:
space:
mode:
Diffstat (limited to 'src/netbeansAgent/lombok')
-rw-r--r--src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java2
-rw-r--r--src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java b/src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java
index 39df269b..e6ae5c03 100644
--- a/src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java
+++ b/src/netbeansAgent/lombok/netbeans/agent/NetbeansPatcher.java
@@ -58,7 +58,7 @@ public class NetbeansPatcher extends Agent {
sm.addScript(ScriptBuilder.exitEarly()
.transplant().request(StackRequest.PARAM1, StackRequest.PARAM2)
.target(new MethodTarget("org.netbeans.StandardModule$OneModuleClassLoader", "<init>"))
- .decisionMethod(new Hook("lombok/netbeans/agent/PatchFixes", "addSelfToClassLoader", "(Lorg/netbeans/Module;Ljava/util/List;)Z"))
+ .decisionMethod(new Hook("lombok/netbeans/agent/PatchFixes", "addSelfToClassLoader", "(Lorg/netbeans/Module;Ljava/util/List;)V"))
.build());
sm.addScript(ScriptBuilder.exitEarly()
.transplant()
diff --git a/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java b/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java
index d9b858cd..7b85be29 100644
--- a/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java
+++ b/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java
@@ -84,13 +84,11 @@ public class PatchFixes {
return (Enumeration<?>) m.invoke(loader, name);
}
- public static boolean addSelfToClassLoader(Module module, List<File> classPath) {
+ public static void addSelfToClassLoader(Module module, List<File> classPath) {
if (module.getJarFile().getName().equals("org-netbeans-libs-javacimpl.jar")) {
String lombokJarLoc = LiveInjector.findPathJar(Lombok.class);
classPath.add(new File(lombokJarLoc));
}
-
- return false;
}
public static void fixContentOnSetTaskListener(JavacTaskImpl that, TaskListener taskListener) throws Throwable {
@@ -133,8 +131,14 @@ public class PatchFixes {
public static void addTaskListenerWhenCallingJavac(JavacTaskImpl task,
@SuppressWarnings("unused") /* Will come in handy later */ ClasspathInfo cpInfo) throws Exception {
+ if (task == null) return;
Class<?> entryPoint = JavacTaskImpl.class.getClassLoader().loadClass("lombok.netbeans.agent.NetbeansEntryPoint");
- task.setTaskListener((TaskListener) entryPoint.getConstructor(Context.class).newInstance(task.getContext()));
+ if (entryPoint == null) {
+ /* TODO tell the user that lombok is not working. loadClass is not supposed to return null, but netbeans' loader does anyway. */
+ System.err.println("[LOMBOK] ClassLoader not patched correctly.");
+ } else {
+ task.setTaskListener((TaskListener) entryPoint.getConstructor(Context.class).newInstance(task.getContext()));
+ }
}
public static Iterator<JCTree> filterGenerated(final Iterator<JCTree> it) {