This is an automated email from the ASF dual-hosted git repository.

jonnybot pushed a commit to branch 
GROOVY-9526-regression-semantic-analysis-exception
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit cd5c3f32992e5d96f12d1cba779e9e76bf7c2981
Author: Jonny Carter <[email protected]>
AuthorDate: Mon Jul 21 15:29:25 2025 -0500

    Failing test
    
    May be a specific regression of 
https://issues.apache.org/jira/browse/GROOVY-9526
    
    See https://github.com/apache/groovy/pull/1168/files for some original
    context
    
    Stacktrace when test is run:
    
    BUG! exception in phase 'semantic analysis' in source unit 
'map://local/BaseClass.groovy' null
    BUG! exception in phase 'semantic analysis' in source unit 
'map://local/BaseClass.groovy' null
            at 
org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:869)
            at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:660)
            at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:634)
            at 
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:365)
            at 
groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:314)
            at 
org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
            at 
org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
            at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314)
            at 
groovy.util.GroovyScriptEngine$ScriptClassLoader.doParseClass(GroovyScriptEngine.java:231)
            at 
groovy.util.GroovyScriptEngine$ScriptClassLoader.parseClass(GroovyScriptEngine.java:218)
            at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:298)
            at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:263)
            at 
groovy.util.GroovyScriptEngine.loadScriptByName(GroovyScriptEngine.java:534)
            at 
org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
            at 
groovy.util.GroovyScriptEngineReloadingTest.testRecompilingWithGenericsTwoElectricBoogaloo(GroovyScriptEngineReloadingTest.groovy:210)
            at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
            at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:568)
            at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
            at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
            at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
            at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
            at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
            at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
            at 
org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
            at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
            at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
            at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
            at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
            at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
            at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
            at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
            at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
            at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
            at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
            at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
            at 
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:112)
            at 
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
            at 
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
            at 
org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:54)
            at 
org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:53)
            at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
            at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:568)
            at 
org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
            at 
org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
            at 
org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
            at 
org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)
            at jdk.proxy1/jdk.proxy1.$Proxy9.processTestClass(Unknown Source)
            at 
org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:183)
            at 
org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:132)
            at 
org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:103)
            at 
org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:63)
            at 
org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
            at 
org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:122)
            at 
org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:72)
            at 
worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
            at 
worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
    Caused by: java.lang.UnsupportedOperationException
            at java.base/java.util.AbstractMap.put(AbstractMap.java:209)
            at 
org.codehaus.groovy.control.ResolveVisitor.resolveGenericsHeader(ResolveVisitor.java:1452)
            at 
org.codehaus.groovy.control.ResolveVisitor.resolveGenericsHeader(ResolveVisitor.java:1409)
            at 
org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1284)
            at 
org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:258)
            at 
org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$3(CompilationUnit.java:201)
            at 
org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:865)
            ... 59 more
---
 .../util/GroovyScriptEngineReloadingTest.groovy    | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy 
b/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
index 660f4ddcf0..935d99abc8 100644
--- a/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
+++ b/src/test/groovy/groovy/util/GroovyScriptEngineReloadingTest.groovy
@@ -182,6 +182,39 @@ final class GroovyScriptEngineReloadingTest {
 
     }
 
+    @Test
+    void testRecompilingWithGenericsAndConstants() {
+        MapFileSystem.instance.modFile('BaseClass.groovy', 'class BaseClass<T> 
{}', gse.@time)
+
+        def tertiaryClassText = '''
+            class NotGeneric {
+                /**
+                 * Not typed on purpose - if typed as String then NotGeneric 
is no longer a dependency of
+                 * ParameterisedClass for some reason...
+                 */
+                public static final Object CONSTANT = "not generic"
+            }
+        '''
+        MapFileSystem.instance.modFile('NotGeneric.groovy', tertiaryClassText, 
gse.@time)
+
+        def subClassText = '''
+            class SubClass extends BaseClass<String> {
+                public static final String CONSTANT = NotGeneric.CONSTANT
+            }
+        '''
+        MapFileSystem.instance.modFile('SubClass.groovy', subClassText, 
gse.@time)
+
+        MapFileSystem.instance.modFile('scriptUsingGeneric.groovy', 
'SubClass.CONSTANT', gse.@time)
+
+
+        gse.loadScriptByName('scriptUsingGeneric.groovy')
+        sleep 1000
+
+        // make a change to the sub-class so that it gets recompiled
+        MapFileSystem.instance.modFile('SubClass.groovy', subClassText + '\n', 
gse.@time)
+        gse.loadScriptByName('scriptUsingGeneric.groovy')
+    }
+
     @Test
     void testDeleteDependent() {
         sleep 10000

Reply via email to