Skip to content
Closed
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ oop java_lang_Class::primitive_mirror(BasicType t) {
macro(_signers_offset, k, "signers", object_array_signature, false); \
macro(_modifiers_offset, k, vmSymbols::modifiers_name(), char_signature, false); \
macro(_protection_domain_offset, k, "protectionDomain", java_security_ProtectionDomain_signature, false); \
macro(_is_primitive_offset, k, "isPrimitiveType", bool_signature, false);
macro(_is_primitive_offset, k, "primitive", bool_signature, false);

void java_lang_Class::compute_offsets() {
if (_offsets_computed) {
Expand Down
12 changes: 7 additions & 5 deletions src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ private static void runtimeSetup() {
* This constructor is not used and prevents the default constructor being
* generated.
*/
private Class(ClassLoader loader, Class<?> arrayComponentType, char mods, ProtectionDomain pd, boolean primitive) {
private Class(ClassLoader loader, Class<?> arrayComponentType, char mods, ProtectionDomain pd, boolean isPrim) {
// Initialize final field for classLoader. The initialization value of non-null
// prevents future JIT optimizations from assuming this final field is null.
classLoader = loader;
componentType = arrayComponentType;
modifiers = mods;
protectionDomain = pd;
isPrimitiveType = primitive;
primitive = isPrim;
}

/**
Expand Down Expand Up @@ -847,7 +847,7 @@ public boolean isArray() {
* @jls 15.8.2 Class Literals
*/
public boolean isPrimitive() {
return isPrimitiveType;
return primitive;
}

/**
Expand Down Expand Up @@ -1007,7 +1007,7 @@ public Module getModule() {
private transient Object classData; // Set by VM
private transient Object[] signers; // Read by VM, mutable
private final transient char modifiers; // Set by the VM
private final transient boolean isPrimitiveType; // Set by the VM
private final transient boolean primitive; // Set by the VM if the Class is a primitive type.

// package-private
Object getClassData() {
Expand Down Expand Up @@ -1292,7 +1292,9 @@ public Class<?> getComponentType() {
return componentType;
}

private final Class<?> componentType;
// The componentType field's null value is the sole indication that the class is an array,
// see isArray().
private transient final Class<?> componentType;

/*
* Returns the {@code Class} representing the element type of an array class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class Reflection {
fieldFilterMap = Map.of(
Reflection.class, ALL_MEMBERS,
AccessibleObject.class, ALL_MEMBERS,
Class.class, Set.of("classLoader", "classData", "modifiers", "protectionDomain", "isPrimitiveType"),
Class.class, Set.of("classLoader", "classData", "modifiers", "protectionDomain", "primitive"),
ClassLoader.class, ALL_MEMBERS,
Constructor.class, ALL_MEMBERS,
Field.class, ALL_MEMBERS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ private static boolean isHiddenFromReflection(ResolvedJavaField f) {
name.equals("classData") ||
name.equals("modifiers") ||
name.equals("protectionDomain") ||
name.equals("isPrimitiveType");
name.equals("primitive");
}
if (f.getDeclaringClass().equals(metaAccess.lookupJavaType(Lookup.class))) {
return f.getName().equals("allowedModes") || f.getName().equals("lookupClass");
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/jdk/internal/reflect/Reflection/Filtering.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private Object[][] sensitiveFields() {
{ Class.class, "classData" },
{ Class.class, "modifiers" },
{ Class.class, "protectionDomain" },
{ Class.class, "isPrimitiveType" },
{ Class.class, "primitive" },
{ ClassLoader.class, "parent" },
{ Field.class, "clazz" },
{ Field.class, "modifiers" },
Expand Down