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

Bug 478408

Summary: Anchor mechanism broken since at least Java 8u40 due to JavaFX bug (JDK-8136465).
Product: [Tools] GEF Reporter: Matthias Wienand <matthias.wienand>
Component: GEF MVCAssignee: Matthias Wienand <matthias.wienand>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: 0.2.0   
Target Milestone: 4.0.0 / 3.11.0 (Neon) M4   
Hardware: All   
OS: All   
Whiteboard:

Description Matthias Wienand CLA 2015-09-25 07:55:30 EDT
The anchor mechanism is currently broken with Java 8, possibly due to a JavaFX 8 regression.

Steps to reproduce:
1. Start the MVC Logo Example.
2. Zoom-in and scroll a bit.
3. Hover a "handle" shape (in the corner) and wait for the hover handles to appear.
4. Create a new connection using the "+" hover handle.
=> The anchors are broken now so that the connections should not be rendered correctly (relocating shapes and connections should reveal this).

This is not the only reproducible bug related to anchors:
1. Start the MVC Logo Example.
2. Hover a "handle" shape that is connected and create another connection using the "+" hover handle.
3. Manipulate the first connection, e.g. drag it.
4. The created connection is not updated correctly.

We will investigate further to find the root of the problem. I am adding UI tests to MVC.FX.Tests to ensure that the anchor mechanism works. We should probably build GEF4 twice on the HIPP, once with Java 7 and once with Java 8, so that we are aware of such regressions. What do you think?
Comment 1 Alexander Nyßen CLA 2015-09-25 09:23:16 EDT
I could reproduce this first (with Java 8). Having updated to e(fx)clipse 2.1 and switched my BREE J2SE-1.7 bindings to (java8) and fro (java7), I can now no longer reproduce the issue (with Java 8). Very strange...
Comment 2 Matthias Wienand CLA 2015-11-20 09:36:12 EST
I investigated further and found that a JavaFX bug [1] is responsible for the strange behavior: when removing a ChangeListener from a MapProperty, all ChangeListeners are removed by mistake. The bug is reported for Java version 8u60 and I could verify that anchors work correctly with 8u20 and 8u25, but do not work with 8u60 and 8u66. I did not test other versions, but I trust the bug report that the issue is fixed since Java 9.

[1] https://bugs.openjdk.java.net/browse/JDK-8136465

Therefore, a workaround has to be implemented that keeps track of all registered ChangeListeners and re-registers the ChangeListeners when a ChangeListener is removed.
Comment 3 Alexander Nyßen CLA 2015-11-22 01:54:53 EST
We introduced org.eclipse.gef4.fx.internal.ReadOnlyMapWrapperEx as a (temporary) replacement for ReadOnlyMapWrapper. It uses a nested read-only property implementation that works around JDK-8136465 by keeping track of all listeners locally, and by adjusting the registered listeners of the underlying MapExpressionHelper as needed.

Ensured ReadOnlyMapWrapperEx is used instead of ReadOnlyMapWrapper in all relevant places. All changes were pushed to origin/master. Resolving as fixed in 3.11.0 M4.

Unless this Java bug is not resolved in a recent Java 8, we will have to leave the workaround in place until changing the BREE of the GEF4 FX bundle to Java 9.