5

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.

Ashley
  • 441
  • 2
  • 8
  • 27
  • @kdgregory Can you please answer this question? – Ashley May 29 '16 at 14:34
  • @Juned Ahsan Can you please answer this question ? – Ashley May 29 '16 at 14:35
  • 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 May 30 '16 at 07:41
  • @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 May 30 '16 at 08:10

1 Answers1

0

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.

Heri
  • 4,368
  • 1
  • 31
  • 51
  • I tested what you wrote about about visibility of projects library for other projects which depend on this project. So I have 2 , say A & B projects to which I have added lombok.jar as libraries. Also A is dependent on B. In both A & B, I have used Lombok. I removed lombok.jar from B's libraries . Now the lombok annotations in B were shown with red lines (in eclipse). – Ashley Jun 02 '16 at 04:36
  • 1
    It seems you interchanged the order. If A is dependant on B as you write, then remove the jar from project A (and not from B) and adjust the build path of project B to show the export of the library. – Heri Jun 02 '16 at 14:05