Share via


SecureClassLoader.DefineClass Method

Definition

Overloads

DefineClass(String, ByteBuffer, CodeSource)

Converts a java.nio.ByteBuffer ByteBuffer into an instance of class Class, with an optional CodeSource.

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

Converts an array of bytes into an instance of class Class, with an optional CodeSource.

DefineClass(String, ByteBuffer, CodeSource)

Converts a java.nio.ByteBuffer ByteBuffer into an instance of class Class, with an optional CodeSource.

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

Parameters

name
String

the expected name of the class, or null if not known, using '.' and not '/' as the separator and without a trailing ".class" suffix.

b
ByteBuffer

the bytes that make up the class data. The bytes from positions b.position() through b.position() + b.limit() -1 should have the format of a valid class file as defined by <cite>The Java&trade; Virtual Machine Specification</cite>.

cs
CodeSource

the associated CodeSource, or null if none

Returns

the Class object created from the data, and optional CodeSource.

Attributes

Exceptions

if the specified data is not valid class data.

if the package to which this class is to be added, already contains classes which were signed by different certificates, or if the class name begins with "java."

Remarks

Converts a java.nio.ByteBuffer ByteBuffer into an instance of class Class, with an optional CodeSource. Before the class can be used it must be resolved.

If a non-null CodeSource is supplied a ProtectionDomain is constructed and associated with the class being defined.

Added in 1.5.

Java documentation for java.security.SecureClassLoader.defineClass(java.lang.String, java.nio.ByteBuffer, java.security.CodeSource).

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

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

Converts an array of bytes into an instance of class Class, with an optional CodeSource.

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

Parameters

name
String

the expected name of the class, or null if not known, using '.' and not '/' as the separator and without a trailing ".class" suffix.

b
Byte[]

the bytes that make up the class data. The bytes in positions off through off+len-1 should have the format of a valid class file as defined by <cite>The Java&trade; Virtual Machine Specification</cite>.

off
Int32

the start offset in b of the class data

len
Int32

the length of the class data

cs
CodeSource

the associated CodeSource, or null if none

Returns

the Class object created from the data, and optional CodeSource.

Attributes

Exceptions

if off or len are not valid in respect to b.

if the specified data is not valid class data.

if the package to which this class is to be added, already contains classes which were signed by different certificates, or if the class name begins with "java."

Remarks

Converts an array of bytes into an instance of class Class, with an optional CodeSource. Before the class can be used it must be resolved.

If a non-null CodeSource is supplied a ProtectionDomain is constructed and associated with the class being defined.

Java documentation for java.security.SecureClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.CodeSource).

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