@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() {
this.constantPoolWriter = constantPoolWriter;
}
- public CompressingDataOutputStream(ByteArrayOutputStream baos) {
- super(baos);
- }
-
public CompressingDataOutputStream(FileOutputStream fos) {
super(fos);
}
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());
// 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);
}
}
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();
}
}
- 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++) {
}
}
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;
}
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");
}
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 {
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.
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;
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++) {
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);
}
private ConstantPoolReader constantPoolReader;
- public VersionedDataInputStream(InputStream is) {
- super(is);
- }
-
public VersionedDataInputStream(InputStream is, ConstantPoolReader constantPoolReader) {
super(is);
this.constantPoolReader = constantPoolReader;
public String readSignature() throws IOException {
return readUtf8(readShort());
}
+
+ public UnresolvedType readSignatureAsUnresolvedType() throws IOException {
+ return UnresolvedType.forSignature(readUtf8(readShort()));
+ }
}
\ No newline at end of file
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);
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);
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;
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() {