/**
* Prevents advice to have inner classes.
*/
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
throw new ProxettaException("Proxetta doesn't allow inner classes in/for advice: " + advice.getName());
}
/**
* Clones advices fields to destination.
*/
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
wd.dest.visitField(access, adviceFieldName(name, aspectIndex), desc, signature, value); // [A5]
return super.visitField(access, name, desc, signature, value);
}
/**
* Copies advices methods to destination.
*/
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals(CLINIT) == true) { // [A6]
if (desc.equals(DESC_VOID) == false) {
throw new ProxettaException("Invalid static initialization block description for advice: " + advice.getName());
}
name = clinitMethodName + methodDivider + aspectIndex;
access |= AsmUtil.ACC_PRIVATE | AsmUtil.ACC_FINAL;
wd.addAdviceClinitMethod(name);
return new MethodAdapter(wd.dest.visitMethod(access, name, desc, signature, exceptions)) {
@Override
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
}
@Override
public void visitLineNumber(int line, Label start) {
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
if (opcode == INVOKESTATIC) {
if (owner.equals(adviceReference)) {
owner = wd.thisReference;
name = adviceMethodName(name, aspectIndex);
}
}
super.visitMethodInsn(opcode, owner, name, desc);
}
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) { // [F6]
if (owner.equals(adviceReference)) {
owner = wd.thisReference; // [F5]
name = adviceFieldName(name, aspectIndex);
}
super.visitFieldInsn(opcode, owner, name, desc);
}
};
} else
if (name.equals(INIT) == true) { // [A7]
if (desc.equals(DESC_VOID) == false) {
throw new ProxettaException("Advices can have only default constructors. Invalid advice: " + advice.getName());
}
name = initMethodName + methodDivider + aspectIndex;
access = ProxettaAsmUtil.makePrivateFinalAccess(access);
wd.addAdviceInitMethod(name);