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

Several errors reported for anonymous Object classes #1915

Closed
fbricon opened this issue Oct 19, 2021 · 3 comments · Fixed by #1929
Closed

Several errors reported for anonymous Object classes #1915

fbricon opened this issue Oct 19, 2021 · 3 comments · Fixed by #1929

Comments

@fbricon
Copy link
Contributor

fbricon commented Oct 19, 2021

Try:

public class Tuples {
    public static void main(String[] args) {
        var tuple = new Object() {
            String name = "Java";
            int age = 25;
        };

        System.out.println(tuple.name +" is "+ tuple.age);
    }
}

You get java.lang.IllegalArgumentException: new java.lang.Object(){} errors on textDocument/codeAction, hover

[Error - 10:02:37 AM] Request textDocument/codeAction failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: new java.lang.Object(){}
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.IllegalArgumentException: new java.lang.Object(){}
	at org.eclipse.jdt.core.Signature.createCharArrayTypeSignature(Signature.java:1097)
	at org.eclipse.jdt.core.Signature.createTypeSignature(Signature.java:1293)
	at org.eclipse.jdt.internal.core.SelectionRequestor.acceptLocalVariable(SelectionRequestor.java:488)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.selectFrom(SelectionEngine.java:1395)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:1098)
	at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:167)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:389)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:382)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.findElementsAtSelection(JDTUtils.java:976)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.findElementAtSelection(JDTUtils.java:957)
	at org.eclipse.jdt.ls.core.internal.text.correction.SourceAssistProcessor.getSourceActionCommands(SourceAssistProcessor.java:110)
	at org.eclipse.jdt.ls.core.internal.handlers.CodeActionHandler.getCodeActionCommands(CodeActionHandler.java:208)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$15(JDTLanguageServer.java:649)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	... 6 more
[Error - 10:01:53 AM] Oct 19, 2021, 10:01:53 AM Error computing hover
new java.lang.Object(){}
java.lang.IllegalArgumentException: new java.lang.Object(){}
	at org.eclipse.jdt.core.Signature.createCharArrayTypeSignature(Signature.java:1097)
	at org.eclipse.jdt.core.Signature.createTypeSignature(Signature.java:1293)
	at org.eclipse.jdt.internal.core.SelectionRequestor.acceptLocalVariable(SelectionRequestor.java:488)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.selectFrom(SelectionEngine.java:1395)
	at org.eclipse.jdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:1098)
	at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:167)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:389)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:382)
	at org.eclipse.jdt.ls.core.internal.JDTUtils.findElementsAtSelection(JDTUtils.java:976)
	at org.eclipse.jdt.ls.core.internal.HoverInfoProvider.computeHover(HoverInfoProvider.java:97)
	at org.eclipse.jdt.ls.core.internal.handlers.HoverHandler.computeHover(HoverHandler.java:57)
	at org.eclipse.jdt.ls.core.internal.handlers.HoverHandler.hover(HoverHandler.java:43)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$7(JDTLanguageServer.java:562)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)


@fbricon
Copy link
Contributor Author

fbricon commented Oct 19, 2021

Eclipse IDE doesn't exhibit this issue

Screenshot 2021-10-19 at 10 05 56

So it's definitely.a jdt.ls bug

@snjeza
Copy link
Contributor

snjeza commented Oct 19, 2021

Eclipse IDE doesn't exhibit this issue

I can reproduce the issue in Eclipse too. You should hover over the tuple field.

fbricon

fbricon2

A simpler case:

public class Test {
    void test() {
        var runnable = new Runnable() {
			public void run() {}
		};
		runnable.run();
    }
}

You get IAE when hovering over runnable.

@snjeza
Copy link
Contributor

snjeza commented Oct 20, 2021

A related Eclipse bug - https://bugs.eclipse.org/bugs/show_bug.cgi?id=576778

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