Bug 196354 - ClassCastException in package binding
Summary: ClassCastException in package binding
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.3.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-12 13:41 EDT by Kelvin CLA
Modified: 2008-09-16 09:46 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (2.06 KB, patch)
2007-07-16 16:58 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression test (2.23 KB, patch)
2007-07-16 16:59 EDT, 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 Kelvin CLA 2007-07-12 13:41:42 EDT
Build ID: 200606281455

Steps To Reproduce:
1. create a java project
2. create a package name "Sample"
3. create a class name "Sample.java"
4. create an AST tree using eclipse parser
5. you will get ClassCastException when you call PackageDeclaration.resolveBinding()


More information:
Comment 1 Olivier Thomann CLA 2007-07-16 16:32:47 EDT
Would it be possible for you to attach the stack trace, please?
Comment 2 Olivier Thomann CLA 2007-07-16 16:37:09 EDT
This is the one I got using 3.3.
java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.PackageBinding
	at org.eclipse.jdt.core.dom.DefaultBindingResolver.resolvePackage(DefaultBindingResolver.java:1330)
	at org.eclipse.jdt.core.dom.PackageDeclaration.resolveBinding(PackageDeclaration.java:340)
	at org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2.test0681(ASTConverterTestAST3_2.java:9353)
	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 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: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: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:504)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1144)

Do you get the same ?
Comment 3 Olivier Thomann CLA 2007-07-16 16:58:34 EDT
Created attachment 73902 [details]
Proposed fix
Comment 4 Olivier Thomann CLA 2007-07-16 16:59:17 EDT
Created attachment 73903 [details]
Regression test
Comment 5 Olivier Thomann CLA 2007-07-16 17:01:22 EDT
Released for 3.4M1.
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#test0681.

Jérôme,

We might want to backport to 3.3.1 since there is an exception thrown and there is no risk fixing it.
Comment 6 Frederic Fusier CLA 2007-08-07 07:11:15 EDT
Test verified for 3.4M1 using build I20070806-1800.
Comment 7 Jerome Lanneluc CLA 2007-08-09 10:35:21 EDT
+1 for backporting to 3.3.1
Comment 8 Olivier Thomann CLA 2007-08-13 14:53:34 EDT
Released for 3.3.1.
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#test0678
Comment 9 Olivier Thomann CLA 2007-08-13 14:54:02 EDT
Reopen for 3.3.1 verification.
Comment 10 Olivier Thomann CLA 2007-08-13 14:54:20 EDT
Released for 3.3.1
Comment 11 Eric Jodet CLA 2007-09-03 10:32:53 EDT
Test verified for 3.3.1 using build M20070831-2000