Hi Michael, I saw this method, but was unsure if this method only looked for loaded classes in the bootstrap class loader or if it proceeded to try load the class. I saw this being used in the ClassLoader.loadClass and the code and comments was what made me unsure. I'll hunt for the native code to see what is actually being done. Meanwhile, a google search made me notice that some implementations had this method named findBootstrapClass0. I can't tell if this is vendor specific or was it renamed at some point - Any idea?
Thanks ./Sam On Mon, Sep 30, 2019 at 12:21 AM Michael Rasmussen < michael.rasmus...@roguewave.com> wrote: > There is a similar protected method on ClassLoader for that: ClassLoader. > findBootstrapClassOrNull > > /Michael > ------------------------------ > *From:* Sam Thomas <sam.tho...@broadcom.com> > *Sent:* 25 September 2019 02:11 > *To:* Michael Rasmussen <michael.rasmus...@roguewave.com> > *Cc:* serviceability-dev@openjdk.java.net < > serviceability-dev@openjdk.java.net>; daniel.daughe...@oracle.com < > daniel.daughe...@oracle.com> > *Subject:* Re: Bytecode Instrumentation and Class Loading. > > 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.tho...@broadcom.com> > wrote: > > cool thanks > > Thanks > ./Sam > > > On Fri, Sep 20, 2019 at 5:05 AM Michael Rasmussen < > michael.rasmus...@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 > >