Enter context if need be; JavaAdapters may have callbacks on threads unassociated

with contexts.
This commit is contained in:
nboyd%atg.com 2002-03-03 16:16:07 +00:00
Родитель b6784de5d6
Коммит d608b0d326
1 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -70,9 +70,16 @@ public class JavaAdapter extends ScriptableObject {
}
public static Scriptable setAdapterProto(Scriptable obj, Object adapter) {
Scriptable res = ScriptRuntime.toObject(ScriptableObject.getTopLevelScope(obj),adapter);
res.setPrototype(obj);
return res;
// We could be called from a thread not associated with a Context
Context cx = Context.enter();
try {
Scriptable topLevel = ScriptableObject.getTopLevelScope(obj);
Scriptable res = ScriptRuntime.toObject(topLevel, adapter);
res.setPrototype(obj);
return res;
} finally {
cx.exit();
}
}
public static Object getAdapterSelf(Class adapterClass, Object adapter)