Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370412 - ClassCastException in PackageUtil, when Package is contained in a component
Summary: ClassCastException in PackageUtil, when Package is contained in a component
Status: RESOLVED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 0.8.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Camille Letavernier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-02 04:45 EST by Marc-Florian Wendland CLA
Modified: 2012-02-06 10:31 EST (History)
0 users

See Also:
cletavernier: documentation-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-Florian Wendland CLA 2012-02-02 04:45:19 EST
Packages can be contained in uml::Components as well. When adding a PackageableElement to a Package, which is contained in a uml::Component, the following exception is thrown (the element is added to the package anyway):

!ENTRY org.eclipse.papyrus.properties 4 0 2012-02-02 10:36:07.099
!MESSAGE Unexpected Error
!STACK 0
java.lang.ClassCastException: org.eclipse.uml2.uml.internal.impl.ComponentImpl cannot be cast to org.eclipse.uml2.uml.Package
	at org.eclipse.papyrus.umlutils.PackageUtil.getRootPackage(PackageUtil.java:149)
	at org.eclipse.papyrus.umlutils.PackageUtil.getRootPackage(PackageUtil.java:137)
	at org.eclipse.papyrus.properties.uml.modelelement.UMLModelElement.getContentProvider(UMLModelElement.java:180)
	at org.eclipse.papyrus.properties.modelelement.DataSource.getContentProvider(DataSource.java:149)
	at org.eclipse.papyrus.properties.widgets.ReferenceDialog.doBinding(ReferenceDialog.java:53)
	at org.eclipse.papyrus.properties.widgets.AbstractPropertyEditor.checkInput(AbstractPropertyEditor.java:158)
	at org.eclipse.papyrus.properties.widgets.AbstractPropertyEditor.setProperty(AbstractPropertyEditor.java:234)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.e4.xwt.javabean.metadata.properties.BeanProperty.setValue(BeanProperty.java:91)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.initSegmentAttribute(ResourceLoader.java:1770)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.initAttribute(ResourceLoader.java:1525)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.init(ResourceLoader.java:1128)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:666)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:702)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:702)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.createUIElement(ResourceLoader.java:363)
	at org.eclipse.e4.xwt.internal.core.Core.createCLRElement(Core.java:625)
	at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:754)
	at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:655)
	at org.eclipse.e4.xwt.XWTLoader.loadWithOptions(XWTLoader.java:1072)
	at org.eclipse.e4.xwt.XWTLoader.load(XWTLoader.java:648)
	at org.eclipse.e4.xwt.XWT.load(XWT.java:463)
	at org.eclipse.papyrus.properties.runtime.DefaultDisplayEngine.createSection(DefaultDisplayEngine.java:182)
	at org.eclipse.papyrus.properties.runtime.DefaultDisplayEngine.createSection(DefaultDisplayEngine.java:143)
	at org.eclipse.papyrus.properties.xwt.XWTSection.display(XWTSection.java:151)
	at org.eclipse.papyrus.properties.xwt.XWTSection.refresh(XWTSection.java:161)
	at org.eclipse.ui.views.properties.tabbed.TabContents$6.run(TabContents.java:217)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.ui.views.properties.tabbed.TabContents.refresh(TabContents.java:220)
	at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage$SelectionChangedListener.selectionChanged(TabbedPropertySheetPage.java:222)
	at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:164)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:162)
	at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:2188)
	at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:1211)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:1241)
	at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:239)
	at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:233)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:403)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
	at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.select(TabbedPropertyList.java:664)
	at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyViewer.setSelectionToWidget(TabbedPropertyViewer.java:122)
	at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1767)
	at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1723)
	at org.eclipse.jface.viewers.Viewer.setSelection(Viewer.java:394)
	at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.setInput(TabbedPropertySheetPage.java:736)
	at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.selectionChanged(TabbedPropertySheetPage.java:555)
	at org.eclipse.ui.views.properties.PropertySheet.selectionChanged(PropertySheet.java:363)
	at org.eclipse.ui.internal.AbstractSelectionService.firePostSelection(AbstractSelectionService.java:179)
	at org.eclipse.ui.internal.AbstractSelectionService$2.selectionChanged(AbstractSelectionService.java:71)
	at org.eclipse.ui.part.PageBookView$5.run(PageBookView.java:255)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.runtime.Platform.run(Platform.java:888)
	at org.eclipse.ui.part.PageBookView$SelectionManager.selectionChanged(PageBookView.java:253)
	at org.eclipse.ui.part.PageBookView$SelectionProvider.postSelectionChanged(PageBookView.java:329)
	at org.eclipse.ui.part.PageBookView.postSelectionChanged(PageBookView.java:910)
	at org.eclipse.ui.part.PageBookView.access$3(PageBookView.java:905)
	at org.eclipse.ui.part.PageBookView$3.selectionChanged(PageBookView.java:172)
	at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.java:888)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(StructuredViewer.java:886)
	at org.eclipse.jface.viewers.StructuredViewer.handlePostSelect(StructuredViewer.java:1226)
	at org.eclipse.ui.navigator.CommonViewer.handlePostSelect(CommonViewer.java:470)
	at org.eclipse.jface.viewers.StructuredViewer$5.widgetSelected(StructuredViewer.java:1251)
	at org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent(OpenStrategy.java:262)
	at org.eclipse.jface.util.OpenStrategy.access$5(OpenStrategy.java:256)
	at org.eclipse.jface.util.OpenStrategy$3.run(OpenStrategy.java:433)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 1 Marc-Florian Wendland CLA 2012-02-02 04:47:01 EST
Solution would be to rather check for package.getNearestPackage() instead of checking the owner in PackageUtil.getRootPackage, line 145. Because in that particular situation, the owner is a Component not a Package
Comment 2 Camille Letavernier CLA 2012-02-06 10:31:53 EST
Fixed in r7139 (Branch 0.8.X)
Fixed in r7140 (Trunk 0.9)

We cannot rely on package#getNearestPackage, because it returns self for a Package.