Warning!! Bootstrap classpath lost in combat

I’m not really sure, but from JVM version 7, when you’re compiling with legacy code or simply you’re a everything-must-be-under-control person who uses the flag “-source” of the javac:

% javac -source 1.6

you get with the following compilation warning:

warning: [options] bootstrap class path not set in conjunction with -source 1.6

As the javac doc explains , this happens because the compiler will use the old language rules in combination with the new bootstrap classes, which can result in class files that do not work on the older platform (in this case, Java SE 6) because reference to non-existent methods can get included. This behaviour can end in some kind of programmer-crazyness, so the documentation gives us a simple solution, the usage of the bootclasspath and extdirs params:

% javac -source 1.6 -target 1.6 -bootclasspath jdk1.6.0/lib/rt.jar \ -extdirs ""

With this, the compiler uses the correct bootstrap classes, and it does not warning us about strange mixes of compiled versions.


Javac doc:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s