diff options
| author | Paul Webster | 2013-05-21 14:54:01 +0000 |
|---|---|---|
| committer | Paul Webster | 2013-07-31 19:55:09 +0000 |
| commit | 5552aec82a0ffc1e0abaa7918377c2dd46c9e5b1 (patch) | |
| tree | 4e47e68fa82354f40724ba57519136b7994b3c9c | |
| parent | 6d8dea6d845c627a4aa0a6386a9bf632ce26d798 (diff) | |
| download | eclipse.platform.ui-5552aec82a0ffc1e0abaa7918377c2dd46c9e5b1.tar.gz eclipse.platform.ui-5552aec82a0ffc1e0abaa7918377c2dd46c9e5b1.tar.xz eclipse.platform.ui-5552aec82a0ffc1e0abaa7918377c2dd46c9e5b1.zip | |
Bug 395642 - Conflict Commands
Take the ABS value of the hash code to prevent the int overflow
that can cause this problem on some JVMs.
| -rw-r--r-- | bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/Util.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/Util.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/Util.java index bab97ce857b..eabea1ea3e1 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/Util.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/util/Util.java @@ -245,18 +245,20 @@ public final class Util { * <code>null</code>. Otherwise, the left identity hash code * minus the right identity hash code. */ - public static final int compareIdentity(Object left, Object right) { - if (left == null && right == null) { + public static final int compareIdentity(Object left, Object right) { + if (left == null && right == null) { return 0; } else if (left == null) { return -1; } else if (right == null) { return 1; - } else { - return System.identityHashCode(left) - - System.identityHashCode(right); } - } + int rc = Math.abs(System.identityHashCode(left)) - Math.abs(System.identityHashCode(right)); + if (rc != 0) { + return rc; + } + return left == right ? 0 : System.identityHashCode(left) - System.identityHashCode(right); + } public static void diff(Map left, Map right, Set leftOnly, Set different, Set rightOnly) { |
