Bug 216894 - [DOM] Suspicious NPE in .log entry during DOM tests: BatchASTCreationTests.test070
Summary: [DOM] Suspicious NPE in .log entry during DOM tests: BatchASTCreationTests.te...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-29 07:23 EST by Philipe Mulet CLA
Modified: 2011-07-20 14:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2008-01-29 07:23:28 EST
With 3.3.2 RC2 codebase:

Noticed the following entry in the .log while running all JDTCore tests:

!ENTRY org.eclipse.jdt.core 4 4 2008-01-29 12:47:21.296
!MESSAGE Could not retrieve declared fields
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypeFor(SourceTypeBinding.java:1250)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(SourceTypeBinding.java:604)
	at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.availableFields(ReferenceBinding.java:167)
	at org.eclipse.jdt.core.dom.TypeBinding.getDeclaredFields(TypeBinding.java:237)
	at org.eclipse.jdt.core.tests.dom.BatchASTCreationTests.test070(BatchASTCreationTests.java:1624)
	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:597)
	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 junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	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:597)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethod(EclipseAppContainer.java:572)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:171)
	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:363)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
Comment 1 Philipe Mulet CLA 2008-01-29 07:24:16 EST
The test did not fail, but the NPE seems like a case where we cannot lazily resolve fields.
Comment 2 Olivier Thomann CLA 2008-07-14 11:56:56 EDT
I could not reproduce.
Comment 3 Olivier Thomann CLA 2008-07-16 11:31:56 EDT
Closing as WORKSFORME.
Please reopen if you get it again.
Comment 4 Kent Johnson CLA 2008-08-06 12:49:05 EDT
Verified for 3.5M1 using I20080805-1307
Comment 5 Stephan Herrmann CLA 2011-06-07 17:17:48 EDT
While running org.eclipse.jdt.core.tests.dom.RunAllTests in the IDE
I see this exact NPE (using HEAD as of 3.7.0 RC4).

The NPE isn't surprising but the way it is caught and logged might deserve
a second and third thought:

The NPE is caught in dom's TypeBinding.getDeclaredFields():

		} catch (RuntimeException e) {
			/* in case a method cannot be resolvable due to missing jars on the classpath
			 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871
			 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550
			 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299
			 */
			org.eclipse.jdt.internal.core.util.Util.log(e, "Could not retrieve declared fields"); //$NON-NLS-1$
		}
		return this.fields = NO_VARIABLE_BINDINGS;

The latter two of the mentioned bugs have the explanation: trying to
resolve fields after scope has been discarded.

Is it wrong usage to call getDeclaredFields() after the compiler may have
discarded scopes (how can the client tell?)?
If it is expected behavior (and returning NO_VARIABLE_BINDINGS is the
expected outcome), why is the exception logged?

Feel free to re-close but the behavior felt strange to me and seeing this
report as cannot reproduce didn't look too satisfactory, either :)
Comment 6 Olivier Thomann CLA 2011-07-20 14:23:20 EDT
Closing again. If this needs to be improved, it should be done in a separate bug report.
Comment 7 Olivier Thomann CLA 2011-07-20 14:23:36 EDT
Verified.