Re: java.lang.ClassNotFoundException during CheckClassAdapter.verify

[email protected]
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <1746009566.10018821314607578095.JavaMail.root@zimbra7-e1.priv.proxad.net>
25/08/2011 10:54, Nikita Salnikov-Tarnovski wrote:
> Hi.
> 
> I am implementing some java agent, which must instrument classes when 
> they are being loaded by JVM. In order to verify my instrumentation I 
> use CheckClassAdapter.verify. But sometimes I get the 
> java.lang.ClassNotFoundException:

> I think that the problem arises when class being instrumented right now 
> uses some other class, which is not loaded yet. And so ASM cannot verify it.
> 
> Is this possible to verify bytecode correctness without all classes 
> being loaded and available?

this is possible, but for that you need to write a subclass of SimpleVerifier, and to override its protected methods. By default these methods perform their work by loading the necessary classes with Class.forName(). Instead, you can implement them by loading only their bytecode (with ClassLoader.getResourceAsStream), and then using ClassReader.getAccess(), getSuperName(), and getInterfaces() to analyze it.

Eric
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.