Browse Source

optimization

tags/V1_6_6
aclement 14 years ago
parent
commit
8c8dbe76aa

+ 5
- 4
weaver/src/org/aspectj/weaver/bcel/AnnotationAccessVar.java View File

@@ -92,7 +92,7 @@ public class AnnotationAccessVar extends BcelVar {
// annotations for fieldset/fieldget when an ITD is involved are stored against a METHOD
((kind == Shadow.FieldGet || kind == Shadow.FieldSet) && member.getKind() == Member.METHOD)) {

Type jlrMethod = BcelWorld.makeBcelType(UnresolvedType.forSignature("Ljava.lang.reflect.Method;"));
Type jlrMethod = BcelWorld.makeBcelType(UnresolvedType.forSignature("Ljava/lang/reflect/Method;"));
Type[] paramTypes = BcelWorld.makeBcelTypes(member.getParameterTypes());

il.append(fact.createConstant(BcelWorld.makeBcelType(containingType)));
@@ -116,7 +116,7 @@ public class AnnotationAccessVar extends BcelVar {
Constants.INVOKEVIRTUAL));
} else { // init/preinit/ctor-call/ctor-exec
buildArray(il, fact, jlClass, paramTypes, 1);
Type jlrCtor = BcelWorld.makeBcelType(UnresolvedType.forSignature("Ljava.lang.reflect.Constructor;"));
Type jlrCtor = BcelWorld.makeBcelType(UnresolvedType.JAVA_LANG_REFLECT_CONSTRUCTOR);
// OPTIMIZE cache result of getDeclaredConstructor and getAnnotation? Might be able to use it again if someone else
// needs the same annotations?
il.append(fact.createInvoke("java/lang/Class", "getDeclaredConstructor", jlrCtor, new Type[] { jlClassArray },
@@ -126,7 +126,7 @@ public class AnnotationAccessVar extends BcelVar {
new Type[] { jlClass }, Constants.INVOKEVIRTUAL));
}
} else if (kind == Shadow.FieldSet || kind == Shadow.FieldGet) {
Type jlrField = BcelWorld.makeBcelType(UnresolvedType.forSignature("Ljava.lang.reflect.Field;"));
Type jlrField = BcelWorld.makeBcelType(UnresolvedType.JAVA_LANG_REFLECT_FIELD);
il.append(fact.createConstant(BcelWorld.makeBcelType(containingType))); // Stick the target on the stack
il.append(fact.createConstant(member.getName())); // Stick what we are after on the stack
il.append(fact.createInvoke("java/lang/Class", "getDeclaredField", jlrField, new Type[] { jlString },
@@ -149,8 +149,9 @@ public class AnnotationAccessVar extends BcelVar {
private void buildArray(InstructionList il, InstructionFactory fact, Type arrayElementType, Type[] arrayEntries, int dim) {
il.append(fact.createConstant(Integer.valueOf(arrayEntries == null ? 0 : arrayEntries.length)));
il.append(fact.createNewArray(arrayElementType, (short) dim));
if (arrayEntries == null)
if (arrayEntries == null) {
return;
}
for (int i = 0; i < arrayEntries.length; i++) {
il.append(InstructionFactory.createDup(1));
il.append(fact.createConstant(Integer.valueOf(i)));

+ 3
- 4
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java View File

@@ -325,7 +325,7 @@ public class BcelShadow extends Shadow {
// Now the exception range starts just after our new instruction.
// The next bit of code changes the exception range to point at
// the store instruction
for (InstructionTargeter t: start.getTargetersCopy()) {
for (InstructionTargeter t : start.getTargetersCopy()) {
if (t instanceof ExceptionRange) {
ExceptionRange er = (ExceptionRange) t;
er.updateTarget(start, insertedInstruction, body);
@@ -407,8 +407,8 @@ public class BcelShadow extends Shadow {
}
}
}
}
}
}

// ---- getters

@@ -454,9 +454,8 @@ public class BcelShadow extends Shadow {
return sourceline;
}

// overrides
@Override
public UnresolvedType getEnclosingType() {
public ResolvedType getEnclosingType() {
return getEnclosingClass().getType();
}


Loading…
Cancel
Save