Language

JNIEnv.NewArray Method

Definition

Overloads

Name Description
NewArray(Array, Type)

Creates a Java array from a managed array.

NewArray(UInt32[])

Creates a Java int[] from the managed array's element bit patterns.

NewArray(UInt16[])

Creates a Java short[] from the managed array's element bit patterns.

NewArray(String[])

Creates a Java string array from managed strings.

NewArray(Single[])

Creates a Java float[] containing the managed array's elements.

NewArray(Int64[])

Creates a Java long[] containing the managed array's elements.

NewArray(UInt64[])

Creates a Java long[] from the managed array's element bit patterns.

NewArray(Int16[])

Creates a Java short[] containing the managed array's elements.

NewArray(Double[])

Creates a Java double[] containing the managed array's elements.

NewArray(Char[])

Creates a Java char[] containing the managed array's elements.

NewArray(Byte[])

Creates a Java byte[] from the managed array's element bit patterns.

NewArray(Boolean[])

Creates a Java boolean[] containing the managed array's elements.

NewArray(Int32[])

Creates a Java int[] containing the managed array's elements.

NewArray(IJavaObject[])

Creates a Java object array from managed Java peers, using the managed array's runtime element type to find the Java element class.

NewArray<T>(T[])

Creates a Java array from a managed array.

NewArray(Array, Type)

Creates a Java array from a managed array.

public static IntPtr NewArray(Array value, Type? elementType = default);
static member NewArray : Array * Type -> nativeint

Parameters

value
Array

The non-null managed array to convert.

elementType
Type

The managed element type used to select a supported conversion, or null to use the array's runtime element type.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if no reference is obtained. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(UInt32[])

Creates a Java int[] from the managed array's element bit patterns.

public static IntPtr NewArray(uint[] array);
static member NewArray : uint32[] -> nativeint

Parameters

array
UInt32[]

The managed uint[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

Remarks

The implementation treats the unsigned input as signed 32-bit storage and copies the same bits into the Java int[].

Applies to

NewArray(UInt16[])

Creates a Java short[] from the managed array's element bit patterns.

public static IntPtr NewArray(ushort[] array);
static member NewArray : uint16[] -> nativeint

Parameters

array
UInt16[]

The managed ushort[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

Remarks

The implementation treats the unsigned input as signed 16-bit storage and copies the same bits into the Java short[].

Applies to

NewArray(String[])

Creates a Java string array from managed strings.

public static IntPtr NewArray(string[]? array);
static member NewArray : string[] -> nativeint

Parameters

array
String[]

The managed string array to copy, or null. Null elements become Java null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(Single[])

Creates a Java float[] containing the managed array's elements.

public static IntPtr NewArray(float[] array);
static member NewArray : single[] -> nativeint

Parameters

array
Single[]

The managed float[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(Int64[])

Creates a Java long[] containing the managed array's elements.

public static IntPtr NewArray(long[] array);
static member NewArray : int64[] -> nativeint

Parameters

array
Int64[]

The managed long[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(UInt64[])

Creates a Java long[] from the managed array's element bit patterns.

public static IntPtr NewArray(ulong[] array);
static member NewArray : uint64[] -> nativeint

Parameters

array
UInt64[]

The managed ulong[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

Remarks

The implementation treats the unsigned input as signed 64-bit storage and copies the same bits into the Java long[].

Applies to

NewArray(Int16[])

Creates a Java short[] containing the managed array's elements.

public static IntPtr NewArray(short[] array);
static member NewArray : int16[] -> nativeint

Parameters

array
Int16[]

The managed short[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(Double[])

Creates a Java double[] containing the managed array's elements.

public static IntPtr NewArray(double[] array);
static member NewArray : double[] -> nativeint

Parameters

array
Double[]

The managed double[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(Char[])

Creates a Java char[] containing the managed array's elements.

public static IntPtr NewArray(char[] array);
static member NewArray : char[] -> nativeint

Parameters

array
Char[]

The managed char[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(Byte[])

Creates a Java byte[] from the managed array's element bit patterns.

public static IntPtr NewArray(byte[] array);
static member NewArray : byte[] -> nativeint

Parameters

array
Byte[]

The managed byte[] to copy, or null. Its unsigned byte bit patterns are passed to Java as signed bytes.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(Boolean[])

Creates a Java boolean[] containing the managed array's elements.

public static IntPtr NewArray(bool[]? array);
static member NewArray : bool[] -> nativeint

Parameters

array
Boolean[]

The managed bool[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(Int32[])

Creates a Java int[] containing the managed array's elements.

public static IntPtr NewArray(int[] array);
static member NewArray : int[] -> nativeint

Parameters

array
Int32[]

The managed int[] to copy, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray(IJavaObject[])

Creates a Java object array from managed Java peers, using the managed array's runtime element type to find the Java element class.

public static IntPtr NewArray(Android.Runtime.IJavaObject[]? array);
static member NewArray : Android.Runtime.IJavaObject[] -> nativeint

Parameters

array
IJavaObject[]

The managed array of Java peers to copy, or null. Non-null peers must have live JNI handles compatible with the Java element class.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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

NewArray<T>(T[])

Creates a Java array from a managed array.

public static IntPtr NewArray<T>(T[]? array);
static member NewArray : 'T[] -> nativeint

Type Parameters

T

The managed element type used to select a supported conversion.

Parameters

array
T[]

The managed array to convert, or null.

Returns

IntPtr

nativeint

A local JNI reference to the new array, or Zero if array is null. A nonzero local reference is valid only on its creating thread and may be released with DeleteLocalRef(IntPtr).

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