Thanks for your reply, this leads me in the right direction.
If my use case for reflection is primarily to determine what Byte Buddy operations are needed - then using the bb reflection API's make the most sense.
As for Jar files - support for Jar *format* (not necessarily 'files) is critical to a few of my use cases and I suspect for others.
Reading files from a Jar is easy - given the Jar library in Java its a snap.
Pulling the .class files from that is not much extra work - although it does take a bit thought to get the paths to classname translations right.
Similarly writing .jar format output from individual classes (and similar doing the reverse mapping).
I may write such a library and publish it - but its of little value on its own.
However that inst the end of the story..
Some use cases that are more difficult - or just more work - that would benefit from direct integration into BB.
Writing:
1) Manifest file - what should go in there ? Should there be references to dependencies ? licenses etc ?
2) Class Loaders -- and other extra bits -- If the generated classes are intended to be used with different classload options,
perhaps different per class ! that information would be very useful in the jar, perhaps as an actual instance of a classloader
and associated reference in the manifest
3) package level annotations - creating and writitng out the package-info.java
Reading:
1-3 from above
4) Creating a ClassLoader from a jar or set of jars - that come from a one-time source -
I have a project where the 'jar' files are stored in a database and I need to load them into the running JVM.
I currently have a custom class loader to do this - but I found its much more difficult then I thought to make a Jar Class loader
then it is to make a single class loader -- Studying the OpenJDK and Oracle source for URLClassLoader (the one one I know of that supports JAR format )
is enlightening - its very complicated, it assumes that the 'jar' files have URL's and that they exist and are accessible indefinitely - unchanged.
This works great for file:// and http:// sources, but no provision at all for a single in-memory blob ---
I ended up having to register my own URL scheme and cache the binary jar and serve it up as if it were a URL resolvable resource.
Having a classloader that works directly on jar format 'blobs' would be a very useful thing.
Consider #2 above especially - if the classloader *also* is responsible for instantiating classes using specific bytebuddy classloader options -
that would solve multiple problems.
Imagine being able to create BB classes and store them in a 'jar' along with the correct classloader options.
Then the users of that (even if its you) could just use the .jar and either put it into the CLASSPATH or load it with a provided classloader ...
( ideally one that is embedded into the jar itself) - and not have to manage keeping track of the classloader options or link with
ByteBuddy at runtime (the jar could contain BB if needed)