Skip to content

JUnitIncompatibleType throws ClassCastException around assertArrayEquals #4291

Closed
@XN137

Description

building on jdk 11:

error-prone version: 2.25.0
BugPattern: JUnitIncompatibleType
Stack Trace:
java.lang.ClassCastException: class com.sun.tools.javac.code.Type$ClassType cannot be cast to class com.sun.tools.javac.code.Type$ArrayType (com.sun.tools.javac.code.Type$ClassType and com.sun.tools.javac.code.Type$ArrayType are in module jdk.compiler of loader 'app')
at com.google.errorprone.bugpatterns.collectionincompatibletype.JUnitIncompatibleType.matchMethodInvocation(JUnitIncompatibleType.java:84)
at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:449)
at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:746)
at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:150)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1666)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)

problematic code:

Map<MyKeyClass, List<byte[]>> byteArrayMap = ...

(...)

} else if (expectedValue instanceof byte[]) {
    assertArrayEquals((byte[]) expectedValue, byteArrayMap.get(index).get(position));
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions