Community
Participate
Working Groups
Created attachment 285170 [details] Sample plugin project The following code works for versions < 4.14: IObservableValue<Object> observe = WorkbenchProperties.singleSelection().observe(getSite().getService(ISelectionService.class)); ISideEffect.create(new Runnable() { @Override public void run() { Object value = observe.getValue(); System.out.println(value); } }); With version 4.14 and newer a ClassCastException is thrown when fireChanged is called in SelectionServiceListener.java as a result of clicking on e.g. the Project Explorer view: java.lang.ClassCastException: class org.eclipse.ui.navigator.resources.ProjectExplorer cannot be cast to class org.eclipse.ui.ISelectionService(org.eclipse.ui.navigator.resources.ProjectExplorer is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @1a25ef08; org.eclipse.ui.ISelectionService is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @79316697) at org.eclipse.ui.internal.databinding.SelectionServiceListener.selectionChanged(SelectionServiceListener.java:64) at org.eclipse.ui.internal.e4.compatibility.SelectionService.notifyListeners(SelectionService.java:240) at org.eclipse.ui.internal.e4.compatibility.SelectionService.handleSelectionChanged(SelectionService.java:94) at org.eclipse.ui.internal.e4.compatibility.SelectionService.lambda$0(SelectionService.java:68) at org.eclipse.e4.ui.internal.workbench.SelectionAggregator$1.run(SelectionAggregator.java:123) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) [...] This change in behaviour was introduced by commit d3c22327f2bdf89bebd15219c8f0f1d6671eb036.
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/174299
Hello HE, and thanks for reporting with a such clear demonstration of the bug. The problem is because SelectionListener uses a non-standard value as the source argument to fireChange. This was not taken into consideration when adding type parameters, leading to ClassCastExceptions. A fix has been pushed.
Hi Jens! Thanks for the quick fix. I see the build is failing although it seems unrelated to this patch?
(In reply to Hans-Erik Floryd from comment #3) > I see the build is failing although it seems unrelated to this patch? It seems like they have introduced a feature that fails builds during the master branch freeze time. There is a master branch freeze time during a short period before each major release.
Gerrit change https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/174299 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=c7bac62e49a0b00a4178310f8ed49476e21f0b41