Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 449846

Summary: [jdt] NPE in PackageExplorerContentProvider.getPackageFragmentRoots
Product: [Eclipse Project] JDT Reporter: EPP Error Reports <error-reports-inbox>
Component: CoreAssignee: Jay Arthanareeswaran <jarthana>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, marcel.bruch, noopur_gupta, psoujany
Version: 4.4.1   
Target Milestone: 4.7 M5   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/87215
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=a816d34b91b0e7949e1a4269cc46805fc0abc45d
Whiteboard:

Description EPP Error Reports CLA 2014-11-03 16:09:11 EST
Hello committers,

we received a new error report for Eclipse 4.4.1.M20140925-0400.


General Information:
    anonymous-id:         7431d31e-7058-4e40-89b0-644cd93252e5
    eclipse-build-id:     4.4.1.M20140925-0400
    eclipse-product:      org.eclipse.epp.package.jee.product
    operating system:     Linux 3.2.0 (x86_64) - gtk
    java-runtime-version: 1.8.0_25-b17

The following plug-ins were present on the execution stack (*):
    1. org.eclipse.core.databinding.observable_1.4.1.v20140210-1835
    2. org.eclipse.core.databinding_1.4.2.v20140729-1044
    3. org.eclipse.core.runtime_3.10.0.v20140318-2214
    4. org.eclipse.e4.ui.workbench_1.2.1.v20140901-1244
    5. org.eclipse.e4.ui.workbench.swt_0.12.100.v20140530-1436
    6. org.eclipse.equinox.app_1.3.200.v20130910-1609
    7. org.eclipse.equinox.launcher_1.3.0.v20140415-2008
    8. org.eclipse.jdt.ui_3.10.1.v20140817-1500
    9. org.eclipse.jdt_3.10.0.v20140925-0400
    10. org.eclipse.jface_3.10.1.v20140813-1009
    11. org.eclipse.swt_3.103.1.v20140903-1938
    12. org.eclipse.ui_3.106.0.v20140812-1751
    13. org.eclipse.ui.ide.application_1.0.500.v20140514-2033
    14. org.eclipse.ui.ide_3.10.1.v20140828-0944


Error Status:

    code:                   4
    plugin:                 org.eclipse.ui_3.106.0.v20140812-1751
    message:                An internal error has occurred.
    fingerprint:            aedd286c
    exception class:        java.lang.NullPointerException
    exception message:      -
    number of children:     0
    
    java.lang.NullPointerException: null
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.getPackageFragmentRoots(PackageExplorerContentProvider.java:365)
    at org.eclipse.jdt.ui.StandardJavaElementContentProvider.getChildren(StandardJavaElementContentProvider.java:183)
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.getChildren(PackageExplorerContentProvider.java:307)
    at org.eclipse.jface.viewers.AbstractTreeViewer.getRawChildren(AbstractTreeViewer.java:1372)
    at org.eclipse.jface.viewers.TreeViewer.getRawChildren(TreeViewer.java:353)
    at org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer.getFilteredChildren(ProblemTreeViewer.java:274)
    at org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildren(AbstractTreeViewer.java:617)
    at org.eclipse.jface.viewers.AbstractTreeViewer.updateChildren(AbstractTreeViewer.java:2649)
    at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefreshStruct(AbstractTreeViewer.java:1918)
    at org.eclipse.jface.viewers.TreeViewer.internalRefreshStruct(TreeViewer.java:684)
    at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefreshStruct(AbstractTreeViewer.java:1925)
    at org.eclipse.jface.viewers.TreeViewer.internalRefreshStruct(TreeViewer.java:684)
    at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefresh(AbstractTreeViewer.java:1893)
    at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefresh(AbstractTreeViewer.java:1850)
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$PackageExplorerProblemTreeViewer.internalRefresh(PackageExplorerPart.java:258)
    at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefresh(AbstractTreeViewer.java:1836)
    at org.eclipse.jface.viewers.StructuredViewer$7.run(StructuredViewer.java:1500)
    at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1436)
    at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:366)
    at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1397)
    at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1497)
    at org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:521)
    at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1456)
    at HIDDEN.HIDDEN(HIDDEN:-1)
    at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:97)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3774)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3412)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
   

    

