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

GroovyEclipseBug: commencingResolution failed: no declaration found for class #1515

Closed
kovax opened this issue Oct 4, 2023 · 8 comments
Closed
Assignees
Labels
Milestone

Comments

@kovax
Copy link

kovax commented Oct 4, 2023

I keep getting this error for some time, and it seriously slows down eclipse. There is no issue running the tests based on this class, in fact I have no compile errors at all. I have attached the logs from the groovy console:

eclipseError.txt

The code is open source, available in the testing module: https://github.com/cristal-ise/cristal-ise

I use freshly installed eclipse 2023-09 and the latest 5.1 plugin with groovy 3, but I saw similar problems with earlier release for some time.

null
org.eclipse.jdt.groovy.core
Error
Wed Oct 04 09:20:21 CEST 2023
Groovy compiler error

BUG! exception in phase 'semantic analysis' in source unit '/home/vagrant/workspace/cristal-ise/testing/src/main/groovy/org/cristalise/restapi/test/RestapiTestBase.groovy' commencingResolution failed: no declaration found for class org.cristalise.restapi.test.RestapiTestBase
	at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:997)
	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:707)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:669)
	at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:239)
	at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilationUnitDeclaration.java:336)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1342)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:808)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1245)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:868)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider$1.run(CoreASTProvider.java:294)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	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.core.manipulation.SharedASTProviderCore.getAST(SharedASTProviderCore.java:138)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:166)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$1.run(SelectionListenerWithASTManager.java:151)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.codehaus.jdt.groovy.internal.compiler.ast.GroovyEclipseBug: commencingResolution failed: no declaration found for class org.cristalise.restapi.test.RestapiTestBase
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.commencingResolution(JDTResolver.java:227)
	at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1558)
	at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:271)
	at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.startResolving(JDTResolver.java:197)
	at org.codehaus.groovy.control.CompilationUnit.lambda$3(CompilationUnit.java:220)
	at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:993)
	... 16 more
@eric-milles eric-milles self-assigned this Oct 5, 2023
@eric-milles eric-milles added the bug label Oct 5, 2023
@eric-milles eric-milles added this to the v5.2.0 milestone Oct 5, 2023
@eric-milles
Copy link
Member

I did some experimenting yesterday and was able to reproduce some of the conditions in your included log file. There are at least 2 issues.

First, when moving the mouse over code in a groovy source, a type inference sequence is triggered to determine what the text you are over means and display a hover info box. In this sequence, HierarchyBuilder has 2 paths. One works fine and the other is not supplying a ClassLoader that can be used to resolve @CompileStatic and @Slf4j in your code. This is why your log has "NullPointerException: Cannot invoke "org.codehaus.groovy.transform.GroovyASTTransformation.phase()" because "transformationClass" is null". I have a fix for this coming shortly.

The second situation I ran into is a bit more complicated and I'm still gathering info. The short version is that mousing over the toolbar or opening context menu in a source and selecting Run As triggers JUnit test detection (see JUnit5TestFinder in your stack traces). In your case there are a lot of cross-project references to resolve when checking a test class. It is this that shows up in your log as errors in SchemaDelegate and so on.

@eric-milles
Copy link
Member

This issue ticket asks the maintainers of JUnit5TestFinder if there is a less-costly way to determine if an IType is a test class: eclipse-jdt/eclipse.jdt.ui#302 (see item 4). You could open a new issue ticket and make reference to this one. In your projects there is a significant pause as it works out the AST so it can check for annotations.

@eric-milles
Copy link
Member

@kovax Could you update to the latest snapshot build and let me know if your situation is improved?

@kovax
Copy link
Author

kovax commented Oct 6, 2023

Thanks for the effort @eric-milles. It feels better, but I am sorry to say it is still too slow. There is another symptom. The 'Run as' menu opens very very slowly after the right click on a groovy test file in Package Explorer. Here are the logs from the groovy console: eclipseError.txt

Let me know if I can help.

@eric-milles
Copy link
Member

eric-milles commented Oct 6, 2023

I have the next fix that should eliminate the errors when opening the Run As submenu.

As noted above, the slowness is part of how the JUnit components check for a test. Since your test classes refer to quite a large type hierarchy (over 250 sources) it takes quite some time to make the determination. You can follow up with JDT UI on this front.

eric-milles added a commit that referenced this issue Oct 6, 2023
like `CompilationUnitProblemFinder` and `HierarchyResolver`
@groovy groovy deleted a comment from kovax Oct 6, 2023
@kovax
Copy link
Author

kovax commented Oct 10, 2023

I have installed the latest snapshot. The exceptions are gone, but I still see a big delay for example when I just select first time (not double click) a groovy test case in the Package Explorer:

      Compiler : 22:06:13 Build Structure starting for ViewpointCreateIT.groovy
AST Transforms : 22:06:16 Local transform org.codehaus.groovy.transform.sc.StaticCompileTransformation applied to ViewpointCreateIT.groovy(type: org.cristalise.dev.test.scenario.ViewpointCreateIT) in 27ms
AST Transforms : 22:06:16 Local transform org.codehaus.groovy.transform.sc.StaticCompileTransformation applied to ViewpointCreateIT.groovy(method: setupItem) in 0ms
      Compiler : 22:06:16 Event complete: 2371ms: Build structure: ViewpointCreateIT.groovy : main
      Compiler : 22:06:16 Build Structure starting for XPathOutcomeInitTestIT.groovy
      Compiler : 22:06:19 Event complete: 2737ms: Build structure: XPathOutcomeInitTestIT.groovy : main

@kovax
Copy link
Author

kovax commented Oct 11, 2023

I also have checked the performance of code completion by editing the ItemCreationPerformanceTest. It took a long time, about 60 sec to show the suggestions, but the console were updated for about 2 more minutes.

eclipseError.txt

@eric-milles
Copy link
Member

I'm going to close this issue as resolved -- original indication was exceptions in logs. If you think the performance needs looking into separate from simplifying your test type hierarchy, please open a new issue with specific goals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants