• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

system class loader creation

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to understand when the system class loader is created by the JVM. Java VM spec has no information on it, while "Inside Java 2 Platform Security, 2nd Edition - Li Gong" states that "the formation of this hierarchy (my note: delegation hierarchy) occurs early in the runtime's start-up sequence, at which point it creates the application class loader" (in this book the system class loader is referred to as application class loader). So, can somebody give a reference describing the creation of the system class loader (the one loading classes from CLASSPATH)? Thank you.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The JVM specification does not specify this, because it's an implementation detail. It's up to the particular JVM implementation to do this when appropriate. There's no definitive answer to this question that is valid for any version of any JVM implementation. If you really want to know how this works under the covers in Oracle's JVM, you could dive into the OpenJDK source code. But beware, it's a very big and very complicated project.

Why exactly are you asking this question - what do you hope to understand by knowing the answer to this question? It's not something that Java programmers normally need to know when developing software in Java.
 
Emil Romascanu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Jesper: it's hard - at least for me - to grow the knowledge tree without understanding how things are supposed to work. So, when I read about class loaders - bootstrap, extension, application - I have questions: what they have to do, when they are created, how they can be accessed, etc. It was easy to get it for bootstrap and extension - it's JVM business and they are created at JVM startup, and so forth. For application class loader was a little bit challenging because in "Inside Java 2 Platform Security", the author says that the app class loader is user defined, which a reader may think that the programmer has to write its code. Then when I read that the app class loader is supposed to be created in the "early stages of JVM startup sequence" I suspected that "app class loader is user defined" may be misleading: probably the correct interpretation is that the app class loader is created by JVM sometime at startup and its dependency with the user is that the user provides the CLASSPATH (in the command line or in the project settings). I was looking for a confirmation, and this is the reason for my posting. From your answer I conclude that I am right. And no, I don't want to dig into OpenJDK, at least not now. Thank you.
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Classloaders aren't actually "beginning java". At that level, it is sufficient to know that such a mechanism exists and that it is repsonsible for making class definitions available to the object instantiator.

Truthfully, I myself after all these years don't have a solid handle on what system classloaders are in effect when the Oracle JVM (for example) starts up. It has been years since I've done any custom classloading code.

I can, however, tell you what they do. They locate the classes defined in the JVM's library jars, its user-added jars - if applicable, any classes that are hard-coded into the JVM itself, and the classes in the JVM's classpath, if one has been defined. The classloader (or classloader chain) gets invoked when you do a "new MyClass()" operation, or invoke "Class.forName("MyClass")". Possibly in some other cases, but those are the 2 most common ones. I guess the introspection classes invoke classloaders, too, especially the "newInstance()" method. It's hard to analyze a class if you don't have a copy of it.
 
Emil Romascanu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to Tim and Jesper. I appreciate help. "I will be back"
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Classloaders aren't actually "beginning java". . . .

Agree. Off to another forum with you!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic