diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/builder/BasicGroovyBuildTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/builder/BasicGroovyBuildTests.java index 714a7cb415..ecaf945130 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/builder/BasicGroovyBuildTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/builder/BasicGroovyBuildTests.java @@ -1731,11 +1731,11 @@ public void testAnnotationCollectorMultiProject() throws Exception { //@formatter:off env.addGroovyClass(paths[1], "com.demo", "MyAnnotation", - "package com.demo\r\n" + - "\r\n" + - "@groovy.transform.AnnotationCollector\r\n" + - "@Deprecated\r\n" + - "@interface MyAnnotation {}\r\n"); + "package com.demo\n" + + "\n" + + "@groovy.transform.AnnotationCollector\n" + + "@Deprecated\n" + + "@interface MyAnnotation {}\n"); //@formatter:on IPath annotationProject = paths[0]; @@ -1747,10 +1747,10 @@ public void testAnnotationCollectorMultiProject() throws Exception { //@formatter:off env.addGroovyClass(paths[1], "com.demo", "Widget", - "package com.demo\r\n" + - "\r\n" + - "@MyAnnotation\r\n" + - "class Widget {}\r\n"); + "package com.demo\n" + + "\n" + + "@MyAnnotation\n" + + "class Widget {}\n"); //@formatter:on fullBuild(); @@ -1822,6 +1822,38 @@ public void testAnnotationCollectorIncremental() throws Exception { executeClass(paths[0], "Book", "@NotNull()\n@Length()\n", ""); } + @Test // GROOVY-10191 + public void testInlineConstantMultiProject() throws Exception { + IPath[] paths = createSimpleProject("One", true); + + //@formatter:off + env.addGroovyClass(paths[1], "pack", "Type", + "package pack\n" + + "class Type {\n" + + " public static final CONST = 'value'\n" + + " static {\n" + + " throw new NoSuchMethodError('simulate complex field init')\n" + + " }\n" + + "}\n"); + //@formatter:on + + IPath one = paths[0]; + incrementalBuild(one); + paths = createSimpleProject("Two", true); + env.addRequiredProjectWithoutTestCode(paths[0], one); + + //@formatter:off + env.addGroovyClass(paths[1], "", "Main", + "class Main {\n" + + " static final prop = pack.Type.CONST\n" + + "}\n"); + //@formatter:on + + incrementalBuild(); + expectingNoProblems(); + expectingCompiledClasses("Main"); + } + @Test public void testClosureIncremental() throws Exception { IPath[] paths = createSimpleProject("Project", true); diff --git a/base/org.codehaus.groovy25/src/org/apache/groovy/ast/tools/ExpressionUtils.java b/base/org.codehaus.groovy25/src/org/apache/groovy/ast/tools/ExpressionUtils.java index ca1b928a01..6c5492116c 100644 --- a/base/org.codehaus.groovy25/src/org/apache/groovy/ast/tools/ExpressionUtils.java +++ b/base/org.codehaus.groovy25/src/org/apache/groovy/ast/tools/ExpressionUtils.java @@ -263,7 +263,7 @@ public static Expression transformInlineConstants(final Expression exp, final Cl // GRECLIPSE end return ce3; } - } catch(Exception e) { + } catch (Exception | LinkageError e) { // ignore, leave property expression in place and we'll report later } } diff --git a/base/org.codehaus.groovy30/src/org/apache/groovy/ast/tools/ExpressionUtils.java b/base/org.codehaus.groovy30/src/org/apache/groovy/ast/tools/ExpressionUtils.java index 7998c00f53..6b1612c4af 100644 --- a/base/org.codehaus.groovy30/src/org/apache/groovy/ast/tools/ExpressionUtils.java +++ b/base/org.codehaus.groovy30/src/org/apache/groovy/ast/tools/ExpressionUtils.java @@ -250,7 +250,7 @@ public static Expression transformInlineConstants(final Expression exp, final Cl configure(exp, ce3); return ce3; } - } catch(Exception e) { + } catch (Exception | LinkageError e) { // ignore, leave property expression in place and we'll report later } } diff --git a/base/org.codehaus.groovy40/src/org/apache/groovy/ast/tools/ExpressionUtils.java b/base/org.codehaus.groovy40/src/org/apache/groovy/ast/tools/ExpressionUtils.java index be96a8d94c..75e4d4f037 100644 --- a/base/org.codehaus.groovy40/src/org/apache/groovy/ast/tools/ExpressionUtils.java +++ b/base/org.codehaus.groovy40/src/org/apache/groovy/ast/tools/ExpressionUtils.java @@ -250,7 +250,7 @@ public static Expression transformInlineConstants(final Expression exp, final Cl configure(exp, ce3); return ce3; } - } catch(Exception e) { + } catch (Exception | LinkageError e) { // ignore, leave property expression in place and we'll report later } }