forcedotcom / salesforcedx-vscode

Salesforce Extensions for VS Code
https://developer.salesforce.com/tools/vscode
BSD 3-Clause "New" or "Revised" License
939 stars 397 forks source link

Repeated IllegalStateException on Valid Apex Code Using Apex Language Server #5657

Closed tepimartin closed 6 days ago

tepimartin commented 1 week ago

Summary

I am consistently encountering an IllegalStateException with various classes and cases when using the Apex Language Server in VS Code. Despite the Apex code being correct and deploying without issues, the language server incorrectly flags method definitions as already defined. This problem persists across restarts of both VS Code and the computer, and is not resolved by reinstalling Java or trying with a fresh installed Zulu JDK 17.0.11+9. Importantly, the class mentioned in the Java error, along with any of its dependencies or dependents, has not been changed for months. The error has become a complete blocker, preventing the use of the replay debugger for my complex project and severely impacting my development workflow.

System Information

OS: macOS Sonoma 14.5 SFDX CLI Version: salesforce/cli/2.46.6 darwin-arm64 node-v20.14.0 VS Code Version: 1.90.2 Salesforce Extension Pack Version: v61.1.2

Error Log

[Trace - 17:57:28] Sending request 'debugger/lineBreakpoints - (142)'.
17:57:31.121 [pool-1-thread-1] ERROR a.j.l.impl.debug.ApexDebuggerService - Error trying to get line breakpoint info
java.lang.IllegalStateException: Method already defined: <init> void VolunteeringsTriggerHandler.<init>(List<Volunteering__c>) from the type VolunteeringsTriggerHandler
    at apex.common.base.Result.throwIfError(Result.java:112)
    at apex.jorje.semantic.symbol.member.method.MethodTableFactory.newMethodTable(MethodTableFactory.java:44)
    at apex.jorje.semantic.symbol.member.method.MethodTableFactory.newMethodTable(MethodTableFactory.java:39)
    at apex.jorje.lsp.impl.index.symbol.VirtualMethodTableInitializer.get(VirtualMethodTableInitializer.java:74)
    at apex.jorje.lsp.impl.index.symbol.VirtualMethodTableInitializer.get(VirtualMethodTableInitializer.java:39)
    at apex.common.base.Initializers$MemoizingInitializer.get(Initializers.java:74)
    at apex.jorje.semantic.symbol.type.AbstractTypeInfo.methods(AbstractTypeInfo.java:122)
    at apex.jorje.semantic.symbol.resolver.MethodResolver.lookupStatic(MethodResolver.java:146)
    at apex.jorje.semantic.symbol.resolver.MethodResolver.lookup(MethodResolver.java:90)
    at apex.jorje.semantic.symbol.resolver.StandardSymbolResolver.lookupMethodInfo(StandardSymbolResolver.java:221)
    at apex.jorje.semantic.ast.expression.MethodCallExpression.validate(MethodCallExpression.java:204)
    at apex.jorje.semantic.ast.statement.ExpressionStatement.validate(ExpressionStatement.java:60)
    at apex.jorje.semantic.ast.statement.MultiStatement.validate(MultiStatement.java:65)
    at apex.jorje.semantic.ast.statement.MethodBlockStatement.validate(MethodBlockStatement.java:82)
    at apex.jorje.semantic.ast.member.Method.validate(Method.java:172)
    at apex.jorje.semantic.ast.compilation.UserTrigger.validate(UserTrigger.java:217)
    at apex.jorje.semantic.compiler.CodeUnit.validate(CodeUnit.java:220)
    at apex.jorje.semantic.compiler.CompilerOperations$ValidateOperation.invoke(CompilerOperations.java:96)
    at apex.jorje.semantic.compiler.CompilerStageProcessor.processFirstStage(CompilerStageProcessor.java:136)
    at apex.jorje.semantic.compiler.CompilerStageProcessor.processToStage(CompilerStageProcessor.java:105)
    at apex.jorje.semantic.compiler.ApexCompiler.compile(ApexCompiler.java:120)
    at apex.jorje.lsp.impl.services.StandardCompilerService.compile(StandardCompilerService.java:149)
    at apex.jorje.lsp.impl.services.StandardCompilerService.fetchCodeUnit(StandardCompilerService.java:236)
    at apex.jorje.lsp.impl.services.StandardCompilerService.compile(StandardCompilerService.java:94)
    at apex.jorje.lsp.impl.debug.ApexDebuggerService.lambda$lineBreakpoints$0(ApexDebuggerService.java:88)
    at java.base/java.util.Optional.ifPresent(Optional.java:178)
    at apex.jorje.lsp.impl.debug.ApexDebuggerService.lineBreakpoints(ApexDebuggerService.java:86)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$recursiveFindRpcMethods$0(GenericEndpoint.java:65)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
svc-idee-bot commented 1 week ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

mingxuanzhangsfdx commented 1 week ago

Hi @tepimartin , You can try to remove the local Apex index files for the Apex language server.

  1. Shut down vscode
  2. Remove the folder .sfdx/tools/250 from your project root directory
  3. Restart vscode

Please let me know the results.

tepimartin commented 1 week ago

Hi @mingxuanzhangsfdx ,

Thank you for your quick reply! This solution seems to be working now. I will continue testing it for a couple of days and will let you know if I notice anything unusual.

Thanks again, Martin

mingxuanzhangsfdx commented 6 days ago

Hi @tepimartin - glad this works out. I am going to close the issue and feel free to reopen it or file another one if you have further questions.