Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?

From: Chris Smith (cdsmith_at_twu.net)
Date: 12/22/03

  • Next message: JC Home: "Java Programming for Windows"
    Date: Mon, 22 Dec 2003 09:59:59 -0700
    
    

    Vincent Cate wrote:
    > In my defense, I quote from the man page for Sun's 1.4 javac:
    >
    > > -target version
    > > Generates class files that will work on VMs with the specified version.
    > > [...] The versions supported are:
    > >
    > > 1.1 Ensures that generated class files will be compatible
    > > with 1.1 and 1.2 VMs.
    > > [...]
    >
    > What the man page says "-target" does is not what it really does. The
    > "will work", "Ensures", and "will be compatible" all don't mean what
    > they seem to mean.

    The option actually does exactly what the man page says that they do,
    and nothing more. That is, the option generates class files that will
    work on the given virtual machine, but they do *not* police your use of
    libraries that will be available on that version of the Java platform.
    When you compile with the "-target" option, the format of the resulting
    class file is compatible the the given virtual machine. If you provided
    libraries matching your usage (for example, if you wrote a replacement
    for java.util.Vector with an add() method and arranged the boot
    classpath to find that instead of the standard system class), the
    application would work fine.

    [Incidentally, the fact that it would be illegal to distribute such an
    application is not considered by the compiler, since it is not a
    lawyer.]

    The problem is that when you read that the generated class file would be
    compatible with that version of the Java virtual machine, you also
    assumed that it would work with the set of APIs that's commonly
    distributed with that VM as part of the J2SE. This is not the case.
    The virtual machine and the Java core API are different things, and
    there is no guarantee that the application you compile with a '-target'
    option will work with a specific core API.

    > So now I will compile on 1.4 to make sure I am ok with current Java
    > (not using anything "deprecated") and then on 1.1 to make sure my code
    > does not use anything that 1.1 does not have. Not exactly compile
    > once run anywhere.
    >
    > Is this what other people do?

    Not really. Mostly, other people compile and test against a single VM
    version or small set of versions, and then require that for their code
    (in fact, often install that with their application). Users who fiddle
    so as to change the version of the Java platform in use then accept
    responsibility for breaking the application, if indeed they do so.

    -- 
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.
    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    

  • Next message: JC Home: "Java Programming for Windows"

    Relevant Pages

    • Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?
      ... >> Generates class files that will work on VMs with the specified version. ... libraries that will be available on that version of the Java platform. ... When you compile with the "-target" option, ... class file is compatible the the given virtual machine. ...
      (comp.lang.java.programmer)
    • Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?
      ... >> Generates class files that will work on VMs with the specified version. ... libraries that will be available on that version of the Java platform. ... When you compile with the "-target" option, ... class file is compatible the the given virtual machine. ...
      (comp.lang.java.help)
    • Re: Target VM Microsoft? or Java Lint to check for MS VM compatibility?
      ... >> Generates class files that will work on VMs with the specified version. ... libraries that will be available on that version of the Java platform. ... When you compile with the "-target" option, ... class file is compatible the the given virtual machine. ...
      (comp.lang.java.softwaretools)
    • Q: Java source and directory structure - standard way ?
      ... When I compile I use the -d option on Sun's SDK... ... and places the class files into it. ... Java source. ... code directory structure has been created to mirror the package names. ...
      (comp.lang.java)
    • Re: Curioser and curiouser
      ... Barkow, Eileen wrote: ... have it that way in my old system and all my class files ... I got my java program to compile on our new ... 'codepage' at first, ...
      (bit.listserv.ibm-main)