| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
📚 Learning and exploring how class loading works in the JVM.
NOTE: This project was developed on macOS. It is designed for my own personal use.
How does class loading work? What is the system class loader? What is the effect of two classes, with the same fully qualified name, existing on the classpath? What does it even mean to load a class? Does a class get loaded "into a classloading space" or does a class get loaded into a shared space for the whole process? Does JPMS let us have strong encapsulation of this space?
This codebase is me exploring class loading by way of runnable examples.
Follow these instructions to build and run the example program.
./gradlew jarjava -jar build/libs/java-class-loading-playground.jarMessageHolder{staticMessage='Hello', classloader='jdk.internal.loader.ClassLoaders$AppClassLoader@63c12fb0'}
MessageHolder{staticMessage='Hello', classloader='java.net.URLClassLoader@44e81672'}
Logically equal?: false
Reference-equal?: false
MessageHolder{staticMessage='Goodbye', classloader='jdk.internal.loader.ClassLoaders$AppClassLoader@63c12fb0'}
MessageHolder{staticMessage='Hello', classloader='java.net.URLClassLoader@44e81672'}
instanceFromAppLoader: MessageHolder{instanceMessage='I'm from the app/system class loader.'}
instanceFromCustomLoader: MessageHolder{instanceMessage='I'm from a custom class loader.'}
instanceFromAppLoader type: class dgroomes.MessageHolder
instanceFromCustomLoader type: class dgroomes.MessageHolder
instanceFromAppLoader is an instance of MessageHolder
instanceFromCustomLoader is NOT an instance of MessageHolder
General clean-ups, TODOs and things I wish to implement for this project:
After creation, a class or interface is determined not by its name alone, but by a pair: its binary name (§4.2.1) and its defining loader. Each such class or interface belongs to a single run-time package. The run-time package of a class or interface is determined by the package name and the defining loader of the class or interface.
| Back | FazBrowse Home | New Git URL |