* consideration, not ours. This object will NOT be cached in another
* local, but will always come from frame zero.
*
- * * non-expressionKind advice is execution advice
+ * * non-expressionKind advice is execution advice
* * may have a this.
* * target is same as this, and is exposed that way to advice
* (i.e., target will not be cached, will always come from frame zero)
depth++;
} else if (inst.opcode == Constants.NEW) {
depth--;
- if (depth == 0)
+ if (depth == 0) {
break;
+ }
} else if (inst.opcode == Constants.DUP_X2) {
// This code seen in the wild (by Brad):
// 40: new #12; //class java/lang/StringBuffer
private List<BcelAdvice> badAdvice = null;
public void addAdvicePreventingLazyTjp(BcelAdvice advice) {
- if (badAdvice == null)
+ if (badAdvice == null) {
badAdvice = new ArrayList<BcelAdvice>();
+ }
badAdvice.add(advice);
}
// this up, every ShadowRange would have three instructionHandle points, the start of
// the arg-setup code, the start of the running code, and the end of the running code.
if (getKind() == ConstructorCall) {
- if (!world.isJoinpointArrayConstructionEnabled() || !this.getSignature().getDeclaringType().isArray())
+ if (!world.isJoinpointArrayConstructionEnabled() || !this.getSignature().getDeclaringType().isArray()) {
deleteNewAndDup(); // no new/dup for new array construction
+ }
initializeArgVars();
} else if (getKind() == PreInitialization) { // pr74952
ShadowRange range = getRange();
for (Iterator<BcelAdvice> iter = badAdvice.iterator(); iter.hasNext();) {
BcelAdvice element = iter.next();
ISourceLocation sLoc = element.getSourceLocation();
- if (sLoc != null && sLoc.getLine() > 0)
+ if (sLoc != null && sLoc.getLine() > 0) {
valid++;
+ }
}
if (valid != 0) {
ISourceLocation[] badLocs = new ISourceLocation[valid];
for (Iterator<BcelAdvice> iter = badAdvice.iterator(); iter.hasNext();) {
BcelAdvice element = iter.next();
ISourceLocation sLoc = element.getSourceLocation();
- if (sLoc != null)
+ if (sLoc != null) {
badLocs[i++] = sLoc;
+ }
}
world.getLint().multipleAdviceStoppingLazyTjp
.signal(new String[] { this.toString() }, getSourceLocation(), badLocs);
// if the kind of join point for which we are a shadow represents
// a method or constructor execution, then the best source line is
// the one from the enclosingMethod declarationLineNumber if available.
- if (sourceline != -1)
+ if (sourceline != -1) {
return sourceline;
+ }
Kind kind = getKind();
if ((kind == MethodExecution) || (kind == ConstructorExecution) || (kind == AdviceExecution)
|| (kind == StaticInitialization) || (kind == PreInitialization) || (kind == Initialization)) {
}
}
sourceline = Utility.getSourceLine(range.getStart());
- if (sourceline < 0)
+ if (sourceline < 0) {
sourceline = 0;
+ }
return sourceline;
}
}
public static BcelShadow makeMethodExecution(BcelWorld world, LazyMethodGen enclosingMethod, boolean lazyInit) {
- if (!lazyInit)
+ if (!lazyInit) {
return makeMethodExecution(world, enclosingMethod);
+ }
BcelShadow s = new BcelShadow(world, MethodExecution, enclosingMethod.getMemberView(), enclosingMethod, null);
}
public void init() {
- if (range != null)
+ if (range != null) {
return;
+ }
final InstructionList body = enclosingMethod.getBody();
ShadowRange r = new ShadowRange(body);
initializeThisAnnotationVars(); // FIXME asc Why bother with this if we always return one?
// Even if we can't find one, we have to return one as we might have this annotation at runtime
Var v = thisAnnotationVars.get(forAnnotationType);
- if (v == null)
+ if (v == null) {
v = new TypeAnnotationAccessVar(forAnnotationType.resolve(world), (BcelVar) getThisVar());
+ }
return v;
}
initializeTargetAnnotationVars(); // FIXME asc why bother with this if we always return one?
Var v = targetAnnotationVars.get(forAnnotationType);
// Even if we can't find one, we have to return one as we might have this annotation at runtime
- if (v == null)
+ if (v == null) {
v = new TypeAnnotationAccessVar(forAnnotationType.resolve(world), (BcelVar) getTargetVar());
+ }
return v;
}
initializeArgAnnotationVars();
Var v = (Var) argAnnotationVars[i].get(forAnnotationType);
- if (v == null)
+ if (v == null) {
v = new TypeAnnotationAccessVar(forAnnotationType.resolve(world), (BcelVar) getArgVar(i));
+ }
return v;
}
}
void initializeThisJoinPoint() {
- if (thisJoinPointVar == null)
+ if (thisJoinPointVar == null) {
return;
+ }
if (isThisJoinPointLazy) {
isThisJoinPointLazy = checkLazyTjp();
appliedLazyTjpOptimization = true;
createThisJoinPoint(); // make sure any state needed is initialized, but throw the instructions out
- if (lazyTjpConsumers == 1)
+ if (lazyTjpConsumers == 1) {
return; // special case only one lazyTjpUser
+ }
InstructionFactory fact = getFactory();
InstructionList il = new InstructionList();
*/
private void initializeThisVar() {
- if (thisVar != null)
+ if (thisVar != null) {
return;
+ }
thisVar = new BcelVar(getThisType().resolve(world), 0);
thisVar.setPositionInAroundState(0);
}
public void initializeTargetVar() {
InstructionFactory fact = getFactory();
- if (targetVar != null)
+ if (targetVar != null) {
return;
+ }
if (getKind().isTargetSameAsThis()) {
- if (hasThis())
+ if (hasThis()) {
initializeThisVar();
+ }
targetVar = thisVar;
} else {
initializeArgVars(); // gotta pop off the args before we find the target
// A load instruction may tell us the real type of what the clone() call is on
if (searchPtr.getInstruction().isLoadInstruction()) {
LocalVariableTag lvt = LazyMethodGen.getLocalVariableTag(searchPtr, searchPtr.getInstruction().getIndex());
- if (lvt != null)
+ if (lvt != null) {
return UnresolvedType.forSignature(lvt.getType());
+ }
}
// A field access instruction may tell us the real type of what the clone() call is on
if (searchPtr.getInstruction() instanceof FieldInstruction) {
public void initializeForAroundClosure() {
initializeArgVars();
- if (hasTarget())
+ if (hasTarget()) {
initializeTargetVar();
- if (hasThis())
+ }
+ if (hasThis()) {
initializeThisVar();
- // System.out.println("initialized: " + this + " thisVar = " + thisVar);
+ // System.out.println("initialized: " + this + " thisVar = " + thisVar);
+ }
}
public void initializeThisAnnotationVars() {
- if (thisAnnotationVars != null)
+ if (thisAnnotationVars != null) {
return;
+ }
thisAnnotationVars = new HashMap<ResolvedType, TypeAnnotationAccessVar>();
// populate..
}
public void initializeTargetAnnotationVars() {
- if (targetAnnotationVars != null)
+ if (targetAnnotationVars != null) {
return;
+ }
if (getKind().isTargetSameAsThis()) {
- if (hasThis())
+ if (hasThis()) {
initializeThisAnnotationVars();
+ }
targetAnnotationVars = thisAnnotationVars;
} else {
targetAnnotationVars = new HashMap<ResolvedType, TypeAnnotationAccessVar>();
}
public void initializeArgAnnotationVars() {
- if (argAnnotationVars != null)
+ if (argAnnotationVars != null) {
return;
+ }
int numArgs = getArgCount();
argAnnotationVars = new Map[numArgs];
for (int i = 0; i < argAnnotationVars.length; i++) {
ResolvedMember decMethods[] = aspectType.getDeclaredMethods();
for (int i = 0; i < decMethods.length; i++) {
ResolvedMember member = decMethods[i];
- if (member.equals(ajcMethod))
+ if (member.equals(ajcMethod)) {
return member;
+ }
}
return null;
}
}
public void initializeWithinAnnotationVars() {
- if (withinAnnotationVars != null)
+ if (withinAnnotationVars != null) {
return;
+ }
withinAnnotationVars = new HashMap<ResolvedType, AnnotationAccessVar>();
ResolvedType[] annotations = getEnclosingType().resolve(world).getAnnotationTypes();
}
public void initializeWithinCodeAnnotationVars() {
- if (withincodeAnnotationVars != null)
+ if (withincodeAnnotationVars != null) {
return;
+ }
withincodeAnnotationVars = new HashMap<ResolvedType, AnnotationAccessVar>();
// For some shadow we are interested in annotations on the method containing that shadow.
// a good optimization would be not to generate anything here
// if the shadow is GUARANTEED empty (i.e., there's NOTHING, not even
// a shadow, inside me).
- if (getRange().getStart().getNext() == getRange().getEnd())
+ if (getRange().getStart().getNext() == getRange().getEnd()) {
return;
+ }
InstructionFactory fact = getFactory();
InstructionList handler = new InstructionList();
BcelVar exceptionVar = genTempVar(catchType);
// a good optimization would be not to generate anything here
// if the shadow is GUARANTEED empty (i.e., there's NOTHING, not even
// a shadow, inside me).
- if (getRange().getStart().getNext() == getRange().getEnd())
+ if (getRange().getStart().getNext() == getRange().getEnd()) {
return;
+ }
InstructionFactory fact = getFactory();
InstructionList handler = new InstructionList();
*/
public void weavePerTypeWithinAspectInitialization(final BcelAdvice munger, UnresolvedType t) {
- if (t.resolve(world).isInterface())
+ if (t.resolve(world).isInterface()) {
return; // Don't initialize statics in
+ }
final InstructionFactory fact = getFactory();
InstructionList entryInstructions = new InstructionList();
if (cflowStateVars.length == 0) {
// This should be getting managed by a counter - lets make sure.
- if (!cflowField.getType().getName().endsWith("CFlowCounter"))
+ if (!cflowField.getType().getName().endsWith("CFlowCounter")) {
throw new RuntimeException("Incorrectly attempting counter operation on stacked cflow");
+ }
entrySuccessInstructions.append(Utility.createGet(fact, cflowField));
// arrayVar.appendLoad(entrySuccessInstructions, fact);
entrySuccessInstructions.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "inc", Type.VOID,
// Member originalSig = mungerSig; // If mungerSig is on a parameterized type, originalSig is the member on the generic type
if (mungerSig instanceof ResolvedMember) {
ResolvedMember rm = (ResolvedMember) mungerSig;
- if (rm.hasBackingGenericMember())
+ if (rm.hasBackingGenericMember()) {
mungerSig = rm.getBackingGenericMember();
+ }
}
ResolvedType declaringAspectType = world.resolve(mungerSig.getDeclaringType(), true);
if (declaringAspectType.isMissing()) {
@Override
public Object visit(ThisOrTargetPointcut node, Object data) {
- if (node.isThis() && node.isBinding())
+ if (node.isThis() && node.isBinding()) {
usesThis = true;
+ }
return node;
}
@Override
public Object visit(AndPointcut node, Object data) {
- if (!usesThis)
+ if (!usesThis) {
node.getLeft().accept(this, data);
- if (!usesThis)
+ }
+ if (!usesThis) {
node.getRight().accept(this, data);
+ }
return node;
}
@Override
public Object visit(NotPointcut node, Object data) {
- if (!usesThis)
+ if (!usesThis) {
node.getNegatedPointcut().accept(this, data);
+ }
return node;
}
@Override
public Object visit(OrPointcut node, Object data) {
- if (!usesThis)
+ if (!usesThis) {
node.getLeft().accept(this, data);
- if (!usesThis)
+ }
+ if (!usesThis) {
node.getRight().accept(this, data);
+ }
return node;
}
}
@Override
public Object visit(ThisOrTargetPointcut node, Object data) {
- if (!node.isThis() && node.isBinding())
+ if (!node.isThis() && node.isBinding()) {
usesTarget = true;
+ }
return node;
}
@Override
public Object visit(AndPointcut node, Object data) {
- if (!usesTarget)
+ if (!usesTarget) {
node.getLeft().accept(this, data);
- if (!usesTarget)
+ }
+ if (!usesTarget) {
node.getRight().accept(this, data);
+ }
return node;
}
@Override
public Object visit(NotPointcut node, Object data) {
- if (!usesTarget)
+ if (!usesTarget) {
node.getNegatedPointcut().accept(this, data);
+ }
return node;
}
@Override
public Object visit(OrPointcut node, Object data) {
- if (!usesTarget)
+ if (!usesTarget) {
node.getLeft().accept(this, data);
- if (!usesTarget)
+ }
+ if (!usesTarget) {
node.getRight().accept(this, data);
+ }
return node;
}
}
// initialize the bit flags for this shadow
int bitflags = 0x000000;
- if (getKind().isTargetSameAsThis())
+ if (getKind().isTargetSameAsThis()) {
bitflags |= 0x010000;
- if (hasThis())
+ }
+ if (hasThis()) {
bitflags |= 0x001000;
- if (bindsThis(munger))
+ }
+ if (bindsThis(munger)) {
bitflags |= 0x000100;
- if (hasTarget())
+ }
+ if (hasTarget()) {
bitflags |= 0x000010;
- if (bindsTarget(munger))
+ }
+ if (bindsTarget(munger)) {
bitflags |= 0x000001;
+ }
// ATAJ for @AJ aspect we need to link the closure with the joinpoint instance
if (munger.getConcreteAspect() != null && munger.getConcreteAspect().isAnnotationStyleAspect()
IntMap ret = new IntMap();
for (int i = 0, len = adviceArgs.length; i < len; i++) {
BcelVar v = adviceArgs[i];
- if (v == null)
+ if (v == null) {
continue; // XXX we don't know why this is required
+ }
int pos = v.getPositionInAroundState();
if (pos >= 0) { // need this test to avoid args bound via cflow
ret.put(pos, i);
}
private boolean samePackage(String p1, String p2) {
- if (p1 == null)
+ if (p1 == null) {
return p2 == null;
- if (p2 == null)
+ }
+ if (p2 == null) {
return false;
+ }
return p1.equals(p2);
}