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;
}
@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(