Issue 3686: How can org.omg.CORBA.portable.InputStream.read_fixed possibly work? (java-rtf) Source: SAP SE (Mr. Evan Ireland, eireland(at)sybase.com) Nature: Uncategorized Issue Severity: Summary: If you look at the signature of org.omg.CORBA.portable.InputStream.read_fixed, you will see that it does not accept parameters for the fixed digits and scale. Since the GIOP CDR encoding for fixed-point decimals does not include meta-data on the wire (e.g. the scale is not explicit in the wire-encoding), how can the Java portable InputStream's read_fixed method reliably determine the scale of the value being read? Maybe I'm missing something, or maybe the mapping spec is just plain broken. Can someone please shed some light on this. Resolution: Close, Duplicate of 3668 Revised Text: Actions taken: June 9, 2000: received issue February 27, 2001: closed issue Discussion: End of Annotations:===== Date: Fri, 09 Jun 2000 11:45:23 +1200 From: Evan Ireland Organization: Sybase, Inc. X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.object.corba CC: issues@omg.org Subject: How can org.omg.CORBA.portable.InputStream.read_fixed possibly work? Is the spec broken? Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-UIDL: X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: eireland@sybase.com Cc: Java RTF , brose@inf.fu-berlin.de Subject: Java RTF Issue 3686: How can org.omg.CORBA.portable.InputStream.read_fixed Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-UIDL: 2P%e9iXKe9$EIe9dYB!! Evan, Gerald Brose posted the following response in the comp.object.corba newsgroup: > The read_fixed() method cannot determine this, but it does not need > to. It just returns a java.math.BigDecimal to the caller, which in > most cases is the Helper. The helper class for a fixed point type > knows the scale and can call, e.g., movePointLeft(scale) on the > BigDecimal. In fact, anyone who has access to the fixed type's > TypeCode can do this. Does this answer satisfy your issue? As a reminder, the issue was > If you look at the signature of > org.omg.CORBA.portable.InputStream.read_fixed, > you will see that it does not > accept parameters for the fixed digits and scale. > Since the GIOP CDR encoding for fixed-point decimals does not include > meta-data on the wire (e.g. the scale is not explicit in the > wire-encoding), how can the Java portable InputStream's > read_fixed method reliably determine the scale of the value > being read? Maybe I'm missing something, or maybe the mapping > spec is just plain broken. Can someone please shed some light on this. Thanks, Mary Leland Hewlett Packard mleland@fpk.hp.com Chair, OMG IDL to Java RTF Date: Thu, 05 Oct 2000 11:08:00 -0700 From: Stefan Bauer X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Mary Leland CC: eireland@sybase.com, Java RTF , brose@inf.fu-berlin.de Subject: Re: Java RTF Issue 3686: How can org.omg.CORBA.portable.InputStream.read_fixed References: <39DCA1CF.7F266548@fpk.hp.com> Content-Type: multipart/mixed; boundary="------------6127CA6432C4141C171291A1" X-UIDL: T+od95n=e9SL&e9H-,!! Mary, I don't think this satisfies the issue. I raised it in March after a discussion with Jonathan Biggar and we agreed that the signature of the read_fixed and write_fixed methods needs to be changed. See attachment. Stefan Mary Leland wrote: > Evan, > > Gerald Brose posted the following response in the comp.object.corba > newsgroup: > > The read_fixed() method cannot determine this, but it does not >need > > to. It just returns a java.math.BigDecimal to the caller, which in > > most cases is the Helper. The helper class for a fixed point type > > knows the scale and can call, e.g., movePointLeft(scale) on the > > BigDecimal. In fact, anyone who has access to the fixed type's > > TypeCode can do this. > > Does this answer satisfy your issue? > As a reminder, the issue was > > If you look at the signature of > >org.omg.CORBA.portable.InputStream.read_fixed, > > you will see that it does not > > accept parameters for the fixed digits and scale. > > Since the GIOP CDR encoding for fixed-point decimals does not >include > > meta-data on the wire (e.g. the scale is not explicit in the > > wire-encoding), how can the Java portable InputStream's > > read_fixed method reliably determine the scale of the value > > being read? Maybe I'm missing something, or maybe the mapping > > spec is just plain broken. Can someone please shed some light on >this. > > Thanks, > Mary Leland > Hewlett Packard > mleland@fpk.hp.com > Chair, OMG IDL to Java RTF Received: from engmail1.Eng.Sun.COM (engmail1 [129.146.1.13]) by shorter.eng.sun.com (8.9.3+Sun/8.9.3/ENSMAIL,v1.7) with >ESMTP id QAA16105; Wed, 22 Mar 2000 16:23:25 -0800 (PST) Received: from shorter.eng.sun.com (shorter.Eng.Sun.COM >[129.144.252.35]) by engmail1.Eng.Sun.COM (8.9.1b+Sun/8.9.1/ENSMAIL,v1.6) with >ESMTP id QAA08352; Wed, 22 Mar 2000 16:23:24 -0800 (PST) Received: from Eng.sun.com (guanica-pc [129.144.251.121]) by shorter.eng.sun.com (8.9.3+Sun/8.9.3/ENSMAIL,v1.7) with >ESMTP id QAA16097; Wed, 22 Mar 2000 16:23:23 -0800 (PST) Message-ID: <38D96437.59E49F19@Eng.sun.com> Date: Wed, 22 Mar 2000 16:24:23 -0800 From: Stefan Bauer X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: java-rtf@OMG.ORG CC: Jonathan Biggar , Peter Walker , rip-dev > Subject: Re: Marshaling fixed-point decimal types References: <38C7F333.D671C8EF@Eng.sun.com> ><38D14A58.438911E5@Eng.sun.com> ><200003170109.RAA17882@corvette.floorboard.com> ><38D65C20.8E8E8B44@Eng.sun.com> ><200003202014.MAA23742@corvette.floorboard.com> ><38D8081D.CF1197B1@Eng.sun.com> <38D864F4.C38468DB@floorboard.com> ><38D878E6.168FDF33@Eng.sun.com> <38D90609.95274CFE@floorboard.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit As Jon indicates below this turns out to be a java-rtf issue. The signature of the methods void org.omg.CORBA.portable.OutputStream.write_fixed(java.math.BigDecimal) java.math.BigDecimal org.omg.CORBA.portable.InputStream.read_fixed() need to be changed to void org.omg.CORBA.portable.OutputStream.write_fixed(java.math.BigDecimal, short, short) java.math.BigDecimal org.omg.CORBA.portable.InputStream.read_fixed(short, short) where the short parameters indicate the digits and scale of the fixed-point decimal. This is because the information of the maximum number of digits and scale is lost when the IDL fixed gets mapped to the BigDecimal for write_fixed. On the other end, when the fixed is read off the stream, the BigDecimal can't be reconstructed to the original scale without explicitly passing in the scale. For fixed contained in an Any this information can be gathered from the associated TypeCode. Stefan Bauer CORBA Technologies Sun Microsystems, Inc. > Jonathan Biggar wrote: > > > > Stefan Bauer wrote: > > > > > Looking at formal/99-10-07, 15.3.2.8 which describes marshaling of fixed > > > > > types I ran into a question. The section doesn't mention how to indicate > > > > > the scale of the written decimal. > > > > > > > > > > My understanding is that the TypeCode of kind fixed, which gets written > > > > > before the value, indicates the maximum number of digits and the maximum > > > > > scale, not what is currently contained in the number. To describe the > > > > > current scale I would expect that a decimal point gets written to the > > > > > stream, just like the decimals into the half-octets as described in > > > > > 15.3.2.8. > > > > > > > > The TypeCode is only written to the stream if the fixed is contained in > > > > an any. Otherwise, both sender & receiver implicitly know the type. > > > > > > So if I have the following scenario > > > > > > Sender has a java.math.BigDecimal with a certain scale. > > > Sender writes it to an OutputStream using write_fixed(BigDecimal) (the > > > scale information is lost) > > > Receiver reads a BigDecimal from InputStream.read_fixed() > > > > > > you are saying that the receiver, implicitly knowing the type, has to > > > apply setScale() to the BigDecimal in order to restore the original > > > value? > > > > > > Unfortunately the scale and digits information of the IDL fixed is lost > > > when you map it to a BigDecimal. The OutputStream.write_fixed() > > > implementation has no knowledge about how to pad it with zeros as you > > > describe for the case of Anys below. > > > > This is a defect in the Java InputStream & OutputStream specification. > > The GIOP encoding for fixed is well specified as packed BCD with the > > number of digits as specified by the fixed type as declared by the IDL. > > The Java InputStream & OutputStream classes need to have a digits and > > scale parameter added to read_fixed and write_fixed. > > > > -- > > Jon Biggar > > Floorboard Software > > jon@floorboard.com > > jon@biggar.org Date: Fri, 06 Oct 2000 10:06:44 +1300 From: Evan Ireland Organization: Sybase, Inc. X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 To: Mary Leland CC: Java RTF , brose@inf.fu-berlin.de, sstrobel@sybase.com Subject: Re: Java RTF Issue 3686: How can org.omg.CORBA.portable.InputStream.read_fixed References: <39DCA1CF.7F266548@fpk.hp.com> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-UIDL: ]k/e9l2Vd9\:pd9$]kd9 Mary Leland wrote: > > Evan, > > Gerald Brose posted the following response in the comp.object.corba > newsgroup: > > The read_fixed() method cannot determine this, but it does not need > > to. It just returns a java.math.BigDecimal to the caller, which in > > most cases is the Helper. The helper class for a fixed point type > > knows the scale and can call, e.g., movePointLeft(scale) on the > > BigDecimal. In fact, anyone who has access to the fixed type's > > TypeCode can do this. > > Does this answer satisfy your issue? I'm not sure that it does. Let's consider org.omg.CORBA.portable.OutputStream.write_fixed instead. Note that a java.math.BigDecimal does not have a 'digits' - it only has a 'scale'. Let's say you have a fixed<20,2> and your Helper class calls output.write_fixed(value), where 'value' is a scale-adjusted equivalent of the value "1.23". How is write_fixed supposed to know how many leading zeroes are required in the CDR transfer syntax? The Helper has no way to communicate this to the write_fixed method. > As a reminder, the issue was > > If you look at the signature of > org.omg.CORBA.portable.InputStream.read_fixed, > > you will see that it does not > > accept parameters for the fixed digits and scale. > > Since the GIOP CDR encoding for fixed-point decimals does not include > > meta-data on the wire (e.g. the scale is not explicit in the > > wire-encoding), how can the Java portable InputStream's > > read_fixed method reliably determine the scale of the value > > being read? Maybe I'm missing something, or maybe the mapping > > spec is just plain broken. Can someone please shed some light on this. > > Thanks, > Mary Leland > Hewlett Packard > mleland@fpk.hp.com > Chair, OMG IDL to Java RTF -- ________________________________________________________________________________ Evan Ireland Sybase EAServer Engineering eireland@sybase.com Wellington, New Zealand +64 4 934-5856