diff options
author | Andy Clement <andrew.clement@gmail.com> | 2013-02-14 09:15:02 -0800 |
---|---|---|
committer | Andy Clement <andrew.clement@gmail.com> | 2013-02-14 09:15:02 -0800 |
commit | 350b77ecc14fe63b55ca261b7c7e0a2041b29c73 (patch) | |
tree | 1a4edc061901dde09395e0a406e51d32c45c3cd8 /loadtime/src/org/aspectj | |
parent | b997ebb2bc653f50ac54da93f0e669ff1d051919 (diff) | |
download | aspectj-350b77ecc14fe63b55ca261b7c7e0a2041b29c73.tar.gz aspectj-350b77ecc14fe63b55ca261b7c7e0a2041b29c73.zip |
improved AdapterKey uniqueness - 400649
Diffstat (limited to 'loadtime/src/org/aspectj')
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/Aj.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/Aj.java b/loadtime/src/org/aspectj/weaver/loadtime/Aj.java index f518e4802..900d59ffe 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/Aj.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/Aj.java @@ -49,7 +49,7 @@ public class Aj implements ClassPreProcessor { private static Trace trace = TraceFactory.getTraceFactory().getTrace(Aj.class); - public Aj() { + public Aj() { this(null); } @@ -144,11 +144,15 @@ public class Aj implements ClassPreProcessor { */ private static class AdaptorKey extends WeakReference { - private int hashcode = -1; + private final int loaderHashCode, sysHashCode, hashValue; + private final String loaderClass; public AdaptorKey(ClassLoader loader) { super(loader, adaptorQueue); - hashcode = loader.hashCode() * 37; + loaderHashCode = loader.hashCode(); + sysHashCode = System.identityHashCode(loader); + loaderClass = loader.getClass().getName(); + hashValue = loaderHashCode + sysHashCode + loaderClass.hashCode(); } public ClassLoader getClassLoader() { @@ -158,14 +162,17 @@ public class Aj implements ClassPreProcessor { } public boolean equals(Object obj) { - if (!(obj instanceof AdaptorKey)) + if (!(obj instanceof AdaptorKey)) { return false; + } AdaptorKey other = (AdaptorKey) obj; - return other.hashcode == hashcode; + return (other.loaderHashCode == loaderHashCode) + && (other.sysHashCode == sysHashCode) + && loaderClass.equals(other.loaderClass); } public int hashCode() { - return hashcode; + return hashValue; } } |