123 @IntrinsicCandidate
124 public static native int getLength(Object array)
125 throws IllegalArgumentException;
126
127 /**
128 * Returns the value of the indexed component in the specified
129 * array object. The value is automatically wrapped in an object
130 * if it has a primitive type.
131 *
132 * @param array the array
133 * @param index the index
134 * @return the (possibly wrapped) value of the indexed component in
135 * the specified array
136 * @throws NullPointerException If the specified object is null
137 * @throws IllegalArgumentException If the specified object is not
138 * an array
139 * @throws ArrayIndexOutOfBoundsException If the specified {@code index}
140 * argument is negative, or if it is greater than or equal to the
141 * length of the specified array
142 */
143 public static native Object get(Object array, int index)
144 throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
145
146 /**
147 * Returns the value of the indexed component in the specified
148 * array object, as a {@code boolean}.
149 *
150 * @param array the array
151 * @param index the index
152 * @return the value of the indexed component in the specified array
153 * @throws NullPointerException If the specified object is null
154 * @throws IllegalArgumentException If the specified object is not
155 * an array, or if the indexed element cannot be converted to the
156 * return type by an identity or widening conversion
157 * @throws ArrayIndexOutOfBoundsException If the specified {@code index}
158 * argument is negative, or if it is greater than or equal to the
159 * length of the specified array
160 * @see Array#get
161 */
162 public static native boolean getBoolean(Object array, int index)
163 throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
164
295 public static native double getDouble(Object array, int index)
296 throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
297
298 /**
299 * Sets the value of the indexed component of the specified array
300 * object to the specified new value. The new value is first
301 * automatically unwrapped if the array has a primitive component
302 * type.
303 * @param array the array
304 * @param index the index into the array
305 * @param value the new value of the indexed component
306 * @throws NullPointerException If the specified object argument
307 * is null
308 * @throws IllegalArgumentException If the specified object argument
309 * is not an array, or if the array component type is primitive and
310 * an unwrapping conversion fails
311 * @throws ArrayIndexOutOfBoundsException If the specified {@code index}
312 * argument is negative, or if it is greater than or equal to
313 * the length of the specified array
314 */
315 public static native void set(Object array, int index, Object value)
316 throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
317
318 /**
319 * Sets the value of the indexed component of the specified array
320 * object to the specified {@code boolean} value.
321 * @param array the array
322 * @param index the index into the array
323 * @param z the new value of the indexed component
324 * @throws NullPointerException If the specified object argument
325 * is null
326 * @throws IllegalArgumentException If the specified object argument
327 * is not an array, or if the specified value cannot be converted
328 * to the underlying array's component type by an identity or a
329 * primitive widening conversion
330 * @throws ArrayIndexOutOfBoundsException If the specified {@code index}
331 * argument is negative, or if it is greater than or equal to
332 * the length of the specified array
333 * @see Array#set
334 */
335 public static native void setBoolean(Object array, int index, boolean z)
336 throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
|
123 @IntrinsicCandidate
124 public static native int getLength(Object array)
125 throws IllegalArgumentException;
126
127 /**
128 * Returns the value of the indexed component in the specified
129 * array object. The value is automatically wrapped in an object
130 * if it has a primitive type.
131 *
132 * @param array the array
133 * @param index the index
134 * @return the (possibly wrapped) value of the indexed component in
135 * the specified array
136 * @throws NullPointerException If the specified object is null
137 * @throws IllegalArgumentException If the specified object is not
138 * an array
139 * @throws ArrayIndexOutOfBoundsException If the specified {@code index}
140 * argument is negative, or if it is greater than or equal to the
141 * length of the specified array
142 */
143 public static Object get(Object array, int index)
144 throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
145 Class<?> componentType = array.getClass().getComponentType();
146 if (componentType != null && !componentType.isPrimitive()) {
147 Object[] objArray = (Object[]) array.getClass().cast(array);
148 return objArray[index];
149 } else {
150 return getReferenceOrPrimitive(array, index);
151 }
152 }
153
154 private static native Object getReferenceOrPrimitive(Object array, int index);
155
156 /**
157 * Returns the value of the indexed component in the specified
158 * array object, as a {@code boolean}.
159 *
160 * @param array the array
161 * @param index the index
162 * @return the value of the indexed component in the specified array
163 * @throws NullPointerException If the specified object is null
164 * @throws IllegalArgumentException If the specified object is not
165 * an array, or if the indexed element cannot be converted to the
166 * return type by an identity or widening conversion
167 * @throws ArrayIndexOutOfBoundsException If the specified {@code index}
168 * argument is negative, or if it is greater than or equal to the
169 * length of the specified array
170 * @see Array#get
171 */
172 public static native boolean getBoolean(Object array, int index)
173 throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
174
305 public static native double getDouble(Object array, int index)
306 throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
307
308 /**
309 * Sets the value of the indexed component of the specified array
310 * object to the specified new value. The new value is first
311 * automatically unwrapped if the array has a primitive component
312 * type.
313 * @param array the array
314 * @param index the index into the array
315 * @param value the new value of the indexed component
316 * @throws NullPointerException If the specified object argument
317 * is null
318 * @throws IllegalArgumentException If the specified object argument
319 * is not an array, or if the array component type is primitive and
320 * an unwrapping conversion fails
321 * @throws ArrayIndexOutOfBoundsException If the specified {@code index}
322 * argument is negative, or if it is greater than or equal to
323 * the length of the specified array
324 */
325 public static void set(Object array, int index, Object value)
326 throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
327 Class<?> componentType = array.getClass().getComponentType();
328 if (componentType != null && !componentType.isPrimitive()) {
329 Object[] objArray = (Object[]) array.getClass().cast(array);
330 objArray[index] = componentType.cast(value);
331 } else {
332 setReferenceOrPrimitive(array, index, value);
333 }
334 }
335
336 private static native void setReferenceOrPrimitive(Object array, int index, Object value);
337
338 /**
339 * Sets the value of the indexed component of the specified array
340 * object to the specified {@code boolean} value.
341 * @param array the array
342 * @param index the index into the array
343 * @param z the new value of the indexed component
344 * @throws NullPointerException If the specified object argument
345 * is null
346 * @throws IllegalArgumentException If the specified object argument
347 * is not an array, or if the specified value cannot be converted
348 * to the underlying array's component type by an identity or a
349 * primitive widening conversion
350 * @throws ArrayIndexOutOfBoundsException If the specified {@code index}
351 * argument is negative, or if it is greater than or equal to
352 * the length of the specified array
353 * @see Array#set
354 */
355 public static native void setBoolean(Object array, int index, boolean z)
356 throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
|