You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Renato Athaydes (JIRA)" <ji...@apache.org> on 2017/01/16 19:10:26 UTC

[jira] [Commented] (GROOVY-8008) @CompileStatic causes failure to compile Groovy class that calls overloaded Java method

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

Renato Athaydes commented on GROOVY-8008:
-----------------------------------------

This file also does not compile with either @CompileStatic or @TypeChecked:

https://github.com/renatoathaydes/osgiaas/blob/master/modules/cli/osgiaas-cli-groovy/src/main/groovy/com/athaydes/osgiaas/cli/groovy/command/GroovyCommand.groovy

I found out that if I comment out the lines creating the "argsSpec":

```
    final ArgsSpec argsSpec = ArgsSpec.builder()
            .accepts( RESET_CODE_ARG, RESET_CODE_LONG_ARG )
        ...
```

Then it works. I tried to reproduce this bug with a simpler setup but it just worked... I couldn't figure out what's the difference between my simpler code and this one. Hope this helps, anyway.

> @CompileStatic causes failure to compile Groovy class that calls overloaded Java method
> ---------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8008
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8008
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.5, 2.4.7
>         Environment: Mac OS / Java 8_u112
>            Reporter: Renato Athaydes
>
> This bug is not making sense to me, but I want to report it because it's incredibly frustrating to get an error message that won't even tell me which file the compiler was trying to compile before throwing an Exception.
> Here's the stacktrace:
> Error:Groovyc: While compiling osgiaas-cli-groovy_main: java.lang.ArrayIndexOutOfBoundsException: 2
> 	at org.codehaus.groovy.vmplugin.v5.Java5.makeParameters(Java5.java:443)
> 	at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:376)
> 	at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:265)
> 	at org.codehaus.groovy.ast.ClassNode.getAnnotations(ClassNode.java:1431)
> 	at org.codehaus.groovy.ast.ClassNode.getAnnotations(ClassNode.java:1430)
> 	at org.codehaus.groovy.transform.trait.Traits.isAnnotatedWithTrait(Traits.java:170)
> 	at org.codehaus.groovy.transform.trait.Traits.isTrait(Traits.java:149)
> 	at org.codehaus.groovy.transform.trait.Traits.collectSelfTypes(Traits.java:309)
> 	at org.codehaus.groovy.transform.trait.Traits.collectSelfTypes(Traits.java:291)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.addSelfTypes(StaticTypeCheckingVisitor.java:3102)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.makeOwnerList(StaticTypeCheckingVisitor.java:3083)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2852)
> 	at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:297)
> 	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2735)
> 	at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:297)
> 	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2735)
> 	at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:297)
> 	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2735)
> 	at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:297)
> 	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitProperty(ClassCodeVisitorSupport.java:144)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitProperty(StaticTypeCheckingVisitor.java:1518)
> 	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1074)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:249)
> 	at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:122)
> 	at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:63)
> 	at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134)
> 	at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178)
> 	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1055)
> 	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
> 	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
> 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
> 	at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:62)
> 	at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:115)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.jetbrains.groovy.compiler.rt.GroovycRunner.intMain2(GroovycRunner.java:136)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.runGroovycInThisProcess(InProcessGroovyc.java:156)
> 	at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.access$000(InProcessGroovyc.java:51)
> 	at org.jetbrains.jps.incremental.groovy.InProcessGroovyc$1.call(InProcessGroovyc.java:85)
> 	at org.jetbrains.jps.incremental.groovy.InProcessGroovyc$1.call(InProcessGroovyc.java:82)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> 	at java.lang.Thread.run(Thread.java:745)
> All I can tell you is that [this commit](https://github.com/renatoathaydes/osgiaas/commit/3b04f1d22b3b612d49a5af6fab402b2f4fe316d7) (to a Java class in another module!) started causing this error. Basically, it adds a new overload to a method (`com.athaydes.osgiaas.cli.args.ArgsSpec.ArgsSpecBuilder#accepts(java.lang.String, java.lang.String)`) which no class even calls yet.
> The error happens when compiling the [:modules:cli:osgiaas-cli-grab](https://github.com/renatoathaydes/osgiaas/tree/master/modules/cli/osgiaas-cli-grab/src/main/groovy/com/athaydes/osgiaas/cli/grab) module, which only contains 2 groovy classes (so it should be possible to determine why this is happening a little more easily).
> Reverting the commit, the code compiles and all tests pass.
> Removing `@CompileStatic` from the classes also seems to fix the problem, but then other Groovy classes (which also have `@CompileStatic`) start failing!
> Please let me know if there's anything I can do to help figure this out... but for now, that's all the information I can provide!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)