[Ikvm-commit] ikvm/runtime DynamicTypeWrapper.cs,1.255,1.256
Brought to you by:
jfrijters
|
From: Jeroen F. <jfr...@us...> - 2014-11-11 15:27:36
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15645 Modified Files: DynamicTypeWrapper.cs Log Message: Add some (level 4) warnings for abstract method errors that can be caused by bugs in default interface method handling. Index: DynamicTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DynamicTypeWrapper.cs,v retrieving revision 1.255 retrieving revision 1.256 diff -C2 -d -r1.255 -r1.256 *** DynamicTypeWrapper.cs 11 Nov 2014 15:03:18 -0000 1.255 --- DynamicTypeWrapper.cs 11 Nov 2014 15:27:34 -0000 1.256 *************** *** 2924,2930 **** if ((!wrapper.IsAbstract && mmw.BaseMethod.IsAbstract) || (!wrapper.IsInterface && mmw.Error != null)) { CodeEmitter ilgen = CodeEmitter.Create(mb); ! ilgen.EmitThrow("java.lang.AbstractMethodError", mmw.Error ?? (wrapper.Name + "." + methods[index].Name + methods[index].Signature)); ilgen.DoEmit(); } #if STATIC_COMPILER --- 2924,2932 ---- if ((!wrapper.IsAbstract && mmw.BaseMethod.IsAbstract) || (!wrapper.IsInterface && mmw.Error != null)) { + string message = mmw.Error ?? (wrapper.Name + "." + methods[index].Name + methods[index].Signature); CodeEmitter ilgen = CodeEmitter.Create(mb); ! ilgen.EmitThrow("java.lang.AbstractMethodError", message); ilgen.DoEmit(); + wrapper.EmitLevel4Warning(HardError.AbstractMethodError, message); } #if STATIC_COMPILER *************** *** 4224,4227 **** --- 4226,4230 ---- ilgen.EmitThrow("java.lang.AbstractMethodError", mw.DeclaringType.Name + "." + mw.Name + mw.Signature); ilgen.DoEmit(); + wrapper.EmitLevel4Warning(HardError.AbstractMethodError, mw.DeclaringType.Name + "." + mw.Name + mw.Signature); } } *************** *** 4277,4280 **** --- 4280,4284 ---- // the CLR doens't allow this, so we have to emit a method that throws an AbstractMethodError stub = true; + wrapper.EmitLevel4Warning(HardError.AbstractMethodError, classFile.Name + "." + m.Name + m.Signature); } else if (classFile.IsPublic && !classFile.IsFinal && !(m.IsPublic || m.IsProtected)) *************** *** 5621,5624 **** --- 5625,5629 ---- typeBuilder.DefineMethodOverride(mb, (MethodInfo)ifmethod.GetMethod()); wrapper.SetHasIncompleteInterfaceImplementation(); + wrapper.EmitLevel4Warning(HardError.AbstractMethodError, wrapper.Name + "." + ifmethod.Name + ifmethod.Signature); } } *************** *** 7144,7147 **** --- 7149,7170 ---- return impl.GetFieldRawTypeAnnotations(Array.IndexOf(GetFields(), fw)); } + + [Conditional("STATIC_COMPILER")] + internal void EmitLevel4Warning(HardError error, string message) + { + #if STATIC_COMPILER + if (GetClassLoader().WarningLevelHigh) + { + switch (error) + { + case HardError.AbstractMethodError: + GetClassLoader().IssueMessage(Message.EmittedAbstractMethodError, this.Name, message); + break; + default: + throw new InvalidOperationException(); + } + } + #endif + } } |