diff options
author | aclement <aclement> | 2010-05-19 15:12:50 +0000 |
---|---|---|
committer | aclement <aclement> | 2010-05-19 15:12:50 +0000 |
commit | 4af64f4bb0b9120d86ad766964626ccc6941ebec (patch) | |
tree | 19be11d154ce26da3b6c578aef12d5b38d390a7b /org.aspectj.matcher | |
parent | fcfdaf918a394323a94fece363f50e521a7fc049 (diff) | |
download | aspectj-4af64f4bb0b9120d86ad766964626ccc6941ebec.tar.gz aspectj-4af64f4bb0b9120d86ad766964626ccc6941ebec.zip |
312839: smaller class files
Diffstat (limited to 'org.aspectj.matcher')
7 files changed, 177 insertions, 62 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java b/org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java index 982a5ab8c..ab1aca134 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/AjAttribute.java @@ -366,12 +366,33 @@ public abstract class AjAttribute { @Override public void write(CompressingDataOutputStream s) throws IOException { - s.writeUTF(sourceFileName); - FileUtil.writeIntArray(lineBreaks, s); + if (s.canCompress()) { + s.writeCompressedPath(sourceFileName); + } else { + s.writeUTF(sourceFileName); + } + s.writeInt(lineBreaks.length); + int previous = 0; + for (int i = 0, max = lineBreaks.length; i < max; i++) { + s.writeShort(lineBreaks[i] - previous); + previous = lineBreaks[i]; + } } public static SourceContextAttribute read(VersionedDataInputStream s) throws IOException { - return new SourceContextAttribute(s.readUTF(), FileUtil.readIntArray(s)); + String sourceFileName = s.isAtLeast169() ? s.readPath() : s.readUTF(); + int lineBreaks = s.readInt(); + int[] lines = new int[lineBreaks]; + int previous = 0; + for (int i = 0; i < lineBreaks; i++) { + if (s.isAtLeast169()) { + lines[i] = s.readShort() + previous; + previous = lines[i]; + } else { + lines[i] = s.readInt(); + } + } + return new SourceContextAttribute(sourceFileName, lines); } public int[] getLineBreaks() { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/CompressingDataOutputStream.java b/org.aspectj.matcher/src/org/aspectj/weaver/CompressingDataOutputStream.java index 1e2f31c35..59b4fbcab 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/CompressingDataOutputStream.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/CompressingDataOutputStream.java @@ -32,10 +32,6 @@ public class CompressingDataOutputStream extends DataOutputStream { this.constantPoolWriter = constantPoolWriter; } - public CompressingDataOutputStream(ByteArrayOutputStream baos) { - super(baos); - } - public CompressingDataOutputStream(FileOutputStream fos) { super(fos); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java index 7f9330c87..963490118 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java @@ -380,10 +380,28 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno public void write(CompressingDataOutputStream s) throws IOException { getKind().write(s); - getDeclaringType().write(s); + s.writeBoolean(s.canCompress()); // boolean indicates if parts of this are compressed references + + // write out the signature of the declaring type of this member + if (s.canCompress()) { + s.writeCompressedSignature(getDeclaringType().getSignature()); + } else { + getDeclaringType().write(s); + } + + // write out the modifiers s.writeInt(modifiers); - s.writeUTF(getName()); - s.writeUTF(getSignature()); + + // write out the name and the signature of this member + if (s.canCompress()) { + s.writeCompressedName(getName()); + s.writeCompressedSignature(getSignature()); + } else { + s.writeUTF(getName()); + s.writeUTF(getSignature()); + } + + // write out the array clauses UnresolvedType.writeArray(getExceptions(), s); s.writeInt(getStart()); @@ -392,24 +410,33 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno // Write out any type variables... if (typeVariables == null) { - s.writeInt(0); + s.writeByte(0); } else { - s.writeInt(typeVariables.length); + s.writeByte(typeVariables.length); for (int i = 0; i < typeVariables.length; i++) { typeVariables[i].write(s); } } String gsig = getGenericSignature(); + + // change this to a byte: 255=false 0>254 means true and encodes the number of parameters if (getSignature().equals(gsig)) { - s.writeBoolean(false); + s.writeByte(0xff); } else { - s.writeBoolean(true); - s.writeInt(parameterTypes.length); + s.writeByte(parameterTypes.length); for (int i = 0; i < parameterTypes.length; i++) { - UnresolvedType array_element = parameterTypes[i]; - array_element.write(s); + if (s.canCompress()) { + s.writeCompressedSignature(parameterTypes[i].getSignature()); + } else { + UnresolvedType array_element = parameterTypes[i]; + array_element.write(s); + } + } + if (s.canCompress()) { + s.writeCompressedSignature(returnType.getSignature()); + } else { + returnType.write(s); } - returnType.write(s); } } @@ -469,8 +496,13 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno public static ResolvedMemberImpl readResolvedMember(VersionedDataInputStream s, ISourceContext sourceContext) throws IOException { - ResolvedMemberImpl m = new ResolvedMemberImpl(MemberKind.read(s), UnresolvedType.read(s), s.readInt(), s.readUTF(), s - .readUTF()); + MemberKind mk = MemberKind.read(s); + boolean compressed = (s.isAtLeast169() ? s.readBoolean() : false); + UnresolvedType declaringType = compressed ? UnresolvedType.forSignature(s.readUtf8(s.readShort())) : UnresolvedType.read(s); + int modifiers = s.readInt(); + String name = compressed ? s.readUtf8(s.readShort()) : s.readUTF(); + String signature = compressed ? s.readUtf8(s.readShort()) : s.readUTF(); + ResolvedMemberImpl m = new ResolvedMemberImpl(mk, declaringType, modifiers, name, signature); m.checkedExceptions = UnresolvedType.readArray(s); m.start = s.readInt(); @@ -486,7 +518,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno } } - int tvcount = s.readInt(); + int tvcount = s.isAtLeast169() ? s.readByte() : s.readInt(); if (tvcount != 0) { m.typeVariables = new TypeVariable[tvcount]; for (int i = 0; i < tvcount; i++) { @@ -495,14 +527,26 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno } } if (s.getMajorVersion() >= AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150M4) { - boolean hasAGenericSignature = s.readBoolean(); + int pcount = -1; + boolean hasAGenericSignature = false; + if (s.isAtLeast169()) { + pcount = s.readByte(); + hasAGenericSignature = (pcount >= 0 && pcount < 255); + } else { + hasAGenericSignature = s.readBoolean(); + } if (hasAGenericSignature) { - int ps = s.readInt(); + int ps = (s.isAtLeast169() ? pcount : s.readInt()); UnresolvedType[] params = new UnresolvedType[ps]; for (int i = 0; i < params.length; i++) { - params[i] = TypeFactory.createTypeFromSignature(s.readUTF()); + if (compressed) { + params[i] = TypeFactory.createTypeFromSignature(s.readSignature()); + } else { + params[i] = TypeFactory.createTypeFromSignature(s.readUTF()); + } } - UnresolvedType rt = TypeFactory.createTypeFromSignature(s.readUTF()); + UnresolvedType rt = compressed ? TypeFactory.createTypeFromSignature(s.readSignature()) : TypeFactory + .createTypeFromSignature(s.readUTF()); m.parameterTypes = params; m.returnType = rt; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedTypeMunger.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedTypeMunger.java index 404d8790f..10915ea58 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedTypeMunger.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedTypeMunger.java @@ -167,7 +167,12 @@ public abstract class ResolvedTypeMunger { protected static Set<ResolvedMember> readSuperMethodsCalled(VersionedDataInputStream s) throws IOException { Set<ResolvedMember> ret = new HashSet<ResolvedMember>(); - int n = s.readInt(); + int n = -1; + if (s.isAtLeast169()) { + n = s.readByte(); + } else { + n = s.readInt(); + } if (n < 0) { throw new BCException("Problem deserializing type munger"); } @@ -177,21 +182,18 @@ public abstract class ResolvedTypeMunger { return ret; } - protected void writeSuperMethodsCalled(CompressingDataOutputStream s) throws IOException { - + protected final void writeSuperMethodsCalled(CompressingDataOutputStream s) throws IOException { if (superMethodsCalled == null || superMethodsCalled.size() == 0) { - s.writeInt(0); + s.writeByte(0); return; } - List<ResolvedMember> ret = new ArrayList<ResolvedMember>(superMethodsCalled); Collections.sort(ret); int n = ret.size(); - s.writeInt(n); + s.writeByte(n); for (ResolvedMember m : ret) { m.write(s); } - } protected static ISourceLocation readSourceLocation(VersionedDataInputStream s) throws IOException { @@ -204,15 +206,29 @@ public abstract class ResolvedTypeMunger { try { // This logic copes with the location missing from the attribute - an EOFException will // occur on the next line and we ignore it. - ois = new ObjectInputStream(s); - Boolean validLocation = (Boolean) ois.readObject(); - if (validLocation.booleanValue()) { - File f = (File) ois.readObject(); - Integer ii = (Integer) ois.readObject(); - Integer offset = (Integer) ois.readObject(); - ret = new SourceLocation(f, ii.intValue()); - ret.setOffset(offset.intValue()); + byte b = 0; + // if we aren't on 1.6.9 or we are on 1.6.9 but not compressed, then read as object stream + if (!s.isAtLeast169() || (b = s.readByte()) == 0) { + ois = new ObjectInputStream(s); + boolean validLocation = (Boolean) ois.readObject(); + if (validLocation) { + File f = (File) ois.readObject(); + Integer ii = (Integer) ois.readObject(); + Integer offset = (Integer) ois.readObject(); + ret = new SourceLocation(f, ii.intValue()); + ret.setOffset(offset.intValue()); + } + } else { + boolean validLocation = b == 2; + if (validLocation) { + String path = s.readUtf8(s.readShort()); + File f = new File(path); + ret = new SourceLocation(f, s.readInt()); + int offset = s.readInt(); + ret.setOffset(offset); + } } + } catch (EOFException eof) { return null; // This exception occurs if processing an 'old style' file where the // type munger attributes don't include the source location. @@ -230,17 +246,26 @@ public abstract class ResolvedTypeMunger { return ret; } - protected void writeSourceLocation(DataOutputStream s) throws IOException { - ObjectOutputStream oos = new ObjectOutputStream(s); - // oos.writeObject(location); - oos.writeObject(new Boolean(location != null)); - if (location != null) { - oos.writeObject(location.getSourceFile()); - oos.writeObject(new Integer(location.getLine())); - oos.writeObject(new Integer(location.getOffset())); + protected final void writeSourceLocation(CompressingDataOutputStream s) throws IOException { + if (s.canCompress()) { + s.writeByte(1 + (location == null ? 0 : 1)); // 1==compressed no location 2==compressed with location + if (location != null) { + s.writeCompressedPath(location.getSourceFile().getPath()); + s.writeInt(location.getLine()); + s.writeInt(location.getOffset()); + } + } else { + s.writeByte(0); + ObjectOutputStream oos = new ObjectOutputStream(s); + oos.writeObject(new Boolean(location != null)); + if (location != null) { + oos.writeObject(location.getSourceFile()); + oos.writeObject(new Integer(location.getLine())); + oos.writeObject(new Integer(location.getOffset())); + } + oos.flush(); + oos.close(); } - oos.flush(); - oos.close(); } public abstract void write(CompressingDataOutputStream s) throws IOException; @@ -346,7 +371,12 @@ public abstract class ResolvedTypeMunger { protected static List<String> readInTypeAliases(VersionedDataInputStream s) throws IOException { if (s.getMajorVersion() >= AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) { - int count = s.readInt(); + int count = -1; + if (s.isAtLeast169()) { + count = s.readByte(); + } else { + count = s.readInt(); + } if (count != 0) { List<String> aliases = new ArrayList<String>(); for (int i = 0; i < count; i++) { @@ -358,12 +388,12 @@ public abstract class ResolvedTypeMunger { return null; } - protected void writeOutTypeAliases(DataOutputStream s) throws IOException { + protected final void writeOutTypeAliases(DataOutputStream s) throws IOException { // Write any type variable aliases if (typeVariableAliases == null || typeVariableAliases.size() == 0) { - s.writeInt(0); + s.writeByte(0); } else { - s.writeInt(typeVariableAliases.size()); + s.writeByte(typeVariableAliases.size()); for (String element : typeVariableAliases) { s.writeUTF(element); } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/VersionedDataInputStream.java b/org.aspectj.matcher/src/org/aspectj/weaver/VersionedDataInputStream.java index 8414c06a1..62a643919 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/VersionedDataInputStream.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/VersionedDataInputStream.java @@ -30,10 +30,6 @@ public class VersionedDataInputStream extends DataInputStream { private ConstantPoolReader constantPoolReader; - public VersionedDataInputStream(InputStream is) { - super(is); - } - public VersionedDataInputStream(InputStream is, ConstantPoolReader constantPoolReader) { super(is); this.constantPoolReader = constantPoolReader; @@ -80,4 +76,8 @@ public class VersionedDataInputStream extends DataInputStream { public String readSignature() throws IOException { return readUtf8(readShort()); } + + public UnresolvedType readSignatureAsUnresolvedType() throws IOException { + return UnresolvedType.forSignature(readUtf8(readShort())); + } }
\ No newline at end of file diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactTypePattern.java index 7bc560305..0e0997962 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ExactTypePattern.java @@ -246,7 +246,7 @@ public class ExactTypePattern extends TypePattern { public void write(CompressingDataOutputStream out) throws IOException { out.writeByte(TypePattern.EXACT); out.writeByte(EXACT_VERSION); - type.write(out); + out.writeCompressedSignature(type.getSignature()); out.writeBoolean(includeSubtypes); out.writeBoolean(isVarArgs); annotationPattern.write(out); @@ -267,7 +267,8 @@ public class ExactTypePattern extends TypePattern { if (version > EXACT_VERSION) { throw new BCException("ExactTypePattern was written by a more recent version of AspectJ"); } - TypePattern ret = new ExactTypePattern(UnresolvedType.read(s), s.readBoolean(), s.readBoolean()); + TypePattern ret = new ExactTypePattern(s.isAtLeast169() ? s.readSignatureAsUnresolvedType() : UnresolvedType.read(s), s + .readBoolean(), s.readBoolean()); ret.setAnnotationTypePattern(AnnotationTypePattern.read(s, context)); ret.setTypeParameters(TypePatternList.read(s, context)); ret.readLocation(context, s); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePatternList.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePatternList.java index 1db65b688..e388ba3b0 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePatternList.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePatternList.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import org.aspectj.bridge.ISourceLocation; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; @@ -492,17 +493,39 @@ public class TypePatternList extends PatternNode { arguments[i] = TypePattern.read(s, context); } TypePatternList ret = new TypePatternList(arguments); - ret.readLocation(context, s); + if (!s.isAtLeast169()) { + ret.readLocation(context, s); + } return ret; } @Override + public int getEnd() { + throw new IllegalStateException(); + } + + @Override + public ISourceContext getSourceContext() { + throw new IllegalStateException(); + } + + @Override + public ISourceLocation getSourceLocation() { + throw new IllegalStateException(); + } + + @Override + public int getStart() { + throw new IllegalStateException(); + } + + @Override public void write(CompressingDataOutputStream s) throws IOException { s.writeShort(typePatterns.length); for (int i = 0; i < typePatterns.length; i++) { typePatterns[i].write(s); } - writeLocation(s); + // writeLocation(s); } public TypePattern[] getTypePatterns() { |