Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm,
} else {
assert(is_phantom, "only remaining strength");
assert(!is_narrow, "phantom access cannot be narrow");
target = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak);
target = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom);
}
__ call(target);
__ mv(t0, x10);
Expand Down
23 changes: 21 additions & 2 deletions src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2026, 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
Expand All @@ -25,6 +25,7 @@

package javax.swing.text;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.HeadlessException;
import java.awt.Point;
Expand Down Expand Up @@ -694,7 +695,25 @@ public void paint(Graphics g) {
// semantics of damage we can't really get around this.
damage(r);
}
g.setColor(component.getCaretColor());
if (component.isEditable()) {
g.setColor(component.getCaretColor());
} else {
Color caretColor = component.getCaretColor();
if (caretColor == null) {
caretColor = g.getColor();
}
Color bg = component.getBackground();
if (bg == null) {
g.setColor(caretColor);
} else {
int red = (caretColor.getRed() + bg.getRed()) / 2;
int green = (caretColor.getGreen() + bg.getGreen()) / 2;
int blue = (caretColor.getBlue() + bg.getBlue()) / 2;
int alpha = 127;
Color newCaretColor = new Color(red, green, blue, alpha);
g.setColor(newCaretColor);
}
}
int paintWidth = getCaretWidth(r.height);
r.x -= paintWidth >> 1;
g.fillRect(r.x, r.y, paintWidth, r.height);
Expand Down
13 changes: 10 additions & 3 deletions test/hotspot/jtreg/containers/docker/EventGeneratorLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import jdk.jfr.Description;
import jdk.jfr.Label;

import java.util.concurrent.TimeUnit;


