DO NOT REPLY [Bug 47428] New: JSTL converts BigDecimal to Long
[email protected] Thu, 25 Jun 2009 09:06:01 -0700 (PDT)
| Newsgroups | gmane.comp.jakarta.taglibs.devel |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://issues.apache.org/bugzilla/show_bug.cgi?id=3D47428=0D
=0D
Summary: JSTL converts BigDecimal to Long=0D
Product: Taglibs=0D
Version: unspecified=0D
Platform: PC=0D
OS/Version: Windows Server 2003=0D
Status: NEW=0D
Severity: normal=0D
Priority: P2=0D
Component: Standard Taglib=0D
AssignedTo: [email protected]=0D
ReportedBy: [email protected]=0D
CC: [email protected]=0D
=0D
=0D
<c:if test=3D"{foo=3D=3D0}">=0D
do something=0D
</c:if>=0D
If foo is a BigDecimal,JSTL converts its type to Long,which means if foo is=
in=0D
the range [0,1), for example,0.01,it always return true! That is not correc=
t.=0D
=0D
I checked SUN's JSP2.0 specification,in the JSP.2.3.5.7 section. It says:=
=0D
A {=3D=3D,!=3D,eq,ne} B=0D
=E2=80=A2 If A=3D=3DB, apply operator=0D
=E2=80=A2 If A is null or B is null return false for =3D=3D or eq, true for=
!=3D or ne.=0D
=E2=80=A2 If A or B is BigDecimal, coerce both A and B to BigDecimal and th=
en:=0D
=01 If operator is =3D=3D or eq, return A.equals( B )=0D
=01 If operator is !=3D or ne, return !A.equals( B )=0D
=E2=80=A2 If A or B is Float or Double coerce both A and B to Double, apply=
operator=0D
=E2=80=A2 If A or B is BigInteger, coerce both A and B to BigInteger and th=
en:=0D
=01 If operator is =3D=3D or eq, return A.equals( B )=0D
=01 If operator is !=3D or ne, return !A.equals( B )=0D
=E2=80=A2 If A or B is Byte, Short, Character, Integer, or Long coerce both=
A and B to=0D
Long, apply operator=0D
=E2=80=A2 If A or B is Boolean coerce both A and B to Boolean, apply operat=
or=0D
=E2=80=A2 If A or B is String coerce both A and B to String, compare lexica=
lly=0D
=E2=80=A2 Otherwise if an error occurs while calling A.equals(B), error=0D
=E2=80=A2 Otherwise, apply operator to result of A.equals(B)=0D
=0D
According to the third rule,it seems like no problem.=0D
=0D
but when I checked apache's implementation of JSTL, in the class =0D
org.apache.taglibs.standard.lang.jstl.Coercions,I found apache didn't imple=
ment=0D
the third specification.so the preceding example will be processed accordin=
g to=0D
this rule:=0D
If A or B is Byte, Short, Character, Integer, or Long coerce both A and B t=
o=0D
Long, apply operator=0D
=0D
that is, it will convert BigDecimal to Long!=0D
=0D
so, is this a bug or something?=0D
=0D
looking forward to your answering.Thanks!=0D
=0D
-- =0D
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=3De=
mail=0D
------- You are receiving this mail because: -------=0D
You are the assignee for the bug.=