Java

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 MyClass.java

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 "" MyClass.java

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

References:

Javac doc: http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html#crosscomp-example

Advertisements
Standard

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s