From a9c2ad1aaf64b069c5d46d9c3e59105511ae5117 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Thu, 28 Nov 2019 03:18:32 +0100 Subject: [PATCH] Fix crossgen2 interface static constructor handling (#370) Crossgen2 is not generating calls to static constructors of interfaces. This is caused by a missing part of a condition in the initClass JIT interface method. That condition is present in the runtime version of that method. This change fixes it. --- src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs index b23e1d355d7..93f6d7af51e 100644 --- a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs @@ -1597,10 +1597,11 @@ namespace Internal.JitInterface return CorInfoInitClassResult.CORINFO_INITCLASS_NOT_REQUIRED; } } - else if (!md.IsConstructor && !typeToInit.IsValueType) + else if (!md.IsConstructor && !typeToInit.IsValueType && !typeToInit.IsInterface) { // According to the spec, we should be able to do this optimization for both reference and valuetypes. // To maintain backward compatibility, we are doing it for reference types only. + // We don't do this for interfaces though, as those don't have instance constructors. // For instance methods of types with precise-initialization // semantics, we can assume that the .ctor triggerred the // type initialization. -- 2.34.1