db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ray Kiddy <kid...@apple.com>
Subject BigDecimal incompatibility from 1.5 -> 1.4
Date Thu, 13 Jul 2006 16:38:32 GMT

I have been e-mailing with Andrew McIntyre about getting some things  
done in the build of Derby on Mac OS X.

We (at Apple) are seeing something and I am wondering how you all  
have dealt with this issue. At one time, we thought we could use Java  
1.5 and achieve backwards compatibility with 1.4. We have seen an  
issue with BigDecimal and I wonder if this has impacted you all, or  
how you have dealt with it.

The problem is this. If one used a method in 1.4, java.math.BigDecimal 
(int), the javac compiler would map this for you, under the covers,  
to java.math.BigDecimal(double).

If one builds in 1.5 with no options, one gets the new API included  
in 1.5. So, java.math.BigDecimal(int) works as is and there is no  
reason for javac to do any magic underneath the covers.

But, if one builds "javac -source 1.4 -target 1.4", then one gets the  
classes in the right class file format for running in the 1.4 VM, but  
the javac compiler has not done the mapping. Result? A runtime  
exception. The 1.4 VM does not know the method java.math.BigDecimal 
(int).

The code below demonstrates this concretely.

Just curious how you all are dealing with this, or if you have had to.

thanx - ray


%
% echo "public class foo { public static void main(String[] arg)  
{ java.math.BigDecimal d = new java.math.BigDecimal(10);  
System.out.println(d); } }" > 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)
%
%
% javac -classpath . foo.java
%
% javap -c -classpath . foo
Compiled from "foo.java"
public class foo extends java.lang.Object{
public foo();
   Code:
    0:   aload_0
    1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
    4:   return

public static void main(java.lang.String[]);
   Code:
    0:   new     #2; //class java/math/BigDecimal
    3:   dup
    4:   bipush  10
    6:   invokespecial   #3; //Method java/math/BigDecimal."<init>":(I)V
    9:   astore_1
    10:  getstatic       #4; //Field java/lang/System.out:Ljava/io/ 
PrintStream;
    13:  aload_1
    14:  invokevirtual   #5; //Method java/io/PrintStream.println: 
(Ljava/lang/Object;)V
    17:  return

}

%
% /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/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 . foo.java
%
%
% /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/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();
   Code:
    0:   aload_0
    1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
    4:   return

public static void main(java.lang.String[]);
   Code:
    0:   new     #2; //class 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

}

%
% javac -source 1.4 -target 1.4 foo.java
%
% javap -c -classpath . foo
Compiled from "foo.java"
public class foo extends java.lang.Object{
public foo();
   Code:
    0:   aload_0
    1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
    4:   return

public static void main(java.lang.String[]);
   Code:
    0:   new     #2; //class java/math/BigDecimal
    3:   dup
    4:   bipush  10
    6:   invokespecial   #3; //Method java/math/BigDecimal."<init>":(I)V
    9:   astore_1
    10:  getstatic       #4; //Field java/lang/System.out:Ljava/io/ 
PrintStream;
    13:  aload_1
    14:  invokevirtual   #5; //Method java/io/PrintStream.println: 
(Ljava/lang/Object;)V
    17:  return

}

%

- ray


Mime
View raw message