.append(key.getRight().getName()).toString();
importedMethods.put(key, result);
privilizer().env.debug("importing %s#%s as %s", key.getLeft().getClassName(), key.getRight(), result);
final int access = Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_SYNTHETIC;
final MethodNode source = getMethods(key.getLeft()).get(key.getRight());
@SuppressWarnings("unchecked")
final String[] exceptions = (String[]) source.exceptions.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
// non-public fields accessed
final Set<FieldAccess> fieldAccesses = new LinkedHashSet<FieldAccess>();
source.accept(new MethodVisitor(Opcodes.ASM4) {
@Override
public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
final FieldAccess fieldAccess = fieldAccess(Type.getObjectType(owner), name);
super.visitFieldInsn(opcode, owner, name, desc);
if (!Modifier.isPublic(fieldAccess.access)) {
fieldAccesses.add(fieldAccess);
}
}
});
final MethodNode withAccessibleAdvice =
new MethodNode(access, result, source.desc, source.signature, exceptions);
// spider own methods:
MethodVisitor mv = new NestedMethodInvocationHandler(withAccessibleAdvice, key.getLeft()); //NOPMD
if (!fieldAccesses.isEmpty()) {
// accessesNonPublicFields = true;
mv = new AccessibleAdvisor(mv, access, result, source.desc, new ArrayList<FieldAccess>(fieldAccesses));
}
source.accept(mv);
// private can only be called by other privileged methods, so no need to mark as privileged
if (!Modifier.isPrivate(source.access)) {
withAccessibleAdvice.visitAnnotation(Type.getType(Privileged.class).getDescriptor(), false).visitEnd();
}
withAccessibleAdvice.accept(this.cv);
return result;
}