Get java.lang.IllegalAccessError when accessing the private field of a outside class via ASM Java Bytecode

<[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Hi, I want to replace reflection code with ASM to access the private field of
an outside class for performance improvement. 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 "

Is there any standard way to access/get the value fro ma private field of an
outside class? Thanks a bundle,

E
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.