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

can't build project after latest jdt core updates (ArrayBinding cannot be cast to class ReferenceBinding) #3199

Open
mfussenegger opened this issue Jun 20, 2024 · 3 comments

Comments

@mfussenegger
Copy link
Contributor

mfussenegger commented Jun 20, 2024

Using the current master (5c5f2e3), eclipse.jdt.ls is no longer able to load and build crate.
Update: Workaround was merged: crate/crate#16416, see #3199 (comment) for a reproduction.

The logs show the following errors:

org.eclipse.core.internal.resources.ResourceException: Errors occurred during the build.
	at org.eclipse.core.internal.resources.Workspace.buildInternal(Workspace.java:611)
	at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:483)
	at org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandler.buildWorkspace(BuildWorkspaceHandler.java:67)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$28(JDTLanguageServer.java:989)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$61(JDTLanguageServer.java:1224)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
Contains: Errors running builder 'Java Builder' on project 'crate-server'.
java.lang.RuntimeException: Internal Error compiling /crate-server/src/test/java/io/crate/execution/engine/sort/OrderingByPositionTest.java
	at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:151)
	at java.base/java.lang.Thread.run(Thread.java:1570)
Caused by: java.lang.ClassCastException
java.lang.ClassCastException: class org.eclipse.jdt.internal.compiler.lookup.ArrayBinding cannot be cast to class org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding (org.eclipse.jdt.internal.compiler.lookup.ArrayBinding and org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @4eb6283e)
	at org.eclipse.jdt.internal.compiler.lookup.CaptureBinding.downwardsProjection(CaptureBinding.java:547)
	at org.eclipse.jdt.internal.compiler.lookup.CaptureBinding.downwardsProjection(CaptureBinding.java:1)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.upwardsProjection(ParameterizedTypeBinding.java:530)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.upwardsProjection(ParameterizedTypeBinding.java:1)
	at org.eclipse.jdt.internal.compiler.lookup.TypeBinding.upwardsProjection(TypeBinding.java:325)
	at org.eclipse.jdt.internal.compiler.lookup.BoundSet.deriveTypeArgumentConstraints(BoundSet.java:974)
	at org.eclipse.jdt.internal.compiler.lookup.BoundSet.incorporate(BoundSet.java:630)
	at org.eclipse.jdt.internal.compiler.lookup.BoundSet.incorporate(BoundSet.java:511)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.resolve(InferenceContext18.java:1215)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.solve(InferenceContext18.java:1052)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.solve(InferenceContext18.java:1035)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod18(ParameterizedGenericMethodBinding.java:256)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod(ParameterizedGenericMethodBinding.java:92)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:842)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:799)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod0(Scope.java:1753)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1655)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(Scope.java:3145)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.findMethodBinding(MessageSend.java:1138)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:914)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:402)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:258)
	at org.eclipse.jdt.internal.compiler.ast.Statement.resolveWithBindings(Statement.java:498)
	at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolveStatements(ASTNode.java:725)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:713)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:409)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:611)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1514)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1643)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:666)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1326)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:791)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateASTCached(ASTParser.java:1248)
	at org.eclipse.jdt.core.dom.ASTParser.lambda$0(ASTParser.java:1126)
	at org.eclipse.jdt.internal.core.JavaModelManager.cacheZipFiles(JavaModelManager.java:5762)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1126)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:874)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider$1.run(CoreASTProvider.java:294)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider.createAST(CoreASTProvider.java:286)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider.getAST(CoreASTProvider.java:199)
	at org.eclipse.jdt.ls.core.internal.handlers.DocumentHighlightHandler.documentHighlight(DocumentHighlightHandler.java:56)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$12(JDTLanguageServer.java:725)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)

I suspect this is caused by one of the recent jdt core/target platform updates, but I cannot compile the older commits of eclipse.jdt.ls so I can't tell for sure. (dependencies disappeared(?)).

After deleting OrderingByPositionTest the project builds again.

