Hi, in reflection, the private field can be access via getDeclaredField() and setAccessible(true). How to access the private field of a outside class via Objectweb ASM bytecode API? I set to get the private field from something like, via
Field current = sourceObject.getDeclaredField(privateFieldName);
Field.setAccessible(true);
Type sourceType = Type.getType(sourceObject.getClass());
mv.visitFieldInsn(Opcodes.GETFIELD,
sourceType.getInternalName(),
privateFieldname,
Type.getDescriptor(current.getType()));
When the byte code is executed and to get the private field, I always got an error "java.lang.IllegalAccessError "
Any clue? Thanks a bundle,