From 6aee3280f90b640a962e97de3fa5a171ca2a8e26 Mon Sep 17 00:00:00 2001 From: "nboyd%atg.com" Date: Wed, 24 Jan 2001 15:16:37 +0000 Subject: [PATCH] Alternative fix for problem in the following email: Subject: minor Rhino bug Date: Tue, 23 Jan 2001 13:14:51 -0800 From: dave russo 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 --- mozilla/js/rhino/org/mozilla/javascript/NativeObject.java | 2 +- mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mozilla/js/rhino/org/mozilla/javascript/NativeObject.java b/mozilla/js/rhino/org/mozilla/javascript/NativeObject.java index be659670608..ac40130085c 100644 --- a/mozilla/js/rhino/org/mozilla/javascript/NativeObject.java +++ b/mozilla/js/rhino/org/mozilla/javascript/NativeObject.java @@ -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 diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java b/mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java index be659670608..ac40130085c 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/NativeObject.java @@ -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