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

Fail to compile Java 21 unnamed class #3089

Closed
testforstephen opened this issue Mar 6, 2024 · 3 comments · Fixed by #3101
Closed

Fail to compile Java 21 unnamed class #3089

testforstephen opened this issue Mar 6, 2024 · 3 comments · Fixed by #3101

Comments

@testforstephen
Copy link
Contributor

Try Java 21 feature in the latest language server version, it fails to compile the Java 21 unnamed class.

UnnamedTest.java

String greeting() { return "Hello, World!"; }

void main() {
    System.out.println(greeting());
}

JavaBuilder error log:

!ENTRY org.eclipse.jdt.core 4 4 2024-03-06 14:25:39.664
!MESSAGE JavaBuilder handling CoreException
!STACK 1
org.eclipse.core.internal.resources.ResourceException: < is an invalid character in resource name '<unnamed_class$UnnamedTest>.class'.
	at org.eclipse.core.internal.resources.Resource.checkValidPath(Resource.java:470)
	at org.eclipse.core.internal.resources.File.create(File.java:125)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.writeClassFileContents(AbstractImageBuilder.java:930)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.writeClassFile(AbstractImageBuilder.java:906)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.acceptResult(AbstractImageBuilder.java:217)
	at org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:614)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:474)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:425)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:411)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:214)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:342)
	at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:79)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:286)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:192)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:1077)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:296)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:352)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:441)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:444)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:555)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:503)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:585)
	at org.eclipse.core.internal.resources.Workspace.buildInternal(Workspace.java:594)
	at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:483)
	at org.eclipse.jdt.ls.core.internal.handlers.BuildWorkspaceHandler.buildWorkspace(BuildWorkspaceHandler.java:65)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$27(JDTLanguageServer.java:988)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$60(JDTLanguageServer.java:1223)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
!SUBENTRY 1 org.eclipse.core.resources 4 77 2024-03-06 14:25:39.664
!MESSAGE < is an invalid character in resource name '<unnamed_class$UnnamedTest>.class'.
@fbricon
Copy link
Contributor

fbricon commented Mar 6, 2024

I believe this will be fixed by eclipse-jdtls/eclipse-jdt-core-incubator#102. @datho7561 ?

@rgrunber rgrunber added this to the Mid March 2024 milestone Mar 13, 2024
@rgrunber
Copy link
Contributor

This should be fixed now. Feel free to close if it's confirmed.

@fbricon
Copy link
Contributor

fbricon commented Mar 25, 2024

microsoft/vscode-java-debug#1444 was closed so that's confirmation it worked.

@fbricon fbricon closed this as completed Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants