简体   繁体   中英

Order in which classLoader will load classes in this scenario

I added lombok to my java project in eclipse . It required me to add the last two lines in eclipse.ini file as vmargs .

-showlocation
-vm
/home/$USER/JavaSE8/jdk1.8/bin/java
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20150204-1316
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms500m
-Xmx2g
-Dorg.eclipse.swt.browser.XULRunnerPath=''
-javaagent:/home/$USER/eclipse/4.4-luna-SR2/lombok.jar
-Xbootclasspath/a:/home/$USER/eclipse/4.4-luna-SR2/lombok.jar

I have also added lombok.jar in libraries (Project -> Properties -> Libraries) and also moved lombok.jar to the topmost level in Order and Export tab (Project -> Properties -> Order and Export) in eclipse and JRE System Library (rt.jar, resources.jar, etc.) all are below lombok.jar . I'm confused about the order in which lombok main class will be loaded as :

  1. When eclipse is launched, the Bootstrap classloader should load all JDK classes in directory of JRE. (But since I have moved lombok.jar up in Order and Export, above JRE system libraries, will rt.jar be loaded after lombok.jar . Mostly No? because bootstrap libraries should always be loaded first no matter WHAT !)

  2. Since we also redefined the bootstrap classpath using -XBootstrapClasspath option, lombok.jar will be loaded by Bootstrap Classloader .

  3. After that Extensions classloader loads the classes in lib\\ext directory of the JRE.

  4. Then System-Classpath classloader loads all classes and jars specified by the CLASSPATH environment variable (Does this loading takes into account the Order and Export order of libraries?)

Please correct me if I'm wrongly interpreting things here as I'm just newbie trying to understand the ClassLoading maze.

You often mention the "order and export". I assume you mean the same named tab in the project classpath dialog. As far as I know this concerns only the visibility of the projects library for other projects which depend on this project. It has nothing to do how eclipse itself is bootstrapped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM