java array return value not array in tcl 
Author Message
 java array return value not array in tcl

Tcl Blend 1.1a1 Bug:  Generated by Scriptics' bug entry form at

        http://www.*-*-*.com/

Responses to this post are encouraged.

------

Submitted by:  George Rudolph
OperatingSystem:  Windows NT
OperatingSystemVersion:  4.0
Extensions:  tcl 8.0.4, tcl blend 1.1a1
CustomShell:  none.
Synopsis:  java array return value not array in tcl

ReproducibleScript:
1. I created a Java object ECCList, with a method getComponentIdList() that
returns an array of ID objects.
the method signature looks like this:

public corba.system.ID[] getComponentIdList()

2. I execute the following script, by starting wish from ny NT 4.0 start up menu, and sourcing the file containing the script:

package require java
set dispenser [java::new system.util.ECCList]
set eccList [$dispenser getComponentIdList]

ObservedBehavior:
No errors or exceptions were thrown by the script, but the results indicate that
the return value of eccList is an Obect, and I expect an array.
Is there a type conversion problem here?

%>puts "array exists [array exists eccList]"
 array exists 0

(I expect 1)

%>java::info class $eccList
corba.system.ID[]

(this is as expected.)

%> java::info methods $eccList
getClass hashCode {equals java.lang.Object} toString notify notifyAll {wait long} {wait long int} wait

(this suggests that the return value is an Object rather than an array.)

DesiredBehavior:
noted above



Sun, 03 Jun 2001 03:00:00 GMT  
 java array return value not array in tcl

Quote:

> Tcl Blend 1.1a1 Bug:  Generated by Scriptics' bug entry form at

>         http://www.scriptics.com/support/bugForm.html

> Responses to this post are encouraged.

> ------

> Submitted by:  George Rudolph
> OperatingSystem:  Windows NT
> OperatingSystemVersion:  4.0
> Extensions:  tcl 8.0.4, tcl blend 1.1a1
> CustomShell:  none.
> Synopsis:  java array return value not array in tcl

> ReproducibleScript:
> 1. I created a Java object ECCList, with a method getComponentIdList() that
> returns an array of ID objects.
> the method signature looks like this:

> public corba.system.ID[] getComponentIdList()

> 2. I execute the following script, by starting wish from ny NT 4.0 start up menu, and sourcing the file containing the script:

> package require java
> set dispenser [java::new system.util.ECCList]
> set eccList [$dispenser getComponentIdList]

> ObservedBehavior:
> No errors or exceptions were thrown by the script, but the results indicate that
> the return value of eccList is an Obect, and I expect an array.
> Is there a type conversion problem here?

> %>puts "array exists [array exists eccList]"
>  array exists 0

> (I expect 1)

> %>java::info class $eccList
> corba.system.ID[]

> (this is as expected.)

> %> java::info methods $eccList
> getClass hashCode {equals java.lang.Object} toString notify notifyAll {wait long} {wait long int} wait

> (this suggests that the return value is an Object rather than an array.)

> DesiredBehavior:
> noted above

Tcl cannot handle arrays like you want.

--
Paul Duffin

IBM UK Laboratories Ltd., Hursley Park nr. Winchester
Internal: 7-246880      International: +44 1962-816880



Mon, 04 Jun 2001 03:00:00 GMT  
 java array return value not array in tcl

Quote:

> Tcl Blend 1.1a1 Bug:  Generated by Scriptics' bug entry form at

>         http://www.scriptics.com/support/bugForm.html

> Responses to this post are encouraged.

> ------

> Submitted by:  George Rudolph
> OperatingSystem:  Windows NT
> OperatingSystemVersion:  4.0
> Extensions:  tcl 8.0.4, tcl blend 1.1a1
> CustomShell:  none.
> Synopsis:  java array return value not array in tcl

> ReproducibleScript:
> 1. I created a Java object ECCList, with a method getComponentIdList() that
> returns an array of ID objects.
> the method signature looks like this:

> public corba.system.ID[] getComponentIdList()

> 2. I execute the following script, by starting wish from ny NT 4.0 start up menu, and sourcing the file containing the script:

> package require java
> set dispenser [java::new system.util.ECCList]
> set eccList [$dispenser getComponentIdList]

> ObservedBehavior:
> No errors or exceptions were thrown by the script, but the results indicate that
> the return value of eccList is an Obect, and I expect an array.
> Is there a type conversion problem here?

> %>puts "array exists [array exists eccList]"
>  array exists 0

> (I expect 1)

> %>java::info class $eccList
> corba.system.ID[]

> (this is as expected.)

> %> java::info methods $eccList
> getClass hashCode {equals java.lang.Object} toString notify notifyAll {wait long} {wait long int} wait

> (this suggests that the return value is an Object rather than an array.)

> DesiredBehavior:
> noted above

Sorry but this is NOT a bug in tcl blend. A Java array is not the same
thing as a Tcl array. In tcl you can set an array like so.

% set arr(ind1) val1
% set arr(ind2) val2

% array names arr
{ind1 ind2}

In this case the indexes into the array are strings but in java
an array in made up of data members that are indexed by offset.

int[] arr = new int[3];
arr[0] = 0;
arr[1] = 1;
arr[2] = 2;

To access Java array elements you need to use methods on the Java
array object that take an integer index and not a string index.

% set jarr [java::call some_method_that_returns_a_java_array]

% $jarr get 0

This would return the array index 0 of the java array.

If you really wanted to index Java arrays like Tcl arrays
you could hack a script that names a Tcl array and then
used read and write traces on the array to track and update
the Tcl array elements so that they were the same as the
Java array elements. It might get ugly but it would be "cool"
from a hacking point of view.

I hope that helps
mo dejong
dejong at cs.umn.edu



Fri, 08 Jun 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Copying one array value into subsequent array values

2. Java Object Not Returned/Java Class Not Preserved

3. Returning Array Values?

4. Array#sort! returns nil when array empty

5. Return value that is an access to array element

6. Allocatable array as return value in function

7. return value as an allocatable array

8. return value maxloc of an empty array!?

9. Storing the return value in an array

10. Index Values of an Array inside a Cluster inside an Array

11. changing array values with the same array

12. Difficult problem to solve: Tcl 7.3 to Tcl 8.0p2 Array of Array Problem

 

 
Powered by phpBB® Forum Software