Skip to content

Commit bd3c903

Browse files
authored
Merge branch 'master' into goetz_backport_8339300
2 parents a0cebde + 4d51cd8 commit bd3c903

File tree

10 files changed

+454
-13
lines changed

10 files changed

+454
-13
lines changed

src/hotspot/os/linux/osContainer_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jlong OSContainer::pids_current() {
138138

139139
void OSContainer::print_container_helper(outputStream* st, jlong j, const char* metrics) {
140140
st->print("%s: ", metrics);
141-
if (j > 0) {
141+
if (j >= 0) {
142142
if (j >= 1024) {
143143
st->print_cr(UINT64_FORMAT " k", uint64_t(j) / 1024);
144144
} else {

src/hotspot/share/code/codeCache.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,6 @@ bool CodeCache::contains(nmethod *nm) {
653653
return contains((void *)nm);
654654
}
655655

656-
static bool is_in_asgct() {
657-
Thread* current_thread = Thread::current_or_null_safe();
658-
return current_thread != NULL && current_thread->is_Java_thread() && current_thread->as_Java_thread()->in_asgct();
659-
}
660-
661656
// This method is safe to call without holding the CodeCache_lock, as long as a dead CodeBlob is not
662657
// looked up (i.e., one that has been marked for deletion). It only depends on the _segmap to contain
663658
// valid indices, which it will always do, as long as the CodeBlob is not in the process of being recycled.
@@ -666,7 +661,7 @@ CodeBlob* CodeCache::find_blob(void* start) {
666661
// We could potentially look up non_entrant methods
667662
bool is_zombie = result != NULL && result->is_zombie();
668663
bool is_result_safe = !is_zombie || result->is_locked_by_vm() || VMError::is_error_reported();
669-
guarantee(is_result_safe || is_in_asgct(), "unsafe access to zombie method");
664+
guarantee(is_result_safe || Thread::current_in_asgct(), "unsafe access to zombie method");
670665
// When in ASGCT the previous gurantee will pass for a zombie method but we still don't want that code blob returned in order
671666
// to minimize the chance of accessing dead memory
672667
return is_result_safe ? result : NULL;

src/hotspot/share/runtime/thread.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,6 @@ void JavaThread::check_for_valid_safepoint_state() {
10081008
JavaThread::JavaThread() :
10091009
// Initialize fields
10101010

1011-
_in_asgct(false),
10121011
_on_thread_list(false),
10131012
DEBUG_ONLY(_java_call_counter(0) COMMA)
10141013
_entry_point(nullptr),

src/hotspot/share/runtime/thread.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,6 @@ class JavaThread: public Thread {
715715
friend class ThreadsSMRSupport; // to access _threadObj for exiting_threads_oops_do
716716
friend class HandshakeState;
717717
private:
718-
bool _in_asgct; // Is set when this JavaThread is handling ASGCT call
719718
bool _on_thread_list; // Is set when this JavaThread is added to the Threads list
720719
OopHandle _threadObj; // The Java level thread object
721720

@@ -1640,10 +1639,6 @@ class JavaThread: public Thread {
16401639
// Helper function to do vm_exit_on_initialization for osthread
16411640
// resource allocation failure.
16421641
static void vm_exit_on_osthread_failure(JavaThread* thread);
1643-
1644-
// AsyncGetCallTrace support
1645-
inline bool in_asgct(void) {return _in_asgct;}
1646-
inline void set_in_asgct(bool value) {_in_asgct = value;}
16471642
};
16481643

16491644
// Inline implementation of JavaThread::current
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2024, Red Hat, Inc.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation.
9+
*
10+
* This code is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* version 2 for more details (a copy is included in the LICENSE file that
14+
* accompanied this code).
15+
*
16+
* You should have received a copy of the GNU General Public License version
17+
* 2 along with this work; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21+
* or visit www.oracle.com if you need additional information or have any
22+
* questions.
23+
*/
24+
25+
26+
/*
27+
* @test
28+
* @summary Test container info for cgroup v2
29+
* @requires docker.support
30+
* @library /test/lib
31+
* @modules java.base/jdk.internal.misc
32+
* java.management
33+
* jdk.jartool/sun.tools.jar
34+
* @build CheckContainerized jdk.test.whitebox.WhiteBox PrintContainerInfo
35+
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox
36+
* @run driver TestContainerInfo
37+
*/
38+
import jtreg.SkippedException;
39+
import jdk.test.lib.containers.docker.Common;
40+
import jdk.test.lib.containers.docker.DockerTestUtils;
41+
import jdk.test.lib.containers.docker.DockerRunOptions;
42+
import jdk.test.lib.process.OutputAnalyzer;
43+
import jdk.test.lib.process.ProcessTools;
44+
45+
46+
public class TestContainerInfo {
47+
private static final String imageName = Common.imageName("container-info");
48+
49+
public static void main(String[] args) throws Exception {
50+
if (!DockerTestUtils.canTestDocker()) {
51+
return;
52+
}
53+
54+
Common.prepareWhiteBox();
55+
DockerTestUtils.buildJdkContainerImage(imageName);
56+
57+
try {
58+
testPrintContainerInfoWithoutSwap();
59+
} finally {
60+
DockerTestUtils.removeDockerImage(imageName);
61+
}
62+
}
63+
64+
private static void testPrintContainerInfoWithoutSwap() throws Exception {
65+
Common.logNewTestCase("Test print_container_info() - without swap");
66+
67+
DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo")
68+
.addDockerOpts("--memory=500m")
69+
.addDockerOpts("--memory-swap=500m"); // no swap
70+
Common.addWhiteBoxOpts(opts);
71+
72+
OutputAnalyzer out = Common.run(opts);
73+
checkContainerInfo(out);
74+
}
75+
76+
private static void shouldMatchWithValue(OutputAnalyzer output, String match, String value) {
77+
output.shouldContain(match);
78+
String str = output.getOutput();
79+
for (String s : str.split(System.lineSeparator())) {
80+
if (s.contains(match)) {
81+
if (!s.contains(value)) {
82+
throw new RuntimeException("memory_swap_current_in_bytes NOT " + value + "! Line was : " + s);
83+
}
84+
}
85+
}
86+
}
87+
88+
private static void checkContainerInfo(OutputAnalyzer out) throws Exception {
89+
String str = out.getOutput();
90+
if (str.contains("cgroupv2")) {
91+
shouldMatchWithValue(out, "memory_swap_max_limit_in_bytes", "0");
92+
shouldMatchWithValue(out, "memory_swap_current_in_bytes", "0");
93+
} else {
94+
throw new SkippedException("This test is cgroups v2 specific, skipped on cgroups v1");
95+
}
96+
}
97+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 4817630
27+
* @summary AncestorEvent ancestorAdded thrown at JFrame creation, not at show()
28+
* @key headful
29+
* @run main bug4817630
30+
*/
31+
32+
import java.lang.reflect.InvocationTargetException;
33+
import javax.swing.JFrame;
34+
import javax.swing.JLabel;
35+
import javax.swing.SwingUtilities;
36+
import javax.swing.event.AncestorEvent;
37+
import javax.swing.event.AncestorListener;
38+
39+
public class bug4817630 {
40+
41+
JFrame fr;
42+
43+
volatile boolean ancestorAdded = false;
44+
volatile boolean passed = true;
45+
46+
public void init() {
47+
fr = new JFrame("bug4817630");
48+
JLabel label = new JLabel("Label");
49+
50+
label.addAncestorListener(new AncestorListener() {
51+
public void ancestorAdded(AncestorEvent e) {
52+
if (!fr.isVisible()) {
53+
setPassed(false);
54+
}
55+
synchronized (bug4817630.this) {
56+
ancestorAdded = true;
57+
bug4817630.this.notifyAll();
58+
}
59+
}
60+
public void ancestorRemoved(AncestorEvent e) {
61+
}
62+
public void ancestorMoved(AncestorEvent e) {
63+
}
64+
});
65+
66+
fr.setLocationRelativeTo(null);
67+
fr.getContentPane().add(label);
68+
fr.pack();
69+
fr.setVisible(true);
70+
}
71+
72+
public void start() {
73+
try {
74+
synchronized (bug4817630.this) {
75+
while (!ancestorAdded) {
76+
bug4817630.this.wait();
77+
}
78+
}
79+
} catch(Exception e) {
80+
throw new RuntimeException("Test failed because of "
81+
+ e.getLocalizedMessage());
82+
}
83+
}
84+
85+
public void destroy() {
86+
if (fr != null) {
87+
fr.setVisible(false);
88+
fr.dispose();
89+
}
90+
if (!isPassed()) {
91+
throw new RuntimeException("ancestorAdded() method shouldn't be "
92+
+ "called before the frame is shown.");
93+
}
94+
}
95+
96+
synchronized void setPassed(boolean passed) {
97+
this.passed = passed;
98+
}
99+
100+
synchronized boolean isPassed() {
101+
return passed;
102+
}
103+
104+
public static void main(String[] args) throws InterruptedException,
105+
InvocationTargetException {
106+
bug4817630 test = new bug4817630();
107+
try {
108+
SwingUtilities.invokeAndWait(test::init);
109+
test.start();
110+
} finally {
111+
SwingUtilities.invokeAndWait(test::destroy);
112+
}
113+
}
114+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 4191948
27+
* @summary BoxLayout doesn't ignore invisible components
28+
* @key headful
29+
* @run main bug4191948
30+
*/
31+
32+
import java.awt.BorderLayout;
33+
import java.lang.reflect.InvocationTargetException;
34+
import javax.swing.BoxLayout;
35+
import javax.swing.JButton;
36+
import javax.swing.JFrame;
37+
import javax.swing.JPanel;
38+
import javax.swing.SwingUtilities;
39+
40+
public class bug4191948 {
41+
JFrame frame;
42+
JPanel p;
43+
JButton foo1;
44+
JButton foo2;
45+
JButton foo3;
46+
47+
public void init() {
48+
frame = new JFrame("bug4191948");
49+
p = new JPanel();
50+
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
51+
foo1 = (JButton)p.add(new JButton("Foo1"));
52+
foo2 = (JButton)p.add(new JButton("Foo2"));
53+
foo3 = (JButton)p.add(new JButton("Foo3"));
54+
55+
foo2.setVisible(false);
56+
frame.setLocationRelativeTo(null);
57+
frame.setLayout(new BorderLayout());
58+
frame.add(p, BorderLayout.CENTER);
59+
frame.pack();
60+
frame.setVisible(true);
61+
}
62+
63+
public void start() {
64+
try {
65+
int totalWidth = p.getPreferredSize().width;
66+
int foo1Width = foo1.getPreferredSize().width;
67+
int foo2Width = foo2.getPreferredSize().width;
68+
int foo3Width = foo3.getPreferredSize().width;
69+
if (totalWidth >= (foo1Width + foo2Width + foo3Width)) {
70+
throw new RuntimeException("Panel is too wide");
71+
}
72+
} finally {
73+
if (frame != null) {
74+
frame.setVisible(false);
75+
frame.dispose();
76+
}
77+
}
78+
}
79+
80+
public static void main(String[] args) throws InterruptedException,
81+
InvocationTargetException {
82+
bug4191948 test = new bug4191948();
83+
SwingUtilities.invokeAndWait(test::init);
84+
SwingUtilities.invokeAndWait(test::start);
85+
}
86+
}

0 commit comments

Comments
 (0)