[Ikvm-commit] ikvm/ikvmc AotTypeWrapper.cs,1.54,1.55
Brought to you by:
jfrijters
From: Jeroen F. <jfr...@us...> - 2010-02-19 08:07:46
|
Update of /cvsroot/ikvm/ikvm/ikvmc In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv17625/ikvmc Modified Files: AotTypeWrapper.cs Log Message: Fix for bug #2946842. Index: AotTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/ikvmc/AotTypeWrapper.cs,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** AotTypeWrapper.cs 28 Jan 2010 09:18:33 -0000 1.54 --- AotTypeWrapper.cs 19 Feb 2010 08:07:37 -0000 1.55 *************** *** 86,90 **** AttributeHelper.HideFromJava(typeBuilder); AttributeHelper.SetEditorBrowsableNever(typeBuilder); ! workaroundBaseClass = new WorkaroundBaseClass(typeBuilder, methods.ToArray()); List<MethodWrapper> constructors = new List<MethodWrapper>(); foreach (MethodWrapper mw in baseTypeWrapper.GetMethods()) --- 86,90 ---- AttributeHelper.HideFromJava(typeBuilder); AttributeHelper.SetEditorBrowsableNever(typeBuilder); ! workaroundBaseClass = new WorkaroundBaseClass(this, typeBuilder, methods.ToArray()); List<MethodWrapper> constructors = new List<MethodWrapper>(); foreach (MethodWrapper mw in baseTypeWrapper.GetMethods()) *************** *** 95,99 **** } } - Serialization.AddAutomagicSerializationToWorkaroundBaseClass(typeBuilder); replacedMethods = constructors.ToArray(); return typeBuilder; --- 95,98 ---- *************** *** 106,116 **** { base.Finish(); ! lock (this) { ! if (workaroundBaseClass != null) ! { ! workaroundBaseClass.Finish(); ! workaroundBaseClass = null; ! } } } --- 105,111 ---- { base.Finish(); ! if (workaroundBaseClass != null) { ! workaroundBaseClass.Finish(); } } *************** *** 118,140 **** private sealed class WorkaroundBaseClass { private readonly TypeBuilder typeBuilder; private readonly MethodWrapper[] methods; ! internal WorkaroundBaseClass(TypeBuilder typeBuilder, MethodWrapper[] methods) { this.typeBuilder = typeBuilder; this.methods = methods; } internal void Finish() { ! foreach (MethodWrapper mw in methods) { ! MethodBuilder mb = typeBuilder.DefineMethod(mw.Name, MethodAttributes.FamORAssem | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.CheckAccessOnOverride, mw.ReturnTypeForDefineMethod, mw.GetParametersForDefineMethod()); ! AttributeHelper.HideFromJava(mb); ! CodeEmitter ilgen = CodeEmitter.Create(mb); ! ilgen.EmitThrow("java.lang.AbstractMethodError"); } - typeBuilder.CreateType(); } } --- 113,150 ---- private sealed class WorkaroundBaseClass { + private readonly AotTypeWrapper wrapper; private readonly TypeBuilder typeBuilder; private readonly MethodWrapper[] methods; + private ConstructorInfo baseSerializationCtor; ! internal WorkaroundBaseClass(AotTypeWrapper wrapper, TypeBuilder typeBuilder, MethodWrapper[] methods) { + this.wrapper = wrapper; this.typeBuilder = typeBuilder; this.methods = methods; } + internal ConstructorInfo GetSerializationConstructor() + { + if (baseSerializationCtor == null) + { + baseSerializationCtor = Serialization.AddAutomagicSerializationToWorkaroundBaseClass(typeBuilder, wrapper.BaseTypeWrapper.GetSerializationConstructor()); + } + return baseSerializationCtor; + } + internal void Finish() { ! if (!typeBuilder.IsCreated()) { ! foreach (MethodWrapper mw in methods) ! { ! MethodBuilder mb = typeBuilder.DefineMethod(mw.Name, MethodAttributes.FamORAssem | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.CheckAccessOnOverride, mw.ReturnTypeForDefineMethod, mw.GetParametersForDefineMethod()); ! AttributeHelper.HideFromJava(mb); ! CodeEmitter ilgen = CodeEmitter.Create(mb); ! ilgen.EmitThrow("java.lang.AbstractMethodError"); ! } ! typeBuilder.CreateType(); } } } *************** *** 1213,1216 **** --- 1223,1255 ---- get { return true; } } + + internal MethodWrapper ReplaceMethodWrapper(MethodWrapper mw) + { + if (replacedMethods != null) + { + foreach (MethodWrapper r in replacedMethods) + { + if (mw.DeclaringType == r.DeclaringType + && mw.Name == r.Name + && mw.Signature == r.Signature) + { + return r; + } + } + } + return mw; + } + + internal override ConstructorInfo GetBaseSerializationConstructor() + { + if (workaroundBaseClass != null) + { + return workaroundBaseClass.GetSerializationConstructor(); + } + else + { + return base.GetBaseSerializationConstructor(); + } + } } } |