Eclipse compiler compliance

J

JavaEnquirer

I've set the following compliance settings in Eclipse:

Compiler compliance level: 1.3
Generate class file compatibility: 1.3
Source file compatibility: 1.3

My JRE system library is 1.5.

However, when I compile a class with the lines:

BitSet bitset ...
bitset.clear();

I get no errors! The clear() method wasn't introduced until 1.4. I
thought that by setting the compliance levels lower to 1.3 ( even
though 1.5 is my JRE system library ) would cause Eclipse to work as if
my JRE system library was 1.3!

What have I missed?
 
R

Ross Bamford

I get no errors! The clear() method wasn't introduced until 1.4. I
thought that by setting the compliance levels lower to 1.3 ( even
though 1.5 is my JRE system library ) would cause Eclipse to work as if
my JRE system library was 1.3!

What have I missed?

The JRE libraries are whatever you have with your version of the JRE /
JDK. When you set source and target versions you are telling
the /compiler/ to treat /your/ source as that version, and emit the
compiled bytecode for that source in a format compatible with that
version of the JVM. In other words, this doesn't touch the .class(es)
you imported from java.*, or anywhere else. Those class files
are /already/ compiled down from a specifically versioned source to a
specifically versioned target bytecode flavour (source and target 1.5
obviously for the 1.5 libraries).

Of course, targeting a lower version ensures that when someone with that
version loads /your/ targeted bytecode into their 1.4 / 1.3 JVM (with
1.4 / 1.3 JDK libraries), it will verify as /correct bytecode/. If the
first thing that correct bytecode then does is try to call out to a
method that wasn't added at that time you'll get NoSuchMethodError - no
protection (at all?) is provided against this kind of version mismatch.

As was recently discussed in this very group, can you imagine the
baggage, the sheer size of the JDK, if it had to carry copies of each
prior version as well as the current one?
 
D

Dale King

Andrew said:
Andrew Thompson wrote:


You can do it in Eclipse too. By default it gives you the runtime jar
from the runtime you have selected but you can remove that and replace
it with your own.


Thanks for that. [ Although I strongly advocate learners using
a simple text editor (and still use a text editor for the SSCCE's
I post to usenet), I worked on a large project recently in which
both JBuilder and Eclipse (..along with their debuggers, build
tools, etcetera) proved quite valuable. ..So there! ;-) ]

Well, I advocate that newbies use BlueJ and not Eclipse even though I
think is a great IDE for those that are experienced (and another thread
discusses IDE vs. command line tools), but I fail to see what that has
to do with this thread since no one was classified as a "learner" and
the OP was specifically asking about Eclipse.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top