Bug 150289 - [hierarchy] NPE in hierarchy builder when region is empty
Summary: [hierarchy] NPE in hierarchy builder when region is empty
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.2   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 157769 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-07-11 13:52 EDT by Raj Mandayam CLA
Modified: 2007-01-16 03:57 EST (History)
4 users (show)

See Also:


Attachments
Proposed patch (1.47 KB, patch)
2006-08-01 13:05 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Raj Mandayam CLA 2006-07-11 13:52:32 EDT
Steps (I know it sounds convoluted)
1. Create a plugin project, choose eclipse version 3.0
2. Open plugin.xml, add the org.junit (3.8) as a dependency
3. Create a test case java class extending the junit base TestCase class, 
4. Export the plugin project with source using (File-Export-Plugin development-Deployable plugin ....), export as a directory
5. Delete the original plugin project from the workspace.
6. Now Import the (exported) plugin project as a binary project (File-Import-Plugin development-Plugins and fragments)
7. Now select the project in the workspace and Right click and 
   Run as->Junit plugin test
8. Get error in launching, there is an error in log


eclipse.buildId=I20060519-1206
java.version=1.5.0_06
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -showlocation
Command-line arguments:  -data D:\eclipse\...\workspace1 -showlocation

Error
Tue Jul 11 13:52:47 EDT 2006
An internal error occurred during: "Launching".

java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.<init>(HierarchyBuilder.java:80)
	at org.eclipse.jdt.internal.core.hierarchy.RegionBasedHierarchyBuilder.<init>(RegionBasedHierarchyBuilder.java:37)
	at org.eclipse.jdt.internal.core.hierarchy.RegionBasedTypeHierarchy.compute(RegionBasedTypeHierarchy.java:73)
	at org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1235)
	at org.eclipse.jdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:90)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:720)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:779)
	at org.eclipse.jdt.internal.core.JavaProject.newTypeHierarchy(JavaProject.java:2641)
	at org.eclipse.jdt.internal.core.JavaProject.newTypeHierarchy(JavaProject.java:2619)
	at org.eclipse.jdt.internal.junit.util.TestSearchEngine.findTestCases(TestSearchEngine.java:227)
	at org.eclipse.jdt.internal.junit.util.TestSearchEngine.collectTypes(TestSearchEngine.java:204)
	at org.eclipse.jdt.internal.junit.util.TestSearchEngine.doFindJUnit3Tests(TestSearchEngine.java:167)
	at org.eclipse.jdt.internal.junit.launcher.JUnit3TestFinder.findTestsInContainer(JUnit3TestFinder.java:32)
	at org.eclipse.jdt.internal.junit.launcher.ContainerTestSearchExtent.find(ContainerTestSearchExtent.java:42)
	at org.eclipse.jdt.internal.junit.launcher.TestKind.search(TestKind.java:107)
	at org.eclipse.jdt.internal.junit.launcher.TestKindRegistry.getTestTypes(TestKindRegistry.java:181)
	at org.eclipse.jdt.internal.junit.launcher.JUnitBaseLaunchConfiguration.findTestTypes(JUnitBaseLaunchConfiguration.java:126)
	at org.eclipse.pde.internal.ui.launcher.JUnitLaunchConfiguration.launch(JUnitLaunchConfiguration.java:83)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:639)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:565)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:754)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlugin.java:944)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)




Please note the steps I mentioned are a simplificaiton of our scenario where we had a plugin with junit test cases that we wanted to debug, so we imported it into our eclipse environment as a binary project (we did not have source at that time) and were trying to run it as a junit plugin.
Comment 1 Martin Aeschlimann CLA 2006-07-20 10:43:10 EDT
Reproduced in 3.2.

Two problems here:
 - IJavaProject.newTypeHierarchy(IType, IRegion, IProgressMonitor) throws a NPE if the passed IRegion is empty
 - The Junit launcher should not only look for tests in sources but also in direct archives (not from referenced projects).

Using this bug for the NPE. Filed bug 151246 for the JUnit issue.
Comment 2 Frederic Fusier CLA 2006-08-01 13:05:07 EDT
Created attachment 47161 [details]
Proposed patch

Null check on project in HierarchyBuilder constructor is enough to get dialog saying that no tests were found...
As bug 151246 won't be fixed, this workaround is perhaps enough to solve this problem...
Comment 3 Frederic Fusier CLA 2006-08-01 13:06:17 EDT
Wait for Jerome's review before applying fix...
Comment 4 Raj Mandayam CLA 2006-09-18 18:09:38 EDT
Any updates on fixing this defect for 3.2.1 
Comment 5 Frederic Fusier CLA 2006-09-19 01:38:37 EDT
(In reply to comment #4)
> Any updates on fixing this defect for 3.2.1 
> 
Sorry, I forgot to finalize this bug after vacations... However, if you wanted this bug fixed for 3.2.1, you should have let us know sooner... Unfortunately, 3.2.1 is now definitely frozen now and this bug will be addressed only in 3.2.2

Philippe, agree to target it for 3.2.2?
Comment 6 Philipe Mulet CLA 2006-09-19 03:37:26 EDT
+1 for 3.2.2
Comment 7 Jerome Lanneluc CLA 2006-09-19 05:44:32 EDT
Patch looks good.
Comment 8 Martin Aeschlimann CLA 2006-09-19 11:09:36 EDT
*** Bug 157769 has been marked as a duplicate of this bug. ***
Comment 9 Frederic Fusier CLA 2006-10-01 09:34:00 EDT
Released for 3.3 M3 in HEAD stream.

Test case added in TypeHierarchyTests#testRegion5_Bug150289().
Comment 10 Frederic Fusier CLA 2006-10-02 04:10:03 EDT
Released for 3.2.2 in R3_2_maintenance stream.
Comment 11 David Audel CLA 2007-01-15 07:19:48 EST
Verified for 3.2.2 using build M20070112-1200