bedatadriven/renjin — pull request #30 by hlin09 (2013-10-25 15:21:04+00:00)
Title: Multithreads sharing Primitives

For the initialization error:

java.lang.RuntimeException: org.renjin.eval.EvalException: could not find function 'if'
at org.renjin.eval.SessionBuilder.build(SessionBuilder.java:77)
Caused by: org.renjin.eval.EvalException: could not find function 'if'
at org.renjin.eval.Context.evaluateFunction(Context.java:269)
at org.renjin.eval.Context.evaluateCall(Context.java:260)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:46)
at org.renjin.eval.Context.evaluateCall(Context.java:261)
at org.renjin.eval.Context.evaluate(Context.java:193)
at org.renjin.eval.Context.evaluate(Context.java:161)

It seems that Primitive.INSTANCE is a uniquely shared (singleton) object. So I put a synchronization on the object whenever the code tries updating the HashMaps like "builtins" and "internals", and the error does not come any more.