JUnitIncompatibleType
on 2.27.0 throws ClassCastException
for com.sun.tools.javac.code.Type$TypeVar
around assertArrayEquals
#4377
Closed
Description
opened on Apr 26, 2024
thanks for dealing with #4291 but sadly even after that fix in 2.27.0 our code base still hits a compile error in this check:
[ERROR] Please report this at https://github.com/google/error-prone/issues/new and include the following:
[ERROR]
[ERROR] error-prone version: 2.27.0
[ERROR] BugPattern: JUnitIncompatibleType
[ERROR] Stack Trace:
[ERROR] java.lang.ClassCastException: class com.sun.tools.javac.code.Type$TypeVar cannot be cast to class com.sun.tools.javac.code.Type$ArrayType (com.sun.tools.javac.code.Type$TypeVar and com.sun.tools.javac.code.Type$ArrayType are in module jdk.compiler of loader 'app')
[ERROR] at com.google.errorprone.bugpatterns.collectionincompatibletype.JUnitIncompatibleType.matchMethodInvocation(JUnitIncompatibleType.java:79)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:449)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:746)
[ERROR] at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:150)
[ERROR] at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1666)
[ERROR] at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[ERROR] at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
problematic code snippet:
protected <T> void runCircularTest(Format<T> format, T original) throws IOException {
final Serializer<T, byte[]> serializer = getSerializer(format);
final String outJson = serializer.toJson(original);
final T backJson = serializer.fromJson(outJson);
if (original instanceof byte[]) {
assertArrayEquals((byte[]) original, (byte[]) backJson); // <-- error happens here
} else {
assertEquals(original, backJson);
}
}
Metadata
Assignees
Labels
No labels
Activity