On Thu, 11 Mar 1999, schenck wrote:
Humm, this does look like a nasty problem. The reason for this is that
Tcl does not have a "long" type. In Tcl your objects can be an int a
double or a string. Of course, when you have a string that you want
to pass as a long it does not seem to make sense to convert the string
to an int and then cast it up to a long. In fact, this is exactly what
is going on behind under the covers. The problem located here
src/tcljava/tcl/lang/JavaInvoke.java in the convertTclObject() method.
(line 787 in Jacl or Tcl Blend 1.2.1)
} else if ((type == Long.TYPE) || (type == Long.class)) {
return new Long((long) TclInteger.get(interp, tclObj));
The the case of a long, the TclObject (could be a string int
or double at this point) is first converted to a Tcl int and then
it is cast up to a long.
So I guess this really comes down to a design question. Should use of
a long really be disallowed because of conversion to an int? I think
it might be possible to change the conversion systems so that long
types are always converted to a string and not to an integer object.
The upside is that you would then be able to pass a long value around
as long as you kept it in a string ref. If this change was made then
this code would work.
% set lm [java::field Long MAX_VALUE]
-1
currently it would return -1 which is the long value cast to an int.
With such a change it could return the long value as a string.
% set lm [java::field Long MAX_VALUE]
9223372036854775807
Currently, you could get the same effect by doing this
% set lm [[java::field -noconvert Long MAX_VALUE] toString]
9223372036854775807
But there is no way to do this when invoking a method.
So what does everyone this? Would this be a feature that a lot
of people find useful?
mo dejong
dejong at cs.umn.edu
> All,
>
> Here is a real problem I have encountered using TclBlend. I wanted to call a Java
>class that
> required a long as input (It was a license control class that had a long key as
>input.). However,
> there seems to be no way to cause an integer that is bigger than what can be
>represented in C to be
> converted. Here is the integer I needed to
> convert: -2398461842900206033. What I get is a message that states, "integer value
>too large to
> represent."
>
> To test this I constructed a simple Java example that had a method that expected a
>long and tried to
> call it like this:
>
> % java::call LongTest {test long} -2398461842900206033
> integer value too large to represent
>
> What I did to solve the problem was to create a simple Java wrapper class that
>accepted a string as
> input and converted it to a long and called the Java class I needed to call from
>inside the wrapper.
> Is there a better solution? If not, should there be?
>
> Thanks,
>
> Dan
>
> -------------------------------------------------
> Dan R. Schenck mailto:[EMAIL PROTECTED]
> Business Unit Manager http://www.posc.org
> POSC, Suite 275
> 10777 Westheimer
> Houston, TX 77042
>
> voice: +1 (713) 267-5166 fax: +1 (713) 784-9219
> -------------------------------------------------
>
>
> ----------------------------------------------------------------
> The TclJava mailing list is sponsored by WebNet Technologies.
> To subscribe: send mail to [EMAIL PROTECTED]
> with the word SUBSCRIBE as the subject.
> To unsubscribe: send mail to [EMAIL PROTECTED]
> with the word UNSUBSCRIBE as the subject.
> To send to the list, send email to '[EMAIL PROTECTED]'.
> A list archive is at: http://www.findmail.com/listsaver/tcldallas/
>
----------------------------------------------------------------
The TclJava mailing list is sponsored by WebNet Technologies.
To subscribe: send mail to [EMAIL PROTECTED]
with the word SUBSCRIBE as the subject.
To unsubscribe: send mail to [EMAIL PROTECTED]
with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'.
A list archive is at: http://www.findmail.com/listsaver/tcldallas/