Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.
/ jdk20 Public archive

Commit 03afec1

Browse files
committed
8298162: Test PrintClasses hits assert when run with code that retransform classes
Reviewed-by: dholmes, mgronlun
1 parent 03d9927 commit 03afec1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/hotspot/share/runtime/fieldDescriptor.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -102,7 +102,9 @@ void fieldDescriptor::reinitialize(InstanceKlass* ik, int index) {
102102
if (_cp.is_null() || field_holder() != ik) {
103103
_cp = constantPoolHandle(Thread::current(), ik->constants());
104104
// _cp should now reference ik's constant pool; i.e., ik is now field_holder.
105-
assert(field_holder() == ik, "must be already initialized to this class");
105+
// If the class is a scratch class, the constant pool points to the original class,
106+
// but that's ok because of constant pool merging.
107+
assert(field_holder() == ik || ik->is_scratch_class(), "must be already initialized to this class");
106108
}
107109
FieldInfo* f = ik->field(index);
108110
_access_flags = accessFlags_from(f->access_flags());

test/hotspot/jtreg/runtime/CommandLine/PrintClasses.java

+9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
* @run main/othervm PrintClasses
3131
*/
3232

33+
/*
34+
* @test
35+
* @bug 8298162
36+
* @summary Test jcmd VM.classes with JFR
37+
* @requires vm.hasJFR
38+
* @library /test/lib
39+
* @run main/othervm -XX:StartFlightRecording PrintClasses
40+
*/
41+
3342
import jdk.test.lib.process.OutputAnalyzer;
3443
import jdk.test.lib.JDKToolFinder;
3544

0 commit comments

Comments
 (0)