From 964a06d8a94ef671eaf72c2518d5ecd1a19618eb Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 30 Jun 2016 09:50:39 +0200 Subject: [PATCH] make it more clear in while loading which class from which module did NCDFE occur inside groovyc --- .../jps/incremental/groovy/GroovycOutputParser.java | 7 ++++++- .../groovy/JointCompilationClassLoader.java | 12 ++++++++++++ .../groovy/compiler/rt/GroovyCompilerWrapper.java | 2 +- .../jetbrains/groovy/compiler/rt/GroovycRunner.java | 4 +++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOutputParser.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOutputParser.java index f0478e46d97c..3b807aca3464 100644 --- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOutputParser.java +++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOutputParser.java @@ -158,6 +158,11 @@ public class GroovycOutputParser { ? BuildMessage.Kind.WARNING : BuildMessage.Kind.INFO; + if (StringUtil.isEmpty(url) || "null".equals(url)) { + url = null; + message = "While compiling " + myChunk.getPresentableShortName() + ": " + message; + } + CompilerMessage compilerMessage = new CompilerMessage("Groovyc", kind, message, url, -1, -1, -1, lineInt, columnInt); if (LOG.isDebugEnabled()) { LOG.debug("Message: " + compilerMessage); @@ -227,7 +232,7 @@ public class GroovycOutputParser { if (msg.contains(GroovyRtConstants.NO_GROOVY)) { messages.add(reportNoGroovy()); } else { - messages.add(new CompilerMessage("Groovyc", BuildMessage.Kind.INFO, msg)); + messages.add(new CompilerMessage("Groovyc", BuildMessage.Kind.INFO, "While compiling " + myChunk.getPresentableShortName() + ":" + msg)); } } diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/JointCompilationClassLoader.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/JointCompilationClassLoader.java index 00e5fc8af2cd..8ded22a10c9d 100644 --- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/JointCompilationClassLoader.java +++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/JointCompilationClassLoader.java @@ -32,6 +32,18 @@ class JointCompilationClassLoader extends UrlClassLoader { myClassPath = super.getClassPath(); } + @Override + protected Class _defineClass(String name, byte[] b) { + try { + return super._defineClass(name, b); + } + catch (NoClassDefFoundError e) { + NoClassDefFoundError wrap = new NoClassDefFoundError(e.getMessage() + " needed for " + name); + wrap.initCause(e); + throw wrap; + } + } + @NotNull @Override protected ClassPath getClassPath() { diff --git a/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovyCompilerWrapper.java b/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovyCompilerWrapper.java index 7819f1fccb2b..fdcc5a2bb95b 100644 --- a/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovyCompilerWrapper.java +++ b/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovyCompilerWrapper.java @@ -73,7 +73,7 @@ public class GroovyCompilerWrapper { } catch (NoClassDefFoundError e) { final String className = e.getMessage(); - if (className.startsWith("org/apache/ivy/")) { + if (className.contains("org/apache/ivy/")) { addMessageWithoutLocation("Cannot @Grab without Ivy, please add it to your module dependencies (NoClassDefFoundError: " + className + ")", true); } else { throw e; diff --git a/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovycRunner.java b/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovycRunner.java index e254767a777c..0da20acd5b4f 100644 --- a/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovycRunner.java +++ b/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovycRunner.java @@ -23,6 +23,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; import java.util.*; @@ -135,7 +136,8 @@ public class GroovycRunner { method.invoke(null, forStubs, argPath, configScript, mailbox); } catch (Throwable e) { - while (e.getCause() != null) { + //noinspection InstanceofCatchParameter + while (e instanceof InvocationTargetException) { e = e.getCause(); } e.printStackTrace();