// This class generates simple event in a loop for a specified time.
public class EventGeneratorLoop {
Expand All @@ -44,16 +46,21 @@ public static void main(String[] args) throws Exception {
throw new IllegalArgumentException("Expecting one argument: time to run (seconds)");
}
int howLong = Integer.parseInt(args[0]);
long endTime = System.nanoTime() + TimeUnit.SECONDS.toNanos(howLong);

System.out.println(MAIN_METHOD_STARTED + ", argument is " + howLong);

for (int i=0; i < howLong; i++) {
int count = 0;
while (System.nanoTime() < endTime) {
SimpleEvent ev = new SimpleEvent();
ev.msg = "Hello";
ev.count = i;
ev.count = count++;
ev.commit();

try { Thread.sleep(1000); } catch (InterruptedException e) {}
try {
Thread.sleep(1000);
} catch (InterruptedException ignore) {
}
System.out.print(".");
}

Expand Down
69 changes: 34 additions & 35 deletions test/hotspot/jtreg/containers/docker/TestJcmdWithSideCar.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import jdk.test.lib.Container;
import jdk.test.lib.Platform;
Expand All @@ -68,7 +68,6 @@ public class TestJcmdWithSideCar {
private static final String IMAGE_NAME = Common.imageName("jfr-jcmd");
private static final int TIME_TO_RUN_MAIN_PROCESS = (int) (30 * Utils.TIMEOUT_FACTOR); // seconds
private static final long TIME_TO_WAIT_FOR_MAIN_METHOD_START = 50 * 1000; // milliseconds
private static final String MAIN_CONTAINER_NAME = "test-container-main";

private static final String UID = "uid";
private static final String GID = "gid";
Expand Down Expand Up @@ -116,19 +115,19 @@ public static void main(String[] args) throws Exception {
// Elevated attach via proc/root not yet supported.
continue;
}
long mainProcPid = testCase01(attachStrategy, elevated);
long mainProcPid = testCase01(mainContainer, attachStrategy, elevated);

// Excluding the test case below until JDK-8228850 is fixed
// JDK-8228850: jhsdb jinfo fails with ClassCastException:
// s.j.h.oops.TypeArray cannot be cast to s.j.h.oops.Instance
// mainContainer.assertIsAlive();
// testCase02(mainProcPid, attachStrategy, elevated);
// testCase02(mainContainer, mainProcPid, attachStrategy, elevated);

mainContainer.assertIsAlive();
testCase03(mainProcPid, attachStrategy, elevated);
testCase03(mainContainer, mainProcPid, attachStrategy, elevated);
}

mainContainer.waitForAndCheck(TIME_TO_RUN_MAIN_PROCESS * 1000);
mainContainer.stop();
}
} finally {
DockerTestUtils.removeDockerImage(IMAGE_NAME);
Expand All @@ -137,8 +136,8 @@ public static void main(String[] args) throws Exception {


// Run "jcmd -l" in a sidecar container, find a target process.
private static long testCase01(AttachStrategy attachStrategy, boolean elevated) throws Exception {
OutputAnalyzer out = runSideCar(MAIN_CONTAINER_NAME, attachStrategy, elevated, "/jdk/bin/jcmd", "-l")
private static long testCase01(MainContainer mainContainer, AttachStrategy attachStrategy, boolean elevated) throws Exception {
OutputAnalyzer out = runSideCar(mainContainer, attachStrategy, elevated, "/jdk/bin/jcmd", "-l")
.shouldHaveExitValue(0)
.shouldContain("sun.tools.jcmd.JCmd");
long pid = findProcess(out, "EventGeneratorLoop");
Expand All @@ -150,20 +149,20 @@ private static long testCase01(AttachStrategy attachStrategy, boolean elevated)
}

// run jhsdb jinfo <PID> (jhsdb uses PTRACE)
private static void testCase02(long pid, AttachStrategy attachStrategy, boolean elevated) throws Exception {
runSideCar(MAIN_CONTAINER_NAME, attachStrategy, elevated, "/jdk/bin/jhsdb", "jinfo", "--pid", "" + pid)
private static void testCase02(MainContainer mainContainer, long pid, AttachStrategy attachStrategy, boolean elevated) throws Exception {
runSideCar(mainContainer, attachStrategy, elevated, "/jdk/bin/jhsdb", "jinfo", "--pid", "" + pid)
.shouldHaveExitValue(0)
.shouldContain("Java System Properties")
.shouldContain("VM Flags");
}

// test jcmd with some commands (help, start JFR recording)
// JCMD will use signal mechanism and Unix Socket
private static void testCase03(long pid, AttachStrategy attachStrategy, boolean elevated) throws Exception {
runSideCar(MAIN_CONTAINER_NAME, attachStrategy, elevated, "/jdk/bin/jcmd", "" + pid, "help")
private static void testCase03(MainContainer mainContainer, long pid, AttachStrategy attachStrategy, boolean elevated) throws Exception {
runSideCar(mainContainer, attachStrategy, elevated, "/jdk/bin/jcmd", "" + pid, "help")
.shouldHaveExitValue(0)
.shouldContain("VM.version");
runSideCar(MAIN_CONTAINER_NAME, attachStrategy, elevated, "/jdk/bin/jcmd", "" + pid, "JFR.start")
runSideCar(mainContainer, attachStrategy, elevated, "/jdk/bin/jcmd", "" + pid, "JFR.start")
.shouldHaveExitValue(0)
.shouldContain("Started recording");
}
Expand All @@ -175,18 +174,18 @@ private static void testCase03(long pid, AttachStrategy attachStrategy, boolean
// we have two options:
// 1. mount /tmp from the main container using --volumes-from.
// 2. access /tmp from the main container via /proc/<pid>/root/tmp.
private static OutputAnalyzer runSideCar(String mainContainerName, AttachStrategy attachStrategy, boolean elevated, String whatToRun, String... args) throws Exception {
private static OutputAnalyzer runSideCar(MainContainer mainContainer, AttachStrategy attachStrategy, boolean elevated, String whatToRun, String... args) throws Exception {
System.out.println("Attach strategy " + attachStrategy);

List<String> initialCommands = List.of(
Container.ENGINE_COMMAND, "run",
"--tty=true", "--rm",
"--cap-add=SYS_PTRACE", "--sig-proxy=true",
"--pid=container:" + mainContainerName
"--pid=container:" + mainContainer.name()
);

List<String> attachStrategyCommands = switch (attachStrategy) {
case TMP_MOUNTED_INTO_SIDECAR -> List.of("--volumes-from", mainContainerName);
case TMP_MOUNTED_INTO_SIDECAR -> List.of("--volumes-from", mainContainer.name());
case ACCESS_TMP_VIA_PROC_ROOT -> List.of();
};

Expand All @@ -210,11 +209,11 @@ private static long findProcess(OutputAnalyzer out, String name) throws Exceptio
List<String> l = out.asLines()
.stream()
.filter(s -> s.contains(name))
.collect(Collectors.toList());
.toList();
if (l.isEmpty()) {
return -1;
}
String psInfo = l.get(0);
String psInfo = l.getFirst();
System.out.println("findProcess(): psInfo: " + psInfo);
String pid = psInfo.substring(0, psInfo.indexOf(' '));
System.out.println("findProcess(): pid: " + pid);
Expand All @@ -237,6 +236,10 @@ private static void sleep(long delay) {


static class MainContainer {
private static final String MAIN_CONTAINER_NAME_PREFIX = "test-container-main";
private static final Random RANDOM = Utils.getRandomInstance();

String name;
boolean mainMethodStarted;
Process p;

Expand All @@ -256,8 +259,11 @@ public Process start(final boolean elevated) throws Exception {
opts.addDockerOpts(NET_BIND_SERVICE);
}

name = MAIN_CONTAINER_NAME_PREFIX + "-elevated-" + elevated + "-" + RANDOM.nextInt();

opts.addDockerOpts("--cap-add=SYS_PTRACE")
.addDockerOpts("--name", MAIN_CONTAINER_NAME)
.addDockerOpts("--init")
.addDockerOpts("--name", name)
.addDockerOpts("--volume", "/tmp")
.addDockerOpts("--volume", Paths.get(".").toAbsolutePath() + ":/workdir/")
.addJavaOpts("-XX:+UsePerfData")
Expand Down Expand Up @@ -297,25 +303,18 @@ public void waitFor(long timeout) throws Exception {
p.waitFor(timeout, TimeUnit.MILLISECONDS);
}

public void waitForAndCheck(long timeout) throws Exception {
int exitValue = -1;
int retryCount = 3;

do {
waitFor(timeout);
try {
exitValue = p.exitValue();
} catch(IllegalThreadStateException ex) {
System.out.println("IllegalThreadStateException occurred when calling exitValue()");
retryCount--;
}
} while (exitValue == -1 && retryCount > 0);

if (exitValue != 0) {
throw new RuntimeException("DockerThread stopped unexpectedly, non-zero exit value is " + exitValue);
public void stop() throws Exception {
OutputAnalyzer out = DockerTestUtils.execute(Container.ENGINE_COMMAND, "ps")
.shouldHaveExitValue(0);
if (out.contains(name)) {
DockerTestUtils.execute(Container.ENGINE_COMMAND, "stop", name)
.shouldHaveExitValue(0);
}
}

public String name() {
return name;
}
}

private enum AttachStrategy {
Expand Down
Loading
Loading