I can try to extract a smaller reproduction if necessary, but I suspected that with the full project, the file that causes the error and the full stacktrace someone more familiar with the code might already have an idea what's causing the problem.

@mfussenegger
Copy link
Contributor Author

Looks like #3200 fixed it

@mfussenegger
Copy link
Contributor Author

Actually, it looks like this is still broken (tested with b363a86). In my earlier test I forgot to switch back to the development version of eclipse.jdt.ls

@mfussenegger mfussenegger reopened this Jul 8, 2024
@mfussenegger
Copy link
Contributor Author

mfussenegger commented Jul 27, 2024

Narrowed it down to:

    @Test
    public void test_compile_error() throws Exception {
        Comparator<Object[]> ordering = CompoundOrdering.of(Arrays.asList(
            OrderingByPosition.arrayOrdering(1, false, false),
            OrderingByPosition.arrayOrdering(0, false, false)
        ));
    }

Which triggers the error. The code compiles with javac. It also compiles with the eclipse compiler if changing to:

    @Test
    public void test_ok() throws Exception {
        var orderings = Arrays.asList(
            OrderingByPosition.arrayOrdering(1, false, false),
            OrderingByPosition.arrayOrdering(0, false, false)
        );
        Comparator<Object[]> ordering = CompoundOrdering.of(orderings);
    }

https://github.com/mfussenegger/eclipse-compiler-bug contains the full trimmed reproduction.
(Currently the problematic code is commented out: https://github.com/mfussenegger/eclipse-compiler-bug/blob/0b1c7bf3fef26d6879b54fdf3ea94432186e8148/src/test/java/foo/CompoundOrderingTest.java#L20)

mfussenegger added a commit to crate/crate that referenced this issue Jul 29, 2024
For some reason `OrderingByPositionTest` triggered a bug in the
eclipse compiler, causing it to crash.

See eclipse-jdtls/eclipse.jdt.ls#3199
mergify bot pushed a commit to crate/crate that referenced this issue Jul 29, 2024
For some reason `OrderingByPositionTest` triggered a bug in the
eclipse compiler, causing it to crash.

See eclipse-jdtls/eclipse.jdt.ls#3199
mergify bot pushed a commit to crate/crate that referenced this issue Jul 29, 2024
For some reason `OrderingByPositionTest` triggered a bug in the
eclipse compiler, causing it to crash.

See eclipse-jdtls/eclipse.jdt.ls#3199

(cherry picked from commit edda49c)
mergify bot pushed a commit to crate/crate that referenced this issue Jul 29, 2024
For some reason `OrderingByPositionTest` triggered a bug in the
eclipse compiler, causing it to crash.

See eclipse-jdtls/eclipse.jdt.ls#3199

(cherry picked from commit edda49c)

# Conflicts:
#	server/src/test/java/io/crate/execution/engine/sort/OrderingByPositionTest.java
mfussenegger added a commit to crate/crate that referenced this issue Jul 29, 2024
For some reason `OrderingByPositionTest` triggered a bug in the
eclipse compiler, causing it to crash.

See eclipse-jdtls/eclipse.jdt.ls#3199

(cherry picked from commit edda49c)

# Conflicts:
#	server/src/test/java/io/crate/execution/engine/sort/OrderingByPositionTest.java
mergify bot pushed a commit to crate/crate that referenced this issue Jul 29, 2024
For some reason `OrderingByPositionTest` triggered a bug in the
eclipse compiler, causing it to crash.

See eclipse-jdtls/eclipse.jdt.ls#3199

(cherry picked from commit edda49c)

# Conflicts:
#	server/src/test/java/io/crate/execution/engine/sort/OrderingByPositionTest.java
mfussenegger added a commit to crate/crate that referenced this issue Jul 29, 2024
For some reason `OrderingByPositionTest` triggered a bug in the
eclipse compiler, causing it to crash.

See eclipse-jdtls/eclipse.jdt.ls#3199

(cherry picked from commit edda49c)
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

No branches or pull requests

1 participant