You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/04/27 23:39:16 UTC

[groovy] 01/02: demonstration of problem when a reloaded class has generic parameters

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

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 3dffa18f707294a73dc5117dc4bbdb4a9ff5e042
Author: Jamie Echlin <je...@adaptavist.com>
AuthorDate: Fri Feb 14 15:47:56 2020 +0000

    demonstration of problem when a reloaded class has generic parameters
---
 .../util/GroovyScriptEngineReloadingTest.groovy    | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/test/groovy/util/GroovyScriptEngineReloadingTest.groovy b/src/test/groovy/util/GroovyScriptEngineReloadingTest.groovy
index 8cfd198..3e655fa 100644
--- a/src/test/groovy/util/GroovyScriptEngineReloadingTest.groovy
+++ b/src/test/groovy/util/GroovyScriptEngineReloadingTest.groovy
@@ -89,6 +89,28 @@ class GroovyScriptEngineReloadingTest extends GroovyTestCase {
         execute(100000, 200000, 2)
     }
 
+    void testRecompilingWithGenerics() {
+        MapFileSystem.instance.modFile('BaseClass.groovy', 'abstract class BaseClass<T> extends Script {}', gse.@time)
+
+        def subClassText = '''
+            class SubClass extends BaseClass<String> {
+                @Override
+                Object run() {
+                    null
+                }
+            }
+        '''
+        MapFileSystem.instance.modFile('SubClass.groovy', subClassText, gse.@time)
+
+        gse.loadScriptByName('SubClass.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('SubClass.groovy')
+
+    }
+
     void testDeleteDependent() {
         sleep 10000
         MapFileSystem.instance.modFile('ClassA.groovy', 'DependentClass ic = new DependentClass()', gse.@time as long)