*/
private LazyMethodGen createShadowMethodGen(String newMethodName, int visibilityModifier, List<String> parameterNames) {
Type[] shadowParameterTypes = BcelWorld.makeBcelTypes(getArgTypes());
int modifiers = Modifier.FINAL | Modifier.STATIC | visibilityModifier;
if (targetVar != null && targetVar != thisVar) {
UnresolvedType targetType = getTargetType();
targetType = ensureTargetTypeIsCorrect(targetType);
// see pr109728,pr229910 - this fixes the case when the declaring class is sometype 'X' but the (gs)etfield
// in the bytecode refers to a subtype of 'X'. This makes sure we use the type originally
// mentioned in the fieldget instruction as the method parameter and *not* the type upon which the
// field is declared because when the instructions are extracted into the new around body,
// they will still refer to the subtype.
if ((getKind() == FieldGet || getKind() == FieldSet) && getActualTargetType() != null
&& !getActualTargetType().equals(targetType.getName())) {
targetType = UnresolvedType.forName(getActualTargetType()).resolve(world);
}
ResolvedMember resolvedMember = getSignature().resolve(world);
// pr230075, pr197719
if (resolvedMember != null && Modifier.isProtected(resolvedMember.getModifiers())
&& !samePackage(resolvedMember.getDeclaringType().getPackageName(), getEnclosingType().getPackageName())
&& !resolvedMember.getName().equals("clone")) {
if (!hasThis()) { // pr197719 - static accessor has been created to handle the call
if (Modifier.isStatic(enclosingMethod.getAccessFlags()) && enclosingMethod.getName().startsWith("access$")) {
targetType = BcelWorld.fromBcel(enclosingMethod.getArgumentTypes()[0]);
}
} else {
if (!targetType.resolve(world).isAssignableFrom(getThisType().resolve(world))) {
throw new BCException("bad bytecode");
}
targetType = getThisType();
}
}
parameterNames.add("target");
// There is a 'target' and it is not the same as 'this', so add it to the parameter list
shadowParameterTypes = addTypeToFront(BcelWorld.makeBcelType(targetType), shadowParameterTypes);
}
if (thisVar != null) {
UnresolvedType thisType = getThisType();
parameterNames.add(0, "ajc$this");
shadowParameterTypes = addTypeToFront(BcelWorld.makeBcelType(thisType), shadowParameterTypes);
}
if (this.getKind() == Shadow.FieldSet || this.getKind() == Shadow.FieldGet) {
parameterNames.add(getSignature().getName());
} else {
String[] pnames = getSignature().getParameterNames(world);
if (pnames != null) {
for (int i = 0; i < pnames.length; i++) {
if (i == 0 && pnames[i].equals("this")) {
parameterNames.add("ajc$this");
} else {
parameterNames.add(pnames[i]);
}
}
}
}
// We always want to pass down thisJoinPoint in case we have already woven
// some advice in here. If we only have a single piece of around advice on a
// join point, it is unnecessary to accept (and pass) tjp.
if (thisJoinPointVar != null) {
parameterNames.add("thisJoinPoint");
shadowParameterTypes = addTypeToEnd(LazyClassGen.tjpType, shadowParameterTypes);
}
UnresolvedType returnType;
if (getKind() == PreInitialization) {
returnType = UnresolvedType.OBJECTARRAY;
} else {
if (getKind() == ConstructorCall) {
returnType = getSignature().getDeclaringType();