"Steve W. Jackson" <stevewjackson@knology.net> wrote in message
In article <1168456294.246173.52740@77g2000hsv.googlegroups.com>,
"Bogdan Tudor" <bogdantudor@gmail.com> wrote:
Hello everybody,
I was wondering if anyone tried to obtain the bytecode of a class (
obtain it as a byte[] for example), but without having to read it from
the .class file found in the classpath.
I am asking this because sometimes the classpath could contain some
non-disk locations, so reading from disk the .class won't always work.
I haven't done anything of the sort myself, but I recall seeing some
sample code when I researched how to use a ClassLoader. I can't say
where, but it was "out there" on the Internet someplace. The idea I
remember was that the bytes were received from some source or another
and written locally so that a custom ClassLoader could then load them
and proceed. But if you know enough about how a ClassLoader works you
could just as easily do the same with a non-disk (in-memory) source of
bytes, I'm sure.
Might not be that easy. There are a bunch of methods in ClassLoader
methods that provide the reverse (i.e. you provide a Class<?> and it returns
a byte[]).