MicrosoftDocs / intellicode

Visual Studio IntelliCode - AI-enhanced development tools. 👋Want to submit an issue to MicrosoftDocs/intellicode? If you have a bug or an idea, read the contributing guidelines before opening an issue. For FAQ's see
https://aka.ms/vsicfaq
Creative Commons Attribution 4.0 International
749 stars 68 forks source link

Java Intellisense throwing ArrayIndexOutOfBoundsException #129

Closed testforstephen closed 2 years ago

testforstephen commented 5 years ago

Original issue is created by @harjoben in https://github.com/redhat-developer/vscode-java/issues/1077

For some reason Intellisense just stopped working for one of the Java files in my workspace. When I looked at the Java language server log file, I saw this exception:

!ENTRY com.microsoft.jdtls.intellicode.core 4 0 2019-09-25 00:37:05.423
!MESSAGE Problem with codeComplete for file:///path/to/file/UtilResource.java
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 278
    at org.eclipse.jdt.internal.core.util.MementoTokenizer.nextToken(MementoTokenizer.java:57)
    at org.eclipse.jdt.internal.core.JavaProject.getHandleFromMemento(JavaProject.java:2008)
    at org.eclipse.jdt.internal.core.JavaElement.getHandleFromMemento(JavaElement.java:348)
    at org.eclipse.jdt.internal.core.JavaModel.getHandleFromMemento(JavaModel.java:159)
    at org.eclipse.jdt.internal.core.JavaElement.getHandleFromMemento(JavaElement.java:348)
    at org.eclipse.jdt.core.JavaCore.create(JavaCore.java:3476)
    at org.eclipse.jdt.core.JavaCore.create(JavaCore.java:3451)
    at org.eclipse.jdt.internal.core.util.Util.getPackageFragment(Util.java:960)
    at org.eclipse.jdt.internal.core.util.Util.getClassFile(Util.java:765)
    at org.eclipse.jdt.internal.core.util.Util.getUnresolvedJavaElement(Util.java:1543)
    at com.microsoft.jdtls.intellicode.core.pythia.PythiaCompletionContext.getReceiverType(PythiaCompletionContext.java:167)
    at com.microsoft.jdtls.intellicode.core.pythia.PythiaCompletionProvider.provideCompletionItems(PythiaCompletionProvider.java:55)
    at com.microsoft.jdtls.intellicode.core.CompletionProvider.computeContentAssist(CompletionProvider.java:117)
    at com.microsoft.jdtls.intellicode.core.CompletionProvider.provideCompletionItems(CompletionProvider.java:60)
    at com.microsoft.jdtls.intellicode.core.CommandHandler.executeCommand(CommandHandler.java:57)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:213)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:203)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$3(JDTLanguageServer.java:462)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer$$Lambda$96.00000000A0087410.apply(Unknown Source)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$45(JDTLanguageServer.java:935)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer$$Lambda$98.00000000A0087960.apply(Unknown Source)
    at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:613)
    at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:588)
    at java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:454)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:300)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:168)
Environment
Eskibear commented 5 years ago

@harjoben Can you provide the content of file UtilResource.java for us to reproduce the issue?

harjoben commented 5 years ago

@Eskibear I'm not able to reproduce the issue anymore. Not sure if it was something that I did that fixed it. Last when I was seeing this issue, it was only for this file in my entire workspace. I made do without using intellisense to update the code. Now when I tried again on the same file, intellisense seems to be working fine. My environment is exactly the same as mentioned in the original issue

Eskibear commented 5 years ago

@harjoben Thanks for the detailed feedback. For now I don't see any suspicious code in IntelliCode, it simply fetch the completion items from Java Language Server (JLS) and re-rank them. About the error, I guess something in JLS was out-of-sync. Recently we're working on stablity and performance improvement of the JLS, and we'll keep an eye on this error.

ayim commented 2 years ago

Going to close for now, seems like this has been fixed.