-
Notifications
You must be signed in to change notification settings - Fork 176
8387304: [lworld] Review the specs of reflective preview APIs #2578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lworld
Are you sure you want to change the base?
Changes from 1 commit
95a4575
78e4042
3108aa3
7d5bb86
49b93e3
f263239
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -632,6 +632,13 @@ public static Class<?> forName(Module module, String name) { | |
| * {@code Class} object represents an interface, array type, primitive type, | ||
| * or {@code void}, the result is {@code false}. | ||
| * | ||
| * <p>This method returns {@code true} if and only if this {@code Class} | ||
| * object represents a class that uses preview features, and the class does | ||
| * not have the {@link AccessFlag#IDENTITY ACC_IDENTITY} flag set. | ||
| * The {@code ACC_IDENTITY} flag is considered always set for a class that | ||
| * does not use preview features; consequently, this method always returns | ||
| * {@code false} when preview features are disabled. | ||
| * | ||
| * @jls value-objects-8.1.1.5 {@code value} Classes | ||
| * @see AccessFlag#IDENTITY | ||
| * @since 28 | ||
|
|
@@ -1369,7 +1376,7 @@ private Class<?> elementType() { | |
| * {@code true} | ||
| * <li> its interface modifier is always {@code false}, even when | ||
| * the component type is an interface | ||
| * <li> when preview features are enabled, its {@linkplain | ||
| * <li> when preview features are enabled, its {@link | ||
| * AccessFlag#IDENTITY identity} modifier is always true | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it's now a link then maybe "identity" should be "IDENTITY". I realize the other non-link usages are "identity". |
||
| * </ul> | ||
| * If this {@code Class} object represents a primitive type or | ||
|
|
@@ -1379,9 +1386,39 @@ private Class<?> elementType() { | |
| * arrays, the values of other modifiers are {@code false} other | ||
| * than as specified above. | ||
| * | ||
| * <div class="preview-block"> | ||
| * <div class="preview-comment"> | ||
| * When preview features are enabled, if this {@code Class} object | ||
| * represents a class that does not use preview features or an | ||
|
liach marked this conversation as resolved.
Outdated
|
||
| * array type, its {@code identity} modifier is always true. | ||
| * <p> | ||
| * When preview features are disabled, such a {@code Class} object | ||
| * does not have its {@code identity} modifier set. | ||
| * </div> | ||
| * </div> | ||
| * | ||
| * <p> The modifier encodings are defined in section {@jvms 4.1} | ||
| * of <cite>The Java Virtual Machine Specification</cite>. | ||
| * | ||
| * @apiNote | ||
| * <div class="preview-block"> | ||
| * <div class="preview-comment"> | ||
| * Developers should be aware that the presence of the {@code | ||
| * identity} modifier is dependent on whether preview features are | ||
| * enabled, a status not accessible to programs. The preferred way | ||
| * to check for the identity status is to use {@link #isValue() | ||
| * Class.isValue()}. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better to drop "a status not accessible to programs", it will just anger developers. Can the second sentence just use "Use the isValue method to test if a value class or identity class"? |
||
| * <p> | ||
| * This snippet below checks whether a given {@code Class<?> clazz} | ||
| * would have its {@code identity} modifier set when preview | ||
| * features are enabled, yet behaves consistently regardless of | ||
| * whether preview features are enabled. | ||
| * {@snippet lang=java : | ||
| * !clazz.isPrimitive() && !clazz.isValue() && !clazz.isInterface() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea to include this snippet as it is useful to have. |
||
| * } | ||
| * </div> | ||
| * </div> | ||
| * | ||
| * @return the {@code int} representing the modifiers for this class | ||
| * @see java.lang.reflect.Modifier | ||
| * @see #accessFlags() | ||
|
|
@@ -1415,6 +1452,36 @@ private Class<?> elementType() { | |
| * For {@code Class} objects representing void, primitive types, and | ||
| * arrays, access flags are absent other than as specified above. | ||
| * | ||
| * <div class="preview-block"> | ||
| * <div class="preview-comment"> | ||
| * When preview features are enabled, if this {@code Class} object | ||
| * represents a class that does not use preview features or an | ||
|
liach marked this conversation as resolved.
Outdated
|
||
| * array type, its flags always include {@code IDENTITY}. | ||
| * <p> | ||
| * When preview features are disabled, such a {@code Class} object | ||
| * does not have the {@code IDENTITY} flag set. | ||
| * </div> | ||
| * </div> | ||
| * | ||
| * @apiNote | ||
| * <div class="preview-block"> | ||
| * <div class="preview-comment"> | ||
| * Developers should be aware that the presence of the {@code | ||
| * IDENTITY} flag is dependent on whether preview features are | ||
| * enabled, a status not accessible to programs. The preferred way | ||
| * to check for the identity status is to use {@link #isValue() | ||
| * Class.isValue()}. | ||
| * <p> | ||
| * This snippet below checks whether a given {@code Class<?> clazz} | ||
| * would have its {@code IDENTITY} modifier set when preview | ||
| * features are enabled, yet behaves consistently regardless of | ||
| * whether preview features are enabled. | ||
| * {@snippet lang=java : | ||
| * !clazz.isPrimitive() && !clazz.isValue() && !clazz.isInterface() | ||
| * } | ||
| * </div> | ||
| * </div> | ||
| * | ||
| * @see #getModifiers() | ||
| * @jvms 4.1 The ClassFile Structure | ||
| * @jvms 4.7.6 The InnerClasses Attribute | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,11 @@ public sealed interface StackMapFrameInfo | |
|
|
||
| /** | ||
| * {@return the expanded unset fields} | ||
| * <p> | ||
| * If a stack map frame in a {@code class} file has a non-empty list of | ||
| * unset fields, the {@code class} file must declare it uses preview | ||
| * features. The list of unset fields is always empty for a stack map frame | ||
| * declared in a {@code class} file that does not use preview features. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be a bit more readable to swap the sentences so that it's initially clear that the list is always empty when they class does not use preview features. It may be non-empty when the class uses preview features. Just a suggestion as I had to read the paragraph a few times to digest it. |
||
| * | ||
| * @jvms strict-fields-4.7.4 The {@code StackMapTable} Attribute | ||
| * @since 28 | ||
|
|
@@ -107,6 +112,12 @@ public static StackMapFrameInfo of(Label target, | |
|
|
||
| /** | ||
| * {@return a new stack map frame} | ||
| * <p> | ||
| * If a stack map frame in a {@code class} file has a non-empty list of | ||
| * unset fields, the {@code class} file must declare it uses preview | ||
| * features. The list of unset fields is always empty for a stack map frame | ||
| * declared in a {@code class} file that does not use preview features. | ||
| * | ||
| * @param target the location of the frame | ||
| * @param locals the complete list of frame locals | ||
| * @param stack the complete frame stack | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,11 +285,12 @@ public boolean isSynthetic() { | |
| * Returns {@code true} if this field is a strictly-initialized field; | ||
| * returns {@code false} otherwise. | ||
| * | ||
| * <p>This method returns {@code true} if and only if preview features are | ||
| * enabled and this field is a strictly-initialized field. The | ||
| * {@link AccessFlag#STRICT_INIT ACC_STRICT_INIT} flag is considered not set | ||
| * when preview features are disabled; consequently, this method always | ||
| * returns {@code false} when preview features are disabled. | ||
| * <p>This method returns {@code true} if and only if the class or interface | ||
| * that declares this field uses preview features and this field is a | ||
| * strictly-initialized field. The {@link AccessFlag#STRICT_INIT | ||
| * ACC_STRICT_INIT} flag is considered not set for a field declared in a | ||
| * class or interface that does not use preview features; consequently, | ||
| * this method always returns {@code false} when preview features are disabled. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good, this is an improvement on what we had previously. |
||
| * | ||
| * @return {@code true} if and only if this field is a strictly-initialized | ||
| * field, as defined by the Java Virtual Machine Specification | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,12 @@ public static String toIdentityString(Object o) { | |
| * {@code false}. All other objects, including arrays, are identity objects | ||
| * and the result will be {@code true}. | ||
| * | ||
| * <p>This method returns {@code false} if and only if the parameter is | ||
| * {@code null} or if the parameter represents a value object when preview | ||
| * features are enabled. Value objects do not exist when preview features | ||
| * are disabled; consequently, this method behaves the same as {@link | ||
| * #nonNull Objects.nonNull} when preview features are disabled. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Value objects do not exist when preview features are disabled". What would you think about just saying that "All objects are identity objects when preview features are disabled"? |
||
| * | ||
| * @apiNote | ||
| * If the parameter is {@code null}, there is no object | ||
| * and hence no identity; the result is {@code false}. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good.