int flags = getAccessFlags();
if (enclosingClass.getWorld().isJoinpointSynchronizationEnabled()
&& enclosingClass.getWorld().areSynchronizationPointcutsInUse()) {
flags = getAccessFlagsWithoutSynchronized();
}
MethodGen gen = new MethodGen(flags, getReturnType(), getArgumentTypes(), null, // getArgumentNames(),
getName(), getEnclosingClass().getName(), new InstructionList(), getEnclosingClass().getConstantPool());
for (int i = 0, len = declaredExceptions.length; i < len; i++) {
gen.addException(declaredExceptions[i]);
}
for (Attribute attr : attributes) {
gen.addAttribute(attr);
}
if (newAnnotations != null) {
for (AnnotationAJ element : newAnnotations) {
gen.addAnnotation(new AnnotationGen(((BcelAnnotation) element).getBcelAnnotation(), gen.getConstantPool(), true));
}
}
if (newParameterAnnotations != null) {
for (int i = 0; i < newParameterAnnotations.length; i++) {
AnnotationAJ[] annos = newParameterAnnotations[i];
for (int j = 0; j < annos.length; j++) {
gen.addParameterAnnotation(i, new AnnotationGen(((BcelAnnotation) annos[j]).getBcelAnnotation(), gen
.getConstantPool(), true));
}
}
}
if (memberView != null && memberView.getAnnotations() != null && memberView.getAnnotations().length != 0) {
AnnotationAJ[] ans = memberView.getAnnotations();
for (int i = 0, len = ans.length; i < len; i++) {
AnnotationGen a = ((BcelAnnotation) ans[i]).getBcelAnnotation();
gen.addAnnotation(new AnnotationGen(a, gen.getConstantPool(), true));
}
}
if (isSynthetic) {
if (enclosingClass.getWorld().isInJava5Mode()) {
gen.setModifiers(gen.getModifiers() | ACC_SYNTHETIC);
}
// belt and braces, do the attribute even on Java 5 in addition to
// the modifier flag
ConstantPool cpg = gen.getConstantPool();
int index = cpg.addUtf8("Synthetic");
gen.addAttribute(new Synthetic(index, 0, new byte[0], cpg));
}
if (hasBody()) {
if (this.enclosingClass.getWorld().shouldFastPackMethods()) {
if (isAdviceMethod() || getName().equals("<clinit>")) {
packBody(gen);
} else {
optimizedPackBody(gen);
}
} else {
packBody(gen);
}
gen.setMaxLocals();
gen.setMaxStack();
} else {
gen.setInstructionList(null);
}
return gen;
}