From a51a8c0a93ae036530539cfd1119e97f95498fd7 Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Sun, 27 Aug 2023 11:12:48 -0500 Subject: [PATCH] GROOVY-8096 --- .../src/org/codehaus/groovy/ast/ModuleNode.java | 9 +++++++++ .../src/org/codehaus/groovy/ast/ModuleNode.java | 9 +++++++++ .../src/org/codehaus/groovy/ast/ModuleNode.java | 9 +++++++++ .../integration/internal/GroovyLanguageSupport.java | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/ModuleNode.java b/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/ModuleNode.java index c529d1c395..ee699092db 100644 --- a/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/ModuleNode.java +++ b/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/ModuleNode.java @@ -344,7 +344,16 @@ private void setScriptBaseClassFromConfig(final ClassNode cn) { } if (baseClassName != null) { if (!cn.getSuperClass().getName().equals(baseClassName)) { + /* GRECLIPSE edit -- GROOVY-8096 cn.setSuperClass(ClassHelper.make(baseClassName)); + */ + ClassLoader cl = unit != null ? unit.getClassLoader() : context.getClassLoader(); + try { + cn.setSuperClass(ClassHelper.make(cl.loadClass(baseClassName))); + } catch (ReflectiveOperationException | RuntimeException e) { + cn.setSuperClass(ClassHelper.make(baseClassName)); + } + // GRECLIPSE end AnnotationNode annotationNode = new AnnotationNode(BaseScriptASTTransformation.MY_TYPE); cn.addAnnotation(annotationNode); } diff --git a/base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/ModuleNode.java b/base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/ModuleNode.java index 7cb981bbe1..472c093d99 100644 --- a/base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/ModuleNode.java +++ b/base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/ModuleNode.java @@ -350,7 +350,16 @@ private void setScriptBaseClassFromConfig(final ClassNode cn) { } if (baseClassName != null) { if (!cn.getSuperClass().getName().equals(baseClassName)) { + /* GRECLIPSE edit -- GROOVY-8096 cn.setSuperClass(ClassHelper.make(baseClassName)); + */ + ClassLoader cl = unit != null ? unit.getClassLoader() : context.getClassLoader(); + try { + cn.setSuperClass(ClassHelper.make(cl.loadClass(baseClassName))); + } catch (ReflectiveOperationException | RuntimeException e) { + cn.setSuperClass(ClassHelper.make(baseClassName)); + } + // GRECLIPSE end AnnotationNode annotationNode = new AnnotationNode(BaseScriptASTTransformation.MY_TYPE); cn.addAnnotation(annotationNode); } diff --git a/base/org.codehaus.groovy50/src/org/codehaus/groovy/ast/ModuleNode.java b/base/org.codehaus.groovy50/src/org/codehaus/groovy/ast/ModuleNode.java index 7e274d9430..8b6371327d 100644 --- a/base/org.codehaus.groovy50/src/org/codehaus/groovy/ast/ModuleNode.java +++ b/base/org.codehaus.groovy50/src/org/codehaus/groovy/ast/ModuleNode.java @@ -349,7 +349,16 @@ private void setScriptBaseClassFromConfig(final ClassNode cn) { } if (baseClassName != null) { if (!cn.getSuperClass().getName().equals(baseClassName)) { + /* GRECLIPSE edit -- GROOVY-8096 cn.setSuperClass(ClassHelper.make(baseClassName)); + */ + ClassLoader cl = unit != null ? unit.getClassLoader() : context.getClassLoader(); + try { + cn.setSuperClass(ClassHelper.make(cl.loadClass(baseClassName))); + } catch (ReflectiveOperationException | RuntimeException e) { + cn.setSuperClass(ClassHelper.make(baseClassName)); + } + // GRECLIPSE end AnnotationNode annotationNode = new AnnotationNode(BaseScriptASTTransformation.MY_TYPE); cn.addAnnotation(annotationNode); } diff --git a/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/integration/internal/GroovyLanguageSupport.java b/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/integration/internal/GroovyLanguageSupport.java index 5082fd744a..2a2f7ae233 100644 --- a/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/integration/internal/GroovyLanguageSupport.java +++ b/base/org.eclipse.jdt.groovy.core/src/org/codehaus/jdt/groovy/integration/internal/GroovyLanguageSupport.java @@ -250,7 +250,7 @@ public static CompilerConfiguration newCompilerConfiguration(final CompilerOptio ic.addStarImports("org.codehaus.groovy.ast.expr"); if (GroovyUtils.getGroovyVersion().compareTo(new Version(4, 0, 6)) >= 0) ic.addStarImports("org.codehaus.groovy.ast"); ic.addStaticStars("org.codehaus.groovy.ast.ClassHelper","org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport"); - config.addCompilationCustomizers(ic).setScriptBaseClass("org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingDSL"); + config.addCompilationCustomizers(ic).setScriptBaseClass("org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport$TypeCheckingDSL"); return config; }