Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2005

Tip: Looking for answers? Try searching our database.

Eclipse compiler compliance

Thread view: 
JavaEnquirer - 24 May 2005 15:05 GMT
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?
Ross Bamford - 24 May 2005 22:42 GMT
> 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?

Signature

  [Ross A. Bamford]     [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + info@the.website.domain

JavaEnquirer - 25 May 2005 10:17 GMT
Makes sense. Thank you. Do you know where I can get hold of a 1.3 jdk?
I couldn't find one on the Suns site
Roland - 25 May 2005 10:58 GMT
> Makes sense. Thank you. Do you know where I can get hold of a 1.3 jdk?
> I couldn't find one on the Suns site

<http://java.sun.com/products/archive/index.html>

Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

John McGrath - 25 May 2005 10:58 GMT
> Do you know where I can get hold of a 1.3 jdk?
> I couldn't find one on the Suns site

http://java.sun.com/products/archive/index.html

Signature

Regards,

John McGrath

Andrew Thompson - 25 May 2005 11:03 GMT
> Makes sense. Thank you. Do you know where I can get hold of a 1.3 jdk?

Try <http://java.sun.com/j2se/1.3/download.html>.

But note that all you require to compile compatible for Java 1.3 classes
is the 1.3 rt.jar itself*, so the JRE will do just fine for that.

* I am referring to compilation from the command line or from any tool that
gives you direct access to setting the standard javac options, I cannot
speak for 'doing it from Eclipse'.

> I couldn't find one on the Suns site

Search on Sun's site is an art, especially recently that they have
been updating their search facility and moving/removing(?) old documents.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Dale King - 26 May 2005 05:38 GMT
>>Makes sense. Thank you. Do you know where I can get hold of a 1.3 jdk?
>
[quoted text clipped - 6 lines]
> gives you direct access to setting the standard javac options, I cannot
> speak for 'doing it from Eclipse'.

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.

Signature

 Dale King

Andrew Thompson - 26 May 2005 05:51 GMT
>> ..note that all you require to compile compatible for Java 1.3 classes
>> is the 1.3 rt.jar itself*, so the JRE will do just fine for that.
[quoted text clipped - 6 lines]
> 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!  ;-) ]

-- Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane
Dale King - 31 May 2005 12:27 GMT
>>>..note that all you require to compile compatible for Java 1.3 classes
>>>is the 1.3 rt.jar itself*, so the JRE will do just fine for that.
[quoted text clipped - 12 lines]
> 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.

Signature

 Dale King



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.