ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Schröder ...@deriva.de>
Subject Re: Cross-compilation problem
Date Fri, 22 Feb 2008 17:46:55 GMT
Scot P. Floess wrote:
> Curious, why don't you just use the 1.5 javac but target 1.4?  That 
> should do what you want...  I think all you will need to do is this:
>
> <javac srcdir="src" destdir="classes" source="1.4" target="1.4"/>
The problem is that the 1.5 javac won't complain if I accidently use 
functions from the 1.5 api. It will create a class file which *looks* 
like 1.4 (as to the class version number), but cannot be executed by a 
1.4 jvm.
Try the following example:

public class Test {
    public static void main(String[] args) {
        String s = "Hello World";
        int i = s.codePointAt(0);
    }
}

If I compile with "/usr/java/jdk1.5.0/bin/javac -source 1.4 -target 1.4 
Test.java" the compiler won't complain. However, if I start this app 
with a 1.4 jvm I get the following exception:

Exception in thread "main" java.lang.NoSuchMethodError: 
java.lang.String.codePointAt(I)I
        at Test.main(Test.java:4)

The 1.4 compiler would have reported the following error:

Test.java:4: cannot resolve symbol
symbol  : method codePointAt (int)
location: class java.lang.String
        int i = s.codePointAt(0);
                 ^
1 error

That's why I try to use the compiler of the target platform.

Regards,
    Christian

-- 
Deriva GmbH                         Tel.: +49 551 489500-42
Financial IT and Consulting         Fax:  +49 551 489500-91
Hans-Böckler-Straße 2                  http://www.deriva.de
D-37079 Göttingen

Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message