package org.aspectj.weaver;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.weaver.patterns.Declare;
import org.aspectj.weaver.patterns.DeclareAnnotation;
import org.aspectj.weaver.patterns.DeclareParents;
import org.aspectj.weaver.patterns.DeclareSoft;
import org.aspectj.weaver.patterns.DeclareTypeErrorOrWarning;
import org.aspectj.weaver.patterns.IVerificationRequired;
public class {
private transient World ;
private final Map<ResolvedType, CrosscuttingMembers> = new HashMap<ResolvedType, CrosscuttingMembers>();
private transient List<IVerificationRequired> = null;
private List<ShadowMunger> shadowMungers = null;
private List<ConcreteTypeMunger> = null;
private List<ConcreteTypeMunger> = null;
private List<DeclareSoft> = null;
private List<DeclareParents> = null;
private List<DeclareAnnotation> = null;
private List<DeclareAnnotation> = null;
private List<DeclareAnnotation> = null;
private List<DeclareTypeErrorOrWarning> = null;
private List<Declare> = null;
private boolean = false;
public (World world) {
this.world = world;
}
public boolean (ResolvedType aspectType) {
return addOrReplaceAspect(aspectType, true);
}
private boolean (ResolvedType aspectType) {
ResolvedType parent = aspectType.getSuperclass();
boolean excludeDueToParent = false;
while (parent != null) {
if (parent.isAspect() && parent.isAbstract() && world.hasUnsatisfiedDependency(parent)) {
if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
world.getMessageHandler().handleMessage(
MessageUtil.info("deactivating aspect '" + aspectType.getName() + "' as the parent aspect '"+parent.getName()+
"' has unsatisfied dependencies"));
}
excludeDueToParent = true;
}
parent = parent.getSuperclass();
}
return excludeDueToParent;
}
public boolean (ResolvedType aspectType, boolean inWeavingPhase) {
if (!world.isAspectIncluded(aspectType)) {
return false;
}
if (world.hasUnsatisfiedDependency(aspectType)) {
return false;
}
if (excludeDueToParentAspectHavingUnresolvedDependency(aspectType)) {
return false;
}
boolean change = false;
CrosscuttingMembers xcut = members.get(aspectType);
if (xcut == null) {
members.put(aspectType, aspectType.collectCrosscuttingMembers(inWeavingPhase));
clearCaches();
change = true;
} else {
if (xcut.replaceWith(aspectType.collectCrosscuttingMembers(inWeavingPhase), inWeavingPhase)) {
clearCaches();
change = true;
} else {
if (inWeavingPhase) {
shadowMungers = null;
}
change = false;
}
}
if (aspectType.isAbstract()) {
boolean ancestorChange = addOrReplaceDescendantsOf(aspectType, inWeavingPhase);
change = change || ancestorChange;
}
changedSinceLastReset = changedSinceLastReset || change;
return change;
}
private boolean (ResolvedType aspectType, boolean inWeavePhase) {
Set<ResolvedType> knownAspects = members.keySet();
Set<ResolvedType> toBeReplaced = new HashSet<ResolvedType>();
for (Iterator<ResolvedType> it = knownAspects.iterator(); it.hasNext();) {
ResolvedType candidateDescendant = it.next();
if ((candidateDescendant != aspectType) && (aspectType.isAssignableFrom(candidateDescendant, true))) {
toBeReplaced.add(candidateDescendant);
}
}
boolean change = false;
for (Iterator<ResolvedType> it = toBeReplaced.iterator(); it.hasNext();) {
ResolvedType next = it.next();
boolean thisChange = addOrReplaceAspect(next, inWeavePhase);
change = change || thisChange;
}
return change;
}
public void (ResolvedType aspectType) {
if (!members.containsKey(aspectType)) {
return;
}
CrosscuttingMembers xcut = members.get(aspectType);
xcut.addDeclares(aspectType.collectDeclares(true));
}
public boolean (UnresolvedType aspectType) {
boolean isAspect = members.remove(aspectType) != null;
clearCaches();
return isAspect;
}
public boolean (UnresolvedType aspectType) {
return members.containsKey(aspectType);
}
public void (ResolvedType aspectType) {
members.put(aspectType, aspectType.crosscuttingMembers);
clearCaches();
}
private void () {
shadowMungers = null;
typeMungers = null;
lateTypeMungers = null;
declareSofts = null;
declareParents = null;
declareAnnotationOnFields = null;
declareAnnotationOnMethods = null;
declareAnnotationOnTypes = null;
declareDominates = null;
}
public List<ShadowMunger> getShadowMungers() {
if (shadowMungers == null) {
List<ShadowMunger> ret = new ArrayList<ShadowMunger>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getShadowMungers());
}
shadowMungers = ret;
}
return shadowMungers;
}
public List<ConcreteTypeMunger> () {
if (typeMungers == null) {
List<ConcreteTypeMunger> ret = new ArrayList<ConcreteTypeMunger>();
for (CrosscuttingMembers xmembers : members.values()) {
for (ConcreteTypeMunger mungerToAdd : xmembers.getTypeMungers()) {
ResolvedTypeMunger resolvedMungerToAdd = mungerToAdd.getMunger();
if (isNewStylePrivilegedAccessMunger(resolvedMungerToAdd)) {
String newFieldName = resolvedMungerToAdd.getSignature().getName();
boolean alreadyExists = false;
for (ConcreteTypeMunger existingMunger : ret) {
ResolvedTypeMunger existing = existingMunger.getMunger();
if (isNewStylePrivilegedAccessMunger(existing)) {
String existingFieldName = existing.getSignature().getName();
if (existingFieldName.equals(newFieldName)
&& existing.getSignature().getDeclaringType().equals(
resolvedMungerToAdd.getSignature().getDeclaringType())) {
alreadyExists = true;
break;
}
}
}
if (!alreadyExists) {
ret.add(mungerToAdd);
}
} else {
ret.add(mungerToAdd);
}
}
}
typeMungers = ret;
}
return typeMungers;
}
public List<ConcreteTypeMunger> (ResolvedTypeMunger.Kind kind) {
List<ConcreteTypeMunger> collected = null;
for (ConcreteTypeMunger typeMunger : typeMungers) {
if (typeMunger.getMunger() != null && typeMunger.getMunger().getKind() == kind) {
if (collected == null) {
collected = new ArrayList<ConcreteTypeMunger>();
}
collected.add(typeMunger);
}
}
if (collected == null) {
return Collections.emptyList();
} else {
return collected;
}
}
private boolean (ResolvedTypeMunger typeMunger) {
boolean b = (typeMunger != null && typeMunger.getKind() == ResolvedTypeMunger.PrivilegedAccess && typeMunger.getSignature()
.getKind() == Member.FIELD);
if (!b) {
return b;
}
PrivilegedAccessMunger privAccessMunger = (PrivilegedAccessMunger) typeMunger;
return privAccessMunger.shortSyntax;
}
public List<ConcreteTypeMunger> () {
if (lateTypeMungers == null) {
List<ConcreteTypeMunger> ret = new ArrayList<ConcreteTypeMunger>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getLateTypeMungers());
}
lateTypeMungers = ret;
}
return lateTypeMungers;
}
public List<DeclareSoft> () {
if (declareSofts == null) {
Set<DeclareSoft> ret = new HashSet<DeclareSoft>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getDeclareSofts());
}
declareSofts = new ArrayList<DeclareSoft>();
declareSofts.addAll(ret);
}
return declareSofts;
}
public List<DeclareParents> () {
if (declareParents == null) {
Set<DeclareParents> ret = new HashSet<DeclareParents>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getDeclareParents());
}
declareParents = new ArrayList<DeclareParents>();
declareParents.addAll(ret);
}
return declareParents;
}
public List<DeclareAnnotation> () {
if (declareAnnotationOnTypes == null) {
Set<DeclareAnnotation> ret = new LinkedHashSet<DeclareAnnotation>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getDeclareAnnotationOnTypes());
}
declareAnnotationOnTypes = new ArrayList<DeclareAnnotation>();
declareAnnotationOnTypes.addAll(ret);
}
return declareAnnotationOnTypes;
}
public List<DeclareAnnotation> () {
if (declareAnnotationOnFields == null) {
Set<DeclareAnnotation> ret = new LinkedHashSet<DeclareAnnotation>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getDeclareAnnotationOnFields());
}
declareAnnotationOnFields = new ArrayList<DeclareAnnotation>();
declareAnnotationOnFields.addAll(ret);
}
return declareAnnotationOnFields;
}
public List<DeclareAnnotation> () {
if (declareAnnotationOnMethods == null) {
Set<DeclareAnnotation> ret = new LinkedHashSet<DeclareAnnotation>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getDeclareAnnotationOnMethods());
}
declareAnnotationOnMethods = new ArrayList<DeclareAnnotation>();
declareAnnotationOnMethods.addAll(ret);
}
return declareAnnotationOnMethods;
}
public List<DeclareTypeErrorOrWarning> () {
if (declareTypeEows == null) {
Set<DeclareTypeErrorOrWarning> ret = new HashSet<DeclareTypeErrorOrWarning>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getDeclareTypeErrorOrWarning());
}
declareTypeEows = new ArrayList<DeclareTypeErrorOrWarning>();
declareTypeEows.addAll(ret);
}
return declareTypeEows;
}
public List<Declare> () {
if (declareDominates == null) {
List<Declare> ret = new ArrayList<Declare>();
for (Iterator<CrosscuttingMembers> i = members.values().iterator(); i.hasNext();) {
ret.addAll(i.next().getDeclareDominates());
}
declareDominates = ret;
}
return declareDominates;
}
public ResolvedType (DeclareParents p) {
Set<ResolvedType> keys = this.members.keySet();
for (Iterator<ResolvedType> iter = keys.iterator(); iter.hasNext();) {
ResolvedType element = iter.next();
for (Iterator i = members.get(element).getDeclareParents().iterator(); i.hasNext();) {
DeclareParents dp = (DeclareParents) i.next();
if (dp.equals(p)) {
return element;
}
}
}
return null;
}
public void () {
verificationList = null;
changedSinceLastReset = false;
}
public boolean () {
return changedSinceLastReset;
}
public void (IVerificationRequired verification) {
if (verificationList == null) {
verificationList = new ArrayList<IVerificationRequired>();
}
verificationList.add(verification);
}
public void () {
if (verificationList == null) {
return;
}
for (Iterator<IVerificationRequired> iter = verificationList.iterator(); iter.hasNext();) {
IVerificationRequired element = iter.next();
element.verify();
}
verificationList = null;
}
public int = 1;
public void (CompressingDataOutputStream stream) throws IOException {
stream.writeInt(shadowMungers.size());
for (Iterator iterator = shadowMungers.iterator(); iterator.hasNext();) {
ShadowMunger shadowMunger = (ShadowMunger) iterator.next();
shadowMunger.write(stream);
}
}
}