You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2018/03/14 05:49:00 UTC

[jira] [Commented] (GROOVY-8505) ArrayIndexOutOfBoundsException with @Nullable change

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

Daniel Sun commented on GROOVY-8505:
------------------------------------

Lóránt, I can not reproduce the issue with the simplified code on 2_4_x branch:

{code:java}
// Groovy8505Bug.groovy
package groovy.bugs.groovy8505bug

class Groovy8505Bug extends GroovyTestCase {
    void testAnnotatedArgument() {
        assert 123 == new JavaClass().t()
    }
}
{code}


{code:java}
// JavaClass.java
package groovy.bugs.groovy8505bug;


import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public class JavaClass {
    public class T {
        Integer x;
        private T(@Nullable Integer c) {
            x = c;
        }
    }

    public Integer t() {
        return new T(123).x;
    }
}

@Retention(RetentionPolicy.RUNTIME)
@interface Nullable {

}
{code}


> ArrayIndexOutOfBoundsException with @Nullable change
> ----------------------------------------------------
>
>                 Key: GROOVY-8505
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8505
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.12
>         Environment: See https://scans.gradle.com/s/gr3dszv44wkfg/console-log#L476 for execution details.
>            Reporter: Lóránt Pintér
>            Priority: Major
>
> *Steps to reproduce:*
> {code}
> $ git clone [https://github.com/gradle/gradle
> $ cd gradle
> $ git checkout c8e7ac4adb2f72390ed681eb8bfdaa41111baa8e
> $ ./gradlew :core:compileTestGroovy
> $ # ^ This version works
> $ git revert --no-commit head
> $ ./gradlew :core:compileTestGroovy
> $ # ^ This will fail
> {code}
> The reverted commit is this:
> https://github.com/gradle/gradle/pull/4682/commits/c8e7ac4adb2f72390ed681eb8bfdaa41111baa8e
> It removes a {{@Nullable}} annotation from a constructor parameter. If the annotation is present (i.e. the commit is reverted), {{./gradlew :core:compileTestGroovy}} will produce the following exception:
> {code}
> java.lang.ArrayIndexOutOfBoundsException: 1
>         at org.codehaus.groovy.vmplugin.v5.Java5.makeParameters(Java5.java:451)
>         at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:382)
>         at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:280)
>         at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1009)
>         at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1004)
>         at org.codehaus.groovy.ast.ClassNode.getSuperClass(ClassNode.java:998)
>         at org.codehaus.groovy.ast.ClassNode.isDerivedFrom(ClassNode.java:941)
>         at org.codehaus.groovy.classgen.asm.InvocationWriter.castToNonPrimitiveIfNecessary(InvocationWriter.java:863)
>         at org.codehaus.groovy.classgen.asm.OperandStack.doConvertAndCast(OperandStack.java:345)
>         at org.codehaus.groovy.classgen.asm.OperandStack.doGroovyCast(OperandStack.java:282)
>         at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:344)
>         at org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:637)
>         at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
>         at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:613)
>         at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:366)
>         at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:624)
>         at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
>         at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:85)
>         at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:159)
>         at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:570)
>         at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
>         at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104)
>         at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
>         at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:434)
>         at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:387)
>         at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126)
>         at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:511)
>         at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1081)
>         at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53)
>         at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:233)
>         at org.codehaus.groovy.control.CompilationUnit.call(CompilationUnit.java:825)
>         at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
>         at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
>         at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
>         at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
>         at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:537)
>         at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:175)
> {code}
> The change actually happens in Java code that the Groovy compilation depends on.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)