diff options
author | Andy Clement <aclement@pivotal.io> | 2019-09-09 16:58:48 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2019-09-09 16:58:48 -0700 |
commit | af640d2d8809a76f87519e09b5db1f3ce9a251f7 (patch) | |
tree | 752010f63b8c95bae1aa43402fa5d209ea9b0ab4 /org.aspectj.matcher/src | |
parent | 589e3dc730d57c4d9c63fa79db97653a8e30c898 (diff) | |
download | aspectj-af640d2d8809a76f87519e09b5db1f3ce9a251f7.tar.gz aspectj-af640d2d8809a76f87519e09b5db1f3ce9a251f7.zip |
Fix Bug 550290 - Lack of TypeSafeEnum#hashCode may lead to non-deterministic bytecode
Diffstat (limited to 'org.aspectj.matcher/src')
-rw-r--r-- | org.aspectj.matcher/src/main/java/org/aspectj/weaver/AdviceKind.java | 34 | ||||
-rw-r--r-- | org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java | 36 |
2 files changed, 43 insertions, 27 deletions
diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AdviceKind.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AdviceKind.java index af0646935..3d5300110 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AdviceKind.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/AdviceKind.java @@ -1,13 +1,13 @@ /* ******************************************************************* * 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: - * 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: + * PARC initial implementation * ******************************************************************/ package org.aspectj.weaver; @@ -18,7 +18,7 @@ import org.aspectj.util.TypeSafeEnum; /** * The five kinds of advice in AspectJ. - * + * * @author Erik Hilsdale * @author Jim Hugunin */ @@ -132,4 +132,20 @@ public class AdviceKind extends TypeSafeEnum { return this == PerThisEntry || this == PerTargetEntry; } + @Override + public int hashCode() { + return ((super.hashCode()*37 + precedence)*37+(isAfter?0:1))*37 + (isCflow?0:1); + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof AdviceKind)) { + return false; + } + AdviceKind ak = (AdviceKind)o; + return super.equals(ak) && + ak.precedence == precedence && + ak.isAfter == isAfter && + ak.isCflow == isCflow; + } } diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java index 1a8ed5290..cde7e5163 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/Shadow.java @@ -1,13 +1,13 @@ /* ******************************************************************* * 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: - * 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: + * PARC initial implementation * ******************************************************************/ package org.aspectj.weaver; @@ -47,7 +47,7 @@ public abstract class Shadow { protected final Shadow enclosingShadow; protected List<ShadowMunger> mungers = Collections.emptyList(); protected boolean needAroundClosureStacking = false; - + public int shadowId = nextShadowID++; // every time we build a shadow, it gets a new id // ---- @@ -82,7 +82,7 @@ public abstract class Shadow { /** * the type of the this object here - * + * * @throws IllegalStateException if there is no this here */ public final UnresolvedType getThisType() { @@ -98,7 +98,7 @@ public abstract class Shadow { /** * a var referencing this - * + * * @throws IllegalStateException if there is no target here */ public abstract Var getThisVar(); @@ -118,7 +118,7 @@ public abstract class Shadow { /** * the type of the target object here - * + * * @throws IllegalStateException if there is no target here */ public final UnresolvedType getTargetType() { @@ -130,7 +130,7 @@ public abstract class Shadow { /** * a var referencing the target - * + * * @throws IllegalStateException if there is no target here */ public abstract Var getTargetVar(); @@ -266,7 +266,7 @@ public abstract class Shadow { /** * returns the resolved signature of the thing under this shadow - * + * */ public ResolvedMember getResolvedSignature() { if (resolvedSignature == null) { @@ -399,7 +399,7 @@ public abstract class Shadow { /** * These shadow kinds have return values that can be bound in after returning(Dooberry doo) advice. - * + * * @return */ public boolean hasReturnValue() { @@ -481,7 +481,7 @@ public abstract class Shadow { /** * Only does the check if the munger requires it (@AJ aspects don't) - * + * * @param munger * @return */ @@ -628,11 +628,11 @@ public abstract class Shadow { /** Actually implement the (non-empty) mungers associated with this shadow */ private void implementMungers() { - World world = getIWorld(); + World world = getIWorld(); needAroundClosureStacking = false; int annotationStyleWithAroundAndProceedCount = 0; for (ShadowMunger munger: mungers) { - if (munger.getDeclaringType()!= null && + if (munger.getDeclaringType()!= null && munger.getDeclaringType().isAnnotationStyleAspect() && munger.isAroundAdvice() && munger.bindsProceedingJoinPoint()) { |