Community
Participate
Working Groups
Hello I am observing following NPE during parsing code with annotation. java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.UnresolvedAnnotationBinding.resolve(UnresolvedAnnotationBinding.java:34) at org.eclipse.jdt.internal.compiler.lookup.UnresolvedAnnotationBinding.getAnnotationType(UnresolvedAnnotationBinding.java:41) at org.eclipse.jdt.core.dom.MethodBinding.filterTypeAnnotations(MethodBinding.java:226) at org.eclipse.jdt.core.dom.MethodBinding.getAnnotations(MethodBinding.java:115) Debugger shows that env value is null during reverting state for env.mayTolerateMissingType (patch https://bugs.eclipse.org/bugs/show_bug.cgi?id=388042).
Wow, thanks. Is it the "this.env = null" inside getElementValuePairs() that breaks it? Maybe we should simply pull this.env into a local variable, to be independent of the changes in the field. @Tomasz are you in a position to try this?
Hi Stephan Creating a local reference of this.env used inside resolve method fixed the NPE problem. However I have a one concern about the flow in this class. - Method resolve() temporary changes state of this.env.mayTolerateMissingType (path 388042) - Since reference of this.env is changed to null during calling "resolve()" method is means that getElementValuePairs() (which can change this state) is called independently (from separated thread). It means that both methods changes state of env in the same time (change it's content or make whole reference null), so they may be not thread safe. Should their content use some synchronization block to avoid case when ie. this.env.mayTolerateMissingType will changed by resolve() in one thread when getElementValuePairs() will start resolving method binding in other thread (method part after independent call to resolve() at its begining) ?
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
I ran into this issue today and Googled the error and found this bug. I tested my code single threaded and didn't get the error. When multi-threaded, I get the error inconsistently, which aligns with the 2019 discussion that it's a bug where env value is null sometimes, which yields the inconsistent bug when multi-threaded. Exception in thread "ForkJoinPool-1-worker-1" java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.UnresolvedAnnotationBinding.resolve(UnresolvedAnnotationBinding.java:34) at org.eclipse.jdt.internal.compiler.lookup.UnresolvedAnnotationBinding.getAnnotationType(UnresolvedAnnotationBinding.java:41) at org.eclipse.jdt.core.dom.MethodBinding.filterTypeAnnotations(MethodBinding.java:227) at org.eclipse.jdt.core.dom.MethodBinding.getAnnotations(MethodBinding.java:116) I'm using Java 8 and the following dependencies <dependency> <groupId>org.eclipse.platform</groupId> <artifactId>org.eclipse.text</artifactId> <version>3.11.0</version> </dependency> <dependency> <groupId>org.eclipse.platform</groupId> <artifactId>org.eclipse.equinox.common</artifactId> <version>3.14.100</version> </dependency> <dependency> <groupId>org.eclipse.platform</groupId> <artifactId>org.eclipse.core.runtime</artifactId> <version>3.20.100</version> </dependency> <dependency> <groupId>org.eclipse.platform</groupId> <artifactId>org.eclipse.core.resources</artifactId> <version>3.14.0</version> </dependency>
I can also confirm the issue remains in org.eclipse.jdt.core version 3.26.0 using JDK 11 <dependency> <groupId>org.eclipse.jdt</groupId> <artifactId>org.eclipse.jdt.core</artifactId> <version>3.26.0</version> </dependency>