Messages, stacktraces, and nested status objects may be shortened. Please visit 
http://dev.eclipse.org/recommenders/committers/confess/0.5/reports/-
for the complete error log.


Some general information and guidelines about how to use this bug report:

1. Feel free to move this bug to your own product and components. Please note
   that this bug is only accessible to Eclipse committers. If you move this bug
   please make sure that it's still in the "Security Advisor" group.

2. The bug contents of the fields status, resolution, keywords, and whitelist
   are presented to reporters. If you needs more information, please set the
   keyword "needinfo". This will trigger a specialized dialog asking the user
   to provide further details.

3. Use the following resolutions for the following situations:
   * CLOSED / FIXED: This bug has been fixed. Please provide additional
     information in the whiteboard field.
   * CLOSED / WORKSFORME: Use this resolution if you can't reproduce this issue
     and request further information. Please use the whiteboard text to specify
     more details what a user should provide and how.
   * CLOSED / INVALID: Use this resolution if the reported problem is a
     'user-configuration' problem. Please consider giving hints how to fix
     these issues in the whiteboard field.
   * CLOSED / NOT ECLIPSE: Use this if the problem is caused by another plugin
     not developed at Eclipse.org
   * CLOSED / MOVED: If this bug has been moved else where. Please provide more 
     information (e.g. a link) in the whiteboard field.

4. Please remember that only committers can view and comment on this bug. You
   may, however, manually add the reporting user to the bug's cc list. But keep
   in mind that the report may contains sensitive information.

5. If you are missing a feature, please file a enhancement request here:
   https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Recommenders.Incubator&component=Stacktraces
    
 

Thank you for your assistance.
Your friendly error-reports-inbox.


--
* Note: The list of present bundles and their respective versions was
  calculated by package naming heuristics. This may or may not reflect reality.
Comment 1 EPP Error Reports CLA 2014-11-03 16:09:12 EST
I've looked up the (to date) top-3 most similar bug groups and listed the 
closest bug of each group below. This report may or may not be duplicate of
those (low or similar scores for all entries may indicate that this hasn't
been reported yet):

>     1. Bug 446303: Resource '/f' is not open. (err_grp: aa418018) – 0,7    
>     2. Bug 447360: [ltk] Problems occurred when invoking code from plug-in: "org.eclipse.ui.navigator". – 0,7    
>     3. Bug 448554: [wtp] Problems occurred when invoking code from plug-in: "org.eclipse.ui.navigator". – 0,6    


If this report actually is a duplicate of those, please mark it as such. This
information helps me to improve the recommendations further for the next issue.

Thank you for your assistance.
Your friendly error-reports-inbox.
Comment 2 Marcel Bruch CLA 2014-11-05 01:17:19 EST
Moving to JDT for review.

The code in question is:

Object[] resources= project.getNonJavaResources();
NPE >> for (int i= 0; i < resources.length; i++) {
   ...
}


