Bug 553472 - NPE while resolving module javadoc
Summary: NPE while resolving module javadoc
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.14   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.14 RC1   Edit
Assignee: Jeff Johnston CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2019-11-26 05:08 EST by Stephan Herrmann CLA
Modified: 2019-11-28 00:13 EST (History)
4 users (show)

See Also:
manoj.palat: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2019-11-26 05:08:07 EST
(In reply to Stephan Herrmann from bug 553453 comment #2)
> Importing this project into build I20191120-1800 produces:
> 
> java.lang.NullPointerException
> 	at
> org.eclipse.jdt.internal.compiler.lookup.Scope.getDeclarationModifiers(Scope.
> java:2533)
> 	at
> org.eclipse.jdt.internal.compiler.ast.JavadocSingleTypeReference.
> reportInvalidType(JavadocSingleTypeReference.java:114)
> 	at
> org.eclipse.jdt.internal.compiler.ast.JavadocSingleTypeReference.
> internalResolveType(JavadocSingleTypeReference.java:94)
> 	at
> org.eclipse.jdt.internal.compiler.ast.TypeReference.
> resolveType(TypeReference.java:629)
> 	at
> org.eclipse.jdt.internal.compiler.ast.TypeReference.
> resolveType(TypeReference.java:625)
> 	at
> org.eclipse.jdt.internal.compiler.ast.TypeReference.
> resolveType(TypeReference.java:621)
> 	at
> org.eclipse.jdt.internal.compiler.ast.Javadoc.resolveReference(Javadoc.java:
> 403)
> 	at org.eclipse.jdt.internal.compiler.ast.Javadoc.resolve(Javadoc.java:293)
> 	at
> org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.
> resolve(CompilationUnitDeclaration.java:645)
> 	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1072)
> 	at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1114)
> 	at
> org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.
> process(CompilationUnitProblemFinder.java:280)
> 	at
> org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.
> process(CompilationUnitProblemFinder.java:346)
> 	at
> org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.
> makeConsistent(ReconcileWorkingCopyOperation.java:193)
> 	at
> org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.
> executeOperation(ReconcileWorkingCopyOperation.java:94)
> 	at
> org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:
> 736)
> 	at
> org.eclipse.jdt.internal.core.JavaModelOperation.
> runOperation(JavaModelOperation.java:802)
> 	at
> org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:
> 1315)
> 	at
> org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.
> reconcile(JavaReconcilingStrategy.java:131)
> 	at
> org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.
> access$0(JavaReconcilingStrategy.java:113)
> 	at
> org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.
> run(JavaReconcilingStrategy.java:93)
> 	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
> 	at
> org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.
> reconcile(JavaReconcilingStrategy.java:90)
> 	at
> org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.
> reconcile(JavaReconcilingStrategy.java:157)
> 	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:
> 76)
> 	at
> org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.
> run(AbstractReconciler.java:210)


NPE still happens in I20191125-1800 and is caused by the fix from bug 549855.

It is an unhappy consequence of using a MethodScope as moduleDeclaration.scope, which has no referenceContext.

I will have to check bug 517808 why it was introduced this way.

Short term solution (RC1?): let Scope.getDeclarationModifiers() check if referenceContext is null (what then?).

Mid term solution: introduce a new scope kind Scope.MODULE_SCOPE.
Comment 1 Stephan Herrmann CLA 2019-11-26 05:12:46 EST
@Jeff, do you have a minute to look at this?

The example project is  attachment 280776 [details]
Comment 2 Jeff Johnston CLA 2019-11-26 10:35:21 EST
(In reply to Stephan Herrmann from comment #1)
> @Jeff, do you have a minute to look at this?
> 
> The example project is  attachment 280776 [details]

Looking at it
Comment 3 Eclipse Genie CLA 2019-11-26 11:26:47 EST
New Gerrit change created: https://git.eclipse.org/r/153425
Comment 4 Jeff Johnston CLA 2019-11-26 11:33:44 EST
(In reply to Stephan Herrmann from comment #1)
> @Jeff, do you have a minute to look at this?
> 
> The example project is  attachment 280776 [details]

Hi Stephan, I have posted a patch that checks for a ModuleDeclaration in getDeclarationModifiers() and simply returns the ModuleDeclaration.modifiers.  It fixes the NPE.  For the sake of expediency I posted to have gerrit run the tests rather than my local set-up.  The CTRL+SHIFT+O removes the comments as it did in 4.13GA.
Comment 5 Stephan Herrmann CLA 2019-11-26 12:30:37 EST
(In reply to Jeff Johnston from comment #4)
> (In reply to Stephan Herrmann from comment #1)
> > @Jeff, do you have a minute to look at this?
> > 
> > The example project is  attachment 280776 [details]
> 
> Hi Stephan, I have posted a patch that checks for a ModuleDeclaration in
> getDeclarationModifiers() and simply returns the
> ModuleDeclaration.modifiers.  It fixes the NPE.  For the sake of expediency
> I posted to have gerrit run the tests rather than my local set-up.  The
> CTRL+SHIFT+O removes the comments as it did in 4.13GA.

Looks reasonable to me (at the given point in the cycle).

Can we please have a project lead's +1 for RC1?
Comment 6 Stephan Herrmann CLA 2019-11-26 17:29:37 EST
Please find my +2 in gerrit.
Comment 8 Vikas Chandra CLA 2019-11-28 00:12:48 EST
>>Mid term solution: introduce a new scope kind Scope.MODULE_SCOPE.
Created bug 553564
Comment 9 Vikas Chandra CLA 2019-11-28 00:13:02 EST
Thanks Jeff
Comment 10 Vikas Chandra CLA 2019-11-28 00:13:18 EST
Verified on
Version: 2019-12 (4.14)
Build id: I20191127-1800