Re: [tcljava-dev] Re: [tcljava-user] Tcl/Java 1.3.0 release is online.
Brought to you by:
mdejong
From: Mo D. <md...@un...> - 2003-03-18 22:22:10
|
On Tue, 18 Mar 2003 14:48:59 -0700 Tom Poindexter <tpo...@ny...> wrote: > > > tcljava/JavaDefineClassCmd.test > > I'm also failing on this test, but it is dependent on the value of the > LANG environment variable: > > Running with: > LANG=en_US.iso885915 make test_jacl.exec > > fails on: > > ==== java::defineclass-2.1 loading a class FAILED > .. > ---- Result was: > 1 > ---- Result should have been: > 0 > ==== java::defineclass-2.1 FAILED ... > As I reported earlier, I believe it has to do with various .toString() > methods. How very odd. I would think that a toString() would not get called here since we are dealing with binary data. Doh! I just opened up the src for JavaDefineClassCmd.java and found this: public void cmdProc( Interp interp, // Current interpreter. TclObject argv[]) // Argument list. throws TclException // A standard Tcl exception. { byte[] classData; Class result; TclClassLoader tclClassLoader; if (argv.length != 2) { throw new TclNumArgsException(interp, 1, argv, "classbytes"); } classData = argv[1].toString().getBytes(); tclClassLoader = new TclClassLoader(interp, null); result = tclClassLoader.defineClass(null, classData); interp.setResult(ReflectObject.newInstance(interp, Class.class, result)); } The code is calling argv[1].toString() on the ByteArray and then calling getBytes() to convert that to an array of bytes. That is just wrong, but it is not clear to me how to make it right. The Jacl package defines the TclByteArray object, so that class can't be used in this code since it lives in the tcljava subdir. Perhaps the right approach is to create a TclByteArray object for TclBlend, that way the same TclByteArray API could be used in both Jacl and Tcl Blend code. Anyone feel like coding this up? I am a bit busy right now so I may not be able to get to this for some time. Mo |