From f4b1f8502f3a64c01374d15e4bf2c2830503c55b Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 18 May 2010 16:20:12 +0000 Subject: [PATCH] change all relevant DataOutputStream usage to use CompressingDataOutputStream --- .../src/org/aspectj/weaver/AjAttribute.java | 28 +- .../weaver/AnnotationOnTypeMunger.java | 6 +- .../weaver/CrosscuttingMembersSet.java | 3 +- .../aspectj/weaver/JoinPointSignature.java | 3 +- .../weaver/MethodDelegateTypeMunger.java | 11 +- .../weaver/NewConstructorTypeMunger.java | 18 +- .../aspectj/weaver/NewFieldTypeMunger.java | 24 +- .../aspectj/weaver/NewMethodTypeMunger.java | 12 +- .../aspectj/weaver/NewParentTypeMunger.java | 3 +- .../weaver/PerObjectInterfaceTypeMunger.java | 13 +- .../weaver/PerTypeWithinTargetTypeMunger.java | 6 +- .../aspectj/weaver/PersistenceSupport.java | 5 +- .../weaver/PrivilegedAccessMunger.java | 3 +- .../org/aspectj/weaver/ResolvedMember.java | 3 +- .../aspectj/weaver/ResolvedMemberImpl.java | 5 +- .../weaver/ResolvedPointcutDefinition.java | 3 +- .../aspectj/weaver/ResolvedTypeMunger.java | 4 +- .../src/org/aspectj/weaver/ShadowMunger.java | 3 +- .../src/org/aspectj/weaver/TypeVariable.java | 3 +- .../org/aspectj/weaver/UnresolvedType.java | 5 +- .../UnresolvedTypeVariableReferenceType.java | 7 - .../org/aspectj/weaver/WeaverStateInfo.java | 2 +- ...ointcutDesignatorHandlerBasedPointcut.java | 4 +- .../patterns/AndAnnotationTypePattern.java | 116 ++++---- .../aspectj/weaver/patterns/AndPointcut.java | 71 ++--- .../weaver/patterns/AndTypePattern.java | 99 +++---- .../patterns/AnnotationPatternList.java | 166 ++++++----- .../weaver/patterns/AnnotationPointcut.java | 23 +- .../patterns/AnnotationTypePattern.java | 4 +- .../patterns/AnyAnnotationTypePattern.java | 4 +- .../patterns/ArgsAnnotationPointcut.java | 184 ++++++------ .../aspectj/weaver/patterns/ArgsPointcut.java | 182 ++++++------ .../BindingAnnotationFieldTypePattern.java | 263 +++++++++--------- .../BindingAnnotationTypePattern.java | 78 +++--- .../weaver/patterns/BindingTypePattern.java | 82 +++--- .../weaver/patterns/CflowPointcut.java | 4 +- .../patterns/ConcreteCflowPointcut.java | 13 +- .../weaver/patterns/DeclareAnnotation.java | 4 +- .../patterns/DeclareErrorOrWarning.java | 84 +++--- .../weaver/patterns/DeclareParents.java | 43 ++- .../weaver/patterns/DeclareParentsMixin.java | 4 +- .../weaver/patterns/DeclarePrecedence.java | 31 ++- .../aspectj/weaver/patterns/DeclareSoft.java | 4 +- .../patterns/DeclareTypeErrorOrWarning.java | 17 +- .../ExactAnnotationFieldTypePattern.java | 4 +- .../patterns/ExactAnnotationTypePattern.java | 4 +- .../weaver/patterns/ExactTypePattern.java | 4 +- .../weaver/patterns/HandlerPointcut.java | 92 +++--- .../weaver/patterns/HasMemberTypePattern.java | 4 +- .../aspectj/weaver/patterns/IfPointcut.java | 8 +- .../weaver/patterns/KindedPointcut.java | 4 +- .../weaver/patterns/ModifiersPattern.java | 76 ++--- .../aspectj/weaver/patterns/NamePattern.java | 4 +- .../patterns/NotAnnotationTypePattern.java | 87 +++--- .../aspectj/weaver/patterns/NotPointcut.java | 75 ++--- .../weaver/patterns/NotTypePattern.java | 4 +- .../patterns/OrAnnotationTypePattern.java | 97 ++++--- .../aspectj/weaver/patterns/OrPointcut.java | 79 +++--- .../weaver/patterns/OrTypePattern.java | 110 ++++---- .../aspectj/weaver/patterns/PatternNode.java | 57 ++-- .../org/aspectj/weaver/patterns/PerCflow.java | 13 +- .../aspectj/weaver/patterns/PerFromSuper.java | 110 ++++---- .../aspectj/weaver/patterns/PerObject.java | 21 +- .../aspectj/weaver/patterns/PerSingleton.java | 7 +- .../weaver/patterns/PerTypeWithin.java | 13 +- .../org/aspectj/weaver/patterns/Pointcut.java | 4 +- .../weaver/patterns/ReferencePointcut.java | 4 +- .../weaver/patterns/SignaturePattern.java | 4 +- .../ThisOrTargetAnnotationPointcut.java | 4 +- .../weaver/patterns/ThisOrTargetPointcut.java | 4 +- .../weaver/patterns/ThrowsPattern.java | 146 +++++----- .../patterns/TypeCategoryTypePattern.java | 4 +- .../aspectj/weaver/patterns/TypePattern.java | 19 +- .../weaver/patterns/TypePatternList.java | 6 +- .../weaver/patterns/TypeVariablePattern.java | 150 ++++++---- .../patterns/TypeVariablePatternList.java | 33 ++- .../patterns/WildAnnotationTypePattern.java | 4 +- .../weaver/patterns/WildTypePattern.java | 7 +- .../patterns/WithinAnnotationPointcut.java | 4 +- .../WithinCodeAnnotationPointcut.java | 172 +++++++----- .../weaver/patterns/WithinPointcut.java | 4 +- .../weaver/patterns/WithincodePointcut.java | 103 ++++--- .../weaver/patterns/AndOrNotTestCase.java | 9 +- .../DeclareErrorOrWarningTestCase.java | 4 +- .../patterns/ModifiersPatternTestCase.java | 6 +- .../weaver/patterns/NamePatternTestCase.java | 74 ++--- .../SignaturePatternMatchSpeedTestCase.java | 4 +- .../patterns/SignaturePatternTestCase.java | 77 ++--- .../patterns/TypePatternListTestCase.java | 9 +- .../weaver/patterns/TypePatternTestCase.java | 4 +- .../weaver/patterns/WithinTestCase.java | 9 +- 91 files changed, 1767 insertions(+), 1624 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java b/org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java index dc90b4e43..07149a518 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java @@ -41,7 +41,7 @@ public abstract class AjAttribute { public static final String AttributePrefix = "org.aspectj.weaver"; - protected abstract void write(DataOutputStream s) throws IOException; + protected abstract void write(CompressingDataOutputStream s) throws IOException; public abstract String getNameString(); @@ -55,7 +55,7 @@ public abstract class AjAttribute { public byte[] getBytes() { try { ByteArrayOutputStream b0 = new ByteArrayOutputStream(); - DataOutputStream s0 = new DataOutputStream(b0); + CompressingDataOutputStream s0 = new CompressingDataOutputStream(b0); write(s0); s0.close(); return b0.toByteArray(); @@ -158,7 +158,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { } } @@ -177,7 +177,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { munger.write(s); } @@ -201,7 +201,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); } @@ -286,7 +286,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeShort(CURRENT_VERSION_MAJOR); s.writeShort(CURRENT_VERSION_MINOR); s.writeLong(Version.getTime()); // build used to construct the @@ -362,7 +362,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeUTF(sourceFileName); FileUtil.writeIntArray(lineBreaks, s); } @@ -409,7 +409,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeInt(lineNumber); s.writeInt(offset); } @@ -444,7 +444,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { pointcutDef.write(s); } @@ -468,7 +468,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { declare.write(s); } @@ -549,7 +549,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); pointcut.write(s); s.writeByte(extraParameterFlags); @@ -641,7 +641,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { perClause.write(s); } @@ -661,7 +661,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { ResolvedMemberImpl.writeArray(accessedMembers, s); } @@ -699,7 +699,7 @@ public abstract class AjAttribute { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { effectiveSignature.write(s); shadowKind.write(s); s.writeBoolean(weaveBody); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/AnnotationOnTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/AnnotationOnTypeMunger.java index 502d53c9a..6390ed311 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/AnnotationOnTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/AnnotationOnTypeMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; /** @@ -26,7 +25,7 @@ public class AnnotationOnTypeMunger extends ResolvedTypeMunger { newAnnotation = anno; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { throw new RuntimeException("unimplemented"); } @@ -35,8 +34,9 @@ public class AnnotationOnTypeMunger extends ResolvedTypeMunger { } public boolean equals(Object other) { - if (!(other instanceof AnnotationOnTypeMunger)) + if (!(other instanceof AnnotationOnTypeMunger)) { return false; + } AnnotationOnTypeMunger o = (AnnotationOnTypeMunger) other; // TODO does not check equality of annotation values return newAnnotation.getTypeSignature().equals(o.newAnnotation.getTypeSignature()); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java b/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java index 04d23488f..d48dc18d3 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -379,7 +378,7 @@ public class CrosscuttingMembersSet { public int serializationVersion = 1; - public void write(DataOutputStream stream) throws IOException { + public void write(CompressingDataOutputStream stream) throws IOException { // stream.writeInt(serializationVersion); stream.writeInt(shadowMungers.size()); for (Iterator iterator = shadowMungers.iterator(); iterator.hasNext();) { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java b/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java index 70f58be9a..8212f7f3c 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/JoinPointSignature.java @@ -11,7 +11,6 @@ * ******************************************************************/ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Collection; import java.util.List; @@ -112,7 +111,7 @@ public class JoinPointSignature implements ResolvedMember { return realMember.isSynthetic(); } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { realMember.write(s); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/MethodDelegateTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/MethodDelegateTypeMunger.java index c1bc59d33..79eab7d4d 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/MethodDelegateTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/MethodDelegateTypeMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.weaver.patterns.TypePattern; @@ -78,8 +77,9 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger { } public boolean equals(Object other) { - if (!(other instanceof MethodDelegateTypeMunger)) + if (!(other instanceof MethodDelegateTypeMunger)) { return false; + } MethodDelegateTypeMunger o = (MethodDelegateTypeMunger) other; return ((o.aspect == null) ? (aspect == null) : aspect.equals(o.aspect)) && ((o.typePattern == null) ? (typePattern == null) : typePattern.equals(o.typePattern)) @@ -127,7 +127,7 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger { return implClassName; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); signature.write(s); aspect.write(s); @@ -210,8 +210,9 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger { } public boolean equals(Object other) { - if (!(other instanceof FieldHostTypeMunger)) + if (!(other instanceof FieldHostTypeMunger)) { return false; + } FieldHostTypeMunger o = (FieldHostTypeMunger) other; return ((o.aspect == null) ? (aspect == null) : aspect.equals(o.aspect)) && ((o.typePattern == null) ? (typePattern == null) : typePattern.equals(o.typePattern)); @@ -224,7 +225,7 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger { return result; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); signature.write(s); aspect.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/NewConstructorTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/NewConstructorTypeMunger.java index fceb72f03..47cfdf505 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/NewConstructorTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/NewConstructorTypeMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.util.List; import java.util.Set; @@ -35,8 +34,9 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger { } public boolean equals(Object other) { - if (!(other instanceof NewConstructorTypeMunger)) + if (!(other instanceof NewConstructorTypeMunger)) { return false; + } NewConstructorTypeMunger o = (NewConstructorTypeMunger) other; return ((syntheticConstructor == null) ? (o.syntheticConstructor == null) : syntheticConstructor .equals(o.syntheticConstructor)) @@ -46,8 +46,9 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger { // pr262218 - equivalence ignores the explicit constructor since that won't have yet been set for an EclipseTypeMunger public boolean equivalentTo(Object other) { - if (!(other instanceof NewConstructorTypeMunger)) + if (!(other instanceof NewConstructorTypeMunger)) { return false; + } NewConstructorTypeMunger o = (NewConstructorTypeMunger) other; return ((syntheticConstructor == null) ? (o.syntheticConstructor == null) : syntheticConstructor .equals(o.syntheticConstructor)); @@ -70,7 +71,7 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger { // return AjcMemberMaker.interMethodBody(signature, aspectType); // } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); signature.write(s); syntheticConstructor.write(s); @@ -90,8 +91,9 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger { List typeVarAliases = readInTypeAliases(s); ResolvedTypeMunger munger = new NewConstructorTypeMunger(sig, syntheticCtor, explicitCtor, superMethodsCalled, typeVarAliases); - if (sloc != null) + if (sloc != null) { munger.setSourceLocation(sloc); + } return munger; } @@ -111,8 +113,9 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger { public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedType aspectType) { ResolvedMember ret = getSyntheticConstructor(); - if (ResolvedType.matches(ret, member)) + if (ResolvedType.matches(ret, member)) { return getSignature(); + } return super.getMatchingSyntheticMember(member, aspectType); } @@ -128,8 +131,9 @@ public class NewConstructorTypeMunger extends ResolvedTypeMunger { */ public ResolvedTypeMunger parameterizedFor(ResolvedType target) { ResolvedType genericType = target; - if (target.isRawType() || target.isParameterizedType()) + if (target.isRawType() || target.isParameterizedType()) { genericType = genericType.getGenericType(); + } ResolvedMember parameterizedSignature = null; // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used // in the original ITD declaration to the ones used in the actual target type declaration. diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/NewFieldTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/NewFieldTypeMunger.java index 8427ca74b..bb2cacbb1 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/NewFieldTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/NewFieldTypeMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; @@ -46,7 +45,7 @@ public class NewFieldTypeMunger extends ResolvedTypeMunger { return AjcMemberMaker.interFieldInitializer(signature, aspectType); } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); signature.write(s); writeSuperMethodsCalled(s); @@ -62,8 +61,9 @@ public class NewFieldTypeMunger extends ResolvedTypeMunger { sloc = readSourceLocation(s); List aliases = readInTypeAliases(s); NewFieldTypeMunger munger = new NewFieldTypeMunger(fieldSignature, superMethodsCalled, aliases); - if (sloc != null) + if (sloc != null) { munger.setSourceLocation(sloc); + } if (s.getMajorVersion() >= WeaverVersionInfo.WEAVER_VERSION_AJ169) { // there is a version int munger.version = s.readInt(); @@ -76,21 +76,26 @@ public class NewFieldTypeMunger extends ResolvedTypeMunger { public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedType aspectType) { // ??? might give a field where a method is expected ResolvedType onType = aspectType.getWorld().resolve(getSignature().getDeclaringType()); - if (onType.isRawType()) + if (onType.isRawType()) { onType = onType.getGenericType(); + } ResolvedMember ret = AjcMemberMaker.interFieldGetDispatcher(getSignature(), aspectType); - if (ResolvedType.matches(ret, member)) + if (ResolvedType.matches(ret, member)) { return getSignature(); + } ret = AjcMemberMaker.interFieldSetDispatcher(getSignature(), aspectType); - if (ResolvedType.matches(ret, member)) + if (ResolvedType.matches(ret, member)) { return getSignature(); + } ret = AjcMemberMaker.interFieldInterfaceGetter(getSignature(), onType, aspectType); - if (ResolvedType.matches(ret, member)) + if (ResolvedType.matches(ret, member)) { return getSignature(); + } ret = AjcMemberMaker.interFieldInterfaceSetter(getSignature(), onType, aspectType); - if (ResolvedType.matches(ret, member)) + if (ResolvedType.matches(ret, member)) { return getSignature(); + } return super.getMatchingSyntheticMember(member, aspectType); } @@ -99,8 +104,9 @@ public class NewFieldTypeMunger extends ResolvedTypeMunger { */ public ResolvedTypeMunger parameterizedFor(ResolvedType target) { ResolvedType genericType = target; - if (target.isRawType() || target.isParameterizedType()) + if (target.isRawType() || target.isParameterizedType()) { genericType = genericType.getGenericType(); + } ResolvedMember parameterizedSignature = null; // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used // in the original ITD declaration to the ones used in the actual target type declaration. diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/NewMethodTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/NewMethodTypeMunger.java index a2158954d..da5c3b1f4 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/NewMethodTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/NewMethodTypeMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; @@ -59,7 +58,7 @@ public class NewMethodTypeMunger extends ResolvedTypeMunger { } } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); signature.write(s); writeSuperMethodsCalled(s); @@ -75,15 +74,17 @@ public class NewMethodTypeMunger extends ResolvedTypeMunger { List typeVarAliases = readInTypeAliases(s); ResolvedTypeMunger munger = new NewMethodTypeMunger(rmImpl, superMethodsCalled, typeVarAliases); - if (sloc != null) + if (sloc != null) { munger.setSourceLocation(sloc); + } return munger; } public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedType aspectType) { ResolvedMember ret = AjcMemberMaker.interMethodDispatcher(getSignature(), aspectType); - if (ResolvedType.matches(ret, member)) + if (ResolvedType.matches(ret, member)) { return getSignature(); + } return super.getMatchingSyntheticMember(member, aspectType); } @@ -92,8 +93,9 @@ public class NewMethodTypeMunger extends ResolvedTypeMunger { */ public ResolvedTypeMunger parameterizedFor(ResolvedType target) { ResolvedType genericType = target; - if (target.isRawType() || target.isParameterizedType()) + if (target.isRawType() || target.isParameterizedType()) { genericType = genericType.getGenericType(); + } ResolvedMember parameterizedSignature = null; // If we are parameterizing it for a generic type, we just need to 'swap the letters' from the ones used // in the original ITD declaration to the ones used in the actual target type declaration. diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/NewParentTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/NewParentTypeMunger.java index 069711bc1..ebb419f5b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/NewParentTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/NewParentTypeMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; public class NewParentTypeMunger extends ResolvedTypeMunger { @@ -25,7 +24,7 @@ public class NewParentTypeMunger extends ResolvedTypeMunger { this.isMixin = false; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { throw new RuntimeException("unimplemented"); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java index 03ee00877..ce4348241 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/PerObjectInterfaceTypeMunger.java @@ -12,15 +12,14 @@ * ******************************************************************/ package org.aspectj.weaver; +import java.io.IOException; + import org.aspectj.weaver.patterns.PerFromSuper; import org.aspectj.weaver.patterns.PerObject; import org.aspectj.weaver.patterns.PerThisOrTargetPointcutVisitor; import org.aspectj.weaver.patterns.Pointcut; import org.aspectj.weaver.patterns.TypePattern; -import java.io.DataOutputStream; -import java.io.IOException; - public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger { private final UnresolvedType interfaceType; @@ -28,8 +27,9 @@ public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger { private TypePattern lazyTestTypePattern; public boolean equals(Object other) { - if (other == null || !(other instanceof PerObjectInterfaceTypeMunger)) + if (other == null || !(other instanceof PerObjectInterfaceTypeMunger)) { return false; + } PerObjectInterfaceTypeMunger o = (PerObjectInterfaceTypeMunger) other; return ((testPointcut == null) ? (o.testPointcut == null) : testPointcut.equals(o.testPointcut)) && ((lazyTestTypePattern == null) ? (o.lazyTestTypePattern == null) : lazyTestTypePattern @@ -71,7 +71,7 @@ public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger { return lazyTestTypePattern; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { throw new RuntimeException("shouldn't be serialized"); } @@ -84,8 +84,9 @@ public class PerObjectInterfaceTypeMunger extends ResolvedTypeMunger { } public boolean matches(ResolvedType matchType, ResolvedType aspectType) { - if (matchType.isInterface()) + if (matchType.isInterface()) { return false; + } return getTestTypePattern(aspectType).matchesStatically(matchType); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java index 4cc4c9e17..036ab9b7c 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/PerTypeWithinTargetTypeMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; @@ -31,8 +30,9 @@ public class PerTypeWithinTargetTypeMunger extends ResolvedTypeMunger { } public boolean equals(Object other) { - if (!(other instanceof PerTypeWithinTargetTypeMunger)) + if (!(other instanceof PerTypeWithinTargetTypeMunger)) { return false; + } PerTypeWithinTargetTypeMunger o = (PerTypeWithinTargetTypeMunger) other; return ((o.testPointcut == null) ? (testPointcut == null) : testPointcut.equals(o.testPointcut)) && ((o.aspectType == null) ? (aspectType == null) : aspectType.equals(o.aspectType)); @@ -50,7 +50,7 @@ public class PerTypeWithinTargetTypeMunger extends ResolvedTypeMunger { return hashCode; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { throw new RuntimeException("shouldn't be serialized"); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java b/org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java index 5eb1de13e..d98c7678d 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -19,11 +18,11 @@ import java.io.Serializable; */ public class PersistenceSupport { - public static void write(DataOutputStream stream, ISourceContext sourceContext) throws IOException { + public static void write(CompressingDataOutputStream stream, ISourceContext sourceContext) throws IOException { throw new IllegalStateException(); } - public static void write(DataOutputStream stream, Serializable serializableObject) throws IOException { + public static void write(CompressingDataOutputStream stream, Serializable serializableObject) throws IOException { ObjectOutputStream oos = new ObjectOutputStream(stream); oos.writeObject(serializableObject); oos.flush(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/PrivilegedAccessMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/PrivilegedAccessMunger.java index 3e5a3be50..3acbf9b4b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/PrivilegedAccessMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/PrivilegedAccessMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; /** @@ -34,7 +33,7 @@ public class PrivilegedAccessMunger extends ResolvedTypeMunger { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { throw new RuntimeException("should not be serialized"); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java index ffeedbbc3..bc0a87151 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMember.java @@ -13,7 +13,6 @@ * ******************************************************************/ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; @@ -56,7 +55,7 @@ public interface ResolvedMember extends Member, AnnotatedElement, TypeVariableDe public boolean isSynthetic(); - public void write(DataOutputStream s) throws IOException; + public void write(CompressingDataOutputStream s) throws IOException; public ISourceContext getSourceContext(World world); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java index c63c8a09c..7f9330c87 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java @@ -8,7 +8,6 @@ * ******************************************************************/ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -379,7 +378,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno return (modifiers & 4096) != 0; // do we know better? } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { getKind().write(s); getDeclaringType().write(s); s.writeInt(modifiers); @@ -460,7 +459,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno return sb.toString(); } - public static void writeArray(ResolvedMember[] members, DataOutputStream s) throws IOException { + public static void writeArray(ResolvedMember[] members, CompressingDataOutputStream s) throws IOException { s.writeInt(members.length); for (int i = 0, len = members.length; i < len; i++) { members[i].write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedPointcutDefinition.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedPointcutDefinition.java index b3532ecae..f42d55488 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedPointcutDefinition.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedPointcutDefinition.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -48,7 +47,7 @@ public class ResolvedPointcutDefinition extends ResolvedMemberImpl { // ---- @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { getDeclaringType().write(s); s.writeInt(getModifiers()); s.writeUTF(getName()); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedTypeMunger.java index 1c2cd4ca2..404d8790f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedTypeMunger.java @@ -177,7 +177,7 @@ public abstract class ResolvedTypeMunger { return ret; } - protected void writeSuperMethodsCalled(DataOutputStream s) throws IOException { + protected void writeSuperMethodsCalled(CompressingDataOutputStream s) throws IOException { if (superMethodsCalled == null || superMethodsCalled.size() == 0) { s.writeInt(0); @@ -243,7 +243,7 @@ public abstract class ResolvedTypeMunger { oos.close(); } - public abstract void write(DataOutputStream s) throws IOException; + public abstract void write(CompressingDataOutputStream s) throws IOException; public Kind getKind() { return kind; diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java index 1b6dbbe6f..0937d5469 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java @@ -12,7 +12,6 @@ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.File; import java.io.IOException; import java.util.Collection; @@ -259,7 +258,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH */ public abstract boolean mustCheckExceptions(); - public void write(DataOutputStream stream) throws IOException { + public void write(CompressingDataOutputStream stream) throws IOException { stream.writeInt(VERSION_1); stream.writeInt(shadowMungerKind); // determines real subclass stream.writeInt(start); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/TypeVariable.java b/org.aspectj.matcher/src/org/aspectj/weaver/TypeVariable.java index 98cbedf0a..a0cfd0c2b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/TypeVariable.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/TypeVariable.java @@ -8,7 +8,6 @@ * ******************************************************************/ package org.aspectj.weaver; -import java.io.DataOutputStream; import java.io.IOException; /** @@ -314,7 +313,7 @@ public class TypeVariable { return declaringElementKind; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { // name, upperbound, additionalInterfaceBounds, lowerbound s.writeUTF(name); superclass.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedType.java index 8436c228e..3453eb1eb 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedType.java @@ -15,7 +15,6 @@ package org.aspectj.weaver; import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; @@ -836,7 +835,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { } } - public void write(DataOutputStream s) throws IOException { + public final void write(CompressingDataOutputStream s) throws IOException { s.writeUTF(getSignature()); } @@ -850,7 +849,7 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement { } } - public static void writeArray(UnresolvedType[] types, DataOutputStream s) throws IOException { + public static void writeArray(UnresolvedType[] types, CompressingDataOutputStream s) throws IOException { int len = types.length; s.writeShort(len); for (int i = 0; i < len; i++) { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java b/org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java index 33099b17b..2dcbbd91a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedTypeVariableReferenceType.java @@ -8,8 +8,6 @@ * ******************************************************************/ package org.aspectj.weaver; -import java.io.DataOutputStream; -import java.io.IOException; /** * @author Adrian Colyer @@ -85,11 +83,6 @@ public class UnresolvedTypeVariableReferenceType extends UnresolvedType implemen return typeVariable.getName(); } - @Override - public void write(DataOutputStream s) throws IOException { - super.write(s); - } - @Override public String getErasureSignature() { return typeVariable.getFirstBound().getSignature(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/WeaverStateInfo.java b/org.aspectj.matcher/src/org/aspectj/weaver/WeaverStateInfo.java index fb496c9b5..c09e656f9 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/WeaverStateInfo.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/WeaverStateInfo.java @@ -154,7 +154,7 @@ public class WeaverStateInfo { * be inserted. When the key is replaced with the diff, the 'kind' byte moves to the front of the attribute - thats why in the * read logic you'll see it expecting the kind as the first byte. */ - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { if (oldStyle || reweavableCompressedMode) { throw new RuntimeException("shouldn't be writing this"); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/internal/tools/PointcutDesignatorHandlerBasedPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/internal/tools/PointcutDesignatorHandlerBasedPointcut.java index 29471cbec..9c508a1a3 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/internal/tools/PointcutDesignatorHandlerBasedPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/internal/tools/PointcutDesignatorHandlerBasedPointcut.java @@ -11,11 +11,11 @@ * ******************************************************************/ package org.aspectj.weaver.internal.tools; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.Shadow; @@ -157,7 +157,7 @@ public class PointcutDesignatorHandlerBasedPointcut extends Pointcut { * * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { throw new UnsupportedOperationException("can't write custom pointcut designator expressions to stream"); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java index 4392a19d3..4889d0f9a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java @@ -9,28 +9,29 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; -import org.aspectj.weaver.ResolvedType; + /** * @author colyer - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * + * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code + * Templates */ public class AndAnnotationTypePattern extends AnnotationTypePattern { private AnnotationTypePattern left; private AnnotationTypePattern right; - + public AndAnnotationTypePattern(AnnotationTypePattern left, AnnotationTypePattern right) { this.left = left; this.right = right; @@ -40,83 +41,96 @@ public class AndAnnotationTypePattern extends AnnotationTypePattern { public FuzzyBoolean matches(AnnotatedElement annotated) { return left.matches(annotated).and(right.matches(annotated)); } - - public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations ) { - return left.matches(annotated,parameterAnnotations).and(right.matches(annotated,parameterAnnotations)); + + public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations) { + return left.matches(annotated, parameterAnnotations).and(right.matches(annotated, parameterAnnotations)); } public void resolve(World world) { left.resolve(world); right.resolve(world); } - - /* (non-Javadoc) - * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean) + + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, + * org.aspectj.weaver.patterns.Bindings, boolean) */ - public AnnotationTypePattern resolveBindings(IScope scope, - Bindings bindings, boolean allowBinding) { - left = left.resolveBindings(scope,bindings,allowBinding); - right =right.resolveBindings(scope,bindings,allowBinding); + public AnnotationTypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding) { + left = left.resolveBindings(scope, bindings, allowBinding); + right = right.resolveBindings(scope, bindings, allowBinding); return this; } - - public AnnotationTypePattern parameterizeWith(Map typeVariableMap,World w) { - AnnotationTypePattern newLeft = left.parameterizeWith(typeVariableMap,w); - AnnotationTypePattern newRight = right.parameterizeWith(typeVariableMap,w); - AndAnnotationTypePattern ret = new AndAnnotationTypePattern(newLeft,newRight); + + public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { + AnnotationTypePattern newLeft = left.parameterizeWith(typeVariableMap, w); + AnnotationTypePattern newRight = right.parameterizeWith(typeVariableMap, w); + AndAnnotationTypePattern ret = new AndAnnotationTypePattern(newLeft, newRight); ret.copyLocationFrom(this); - if (this.isForParameterAnnotationMatch()) ret.setForParameterAnnotationMatch(); + if (this.isForParameterAnnotationMatch()) { + ret.setForParameterAnnotationMatch(); + } return ret; } - + public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { - AnnotationTypePattern p = new AndAnnotationTypePattern( - AnnotationTypePattern.read(s,context), - AnnotationTypePattern.read(s,context)); - p.readLocation(context,s); - if (s.getMajorVersion()>=WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ160) { - if (s.readBoolean()) p.setForParameterAnnotationMatch(); + AnnotationTypePattern p = new AndAnnotationTypePattern(AnnotationTypePattern.read(s, context), AnnotationTypePattern.read( + s, context)); + p.readLocation(context, s); + if (s.getMajorVersion() >= WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ160) { + if (s.readBoolean()) { + p.setForParameterAnnotationMatch(); + } } - return p; + return p; } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.AND); left.write(s); right.write(s); writeLocation(s); s.writeBoolean(isForParameterAnnotationMatch()); } - + public boolean equals(Object obj) { - if (!(obj instanceof AndAnnotationTypePattern)) return false; + if (!(obj instanceof AndAnnotationTypePattern)) { + return false; + } AndAnnotationTypePattern other = (AndAnnotationTypePattern) obj; - return (left.equals(other.left) && right.equals(other.right) && left.isForParameterAnnotationMatch()==right.isForParameterAnnotationMatch()); + return (left.equals(other.left) && right.equals(other.right) && left.isForParameterAnnotationMatch() == right + .isForParameterAnnotationMatch()); } - + public int hashCode() { int result = 17; - result = result*37 + left.hashCode(); - result = result*37 + right.hashCode(); - result = result*37 + (isForParameterAnnotationMatch()?0:1); - return result; + result = result * 37 + left.hashCode(); + result = result * 37 + right.hashCode(); + result = result * 37 + (isForParameterAnnotationMatch() ? 0 : 1); + return result; } - + public String toString() { return left.toString() + " " + right.toString(); } - - public AnnotationTypePattern getLeft() { return left; } - public AnnotationTypePattern getRight() { return right; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - + public AnnotationTypePattern getLeft() { + return left; + } + + public AnnotationTypePattern getRight() { + return right; + } + + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); - left.traverse(visitor,ret); - right.traverse(visitor,ret); + Object ret = accept(visitor, data); + left.traverse(visitor, ret); + right.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java index 58608a793..c3f003ad8 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java @@ -10,14 +10,13 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -27,10 +26,10 @@ import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Test; public class AndPointcut extends Pointcut { - Pointcut left, right; // exposed for testing + Pointcut left, right; // exposed for testing private int couldMatchKinds; - + public AndPointcut(Pointcut left, Pointcut right) { super(); this.left = left; @@ -39,7 +38,7 @@ public class AndPointcut extends Pointcut { setLocation(left.getSourceContext(), left.getStart(), right.getEnd()); couldMatchKinds = left.couldMatchKinds() & right.couldMatchKinds(); } - + public int couldMatchKinds() { return couldMatchKinds; } @@ -47,63 +46,65 @@ public class AndPointcut extends Pointcut { public FuzzyBoolean fastMatch(FastMatchInfo type) { return left.fastMatch(type).and(right.fastMatch(type)); } - + protected FuzzyBoolean matchInternal(Shadow shadow) { FuzzyBoolean leftMatch = left.match(shadow); - if (leftMatch.alwaysFalse()) return leftMatch; + if (leftMatch.alwaysFalse()) { + return leftMatch; + } return leftMatch.and(right.match(shadow)); } - + public String toString() { return "(" + left.toString() + " && " + right.toString() + ")"; } - - public boolean equals(Object other) { - if (!(other instanceof AndPointcut)) return false; - AndPointcut o = (AndPointcut)other; + + public boolean equals(Object other) { + if (!(other instanceof AndPointcut)) { + return false; + } + AndPointcut o = (AndPointcut) other; return o.left.equals(left) && o.right.equals(right); } - - public int hashCode() { - int result = 19; - result = 37*result + left.hashCode(); - result = 37*result + right.hashCode(); - return result; - } + + public int hashCode() { + int result = 19; + result = 37 * result + left.hashCode(); + result = 37 * result + right.hashCode(); + return result; + } public void resolveBindings(IScope scope, Bindings bindings) { left.resolveBindings(scope, bindings); right.resolveBindings(scope, bindings); } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.AND); left.write(s); right.write(s); writeLocation(s); } - + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { AndPointcut ret = new AndPointcut(Pointcut.read(s, context), Pointcut.read(s, context)); ret.readLocation(context, s); return ret; } - protected Test findResidueInternal(Shadow shadow, ExposedState state) { return Test.makeAnd(left.findResidue(shadow, state), right.findResidue(shadow, state)); } public Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { - AndPointcut ret = new AndPointcut(left.concretize(inAspect, declaringType, bindings), - right.concretize(inAspect, declaringType, bindings)); + AndPointcut ret = new AndPointcut(left.concretize(inAspect, declaringType, bindings), right.concretize(inAspect, + declaringType, bindings)); ret.copyLocationFrom(this); return ret; } - - public Pointcut parameterizeWith(Map typeVariableMap,World w) { - AndPointcut ret = new AndPointcut(left.parameterizeWith(typeVariableMap,w), - right.parameterizeWith(typeVariableMap,w)); + + public Pointcut parameterizeWith(Map typeVariableMap, World w) { + AndPointcut ret = new AndPointcut(left.parameterizeWith(typeVariableMap, w), right.parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; } @@ -116,14 +117,14 @@ public class AndPointcut extends Pointcut { return right; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); - left.traverse(visitor,ret); - right.traverse(visitor,ret); + Object ret = accept(visitor, data); + left.traverse(visitor, ret); + right.traverse(visitor, ret); return ret; } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndTypePattern.java index ebf79de6d..d23404f7f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndTypePattern.java @@ -10,14 +10,13 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; @@ -26,16 +25,17 @@ import org.aspectj.weaver.World; /** * left && right * - *

any binding to formals is explicitly forbidden for any composite by the language + *

+ * any binding to formals is explicitly forbidden for any composite by the language * * @author Erik Hilsdale * @author Jim Hugunin */ public class AndTypePattern extends TypePattern { private TypePattern left, right; - + public AndTypePattern(TypePattern left, TypePattern right) { - super(false,false); //?? we override all methods that care about includeSubtypes + super(false, false); // ?? we override all methods that care about includeSubtypes this.left = left; this.right = right; setLocation(left.getSourceContext(), left.getStart(), right.getEnd()); @@ -44,78 +44,79 @@ public class AndTypePattern extends TypePattern { protected boolean couldEverMatchSameTypesAs(TypePattern other) { return true; // don't dive into ands yet.... } + public FuzzyBoolean matchesInstanceof(ResolvedType type) { return left.matchesInstanceof(type).and(right.matchesInstanceof(type)); } protected boolean matchesExactly(ResolvedType type) { - //??? if these had side-effects, this sort-circuit could be a mistake + // ??? if these had side-effects, this sort-circuit could be a mistake return left.matchesExactly(type) && right.matchesExactly(type); } - + protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { - return left.matchesExactly(type,annotatedType) && right.matchesExactly(type,annotatedType); + return left.matchesExactly(type, annotatedType) && right.matchesExactly(type, annotatedType); } - + public boolean matchesStatically(ResolvedType type) { return left.matchesStatically(type) && right.matchesStatically(type); } - + public void setIsVarArgs(boolean isVarArgs) { this.isVarArgs = isVarArgs; left.setIsVarArgs(isVarArgs); right.setIsVarArgs(isVarArgs); } - + public void setAnnotationTypePattern(AnnotationTypePattern annPatt) { - if (annPatt == AnnotationTypePattern.ANY) return; + if (annPatt == AnnotationTypePattern.ANY) { + return; + } if (left.annotationPattern == AnnotationTypePattern.ANY) { left.setAnnotationTypePattern(annPatt); } else { - left.setAnnotationTypePattern( - new AndAnnotationTypePattern(left.annotationPattern,annPatt)); + left.setAnnotationTypePattern(new AndAnnotationTypePattern(left.annotationPattern, annPatt)); } if (right.annotationPattern == AnnotationTypePattern.ANY) { - right.setAnnotationTypePattern(annPatt); + right.setAnnotationTypePattern(annPatt); } else { - right.setAnnotationTypePattern( - new AndAnnotationTypePattern(right.annotationPattern,annPatt)); + right.setAnnotationTypePattern(new AndAnnotationTypePattern(right.annotationPattern, annPatt)); } } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(TypePattern.AND); left.write(s); right.write(s); writeLocation(s); } - + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { AndTypePattern ret = new AndTypePattern(TypePattern.read(s, context), TypePattern.read(s, context)); ret.readLocation(context, s); - if (ret.left.isVarArgs && ret.right.isVarArgs) ret.isVarArgs = true; + if (ret.left.isVarArgs && ret.right.isVarArgs) { + ret.isVarArgs = true; + } return ret; } - public TypePattern resolveBindings( - IScope scope, - Bindings bindings, - boolean allowBinding, boolean requireExactType) - { - if (requireExactType) return notExactType(scope); + public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) { + if (requireExactType) { + return notExactType(scope); + } left = left.resolveBindings(scope, bindings, false, false); right = right.resolveBindings(scope, bindings, false, false); return this; } - - public TypePattern parameterizeWith(Map typeVariableMap,World w) { - TypePattern newLeft = left.parameterizeWith(typeVariableMap,w); - TypePattern newRight = right.parameterizeWith(typeVariableMap,w); - AndTypePattern ret = new AndTypePattern(newLeft,newRight); + + public TypePattern parameterizeWith(Map typeVariableMap, World w) { + TypePattern newLeft = left.parameterizeWith(typeVariableMap, w); + TypePattern newRight = right.parameterizeWith(typeVariableMap, w); + AndTypePattern ret = new AndTypePattern(newLeft, newRight); ret.copyLocationFrom(this); return ret; } - + public String toString() { StringBuffer buff = new StringBuffer(); if (annotationPattern != AnnotationTypePattern.ANY) { @@ -134,16 +135,18 @@ public class AndTypePattern extends TypePattern { return buff.toString(); } - public TypePattern getLeft() { - return left; - } + public TypePattern getLeft() { + return left; + } - public TypePattern getRight() { - return right; - } + public TypePattern getRight() { + return right; + } public boolean equals(Object obj) { - if (! (obj instanceof AndTypePattern)) return false; + if (!(obj instanceof AndTypePattern)) { + return false; + } AndTypePattern atp = (AndTypePattern) obj; return left.equals(atp.left) && right.equals(atp.right); } @@ -151,8 +154,10 @@ public class AndTypePattern extends TypePattern { public boolean isStarAnnotation() { return left.isStarAnnotation() && right.isStarAnnotation(); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ public int hashCode() { @@ -162,12 +167,12 @@ public class AndTypePattern extends TypePattern { return ret; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); + Object ret = accept(visitor, data); left.traverse(visitor, ret); right.traverse(visitor, ret); return ret; diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationPatternList.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationPatternList.java index f423eb350..6b6d820b7 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationPatternList.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnnotationPatternList.java @@ -9,12 +9,12 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -23,21 +23,20 @@ import org.aspectj.weaver.World; /** * @author colyer - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * + * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code + * Templates */ public class AnnotationPatternList extends PatternNode { private AnnotationTypePattern[] typePatterns; int ellipsisCount = 0; - - public static final AnnotationPatternList EMPTY = - new AnnotationPatternList(new AnnotationTypePattern[] {}); - - public static final AnnotationPatternList ANY = - new AnnotationPatternList(new AnnotationTypePattern[] {AnnotationTypePattern.ELLIPSIS}); - + + public static final AnnotationPatternList EMPTY = new AnnotationPatternList(new AnnotationTypePattern[] {}); + + public static final AnnotationPatternList ANY = new AnnotationPatternList( + new AnnotationTypePattern[] { AnnotationTypePattern.ELLIPSIS }); + public AnnotationPatternList() { typePatterns = new AnnotationTypePattern[0]; ellipsisCount = 0; @@ -45,11 +44,13 @@ public class AnnotationPatternList extends PatternNode { public AnnotationPatternList(AnnotationTypePattern[] arguments) { this.typePatterns = arguments; - for (int i=0; i 0) && (ellipsisCount == 0)) { return FuzzyBoolean.NO; } // now work through the args and the patterns, skipping at ellipsis - FuzzyBoolean ret = FuzzyBoolean.YES; - int argsIndex = 0; - for (int i = 0; i < typePatterns.length; i++) { + FuzzyBoolean ret = FuzzyBoolean.YES; + int argsIndex = 0; + for (int i = 0; i < typePatterns.length; i++) { if (typePatterns[i] == AnnotationTypePattern.ELLIPSIS) { // match ellipsisMatchCount args argsIndex += numArgsMatchedByEllipsis; @@ -93,28 +96,32 @@ public class AnnotationPatternList extends PatternNode { } else { // match the argument type at argsIndex with the ExactAnnotationTypePattern // we know it is exact because nothing else is allowed in args - if (someArgs[argsIndex].isPrimitiveType()) return FuzzyBoolean.NO; // can never match - ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern)typePatterns[i]; + if (someArgs[argsIndex].isPrimitiveType()) { + return FuzzyBoolean.NO; // can never match + } + ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern) typePatterns[i]; FuzzyBoolean matches = ap.matchesRuntimeType(someArgs[argsIndex]); if (matches == FuzzyBoolean.NO) { - return FuzzyBoolean.MAYBE; // could still match at runtime + return FuzzyBoolean.MAYBE; // could still match at runtime } else { argsIndex++; ret = ret.and(matches); } } - } - return ret; + } + return ret; } - - public int size() { return typePatterns.length; } - + + public int size() { + return typePatterns.length; + } + public AnnotationTypePattern get(int index) { return typePatterns[index]; } public AnnotationPatternList resolveBindings(IScope scope, Bindings bindings, boolean allowBinding) { - for (int i=0; i 0) buf.append(", "); - if (type == AnnotationTypePattern.ELLIPSIS) { - buf.append(".."); - } else { - String annPatt = type.toString(); - buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt); - } - } - buf.append(")"); - return buf.toString(); - } - + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append("("); + for (int i = 0, len = typePatterns.length; i < len; i++) { + AnnotationTypePattern type = typePatterns[i]; + if (i > 0) { + buf.append(", "); + } + if (type == AnnotationTypePattern.ELLIPSIS) { + buf.append(".."); + } else { + String annPatt = type.toString(); + buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt); + } + } + buf.append(")"); + return buf.toString(); + } + public boolean equals(Object other) { - if (!(other instanceof AnnotationPatternList)) return false; - AnnotationPatternList o = (AnnotationPatternList)other; + if (!(other instanceof AnnotationPatternList)) { + return false; + } + AnnotationPatternList o = (AnnotationPatternList) other; int len = o.typePatterns.length; - if (len != this.typePatterns.length) return false; - for (int i=0; i 1) { - scope.message(IMessage.ERROR, this, - "uses more than one .. in args (compiler limitation)"); + scope.message(IMessage.ERROR, this, "uses more than one .. in args (compiler limitation)"); } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.Pointcut#concretize1(org.aspectj.weaver.ResolvedType, org.aspectj.weaver.IntMap) */ protected Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { if (isDeclare(bindings.getEnclosingAdvice())) { - // Enforce rule about which designators are supported in declare - inAspect.getWorld().showMessage(IMessage.ERROR, - WeaverMessages.format(WeaverMessages.ARGS_IN_DECLARE), + // Enforce rule about which designators are supported in declare + inAspect.getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ARGS_IN_DECLARE), bindings.getEnclosingAdvice().getSourceLocation(), null); - return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); + return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); } AnnotationPatternList list = arguments.resolveReferences(bindings); Pointcut ret = new ArgsAnnotationPointcut(list); @@ -117,22 +123,26 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut { return ret; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.Pointcut#findResidue(org.aspectj.weaver.Shadow, org.aspectj.weaver.patterns.ExposedState) */ protected Test findResidueInternal(Shadow shadow, ExposedState state) { int len = shadow.getArgCount(); - + // do some quick length tests first int numArgsMatchedByEllipsis = (len + arguments.ellipsisCount) - arguments.size(); - if (numArgsMatchedByEllipsis < 0) return Literal.FALSE; // should never happen + if (numArgsMatchedByEllipsis < 0) { + return Literal.FALSE; // should never happen + } if ((numArgsMatchedByEllipsis > 0) && (arguments.ellipsisCount == 0)) { return Literal.FALSE; // should never happen } // now work through the args and the patterns, skipping at ellipsis - Test ret = Literal.TRUE; - int argsIndex = 0; - for (int i = 0; i < arguments.size(); i++) { + Test ret = Literal.TRUE; + int argsIndex = 0; + for (int i = 0; i < arguments.size(); i++) { if (arguments.get(i) == AnnotationTypePattern.ELLIPSIS) { // match ellipsisMatchCount args argsIndex += numArgsMatchedByEllipsis; @@ -141,41 +151,37 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut { } else { // match the argument type at argsIndex with the ExactAnnotationTypePattern // we know it is exact because nothing else is allowed in args - ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern)arguments.get(i); + ExactAnnotationTypePattern ap = (ExactAnnotationTypePattern) arguments.get(i); UnresolvedType argType = shadow.getArgType(argsIndex); ResolvedType rArgType = argType.resolve(shadow.getIWorld()); if (rArgType.isMissing()) { - shadow.getIWorld().getLint().cantFindType.signal( - new String[] {WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_ARG_TYPE,argType.getName())}, - shadow.getSourceLocation(), - new ISourceLocation[]{getSourceLocation()} - ); -// IMessage msg = new Message( -// WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_ARG_TYPE,argType.getName()), -// "",IMessage.ERROR,shadow.getSourceLocation(),null,new ISourceLocation[]{getSourceLocation()}); - } + shadow.getIWorld().getLint().cantFindType.signal(new String[] { WeaverMessages.format( + WeaverMessages.CANT_FIND_TYPE_ARG_TYPE, argType.getName()) }, shadow.getSourceLocation(), + new ISourceLocation[] { getSourceLocation() }); + // IMessage msg = new Message( + // WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_ARG_TYPE,argType.getName()), + // "",IMessage.ERROR,shadow.getSourceLocation(),null,new ISourceLocation[]{getSourceLocation()}); + } ResolvedType rAnnType = ap.getAnnotationType().resolve(shadow.getIWorld()); if (ap instanceof BindingAnnotationTypePattern) { - BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern)ap; - Var annvar = shadow.getArgAnnotationVar(argsIndex,rAnnType); - state.set(btp.getFormalIndex(),annvar); + BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) ap; + Var annvar = shadow.getArgAnnotationVar(argsIndex, rAnnType); + state.set(btp.getFormalIndex(), annvar); } if (!ap.matches(rArgType).alwaysTrue()) { // we need a test... - ret = Test.makeAnd(ret, - Test.makeHasAnnotation( - shadow.getArgVar(argsIndex), - rAnnType)); - } + ret = Test.makeAnd(ret, Test.makeHasAnnotation(shadow.getArgVar(argsIndex), rAnnType)); + } argsIndex++; } - } - return ret; + } + return ret; } - - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingAnnotationTypePatterns() */ public List getBindingAnnotationTypePatterns() { @@ -188,58 +194,72 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut { } return l; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingTypePatterns() */ public List getBindingTypePatterns() { - return Collections.EMPTY_LIST; + return Collections.EMPTY_LIST; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.ATARGS); arguments.write(s); writeLocation(s); } - + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { - AnnotationPatternList annotationPatternList = AnnotationPatternList.read(s,context); + AnnotationPatternList annotationPatternList = AnnotationPatternList.read(s, context); ArgsAnnotationPointcut ret = new ArgsAnnotationPointcut(annotationPatternList); ret.readLocation(context, s); return ret; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { - if (!(obj instanceof ArgsAnnotationPointcut)) return false; + if (!(obj instanceof ArgsAnnotationPointcut)) { + return false; + } ArgsAnnotationPointcut other = (ArgsAnnotationPointcut) obj; return other.arguments.equals(arguments); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ public int hashCode() { - return 17 + 37*arguments.hashCode(); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - private void buildDeclarationText() { - StringBuffer buf = new StringBuffer("@args"); - buf.append(arguments.toString()); - this.declarationText = buf.toString(); - } - - public String toString() { return this.declarationText; } - - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } + return 17 + 37 * arguments.hashCode(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + private void buildDeclarationText() { + StringBuffer buf = new StringBuffer("@args"); + buf.append(arguments.toString()); + this.declarationText = buf.toString(); + } + + public String toString() { + return this.declarationText; + } + + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java index 68d2d62f1..c10e090d4 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ArgsPointcut.java @@ -10,10 +10,8 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -24,6 +22,7 @@ import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -44,56 +43,56 @@ import org.aspectj.weaver.ast.Test; public class ArgsPointcut extends NameBindingPointcut { private static final String ASPECTJ_JP_SIGNATURE_PREFIX = "Lorg/aspectj/lang/JoinPoint"; private static final String ASPECTJ_SYNTHETIC_SIGNATURE_PREFIX = "Lorg/aspectj/runtime/internal/"; - + private TypePatternList arguments; private String stringRepresentation; - + public ArgsPointcut(TypePatternList arguments) { this.arguments = arguments; this.pointcutKind = ARGS; this.stringRepresentation = "args" + arguments.toString() + ""; } - public TypePatternList getArguments() { - return arguments; - } + public TypePatternList getArguments() { + return arguments; + } + + public Pointcut parameterizeWith(Map typeVariableMap, World w) { + ArgsPointcut ret = new ArgsPointcut(this.arguments.parameterizeWith(typeVariableMap, w)); + ret.copyLocationFrom(this); + return ret; + } - public Pointcut parameterizeWith(Map typeVariableMap,World w) { - ArgsPointcut ret = new ArgsPointcut(this.arguments.parameterizeWith(typeVariableMap,w)); - ret.copyLocationFrom(this); - return ret; - } - public int couldMatchKinds() { - return Shadow.ALL_SHADOW_KINDS_BITS; // empty args() matches jps with no args + return Shadow.ALL_SHADOW_KINDS_BITS; // empty args() matches jps with no args } - public FuzzyBoolean fastMatch(FastMatchInfo type) { + public FuzzyBoolean fastMatch(FastMatchInfo type) { return FuzzyBoolean.MAYBE; } - + protected FuzzyBoolean matchInternal(Shadow shadow) { ResolvedType[] argumentsToMatchAgainst = getArgumentsToMatchAgainst(shadow); - FuzzyBoolean ret = - arguments.matches(argumentsToMatchAgainst, TypePattern.DYNAMIC); + FuzzyBoolean ret = arguments.matches(argumentsToMatchAgainst, TypePattern.DYNAMIC); return ret; } - + private ResolvedType[] getArgumentsToMatchAgainst(Shadow shadow) { - + if (shadow.isShadowForArrayConstructionJoinpoint()) { - return shadow.getArgumentTypesForArrayConstructionShadow(); + return shadow.getArgumentTypesForArrayConstructionShadow(); } - + ResolvedType[] argumentsToMatchAgainst = shadow.getIWorld().resolve(shadow.getGenericArgTypes()); - + // special treatment for adviceexecution which may have synthetic arguments we // want to ignore. if (shadow.getKind() == Shadow.AdviceExecution) { int numExtraArgs = 0; for (int i = 0; i < argumentsToMatchAgainst.length; i++) { String argumentSignature = argumentsToMatchAgainst[i].getSignature(); - if (argumentSignature.startsWith(ASPECTJ_JP_SIGNATURE_PREFIX) || argumentSignature.startsWith(ASPECTJ_SYNTHETIC_SIGNATURE_PREFIX)) { + if (argumentSignature.startsWith(ASPECTJ_JP_SIGNATURE_PREFIX) + || argumentSignature.startsWith(ASPECTJ_SYNTHETIC_SIGNATURE_PREFIX)) { numExtraArgs++; } else { // normal arg after AJ type means earlier arg was NOT synthetic @@ -106,27 +105,31 @@ public class ArgsPointcut extends NameBindingPointcut { System.arraycopy(argumentsToMatchAgainst, 0, argsSubset, 0, newArgLength); argumentsToMatchAgainst = argsSubset; } - } else if (shadow.getKind() == Shadow.ConstructorExecution) { + } else if (shadow.getKind() == Shadow.ConstructorExecution) { if (shadow.getMatchingSignature().getParameterTypes().length < argumentsToMatchAgainst.length) { - // there are one or more synthetic args on the end, caused by non-public itd constructor + // there are one or more synthetic args on the end, caused by non-public itd constructor int newArgLength = shadow.getMatchingSignature().getParameterTypes().length; ResolvedType[] argsSubset = new ResolvedType[newArgLength]; System.arraycopy(argumentsToMatchAgainst, 0, argsSubset, 0, newArgLength); - argumentsToMatchAgainst = argsSubset; + argumentsToMatchAgainst = argsSubset; } } - + return argumentsToMatchAgainst; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingAnnotationTypePatterns() */ public List getBindingAnnotationTypePatterns() { - return Collections.EMPTY_LIST; + return Collections.EMPTY_LIST; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingTypePatterns() */ public List getBindingTypePatterns() { @@ -139,50 +142,48 @@ public class ArgsPointcut extends NameBindingPointcut { } return l; } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.ARGS); arguments.write(s); writeLocation(s); } - + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { ArgsPointcut ret = new ArgsPointcut(TypePatternList.read(s, context)); ret.readLocation(context, s); return ret; } - public boolean equals(Object other) { - if (!(other instanceof ArgsPointcut)) return false; - ArgsPointcut o = (ArgsPointcut)other; + if (!(other instanceof ArgsPointcut)) { + return false; + } + ArgsPointcut o = (ArgsPointcut) other; return o.arguments.equals(this.arguments); } - public int hashCode() { - return arguments.hashCode(); - } - + public int hashCode() { + return arguments.hashCode(); + } + public void resolveBindings(IScope scope, Bindings bindings) { arguments.resolveBindings(scope, bindings, true, true); if (arguments.ellipsisCount > 1) { - scope.message(IMessage.ERROR, this, - "uses more than one .. in args (compiler limitation)"); + scope.message(IMessage.ERROR, this, "uses more than one .. in args (compiler limitation)"); } } - + public void postRead(ResolvedType enclosingType) { arguments.postRead(enclosingType); } - public Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { if (isDeclare(bindings.getEnclosingAdvice())) { - // Enforce rule about which designators are supported in declare - inAspect.getWorld().showMessage(IMessage.ERROR, - WeaverMessages.format(WeaverMessages.ARGS_IN_DECLARE), - bindings.getEnclosingAdvice().getSourceLocation(), null); - return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); + // Enforce rule about which designators are supported in declare + inAspect.getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ARGS_IN_DECLARE), + bindings.getEnclosingAdvice().getSourceLocation(), null); + return Pointcut.makeMatchesNothing(Pointcut.CONCRETE); } TypePatternList args = arguments.resolveReferences(bindings); if (inAspect.crosscuttingMembers != null) { @@ -196,29 +197,27 @@ public class ArgsPointcut extends NameBindingPointcut { private Test findResidueNoEllipsis(Shadow shadow, ExposedState state, TypePattern[] patterns) { ResolvedType[] argumentsToMatchAgainst = getArgumentsToMatchAgainst(shadow); int len = argumentsToMatchAgainst.length; - //System.err.println("boudn to : " + len + ", " + patterns.length); + // System.err.println("boudn to : " + len + ", " + patterns.length); if (patterns.length != len) { return Literal.FALSE; } - + Test ret = Literal.TRUE; - - for (int i=0; i < len; i++) { + + for (int i = 0; i < len; i++) { UnresolvedType argType = shadow.getGenericArgTypes()[i]; TypePattern type = patterns[i]; - ResolvedType argRTX = shadow.getIWorld().resolve(argType,true); + ResolvedType argRTX = shadow.getIWorld().resolve(argType, true); if (!(type instanceof BindingTypePattern)) { - if (argRTX.isMissing()) { - shadow.getIWorld().getLint().cantFindType.signal( - new String[] {WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_ARG_TYPE,argType.getName())}, - shadow.getSourceLocation(), - new ISourceLocation[]{getSourceLocation()} - ); -// IMessage msg = new Message( -// WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_ARG_TYPE,argType.getName()), -// "",IMessage.ERROR,shadow.getSourceLocation(),null,new ISourceLocation[]{getSourceLocation()}); -// shadow.getIWorld().getMessageHandler().handleMessage(msg); - } + if (argRTX.isMissing()) { + shadow.getIWorld().getLint().cantFindType.signal(new String[] { WeaverMessages.format( + WeaverMessages.CANT_FIND_TYPE_ARG_TYPE, argType.getName()) }, shadow.getSourceLocation(), + new ISourceLocation[] { getSourceLocation() }); + // IMessage msg = new Message( + // WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_ARG_TYPE,argType.getName()), + // "",IMessage.ERROR,shadow.getSourceLocation(),null,new ISourceLocation[]{getSourceLocation()}); + // shadow.getIWorld().getMessageHandler().handleMessage(msg); + } if (type.matchesInstanceof(argRTX).alwaysTrue()) { continue; } @@ -227,42 +226,36 @@ public class ArgsPointcut extends NameBindingPointcut { World world = shadow.getIWorld(); ResolvedType typeToExpose = type.getExactType().resolve(world); if (typeToExpose.isParameterizedType()) { - boolean inDoubt = (type.matchesInstanceof(argRTX) == FuzzyBoolean.MAYBE); + boolean inDoubt = (type.matchesInstanceof(argRTX) == FuzzyBoolean.MAYBE); if (inDoubt && world.getLint().uncheckedArgument.isEnabled()) { String uncheckedMatchWith = typeToExpose.getSimpleBaseName(); if (argRTX.isParameterizedType() && (argRTX.getRawType() == typeToExpose.getRawType())) { uncheckedMatchWith = argRTX.getSimpleName(); } if (!isUncheckedArgumentWarningSuppressed()) { - world.getLint().uncheckedArgument.signal( - new String[] { - typeToExpose.getSimpleName(), - uncheckedMatchWith, - typeToExpose.getSimpleBaseName(), - shadow.toResolvedString(world)}, - getSourceLocation(), - new ISourceLocation[] {shadow.getSourceLocation()}); - } + world.getLint().uncheckedArgument.signal(new String[] { typeToExpose.getSimpleName(), uncheckedMatchWith, + typeToExpose.getSimpleBaseName(), shadow.toResolvedString(world) }, getSourceLocation(), + new ISourceLocation[] { shadow.getSourceLocation() }); + } } - } - - ret = Test.makeAnd(ret, - exposeStateForVar(shadow.getArgVar(i), type, state,shadow.getIWorld())); + } + + ret = Test.makeAnd(ret, exposeStateForVar(shadow.getArgVar(i), type, state, shadow.getIWorld())); } - - return ret; + + return ret; } /** - * We need to find out if someone has put the @SuppressAjWarnings{"uncheckedArgument"} - * annotation somewhere. That somewhere is going to be an a piece of advice that uses this - * pointcut. But how do we find it??? + * We need to find out if someone has put the @SuppressAjWarnings{"uncheckedArgument"} annotation somewhere. That somewhere is + * going to be an a piece of advice that uses this pointcut. But how do we find it??? + * * @return */ private boolean isUncheckedArgumentWarningSuppressed() { return false; } - + protected Test findResidueInternal(Shadow shadow, ExposedState state) { ResolvedType[] argsToMatch = getArgumentsToMatchAgainst(shadow); if (arguments.matches(argsToMatch, TypePattern.DYNAMIC).alwaysFalse()) { @@ -270,7 +263,7 @@ public class ArgsPointcut extends NameBindingPointcut { } int ellipsisCount = arguments.ellipsisCount; if (ellipsisCount == 0) { - return findResidueNoEllipsis(shadow, state, arguments.getTypePatterns()); + return findResidueNoEllipsis(shadow, state, arguments.getTypePatterns()); } else if (ellipsisCount == 1) { TypePattern[] patternsWithEllipsis = arguments.getTypePatterns(); TypePattern[] patternsWithoutEllipsis = new TypePattern[argsToMatch.length]; @@ -282,8 +275,7 @@ public class ArgsPointcut extends NameBindingPointcut { while (indexWithoutEllipsis < lenWithoutEllipsis) { TypePattern p = patternsWithEllipsis[indexWithEllipsis++]; if (p == TypePattern.ELLIPSIS) { - int newLenWithoutEllipsis = - lenWithoutEllipsis - (lenWithEllipsis-indexWithEllipsis); + int newLenWithoutEllipsis = lenWithoutEllipsis - (lenWithEllipsis - indexWithEllipsis); while (indexWithoutEllipsis < newLenWithoutEllipsis) { patternsWithoutEllipsis[indexWithoutEllipsis++] = TypePattern.ANY; } @@ -296,12 +288,12 @@ public class ArgsPointcut extends NameBindingPointcut { throw new BCException("unimplemented"); } } - + public String toString() { return this.stringRepresentation; } - - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } + + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingAnnotationFieldTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingAnnotationFieldTypePattern.java index 96a651e7f..47c4d4fb3 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingAnnotationFieldTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingAnnotationFieldTypePattern.java @@ -11,7 +11,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; @@ -20,6 +19,7 @@ import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ReferenceType; @@ -39,133 +39,138 @@ import org.aspectj.weaver.World; */ public class BindingAnnotationFieldTypePattern extends ExactAnnotationTypePattern implements BindingPattern { - protected int formalIndex; - UnresolvedType formalType; // In this construct the formal type differs from the annotation type - - public BindingAnnotationFieldTypePattern(UnresolvedType formalType, int formalIndex, UnresolvedType theAnnotationType) { - super(theAnnotationType, null); - this.formalIndex = formalIndex; - this.formalType = formalType; - } - - public void resolveBinding(World world) { - if (resolved) return; - resolved = true; - formalType = world.resolve(formalType); - annotationType = world.resolve(annotationType); - ResolvedType annoType = (ResolvedType) annotationType; - if (!annoType.isAnnotation()) { - IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE, annoType.getName()), - getSourceLocation()); - world.getMessageHandler().handleMessage(m); - resolved = false; - } - } - - public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { - throw new BCException("Parameterization not implemented for annotation field binding construct (compiler limitation)"); - // UnresolvedType newAnnotationType = annotationType; - // if (annotationType.isTypeVariableReference()) { - // TypeVariableReference t = (TypeVariableReference) annotationType; - // String key = t.getTypeVariable().getName(); - // if (typeVariableMap.containsKey(key)) { - // newAnnotationType = (UnresolvedType) typeVariableMap.get(key); - // } - // } else if (annotationType.isParameterizedType()) { - // newAnnotationType = annotationType.parameterize(typeVariableMap); - // } - // BindingAnnotationTypePattern ret = new BindingAnnotationTypePattern(newAnnotationType, this.formalIndex); - // if (newAnnotationType instanceof ResolvedType) { - // ResolvedType rat = (ResolvedType) newAnnotationType; - // verifyRuntimeRetention(rat.getWorld(), rat); - // } - // ret.copyLocationFrom(this); - // return ret; - } - - public int getFormalIndex() { - return formalIndex; - } - - public boolean equals(Object obj) { - if (!(obj instanceof BindingAnnotationFieldTypePattern)) return false; - BindingAnnotationFieldTypePattern btp = (BindingAnnotationFieldTypePattern) obj; - return (btp.formalIndex == formalIndex) && (annotationType.equals(btp.annotationType)) && (formalType.equals(btp.formalType)); - } - - public int hashCode() { - return (annotationType.hashCode() * 37 + formalIndex * 37) + formalType.hashCode(); - } - - public AnnotationTypePattern remapAdviceFormals(IntMap bindings) { - if (!bindings.hasKey(formalIndex)) { - throw new BCException("Annotation field binding reference must be bound (compiler limitation)"); - // must be something like returning the unbound form: return new ExactAnnotationTypePattern(annotationType, - // null); - } else { - int newFormalIndex = bindings.get(formalIndex); - return new BindingAnnotationFieldTypePattern(formalType, newFormalIndex, annotationType); - } - } - - public void write(DataOutputStream s) throws IOException { - s.writeByte(AnnotationTypePattern.BINDINGFIELD); - formalType.write(s); // the type of the field within the annotation - s.writeShort((short) formalIndex); - annotationType.write(s); // the annotation type - writeLocation(s); - } - - public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { - AnnotationTypePattern ret = new BindingAnnotationFieldTypePattern(UnresolvedType.read(s), s.readShort(), UnresolvedType.read(s)); - ret.readLocation(context, s); - return ret; - } - - - public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations) { - // Inheritance irrelevant because @annotation(Anno(x)) only supported at method execution join points (compiler limitation) -// boolean checkSupers = false; -// if (getResolvedAnnotationType().hasAnnotation(UnresolvedType.AT_INHERITED)) { -// if (annotated instanceof ResolvedType) { -// checkSupers = true; -// } -// } -// - if (annotated.hasAnnotation(annotationType)) { - if (annotationType instanceof ReferenceType) { - ReferenceType rt = (ReferenceType) annotationType; - if (rt.getRetentionPolicy() != null && rt.getRetentionPolicy().equals("SOURCE")) { - rt.getWorld().getMessageHandler().handleMessage( - MessageUtil.warn(WeaverMessages.format(WeaverMessages.NO_MATCH_BECAUSE_SOURCE_RETENTION, annotationType, annotated), - getSourceLocation())); - return FuzzyBoolean.NO; - } - ResolvedMember[] methods = rt.getDeclaredMethods(); - boolean found = false; - for (int i = 0; i < methods.length && !found; i++) { - if (methods[i].getReturnType().equals(formalType)) { - found = true; - } - } - return (found ? FuzzyBoolean.YES : FuzzyBoolean.NO); - } - } -// else if (checkSupers) { -// ResolvedType toMatchAgainst = ((ResolvedType) annotated).getSuperclass(); -// while (toMatchAgainst != null) { -// if (toMatchAgainst.hasAnnotation(annotationType)) { -// return FuzzyBoolean.YES; -// } -// toMatchAgainst = toMatchAgainst.getSuperclass(); -// } -// } -// - return FuzzyBoolean.NO; - } - - public UnresolvedType getFormalType() { - return formalType; - } + protected int formalIndex; + UnresolvedType formalType; // In this construct the formal type differs from the annotation type + + public BindingAnnotationFieldTypePattern(UnresolvedType formalType, int formalIndex, UnresolvedType theAnnotationType) { + super(theAnnotationType, null); + this.formalIndex = formalIndex; + this.formalType = formalType; + } + + public void resolveBinding(World world) { + if (resolved) { + return; + } + resolved = true; + formalType = world.resolve(formalType); + annotationType = world.resolve(annotationType); + ResolvedType annoType = (ResolvedType) annotationType; + if (!annoType.isAnnotation()) { + IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE, annoType + .getName()), getSourceLocation()); + world.getMessageHandler().handleMessage(m); + resolved = false; + } + } + + public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { + throw new BCException("Parameterization not implemented for annotation field binding construct (compiler limitation)"); + // UnresolvedType newAnnotationType = annotationType; + // if (annotationType.isTypeVariableReference()) { + // TypeVariableReference t = (TypeVariableReference) annotationType; + // String key = t.getTypeVariable().getName(); + // if (typeVariableMap.containsKey(key)) { + // newAnnotationType = (UnresolvedType) typeVariableMap.get(key); + // } + // } else if (annotationType.isParameterizedType()) { + // newAnnotationType = annotationType.parameterize(typeVariableMap); + // } + // BindingAnnotationTypePattern ret = new BindingAnnotationTypePattern(newAnnotationType, this.formalIndex); + // if (newAnnotationType instanceof ResolvedType) { + // ResolvedType rat = (ResolvedType) newAnnotationType; + // verifyRuntimeRetention(rat.getWorld(), rat); + // } + // ret.copyLocationFrom(this); + // return ret; + } + + public int getFormalIndex() { + return formalIndex; + } + + public boolean equals(Object obj) { + if (!(obj instanceof BindingAnnotationFieldTypePattern)) { + return false; + } + BindingAnnotationFieldTypePattern btp = (BindingAnnotationFieldTypePattern) obj; + return (btp.formalIndex == formalIndex) && (annotationType.equals(btp.annotationType)) + && (formalType.equals(btp.formalType)); + } + + public int hashCode() { + return (annotationType.hashCode() * 37 + formalIndex * 37) + formalType.hashCode(); + } + + public AnnotationTypePattern remapAdviceFormals(IntMap bindings) { + if (!bindings.hasKey(formalIndex)) { + throw new BCException("Annotation field binding reference must be bound (compiler limitation)"); + // must be something like returning the unbound form: return new ExactAnnotationTypePattern(annotationType, + // null); + } else { + int newFormalIndex = bindings.get(formalIndex); + return new BindingAnnotationFieldTypePattern(formalType, newFormalIndex, annotationType); + } + } + + public void write(CompressingDataOutputStream s) throws IOException { + s.writeByte(AnnotationTypePattern.BINDINGFIELD); + formalType.write(s); // the type of the field within the annotation + s.writeShort((short) formalIndex); + annotationType.write(s); // the annotation type + writeLocation(s); + } + + public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { + AnnotationTypePattern ret = new BindingAnnotationFieldTypePattern(UnresolvedType.read(s), s.readShort(), UnresolvedType + .read(s)); + ret.readLocation(context, s); + return ret; + } + + public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations) { + // Inheritance irrelevant because @annotation(Anno(x)) only supported at method execution join points (compiler limitation) + // boolean checkSupers = false; + // if (getResolvedAnnotationType().hasAnnotation(UnresolvedType.AT_INHERITED)) { + // if (annotated instanceof ResolvedType) { + // checkSupers = true; + // } + // } + // + if (annotated.hasAnnotation(annotationType)) { + if (annotationType instanceof ReferenceType) { + ReferenceType rt = (ReferenceType) annotationType; + if (rt.getRetentionPolicy() != null && rt.getRetentionPolicy().equals("SOURCE")) { + rt.getWorld().getMessageHandler().handleMessage( + MessageUtil.warn(WeaverMessages.format(WeaverMessages.NO_MATCH_BECAUSE_SOURCE_RETENTION, + annotationType, annotated), getSourceLocation())); + return FuzzyBoolean.NO; + } + ResolvedMember[] methods = rt.getDeclaredMethods(); + boolean found = false; + for (int i = 0; i < methods.length && !found; i++) { + if (methods[i].getReturnType().equals(formalType)) { + found = true; + } + } + return (found ? FuzzyBoolean.YES : FuzzyBoolean.NO); + } + } + // else if (checkSupers) { + // ResolvedType toMatchAgainst = ((ResolvedType) annotated).getSuperclass(); + // while (toMatchAgainst != null) { + // if (toMatchAgainst.hasAnnotation(annotationType)) { + // return FuzzyBoolean.YES; + // } + // toMatchAgainst = toMatchAgainst.getSuperclass(); + // } + // } + // + return FuzzyBoolean.NO; + } + + public UnresolvedType getFormalType() { + return formalType; + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java index f0be890a1..142f6155e 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java @@ -9,13 +9,13 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.MessageUtil; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -28,47 +28,49 @@ import org.aspectj.weaver.World; public class BindingAnnotationTypePattern extends ExactAnnotationTypePattern implements BindingPattern { protected int formalIndex; - + /** * @param annotationType */ public BindingAnnotationTypePattern(UnresolvedType annotationType, int index) { - super(annotationType,null); + super(annotationType, null); this.formalIndex = index; } - + public BindingAnnotationTypePattern(FormalBinding binding) { - this(binding.getType(),binding.getIndex()); + this(binding.getType(), binding.getIndex()); } - + public void resolveBinding(World world) { - if (resolved) return; + if (resolved) { + return; + } resolved = true; annotationType = annotationType.resolve(world); ResolvedType resolvedAnnotationType = (ResolvedType) annotationType; if (!resolvedAnnotationType.isAnnotation()) { - IMessage m = MessageUtil.error( - WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE,annotationType.getName()), - getSourceLocation()); + IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE, annotationType + .getName()), getSourceLocation()); world.getMessageHandler().handleMessage(m); resolved = false; } - if (annotationType.isTypeVariableReference()) return; // we'll deal with this next check when the type var is actually bound... - verifyRuntimeRetention(world, resolvedAnnotationType); + if (annotationType.isTypeVariableReference()) { + return; // we'll deal with this next check when the type var is actually bound... + } + verifyRuntimeRetention(world, resolvedAnnotationType); } private void verifyRuntimeRetention(World world, ResolvedType resolvedAnnotationType) { if (!resolvedAnnotationType.isAnnotationWithRuntimeRetention()) { // default is class visibility - // default is class visibility - IMessage m = MessageUtil.error( - WeaverMessages.format(WeaverMessages.BINDING_NON_RUNTIME_RETENTION_ANNOTATION,annotationType.getName()), - getSourceLocation()); + // default is class visibility + IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.BINDING_NON_RUNTIME_RETENTION_ANNOTATION, + annotationType.getName()), getSourceLocation()); world.getMessageHandler().handleMessage(m); - resolved = false; + resolved = false; } } - - public AnnotationTypePattern parameterizeWith(Map typeVariableMap,World w) { + + public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { UnresolvedType newAnnotationType = annotationType; if (annotationType.isTypeVariableReference()) { TypeVariableReference t = (TypeVariableReference) annotationType; @@ -79,56 +81,58 @@ public class BindingAnnotationTypePattern extends ExactAnnotationTypePattern imp } else if (annotationType.isParameterizedType()) { newAnnotationType = annotationType.parameterize(typeVariableMap); } - BindingAnnotationTypePattern ret = new BindingAnnotationTypePattern(newAnnotationType,this.formalIndex); + BindingAnnotationTypePattern ret = new BindingAnnotationTypePattern(newAnnotationType, this.formalIndex); if (newAnnotationType instanceof ResolvedType) { ResolvedType rat = (ResolvedType) newAnnotationType; - verifyRuntimeRetention(rat.getWorld(),rat); + verifyRuntimeRetention(rat.getWorld(), rat); } ret.copyLocationFrom(this); return ret; } - + public int getFormalIndex() { return formalIndex; } public boolean equals(Object obj) { - if (!(obj instanceof BindingAnnotationTypePattern)) return false; + if (!(obj instanceof BindingAnnotationTypePattern)) { + return false; + } BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) obj; return (super.equals(btp) && (btp.formalIndex == formalIndex)); } - + public int hashCode() { - return super.hashCode()*37 + formalIndex; + return super.hashCode() * 37 + formalIndex; } - - public AnnotationTypePattern remapAdviceFormals(IntMap bindings) { + + public AnnotationTypePattern remapAdviceFormals(IntMap bindings) { if (!bindings.hasKey(formalIndex)) { - return new ExactAnnotationTypePattern(annotationType,null); + return new ExactAnnotationTypePattern(annotationType, null); } else { int newFormalIndex = bindings.get(formalIndex); return new BindingAnnotationTypePattern(annotationType, newFormalIndex); } } + private static final byte VERSION = 1; // rev if serialised form changed - /* (non-Javadoc) - * @see org.aspectj.weaver.patterns.ExactAnnotationTypePattern#write(java.io.DataOutputStream) - */ - public void write(DataOutputStream s) throws IOException { + + @Override + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.BINDING); s.writeByte(VERSION); annotationType.write(s); - s.writeShort((short)formalIndex); + s.writeShort((short) formalIndex); writeLocation(s); - } - + } + public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { byte version = s.readByte(); if (version > VERSION) { throw new BCException("BindingAnnotationTypePattern was written by a more recent version of AspectJ"); } - AnnotationTypePattern ret = new BindingAnnotationTypePattern(UnresolvedType.read(s),s.readShort()); - ret.readLocation(context,s); + AnnotationTypePattern ret = new BindingAnnotationTypePattern(UnresolvedType.read(s), s.readShort()); + ret.readLocation(context, s); return ret; } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingTypePattern.java index 28c5739ad..c24e779be 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingTypePattern.java @@ -10,14 +10,13 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.weaver.AjAttribute; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.UnresolvedType; @@ -27,54 +26,61 @@ import org.aspectj.weaver.World; public class BindingTypePattern extends ExactTypePattern implements BindingPattern { private int formalIndex; - public BindingTypePattern(UnresolvedType type, int index,boolean isVarArgs) { - super(type, false,isVarArgs); + public BindingTypePattern(UnresolvedType type, int index, boolean isVarArgs) { + super(type, false, isVarArgs); this.formalIndex = index; } public BindingTypePattern(FormalBinding binding, boolean isVarArgs) { - this(binding.getType(), binding.getIndex(),isVarArgs); + this(binding.getType(), binding.getIndex(), isVarArgs); } - + public int getFormalIndex() { return formalIndex; } - public boolean equals(Object other) { - if (!(other instanceof BindingTypePattern)) return false; - BindingTypePattern o = (BindingTypePattern)other; - if (includeSubtypes != o.includeSubtypes) return false; - if (isVarArgs != o.isVarArgs) return false; - return o.type.equals(this.type) && o.formalIndex == this.formalIndex; - } - public int hashCode() { - int result = 17; - result = 37*result + super.hashCode(); - result = 37*result + formalIndex; - return result; - } - - public void write(DataOutputStream out) throws IOException { + public boolean equals(Object other) { + if (!(other instanceof BindingTypePattern)) { + return false; + } + BindingTypePattern o = (BindingTypePattern) other; + if (includeSubtypes != o.includeSubtypes) { + return false; + } + if (isVarArgs != o.isVarArgs) { + return false; + } + return o.type.equals(this.type) && o.formalIndex == this.formalIndex; + } + + public int hashCode() { + int result = 17; + result = 37 * result + super.hashCode(); + result = 37 * result + formalIndex; + return result; + } + + public void write(CompressingDataOutputStream out) throws IOException { out.writeByte(TypePattern.BINDING); type.write(out); - out.writeShort((short)formalIndex); + out.writeShort((short) formalIndex); out.writeBoolean(isVarArgs); writeLocation(out); } - + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { - UnresolvedType type = UnresolvedType.read(s); - int index = s.readShort(); - boolean isVarargs = false; - if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { + UnresolvedType type = UnresolvedType.read(s); + int index = s.readShort(); + boolean isVarargs = false; + if (s.getMajorVersion() >= AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { isVarargs = s.readBoolean(); } - TypePattern ret = new BindingTypePattern(type,index,isVarargs); + TypePattern ret = new BindingTypePattern(type, index, isVarargs); ret.readLocation(context, s); return ret; } - - public TypePattern remapAdviceFormals(IntMap bindings) { + + public TypePattern remapAdviceFormals(IntMap bindings) { if (!bindings.hasKey(formalIndex)) { return new ExactTypePattern(type, false, isVarArgs); } else { @@ -82,16 +88,16 @@ public class BindingTypePattern extends ExactTypePattern implements BindingPatte return new BindingTypePattern(type, newFormalIndex, isVarArgs); } } - - public TypePattern parameterizeWith(Map typeVariableMap,World w) { - ExactTypePattern superParameterized = (ExactTypePattern) super.parameterizeWith(typeVariableMap,w); - BindingTypePattern ret = new BindingTypePattern(superParameterized.getExactType(),this.formalIndex,this.isVarArgs); + + public TypePattern parameterizeWith(Map typeVariableMap, World w) { + ExactTypePattern superParameterized = (ExactTypePattern) super.parameterizeWith(typeVariableMap, w); + BindingTypePattern ret = new BindingTypePattern(superParameterized.getExactType(), this.formalIndex, this.isVarArgs); ret.copyLocationFrom(this); return ret; } - public String toString() { - //Thread.currentThread().dumpStack(); - return "BindingTypePattern(" + super.toString() + ", " + formalIndex + ")"; - } + public String toString() { + // Thread.currentThread().dumpStack(); + return "BindingTypePattern(" + super.toString() + ", " + formalIndex + ")"; + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/CflowPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/CflowPointcut.java index 6da40e523..1aa58dec0 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/CflowPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/CflowPointcut.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -24,6 +23,7 @@ import org.aspectj.bridge.IMessage; import org.aspectj.util.FileUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.Advice; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.CrosscuttingMembers; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; @@ -87,7 +87,7 @@ public class CflowPointcut extends Pointcut { return FuzzyBoolean.MAYBE; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.CFLOW); entry.write(s); s.writeBoolean(isBelow); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java index 842384b01..443a58645 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ConcreteCflowPointcut.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; @@ -21,6 +20,7 @@ import java.util.Map; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.Message; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.Member; import org.aspectj.weaver.MemberImpl; @@ -80,8 +80,9 @@ public class ConcreteCflowPointcut extends Pointcut { // used by weaver when validating bindings public int[] getUsedFormalSlots() { - if (slots == null) + if (slots == null) { return new int[0]; + } int[] indices = new int[slots.size()]; for (int i = 0; i < indices.length; i++) { indices[i] = ((Slot) slots.get(i)).formalIndex; @@ -89,7 +90,7 @@ public class ConcreteCflowPointcut extends Pointcut { return indices; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { throw new RuntimeException("unimplemented"); } @@ -102,8 +103,9 @@ public class ConcreteCflowPointcut extends Pointcut { } public boolean equals(Object other) { - if (!(other instanceof ConcreteCflowPointcut)) + if (!(other instanceof ConcreteCflowPointcut)) { return false; + } ConcreteCflowPointcut o = (ConcreteCflowPointcut) other; return o.cflowField.equals(this.cflowField); } @@ -161,8 +163,9 @@ public class ConcreteCflowPointcut extends Pointcut { } public boolean equals(Object other) { - if (!(other instanceof Slot)) + if (!(other instanceof Slot)) { return false; + } Slot o = (Slot) other; return o.formalIndex == this.formalIndex && o.arrayIndex == this.arrayIndex && o.formalType.equals(this.formalType); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java index 261a01c4a..6f6d54c30 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java @@ -12,13 +12,13 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.Map; import org.aspectj.bridge.MessageUtil; import org.aspectj.weaver.AnnotationAJ; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedType; @@ -221,7 +221,7 @@ public class DeclareAnnotation extends Declare { * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.ANNOTATION); s.writeInt(kind.id); s.writeUTF(annotationString); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java index c8922933b..c3a698967 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java @@ -10,13 +10,12 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; @@ -31,15 +30,18 @@ public class DeclareErrorOrWarning extends Declare { this.pointcut = pointcut; this.message = message; } - + /** * returns "declare warning: " or "declare error: " */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append("declare "); - if (isError) buf.append("error: "); - else buf.append("warning: "); + if (isError) { + buf.append("error: "); + } else { + buf.append("warning: "); + } buf.append(pointcut); buf.append(": "); buf.append("\""); @@ -47,27 +49,27 @@ public class DeclareErrorOrWarning extends Declare { buf.append("\";"); return buf.toString(); } - - public boolean equals(Object other) { - if (!(other instanceof DeclareErrorOrWarning)) return false; - DeclareErrorOrWarning o = (DeclareErrorOrWarning)other; - return (o.isError == isError) && - o.pointcut.equals(pointcut) && - o.message.equals(message); + + public boolean equals(Object other) { + if (!(other instanceof DeclareErrorOrWarning)) { + return false; + } + DeclareErrorOrWarning o = (DeclareErrorOrWarning) other; + return (o.isError == isError) && o.pointcut.equals(pointcut) && o.message.equals(message); + } + + public int hashCode() { + int result = isError ? 19 : 23; + result = 37 * result + pointcut.hashCode(); + result = 37 * result + message.hashCode(); + return result; } - - public int hashCode() { - int result = isError ? 19 : 23; - result = 37*result + pointcut.hashCode(); - result = 37*result + message.hashCode(); - return result; - } public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this,data); + return visitor.visit(this, data); } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.ERROR_OR_WARNING); s.writeBoolean(isError); pointcut.write(s); @@ -76,16 +78,11 @@ public class DeclareErrorOrWarning extends Declare { } public static Declare read(VersionedDataInputStream s, ISourceContext context) throws IOException { - Declare ret = new DeclareErrorOrWarning( - s.readBoolean(), - Pointcut.read(s, context), - s.readUTF() - ); + Declare ret = new DeclareErrorOrWarning(s.readBoolean(), Pointcut.read(s, context), s.readUTF()); ret.readLocation(context, s); return ret; } - public boolean isError() { return isError; } @@ -97,17 +94,17 @@ public class DeclareErrorOrWarning extends Declare { public Pointcut getPointcut() { return pointcut; } - - public void resolve(IScope scope) { - pointcut = pointcut.resolve(scope); - } - - public Declare parameterizeWith(Map typeVariableBindingMap,World w) { - Declare ret = new DeclareErrorOrWarning(isError,pointcut.parameterizeWith(typeVariableBindingMap,w),message); - ret.copyLocationFrom(this); - return ret; - } - + + public void resolve(IScope scope) { + pointcut = pointcut.resolve(scope); + } + + public Declare parameterizeWith(Map typeVariableBindingMap, World w) { + Declare ret = new DeclareErrorOrWarning(isError, pointcut.parameterizeWith(typeVariableBindingMap, w), message); + ret.copyLocationFrom(this); + return ret; + } + public boolean isAdviceLike() { return true; } @@ -115,15 +112,18 @@ public class DeclareErrorOrWarning extends Declare { public String getNameSuffix() { return "eow"; } - + /** * returns "declare warning" or "declare error" */ public String getName() { StringBuffer buf = new StringBuffer(); buf.append("declare "); - if (isError) buf.append("error"); - else buf.append("warning"); + if (isError) { + buf.append("error"); + } else { + buf.append("warning"); + } return buf.toString(); } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java index 1bef37c60..c11967fca 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParents.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -23,6 +22,7 @@ import java.util.Map; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.Message; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; @@ -46,8 +46,9 @@ public class DeclareParents extends Declare { this.child = child; this.parents = parents; this.isExtends = isExtends; - if (child instanceof WildTypePattern) + if (child instanceof WildTypePattern) { isWildChild = true; + } } // public String[] getTypeParameterNames() { @@ -59,8 +60,9 @@ public class DeclareParents extends Declare { // } public boolean match(ResolvedType typeX) { - if (!child.matchesStatically(typeX)) + if (!child.matchesStatically(typeX)) { return false; + } if (typeX.getWorld().getLint().typeNotExposedToWeaver.isEnabled() && !typeX.isExposedToWeaver()) { typeX.getWorld().getLint().typeNotExposedToWeaver.signal(typeX.getName(), getSourceLocation()); } @@ -94,8 +96,9 @@ public class DeclareParents extends Declare { @Override public boolean equals(Object other) { - if (!(other instanceof DeclareParents)) + if (!(other instanceof DeclareParents)) { return false; + } DeclareParents o = (DeclareParents) other; return o.child.equals(child) && o.parents.equals(parents); } @@ -110,7 +113,7 @@ public class DeclareParents extends Declare { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.PARENTS); child.write(s); parents.write(s); @@ -136,16 +139,18 @@ public class DeclareParents extends Declare { public boolean parentsIncludeInterface(World w) { for (int i = 0; i < parents.size(); i++) { - if (parents.get(i).getExactType().resolve(w).isInterface()) + if (parents.get(i).getExactType().resolve(w).isInterface()) { return true; + } } return false; } public boolean parentsIncludeClass(World w) { for (int i = 0; i < parents.size(); i++) { - if (parents.get(i).getExactType().resolve(w).isClass()) + if (parents.get(i).getExactType().resolve(w).isClass()) { return true; + } } return false; } @@ -182,8 +187,9 @@ public class DeclareParents extends Declare { } private ResolvedType maybeGetNewParent(ResolvedType targetType, TypePattern typePattern, World world, boolean reportErrors) { - if (typePattern == TypePattern.NO) + if (typePattern == TypePattern.NO) { return null; // already had an error here + } // isWildChild = (child instanceof WildTypePattern); UnresolvedType iType = typePattern.getExactType(); @@ -199,12 +205,14 @@ public class DeclareParents extends Declare { if (parentType.isParameterizedType() || parentType.isRawType()) { // Let's take a look at the parents we already have boolean isOK = verifyNoInheritedAlternateParameterization(targetType, parentType, world); - if (!isOK) + if (!isOK) { return null; + } } - if (parentType.isAssignableFrom(targetType)) + if (parentType.isAssignableFrom(targetType)) { return null; // already a parent + } // Enum types that are targetted for decp through a wild type pattern get linted if (reportErrors && isWildChild && targetType.isEnum()) { @@ -264,8 +272,9 @@ public class DeclareParents extends Declare { return null; } - if (parentType.isAssignableFrom(targetType)) + if (parentType.isAssignableFrom(targetType)) { return null; // already a parent + } if (targetType.isAssignableFrom(parentType)) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.CANT_EXTEND_SELF, targetType.getName()), this @@ -305,8 +314,9 @@ public class DeclareParents extends Declare { */ private boolean verifyNoInheritedAlternateParameterization(ResolvedType typeToVerify, ResolvedType newParent, World world) { - if (typeToVerify.equals(ResolvedType.OBJECT)) + if (typeToVerify.equals(ResolvedType.OBJECT)) { return true; + } ResolvedType newParentGenericType = newParent.getGenericType(); Iterator iter = typeToVerify.getDirectSupertypes(); @@ -342,16 +352,19 @@ public class DeclareParents extends Declare { } public List findMatchingNewParents(ResolvedType onType, boolean reportErrors) { - if (onType.isRawType()) + if (onType.isRawType()) { onType = onType.getGenericType(); - if (!match(onType)) + } + if (!match(onType)) { return Collections.emptyList(); + } List ret = new ArrayList(); for (int i = 0; i < parents.size(); i++) { ResolvedType t = maybeGetNewParent(onType, parents.get(i), onType.getWorld(), reportErrors); - if (t != null) + if (t != null) { ret.add(t); + } } return ret; diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParentsMixin.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParentsMixin.java index 2c4e727ca..9c2db1156 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParentsMixin.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareParentsMixin.java @@ -11,10 +11,10 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.List; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.VersionedDataInputStream; @@ -50,7 +50,7 @@ public class DeclareParentsMixin extends DeclareParents { return result; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.PARENTSMIXIN); child.write(s); parents.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclarePrecedence.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclarePrecedence.java index 896344557..678ea89e6 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclarePrecedence.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclarePrecedence.java @@ -12,12 +12,12 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; import org.aspectj.bridge.IMessage; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; @@ -55,8 +55,9 @@ public class DeclarePrecedence extends Declare { } public boolean equals(Object other) { - if (!(other instanceof DeclarePrecedence)) + if (!(other instanceof DeclarePrecedence)) { return false; + } DeclarePrecedence o = (DeclarePrecedence) other; return o.patterns.equals(patterns); } @@ -65,7 +66,7 @@ public class DeclarePrecedence extends Declare { return patterns.hashCode(); } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.DOMINATES); patterns.write(s); writeLocation(s); @@ -106,8 +107,9 @@ public class DeclarePrecedence extends Declare { continue; } ResolvedType exactType = pi.getExactType().resolve(scope.getWorld()); - if (exactType.isMissing()) + if (exactType.isMissing()) { continue; + } // Cannot do a dec prec specifying a non-aspect types unless suffixed with a '+' if (!exactType.isAspect() && !exactType.isAnnotationStyleAspect() && !pi.isIncludeSubtypes() @@ -118,11 +120,13 @@ public class DeclarePrecedence extends Declare { } for (int j = 0; j < patterns.size(); j++) { - if (j == i) + if (j == i) { continue; + } TypePattern pj = patterns.get(j); - if (pj.isStar()) + if (pj.isStar()) { continue; + } if (pj.matchesStatically(exactType)) { scope.getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.TWO_PATTERN_MATCHES_IN_PRECEDENCE, exactType.getName()), @@ -156,10 +160,11 @@ public class DeclarePrecedence extends Declare { } } } - if (knownMatch == -1) + if (knownMatch == -1) { return starMatch; - else + } else { return knownMatch; + } } public int compare(ResolvedType aspect1, ResolvedType aspect2) { @@ -169,15 +174,17 @@ public class DeclarePrecedence extends Declare { // System.out.println("a1: " + aspect1 + ", " + aspect2 + " = " + index1 + ", " + index2); - if (index1 == -1 || index2 == -1) + if (index1 == -1 || index2 == -1) { return 0; + } - if (index1 == index2) + if (index1 == index2) { return 0; - else if (index1 > index2) + } else if (index1 > index2) { return -1; - else + } else { return +1; + } } public boolean isAdviceLike() { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareSoft.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareSoft.java index 7e8d831ca..3714d5fdc 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareSoft.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareSoft.java @@ -12,11 +12,11 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.bridge.IMessage; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.TypeVariableReferenceType; @@ -76,7 +76,7 @@ public class DeclareSoft extends Declare { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.SOFT); exception.write(s); pointcut.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareTypeErrorOrWarning.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareTypeErrorOrWarning.java index bf477e542..daaf84496 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareTypeErrorOrWarning.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareTypeErrorOrWarning.java @@ -12,10 +12,10 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; @@ -43,10 +43,11 @@ public class DeclareTypeErrorOrWarning extends Declare { public String toString() { StringBuffer buf = new StringBuffer(); buf.append("declare "); - if (isError) + if (isError) { buf.append("error: "); - else + } else { buf.append("warning: "); + } buf.append(typePattern); buf.append(": "); buf.append("\""); @@ -56,8 +57,9 @@ public class DeclareTypeErrorOrWarning extends Declare { } public boolean equals(Object other) { - if (!(other instanceof DeclareTypeErrorOrWarning)) + if (!(other instanceof DeclareTypeErrorOrWarning)) { return false; + } DeclareTypeErrorOrWarning o = (DeclareTypeErrorOrWarning) other; return (o.isError == isError) && o.typePattern.equals(typePattern) && o.message.equals(message); } @@ -73,7 +75,7 @@ public class DeclareTypeErrorOrWarning extends Declare { return visitor.visit(this, data); } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.TYPE_ERROR_OR_WARNING); s.writeBoolean(isError); typePattern.write(s); @@ -123,10 +125,11 @@ public class DeclareTypeErrorOrWarning extends Declare { public String getName() { StringBuffer buf = new StringBuffer(); buf.append("declare type "); - if (isError) + if (isError) { buf.append("error"); - else + } else { buf.append("warning"); + } return buf.toString(); } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java index ea2ec2a70..41b276075 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationFieldTypePattern.java @@ -11,7 +11,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; @@ -19,6 +18,7 @@ import org.aspectj.bridge.IMessage; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ResolvedMember; @@ -127,7 +127,7 @@ public class ExactAnnotationFieldTypePattern extends ExactAnnotationTypePattern } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.EXACTFIELD); s.writeUTF(formalName); annotationType.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java index 1105d87cf..f332f1c1b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; @@ -22,6 +21,7 @@ import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.AnnotationAJ; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ResolvedMember; @@ -346,7 +346,7 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern { * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.EXACT); s.writeByte(VERSION); s.writeBoolean(bindingPattern); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactTypePattern.java index 1f1262317..7bc560305 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactTypePattern.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -21,6 +20,7 @@ import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.TypeVariableReference; @@ -243,7 +243,7 @@ public class ExactTypePattern extends TypePattern { private static final byte EXACT_VERSION = 1; // rev if changed @Override - public void write(DataOutputStream out) throws IOException { + public void write(CompressingDataOutputStream out) throws IOException { out.writeByte(TypePattern.EXACT); out.writeByte(EXACT_VERSION); type.write(out); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HandlerPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HandlerPointcut.java index b26dc9bb7..3f92ab04a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HandlerPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HandlerPointcut.java @@ -10,15 +10,14 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -31,16 +30,14 @@ import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; /** - * This is a kind of KindedPointcut. This belongs either in - * a hierarchy with it or in a new place to share code - * with other potential future statement-level pointcuts like - * synchronized and throws + * This is a kind of KindedPointcut. This belongs either in a hierarchy with it or in a new place to share code with other potential + * future statement-level pointcuts like synchronized and throws */ public class HandlerPointcut extends Pointcut { TypePattern exceptionType; private static final int MATCH_KINDS = Shadow.ExceptionHandler.bit; - + public HandlerPointcut(TypePattern exceptionType) { this.exceptionType = exceptionType; this.pointcutKind = HANDLER; @@ -49,40 +46,43 @@ public class HandlerPointcut extends Pointcut { public int couldMatchKinds() { return MATCH_KINDS; } - - public FuzzyBoolean fastMatch(FastMatchInfo type) { - //??? should be able to do better by finding all referenced types in type + + public FuzzyBoolean fastMatch(FastMatchInfo type) { + // ??? should be able to do better by finding all referenced types in type return FuzzyBoolean.MAYBE; } - + protected FuzzyBoolean matchInternal(Shadow shadow) { - if (shadow.getKind() != Shadow.ExceptionHandler) return FuzzyBoolean.NO; - + if (shadow.getKind() != Shadow.ExceptionHandler) { + return FuzzyBoolean.NO; + } + exceptionType.resolve(shadow.getIWorld()); - + // we know we have exactly one parameter since we're checking an exception handler - return exceptionType.matches( - shadow.getSignature().getParameterTypes()[0].resolve(shadow.getIWorld()), - TypePattern.STATIC); + return exceptionType.matches(shadow.getSignature().getParameterTypes()[0].resolve(shadow.getIWorld()), TypePattern.STATIC); } - - public Pointcut parameterizeWith(Map typeVariableMap,World w) { - HandlerPointcut ret = new HandlerPointcut(exceptionType.parameterizeWith(typeVariableMap,w)); + + public Pointcut parameterizeWith(Map typeVariableMap, World w) { + HandlerPointcut ret = new HandlerPointcut(exceptionType.parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; } - + public boolean equals(Object other) { - if (!(other instanceof HandlerPointcut)) return false; - HandlerPointcut o = (HandlerPointcut)other; - return o.exceptionType.equals(this.exceptionType); } - - public int hashCode() { - int result = 17; - result = 37*result + exceptionType.hashCode(); - return result; - } - + if (!(other instanceof HandlerPointcut)) { + return false; + } + HandlerPointcut o = (HandlerPointcut) other; + return o.exceptionType.equals(this.exceptionType); + } + + public int hashCode() { + int result = 17; + result = 37 * result + exceptionType.hashCode(); + return result; + } + public String toString() { StringBuffer buf = new StringBuffer(); buf.append("handler("); @@ -90,14 +90,13 @@ public class HandlerPointcut extends Pointcut { buf.append(")"); return buf.toString(); } - - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.HANDLER); exceptionType.write(s); writeLocation(s); } - + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { HandlerPointcut ret = new HandlerPointcut(TypePattern.read(s, context)); ret.readLocation(context, s); @@ -111,29 +110,32 @@ public class HandlerPointcut extends Pointcut { public void resolveBindings(IScope scope, Bindings bindings) { exceptionType = exceptionType.resolveBindings(scope, bindings, false, false); boolean invalidParameterization = false; - if (exceptionType.getTypeParameters().size() > 0) invalidParameterization = true ; + if (exceptionType.getTypeParameters().size() > 0) { + invalidParameterization = true; + } UnresolvedType exactType = exceptionType.getExactType(); - if (exactType != null && exactType.isParameterizedType()) invalidParameterization = true; + if (exactType != null && exactType.isParameterizedType()) { + invalidParameterization = true; + } if (invalidParameterization) { // no parameterized or generic types for handler - scope.message( - MessageUtil.error(WeaverMessages.format(WeaverMessages.HANDLER_PCD_DOESNT_SUPPORT_PARAMETERS), - getSourceLocation())); + scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.HANDLER_PCD_DOESNT_SUPPORT_PARAMETERS), + getSourceLocation())); } - //XXX add error if exact binding and not an exception + // XXX add error if exact binding and not an exception } - + protected Test findResidueInternal(Shadow shadow, ExposedState state) { return match(shadow).alwaysTrue() ? Literal.TRUE : Literal.FALSE; } - + public Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { Pointcut ret = new HandlerPointcut(exceptionType); ret.copyLocationFrom(this); return ret; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java index 3cfc62c7b..c0715c857 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java @@ -11,7 +11,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.Iterator; @@ -20,6 +19,7 @@ import java.util.Map; import org.aspectj.bridge.IMessage; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.Member; @@ -162,7 +162,7 @@ public class HasMemberTypePattern extends TypePattern { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(TypePattern.HAS_MEMBER); signaturePattern.write(s); writeLocation(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/IfPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/IfPointcut.java index c0e0f2b20..a3b5e79e2 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/IfPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/IfPointcut.java @@ -12,7 +12,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; @@ -25,6 +24,7 @@ import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.Advice; import org.aspectj.weaver.AjcMemberMaker; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedMember; @@ -110,7 +110,7 @@ public class IfPointcut extends Pointcut { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.IF); s.writeBoolean(testMethod != null); // do we have a test method? if (testMethod != null) { @@ -506,7 +506,7 @@ public class IfPointcut extends Pointcut { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.IF_FALSE); } @@ -575,7 +575,7 @@ public class IfPointcut extends Pointcut { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(IF_TRUE); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/KindedPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/KindedPointcut.java index bdfab6714..13770253a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/KindedPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/KindedPointcut.java @@ -14,7 +14,6 @@ package org.aspectj.weaver.patterns; import static org.aspectj.util.FuzzyBoolean.MAYBE; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.Map; @@ -23,6 +22,7 @@ import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.Checker; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.Member; @@ -323,7 +323,7 @@ public class KindedPointcut extends Pointcut { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.KINDED); kind.write(s); signature.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ModifiersPattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ModifiersPattern.java index 7d304c6bc..a8d2680e3 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ModifiersPattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ModifiersPattern.java @@ -10,72 +10,74 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.Map; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.VersionedDataInputStream; public class ModifiersPattern extends PatternNode { private int requiredModifiers; private int forbiddenModifiers; - + public static final ModifiersPattern ANY = new ModifiersPattern(0, 0); - + public ModifiersPattern(int requiredModifiers, int forbiddenModifiers) { this.requiredModifiers = requiredModifiers; this.forbiddenModifiers = forbiddenModifiers; } public String toString() { - if (this == ANY) return ""; - + if (this == ANY) { + return ""; + } + String ret = Modifier.toString(requiredModifiers); - if (forbiddenModifiers == 0) return ret; - else return ret + " !" + Modifier.toString(forbiddenModifiers); + if (forbiddenModifiers == 0) { + return ret; + } else { + return ret + " !" + Modifier.toString(forbiddenModifiers); + } } - + public boolean equals(Object other) { - if (!(other instanceof ModifiersPattern)) return false; - ModifiersPattern o = (ModifiersPattern)other; - return o.requiredModifiers == this.requiredModifiers && - o.forbiddenModifiers == this.forbiddenModifiers; + if (!(other instanceof ModifiersPattern)) { + return false; + } + ModifiersPattern o = (ModifiersPattern) other; + return o.requiredModifiers == this.requiredModifiers && o.forbiddenModifiers == this.forbiddenModifiers; } - public int hashCode() { - int result = 17; - result = 37*result + requiredModifiers; - result = 37*result + forbiddenModifiers; - return result; - } - + + public int hashCode() { + int result = 17; + result = 37 * result + requiredModifiers; + result = 37 * result + forbiddenModifiers; + return result; + } + public boolean matches(int modifiers) { - return ((modifiers & requiredModifiers) == requiredModifiers) && - ((modifiers & forbiddenModifiers) == 0); + return ((modifiers & requiredModifiers) == requiredModifiers) && ((modifiers & forbiddenModifiers) == 0); } - public static ModifiersPattern read(VersionedDataInputStream s) throws IOException { int requiredModifiers = s.readShort(); int forbiddenModifiers = s.readShort(); - if (requiredModifiers == 0 && forbiddenModifiers == 0) return ANY; + if (requiredModifiers == 0 && forbiddenModifiers == 0) { + return ANY; + } return new ModifiersPattern(requiredModifiers, forbiddenModifiers); } - /** - * @see org.aspectj.weaver.patterns.PatternNode#write(DataOutputStream) - */ - public void write(DataOutputStream s) throws IOException { - //s.writeByte(MODIFIERS_PATTERN); + public void write(CompressingDataOutputStream s) throws IOException { + // s.writeByte(MODIFIERS_PATTERN); s.writeShort(requiredModifiers); s.writeShort(forbiddenModifiers); } - - + private static Map modifierFlags = null; public static int getModifierFlag(String name) { @@ -88,12 +90,14 @@ public class ModifiersPattern extends PatternNode { flag = flag << 1; } } - Integer flag = (Integer)modifierFlags.get(name); - if (flag == null) return -1; + Integer flag = (Integer) modifierFlags.get(name); + if (flag == null) { + return -1; + } return flag.intValue(); } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NamePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NamePattern.java index f4b61f4ea..561b99197 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NamePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NamePattern.java @@ -12,9 +12,9 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.VersionedDataInputStream; public class NamePattern extends PatternNode { @@ -168,7 +168,7 @@ public class NamePattern extends PatternNode { } @Override - public void write(DataOutputStream out) throws IOException { + public void write(CompressingDataOutputStream out) throws IOException { out.writeUTF(new String(pattern)); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java index 02802946a..76acc110a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java @@ -9,12 +9,12 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; @@ -24,51 +24,61 @@ import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; public class NotAnnotationTypePattern extends AnnotationTypePattern { AnnotationTypePattern negatedPattern; - + public NotAnnotationTypePattern(AnnotationTypePattern pattern) { this.negatedPattern = pattern; setLocation(pattern.getSourceContext(), pattern.getStart(), pattern.getEnd()); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.AnnotationTypePattern#matches(org.aspectj.weaver.AnnotatedElement) */ public FuzzyBoolean matches(AnnotatedElement annotated) { return negatedPattern.matches(annotated).not(); } - - public FuzzyBoolean matches(AnnotatedElement annotated,ResolvedType[] parameterAnnotations) { - return negatedPattern.matches(annotated,parameterAnnotations).not(); + + public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations) { + return negatedPattern.matches(annotated, parameterAnnotations).not(); } - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolve(org.aspectj.weaver.World) */ public void resolve(World world) { negatedPattern.resolve(world); } - /* (non-Javadoc) - * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean) + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, + * org.aspectj.weaver.patterns.Bindings, boolean) */ - public AnnotationTypePattern resolveBindings(IScope scope, - Bindings bindings, boolean allowBinding) { - negatedPattern = negatedPattern.resolveBindings(scope,bindings,allowBinding); + public AnnotationTypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding) { + negatedPattern = negatedPattern.resolveBindings(scope, bindings, allowBinding); return this; } - - public AnnotationTypePattern parameterizeWith(Map typeVariableMap,World w) { - AnnotationTypePattern newNegatedPattern = negatedPattern.parameterizeWith(typeVariableMap,w); + public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { + AnnotationTypePattern newNegatedPattern = negatedPattern.parameterizeWith(typeVariableMap, w); NotAnnotationTypePattern ret = new NotAnnotationTypePattern(newNegatedPattern); ret.copyLocationFrom(this); - if (this.isForParameterAnnotationMatch()) ret.setForParameterAnnotationMatch(); + if (this.isForParameterAnnotationMatch()) { + ret.setForParameterAnnotationMatch(); + } return ret; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.NOT); negatedPattern.write(s); writeLocation(s); @@ -76,41 +86,46 @@ public class NotAnnotationTypePattern extends AnnotationTypePattern { } public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { - AnnotationTypePattern ret = new NotAnnotationTypePattern(AnnotationTypePattern.read(s,context)); - ret.readLocation(context,s); - if (s.getMajorVersion()>=WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ160) { - if (s.readBoolean()) ret.setForParameterAnnotationMatch(); + AnnotationTypePattern ret = new NotAnnotationTypePattern(AnnotationTypePattern.read(s, context)); + ret.readLocation(context, s); + if (s.getMajorVersion() >= WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ160) { + if (s.readBoolean()) { + ret.setForParameterAnnotationMatch(); + } } return ret; } - + public boolean equals(Object obj) { - if (!(obj instanceof NotAnnotationTypePattern)) return false; + if (!(obj instanceof NotAnnotationTypePattern)) { + return false; + } NotAnnotationTypePattern other = (NotAnnotationTypePattern) obj; - return other.negatedPattern.equals(negatedPattern) && other.isForParameterAnnotationMatch()==isForParameterAnnotationMatch(); + return other.negatedPattern.equals(negatedPattern) + && other.isForParameterAnnotationMatch() == isForParameterAnnotationMatch(); } public int hashCode() { - int result = 17 + 37*negatedPattern.hashCode(); - result = 37*result +(isForParameterAnnotationMatch()?0:1); + int result = 17 + 37 * negatedPattern.hashCode(); + result = 37 * result + (isForParameterAnnotationMatch() ? 0 : 1); return result; } - + public String toString() { return "!" + negatedPattern.toString(); } - + public AnnotationTypePattern getNegatedPattern() { return negatedPattern; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); - negatedPattern.traverse(visitor,ret); + Object ret = accept(visitor, data); + negatedPattern.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotPointcut.java index 4a131c9a8..09ce1f6d8 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotPointcut.java @@ -10,14 +10,13 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -28,28 +27,31 @@ import org.aspectj.weaver.ast.Test; public class NotPointcut extends Pointcut { private Pointcut body; + public NotPointcut(Pointcut negated) { super(); this.body = negated; this.pointcutKind = NOT; - setLocation(negated.getSourceContext(), negated.getStart(),negated.getEnd()); // should that be at least start-1? + setLocation(negated.getSourceContext(), negated.getStart(), negated.getEnd()); // should that be at least start-1? } public NotPointcut(Pointcut pointcut, int startPos) { this(pointcut); - setLocation(pointcut.getSourceContext(), startPos, pointcut.getEnd()); + setLocation(pointcut.getSourceContext(), startPos, pointcut.getEnd()); } public int couldMatchKinds() { return Shadow.ALL_SHADOW_KINDS_BITS; } - - public Pointcut getNegatedPointcut() { return body; } + + public Pointcut getNegatedPointcut() { + return body; + } public FuzzyBoolean fastMatch(FastMatchInfo type) { return body.fastMatch(type).not(); } - + protected FuzzyBoolean matchInternal(Shadow shadow) { return body.match(shadow).not(); } @@ -58,36 +60,37 @@ public class NotPointcut extends Pointcut { return "!" + body.toString(); } - - public boolean equals(Object other) { - if (!(other instanceof NotPointcut)) return false; - NotPointcut o = (NotPointcut)other; + + public boolean equals(Object other) { + if (!(other instanceof NotPointcut)) { + return false; + } + NotPointcut o = (NotPointcut) other; return o.body.equals(body); } - public int hashCode() { - return 37*23 + body.hashCode(); - } + public int hashCode() { + return 37 * 23 + body.hashCode(); + } public void resolveBindings(IScope scope, Bindings bindings) { - //Bindings old = bindings.copy(); - - //Bindings newBindings = new Bindings(bindings.size()); - - + // Bindings old = bindings.copy(); + + // Bindings newBindings = new Bindings(bindings.size()); + body.resolveBindings(scope, null); - - //newBindings.checkEmpty(scope, "negation does not allow binding"); - //bindings.checkEquals(old, scope); - + + // newBindings.checkEmpty(scope, "negation does not allow binding"); + // bindings.checkEquals(old, scope); + } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.NOT); body.write(s); writeLocation(s); } - + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { NotPointcut ret = new NotPointcut(Pointcut.read(s, context)); ret.readLocation(context, s); @@ -97,26 +100,26 @@ public class NotPointcut extends Pointcut { protected Test findResidueInternal(Shadow shadow, ExposedState state) { return Test.makeNot(body.findResidue(shadow, state)); } - + public Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { Pointcut ret = new NotPointcut(body.concretize(inAspect, declaringType, bindings)); ret.copyLocationFrom(this); return ret; } - - public Pointcut parameterizeWith(Map typeVariableMap,World w) { - Pointcut ret = new NotPointcut(body.parameterizeWith(typeVariableMap,w)); + + public Pointcut parameterizeWith(Map typeVariableMap, World w) { + Pointcut ret = new NotPointcut(body.parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); - this.body.traverse(visitor,ret); + Object ret = accept(visitor, data); + this.body.traverse(visitor, ret); return ret; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotTypePattern.java index 14f7dad6d..cea4b84d4 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotTypePattern.java @@ -12,12 +12,12 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AjAttribute; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; @@ -83,7 +83,7 @@ public class NotTypePattern extends TypePattern { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(TypePattern.NOT); negatedPattern.write(s); annotationPattern.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java index 9c70ac337..559b0046a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java @@ -9,12 +9,12 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; @@ -25,7 +25,7 @@ public class OrAnnotationTypePattern extends AnnotationTypePattern { private AnnotationTypePattern left; private AnnotationTypePattern right; - + public OrAnnotationTypePattern(AnnotationTypePattern left, AnnotationTypePattern right) { this.left = left; this.right = right; @@ -36,84 +36,97 @@ public class OrAnnotationTypePattern extends AnnotationTypePattern { return left.matches(annotated).or(right.matches(annotated)); } - public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations ) { - return left.matches(annotated,parameterAnnotations).or(right.matches(annotated,parameterAnnotations)); + public FuzzyBoolean matches(AnnotatedElement annotated, ResolvedType[] parameterAnnotations) { + return left.matches(annotated, parameterAnnotations).or(right.matches(annotated, parameterAnnotations)); } - + public void resolve(World world) { left.resolve(world); right.resolve(world); } - /* (non-Javadoc) - * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings, boolean) + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.patterns.AnnotationTypePattern#resolveBindings(org.aspectj.weaver.patterns.IScope, + * org.aspectj.weaver.patterns.Bindings, boolean) */ - public AnnotationTypePattern resolveBindings(IScope scope, - Bindings bindings, boolean allowBinding) { - left = left.resolveBindings(scope,bindings,allowBinding); - right =right.resolveBindings(scope,bindings,allowBinding); + public AnnotationTypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding) { + left = left.resolveBindings(scope, bindings, allowBinding); + right = right.resolveBindings(scope, bindings, allowBinding); return this; } - public AnnotationTypePattern parameterizeWith(Map typeVariableMap,World w) { - AnnotationTypePattern newLeft = left.parameterizeWith(typeVariableMap,w); - AnnotationTypePattern newRight = right.parameterizeWith(typeVariableMap,w); - OrAnnotationTypePattern ret = new OrAnnotationTypePattern(newLeft,newRight); + public AnnotationTypePattern parameterizeWith(Map typeVariableMap, World w) { + AnnotationTypePattern newLeft = left.parameterizeWith(typeVariableMap, w); + AnnotationTypePattern newRight = right.parameterizeWith(typeVariableMap, w); + OrAnnotationTypePattern ret = new OrAnnotationTypePattern(newLeft, newRight); ret.copyLocationFrom(this); - if (isForParameterAnnotationMatch()) ret.setForParameterAnnotationMatch(); + if (isForParameterAnnotationMatch()) { + ret.setForParameterAnnotationMatch(); + } return ret; } public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this,data); + return visitor.visit(this, data); } - + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); - left.traverse(visitor,ret); - right.traverse(visitor,ret); + Object ret = accept(visitor, data); + left.traverse(visitor, ret); + right.traverse(visitor, ret); return ret; } - + public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { - AnnotationTypePattern p = new OrAnnotationTypePattern( - AnnotationTypePattern.read(s,context), - AnnotationTypePattern.read(s,context)); - p.readLocation(context,s); - if (s.getMajorVersion()>=WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ160) { - if (s.readBoolean()) p.setForParameterAnnotationMatch(); + AnnotationTypePattern p = new OrAnnotationTypePattern(AnnotationTypePattern.read(s, context), AnnotationTypePattern.read(s, + context)); + p.readLocation(context, s); + if (s.getMajorVersion() >= WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ160) { + if (s.readBoolean()) { + p.setForParameterAnnotationMatch(); + } } - return p; + return p; } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.OR); left.write(s); right.write(s); writeLocation(s); s.writeBoolean(isForParameterAnnotationMatch()); } - + public boolean equals(Object obj) { - if (!(obj instanceof OrAnnotationTypePattern)) return false; + if (!(obj instanceof OrAnnotationTypePattern)) { + return false; + } OrAnnotationTypePattern other = (OrAnnotationTypePattern) obj; - return (left.equals(other.left) && right.equals(other.right)) && isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch(); + return (left.equals(other.left) && right.equals(other.right)) + && isForParameterAnnotationMatch() == other.isForParameterAnnotationMatch(); } - + public int hashCode() { int result = 17; - result = result*37 + left.hashCode(); - result = result*37 + right.hashCode(); - result = result*37 + (isForParameterAnnotationMatch()?0:1); - return result; + result = result * 37 + left.hashCode(); + result = result * 37 + right.hashCode(); + result = result * 37 + (isForParameterAnnotationMatch() ? 0 : 1); + return result; } - + public String toString() { return "(" + left.toString() + " || " + right.toString() + ")"; } - public AnnotationTypePattern getLeft() { return left; } - public AnnotationTypePattern getRight() { return right; } + public AnnotationTypePattern getLeft() { + return left; + } + + public AnnotationTypePattern getRight() { + return right; + } public void setForParameterAnnotationMatch() { left.setForParameterAnnotationMatch(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrPointcut.java index 01637f3b6..d1426e606 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrPointcut.java @@ -10,14 +10,13 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -46,71 +45,79 @@ public class OrPointcut extends Pointcut { public FuzzyBoolean fastMatch(FastMatchInfo type) { return left.fastMatch(type).or(right.fastMatch(type)); } - + protected FuzzyBoolean matchInternal(Shadow shadow) { FuzzyBoolean leftMatch = left.match(shadow); - if (leftMatch.alwaysTrue()) return leftMatch; + if (leftMatch.alwaysTrue()) { + return leftMatch; + } return leftMatch.or(right.match(shadow)); } - + public String toString() { return "(" + left.toString() + " || " + right.toString() + ")"; } - - public boolean equals(Object other) { - if (!(other instanceof OrPointcut)) return false; - OrPointcut o = (OrPointcut)other; + + public boolean equals(Object other) { + if (!(other instanceof OrPointcut)) { + return false; + } + OrPointcut o = (OrPointcut) other; return o.left.equals(left) && o.right.equals(right); } - public int hashCode() { - int result = 31; - result = 37*result + left.hashCode(); - result = 37*result + right.hashCode(); - return result; - } + + public int hashCode() { + int result = 31; + result = 37 * result + left.hashCode(); + result = 37 * result + right.hashCode(); + return result; + } + /** * @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(IScope, Bindings) */ public void resolveBindings(IScope scope, Bindings bindings) { Bindings old = bindings == null ? null : bindings.copy(); - + left.resolveBindings(scope, bindings); right.resolveBindings(scope, old); - if (bindings != null) bindings.checkEquals(old, scope); - + if (bindings != null) { + bindings.checkEquals(old, scope); + } + } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.OR); left.write(s); right.write(s); writeLocation(s); } - + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { OrPointcut ret = new OrPointcut(Pointcut.read(s, context), Pointcut.read(s, context)); ret.readLocation(context, s); return ret; - + } + protected Test findResidueInternal(Shadow shadow, ExposedState state) { return Test.makeOr(left.findResidue(shadow, state), right.findResidue(shadow, state)); } - + public Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { - Pointcut ret = new OrPointcut(left.concretize(inAspect, declaringType, bindings), - right.concretize(inAspect, declaringType, bindings)); + Pointcut ret = new OrPointcut(left.concretize(inAspect, declaringType, bindings), right.concretize(inAspect, declaringType, + bindings)); ret.copyLocationFrom(this); return ret; } - - public Pointcut parameterizeWith(Map typeVariableMap,World w) { - Pointcut ret = new OrPointcut(left.parameterizeWith(typeVariableMap,w), - right.parameterizeWith(typeVariableMap,w)); + + public Pointcut parameterizeWith(Map typeVariableMap, World w) { + Pointcut ret = new OrPointcut(left.parameterizeWith(typeVariableMap, w), right.parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; } - + public Pointcut getLeft() { return left; } @@ -119,14 +126,14 @@ public class OrPointcut extends Pointcut { return right; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); + Object ret = accept(visitor, data); left.traverse(visitor, ret); - right.traverse(visitor,ret); + right.traverse(visitor, ret); return ret; } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrTypePattern.java index 52a18d50a..d61917a99 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrTypePattern.java @@ -10,14 +10,13 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; @@ -26,109 +25,112 @@ import org.aspectj.weaver.World; /** * left || right * - *

any binding to formals is explicitly forbidden for any composite by the language + *

+ * any binding to formals is explicitly forbidden for any composite by the language * * @author Erik Hilsdale * @author Jim Hugunin */ public class OrTypePattern extends TypePattern { private TypePattern left, right; - + public OrTypePattern(TypePattern left, TypePattern right) { - super(false,false); //??? we override all methods that care about includeSubtypes + super(false, false); // ??? we override all methods that care about includeSubtypes this.left = left; this.right = right; setLocation(left.getSourceContext(), left.getStart(), right.getEnd()); } - public TypePattern getRight() { - return right; - } + public TypePattern getRight() { + return right; + } - public TypePattern getLeft() { - return left; - } + public TypePattern getLeft() { + return left; + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern) */ protected boolean couldEverMatchSameTypesAs(TypePattern other) { return true; // don't dive at the moment... } - + public FuzzyBoolean matchesInstanceof(ResolvedType type) { return left.matchesInstanceof(type).or(right.matchesInstanceof(type)); } protected boolean matchesExactly(ResolvedType type) { - //??? if these had side-effects, this sort-circuit could be a mistake + // ??? if these had side-effects, this sort-circuit could be a mistake return left.matchesExactly(type) || right.matchesExactly(type); } protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { - //??? if these had side-effects, this sort-circuit could be a mistake - return left.matchesExactly(type,annotatedType) || right.matchesExactly(type,annotatedType); + // ??? if these had side-effects, this sort-circuit could be a mistake + return left.matchesExactly(type, annotatedType) || right.matchesExactly(type, annotatedType); } - + public boolean matchesStatically(ResolvedType type) { return left.matchesStatically(type) || right.matchesStatically(type); } - + public void setIsVarArgs(boolean isVarArgs) { this.isVarArgs = isVarArgs; left.setIsVarArgs(isVarArgs); right.setIsVarArgs(isVarArgs); } - + public void setAnnotationTypePattern(AnnotationTypePattern annPatt) { - if (annPatt == AnnotationTypePattern.ANY) return; + if (annPatt == AnnotationTypePattern.ANY) { + return; + } if (left.annotationPattern == AnnotationTypePattern.ANY) { left.setAnnotationTypePattern(annPatt); } else { - left.setAnnotationTypePattern( - new AndAnnotationTypePattern(left.annotationPattern,annPatt)); + left.setAnnotationTypePattern(new AndAnnotationTypePattern(left.annotationPattern, annPatt)); } if (right.annotationPattern == AnnotationTypePattern.ANY) { - right.setAnnotationTypePattern(annPatt); + right.setAnnotationTypePattern(annPatt); } else { - right.setAnnotationTypePattern( - new AndAnnotationTypePattern(right.annotationPattern,annPatt)); + right.setAnnotationTypePattern(new AndAnnotationTypePattern(right.annotationPattern, annPatt)); } } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(TypePattern.OR); left.write(s); right.write(s); writeLocation(s); } - + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { OrTypePattern ret = new OrTypePattern(TypePattern.read(s, context), TypePattern.read(s, context)); ret.readLocation(context, s); - if (ret.left.isVarArgs && ret.right.isVarArgs) ret.isVarArgs = true; + if (ret.left.isVarArgs && ret.right.isVarArgs) { + ret.isVarArgs = true; + } return ret; } - public TypePattern resolveBindings( - IScope scope, - Bindings bindings, - boolean allowBinding, boolean requireExactType) - { - if (requireExactType) return notExactType(scope); + public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) { + if (requireExactType) { + return notExactType(scope); + } left = left.resolveBindings(scope, bindings, false, false); right = right.resolveBindings(scope, bindings, false, false); return this; } - - public TypePattern parameterizeWith(Map typeVariableMap,World w) { - TypePattern newLeft = left.parameterizeWith(typeVariableMap,w); - TypePattern newRight = right.parameterizeWith(typeVariableMap,w); - OrTypePattern ret = new OrTypePattern(newLeft,newRight); + + public TypePattern parameterizeWith(Map typeVariableMap, World w) { + TypePattern newLeft = left.parameterizeWith(typeVariableMap, w); + TypePattern newRight = right.parameterizeWith(typeVariableMap, w); + OrTypePattern ret = new OrTypePattern(newLeft, newRight); ret.copyLocationFrom(this); return ret; } - + public String toString() { StringBuffer buff = new StringBuffer(); if (annotationPattern != AnnotationTypePattern.ANY) { @@ -150,17 +152,23 @@ public class OrTypePattern extends TypePattern { public boolean isStarAnnotation() { return left.isStarAnnotation() || right.isStarAnnotation(); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { - if (! (obj instanceof OrTypePattern)) return false; + if (!(obj instanceof OrTypePattern)) { + return false; + } OrTypePattern other = (OrTypePattern) obj; return left.equals(other.left) && right.equals(other.right); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ public int hashCode() { @@ -170,12 +178,12 @@ public class OrTypePattern extends TypePattern { return ret; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); + Object ret = accept(visitor, data); left.traverse(visitor, ret); right.traverse(visitor, ret); return ret; diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternNode.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternNode.java index 8cf9f3ffb..8a7aae097 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternNode.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternNode.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; import java.io.DataInputStream; @@ -18,6 +17,7 @@ import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.bridge.ISourceLocation; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.IHasSourceLocation; import org.aspectj.weaver.ISourceContext; @@ -37,53 +37,52 @@ public abstract class PatternNode implements IHasSourceLocation { public int getEnd() { return end + (sourceContext != null ? sourceContext.getOffset() : 0); } - + public ISourceContext getSourceContext() { return sourceContext; } - + public String getFileName() { return "unknown"; } - public void setLocation(ISourceContext sourceContext, int start, int end) { - this.sourceContext = sourceContext; - this.start = start; - this.end = end; - } - - public void copyLocationFrom(PatternNode other) { - this.start = other.start; - this.end = other.end; - this.sourceContext = other.sourceContext; - } - - public ISourceLocation getSourceLocation() { - //System.out.println("get context: " + this + " is " + sourceContext); - if (sourceContext == null) { - //System.err.println("no context: " + this); - return null; - } - return sourceContext.makeSourceLocation(this); - } - - public abstract void write(DataOutputStream s) throws IOException; + public void setLocation(ISourceContext sourceContext, int start, int end) { + this.sourceContext = sourceContext; + this.start = start; + this.end = end; + } + + public void copyLocationFrom(PatternNode other) { + this.start = other.start; + this.end = other.end; + this.sourceContext = other.sourceContext; + } + + public ISourceLocation getSourceLocation() { + // System.out.println("get context: " + this + " is " + sourceContext); + if (sourceContext == null) { + // System.err.println("no context: " + this); + return null; + } + return sourceContext.makeSourceLocation(this); + } + public abstract void write(CompressingDataOutputStream s) throws IOException; public void writeLocation(DataOutputStream s) throws IOException { s.writeInt(start); s.writeInt(end); } - + public void readLocation(ISourceContext context, DataInputStream s) throws IOException { start = s.readInt(); end = s.readInt(); this.sourceContext = context; } - public abstract Object accept(PatternNodeVisitor visitor, Object data); - + public abstract Object accept(PatternNodeVisitor visitor, Object data); + public Object traverse(PatternNodeVisitor visitor, Object data) { - return accept(visitor,data); + return accept(visitor, data); } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerCflow.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerCflow.java index 7cc0a242b..1d58260a6 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerCflow.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerCflow.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -23,6 +22,7 @@ import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.Advice; import org.aspectj.weaver.AjcMemberMaker; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.CrosscuttingMembers; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.Member; @@ -83,8 +83,9 @@ public class PerCflow extends PerClause { public PerClause concretize(ResolvedType inAspect) { PerCflow ret = new PerCflow(entry, isBelow); ret.inAspect = inAspect; - if (inAspect.isAbstract()) + if (inAspect.isAbstract()) { return ret; + } Member cflowStackField = new ResolvedMemberImpl(Member.FIELD, inAspect, Modifier.STATIC | Modifier.PUBLIC | Modifier.FINAL, UnresolvedType.forName(NameMangler.CFLOW_STACK_TYPE), NameMangler.PERCFLOW_FIELD_NAME, UnresolvedType.NONE); @@ -121,7 +122,7 @@ public class PerCflow extends PerClause { return ret; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { PERCFLOW.write(s); entry.write(s); s.writeBoolean(isBelow); @@ -147,14 +148,16 @@ public class PerCflow extends PerClause { } public String toDeclarationString() { - if (isBelow) + if (isBelow) { return "percflowbelow(" + entry + ")"; + } return "percflow(" + entry + ")"; } public boolean equals(Object other) { - if (!(other instanceof PerCflow)) + if (!(other instanceof PerCflow)) { return false; + } PerCflow pc = (PerCflow) other; return (pc.isBelow && isBelow) && ((pc.inAspect == null) ? (inAspect == null) : pc.inAspect.equals(inAspect)) && ((pc.entry == null) ? (entry == null) : pc.entry.equals(entry)); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerFromSuper.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerFromSuper.java index 13c81fe93..d513d65f7 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerFromSuper.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerFromSuper.java @@ -10,15 +10,14 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.Shadow; @@ -29,15 +28,15 @@ import org.aspectj.weaver.ast.Test; public class PerFromSuper extends PerClause { private PerClause.Kind kind; - + public PerFromSuper(PerClause.Kind kind) { this.kind = kind; } public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this,data); + return visitor.visit(this, data); } - + public int couldMatchKinds() { return Shadow.ALL_SHADOW_KINDS_BITS; } @@ -45,70 +44,67 @@ public class PerFromSuper extends PerClause { public FuzzyBoolean fastMatch(FastMatchInfo type) { throw new RuntimeException("unimplemented"); } - - protected FuzzyBoolean matchInternal(Shadow shadow) { - throw new RuntimeException("unimplemented"); - } - public void resolveBindings(IScope scope, Bindings bindings) { - // this method intentionally left blank - } + protected FuzzyBoolean matchInternal(Shadow shadow) { + throw new RuntimeException("unimplemented"); + } - protected Test findResidueInternal(Shadow shadow, ExposedState state) { - throw new RuntimeException("unimplemented"); - } + public void resolveBindings(IScope scope, Bindings bindings) { + // this method intentionally left blank + } + protected Test findResidueInternal(Shadow shadow, ExposedState state) { + throw new RuntimeException("unimplemented"); + } public PerClause concretize(ResolvedType inAspect) { PerClause p = lookupConcretePerClause(inAspect.getSuperclass()); if (p == null) { inAspect.getWorld().getMessageHandler().handleMessage( - MessageUtil.error(WeaverMessages.format(WeaverMessages.MISSING_PER_CLAUSE,inAspect.getSuperclass()), getSourceLocation()) - ); - return new PerSingleton().concretize(inAspect);// AV: fallback on something else NPE in AJDT + MessageUtil.error(WeaverMessages.format(WeaverMessages.MISSING_PER_CLAUSE, inAspect.getSuperclass()), + getSourceLocation())); + return new PerSingleton().concretize(inAspect);// AV: fallback on something else NPE in AJDT } else { - if (p.getKind() != kind) { - inAspect.getWorld().getMessageHandler().handleMessage( - MessageUtil.error(WeaverMessages.format(WeaverMessages.WRONG_PER_CLAUSE,kind,p.getKind()), - getSourceLocation()) - ); - } - return p.concretize(inAspect); - } - } - - public Pointcut parameterizeWith(Map typeVariableMap,World w) { + if (p.getKind() != kind) { + inAspect.getWorld().getMessageHandler().handleMessage( + MessageUtil.error(WeaverMessages.format(WeaverMessages.WRONG_PER_CLAUSE, kind, p.getKind()), + getSourceLocation())); + } + return p.concretize(inAspect); + } + } + + public Pointcut parameterizeWith(Map typeVariableMap, World w) { return this; } - - - + public PerClause lookupConcretePerClause(ResolvedType lookupType) { PerClause ret = lookupType.getPerClause(); - if (ret == null) return null; + if (ret == null) { + return null; + } if (ret instanceof PerFromSuper) { return lookupConcretePerClause(lookupType.getSuperclass()); } return ret; } - - public void write(DataOutputStream s) throws IOException { - FROMSUPER.write(s); - kind.write(s); - writeLocation(s); - } - + public void write(CompressingDataOutputStream s) throws IOException { + FROMSUPER.write(s); + kind.write(s); + writeLocation(s); + } + public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException { PerFromSuper ret = new PerFromSuper(Kind.read(s)); ret.readLocation(context, s); return ret; } - + public String toString() { return "perFromSuper(" + kind + ", " + inAspect + ")"; } - + public String toDeclarationString() { return ""; } @@ -117,19 +113,19 @@ public class PerFromSuper extends PerClause { return kind; } - public boolean equals(Object other) { - if (!(other instanceof PerFromSuper)) return false; - PerFromSuper pc = (PerFromSuper)other; - return pc.kind.equals(kind) - && ((pc.inAspect == null) ? (inAspect == null) : pc.inAspect.equals(inAspect)); - } - - public int hashCode() { - int result = 17; - result = 37*result + kind.hashCode(); - result = 37*result + ((inAspect == null) ? 0 : inAspect.hashCode()); - return result; - } - - + public boolean equals(Object other) { + if (!(other instanceof PerFromSuper)) { + return false; + } + PerFromSuper pc = (PerFromSuper) other; + return pc.kind.equals(kind) && ((pc.inAspect == null) ? (inAspect == null) : pc.inAspect.equals(inAspect)); + } + + public int hashCode() { + int result = 17; + result = 37 * result + kind.hashCode(); + result = 37 * result + ((inAspect == null) ? 0 : inAspect.hashCode()); + return result; + } + } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerObject.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerObject.java index ab28c8fae..3a799f78e 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerObject.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerObject.java @@ -12,13 +12,13 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.Advice; import org.aspectj.weaver.AjcMemberMaker; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.PerObjectInterfaceTypeMunger; import org.aspectj.weaver.ResolvedType; @@ -42,10 +42,12 @@ public class PerObject extends PerClause { int targFlags = Shadow.ALL_SHADOW_KINDS_BITS; for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { Shadow.Kind kind = Shadow.SHADOW_KINDS[i]; - if (kind.neverHasThis()) + if (kind.neverHasThis()) { thisFlags -= kind.bit; - if (kind.neverHasTarget()) + } + if (kind.neverHasTarget()) { targFlags -= kind.bit; + } } thisKindSet = thisFlags; targetKindSet = targFlags; @@ -73,10 +75,11 @@ public class PerObject extends PerClause { // System.err.println("matches " + this + " ? " + shadow + ", " + // shadow.hasTarget()); // ??? could probably optimize this better by testing could match - if (isThis) + if (isThis) { return FuzzyBoolean.fromBoolean(shadow.hasThis()); - else + } else { return FuzzyBoolean.fromBoolean(shadow.hasTarget()); + } } public void resolveBindings(IScope scope, Bindings bindings) { @@ -105,8 +108,9 @@ public class PerObject extends PerClause { PerObject ret = new PerObject(entry, isThis); ret.inAspect = inAspect; - if (inAspect.isAbstract()) + if (inAspect.isAbstract()) { return ret; + } World world = inAspect.getWorld(); @@ -136,7 +140,7 @@ public class PerObject extends PerClause { return ret; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { PEROBJECT.write(s); entry.write(s); s.writeBoolean(isThis); @@ -170,8 +174,9 @@ public class PerObject extends PerClause { } public boolean equals(Object other) { - if (!(other instanceof PerObject)) + if (!(other instanceof PerObject)) { return false; + } PerObject pc = (PerObject) other; return (pc.isThis && isThis) && ((pc.inAspect == null) ? (inAspect == null) : pc.inAspect.equals(inAspect)) && ((pc.entry == null) ? (entry == null) : pc.entry.equals(entry)); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerSingleton.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerSingleton.java index e91e9f45d..798b1ba55 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerSingleton.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerSingleton.java @@ -12,12 +12,12 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AjcMemberMaker; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedType; @@ -134,7 +134,7 @@ public class PerSingleton extends PerClause { return ret; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { SINGLETON.write(s); writeLocation(s); } @@ -158,8 +158,9 @@ public class PerSingleton extends PerClause { } public boolean equals(Object other) { - if (!(other instanceof PerSingleton)) + if (!(other instanceof PerSingleton)) { return false; + } PerSingleton pc = (PerSingleton) other; return ((pc.inAspect == null) ? (inAspect == null) : pc.inAspect.equals(inAspect)); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerTypeWithin.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerTypeWithin.java index 9c1fd655b..0bcc85870 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerTypeWithin.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PerTypeWithin.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; @@ -22,6 +21,7 @@ import org.aspectj.bridge.Message; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.Advice; import org.aspectj.weaver.AjcMemberMaker; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.Member; import org.aspectj.weaver.PerTypeWithinTargetTypeMunger; @@ -86,8 +86,9 @@ public class PerTypeWithin extends PerClause { // in a pertypewithin aspect - the JPs only exist in the static // initializer and can't // call the localAspectOf() method. - if (enclosingType.isInterface()) + if (enclosingType.isInterface()) { return FuzzyBoolean.NO; + } typePattern.resolve(shadow.getIWorld()); return isWithinType(enclosingType); @@ -137,8 +138,9 @@ public class PerTypeWithin extends PerClause { PerTypeWithin ret = new PerTypeWithin(typePattern); ret.copyLocationFrom(this); ret.inAspect = inAspect; - if (inAspect.isAbstract()) + if (inAspect.isAbstract()) { return ret; + } World world = inAspect.getWorld(); @@ -178,7 +180,7 @@ public class PerTypeWithin extends PerClause { } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { PERTYPEWITHIN.write(s); typePattern.write(s); writeLocation(s); @@ -213,8 +215,9 @@ public class PerTypeWithin extends PerClause { } public boolean equals(Object other) { - if (!(other instanceof PerTypeWithin)) + if (!(other instanceof PerTypeWithin)) { return false; + } PerTypeWithin pc = (PerTypeWithin) other; return ((pc.inAspect == null) ? (inAspect == null) : pc.inAspect.equals(inAspect)) && ((pc.typePattern == null) ? (typePattern == null) : pc.typePattern.equals(typePattern)); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java index da8d98eee..b9dfc9048 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/Pointcut.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; @@ -22,6 +21,7 @@ import org.aspectj.weaver.Advice; import org.aspectj.weaver.AdviceKind; import org.aspectj.weaver.BCException; import org.aspectj.weaver.Checker; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.PoliceExtensionUse; @@ -396,7 +396,7 @@ public abstract class Pointcut extends PatternNode { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(NONE); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java index 0cc5b9e45..b321382f4 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.HashMap; @@ -21,6 +20,7 @@ import java.util.Map; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedPointcutDefinition; @@ -97,7 +97,7 @@ public class ReferencePointcut extends Pointcut { return buf.toString(); } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { // XXX ignores onType s.writeByte(Pointcut.REFERENCE); if (onType != null) { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java index 52115f7e4..ffd8e64be 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/SignaturePattern.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -27,6 +26,7 @@ import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.AjcMemberMaker; import org.aspectj.weaver.AnnotationTargetKind; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ConcreteTypeMunger; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.JoinPointSignature; @@ -894,7 +894,7 @@ public class SignaturePattern extends PatternNode { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); modifiers.write(s); returnType.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java index 4cf1202e8..7656a08e0 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -19,6 +18,7 @@ import java.util.Map; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -272,7 +272,7 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut { * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.ATTHIS_OR_TARGET); s.writeBoolean(isThis); annotationTypePattern.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java index 974991bc4..f2e77440b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -22,6 +21,7 @@ import java.util.Map; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -125,7 +125,7 @@ public class ThisOrTargetPointcut extends NameBindingPointcut { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.THIS_OR_TARGET); s.writeBoolean(isThis); typePattern.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThrowsPattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThrowsPattern.java index 04dd0c264..d3e0afce2 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThrowsPattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ThrowsPattern.java @@ -10,133 +10,137 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; - public class ThrowsPattern extends PatternNode { private TypePatternList required; private TypePatternList forbidden; - - public static final ThrowsPattern ANY = - new ThrowsPattern(TypePatternList.EMPTY, TypePatternList.EMPTY); - + + public static final ThrowsPattern ANY = new ThrowsPattern(TypePatternList.EMPTY, TypePatternList.EMPTY); + public ThrowsPattern(TypePatternList required, TypePatternList forbidden) { this.required = required; this.forbidden = forbidden; } - public TypePatternList getRequired() { - return required; - } + public TypePatternList getRequired() { + return required; + } - public TypePatternList getForbidden() { - return forbidden; - } + public TypePatternList getForbidden() { + return forbidden; + } public String toString() { - if (this == ANY) return ""; - - + if (this == ANY) { + return ""; + } + String ret = "throws " + required.toString(); if (forbidden.size() > 0) { ret = ret + " !(" + forbidden.toString() + ")"; } return ret; } - + public boolean equals(Object other) { - if (!(other instanceof ThrowsPattern)) return false; - ThrowsPattern o = (ThrowsPattern)other; - boolean ret = o.required.equals(this.required) && - o.forbidden.equals(this.forbidden); + if (!(other instanceof ThrowsPattern)) { + return false; + } + ThrowsPattern o = (ThrowsPattern) other; + boolean ret = o.required.equals(this.required) && o.forbidden.equals(this.forbidden); + return ret; + } + + public int hashCode() { + int result = 17; + result = 37 * result + required.hashCode(); + result = 37 * result + forbidden.hashCode(); + return result; + } + + public ThrowsPattern resolveBindings(IScope scope, Bindings bindings) { + if (this == ANY) { + return this; + } + required = required.resolveBindings(scope, bindings, false, false); + forbidden = forbidden.resolveBindings(scope, bindings, false, false); + return this; + } + + public ThrowsPattern parameterizeWith(Map/* name -> resolved type */typeVariableMap, World w) { + ThrowsPattern ret = new ThrowsPattern(required.parameterizeWith(typeVariableMap, w), forbidden.parameterizeWith( + typeVariableMap, w)); + ret.copyLocationFrom(this); return ret; } - public int hashCode() { - int result = 17; - result = 37*result + required.hashCode(); - result = 37*result + forbidden.hashCode(); - return result; - } - - public ThrowsPattern resolveBindings(IScope scope, Bindings bindings) { - if (this == ANY) return this; - required = required.resolveBindings(scope, bindings, false, false); - forbidden = forbidden.resolveBindings(scope, bindings, false, false); - return this; - } - - public ThrowsPattern parameterizeWith(Map/*name -> resolved type*/ typeVariableMap,World w) { - ThrowsPattern ret = new ThrowsPattern( - required.parameterizeWith(typeVariableMap,w), - forbidden.parameterizeWith(typeVariableMap,w)); - ret.copyLocationFrom(this); - return ret; - } - + public boolean matches(UnresolvedType[] tys, World world) { - if (this == ANY) return true; - - //System.out.println("matching: " + this + " with " + Arrays.asList(tys)); - + if (this == ANY) { + return true; + } + + // System.out.println("matching: " + this + " with " + Arrays.asList(tys)); + ResolvedType[] types = world.resolve(tys); // int len = types.length; - for (int j=0, lenj = required.size(); j < lenj; j++) { - if (! matchesAny(required.get(j), types)) { + for (int j = 0, lenj = required.size(); j < lenj; j++) { + if (!matchesAny(required.get(j), types)) { return false; } } - for (int j=0, lenj = forbidden.size(); j < lenj; j++) { + for (int j = 0, lenj = forbidden.size(); j < lenj; j++) { if (matchesAny(forbidden.get(j), types)) { return false; } } return true; } - - private boolean matchesAny( - TypePattern typePattern, - ResolvedType[] types) - { + + private boolean matchesAny(TypePattern typePattern, ResolvedType[] types) { for (int i = types.length - 1; i >= 0; i--) { - if (typePattern.matchesStatically(types[i])) return true; + if (typePattern.matchesStatically(types[i])) { + return true; + } } return false; } - + public static ThrowsPattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypePatternList required = TypePatternList.read(s, context); TypePatternList forbidden = TypePatternList.read(s, context); - if (required.size() == 0 && forbidden.size() == 0) return ANY; + if (required.size() == 0 && forbidden.size() == 0) { + return ANY; + } ThrowsPattern ret = new ThrowsPattern(required, forbidden); - //XXXret.readLocation(context, s); + // XXXret.readLocation(context, s); return ret; } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { required.write(s); forbidden.write(s); - //XXXwriteLocation(s); + // XXXwriteLocation(s); } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - - public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); - forbidden.traverse(visitor, data); - required.traverse(visitor, data); - return ret; - } + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + public Object traverse(PatternNodeVisitor visitor, Object data) { + Object ret = accept(visitor, data); + forbidden.traverse(visitor, data); + required.traverse(visitor, data); + return ret; + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java index 06c51dbf2..beffd131e 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java @@ -9,11 +9,11 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; @@ -88,7 +88,7 @@ public class TypeCategoryTypePattern extends TypePattern { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(TypePattern.TYPE_CATEGORY); s.writeInt(VERSION); s.writeInt(category); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java index f77352fcc..bc3d6712f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.Iterator; @@ -21,6 +20,7 @@ import java.util.Map; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -395,11 +395,8 @@ class EllipsisTypePattern extends TypePattern { return FuzzyBoolean.NO; } - /** - * @see org.aspectj.weaver.patterns.PatternNode#write(DataOutputStream) - */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(ELLIPSIS_KEY); } @@ -487,11 +484,8 @@ class AnyTypePattern extends TypePattern { return FuzzyBoolean.YES; } - /** - * @see org.aspectj.weaver.patterns.PatternNode#write(DataOutputStream) - */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(ANY_KEY); } @@ -605,7 +599,7 @@ class AnyWithAnnotationTypePattern extends TypePattern { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(TypePattern.ANY_WITH_ANNO); annotationPattern.write(s); writeLocation(s); @@ -689,11 +683,8 @@ class NoTypePattern extends TypePattern { return FuzzyBoolean.NO; } - /** - * @see org.aspectj.weaver.patterns.PatternNode#write(DataOutputStream) - */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(NO_KEY); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePatternList.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePatternList.java index 991a5128b..1db65b688 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePatternList.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePatternList.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -20,6 +19,7 @@ import java.util.List; import java.util.Map; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvableTypeList; @@ -263,7 +263,7 @@ public class TypePatternList extends PatternNode { tLeft--; } } - + public FuzzyBoolean matches(ResolvableTypeList types, TypePattern.MatchKind kind, ResolvedType[][] parameterAnnotations) { int nameLength = types.length; int patternLength = typePatterns.length; @@ -497,7 +497,7 @@ public class TypePatternList extends PatternNode { } @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeShort(typePatterns.length); for (int i = 0; i < typePatterns.length; i++) { typePatterns[i].write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeVariablePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeVariablePattern.java index 7016b23fd..c2d4bd0ec 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeVariablePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeVariablePattern.java @@ -11,48 +11,48 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.VersionedDataInputStream; /** - * @author colyer - * Represents a type variable as declared as part of a type declaration, parameter declaration, - * or type parameter specification. - *

For example:

- * + * @author colyer Represents a type variable as declared as part of a type declaration, parameter declaration, or type parameter + * specification. + *

+ * For example: + *

+ * */ public class TypeVariablePattern extends PatternNode { private static final String anything = "?"; - - private String name; // eg. "T" + + private String name; // eg. "T" private TypePattern upperBound; // default is object unless of the form T extends Bar private TypePattern[] interfaceBounds; // additional upper bounds (must be interfaces) arising from - // declarations of the form T extends Bar & IGoo, IDoo + // declarations of the form T extends Bar & IGoo, IDoo private TypePattern lowerBound; // only set if type variable is of the form T super Bar - + /** - * Create a named type variable with upper bound Object and no lower bounds. - * Use this constructor for the simple "T" case + * Create a named type variable with upper bound Object and no lower bounds. Use this constructor for the simple "T" case */ public TypeVariablePattern(String variableName) { this.name = variableName; - this.upperBound = new ExactTypePattern(UnresolvedType.OBJECT,false,false); + this.upperBound = new ExactTypePattern(UnresolvedType.OBJECT, false, false); this.lowerBound = null; this.interfaceBounds = null; } - + /** - * Create a named type variable with the given upper bound and no lower bounds - * Use this constructor for the T extends Foo case + * Create a named type variable with the given upper bound and no lower bounds Use this constructor for the T extends Foo case + * * @param variableName * @param upperBound */ @@ -62,45 +62,49 @@ public class TypeVariablePattern extends PatternNode { this.lowerBound = null; this.interfaceBounds = null; } - + public TypeVariablePattern(String variableName, TypePattern upperLimit, TypePattern[] interfaceBounds, TypePattern lowerBound) { this.name = variableName; this.upperBound = upperLimit; - if (upperBound == null) upperBound = new ExactTypePattern(UnresolvedType.OBJECT,false,false); + if (upperBound == null) { + upperBound = new ExactTypePattern(UnresolvedType.OBJECT, false, false); + } this.interfaceBounds = interfaceBounds; this.lowerBound = lowerBound; } public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this,data); + return visitor.visit(this, data); } - + public String getName() { return name; } - + public boolean isAnythingPattern() { return name.equals(anything); } - + public TypePattern getRawTypePattern() { return upperBound; } - + public TypePattern getUpperBound() { return upperBound; } - - public boolean hasLowerBound() { return (lowerBound != null); } - + + public boolean hasLowerBound() { + return (lowerBound != null); + } + public TypePattern getLowerBound() { return lowerBound; } - + public boolean hasAdditionalInterfaceBounds() { return (interfaceBounds != null); } - + public TypePattern[] getAdditionalInterfaceBounds() { if (interfaceBounds != null) { return interfaceBounds; @@ -108,42 +112,64 @@ public class TypeVariablePattern extends PatternNode { return new TypePattern[0]; } } - + public boolean equals(Object obj) { - if (!(obj instanceof TypeVariablePattern)) return false; + if (!(obj instanceof TypeVariablePattern)) { + return false; + } TypeVariablePattern other = (TypeVariablePattern) obj; - if (!name.equals(other.name)) return false; - if (!upperBound.equals(other.upperBound)) return false; + if (!name.equals(other.name)) { + return false; + } + if (!upperBound.equals(other.upperBound)) { + return false; + } if (lowerBound != null) { - if (other.lowerBound == null) return false; - if (!lowerBound.equals(other.lowerBound)) return false; + if (other.lowerBound == null) { + return false; + } + if (!lowerBound.equals(other.lowerBound)) { + return false; + } } else { - if (other.lowerBound != null) return false; + if (other.lowerBound != null) { + return false; + } } if (interfaceBounds != null) { - if (other.interfaceBounds == null) return false; - if (interfaceBounds.length != other.interfaceBounds.length) return false; + if (other.interfaceBounds == null) { + return false; + } + if (interfaceBounds.length != other.interfaceBounds.length) { + return false; + } for (int i = 0; i < interfaceBounds.length; i++) { - if (!interfaceBounds[i].equals(other.interfaceBounds[i])) return false; + if (!interfaceBounds[i].equals(other.interfaceBounds[i])) { + return false; + } } } else { - if (other.interfaceBounds != null) return false; + if (other.interfaceBounds != null) { + return false; + } } return true; } - + public int hashCode() { int hashCode = 17 + (37 * name.hashCode()); hashCode = hashCode * 37 + upperBound.hashCode(); - if (lowerBound != null) hashCode = hashCode * 37 + lowerBound.hashCode(); + if (lowerBound != null) { + hashCode = hashCode * 37 + lowerBound.hashCode(); + } if (interfaceBounds != null) { for (int i = 0; i < interfaceBounds.length; i++) { - hashCode = 37*hashCode + interfaceBounds[i].hashCode(); + hashCode = 37 * hashCode + interfaceBounds[i].hashCode(); } } return hashCode; } - + public String toString() { StringBuffer sb = new StringBuffer(); sb.append(name); @@ -152,7 +178,9 @@ public class TypeVariablePattern extends PatternNode { sb.append(" & "); for (int i = 0; i < interfaceBounds.length; i++) { sb.append(interfaceBounds[i].toString()); - if (i < interfaceBounds.length) sb.append(","); + if (i < interfaceBounds.length) { + sb.append(","); + } } } if (lowerBound != null) { @@ -161,16 +189,18 @@ public class TypeVariablePattern extends PatternNode { } return sb.toString(); } - + private String getExtendsClause() { if (upperBound instanceof ExactTypePattern) { ExactTypePattern bound = (ExactTypePattern) upperBound; - if (bound.type == UnresolvedType.OBJECT) return ""; + if (bound.type == UnresolvedType.OBJECT) { + return ""; + } } return " extends " + upperBound.toString(); } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeUTF(name); upperBound.write(s); if (interfaceBounds == null) { @@ -182,10 +212,12 @@ public class TypeVariablePattern extends PatternNode { } } s.writeBoolean(hasLowerBound()); - if (hasLowerBound()) lowerBound.write(s); - writeLocation(s); + if (hasLowerBound()) { + lowerBound.write(s); + } + writeLocation(s); } - + public static TypeVariablePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypeVariablePattern tv = null; String name = s.readUTF(); @@ -200,10 +232,12 @@ public class TypeVariablePattern extends PatternNode { } boolean hasLowerBound = s.readBoolean(); TypePattern lowerBound = null; - if (hasLowerBound) lowerBound = TypePattern.read(s,context); - tv = new TypeVariablePattern(name,upperBound,additionalInterfaceBounds,lowerBound); + if (hasLowerBound) { + lowerBound = TypePattern.read(s, context); + } + tv = new TypeVariablePattern(name, upperBound, additionalInterfaceBounds, lowerBound); tv.readLocation(context, s); return tv; } - + } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeVariablePatternList.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeVariablePatternList.java index 8ede2a073..7bbe67872 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeVariablePatternList.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeVariablePatternList.java @@ -11,30 +11,29 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.VersionedDataInputStream; /** - * @author colyer - * A list of type variable specifications, eg. <T,S> + * @author colyer A list of type variable specifications, eg. <T,S> */ public class TypeVariablePatternList extends PatternNode { public static final TypeVariablePatternList EMPTY = new TypeVariablePatternList(new TypeVariablePattern[0]); - + private TypeVariablePattern[] patterns; - + public TypeVariablePatternList(TypeVariablePattern[] typeVars) { this.patterns = typeVars; } - + public TypeVariablePattern[] getTypeVariablePatterns() { return this.patterns; } - + public TypeVariablePattern lookupTypeVariable(String name) { for (int i = 0; i < patterns.length; i++) { if (patterns[i].getName().equals(name)) { @@ -43,12 +42,12 @@ public class TypeVariablePatternList extends PatternNode { } return null; } - + public boolean isEmpty() { return ((patterns == null) || (patterns.length == 0)); } - - public void write(DataOutputStream s) throws IOException { + + public void write(CompressingDataOutputStream s) throws IOException { s.writeInt(patterns.length); for (int i = 0; i < patterns.length; i++) { patterns[i].write(s); @@ -62,24 +61,24 @@ public class TypeVariablePatternList extends PatternNode { if (length > 0) { TypeVariablePattern[] patterns = new TypeVariablePattern[length]; for (int i = 0; i < patterns.length; i++) { - patterns[i] = TypeVariablePattern.read(s,context); + patterns[i] = TypeVariablePattern.read(s, context); } ret = new TypeVariablePatternList(patterns); } - ret.readLocation(context, s); // redundant but safe to read location for EMPTY + ret.readLocation(context, s); // redundant but safe to read location for EMPTY return ret; } public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this,data); + return visitor.visit(this, data); } - + public Object traverse(PatternNodeVisitor visitor, Object data) { - Object ret = accept(visitor,data); + Object ret = accept(visitor, data); for (int i = 0; i < patterns.length; i++) { - patterns[i].traverse(visitor,ret); + patterns[i].traverse(visitor, ret); } return ret; } - + } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java index 5fc6e36b2..f988ed500 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; @@ -21,6 +20,7 @@ import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedType; @@ -302,7 +302,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.WILD); s.writeByte(VERSION); typePattern.write(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildTypePattern.java index 42845b55d..7cdfd0c23 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -12,7 +12,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -28,6 +27,7 @@ import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.BCException; import org.aspectj.weaver.BoundedReferenceType; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.IHasPosition; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ReferenceType; @@ -1295,11 +1295,8 @@ public class WildTypePattern extends TypePattern { private static final byte VERSION = 1; // rev on change - /** - * @see org.aspectj.weaver.patterns.PatternNode#write(DataOutputStream) - */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(TypePattern.WILD); s.writeByte(VERSION); s.writeShort(namePatterns.length); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java index 1003a475b..87966f017 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -20,6 +19,7 @@ import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -193,7 +193,7 @@ public class WithinAnnotationPointcut extends NameBindingPointcut { * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ @Override - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.ATWITHIN); annotationTypePattern.write(s); writeLocation(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java index ed3e5f145..0b574c4d4 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -19,6 +18,7 @@ import java.util.Map; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.BCException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.Member; @@ -37,28 +37,29 @@ import org.aspectj.weaver.ast.Var; /** * @author colyer - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * + * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code + * Templates */ public class WithinCodeAnnotationPointcut extends NameBindingPointcut { private ExactAnnotationTypePattern annotationTypePattern; - private String declarationText; - - private static final int matchedShadowKinds; - static { - int flags = Shadow.ALL_SHADOW_KINDS_BITS; - for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { - if (Shadow.SHADOW_KINDS[i].isEnclosingKind()) + private String declarationText; + + private static final int matchedShadowKinds; + static { + int flags = Shadow.ALL_SHADOW_KINDS_BITS; + for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { + if (Shadow.SHADOW_KINDS[i].isEnclosingKind()) { flags -= Shadow.SHADOW_KINDS[i].bit; + } } - matchedShadowKinds=flags; - } - + matchedShadowKinds = flags; + } + public WithinCodeAnnotationPointcut(ExactAnnotationTypePattern type) { super(); - this.annotationTypePattern = type; + this.annotationTypePattern = type; this.pointcutKind = Pointcut.ATWITHINCODE; buildDeclarationText(); } @@ -68,37 +69,42 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut { this.pointcutKind = Pointcut.ATWITHINCODE; } - public ExactAnnotationTypePattern getAnnotationTypePattern() { - return annotationTypePattern; - } + public ExactAnnotationTypePattern getAnnotationTypePattern() { + return annotationTypePattern; + } public int couldMatchKinds() { return matchedShadowKinds; } - - public Pointcut parameterizeWith(Map typeVariableMap,World w) { - WithinCodeAnnotationPointcut ret = new WithinCodeAnnotationPointcut((ExactAnnotationTypePattern)this.annotationTypePattern.parameterizeWith(typeVariableMap,w)); + + public Pointcut parameterizeWith(Map typeVariableMap, World w) { + WithinCodeAnnotationPointcut ret = new WithinCodeAnnotationPointcut((ExactAnnotationTypePattern) this.annotationTypePattern + .parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.Pointcut#fastMatch(org.aspectj.weaver.patterns.FastMatchInfo) */ public FuzzyBoolean fastMatch(FastMatchInfo info) { return FuzzyBoolean.MAYBE; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.Pointcut#match(org.aspectj.weaver.Shadow) */ protected FuzzyBoolean matchInternal(Shadow shadow) { - Member member = shadow.getEnclosingCodeSignature(); + Member member = shadow.getEnclosingCodeSignature(); ResolvedMember rMember = member.resolve(shadow.getIWorld()); if (rMember == null) { - if (member.getName().startsWith(NameMangler.PREFIX)) { - return FuzzyBoolean.NO; + if (member.getName().startsWith(NameMangler.PREFIX)) { + return FuzzyBoolean.NO; } shadow.getIWorld().getLint().unresolvableMember.signal(member.toString(), getSourceLocation()); return FuzzyBoolean.NO; @@ -107,10 +113,12 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut { annotationTypePattern.resolve(shadow.getIWorld()); return annotationTypePattern.matches(rMember); } - - /* (non-Javadoc) - * @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, org.aspectj.weaver.patterns.Bindings) + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.patterns.Pointcut#resolveBindings(org.aspectj.weaver.patterns.IScope, + * org.aspectj.weaver.patterns.Bindings) */ protected void resolveBindings(IScope scope, Bindings bindings) { if (!scope.getWorld().isInJava5Mode()) { @@ -118,45 +126,53 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut { getSourceLocation())); return; } - annotationTypePattern = (ExactAnnotationTypePattern) annotationTypePattern.resolveBindings(scope,bindings,true); + annotationTypePattern = (ExactAnnotationTypePattern) annotationTypePattern.resolveBindings(scope, bindings, true); // must be either a Var, or an annotation type pattern } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.Pointcut#concretize1(org.aspectj.weaver.ResolvedType, org.aspectj.weaver.IntMap) */ protected Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { - ExactAnnotationTypePattern newType = (ExactAnnotationTypePattern) annotationTypePattern.remapAdviceFormals(bindings); + ExactAnnotationTypePattern newType = (ExactAnnotationTypePattern) annotationTypePattern.remapAdviceFormals(bindings); Pointcut ret = new WithinCodeAnnotationPointcut(newType, bindings.getEnclosingAdvice()); - ret.copyLocationFrom(this); - return ret; + ret.copyLocationFrom(this); + return ret; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.Pointcut#findResidue(org.aspectj.weaver.Shadow, org.aspectj.weaver.patterns.ExposedState) */ protected Test findResidueInternal(Shadow shadow, ExposedState state) { - + if (annotationTypePattern instanceof BindingAnnotationTypePattern) { - BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern)annotationTypePattern; + BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern; UnresolvedType annotationType = btp.annotationType; Var var = shadow.getWithinCodeAnnotationVar(annotationType); - - // This should not happen, we shouldn't have gotten this far + + // This should not happen, we shouldn't have gotten this far // if we weren't going to find the annotation - if (var == null) - throw new BCException("Impossible! annotation=["+annotationType+ - "] shadow=["+shadow+" at "+shadow.getSourceLocation()+ - "] pointcut is at ["+getSourceLocation()+"]"); - - state.set(btp.getFormalIndex(),var); - } - if (matchInternal(shadow).alwaysTrue()) return Literal.TRUE; - else return Literal.FALSE; - } - - - /* (non-Javadoc) + if (var == null) { + throw new BCException("Impossible! annotation=[" + annotationType + "] shadow=[" + shadow + " at " + + shadow.getSourceLocation() + "] pointcut is at [" + getSourceLocation() + "]"); + } + + state.set(btp.getFormalIndex(), var); + } + if (matchInternal(shadow).alwaysTrue()) { + return Literal.TRUE; + } else { + return Literal.FALSE; + } + } + + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingAnnotationTypePatterns() */ public List getBindingAnnotationTypePatterns() { @@ -164,20 +180,26 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut { List l = new ArrayList(); l.add(annotationTypePattern); return l; - } else return Collections.EMPTY_LIST; + } else { + return Collections.EMPTY_LIST; + } } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.NameBindingPointcut#getBindingTypePatterns() */ public List getBindingTypePatterns() { return Collections.EMPTY_LIST; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream) */ - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.ATWITHINCODE); annotationTypePattern.write(s); writeLocation(s); @@ -185,35 +207,39 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut { public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { AnnotationTypePattern type = AnnotationTypePattern.read(s, context); - WithinCodeAnnotationPointcut ret = new WithinCodeAnnotationPointcut((ExactAnnotationTypePattern)type); + WithinCodeAnnotationPointcut ret = new WithinCodeAnnotationPointcut((ExactAnnotationTypePattern) type); ret.readLocation(context, s); return ret; } public boolean equals(Object other) { - if (!(other instanceof WithinCodeAnnotationPointcut)) return false; - WithinCodeAnnotationPointcut o = (WithinCodeAnnotationPointcut)other; + if (!(other instanceof WithinCodeAnnotationPointcut)) { + return false; + } + WithinCodeAnnotationPointcut o = (WithinCodeAnnotationPointcut) other; return o.annotationTypePattern.equals(this.annotationTypePattern); } - - public int hashCode() { - int result = 17; - result = 23*result + annotationTypePattern.hashCode(); - return result; - } - + + public int hashCode() { + int result = 17; + result = 23 * result + annotationTypePattern.hashCode(); + return result; + } + private void buildDeclarationText() { - StringBuffer buf = new StringBuffer(); + StringBuffer buf = new StringBuffer(); buf.append("@withincode("); String annPatt = annotationTypePattern.toString(); buf.append(annPatt.startsWith("@") ? annPatt.substring(1) : annPatt); buf.append(")"); this.declarationText = buf.toString(); } - - public String toString() { return this.declarationText; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } + public String toString() { + return this.declarationText; + } + + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinPointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinPointcut.java index f7b2c00e7..cc0f40add 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinPointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinPointcut.java @@ -12,13 +12,13 @@ package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -79,7 +79,7 @@ public class WithinPointcut extends Pointcut { return isWithinType(enclosingType); } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.WITHIN); typePattern.write(s); writeLocation(s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithincodePointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithincodePointcut.java index 91beeb87c..bb4a1e72c 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithincodePointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithincodePointcut.java @@ -10,15 +10,14 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Map; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -31,55 +30,55 @@ import org.aspectj.weaver.ast.Test; public class WithincodePointcut extends Pointcut { private SignaturePattern signature; - private static final int matchedShadowKinds; - static { - int flags = Shadow.ALL_SHADOW_KINDS_BITS; - for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { - if (Shadow.SHADOW_KINDS[i].isEnclosingKind()) + private static final int matchedShadowKinds; + static { + int flags = Shadow.ALL_SHADOW_KINDS_BITS; + for (int i = 0; i < Shadow.SHADOW_KINDS.length; i++) { + if (Shadow.SHADOW_KINDS[i].isEnclosingKind()) { flags -= Shadow.SHADOW_KINDS[i].bit; + } } - // these next two are needed for inlining of field initializers - flags|=Shadow.ConstructorExecution.bit; - flags|=Shadow.Initialization.bit; - matchedShadowKinds = flags; - } - + // these next two are needed for inlining of field initializers + flags |= Shadow.ConstructorExecution.bit; + flags |= Shadow.Initialization.bit; + matchedShadowKinds = flags; + } + public WithincodePointcut(SignaturePattern signature) { this.signature = signature; this.pointcutKind = WITHINCODE; } - public SignaturePattern getSignature() { - return signature; - } + public SignaturePattern getSignature() { + return signature; + } public int couldMatchKinds() { return matchedShadowKinds; } - - public Pointcut parameterizeWith(Map typeVariableMap,World w) { - WithincodePointcut ret = new WithincodePointcut(signature.parameterizeWith(typeVariableMap,w)); + + public Pointcut parameterizeWith(Map typeVariableMap, World w) { + WithincodePointcut ret = new WithincodePointcut(signature.parameterizeWith(typeVariableMap, w)); ret.copyLocationFrom(this); return ret; } - + public FuzzyBoolean fastMatch(FastMatchInfo type) { return FuzzyBoolean.MAYBE; } - + protected FuzzyBoolean matchInternal(Shadow shadow) { - //This will not match code in local or anonymous classes as if - //they were withincode of the outer signature - return FuzzyBoolean.fromBoolean( - signature.matches(shadow.getEnclosingCodeSignature(), shadow.getIWorld(), false)); + // This will not match code in local or anonymous classes as if + // they were withincode of the outer signature + return FuzzyBoolean.fromBoolean(signature.matches(shadow.getEnclosingCodeSignature(), shadow.getIWorld(), false)); } - public void write(DataOutputStream s) throws IOException { + public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.WITHINCODE); signature.write(s); writeLocation(s); } - + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { WithincodePointcut ret = new WithincodePointcut(SignaturePattern.read(s, context)); ret.readLocation(context, s); @@ -88,38 +87,39 @@ public class WithincodePointcut extends Pointcut { public void resolveBindings(IScope scope, Bindings bindings) { signature = signature.resolveBindings(scope, bindings); - + // look for inappropriate use of parameterized types and tell user... - HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor - visitor = new HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor(); + HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor visitor = new HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor(); signature.getDeclaringType().traverse(visitor, null); - if (visitor.wellHasItThen/*?*/()) { - scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.WITHINCODE_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES), - getSourceLocation())); - } - + if (visitor.wellHasItThen/* ? */()) { + scope.message(MessageUtil.error(WeaverMessages + .format(WeaverMessages.WITHINCODE_DOESNT_SUPPORT_PARAMETERIZED_DECLARING_TYPES), getSourceLocation())); + } + visitor = new HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor(); signature.getThrowsPattern().traverse(visitor, null); - if (visitor.wellHasItThen/*?*/()) { - scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.NO_GENERIC_THROWABLES), - getSourceLocation())); - } + if (visitor.wellHasItThen/* ? */()) { + scope.message(MessageUtil.error(WeaverMessages.format(WeaverMessages.NO_GENERIC_THROWABLES), getSourceLocation())); + } } - + public void postRead(ResolvedType enclosingType) { signature.postRead(enclosingType); } public boolean equals(Object other) { - if (!(other instanceof WithincodePointcut)) return false; - WithincodePointcut o = (WithincodePointcut)other; + if (!(other instanceof WithincodePointcut)) { + return false; + } + WithincodePointcut o = (WithincodePointcut) other; return o.signature.equals(this.signature); } - public int hashCode() { - int result = 43; - result = 37*result + signature.hashCode(); - return result; - } + + public int hashCode() { + int result = 43; + result = 37 * result + signature.hashCode(); + return result; + } public String toString() { return "withincode(" + signature + ")"; @@ -128,15 +128,14 @@ public class WithincodePointcut extends Pointcut { protected Test findResidueInternal(Shadow shadow, ExposedState state) { return match(shadow).alwaysTrue() ? Literal.TRUE : Literal.FALSE; } - - + public Pointcut concretize1(ResolvedType inAspect, ResolvedType declaringType, IntMap bindings) { Pointcut ret = new WithincodePointcut(signature); ret.copyLocationFrom(this); return ret; } - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } } diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java index 70e192afe..44d8d2b04 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java @@ -14,16 +14,11 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.AndPointcut; -import org.aspectj.weaver.patterns.NotPointcut; -import org.aspectj.weaver.patterns.OrPointcut; -import org.aspectj.weaver.patterns.PatternParser; -import org.aspectj.weaver.patterns.Pointcut; import org.aspectj.weaver.reflect.ReflectionWorld; /** @@ -86,7 +81,7 @@ public class AndOrNotTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { Pointcut p = makePointcut(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java index bece96251..444db0c75 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java @@ -14,11 +14,11 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import junit.framework.TestCase; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.VersionedDataInputStream; public class DeclareErrorOrWarningTestCase extends TestCase { @@ -50,7 +50,7 @@ public class DeclareErrorOrWarningTestCase extends TestCase { private void checkSerialization(Declare declare) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); declare.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java index b680376d7..a82626336 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java @@ -14,14 +14,12 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.ModifiersPattern; -import org.aspectj.weaver.patterns.PatternParser; import org.aspectj.weaver.reflect.ReflectionWorld; public class ModifiersPatternTestCase extends PatternsTestCase { @@ -93,7 +91,7 @@ public class ModifiersPatternTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { ModifiersPattern p = makeModifiersPattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java index 91858de88..41685973c 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java @@ -10,77 +10,61 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; -import org.aspectj.weaver.VersionedDataInputStream; -import org.aspectj.weaver.patterns.NamePattern; - import junit.framework.TestCase; +import org.aspectj.weaver.CompressingDataOutputStream; +import org.aspectj.weaver.VersionedDataInputStream; + /** * @author hugunin - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. + * + * To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable + * and disable the creation of type comments go to Window>Preferences>Java>Code Generation. */ public class NamePatternTestCase extends TestCase { - static String[] matchAll = new String[] { - "*****", - "*" - }; - - - static String[] match1 = new String[] { - "abcde", "abc*", "abcd*", "abcde*", - "*e", "*cde", "*abcde", - "a*e", "ab*e", "abc*de", - "*a*b*c*d*e*", "a*c*e", "a***bcde", - "*d*", - }; - - static String[] match2 = new String[] { - "abababab", - "aba*", "abab*", "abababab*", - "*b", "*ab", "*ababab", "*abababab", - "a*b", "ab*b", "abab*abab", - "*a*b*a*b*a*b*a*b*", "a*****b", "a**b", "ab*b*b", - }; - + static String[] matchAll = new String[] { "*****", "*" }; + + static String[] match1 = new String[] { "abcde", "abc*", "abcd*", "abcde*", "*e", "*cde", "*abcde", "a*e", "ab*e", "abc*de", + "*a*b*c*d*e*", "a*c*e", "a***bcde", "*d*", }; + + static String[] match2 = new String[] { "abababab", "aba*", "abab*", "abababab*", "*b", "*ab", "*ababab", "*abababab", "a*b", + "ab*b", "abab*abab", "*a*b*a*b*a*b*a*b*", "a*****b", "a**b", "ab*b*b", }; + /** * Constructor for PatternTestCase. + * * @param name */ public NamePatternTestCase(String name) { super(name); } - + public void testMatch() { checkMatch("abcde", matchAll, true); checkMatch("abcde", match1, true); checkMatch("abcde", match2, false); - + checkMatch("abababab", matchAll, true); checkMatch("abababab", match1, false); checkMatch("abababab", match2, true); - + } /** * Method checkMatch. + * * @param string * @param matchAll * @param b */ private void checkMatch(String string, String[] patterns, boolean shouldMatch) { - for (int i=0, len=patterns.length; i < len; i++) { + for (int i = 0, len = patterns.length; i < len; i++) { NamePattern p = new NamePattern(patterns[i]); checkMatch(string, p, shouldMatch); } @@ -90,33 +74,31 @@ public class NamePatternTestCase extends TestCase { String msg = "matching " + string + " to " + p; assertEquals(msg, shouldMatch, p.matches(string)); } - - + public void testSerialization() throws IOException { checkSerialization(matchAll); checkSerialization(match1); checkSerialization(match2); } - + private void checkSerialization(String[] patterns) throws IOException { - for (int i=0, len=patterns.length; i < len; i++) { + for (int i = 0, len = patterns.length; i < len; i++) { NamePattern p = new NamePattern(patterns[i]); checkSerialization(p); } } - - + private void checkSerialization(NamePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); - + ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); VersionedDataInputStream in = new VersionedDataInputStream(bi); NamePattern newP = NamePattern.read(in); - - assertEquals("write/read", p, newP); + + assertEquals("write/read", p, newP); } } diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java index 02058d898..67cf5be98 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternMatchSpeedTestCase.java @@ -14,9 +14,9 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.Member; import org.aspectj.weaver.TestUtils; import org.aspectj.weaver.VersionedDataInputStream; @@ -152,7 +152,7 @@ public class SignaturePatternMatchSpeedTestCase extends PatternsTestCase { private void checkSerialization(SignaturePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java index 110137cf9..629e26719 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java @@ -15,9 +15,9 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.Member; import org.aspectj.weaver.TestUtils; import org.aspectj.weaver.VersionedDataInputStream; @@ -61,53 +61,34 @@ public class SignaturePatternTestCase extends PatternsTestCase { checkMatch(makeMethodPat("* *(..) throws *..IOException, !*..Clone*"), NONE, BOTH); checkMatch(makeMethodPat("* *(..) throws !*..IOException"), NO_EXCEPTIONS, M); } -/* - public void testInstanceMethodMatchSpeed() throws IOException { - // Member objectToString = TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); - Member objectToString = TestUtils.methodFromString( - "java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)").resolve(world); - SignaturePattern signaturePattern = makeMethodPat("* *(..))"); - signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0)); - for (int i = 0; i < 1000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - long stime = System.currentTimeMillis(); - for (int i = 0; i < 2000000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - long etime = System.currentTimeMillis(); - System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 - signaturePattern = makeMethodPat("* *())"); - signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0)); - for (int i = 0; i < 1000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - stime = System.currentTimeMillis(); - for (int i = 0; i < 2000000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - etime = System.currentTimeMillis(); - System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 - } - - public void testInstanceMethodMatchSpeed2() throws IOException { - // Member objectToString = TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); - Member objectToString = TestUtils.methodFromString( - "java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)").resolve(world); - SignaturePattern signaturePattern = makeMethodPat("!void *(..))"); - signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new FormalBinding[0]), new Bindings(0)); - for (int i = 0; i < 1000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - long stime = System.currentTimeMillis(); - for (int i = 0; i < 2000000; i++) { - boolean matches = signaturePattern.matches(objectToString, world, false); - } - long etime = System.currentTimeMillis(); - System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 - } -*/ + /* + * public void testInstanceMethodMatchSpeed() throws IOException { // Member objectToString = + * TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); Member objectToString = + * TestUtils.methodFromString( + * "java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)").resolve(world); SignaturePattern + * signaturePattern = makeMethodPat("* *(..))"); signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new + * FormalBinding[0]), new Bindings(0)); for (int i = 0; i < 1000; i++) { boolean matches = + * signaturePattern.matches(objectToString, world, false); } long stime = System.currentTimeMillis(); for (int i = 0; i < + * 2000000; i++) { boolean matches = signaturePattern.matches(objectToString, world, false); } long etime = + * System.currentTimeMillis(); System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 + * + * signaturePattern = makeMethodPat("* *())"); signaturePattern = signaturePattern.resolveBindings(new TestScope(world, new + * FormalBinding[0]), new Bindings(0)); for (int i = 0; i < 1000; i++) { boolean matches = + * signaturePattern.matches(objectToString, world, false); } stime = System.currentTimeMillis(); for (int i = 0; i < 2000000; + * i++) { boolean matches = signaturePattern.matches(objectToString, world, false); } etime = System.currentTimeMillis(); + * System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 } + * + * public void testInstanceMethodMatchSpeed2() throws IOException { // Member objectToString = + * TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); Member objectToString = + * TestUtils.methodFromString( + * "java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String)").resolve(world); SignaturePattern + * signaturePattern = makeMethodPat("!void *(..))"); signaturePattern = signaturePattern.resolveBindings(new TestScope(world, + * new FormalBinding[0]), new Bindings(0)); for (int i = 0; i < 1000; i++) { boolean matches = + * signaturePattern.matches(objectToString, world, false); } long stime = System.currentTimeMillis(); for (int i = 0; i < + * 2000000; i++) { boolean matches = signaturePattern.matches(objectToString, world, false); } long etime = + * System.currentTimeMillis(); System.out.println("Took " + (etime - stime) + "ms for 2,000,000");// 4081 } + */ public void testInstanceMethodMatch() throws IOException { Member objectToString = TestUtils.methodFromString("java.lang.String java.lang.Object.toString()"); Member integerToString = TestUtils.methodFromString("java.lang.String java.lang.Integer.toString()"); @@ -190,7 +171,7 @@ public class SignaturePatternTestCase extends PatternsTestCase { private void checkSerialization(SignaturePattern p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java index fd3e8f23e..15460d4cf 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java @@ -14,19 +14,14 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.util.Arrays; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.Bindings; -import org.aspectj.weaver.patterns.PatternParser; -import org.aspectj.weaver.patterns.TestScope; -import org.aspectj.weaver.patterns.TypePattern; -import org.aspectj.weaver.patterns.TypePatternList; import org.aspectj.weaver.reflect.ReflectionWorld; /** @@ -161,7 +156,7 @@ public class TypePatternListTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { TypePatternList p = makeArgumentsPattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java index e4f5a4dbf..416ccc11c 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java @@ -14,10 +14,10 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; @@ -248,7 +248,7 @@ public class TypePatternTestCase extends PatternsTestCase { private void checkSerialization(String string) throws IOException { TypePattern p = makeTypePattern(string); ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java index ccc117b02..2665b6e96 100644 --- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java +++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java @@ -14,10 +14,10 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TestShadow; @@ -25,11 +25,6 @@ import org.aspectj.weaver.TestUtils; import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.Bindings; -import org.aspectj.weaver.patterns.FormalBinding; -import org.aspectj.weaver.patterns.IScope; -import org.aspectj.weaver.patterns.Pointcut; -import org.aspectj.weaver.patterns.SimpleScope; import org.aspectj.weaver.reflect.ReflectionWorld; public class WithinTestCase extends PatternsTestCase { @@ -112,7 +107,7 @@ public class WithinTestCase extends PatternsTestCase { private void checkSerialization(Pointcut p) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(bo); + CompressingDataOutputStream out = new CompressingDataOutputStream(bo); p.write(out); out.close(); -- 2.39.5