8298162: Test PrintClasses hits assert when run with code that retransform classes

Reviewed-by: dholmes, mgronlun
This commit is contained in:
Coleen Phillimore 2022-12-20 14:09:22 +00:00
parent 03d992728e
commit 03afec16f8
2 changed files with 13 additions and 2 deletions
src/hotspot/share/runtime
test/hotspot/jtreg/runtime/CommandLine

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, 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
@ -102,7 +102,9 @@ void fieldDescriptor::reinitialize(InstanceKlass* ik, int index) {
if (_cp.is_null() || field_holder() != ik) {
_cp = constantPoolHandle(Thread::current(), ik->constants());
// _cp should now reference ik's constant pool; i.e., ik is now field_holder.
assert(field_holder() == ik, "must be already initialized to this class");
// If the class is a scratch class, the constant pool points to the original class,
// but that's ok because of constant pool merging.
assert(field_holder() == ik || ik->is_scratch_class(), "must be already initialized to this class");
}
FieldInfo* f = ik->field(index);
_access_flags = accessFlags_from(f->access_flags());

@ -30,6 +30,15 @@
* @run main/othervm PrintClasses
*/
/*
* @test
* @bug 8298162
* @summary Test jcmd VM.classes with JFR
* @requires vm.hasJFR
* @library /test/lib
* @run main/othervm -XX:StartFlightRecording PrintClasses
*/
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.JDKToolFinder;