aboutsummaryrefslogtreecommitdiffstats
path: root/util/src/main
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-09-09 16:58:48 -0700
committerAndy Clement <aclement@pivotal.io>2019-09-09 16:58:48 -0700
commitaf640d2d8809a76f87519e09b5db1f3ce9a251f7 (patch)
tree752010f63b8c95bae1aa43402fa5d209ea9b0ab4 /util/src/main
parent589e3dc730d57c4d9c63fa79db97653a8e30c898 (diff)
downloadaspectj-af640d2d8809a76f87519e09b5db1f3ce9a251f7.tar.gz
aspectj-af640d2d8809a76f87519e09b5db1f3ce9a251f7.zip
Fix Bug 550290 - Lack of TypeSafeEnum#hashCode may lead to non-deterministic bytecode
Diffstat (limited to 'util/src/main')
-rw-r--r--util/src/main/java/org/aspectj/util/TypeSafeEnum.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/util/src/main/java/org/aspectj/util/TypeSafeEnum.java b/util/src/main/java/org/aspectj/util/TypeSafeEnum.java
index 99d223143..aba78b117 100644
--- a/util/src/main/java/org/aspectj/util/TypeSafeEnum.java
+++ b/util/src/main/java/org/aspectj/util/TypeSafeEnum.java
@@ -1,18 +1,19 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.util;
-import java.io.*;
+import java.io.DataOutputStream;
+import java.io.IOException;
public class TypeSafeEnum {
private byte key;
@@ -41,4 +42,15 @@ public class TypeSafeEnum {
public void write(DataOutputStream s) throws IOException {
s.writeByte(key);
}
+ @Override
+ public int hashCode() {
+ return name.hashCode()*37+key;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return (o instanceof TypeSafeEnum) &&
+ ((TypeSafeEnum)o).key == key &&
+ ((TypeSafeEnum)o).name.equals(name);
+ }
}