From 9f92561737d33dab6ced596654566feb9dad5fb8 Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Tue, 28 Oct 2025 17:10:13 -0500 Subject: [PATCH 1/6] 4517644: (reflect spec) Array.set documentation hole for array/value ref type mismatch --- .../classes/java/lang/reflect/Array.java | 47 +++++++--- .../classes/java/lang/reflect/Field.java | 85 ++++++++++--------- 2 files changed, 76 insertions(+), 56 deletions(-) diff --git a/src/java.base/share/classes/java/lang/reflect/Array.java b/src/java.base/share/classes/java/lang/reflect/Array.java index 2fbad52c37402..d175cde635780 100644 --- a/src/java.base/share/classes/java/lang/reflect/Array.java +++ b/src/java.base/share/classes/java/lang/reflect/Array.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -297,17 +297,20 @@ public static native double getDouble(Object array, int index) /** * Sets the value of the indexed component of the specified array - * object to the specified new value. The new value is first - * automatically unwrapped if the array has a primitive component - * type. + * object to the specified new value. If the array has a primitive + * component type, the new value is first converted to a value of a + * primitive type by an unboxing conversion. The possibly unboxed new + * value is converted to the array's component type by an identity or + * widening conversion and stored into the array. + * * @param array the array * @param index the index into the array * @param value the new value of the indexed component * @throws NullPointerException If the specified object argument * is null * @throws IllegalArgumentException If the specified object argument - * is not an array, or if the array component type is primitive and - * an unwrapping conversion fails + * is not an array, if the array component type is primitive and the + * unboxing conversion fails, or if the identity or widening conversion fails * @throws ArrayIndexOutOfBoundsException If the specified {@code index} * argument is negative, or if it is greater than or equal to * the length of the specified array @@ -317,7 +320,9 @@ public static native void set(Object array, int index, Object value) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code boolean} value. + * object to the specified {@code boolean} value. This method never performs + * a boxing conversion. + * * @param array the array * @param index the index into the array * @param z the new value of the indexed component @@ -337,7 +342,9 @@ public static native void setBoolean(Object array, int index, boolean z) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code byte} value. + * object to the specified {@code byte} value. This method never performs + * a boxing conversion. + * * @param array the array * @param index the index into the array * @param b the new value of the indexed component @@ -357,7 +364,9 @@ public static native void setByte(Object array, int index, byte b) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code char} value. + * object to the specified {@code char} value. This method never performs + * a boxing conversion. + * * @param array the array * @param index the index into the array * @param c the new value of the indexed component @@ -377,7 +386,9 @@ public static native void setChar(Object array, int index, char c) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code short} value. + * object to the specified {@code short} value. This method never performs + * a boxing conversion. + * * @param array the array * @param index the index into the array * @param s the new value of the indexed component @@ -397,7 +408,9 @@ public static native void setShort(Object array, int index, short s) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code int} value. + * object to the specified {@code int} value. This method never performs + * a boxing conversion. + * * @param array the array * @param index the index into the array * @param i the new value of the indexed component @@ -417,7 +430,9 @@ public static native void setInt(Object array, int index, int i) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code long} value. + * object to the specified {@code long} value. This method never performs + * a boxing conversion. + * * @param array the array * @param index the index into the array * @param l the new value of the indexed component @@ -437,7 +452,9 @@ public static native void setLong(Object array, int index, long l) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code float} value. + * object to the specified {@code float} value. This method never performs + * a boxing conversion. + * * @param array the array * @param index the index into the array * @param f the new value of the indexed component @@ -457,7 +474,9 @@ public static native void setFloat(Object array, int index, float f) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code double} value. + * object to the specified {@code double} value. This method never performs + * a boxing conversion. + * * @param array the array * @param index the index into the array * @param d the new value of the indexed component diff --git a/src/java.base/share/classes/java/lang/reflect/Field.java b/src/java.base/share/classes/java/lang/reflect/Field.java index e26d8b03ff8aa..ba9ffdb30e768 100644 --- a/src/java.base/share/classes/java/lang/reflect/Field.java +++ b/src/java.base/share/classes/java/lang/reflect/Field.java @@ -812,8 +812,9 @@ public double getDouble(Object obj) * or if this {@code Field} object has no write access. * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying - * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * field (or a subclass or implementor thereof), if an + * unboxing conversion fails, or if the identity or widening + * conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked @@ -835,10 +836,10 @@ public void set(Object obj, Object value) /** * Sets the value of a field as a {@code boolean} on the specified object. - * This method is equivalent to - * {@code set(obj, zObj)}, - * where {@code zObj} is a {@code Boolean} object and - * {@code zObj.booleanValue() == z}. + * If this field is of a primitive type, this method is equivalent to + * {@code set(obj, zObj)}, where {@code zObj} is a {@code Boolean} object + * and {@code zObj.booleanValue() == z}. This method never performs a boxing + * conversion. * * @param obj the object whose field should be modified * @param z the new value for the field of {@code obj} @@ -851,7 +852,7 @@ public void set(Object obj, Object value) * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * or if an identity or primitive widening conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked @@ -874,10 +875,10 @@ public void setBoolean(Object obj, boolean z) /** * Sets the value of a field as a {@code byte} on the specified object. - * This method is equivalent to - * {@code set(obj, bObj)}, - * where {@code bObj} is a {@code Byte} object and - * {@code bObj.byteValue() == b}. + * If this field is of a primitive type, this method is equivalent to + * {@code set(obj, bObj)}, where {@code bObj} is a {@code Byte} object and + * {@code bObj.byteValue() == b}. This method never performs a boxing + * conversion. * * @param obj the object whose field should be modified * @param b the new value for the field of {@code obj} @@ -890,7 +891,7 @@ public void setBoolean(Object obj, boolean z) * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * or if an identity or primitive widening conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked @@ -913,10 +914,10 @@ public void setByte(Object obj, byte b) /** * Sets the value of a field as a {@code char} on the specified object. - * This method is equivalent to - * {@code set(obj, cObj)}, - * where {@code cObj} is a {@code Character} object and - * {@code cObj.charValue() == c}. + * If this field is of a primitive type, this method is equivalent to + * {@code set(obj, cObj)}, where {@code cObj} is a {@code Character} object + * and {@code cObj.charValue() == c}. This method never performs a boxing + * conversion. * * @param obj the object whose field should be modified * @param c the new value for the field of {@code obj} @@ -929,7 +930,7 @@ public void setByte(Object obj, byte b) * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * or if an identity or primitive widening conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked @@ -952,10 +953,10 @@ public void setChar(Object obj, char c) /** * Sets the value of a field as a {@code short} on the specified object. - * This method is equivalent to - * {@code set(obj, sObj)}, - * where {@code sObj} is a {@code Short} object and - * {@code sObj.shortValue() == s}. + * If this field is of a primitive type, this method is equivalent to + * {@code set(obj, sObj)}, where {@code sObj} is a {@code Short} object and + * {@code sObj.shortValue() == s}. This method never performs a boxing + * conversion. * * @param obj the object whose field should be modified * @param s the new value for the field of {@code obj} @@ -968,7 +969,7 @@ public void setChar(Object obj, char c) * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * or if an identity or primitive widening conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked @@ -991,10 +992,10 @@ public void setShort(Object obj, short s) /** * Sets the value of a field as an {@code int} on the specified object. - * This method is equivalent to - * {@code set(obj, iObj)}, - * where {@code iObj} is an {@code Integer} object and - * {@code iObj.intValue() == i}. + * If this field is of a primitive type, this method is equivalent to + * {@code set(obj, iObj)}, where {@code iObj} is an {@code Integer} object + * and {@code iObj.intValue() == i}. This method never performs a boxing + * conversion. * * @param obj the object whose field should be modified * @param i the new value for the field of {@code obj} @@ -1007,7 +1008,7 @@ public void setShort(Object obj, short s) * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * or if an identity or primitive widening conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked @@ -1030,10 +1031,10 @@ public void setInt(Object obj, int i) /** * Sets the value of a field as a {@code long} on the specified object. - * This method is equivalent to - * {@code set(obj, lObj)}, - * where {@code lObj} is a {@code Long} object and - * {@code lObj.longValue() == l}. + * If this field is of a primitive type, this method is equivalent to + * {@code set(obj, lObj)}, where {@code lObj} is a {@code Long} object and + * {@code lObj.longValue() == l}. This method never performs a boxing + * conversion. * * @param obj the object whose field should be modified * @param l the new value for the field of {@code obj} @@ -1046,7 +1047,7 @@ public void setInt(Object obj, int i) * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * or if an identity or primitive widening conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked @@ -1069,10 +1070,10 @@ public void setLong(Object obj, long l) /** * Sets the value of a field as a {@code float} on the specified object. - * This method is equivalent to - * {@code set(obj, fObj)}, - * where {@code fObj} is a {@code Float} object and - * {@code fObj.floatValue() == f}. + * If this field is of a primitive type, this method is equivalent to + * {@code set(obj, fObj)}, where {@code fObj} is a {@code Float} object and + * {@code fObj.floatValue() == f}. This method never performs a boxing + * conversion. * * @param obj the object whose field should be modified * @param f the new value for the field of {@code obj} @@ -1085,7 +1086,7 @@ public void setLong(Object obj, long l) * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * or if an identity or primitive widening conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked @@ -1108,10 +1109,10 @@ public void setFloat(Object obj, float f) /** * Sets the value of a field as a {@code double} on the specified object. - * This method is equivalent to - * {@code set(obj, dObj)}, - * where {@code dObj} is a {@code Double} object and - * {@code dObj.doubleValue() == d}. + * If this field is of a primitive type, this method is equivalent to + * {@code set(obj, dObj)}, where {@code dObj} is a {@code Double} object and + * {@code dObj.doubleValue() == d}. This method never performs a boxing + * conversion. * * @param obj the object whose field should be modified * @param d the new value for the field of {@code obj} @@ -1124,7 +1125,7 @@ public void setFloat(Object obj, float f) * @throws IllegalArgumentException if the specified object is not an * instance of the class or interface declaring the underlying * field (or a subclass or implementor thereof), - * or if an unwrapping conversion fails. + * or if an identity or primitive widening conversion fails * @throws NullPointerException if the specified object is null * and the field is an instance field. * @throws ExceptionInInitializerError if the initialization provoked From 5559e613e15fcc09e3379d261575823a8f8488e7 Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Wed, 29 Oct 2025 09:40:12 -0500 Subject: [PATCH 2/6] the narrowing conversion restriction is primitive-only --- src/java.base/share/classes/java/lang/reflect/Field.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/java/lang/reflect/Field.java b/src/java.base/share/classes/java/lang/reflect/Field.java index ba9ffdb30e768..e5e0398cebe45 100644 --- a/src/java.base/share/classes/java/lang/reflect/Field.java +++ b/src/java.base/share/classes/java/lang/reflect/Field.java @@ -49,9 +49,9 @@ * single field of a class or an interface. The reflected field may * be a class (static) field or an instance field. * - *

A {@code Field} permits widening conversions to occur during a get or - * set access operation, but throws an {@code IllegalArgumentException} if a - * narrowing conversion would occur. + *

A {@code Field} permits widening primitive conversions to occur during a + * primitive get or set access operation, but throws an {@code IllegalArgumentException} + * if a narrowing primitive conversion would occur. * * @see Member * @see java.lang.Class From 3bae1f5a39ac954cb81b3fa98423d9abb332ce49 Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Thu, 6 Nov 2025 13:08:44 -0600 Subject: [PATCH 3/6] Stuff for the class spec --- .../classes/java/lang/reflect/Array.java | 63 +++++++++++----- .../classes/java/lang/reflect/Field.java | 75 +++++++++++-------- 2 files changed, 89 insertions(+), 49 deletions(-) diff --git a/src/java.base/share/classes/java/lang/reflect/Array.java b/src/java.base/share/classes/java/lang/reflect/Array.java index d175cde635780..95b28c9ff9118 100644 --- a/src/java.base/share/classes/java/lang/reflect/Array.java +++ b/src/java.base/share/classes/java/lang/reflect/Array.java @@ -31,9 +31,42 @@ * The {@code Array} class provides static methods to dynamically create and * access Java arrays. * - *

{@code Array} permits widening conversions to occur during a get or set - * operation, but throws an {@code IllegalArgumentException} if a narrowing - * conversion would occur. + *

+ * {@code Array} declares {@link #get get} and {@link #set set} access + * operations with overloads for all primitive types. They convert their + * argument and return values depending on whether the array's component type + * is primitive or reference: + *

* * @author Nakul Saraiya * @since 1.1 @@ -320,8 +353,7 @@ public static native void set(Object array, int index, Object value) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code boolean} value. This method never performs - * a boxing conversion. + * object to the specified {@code boolean} value. * * @param array the array * @param index the index into the array @@ -342,8 +374,7 @@ public static native void setBoolean(Object array, int index, boolean z) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code byte} value. This method never performs - * a boxing conversion. + * object to the specified {@code byte} value. * * @param array the array * @param index the index into the array @@ -364,8 +395,7 @@ public static native void setByte(Object array, int index, byte b) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code char} value. This method never performs - * a boxing conversion. + * object to the specified {@code char} value. * * @param array the array * @param index the index into the array @@ -386,8 +416,7 @@ public static native void setChar(Object array, int index, char c) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code short} value. This method never performs - * a boxing conversion. + * object to the specified {@code short} value. * * @param array the array * @param index the index into the array @@ -408,8 +437,7 @@ public static native void setShort(Object array, int index, short s) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code int} value. This method never performs - * a boxing conversion. + * object to the specified {@code int} value. * * @param array the array * @param index the index into the array @@ -430,8 +458,7 @@ public static native void setInt(Object array, int index, int i) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code long} value. This method never performs - * a boxing conversion. + * object to the specified {@code long} value. * * @param array the array * @param index the index into the array @@ -452,8 +479,7 @@ public static native void setLong(Object array, int index, long l) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code float} value. This method never performs - * a boxing conversion. + * object to the specified {@code float} value. * * @param array the array * @param index the index into the array @@ -474,8 +500,7 @@ public static native void setFloat(Object array, int index, float f) /** * Sets the value of the indexed component of the specified array - * object to the specified {@code double} value. This method never performs - * a boxing conversion. + * object to the specified {@code double} value. * * @param array the array * @param index the index into the array diff --git a/src/java.base/share/classes/java/lang/reflect/Field.java b/src/java.base/share/classes/java/lang/reflect/Field.java index e5e0398cebe45..552acbccca4b4 100644 --- a/src/java.base/share/classes/java/lang/reflect/Field.java +++ b/src/java.base/share/classes/java/lang/reflect/Field.java @@ -48,10 +48,42 @@ * A {@code Field} provides information about, and dynamic access to, a * single field of a class or an interface. The reflected field may * be a class (static) field or an instance field. - * - *

A {@code Field} permits widening primitive conversions to occur during a - * primitive get or set access operation, but throws an {@code IllegalArgumentException} - * if a narrowing primitive conversion would occur. + *

+ * A {@code Field} declares {@link #get get} and {@link #set set} access + * operations with overloads for all primitive types. They convert their + * argument and return values depending on whether the underlying field is of a + * primitive or a reference type: + *

* * @see Member * @see java.lang.Class @@ -783,16 +815,7 @@ public double getDouble(Object obj) * any other context may have unpredictable effects, including cases * in which other parts of a program continue to use the original * value of this field. - * - *

If the underlying field is of a primitive type, an unwrapping - * conversion is attempted to convert the new value to a value of - * a primitive type. If this attempt fails, the method throws an - * {@code IllegalArgumentException}. - * - *

If, after possible unwrapping, the new value cannot be - * converted to the type of the underlying field by an identity or - * widening conversion, the method throws an - * {@code IllegalArgumentException}. + * *

If the underlying field is static, the class that declared the * field is initialized if it has not already been initialized. @@ -838,8 +861,7 @@ public void set(Object obj, Object value) * Sets the value of a field as a {@code boolean} on the specified object. * If this field is of a primitive type, this method is equivalent to * {@code set(obj, zObj)}, where {@code zObj} is a {@code Boolean} object - * and {@code zObj.booleanValue() == z}. This method never performs a boxing - * conversion. + * and {@code zObj.booleanValue() == z}. * * @param obj the object whose field should be modified * @param z the new value for the field of {@code obj} @@ -877,8 +899,7 @@ public void setBoolean(Object obj, boolean z) * Sets the value of a field as a {@code byte} on the specified object. * If this field is of a primitive type, this method is equivalent to * {@code set(obj, bObj)}, where {@code bObj} is a {@code Byte} object and - * {@code bObj.byteValue() == b}. This method never performs a boxing - * conversion. + * {@code bObj.byteValue() == b}. * * @param obj the object whose field should be modified * @param b the new value for the field of {@code obj} @@ -916,8 +937,7 @@ public void setByte(Object obj, byte b) * Sets the value of a field as a {@code char} on the specified object. * If this field is of a primitive type, this method is equivalent to * {@code set(obj, cObj)}, where {@code cObj} is a {@code Character} object - * and {@code cObj.charValue() == c}. This method never performs a boxing - * conversion. + * and {@code cObj.charValue() == c}. * * @param obj the object whose field should be modified * @param c the new value for the field of {@code obj} @@ -955,8 +975,7 @@ public void setChar(Object obj, char c) * Sets the value of a field as a {@code short} on the specified object. * If this field is of a primitive type, this method is equivalent to * {@code set(obj, sObj)}, where {@code sObj} is a {@code Short} object and - * {@code sObj.shortValue() == s}. This method never performs a boxing - * conversion. + * {@code sObj.shortValue() == s}. * * @param obj the object whose field should be modified * @param s the new value for the field of {@code obj} @@ -994,8 +1013,7 @@ public void setShort(Object obj, short s) * Sets the value of a field as an {@code int} on the specified object. * If this field is of a primitive type, this method is equivalent to * {@code set(obj, iObj)}, where {@code iObj} is an {@code Integer} object - * and {@code iObj.intValue() == i}. This method never performs a boxing - * conversion. + * and {@code iObj.intValue() == i}. * * @param obj the object whose field should be modified * @param i the new value for the field of {@code obj} @@ -1033,8 +1051,7 @@ public void setInt(Object obj, int i) * Sets the value of a field as a {@code long} on the specified object. * If this field is of a primitive type, this method is equivalent to * {@code set(obj, lObj)}, where {@code lObj} is a {@code Long} object and - * {@code lObj.longValue() == l}. This method never performs a boxing - * conversion. + * {@code lObj.longValue() == l}. * * @param obj the object whose field should be modified * @param l the new value for the field of {@code obj} @@ -1072,8 +1089,7 @@ public void setLong(Object obj, long l) * Sets the value of a field as a {@code float} on the specified object. * If this field is of a primitive type, this method is equivalent to * {@code set(obj, fObj)}, where {@code fObj} is a {@code Float} object and - * {@code fObj.floatValue() == f}. This method never performs a boxing - * conversion. + * {@code fObj.floatValue() == f}. * * @param obj the object whose field should be modified * @param f the new value for the field of {@code obj} @@ -1111,8 +1127,7 @@ public void setFloat(Object obj, float f) * Sets the value of a field as a {@code double} on the specified object. * If this field is of a primitive type, this method is equivalent to * {@code set(obj, dObj)}, where {@code dObj} is a {@code Double} object and - * {@code dObj.doubleValue() == d}. This method never performs a boxing - * conversion. + * {@code dObj.doubleValue() == d}. * * @param obj the object whose field should be modified * @param d the new value for the field of {@code obj} From 7652493f696a213e20f53e6470b06d7156cd07ae Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Thu, 6 Nov 2025 13:10:23 -0600 Subject: [PATCH 4/6] Redundant --- src/java.base/share/classes/java/lang/reflect/Array.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/java.base/share/classes/java/lang/reflect/Array.java b/src/java.base/share/classes/java/lang/reflect/Array.java index 95b28c9ff9118..a5b5ada33c88a 100644 --- a/src/java.base/share/classes/java/lang/reflect/Array.java +++ b/src/java.base/share/classes/java/lang/reflect/Array.java @@ -354,7 +354,6 @@ public static native void set(Object array, int index, Object value) /** * Sets the value of the indexed component of the specified array * object to the specified {@code boolean} value. - * * @param array the array * @param index the index into the array * @param z the new value of the indexed component @@ -375,7 +374,6 @@ public static native void setBoolean(Object array, int index, boolean z) /** * Sets the value of the indexed component of the specified array * object to the specified {@code byte} value. - * * @param array the array * @param index the index into the array * @param b the new value of the indexed component @@ -396,7 +394,6 @@ public static native void setByte(Object array, int index, byte b) /** * Sets the value of the indexed component of the specified array * object to the specified {@code char} value. - * * @param array the array * @param index the index into the array * @param c the new value of the indexed component @@ -417,7 +414,6 @@ public static native void setChar(Object array, int index, char c) /** * Sets the value of the indexed component of the specified array * object to the specified {@code short} value. - * * @param array the array * @param index the index into the array * @param s the new value of the indexed component @@ -438,7 +434,6 @@ public static native void setShort(Object array, int index, short s) /** * Sets the value of the indexed component of the specified array * object to the specified {@code int} value. - * * @param array the array * @param index the index into the array * @param i the new value of the indexed component @@ -459,7 +454,6 @@ public static native void setInt(Object array, int index, int i) /** * Sets the value of the indexed component of the specified array * object to the specified {@code long} value. - * * @param array the array * @param index the index into the array * @param l the new value of the indexed component @@ -480,7 +474,6 @@ public static native void setLong(Object array, int index, long l) /** * Sets the value of the indexed component of the specified array * object to the specified {@code float} value. - * * @param array the array * @param index the index into the array * @param f the new value of the indexed component @@ -501,7 +494,6 @@ public static native void setFloat(Object array, int index, float f) /** * Sets the value of the indexed component of the specified array * object to the specified {@code double} value. - * * @param array the array * @param index the index into the array * @param d the new value of the indexed component From 7a5a133160c48193b1098ea839cabab044613f4b Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Thu, 6 Nov 2025 14:18:31 -0600 Subject: [PATCH 5/6] Update --- .../classes/java/lang/reflect/Array.java | 35 ++++++++--------- .../classes/java/lang/reflect/Field.java | 38 ++++++++++--------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/java.base/share/classes/java/lang/reflect/Array.java b/src/java.base/share/classes/java/lang/reflect/Array.java index a5b5ada33c88a..e572987d1aad0 100644 --- a/src/java.base/share/classes/java/lang/reflect/Array.java +++ b/src/java.base/share/classes/java/lang/reflect/Array.java @@ -34,34 +34,34 @@ *

* {@code Array} declares {@link #get get} and {@link #set set} access * operations with overloads for all primitive types. They convert their - * argument and return values depending on whether the array's component type + * retrieved and new values depending on whether the array's component type * is primitive or reference: *