/** * Just writes the contents */ public byte[] getBytes(ConstantPoolWriter compressor) { try { ByteArrayOutputStream b0 = new ByteArrayOutputStream(); CompressingDataOutputStream s0 = new CompressingDataOutputStream(b0, compressor); write(s0); s0.close(); return b0.toByteArray(); } catch (IOException e) { // shouldn't happen with ByteArrayOutputStreams throw new RuntimeException("sanity check"); } }
@Override public void write(CompressingDataOutputStream s) throws IOException { 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]; } }
/** * @param path a file system path 'c:\a\b\c.txt' or '/a/b/c.txt' */ public void writeCompressedPath(String path) throws IOException { writeShort(compressFilepath(path)); }
/** * @param name a simple name (for example a method or field name) */ public void writeCompressedName(String name) throws IOException { writeShort(compressName(name)); }
/** * @param signature of the form 'La/b/c/d;' */ public void writeCompressedSignature(String signature) throws IOException { writeShort(compressSignature(signature)); }
public void write(CompressingDataOutputStream s) throws IOException { getKind().write(s); s.writeBoolean(s.canCompress()); // boolean indicates if parts of this are compressed references if (s.canCompress()) { s.writeCompressedSignature(getDeclaringType().getSignature()); } else { getDeclaringType().write(s); s.writeInt(modifiers); if (s.canCompress()) { s.writeCompressedName(getName()); s.writeCompressedSignature(getSignature()); } else { s.writeUTF(getName()); s.writeUTF(getSignature()); s.writeInt(getStart()); s.writeInt(getEnd()); s.writeBoolean(isVarargsMethod()); s.writeByte(0); } else { s.writeByte(typeVariables.length); for (int i = 0; i < typeVariables.length; i++) { typeVariables[i].write(s); s.writeByte(0xff); } else {
s.write(key); // put key in so we can replace it with the diff later weaverStateInfoKind |= REWEAVABLE_DIFF_BIT; s.writeByte(weaverStateInfoKind); s.writeBoolean(s.canCompress()); s.writeShort(n); for (Entry e : typeMungers) { if (s.canCompress()) { s.writeCompressedSignature(e.aspectType.getSignature()); } else { e.aspectType.write(s); writeAnyReweavableData(this, s, s.canCompress()); } finally { s.compressionEnabled = true;
private static void writeAnyReweavableData(WeaverStateInfo wsi, CompressingDataOutputStream s, boolean compress) throws IOException { if (wsi.isReweavable()) { // Write out list of aspects that must exist next time we try and weave this class s.writeShort(wsi.aspectsAffectingType.size()); for (String type : wsi.aspectsAffectingType) { if (compress) { s.writeCompressedSignature(type); } else { s.writeUTF(type); } } byte[] data = wsi.unwovenClassFile; // if we're not in diffMode, write the unwovenClassFile now, // otherwise we'll insert it as a diff later if (!wsi.reweavableDiffMode) { s.writeInt(data.length); s.write(wsi.unwovenClassFile); } } }
@Override public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.WILD); s.writeByte(VERSION); typePattern.write(s); writeLocation(s); s.writeBoolean(isForParameterAnnotationMatch()); // PVAL if (annotationValues == null) { s.writeInt(0); } else { s.writeInt(annotationValues.size()); Set<String> key = annotationValues.keySet(); for (Iterator<String> keys = key.iterator(); keys.hasNext();) { String k = keys.next(); s.writeUTF(k); s.writeUTF(annotationValues.get(k)); } } }
@Override public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(ELLIPSIS_KEY); }
@Override public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Pointcut.IF); s.writeBoolean(testMethod != null); // do we have a test method? if (testMethod != null) { testMethod.write(s); } s.writeByte(extraParameterFlags); writeLocation(s); }
public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.TYPE_ERROR_OR_WARNING); s.writeBoolean(isError); typePattern.write(s); s.writeUTF(message); writeLocation(s); }
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(); } }
@Override public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(TypePattern.WILD); s.writeByte(VERSION); s.writeShort(namePatterns.length); for (int i = 0; i < namePatterns.length; i++) { namePatterns[i].write(s); s.writeBoolean(includeSubtypes); s.writeInt(dim); s.writeBoolean(isVarArgs); annotationPattern.write(s); s.writeBoolean(isGeneric); s.writeBoolean(upperBound != null); if (upperBound != null) { upperBound.write(s); s.writeBoolean(lowerBound != null); if (lowerBound != null) { lowerBound.write(s); s.writeInt(additionalInterfaceBounds == null ? 0 : additionalInterfaceBounds.length); if (additionalInterfaceBounds != null) { for (int i = 0; i < additionalInterfaceBounds.length; i++) {
public void write(CompressingDataOutputStream out) throws IOException { out.writeByte(TypePattern.BINDING); type.write(out); out.writeShort((short) formalIndex); out.writeBoolean(isVarArgs); writeLocation(out); }
@Override public void write(CompressingDataOutputStream out) throws IOException { out.writeByte(TypePattern.EXACT); out.writeByte(EXACT_VERSION); out.writeCompressedSignature(type.getSignature()); out.writeBoolean(includeSubtypes); out.writeBoolean(isVarArgs); annotationPattern.write(out); typeParameters.write(out); writeLocation(out); }
@Override public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(AnnotationTypePattern.BINDINGFIELD2); formalType.write(s); // the type of the field within the annotation s.writeShort((short) formalIndex); annotationType.write(s); // the annotation type s.writeUTF(formalName); writeLocation(s); }
@Override public void write(CompressingDataOutputStream s) throws IOException { s.writeByte(Declare.ANNOTATION); if (kind.id == AT_FIELD.id && isRemover) { s.writeInt(AT_REMOVE_FROM_FIELD.id); } else { s.writeInt(kind.id); } int max = 0; s.writeByte(max = annotationStrings.size()); for (int i = 0; i < max; i++) { s.writeUTF(annotationStrings.get(i)); } s.writeByte(max = annotationMethods.size()); for (int i = 0; i < max; i++) { s.writeUTF(annotationMethods.get(i)); } if (typePattern != null) { typePattern.write(s); } if (signaturePattern != null) { AbstractSignaturePattern.writeCompoundSignaturePattern(s, signaturePattern); } writeLocation(s); }
@Override public void write(CompressingDataOutputStream s) throws IOException { kind.write(s); pointcut.write(s); s.writeByte(extraParameterFlags); s.writeInt(start); s.writeInt(end); if (kind == AdviceKind.Around) { s.writeBoolean(proceedInInners); ResolvedMemberImpl.writeArray(proceedCallSignatures, s); FileUtil.writeBooleanArray(formalsUnchangedToProceed, s); UnresolvedType.writeArray(declaredExceptions, s); } }