[jboss-jira] [JBoss JIRA] Commented: (JBRULES-537) BigDecimalFactory and BigIntegerFactory don't compile with java 1.5 source

Geoffrey De Smet (JIRA) jira-events at jboss.com
Thu Nov 2 03:17:41 EST 2006


    [ http://jira.jboss.com/jira/browse/JBRULES-537?page=comments#action_12346138 ] 
            
Geoffrey De Smet commented on JBRULES-537:
------------------------------------------

Such a use case would already fail according to the java 1.4 docs:
http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html#compareTo(java.lang.Object)
"Compares this BigInteger with the specified Object. If the Object is a BigInteger, this method behaves like compareTo(BigInteger). Otherwise, it throws a ClassCastException (as BigIntegers are comparable only to other BigIntegers)."

In java 1.5 the compareTo(Object) method has even been removed:
http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigInteger.html#compareTo(java.math.BigInteger)
BigInteger's superclass Number, doesn't have a compareTo method.

> BigDecimalFactory and BigIntegerFactory don't compile with java 1.5 source
> --------------------------------------------------------------------------
>
>                 Key: JBRULES-537
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-537
>             Project: JBoss Rules
>          Issue Type: Task
>      Security Level: Public(Everyone can see) 
>          Components: All
>    Affects Versions: 3.1-m1
>            Reporter: Geoffrey De Smet
>         Assigned To: Mark Proctor
>            Priority: Minor
>   Original Estimate: 10 minutes
>  Remaining Estimate: 10 minutes
>
> jbossrules\drools-core\src\main\java\org\drools\base\evaluators\BigIntegerFactory.java and BigIntegerFactory.java
> won't compile in 1.5 source because BigDecimal isn't a 100% backwards compatible from java 1.5 to 1.4,
> due to them generifying it.
> The fix is easy: just add some casts, the JVM does this at runtime anyway.
> For example:
>             final BigDecimal comp = (BigDecimal) extractor.getValue( object1 );
>             return comp.compareTo( object2.getValue() ) < 0;
> This code turns red in java source=1.5 in IntelliJ IDEA  (and in Eclipse I would expect the same?)
> Turn it into:
>             ...
>             return comp.compareTo( (BigDecimal) object2.getValue() ) < 0;
> I didn't create a patch as it's fast to fix: just copy-paste (BigDecimal) in the 2 classes's use of the compareTo method.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list