Bug 215858 - [AST/DOM] CCE when using ASTParser.setFocalPosition(int) with the position of a field declaration name
Summary: [AST/DOM] CCE when using ASTParser.setFocalPosition(int) with the position of...
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.3.2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-18 15:49 EST by Olivier Thomann CLA
Modified: 2008-02-04 12:38 EST (History)
3 users (show)

See Also:
philippe_mulet: pmc_approved+


Attachments
Proposed fix + regression test (3.66 KB, patch)
2008-01-18 15:52 EST, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression test for 3.3.x maintenance stream (3.41 KB, patch)
2008-01-22 15:11 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2008-01-18 15:49:45 EST
Using HEAD, I got:
java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.ast.FieldDeclaration cannot be cast to org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.parse(CompilationUnitResolver.java:430)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:887)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:653)
	at org.eclipse.jdt.core.tests.dom.ConverterTestSetup.runConversion(ConverterTestSetup.java:452)
	at org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0688(ASTConverterTestAST3_2.java:9567)
	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:100)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite.superRun(SuiteOfTestCases.java:84)
	at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$1.protect(SuiteOfTestCases.java:72)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at org.eclipse.jdt.core.tests.model.SuiteOfTestCases$Suite.run(SuiteOfTestCases.java:81)
	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:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	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:547)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195)
	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:362)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
	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:564)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1227)

when trying to create a compilation unit declaration using setFocalPosition(int) where the focal position is the position of a field name.
Comment 1 Olivier Thomann CLA 2008-01-18 15:50:11 EST
I'll fix it since I need it for api tooling.
Comment 2 Olivier Thomann CLA 2008-01-18 15:51:59 EST
Jérôme,

you might want to backport to 3.3.2 since this throws an exception and there is no workaround for the position that corresponds to a field name.
The fix is trivial and risk free.
Comment 3 Olivier Thomann CLA 2008-01-18 15:52:35 EST
Created attachment 87297 [details]
Proposed fix + regression test
Comment 4 Olivier Thomann CLA 2008-01-18 15:53:32 EST
Fixed and released for 3.4M5.
Regression test added in:
org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#test0688
Comment 5 Philipe Mulet CLA 2008-01-22 13:14:15 EST
+1 for 3.3.2. It looks bad, fix is trivial, and we need to reopen the box to contribute fix for bug 215843... so let's take it as well.
Comment 6 Olivier Thomann CLA 2008-01-22 15:10:52 EST
Reopen to release for 3.3.2.
Comment 7 Olivier Thomann CLA 2008-01-22 15:11:26 EST
Created attachment 87552 [details]
Proposed fix + regression test for 3.3.x maintenance stream
Comment 8 Jerome Lanneluc CLA 2008-01-22 17:17:04 EST
Agreed to backport to 3.3.2 since:
- there is no workaround
- the exception is bad
- the fix is simple
- the fix is safe
Comment 9 Jerome Lanneluc CLA 2008-01-23 06:15:09 EST
Marking FIXED since it was already released for 3.3.2
Comment 10 Maxime Daniel CLA 2008-01-24 07:29:22 EST
Verified for 3.3.2 using M20080123-0800 build.
Comment 11 Jerome Lanneluc CLA 2008-02-04 12:38:48 EST
Verified for 3.4M5 using I20080204-0010