I create a class dynamically - by constructing the bytecode and loading it with class loader. Later, I need to get InputStream of this class. With common class, I get this by getting resource URL for this class and then opening the stream (url.openStream()). Obviously, here I can't do that, as dynamically loaded class does not have the URL.
How can I get InputStream of dynamically created class?
The only solution I can think of atm is to save the bytecodes to some temp file/memory and then to provide InputStream from it.
EDIT
I need InputStream to make another bytecode change on top of existing.
byte[]then you could construct aByteArrayInputStream.byte[]for each proxy class it is generated, it's going to be too much. Anyway, I am exploring this option.URLstep, as that requires defining a custom protocol and implementing a protocol handler for in-memory representations. Just use, e.g.Foo.class.getResourceAsStream("Foo.class"). That way, theClassLoadercan return aByteArrayInputStreamwithout the need to supportURLs. If you change it to use temporary files to save memory in-between, the application logic doesn’t change.