On Fri, 18 Aug 2000, c.j.pulley wrote:

> Dear all,
>   I'd be very grateful for any problems with this one!
> 
>   I'm running LinuxPPC (kernel 2.2.14 with glibc2.1.3) on a PowerMac
> 8600/250. I've installed, and have working, a Blackdown port of
> JDK1.2.2.
> 
>   Compiling tclBlend (version 1.2.6 built on top of TCL/TK 8.3.2) and
> running it (via jtclsh) is fine - no compile warnings or errors! The
> demos all work fine. The tclblend tests fail, complaining about not
> being able to find 'tcl.lang.NativeTestExtension'.

Humm, that should not be. Could you try running "make test.build"
and then "make test" to see if that fixes it? It might be a makefile
problem.
 
>   However, I'm interested in testing Java code from a TCL script. As I
> understand things (I may be wrong here?), if we launch jtclsh from the
> directory containing our compiled Java code (assuming that '.' is
> locatable on the relevant environment variables), we can then create
> instances of classes within the compiled code via 'java::new <my
> class>'.

Yes, that is one of the ways TclBlend would work. The catch is that
if your Tcl process does a cd, then a . on the CLASSPATH will not
ref the same dir. This does not seem to be the case in your example
as the JVM can find the class.

>   Now, if this is so, then I've definitely got a problem since the JVM
> returns with the error:
> 
>     java.lang.IllegalAccessException <my class>
> 
> catching the Java exception object and printing out the trace stack
> yields the following:
> 
> java.lang.IllegalAccessException: <my class>
>  at java.lang.reflect.Constructor.newInstance(Native Method)
>  at tcl.lang.reflect.PkgInvoker.invokeConstructor(PkgInvoker.java:95)
>  at tcl.lang.JavaInvoke.call(JavaInvoke.java:252)
>  at tcl.lang.JavaInvoke.newInstance(JavaInvoke.java:69)
>  at tcl.lang.JavaNewCmd.cmdProc(JavaNewCmd.java:103)
>  at tcl.lang.Interp.callCommand(Interp.java:953)
>  at tcl.lang.Interp.eval(Native Method)
>  at tcl.lang.Interp.eval(Interp.java:794)
>  at tcl.lang.JavaTryCmd.cmdProc(JavaTryCmd.java:74)
>  at tcl.lang.Interp.callCommand(Interp.java:953)
> 
>   Attacking the problem the other way (ie. open the class file, load it
> into a string and then use java::defineclass etc. to manually load the
> classes bytecode into the JVM) results in the same error message.
> 
>   So, which is it: a faulty understanding of how to manipulate Java from
> TCL or do I have a bug in my build of tclBlend somewhere? Or is
> something else up?

I am willing to bet that the class you are trying to access is not
public. If the class is not public, then by default it can not
be accessed from outside the package.

If this is the problem, you do not have to make the class public.
There is also a way to add a class to your package to make the
internal classes visible to Tcl Blend.

Take a look at src/tcljava/tcl/lang/reflect/PkgInvoker.java
for an example of how you can add a "special" class to you
package so that Tcl Blend can access private parts.
The actual tests for this are in tests/tcljava/PkgInvoker.test.

I hope that helps
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