eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Null pointer exception while processing the binding for a SimpleName

Open
#4,636 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

I am running our static analysis tool based on JDT (`org.eclipse.jdt.core@3.43.0`) on `org.apache.solr:solr-core@9.10.0` and encountering a null pointer exception.

```
java.lang.NullPointerException: Cannot invoke "org.eclipse.jdt.internal.compiler.lookup.TypeBinding.original()" because "lambdaExpression.resolvedType" is null
at org.eclipse.jdt.internal.core.LambdaExpression.findLambdaSuperType(LambdaExpression.java:66)
at org.eclipse.jdt.internal.core.LambdaExpression.(LambdaExpression.java:57)
at org.eclipse.jdt.internal.core.LambdaFactory.createLambdaExpression(LambdaFactory.java:30)
at org.eclipse.jdt.core.dom.MethodBinding$LambdaMethod.getUnresolvedJavaElement(MethodBinding.java:632)
at org.eclipse.jdt.core.dom.MethodBinding.getJavaElement(MethodBinding.java:307)
at org.eclipse.jdt.core.dom.VariableBinding.getUnresolvedJavaElement(VariableBinding.java:296)
at org.eclipse.jdt.core.dom.VariableBinding.getJavaElement(VariableBinding.java:161)
at com.openrefactory.ui.cli.ORDaemon.start(ORDaemon.java:61)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:219)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:149)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:115)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:467)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:298)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:627)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1431)
at org.eclipse.equinox.launcher.Main.main(Main.java:1403)
```

I have created a reproducer for demonstrating.

https://github.com/OpenRefactory-Inc/eclipse-binding-reproducer

To get this, please clone the project.

```
git clone https://github.com/OpenRefactory-Inc/eclipse-binding-reproducer
```

The project that runs on a `sol-core` branch 9.10.0 (https://github.com/apache/solr/tree/branch_9_10). I have tested on `branch_9_10`, but this may be a problem in the current code as well. To go to `branch_9_10`,

```
git clone https://github.com/apache/solr/
git checkout --track origin/branch_9_10
```

I loaded the reproducer project on Eclipse 2025-09.

The main file is `ORDaemon.java`. You have to change the path to the test project here:

https://github.com/OpenRefactory-Inc/eclipse-binding-reproducer/blob/7b98311da937a58a03f69a5056a8763e083235ab/org.openrefactory.ui.cli/src/com/openrefactory/ui/cli/ORDaemon.java#L42

Then you can see the null pointer dereference while processing `SolrCore.java` file. It was getting a binding but then failing to process the `binding.getJavaElement()` here: https://github.com/OpenRefactory-Inc/eclipse-binding-reproducer/blob/7b98311da937a58a03f69a5056a8763e083235ab/org.openrefactory.ui.cli/src/com/openrefactory/ui/cli/ORDaemon.java#L61

Note that, I am parsing and creating the AST in the following way (https://github.com/OpenRefactory-Inc/eclipse-binding-reproducer/blob/7b98311da937a58a03f69a5056a8763e083235ab/org.openrefactory.ui.cli/src/com/openrefactory/ui/cli/ASTNodeUtilities.java#L49).

This may be contradicting with suggestion made in #4492. However, if we parse like that, I get a `null` binding.

Not sure which is the correct behavior. However, I think that this may be an internal bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.