Bug 559851 - ProblemReporter.deprecatedSinceValue(...) throws NullPointerException
Summary: ProblemReporter.deprecatedSinceValue(...) throws NullPointerException
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.15   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-04 17:20 EST by Ivan Ivan CLA
Modified: 2023-05-19 17:56 EDT (History)
2 users (show)

See Also:


Attachments
Test case (12.77 KB, application/zip)
2020-02-04 17:20 EST, Ivan Ivan CLA
no flags Details
Stacktrace in .metadata/.log (24.19 KB, text/x-log)
2021-05-10 04:51 EDT, David Matějček CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Ivan CLA 2020-02-04 17:20:10 EST
Created attachment 281710 [details]
Test case

Hi, exception is thrown 
Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.deprecatedSinceValue(ProblemReporter.java:1925)
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.deprecatedType(ProblemReporter.java:1884)
	at org.eclipse.jdt.internal.compiler.problem.ProblemReporter.deprecatedType(ProblemReporter.java:1870)
	at org.eclipse.jdt.internal.compiler.lookup.BlockScope.getBinding(BlockScope.java:548)
	at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.resolveType(QualifiedNameReference.java:1025)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:691)
	at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1066)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:641)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:316)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:551)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1293)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1418)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:666)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:901)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1044)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:662)
	at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1013)

Use "Dependent jar" and "Use it to creates ast" from bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=559849
Comment 1 Stephan Herrmann CLA 2020-02-04 17:45:54 EST
To correlate line numbers in the stack: which exact version of Eclipse? JDT?
Comment 2 Ivan Ivan CLA 2020-02-04 17:48:34 EST
org.eclipse.jdt.core-3.20.100

Or the exception happens on lines 
String deprecatedSinceValue(Supplier<AnnotationBinding[]> annotations) {
	if (this.options != null && this.options.complianceLevel >= ClassFileConstants.JDK9) {
		ReferenceContext contextSave = this.referenceContext;
		try {
			for (AnnotationBinding annotationBinding : annotations.get()) {
				if (annotationBinding.getAnnotationType().id == TypeIds.T_JavaLangDeprecated) { // <<<
Comment 3 Stephan Herrmann CLA 2020-02-04 17:55:49 EST
(In reply to Sergey Toshin from comment #2)
> org.eclipse.jdt.core-3.20.100

Mh, so that's some build between 2019-12-14 and 2020-01-05 :)

> Or the exception happens on lines 
> String deprecatedSinceValue(Supplier<AnnotationBinding[]> annotations) {
> 	if (this.options != null && this.options.complianceLevel >=
> ClassFileConstants.JDK9) {
> 		ReferenceContext contextSave = this.referenceContext;
> 		try {
> 			for (AnnotationBinding annotationBinding : annotations.get()) {
> 				if (annotationBinding.getAnnotationType().id ==
> TypeIds.T_JavaLangDeprecated) { // <<<

Thanks, so without running your test case this looks like your deprecated element has an annotation that cannot be resolved, could that be?
Comment 4 Ivan Ivan CLA 2020-02-04 17:57:55 EST
This is a decompiled Java source, I cannot say exactly :) But because of this error I cannot get ASTs for the rest of files :(
Comment 5 Stephan Herrmann CLA 2020-05-18 18:59:01 EDT
Let's keep this on our radar, no promise implied ...
Comment 6 Ivan Ivan CLA 2020-10-29 20:13:02 EDT
Hey, any changes regarding this bug?
Comment 7 David Matějček CLA 2021-05-10 04:51:12 EDT
Created attachment 286345 [details]
Stacktrace in .metadata/.log

I tried to change JDK from 11 to 13, nothing changed. No success also with other experiments. Even when I removed all deprecated annotations from the file, the NPE was thrown again, which is really suspicious behavior.

I seems that the NPE is related to some dependency of this class (some class implementing this interface, or some class using class implementing this interface?).

But ... NPE is always an error, especially without a message.

Caused by: java.lang.NullPointerException
at ....ProblemReporter.deprecatedSinceValue(ProblemReporter.java:1961)
Comment 8 David Matějček CLA 2021-05-10 04:54:36 EDT
Switching project's compiler from JDK11/JDK13 to JDK8 works as a workaround. But it is not a solution for projects using newer features.
Comment 9 Eclipse Genie CLA 2023-05-19 17:56:52 EDT
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.