Re: Get java.lang.IllegalAccessError when accessing the private field of a outside class via ASM Java Bytecode
Rémi Forax <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Le 03/10/2010 22:26, [email protected] a écrit : > 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 " > The VM also verifies the bytecode. > Is there any standard way to access/get the value fro ma private field of an > outside class? Thanks a bundle, > > E > Reflection :) Why do you want to bypass reflection ? Rémi
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