ClassLoader.DefineClass ClassLoader.DefineClass Method

Definition

Overloads

DefineClass(Byte[], Int32, Int32) DefineClass(Byte[], Int32, Int32)

Constructs a new class from an array of bytes containing a class definition in class file format.

DefineClass(String, ByteBuffer, ProtectionDomain) DefineClass(String, ByteBuffer, ProtectionDomain)

Defines a new class with the specified name, byte code from the byte buffer and the optional protection domain.

DefineClass(String, Byte[], Int32, Int32) DefineClass(String, Byte[], Int32, Int32)

Constructs a new class from an array of bytes containing a class definition in class file format.

DefineClass(String, Byte[], Int32, Int32, ProtectionDomain) DefineClass(String, Byte[], Int32, Int32, ProtectionDomain)

Constructs a new class from an array of bytes containing a class definition in class file format and assigns the specified protection domain to the new class.

DefineClass(Byte[], Int32, Int32) DefineClass(Byte[], Int32, Int32)

Warning

This API is now obsolete.

Constructs a new class from an array of bytes containing a class definition in class file format.

[Android.Runtime.Register("defineClass", "([BII)Ljava/lang/Class;", "")]
[System.Obsolete("deprecated")]
protected Java.Lang.Class DefineClass (byte[] b, int off, int len);
member this.DefineClass : byte[] * int * int -> Java.Lang.Class

Parameters

b
Byte[]
off
Int32 Int32
len
Int32 Int32

Returns

Exceptions

if classRep does not contain a valid class.

if offset , length or if offset + length is greater than the length of classRep.

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

DefineClass(String, ByteBuffer, ProtectionDomain) DefineClass(String, ByteBuffer, ProtectionDomain)

Defines a new class with the specified name, byte code from the byte buffer and the optional protection domain.

[Android.Runtime.Register("defineClass", "(Ljava/lang/String;Ljava/nio/ByteBuffer;Ljava/security/ProtectionDomain;)Ljava/lang/Class;", "")]
protected Java.Lang.Class DefineClass (string name, Java.Nio.ByteBuffer b, Java.Security.ProtectionDomain protectionDomain);
member this.DefineClass : string * Java.Nio.ByteBuffer * Java.Security.ProtectionDomain -> Java.Lang.Class

Parameters

name
String String

the expected name of the new class, may be null if not known.

b
ByteBuffer ByteBuffer

the byte buffer containing the byte code of the new class.

protectionDomain
ProtectionDomain ProtectionDomain

the protection domain to assign to the loaded class, may be null.

Returns

Exceptions

if b does not contain a valid class.

if className is not equal to the name of the class contained in b.

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

DefineClass(String, Byte[], Int32, Int32) DefineClass(String, Byte[], Int32, Int32)

Constructs a new class from an array of bytes containing a class definition in class file format.

[Android.Runtime.Register("defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;", "")]
protected Java.Lang.Class DefineClass (string name, byte[] b, int off, int len);
member this.DefineClass : string * byte[] * int * int -> Java.Lang.Class

Parameters

name
String String
b
Byte[]
off
Int32 Int32
len
Int32 Int32

Returns

Exceptions

if classRep does not contain a valid class.

if offset , length or if offset + length is greater than the length of classRep.

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

DefineClass(String, Byte[], Int32, Int32, ProtectionDomain) DefineClass(String, Byte[], Int32, Int32, ProtectionDomain)

Constructs a new class from an array of bytes containing a class definition in class file format and assigns the specified protection domain to the new class.

[Android.Runtime.Register("defineClass", "(Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;", "")]
protected Java.Lang.Class DefineClass (string name, byte[] b, int off, int len, Java.Security.ProtectionDomain protectionDomain);
member this.DefineClass : string * byte[] * int * int * Java.Security.ProtectionDomain -> Java.Lang.Class

Parameters

name
String String
b
Byte[]
off
Int32 Int32
len
Int32 Int32
protectionDomain
ProtectionDomain ProtectionDomain

the protection domain to assign to the loaded class, may be null.

Returns

Exceptions

if classRep does not contain a valid class.

if offset , length or if offset + length is greater than the length of classRep.

if className is not equal to the name of the class contained in classRep.

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to