Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjfrijters <jfrijters>2014-06-16 17:07:11 +0400
committerjfrijters <jfrijters>2014-06-16 17:07:11 +0400
commita85b1bb66548926f2e2dcd14a844aa97cc342fda (patch)
tree658a8f71997c6aa4a81ad1901da2db38167b054f
parenteb783d1a9bddd9361997635fa65f2f78ab6e80e2 (diff)
Improved handling of incorrect bootstrap methods.
-rw-r--r--runtime/compiler.cs41
1 files changed, 33 insertions, 8 deletions
diff --git a/runtime/compiler.cs b/runtime/compiler.cs
index 2145a68b..2ec195c7 100644
--- a/runtime/compiler.cs
+++ b/runtime/compiler.cs
@@ -3026,17 +3026,42 @@ sealed class Compiler
}
ClassFile.ConstantPoolItemMethodHandle mh = compiler.classFile.GetConstantPoolConstantMethodHandle(bsm.BootstrapMethodIndex);
MethodWrapper mw = mh.Member as MethodWrapper;
- ClassFile.ConstantPoolItemMI cpiMI;
- if (mw == null && (cpiMI = mh.MemberConstantPoolItem as ClassFile.ConstantPoolItemMI) != null)
+ switch (mh.Kind)
{
- mw = new DynamicBinder().Get(compiler, mh.Kind, cpiMI, false);
+ case ClassFile.RefKind.invokeStatic:
+ if (mw != null && !mw.IsStatic)
+ goto default;
+ break;
+ case ClassFile.RefKind.newInvokeSpecial:
+ if (mw != null && !mw.IsConstructor)
+ goto default;
+ break;
+ default:
+ // to throw the right exception, we have to resolve the MH constant here
+ compiler.context.GetValue<MethodHandleConstant>(bsm.BootstrapMethodIndex).Emit(compiler, ilgen, bsm.BootstrapMethodIndex);
+ ilgen.Emit(OpCodes.Pop);
+ ilgen.EmitLdc_I4(1);
+ ilgen.Emit(OpCodes.Stloc, ok);
+ ilgen.EmitThrow("java.lang.invoke.WrongMethodTypeException");
+ return false;
}
- if (mw == null || (!mw.IsStatic && !mw.IsConstructor))
+ if (mw == null)
{
- ilgen.EmitLdc_I4(1);
- ilgen.Emit(OpCodes.Stloc, ok);
- ilgen.EmitThrow("java.lang.invoke.WrongMethodTypeException");
- return false;
+ // to throw the right exception (i.e. without wrapping it in a BootstrapMethodError), we have to resolve the MH constant here
+ compiler.context.GetValue<MethodHandleConstant>(bsm.BootstrapMethodIndex).Emit(compiler, ilgen, bsm.BootstrapMethodIndex);
+ ilgen.Emit(OpCodes.Pop);
+ ClassFile.ConstantPoolItemMI cpiMI;
+ if ((cpiMI = mh.MemberConstantPoolItem as ClassFile.ConstantPoolItemMI) != null)
+ {
+ mw = new DynamicBinder().Get(compiler, mh.Kind, cpiMI, false);
+ }
+ else
+ {
+ ilgen.EmitLdc_I4(1);
+ ilgen.Emit(OpCodes.Stloc, ok);
+ ilgen.EmitThrow("java.lang.invoke.WrongMethodTypeException");
+ return false;
+ }
}
TypeWrapper[] parameters = mw.GetParameters();
int extraArgs = parameters.Length - 3;