Alternative fix for problem in the following email:

Subject:
        minor Rhino bug
   Date:
        Tue, 23 Jan 2001 13:14:51 -0800
   From:
        dave russo <d-russo@ti.com>
     To:
        nboyd@atg.com
    CC:
        d-russo@ti.com




Norris,

While using the new Rhino debugger (from the latest tip) I started to get "No
Context associated with current Thread" exceptions when expanding host objects
in the "Context:" debugger window.

In looking at the code, I discovered that NativeObject.toString seems to assume
that Context.getContext() may return null.  In fact, getContext() always returns
a non-null context or throws an exception.

I changed NativeObject.toString to never throw an exception (see below) and this
eliminated the problem I was seeing (of course).

It would be nice to incorporate this in a future Rhino tip or, if this change is
inappropriate, any guidance would be appreciated.  Thanks in advance.

I changed NativeObject.toString to:

    public String toString() {
        try {
            Context cx = Context.getContext();
            return jsFunction_toString(cx, this, null, null);
        }
        catch (Exception e) {
            return "[object " + getClassName() + "]";
        }
    }

from:

   public String toString() {
        Context cx = Context.getContext();
        if (cx != null)
            return jsFunction_toString(cx, this, null, null);
        else
            return "[object " + getClassName() + "]";
    }


git-svn-id: svn://10.0.0.236/trunk@85431 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
nboyd%atg.com
2001-01-24 15:16:37 +00:00
parent ad2414d680
commit 6aee3280f9
2 changed files with 2 additions and 2 deletions

View File

@@ -73,7 +73,7 @@ public class NativeObject extends ScriptableObject {
}
public String toString() {
Context cx = Context.getContext();
Context cx = Context.getCurrentContext();
if (cx != null)
return jsFunction_toString(cx, this, null, null);
else

View File

@@ -73,7 +73,7 @@ public class NativeObject extends ScriptableObject {
}
public String toString() {
Context cx = Context.getContext();
Context cx = Context.getCurrentContext();
if (cx != null)
return jsFunction_toString(cx, this, null, null);
else