IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ByteCodeHelper.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2015 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System;
25using System.Diagnostics;
26using System.Runtime.InteropServices;
27using System.Threading;
29
30using IKVM.Attributes;
31using IKVM.ByteCode;
32
33#if IMPORTER || EXPORTER
34using IKVM.Reflection;
37
38using Type = IKVM.Reflection.Type;
39#else
40using System.Reflection;
41#endif
42
43#if EXPORTER == false
44
47
48#endif
49
50namespace IKVM.Runtime
51{
52
53 public static class ByteCodeHelper
54 {
55
56#if FIRST_PASS == false && EXPORTER == FALSE
57
58 static ObjectAccessor objectAccessor;
59
60 static ObjectAccessor ObjectAccessor => JVM.Internal.BaseAccessors.Get(ref objectAccessor);
61
62#endif
63
64#if EXPORTER == false
65
66 [DebuggerStepThrough]
67 public static object multianewarray(RuntimeTypeHandle typeHandle, int[] lengths)
68 {
69 for (int i = 0; i < lengths.Length; i++)
70 {
71 if (lengths[i] < 0)
72 {
73#if !FIRST_PASS
74 throw new global::java.lang.NegativeArraySizeException();
75#endif
76 }
77 }
78
79 return MultianewarrayHelper(Type.GetTypeFromHandle(typeHandle).GetElementType(), lengths, 0);
80 }
81
82
83 static object MultianewarrayHelper(Type elemType, int[] lengths, int index)
84 {
85 var o = Array.CreateInstance(elemType, lengths[index++]);
86 if (index < lengths.Length)
87 {
88 elemType = elemType.GetElementType();
89 var a = (object[])o;
90 for (int i = 0; i < a.Length; i++)
91 a[i] = MultianewarrayHelper(elemType, lengths, index);
92 }
93
94 return o;
95 }
96
97 [DebuggerStepThrough]
98 public static object multianewarray_ghost(RuntimeTypeHandle typeHandle, int[] lengths)
99 {
100 var type = Type.GetTypeFromHandle(typeHandle);
101 int rank = 0;
102 while (ReflectUtil.IsVector(type))
103 {
104 rank++;
105 type = type.GetElementType();
106 }
107
108 var obj = multianewarray(RuntimeArrayJavaType.MakeArrayType(typeof(object), rank).TypeHandle, lengths);
109 GhostTag.SetTag(obj, typeHandle);
110 return obj;
111 }
112
113 [DebuggerStepThrough]
114 public static T[] anewarray_ghost<T>(int length, RuntimeTypeHandle typeHandle)
115 {
116 var obj = new T[length];
117 GhostTag.SetTag(obj, typeHandle);
118 return obj;
119 }
120
121 [DebuggerStepThrough]
122 public static object DynamicMultianewarray(int[] lengths, global::java.lang.Class clazz)
123 {
124#if FIRST_PASS
125 throw new NotImplementedException();
126#else
127 Profiler.Count("DynamicMultianewarray");
128
129 var wrapper = RuntimeJavaType.FromClass(clazz);
130 var obj = multianewarray(wrapper.TypeAsArrayType.TypeHandle, lengths);
131 if (wrapper.IsGhostArray)
132 GhostTag.SetTag(obj, wrapper);
133
134 return obj;
135#endif
136 }
137
138 [DebuggerStepThrough]
139 public static object DynamicNewarray(int length, global::java.lang.Class clazz)
140 {
141#if FIRST_PASS
142 throw new NotImplementedException();
143#else
144 Profiler.Count("DynamicNewarray");
145 if (length < 0)
146 throw new global::java.lang.NegativeArraySizeException();
147
148 var wrapper = RuntimeJavaType.FromClass(clazz);
149 var obj = Array.CreateInstance(wrapper.TypeAsArrayType, length);
150 if (wrapper.IsGhost || wrapper.IsGhostArray)
151 GhostTag.SetTag(obj, wrapper.MakeArrayType(1));
152
153 return obj;
154#endif
155 }
156
157#endif
158
159 [DebuggerStepThrough]
160 public static void DynamicAastore(object arrayref, int index, object val)
161 {
162#if FIRST_PASS
163 throw new NotImplementedException();
164#else
165 Profiler.Count("DynamicAastore");
166 ((Array)arrayref).SetValue(val, index);
167#endif
168 }
169
170 [DebuggerStepThrough]
171 public static object DynamicAaload(object arrayref, int index)
172 {
173#if FIRST_PASS
174 throw new NotImplementedException();
175#else
176 Profiler.Count("DynamicAaload");
177 return ((Array)arrayref).GetValue(index);
178#endif
179 }
180
181#if EXPORTER == false
182
183 // the sole purpose of this method is to check whether the clazz can be instantiated (but not to actually do it)
184 [DebuggerStepThrough]
185 public static void DynamicNewCheckOnly(global::java.lang.Class clazz)
186 {
187#if FIRST_PASS
188 throw new NotImplementedException();
189#else
190 Profiler.Count("DynamicNewCheckOnly");
191 var wrapper = RuntimeJavaType.FromClass(clazz);
192 if (wrapper.IsAbstract)
193 throw new global::java.lang.InstantiationError(wrapper.Name);
194
195 wrapper.RunClassInit();
196#endif
197 }
198
199 static RuntimeJavaType LoadTypeWrapper(string clazz, ikvm.@internal.CallerID callerId)
200 {
201#if FIRST_PASS
202 throw new NotImplementedException();
203#else
204 try
205 {
206 var context = RuntimeJavaType.FromClass(callerId.getCallerClass());
207 var wrapper = RuntimeClassLoader.FromCallerID(callerId).LoadClassByName(clazz);
208 var loader = callerId.getCallerClassLoader();
209 if (loader != null)
210 {
211 ClassLoaderAccessor cla = null;
212 JVM.Internal.BaseAccessors.Get(ref cla);
213 cla.InvokeCheckPackageAccess(loader, wrapper.ClassObject, callerId.getCallerClass().pd);
214 }
215
216 if (!wrapper.IsAccessibleFrom(context))
217 throw new global::java.lang.IllegalAccessError("Try to access class " + wrapper.Name + " from class " + context.Name);
218
219 wrapper.Finish();
220 return wrapper;
221 }
223 {
224 throw e.ToJava();
225 }
226#endif
227 }
228
229 [DebuggerStepThrough]
230 public static global::java.lang.Class DynamicClassLiteral(string clazz, ikvm.@internal.CallerID callerId)
231 {
232#if FIRST_PASS
233 throw new NotImplementedException();
234#else
235 Profiler.Count("DynamicClassLiteral");
236 return LoadTypeWrapper(clazz, callerId).ClassObject;
237#endif
238 }
239
240 [DebuggerStepThrough]
241 public static object DynamicCast(object obj, global::java.lang.Class clazz)
242 {
243#if FIRST_PASS
244 throw new NotImplementedException();
245#else
246 Debug.Assert(obj != null);
247 Profiler.Count("DynamicCast");
248 if (!DynamicInstanceOf(obj, clazz))
249 throw new global::java.lang.ClassCastException(IKVM.Java.Externs.ikvm.runtime.Util.GetTypeWrapperFromObject(JVM.Context, obj).Name + " cannot be cast to " + clazz.getName());
250
251 return obj;
252#endif
253 }
254
255 [DebuggerStepThrough]
256 public static bool DynamicInstanceOf(object obj, global::java.lang.Class clazz)
257 {
258#if FIRST_PASS
259 throw new NotImplementedException();
260#else
261 Debug.Assert(obj != null);
262 Profiler.Count("DynamicInstanceOf");
263
264 var tw = RuntimeJavaType.FromClass(clazz);
265 // we have to mimick the bytecode behavior, which allows these .NET-isms to show through
266 if (tw.TypeAsBaseType == typeof(Array))
267 return obj is Array;
268
269 if (tw.TypeAsBaseType == typeof(string))
270 return obj is string;
271
272 if (tw.TypeAsBaseType == typeof(IComparable))
273 return obj is IComparable;
274
275 return tw.IsInstance(obj);
276#endif
277 }
278
279 [DebuggerStepThrough]
280 public static global::java.lang.invoke.MethodType DynamicLoadMethodType(ref global::java.lang.invoke.MethodType cache, string sig, ikvm.@internal.CallerID callerID)
281 {
282 if (cache == null)
283 DynamicLoadMethodTypeImpl(ref cache, sig, callerID);
284
285 return cache;
286 }
287
288 private static void DynamicLoadMethodTypeImpl(ref global::java.lang.invoke.MethodType cache, string sig, global::ikvm.@internal.CallerID callerID)
289 {
290#if FIRST_PASS
291 throw new NotImplementedException();
292#else
293 try
294 {
295 var loader = RuntimeClassLoader.FromCallerID(callerID);
296 var args = loader.ArgJavaTypeListFromSig(sig, LoadMode.LoadOrThrow);
297 var ptypes = new global::java.lang.Class[args.Length];
298 for (int i = 0; i < ptypes.Length; i++)
299 ptypes[i] = args[i].ClassObject;
300
301 Interlocked.CompareExchange(ref cache, global::java.lang.invoke.MethodType.methodType(loader.RetTypeWrapperFromSig(sig, LoadMode.LoadOrThrow).ClassObject, ptypes), null);
302 }
304 {
305 throw e.ToJava();
306 }
307#endif
308 }
309
310 [DebuggerStepThrough]
311 public static global::java.lang.invoke.MethodHandle DynamicLoadMethodHandle(ref global::java.lang.invoke.MethodHandle cache, int kind, string clazz, string name, string sig, ikvm.@internal.CallerID callerID)
312 {
313 if (cache == null)
314 Interlocked.CompareExchange(ref cache, DynamicLoadMethodHandleImpl(kind, clazz, name, sig, callerID), null);
315
316 return cache;
317 }
318
319 static global::java.lang.invoke.MethodHandle DynamicLoadMethodHandleImpl(int kind, string clazz, string name, string sig, ikvm.@internal.CallerID callerID)
320 {
321#if FIRST_PASS
322 throw new NotImplementedException();
323#else
324 var refc = LoadTypeWrapper(clazz, callerID).ClassObject;
325
326 try
327 {
328 switch ((MethodHandleKind)kind)
329 {
330 case MethodHandleKind.GetStatic:
331 case MethodHandleKind.PutStatic:
332 case MethodHandleKind.GetField:
333 case MethodHandleKind.PutField:
334 global::java.lang.Class type = RuntimeClassLoader.FromCallerID(callerID).FieldTypeWrapperFromSig(sig, LoadMode.LoadOrThrow).ClassObject;
335 return global::java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(callerID.getCallerClass(), kind, refc, name, type);
336 default:
337 global::java.lang.invoke.MethodType mt = null;
338 DynamicLoadMethodType(ref mt, sig, callerID);
339 // HACK linkMethodHandleConstant is broken for MethodHandle.invoke[Exact]
340 if (kind == (int)MethodHandleKind.InvokeVirtual && refc == JVM.Context.JavaBase.TypeOfJavaLangInvokeMethodHandle.ClassObject)
341 {
342 switch (name)
343 {
344 case "invokeExact":
345 return global::java.lang.invoke.MethodHandles.exactInvoker(mt);
346 case "invoke":
347 return global::java.lang.invoke.MethodHandles.invoker(mt);
348 }
349 }
350
351 return global::java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(callerID.getCallerClass(), kind, refc, name, mt);
352 }
353 }
355 {
356 throw x.ToJava();
357 }
358#endif
359 }
360
361 [DebuggerStepThrough]
362 public static T DynamicBinderMemberLookup<T>(int kind, string clazz, string name, string sig, ikvm.@internal.CallerID callerID)
363 where T : class, Delegate
364 {
365#if FIRST_PASS
366 throw new NotImplementedException();
367#else
368 try
369 {
370 var mh = DynamicLoadMethodHandleImpl(kind, clazz, name, sig, callerID);
371 return GetDelegateForInvokeExact<T>(global::java.lang.invoke.MethodHandles.explicitCastArguments(mh, JVM.Context.MethodHandleUtil.GetDelegateMethodType(typeof(T))));
372 }
373 catch (global::java.lang.IncompatibleClassChangeError x)
374 {
375 if (x.getCause() is global::java.lang.NoSuchMethodException)
376 {
377 throw new global::java.lang.NoSuchMethodError(x.getCause().Message);
378 }
379 if (x.getCause() is global::java.lang.NoSuchFieldException)
380 {
381 throw new global::java.lang.NoSuchFieldError(x.getCause().Message);
382 }
383 if (x.getCause() is global::java.lang.IllegalAccessException)
384 {
385 throw new global::java.lang.IllegalAccessError(x.getCause().Message);
386 }
387 throw;
388 }
389#endif
390 }
391
392 [DebuggerStepThrough]
393 public static Delegate DynamicCreateDelegate(object obj, Type delegateType, string name, string sig)
394 {
395#if FIRST_PASS
396 throw new NotImplementedException();
397#else
398 RuntimeJavaType tw = RuntimeJavaType.FromClass(global::ikvm.runtime.Util.getClassFromObject(obj));
399 RuntimeJavaMethod mw = tw.GetMethod(name, sig, true);
400 if (mw == null || mw.IsStatic || !mw.IsPublic)
401 {
402#if NO_REF_EMIT
403 global::java.lang.invoke.MethodType methodType = MethodHandleUtil.GetDelegateMethodType(delegateType);
404 if (methodType.parameterCount() > MethodHandleUtil.MaxArity)
405 {
406 throw new NotImplementedException();
407 }
408 global::java.lang.invoke.MethodHandle exception = global::java.lang.invoke.MethodHandles.publicLookup()
409 .findConstructor(mw == null || mw.IsStatic ? typeof(global::java.lang.AbstractMethodError) : typeof(global::java.lang.IllegalAccessError),
410 global::java.lang.invoke.MethodType.methodType(typeof(void), typeof(string)))
411 .bindTo(tw.Name + ".Invoke" + sig);
412 return Delegate.CreateDelegate(delegateType,
413 global::java.lang.invoke.MethodHandles.dropArguments(
414 global::java.lang.invoke.MethodHandles.foldArguments(global::java.lang.invoke.MethodHandles.throwException(methodType.returnType(), exception.type().returnType()), exception),
415 0, methodType.parameterArray()).vmtarget, "Invoke");
416#else
417 MethodInfo invoke = delegateType.GetMethod("Invoke");
418 ParameterInfo[] parameters = invoke.GetParameters();
419 Type[] parameterTypes = new Type[parameters.Length + 1];
420 parameterTypes[0] = typeof(object);
421 for (int i = 0; i < parameters.Length; i++)
422 {
423 parameterTypes[i + 1] = parameters[i].ParameterType;
424 }
425 System.Reflection.Emit.DynamicMethod dm = new System.Reflection.Emit.DynamicMethod("Invoke", invoke.ReturnType, parameterTypes);
426 CodeEmitter ilgen = JVM.Context.CodeEmitterFactory.Create(dm);
427 ilgen.Emit(System.Reflection.Emit.OpCodes.Ldstr, tw.Name + ".Invoke" + sig);
428 JVM.Context.ClassLoaderFactory.GetBootstrapClassLoader()
429 .LoadClassByName(mw == null || mw.IsStatic ? "global::java.lang.AbstractMethodError" : "global::java.lang.IllegalAccessError")
430 .GetMethod("<init>", "(Lglobal::java.lang.String;)V", false)
431 .EmitNewobj(ilgen);
432 ilgen.Emit(System.Reflection.Emit.OpCodes.Throw);
433 ilgen.DoEmit();
434 return dm.CreateDelegate(delegateType, obj);
435#endif
436 }
437 else
438 {
439 mw.ResolveMethod();
440 return Delegate.CreateDelegate(delegateType, obj, (MethodInfo)mw.GetMethod());
441 }
442#endif
443 }
444
445 [DebuggerStepThrough]
446 public static ikvm.@internal.CallerID DynamicCallerID(object capability)
447 {
448 return ((DynamicCallerIDProvider)capability).GetCallerID();
449 }
450
451 [DebuggerStepThrough]
452 public static global::java.lang.invoke.MethodHandle DynamicEraseInvokeExact(global::java.lang.invoke.MethodHandle mh, global::java.lang.invoke.MethodType expected, global::java.lang.invoke.MethodType target)
453 {
454#if FIRST_PASS
455 return null;
456#else
457 if (mh.type() != expected)
458 {
459 throw new global::java.lang.invoke.WrongMethodTypeException();
460 }
461 return global::java.lang.invoke.MethodHandles.explicitCastArguments(mh, target);
462#endif
463 }
464
465#endif
466
467 [DebuggerStepThrough]
468 public static int f2i(float f)
469 {
470 if (f > int.MinValue && f < int.MaxValue)
471 {
472 return (int)f;
473 }
474 if (f <= int.MinValue)
475 {
476 return int.MinValue;
477 }
478 if (f >= int.MaxValue)
479 {
480 return int.MaxValue;
481 }
482 return 0;
483 }
484
485 [DebuggerStepThrough]
486 public static long f2l(float f)
487 {
488 if (f > long.MinValue && f < long.MaxValue)
489 {
490 return (long)f;
491 }
492 if (f <= long.MinValue)
493 {
494 return long.MinValue;
495 }
496 if (f >= long.MaxValue)
497 {
498 return long.MaxValue;
499 }
500 return 0;
501 }
502
503 [DebuggerStepThrough]
504 public static int d2i(double d)
505 {
506 if (d > int.MinValue && d < int.MaxValue)
507 {
508 return (int)d;
509 }
510 if (d <= int.MinValue)
511 {
512 return int.MinValue;
513 }
514 if (d >= int.MaxValue)
515 {
516 return int.MaxValue;
517 }
518 return 0;
519 }
520
521 [DebuggerStepThrough]
522 public static long d2l(double d)
523 {
524 if (d > long.MinValue && d < long.MaxValue)
525 {
526 return (long)d;
527 }
528 if (d <= long.MinValue)
529 {
530 return long.MinValue;
531 }
532 if (d >= long.MaxValue)
533 {
534 return long.MaxValue;
535 }
536 return 0;
537 }
538
539#if EXPORTER == false
540
541 // This is used by static JNI and synchronized methods that need a class object
542 [DebuggerStepThrough]
543 public static object GetClassFromTypeHandle(RuntimeTypeHandle typeHandle)
544 {
546 }
547
548 [DebuggerStepThrough]
549 public static void arraycopy(object src, int srcStart, object dest, int destStart, int len)
550 {
551#if FIRST_PASS
552 throw new NotImplementedException();
553#else
554 // If the two arrays are the same, we can use the fast path, but we're also required to do so,
555 // to get the required memmove semantics.
556 if (src == dest)
557 {
558 try
559 {
560 arraycopy_fast((Array)src, srcStart, (Array)dest, destStart, len);
561 return;
562 }
563 catch (InvalidCastException)
564 {
565 throw new global::java.lang.ArrayStoreException();
566 }
567 }
568 else if (src == null || dest == null)
569 {
570 throw new global::java.lang.NullPointerException();
571 }
572 else if (len < 0)
573 {
574 throw new global::java.lang.ArrayIndexOutOfBoundsException();
575 }
576 else
577 {
578 if (src is object[] src1 && dest is object[] dst1)
579 {
580 // for small copies, don't bother comparing the types as this is relatively expensive
581 if (len > 100 && src.GetType() == dest.GetType())
582 {
583 arraycopy_fast(src1, srcStart, dst1, destStart, len);
584 return;
585 }
586 else
587 {
588 for (; len > 0; len--)
589 {
590 // NOTE we don't need to catch ArrayTypeMismatchException & IndexOutOfRangeException, because
591 // they automatically get converted to the Java equivalents anyway.
592 dst1[destStart++] = src1[srcStart++];
593 }
594
595 return;
596 }
597 }
598 else if (src.GetType() != dest.GetType() && (IsPrimitiveArrayType(src.GetType()) || IsPrimitiveArrayType(dest.GetType())))
599 {
600 // we don't want to allow copying a primitive into an object array!
601 throw new global::java.lang.ArrayStoreException();
602 }
603 else
604 {
605 try
606 {
607 arraycopy_fast((Array)src, srcStart, (Array)dest, destStart, len);
608 return;
609 }
610 catch (InvalidCastException)
611 {
612 throw new global::java.lang.ArrayStoreException();
613 }
614 }
615 }
616#endif
617 }
618
619 private static bool IsPrimitiveArrayType(Type type)
620 {
621#if FIRST_PASS
622 throw new NotImplementedException();
623#else
624 return type.IsArray && JVM.Context.ClassLoaderFactory.GetJavaTypeFromType(type.GetElementType()).IsPrimitive;
625#endif
626 }
627
628 [DebuggerStepThrough]
629 public static void arraycopy_fast(Array src, int srcStart, Array dest, int destStart, int len)
630 {
631#if FIRST_PASS
632 throw new NotImplementedException();
633#else
634 try
635 {
636 Array.Copy(src, srcStart, dest, destStart, len);
637 }
638 catch (ArgumentNullException)
639 {
640 throw new global::java.lang.NullPointerException();
641 }
642 catch (ArgumentException)
643 {
644 throw new global::java.lang.ArrayIndexOutOfBoundsException();
645 }
646#endif
647 }
648
649 [DebuggerStepThrough]
650 public static void arraycopy_primitive_8(Array src, int srcStart, Array dest, int destStart, int len)
651 {
652#if FIRST_PASS
653 throw new NotImplementedException();
654#else
655 try
656 {
657 checked
658 {
659 Buffer.BlockCopy(src, srcStart * 8, dest, destStart * 8, len * 8);
660 return;
661 }
662 }
663 catch (ArgumentNullException)
664 {
665 throw new global::java.lang.NullPointerException();
666 }
667 catch (OverflowException)
668 {
669 throw new global::java.lang.ArrayIndexOutOfBoundsException();
670 }
671 catch (ArgumentException)
672 {
673 throw new global::java.lang.ArrayIndexOutOfBoundsException();
674 }
675#endif
676 }
677
678 [DebuggerStepThrough]
679 public static void arraycopy_primitive_4(Array src, int srcStart, Array dest, int destStart, int len)
680 {
681#if FIRST_PASS
682 throw new NotImplementedException();
683#else
684 try
685 {
686 checked
687 {
688 Buffer.BlockCopy(src, srcStart * 4, dest, destStart * 4, len * 4);
689 return;
690 }
691 }
692 catch (ArgumentNullException)
693 {
694 throw new global::java.lang.NullPointerException();
695 }
696 catch (OverflowException)
697 {
698 throw new global::java.lang.ArrayIndexOutOfBoundsException();
699 }
700 catch (ArgumentException)
701 {
702 throw new global::java.lang.ArrayIndexOutOfBoundsException();
703 }
704#endif
705 }
706
707 [DebuggerStepThrough]
708 public static void arraycopy_primitive_2(Array src, int srcStart, Array dest, int destStart, int len)
709 {
710#if FIRST_PASS
711 throw new NotImplementedException();
712#else
713 try
714 {
715 checked
716 {
717 Buffer.BlockCopy(src, srcStart * 2, dest, destStart * 2, len * 2);
718 return;
719 }
720 }
721 catch (ArgumentNullException)
722 {
723 throw new global::java.lang.NullPointerException();
724 }
725 catch (OverflowException)
726 {
727 throw new global::java.lang.ArrayIndexOutOfBoundsException();
728 }
729 catch (ArgumentException)
730 {
731 throw new global::java.lang.ArrayIndexOutOfBoundsException();
732 }
733#endif
734 }
735
736 [DebuggerStepThrough]
737 public static void arraycopy_primitive_1(Array src, int srcStart, Array dest, int destStart, int len)
738 {
739#if FIRST_PASS
740 throw new NotImplementedException();
741#else
742 try
743 {
744 Buffer.BlockCopy(src, srcStart, dest, destStart, len);
745 return;
746 }
747 catch (ArgumentNullException)
748 {
749 throw new global::java.lang.NullPointerException();
750 }
751 catch (OverflowException)
752 {
753 throw new global::java.lang.ArrayIndexOutOfBoundsException();
754 }
755 catch (ArgumentException)
756 {
757 throw new global::java.lang.ArrayIndexOutOfBoundsException();
758 }
759#endif
760 }
761
762 [HideFromJava]
763 public static void VerboseCastFailure(RuntimeTypeHandle typeHandle, object obj)
764 {
765#if FIRST_PASS
766 throw new NotImplementedException();
767#else
768 Type t1 = obj.GetType();
769 Type t2 = Type.GetTypeFromHandle(typeHandle);
770 string msg;
771 if (t1.Assembly.FullName == t2.Assembly.FullName && t1.Assembly.Location != t2.Assembly.Location)
772 {
773 string l1 = t1.Assembly.Location;
774 string l2 = t2.Assembly.Location;
775 if (l1 == "")
776 {
777 l1 = "unknown location";
778 }
779 if (l2 == "")
780 {
781 l2 = "unknown location";
782 }
783 msg = String.Format("Object of type \"{0}\" loaded from {1} cannot be cast to \"{2}\" loaded from {3}", t1.AssemblyQualifiedName, l1, t2.AssemblyQualifiedName, l2);
784 }
785 else
786 {
787 msg = String.Format("Object of type \"{0}\" cannot be cast to \"{1}\"", t1.AssemblyQualifiedName, t2.AssemblyQualifiedName);
788 }
789 throw new global::java.lang.ClassCastException(msg);
790#endif
791 }
792
797 public static bool SkipFinalizer()
798 {
799#if FIRST_PASS
800 throw new NotImplementedException();
801#else
802 return Environment.HasShutdownStarted && !global::java.lang.Shutdown.runFinalizersOnExit;
803#endif
804 }
805
811 public static bool SkipFinalizer(object o)
812 {
813#if FIRST_PASS
814 throw new NotImplementedException();
815#else
816 if (SkipFinalizer())
817 return true;
818
819 if (o is global::java.lang.Object jlo)
820 if (ObjectAccessor.GetInit(jlo) == false)
821 return true;
822
823 return false;
824#endif
825 }
826
827#endif
828
834 public static bool VolatileRead(ref bool location)
835 {
836#if FIRST_PASS || IMPORTER || EXPORTER
837 throw new NotImplementedException();
838#else
839 try
840 {
841 return Volatile.Read(ref location);
842 }
843 catch (SEHException e)
844 {
845 throw new global::java.lang.InternalError(e);
846 }
847#endif
848 }
849
855 public static void VolatileWrite(ref bool location, bool value)
856 {
857#if FIRST_PASS || IMPORTER || EXPORTER
858 throw new NotImplementedException();
859#else
860 try
861 {
862 Volatile.Write(ref location, value);
863 }
864 catch (SEHException e)
865 {
866 throw new global::java.lang.InternalError(e);
867 }
868#endif
869 }
870
876 public static byte VolatileRead(ref byte location)
877 {
878#if FIRST_PASS || IMPORTER || EXPORTER
879 throw new NotImplementedException();
880#else
881 try
882 {
883 return Volatile.Read(ref location);
884 }
885 catch (SEHException e)
886 {
887 throw new global::java.lang.InternalError(e);
888 }
889#endif
890 }
891
897 public static void VolatileWrite(ref byte location, byte value)
898 {
899#if FIRST_PASS || IMPORTER || EXPORTER
900 throw new NotImplementedException();
901#else
902 try
903 {
904 Volatile.Write(ref location, value);
905 }
906 catch (SEHException e)
907 {
908 throw new global::java.lang.InternalError(e);
909 }
910#endif
911 }
912
918 public static char VolatileRead(ref char location)
919 {
920#if FIRST_PASS || IMPORTER || EXPORTER
921 throw new NotImplementedException();
922#else
923 try
924 {
925 return (char)Volatile.Read(ref Unsafe.As<char, short>(ref location));
926 }
927 catch (SEHException e)
928 {
929 throw new global::java.lang.InternalError(e);
930 }
931#endif
932 }
933
939 public static void VolatileWrite(ref char location, char value)
940 {
941#if FIRST_PASS || IMPORTER || EXPORTER
942 throw new NotImplementedException();
943#else
944 try
945 {
946 Volatile.Write(ref Unsafe.As<char, short>(ref location), (short)value);
947 }
948 catch (SEHException e)
949 {
950 throw new global::java.lang.InternalError(e);
951 }
952#endif
953 }
954
960 public static short VolatileRead(ref short location)
961 {
962#if FIRST_PASS || IMPORTER || EXPORTER
963 throw new NotImplementedException();
964#else
965 try
966 {
967 return Volatile.Read(ref location);
968 }
969 catch (SEHException e)
970 {
971 throw new global::java.lang.InternalError(e);
972 }
973#endif
974 }
975
981 public static void VolatileWrite(ref short location, short value)
982 {
983#if FIRST_PASS || IMPORTER || EXPORTER
984 throw new NotImplementedException();
985#else
986 try
987 {
988 Volatile.Write(ref location, value);
989 }
990 catch (SEHException e)
991 {
992 throw new global::java.lang.InternalError(e);
993 }
994#endif
995 }
996
1002 public static int VolatileRead(ref int location)
1003 {
1004#if FIRST_PASS || IMPORTER || EXPORTER
1005 throw new NotImplementedException();
1006#else
1007 try
1008 {
1009 return Volatile.Read(ref location);
1010 }
1011 catch (SEHException e)
1012 {
1013 throw new global::java.lang.InternalError(e);
1014 }
1015#endif
1016 }
1017
1023 public static void VolatileWrite(ref int location, int value)
1024 {
1025#if FIRST_PASS || IMPORTER || EXPORTER
1026 throw new NotImplementedException();
1027#else
1028 try
1029 {
1030 Volatile.Write(ref location, value);
1031 }
1032 catch (SEHException e)
1033 {
1034 throw new global::java.lang.InternalError(e);
1035 }
1036#endif
1037 }
1038
1044 public static long VolatileRead(ref long location)
1045 {
1046#if FIRST_PASS || IMPORTER || EXPORTER
1047 throw new NotImplementedException();
1048#else
1049 try
1050 {
1051 return Interlocked.CompareExchange(ref location, 0, 0);
1052 }
1053 catch (SEHException e)
1054 {
1055 throw new global::java.lang.InternalError(e);
1056 }
1057#endif
1058 }
1059
1065 public static void VolatileWrite(ref long location, long value)
1066 {
1067#if FIRST_PASS || IMPORTER || EXPORTER
1068 throw new NotImplementedException();
1069#else
1070 try
1071 {
1072 Interlocked.Exchange(ref location, value);
1073 }
1074 catch (SEHException e)
1075 {
1076 throw new global::java.lang.InternalError(e);
1077 }
1078#endif
1079 }
1080
1086 public static float VolatileRead(ref float location)
1087 {
1088#if FIRST_PASS || IMPORTER || EXPORTER
1089 throw new NotImplementedException();
1090#else
1091 try
1092 {
1093 return Volatile.Read(ref location);
1094 }
1095 catch (SEHException e)
1096 {
1097 throw new global::java.lang.InternalError(e);
1098 }
1099#endif
1100 }
1101
1107 public static void VolatileWrite(ref float location, float value)
1108 {
1109#if FIRST_PASS || IMPORTER || EXPORTER
1110 throw new NotImplementedException();
1111#else
1112 try
1113 {
1114 Volatile.Write(ref location, value);
1115 }
1116 catch (SEHException e)
1117 {
1118 throw new global::java.lang.InternalError(e);
1119 }
1120#endif
1121 }
1122
1128 public static double VolatileRead(ref double location)
1129 {
1130#if FIRST_PASS || IMPORTER || EXPORTER
1131 throw new NotImplementedException();
1132#else
1133 try
1134 {
1135 return Interlocked.CompareExchange(ref location, 0, 0);
1136 }
1137 catch (SEHException e)
1138 {
1139 throw new global::java.lang.InternalError(e);
1140 }
1141#endif
1142 }
1143
1149 public static void VolatileWrite(ref double location, double value)
1150 {
1151#if FIRST_PASS || IMPORTER || EXPORTER
1152 throw new NotImplementedException();
1153#else
1154 try
1155 {
1156 Interlocked.Exchange(ref location, value);
1157 }
1158 catch (SEHException e)
1159 {
1160 throw new global::java.lang.InternalError(e);
1161 }
1162#endif
1163 }
1164
1172 public static bool CompareAndSwap(ref object location, object expected, object value)
1173 {
1174#if FIRST_PASS || IMPORTER || EXPORTER
1175 throw new NotImplementedException();
1176#else
1177 try
1178 {
1179 return Interlocked.CompareExchange(ref location, value, expected) == expected;
1180 }
1181 catch (SEHException e)
1182 {
1183 throw new global::java.lang.InternalError(e);
1184 }
1185#endif
1186 }
1187
1195 public static bool CompareAndSwap(ref int location, int expected, int value)
1196 {
1197#if FIRST_PASS || IMPORTER || EXPORTER
1198 throw new NotImplementedException();
1199#else
1200 try
1201 {
1202 return Interlocked.CompareExchange(ref location, value, expected) == expected;
1203 }
1204 catch (SEHException e)
1205 {
1206 throw new global::java.lang.InternalError(e);
1207 }
1208#endif
1209 }
1210
1218 public static bool CompareAndSwap(ref long location, long expected, long value)
1219 {
1220#if FIRST_PASS || IMPORTER || EXPORTER
1221 throw new NotImplementedException();
1222#else
1223 try
1224 {
1225 return Interlocked.CompareExchange(ref location, value, expected) == expected;
1226 }
1227 catch (SEHException e)
1228 {
1229 throw new global::java.lang.InternalError(e);
1230 }
1231#endif
1232 }
1233
1241 public static bool CompareAndSwap(ref double location, double expected, double value)
1242 {
1243#if FIRST_PASS || IMPORTER || EXPORTER
1244 throw new NotImplementedException();
1245#else
1246 try
1247 {
1248 return Interlocked.CompareExchange(ref location, value, expected) == expected;
1249 }
1250 catch (SEHException)
1251 {
1252 throw new global::java.lang.InternalError();
1253 }
1254#endif
1255 }
1256
1257#if EXPORTER == false
1258
1264 [MethodImpl(MethodImplOptions.NoInlining)]
1265 public static void InitializeModule(Module module)
1266 {
1267#if FIRST_PASS
1268 throw new NotImplementedException();
1269#else
1270 var asm = Assembly.GetCallingAssembly();
1271 if (module.Assembly != asm)
1272 throw new ArgumentOutOfRangeException();
1273
1274 // check for InitializeModule method present on classloader
1275 var classLoader = JVM.Context.AssemblyClassLoaderFactory.FromAssembly(asm).GetJavaClassLoader();
1276 if (classLoader != null)
1277 {
1278 var init = (Action<Module>)Delegate.CreateDelegate(typeof(Action<Module>), classLoader, "InitializeModule", false, false);
1279 if (init != null)
1280 init(module);
1281 }
1282#endif
1283 }
1284
1285 public static T GetDotNetEnumField<T>(string name)
1286#if !FIRST_PASS
1287 where T : global::java.lang.Enum
1288#endif
1289 {
1290#if FIRST_PASS
1291 throw new NotImplementedException();
1292#else
1293 try
1294 {
1295 return (T)global::java.lang.Enum.valueOf((global::java.lang.Class)ClassLiteral<T>.Value, name);
1296 }
1297 catch (global::java.lang.IllegalArgumentException)
1298 {
1299 throw new global::java.lang.NoSuchFieldError(((global::java.lang.Class)ClassLiteral<T>.Value).getName() + "." + name);
1300 }
1301#endif
1302 }
1303
1304 [Flags]
1305 public enum MapFlags
1306 {
1307 None = 0,
1308 NoRemapping = 1,
1309 Unused = 2,
1310 }
1311
1312 [HideFromJava]
1313 public static T MapException<T>(Exception x, MapFlags mode) where T : Exception
1314 {
1315#if FIRST_PASS
1316 throw new NotImplementedException();
1317#else
1318 return JVM.Context.ExceptionHelper.MapException<T>(x, (mode & MapFlags.NoRemapping) == 0, (mode & MapFlags.Unused) != 0);
1319#endif
1320 }
1321
1322 [HideFromJava]
1323 public static Exception DynamicMapException(Exception x, MapFlags mode, global::java.lang.Class exceptionClass)
1324 {
1325#if FIRST_PASS
1326 throw new NotImplementedException();
1327#else
1328 var exceptionTypeWrapper = RuntimeJavaType.FromClass(exceptionClass);
1329 mode &= ~MapFlags.NoRemapping;
1330 if (exceptionTypeWrapper.IsSubTypeOf(JVM.Context.JavaBase.TypeOfCliSystemException))
1331 mode |= MapFlags.NoRemapping;
1332
1333 var exceptionType = exceptionTypeWrapper == JVM.Context.JavaBase.TypeOfjavaLangThrowable ? typeof(System.Exception) : exceptionTypeWrapper.TypeAsBaseType;
1334 return (Exception)JVM.Context.ByteCodeHelperMethods.MapException.MakeGenericMethod(exceptionType).Invoke(null, new object[] { x, mode });
1335#endif
1336 }
1337
1338 public static T GetDelegateForInvokeExact<T>(object methodHandle)
1339 where T : class, Delegate
1340 {
1341#if FIRST_PASS
1342 throw new NotImplementedException();
1343#else
1344 var methodHandle_ = (global::java.lang.invoke.MethodHandle)methodHandle;
1345 var del = methodHandle_._invokeExactDelegate as T;
1346 del ??= JVM.Context.MethodHandleUtil.GetDelegateForInvokeExact<T>(methodHandle_);
1347 return del;
1348#endif
1349 }
1350
1351 public static T GetDelegateForInvoke<T>(object methodHandle, object realType, ref InvokeCache<T> cache)
1352 where T : class, Delegate
1353 {
1354#if FIRST_PASS
1355 throw new NotImplementedException();
1356#else
1357 var methodHandle_ = (global::java.lang.invoke.MethodHandle)methodHandle;
1358 var realType_ = (global::java.lang.invoke.MethodType)realType;
1359
1360 T del;
1361 if (cache.Type == methodHandle_.type() && (del = (methodHandle_.isVarargsCollector() ? cache.varArg : cache.fixedArg)) != null)
1362 return del;
1363
1364 del = methodHandle_.form.vmentry.vmtarget as T;
1365 if (del == null)
1366 {
1367 var adapter = global::java.lang.invoke.MethodHandles.exactInvoker(methodHandle_.type());
1368 if (methodHandle_.isVarargsCollector())
1369 adapter = adapter.asVarargsCollector(methodHandle_.type().parameterType(methodHandle_.type().parameterCount() - 1));
1370
1371 // if realType is set, the delegate contains erased unloadable types
1372 if (realType_ != null)
1373 adapter = adapter.asType(realType_.insertParameterTypes(0, (global::java.lang.Class)ClassLiteral<global::java.lang.invoke.MethodHandle>.Value)).asFixedArity();
1374
1375 adapter = adapter.asType(JVM.Context.MethodHandleUtil.GetDelegateMethodType(typeof(T)));
1376 del = GetDelegateForInvokeExact<T>(adapter);
1377 if (cache.TrySetType(methodHandle_.type()))
1378 {
1379 if (methodHandle_.isVarargsCollector())
1380 cache.varArg = del;
1381 else
1382 cache.fixedArg = del;
1383 }
1384 }
1385
1386 return del;
1387#endif
1388 }
1389
1390 public static T GetDelegateForInvokeBasic<T>(global::java.lang.invoke.MethodHandle h)
1391 where T : class, Delegate
1392 {
1393#if FIRST_PASS
1394 throw new NotImplementedException();
1395#else
1396 var del = h.form.vmentry.vmtarget as T;
1397 del ??= MethodHandleUtil.GetVoidAdapter(h.form.vmentry) as T;
1398 return del;
1399#endif
1400 }
1401
1402 public static global::java.lang.invoke.MethodType LoadMethodType<T>()
1403 where T : class, Delegate
1404 {
1405#if FIRST_PASS
1406 throw new NotImplementedException();
1407#else
1408 return JVM.Context.MethodHandleUtil.GetDelegateMethodType(typeof(T));
1409#endif
1410 }
1411
1412 [HideFromJava]
1413 public static void LinkIndyCallSite<T>(ref IndyCallSite<T> site, global::java.lang.invoke.CallSite cs, Exception x)
1414 where T : class, Delegate
1415 {
1416#if FIRST_PASS
1417 throw new NotImplementedException();
1418#else
1419 // when a CallSite is first constructed, it doesn't call MethodHandleNatives.setCallSiteTargetNormal(),
1420 // so we have to check if we need to initialize it here (i.e. attach an IndyCallSite<T> to it)
1421 if (cs != null)
1422 {
1423 if (cs.ics == null)
1424 MethodHandleNatives.InitializeCallSite(cs);
1425
1426 lock (cs.ics)
1427 cs.ics.SetTarget(cs.target);
1428 }
1429
1430 IndyCallSite<T> ics;
1431 if (x != null || cs == null)
1432 {
1433 x = MapException<Exception>(x ?? (Exception)new global::java.lang.ClassCastException("bootstrap method failed to produce a CallSite"), MapFlags.None);
1434 global::java.lang.invoke.MethodType type = LoadMethodType<T>();
1435 global::java.lang.invoke.MethodHandle exc = x is global::java.lang.BootstrapMethodError
1436 ? global::java.lang.invoke.MethodHandles.constant(typeof(global::java.lang.BootstrapMethodError), x)
1437 : global::java.lang.invoke.MethodHandles.publicLookup().findConstructor(typeof(global::java.lang.BootstrapMethodError), global::java.lang.invoke.MethodType.methodType(typeof(void), typeof(string), typeof(Exception)))
1438 .bindTo("call site initialization exception: " + x + "\n" + x.StackTrace).bindTo(x);
1439 ics = new IndyCallSite<T>();
1440 ((IIndyCallSite)ics).SetTarget(
1441 global::java.lang.invoke.MethodHandles.dropArguments(
1442 global::java.lang.invoke.MethodHandles.foldArguments(
1443 global::java.lang.invoke.MethodHandles.throwException(type.returnType(), typeof(global::java.lang.BootstrapMethodError)),
1444 exc),
1445 0, type.parameterArray()));
1446 }
1447 else if ((ics = cs.ics as IndyCallSite<T>) == null)
1448 {
1449 ics = new IndyCallSite<T>();
1450 var expectedType = LoadMethodType<T>();
1451 try
1452 {
1453 ((IIndyCallSite)ics).SetTarget(cs.dynamicInvoker().asType(expectedType));
1454 }
1455 catch (global::java.lang.invoke.WrongMethodTypeException e)
1456 {
1457 throw new global::java.lang.invoke.WrongMethodTypeException("call site " + cs.type() + ", requested " + expectedType + ": " + e.Message);
1458 }
1459 }
1460
1461 var curr = site;
1462 if (curr.IsBootstrap)
1463 Interlocked.CompareExchange(ref site, ics, curr);
1464#endif
1465 }
1466
1467 [HideFromJava]
1468 public static void DynamicLinkIndyCallSite<T>(ref IndyCallSite<T> site, global::java.lang.invoke.CallSite cs, Exception x, string signature, ikvm.@internal.CallerID callerID)
1469 where T : class, Delegate
1470 {
1471#if FIRST_PASS
1472 throw new NotImplementedException();
1473#else
1474 // when a CallSite is first constructed, it doesn't call MethodHandleNatives.setCallSiteTargetNormal(),
1475 // so we have to check if we need to initialize it here (i.e. attach an IndyCallSite<T> to it)
1476 if (cs != null)
1477 {
1478 if (cs.ics == null)
1479 MethodHandleNatives.InitializeCallSite(cs);
1480
1481 lock (cs.ics)
1482 cs.ics.SetTarget(cs.target);
1483 }
1484 IndyCallSite<T> ics;
1485 if (x != null || cs == null)
1486 {
1487 x = MapException<Exception>(x ?? (cs == null
1488 ? (Exception)new global::java.lang.ClassCastException("bootstrap method failed to produce a CallSite")
1489 : new global::java.lang.ClassCastException("bootstrap method failed to produce a CallSite")), MapFlags.None);
1490 global::java.lang.invoke.MethodType type = LoadMethodType<T>();
1491 global::java.lang.invoke.MethodHandle exc = x is global::java.lang.BootstrapMethodError
1492 ? global::java.lang.invoke.MethodHandles.constant(typeof(global::java.lang.BootstrapMethodError), x)
1493 : global::java.lang.invoke.MethodHandles.publicLookup().findConstructor(typeof(global::java.lang.BootstrapMethodError), global::java.lang.invoke.MethodType.methodType(typeof(void), typeof(string), typeof(Exception)))
1494 .bindTo("call site initialization exception: " + x + "\n" + x.StackTrace).bindTo(x);
1495 ics = new IndyCallSite<T>();
1496 ((IIndyCallSite)ics).SetTarget(
1497 global::java.lang.invoke.MethodHandles.dropArguments(
1498 global::java.lang.invoke.MethodHandles.foldArguments(
1499 global::java.lang.invoke.MethodHandles.throwException(type.returnType(), typeof(global::java.lang.BootstrapMethodError)),
1500 exc),
1501 0, type.parameterArray()));
1502 }
1503 else
1504 {
1505 ics = new IndyCallSite<T>();
1506 var delegateType = LoadMethodType<T>();
1507 try
1508 {
1509 ((IIndyCallSite)ics).SetTarget(cs.dynamicInvoker().asType(delegateType));
1510 }
1511 catch (global::java.lang.invoke.WrongMethodTypeException e)
1512 {
1513 throw new global::java.lang.invoke.WrongMethodTypeException("call site " + cs.type() + ", requested " + delegateType + ": " + e.Message);
1514 }
1515 }
1516
1517 IndyCallSite<T> curr = site;
1518 if (curr.IsBootstrap)
1519 Interlocked.CompareExchange(ref site, ics, curr);
1520#endif
1521 }
1522
1523#endif
1524
1525 }
1526
1527#if EXPORTER == false
1528
1530 {
1531
1532 void SetTarget(global::java.lang.invoke.MethodHandle mh);
1533
1534 }
1535
1536 public sealed class IndyCallSite<T> : IIndyCallSite
1537 where T : class, Delegate
1538 {
1539
1540 internal readonly bool IsBootstrap;
1541 volatile T target;
1542
1543 internal IndyCallSite()
1544
1545 {
1546 }
1547
1548 internal IndyCallSite(T target, bool bootstrap)
1549 {
1550 this.IsBootstrap = bootstrap;
1551 this.target = target;
1552 }
1553
1554 void IIndyCallSite.SetTarget(global::java.lang.invoke.MethodHandle mh)
1555 {
1556#if !FIRST_PASS
1557 target = ByteCodeHelper.GetDelegateForInvokeExact<T>(mh);
1558#endif
1559 }
1560
1561 public static IndyCallSite<T> CreateBootstrap(T bootstrap)
1562 {
1563 return new IndyCallSite<T>(bootstrap, true);
1564 }
1565
1566 public T GetTarget()
1567 {
1568 return target;
1569 }
1570
1571 }
1572
1573 public struct InvokeCache<T>
1574 where T : class
1575 {
1576
1577 internal T fixedArg;
1578 internal T varArg;
1579
1580 global::java.lang.invoke.MethodType type;
1581
1582 internal global::java.lang.invoke.MethodType Type => type;
1583
1584 internal bool TrySetType(global::java.lang.invoke.MethodType newType)
1585 {
1586 Interlocked.CompareExchange(ref type, newType, null);
1587 return type == newType;
1588 }
1589
1590 }
1591
1592#endif
1593
1594 [StructLayout(LayoutKind.Explicit)]
1595 public struct DoubleConverter
1596 {
1597
1598 [FieldOffset(0)]
1599 double d;
1600
1601 [FieldOffset(0)]
1602 long l;
1603
1604 public static long ToLong(double value, ref DoubleConverter converter)
1605 {
1606 converter.d = value;
1607 return converter.l;
1608 }
1609
1610 public static double ToDouble(long value, ref DoubleConverter converter)
1611 {
1612 converter.l = value;
1613 return converter.d;
1614 }
1615
1616 }
1617
1618 [StructLayout(LayoutKind.Explicit)]
1619 public struct FloatConverter
1620 {
1621
1622 [FieldOffset(0)]
1623 float f;
1624
1625 [FieldOffset(0)]
1626 int i;
1627
1628 public static int ToInt(float value, ref FloatConverter converter)
1629 {
1630 converter.f = value;
1631 return converter.i;
1632 }
1633
1634 public static float ToFloat(int value, ref FloatConverter converter)
1635 {
1636 converter.i = value;
1637 return converter.f;
1638 }
1639
1640 }
1641
1642 public struct MHA<T1, T2, T3, T4, T5, T6, T7, T8>
1643 {
1644 public T1 t1;
1645 public T2 t2;
1646 public T3 t3;
1647 public T4 t4;
1648 public T5 t5;
1649 public T6 t6;
1650 public T7 t7;
1651 public T8 t8;
1652
1653 public MHA(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
1654 {
1655 this.t1 = t1;
1656 this.t2 = t2;
1657 this.t3 = t3;
1658 this.t4 = t4;
1659 this.t5 = t5;
1660 this.t6 = t6;
1661 this.t7 = t7;
1662 this.t8 = t8;
1663 }
1664 }
1665
1666 public delegate void MHV();
1667 public delegate void MHV<T1>(T1 t1);
1668 public delegate void MHV<T1, T2>(T1 t1, T2 t2);
1669 public delegate void MHV<T1, T2, T3>(T1 t1, T2 t2, T3 t3);
1670 public delegate void MHV<T1, T2, T3, T4>(T1 t1, T2 t2, T3 t3, T4 t4);
1671 public delegate void MHV<T1, T2, T3, T4, T5>(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5);
1672 public delegate void MHV<T1, T2, T3, T4, T5, T6>(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6);
1673 public delegate void MHV<T1, T2, T3, T4, T5, T6, T7>(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7);
1674 public delegate void MHV<T1, T2, T3, T4, T5, T6, T7, T8>(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8);
1675
1676 public delegate TResult MH<TResult>();
1677 public delegate TResult MH<T1, TResult>(T1 t1);
1678 public delegate TResult MH<T1, T2, TResult>(T1 t1, T2 t2);
1679 public delegate TResult MH<T1, T2, T3, TResult>(T1 t1, T2 t2, T3 t3);
1680 public delegate TResult MH<T1, T2, T3, T4, TResult>(T1 t1, T2 t2, T3 t3, T4 t4);
1681 public delegate TResult MH<T1, T2, T3, T4, T5, TResult>(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5);
1682 public delegate TResult MH<T1, T2, T3, T4, T5, T6, TResult>(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6);
1683 public delegate TResult MH<T1, T2, T3, T4, T5, T6, T7, TResult>(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7);
1684 public delegate TResult MH<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8);
1685
1686 public static class LiveObjectHolder<T>
1687 {
1688
1689 public static object[] values;
1690
1691 }
1692
1693}
System.Threading.Interlocked Interlocked
IKVM.Reflection.Module Module
IKVM.Reflection.Type Type
IKVM.Reflection.Assembly Assembly
IKVM.Reflection.MethodInfo MethodInfo
IKVM.Reflection.ParameterInfo ParameterInfo
static global::java.lang.Class getClassFromTypeHandle(RuntimeTypeHandle handle)
Definition Util.cs:67
static T GetDelegateForInvoke< T >(object methodHandle, object realType, ref InvokeCache< T > cache)
static global::java.lang.Class DynamicClassLiteral(string clazz, ikvm. @internal.CallerID callerId)
static global::java.lang.invoke.MethodType LoadMethodType< T >()
static global::java.lang.invoke.MethodHandle DynamicEraseInvokeExact(global::java.lang.invoke.MethodHandle mh, global::java.lang.invoke.MethodType expected, global::java.lang.invoke.MethodType target)
static void VolatileWrite(ref double location, double value)
Implements a volatile write against a reference to a double. In Java, a volatile operation is atomic.
static void LinkIndyCallSite< T >(ref IndyCallSite< T > site, global::java.lang.invoke.CallSite cs, Exception x)
static object DynamicCast(object obj, global::java.lang.Class clazz)
static object GetClassFromTypeHandle(RuntimeTypeHandle typeHandle)
static void arraycopy_primitive_1(Array src, int srcStart, Array dest, int destStart, int len)
static bool VolatileRead(ref bool location)
Implements a volatile read against a reference to a bool. In Java, a volatile operation is atomic.
static float VolatileRead(ref float location)
Implements a volatile read against a reference to a float. In Java, a volatile operation is atomic.
static T GetDelegateForInvokeBasic< T >(global::java.lang.invoke.MethodHandle h)
static object DynamicAaload(object arrayref, int index)
static void arraycopy(object src, int srcStart, object dest, int destStart, int len)
static object multianewarray_ghost(RuntimeTypeHandle typeHandle, int[] lengths)
static object DynamicNewarray(int length, global::java.lang.Class clazz)
static T GetDelegateForInvokeExact< T >(object methodHandle)
static void VerboseCastFailure(RuntimeTypeHandle typeHandle, object obj)
static bool CompareAndSwap(ref long location, long expected, long value)
Implements a compare and swap operation against a reference to a long.
static void VolatileWrite(ref long location, long value)
Implements a volatile write against a reference to a long. In Java, a volatile operation is atomic.
static void DynamicLinkIndyCallSite< T >(ref IndyCallSite< T > site, global::java.lang.invoke.CallSite cs, Exception x, string signature, ikvm. @internal.CallerID callerID)
static void VolatileWrite(ref short location, short value)
Implements a volatile write against a reference to a short. In Java, a volatile operation is atomic.
static void VolatileWrite(ref float location, float value)
Implements a volatile write against a reference to a float. In Java, a volatile operation is atomic.
static void arraycopy_fast(Array src, int srcStart, Array dest, int destStart, int len)
static T GetDotNetEnumField< T >(string name)
static bool SkipFinalizer()
Returns true if the Java finalizer should be skipped.
static bool DynamicInstanceOf(object obj, global::java.lang.Class clazz)
static global::java.lang.invoke.MethodType DynamicLoadMethodType(ref global::java.lang.invoke.MethodType cache, string sig, ikvm. @internal.CallerID callerID)
static long d2l(double d)
static void VolatileWrite(ref char location, char value)
Implements a volatile write against a reference to a char. In Java, a volatile operation is atomic.
static object DynamicMultianewarray(int[] lengths, global::java.lang.Class clazz)
static void DynamicAastore(object arrayref, int index, object val)
static void VolatileWrite(ref int location, int value)
Implements a volatile write against a reference to a int. In Java, a volatile operation is atomic.
static bool CompareAndSwap(ref object location, object expected, object value)
Implements the compare and swap operation against a reference to an object.
static void VolatileWrite(ref byte location, byte value)
Implements a volatile write against a reference to a byte. In Java, a volatile operation is atomic.
static long VolatileRead(ref long location)
Implements a volatile read against a reference to a long. In Java, a volatile operation is atomic.
static void arraycopy_primitive_4(Array src, int srcStart, Array dest, int destStart, int len)
static object multianewarray(RuntimeTypeHandle typeHandle, int[] lengths)
static byte VolatileRead(ref byte location)
Implements a volatile read against a reference to a byte. In Java, a volatile operation is atomic.
static short VolatileRead(ref short location)
Implements a volatile read against a reference to a short. In Java, a volatile operation is atomic.
static T DynamicBinderMemberLookup< T >(int kind, string clazz, string name, string sig, ikvm. @internal.CallerID callerID)
static Delegate DynamicCreateDelegate(object obj, Type delegateType, string name, string sig)
static T[] anewarray_ghost< T >(int length, RuntimeTypeHandle typeHandle)
static int VolatileRead(ref int location)
Implements a volatile read against a reference to a int. In Java, a volatile operation is atomic.
static Exception DynamicMapException(Exception x, MapFlags mode, global::java.lang.Class exceptionClass)
static void InitializeModule(Module module)
Invoked by exported assemblies.
static bool CompareAndSwap(ref double location, double expected, double value)
Implements a compare and swap operation against a reference to a double.
static long f2l(float f)
static global::java.lang.invoke.MethodHandle DynamicLoadMethodHandle(ref global::java.lang.invoke.MethodHandle cache, int kind, string clazz, string name, string sig, ikvm. @internal.CallerID callerID)
static void arraycopy_primitive_2(Array src, int srcStart, Array dest, int destStart, int len)
static double VolatileRead(ref double location)
Implements a volatile read against a reference to a double. In Java, a volatile operation is atomic.
static void VolatileWrite(ref bool location, bool value)
Implements a volatile write against a reference to a bool. In Java, a volatile operation is atomic.
static void DynamicNewCheckOnly(global::java.lang.Class clazz)
static bool SkipFinalizer(object o)
Returns true if the Java finalizer for the given object should be skipped.
static char VolatileRead(ref char location)
Implements a volatile read against a reference to a char. In Java, a volatile operation is atomic.
static int d2i(double d)
static void arraycopy_primitive_8(Array src, int srcStart, Array dest, int destStart, int len)
static bool CompareAndSwap(ref int location, int expected, int value)
Implements the compare and swap operation against a reference to an int.
static T MapException< T >(Exception x, MapFlags mode)
Provides a static cache of java.lang.Class instances per .NET type.
static object Value
Gets the class literal value, caching the result.
CodeEmitter Create(MethodBuilder mb)
Creates a new instance.
static IndyCallSite< T > CreateBootstrap(T bootstrap)
Main state of the running JVM.
.NET exception that corresponds to a Java exception.
RuntimeAssemblyClassLoader FromAssembly(Assembly assembly)
Obtains the RuntimeAssemblyClassLoader for the given Assembly. This method should not be used with dy...
Runtime support for a class loader.
CodeEmitterFactory CodeEmitterFactory
Gets the CodeEmitterFactory associated with this instance of the runtime.
MethodHandleUtil MethodHandleUtil
Gets the MethodHandleUtil associated with this instance of the runtime.
ByteCodeHelperMethods ByteCodeHelperMethods
Gets the ByteCodeHelperMethods associated with this instance of the runtime.
ExceptionHelper ExceptionHelper
Gets the ExceptionHelper associated with this instance of the runtime.
RuntimeAssemblyClassLoaderFactory AssemblyClassLoaderFactory
Gets the RuntimeAssemblyClassLoaderFactory associated with this instance of the runtime.
CoreClasses JavaBase
Gets the CoreClasses associated with this instance of the runtime.
RuntimeClassLoaderFactory ClassLoaderFactory
Gets the RuntimeClassLoaderFactory associated with this instance of the runtime.
void SetTarget(global::java.lang.invoke.MethodHandle mh)
delegate void MHV< T1, T2, T3, T4, T5 >(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
delegate void MHV< T1, T2, T3 >(T1 t1, T2 t2, T3 t3)
delegate void MHV< T1, T2, T3, T4, T5, T6, T7, T8 >(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
delegate void MHV< T1, T2, T3, T4, T5, T6 >(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
delegate void MHV()
delegate TResult MH< T1, T2, T3, TResult >(T1 t1, T2 t2, T3 t3)
delegate void MHV< T1, T2, T3, T4 >(T1 t1, T2 t2, T3 t3, T4 t4)
delegate TResult MH< T1, T2, T3, T4, T5, T6, T7, TResult >(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
delegate TResult MH< TResult >()
delegate void MHV< T1, T2, T3, T4, T5, T6, T7 >(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
delegate TResult MH< T1, T2, T3, T4, T5, T6, TResult >(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
delegate TResult MH< T1, T2, T3, T4, T5, T6, T7, T8, TResult >(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
delegate TResult MH< T1, T2, T3, T4, TResult >(T1 t1, T2 t2, T3 t3, T4 t4)
delegate void MHV< T1 >(T1 t1)
delegate TResult MH< T1, T2, T3, T4, T5, TResult >(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
delegate void MHV< T1, T2 >(T1 t1, T2 t2)
delegate TResult MH< T1, T2, TResult >(T1 t1, T2 t2)
delegate TResult MH< T1, TResult >(T1 t1)
static long ToLong(double value, ref DoubleConverter converter)
static double ToDouble(long value, ref DoubleConverter converter)
static float ToFloat(int value, ref FloatConverter converter)
static int ToInt(float value, ref FloatConverter converter)
global::java.lang.invoke.MethodType type
MHA(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)