Skip to content

Commit a30f387

Browse files
committed
Minor cleanup, preview and since
Reviewed-by: vromero
1 parent 67758d3 commit a30f387

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/java.base/share/classes/java/lang/reflect/Array.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ public static Object newInstance(Class<?> componentType, int... dimensions)
147147
* @throws ArrayStoreException if a component of {@code sourceArray} cannot
148148
* be stored into the new array because of a type mismatch.
149149
* @throws NegativeArraySizeException if {@code length < 0}
150+
* @since Valhalla
150151
*/
151-
@PreviewFeature(feature = Feature.VALUE_OBJECTS)
152+
@PreviewFeature(feature = Feature.NULL_RESTRICTION)
152153
public static Object newInstance(Class<?> componentType, int modifiers, int length,
153154
Object sourceArray, int sourceOffset) {
154155
// modifiers may be ignored for now
@@ -162,8 +163,7 @@ public static Object newInstance(Class<?> componentType, int modifiers, int leng
162163
Object newArray;
163164
if ((modifiers & NULL_CHECKED) != 0 &&
164165
length > 0 &&
165-
componentType.isValue() &&
166-
Modifier.isFinal(componentType.getModifiers())) {
166+
ValueClass.isConcreteValueClass(componentType)) {
167167
newArray = ValueClass.newNullRestrictedAtomicArray(
168168
componentType, length, get(sourceArray, 0));
169169
} else {

src/java.base/share/classes/java/lang/reflect/NullRestrictedType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@
3535
* <p>Instances of classes that implement this interface must implement
3636
* an equals() method that equates any two null restricted type instances that
3737
* share the same base type.
38+
*
39+
* @since Valhalla
3840
*/
39-
@PreviewFeature(feature = Feature.VALUE_OBJECTS, reflective = true)
41+
@PreviewFeature(feature = Feature.NULL_RESTRICTION, reflective = true)
4042
public interface NullRestrictedType extends Type {
4143
/**
4244
* {@return the {@code Type} object representing the type to which the null-restriction has

src/java.base/share/classes/java/lang/runtime/ArrayCreation.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import jdk.internal.javac.PreviewFeature;
2929
import jdk.internal.javac.PreviewFeature.Feature;
3030
import java.lang.reflect.Array;
31-
import java.lang.reflect.Modifier;
3231
import java.util.Arrays;
3332
import java.util.List;
3433
import java.util.Collections;
@@ -40,9 +39,11 @@
4039

4140
/**
4241
* Factory and bootstrap methods for strictly-initialized array creation.
42+
*
43+
* @since Valhalla
4344
*/
44-
@PreviewFeature(reflective = true, feature = Feature.VALUE_OBJECTS)
45-
public class ArrayCreation {
45+
@PreviewFeature(reflective = true, feature = Feature.NULL_RESTRICTION)
46+
public final class ArrayCreation {
4647

4748
private ArrayCreation() {}
4849

src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public enum Feature {
6767
@JEP(number=401, title="Value Classes and Objects", status = "Preview")
6868
VALUE_OBJECTS,
6969

70+
@JEP(number=8303099, title="Null-Restricted and Nullable Types", status = "Preview")
71+
NULL_RESTRICTION,
72+
7073
// The JDK build process involves creating an interim javac which is then
7174
// used to compile the rest of the JDK. The jdk.internal.javac.PreviewFeature
7275
// annotation from the current sources is used when compiling interim javac.

0 commit comments

Comments
 (0)