1 |
Sorry, I forgot to CC the mailing list on my last response... Please |
2 |
read now: |
3 |
|
4 |
Sven Köhler schrieb: |
5 |
>> Because selecting -target 1.5 is quite sufficient. I'm not sure what you |
6 |
>> meant by overloading, but 1.4 bytecode compiled with a Java 6 JDK runs |
7 |
>> fine on a Java1.4 JDK. |
8 |
> |
9 |
> Oh i see! |
10 |
> |
11 |
> Now i got you - and you ran into the old mistake. I know, that it is |
12 |
> common practice to compile Java-Code with "-target X.Y" and to assume, |
13 |
> that it automatically run's fine with a Java X.Y VM. |
14 |
> |
15 |
> But i hope, that i can show to you, that this is not true. Assume you |
16 |
> have the following code: |
17 |
> |
18 |
> public class OverloadTest |
19 |
> { |
20 |
> public static void main(String[] args) |
21 |
> { |
22 |
> CharSequence sb1 = new StringBuffer("abc"); |
23 |
> StringBuffer sb2 = new StringBuffer(); |
24 |
> sb2.append(sb1); |
25 |
> System.out.println(sb2); |
26 |
> } |
27 |
> } |
28 |
> |
29 |
> |
30 |
> Compile it with JDK 1.5 or higher. Use "-target 1.4". |
31 |
> |
32 |
> The generated class files run fine with JDK 1.5 or higher. But with JDK |
33 |
> 1.4 you will get the following exception: |
34 |
> |
35 |
> java.lang.NoSuchMethodError: |
36 |
> java.lang.StringBuffer.append(Ljava/lang/CharSequence;)Ljava/lang/StringBuffer; |
37 |
> at compat.overload.OverloadTest.main(OverloadTest.java:9) |
38 |
> |
39 |
> |
40 |
> I hope, you see, why this error had to happen. The methode |
41 |
> StringBuffer.append(CharSequence) is documented is marked to be @since |
42 |
> 1.5 - but this is just a JavaDoc feature. Using "-target 1.4" does NOT |
43 |
> avoid, that it's actually used within the Bytecode. |
44 |
> |
45 |
> |
46 |
> I know, that you might not have seen this issue in real life. On the |
47 |
> other hand, this kind of issues go unnoticed, until the code is actually |
48 |
> executed because the NoSuchMethodError is thrown AT RUNTIME. |
49 |
> |
50 |
> |
51 |
|
52 |
|
53 |
Such packages will then be marked with RDEPEND=">=virtual/jre-1.5" and |
54 |
emerging them will pull in a JRE that supports the needed features (if |
55 |
not already installed). I don't see a problem there. |
56 |
-- |
57 |
gentoo-java@g.o mailing list |