which makes me think that project.getNonJavaResources() returned null instead of an empty array. Looks suspicious to me.
Comment 3 Noopur Gupta CLA 2014-11-06 01:44:49 EST
(In reply to Marcel Bruch from comment #2)
> Moving to JDT for review.
> 
> The code in question is:
> 
> Object[] resources= project.getNonJavaResources();
> NPE >> for (int i= 0; i < resources.length; i++) {
>    ...
> }
> 
> 
> which makes me think that project.getNonJavaResources() returned null
> instead of an empty array. Looks suspicious to me.

Moving to JDT/Core for comments. See also bug 162104.
Comment 4 pasam soujanya CLA 2016-12-15 02:42:32 EST
Similar NullPointerException is seen with various jdt testcases like debug,ui,text,uirefactoring with IBM SDK with the below java version.

Version:
java version "1.8.0"
Java(TM) SE Runtime Environment (build pxa6480sr5-20161213_01(SR5))
IBM J9 VM (build 2.9, JRE 1.8.0 Linux amd64-64 Compressed References 20161212_329466 (JIT enabled, AOT enabled)
J9VM - abd22009
JIT  - tr.open_20161209_129106_9e895d82.green
OMR   - e6bf93b)
JCL - 20161209_01 based on Oracle jdk8u121-b12

Exception Trace:
ECL (eclipse) java.lang.NullPointerException
ECL 	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.parseStatements(MethodDeclaration.java:194)
ECL 	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.parseMethods(TypeDeclaration.java:874)
ECL 	at org.eclipse.jdt.internal.compiler.parser.Parser.getMethodBodies(Parser.java:10150)
ECL 	at org.eclipse.jdt.internal.compiler.SourceElementParser.parseCompilationUnit(SourceElementParser.java:964)
ECL 	at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:197)
ECL 	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:259)
ECL 	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:579)
ECL 	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:316)
ECL 	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:302)
ECL 	at org.eclipse.jdt.internal.core.JavaElement.getChildren(JavaElement.java:257)
ECL 	at org.eclipse.jdt.internal.core.JavaElement.getChildrenOfType(JavaElement.java:271)
ECL 	at org.eclipse.jdt.internal.core.CompilationUnit.getTypes(CompilationUnit.java:923)
ECL 	at org.eclipse.jdt.internal.core.NameLookup.<init>(NameLookup.java:188)
ECL 	at org.eclipse.jdt.internal.core.JavaProjectElementInfo.newNameLookup(JavaProjectElementInfo.java:347)
ECL 	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2329)
ECL 	at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.java:2339)
ECL 	at org.eclipse.jdt.internal.core.JavaProject.findType(JavaProject.java:1357)
ECL 	at org.eclipse.jdt.internal.core.JavaProject.findType(JavaProject.java:1264)
ECL 	at org.eclipse.jdt.debug.tests.AbstractDebugTest.getType(AbstractDebugTest.java:1889)
ECL 	at org.eclipse.jdt.debug.tests.AbstractDebugTest.createLineBreakpoint(AbstractDebugTest.java:1496)
ECL 	at org.eclipse.jdt.debug.tests.eval.GenericsEvalTests.testEvalGeneric10(GenericsEvalTests.java:203)
ECL 	at org.eclipse.jdt.debug.tests.AbstractDebugTest.runBare(AbstractDebugTest.java:2466)
ECL 	at org.eclipse.jdt.debug.tests.DebugSuite$1.run(DebugSuite.java:57)
ECL 	at java.lang.Thread.run(Thread.java:787)
ECL 

Please confirm if different bugs needs to be raised.
Comment 5 Jay Arthanareeswaran CLA 2016-12-15 03:11:50 EST
(In reply to pasam soujanya from comment #4)
> Please confirm if different bugs needs to be raised.

Yes, please. These are errors on the compiler ast itself, bit deeper than the ones reported in comment #0.
Comment 6 Jay Arthanareeswaran CLA 2016-12-15 05:17:57 EST
Looking at the code, the only possibility I see is a race condition in any of the getNonJavaResources() implementation. Looks like some versions (e.g., PackageFragmentRootInfo) already knew of this issue and employ a temporary variable to work around this. I think we should apply the same to other places as well.
Comment 7 Eclipse Genie CLA 2016-12-15 06:03:55 EST
New Gerrit change created: https://git.eclipse.org/r/87215
Comment 9 Jay Arthanareeswaran CLA 2016-12-15 08:57:00 EST
The fix has been released for M5.
Comment 10 Sasikanth Bharadwaj CLA 2017-01-24 03:42:45 EST
Verified for 4.7 M5 using I20170123-2000 build (by inspection)