ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Schröder>
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" 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: 
        at Test.main(

The 1.4 compiler would have reported the following error: 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.


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

Deriva CA Certificate:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message