Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002345 [Quercus] major always 01-18-08 16:42 01-23-08 21:53
Reporter gorck View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 3.1.3
Summary 0002345: Cannot create a BigDecimal, seems to call wrong constructor
Description It appears BigDecimal is not working.

php script running under tomcat 5.5.25 with quercus jars.

I can run many php scripts and am even able to return a list of my own dtos from a Spring Managed Bean.

However for the life of me I can't get a BigDecimal instantiated via Quercus in a php script. I have even tried to use a my own custom BigDecimalFactory coded in java and it wont work.

I must use BigDecimal in my Dtos. I dont have a choice not to use BigDecimals

If this is not a bug will someone explain to me how to instantiate a java.math.BigDecimal in php.

Here is the simple php script I also tried the lines that are commented out.
import java.lang.Double;
import java.math.BigDecimal;

$double = Double::parseDouble(3.1);
var_dump($double); //works shows as a float

//none of the following work I get the same stack trace basically for all of them
$bigDecimal = new BigDecimal($double);
//$bigDecimal = new BigDecimal(3.1);
//$bigDecimal = new BigDecimal("3.1");
//$bigDecimal = BigDecimal::valueOf($double);

The stack trace I get is:

java.lang.NumberFormatException: For input string: "3.1"
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Long.parseLong(Unknown Source)
java.lang.Long.(Unknown Source)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)

It appears as though the somehow the incorrect BigDecimal constructor is being called. The one that takes a long instead of a double and Long.parseLong is throwing a NumberFormatException on 3.1.

Any help is much appreciated.
Additional Information
Attached Files  bigDecimal.php [^] (374 bytes) 01-18-08 16:42

- Relationships

- Notes
01-18-08 17:29

I also upgrade my jars to version 3.1.4 and the same behavior occurs.

Also I setup my own java factory. That takes in a double and returns a BigDecimal but when I do a var_dump on the php variable it says that its a int instead of a float or a BigDecimal.
public class ObjectFactory {

    public static BigDecimal getBigDecimal(double val)
        BigDecimal bd = new BigDecimal(val);
        return bd;


import java.lang.Double;
import java.math.BigDecimal;
import com.cms.php.ObjectFactory;

$double = Double::parseDouble(3.1);
var_dump($double); //works shows as a float

//ObjectFactory almost works but showing up as an int
//in the vardump instead of a float
//i.e var_dump($bigDecimal); = int(3) instead of float(3.1) or BigDecimal
$bigDecimal = ObjectFactory::getBigDecimal($double);

//none of the following work all throw stack trace
//$bigDecimal = new BigDecimal($double);
//$bigDecimal = new BigDecimal("3.1");
//$bigDecimal = new BigDecimal(3.1);
//$bigDecimal = BigDecimal::valueOf($double);


01-23-08 21:52


Fixed for the upcoming 3.1.5.

- Issue History
Date Modified Username Field Change
01-18-08 16:42 gorck New Issue
01-18-08 16:42 gorck File Added: bigDecimal.php
01-18-08 17:29 gorck Note Added: 0002660
01-23-08 12:04 nam Status new => assigned
01-23-08 12:04 nam Assigned To  => nam
01-23-08 21:52 nam Status assigned => closed
01-23-08 21:52 nam Note Added: 0002673
01-23-08 21:53 nam Resolution open => fixed
01-23-08 21:53 nam Fixed in Version  => 3.1.5

Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
32 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker