5
votes

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.

1
@kdgregory Can you please answer this question? - Ashley
@Juned Ahsan Can you please answer this question ? - Ashley
FYI: Since at least version 1.16.4, it is no longer necessary to add lombok.jar to the bootclasspath at all. You only need to add the jar as an agent. - Roel Spilker
@RoelSpilker Thanks for the info. Yes Lombok 1.16.x works by just adding jar as agent. I just want to know when do you add a jar as an agent and to bootclasspath? - Ashley

1 Answers

0
votes

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.