On Tue, 22 Aug 2000, Jiang Wu wrote:

> % set a [java::new String foo]
> java0x3
> % [java::getinterp] {setVar java.lang.String java.lang.String int} b $a 0
> java0x6
> % set c $a
> java0x3
> % set a
> java0x3
> % set b
> foo
> % set c
> java0x3
> 
> Can someone explain to me why 'b' and 'c' should be different?  Is the
> difference due to a feature, a bug, or a limitation?

Humm, there does seem to be something wrong here.
I would expect b to get set to "java0x3" (what a was set to).


Here is a really simple test case:

public class PrintString {
  public static String foo(String s) {
    return s;
  }
}


package require java

set a [java::new String foo]

java::call PrintString foo $a
> foo

It should not work like that. The method
should just return javax0x1.


I have also added a test case for this problem to
the HEAD branch. The patch is as follows.

Index: ChangeLog
===================================================================
RCS file: /home/cvs/external/tcljava/ChangeLog,v
retrieving revision 1.59
diff -u -r1.59 ChangeLog
--- ChangeLog   2000/08/21 04:48:11     1.59
+++ ChangeLog   2000/08/23 05:51:29
@@ -1,3 +1,10 @@
+2000-08-22  Mo DeJong  <[EMAIL PROTECTED]>
+
+       * src/tests/tcljava/tests/JavaTest.java:
+       * tests/tcljava/JavaInvoke.test: Add identity
+       test case for passing of a java.lang.String
+       ReflectObject to a Java method.
+
 2000-08-20  Christian Krone  <[EMAIL PROTECTED]>
 
        * src/jacl/tcl/lang/LreplaceCmd.java:
Index: src/tests/tcljava/tests/JavaTest.java
===================================================================
RCS file: /home/cvs/external/tcljava/src/tests/tcljava/tests/JavaTest.java,v
retrieving revision 1.2
diff -u -r1.2 JavaTest.java
--- JavaTest.java       1999/05/16 00:06:03     1.2
+++ JavaTest.java       2000/08/23 05:51:29
@@ -105,5 +105,12 @@
     public void disposeCmd() {
        istr = "disposed";
     }
+
+    // Returns the java.lang.String that was passed in
+    // used to test argument conversion.
+
+    public static String retStr(String str) {
+        return str;
+    }
 }
 
Index: tests/tcljava/JavaInvoke.test
===================================================================
RCS file: /home/cvs/external/tcljava/tests/tcljava/JavaInvoke.test,v
retrieving revision 1.4
diff -u -r1.4 JavaInvoke.test
--- JavaInvoke.test     1999/05/16 00:15:38     1.4
+++ JavaInvoke.test     2000/08/23 05:51:30
@@ -419,6 +419,12 @@
     jtest type [java::field $x iobj3]
 } tcl.lang.ReflectObject
 
+set str [java::new String hello]
+test invoke-9.16 {convertJavaObject: Check passing of java.lang.String} {
+    java::call tests.JavaTest retStr $str
+} $str
+unset str
+
 #
 # convertTclObject
 #


Of course, the problem still needs to be fixed, but now
that we have a test case it should be easy.

Mo DeJong
Red Hat Inc

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
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]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to