AjAttributeStruct struct = new AjAttributeStruct(type, context, msgHandler);
Attribute[] attributes = javaClass.getAttributes();
boolean hasAtAspectAnnotation = false;
boolean hasAtPrecedenceAnnotation = false;
WeaverVersionInfo wvinfo = null;
for (int i = 0; i < attributes.length; i++) {
Attribute attribute = attributes[i];
if (acceptAttribute(attribute)) {
RuntimeAnnos rvs = (RuntimeAnnos) attribute;
// we don't need to look for several attribute occurrences since
// it cannot happen as per JSR175
if (!isCodeStyleAspect && !javaClass.isInterface()) {
hasAtAspectAnnotation = handleAspectAnnotation(rvs, struct);
// TODO AV - if put outside the if isCodeStyleAspect then we
// would enable mix style
hasAtPrecedenceAnnotation = handlePrecedenceAnnotation(rvs, struct);
}
// there can only be one RuntimeVisible bytecode attribute
break;
}
}
for (int i = attributes.length - 1; i >= 0; i--) {
Attribute attribute = attributes[i];
if (attribute.getName().equals(WeaverVersionInfo.AttributeName)) {
try {
VersionedDataInputStream s = new VersionedDataInputStream(new ByteArrayInputStream(
((Unknown) attribute).getBytes()), null);
wvinfo = WeaverVersionInfo.read(s);
struct.ajAttributes.add(0, wvinfo);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
if (wvinfo == null) {
// If we are in here due to a resetState() call (presumably because of reweavable state processing), the
// original type delegate will have been set with a version but that version will be missing from
// the new set of attributes (looks like a bug where the version attribute was not included in the
// data compressed into the attribute). So rather than 'defaulting' to current, we should use one
// if it set on the delegate for the type.
ReferenceTypeDelegate delegate = type.getDelegate();
if (delegate instanceof BcelObjectType) {
wvinfo = ((BcelObjectType) delegate).getWeaverVersionAttribute();
if (wvinfo != null) {
if (wvinfo.getMajorVersion() != WeaverVersionInfo.WEAVER_VERSION_MAJOR_UNKNOWN) {
// use this one
struct.ajAttributes.add(0, wvinfo);
} else {
wvinfo = null;
}