Bytecode Instrumentation and Class Loading.

Sam Thomas sam.thomas at broadcom.com
Tue Sep 24 23:11:00 UTC 2019


Hi Michael,

Returning question: I understand that the method findLoadedClass is
protected. But say it was public, how would you find out loaded classes on
the bootstrap classloader? Since from instrumentation perspective when a
loader is null its the bootstrap classloader.

Thanks
./Sam


On Fri, Sep 20, 2019 at 2:08 PM Sam Thomas <sam.thomas at broadcom.com> wrote:

> cool thanks
>
> Thanks
> ./Sam
>
>
> On Fri, Sep 20, 2019 at 5:05 AM Michael Rasmussen <
> Michael.Rasmussen at roguewave.com> wrote:
>
>> On 9/18/19 2:47 PM, Sam Thomas wrote:
>> > Hi,
>> >
>> > I'm trying to understand if a class will load as soon as all the
>> transformers return. The aim is to get a class reference of a class I have
>> seen in my transformer.
>>
>> Short answer: no.
>>
>> Trying to define a class can cause other classes to try to be loaded
>> before (for instance the super types), meaning when you're done
>> transforming class A, the same thread might try to load multiple other
>> classes before it finishes defining A.
>> And if any of these fail, A will also fail to be defined.
>>
>> > Also if there is way to get the same without triggering class loading -
>> if the class is not loaded return a null reference.
>>
>> ClassLoader has a protected method findLoadedClass that checks if a class
>> is loaded by that classloader and returns the Class instance if so, or null
>> otherwise.
>> But as mentioned, the method is protected so normally not accessible
>> outside the classloader itself.
>>
>> /Michael
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20190924/c9da1f7d/attachment-0001.html>


More information about the serviceability-dev mailing list