Top Description Inners Fields Constructors Methods
org.aspectj.weaver

public Class WeaverStateInfo

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .DataInputStream, .DataOutputStream, .IOException, java.util.ArrayList, .Collection, .Collections, .HashSet, .List, .Set, java.util.zip.ZipEntry, .ZipInputStream, org.aspectj.bridge.IMessage, org.aspectj.weaver.AjAttribute.WeaverVersionInfo

WeaverStateInfo represents how a type was processed. It is used by the weaver to determine how a type was previously treated and whether reweaving is allowed. The format in the data stream is: Byte: Kind. UNTOUCHED|WOVEN|EXTENDED - If extended it can have two extra bits set 'REWEAVABLE' and 'REWEAVABLE_COMPRESSION_BIT' Short: typeMungerCount - how many type mungers have affected this type <UnresolvedType & ResolvedTypeMunger>: The type mungers themselves If we are reweavable then we also have: Short: Number of aspects that touched this type in some way when it was previously woven <String> The fully qualified name of each type Int: Length of class file data (i.e. the unwovenclassfile) Byte[]: The class file data, compressed if REWEAVABLE_COMPRESSION_BIT set.
Author
Andy Clement

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private Set<String>
pack-priv int
private static final int
private static byte[]
private static final byte[]
private boolean
private boolean
private static final byte
private static final byte
private static final byte
private boolean
private static boolean
private static boolean
private boolean
private static boolean
private List<WeaverStateInfo.Entry>
private static final int
private byte[]
private boolean
private static final int

Constructor Summary

AccessConstructor and Description
private
public
WeaverStateInfo(boolean reweavable)

private
WeaverStateInfo(List<WeaverStateInfo.Entry> typeMungers, boolean oldStyle, boolean reweavableMode, boolean reweavableCompressedMode, boolean reweavableDiffMode)

Method Summary

Modifier and TypeMethod and Description
public void
addAspectAffectingType(String aspectSignature)

public void
public void
pack-priv byte[]
applyDiff(byte[] wovenClassFile, byte[] diff)

private void
private static final byte[]
deleteInArray(byte[] a, int start, int end)

private static final boolean
endOfKeyHere(byte[] lookIn, int i)

private static final int
findEndOfKey(byte[] wovenClassFile)

pack-priv byte[]
generateDiff(byte[] wovenClassFile, byte[] unWovenClassFile)

public Set<String>
public List<ConcreteTypeMunger>
public byte[]
public byte[]
getUnwovenClassFileData(byte[] wovenClassFile)

private static final byte[]
insertArray(byte[] toInsert, byte[] original, int offset)

public boolean

Returns:

true if the supplied aspect is already in the list of those affecting this type
isAspectAlreadyApplied
(ResolvedType someAspect)

public boolean
public boolean
public void
markOverweavingInUse()

If the weaver is ever invoked in over weaving mode, we should not include the key when writing out, it won't be replaced later.

public static final WeaverStateInfo
read(VersionedDataInputStream s, ISourceContext context)

See comments on write()

private static void
private static final int
readInt(byte[] a, int offset)

public byte[]
replaceKeyWithDiff(byte[] wovenClassFile)

Here is the cleverness for reweavable diff mode.

private byte[]
serializeInt(int i)

public void
setReweavable(boolean rw)

public static void
setReweavableModeDefaults(boolean mode, boolean compress, boolean diff)

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
write(CompressingDataOutputStream s)

Serialize the WeaverStateInfo.

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

aspectsAffectingTypeback to summary
private Set<String> aspectsAffectingType
compressionEnabledback to summary
pack-priv int compressionEnabled
EXTENDEDback to summary
private static final int EXTENDED
keyback to summary
private static byte[] key
NO_BYTESback to summary
private static final byte[] NO_BYTES
oldStyleback to summary
private boolean oldStyle
reweavableback to summary
private boolean reweavable
REWEAVABLE_BITback to summary
private static final byte REWEAVABLE_BIT
REWEAVABLE_COMPRESSION_BITback to summary
private static final byte REWEAVABLE_COMPRESSION_BIT
REWEAVABLE_DIFF_BITback to summary
private static final byte REWEAVABLE_DIFF_BIT
reweavableCompressedModeback to summary
private boolean reweavableCompressedMode
reweavableCompressedModeDefaultback to summary
private static boolean reweavableCompressedModeDefault
reweavableDefaultback to summary
private static boolean reweavableDefault
reweavableDiffModeback to summary
private boolean reweavableDiffMode
reweavableDiffModeDefaultback to summary
private static boolean reweavableDiffModeDefault
typeMungersback to summary
private List<WeaverStateInfo.Entry> typeMungers
UNTOUCHEDback to summary
private static final int UNTOUCHED
unwovenClassFileback to summary
private byte[] unwovenClassFile
unwovenClassFileIsADiffback to summary
private boolean unwovenClassFileIsADiff
WOVENback to summary
private static final int WOVEN

