ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <flo...@mindspring.com>
Subject Re: Cross-compilation problem
Date Fri, 22 Feb 2008 17:58:01 GMT
That's really interesting!  To be honest I have not really had a need to 
do something like that to date...

I'll have to give this some more thought...


Christian Schröder wrote:
> 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
>

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros


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


Mime
View raw message