Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 549188

Summary: "Internal compiler error" on "instanceof Object[]"
Product: [Eclipse Project] JDT Reporter: Yurx Cherio <cherio>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: paul-eclipse
Version: 4.11   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Eclipse installation details none

Description Yurx Cherio CLA 2019-07-11 13:36:46 EDT
Created attachment 279251 [details]
Eclipse installation details

Eclipse generates in internal compiler error (snapshot from the log) when it processes a java file with instruction "if (obj instanceof Object[]) {"

!ENTRY org.eclipse.core.resources 4 75 2019-07-11 13:15:53.972
!MESSAGE Errors occurred during the build.
!SUBENTRY 1 org.eclipse.jdt.core 4 75 2019-07-11 13:15:53.972
!MESSAGE Errors running builder 'Java Builder' on project 'xxxxxxxxxxxxxxxxx'.
!STACK 0
java.lang.NullPointerException
        at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:655)
        at java.base/java.lang.StringBuffer.append(StringBuffer.java:399)
        at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.shortReadableName(ParameterizedTypeBinding.java:1267)
        at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.shortReadableName(ParameterizedTypeBinding.java:1259)
        at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.notCompatibleTypesErrorInForeach(ProblemReporter.java:7033)
        at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.resolve(ForeachStatement.java:598)
        at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:641)
        at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:316)
        at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:551)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1262)
        at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1387)
        at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:652)
        at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:892)
        at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:145)
        at java.base/java.lang.Thread.run(Thread.java:834)

Replacing that line with "if (obj.getClass().isArray()) {" and clearing the project eliminates the internal compiler error. This error is reliably reproducible but only in one java module; I have the same line "if (obj instanceof Object[]) {" in a couple more modules and they don't seem to break the compiler.

Eclipse version:
Version: 2019-03 (4.11.0)
Build id: 20190314-1200
Comment 1 Paul Pazderski CLA 2019-07-11 13:45:39 EDT
JDT problem. And I'm quite sure it is the same problem as bug 540738.

*** This bug has been marked as a duplicate of bug 540738 ***