Constructor Detail

WeaverStateInfoback to summary
private WeaverStateInfo()
WeaverStateInfoback to summary
public WeaverStateInfo(boolean reweavable)
WeaverStateInfoback to summary
private WeaverStateInfo(List<WeaverStateInfo.Entry> typeMungers, boolean oldStyle, boolean reweavableMode, boolean reweavableCompressedMode, boolean reweavableDiffMode)

Method Detail

addAspectAffectingTypeback to summary
public void addAspectAffectingType(String aspectSignature)
addAspectsAffectingTypeback to summary
public void addAspectsAffectingType(Collection<String> aspects)
addConcreteMungerback to summary
public void addConcreteMunger(ConcreteTypeMunger munger)
applyDiffback to summary
pack-priv byte[] applyDiff(byte[] wovenClassFile, byte[] diff)
checkCompressionEnabledback to summary
private void checkCompressionEnabled()
deleteInArrayback to summary
private static final byte[] deleteInArray(byte[] a, int start, int end)
endOfKeyHereback to summary
private static final boolean endOfKeyHere(byte[] lookIn, int i)
findEndOfKeyback to summary
private static final int findEndOfKey(byte[] wovenClassFile)
generateDiffback to summary
pack-priv byte[] generateDiff(byte[] wovenClassFile, byte[] unWovenClassFile)
getAspectsAffectingTypeback to summary
public Set<String> getAspectsAffectingType()
getTypeMungersback to summary
public List<ConcreteTypeMunger> getTypeMungers(ResolvedType onType)
getUnwovenClassFileDataback to summary
public byte[] getUnwovenClassFileData()
getUnwovenClassFileDataback to summary
public byte[] getUnwovenClassFileData(byte[] wovenClassFile)
insertArrayback to summary
private static final byte[] insertArray(byte[] toInsert, byte[] original, int offset)
isAspectAlreadyAppliedback to summary
public boolean isAspectAlreadyApplied(ResolvedType someAspect)
Returns:boolean

true if the supplied aspect is already in the list of those affecting this type

isOldStyleback to summary
public boolean isOldStyle()
isReweavableback to summary
public boolean isReweavable()
markOverweavingInUseback to summary
public void markOverweavingInUse()

If the weaver is ever invoked in over weaving mode, we should not include the key when writing out, it won't be replaced later. If we turn off the reweaving flag that unfortunately removes the 'what aspects have been woven into this type' list which we want to keep as it helps overweaving avoid weaving an aspect in twice.

readback to summary
public static final WeaverStateInfo read(VersionedDataInputStream s, ISourceContext context) throws IOException

See comments on write()

readAnyReweavableDataback to summary
private static void readAnyReweavableData(WeaverStateInfo wsi, VersionedDataInputStream s, boolean compressed) throws IOException
readIntback to summary
private static final int readInt(byte[] a, int offset)
replaceKeyWithDiffback to summary
public byte[] replaceKeyWithDiff(byte[] wovenClassFile)

Here is the cleverness for reweavable diff mode. The class file on disk contains, inside the weaverstateinfo attribute, a diff that can be applied to 'itself' to recover the original class - which can then be rewoven.

serializeIntback to summary
private byte[] serializeInt(int i)
setReweavableback to summary
public void setReweavable(boolean rw)
setReweavableModeDefaultsback to summary
public static void setReweavableModeDefaults(boolean mode, boolean compress, boolean diff)
setUnwovenClassFileDataback to summary
public void setUnwovenClassFileData(byte[] data)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

writeback to summary
public void write(CompressingDataOutputStream s) throws IOException

Serialize the WeaverStateInfo. Various bits are set within the 'kind' flag to indicate the structure of the attribute. In reweavable diff mode a 'marker' is inserted at the start of the attribute to indicate where the final calculated diff should be inserted. When the key is replaced with the diff, the 'kind' byte moves to the front of the attribute - thats why in the read logic you'll see it expecting the kind as the first byte.

writeAnyReweavableDataback to summary
private static void writeAnyReweavableData(WeaverStateInfo wsi, CompressingDataOutputStream s, boolean compress) throws IOException
org.aspectj.weaver back to summary

private Class WeaverStateInfo.Entry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public UnresolvedType
public ResolvedTypeMunger

Constructor Summary

AccessConstructor and Description
public
Entry(UnresolvedType aspectType, ResolvedTypeMunger typeMunger)

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

aspectTypeback to summary
public UnresolvedType aspectType
typeMungerback to summary
public ResolvedTypeMunger typeMunger

Constructor Detail

Entryback to summary
public Entry(UnresolvedType aspectType, ResolvedTypeMunger typeMunger)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.