Skip to content
1 change: 0 additions & 1 deletion src/hotspot/share/oops/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,6 @@ bool Method::is_ignored_by_security_stack_walk() const {
// This is Method.invoke() -- ignore it
return true;
}
// This also looks obsolete
if (method_holder()->is_subclass_of(vmClasses::reflect_MethodAccessorImpl_klass())) {
// This is an auxiliary frame -- ignore it
return true;
Expand Down
24 changes: 4 additions & 20 deletions src/hotspot/share/prims/jvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,22 @@
and thus can only support use of handles passed in.
*/

static void trace_class_resolution_impl(Klass* to_class, TRAPS) {
extern void trace_class_resolution(Klass* to_class) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why extern ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jni.cpp functions call this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any difference in the callers in relation to this PR and the function is not presently declared extern. ??

Copy link
Contributor Author

@coleenp coleenp Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an extern trace_class_resolution() function that called this _impl function that I removed, so renamed this impl function to trace_class_resolution().
It's declared extern in jvm.hp file, and this 'extern' qualifier is added so it's easy to see that this is used externally.

Copy link
Member

@dholmes-ora dholmes-ora Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but not seeing that. It is declared in jvm_misc.hpp but not as extern. The original version was not extern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it has extern linkage but not declared with extern.

ResourceMark rm;
int line_number = -1;
const char * source_file = nullptr;
const char * trace = "explicit";
InstanceKlass* caller = nullptr;
JavaThread* jthread = THREAD;
JavaThread* jthread = JavaThread::current();
if (jthread->has_last_Java_frame()) {
vframeStream vfst(jthread);

// scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames
// It was this thing - is this no longer needed also? We won't have these frames anymore, right (except class loader)?
TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController");
Klass* access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK);
TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction");
Klass* privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK);

// Scan up the stack skipping ClassLoader frames.
Method* last_caller = nullptr;

while (!vfst.at_end()) {
Method* m = vfst.method();
if (!vfst.method()->method_holder()->is_subclass_of(vmClasses::ClassLoader_klass())&&
!vfst.method()->method_holder()->is_subclass_of(access_controller_klass) &&
!vfst.method()->method_holder()->is_subclass_of(privileged_action_klass)) {
if (!vfst.method()->method_holder()->is_subclass_of(vmClasses::ClassLoader_klass())) {
break;
}
last_caller = m;
Expand Down Expand Up @@ -233,14 +225,6 @@ static void trace_class_resolution_impl(Klass* to_class, TRAPS) {
}
}

void trace_class_resolution(Klass* to_class) {
EXCEPTION_MARK;
trace_class_resolution_impl(to_class, THREAD);
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
}
}

// java.lang.System //////////////////////////////////////////////////////////////////////


Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/runtime/vframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,7 @@ vframeStream::vframeStream(oop continuation, Handle continuation_scope)


// Step back n frames, skip any pseudo frames in between.
// This function is used in Class.forName, Class.newInstance, Method.Invoke,
// AccessController.doPrivileged.
// This function is used in Class.forName, Class.newInstance, and Method.Invoke.
void vframeStreamCommon::security_get_caller_frame(int depth) {
assert(depth >= 0, "invalid depth: %d", depth);
for (int n = 0; !at_end(); security_next()) {
Expand Down