Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 251612

Summary: backward compatibility and dependency on com.ibm.icu
Product: [Tools] GEF Reporter: Eugene Kuleshov <ekuleshov>
Component: GEF-Legacy Draw2dAssignee: Anthony Hunter <ahunter.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse, libinv, weisz
Version: unspecified   
Target Milestone: 3.5.0 (Galileo) M5   
Hardware: All   
OS: All   
Whiteboard:

Description Eugene Kuleshov CLA 2008-10-21 16:22:59 EDT
There is a stack trace below caused by using draw2d that came from Eclipse 3.4.1/Ganymede update site with Eclipse 3.3. 

The problem is that draw2d bundle declares dependency on com.ibm.icu bundle using the following declaration:

  Import-Package: com.ibm.icu.text

So, there is no version specified and yet recent draw2d requires com.ibm.icu version 3.8.1 or something like that.
Because draw2d is not part of the Eclipse Platform it would be great to restore compatibility with older com.ibm.icu versions to simplify deployment for older Eclipse releases (e.g. draw2d needto be installed along with Zest if someone need to use Zest with Eclipse 3.3).

java.lang.NoClassDefFoundError: com/ibm/icu/text/Bidi
	at org.eclipse.draw2d.text.BidiProcessor.process(BidiProcessor.java:190)
	at org.eclipse.draw2d.text.BlockFlow.validate(BlockFlow.java:297)
	at org.eclipse.draw2d.text.FlowPage.validate(FlowPage.java:149)
	at org.eclipse.draw2d.text.FlowPage.getPreferredSize(FlowPage.java:86)
	at org.eclipse.draw2d.text.FlowPage.getMinimumSize(FlowPage.java:56)
	at org.eclipse.draw2d.BorderLayout.calculateMinimumSize(BorderLayout.java:94)
	at org.eclipse.draw2d.AbstractHintLayout.getMinimumSize(AbstractHintLayout.java:68)
	at org.eclipse.draw2d.Figure.getMinimumSize(Figure.java:707)
	at org.eclipse.draw2d.StackLayout.calculateMinimumSize(StackLayout.java:44)
	at org.eclipse.draw2d.AbstractHintLayout.getMinimumSize(AbstractHintLayout.java:68)
	at org.eclipse.draw2d.Figure.getMinimumSize(Figure.java:707)
	at org.eclipse.draw2d.ToolbarLayout.getChildMinimumSize(ToolbarLayout.java:195)
	at org.eclipse.draw2d.ToolbarLayout.calculateChildrenSize(ToolbarLayout.java:96)
	at org.eclipse.draw2d.ToolbarLayout.calculateMinimumSize(ToolbarLayout.java:131)
	at org.eclipse.draw2d.AbstractHintLayout.getMinimumSize(AbstractHintLayout.java:68)
	at org.eclipse.draw2d.Figure.getMinimumSize(Figure.java:707)
	at org.eclipse.draw2d.ViewportLayout.calculatePreferredSize(ViewportLayout.java:65)
	at org.eclipse.draw2d.AbstractLayout.getPreferredSize(AbstractLayout.java:93)
	at org.eclipse.draw2d.AbstractHintLayout.getPreferredSize(AbstractHintLayout.java:85)
	at org.eclipse.draw2d.Figure.getPreferredSize(Figure.java:735)
	at org.eclipse.gef.internal.ui.palette.editparts.OverlayScrollPaneLayout.calculatePreferredSize(OverlayScrollPaneLayout.java:41)
	at org.eclipse.draw2d.AbstractLayout.getPreferredSize(AbstractLayout.java:93)
	at org.eclipse.draw2d.AbstractHintLayout.getPreferredSize(AbstractHintLayout.java:85)
	at org.eclipse.draw2d.Figure.getPreferredSize(Figure.java:735)
	at org.eclipse.draw2d.ToolbarLayout.getChildPreferredSize(ToolbarLayout.java:206)
	at org.eclipse.draw2d.ToolbarLayout.calculateChildrenSize(ToolbarLayout.java:95)
	at org.eclipse.draw2d.ToolbarLayout.calculatePreferredSize(ToolbarLayout.java:173)
	at org.eclipse.draw2d.AbstractLayout.getPreferredSize(AbstractLayout.java:93)
	at org.eclipse.draw2d.AbstractHintLayout.getPreferredSize(AbstractHintLayout.java:85)
	at org.eclipse.draw2d.Figure.getPreferredSize(Figure.java:735)
	at org.eclipse.gef.internal.ui.palette.editparts.PaletteAnimator.autoCollapse(PaletteAnimator.java:67)
	at org.eclipse.gef.internal.ui.palette.editparts.PaletteAnimator.init(PaletteAnimator.java:99)
	at org.eclipse.draw2d.Animation.hookAnimator(Animation.java:177)
	at org.eclipse.draw2d.LayoutAnimator.invalidate(LayoutAnimator.java:83)
	at org.eclipse.draw2d.Figure$LayoutNotifier.invalidate(Figure.java:1800)
	at org.eclipse.draw2d.Figure.invalidate(Figure.java:917)
	at org.eclipse.draw2d.Figure.revalidate(Figure.java:1347)
	at org.eclipse.draw2d.Figure.add(Figure.java:158)
	at org.eclipse.draw2d.Figure.add(Figure.java:171)
	at org.eclipse.gef.internal.ui.palette.editparts.DrawerFigure.handleExpandStateChanged(DrawerFigure.java:331)
	at org.eclipse.gef.internal.ui.palette.editparts.DrawerFigure$3.handleStateChanged(DrawerFigure.java:163)
	at org.eclipse.draw2d.Clickable.fireStateChanged(Clickable.java:215)
	at org.eclipse.draw2d.Clickable$1.handleStateChanged(Clickable.java:175)
	at org.eclipse.draw2d.ButtonModel.fireStateChanged(ButtonModel.java:199)
	at org.eclipse.draw2d.ButtonModel.setSelected(ButtonModel.java:470)
	at org.eclipse.draw2d.ToggleModel.fireActionPerformed(ToggleModel.java:27)
	at org.eclipse.draw2d.ButtonModel$DefaultFiringBehavior.released(ButtonModel.java:487)
	at org.eclipse.draw2d.ButtonModel.fireReleased(ButtonModel.java:172)
	at org.eclipse.draw2d.ButtonModel.setPressed(ButtonModel.java:447)
	at org.eclipse.draw2d.ClickableEventHandler.mouseReleased(ClickableEventHandler.java:96)
	at org.eclipse.draw2d.Figure.handleMouseReleased(Figure.java:883)
	at org.eclipse.draw2d.SWTEventDispatcher.dispatchMouseReleased(SWTEventDispatcher.java:239)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:368)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:538)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:206)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
	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(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:508)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
