This is an interesting and slightly difficult problem becuase
what is apparently happening in the threaded environment is
that
for(var prop in foo)
will iterate over properties of the Java Object. Even though the
object is created in the script context as a simple object
{bar:"abc"}; This happens when we call $.ajax({}) because the
jquery ajax method calls $.extend wich iterates over the property
and throws
js: Java class "[B" has no public instance field or method named "nodeType".
Exception in thread "Thread-8" org.mozilla.javascript.EvaluatorException: Java class "[B" has no public instance field or m
at org.mozilla.javascript.tools.ToolErrorReporter.runtimeError(ToolErrorReporter.java:144)
at org.mozilla.javascript.Context.reportRuntimeError(Context.java:922)
at org.mozilla.javascript.Context.reportRuntimeError(Context.java:978)
at org.mozilla.javascript.Context.reportRuntimeError2(Context.java:948)
at org.mozilla.javascript.NativeJavaArray.get(NativeJavaArray.java:103)
at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1601)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1398)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1384)
at org.mozilla.javascript.gen.c3._c63(Unknown Source)
at org.mozilla.javascript.gen.c3.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.c3._c63(Unknown Source)
at org.mozilla.javascript.gen.c3.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen.c3._c230(Unknown Source)
at org.mozilla.javascript.gen.c3.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.c10._c2(Unknown Source)
at org.mozilla.javascript.gen.c10.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
at org.mozilla.javascript.gen.c2._c868(Unknown Source)
at org.mozilla.javascript.gen.c2.call(Unknown Source)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
at org.mozilla.javascript.gen.c2._c9(Unknown Source)
at org.mozilla.javascript.gen.c2.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
at org.mozilla.javascript.gen.c2.call(Unknown Source)
at org.mozilla.javascript.Context$1.run(Context.java:488)
at org.mozilla.javascript.Context.call(Context.java:499)
at org.mozilla.javascript.Context.call(Context.java:486)
at org.mozilla.javascript.JavaAdapter.callMethod(JavaAdapter.java:548)
at adapter1.run()
at java.lang.Thread.run(Unknown Source)
js: Java class "[B" has no public instance field or method named "nodeType".
make: *** [runtest] Error 3
thatcher@Flare /opt/apache-tomcat-6.0.16/webapps/env-js
Another interesting thing is that if you call
print(foo);
on the object before the iteration of properties it acts like a
normal javascript object.
This is a major blocker in several areas, not just jquery.