]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/JavaMethod.java
Fixes to thread safety problems in SCL compiler
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / constants / JavaMethod.java
index a5efd23f604d5732b9ed1043dade1d2721a2fdf3..6d02784a23eedc083b28284779ca238019b4c84b 100644 (file)
@@ -55,7 +55,10 @@ public class JavaMethod extends FunctionValue {
    
     @Override
     public Type applyExact(MethodBuilder mb, Val[] parameters) {
-        if(returnTypeDesc == null) {
+        if(returnTypeDesc == null || parameterTypeDescs == null) {
+            // This method may be called from multiple threads at the same time when returnTypeDesc
+            // and parameterTypeDescs are uninitialized. Double initialization is OK in this case,
+            // but because there are two fields, we have to check that both are initialized. 
             JavaTypeTranslator tt = mb.getJavaTypeTranslator();
             returnTypeDesc = tt.toTypeDesc(returnType);
             parameterTypeDescs = JavaTypeTranslator.filterVoid(