Comment 1 Libin Varghese CLA 2008-12-02 02:07:50 EST
Is there a work around?

Can I manually change this dependency using PDE? ( Any pointers )
Comment 2 Anthony Hunter CLA 2008-12-03 10:21:06 EST
This issue is discussed in Bug 214900 and Bug 134789 .

GEF does not directly reference a specific version of icu4j and we expect that GEF is using the same icu4j that is shipped with the Eclipse platform.

Note as well that GEF 3.4.1 is not supported on version 3.3 of the Eclipse platform. 
Comment 3 Anthony Hunter CLA 2008-12-03 10:23:05 EST
GEF 3.4.1 is not supported on version 3.3 of the Eclipse platform since it requires com.ibm.icu version 3.8.1 included in the Eclipse 3.4 release.
Comment 4 Eugene Kuleshov CLA 2008-12-03 10:25:41 EST
I don't understand last comment about GEF. The issue reported is about dependency from draw2d and zest to a recent version of icu4j without specifying version of that dependency. Please specify version of required icu4j explicitly.
Comment 5 Anthony Hunter CLA 2008-12-03 11:16:30 EST
What version(s) of icu4j do you have in your configuration?

Are you using Eclipse 3.4?
Comment 6 Eugene Kuleshov CLA 2008-12-03 11:21:51 EST
(In reply to comment #5)
> What version(s) of icu4j do you have in your configuration?
> Are you using Eclipse 3.4?

Anthony, I am not, but users of our tools have no choice but to use draw2d from Eclipse 3.4 update sites even for Eclipse 3.3. From what I see all it would take to fix the issue is to add proper version declaration on packages or bundles required by draw2d plugin. So, resolver would pickup the right versions.
Comment 7 Anthony Hunter CLA 2008-12-03 11:47:45 EST
(In reply to comment #6)
> 
> Anthony, I am not, but users of our tools have no choice but to use draw2d from
> Eclipse 3.4 update sites even for Eclipse 3.3. From what I see all it would
> take to fix the issue is to add proper version declaration on packages or
> bundles required by draw2d plugin. So, resolver would pickup the right
> versions.
> 

If you have Eclipse 3.3, you cannot get Draw2D 3.3 from any update sites? This is the bug then right?
Comment 8 Eugene Kuleshov CLA 2008-12-03 12:02:20 EST
(In reply to comment #7)
> If you have Eclipse 3.3, you cannot get Draw2D 3.3 from any update sites? This
> is the bug then right?

Sorry, I don't understand the question. Judging from the draw2d plugin version it supposed to be backward compatible with the previous versions, so as icu4j plugin is backward compatible from the API point of view. However draw2d does not declare dependencies properly and making some implicit assumptions on what version of icu4j will be available at runtime, so its requirements can be matched incorrectly because of that (hence the stack trace above). Is it a problem to specify required version of dependencies?
Comment 9 Anthony Hunter CLA 2008-12-03 12:55:44 EST
(In reply to comment #8)
> (In reply to comment #7)
> > If you have Eclipse 3.3, you cannot get Draw2D 3.3 from any update sites? This
> > is the bug then right?
> 
> Sorry, I don't understand the question. Judging from the draw2d plugin version
> it supposed to be backward compatible with the previous versions, so as icu4j
> plugin is backward compatible from the API point of view. However draw2d does
> not declare dependencies properly and making some implicit assumptions on what
> version of icu4j will be available at runtime, so its requirements can be
> matched incorrectly because of that (hence the stack trace above). Is it a
> problem to specify required version of dependencies?
> 

Yes, Bug 134789 says that we cannot Require-Bundle, we must Import-Package . And import package does not have a version dependency.

I will investigate further with the platform team.
Comment 10 Robert Weisz CLA 2008-12-12 11:43:14 EST
Not sure I understand the consequence: the outcome of this limitation is that it will fail at runtime,  instead of failing at load time ?  At load time it would "fail" gracefully with an expected message,  while at runtime it will fail kind of hard to figure out without some additional digging ?
Comment 11 Eugene Kuleshov CLA 2008-12-12 11:58:52 EST
(In reply to comment #10)
> Not sure I understand the consequence: the outcome of this limitation is that
> it will fail at runtime,  instead of failing at load time ?  At load time it
> would "fail" gracefully with an expected message,  while at runtime it will
> fail kind of hard to figure out without some additional digging ?

Not only that, but it also doesn't tell p2 resolver what is the right compatible version should be used.

Comment 12 Anthony Hunter CLA 2009-02-03 10:32:59 EST
Found a solution
Comment 13 Anthony Hunter CLA 2009-02-03 11:08:54 EST
We need to specify

Import-Package: com.ibm.icu.text;version="[3.8.1,5.0.0)"

To indicate that we need version 3.8.1 of the ICU4J bundle or higher.
Comment 14 Anthony Hunter CLA 2009-02-03 12:20:26 EST
Committed to HEAD