getResourceAsStream causes misleading errorInfo wrong # args: should be either: socket ?-myaddr addr

Skip to first unread message

Brian Brooks

Feb 22, 2016, 2:20:16 PM2/22/16
to jtcl-project
First, thank you for JTCL.  We're migrating a TCL-based app from C to Java and would really be in a bind without JTCL.

While getting acquainted with JTCL, I just spent a few hours debugging a misleading error message

java.lang.Exception: wrong # args: should be either:
socket ?-myaddr addr? ?-myport myport? ?-async? host port
socket -server command ?-myaddr addr? port
    while executing
while running tcltest

in which the root cause is really (sort of a "classpath" problem caused by testing in an bndtools OSGi test environment)

tcl.lang.TclException: cannot read resource "/tcl/lang/cmd/append.test"

Such a misleading error message could be avoided if when the getResourceAsStream fails in tcl.lang.Interp#evalResource(), evalResource() overwrote the errorInfo with something like

  Interp#setVar("errorInfo", "tcl.lang.TclException: cannot read resource \"/tcl/lang/cmd/append.test\"", TCL.GLOBAL_ONLY);

Would such a JTCL code change make sense?  If so, I can put together a Pull Request with the change.

Brian Brooks

Dan Bodoh

Feb 28, 2016, 9:08:40 AM2/28/16
to Brian Brooks, jtcl-project
I haven't done anything on JTCL recently, but your suggestion sounds reasonable.  You'll want to make sure that the tests pass, which look for error messages.  I'd guess this particular type of error is not part of the test suite.

Dan Bodoh

You received this message because you are subscribed to the Google Groups "jtcl-project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit
Reply all
Reply to author
0 new messages