IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
RuntimeManagedJavaType.CloneJavaMethod.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;
25
26using IKVM.Attributes;
27
28#if IMPORTER || EXPORTER
29using IKVM.Reflection;
31
32using Type = IKVM.Reflection.Type;
33#else
34using System.Reflection;
35using System.Reflection.Emit;
36#endif
37
38namespace IKVM.Runtime
39{
40
41 sealed partial class RuntimeManagedJavaType
42 {
43
47 sealed class CloneJavaMethod : RuntimeJavaMethod
48 {
49
54 internal CloneJavaMethod(RuntimeManagedJavaType declaringType) :
55 base(declaringType, "clone", "()Ljava.lang.Object;", null, declaringType.Context.JavaBase.TypeOfJavaLangObject, Array.Empty<RuntimeJavaType>(), Modifiers.Protected | Modifiers.Final, MemberFlags.None)
56 {
57
58 }
59
60#if EMITTERS
61
62 internal override void EmitCall(CodeEmitter ilgen)
63 {
64 ilgen.Emit(OpCodes.Dup);
65 ilgen.Emit(OpCodes.Isinst, DeclaringType.Context.JavaBase.TypeOfJavaLangCloneable.TypeAsBaseType);
66 var label1 = ilgen.DefineLabel();
67 ilgen.EmitBrtrue(label1);
68 var label2 = ilgen.DefineLabel();
69 ilgen.EmitBrfalse(label2);
70 ilgen.EmitThrow("java.lang.CloneNotSupportedException");
71 ilgen.MarkLabel(label2);
72 ilgen.EmitThrow("java.lang.NullPointerException");
73 ilgen.MarkLabel(label1);
74 ilgen.Emit(OpCodes.Call, DeclaringType.Context.Types.Object.GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic, null, Type.EmptyTypes, null));
75 }
76
77 internal override void EmitCallvirt(CodeEmitter ilgen)
78 {
79 EmitCall(ilgen);
80 }
81
82#endif
83
84 }
85
86 }
87
88}
IKVM.Reflection.Type Type
Types Types
Gets the Types associated with this instance of the runtime.
CoreClasses JavaBase
Gets the CoreClasses associated with this instance of the runtime.
MemberFlags
Describes various options applied to a member.