I'm using org.mozilla.javascript.Context.compileString() to compile and cache a Javascript source. The returned InterpretedFunction instance looks immutable, I'm exec()'ing it in multiple scopes and threads, and everything seems to work fine.
However, compileString() needs the current context, which is usually thread-local, and I was not able to find any information on whether it's safe to execute InterpretedFunction in a different context than it was compiled in.