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();
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();
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
}
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
munger.write(s);
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
kind.write(s);
}
}
@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
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
s.writeUTF(sourceFileName);
FileUtil.writeIntArray(lineBreaks, s);
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
s.writeInt(lineNumber);
s.writeInt(offset);
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
pointcutDef.write(s);
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
declare.write(s);
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
kind.write(s);
pointcut.write(s);
s.writeByte(extraParameterFlags);
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
perClause.write(s);
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
ResolvedMemberImpl.writeArray(accessedMembers, s);
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
effectiveSignature.write(s);
shadowKind.write(s);
s.writeBoolean(weaveBody);
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
newAnnotation = anno;
}
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
throw new RuntimeException("unimplemented");
}
}
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());
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
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();) {
* ******************************************************************/
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
return realMember.isSynthetic();
}
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
realMember.write(s);
}
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import org.aspectj.weaver.patterns.TypePattern;
}
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))
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);
}
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));
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);
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Set;
}
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))
// 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));
// 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);
List typeVarAliases = readInTypeAliases(s);
ResolvedTypeMunger munger = new NewConstructorTypeMunger(sig, syntheticCtor, explicitCtor, superMethodsCalled,
typeVarAliases);
- if (sloc != null)
+ if (sloc != null) {
munger.setSourceLocation(sloc);
+ }
return munger;
}
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);
}
*/
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.
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;
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);
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();
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);
}
*/
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.
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;
}
}
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
kind.write(s);
signature.write(s);
writeSuperMethodsCalled(s);
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);
}
*/
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.
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
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");
}
* ******************************************************************/
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;
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
return lazyTestTypePattern;
}
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
throw new RuntimeException("shouldn't be serialized");
}
}
public boolean matches(ResolvedType matchType, ResolvedType aspectType) {
- if (matchType.isInterface())
+ if (matchType.isInterface()) {
return false;
+ }
return getTestTypePattern(aspectType).matchesStatically(matchType);
}
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import org.aspectj.util.FuzzyBoolean;
}
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));
return hashCode;
}
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
throw new RuntimeException("shouldn't be serialized");
}
* ******************************************************************/
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
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();
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
throw new RuntimeException("should not be serialized");
}
* ******************************************************************/
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public boolean isSynthetic();
- public void write(DataOutputStream s) throws IOException;
+ public void write(CompressingDataOutputStream s) throws IOException;
public ISourceContext getSourceContext(World world);
* ******************************************************************/
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
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);
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);
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
// ----
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
getDeclaringType().write(s);
s.writeInt(getModifiers());
s.writeUTF(getName());
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);
oos.close();
}
- public abstract void write(DataOutputStream s) throws IOException;
+ public abstract void write(CompressingDataOutputStream s) throws IOException;
public Kind getKind() {
return kind;
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
*/
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);
* ******************************************************************/
package org.aspectj.weaver;
-import java.io.DataOutputStream;
import java.io.IOException;
/**
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);
package org.aspectj.weaver;
import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
}
}
- public void write(DataOutputStream s) throws IOException {
+ public final void write(CompressingDataOutputStream s) throws IOException {
s.writeUTF(getSignature());
}
}
}
- 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++) {
* ******************************************************************/
package org.aspectj.weaver;
-import java.io.DataOutputStream;
-import java.io.IOException;
/**
* @author Adrian Colyer
return typeVariable.getName();
}
- @Override
- public void write(DataOutputStream s) throws IOException {
- super.write(s);
- }
-
@Override
public String getErasureSignature() {
return typeVariable.getFirstBound().getSignature();
* 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");
}
* ******************************************************************/
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;
*
* @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");
}
* ******************************************************************/
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;
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;
}
* 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;
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;
setLocation(left.getSourceContext(), left.getStart(), right.getEnd());
couldMatchKinds = left.couldMatchKinds() & right.couldMatchKinds();
}
-
+
public int couldMatchKinds() {
return couldMatchKinds;
}
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;
}
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;
}
}
* 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;
/**
* left && right
*
- * <p>any binding to formals is explicitly forbidden for any composite by the language
+ * <p>
+ * 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());
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) {
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);
}
public boolean isStarAnnotation() {
return left.isStarAnnotation() && right.isStarAnnotation();
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
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;
* ******************************************************************/
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;
/**
* @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;
public AnnotationPatternList(AnnotationTypePattern[] arguments) {
this.typePatterns = arguments;
- for (int i=0; i<arguments.length; i++) {
- if (arguments[i] == AnnotationTypePattern.ELLIPSIS) ellipsisCount++;
+ for (int i = 0; i < arguments.length; i++) {
+ if (arguments[i] == AnnotationTypePattern.ELLIPSIS) {
+ ellipsisCount++;
+ }
}
}
-
+
public AnnotationPatternList(List l) {
this((AnnotationTypePattern[]) l.toArray(new AnnotationTypePattern[l.size()]));
}
protected AnnotationTypePattern[] getAnnotationPatterns() {
return typePatterns;
}
-
- public AnnotationPatternList parameterizeWith(Map typeVariableMap,World w) {
+
+ public AnnotationPatternList parameterizeWith(Map typeVariableMap, World w) {
AnnotationTypePattern[] parameterizedPatterns = new AnnotationTypePattern[this.typePatterns.length];
for (int i = 0; i < parameterizedPatterns.length; i++) {
- parameterizedPatterns[i] = this.typePatterns[i].parameterizeWith(typeVariableMap,w);
+ parameterizedPatterns[i] = this.typePatterns[i].parameterizeWith(typeVariableMap, w);
}
AnnotationPatternList ret = new AnnotationPatternList(parameterizedPatterns);
ret.copyLocationFrom(this);
return ret;
}
-
+
public void resolve(World inWorld) {
for (int i = 0; i < typePatterns.length; i++) {
typePatterns[i].resolve(inWorld);
}
}
-
+
public FuzzyBoolean matches(ResolvedType[] someArgs) {
// do some quick length tests first
- int numArgsMatchedByEllipsis = (someArgs.length + ellipsisCount) - typePatterns.length;
- if (numArgsMatchedByEllipsis < 0) return FuzzyBoolean.NO;
+ int numArgsMatchedByEllipsis = (someArgs.length + ellipsisCount) - typePatterns.length;
+ if (numArgsMatchedByEllipsis < 0) {
+ return FuzzyBoolean.NO;
+ }
if ((numArgsMatchedByEllipsis > 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;
} 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<typePatterns.length; i++) {
+ for (int i = 0; i < typePatterns.length; i++) {
AnnotationTypePattern p = typePatterns[i];
if (p != null) {
typePatterns[i] = typePatterns[i].resolveBindings(scope, bindings, allowBinding);
}
return this;
}
-
+
public AnnotationPatternList resolveReferences(IntMap bindings) {
int len = typePatterns.length;
AnnotationTypePattern[] ret = new AnnotationTypePattern[len];
- for (int i=0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
ret[i] = typePatterns[i].remapAdviceFormals(bindings);
}
return new AnnotationPatternList(ret);
}
- 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 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<len; i++) {
- if (!this.typePatterns[i].equals(o.typePatterns[i])) return false;
+ if (len != this.typePatterns.length) {
+ return false;
+ }
+ for (int i = 0; i < len; i++) {
+ if (!this.typePatterns[i].equals(o.typePatterns[i])) {
+ return false;
+ }
}
return true;
}
-
- public int hashCode() {
- int result = 41;
- for (int i = 0, len = typePatterns.length; i < len; i++) {
- result = 37*result + typePatterns[i].hashCode();
- }
- return result;
- }
-
- public static AnnotationPatternList read(VersionedDataInputStream s, ISourceContext context) throws IOException {
+
+ public int hashCode() {
+ int result = 41;
+ for (int i = 0, len = typePatterns.length; i < len; i++) {
+ result = 37 * result + typePatterns[i].hashCode();
+ }
+ return result;
+ }
+
+ public static AnnotationPatternList read(VersionedDataInputStream s, ISourceContext context) throws IOException {
short len = s.readShort();
AnnotationTypePattern[] arguments = new AnnotationTypePattern[len];
- for (int i=0; i<len; i++) {
+ for (int i = 0; i < len; i++) {
arguments[i] = AnnotationTypePattern.read(s, context);
}
AnnotationPatternList ret = new AnnotationPatternList(arguments);
return ret;
}
-
- 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++) {
+ for (int i = 0; i < typePatterns.length; i++) {
typePatterns[i].write(s);
}
writeLocation(s);
}
- 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);
for (int i = 0; i < typePatterns.length; i++) {
- typePatterns[i].traverse(visitor,ret);
+ typePatterns[i].traverse(visitor, ret);
}
return ret;
}
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.AnnotatedElement;
import org.aspectj.weaver.BCException;
+import org.aspectj.weaver.CompressingDataOutputStream;
import org.aspectj.weaver.ConcreteTypeMunger;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.IntMap;
ResolvedMember decMethods[] = aspectType.getDeclaredMethods();
for (int i = 0; i < decMethods.length; i++) {
ResolvedMember member = decMethods[i];
- if (member.equals(ajcMethod))
+ if (member.equals(ajcMethod)) {
return member;
+ }
}
return null;
}
// "] shadow=["+shadow+" at "+shadow.getSourceLocation()+
// "] pointcut is at ["+getSourceLocation()+"]");
if (var == null) {
- if (matchInternal(shadow).alwaysTrue())
+ if (matchInternal(shadow).alwaysTrue()) {
return Literal.TRUE;
- else
+ } else {
return Literal.FALSE;
+ }
}
state.set(btp.getFormalIndex(), var);
}
- if (matchInternal(shadow).alwaysTrue())
+ if (matchInternal(shadow).alwaysTrue()) {
return Literal.TRUE;
- else
+ } else {
return Literal.FALSE;
+ }
}
/*
List l = new ArrayList();
l.add(annotationTypePattern);
return l;
- } else
+ } else {
return Collections.EMPTY_LIST;
+ }
}
/*
*
* @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.ANNOTATION);
annotationTypePattern.write(s);
writeLocation(s);
}
public boolean equals(Object other) {
- if (!(other instanceof AnnotationPointcut))
+ if (!(other instanceof AnnotationPointcut)) {
return false;
+ }
AnnotationPointcut o = (AnnotationPointcut) other;
return o.annotationTypePattern.equals(this.annotationTypePattern);
}
* ******************************************************************/
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.BCException;
+import org.aspectj.weaver.CompressingDataOutputStream;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.IntMap;
import org.aspectj.weaver.ResolvedType;
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
s.writeByte(AnnotationTypePattern.ELLIPSIS_KEY);
}
* ******************************************************************/
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.ResolvedType;
import org.aspectj.weaver.World;
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
s.writeByte(AnnotationTypePattern.ANY_KEY);
}
* ******************************************************************/
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
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;
/**
* @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 ArgsAnnotationPointcut extends NameBindingPointcut {
buildDeclarationText();
}
- public AnnotationPatternList getArguments() {
- return arguments;
- }
+ public AnnotationPatternList getArguments() {
+ return arguments;
+ }
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 Pointcut parameterizeWith(Map typeVariableMap,World w) {
- ArgsAnnotationPointcut ret = new ArgsAnnotationPointcut(arguments.parameterizeWith(typeVariableMap,w));
+
+ public Pointcut parameterizeWith(Map typeVariableMap, World w) {
+ ArgsAnnotationPointcut ret = new ArgsAnnotationPointcut(arguments.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) {
arguments.resolve(shadow.getIWorld());
- FuzzyBoolean ret =
- arguments.matches(shadow.getIWorld().resolve(shadow.getArgTypes()));
+ FuzzyBoolean ret = arguments.matches(shadow.getIWorld().resolve(shadow.getArgTypes()));
return ret;
}
- /* (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()) {
}
arguments.resolveBindings(scope, bindings, 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)");
}
}
- /* (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);
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;
} 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() {
}
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);
+ }
}
* PARC initial implementation
* ******************************************************************/
-
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
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;
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
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() {
}
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) {
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;
}
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()) {
}
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];
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;
}
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);
+ }
}
* ******************************************************************/
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.BCException;
+import org.aspectj.weaver.CompressingDataOutputStream;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.IntMap;
import org.aspectj.weaver.ReferenceType;
*/
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;
+ }
}
* ******************************************************************/
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;
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;
} 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;
}
}
* 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;
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 {
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 + ")";
+ }
}
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
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;
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);
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
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;
// 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;
return indices;
}
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
throw new RuntimeException("unimplemented");
}
}
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);
}
}
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);
* ******************************************************************/
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;
* @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);
* 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;
this.pointcut = pointcut;
this.message = message;
}
-
+
/**
* returns "declare warning: <message>" or "declare error: <message>"
*/
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("\"");
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);
}
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;
}
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;
}
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();
}
}
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
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;
this.child = child;
this.parents = parents;
this.isExtends = isExtends;
- if (child instanceof WildTypePattern)
+ if (child instanceof WildTypePattern) {
isWildChild = true;
+ }
}
// public String[] getTypeParameterNames() {
// }
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());
}
@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);
}
}
@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);
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;
}
}
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();
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()) {
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
*/
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();
}
public List<ResolvedType> findMatchingNewParents(ResolvedType onType, boolean reportErrors) {
- if (onType.isRawType())
+ if (onType.isRawType()) {
onType = onType.getGenericType();
- if (!match(onType))
+ }
+ if (!match(onType)) {
return Collections.emptyList();
+ }
List<ResolvedType> ret = new ArrayList<ResolvedType>();
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;
* ******************************************************************/
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;
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);
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;
}
public boolean equals(Object other) {
- if (!(other instanceof DeclarePrecedence))
+ if (!(other instanceof DeclarePrecedence)) {
return false;
+ }
DeclarePrecedence o = (DeclarePrecedence) other;
return o.patterns.equals(patterns);
}
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);
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()
}
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()),
}
}
}
- if (knownMatch == -1)
+ if (knownMatch == -1) {
return starMatch;
- else
+ } else {
return knownMatch;
+ }
}
public int compare(ResolvedType aspect1, ResolvedType aspect2) {
// 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() {
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;
}
@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);
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;
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("\"");
}
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);
}
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);
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();
}
}
* ******************************************************************/
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.BCException;
+import org.aspectj.weaver.CompressingDataOutputStream;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
}
@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);
* ******************************************************************/
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
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;
* @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);
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;
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;
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);
* 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;
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;
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(");
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);
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);
+ }
}
* ******************************************************************/
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.Iterator;
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;
}
@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);
* ******************************************************************/
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
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;
}
@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) {
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
s.writeByte(Pointcut.IF_FALSE);
}
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
s.writeByte(IF_TRUE);
}
import static org.aspectj.util.FuzzyBoolean.MAYBE;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
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;
}
@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);
* 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) {
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);
+ }
}
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 {
}
@Override
- public void write(DataOutputStream out) throws IOException {
+ public void write(CompressingDataOutputStream out) throws IOException {
out.writeUTF(new String(pattern));
}
* ******************************************************************/
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;
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);
}
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;
}
* 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;
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();
}
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);
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;
}
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;
}
@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);
* ******************************************************************/
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;
private AnnotationTypePattern left;
private AnnotationTypePattern right;
-
+
public OrAnnotationTypePattern(AnnotationTypePattern left, AnnotationTypePattern right) {
this.left = left;
this.right = right;
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();
* 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;
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;
}
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;
}
}
* 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;
/**
* left || right
*
- * <p>any binding to formals is explicitly forbidden for any composite by the language
+ * <p>
+ * 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) {
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() {
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;
* PARC initial implementation
* ******************************************************************/
-
package org.aspectj.weaver.patterns;
import java.io.DataInputStream;
import java.io.IOException;
import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.weaver.CompressingDataOutputStream;
import org.aspectj.weaver.IHasSourceLocation;
import org.aspectj.weaver.ISourceContext;
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);
}
}
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
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;
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);
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);
}
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));
* 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;
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;
}
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 "";
}
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;
+ }
+
}
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;
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;
// 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) {
PerObject ret = new PerObject(entry, isThis);
ret.inAspect = inAspect;
- if (inAspect.isAbstract())
+ if (inAspect.isAbstract()) {
return ret;
+ }
World world = inAspect.getWorld();
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);
}
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));
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;
return ret;
}
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
SINGLETON.write(s);
writeLocation(s);
}
}
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));
}
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.Member;
import org.aspectj.weaver.PerTypeWithinTargetTypeMunger;
// 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);
PerTypeWithin ret = new PerTypeWithin(typePattern);
ret.copyLocationFrom(this);
ret.inAspect = inAspect;
- if (inAspect.isAbstract())
+ if (inAspect.isAbstract()) {
return ret;
+ }
World world = inAspect.getWorld();
}
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
PERTYPEWITHIN.write(s);
typePattern.write(s);
writeLocation(s);
}
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));
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
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;
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
s.writeByte(NONE);
}
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.HashMap;
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;
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) {
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
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;
}
@Override
- public void write(DataOutputStream s) throws IOException {
+ public void write(CompressingDataOutputStream s) throws IOException {
kind.write(s);
modifiers.write(s);
returnType.write(s);
* ******************************************************************/
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
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;
* @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);
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
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;
}
@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);
* 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;
+ }
}
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;
}
@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);
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.Iterator;
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;
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);
}
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);
}
}
@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);
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);
}
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
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;
tLeft--;
}
}
-
+
public FuzzyBoolean matches(ResolvableTypeList types, TypePattern.MatchKind kind, ResolvedType[][] parameterAnnotations) {
int nameLength = types.length;
int patternLength = typePatterns.length;
}
@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);
* ******************************************************************/
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.
- * <p>For example:</p>
- * <ul>
- * <li><T> T genericMethod(T t) {...}</li>
- * <li>static <T extends Foo> T staticGenericMethod(T t) {...}</li>
- * <li>Foo<T extends Bar & IGoo>
- * </ul>
+ * @author colyer Represents a type variable as declared as part of a type declaration, parameter declaration, or type parameter
+ * specification.
+ * <p>
+ * For example:
+ * </p>
+ * <ul>
+ * <li><T> T genericMethod(T t) {...}</li>
+ * <li>static <T extends Foo> T staticGenericMethod(T t) {...}</li>
+ * <li>Foo<T extends Bar & IGoo>
+ * </ul>
*/
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
*/
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;
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);
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) {
}
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) {
}
}
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();
}
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;
}
-
+
}
* ******************************************************************/
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)) {
}
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);
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;
}
-
+
}
* ******************************************************************/
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
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;
* @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);
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
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;
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);
* ******************************************************************/
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
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;
* @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);
* ******************************************************************/
package org.aspectj.weaver.patterns;
-import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
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;
/**
* @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();
}
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;
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()) {
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() {
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);
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);
+ }
}
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;
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);
* 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;
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);
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 + ")";
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);
+ }
}
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;
/**
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();
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 {
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();
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 {
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();
* 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);
}
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);
}
}
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;
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();
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;
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()");
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();
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;
/**
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();
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;
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();
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;
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 {
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();