Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/hotspot/share/oops/fieldInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,7 @@ void FieldInfo::print(outputStream* os, ConstantPool* cp) {
name_index(), name(cp)->as_utf8(),
signature_index(), signature(cp)->as_utf8(),
offset(),
access_flags().as_unsigned_short(),
access_flags().as_field_flags(),
field_flags().as_uint(),
initializer_index(),
generic_signature_index(),
Expand Down Expand Up @@ -97,7 +97,7 @@ Array<u1>* FieldInfoStream::create_FieldInfoStream(GrowableArray<FieldInfo>* fie
assert(fi_ref->name_index() == fi.name_index(), "Must be");
assert(fi_ref->signature_index() == fi.signature_index(), "Must be");
assert(fi_ref->offset() == fi.offset(), "Must be");
assert(fi_ref->access_flags().as_unsigned_short() == fi.access_flags().as_unsigned_short(), "Must be");
assert(fi_ref->access_flags().as_field_flags() == fi.access_flags().as_field_flags(), "Must be");
assert(fi_ref->field_flags().as_uint() == fi.field_flags().as_uint(), " Must be");
if(fi_ref->field_flags().is_initialized()) {
assert(fi_ref->initializer_index() == fi.initializer_index(), "Must be");
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/fieldInfo.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -73,7 +73,7 @@ inline void Mapper<CON>::map_field_info(const FieldInfo& fi) {
_consumer->accept_uint(fi.name_index());
_consumer->accept_uint(fi.signature_index());
_consumer->accept_uint(fi.offset());
_consumer->accept_uint(fi.access_flags().as_unsigned_short());
_consumer->accept_uint(fi.access_flags().as_field_flags());
_consumer->accept_uint(fi.field_flags().as_uint());
if(fi.field_flags().has_any_optionals()) {
if (fi.field_flags().is_initialized()) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3340,7 +3340,7 @@ InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRA
}

u2 InstanceKlass::compute_modifier_flags() const {
u2 access = access_flags().as_unsigned_short();
u2 access = access_flags().as_class_flags();

// But check if it happens to be member class.
InnerClassesIterator iter(this);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ void Method::init_intrinsic_id(vmSymbolID klass_id) {
return;
}

u2 flags = access_flags().as_unsigned_short();
u2 flags = access_flags().as_method_flags();
vmIntrinsics::ID id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
if (id != vmIntrinsics::_none) {
set_intrinsic_id(id);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/jvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ JVM_ENTRY(jint, JVM_GetClassAccessFlags(JNIEnv *env, jclass cls))
}

Klass* k = java_lang_Class::as_Klass(mirror);
return k->access_flags().as_unsigned_short();
return k->access_flags().as_class_flags();
}
JVM_END

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/prims/jvmtiEnv.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -3149,7 +3149,7 @@ jvmtiError
JvmtiEnv::GetFieldModifiers(fieldDescriptor* fdesc_ptr, jint* modifiers_ptr) {

AccessFlags resultFlags = fdesc_ptr->access_flags();
jint result = resultFlags.as_unsigned_short();
jint result = resultFlags.as_field_flags();
*modifiers_ptr = result;

return JVMTI_ERROR_NONE;
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/prims/jvmtiRedefineClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions(
}

// Check whether class modifiers are the same.
u2 old_flags = the_class->access_flags().as_unsigned_short();
u2 new_flags = scratch_class->access_flags().as_unsigned_short();
u2 old_flags = the_class->access_flags().as_class_flags();
u2 new_flags = scratch_class->access_flags().as_class_flags();
if (old_flags != new_flags) {
log_info(redefine, class, normalize)
("redefined class %s modifiers change error: modifiers changed from %d to %d.",
Expand Down Expand Up @@ -1147,8 +1147,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions(
switch (method_was) {
case matched:
// methods match, be sure modifiers do too
old_flags = k_old_method->access_flags().as_unsigned_short();
new_flags = k_new_method->access_flags().as_unsigned_short();
old_flags = k_old_method->access_flags().as_method_flags();
new_flags = k_new_method->access_flags().as_method_flags();
if ((old_flags ^ new_flags) & ~(JVM_ACC_NATIVE)) {
log_info(redefine, class, normalize)
("redefined class %s method %s modifiers error: modifiers changed from %d to %d",
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/prims/methodHandles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) {
Method* m = iklass->find_method(name, poly_sig);
if (m != nullptr) {
int required = JVM_ACC_NATIVE | JVM_ACC_VARARGS;
int flags = m->access_flags().as_unsigned_short();
int flags = m->access_flags().as_method_flags();
if ((flags & required) == required) {
return true;
}
Expand All @@ -417,7 +417,7 @@ bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) {
for (; ms < me; ms++) {
Method* m = iklass->methods()->at(ms);
int required = JVM_ACC_NATIVE | JVM_ACC_VARARGS;
int flags = m->access_flags().as_unsigned_short();
int flags = m->access_flags().as_method_flags();
if ((flags & required) == required && ArgumentCount(m->signature()).size() == 1) {
return true;
}
Expand Down Expand Up @@ -522,7 +522,7 @@ bool MethodHandles::is_signature_polymorphic_public_name(Klass* klass, Symbol* n
for (; ms < me; ms++) {
Method* m = iklass->methods()->at(ms);
int required = JVM_ACC_NATIVE | JVM_ACC_VARARGS | JVM_ACC_PUBLIC;
int flags = m->access_flags().as_unsigned_short();
int flags = m->access_flags().as_method_flags();
if ((flags & required) == required && ArgumentCount(m->signature()).size() == 1) {
return true;
}
Expand Down
22 changes: 14 additions & 8 deletions src/hotspot/share/utilities/accessFlags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ class AccessFlags {
// get as integral value
u2 as_unsigned_short() const { return _flags; }

// Initialization
void set_field_flags(u2 flags) {
assert((flags & JVM_RECOGNIZED_FIELD_MODIFIERS) == flags, "only recognized flags");
_flags = (flags & JVM_RECOGNIZED_FIELD_MODIFIERS);
}
void set_flags(u2 flags) { _flags = flags; }

private:
Expand All @@ -83,9 +78,20 @@ class AccessFlags {
public:
inline friend AccessFlags accessFlags_from(u2 flags);

u2 as_method_flags() const { return _flags & JVM_RECOGNIZED_METHOD_MODIFIERS; }
u2 as_field_flags() const { return _flags & JVM_RECOGNIZED_FIELD_MODIFIERS; }
u2 as_class_flags() const { return _flags & JVM_RECOGNIZED_CLASS_MODIFIERS; }
u2 as_method_flags() const {
assert((_flags & JVM_RECOGNIZED_METHOD_MODIFIERS) == _flags, "only recognized flags");
return _flags;
}

u2 as_field_flags() const {
assert((_flags & JVM_RECOGNIZED_FIELD_MODIFIERS) == _flags, "only recognized flags");
return _flags;
}

u2 as_class_flags() const {
assert((_flags & JVM_RECOGNIZED_CLASS_MODIFIERS) == _flags, "only recognized flags");
return _flags;
}

// Printing/debugging
#if INCLUDE_JVMTI
Expand Down