Bug 183923 - [prefs] NPE in JavaProject#setOptions
Summary: [prefs] NPE in JavaProject#setOptions
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M2   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-25 01:42 EDT by Maxime Daniel CLA
Modified: 2007-09-18 04:39 EDT (History)
0 users

See Also:


Attachments
Proposed patch (61.51 KB, patch)
2007-08-20 04:42 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 Maxime Daniel CLA 2007-04-25 01:42:11 EDT
Build I20070418-1012, circa v_750.

Add the following method to org.eclipse.jdt.core.tests.model.JavaProjectTests and run: it raises the following NPE:
java.lang.NullPointerException
	at org.eclipse.jdt.internal.core.JavaProject.setOptions(JavaProject.java:2705)
	at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.setUpProjectCompliance(AbstractJavaModelTests.java:2197)
	at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.setUpJavaProject(AbstractJavaModelTests.java:2152)
	at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.setUpJavaProject(AbstractJavaModelTests.java:2130)
	at org.eclipse.jdt.core.tests.model.JavaProjectTests.testInvalidProject(JavaProjectTests.java:552)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite.runTest(SuiteOfTestCases.java:99)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite.superRun(SuiteOfTestCases.java:83)
	at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$1.protect(SuiteOfTestCases.java:71)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite.run(SuiteOfTestCases.java:80)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:58)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:24)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethod(EclipseAppContainer.java:533)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:155)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:359)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:174)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:475)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:415)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1140)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1115)

While there may be a problem with the test harness itself, I believe that JavaProject#getEclipsePreferences should state it can return null, and JavaProject#setOptions should protect against it.
Comment 1 Maxime Daniel CLA 2007-04-25 04:56:13 EDT
Sorry, forgot the test case code:
public void testInvalidProject() throws CoreException, IOException {
	try {
		setUpJavaProject("JavaProjectTestsInvalidProject");
	} finally {
		deleteProject("JavaProjectTestsInvalidProject");
	}
}
Comment 2 Frederic Fusier CLA 2007-08-20 04:42:16 EDT
Created attachment 76429 [details]
Proposed patch
Comment 3 Frederic Fusier CLA 2007-08-20 06:10:48 EDT
Comment on attachment 76429 [details]
Proposed patch

Patch attached to bug 152562 also includes the fix for this bug.
Comment 4 Frederic Fusier CLA 2007-08-20 10:58:41 EDT
Released for 3.4M2 in HEAD stream.
Comment 5 Eric Jodet CLA 2007-09-18 04:32:50 EDT
Verified for 3.4 M2 using build I20070917-0010.