diff --git a/ikvmstub/ikvmstub.cs b/ikvmstub/ikvmstub.cs index 2d51be76..f74484ee 100644 --- a/ikvmstub/ikvmstub.cs +++ b/ikvmstub/ikvmstub.cs @@ -904,6 +904,7 @@ static class NetExp { if (mw.IsPublic || mw.IsProtected) { + mw.Link(); AddToExportListIfNeeded(mw.ReturnType); AddToExportListIfNeeded(mw.GetParameters()); } @@ -912,6 +913,7 @@ static class NetExp { if (fw.IsPublic || fw.IsProtected) { + fw.Link(); AddToExportListIfNeeded(fw.FieldTypeWrapper); } } diff --git a/runtime/DotNetTypeWrapper.cs b/runtime/DotNetTypeWrapper.cs index 3a82cc7d..58060873 100644 --- a/runtime/DotNetTypeWrapper.cs +++ b/runtime/DotNetTypeWrapper.cs @@ -2158,8 +2158,6 @@ namespace IKVM.Internal // methods, which don't really exist). if (ClassLoaderWrapper.IsRemappedType(type) && !type.IsSealed && !type.IsInterface) { - // Finish the type, to make sure the methods are populated - this.BaseTypeWrapper.Finish(); TypeWrapper baseTypeWrapper = this.BaseTypeWrapper; while (baseTypeWrapper != null) { @@ -2242,11 +2240,15 @@ namespace IKVM.Internal private MethodWrapper m; internal BaseFinalMethodWrapper(DotNetTypeWrapper tw, MethodWrapper m) - : base(tw, m.Name, m.Signature, m.GetMethod(), m.ReturnType, m.GetParameters(), (m.Modifiers & ~Modifiers.Abstract) | Modifiers.Final, MemberFlags.None) + : base(tw, m.Name, m.Signature, null, null, null, (m.Modifiers & ~Modifiers.Abstract) | Modifiers.Final, MemberFlags.None) { this.m = m; } + protected override void DoLinkMethod() + { + } + #if !STUB_GENERATOR internal override void EmitCall(CodeEmitter ilgen) { diff --git a/runtime/DynamicTypeWrapper.cs b/runtime/DynamicTypeWrapper.cs index 35b7d09c..0d434bfc 100644 --- a/runtime/DynamicTypeWrapper.cs +++ b/runtime/DynamicTypeWrapper.cs @@ -2297,7 +2297,7 @@ namespace IKVM.Internal ((TryGetClassFileVersion(baseMethod.DeclaringType, out majorVersion) && majorVersion < 51) // if TryGetClassFileVersion fails, we know that it is safe to call GetMethod() so we look at the actual method attributes here, // because access widing ensures that if the method had overridden the top level method it would also be public or protected - || (baseMethod.GetMethod().Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly)) + || (LinkAndGetMethod(baseMethod).Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly)) { // the method we're overriding is not public or protected, but there is a public or protected top level method, // this means that baseMethod is part of a class with a major version < 51, so we have to explicitly override the top level method as well @@ -2344,6 +2344,12 @@ namespace IKVM.Internal return null; } + private static MethodBase LinkAndGetMethod(MethodWrapper mw) + { + mw.Link(); + return mw.GetMethod(); + } + private static bool TryGetClassFileVersion(TypeWrapper tw, out int majorVersion) { DynamicTypeWrapper dtw = tw as DynamicTypeWrapper; diff --git a/runtime/MemberWrapper.cs b/runtime/MemberWrapper.cs index c963ac9e..ff388f22 100644 --- a/runtime/MemberWrapper.cs +++ b/runtime/MemberWrapper.cs @@ -510,6 +510,7 @@ namespace IKVM.Internal object method = reflectionMethod; if (method == null) { + Link(); ClassLoaderWrapper loader = this.DeclaringType.GetClassLoader(); TypeWrapper[] argTypes = GetParameters(); java.lang.Class[] parameterTypes = new java.lang.Class[argTypes.Length]; @@ -1331,6 +1332,7 @@ namespace IKVM.Internal java.lang.reflect.Field field = reflectionField; if (field == null) { + Link(); field = new java.lang.reflect.Field( this.DeclaringType.ClassObject, this.Name,