Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?
From: Raymond DeCampo (rdecampo_at_spam-I-am-not.twcny.rr.com)
Date: 12/20/03
- Next message: Raymond DeCampo: "Re: waiting message"
- Previous message: Edward Micciulli: "Sr Java Developer - Swing - Fixed Income - Glendale California"
- In reply to: Vincent Cate: "Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?"
- Next in thread: Chris Smith: "Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 20 Dec 2003 03:09:59 GMT
Vincent Cate wrote:
> Chris Smith <cdsmith@twu.net> wrote in message news:<MPG.1a4cc749902e95f298984c@news.pop4.net>...
>
>>The Java API version 1.1 also doesn't have Vector.add() The
>>java.util.List-based names for Vector functions were only added with the
>>advent of the Collections API in 1.2. I'm guessing, then, that you only
>>think you are doing that, and that you aren't really doing it at all.
>
>
> I just installed j2sdk1.4.2_03 from Sun on a Linux machine and even
> here when I compile with "-target 1.1", I can have Vector.add()
> and it compiles fine (as does under JBuilder). But Microsoft JVM seems to
> need Vector.addElement(). So it is not just JBuilder that thinks
> it is ok in 1.1.
>
> It is not just my imagination. Really.
>
That makes perfect sense. The -target switch only says that it will
make byte code that is compatible with the given JVM. However, that
does not mean that the 1.1 versions of the JFC classes are used. Keep
in mind that the compiler is separate from the JFC classes. So the
compiler is generating byte code that will be compatible with 1.1 JVMs,
however, it is using the 1.4 JFC classes as a reference. There is
nothing to tell the compiler that Vector.add() does not exist in 1.1 JFC
classes and the Vector class it sees has it.
According to the javac documentation, you should use the -bootclasspath
and -extdirs options as well to achieve full cross compilation.
Here's the relevant portion of the javac documentation:
<quote>
Here we use the Java 2 SDK javac to compile code that will run on a
1.1 VM.
% javac -target 1.1 -bootclasspath jdk1.1.7/lib/classes.zip \
-extdirs "" OldCode.java
The -target 1.1 option ensures that the generated class files will
be compatible with 1.1 VMs. In the Java 2 SDK javac compiles for 1.2 by
default.
The Java 2 SDK's javac would also by default compile against its
own bootstrap classes, so we need to tell javac to compile against JDK
1.1 bootstrap classes instead. We do this with -bootclasspath and
-extdirs. Failing to do this might allow compilation against a Java 2
Platform API that would not be present on a 1.1 VM and fail at runtime.
</quote>
So it looks like this is a case of RTFM. :)
HTH,
Ray
- Next message: Raymond DeCampo: "Re: waiting message"
- Previous message: Edward Micciulli: "Sr Java Developer - Swing - Fixed Income - Glendale California"
- In reply to: Vincent Cate: "Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?"
- Next in thread: Chris Smith: "Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|