< prev index next >
src/java.base/share/classes/java/lang/Class.java
Print this page
@@ -56,10 +56,11 @@
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Set;
import java.util.StringJoiner;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.loader.BootLoader;
import jdk.internal.loader.BuiltinClassLoader;
@@ -456,11 +457,10 @@
/**
* Returns {@code true} if this class is a value class.
*
* @return {@code true} if this class is a value class.
- * @since 11
*/
public boolean isValue() {
int mods = this.getModifiers();
if ((mods & VALUE_TYPE) != 0) {
if ((mods & (Modifier.INTERFACE | Modifier.ABSTRACT)) != 0) {
@@ -473,10 +473,33 @@
}
return false;
}
/**
+ * Returns the names listed in the {@code "ValueTypes"} attribute.
+ */
+ Set<String> getDeclaredValueTypeNames() {
+ Set<String> names = declaredValueTypeNames;
+ if (names == null) {
+ String[] lvts = getLocalValueTypes0();
+ if (lvts != null) {
+ for (int i=0; i < lvts.length; i++) {
+ lvts[i] = lvts[i].replace('/', '.');
+ }
+ names = Set.of(lvts);
+ } else {
+ names = Set.of();
+ }
+ declaredValueTypeNames = names;
+ }
+ return declaredValueTypeNames;
+ }
+
+ private transient volatile Set<String> declaredValueTypeNames;
+ private native String[] getLocalValueTypes0();
+
+ /**
* Creates a new instance of the class represented by this {@code Class}
* object. The class is instantiated as if by a {@code new}
* expression with an empty argument list. The class is initialized if it
* has not already been initialized.
*
< prev index next >