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

[Resource Leak Analysis] NPE and build failure #3328

Open
david-x64 opened this issue Nov 19, 2024 · 3 comments
Open

[Resource Leak Analysis] NPE and build failure #3328

david-x64 opened this issue Nov 19, 2024 · 3 comments
Assignees
Labels
bug Something isn't working compiler Eclipse Java Compiler (ecj) related issues

Comments

@david-x64
Copy link

I have encountered a compile error on a switch expression.
It seems the error only happens when an Object implementing AutoCloseable is involved.

I have created a minimum reproducable example here:
compile-error-switch example on github

There is no error compiling with OpenJDK Compiler, but in Eclipse it produces this error:

Internal compiler error: java.lang.RuntimeException:
Internal Error compiling /test/src/org/example/ExampleService.java
at org.eclipse.jdt.internal.compiler.ProcessTaskManager.compile(ProcessTaskManager.java:167)

Tested on Linux Mint 22.

openjdk 21.0.5 2024-10-15
OpenJDK Runtime Environment (build 21.0.5+11-Ubuntu-1ubuntu124.04)
OpenJDK 64-Bit Server VM (build 21.0.5+11-Ubuntu-1ubuntu124.04, mixed mode, sharing)

Eclipse IDE for Java Developers (includes Incubating components)

Version: 2024-09 (4.33.0)
Build id: 20240905-0614

maven-3.9.9

@iloveeclipse
Copy link
Member

Could you please try latest Eclipse build from https://download.eclipse.org/eclipse/downloads/drops4/I20241119-0600/?
This area was heavily modified recently.

@iloveeclipse iloveeclipse added bug Something isn't working compiler Eclipse Java Compiler (ecj) related issues labels Nov 19, 2024
@srikanth-sankaran srikanth-sankaran changed the title compiler error in switch expression [Resource Leak Analysis] NPE and build failure Nov 19, 2024
@srikanth-sankaran
Copy link
Contributor

Fails on master too: This doesn't involve switch expression per se, but is arising from resource leak analysis code. (Changed subject/title to reflect that.)

@stephan-herrmann - surprised to see this code run even when the annotation based resource analysis is turned off.
Thanks for taking a look.

Caused by: java.lang.NullPointerException: Cannot read field "binding" because "tracker2" is null
at org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable.pickMoreUnsafe(FakedTrackingVariable.java:576)
at org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable.analyseCloseableExpression(FakedTrackingVariable.java:896)
at org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable.handleResourceAssignment(FakedTrackingVariable.java:775)
at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.analyseCode(LocalDeclaration.java:113)
at org.eclipse.jdt.internal.compiler.ast.Block.analyseCode(Block.java:52)
at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.analyseCode(ForeachStatement.java:136)
at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.analyseCode(MethodDeclaration.java:160)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.internalAnalyseCode(TypeDeclaration.java:975)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode(TypeDeclaration.java:319)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode(CompilationUnitDeclaration.java:127)
at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1116)
at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1155)
at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:292)
at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:358)
at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:243)
at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:108)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:751)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:816)
at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1419)
at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1378)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:139)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:94)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:91)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:158)
at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:94)
at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:107)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:78)
at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:207)

@jukzi
Copy link
Contributor

jukzi commented Nov 20, 2024

caused by 4989c7f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Eclipse Java Compiler (ecj) related issues
Projects
None yet
Development

No branches or pull requests

5 participants