On Jul 13, 2006, at 11:25 AM, Ray Kiddy wrote:

On Jul 13, 2006, at 11:01 AM, Craig L Russell wrote:

Hi Ray,

This sounds like a bug in the compiler. Have you raised an issue with the JDK folks?


It had not occurred to me to look at this as a bug in the 1.5 javac. I think I will file that with Sun. I was just thinking that the 1.4.2 compiler was, you know, done.

- ray

FYI, it appears that if you use the 1.5 javac AND specify the 1.4 libraries, the compiler does the right thing. In talking to other people, I have been convinced that Sun would say this is correct behavior.

To get true 1.4 compatibility, you need "-source 1.4 -target 1.4" and you need to reference the correct -bootclasspath and -extdirs.

- ray

% /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/javac -bootclasspath /Users/ray/Library/Java:/Library/Java:/System/Library/Java:/Network/Library/Java:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/ui.jar -extdirs /System/Library/Java/Extensions -classpath . -source 1.4 -target 1.4 foo.java
% java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-112)
Java HotSpot(TM) Client VM (build 1.5.0_06-64, mixed mode, sharing)
% /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/javap -bootclasspath /Users/ray/Library/Java:/Library/Java:/System/Library/Java:/Network/Library/Java:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/ui.jar -extdirs /System/Library/Java/Extensions -classpath . -c foo
Compiled from "foo.java"
public class foo extends java.lang.Object{
public foo();
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return

public static void main(java.lang.String[]);
   0:   new     #2; //class java/math/BigDecimal
   3:   dup
   4:   ldc2_w  #3; //double 10.0d
   7:   invokespecial   #5; //Method java/math/BigDecimal."<init>":(D)V
   10:  astore_1
   11:  getstatic       #6; //Field java/lang/System.out:Ljava/io/PrintStream;
   14:  aload_1
   15:  invokevirtual   #7; //Method java/io/PrintStream.println:(Ljava/lang/Object;)V
   18:  return