-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8364187: Make getClassAccessFlagsRaw non-native #26517
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
Changes from all commits
1d17cbd
5313fa1
b4daf73
163a8e5
a497447
45b92c5
fb6c15e
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 | ||
---|---|---|---|---|
|
@@ -1741,19 +1741,6 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofC | |||
} | ||||
JVM_END | ||||
|
||||
JVM_ENTRY(jint, JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)) | ||||
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. What about the declaration in jdk/src/hotspot/share/include/jvm.h Line 610 in 6c52b73
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. Created issue https://bugs.openjdk.org/browse/JDK-8364750 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. Sorry I missed the declaration. Will fix it. Thanks for filing the bug Roger. |
||||
{ | ||||
oop mirror = JNIHandles::resolve_non_null(cls); | ||||
if (java_lang_Class::is_primitive(mirror)) { | ||||
// Primitive type | ||||
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; | ||||
} | ||||
|
||||
Klass* k = java_lang_Class::as_Klass(mirror); | ||||
return k->access_flags().as_class_flags(); | ||||
} | ||||
JVM_END | ||||
|
||||
JVM_ENTRY(jboolean, JVM_AreNestMates(JNIEnv *env, jclass current, jclass member)) | ||||
{ | ||||
Klass* c = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(current)); | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,7 +236,7 @@ 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 isPrim) { | ||
private Class(ClassLoader loader, Class<?> arrayComponentType, char mods, ProtectionDomain pd, boolean isPrim, char flags) { | ||
// Initialize final field for classLoader. The initialization value of non-null | ||
// prevents future JIT optimizations from assuming this final field is null. | ||
// The following assignments are done directly by the VM without calling this constructor. | ||
|
@@ -245,6 +245,7 @@ private Class(ClassLoader loader, Class<?> arrayComponentType, char mods, Protec | |
modifiers = mods; | ||
protectionDomain = pd; | ||
primitive = isPrim; | ||
classFileAccessFlags = flags; | ||
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. Its not that hard to add a field, why not have done this for identity? 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. Fields are initialized by injection in javaClasses instead of through this constructor, so it's easy for us to accidentally forget to inject a field. 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. For IDENTITY, I didn't have to inject that one because the Java code knew when to set it, not the JVM code reading the data out of the classfile. And the logic belongs in the Java code, not the JVM. This one comes from the classfile, there isn't another way to get the information to the java.lang.Class. 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. The VM and Java use the same logic for the value of isIdentity(). 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. Roger, can you file another RFE for this for repo-valhalla and I can try to figure out how to best to do this? Or I can. I didn't think the valhalla isIdentityClass() code was expensive to call. 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. Created JDK-8364447 |
||
} | ||
|
||
/** | ||
|
@@ -1008,6 +1009,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 char classFileAccessFlags; // Set by the VM | ||
private final transient boolean primitive; // Set by the VM if the Class is a primitive type. | ||
|
||
// package-private | ||
|
@@ -1379,13 +1381,13 @@ public Set<AccessFlag> accessFlags() { | |
// Location.CLASS allows SUPER and AccessFlag.MODULE which | ||
// INNER_CLASS forbids. INNER_CLASS allows PRIVATE, PROTECTED, | ||
// and STATIC, which are not allowed on Location.CLASS. | ||
// Use getClassAccessFlagsRaw to expose SUPER status. | ||
// Use getClassFileAccessFlags to expose SUPER status. | ||
var location = (isMemberClass() || isLocalClass() || | ||
isAnonymousClass() || isArray()) ? | ||
AccessFlag.Location.INNER_CLASS : | ||
AccessFlag.Location.CLASS; | ||
return getReflectionFactory().parseAccessFlags((location == AccessFlag.Location.CLASS) ? | ||
getClassAccessFlagsRaw() : getModifiers(), location, this); | ||
getClassFileAccessFlags() : getModifiers(), location, this); | ||
} | ||
|
||
/** | ||
|
@@ -4130,17 +4132,16 @@ int getClassFileVersion() { | |
|
||
private native int getClassFileVersion0(); | ||
|
||
/* | ||
* Return the access flags as they were in the class's bytecode, including | ||
* the original setting of ACC_SUPER. | ||
* | ||
* If the class is an array type then the access flags of the element type is | ||
* returned. If the class is a primitive then ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC. | ||
*/ | ||
private int getClassAccessFlagsRaw() { | ||
Class<?> c = isArray() ? elementType() : this; | ||
return c.getClassAccessFlagsRaw0(); | ||
} | ||
|
||
private native int getClassAccessFlagsRaw0(); | ||
/** | ||
* Return the access flags as they were in the class's bytecode, including | ||
* the original setting of ACC_SUPER. | ||
* | ||
* If this {@code Class} object represents a primitive type or | ||
* void, the flags are {@code PUBLIC}, {@code ABSTRACT}, and | ||
* {@code FINAL}. | ||
* If this {@code Class} object represents an array type, return 0. | ||
*/ | ||
int getClassFileAccessFlags() { | ||
return classFileAccessFlags; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.