Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfBoundsException in AtmLubVisitor.visitIntersection_Intersection #6438

Closed
cushon opened this issue Feb 2, 2024 · 1 comment · Fixed by #6441
Closed

IndexOutOfBoundsException in AtmLubVisitor.visitIntersection_Intersection #6438

cushon opened this issue Feb 2, 2024 · 1 comment · Fixed by #6441
Assignees

Comments

@cushon
Copy link
Contributor

cushon commented Feb 2, 2024

import java.util.Optional;

abstract class X {
  <T extends First & Second> Optional<T> a(boolean b, Class<T> clazz) {
    return b ? Optional.empty() : Optional.of(b(clazz));
  }

  abstract <T extends First & Second> T b(Class<T> clazz);

  interface First {}

  interface Second {}
}
$ ./checker-framework-3.42.0/checker/bin/javac -processor nullness X.java
error: Error in AnnotatedTypeMirror.fromExpression(KeyForAnnotatedTypeFactory, b ? Optional.empty() : Optional.of(b(clazz))): Index 0 out of bounds for length 0
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.42.0.
  Compilation unit: X.java
  Last visited tree at line 3 column 1:
  abstract class X {
  Exception: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0; java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
        at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
        at java.base/java.util.Objects.checkIndex(Objects.java:372)
        at java.base/java.util.ArrayList.get(ArrayList.java:460)
        at org.checkerframework.framework.util.AtmLubVisitor.visitIntersection_Intersection(AtmLubVisitor.java:374)
        at org.checkerframework.framework.util.AtmLubVisitor.visitIntersection_Intersection(AtmLubVisitor.java:33)
        at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:400)
        at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visit(AbstractAtmComboVisitor.java:34)
        at org.checkerframework.framework.util.AtmLubVisitor.visitTypevar_Typevar(AtmLubVisitor.java:307)
        at org.checkerframework.framework.util.AtmLubVisitor.visitTypevar_Typevar(AtmLubVisitor.java:33)
        at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:612)
        at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visit(AbstractAtmComboVisitor.java:34)
        at org.checkerframework.framework.util.AtmLubVisitor.lubTypeArgument(AtmLubVisitor.java:263)
        at org.checkerframework.framework.util.AtmLubVisitor.visitDeclared_Declared(AtmLubVisitor.java:208)
        at org.checkerframework.framework.util.AtmLubVisitor.visitDeclared_Declared(AtmLubVisitor.java:33)
        at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:312)
        at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visit(AbstractAtmComboVisitor.java:34)
        at org.checkerframework.framework.util.AtmLubVisitor.lub(AtmLubVisitor.java:72)
        at org.checkerframework.framework.util.AnnotatedTypes.leastUpperBound(AnnotatedTypes.java:788)
        at org.checkerframework.framework.type.TypeFromExpressionVisitor.visitConditionalExpression(TypeFromExpressionVisitor.java:182)
        at org.checkerframework.framework.type.TypeFromExpressionVisitor.visitConditionalExpression(TypeFromExpressionVisitor.java:77)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1413)
        at jdk.compiler/com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:80)
@smillst
Copy link
Member

smillst commented Feb 6, 2024

Thanks for reporting. This has already been fixed in master. (#6441 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants