This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 9a16ac96d0 GROOVY-11046: defer class header parsing for reference w/o
type argument
9a16ac96d0 is described below
commit 9a16ac96d09a654a5ddf216f42913da547c04495
Author: Eric Milles <[email protected]>
AuthorDate: Wed Dec 20 13:48:39 2023 -0600
GROOVY-11046: defer class header parsing for reference w/o type argument
---
.../codehaus/groovy/control/GenericsVisitor.java | 2 +-
src/test/groovy/bugs/Groovy11046.groovy | 34 ++++++++++++++++++
.../IncrementalRecompilationWithStubsTest.groovy | 41 +++++++++++-----------
.../groovy/tools/stubgenerator/StubTestCase.groovy | 16 ++++-----
4 files changed, 64 insertions(+), 29 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/control/GenericsVisitor.java
b/src/main/java/org/codehaus/groovy/control/GenericsVisitor.java
index 515bbb7934..79a0ada952 100644
--- a/src/main/java/org/codehaus/groovy/control/GenericsVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/GenericsVisitor.java
@@ -154,9 +154,9 @@ public class GenericsVisitor extends
ClassCodeVisitorSupport {
private void checkGenericsUsage(final ClassNode cn, final ClassNode rn,
final Boolean isAIC) {
if (cn.isGenericsPlaceHolder()) return;
GenericsType[] cnTypes = cn.getGenericsTypes();
- GenericsType[] rnTypes = rn.getGenericsTypes();
// raw type usage is always allowed
if (cnTypes == null) return;
+ GenericsType[] rnTypes = rn.getGenericsTypes();
// you can't parameterize a non-generified type
if (rnTypes == null) {
String message = "The class " + cn.toString(false) + " (supplied
with " + plural("type parameter", cnTypes.length) +
diff --git a/src/test/groovy/bugs/Groovy11046.groovy
b/src/test/groovy/bugs/Groovy11046.groovy
new file mode 100644
index 0000000000..e405cf1337
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy11046.groovy
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package groovy.bugs
+
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class Groovy11046 {
+ @Test
+ void testGrabErrorForMissingDependency() {
+ // throws NoClassDefFoundError:
com.lmax.disruptor.EventTranslatorVararg
+ assertScript '''
+ @Grab('org.apache.logging.log4j:log4j-core:2.22.0')
+ org.apache.logging.log4j.core.async.AsyncLogger log
+ '''
+ }
+}
diff --git
a/src/test/org/codehaus/groovy/ast/decompiled/IncrementalRecompilationWithStubsTest.groovy
b/src/test/org/codehaus/groovy/ast/decompiled/IncrementalRecompilationWithStubsTest.groovy
index 017c4ba243..8f23b512cf 100644
---
a/src/test/org/codehaus/groovy/ast/decompiled/IncrementalRecompilationWithStubsTest.groovy
+++
b/src/test/org/codehaus/groovy/ast/decompiled/IncrementalRecompilationWithStubsTest.groovy
@@ -20,35 +20,36 @@ package org.codehaus.groovy.ast.decompiled
import org.codehaus.groovy.tools.stubgenerator.StubTestCase
-class IncrementalRecompilationWithStubsTest extends StubTestCase {
+final class IncrementalRecompilationWithStubsTest extends StubTestCase {
+
+ private static File createFile(File dir, String name, String text) {
+ new File(dir, name).tap {
+ createNewFile()
+ setText(text)
+ }
+ }
+
@Override
void testRun() {
configure()
- File srcDir = createTempDirectory()
- srcDir.deleteOnExit()
- File src1 = createFile(srcDir, "AsmClass1.groovy", "class AsmClass1
{}")
- File src2 = createFile(srcDir, "AsmClass2.groovy", "class AsmClass2
extends AsmClass1 {}")
- File src3 = createFile(srcDir, "AsmClass3.groovy", "class AsmClass3
extends AsmClass2 {}")
- File javaSrc = createFile(srcDir, "JavaClass.java", "class JavaClass
{}")
+ File groovy1 = createFile(stubDir, "AsmClass1.groovy", "class
AsmClass1 {}")
+ File groovy2 = createFile(stubDir, "AsmClass2.groovy", "class
AsmClass2 extends AsmClass1 {}")
+ File groovy3 = createFile(stubDir, "AsmClass3.groovy", "class
AsmClass3 extends AsmClass2 {}")
+ File javaOne = createFile(stubDir, "JavaClass.java" , "class
JavaClass {}")
- compile([src1, src2, src3, javaSrc])
+ compile([groovy1, groovy2, groovy3, javaOne])
- def cls1 = new File(targetDir, "AsmClass1.class")
- assert cls1.exists()
- assert cls1.delete()
+ File class1 = new File(targetDir, "AsmClass1.class")
+ assert class1.exists()
+ assert class1.delete()
- compile([src1, src3, javaSrc])
- assert cls1.exists()
- }
+ compile([groovy1, groovy3, javaOne])
- private static File createFile(File srcDir, String name, String text) {
- File srcFile = new File(srcDir, name)
- assert srcFile.createNewFile()
- srcFile.text = text
- return srcFile
+ assert class1.exists()
}
@Override
- void verifyStubs() {}
+ void verifyStubs() {
+ }
}
diff --git
a/src/test/org/codehaus/groovy/tools/stubgenerator/StubTestCase.groovy
b/src/test/org/codehaus/groovy/tools/stubgenerator/StubTestCase.groovy
index 8bcd65bb7d..d6cee4c5c5 100644
--- a/src/test/org/codehaus/groovy/tools/stubgenerator/StubTestCase.groovy
+++ b/src/test/org/codehaus/groovy/tools/stubgenerator/StubTestCase.groovy
@@ -73,8 +73,7 @@ abstract class StubTestCase extends GroovyTestCase {
*/
@Override
protected void setUp() {
- // TODO: commented super.setUp() as it generates a stackoverflow, for
some reason?!
- // super.setUp()
+ super.setUp()
if (debug) {
println """\
Stub generator test [${this.class.name}]
@@ -91,7 +90,7 @@ abstract class StubTestCase extends GroovyTestCase {
*/
@Override
protected void tearDown() {
- if(delete) {
+ if (delete) {
if (debug) println "Deleting temporary folders"
targetDir.deleteDir()
stubDir.deleteDir()
@@ -115,7 +114,8 @@ abstract class StubTestCase extends GroovyTestCase {
* }
* </code></pre>
*/
- protected void init() {}
+ protected void init() {
+ }
/**
* @return the folder containing the sample Groovy and Java sources for
the test
@@ -267,7 +267,7 @@ abstract class StubTestCase extends GroovyTestCase {
/**
* All tests must implement this method, for doing
*/
- abstract void verifyStubs()
+ protected abstract void verifyStubs()
/**
* Method providing a useful shortcut for the subclasses, so that you can
use <code>classes</code>
@@ -311,18 +311,18 @@ abstract class StubTestCase extends GroovyTestCase {
protected static void createNecessaryPackageDirs(File path, String
relativeFilePath) {
def index = relativeFilePath.lastIndexOf('/')
- if(index < 0) return
+ if (index < 0) return
def relativeDirectories = relativeFilePath.substring(0, index)
def tmpPath = path.absolutePath
relativeDirectories.split('/').each {
- if(!tmpPath.endsWith(File.separator)) {
+ if (!tmpPath.endsWith(File.separator)) {
tmpPath = tmpPath + File.separator
}
File newDir = new File(tmpPath + it)
- if(!newDir.exists()) {
+ if (!newDir.exists()) {
if (!(newDir.mkdir())) {
throw new IOException("Impossible to create package
directory: ${newDir.absolutePath}")
}