Skip to content

Commit 54c9348

Browse files
committed
8336103: Clean up confusing Method::is_initializer
Reviewed-by: dholmes, coleenp
1 parent 2c0c653 commit 54c9348

File tree

7 files changed

+11
-20
lines changed

7 files changed

+11
-20
lines changed

src/hotspot/share/ci/ciMethod.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,6 @@ bool ciMethod::has_jsrs () const { FETCH_FLAG_FROM_VM(has_jsrs);
12491249
bool ciMethod::is_getter () const { FETCH_FLAG_FROM_VM(is_getter); }
12501250
bool ciMethod::is_setter () const { FETCH_FLAG_FROM_VM(is_setter); }
12511251
bool ciMethod::is_accessor () const { FETCH_FLAG_FROM_VM(is_accessor); }
1252-
bool ciMethod::is_initializer () const { FETCH_FLAG_FROM_VM(is_initializer); }
12531252
bool ciMethod::is_empty () const { FETCH_FLAG_FROM_VM(is_empty_method); }
12541253

12551254
bool ciMethod::is_boxing_method() const {

src/hotspot/share/ci/ciMethod.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ class ciMethod : public ciMetadata {
352352
bool is_getter () const;
353353
bool is_setter () const;
354354
bool is_accessor () const;
355-
bool is_initializer () const;
356355
bool is_empty () const;
357356
bool can_be_statically_bound() const { return _can_be_statically_bound; }
358357
bool has_reserved_stack_access() const { return _has_reserved_stack_access; }

src/hotspot/share/jvmci/jvmciCompiler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void JVMCICompiler::bootstrap(TRAPS) {
8787
int len = objectMethods->length();
8888
for (int i = 0; i < len; i++) {
8989
methodHandle mh(THREAD, objectMethods->at(i));
90-
if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) {
90+
if (!mh->is_native() && !mh->is_static() && !mh->is_object_initializer() && !mh->is_static_initializer()) {
9191
ResourceMark rm;
9292
int hot_count = 10; // TODO: what's the appropriate value?
9393
CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, CompileTask::Reason_Bootstrap, CHECK);

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,7 @@ C2V_VMENTRY_NULL(jobjectArray, getDeclaredConstructors, (JNIEnv* env, jobject, A
21782178
GrowableArray<Method*> constructors_array;
21792179
for (int i = 0; i < iklass->methods()->length(); i++) {
21802180
Method* m = iklass->methods()->at(i);
2181-
if (m->is_initializer() && !m->is_static()) {
2181+
if (m->is_object_initializer()) {
21822182
constructors_array.append(m);
21832183
}
21842184
}
@@ -2205,7 +2205,7 @@ C2V_VMENTRY_NULL(jobjectArray, getDeclaredMethods, (JNIEnv* env, jobject, ARGUME
22052205
GrowableArray<Method*> methods_array;
22062206
for (int i = 0; i < iklass->methods()->length(); i++) {
22072207
Method* m = iklass->methods()->at(i);
2208-
if (!m->is_initializer() && !m->is_overpass()) {
2208+
if (!m->is_object_initializer() && !m->is_static_initializer() && !m->is_overpass()) {
22092209
methods_array.append(m);
22102210
}
22112211
}
@@ -2921,12 +2921,11 @@ C2V_VMENTRY_NULL(jobject, asReflectionExecutable, (JNIEnv* env, jobject, ARGUMEN
29212921
requireInHotSpot("asReflectionExecutable", JVMCI_CHECK_NULL);
29222922
methodHandle m(THREAD, UNPACK_PAIR(Method, method));
29232923
oop executable;
2924-
if (m->is_initializer()) {
2925-
if (m->is_static_initializer()) {
2926-
JVMCI_THROW_MSG_NULL(IllegalArgumentException,
2927-
"Cannot create java.lang.reflect.Method for class initializer");
2928-
}
2924+
if (m->is_object_initializer()) {
29292925
executable = Reflection::new_constructor(m, CHECK_NULL);
2926+
} else if (m->is_static_initializer()) {
2927+
JVMCI_THROW_MSG_NULL(IllegalArgumentException,
2928+
"Cannot create java.lang.reflect.Method for class initializer");
29302929
} else {
29312930
executable = Reflection::new_method(m, false, CHECK_NULL);
29322931
}

src/hotspot/share/oops/klassVtable.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1230,9 +1230,10 @@ void klassItable::initialize_itable_and_check_constraints(TRAPS) {
12301230
}
12311231

12321232
inline bool interface_method_needs_itable_index(Method* m) {
1233-
if (m->is_static()) return false; // e.g., Stream.empty
1234-
if (m->is_initializer()) return false; // <init> or <clinit>
1235-
if (m->is_private()) return false; // uses direct call
1233+
if (m->is_static()) return false; // e.g., Stream.empty
1234+
if (m->is_object_initializer()) return false; // <init>
1235+
if (m->is_static_initializer()) return false; // <clinit>
1236+
if (m->is_private()) return false; // uses direct call
12361237
// If an interface redeclares a method from java.lang.Object,
12371238
// it should already have a vtable index, don't touch it.
12381239
// e.g., CharSequence.toString (from initialize_vtable)

src/hotspot/share/oops/method.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -846,10 +846,6 @@ bool Method::is_constant_getter() const {
846846
Bytecodes::is_return(java_code_at(last_index)));
847847
}
848848

849-
bool Method::is_initializer() const {
850-
return is_object_initializer() || is_static_initializer();
851-
}
852-
853849
bool Method::has_valid_initializer_flags() const {
854850
return (is_static() ||
855851
method_holder()->major_version() < 51);

src/hotspot/share/oops/method.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,6 @@ class Method : public Metadata {
576576
// returns true if the method does nothing but return a constant of primitive type
577577
bool is_constant_getter() const;
578578

579-
// returns true if the method is an initializer (<init> or <clinit>).
580-
bool is_initializer() const;
581-
582579
// returns true if the method is static OR if the classfile version < 51
583580
bool has_valid_initializer_flags() const;
584581

0 commit comments

Comments
 (0)