You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Lóránt Pintér (Jira)" <ji...@apache.org> on 2023/02/13 10:42:00 UTC

[jira] [Commented] (GROOVY-10932) Groovy incremental compilation failure with traits

    [ https://issues.apache.org/jira/browse/GROOVY-10932?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17687879#comment-17687879 ] 

Lóránt Pintér commented on GROOVY-10932:
----------------------------------------

Issue on Gradle side: https://github.com/gradle/gradle/issues/22814

> Groovy incremental compilation failure with traits
> --------------------------------------------------
>
>                 Key: GROOVY-10932
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10932
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 3.0.15
>            Reporter: Lóránt Pintér
>            Priority: Major
>
> See reproducer here: https://github.com/asodja/groovy-traits-compilation-reproducer
> This reproduces issue with Groovy traits and Gradle incremental compilation.
> Steps to reproduce:
> 1. git clone git@github.com:asodja/groovy-traits-compilation-reproducer.git
> 2. run `./gradlew :lib:compileGroovy --no-build-cache`
> 3. Change `println("a")` in MyTest.groovy to `println("b")`
> 4. run `./gradlew :lib:compileGroovy --no-build-cache` again
> 5. See error
> To resolve the issue run `./gradlew :lib:compileGroovy --no-build-cache --rerun-tasks`
> Exception thrown:
> {code:java}
> java.lang.RuntimeException: java.lang.NoClassDefFoundError: Unable to load class test.groovy.traits.WithPluginValidation$AllPluginsValidation due to missing dependency Ltest/groovy/traits/MyTestBase;
> at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:977)
> at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:672)
> at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:636)
> at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:611)
> at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:271)
> ...
> Caused by: java.lang.NoClassDefFoundError: Unable to load class test.groovy.traits.WithPluginValidation$AllPluginsValidation due to missing dependency Ltest/groovy/traits/MyTestBase;
> at org.codehaus.groovy.vmplugin.v8.Java8.configureClassNode(Java8.java:447)
> at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:273)
> at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1014)
> at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1006)
> at org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:1000)
> at org.codehaus.groovy.ast.ClassNode.isDerivedFrom(ClassNode.java:911)
> at org.codehaus.groovy.classgen.asm.InvocationWriter.castToNonPrimitiveIfNecessary(InvocationWriter.java:1144)
> at org.codehaus.groovy.classgen.asm.OperandStack.doConvertAndCast(OperandStack.java:363)
> at org.codehaus.groovy.classgen.asm.OperandStack.doGroovyCast(OperandStack.java:300)
> at org.codehaus.groovy.classgen.AsmClassGenerator.storeThisInstanceField(AsmClassGenerator.java:1259)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitFieldExpression(AsmClassGenerator.java:1196)
> at org.codehaus.groovy.ast.expr.FieldExpression.visit(FieldExpression.java:41)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitPropertyExpression(AsmClassGenerator.java:1124)
> at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:63)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitVariableExpression(AsmClassGenerator.java:1339)
> at org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:71)
> ...
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:273)
> at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:798)
> at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:943)
> ... 34 more
> {code}
> Classes hierarchy:
> {code:java}
> class MyTest extends MyTestBase implements WithPluginValidation
> { ... }
> class MyTestBase \{ ... }
> has a dependency to MyTest inside a method
> @SelfType(MyTestBase)
> trait WithPluginValidation {
> final AllPluginsValidation allPlugins = new AllPluginsValidation(this)
> static class AllPluginsValidation {
> final MyTestBase base
> AllPluginsValidation(MyTestBase base)
> { this.base = base }
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)