diff options
author | aclement <aclement> | 2005-01-07 14:14:45 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-01-07 14:14:45 +0000 |
commit | 797b6a6afb75b14dc530bc0831566e110da3ae91 (patch) | |
tree | 215856c38192e7e6091c994187c60678312cba3d /weaver | |
parent | e63ee67d9514aa9eef6038aa718aab499962252e (diff) | |
download | aspectj-797b6a6afb75b14dc530bc0831566e110da3ae91.tar.gz aspectj-797b6a6afb75b14dc530bc0831566e110da3ae91.zip |
Fix for Bug 82134: AspectJ 5 M2 should implement backwards compatibility for binary aspect form
Diffstat (limited to 'weaver')
68 files changed, 256 insertions, 151 deletions
diff --git a/weaver/src/org/aspectj/weaver/AdviceKind.java b/weaver/src/org/aspectj/weaver/AdviceKind.java index 55fbb1e97..abc560386 100644 --- a/weaver/src/org/aspectj/weaver/AdviceKind.java +++ b/weaver/src/org/aspectj/weaver/AdviceKind.java @@ -13,7 +13,6 @@ package org.aspectj.weaver; -import java.io.DataInputStream; import java.io.IOException; import org.aspectj.util.TypeSafeEnum; @@ -35,7 +34,7 @@ public class AdviceKind extends TypeSafeEnum { this.isCflow = isCflow; } - public static AdviceKind read(DataInputStream s) throws IOException { + public static AdviceKind read(VersionedDataInputStream s) throws IOException { int key = s.readByte(); switch(key) { case 1: return Before; diff --git a/weaver/src/org/aspectj/weaver/AjAttribute.java b/weaver/src/org/aspectj/weaver/AjAttribute.java index c1d631e6c..8bb1f6a9c 100644 --- a/weaver/src/org/aspectj/weaver/AjAttribute.java +++ b/weaver/src/org/aspectj/weaver/AjAttribute.java @@ -15,7 +15,6 @@ package org.aspectj.weaver; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -82,11 +81,12 @@ public abstract class AjAttribute { throw new RuntimeException("sanity check"); } } - - public static AjAttribute read(String name, byte[] bytes, ISourceContext context,IMessageHandler msgHandler) { + + public static AjAttribute read(AjAttribute.WeaverVersionInfo v, String name, byte[] bytes, ISourceContext context,IMessageHandler msgHandler) { try { if (bytes == null) bytes = new byte[0]; - DataInputStream s = new DataInputStream(new ByteArrayInputStream(bytes)); + VersionedDataInputStream s = new VersionedDataInputStream(new ByteArrayInputStream(bytes)); + s.setVersion(v); if (name.equals(Aspect.AttributeName)) { return new Aspect(PerClause.readPerClause(s, context)); } else if (name.equals(MethodDeclarationLineNumberAttribute.AttributeName)) { @@ -196,13 +196,25 @@ public abstract class AjAttribute { // The user will get a warning for any org.aspectj.weaver attributes the weaver does // not recognize. + // When we don't know ... (i.e. pre 1.2.1) + public static short WEAVER_VERSION_MAJOR_UNKNOWN = 0; + public static short WEAVER_VERSION_MINOR_UNKNOWN = 0; + + // These are the weaver major/minor numbers for AspectJ 1.2.1 - private static short WEAVER_VERSION_MAJOR_AJ121 = 1; - private static short WEAVER_VERSION_MINOR_AJ121 = 0; + public static short WEAVER_VERSION_MAJOR_AJ121 = 1; + public static short WEAVER_VERSION_MINOR_AJ121 = 0; + + // These are the weaver major/minor numbers for AspectJ 1.5.0 + public static short WEAVER_VERSION_MAJOR_AJ150 = 2; + public static short WEAVER_VERSION_MINOR_AJ150 = 0; // These are the weaver major/minor versions for *this* weaver - private static short CURRENT_VERSION_MAJOR = WEAVER_VERSION_MAJOR_AJ121; - private static short CURRENT_VERSION_MINOR = WEAVER_VERSION_MINOR_AJ121; + private static short CURRENT_VERSION_MAJOR = WEAVER_VERSION_MAJOR_AJ150; + private static short CURRENT_VERSION_MINOR = WEAVER_VERSION_MINOR_AJ150; + + public static final WeaverVersionInfo UNKNOWN = + new WeaverVersionInfo(WEAVER_VERSION_MAJOR_UNKNOWN,WEAVER_VERSION_MINOR_UNKNOWN); // These are the versions read in from a particular class file. private short major_version; @@ -228,10 +240,12 @@ public abstract class AjAttribute { s.writeShort(CURRENT_VERSION_MINOR); } - public static WeaverVersionInfo read(DataInputStream s) throws IOException { + public static WeaverVersionInfo read(VersionedDataInputStream s) throws IOException { short major = s.readShort(); short minor = s.readShort(); - return new WeaverVersionInfo(major,minor); + WeaverVersionInfo wvi = new WeaverVersionInfo(major,minor); +// s.setVersion(wvi); + return wvi; } public short getMajorVersion() { @@ -279,7 +293,7 @@ public abstract class AjAttribute { FileUtil.writeIntArray(lineBreaks, s); } - public static SourceContextAttribute read(DataInputStream s) throws IOException { + public static SourceContextAttribute read(VersionedDataInputStream s) throws IOException { return new SourceContextAttribute(s.readUTF(), FileUtil.readIntArray(s)); } public int[] getLineBreaks() { @@ -311,7 +325,7 @@ public abstract class AjAttribute { s.writeInt(lineNumber); } - public static MethodDeclarationLineNumberAttribute read(DataInputStream s) throws IOException { + public static MethodDeclarationLineNumberAttribute read(VersionedDataInputStream s) throws IOException { return new MethodDeclarationLineNumberAttribute(s.readInt()); } @@ -417,7 +431,7 @@ public abstract class AjAttribute { this.declaredExceptions = declaredExceptions; } - public static AdviceAttribute read(DataInputStream s, ISourceContext context) throws IOException { + public static AdviceAttribute read(VersionedDataInputStream s, ISourceContext context) throws IOException { AdviceKind kind = AdviceKind.read(s); if (kind == AdviceKind.Around) { return new AdviceAttribute( @@ -544,7 +558,7 @@ public abstract class AjAttribute { return accessedMembers; } - public static PrivilegedAttribute read(DataInputStream s, ISourceContext context) throws IOException { + public static PrivilegedAttribute read(VersionedDataInputStream s, ISourceContext context) throws IOException { return new PrivilegedAttribute(ResolvedMember.readResolvedMemberArray(s, context)); } } @@ -571,7 +585,7 @@ public abstract class AjAttribute { s.writeBoolean(weaveBody); } - public static EffectiveSignatureAttribute read(DataInputStream s, ISourceContext context) throws IOException { + public static EffectiveSignatureAttribute read(VersionedDataInputStream s, ISourceContext context) throws IOException { return new EffectiveSignatureAttribute( ResolvedMember.readResolvedMember(s, context), Shadow.Kind.read(s), diff --git a/weaver/src/org/aspectj/weaver/ResolvedPointcutDefinition.java b/weaver/src/org/aspectj/weaver/ResolvedPointcutDefinition.java index c5539a5fe..749243810 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedPointcutDefinition.java +++ b/weaver/src/org/aspectj/weaver/ResolvedPointcutDefinition.java @@ -13,7 +13,6 @@ package org.aspectj.weaver; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -52,7 +51,7 @@ public class ResolvedPointcutDefinition extends ResolvedMember { pointcut.write(s); } - public static ResolvedPointcutDefinition read(DataInputStream s, ISourceContext context) throws IOException { + public static ResolvedPointcutDefinition read(VersionedDataInputStream s, ISourceContext context) throws IOException { return new ResolvedPointcutDefinition( TypeX.read(s), s.readInt(), diff --git a/weaver/src/org/aspectj/weaver/VersionedDataInputStream.java b/weaver/src/org/aspectj/weaver/VersionedDataInputStream.java new file mode 100644 index 000000000..a9f239692 --- /dev/null +++ b/weaver/src/org/aspectj/weaver/VersionedDataInputStream.java @@ -0,0 +1,31 @@ +/* ******************************************************************* + * Copyright (c) 2005 IBM + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Andy Clement initial implementation + * ******************************************************************/ + +package org.aspectj.weaver; + +import java.io.DataInputStream; +import java.io.InputStream; + +import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; + +/** + * Lightweight subclass of DataInputStream that knows what version of the weaver was used to construct the data in it. + */ +public class VersionedDataInputStream extends DataInputStream { + private WeaverVersionInfo version = new WeaverVersionInfo();// assume we are the latest unless something tells us otherwise... + public VersionedDataInputStream(InputStream is) { super(is); } + + public int getMajorVersion() { return version.getMajorVersion(); } + public int getMinorVersion() { return version.getMinorVersion(); } + + public void setVersion(WeaverVersionInfo version) { this.version = version; } +}
\ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/WeaverStateInfo.java b/weaver/src/org/aspectj/weaver/WeaverStateInfo.java index 4b1a1a7b6..a2fc8eacb 100644 --- a/weaver/src/org/aspectj/weaver/WeaverStateInfo.java +++ b/weaver/src/org/aspectj/weaver/WeaverStateInfo.java @@ -84,7 +84,7 @@ public class WeaverStateInfo { private static final byte REWEAVABLE_BIT = 1<<4; private static final byte REWEAVABLE_COMPRESSION_BIT = 1<<5; - public static final WeaverStateInfo read(DataInputStream s, ISourceContext context) throws IOException { + public static final WeaverStateInfo read(VersionedDataInputStream s, ISourceContext context) throws IOException { byte b = s.readByte(); boolean isReweavable = ((b&REWEAVABLE_BIT)!=0); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAttributes.java b/weaver/src/org/aspectj/weaver/bcel/BcelAttributes.java index 9fb4b451e..f43ab8f2b 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAttributes.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAttributes.java @@ -21,22 +21,35 @@ import org.aspectj.apache.bcel.classfile.Unknown; import org.aspectj.apache.bcel.generic.ConstantPoolGen; import org.aspectj.bridge.IMessageHandler; import org.aspectj.weaver.AjAttribute; +import org.aspectj.weaver.BCException; import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; // this is a class o' static methods for reading attributes. It's pretty much a bridge from // bcel to AjAttribute. class BcelAttributes { - public static List readAjAttributes(Attribute[] as, ISourceContext context,IMessageHandler msgHandler) { + public static List readAjAttributes(String classname,Attribute[] as, ISourceContext context,IMessageHandler msgHandler) { List l = new ArrayList(); + AjAttribute.WeaverVersionInfo version = new WeaverVersionInfo(); for (int i = as.length - 1; i >= 0; i--) { Attribute a = as[i]; if (a instanceof Unknown) { Unknown u = (Unknown) a; String name = u.getName(); if (name.startsWith(AjAttribute.AttributePrefix)) { - AjAttribute attr = AjAttribute.read(name, u.getBytes(), context,msgHandler); + AjAttribute attr = AjAttribute.read(version,name,u.getBytes(),context,msgHandler); + if (attr!=null && attr instanceof AjAttribute.WeaverVersionInfo) { + version = (AjAttribute.WeaverVersionInfo)attr; + + // Do a version check, this weaver can't process versions + // from a future AspectJ (where the major number has changed) + if (version.getMajorVersion() > WeaverVersionInfo.getCurrentWeaverMajorVersion()) { + throw new BCException("Unable to continue, this version of AspectJ supports classes built with weaver version "+ + WeaverVersionInfo.toCurrentVersionString()+" but the class "+classname+" is version "+version.toString()); + } + } if (attr!=null) l.add(attr); } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelField.java b/weaver/src/org/aspectj/weaver/bcel/BcelField.java index 230513585..042947543 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelField.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelField.java @@ -52,7 +52,7 @@ final class BcelField extends ResolvedMember { private void unpackAttributes(World world) { Attribute[] attrs = field.getAttributes(); - List as = BcelAttributes.readAjAttributes(attrs, getSourceContext(world),world.getMessageHandler()); + List as = BcelAttributes.readAjAttributes(getDeclaringType().getClassName(),attrs, getSourceContext(world),world.getMessageHandler()); for (Iterator iter = as.iterator(); iter.hasNext();) { AjAttribute a = (AjAttribute) iter.next(); if (a instanceof AjAttribute.AjSynthetic) { diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java index e7725f374..e3e2de98e 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java @@ -90,7 +90,7 @@ final class BcelMethod extends ResolvedMember { } private void unpackAjAttributes(World world) { - List as = BcelAttributes.readAjAttributes(method.getAttributes(), getSourceContext(world),world.getMessageHandler()); + List as = BcelAttributes.readAjAttributes(getDeclaringType().getClassName(),method.getAttributes(), getSourceContext(world),world.getMessageHandler()); //System.out.println("unpack: " + this + ", " + as); for (Iterator iter = as.iterator(); iter.hasNext();) { AjAttribute a = (AjAttribute) iter.next(); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java index 9ccd7ad6d..34f9c6577 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java @@ -35,7 +35,6 @@ import org.aspectj.weaver.ResolvedPointcutDefinition; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; import org.aspectj.weaver.WeaverStateInfo; -import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; import org.aspectj.weaver.patterns.PerClause; // ??? exposed for testing @@ -169,7 +168,7 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { List pointcuts = new ArrayList(); typeMungers = new ArrayList(); declares = new ArrayList(); - List l = BcelAttributes.readAjAttributes(javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),getResolvedTypeX().getWorld().getMessageHandler()); + List l = BcelAttributes.readAjAttributes(javaClass.getClassName(),javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),getResolvedTypeX().getWorld().getMessageHandler()); for (Iterator iter = l.iterator(); iter.hasNext();) { AjAttribute a = (AjAttribute) iter.next(); //System.err.println("unpacking: " + this + " and " + a); @@ -190,20 +189,19 @@ public class BcelObjectType extends ResolvedTypeX.ConcreteName { ((BcelSourceContext)getResolvedTypeX().getSourceContext()).addAttributeInfo((AjAttribute.SourceContextAttribute)a); } } else if (a instanceof AjAttribute.WeaverVersionInfo) { - wvInfo = (AjAttribute.WeaverVersionInfo)a; - if (wvInfo.getMajorVersion() > WeaverVersionInfo.getCurrentWeaverMajorVersion()) { - // The class file containing this attribute was created by a version of AspectJ that - // added some behavior that 'this' version of AspectJ doesn't understand. And the - // class file contains changes that mean 'this' version of AspectJ cannot continue. - throw new BCException("Unable to continue, this version of AspectJ supports classes built with weaver version "+ - WeaverVersionInfo.toCurrentVersionString()+" but the class "+ javaClass.getClassName()+" is version "+wvInfo.toString()); - } + wvInfo = (AjAttribute.WeaverVersionInfo)a; // Set the weaver version used to build this type } else { throw new BCException("bad attribute " + a); } } this.pointcuts = (ResolvedPointcutDefinition[]) pointcuts.toArray(new ResolvedPointcutDefinition[pointcuts.size()]); + // Test isn't quite right, leaving this out for now... +// if (isAspect() && wvInfo.getMajorVersion() == WeaverVersionInfo.UNKNOWN.getMajorVersion()) { +// throw new BCException("Unable to continue, this version of AspectJ cannot use aspects as input that were built "+ +// "with an AspectJ earlier than version 1.2.1. Please rebuild class: "+javaClass.getClassName()); +// } + // this.typeMungers = (BcelTypeMunger[]) // typeMungers.toArray(new BcelTypeMunger[typeMungers.size()]); // this.declares = (Declare[]) diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index dc7741c4c..9c002bd9c 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -441,7 +441,7 @@ public final class LazyMethodGen { if (enclosingClass != null && enclosingClass.getType() != null) { context = enclosingClass.getType().getSourceContext(); } - List as = BcelAttributes.readAjAttributes(attributes, context,null); + List as = BcelAttributes.readAjAttributes(getClassName(),attributes, context,null); if (! as.isEmpty()) { out.println(" " + as.get(0)); // XXX assuming exactly one attribute, munger... } diff --git a/weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java index 47ec35969..018a0e8fc 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java @@ -9,13 +9,13 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; /** @@ -54,7 +54,7 @@ public class AndAnnotationTypePattern extends AnnotationTypePattern { return this; } - public static AnnotationTypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { AnnotationTypePattern p = new AndAnnotationTypePattern( AnnotationTypePattern.read(s,context), AnnotationTypePattern.read(s,context)); diff --git a/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java b/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java index dcb951d46..4bb8b1ce4 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/AndPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -26,6 +25,7 @@ import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Test; public class AndPointcut extends Pointcut { @@ -120,7 +120,7 @@ public class AndPointcut extends Pointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + 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; diff --git a/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java index 5258151fa..d72b84371 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java @@ -13,13 +13,13 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; +import org.aspectj.weaver.VersionedDataInputStream; /** * left && right @@ -75,7 +75,7 @@ public class AndTypePattern extends TypePattern { writeLocation(s); } - public static TypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypePattern ret = new AndTypePattern(TypePattern.read(s, context), TypePattern.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java index d586a824c..8361e65e4 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java +++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationPatternList.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.List; @@ -18,6 +17,7 @@ import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; /** @@ -155,7 +155,7 @@ public class AnnotationPatternList extends PatternNode { return result; } - public static AnnotationPatternList read(DataInputStream s, ISourceContext context) throws IOException { + 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++) { diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java index d8b378a9b..8cc80a37a 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationPointcut.java @@ -10,7 +10,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -29,6 +28,7 @@ import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; import org.aspectj.weaver.ast.Var; @@ -194,7 +194,7 @@ public class AnnotationPointcut extends NameBindingPointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { AnnotationTypePattern type = AnnotationTypePattern.read(s, context); AnnotationPointcut ret = new AnnotationPointcut((ExactAnnotationTypePattern)type); ret.readLocation(context, s); diff --git a/weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java index df5952b72..df25c75fb 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/AnnotationTypePattern.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -18,6 +17,7 @@ import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.BCException; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; public abstract class AnnotationTypePattern extends PatternNode { @@ -64,7 +64,7 @@ public abstract class AnnotationTypePattern extends PatternNode { public static final byte ANY_KEY = 7; public static final byte WILD = 8; - public static AnnotationTypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { byte key = s.readByte(); switch(key) { case EXACT: return ExactAnnotationTypePattern.read(s, context); diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java index d78dd8751..ff3336d62 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ArgsAnnotationPointcut.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -26,6 +25,7 @@ import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -182,7 +182,7 @@ public class ArgsAnnotationPointcut extends NameBindingPointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { AnnotationPatternList annotationPatternList = AnnotationPatternList.read(s,context); ArgsAnnotationPointcut ret = new ArgsAnnotationPointcut(annotationPatternList); ret.readLocation(context, s); diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java index aaa780cdd..15198d92d 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Constructor; @@ -39,6 +38,7 @@ import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -170,7 +170,7 @@ public class ArgsPointcut extends NameBindingPointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { ArgsPointcut ret = new ArgsPointcut(TypePatternList.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java index a140e9149..df35459eb 100644 --- a/weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/BindingAnnotationTypePattern.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -19,6 +18,7 @@ import org.aspectj.weaver.BCException; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; @@ -103,7 +103,7 @@ public class BindingAnnotationTypePattern extends ExactAnnotationTypePattern imp writeLocation(s); } - public static AnnotationTypePattern read(DataInputStream s, ISourceContext context) throws IOException { + 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"); diff --git a/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java index b49b75f8b..7a2488459 100644 --- a/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/BindingTypePattern.java @@ -13,13 +13,13 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; public class BindingTypePattern extends ExactTypePattern implements BindingPattern { private int formalIndex; @@ -59,7 +59,7 @@ public class BindingTypePattern extends ExactTypePattern implements BindingPatte writeLocation(out); } - public static TypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypePattern ret = new BindingTypePattern(TypeX.read(s), s.readShort(), s.readBoolean()); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java b/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java index 7203339f8..b8d1348f7 100644 --- a/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/CflowPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; @@ -37,6 +36,7 @@ import org.aspectj.weaver.ResolvedPointcutDefinition; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Test; @@ -106,7 +106,7 @@ public class CflowPointcut extends Pointcut { FileUtil.writeIntArray(freeVars, s); writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { CflowPointcut ret = new CflowPointcut(Pointcut.read(s, context), s.readBoolean(), FileUtil.readIntArray(s)); ret.readLocation(context, s); diff --git a/weaver/src/org/aspectj/weaver/patterns/Declare.java b/weaver/src/org/aspectj/weaver/patterns/Declare.java index 010a306a1..c03394316 100644 --- a/weaver/src/org/aspectj/weaver/patterns/Declare.java +++ b/weaver/src/org/aspectj/weaver/patterns/Declare.java @@ -13,10 +13,10 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.IOException; import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.VersionedDataInputStream; public abstract class Declare extends PatternNode { public static final byte ERROR_OR_WARNING = 1; @@ -24,7 +24,7 @@ public abstract class Declare extends PatternNode { public static final byte SOFT = 3; public static final byte DOMINATES = 4; - public static Declare read(DataInputStream s, ISourceContext context) throws IOException { + public static Declare read(VersionedDataInputStream s, ISourceContext context) throws IOException { byte kind = s.readByte(); switch (kind) { case ERROR_OR_WARNING: diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java b/weaver/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java index 051b44d81..33321dd73 100644 --- a/weaver/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java +++ b/weaver/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java @@ -13,11 +13,11 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.VersionedDataInputStream; public class DeclareErrorOrWarning extends Declare { private boolean isError; @@ -67,7 +67,7 @@ public class DeclareErrorOrWarning extends Declare { writeLocation(s); } - public static Declare read(DataInputStream s, ISourceContext context) throws IOException { + public static Declare read(VersionedDataInputStream s, ISourceContext context) throws IOException { Declare ret = new DeclareErrorOrWarning( s.readBoolean(), Pointcut.read(s, context), diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclareParents.java b/weaver/src/org/aspectj/weaver/patterns/DeclareParents.java index abb93d4b4..a6bbe0af1 100644 --- a/weaver/src/org/aspectj/weaver/patterns/DeclareParents.java +++ b/weaver/src/org/aspectj/weaver/patterns/DeclareParents.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -24,6 +23,7 @@ import org.aspectj.bridge.IMessage; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; @@ -86,7 +86,7 @@ public class DeclareParents extends Declare { writeLocation(s); } - public static Declare read(DataInputStream s, ISourceContext context) throws IOException { + public static Declare read(VersionedDataInputStream s, ISourceContext context) throws IOException { Declare ret = new DeclareParents(TypePattern.read(s, context), TypePatternList.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java b/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java index 19686b063..02f59df48 100644 --- a/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java +++ b/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.List; @@ -21,6 +20,7 @@ import java.util.List; import org.aspectj.bridge.IMessage; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; public class DeclarePrecedence extends Declare { @@ -60,7 +60,7 @@ public class DeclarePrecedence extends Declare { writeLocation(s); } - public static Declare read(DataInputStream s, ISourceContext context) throws IOException { + public static Declare read(VersionedDataInputStream s, ISourceContext context) throws IOException { Declare ret = new DeclarePrecedence(TypePatternList.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java b/weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java index 766df62d2..b794c9459 100644 --- a/weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java +++ b/weaver/src/org/aspectj/weaver/patterns/DeclareSoft.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -21,6 +20,7 @@ import org.aspectj.bridge.IMessage; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; public class DeclareSoft extends Declare { @@ -65,7 +65,7 @@ public class DeclareSoft extends Declare { writeLocation(s); } - public static Declare read(DataInputStream s, ISourceContext context) throws IOException { + public static Declare read(VersionedDataInputStream s, ISourceContext context) throws IOException { Declare ret = new DeclareSoft( TypePattern.read(s, context), Pointcut.read(s, context) diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java index 61b1eaa13..b4a67924b 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -21,6 +20,7 @@ import org.aspectj.weaver.BCException; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; @@ -151,7 +151,7 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern { writeLocation(s); } - public static AnnotationTypePattern read(DataInputStream s,ISourceContext context) throws IOException { + public static AnnotationTypePattern read(VersionedDataInputStream s,ISourceContext context) throws IOException { AnnotationTypePattern ret; byte version = s.readByte(); if (version > VERSION) { diff --git a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java index 2f150d3f4..1339c4dd8 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java @@ -20,10 +20,12 @@ 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.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; public class ExactTypePattern extends TypePattern { protected TypeX type; @@ -197,7 +199,15 @@ public class ExactTypePattern extends TypePattern { writeLocation(out); } - public static TypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { + if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { + return readTypePattern150(s,context); + } else { + return readTypePatternOldStyle(s,context); + } + } + + public static TypePattern readTypePattern150(VersionedDataInputStream s, ISourceContext context) throws IOException { byte version = s.readByte(); if (version > EXACT_VERSION) throw new BCException("ExactTypePattern was written by a more recent version of AspectJ"); TypePattern ret = new ExactTypePattern(TypeX.read(s), s.readBoolean(), s.readBoolean()); @@ -206,7 +216,13 @@ public class ExactTypePattern extends TypePattern { return ret; } - public String toString() { + public static TypePattern readTypePatternOldStyle(DataInputStream s, ISourceContext context) throws IOException { + TypePattern ret = new ExactTypePattern(TypeX.read(s), s.readBoolean(),false); + ret.readLocation(context, s); + return ret; + } + + public String toString() { StringBuffer buff = new StringBuffer(); if (annotationPattern != AnnotationTypePattern.ANY) { buff.append('('); diff --git a/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java b/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java index 398763788..0c3b80385 100644 --- a/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/HandlerPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -26,6 +25,7 @@ import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; import org.aspectj.weaver.internal.tools.PointcutExpressionImpl; @@ -128,7 +128,7 @@ public class HandlerPointcut extends Pointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { HandlerPointcut ret = new HandlerPointcut(TypePattern.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java index 612d18a01..b15d81a39 100644 --- a/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/IfPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -33,6 +32,7 @@ import org.aspectj.weaver.ResolvedPointcutDefinition; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Expr; import org.aspectj.weaver.ast.Literal; @@ -100,7 +100,7 @@ public class IfPointcut extends Pointcut { s.writeByte(extraParameterFlags); writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { IfPointcut ret = new IfPointcut(ResolvedMember.readResolvedMember(s, context), s.readByte()); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java b/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java index 611dbe4f6..26749020b 100644 --- a/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/KindedPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.HashSet; @@ -31,6 +30,7 @@ import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -257,7 +257,7 @@ public class KindedPointcut extends Pointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { Shadow.Kind kind = Shadow.Kind.read(s); SignaturePattern sig = SignaturePattern.read(s, context); KindedPointcut ret = new KindedPointcut(kind, sig); diff --git a/weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java b/weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java index f60eecc3b..ad11cfd12 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/ModifiersPattern.java @@ -13,13 +13,14 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; 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.VersionedDataInputStream; + public class ModifiersPattern extends PatternNode { private int requiredModifiers; private int forbiddenModifiers; @@ -58,7 +59,7 @@ public class ModifiersPattern extends PatternNode { } - public static ModifiersPattern read(DataInputStream s) throws IOException { + public static ModifiersPattern read(VersionedDataInputStream s) throws IOException { int requiredModifiers = s.readShort(); int forbiddenModifiers = s.readShort(); if (requiredModifiers == 0 && forbiddenModifiers == 0) return ANY; diff --git a/weaver/src/org/aspectj/weaver/patterns/NamePattern.java b/weaver/src/org/aspectj/weaver/patterns/NamePattern.java index 361060faf..9ede44bf2 100644 --- a/weaver/src/org/aspectj/weaver/patterns/NamePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/NamePattern.java @@ -13,10 +13,11 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.VersionedDataInputStream; + public class NamePattern extends PatternNode { char[] pattern; int starCount = 0; @@ -135,7 +136,7 @@ public class NamePattern extends PatternNode { out.writeUTF(new String(pattern)); } - public static NamePattern read(DataInputStream in) throws IOException { + public static NamePattern read(VersionedDataInputStream in) throws IOException { String s = in.readUTF(); if (s.length() == 0) return ELLIPSIS; return new NamePattern(s); diff --git a/weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java index 869bbf43c..694cf4652 100644 --- a/weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java @@ -9,13 +9,13 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; public class NotAnnotationTypePattern extends AnnotationTypePattern { @@ -59,7 +59,7 @@ public class NotAnnotationTypePattern extends AnnotationTypePattern { writeLocation(s); } - public static AnnotationTypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { AnnotationTypePattern ret = new NotAnnotationTypePattern(AnnotationTypePattern.read(s,context)); ret.readLocation(context,s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java b/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java index ea2587ed5..bdbecfcbf 100644 --- a/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/NotPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -25,6 +24,7 @@ import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Test; public class NotPointcut extends Pointcut { @@ -117,7 +117,7 @@ public class NotPointcut extends Pointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { NotPointcut ret = new NotPointcut(Pointcut.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java index 2e6ab0a43..772b4cdd4 100644 --- a/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java @@ -13,13 +13,13 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; +import org.aspectj.weaver.VersionedDataInputStream; /** * !TypePattern @@ -76,7 +76,7 @@ public class NotTypePattern extends TypePattern { writeLocation(s); } - public static TypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypePattern ret = new NotTypePattern(TypePattern.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java index 7c7c12fca..6bdf616e4 100644 --- a/weaver/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/OrAnnotationTypePattern.java @@ -9,13 +9,13 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; public class OrAnnotationTypePattern extends AnnotationTypePattern { @@ -48,7 +48,7 @@ public class OrAnnotationTypePattern extends AnnotationTypePattern { return this; } - public static AnnotationTypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static AnnotationTypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { AnnotationTypePattern p = new OrAnnotationTypePattern( AnnotationTypePattern.read(s,context), AnnotationTypePattern.read(s,context)); diff --git a/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java b/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java index 2eca6de01..d5fd12471 100644 --- a/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/OrPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -26,6 +25,7 @@ import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Test; public class OrPointcut extends Pointcut { @@ -123,7 +123,7 @@ public class OrPointcut extends Pointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + 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; diff --git a/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java index 4d8e6316c..0d51c464e 100644 --- a/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java @@ -13,13 +13,13 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; +import org.aspectj.weaver.VersionedDataInputStream; /** * left || right @@ -79,7 +79,7 @@ public class OrTypePattern extends TypePattern { writeLocation(s); } - public static TypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypePattern ret = new OrTypePattern(TypePattern.read(s, context), TypePattern.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/PerCflow.java b/weaver/src/org/aspectj/weaver/patterns/PerCflow.java index d03daa5eb..3c7c2067f 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerCflow.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerCflow.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; @@ -33,6 +32,7 @@ import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Expr; import org.aspectj.weaver.ast.Test; @@ -105,7 +105,7 @@ public class PerCflow extends PerClause { writeLocation(s); } - public static PerClause readPerClause(DataInputStream s, ISourceContext context) throws IOException { + public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException { PerCflow ret = new PerCflow(Pointcut.read(s, context), s.readBoolean()); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/PerClause.java b/weaver/src/org/aspectj/weaver/patterns/PerClause.java index 632778c9e..5bff424eb 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerClause.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerClause.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.IOException; import org.aspectj.util.TypeSafeEnum; @@ -22,7 +21,7 @@ import org.aspectj.weaver.*; public abstract class PerClause extends Pointcut { protected ResolvedTypeX inAspect; - public static PerClause readPerClause(DataInputStream s, ISourceContext context) throws IOException { + public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException { Kind kind = Kind.read(s); if (kind == SINGLETON) return PerSingleton.readPerClause(s, context); else if (kind == PERCFLOW) return PerCflow.readPerClause(s, context); @@ -43,7 +42,7 @@ public abstract class PerClause extends Pointcut { public static class Kind extends TypeSafeEnum { public Kind(String name, int key) { super(name, key); } - public static Kind read(DataInputStream s) throws IOException { + public static Kind read(VersionedDataInputStream s) throws IOException { int key = s.readByte(); switch(key) { case 1: return SINGLETON; diff --git a/weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java b/weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java index c7274ea81..d7841008e 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerFromSuper.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.Set; @@ -23,6 +22,7 @@ import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Test; @@ -88,7 +88,7 @@ public class PerFromSuper extends PerClause { writeLocation(s); } - public static PerClause readPerClause(DataInputStream s, ISourceContext context) throws IOException { + public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException { PerFromSuper ret = new PerFromSuper(Kind.read(s)); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/PerObject.java b/weaver/src/org/aspectj/weaver/patterns/PerObject.java index ef74a8d13..76d7425bb 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerObject.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerObject.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.HashSet; @@ -28,6 +27,7 @@ import org.aspectj.weaver.PerObjectInterfaceTypeMunger; import org.aspectj.weaver.ResolvedTypeMunger; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; import org.aspectj.weaver.ast.Expr; import org.aspectj.weaver.ast.Test; @@ -115,7 +115,7 @@ public class PerObject extends PerClause { writeLocation(s); } - public static PerClause readPerClause(DataInputStream s, ISourceContext context) throws IOException { + public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException { PerClause ret = new PerObject(Pointcut.read(s, context), s.readBoolean()); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java b/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java index f4d8b9879..ead14bef2 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java +++ b/weaver/src/org/aspectj/weaver/patterns/PerSingleton.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.Set; @@ -23,6 +22,7 @@ import org.aspectj.weaver.AjcMemberMaker; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Expr; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -71,7 +71,7 @@ public class PerSingleton extends PerClause { writeLocation(s); } - public static PerClause readPerClause(DataInputStream s, ISourceContext context) throws IOException { + public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException { PerSingleton ret = new PerSingleton(); ret.readLocation(context, s); return ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java index 1ba966c05..d6950a4c4 100644 --- a/weaver/src/org/aspectj/weaver/patterns/Pointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/Pointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -32,6 +31,7 @@ import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -298,7 +298,7 @@ public abstract class Pointcut extends PatternNode implements PointcutExpression //XXX currently it's unused we're keeping it around as a stub public void postRead(ResolvedTypeX enclosingType) {} - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { byte kind = s.readByte(); Pointcut ret; diff --git a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java index ded642b4e..664ddbfb5 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Modifier; @@ -30,6 +29,7 @@ import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Test; @@ -107,7 +107,7 @@ public class ReferencePointcut extends Pointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypeX onType = null; if (s.readBoolean()) { onType = TypeX.read(s); diff --git a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java index f48cd76ae..983b5409b 100644 --- a/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Constructor; @@ -30,6 +29,7 @@ import org.aspectj.lang.reflect.AdviceSignature; import org.aspectj.lang.reflect.ConstructorSignature; import org.aspectj.lang.reflect.FieldSignature; import org.aspectj.lang.reflect.MethodSignature; +import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.Constants; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.Member; @@ -37,6 +37,7 @@ import org.aspectj.weaver.NameMangler; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; @@ -516,7 +517,7 @@ public class SignaturePattern extends PatternNode { writeLocation(s); } - public static SignaturePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static SignaturePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { Member.Kind kind = Member.Kind.read(s); ModifiersPattern modifiers = ModifiersPattern.read(s); TypePattern returnType = TypePattern.read(s, context); @@ -524,7 +525,13 @@ public class SignaturePattern extends PatternNode { NamePattern name = NamePattern.read(s); TypePatternList parameterTypes = TypePatternList.read(s, context); ThrowsPattern throwsPattern = ThrowsPattern.read(s, context); - AnnotationTypePattern annotationPattern = AnnotationTypePattern.read(s,context); + + AnnotationTypePattern annotationPattern = AnnotationTypePattern.ANY; + + if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { + annotationPattern = AnnotationTypePattern.read(s,context); + } + SignaturePattern ret = new SignaturePattern(kind, modifiers, returnType, declaringType, name, parameterTypes, throwsPattern,annotationPattern); ret.readLocation(context, s); diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java index a0ee2ffd4..6870b6ee9 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetAnnotationPointcut.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -28,6 +27,7 @@ import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -227,7 +227,7 @@ public class ThisOrTargetAnnotationPointcut extends NameBindingPointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { boolean isThis = s.readBoolean(); AnnotationTypePattern type = AnnotationTypePattern.read(s, context); ThisOrTargetAnnotationPointcut ret = new ThisOrTargetAnnotationPointcut(isThis,(ExactAnnotationTypePattern)type); diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java index 148d29a7c..8c3dcccfd 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -32,6 +31,7 @@ import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -127,7 +127,7 @@ public class ThisOrTargetPointcut extends NameBindingPointcut { type.write(s); writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { boolean isThis = s.readBoolean(); TypePattern type = TypePattern.read(s, context); ThisOrTargetPointcut ret = new ThisOrTargetPointcut(isThis, type); diff --git a/weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java b/weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java index 5af1c4049..ea66f5900 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/ThrowsPattern.java @@ -13,13 +13,13 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.World; @@ -129,7 +129,7 @@ public class ThrowsPattern extends PatternNode { return false; } - public static ThrowsPattern read(DataInputStream s, ISourceContext context) throws IOException { + 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; diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java index 256373198..dd63bae16 100644 --- a/weaver/src/org/aspectj/weaver/patterns/TypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/TypePattern.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.Iterator; @@ -25,6 +24,7 @@ import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; /** @@ -267,7 +267,7 @@ public abstract class TypePattern extends PatternNode { public static final byte AND = 8; public static final byte NO_KEY = 9; - public static TypePattern read(DataInputStream s, ISourceContext context) throws IOException { + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { byte key = s.readByte(); switch(key) { case WILD: return WildTypePattern.read(s, context); diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java b/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java index 3aa4f9cf8..67dff9dc1 100644 --- a/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java +++ b/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -25,6 +24,7 @@ import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; public class TypePatternList extends PatternNode { private TypePattern[] typePatterns; @@ -471,7 +471,7 @@ public class TypePatternList extends PatternNode { } - public static TypePatternList read(DataInputStream s, ISourceContext context) throws IOException { + public static TypePatternList read(VersionedDataInputStream s, ISourceContext context) throws IOException { short len = s.readShort(); TypePattern[] arguments = new TypePattern[len]; for (int i=0; i<len; i++) { diff --git a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java index 3cce9aca8..c6a9fabe2 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -20,6 +19,7 @@ import org.aspectj.weaver.AnnotatedElement; import org.aspectj.weaver.BCException; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.World; @@ -102,7 +102,7 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern { writeLocation(s); } - public static AnnotationTypePattern read(DataInputStream s,ISourceContext context) throws IOException { + public static AnnotationTypePattern read(VersionedDataInputStream s,ISourceContext context) throws IOException { AnnotationTypePattern ret; byte version = s.readByte(); if (version > VERSION) { diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java index d0cc882a6..8e631c09b 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java +++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -24,10 +23,12 @@ import org.aspectj.bridge.Message; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FileUtil; import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.BCException; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; //XXX need to use dim in matching @@ -607,11 +608,36 @@ public class WildTypePattern extends TypePattern { annotationPattern.write(s); } - public static TypePattern read(DataInputStream s, ISourceContext context) throws IOException { - byte version = s.readByte(); - if (version > VERSION) { - throw new BCException("WildTypePattern was written by a more recent version of AspectJ, cannot read"); - } + public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { + if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { + return readTypePattern150(s,context); + } else { + return readTypePatternOldStyle(s,context); + } + } + + public static TypePattern readTypePattern150(VersionedDataInputStream s, ISourceContext context) throws IOException { + byte version = s.readByte(); + if (version > VERSION) { + throw new BCException("WildTypePattern was written by a more recent version of AspectJ, cannot read"); + } + int len = s.readShort(); + NamePattern[] namePatterns = new NamePattern[len]; + for (int i=0; i < len; i++) { + namePatterns[i] = NamePattern.read(s); + } + boolean includeSubtypes = s.readBoolean(); + int dim = s.readInt(); + boolean varArg = s.readBoolean(); + WildTypePattern ret = new WildTypePattern(namePatterns, includeSubtypes, dim, varArg); + ret.knownMatches = FileUtil.readStringArray(s); + ret.importedPrefixes = FileUtil.readStringArray(s); + ret.readLocation(context, s); + ret.setAnnotationTypePattern(AnnotationTypePattern.read(s,context)); + return ret; + } + + public static TypePattern readTypePatternOldStyle(VersionedDataInputStream s, ISourceContext context) throws IOException { int len = s.readShort(); NamePattern[] namePatterns = new NamePattern[len]; for (int i=0; i < len; i++) { @@ -619,12 +645,10 @@ public class WildTypePattern extends TypePattern { } boolean includeSubtypes = s.readBoolean(); int dim = s.readInt(); - boolean varArg = s.readBoolean(); - WildTypePattern ret = new WildTypePattern(namePatterns, includeSubtypes, dim,varArg); + WildTypePattern ret = new WildTypePattern(namePatterns, includeSubtypes, dim, false); ret.knownMatches = FileUtil.readStringArray(s); ret.importedPrefixes = FileUtil.readStringArray(s); ret.readLocation(context, s); - ret.setAnnotationTypePattern(AnnotationTypePattern.read(s,context)); return ret; } diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java index bc65e609e..7dc8c60f3 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/WithinAnnotationPointcut.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -27,6 +26,7 @@ import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -162,7 +162,7 @@ public class WithinAnnotationPointcut extends NameBindingPointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { AnnotationTypePattern type = AnnotationTypePattern.read(s, context); WithinAnnotationPointcut ret = new WithinAnnotationPointcut((ExactAnnotationTypePattern)type); ret.readLocation(context, s); diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java index 9e0411e3e..b91ee20e3 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/WithinCodeAnnotationPointcut.java @@ -9,7 +9,6 @@ * ******************************************************************/ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -29,6 +28,7 @@ import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; import org.aspectj.weaver.ShadowMunger; import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; import org.aspectj.weaver.ast.Var; @@ -176,7 +176,7 @@ public class WithinCodeAnnotationPointcut extends NameBindingPointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { AnnotationTypePattern type = AnnotationTypePattern.read(s, context); WithinCodeAnnotationPointcut ret = new WithinCodeAnnotationPointcut((ExactAnnotationTypePattern)type); ret.readLocation(context, s); diff --git a/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java index 96201d203..5e043d438 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/WithinPointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -28,6 +27,7 @@ import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.WeaverMessages; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -121,7 +121,7 @@ public class WithinPointcut extends Pointcut { typePattern.write(s); writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { TypePattern type = TypePattern.read(s, context); WithinPointcut ret = new WithinPointcut(type); ret.readLocation(context, s); diff --git a/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java b/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java index 2de912cc4..326567be3 100644 --- a/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/WithincodePointcut.java @@ -13,7 +13,6 @@ package org.aspectj.weaver.patterns; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Member; @@ -27,6 +26,7 @@ import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedTypeX; import org.aspectj.weaver.Shadow; +import org.aspectj.weaver.VersionedDataInputStream; import org.aspectj.weaver.ast.Literal; import org.aspectj.weaver.ast.Test; @@ -91,7 +91,7 @@ public class WithincodePointcut extends Pointcut { writeLocation(s); } - public static Pointcut read(DataInputStream s, ISourceContext context) throws IOException { + public static Pointcut read(VersionedDataInputStream s, ISourceContext context) throws IOException { WithincodePointcut ret = new WithincodePointcut(SignaturePattern.read(s, context)); ret.readLocation(context, s); return ret; diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/PatternWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/PatternWeaveTestCase.java index fa3b0481f..31560fa90 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/PatternWeaveTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/PatternWeaveTestCase.java @@ -108,7 +108,7 @@ public class PatternWeaveTestCase extends WeaveTestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); Pointcut newP = Pointcut.read(in, null); assertEquals("write/read", p, newP); diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java index 3c37e1bf9..28cc91bc5 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/PointcutResidueTestCase.java @@ -226,7 +226,7 @@ public class PointcutResidueTestCase extends WeaveTestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); Pointcut newP = Pointcut.read(in, null); assertEquals("write/read", p, newP); diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java index 45f9b59d5..ddb00a318 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/AndOrNotTestCase.java @@ -142,7 +142,7 @@ public class AndOrNotTestCase extends TestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); Pointcut newP = Pointcut.read(in, null); assertEquals("write/read", p, newP); diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java index c0d5fa848..00bebaef9 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java @@ -15,6 +15,8 @@ package org.aspectj.weaver.patterns; import java.io.*; +import org.aspectj.weaver.VersionedDataInputStream; + import junit.framework.TestCase; public class DeclareErrorOrWarningTestCase extends TestCase { @@ -53,7 +55,7 @@ public class DeclareErrorOrWarningTestCase extends TestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); Declare newDeclare = Declare.read(in, null); assertEquals("write/read", declare, newDeclare); diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java index 9a1026032..4adf2e88c 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/ModifiersPatternTestCase.java @@ -130,7 +130,7 @@ public class ModifiersPatternTestCase extends TestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); ModifiersPattern newP = ModifiersPattern.read(in); assertEquals("write/read", p, newP); diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java index 2239d0be8..e3baf278d 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/NamePatternTestCase.java @@ -15,10 +15,11 @@ package org.aspectj.weaver.patterns; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import org.aspectj.weaver.VersionedDataInputStream; + import junit.framework.TestCase; /** @@ -111,7 +112,7 @@ public class NamePatternTestCase extends TestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); NamePattern newP = NamePattern.read(in); assertEquals("write/read", p, newP); diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java index b61d3aa1e..4a9188bbc 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/SignaturePatternTestCase.java @@ -166,7 +166,7 @@ public class SignaturePatternTestCase extends TestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); SignaturePattern newP = SignaturePattern.read(in, null); assertEquals("write/read", p, newP); diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java index acd6dcb65..429e8634e 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternListTestCase.java @@ -181,7 +181,7 @@ public class TypePatternListTestCase extends TestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); TypePatternList newP = TypePatternList.read(in, null); assertEquals("write/read", p, newP); diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java index ad6d7e45a..354d6edba 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/TypePatternTestCase.java @@ -294,7 +294,7 @@ public class TypePatternTestCase extends TestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); TypePattern newP = TypePattern.read(in, null); assertEquals("write/read", p, newP); diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java index 18d0380ca..208431598 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/WithinTestCase.java @@ -117,7 +117,7 @@ public class WithinTestCase extends TestCase { out.close(); ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); - DataInputStream in = new DataInputStream(bi); + VersionedDataInputStream in = new VersionedDataInputStream(bi); Pointcut newP = Pointcut.read(in, null); assertEquals("write/read", p, newP); |