X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fconstants%2FJavaStaticMethod.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fconstants%2FJavaStaticMethod.java;h=a72b844bae99c89cea35cc1304678da62209df4f;hp=9e071e9cb9002c700d9c398fec92a3b4eafca8ff;hb=48e0bda8e45286b2bcc65b75e0364e2223ba3ec4;hpb=17d467c13f8efe0b5d851b0493ead9df124f84cf diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/JavaStaticMethod.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/JavaStaticMethod.java index 9e071e9cb..a72b844ba 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/JavaStaticMethod.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/JavaStaticMethod.java @@ -56,6 +56,8 @@ public class JavaStaticMethod extends FunctionValue { if(td.equals(TypeDesc.VOID)) throw new InternalCompilerError(); } + if( (returnTypeDesc == null) != (parameterTypeDescs == null) ) + throw new IllegalArgumentException("Either specify both returnTypeDesc and parameterTypeDescs or neither"); ClassBuilder.checkClassName(className); this.className = className; this.methodName = methodName; @@ -73,8 +75,11 @@ public class JavaStaticMethod extends FunctionValue { } @Override - public Type applyExact(MethodBuilder mb, Val[] parameters) { - if(returnTypeDesc == null) { + public Type applyExact(MethodBuilder mb, Val[] parameters) { + 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(