[lworld] RFR: 8287692: Move Class primitive APIs to jdk.internal.value.PrimitiveClass
Mandy Chung
mchung at openjdk.java.net
Fri Jun 3 22:02:03 UTC 2022
On Fri, 3 Jun 2022 19:07:52 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> To avoid confusion with the reflection support for [Value Objects](https://bugs.openjdk.java.net/browse/JDK-8277163)
> the java.lang.Class APIs in support of JEP 401 (Primitive Objects) should be hidden.
>
> The methods `Class.asValueType`, `asPrimaryType`, `isPrimaryType`, `isPrimitiveClass`, and `asPrimitiveValueType`
> are moved to be static methods of `jdk.internal.value.PrimitiveClass`.
>
> To access those methods, add `--exports java.base/jdk.internal.value:+open` to the command line
> in addition to other flags needed to enable Primitive Objects and convert to invoke them as static methods with the class.
>
> The openjdk classes and tests are modified to use the alternate API.
Looks okay. Thanks for taking this one. Lots of renaming.
src/java.base/share/classes/jdk/internal/value/PrimitiveClass.java line 2:
> 1: /*
> 2: * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
2022 is the start year.
src/java.base/share/classes/jdk/internal/value/PrimitiveClass.java line 62:
> 60: * @since Valhalla
> 61: */
> 62: @IntrinsicCandidate
The compiler intrinsic is for the method in `java.lang.Class`. So the annotation should be dropped. Same for `asValueType`.
src/java.base/share/classes/jdk/internal/value/PrimitiveClass.java line 84:
> 82: public static <T> Class<?> asValueType(Class<T> aClass) {
> 83: return javaLangAccess.asValueType(aClass);
> 84:
I guess this empty line is not intended? Same for iine 109
src/java.base/share/classes/jdk/internal/value/PrimitiveClass.java line 145:
> 143: */
> 144: public static <T> boolean isPrimitiveClass(Class<T> aClass) {
> 145: return (aClass.getModifiers() & PRIMITIVE_CLASS) != 0;
why not including `isPrimitiveClass` in the shared secret as other methods?
src/java.base/share/classes/sun/invoke/util/VerifyAccess.java line 31:
> 29: import static java.lang.reflect.Modifier.*;
> 30:
> 31: import jdk.internal.value.PrimitiveClass;
nit: sorted in an alphabetic order (though not always apply in other files)
test/jdk/java/lang/invoke/TEST.properties line 5:
> 3:
> 4: # Reflection methods for primitive classes are in PrimitiveClass instead of java.lang.class
> 5: modules = java.base/jdk.internal.value:+open
which test needs to reflective access to `jdk.internal.value.PrimitiveClass`? The methods are public and I don't expect they need any reflective access.
test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.java line 5:
> 3: * @bug 8221323
> 4: * @summary Javac should support class literals for projection types.
> 5: * @modules java.base/jdk.internal.value:+open
This and the import is not needed.
test/langtools/tools/javac/valhalla/lworld-values/TestReflectiveMirrors.java line 30:
> 28: * @bug 8269956
> 29: * @summary javac should generate `ldc LPoint;` for class literal Point.class
> 30: * @modules java.base/jdk.internal.value:+open
This test does not need reflective access. `@modules java.base/jdk.internal.value` should work. Same applies to other tests.
-------------
PR: https://git.openjdk.java.net/valhalla/pull/704
More information about the valhalla-dev
mailing list