From 38f138bc22ae705e8e09f75fe6bac4bb470dc29b Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Thu, 17 Apr 2025 23:37:45 +0000 Subject: [PATCH 001/901] 8354985: Add unit tests for Executor class from jpackage test lib Reviewed-by: almatvee --- .../jdk/jpackage/test/ExecutorTest.java | 370 ++++++++++++++++++ .../helpers/jdk/jpackage/test/Executor.java | 30 +- 2 files changed, 387 insertions(+), 13 deletions(-) create mode 100644 test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/ExecutorTest.java diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/ExecutorTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/ExecutorTest.java new file mode 100644 index 00000000000..8175f49a2b2 --- /dev/null +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/ExecutorTest.java @@ -0,0 +1,370 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jpackage.test; + +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toSet; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.UncheckedIOException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.function.Consumer; +import java.util.spi.ToolProvider; +import java.util.stream.Stream; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +public class ExecutorTest extends JUnitAdapter { + + private record Command(List stdout, List stderr) { + Command { + stdout.forEach(Objects::requireNonNull); + stderr.forEach(Objects::requireNonNull); + } + + List asExecutable() { + final List commandline = new ArrayList<>(); + if (TKit.isWindows()) { + commandline.addAll(List.of("cmd", "/C")); + } else { + commandline.addAll(List.of("sh", "-c")); + } + commandline.add(Stream.concat(createEchoCommands(stdout), + createEchoCommands(stderr).map(v -> v + ">&2")).collect(joining(" && "))); + return commandline; + } + + private static Stream createEchoCommands(List lines) { + return lines.stream().map(line -> { + if (TKit.isWindows()) { + return "(echo " + line + ")"; + } else { + return "echo " + line; + } + }); + } + + ToolProvider asToolProvider() { + return new ToolProvider() { + + @Override + public int run(PrintWriter out, PrintWriter err, String... args) { + stdout.forEach(out::println); + stderr.forEach(err::println); + return 0; + } + + @Override + public String name() { + return "test"; + } + }; + } + } + + private enum OutputData { + EMPTY(List.of()), + ONE_LINE(List.of("Jupiter")), + MANY(List.of("Uranus", "Saturn", "Earth")); + + OutputData(List data) { + data.forEach(Objects::requireNonNull); + this.data = data; + } + + final List data; + } + + private record CommandSpec(OutputData stdout, OutputData stderr) { + CommandSpec { + Objects.requireNonNull(stdout); + Objects.requireNonNull(stderr); + } + + Command command() { + return new Command(stdout.data.stream().map(line -> { + return "stdout." + line; + }).toList(), stderr.data.stream().map(line -> { + return "stderr." + line; + }).toList()); + } + } + + public enum OutputControl { + DUMP(Executor::dumpOutput), + SAVE_ALL(Executor::saveOutput), + SAVE_FIRST_LINE(Executor::saveFirstLineOfOutput), + DISCARD_STDOUT(NOP), + DISCARD_STDERR(NOP), + ; + + OutputControl(Consumer configureExector) { + this.configureExector = Objects.requireNonNull(configureExector); + } + + Executor applyTo(Executor exec) { + configureExector.accept(exec); + return exec; + } + + static List> variants() { + final List> variants = new ArrayList<>(); + for (final var withDump : BOOLEAN_VALUES) { + variants.addAll(Stream.of( + Set.of(), + Set.of(SAVE_ALL), + Set.of(SAVE_FIRST_LINE), + Set.of(DISCARD_STDOUT), + Set.of(DISCARD_STDERR), + Set.of(SAVE_ALL, DISCARD_STDOUT), + Set.of(SAVE_FIRST_LINE, DISCARD_STDOUT), + Set.of(SAVE_ALL, DISCARD_STDERR), + Set.of(SAVE_FIRST_LINE, DISCARD_STDERR), + Set.of(SAVE_ALL, DISCARD_STDOUT, DISCARD_STDERR), + Set.of(SAVE_FIRST_LINE, DISCARD_STDOUT, DISCARD_STDERR) + ).map(v -> { + if (withDump) { + return Stream.concat(Stream.of(DUMP), v.stream()).collect(toSet()); + } else { + return v; + } + }).toList()); + } + return variants.stream().map(options -> { + return options.stream().filter(o -> { + return o.configureExector != NOP; + }).collect(toSet()); + }).distinct().toList(); + } + + private final Consumer configureExector; + + static final Set SAVE = Set.of(SAVE_ALL, SAVE_FIRST_LINE); + } + + public record OutputTestSpec(boolean toolProvider, Set outputControl, CommandSpec commandSpec) { + public OutputTestSpec { + outputControl.forEach(Objects::requireNonNull); + if (outputControl.containsAll(OutputControl.SAVE)) { + throw new IllegalArgumentException(); + } + Objects.requireNonNull(commandSpec); + } + + @Override + public String toString() { + final List tokens = new ArrayList<>(); + + if (toolProvider) { + tokens.add("tool-provider"); + } + + tokens.add("output=" + format(outputControl)); + tokens.add("command=" + commandSpec); + + return String.join(",", tokens.toArray(String[]::new)); + } + + void test() { + final var command = commandSpec.command(); + final var commandWithDiscardedStreams = discardStreams(command); + + final Executor.Result[] result = new Executor.Result[1]; + final var outputCapture = OutputCapture.captureOutput(() -> { + result[0] = createExecutor(command).executeWithoutExitCodeCheck(); + }); + + assertEquals(0, result[0].getExitCode()); + + assertEquals(expectedCapturedSystemOut(commandWithDiscardedStreams), outputCapture.outLines()); + assertEquals(expectedCapturedSystemErr(commandWithDiscardedStreams), outputCapture.errLines()); + + if (!saveOutput()) { + assertNull(result[0].getOutput()); + } else { + assertNotNull(result[0].getOutput()); + final var allExpectedOutput = expectedCommandOutput(command); + assertEquals(allExpectedOutput.isEmpty(), result[0].getOutput().isEmpty()); + if (!allExpectedOutput.isEmpty()) { + if (outputControl.contains(OutputControl.SAVE_ALL)) { + assertEquals(allExpectedOutput, result[0].getOutput()); + } else if (outputControl.contains(OutputControl.SAVE_FIRST_LINE)) { + assertEquals(1, result[0].getOutput().size()); + assertEquals(allExpectedOutput.getFirst(), result[0].getFirstLineOfOutput()); + } else { + throw new UnsupportedOperationException(); + } + } + } + } + + private boolean dumpOutput() { + return outputControl.contains(OutputControl.DUMP); + } + + private boolean saveOutput() { + return !Collections.disjoint(outputControl, OutputControl.SAVE); + } + + private boolean discardStdout() { + return outputControl.contains(OutputControl.DISCARD_STDOUT); + } + + private boolean discardStderr() { + return outputControl.contains(OutputControl.DISCARD_STDERR); + } + + private static String format(Set outputControl) { + return outputControl.stream().map(OutputControl::name).sorted().collect(joining("+")); + } + + private List expectedCapturedSystemOut(Command command) { + if (!dumpOutput() || (!toolProvider && !saveOutput())) { + return List.of(); + } else if(saveOutput()) { + return Stream.concat(command.stdout().stream(), command.stderr().stream()).toList(); + } else { + return command.stdout(); + } + } + + private List expectedCapturedSystemErr(Command command) { + if (!dumpOutput() || (!toolProvider && !saveOutput())) { + return List.of(); + } else if(saveOutput()) { + return List.of(); + } else { + return command.stderr(); + } + } + + private Command discardStreams(Command command) { + return new Command(discardStdout() ? List.of() : command.stdout(), discardStderr() ? List.of() : command.stderr()); + } + + private record OutputCapture(byte[] out, byte[] err, Charset outCharset, Charset errCharset) { + OutputCapture { + Objects.requireNonNull(out); + Objects.requireNonNull(err); + Objects.requireNonNull(outCharset); + Objects.requireNonNull(errCharset); + } + + List outLines() { + return toLines(out, outCharset); + } + + List errLines() { + return toLines(err, errCharset); + } + + private static List toLines(byte[] buf, Charset charset) { + try (var reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buf), charset))) { + return reader.lines().filter(line -> { + return !line.contains("TRACE"); + }).toList(); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + + static OutputCapture captureOutput(Runnable runnable) { + final var captureOut = new ByteArrayOutputStream(); + final var captureErr = new ByteArrayOutputStream(); + + final var out = System.out; + final var err = System.err; + try { + final var outCharset = System.out.charset(); + final var errCharset = System.err.charset(); + System.setOut(new PrintStream(captureOut, true, outCharset)); + System.setErr(new PrintStream(captureErr, true, errCharset)); + runnable.run(); + return new OutputCapture(captureOut.toByteArray(), captureErr.toByteArray(), outCharset, errCharset); + } finally { + try { + System.setOut(out); + } finally { + System.setErr(err); + } + } + } + } + + private List expectedCommandOutput(Command command) { + command = discardStreams(command); + return Stream.of(command.stdout(), command.stderr()).flatMap(List::stream).toList(); + } + + private Executor createExecutor(Command command) { + final Executor exec; + if (toolProvider) { + exec = Executor.of(command.asToolProvider()); + } else { + exec = Executor.of(command.asExecutable()); + } + + outputControl.forEach(control -> control.applyTo(exec)); + + return exec; + } + } + + @ParameterizedTest + @MethodSource + public void testSavedOutput(OutputTestSpec spec) { + spec.test(); + } + + public static List testSavedOutput() { + List testCases = new ArrayList<>(); + for (final var toolProvider : BOOLEAN_VALUES) { + for (final var outputControl : OutputControl.variants()) { + for (final var stdoutContent : List.of(OutputData.values())) { + for (final var stderrContent : List.of(OutputData.values())) { + final var commandSpec = new CommandSpec(stdoutContent, stderrContent); + testCases.add(new OutputTestSpec(toolProvider, outputControl, commandSpec)); + } + } + } + } + return testCases; + } + + private static final List BOOLEAN_VALUES = List.of(Boolean.TRUE, Boolean.FALSE); + private static final Consumer NOP = exec -> {}; +} diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java index 66cd422203b..053674960c4 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java @@ -29,9 +29,9 @@ import java.io.OutputStream; import java.io.PrintStream; import java.io.StringReader; +import java.io.Writer; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -50,8 +50,16 @@ public final class Executor extends CommandArguments { public static Executor of(String... cmdline) { - return new Executor().setExecutable(cmdline[0]).addArguments( - Arrays.copyOfRange(cmdline, 1, cmdline.length)); + return of(List.of(cmdline)); + } + + public static Executor of(List cmdline) { + cmdline.forEach(Objects::requireNonNull); + return new Executor().setExecutable(cmdline.getFirst()).addArguments(cmdline.subList(1, cmdline.size())); + } + + public static Executor of(ToolProvider toolProvider, String... args) { + return new Executor().setToolProvider(toolProvider).addArguments(List.of(args)); } public Executor() { @@ -414,8 +422,8 @@ private Result runExecutable() throws IOException, InterruptedException { || saveOutputType.contains(SaveOutputType.FULL)) { outputLines = outReader.lines().collect(Collectors.toList()); } else { - outputLines = Arrays.asList( - outReader.lines().findFirst().orElse(null)); + outputLines = Optional.ofNullable(outReader.readLine()).map(List::of).orElseGet(List::of); + outReader.transferTo(Writer.nullWriter()); } } finally { if (saveOutputType.contains(SaveOutputType.DUMP) && outputLines != null) { @@ -475,15 +483,11 @@ public void write(int b) { final var exitCode = runToolProvider(ps, ps); ps.flush(); final List output; + final var bufAsString = buf.toString(); try (BufferedReader bufReader = new BufferedReader(new StringReader( - buf.toString()))) { + bufAsString))) { if (saveOutputType.contains(SaveOutputType.FIRST_LINE)) { - String firstLine = bufReader.lines().findFirst().orElse(null); - if (firstLine != null) { - output = List.of(firstLine); - } else { - output = null; - } + output = bufReader.lines().findFirst().map(List::of).orElseGet(List::of); } else if (saveOutputType.contains(SaveOutputType.FULL)) { output = bufReader.lines().collect(Collectors.toUnmodifiableList()); } else { @@ -495,7 +499,7 @@ public void write(int b) { if (saveOutputType.contains(SaveOutputType.FULL)) { lines = output.stream(); } else { - lines = bufReader.lines(); + lines = new BufferedReader(new StringReader(bufAsString)).lines(); } lines.forEach(System.out::println); } From 0995b9409d910d816276673b5c06fdf7826bfac7 Mon Sep 17 00:00:00 2001 From: Anjian-Wen Date: Fri, 18 Apr 2025 02:20:39 +0000 Subject: [PATCH 002/901] 8354815: RISC-V: Change type of bitwise rotation shift to iRegIorL2I Reviewed-by: fyang, fjiang --- src/hotspot/cpu/riscv/riscv.ad | 14 ++++++-------- src/hotspot/cpu/riscv/riscv_b.ad | 20 +++++++++++++++----- src/hotspot/cpu/riscv/riscv_v.ad | 4 ++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index aca2f4dd488..1eb1464e7d9 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -6445,7 +6445,6 @@ instruct addI_reg_imm(iRegINoSp dst, iRegIorL2I src1, immIAdd src2) %{ format %{ "addiw $dst, $src1, $src2\t#@addI_reg_imm" %} ins_encode %{ - int32_t con = (int32_t)$src2$$constant; __ addiw(as_Register($dst$$reg), as_Register($src1$$reg), $src2$$constant); @@ -6507,7 +6506,6 @@ instruct addP_reg_imm(iRegPNoSp dst, iRegP src1, immLAdd src2) %{ format %{ "addi $dst, $src1, $src2\t# ptr, #@addP_reg_imm" %} ins_encode %{ - // src2 is imm, so actually call the addi __ addi(as_Register($dst$$reg), as_Register($src1$$reg), $src2$$constant); @@ -6829,7 +6827,7 @@ instruct UmodL(iRegLNoSp dst, iRegL src1, iRegL src2) %{ // Integer Shifts // Shift Left Register -// In RV64I, only the low 5 bits of src2 are considered for the shift amount +// Only the low 5 bits of src2 are considered for the shift amount, all other bits are ignored. instruct lShiftI_reg_reg(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{ match(Set dst (LShiftI src1 src2)); ins_cost(ALU_COST); @@ -6862,7 +6860,7 @@ instruct lShiftI_reg_imm(iRegINoSp dst, iRegIorL2I src1, immI src2) %{ %} // Shift Right Logical Register -// In RV64I, only the low 5 bits of src2 are considered for the shift amount +// Only the low 5 bits of src2 are considered for the shift amount, all other bits are ignored. instruct urShiftI_reg_reg(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{ match(Set dst (URShiftI src1 src2)); ins_cost(ALU_COST); @@ -6895,7 +6893,7 @@ instruct urShiftI_reg_imm(iRegINoSp dst, iRegIorL2I src1, immI src2) %{ %} // Shift Right Arithmetic Register -// In RV64I, only the low 5 bits of src2 are considered for the shift amount +// Only the low 5 bits of src2 are considered for the shift amount, all other bits are ignored. instruct rShiftI_reg_reg(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{ match(Set dst (RShiftI src1 src2)); ins_cost(ALU_COST); @@ -6930,7 +6928,7 @@ instruct rShiftI_reg_imm(iRegINoSp dst, iRegIorL2I src1, immI src2) %{ // Long Shifts // Shift Left Register -// In RV64I, only the low 6 bits of src2 are considered for the shift amount +// Only the low 6 bits of src2 are considered for the shift amount, all other bits are ignored. instruct lShiftL_reg_reg(iRegLNoSp dst, iRegL src1, iRegIorL2I src2) %{ match(Set dst (LShiftL src1 src2)); @@ -6965,7 +6963,7 @@ instruct lShiftL_reg_imm(iRegLNoSp dst, iRegL src1, immI src2) %{ %} // Shift Right Logical Register -// In RV64I, only the low 6 bits of src2 are considered for the shift amount +// Only the low 6 bits of src2 are considered for the shift amount, all other bits are ignored. instruct urShiftL_reg_reg(iRegLNoSp dst, iRegL src1, iRegIorL2I src2) %{ match(Set dst (URShiftL src1 src2)); @@ -7018,7 +7016,7 @@ instruct urShiftP_reg_imm(iRegLNoSp dst, iRegP src1, immI src2) %{ %} // Shift Right Arithmetic Register -// In RV64I, only the low 6 bits of src2 are considered for the shift amount +// Only the low 6 bits of src2 are considered for the shift amount, all other bits are ignored. instruct rShiftL_reg_reg(iRegLNoSp dst, iRegL src1, iRegIorL2I src2) %{ match(Set dst (RShiftL src1 src2)); diff --git a/src/hotspot/cpu/riscv/riscv_b.ad b/src/hotspot/cpu/riscv/riscv_b.ad index ed9fca13a1b..beac10ec03d 100644 --- a/src/hotspot/cpu/riscv/riscv_b.ad +++ b/src/hotspot/cpu/riscv/riscv_b.ad @@ -25,7 +25,8 @@ // RISCV Bit-Manipulation Extension Architecture Description File -instruct rorI_imm_b(iRegINoSp dst, iRegI src, immI shift) %{ +// Rotate Right Word Immediate +instruct rorI_imm_b(iRegINoSp dst, iRegIorL2I src, immI shift) %{ predicate(UseZbb); match(Set dst (RotateRight src shift)); @@ -39,6 +40,7 @@ instruct rorI_imm_b(iRegINoSp dst, iRegI src, immI shift) %{ ins_pipe(ialu_reg_shift); %} +// Rotate Right Immediate instruct rorL_imm_b(iRegLNoSp dst, iRegL src, immI shift) %{ predicate(UseZbb); match(Set dst (RotateRight src shift)); @@ -53,7 +55,9 @@ instruct rorL_imm_b(iRegLNoSp dst, iRegL src, immI shift) %{ ins_pipe(ialu_reg_shift); %} -instruct rorI_reg_b(iRegINoSp dst, iRegI src, iRegI shift) %{ +// Rotate Right Word Register +// Only the low 5 bits of shift value are used, all other bits are ignored. +instruct rorI_reg_b(iRegINoSp dst, iRegIorL2I src, iRegIorL2I shift) %{ predicate(UseZbb); match(Set dst (RotateRight src shift)); @@ -65,7 +69,9 @@ instruct rorI_reg_b(iRegINoSp dst, iRegI src, iRegI shift) %{ ins_pipe(ialu_reg_reg); %} -instruct rorL_reg_b(iRegLNoSp dst, iRegL src, iRegI shift) %{ +// Rotate Right Register +// Only the low 6 bits of shift value are used, all other bits are ignored. +instruct rorL_reg_b(iRegLNoSp dst, iRegL src, iRegIorL2I shift) %{ predicate(UseZbb); match(Set dst (RotateRight src shift)); @@ -77,7 +83,9 @@ instruct rorL_reg_b(iRegLNoSp dst, iRegL src, iRegI shift) %{ ins_pipe(ialu_reg_reg); %} -instruct rolI_reg_b(iRegINoSp dst, iRegI src, iRegI shift) %{ +// Rotate Left Word Register +// Only the low 5 bits of shift value are used, all other bits are ignored. +instruct rolI_reg_b(iRegINoSp dst, iRegIorL2I src, iRegIorL2I shift) %{ predicate(UseZbb); match(Set dst (RotateLeft src shift)); @@ -89,7 +97,9 @@ instruct rolI_reg_b(iRegINoSp dst, iRegI src, iRegI shift) %{ ins_pipe(ialu_reg_reg); %} -instruct rolL_reg_b(iRegLNoSp dst, iRegL src, iRegI shift) %{ +// Rotate Left Register +// Only the low 6 bits of shift value are used, all other bits are ignored. +instruct rolL_reg_b(iRegLNoSp dst, iRegL src, iRegIorL2I shift) %{ predicate(UseZbb); match(Set dst (RotateLeft src shift)); diff --git a/src/hotspot/cpu/riscv/riscv_v.ad b/src/hotspot/cpu/riscv/riscv_v.ad index 9b135215b3d..7c1ca4f8960 100644 --- a/src/hotspot/cpu/riscv/riscv_v.ad +++ b/src/hotspot/cpu/riscv/riscv_v.ad @@ -3499,6 +3499,7 @@ instruct vrotate_right(vReg dst, vReg src, vReg shift) %{ ins_pipe(pipe_slow); %} +// Only the low log2(SEW) bits of shift value are used, all other bits are ignored. instruct vrotate_right_reg(vReg dst, vReg src, iRegIorL2I shift) %{ match(Set dst (RotateRightV src (Replicate shift))); format %{ "vrotate_right_reg $dst, $src, $shift\t" %} @@ -3541,6 +3542,7 @@ instruct vrotate_right_masked(vReg dst_src, vReg shift, vRegMask_V0 v0) %{ ins_pipe(pipe_slow); %} +// Only the low log2(SEW) bits of shift value are used, all other bits are ignored. instruct vrotate_right_reg_masked(vReg dst_src, iRegIorL2I shift, vRegMask_V0 v0) %{ match(Set dst_src (RotateRightV (Binary dst_src (Replicate shift)) v0)); format %{ "vrotate_right_reg_masked $dst_src, $dst_src, $shift, v0.t\t" %} @@ -3584,6 +3586,7 @@ instruct vrotate_left(vReg dst, vReg src, vReg shift) %{ ins_pipe(pipe_slow); %} +// Only the low log2(SEW) bits of shift value are used, all other bits are ignored. instruct vrotate_left_reg(vReg dst, vReg src, iRegIorL2I shift) %{ match(Set dst (RotateLeftV src (Replicate shift))); format %{ "vrotate_left_reg $dst, $src, $shift\t" %} @@ -3627,6 +3630,7 @@ instruct vrotate_left_masked(vReg dst_src, vReg shift, vRegMask_V0 v0) %{ ins_pipe(pipe_slow); %} +// Only the low log2(SEW) bits of shift value are used, all other bits are ignored. instruct vrotate_left_reg_masked(vReg dst_src, iRegIorL2I shift, vRegMask_V0 v0) %{ match(Set dst_src (RotateLeftV (Binary dst_src (Replicate shift)) v0)); format %{ "vrotate_left_reg_masked $dst_src, $dst_src, $shift, v0.t\t" %} From 0feecb7c6a982e5c65df0242711ecdb0691cef87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C5=A0ipka?= Date: Fri, 18 Apr 2025 10:44:29 +0000 Subject: [PATCH 003/901] 8351851: Update PmemTest to run on AMD64 Reviewed-by: adinn --- test/jdk/java/nio/MappedByteBuffer/PmemTest.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/jdk/java/nio/MappedByteBuffer/PmemTest.java b/test/jdk/java/nio/MappedByteBuffer/PmemTest.java index 2771295c8a0..0c931b3606f 100644 --- a/test/jdk/java/nio/MappedByteBuffer/PmemTest.java +++ b/test/jdk/java/nio/MappedByteBuffer/PmemTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -77,25 +77,24 @@ * make test TEST=jdk/java/nio/MappedByteBuffer/PmemTest.java */ -/* @test +/* @test id=default_architecture_test_case * @summary Testing NVRAM mapped byte buffer support * @run main/manual PmemTest * @requires (os.family == "linux") - * @requires (os.arch == "x86_64") + * @requires ((os.arch == "x86_64")|(os.arch == "amd64")) */ -/* @test +/* @test id=other_architectures_test_case * @summary Testing NVRAM mapped byte buffer support * @run main/manual PmemTest * @requires (os.family == "linux") - * @requires ((os.arch == "amd64")|(os.arch == "aarch64")|(os.arch == "ppc64le")) + * @requires ((os.arch == "aarch64")|(os.arch == "ppc64le")) * @ignore The test described here is currently disabled on systems that are not * x64-based and lack an external NVRAM memory device. In order to re-enable the * test, you will need to mount the NVRAM device, which will typically appear as * /dev/pmem0, to the directory /mnt/pmem. Once that is done, you can follow the * instructions above to create a test directory and remove the ignore tag. */ - import java.io.File; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; @@ -173,4 +172,4 @@ public static void dumpBufferPoolBeans() "\n}"); } } -} +} \ No newline at end of file From eda7394551b470e9dc547be93711bcceac45f303 Mon Sep 17 00:00:00 2001 From: Jayathirth D V Date: Fri, 18 Apr 2025 12:05:01 +0000 Subject: [PATCH 004/901] 8354900: javax/swing/AbstractButton/bug4133768.java failing on macosx-aarch64 Reviewed-by: abhiscxk --- .../swing/AbstractButton/bug4133768.java | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/test/jdk/javax/swing/AbstractButton/bug4133768.java b/test/jdk/javax/swing/AbstractButton/bug4133768.java index ad5f56c0149..4ccec98c6ec 100644 --- a/test/jdk/javax/swing/AbstractButton/bug4133768.java +++ b/test/jdk/javax/swing/AbstractButton/bug4133768.java @@ -34,8 +34,11 @@ import java.awt.GridLayout; import java.awt.Point; import java.awt.Robot; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.awt.image.BufferedImage; -import java.io.IOException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import javax.swing.AbstractButton; import javax.swing.Icon; import javax.swing.ImageIcon; @@ -47,20 +50,28 @@ import javax.swing.SwingUtilities; public class bug4133768 { - private static Icon RED, GREEN; + private static Icon RED; + private static Icon GREEN; private static JFrame f; private static AbstractButton[] buttons; private static volatile Point buttonLocation; private static volatile int buttonWidth; private static volatile int buttonHeight; private static Robot robot; + private static int ROLLOVER_Y_OFFSET = 4; + private static CountDownLatch frameGainedFocusLatch = + new CountDownLatch(1); public static void main(String[] args) throws Exception { try { createTestImages(); createUI(); + f.requestFocus(); + if (!frameGainedFocusLatch.await(5, TimeUnit.SECONDS)) { + throw new RuntimeException("Waited too long, but can't gain" + + " focus for frame"); + } robot = new Robot(); - robot.delay(1000); for (AbstractButton b : buttons) { testEnabledButton(b); } @@ -78,9 +89,9 @@ public static void main(String[] args) throws Exception { } } - private static void createTestImages() throws IOException { - int imageWidth = 32; - int imageHeight = 32; + private static void createTestImages() { + int imageWidth = 100; + int imageHeight = 100; BufferedImage redImg = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB); Graphics2D g = redImg.createGraphics(); @@ -114,6 +125,12 @@ private static void createUI() throws Exception { b.setRolloverSelectedIcon(GREEN); buttonPanel.add(b); } + f.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + frameGainedFocusLatch.countDown(); + } + }); f.setLayout(new GridLayout(2, 1)); f.add(buttonPanel); f.pack(); @@ -123,7 +140,8 @@ private static void createUI() throws Exception { }); } - private static void testEnabledButton(AbstractButton button) throws Exception { + private static void testEnabledButton(AbstractButton button) + throws Exception { robot.waitForIdle(); SwingUtilities.invokeAndWait(() -> { buttonLocation = button.getLocationOnScreen(); @@ -131,7 +149,7 @@ private static void testEnabledButton(AbstractButton button) throws Exception { buttonHeight = button.getHeight(); }); robot.mouseMove(buttonLocation.x + buttonWidth / 2, - buttonLocation.y + buttonHeight / 2 ); + buttonLocation.y + ROLLOVER_Y_OFFSET); robot.delay(1000); Color buttonColor = robot.getPixelColor(buttonLocation.x + buttonWidth / 2, buttonLocation.y + buttonHeight / 2); @@ -141,16 +159,15 @@ private static void testEnabledButton(AbstractButton button) throws Exception { } } - private static void testDisabledButton(AbstractButton button) throws Exception { + private static void testDisabledButton(AbstractButton button) + throws Exception { robot.waitForIdle(); SwingUtilities.invokeAndWait(() -> { buttonLocation = button.getLocationOnScreen(); buttonWidth = button.getWidth(); buttonHeight = button.getHeight(); }); - robot.mouseMove(buttonLocation.x + buttonWidth / 2, - buttonLocation.y + buttonHeight / 2 ); - robot.delay(1000); + robot.delay(200); Color buttonColor = robot.getPixelColor(buttonLocation.x + buttonWidth / 2, buttonLocation.y + buttonHeight / 2); if (buttonColor.equals(Color.GREEN) || From 22e8a97a1ce4e1c781fbc6f1e271c477fe95f069 Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Fri, 18 Apr 2025 12:12:52 +0000 Subject: [PATCH 005/901] 8354988: Separate stderr and stdout in Executor class from jpackage test lib Reviewed-by: almatvee --- .../jdk/jpackage/test/ExecutorTest.java | 29 +- .../jdk/jpackage/test/PackageTestTest.java | 2 +- .../helpers/jdk/jpackage/test/Executor.java | 668 ++++++++++++++---- .../jdk/jpackage/test/JPackageCommand.java | 17 + .../jdk/jpackage/test/WindowsHelper.java | 13 +- test/jdk/tools/jpackage/share/BasicTest.java | 7 +- .../jpackage/windows/Win8301247Test.java | 36 +- 7 files changed, 601 insertions(+), 171 deletions(-) diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/ExecutorTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/ExecutorTest.java index 8175f49a2b2..c5d8aed845c 100644 --- a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/ExecutorTest.java +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/ExecutorTest.java @@ -128,8 +128,8 @@ public enum OutputControl { DUMP(Executor::dumpOutput), SAVE_ALL(Executor::saveOutput), SAVE_FIRST_LINE(Executor::saveFirstLineOfOutput), - DISCARD_STDOUT(NOP), - DISCARD_STDERR(NOP), + DISCARD_STDOUT(Executor::discardStdout), + DISCARD_STDERR(Executor::discardStderr), ; OutputControl(Consumer configureExector) { @@ -213,6 +213,9 @@ void test() { assertEquals(expectedCapturedSystemOut(commandWithDiscardedStreams), outputCapture.outLines()); assertEquals(expectedCapturedSystemErr(commandWithDiscardedStreams), outputCapture.errLines()); + assertEquals(expectedResultStdout(commandWithDiscardedStreams), result[0].stdout().getOutput()); + assertEquals(expectedResultStderr(commandWithDiscardedStreams), result[0].stderr().getOutput()); + if (!saveOutput()) { assertNull(result[0].getOutput()); } else { @@ -272,6 +275,28 @@ private List expectedCapturedSystemErr(Command command) { } } + private List expectedResultStdout(Command command) { + return expectedResultStream(command.stdout()); + } + + private List expectedResultStderr(Command command) { + if (outputControl.contains(OutputControl.SAVE_FIRST_LINE) && !command.stdout().isEmpty()) { + return List.of(); + } + return expectedResultStream(command.stderr()); + } + + private List expectedResultStream(List commandOutput) { + Objects.requireNonNull(commandOutput); + if (outputControl.contains(OutputControl.SAVE_ALL)) { + return commandOutput; + } else if (outputControl.contains(OutputControl.SAVE_FIRST_LINE)) { + return commandOutput.stream().findFirst().map(List::of).orElseGet(List::of); + } else { + return null; + } + } + private Command discardStreams(Command command) { return new Command(discardStdout() ? List.of() : command.stdout(), discardStderr() ? List.of() : command.stderr()); } diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/PackageTestTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/PackageTestTest.java index 3e14022a70e..da94db30925 100644 --- a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/PackageTestTest.java +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/PackageTestTest.java @@ -370,7 +370,7 @@ public Executor.Result execute(int expectedExitCode) { } catch (IOException ex) { throw new UncheckedIOException(ex); } - return new Executor.Result(actualJPackageExitCode, null, + return new Executor.Result(actualJPackageExitCode, this::getPrintableCommandLine).assertExitCodeIs(expectedExitCode); } }; diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java index 053674960c4..91625603a2b 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Executor.java @@ -22,9 +22,12 @@ */ package jdk.jpackage.test; +import static java.util.stream.Collectors.joining; + import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; @@ -32,7 +35,6 @@ import java.io.Writer; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -63,7 +65,7 @@ public static Executor of(ToolProvider toolProvider, String... args) { } public Executor() { - saveOutputType = new HashSet<>(Set.of(SaveOutputType.NONE)); + outputStreamsControl = new OutputStreamsControl(); winEnglishOutput = false; } @@ -131,54 +133,48 @@ public Executor setWindowsTmpDir(String tmp) { } /** - * Configures this instance to save full output that command will produce. - * This function is mutual exclusive with - * saveFirstLineOfOutput() function. + * Configures this instance to save all stdout and stderr streams from the to be + * executed command. + *

+ * This function is mutually exclusive with {@link #saveFirstLineOfOutput()}. * * @return this */ public Executor saveOutput() { - saveOutputType.remove(SaveOutputType.FIRST_LINE); - saveOutputType.add(SaveOutputType.FULL); - return this; + return saveOutput(true); } /** - * Configures how to save output that command will produce. If - * v is true, the function call is equivalent to - * saveOutput() call. If v is false, - * the function will result in not preserving command output. + * Configures if all stdout and stderr streams from the to be executed command + * should be saved. + *

+ * If v is true, the function call is equivalent to + * {@link #saveOutput()} call. If v is false, command + * output will not be saved. + * + * @parameter v if both stdout and stderr streams should be saved * * @return this */ public Executor saveOutput(boolean v) { - if (v) { - saveOutput(); - } else { - saveOutputType.remove(SaveOutputType.FIRST_LINE); - saveOutputType.remove(SaveOutputType.FULL); - } - return this; + return setOutputControl(v, OutputControlOption.SAVE_ALL); } /** - * Configures this instance to save only the first line out output that - * command will produce. This function is mutual exclusive with - * saveOutput() function. + * Configures this instance to save the first line of a stream merged from + * stdout and stderr streams from the to be executed command. + *

+ * This function is mutually exclusive with {@link #saveOutput()}. * * @return this */ public Executor saveFirstLineOfOutput() { - saveOutputType.add(SaveOutputType.FIRST_LINE); - saveOutputType.remove(SaveOutputType.FULL); - return this; + return setOutputControl(true, OutputControlOption.SAVE_FIRST_LINE); } /** - * Configures this instance to dump all output that command will produce to - * System.out and System.err. Can be used together with saveOutput() and - * saveFirstLineOfOutput() to save command output and also copy it in the - * default output streams. + * Configures this instance to dump both stdout and stderr streams from the to + * be executed command into {@link System.out}. * * @return this */ @@ -187,26 +183,60 @@ public Executor dumpOutput() { } public Executor dumpOutput(boolean v) { - if (v) { - saveOutputType.add(SaveOutputType.DUMP); - } else { - saveOutputType.remove(SaveOutputType.DUMP); - } + return setOutputControl(v, OutputControlOption.DUMP); + } + + public Executor discardStdout(boolean v) { + outputStreamsControl.stdout().discard(v); return this; } - public record Result(int exitCode, List output, Supplier cmdline) { + public Executor discardStdout() { + return discardStdout(true); + } + public Executor discardStderr(boolean v) { + outputStreamsControl.stderr().discard(v); + return this; + } + + public Executor discardStderr() { + return discardStderr(true); + } + + public interface Output { + public List getOutput(); + + public default String getFirstLineOfOutput() { + return findFirstLineOfOutput().orElseThrow(); + } + + public default Optional findFirstLineOfOutput() { + return getOutput().stream().findFirst(); + } + } + + public record Result(int exitCode, CommandOutput output, Supplier cmdline) implements Output { public Result { + Objects.requireNonNull(output); Objects.requireNonNull(cmdline); } - public String getFirstLineOfOutput() { - return output.get(0); + public Result(int exitCode, Supplier cmdline) { + this(exitCode, CommandOutput.EMPTY, cmdline); } + @Override public List getOutput() { - return output; + return output.lines().orElse(null); + } + + public Output stdout() { + return createView(output.stdoutLines()); + } + + public Output stderr() { + return createView(output.stderrLines()); } public Result assertExitCodeIs(int expectedExitCode) { @@ -223,6 +253,15 @@ public Result assertExitCodeIsZero() { public int getExitCode() { return exitCode; } + + private static Output createView(Optional> lines) { + return new Output() { + @Override + public List getOutput() { + return lines.orElse(null); + } + }; + } } public Result executeWithoutExitCodeCheck() { @@ -278,27 +317,42 @@ Result getValue() { private static final long serialVersionUID = 1L; } - /* - * Repeates command "max" times and waits for "wait" seconds between each - * execution until command returns expected error code. + /** + * Executes the configured command {@code max} at most times and waits for + * {@code wait} seconds between each execution until the command exits with + * {@code expectedCode} exit code. + * + * @param expectedExitCode the expected exit code of the command + * @param max the maximum times to execute the command + * @param wait number of seconds to wait between executions of the + * command */ - public Result executeAndRepeatUntilExitCode(int expectedCode, int max, int wait) { + public Result executeAndRepeatUntilExitCode(int expectedExitCode, int max, int wait) { try { return tryRunMultipleTimes(() -> { Result result = executeWithoutExitCodeCheck(); - if (result.getExitCode() != expectedCode) { + if (result.getExitCode() != expectedExitCode) { throw new BadResultException(result); } return result; - }, max, wait).assertExitCodeIs(expectedCode); + }, max, wait).assertExitCodeIs(expectedExitCode); } catch (BadResultException ex) { - return ex.getValue().assertExitCodeIs(expectedCode); + return ex.getValue().assertExitCodeIs(expectedExitCode); } } - /* - * Repeates a "task" "max" times and waits for "wait" seconds between each - * execution until the "task" returns without throwing an exception. + /** + * Calls {@code task.get()} at most {@code max} times and waits for {@code wait} + * seconds between each call until {@code task.get()} invocation returns without + * throwing {@link RuntimeException} exception. + *

+ * Returns the object returned by the first {@code task.get()} invocation that + * didn't throw an exception or rethrows the last exception if all of + * {@code max} attempts ended in exception being thrown. + * + * @param task the object of which to call {@link Supplier#get()} function + * @param max the maximum times to execute the command + * @param wait number of seconds to wait between executions of the */ public static T tryRunMultipleTimes(Supplier task, int max, int wait) { RuntimeException lastException = null; @@ -334,9 +388,10 @@ public List executeWithoutExitCodeCheckAndGetOutput() { return saveOutput().executeWithoutExitCodeCheck().getOutput(); } - private boolean withSavedOutput() { - return saveOutputType.contains(SaveOutputType.FULL) || saveOutputType.contains( - SaveOutputType.FIRST_LINE); + private Executor setOutputControl(boolean set, OutputControlOption v) { + outputStreamsControl.stdout().set(set, v); + outputStreamsControl.stderr().set(set, v); + return this; } private Path executablePath() { @@ -349,8 +404,8 @@ private Path executablePath() { // If relative path to executable is used it seems to be broken when // ProcessBuilder changes the directory. On Windows it changes the // directory first and on Linux it looks up for executable before - // changing the directory. So to stay of safe side, use absolute path - // to executable. + // changing the directory. Use absolute path to executable to play + // it safely on all platforms. return executable.toAbsolutePath(); } @@ -371,18 +426,14 @@ private Result runExecutable() throws IOException, InterruptedException { if (winTmpDir != null) { builder.environment().put("TMP", winTmpDir); } + + outputStreamsControl.applyTo(builder); + StringBuilder sb = new StringBuilder(getPrintableCommandLine()); - if (withSavedOutput()) { - builder.redirectErrorStream(true); - sb.append("; save output"); - } else if (saveOutputType.contains(SaveOutputType.DUMP)) { - builder.inheritIO(); - sb.append("; inherit I/O"); - } else { - builder.redirectError(ProcessBuilder.Redirect.DISCARD); - builder.redirectOutput(ProcessBuilder.Redirect.DISCARD); - sb.append("; discard I/O"); - } + outputStreamsControl.describe().ifPresent(desc -> { + sb.append("; ").append(desc); + }); + if (directory != null) { builder.directory(directory.toFile()); sb.append(String.format("; in directory [%s]", directory)); @@ -414,100 +465,112 @@ private Result runExecutable() throws IOException, InterruptedException { trace("Execute " + sb.toString() + "..."); Process process = builder.start(); - List outputLines = null; - if (withSavedOutput()) { - try (BufferedReader outReader = new BufferedReader( - new InputStreamReader(process.getInputStream()))) { - if (saveOutputType.contains(SaveOutputType.DUMP) - || saveOutputType.contains(SaveOutputType.FULL)) { - outputLines = outReader.lines().collect(Collectors.toList()); - } else { - outputLines = Optional.ofNullable(outReader.readLine()).map(List::of).orElseGet(List::of); - outReader.transferTo(Writer.nullWriter()); - } - } finally { - if (saveOutputType.contains(SaveOutputType.DUMP) && outputLines != null) { - outputLines.stream().forEach(System.out::println); - if (saveOutputType.contains(SaveOutputType.FIRST_LINE)) { - // Pick the first line of saved output if there is one - for (String line: outputLines) { - outputLines = List.of(line); - break; - } - } - } - } - } + final var output = combine( + processProcessStream(outputStreamsControl.stdout(), process.getInputStream()), + processProcessStream(outputStreamsControl.stderr(), process.getErrorStream())); final int exitCode = process.waitFor(); trace("Done. Exit code: " + exitCode); - final List output; - if (outputLines != null) { - output = Collections.unmodifiableList(outputLines); - } else { - output = null; - } return createResult(exitCode, output); } private int runToolProvider(PrintStream out, PrintStream err) { - trace("Execute " + getPrintableCommandLine() + "..."); + final var sb = new StringBuilder(getPrintableCommandLine()); + outputStreamsControl.describe().ifPresent(desc -> { + sb.append("; ").append(desc); + }); + trace("Execute " + sb + "..."); final int exitCode = toolProvider.run(out, err, args.toArray( String[]::new)); trace("Done. Exit code: " + exitCode); return exitCode; } - private Result createResult(int exitCode, List output) { - return new Result(exitCode, output, this::getPrintableCommandLine); + private Result runToolProvider() throws IOException { + final var toolProviderStreamConfig = ToolProviderStreamConfig.create(outputStreamsControl); + + final var exitCode = runToolProvider(toolProviderStreamConfig); + + final var output = combine( + read(outputStreamsControl.stdout(), toolProviderStreamConfig.out()), + read(outputStreamsControl.stderr(), toolProviderStreamConfig.err())); + return createResult(exitCode, output); } - private Result runToolProvider() throws IOException { - if (!withSavedOutput()) { - if (saveOutputType.contains(SaveOutputType.DUMP)) { - return createResult(runToolProvider(System.out, System.err), null); - } + private int runToolProvider(ToolProviderStreamConfig cfg) throws IOException { + try { + return runToolProvider(cfg.out().ps(), cfg.err().ps()); + } finally { + cfg.out().ps().flush(); + cfg.err().ps().flush(); + } + } - PrintStream nullPrintStream = new PrintStream(new OutputStream() { - @Override - public void write(int b) { - // Nop - } - }); - return createResult(runToolProvider(nullPrintStream, nullPrintStream), null); - } - - try (ByteArrayOutputStream buf = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(buf)) { - final var exitCode = runToolProvider(ps, ps); - ps.flush(); - final List output; - final var bufAsString = buf.toString(); - try (BufferedReader bufReader = new BufferedReader(new StringReader( - bufAsString))) { - if (saveOutputType.contains(SaveOutputType.FIRST_LINE)) { - output = bufReader.lines().findFirst().map(List::of).orElseGet(List::of); - } else if (saveOutputType.contains(SaveOutputType.FULL)) { - output = bufReader.lines().collect(Collectors.toUnmodifiableList()); - } else { - output = null; + private static Optional> processProcessStream(OutputControl outputControl, InputStream in) throws IOException { + List outputLines = null; + try (final var bufReader = new BufferedReader(new InputStreamReader(in))) { + if (outputControl.dump() || outputControl.saveAll()) { + outputLines = bufReader.lines().toList(); + } else if (outputControl.saveFirstLine()) { + outputLines = Optional.ofNullable(bufReader.readLine()).map(List::of).orElseGet(List::of); + // Read all input, or the started process may exit with an error (cmd.exe does so). + bufReader.transferTo(Writer.nullWriter()); + } else { + // This should be empty input stream, fetch it anyway. + bufReader.transferTo(Writer.nullWriter()); + } + } finally { + if (outputControl.dump() && outputLines != null) { + outputLines.forEach(System.out::println); + if (outputControl.saveFirstLine()) { + outputLines = outputLines.stream().findFirst().map(List::of).orElseGet(List::of); } + } + if (!outputControl.save()) { + outputLines = null; + } + } + return Optional.ofNullable(outputLines); + } + + private static Optional> read(OutputControl outputControl, CachingPrintStream cps) throws IOException { + final var bufferAsString = cps.bufferContents(); + try (final var bufReader = new BufferedReader(new StringReader(bufferAsString.orElse("")))) { + if (outputControl.saveFirstLine()) { + return Optional.of(bufReader.lines().findFirst().map(List::of).orElseGet(List::of)); + } else if (outputControl.saveAll()) { + return Optional.of(bufReader.lines().toList()); + } else if (bufferAsString.isPresent()) { + return Optional.of(List.of()); + } else { + return Optional.empty(); + } + } + } - if (saveOutputType.contains(SaveOutputType.DUMP)) { - Stream lines; - if (saveOutputType.contains(SaveOutputType.FULL)) { - lines = output.stream(); - } else { - lines = new BufferedReader(new StringReader(bufAsString)).lines(); - } - lines.forEach(System.out::println); - } + private CommandOutput combine(Optional> out, Optional> err) { + if (out.isEmpty() && err.isEmpty()) { + return new CommandOutput(); + } else if (out.isEmpty()) { + return new CommandOutput(err, -1); + } else if (err.isEmpty()) { + return new CommandOutput(out, Integer.MAX_VALUE); + } else { + final var combined = Stream.of(out, err).map(Optional::orElseThrow).flatMap(List::stream); + if (outputStreamsControl.stdout().saveFirstLine() && outputStreamsControl.stderr().saveFirstLine()) { + return new CommandOutput(Optional.of(combined.findFirst().map(List::of).orElseGet(List::of)), + Integer.min(1, out.orElseThrow().size())); + } else { + return new CommandOutput(Optional.of(combined.toList()), out.orElseThrow().size()); } - return createResult(exitCode, output); } } + private Result createResult(int exitCode, CommandOutput output) { + return new Result(exitCode, output, this::getPrintableCommandLine); + } + public String getPrintableCommandLine() { final String exec; String format = "[%s](%d)"; @@ -539,16 +602,343 @@ private static void trace(String msg) { TKit.trace(String.format("exec: %s", msg)); } + private static PrintStream nullPrintStream() { + return new PrintStream(OutputStream.nullOutputStream()); + } + + private record OutputStreamsControl(OutputControl stdout, OutputControl stderr) { + OutputStreamsControl { + Objects.requireNonNull(stdout); + Objects.requireNonNull(stderr); + } + + OutputStreamsControl() { + this(new OutputControl(), new OutputControl()); + } + + void applyTo(ProcessBuilder pb) { + pb.redirectOutput(stdout.asProcessBuilderRedirect()); + pb.redirectError(stderr.asProcessBuilderRedirect()); + } + + Optional describe() { + final List tokens = new ArrayList<>(); + if (stdout.save() || stderr.save()) { + streamsLabel("save ", true).ifPresent(tokens::add); + } + if (stdout.dump() || stderr.dump()) { + streamsLabel("inherit ", true).ifPresent(tokens::add); + } + streamsLabel("discard ", false).ifPresent(tokens::add); + if (tokens.isEmpty()) { + return Optional.empty(); + } else { + return Optional.of(String.join("; ", tokens)); + } + } + + Optional streamsLabel(String prefix, boolean negate) { + Objects.requireNonNull(prefix); + final var str = Stream.of(stdoutLabel(negate), stderrLabel(negate)) + .filter(Optional::isPresent) + .map(Optional::orElseThrow) + .collect(joining("+")); + if (str.isEmpty()) { + return Optional.empty(); + } else { + return Optional.of(prefix + str); + } + } + + private Optional stdoutLabel(boolean negate) { + if ((stdout.discard() && !negate) || (!stdout.discard() && negate)) { + return Optional.of("out"); + } else { + return Optional.empty(); + } + } + + private Optional stderrLabel(boolean negate) { + if ((stderr.discard() && !negate) || (!stderr.discard() && negate)) { + return Optional.of("err"); + } else { + return Optional.empty(); + } + } + } + + private record CachingPrintStream(PrintStream ps, Optional buf) { + CachingPrintStream { + Objects.requireNonNull(ps); + Objects.requireNonNull(buf); + } + + Optional bufferContents() { + return buf.map(ByteArrayOutputStream::toString); + } + + static Builder build() { + return new Builder(); + } + + static final class Builder { + + Builder save(boolean v) { + save = v; + return this; + } + + Builder discard(boolean v) { + discard = v; + return this; + } + + Builder dumpStream(PrintStream v) { + dumpStream = v; + return this; + } + + CachingPrintStream create() { + final Optional buf; + if (save && !discard) { + buf = Optional.of(new ByteArrayOutputStream()); + } else { + buf = Optional.empty(); + } + + final PrintStream ps; + if (buf.isPresent() && dumpStream != null) { + ps = new PrintStream(new TeeOutputStream(List.of(buf.orElseThrow(), dumpStream)), true, dumpStream.charset()); + } else if (!discard) { + ps = buf.map(PrintStream::new).or(() -> Optional.ofNullable(dumpStream)).orElseGet(Executor::nullPrintStream); + } else { + ps = nullPrintStream(); + } + + return new CachingPrintStream(ps, buf); + } + + private boolean save; + private boolean discard; + private PrintStream dumpStream; + } + } + + private record ToolProviderStreamConfig(CachingPrintStream out, CachingPrintStream err) { + ToolProviderStreamConfig { + Objects.requireNonNull(out); + Objects.requireNonNull(err); + } + + static ToolProviderStreamConfig create(OutputStreamsControl cfg) { + final var errCfgBuilder = cfg.stderr().buildCachingPrintStream(System.err); + if (cfg.stderr().dump() && cfg.stderr().save()) { + errCfgBuilder.dumpStream(System.out); + } + return new ToolProviderStreamConfig( + cfg.stdout().buildCachingPrintStream(System.out).create(), errCfgBuilder.create()); + } + } + + private static final class OutputControl { + + boolean save() { + return save.isPresent(); + } + + boolean saveAll() { + return save.orElse(null) == OutputControlOption.SAVE_ALL; + } + + boolean saveFirstLine() { + return save.orElse(null) == OutputControlOption.SAVE_FIRST_LINE; + } + + boolean discard() { + return discard || (!dump && save.isEmpty()); + } + + boolean dump() { + return !discard && dump; + } + + OutputControl dump(boolean v) { + this.dump = v; + return this; + } + + OutputControl discard(boolean v) { + this.discard = v; + return this; + } + + OutputControl saveAll(boolean v) { + if (v) { + save = Optional.of(OutputControlOption.SAVE_ALL); + } else { + save = Optional.empty(); + } + return this; + } + + OutputControl saveFirstLine(boolean v) { + if (v) { + save = Optional.of(OutputControlOption.SAVE_FIRST_LINE); + } else { + save = Optional.empty(); + } + return this; + } + + OutputControl set(boolean set, OutputControlOption v) { + switch (v) { + case DUMP -> dump(set); + case SAVE_ALL -> saveAll(set); + case SAVE_FIRST_LINE -> saveFirstLine(set); + } + return this; + } + + ProcessBuilder.Redirect asProcessBuilderRedirect() { + if (discard()) { + return ProcessBuilder.Redirect.DISCARD; + } else if (dump && !save()) { + return ProcessBuilder.Redirect.INHERIT; + } else { + return ProcessBuilder.Redirect.PIPE; + } + } + + CachingPrintStream.Builder buildCachingPrintStream(PrintStream dumpStream) { + Objects.requireNonNull(dumpStream); + final var builder = CachingPrintStream.build().save(save()).discard(discard()); + if (dump()) { + builder.dumpStream(dumpStream); + } + return builder; + } + + private boolean dump; + private boolean discard; + private Optional save = Optional.empty(); + } + + private static final class TeeOutputStream extends OutputStream { + + public TeeOutputStream(Iterable streams) { + streams.forEach(Objects::requireNonNull); + this.streams = streams; + } + + @Override + public void write(int b) throws IOException { + for (final var out : streams) { + out.write(b); + } + } + + @Override + public void write(byte[] b) throws IOException { + for (final var out : streams) { + out.write(b); + } + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + for (final var out : streams) { + out.write(b, off, len); + } + } + + @Override + public void flush() throws IOException { + forEach(OutputStream::flush); + } + + @Override + public void close() throws IOException { + forEach(OutputStream::close); + } + + private void forEach(OutputStreamConsumer c) throws IOException { + IOException firstEx = null; + for (final var out : streams) { + try { + c.accept(out); + } catch (IOException e) { + if (firstEx == null) { + firstEx = e; + } + } + } + if (firstEx != null) { + throw firstEx; + } + } + + @FunctionalInterface + private static interface OutputStreamConsumer { + void accept(OutputStream out) throws IOException; + } + + private final Iterable streams; + } + + private static final class CommandOutput { + CommandOutput(Optional> lines, int stdoutLineCount) { + this.lines = Objects.requireNonNull(lines); + this.stdoutLineCount = stdoutLineCount; + } + + CommandOutput() { + this(Optional.empty(), 0); + } + + Optional> lines() { + return lines; + } + + Optional> stdoutLines() { + if (lines.isEmpty() || stdoutLineCount < 0) { + return Optional.empty(); + } + + final var theLines = lines.orElseThrow(); + if (stdoutLineCount == theLines.size()) { + return lines; + } else { + return Optional.of(theLines.subList(0, Integer.min(stdoutLineCount, theLines.size()))); + } + } + + Optional> stderrLines() { + if (lines.isEmpty() || stdoutLineCount > lines.orElseThrow().size()) { + return Optional.empty(); + } else if (stdoutLineCount == 0) { + return lines; + } else { + final var theLines = lines.orElseThrow(); + return Optional.of(theLines.subList(stdoutLineCount, theLines.size())); + } + } + + private final Optional> lines; + private final int stdoutLineCount; + + static final CommandOutput EMPTY = new CommandOutput(); + } + private ToolProvider toolProvider; private Path executable; - private Set saveOutputType; + private OutputStreamsControl outputStreamsControl; private Path directory; private Set removeEnvVars = new HashSet<>(); private Map setEnvVars = new HashMap<>(); private boolean winEnglishOutput; private String winTmpDir = null; - private static enum SaveOutputType { - NONE, FULL, FIRST_LINE, DUMP - }; + private static enum OutputControlOption { + SAVE_ALL, SAVE_FIRST_LINE, DUMP + } } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java index b4d2d1872eb..cb9e3a687c7 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java @@ -67,6 +67,8 @@ public JPackageCommand(JPackageCommand cmd) { args.addAll(cmd.args); withToolProvider = cmd.withToolProvider; saveConsoleOutput = cmd.saveConsoleOutput; + discardStdout = cmd.discardStdout; + discardStderr = cmd.discardStderr; suppressOutput = cmd.suppressOutput; ignoreDefaultRuntime = cmd.ignoreDefaultRuntime; ignoreDefaultVerbose = cmd.ignoreDefaultVerbose; @@ -679,6 +681,18 @@ public JPackageCommand saveConsoleOutput(boolean v) { return this; } + public JPackageCommand discardStdout(boolean v) { + verifyMutable(); + discardStdout = v; + return this; + } + + public JPackageCommand discardStderr(boolean v) { + verifyMutable(); + discardStderr = v; + return this; + } + public JPackageCommand dumpOutput(boolean v) { verifyMutable(); suppressOutput = !v; @@ -770,6 +784,7 @@ public JPackageCommand executeVerifyActions() { private Executor createExecutor() { Executor exec = new Executor() .saveOutput(saveConsoleOutput).dumpOutput(!suppressOutput) + .discardStdout(discardStdout).discardStderr(discardStderr) .setDirectory(executeInDirectory) .addArguments(args); @@ -1272,6 +1287,8 @@ public void run() { private Boolean withToolProvider; private boolean saveConsoleOutput; + private boolean discardStdout; + private boolean discardStderr; private boolean suppressOutput; private boolean ignoreDefaultRuntime; private boolean ignoreDefaultVerbose; diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java index bc67f6e417d..1c6ac9a7669 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java @@ -323,18 +323,19 @@ public static void killAppLauncherProcess(JPackageCommand cmd, private static long[] findAppLauncherPIDs(JPackageCommand cmd, String launcherName) { // Get the list of PIDs and PPIDs of app launcher processes. Run setWinRunWithEnglishOutput(true) for JDK-8344275. // wmic process where (name = "foo.exe") get ProcessID,ParentProcessID - List output = Executor.of("wmic", "process", "where", "(name", + final var result = Executor.of("wmic", "process", "where", "(name", "=", "\"" + cmd.appLauncherPath(launcherName).getFileName().toString() + "\"", ")", "get", "ProcessID,ParentProcessID").dumpOutput(true).saveOutput(). - setWinRunWithEnglishOutput(true).executeAndGetOutput(); - if ("No Instance(s) Available.".equals(output.getFirst().trim())) { + setWinRunWithEnglishOutput(true).execute(); + if ("No Instance(s) Available.".equals(result.stderr().findFirstLineOfOutput().map(String::trim).orElse(""))) { return new long[0]; } - String[] headers = Stream.of(output.getFirst().split("\\s+", 2)).map( + final var stdout = result.stdout(); + String[] headers = Stream.of(stdout.getFirstLineOfOutput().split("\\s+", 2)).map( String::trim).map(String::toLowerCase).toArray(String[]::new); - Pattern pattern; + final Pattern pattern; if (headers[0].equals("parentprocessid") && headers[1].equals( "processid")) { pattern = Pattern.compile("^(?\\d+)\\s+(?\\d+)\\s+$"); @@ -346,7 +347,7 @@ private static long[] findAppLauncherPIDs(JPackageCommand cmd, String launcherNa "Unrecognizable output of \'wmic process\' command"); } - List processes = output.stream().skip(1).map(line -> { + List processes = stdout.getOutput().stream().skip(1).map(line -> { Matcher m = pattern.matcher(line); long[] pids = null; if (m.matches()) { diff --git a/test/jdk/tools/jpackage/share/BasicTest.java b/test/jdk/tools/jpackage/share/BasicTest.java index 68c1b2c76cb..bfcfe7587d4 100644 --- a/test/jdk/tools/jpackage/share/BasicTest.java +++ b/test/jdk/tools/jpackage/share/BasicTest.java @@ -237,20 +237,21 @@ public void testErrorsAlwaysPrinted(boolean verbose) { final var cmd = JPackageCommand.helloAppImage() .ignoreDefaultVerbose(true) .useToolProvider(false) + .discardStdout(true) .removeArgumentWithValue("--main-class"); if (verbose) { cmd.addArgument("--verbose"); } - final var textVerifier = Stream.of( + cmd.validateOutput(Stream.of( List.of("error.no-main-class-with-main-jar", "hello.jar"), List.of("error.no-main-class-with-main-jar.advice", "hello.jar") ).map(args -> { return JPackageStringBundle.MAIN.cannedFormattedString(args.getFirst(), args.subList(1, args.size()).toArray()); - }).map(CannedFormattedString::getValue).map(TKit::assertTextStream).reduce(TKit.TextStreamVerifier::andThen).orElseThrow(); + }).toArray(CannedFormattedString[]::new)); - textVerifier.apply(cmd.saveConsoleOutput(true).execute(1).getOutput().stream().filter(Predicate.not(JPackageCommand::withTimestamp))); + cmd.execute(1); } @Test diff --git a/test/jdk/tools/jpackage/windows/Win8301247Test.java b/test/jdk/tools/jpackage/windows/Win8301247Test.java index b0c11147a17..2f98141dcb4 100644 --- a/test/jdk/tools/jpackage/windows/Win8301247Test.java +++ b/test/jdk/tools/jpackage/windows/Win8301247Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -21,14 +21,12 @@ * questions. */ -import java.io.IOException; +import static jdk.jpackage.test.WindowsHelper.killAppLauncherProcess; + import java.time.Duration; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.HelloApp; -import static jdk.jpackage.test.WindowsHelper.killAppLauncherProcess; +import jdk.jpackage.test.JPackageCommand; /** * Test that terminating of the parent app launcher process automatically @@ -48,7 +46,7 @@ public class Win8301247Test { @Test - public void test() throws IOException, InterruptedException { + public void test() throws InterruptedException { var cmd = JPackageCommand.helloAppImage().ignoreFakeRuntime(); // Launch the app in a way it doesn't exit to let us trap app laucnher @@ -56,22 +54,20 @@ public void test() throws IOException, InterruptedException { cmd.addArguments("--java-options", "-Djpackage.test.noexit=true"); cmd.executeAndAssertImageCreated(); - try ( // Launch the app in a separate thread - ExecutorService exec = Executors.newSingleThreadExecutor()) { - exec.execute(() -> { - HelloApp.executeLauncher(cmd); - }); + // Launch the app in a separate thread + new Thread(() -> { + HelloApp.executeLauncher(cmd); + }).start(); - // Wait a bit to let the app start - Thread.sleep(Duration.ofSeconds(10)); + // Wait a bit to let the app start + Thread.sleep(Duration.ofSeconds(10)); - // Find the main app launcher process and kill it - killAppLauncherProcess(cmd, null, 2); + // Find the main app launcher process and kill it + killAppLauncherProcess(cmd, null, 2); - // Wait a bit and check if child app launcher process is still running (it must NOT) - Thread.sleep(Duration.ofSeconds(5)); + // Wait a bit and check if child app launcher process is still running (it must NOT) + Thread.sleep(Duration.ofSeconds(5)); - killAppLauncherProcess(cmd, null, 0); - } + killAppLauncherProcess(cmd, null, 0); } } From bb08a70bd8deadc9c7522d1ce2ec779d5a6bd986 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Fri, 18 Apr 2025 17:01:42 +0000 Subject: [PATCH 006/901] 8355002: Clean up some mentions of "applet" in tests Reviewed-by: serb --- .../ChoiceLocationTest.java | 2 +- .../Dialog/CloseDialog/CloseDialogTest.java | 2 +- .../awt/Focus/ChoiceFocus/ChoiceFocus.java | 1 - .../FirstItemRemoveTest.java | 2 +- .../FocusEmptyListTest.java | 2 +- .../GetMousePositionWithOverlay.java | 2 +- .../GetMousePositionWithPopup.java | 4 +- .../PageSetupDlgBlockingTest.java | 1 - .../jdk/java/awt/TextArea/TextScrollTest.java | 2 +- .../DragUnicodeBetweenJVMTest.java | 1 - .../MissedHtmlAndRtfBug.java | 1 - .../DnDFileGroupDescriptor.java | 2 +- .../FileListBetweenJVMsTest.java | 1 - .../URIListBetweenJVMsTest.java | 1 - .../URIListToFileListBetweenJVMsTest.java | 1 - .../MenuDragMouseEventAbsoluteCoordsTest.java | 2 +- .../InfiniteRecursion_2.java | 12 +- .../InfiniteRecursion_3.java | 8 +- .../event/helpers/lwcomponents/LWButton.java | 12 +- .../EmbeddedFrameTest1.java | 4 +- test/jdk/java/awt/im/8041990/bug8041990.java | 2 +- .../java/awt/print/Dialog/DialogOrient.java | 3 - .../awt/print/PrinterJob/PrintDialog.java | 3 - .../print/PrinterJob/PrintDialogCancel.java | 3 - .../java/awt/print/PrinterJob/ThinLines.java | 3 - .../java/awt/regtesthelpers/AbstractTest.java | 2 - test/jdk/java/awt/regtesthelpers/Util.java | 2 - .../process/ProcessCommunicator.java | 2 +- .../sound/sampled/Clip/ClipFlushCrash.java | 2 +- .../sound/sampled/LinuxBlock/PlaySine.java | 2 +- .../javax/swing/JPopupMenu/bug4212464.java | 1 - .../swing/JTextArea/4697612/bug4697612.java | 2 +- .../swing/JTextArea/4697612/bug4697612.txt | 221 ------------------ .../parser/Parser/6990651/bug6990651.java | 2 +- .../SwingMark/src/AbstractSwingTest.java | 9 - .../client/SwingMark/src/JMTest_01.java | 8 - .../client/SwingMark/src/JMTest_02.java | 8 - .../client/SwingMark/src/JMTest_03.java | 8 - .../client/SwingMark/src/JMTest_04.java | 8 - .../client/SwingMark/src/JMTest_05.java | 8 - .../client/SwingMark/src/MenuTest.java | 8 - .../client/SwingMark/src/TypingTest.java | 4 - 42 files changed, 28 insertions(+), 346 deletions(-) delete mode 100644 test/jdk/javax/swing/JTextArea/4697612/bug4697612.txt diff --git a/test/jdk/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java b/test/jdk/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java index 78c83185cbe..5bff03d5b34 100644 --- a/test/jdk/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java +++ b/test/jdk/java/awt/Choice/ChoiceLocationTest/ChoiceLocationTest.java @@ -25,7 +25,7 @@ * @test * @key headful * @bug 7159566 - * @summary The choice positioned in the top of applet when clicking the choice. + * @summary The choice positioned in the top of window when clicking the choice. * @author Petr Pchelko * @library ../../regtesthelpers * @build Util diff --git a/test/jdk/java/awt/Dialog/CloseDialog/CloseDialogTest.java b/test/jdk/java/awt/Dialog/CloseDialog/CloseDialogTest.java index 4db2d52e4ea..93bf59d2757 100644 --- a/test/jdk/java/awt/Dialog/CloseDialog/CloseDialogTest.java +++ b/test/jdk/java/awt/Dialog/CloseDialog/CloseDialogTest.java @@ -32,7 +32,7 @@ * @test * @key headful * @bug 8043705 - * @summary Can't exit color chooser dialog when running as an applet + * @summary Can't exit color chooser dialog when running in non-default AppContext * @modules java.desktop/sun.awt * @run main CloseDialogTest */ diff --git a/test/jdk/java/awt/Focus/ChoiceFocus/ChoiceFocus.java b/test/jdk/java/awt/Focus/ChoiceFocus/ChoiceFocus.java index 904992f96b2..2456379f0f9 100644 --- a/test/jdk/java/awt/Focus/ChoiceFocus/ChoiceFocus.java +++ b/test/jdk/java/awt/Focus/ChoiceFocus/ChoiceFocus.java @@ -32,7 +32,6 @@ @run main ChoiceFocus */ -import java.applet.*; import java.awt.*; import java.awt.event.*; import test.java.awt.regtesthelpers.Util; diff --git a/test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java b/test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java index 1efcee3e675..69bd1dd6c83 100644 --- a/test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java +++ b/test/jdk/java/awt/List/FirstItemRemoveTest/FirstItemRemoveTest.java @@ -127,4 +127,4 @@ private void test(){ } -}// class AutomaticAppletTest +} diff --git a/test/jdk/java/awt/List/FocusEmptyListTest/FocusEmptyListTest.java b/test/jdk/java/awt/List/FocusEmptyListTest/FocusEmptyListTest.java index 67926b5fe19..1b1d4e4b5c4 100644 --- a/test/jdk/java/awt/List/FocusEmptyListTest/FocusEmptyListTest.java +++ b/test/jdk/java/awt/List/FocusEmptyListTest/FocusEmptyListTest.java @@ -99,4 +99,4 @@ public void start() { }// start() -}// class AutomaticAppletTest +} diff --git a/test/jdk/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithOverlay.java b/test/jdk/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithOverlay.java index b380af149f6..fb3ea40a531 100644 --- a/test/jdk/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithOverlay.java +++ b/test/jdk/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithOverlay.java @@ -31,7 +31,7 @@ * @test * @key headful * @bug 8012026 8196435 - * @summary Component.getMousePosition() does not work in an applet on MacOS + * @summary Component.getMousePosition() does not work in some cases on MacOS * @run main GetMousePositionWithOverlay */ diff --git a/test/jdk/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java b/test/jdk/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java index 5bfadc6fbe7..663942b7630 100644 --- a/test/jdk/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java +++ b/test/jdk/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java @@ -33,7 +33,7 @@ * @test * @key headful * @bug 8012026 8027154 - * @summary Component.getMousePosition() does not work in an applet on MacOS + * @summary Component.getMousePosition() does not work in some cases on MacOS * * @requires (os.family == "windows") * @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1 GetMousePositionWithPopup @@ -48,7 +48,7 @@ * @test * @key headful * @bug 8012026 8027154 - * @summary Component.getMousePosition() does not work in an applet on MacOS + * @summary Component.getMousePosition() does not work in some cases on MacOS * * @requires (os.family == "mac" | os.family == "linux") * @run main/othervm -Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=1 GetMousePositionWithPopup diff --git a/test/jdk/java/awt/PrintJob/PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java b/test/jdk/java/awt/PrintJob/PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java index 9fbf48f3eb4..bc392ab9efe 100644 --- a/test/jdk/java/awt/PrintJob/PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java +++ b/test/jdk/java/awt/PrintJob/PageSetupDlgBlockingTest/PageSetupDlgBlockingTest.java @@ -34,7 +34,6 @@ import java.awt.print.*; import java.awt.event.*; import javax.swing.*; -import java.applet.*; public class PageSetupDlgBlockingTest extends Panel { public static Frame frame = new TestFrame("Test Frame"); diff --git a/test/jdk/java/awt/TextArea/TextScrollTest.java b/test/jdk/java/awt/TextArea/TextScrollTest.java index 4a92391e7af..fbd5c022580 100644 --- a/test/jdk/java/awt/TextArea/TextScrollTest.java +++ b/test/jdk/java/awt/TextArea/TextScrollTest.java @@ -38,7 +38,7 @@ public class TextScrollTest extends Frame { private static final String INSTRUCTIONS = """ 1. A TextArea whose content starts with the text ", - 'Scroll till the' will appear on the applet ", + 'Scroll till the' will appear on the window ", 2. Use the Horizontal thumb button of the TextArea to view the entire", content of the TextArea", 3. While scrolling, if the text 'Scroll till the' appears repeatedly, Click Fail ", diff --git a/test/jdk/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.java b/test/jdk/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.java index 18159dce64f..aa785f54733 100644 --- a/test/jdk/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.java +++ b/test/jdk/java/awt/datatransfer/DragUnicodeBetweenJVMTest/DragUnicodeBetweenJVMTest.java @@ -101,7 +101,6 @@ private static void verifyTestResults(ProcessResults processResults) { processResults.printProcessStandartOutput(System.out); } - //We cannot make an instance of the applet without the default constructor public DragUnicodeBetweenJVMTest () { super(); } diff --git a/test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java b/test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java index 0254a3f0d41..3502cd4f9c5 100644 --- a/test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java +++ b/test/jdk/java/awt/datatransfer/MissedHtmlAndRtfBug/MissedHtmlAndRtfBug.java @@ -123,7 +123,6 @@ private static void verifyTestResults(ProcessResults processResults) { processResults.printProcessStandartOutput(System.out); } - //We cannot make an instance of the applet without the default constructor public MissedHtmlAndRtfBug() { super(); } diff --git a/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java b/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java index 51129f26408..b106deac73c 100644 --- a/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java +++ b/test/jdk/java/awt/dnd/DnDFileGroupDescriptor/DnDFileGroupDescriptor.java @@ -42,7 +42,7 @@ public class DnDFileGroupDescriptor { When the test starts, a RED panel appears. 1. Start MS Outlook program. Find and open the mail form with attachments. - 2. Select attachments from the mail and drag into a red field of applet. + 2. Select attachments from the mail and drag into a red field of the window. When the mouse enters the field during the process of drag, the application should change the cursor form to OLE-copy and field color to yellow. diff --git a/test/jdk/java/awt/dnd/FileListBetweenJVMsTest/FileListBetweenJVMsTest.java b/test/jdk/java/awt/dnd/FileListBetweenJVMsTest/FileListBetweenJVMsTest.java index 6fc7b9e049d..102ff501040 100644 --- a/test/jdk/java/awt/dnd/FileListBetweenJVMsTest/FileListBetweenJVMsTest.java +++ b/test/jdk/java/awt/dnd/FileListBetweenJVMsTest/FileListBetweenJVMsTest.java @@ -80,7 +80,6 @@ private static void verifyTestResults(ProcessResults processResults) { processResults.printProcessStandartOutput(System.out); } - //We cannot make an instance of the applet without the default constructor public FileListBetweenJVMsTest () { super(); } diff --git a/test/jdk/java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java b/test/jdk/java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java index e847752ee6a..6de649f846f 100644 --- a/test/jdk/java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java +++ b/test/jdk/java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java @@ -89,7 +89,6 @@ private static void verifyTestResults(ProcessResults processResults) { processResults.printProcessStandartOutput(System.out); } - //We cannot make an instance of the applet without the default constructor public URIListBetweenJVMsTest () { super(); } diff --git a/test/jdk/java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.java b/test/jdk/java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.java index f2e34493b8b..d9b6bd5e87c 100644 --- a/test/jdk/java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.java +++ b/test/jdk/java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.java @@ -77,7 +77,6 @@ private static void verifyTestResults(ProcessResults processResults) { processResults.printProcessStandartOutput(System.out); } - //We cannot make an instance of the applet without the default constructor public URIListToFileListBetweenJVMsTest() { super(); } diff --git a/test/jdk/java/awt/event/MouseEvent/MenuDragMouseEventAbsoluteCoordsTest/MenuDragMouseEventAbsoluteCoordsTest.java b/test/jdk/java/awt/event/MouseEvent/MenuDragMouseEventAbsoluteCoordsTest/MenuDragMouseEventAbsoluteCoordsTest.java index e0cfbaba1bb..41dc4709fc2 100644 --- a/test/jdk/java/awt/event/MouseEvent/MenuDragMouseEventAbsoluteCoordsTest/MenuDragMouseEventAbsoluteCoordsTest.java +++ b/test/jdk/java/awt/event/MouseEvent/MenuDragMouseEventAbsoluteCoordsTest/MenuDragMouseEventAbsoluteCoordsTest.java @@ -150,4 +150,4 @@ public void checkEventAbsolutePosition(MouseEvent evt, String message){ } System.out.println(message); } -}// class AutomaticAppletTest +} diff --git a/test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java b/test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java index 7db513eeac8..6022ed32094 100644 --- a/test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java +++ b/test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java @@ -27,21 +27,17 @@ @bug 6480024 @library ../../../regtesthelpers @build Util Sysout AbstractTest - @summary stack overflow on mouse wheel rotation within JApplet + @summary stack overflow on mouse wheel rotation within a Window @run main InfiniteRecursion_2 */ /** * InfiniteRecursion_2.java * - * summary: put a JButton into JPanel and then put JPanel into Applet. - * Add MouseWheelListener to Applet. + * summary: put a JButton into JPanel and then put JPanel into the Window. + * Add MouseWheelListener to the Window * Add MouseListener to JPanel. * Rotating a wheel over the JButton would result in stack overflow. - - * summary: put a JButton into JApplet. - * Add MouseWheelListener to JApplet. - * Rotating a wheel over the JButton would result in stack overflow. */ import java.awt.*; @@ -79,7 +75,7 @@ public void start () this.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { - System.out.println("Wheel moved on APPLET : "+e); + System.out.println("Wheel moved on Window : "+e); actualEvents++; } }); diff --git a/test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java b/test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java index 911e7c10864..e1f2991a2fb 100644 --- a/test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java +++ b/test/jdk/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java @@ -27,15 +27,15 @@ @bug 6480024 @library ../../../regtesthelpers @build Util Sysout AbstractTest - @summary stack overflow on mouse wheel rotation within JApplet + @summary stack overflow on mouse wheel rotation within a Window @run main InfiniteRecursion_3 */ /** * InfiniteRecursion_3.java * - * summary: put a JButton into Applet. - * Add MouseWheelListener to Applet. + * summary: put a JButton into the Window. + * Add MouseWheelListener to the Window. * Rotating a wheel over the JButton would result in stack overflow. */ @@ -72,7 +72,7 @@ public void start () this.addMouseWheelListener(new MouseWheelListener() { public void mouseWheelMoved(MouseWheelEvent e) { - System.out.println("Wheel moved on APPLET : "+e); + System.out.println("Wheel moved on Window : "+e); actualEvents++; } }); diff --git a/test/jdk/java/awt/event/helpers/lwcomponents/LWButton.java b/test/jdk/java/awt/event/helpers/lwcomponents/LWButton.java index 866844e1ce7..e45d3d5f430 100644 --- a/test/jdk/java/awt/event/helpers/lwcomponents/LWButton.java +++ b/test/jdk/java/awt/event/helpers/lwcomponents/LWButton.java @@ -116,16 +116,8 @@ public void run() { repaint(); } } - try { - unClicker uc = new unClicker(); - new Thread(uc).start(); - } catch (Exception e) { - // In case we're in an applet and the security has not been - // turned off (in which case we can't start a new thread) - // we can catch that and set the flag back to how it should be. - isInClick = false; - repaint(); - } + unClicker uc = new unClicker(); + new Thread(uc).start(); } /** diff --git a/test/jdk/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java b/test/jdk/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java index fd2acaad396..7942402af4f 100644 --- a/test/jdk/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java +++ b/test/jdk/java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java @@ -25,7 +25,7 @@ @test @key headful @bug 6359129 - @summary REGRESSION: Popup menus dont respond to selections when extend outside Applet + @summary REGRESSION: Popup menus dont respond to selections when extend outside EmbeddedFrame @author oleg.sukhodolsky area=awt.grab @modules java.desktop/java.awt.peer java.desktop/sun.awt @@ -38,7 +38,7 @@ /** * EmbeddedFrameTest1.java * - * summary: REGRESSION: Popup menus dont respond to selections when extend outside Applet + * summary: REGRESSION: Popup menus dont respond to selections when extend outside EmbeddedFrame */ import java.awt.BorderLayout; diff --git a/test/jdk/java/awt/im/8041990/bug8041990.java b/test/jdk/java/awt/im/8041990/bug8041990.java index 303fde5a459..d4bf847592d 100644 --- a/test/jdk/java/awt/im/8041990/bug8041990.java +++ b/test/jdk/java/awt/im/8041990/bug8041990.java @@ -26,7 +26,7 @@ * @test * @key headful * @bug 8041990 - * @summary Language specific keys does not work in applets when opened outside the browser + * @summary Language specific keys does not work in non-default AppContexts of top-level windows * @author Petr Pchelko * @modules java.desktop/sun.awt */ diff --git a/test/jdk/java/awt/print/Dialog/DialogOrient.java b/test/jdk/java/awt/print/Dialog/DialogOrient.java index 6650ced64f4..b89f3950e99 100644 --- a/test/jdk/java/awt/print/Dialog/DialogOrient.java +++ b/test/jdk/java/awt/print/Dialog/DialogOrient.java @@ -34,9 +34,6 @@ import java.awt.geom.*; import java.awt.print.*; -// This test is a "main" test as applets would need Runtime permission -// "queuePrintJob". - public class DialogOrient implements Printable { private static void init() throws Exception { diff --git a/test/jdk/java/awt/print/PrinterJob/PrintDialog.java b/test/jdk/java/awt/print/PrinterJob/PrintDialog.java index fa9569e1aa7..395312aaa45 100644 --- a/test/jdk/java/awt/print/PrinterJob/PrintDialog.java +++ b/test/jdk/java/awt/print/PrinterJob/PrintDialog.java @@ -42,9 +42,6 @@ import java.awt.event.*; import java.awt.print.*; -// This test is a "main" test as applets would need Runtime permission -// "queuePrintJob". - public class PrintDialog { diff --git a/test/jdk/java/awt/print/PrinterJob/PrintDialogCancel.java b/test/jdk/java/awt/print/PrinterJob/PrintDialogCancel.java index b2d3d3a2230..9a1884a5f54 100644 --- a/test/jdk/java/awt/print/PrinterJob/PrintDialogCancel.java +++ b/test/jdk/java/awt/print/PrinterJob/PrintDialogCancel.java @@ -43,9 +43,6 @@ import java.awt.event.*; import java.awt.print.*; -// This test is a "main" test as applets would need Runtime permission -// "queuePrintJob". - public class PrintDialogCancel { diff --git a/test/jdk/java/awt/print/PrinterJob/ThinLines.java b/test/jdk/java/awt/print/PrinterJob/ThinLines.java index f8e4e60b319..95cbfed8796 100644 --- a/test/jdk/java/awt/print/PrinterJob/ThinLines.java +++ b/test/jdk/java/awt/print/PrinterJob/ThinLines.java @@ -42,9 +42,6 @@ import java.awt.event.*; import java.awt.print.*; -// This test is a "main" test as applets would need Runtime permission -// "queuePrintJob". - public class ThinLines implements Printable { private static final int INCH = 72; diff --git a/test/jdk/java/awt/regtesthelpers/AbstractTest.java b/test/jdk/java/awt/regtesthelpers/AbstractTest.java index f5c34cc6fbd..fbf66e45e3b 100644 --- a/test/jdk/java/awt/regtesthelpers/AbstractTest.java +++ b/test/jdk/java/awt/regtesthelpers/AbstractTest.java @@ -30,8 +30,6 @@ @build AbstractTest @run main YourTest - * Note that if you are about to create a test based on - * Applet-template, then put those lines into html-file, not in java-file. *

And put an * import test.java.awt.regtesthelpers.AbstractTest; * into the java source. diff --git a/test/jdk/java/awt/regtesthelpers/Util.java b/test/jdk/java/awt/regtesthelpers/Util.java index 6d570e903b6..45d9c89ee46 100644 --- a/test/jdk/java/awt/regtesthelpers/Util.java +++ b/test/jdk/java/awt/regtesthelpers/Util.java @@ -31,8 +31,6 @@ @build Util @run main YourTest - * Note that if you are about to create a test based on - * Applet-template, then put those lines into html-file, not in java-file. *

And put an * import test.java.awt.regtesthelpers.Util; * into the java source of test. diff --git a/test/jdk/java/awt/regtesthelpers/process/ProcessCommunicator.java b/test/jdk/java/awt/regtesthelpers/process/ProcessCommunicator.java index d6806947af2..3b173009d23 100644 --- a/test/jdk/java/awt/regtesthelpers/process/ProcessCommunicator.java +++ b/test/jdk/java/awt/regtesthelpers/process/ProcessCommunicator.java @@ -31,7 +31,7 @@ * behavior such as DnD data transfer, Clipboard data transfer, focus * transfer etc., you could use the next scenario: * - * 1. Write an implementation for the parent JVM, using applet test. + * 1. Write an implementation for the parent JVM * 2. Write an implementation for the child JVM or native application, using * main() function. * 3. Execute child process using ProcessCommunicator.executeChildProcess() diff --git a/test/jdk/javax/sound/sampled/Clip/ClipFlushCrash.java b/test/jdk/javax/sound/sampled/Clip/ClipFlushCrash.java index a72509fdf53..2baeb499eac 100644 --- a/test/jdk/javax/sound/sampled/Clip/ClipFlushCrash.java +++ b/test/jdk/javax/sound/sampled/Clip/ClipFlushCrash.java @@ -35,7 +35,7 @@ * @test * @key sound * @bug 4946945 - * @summary Crash in javasound while running TicTacToe demo applet tiger b26 + * @summary Crash in javasound while running TicTacToe demo tiger b26 */ public class ClipFlushCrash { static int frameCount = 441000; // lets say 10 seconds diff --git a/test/jdk/javax/sound/sampled/LinuxBlock/PlaySine.java b/test/jdk/javax/sound/sampled/LinuxBlock/PlaySine.java index ab567dacb23..ceead0dae62 100644 --- a/test/jdk/javax/sound/sampled/LinuxBlock/PlaySine.java +++ b/test/jdk/javax/sound/sampled/LinuxBlock/PlaySine.java @@ -36,7 +36,7 @@ * @test * @key sound * @bug 4834461 - * @summary Applet hang when you load it during sound card is in use + * @summary App hang when you load it during sound card is in use * @run main/manual PlaySine */ public class PlaySine { diff --git a/test/jdk/javax/swing/JPopupMenu/bug4212464.java b/test/jdk/javax/swing/JPopupMenu/bug4212464.java index c1c434f6b16..cbfecc989cc 100644 --- a/test/jdk/javax/swing/JPopupMenu/bug4212464.java +++ b/test/jdk/javax/swing/JPopupMenu/bug4212464.java @@ -36,7 +36,6 @@ import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; diff --git a/test/jdk/javax/swing/JTextArea/4697612/bug4697612.java b/test/jdk/javax/swing/JTextArea/4697612/bug4697612.java index ed7f3dba73f..ee01c38ed67 100644 --- a/test/jdk/javax/swing/JTextArea/4697612/bug4697612.java +++ b/test/jdk/javax/swing/JTextArea/4697612/bug4697612.java @@ -224,7 +224,7 @@ private static void createAndShowGUI() { text = new JTextArea(); try { InputStream is = - bug4697612.class.getResourceAsStream("bug4697612.txt"); + bug4697612.class.getResourceAsStream("bug4697612.java"); text.read(new InputStreamReader(is), null); } catch (IOException e) { throw new Error(e); diff --git a/test/jdk/javax/swing/JTextArea/4697612/bug4697612.txt b/test/jdk/javax/swing/JTextArea/4697612/bug4697612.txt deleted file mode 100644 index f7273541285..00000000000 --- a/test/jdk/javax/swing/JTextArea/4697612/bug4697612.txt +++ /dev/null @@ -1,221 +0,0 @@ - README - - Java(TM) 2 SDK, Standard Edition - Version 1.4.2 Beta - - For a more extensive HTML version of this file, see README.html. - -Contents - - * Introduction - * Release Notes - * Bug Reports and Feedback - * Java 2 SDK Documentation - * Redistribution - * Web Pages - - -Introduction - - Thank you for downloading this release of the Java(TM) 2 SDK, - Standard Edition. The Java 2 SDK is a development environment for - building applications, applets, and components that can be - deployed on the Java platform. - - The Java 2 SDK software includes tools useful for developing and - testing programs written in the Java programming language and - running on the Java platform. These tools are designed to be used - from the command line. Except for appletviewer, these tools do not - provide a graphical user interface. - - -Release Notes - - See the Release Notes on the Java Software web site for additional - information pertaining to this release. - - http://java.sun.com/j2se/1.4.2/relnotes.html - - The on-line release notes will be updated as needed, so you should - check it occasionally for the latest information. - - -Bug Reports and Feedback - - The Bug Parade Web Page on the Java Developer Connection(SM) web - site lets you search for and examine existing bug reports, submit - your own bug reports, and tell us which bug fixes matter most to you. - - http://java.sun.com/jdc/bugParade/ - - To directly submit a bug or request a feature, fill out this form: - - http://java.sun.com/cgi-bin/bugreport.cgi - - You can also send comments directly to Java Software engineering - team email addresses. - - http://java.sun.com/mail/ - - -Java 2 SDK Documentation - - The on-line Java 2 SDK Documentation contains API specifications, - feature descriptions, developer guides, tool reference pages, demos, - and links to related information. It is located at - - http://java.sun.com/j2se/1.4.2/docs/ - - The Java 2 SDK documentation is also available in a download bundle - which you can install locally on your machine. See the - Java 2 SDK download page: - - http://java.sun.com/j2se/1.4.2/download.html - - -Redistribution - - The term "vendors" used here refers to licensees, developers, - and independent software vendors (ISVs) who license and - distribute the Java 2 Runtime Environment with their programs. - Vendors must follow the terms of the Java 2 SDK, Standard - Edition, Binary Code License agreement. - Required vs. Optional Files - - The files that make up the Java 2 SDK, Standard Edition, are - divided into two categories: required and optional. Optional - files may be excluded from redistributions of the Java 2 SDK - at the vendor's discretion. The following section contains a - list of the files and directories that may optionally be - omitted from redistributions of the Java 2 SDK. All files not - in these lists of optional files must be included in - redistributions of the Java 2 SDK. - - Optional Files and Directories - - The following files may be optionally excluded from - redistributions: - - jre/lib/charsets.jar - Character conversion classes - jre/lib/ext/ - sunjce_provider.jar - the SunJCE provider for Java - Cryptography APIs - localedata.jar - contains many of the resources - needed for non US English locales - ldapsec.jar - contains security features supported - by the LDAP service provider - dnsns.jar - for the InetAddress wrapper of JNDI DNS - provider - bin/rmid and jre/bin/rmid - Java RMI Activation System Daemon - bin/rmiregistry and jre/bin/rmiregistry - Java Remote Object Registry - bin/tnameserv and jre/bin/tnameserv - Java IDL Name Server - bin/keytool and jre/bin/keytool - Key and Certificate Management Tool - bin/kinit and jre/bin/kinit - Used to obtain and cache Kerberos ticket-granting tickets - bin/klist and jre/bin/klist - Kerberos display entries in credentials cache and keytab - bin/ktab and jre/bin/ktab - Kerberos key table manager - bin/policytool and jre/bin/policytool - Policy File Creation and Management Tool - bin/orbd and jre/bin/orbd - Object Request Broker Daemon - bin/servertool and jre/bin/servertool - Java IDL Server Tool - src.zip - Archive of source files - - In addition, the Java Web Start product may be excluded from - redistributions. The Java Web Start product is contained in a - file named javaws-1_2-solaris-sparc-i.zip, - javaws-1_2-solaris-i586-i.zip, - javaws-1_2-linux-i586-i.zip, or - javaws-1_2-windows-i586-i.exe, depending on the platform. - - - Unlimited Strength Java Cryptography Extension - - Due to import control restrictions for some countries, the - Java Cryptography Extension (JCE) policy files shipped with - the Java 2 SDK, Standard Edition and the Java 2 Runtime - Environment allow strong but limited cryptography to be - used. These files are located at - - /lib/security/local_policy.jar - /lib/security/US_export_policy.jar - - where is the jre directory of the Java 2 - SDK or the top-level directory of the Java 2 Runtime - Environment. - - An unlimited strength version of these files indicating - no restrictions on cryptographic strengths is available - on the Java 2 SDK web site for those living in eligible - countries. Those living in eligible countries may download - the unlimited strength version and replace the strong - cryptography jar files with the unlimited strength files. - - - Endorsed Standards Override Mechanism - - An endorsed standard is a Java API defined through a standards - process other than the Java Community Process(SM) (JCP(SM)). - Because endorsed standards are defined outside the JCP, it is - anticipated that such standards will be revised between - releases of the Java 2 Platform. In order to take advantage of - new revisions to endorsed standards, developers and software - vendors may use the Endorsed Standards Override Mechanism to - provide newer versions of an endorsed standard than those - included in the Java 2 Platform as released by Sun Microsystems. - - For more information on the Endorsed Standards Override - Mechanism, including the list of platform packages that it may - be used to override, see - - http://java.sun.com/j2se/1.4.2/docs/guide/standards/ - - Classes in the packages listed on that web page may be replaced - only by classes implementing a more recent version of the API - as defined by the appropriate standards body. - - In addition to the packages listed in the document at the above - URL, which are part of the Java 2 Platform, Standard Edition - (J2SE(TM)) specification, redistributors of Sun's J2SE - Reference Implementation are allowed to override classes whose - sole purpose is to implement the functionality provided by - public APIs defined in these Endorsed Standards packages. - Redistributors may also override classes in the org.w3c.dom.* - packages, or other classes whose sole purpose is to implement - these APIs. - - -Sun Java Web Pages - - For additional information, refer to these Sun Microsystems pages - on the World Wide Web: - - http://java.sun.com/ - The Java Software web site, with the latest information on - Java technology, product information, news, and features. - http://java.sun.com/docs - Java Platform Documentation provides access to white papers, - the Java Tutorial and other documents. - http://java.sun.com/jdc - The Java Developer Connection(SM) web site. (Free registration - required.) Additional technical information, news, and - features; user forums; support information, and much more. - http://java.sun.com/products/ - Java Technology Products & API - - ------------------------------------------------------------------------- -The Java 2 SDK, Standard Edition, is a product of Sun Microsystems(TM), -Inc. This product includes code licensed from RSA Security. - -Copyright 2003 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, -California 95054, U.S.A. All rights reserved. diff --git a/test/jdk/javax/swing/text/html/parser/Parser/6990651/bug6990651.java b/test/jdk/javax/swing/text/html/parser/Parser/6990651/bug6990651.java index b939f3e148f..9dada22ba60 100644 --- a/test/jdk/javax/swing/text/html/parser/Parser/6990651/bug6990651.java +++ b/test/jdk/javax/swing/text/html/parser/Parser/6990651/bug6990651.java @@ -23,7 +23,7 @@ /* @test @bug 6990651 - @summary Regression: NPE when refreshing applet since 6u22-b01 + @summary Regression: NPE when refreshing embedded window since 6u22-b01 @author Pavel Porvatov @modules java.desktop/sun.awt */ diff --git a/test/jdk/performance/client/SwingMark/src/AbstractSwingTest.java b/test/jdk/performance/client/SwingMark/src/AbstractSwingTest.java index 52394054f29..8a62d196857 100644 --- a/test/jdk/performance/client/SwingMark/src/AbstractSwingTest.java +++ b/test/jdk/performance/client/SwingMark/src/AbstractSwingTest.java @@ -86,15 +86,6 @@ public abstract class AbstractSwingTest { */ public abstract void runTest(); - /** - * This method is used to determine if a test can be run from within - * an applet. If your test will cause security exceptions when run as - * an applet then you should return false from this method. - */ - public boolean canRunInApplet() { - return true; - } - public int getPaintCount() { return paintCount; } diff --git a/test/jdk/performance/client/SwingMark/src/JMTest_01.java b/test/jdk/performance/client/SwingMark/src/JMTest_01.java index 83127e3bc21..fcc5fe309ba 100644 --- a/test/jdk/performance/client/SwingMark/src/JMTest_01.java +++ b/test/jdk/performance/client/SwingMark/src/JMTest_01.java @@ -66,14 +66,6 @@ public class JMTest_01 extends AbstractSwingTest { int DOWN = 40; int UP = 38; - /** - * This test cannot run as an applet because it - * posts events to the event queue - */ - public boolean canRunInApplet() { - return false; - } - public JComponent getTestComponent() { JPanel panel = new JPanel(); diff --git a/test/jdk/performance/client/SwingMark/src/JMTest_02.java b/test/jdk/performance/client/SwingMark/src/JMTest_02.java index b77844162ab..680ada9f1df 100644 --- a/test/jdk/performance/client/SwingMark/src/JMTest_02.java +++ b/test/jdk/performance/client/SwingMark/src/JMTest_02.java @@ -67,14 +67,6 @@ public class JMTest_02 extends AbstractSwingTest { int repeat = 15; - /** - * This test cannot run as an applet because it - * posts events to the event queue - */ - public boolean canRunInApplet() { - return false; - } - public JComponent getTestComponent() { JPanel panel = new JPanel(); diff --git a/test/jdk/performance/client/SwingMark/src/JMTest_03.java b/test/jdk/performance/client/SwingMark/src/JMTest_03.java index eed96da1e93..38f5dff43bc 100644 --- a/test/jdk/performance/client/SwingMark/src/JMTest_03.java +++ b/test/jdk/performance/client/SwingMark/src/JMTest_03.java @@ -65,14 +65,6 @@ public class JMTest_03 extends AbstractSwingTest { int DOWN = 40; int UP = 38; - /** - * This test cannot run as an applet because it - * posts events to the event queue - */ - public boolean canRunInApplet() { - return false; - } - public JComponent getTestComponent() { JPanel panel = new JPanel(); diff --git a/test/jdk/performance/client/SwingMark/src/JMTest_04.java b/test/jdk/performance/client/SwingMark/src/JMTest_04.java index 4c4c7f65d32..cbb32e5b916 100644 --- a/test/jdk/performance/client/SwingMark/src/JMTest_04.java +++ b/test/jdk/performance/client/SwingMark/src/JMTest_04.java @@ -70,14 +70,6 @@ public class JMTest_04 extends AbstractSwingTest { String MENU_ITEM_STRING = "JMenuItem"; String SUB_MENU_STRING = "SubMenu"; - /** - * This test cannot run as an applet because it - * posts events to the event queue - */ - public boolean canRunInApplet() { - return false; - } - public JComponent getTestComponent() { loadBundle(); JPanel panel = new JPanel(); diff --git a/test/jdk/performance/client/SwingMark/src/JMTest_05.java b/test/jdk/performance/client/SwingMark/src/JMTest_05.java index bd4eea45f9b..dc2a0bd1489 100644 --- a/test/jdk/performance/client/SwingMark/src/JMTest_05.java +++ b/test/jdk/performance/client/SwingMark/src/JMTest_05.java @@ -65,14 +65,6 @@ public class JMTest_05 extends AbstractSwingTest { int DOWN = 40; int UP = 38; - /** - * This test cannot run as an applet because it - * posts events to the event queue - */ - public boolean canRunInApplet() { - return false; - } - public JComponent getTestComponent() { JPanel panel = new JPanel(); diff --git a/test/jdk/performance/client/SwingMark/src/MenuTest.java b/test/jdk/performance/client/SwingMark/src/MenuTest.java index 9d9d8751d3e..91ce63e7667 100644 --- a/test/jdk/performance/client/SwingMark/src/MenuTest.java +++ b/test/jdk/performance/client/SwingMark/src/MenuTest.java @@ -69,14 +69,6 @@ public class MenuTest extends AbstractSwingTest { int repeat = 50; - /** - * This test cannot run as an applet because it - * posts events to the event queue - */ - public boolean canRunInApplet() { - return false; - } - public JComponent getTestComponent() { listener = new MyListener(); diff --git a/test/jdk/performance/client/SwingMark/src/TypingTest.java b/test/jdk/performance/client/SwingMark/src/TypingTest.java index 0019f7bd2c4..440b8b09e87 100644 --- a/test/jdk/performance/client/SwingMark/src/TypingTest.java +++ b/test/jdk/performance/client/SwingMark/src/TypingTest.java @@ -52,10 +52,6 @@ public JComponent getTestComponent() { return panel; } - public boolean canRunInApplet() { - return false; - } - public String getTestName() { return "Typing"; } From a551cc929426590bfbbcaa4bd8bee5e4e8cfe16d Mon Sep 17 00:00:00 2001 From: Damon Nguyen Date: Fri, 18 Apr 2025 17:07:16 +0000 Subject: [PATCH 007/901] 8353293: Open source several swing tests batch4 Reviewed-by: serb --- .../DrawEtchedRectTest.java | 77 ++++++++++++++++ .../basic/BasicHTML/4228104/bug4228104.java | 75 +++++++++++++++ .../plaf/basic/BasicHTML/4228104/duke.gif | Bin 0 -> 1929 bytes .../plaf/basic/BasicSliderUI/bug4220108.java | 75 +++++++++++++++ .../BasicSplitPaneUI/NegativeSizeTest.java | 87 ++++++++++++++++++ .../PreferredSizeLayoutTest.java | 71 ++++++++++++++ 6 files changed, 385 insertions(+) create mode 100644 test/jdk/javax/swing/plaf/basic/BasicGraphicsUtils/DrawEtchedRectTest.java create mode 100644 test/jdk/javax/swing/plaf/basic/BasicHTML/4228104/bug4228104.java create mode 100644 test/jdk/javax/swing/plaf/basic/BasicHTML/4228104/duke.gif create mode 100644 test/jdk/javax/swing/plaf/basic/BasicSliderUI/bug4220108.java create mode 100644 test/jdk/javax/swing/plaf/basic/BasicSplitPaneUI/NegativeSizeTest.java create mode 100644 test/jdk/javax/swing/plaf/basic/BasicSplitPaneUI/PreferredSizeLayoutTest.java diff --git a/test/jdk/javax/swing/plaf/basic/BasicGraphicsUtils/DrawEtchedRectTest.java b/test/jdk/javax/swing/plaf/basic/BasicGraphicsUtils/DrawEtchedRectTest.java new file mode 100644 index 00000000000..0c5c501596c --- /dev/null +++ b/test/jdk/javax/swing/plaf/basic/BasicGraphicsUtils/DrawEtchedRectTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4198822 + * @summary Tests that the bottom line drawn by + * BasicGraphicsUtils.drawEtchedRect extends to the end. + * @run main DrawEtchedRectTest + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; + +import javax.imageio.ImageIO; +import javax.swing.plaf.basic.BasicGraphicsUtils; + +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; + +public class DrawEtchedRectTest { + private static final int WIDTH = 200; + private static final int HEIGHT = 200; + private static final int RANGE = 10; + + public static void main(String[] args) throws Exception { + // Draw etched rectangle to a BufferedImage + BufferedImage image = new BufferedImage(WIDTH, HEIGHT, TYPE_INT_ARGB); + Graphics2D g2d = image.createGraphics(); + Component sq = new Component() { + public void paint(Graphics g) { + g.setColor(Color.WHITE); + g.fillRect(0, 0, WIDTH, HEIGHT); + BasicGraphicsUtils.drawEtchedRect(g, 0, 0, WIDTH, HEIGHT, + Color.black, Color.black, + Color.black, Color.black); + } + }; + sq.paint(g2d); + g2d.dispose(); + + // Check if connected at bottom-right corner + int c1; + int c2; + for (int i = 1; i < RANGE; i++) { + c1 = image.getRGB(WIDTH - i, HEIGHT - 1); + c2 = image.getRGB(WIDTH - 1, HEIGHT - i); + if (c1 == Color.WHITE.getRGB() || c2 == Color.WHITE.getRGB()) { + ImageIO.write(image, "png", new File("failImage.png")); + throw new RuntimeException("Bottom line is not connected!"); + } + } + } +} diff --git a/test/jdk/javax/swing/plaf/basic/BasicHTML/4228104/bug4228104.java b/test/jdk/javax/swing/plaf/basic/BasicHTML/4228104/bug4228104.java new file mode 100644 index 00000000000..451590c66ab --- /dev/null +++ b/test/jdk/javax/swing/plaf/basic/BasicHTML/4228104/bug4228104.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4228104 + * @summary Tests work of BODY BACKGROUND tag in HTML renderer + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4228104 + */ + +import java.awt.BorderLayout; + +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class bug4228104 { + static final String INSTRUCTIONS = """ + There should be an image displaying dukes under the rows of digits. + If you can see it, the test PASSES. Otherwise, the test FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4228104 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4228104::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("Background HTML Text Test"); + String dir = System.getProperty("test.src", + System.getProperty("user.dir")); + String htmlText1 = + "\n" + + "
111111111111111111" + + "
111111111111111111" + + "
111111111111111111" + + "
111111111111111111" + + "
111111111111111111" + + "
111111111111111111" + + "
111111111111111111" + + "
111111111111111111" + + "
111111111111111111"; + JLabel button1 = new JLabel(htmlText1); + f.add(button1, BorderLayout.NORTH); + f.setSize(200, 200); + return f; + } +} diff --git a/test/jdk/javax/swing/plaf/basic/BasicHTML/4228104/duke.gif b/test/jdk/javax/swing/plaf/basic/BasicHTML/4228104/duke.gif new file mode 100644 index 0000000000000000000000000000000000000000..ed32e0ff79b05c07b82863ce6fb07fa9898adaa2 GIT binary patch literal 1929 zcmWlYe^AtB8pi`HvM4_?{J2I$8$dLc1#@!R2zwgXMWdj^k;9xr+bDW&4{JlE8WpDj z7F-cwwK{H<)?L&#SJz$!;hJ{%BY2FYf)Wp^xl?aq!5Xcdi$c#hV~>m9_n-Hl=Xsy+ z=li^?*Q~;pZ+R1N1J40KRkeWM7ew3~jLM24A{CM-A}~TzqzYpq&od0GC=z71!w_=b z-==B0rt2t*nA}((5YSLs6a*Z@X__WqiSjTW6oLo{5km&|K1mGAimYjhs#wwZtvV8SV~7LCFpgub+-TTAk%UQb0dE_cj+pc?!+0o?qG$?% zVFD)%!w7Z;g)ndE8Uk6Aky=+kLaUQ{UW`XS?Nn*s@SQ{VmFgGdkV{&&98EcEQ5hjc@H$`e)fX zj@&GdchxpMUo|-A^M4iBP3(#Ib53Ap?5{nGT7SBA_V!o!TTzL5R~FUWe)4X?@iTd8 z1;TcF^rQLj?4p0uy?@ikb2eUSXdHVa_jIn=@W%a<6~57D>am6&Z!{lzc=@ZbuGB8` zpU38H8d~@82Da!+qdYG5ls&Cx?~|oPMnbqTHMw%I*KlV~?fc{rSwe29?Om}fsknG# z@n5IwY=4Mx>>0WJLG>=yJX^WbHA30iQ$H!X)3<4K zBe1|sf3NKKTS;)mg{$k(2eDJG^u5=&x{@M!V>EWgzRA((>}?o{WQBehp1mIHU!BGG zYz5_6B(+KIVdCVoum2ItM&gXZd+SB^vQTN=a zeYbbah=i-xCho2{4Pazv_i%2mH`EkM{r8XYDLbdY@(a7Ud}$%!$QrTN_DqwNXA9~g zTGKxKyfto7NDp;5A3O5zgb(hyxjN@OAG!(zy^*Ug4!yjF=Y*8aHA@ovB1({&a4;sR zTf1CVC{>Pgy`m$lG;P1$pC_6F7u%iP+qz0q4{lXT`i9g-ThiYgO^GXC`f?JNo*|@p zr{b%U-tSKw99q0|YJa9{Va?`H{IaNICo>p5lGEY*+IDR4bfIUwq~CTRuC_mGWA%~W zea{@eKJ(Iq^7MvdsPsR%&vt$@4i&s?bPptz#y#!FcRZEaMS0WFTyXMCUEfsNxnJ_9 zPwpt`Er4O>``2G{7=4r1GCSTO8#0xw+{<^L4X(K8y1wKj72KLrYD}Y7SJuY7y==wf z;UkI5?(v?h+4r;vR{P*U`ul~=D@U7K5$eV8c!%rX-38vE>azU80UrhFXCv#d`(ylZS4+i2a^vI91MTIxCx%9gd2&N&D9RC&xcpx8#f=GZv%9;F z#?CEVT%UV$nk;L%RJA+d=f8ZB@U*Xz-TZbG?HKKT(VJZMBH!)$#qRuwbFc%Aljqha zoNBs8od~V$_^vux0ZSk!iP!hI($t35SxY8`FV{pxCjpU}Ova2VIg1&>V)CvvMb_ cardLayout.show(mainPanel, "split")); + f.add(button, BorderLayout.SOUTH); + f.setSize(400, 300); + return f; + } +} diff --git a/test/jdk/javax/swing/plaf/basic/BasicSplitPaneUI/PreferredSizeLayoutTest.java b/test/jdk/javax/swing/plaf/basic/BasicSplitPaneUI/PreferredSizeLayoutTest.java new file mode 100644 index 00000000000..76d0e45b8eb --- /dev/null +++ b/test/jdk/javax/swing/plaf/basic/BasicSplitPaneUI/PreferredSizeLayoutTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4208549 + * @summary Makes sure preferred size returned by layout managers used by + * JSplitPane is correct. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PreferredSizeLayoutTest + */ + +import java.awt.Container; +import java.awt.FlowLayout; + +import javax.swing.JFrame; +import javax.swing.JSplitPane; + +public class PreferredSizeLayoutTest { + static final String INSTRUCTIONS = """ + If the buttons in the JSplitpanes do not have '...' in them, + click PASS, otherwise click FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("PreferredSizeLayoutTest Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(PreferredSizeLayoutTest::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("Preferred Size Layout Test"); + Container parent = f.getContentPane(); + JSplitPane sp = new JSplitPane(); + + parent.setLayout(new FlowLayout()); + + sp.setOrientation(JSplitPane.HORIZONTAL_SPLIT); + parent.add(sp); + sp = new JSplitPane(); + sp.setOrientation(JSplitPane.VERTICAL_SPLIT); + parent.add(sp); + f.setSize(400, 300); + return f; + } +} From 924638c471b0bf4a00a890ce6a3fd7e118cdd578 Mon Sep 17 00:00:00 2001 From: Damon Nguyen Date: Fri, 18 Apr 2025 17:08:46 +0000 Subject: [PATCH 008/901] 8353661: Open source several swing tests batch5 Reviewed-by: jdv --- test/jdk/javax/swing/JSlider/bug4186062.java | 99 +++++++++++++ test/jdk/javax/swing/JSlider/bug4275631.java | 132 ++++++++++++++++++ test/jdk/javax/swing/JSlider/bug4382876.java | 110 +++++++++++++++ .../javax/swing/plaf/windows/bug4991587.java | 95 +++++++++++++ 4 files changed, 436 insertions(+) create mode 100644 test/jdk/javax/swing/JSlider/bug4186062.java create mode 100644 test/jdk/javax/swing/JSlider/bug4275631.java create mode 100644 test/jdk/javax/swing/JSlider/bug4382876.java create mode 100644 test/jdk/javax/swing/plaf/windows/bug4991587.java diff --git a/test/jdk/javax/swing/JSlider/bug4186062.java b/test/jdk/javax/swing/JSlider/bug4186062.java new file mode 100644 index 00000000000..1db2f1bba6c --- /dev/null +++ b/test/jdk/javax/swing/JSlider/bug4186062.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4382876 + * @summary Tests if JSlider fires ChangeEvents when thumb is clicked and not moved + * @key headful + * @run main bug4186062 + */ + +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeListener; + +public class bug4186062 { + private static JFrame f; + private static JSlider slider; + private static volatile Point loc; + private static volatile int labelNum; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("JSlider Click Value Test"); + f.setSize(400, 200); + f.setLocationRelativeTo(null); + f.setVisible(true); + JPanel panel = new JPanel(); + slider = new JSlider(); + final JLabel label = new JLabel("0"); + labelNum = 0; + + ChangeListener listener = e -> { + labelNum++; + label.setText("" + labelNum); + }; + slider.addChangeListener(listener); + + panel.add(slider); + panel.add(label); + f.add(panel); + }); + + Robot r = new Robot(); + r.setAutoDelay(100); + r.waitForIdle(); + r.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + loc = slider.getLocationOnScreen(); + loc.setLocation(loc.x + (slider.getWidth() / 2), + loc.y + (slider.getHeight() / 2)); + }); + + r.mouseMove(loc.x, loc.y); + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + if (labelNum > 0) { + throw new RuntimeException(labelNum + " ChangeEvents fired. " + + "Test failed"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} diff --git a/test/jdk/javax/swing/JSlider/bug4275631.java b/test/jdk/javax/swing/JSlider/bug4275631.java new file mode 100644 index 00000000000..4d0aa555721 --- /dev/null +++ b/test/jdk/javax/swing/JSlider/bug4275631.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4275631 + * @summary Tests if vertical JSlider is properly aligned in large container + * @key headful + * @run main bug4275631 + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Point; +import java.awt.Robot; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.SwingUtilities; + +public class bug4275631 { + private static final int OFFSET = 1; + private static JFrame f; + private static JSlider slider1; + private static JSlider slider2; + private static volatile Point loc1; + private static volatile Point loc2; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("JSlider Alignment Test"); + f.setSize(400, 200); + f.setLocationRelativeTo(null); + + // Create two sliders, verify the alignment on the slider to be + // used in the border layout + slider1 = new JSlider(JSlider.VERTICAL, 0, 99, 50); + slider1.setInverted(true); + slider1.setMajorTickSpacing(10); + slider1.setMinorTickSpacing(1); + slider1.setPaintTicks(true); + slider1.setPaintLabels(true); + slider2 = new JSlider(JSlider.VERTICAL, 0, 99, 50); + slider2.setInverted(true); + slider2.setMajorTickSpacing(10); + slider2.setMinorTickSpacing(1); + slider2.setPaintTicks(true); + slider2.setPaintLabels(true); + + // Try to center the natural way, using a border layout in the "Center" + JPanel borderPanel = new JPanel(); + borderPanel.setLayout(new BorderLayout()); + borderPanel.setBorder(BorderFactory.createTitledBorder("BorderLayout")); + borderPanel.add(slider1, BorderLayout.CENTER); + borderPanel.setPreferredSize(new Dimension(200, 200)); + + // Try to center using GridBagLayout, with glue on left + // and right to squeeze slider into place + JPanel gridBagPanel = new JPanel(new GridBagLayout()); + gridBagPanel.setBorder(BorderFactory.createTitledBorder("GridBagLayout")); + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 1; + c.fill = GridBagConstraints.VERTICAL; + c.weighty = 1.0; + gridBagPanel.add(slider2, c); + c.gridx = 0; + c.fill = GridBagConstraints.BOTH; + c.weighty = 0.0; + gridBagPanel.add(Box.createHorizontalGlue(), c); + c.gridx = 2; + c.fill = GridBagConstraints.BOTH; + gridBagPanel.add(Box.createHorizontalGlue(), c); + gridBagPanel.setPreferredSize(new Dimension(200, 200)); + + f.add(borderPanel, BorderLayout.WEST); + f.add(gridBagPanel, BorderLayout.EAST); + f.setVisible(true); + }); + + Robot r = new Robot(); + r.setAutoDelay(100); + r.waitForIdle(); + r.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + loc1 = slider1.getLocationOnScreen(); + loc1.setLocation(loc1.x + (slider1.getWidth() / 2), + loc1.y + (slider1.getHeight() / 2)); + + loc2 = slider2.getLocationOnScreen(); + loc2.setLocation(loc2.x + (slider2.getWidth() / 2), + loc2.y + (slider2.getHeight() / 2)); + }); + + if (loc1.y > loc2.y + OFFSET || loc1.y < loc2.y - OFFSET) { + throw new RuntimeException("JSlider position is not aligned!"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} diff --git a/test/jdk/javax/swing/JSlider/bug4382876.java b/test/jdk/javax/swing/JSlider/bug4382876.java new file mode 100644 index 00000000000..b9ec64aab21 --- /dev/null +++ b/test/jdk/javax/swing/JSlider/bug4382876.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4382876 + * @summary Tests how PgUp and PgDn keys work with JSlider + * @key headful + * @run main bug4382876 + */ + +import java.awt.BorderLayout; +import java.awt.ComponentOrientation; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.swing.JFrame; +import javax.swing.JSlider; +import javax.swing.SwingUtilities; + +public class bug4382876 { + private static Robot r; + private static JFrame f; + private static JSlider slider; + private static boolean upFail; + private static boolean downFail; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("JSlider PageUp/Down Test"); + f.setSize(300, 200); + f.setLocationRelativeTo(null); + f.setVisible(true); + slider = new JSlider(-1000, -900, -1000); + slider.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + slider.putClientProperty("JSlider.isFilled", Boolean.TRUE); + f.add(slider, BorderLayout.CENTER); + }); + + r = new Robot(); + r.setAutoDelay(100); + r.waitForIdle(); + r.delay(1000); + + r.keyPress(KeyEvent.VK_PAGE_UP); + SwingUtilities.invokeAndWait(() -> { + if (slider.getValue() < -1000) { + System.out.println("PAGE_UP VAL: " + slider.getValue()); + upFail = true; + } + }); + if (upFail) { + writeFailImage(); + throw new RuntimeException("Slider value did NOT change with PAGE_UP"); + } + r.keyPress(KeyEvent.VK_PAGE_DOWN); + SwingUtilities.invokeAndWait(() -> { + if (slider.getValue() > -1000) { + System.out.println("PAGE_DOWN VAL: " + slider.getValue()); + downFail = true; + } + }); + if (downFail) { + writeFailImage(); + throw new RuntimeException("Slider value did NOT change with PAGE_DOWN"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + private static void writeFailImage() throws IOException { + GraphicsConfiguration ge = GraphicsEnvironment + .getLocalGraphicsEnvironment().getDefaultScreenDevice() + .getDefaultConfiguration(); + BufferedImage failImage = r.createScreenCapture(ge.getBounds()); + ImageIO.write(failImage, "png", new File("failImage.png")); + } +} diff --git a/test/jdk/javax/swing/plaf/windows/bug4991587.java b/test/jdk/javax/swing/plaf/windows/bug4991587.java new file mode 100644 index 00000000000..e4e4fde2b86 --- /dev/null +++ b/test/jdk/javax/swing/plaf/windows/bug4991587.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4991587 + * @requires (os.family == "windows") + * @summary Tests that disabled JButton text is positioned properly in Windows L&F + * @modules java.desktop/com.sun.java.swing.plaf.windows + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4991587 + */ + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Rectangle; + +import javax.swing.AbstractButton; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.UIManager; + +import com.sun.java.swing.plaf.windows.WindowsButtonUI; + +public class bug4991587 { + static final String INSTRUCTIONS = """ + There are two buttons: enabled (left) and disabled (right). + Ensure that the disabled button text is painted entirely + inside the blue bounding rectangle, just like the enabled + button (use it as an example of how this should look like). + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + PassFailJFrame.builder() + .title("bug4991587 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4991587::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("Disabled JButton Text Test"); + f.setLayout(new FlowLayout()); + f.setSize(400, 100); + + JButton button1 = new JButton("\u0114 Enabled JButton"); + button1.setUI(new MyButtonUI()); + f.add(button1); + + JButton button2 = new JButton("\u0114 Disabled JButton"); + button2.setEnabled(false); + button2.setUI(new MyButtonUI()); + f.add(button2); + + return f; + } + + static class MyButtonUI extends WindowsButtonUI { + protected void paintText(Graphics g, AbstractButton b, + Rectangle textRect, String text) { + g.setColor(Color.blue); + g.drawRect(textRect.x, + textRect.y, + textRect.width + 1, // add 1 for the shadow, otherwise it + // will be painted over the textRect + textRect.height); + super.paintText(g, b, textRect, text); + } + } +} From f8f1be3de56986c06f368334b7c64ef50f0117cf Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 18 Apr 2025 18:50:08 +0000 Subject: [PATCH 009/901] 8353552: Opensource Several Font related tests - Batch 3 8355048: ProblemList TestGlyphVectorLayout.java on all platforms Reviewed-by: serb, aivanov --- test/jdk/ProblemList.txt | 1 + .../jdk/java/awt/font/BoldItalicFontTest.java | 73 +++++++ .../GlyphVector/TestGlyphVectorLayout.java | 121 +++++++++++ .../GlyphVector/TestSetGlyphPositions.java | 96 +++++++++ .../jdk/java/awt/font/Rotate/RotateTest1.java | 97 +++++++++ .../java/awt/font/TestGraphicPlacement.java | 199 ++++++++++++++++++ 6 files changed, 587 insertions(+) create mode 100644 test/jdk/java/awt/font/BoldItalicFontTest.java create mode 100644 test/jdk/java/awt/font/GlyphVector/TestGlyphVectorLayout.java create mode 100644 test/jdk/java/awt/font/GlyphVector/TestSetGlyphPositions.java create mode 100644 test/jdk/java/awt/font/Rotate/RotateTest1.java create mode 100644 test/jdk/java/awt/font/TestGraphicPlacement.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 4a00130d3aa..b0a97929c6d 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -796,6 +796,7 @@ java/awt/Modal/InvisibleParentTest/InvisibleParentTest.java 8172245 linux-all java/awt/Frame/FrameStateTest/FrameStateTest.java 8203920 macosx-all,linux-all java/awt/print/PrinterJob/ScaledText/ScaledText.java 8231226 macosx-all java/awt/print/PrinterJob/PrintTextTest.java 8148334 macosx-all +java/awt/font/GlyphVector/TestGlyphVectorLayout.java 8354987 generic-all java/awt/font/TextLayout/TestJustification.java 8250791 macosx-all java/awt/TrayIcon/DragEventSource/DragEventSource.java 8252242 macosx-all java/awt/FileDialog/DefaultFocusOwner/DefaultFocusOwner.java 7187728 macosx-all,linux-all diff --git a/test/jdk/java/awt/font/BoldItalicFontTest.java b/test/jdk/java/awt/font/BoldItalicFontTest.java new file mode 100644 index 00000000000..7fdefcfe2b5 --- /dev/null +++ b/test/jdk/java/awt/font/BoldItalicFontTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; + +/* + * @test + * @bug 4935871 + * @summary Check that correct type faces are used regardless of bold/italic styles + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual/othervm -Duser.language=ja -Duser.country=JP BoldItalicFontTest + */ + +public class BoldItalicFontTest { + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + This test is reproduced with a non-English user locale only. + All the letters "X" in the first line should be in serif font. + All the letters "X" in the second line should be in sans-serif font. + + If so, press Pass, else press Fail."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(BoldItalicFontTest::createUI) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + String[] faces = { Font.SERIF, Font.SANS_SERIF }; + int[] styles = { 0, Font.BOLD, Font.ITALIC, Font.BOLD | Font.ITALIC }; + + Frame f = new Frame("BoldItalicFontTest Test UI"); + f.setLayout(new GridLayout(faces.length, styles.length)); + for (int fn = 0; fn < faces.length; fn++) { + for (int sn = 0; sn < styles.length; sn++) { + Label l = new Label("X"); + Font f1 = new Font(faces[fn], styles[sn], 36); + l.setFont(f1); + f.add(l); + } + } + f.setSize(300, 300); + return f; + } +} diff --git a/test/jdk/java/awt/font/GlyphVector/TestGlyphVectorLayout.java b/test/jdk/java/awt/font/GlyphVector/TestGlyphVectorLayout.java new file mode 100644 index 00000000000..b183b652642 --- /dev/null +++ b/test/jdk/java/awt/font/GlyphVector/TestGlyphVectorLayout.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.font.GlyphVector; +import java.awt.font.FontRenderContext; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; + +import javax.swing.JPanel; + +/* + * @test + * @bug 4615017 + * @summary Display two GlyphVectors, and ensure they are of the same length. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestGlyphVectorLayout + */ + +public class TestGlyphVectorLayout extends JPanel { + private final Font font; + private final FontRenderContext frc; + private final String text; + + private GlyphVector aftergv; + private Rectangle pbounds; + private Rectangle2D vbounds; + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + Two lines of text should appear, the top one with boxes + (red and blue) around it. + The two lines should be of the same length, and the boxes around the + top line should 'fit' the text with no empty space between the end + of the text and the box. + + Pass the test if this is true."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(TestGlyphVectorLayout::new) + .build() + .awaitAndCheck(); + } + + private TestGlyphVectorLayout() { + setBackground(Color.WHITE); + font = new Font(Font.DIALOG, Font.PLAIN, 24); + frc = new FontRenderContext(null, false, false); + text = "this is a test of glyph vector"; + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(550, 150); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + Graphics2D g2d = (Graphics2D) g; + + float x = 50; + float y = 50; + AffineTransform oldtx = g2d.getTransform(); + g2d.translate(x, y); + g2d.scale(1.5, 1.5); + + g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + RenderingHints.VALUE_FRACTIONALMETRICS_OFF); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); + + g2d.setColor(Color.BLACK); + + GlyphVector gv = font.createGlyphVector(frc, text); // new each time + g2d.drawGlyphVector(gv, 0, 0); + + if (vbounds == null) { + vbounds = gv.getVisualBounds(); + pbounds = gv.getPixelBounds(g2d.getFontRenderContext(), 0, 0); + aftergv = gv; + } + g2d.drawGlyphVector(aftergv, 0, 30); + + g2d.setColor(Color.BLUE); + g2d.draw(vbounds); + + g2d.setTransform(oldtx); + g2d.setColor(Color.RED); + g2d.draw(pbounds); + } +} diff --git a/test/jdk/java/awt/font/GlyphVector/TestSetGlyphPositions.java b/test/jdk/java/awt/font/GlyphVector/TestSetGlyphPositions.java new file mode 100644 index 00000000000..f56d8214395 --- /dev/null +++ b/test/jdk/java/awt/font/GlyphVector/TestSetGlyphPositions.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.font.GlyphVector; +import java.awt.font.FontRenderContext; +import java.awt.geom.Point2D; + +import javax.swing.JPanel; + +/* + * @test + * @bug 4180379 + * @summary set the positions of glyphs in the GlyphVector to other than + * their default x, y positions, and verify that the rendered glyphs are + * in the new positions, not the default positions. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestSetGlyphPositions + */ + +public class TestSetGlyphPositions extends JPanel { + GlyphVector gv = null; + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + 'TopLeft text and >' should appear towards the top left of the frame, + and '< and BottomRight text' should appear towards the bottom right. + + There should be some space between the '>' and '<' symbols, both vertically + and horizontally. + + Pass the test if this is true."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(TestSetGlyphPositions::new) + .build() + .awaitAndCheck(); + } + + public TestSetGlyphPositions() { + setBackground(Color.WHITE); + setSize(550, 150); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(550, 150); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + Graphics2D g2d = (Graphics2D) g; + + if (gv == null) { + Font font = new Font(Font.DIALOG, Font.PLAIN, 36); + FontRenderContext frc = g2d.getFontRenderContext(); + String str = "TopLeft> Date: Fri, 18 Apr 2025 19:38:09 +0000 Subject: [PATCH 010/901] 8355051: Problemlist java/awt/Graphics2D/CopyAreaOOB.java on macosx-aarch64 Reviewed-by: prr, aivanov --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index b0a97929c6d..075ce0e9c10 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -473,6 +473,7 @@ java/awt/MenuBar/TestNoScreenMenuBar.java 8265987 macosx-all java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java 8266283 generic-all java/awt/Graphics2D/DrawString/RotTransText.java 8316878 linux-all +java/awt/Graphics2D/CopyAreaOOB.java 8343106 macosx-aarch64 java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.java 8257529 windows-x64 java/awt/KeyboardFocusmanager/ConsumeNextMnemonicKeyTypedTest/ConsumeForModalDialogTest/ConsumeForModalDialogTest.java 8302787 windows-all java/awt/KeyboardFocusmanager/TypeAhead/MenuItemActivatedTest/MenuItemActivatedTest.java 8302787 windows-all From bf63f9ffa5e107ecb01e67dbef785a7bf4c89f16 Mon Sep 17 00:00:00 2001 From: Harshitha Onkar Date: Fri, 18 Apr 2025 20:58:21 +0000 Subject: [PATCH 011/901] 8353319: Open source Swing tests - Set 3 Reviewed-by: abhiscxk, dnguyen --- test/jdk/javax/swing/JFrame/bug4419914.java | 128 +++++++++++++++--- .../jdk/javax/swing/JRootPane/bug4614623.java | 84 ++++++++++++ .../javax/swing/JTabbedPane/bug4613811.java | 82 +++++++++++ test/jdk/javax/swing/JWindow/bug4251781.java | 76 +++++++++++ 4 files changed, 349 insertions(+), 21 deletions(-) create mode 100644 test/jdk/javax/swing/JRootPane/bug4614623.java create mode 100644 test/jdk/javax/swing/JTabbedPane/bug4613811.java create mode 100644 test/jdk/javax/swing/JWindow/bug4251781.java diff --git a/test/jdk/javax/swing/JFrame/bug4419914.java b/test/jdk/javax/swing/JFrame/bug4419914.java index 4574b1ac3d6..f87dcc8c468 100644 --- a/test/jdk/javax/swing/JFrame/bug4419914.java +++ b/test/jdk/javax/swing/JFrame/bug4419914.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -28,55 +28,141 @@ * @library /java/awt/regtesthelpers * @build PassFailJFrame * @run main/manual bug4419914 -*/ + */ import java.awt.BorderLayout; import java.awt.ComponentOrientation; +import java.awt.Frame; +import java.awt.Window; +import java.util.List; +import java.util.Locale; import javax.swing.JButton; +import javax.swing.JDialog; import javax.swing.JFrame; -import java.util.Locale; +import javax.swing.JLabel; +import javax.swing.JWindow; public class bug4419914 { + private static JFrame frame; private static final String INSTRUCTIONS = """ - 1. You will see a frame with five buttons. - 2. Confirm that each button is placed as follows: - NORTH - END CENTER START - SOUTH - 3. Press the "NORTH" button and confirm the button is focused. - 4. Press TAB repeatedly and confirm that the TAB focus moves from right to left. - (NORTH - START - CENTER - END - SOUTH - NORTH - START - CENTER - ...) + This test verifies tab movement on RTL component orientation + in JWindow, JFrame and JDialog. + + When test starts 3 test windows are displayed - JFrame, JWindow and JDialog. + Follow the instructions below and if any condition does not hold + press FAIL. + + 1. Confirm that each button in the child window is placed as follows: + + For JFrame: + NORTH + END CENTER START + SOUTH + + For JWindow: + END CENTER START + QUIT + + For JDialog: + END CENTER START + + 3. Press on the "START" button in case of JWindow & JDialog and "NORTH" + in case of JFrame, confirm that the respective button is focused. + + 4. Press TAB repeatedly and confirm that the TAB focus moves + from right to left. + + For JFrame: + (NORTH - START - CENTER - END - SOUTH - NORTH - START - CENTER - ...) - If there's anything different from the above items, click Fail else click Pass."""; + For JWindow: + (START - CENTER - END - QUIT - START - CENTER - END - QUIT - ...) + + For JDialog: + (START - CENTER - END - START - CENTER - END - ...) + + If all of the above conditions are true press PASS else FAIL. + """; public static void main(String[] args) throws Exception { PassFailJFrame.builder() - .title("Tab movement Instructions") .instructions(INSTRUCTIONS) - .rows((int) INSTRUCTIONS.lines().count() + 2) - .columns(48) - .testUI(bug4419914::createTestUI) + .columns(45) + .testTimeOut(10) + .testUI(bug4419914::createAndShowUI) + .positionTestUI(WindowLayouts::rightOneColumn) .build() .awaitAndCheck(); } - private static JFrame createTestUI() { - JFrame frame = new JFrame("bug4419914"); + private static List createAndShowUI() { + return List.of(createJFrame(), createJWindow(), createJDialog()); + } + + private static JFrame createJFrame() { + frame = new JFrame("bug4419914 JFrame"); frame.setFocusCycleRoot(true); + // Tab movement set to RTL frame.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); frame.setLocale(Locale.ENGLISH); frame.enableInputMethods(false); + // Component placement within content pane set to RTL frame.getContentPane().setComponentOrientation( - ComponentOrientation.RIGHT_TO_LEFT); + ComponentOrientation.RIGHT_TO_LEFT); frame.getContentPane().setLocale(Locale.ENGLISH); - frame.getContentPane().setLayout(new BorderLayout()); + frame.setLayout(new BorderLayout()); frame.add(new JButton("SOUTH"), BorderLayout.SOUTH); frame.add(new JButton("CENTER"), BorderLayout.CENTER); frame.add(new JButton("END"), BorderLayout.LINE_END); frame.add(new JButton("START"), BorderLayout.LINE_START); frame.add(new JButton("NORTH"), BorderLayout.NORTH); - frame.setSize(300, 150); + frame.setSize(300, 160); return frame; } + + private static JWindow createJWindow() { + JWindow window = new JWindow(frame); + window.setFocusableWindowState(true); + // Tab movement set to RTL + window.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + window.setLocale(new Locale("en")); + window.enableInputMethods(false); + + // Component placement within content pane set to RTL + window.getContentPane().setComponentOrientation( + ComponentOrientation.RIGHT_TO_LEFT); + window.getContentPane().setLocale(new Locale("en")); + window.setLayout(new BorderLayout()); + window.add(new JLabel("bug4419914 JWindow"), BorderLayout.NORTH); + window.add(new JButton("START"), BorderLayout.LINE_START); + window.add(new JButton("CENTER"), BorderLayout.CENTER); + window.add(new JButton("END"), BorderLayout.LINE_END); + + JButton quitButton = new JButton("QUIT"); + quitButton.addActionListener(e1 -> window.dispose()); + window.add(quitButton, BorderLayout.SOUTH); + window.setSize(300, 153); + window.requestFocus(); + return window; + } + + private static JDialog createJDialog() { + JDialog dialog = new JDialog((Frame) null, "bug4419914 JDialog"); + // Tab movement set to RTL + dialog.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + dialog.setLocale(new Locale("en")); + dialog.enableInputMethods(false); + + // Component placement within content pane set to RTL + dialog.getContentPane().setComponentOrientation( + ComponentOrientation.RIGHT_TO_LEFT); + dialog.getContentPane().setLocale(new Locale("en")); + dialog.setLayout(new BorderLayout()); + dialog.add(new JButton("CENTER"), BorderLayout.CENTER); + dialog.add(new JButton("END"), BorderLayout.LINE_END); + dialog.add(new JButton("START"), BorderLayout.LINE_START); + dialog.setSize(300, 160); + return dialog; + } } diff --git a/test/jdk/javax/swing/JRootPane/bug4614623.java b/test/jdk/javax/swing/JRootPane/bug4614623.java new file mode 100644 index 00000000000..9a714d3cdfd --- /dev/null +++ b/test/jdk/javax/swing/JRootPane/bug4614623.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4614623 + * @requires (os.family == "windows") + * @summary Tests that w2k mnemonic underlining works when there's no + focus owner + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4614623 + */ + +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.UIManager; + +public class bug4614623 { + private static final String INSTRUCTIONS = """ + This test verifies if the short-cut character + (menu mnemonic) is underlined when the ALT key is held down. + + Check if the following is true. + 1) Press Alt key. The letter 'F' (menu mnemonic) of + the "File" menu should now be underlined. + 2) Release the Alt key, the selection background (light grey) + should appear around the "File" menu. Compare "About" menu + with "File" menu to see the light grey selection background. + + If the above is true, press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(62) + .rows(12) + .testUI(bug4614623::createAndShowUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4614623 - File menu test"); + JMenuBar menuBar = new JMenuBar(); + + JMenu fileMenu = new JMenu("File"); + fileMenu.setMnemonic('F'); + menuBar.add(fileMenu); + + JMenu about = new JMenu("About"); + menuBar.add(about); + menuBar.setSize(300, 100); + + frame.setJMenuBar(menuBar); + menuBar.requestFocus(); + frame.setSize(300, 200); + return frame; + } +} diff --git a/test/jdk/javax/swing/JTabbedPane/bug4613811.java b/test/jdk/javax/swing/JTabbedPane/bug4613811.java new file mode 100644 index 00000000000..ecad64e95f8 --- /dev/null +++ b/test/jdk/javax/swing/JTabbedPane/bug4613811.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2003, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4613811 + * @summary Scrollable Buttons of JTabbedPane don't + * get enabled or disabled on selecting tab + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4613811 + */ + +import java.awt.BorderLayout; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTabbedPane; + +public class bug4613811 { + private static final String INSTRUCTIONS = """ + Select different tabs and check that the scrollable + buttons are correctly enabled and disabled. + + When the very first tab (Tab 1) is fully visible + On macOS: + the left arrow button should NOT be visible. + + On other platforms: + the left arrow button should be disabled. + + If the last tab (Tab 5) is fully visible + On macOS: + the right arrow button should NOT be visible. + + On other platforms: + the right arrow button should be disabled. + + If the above is true press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(30) + .testUI(bug4613811::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4613811 - JTabbedPane Test"); + final JTabbedPane tabPane = new JTabbedPane(JTabbedPane.TOP, + JTabbedPane.SCROLL_TAB_LAYOUT); + for (int i = 1; i <= 5; i++) { + tabPane.addTab("TabbedPane: Tab " + i, null, new JLabel("Tab " + i)); + } + frame.add(tabPane, BorderLayout.CENTER); + frame.setResizable(false); + frame.setSize(400, 200); + return frame; + } +} diff --git a/test/jdk/javax/swing/JWindow/bug4251781.java b/test/jdk/javax/swing/JWindow/bug4251781.java new file mode 100644 index 00000000000..0152db71f24 --- /dev/null +++ b/test/jdk/javax/swing/JWindow/bug4251781.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4251781 + * @summary Tests that JWindow repaint is optimized (background is not + cleared). + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4251781 + */ + +import java.awt.Color; +import java.awt.Container; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.JWindow; + +public class bug4251781 { + private static final String INSTRUCTIONS = """ + Press the button at the bottom-right corner of the gray + window with the mouse. + If the window DOES NOT flicker when you press and/or release + the mouse button press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4251781::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JWindow createAndShowUI() { + JWindow w = new JWindow(); + final Container pane = w.getContentPane(); + pane.setLayout(null); + pane.setBackground(Color.GRAY.darker()); + + final JPopupMenu popup = new JPopupMenu(); + popup.add(new JMenuItem("item 1")); + popup.add(new JMenuItem("exit")); + + JButton b = new JButton("menu"); + b.setBounds(350, 250, 50, 50); + b.addActionListener(ev -> popup.show(pane, 0, 0)); + pane.add(b); + + w.setSize(400, 300); + return w; + } +} From 38f9b3a9738de7896d840fc114a76ced3b77c269 Mon Sep 17 00:00:00 2001 From: Damon Nguyen Date: Fri, 18 Apr 2025 21:11:41 +0000 Subject: [PATCH 012/901] 8353748: Open source several swing tests batch6 Reviewed-by: kizune --- .../javax/swing/JTree/NodeChangedTest.java | 72 +++++++++++ test/jdk/javax/swing/JTree/bug4118860.java | 97 ++++++++++++++ test/jdk/javax/swing/JTree/bug4169215.java | 65 ++++++++++ test/jdk/javax/swing/JTree/bug4196987.java | 70 ++++++++++ test/jdk/javax/swing/JTree/bug4270654.java | 76 +++++++++++ test/jdk/javax/swing/JTree/bug4618767.java | 121 ++++++++++++++++++ 6 files changed, 501 insertions(+) create mode 100644 test/jdk/javax/swing/JTree/NodeChangedTest.java create mode 100644 test/jdk/javax/swing/JTree/bug4118860.java create mode 100644 test/jdk/javax/swing/JTree/bug4169215.java create mode 100644 test/jdk/javax/swing/JTree/bug4196987.java create mode 100644 test/jdk/javax/swing/JTree/bug4270654.java create mode 100644 test/jdk/javax/swing/JTree/bug4618767.java diff --git a/test/jdk/javax/swing/JTree/NodeChangedTest.java b/test/jdk/javax/swing/JTree/NodeChangedTest.java new file mode 100644 index 00000000000..5461136c57b --- /dev/null +++ b/test/jdk/javax/swing/JTree/NodeChangedTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4199472 + * @summary Tests that node changed for the root of the tree update the + * structure. + * @run main NodeChangedTest + */ + +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; + +public class NodeChangedTest { + public static void main(String[] args) { + // Create 3 nodes + final DefaultMutableTreeNode root = new DefaultMutableTreeNode("root", + true); + final DefaultMutableTreeNode child = new DefaultMutableTreeNode("child", + true); + final DefaultMutableTreeNode leaf = new DefaultMutableTreeNode("leaf", + false); + root.add(child); + child.add(leaf); + + final JTree tree = new JTree(root); + + // Change the root node + root.setUserObject("New root"); + ((DefaultTreeModel) tree.getModel()).nodeChanged(root); + + // Check + if (!root.getUserObject().toString().equals("New root")) { + throw new RuntimeException("Failed changing root node for default model."); + } + + // Change to large model + tree.setLargeModel(true); + tree.setRowHeight(20); + root.setUserObject("root"); + tree.setModel(new DefaultTreeModel(root)); + root.setUserObject("New root"); + ((DefaultTreeModel) tree.getModel()).nodeChanged(root); + + // Check again + if (!root.getUserObject().toString().equals("New root")) { + throw new RuntimeException("Failed changing root node for large model."); + } + } +} diff --git a/test/jdk/javax/swing/JTree/bug4118860.java b/test/jdk/javax/swing/JTree/bug4118860.java new file mode 100644 index 00000000000..eb266eb9324 --- /dev/null +++ b/test/jdk/javax/swing/JTree/bug4118860.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4118860 + * @summary setToggleClickCount/getToggleClickCount have been added. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4118860 + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTree; + +public class bug4118860 { + static final String INSTRUCTIONS = """ + Push the "Single Click" button and try expanding/contracting + branch nodes of the tree with one left mouse button click + on the label part of the node (not the icon or handles). + + Then push the "Double Click" button and try doing the same using + left mouse button double click. Single click shouldn't cause + expanding/contracting. A double click should now be required + to expand/contract nodes. + + If it works then the test PASSES, else the test FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4118860 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4118860::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("ToggleClickCount Test"); + JTree tr = new JTree(); + JPanel p = new JPanel(); + p.setBackground(Color.red); + p.setLayout(new GridLayout(1, 1)); + tr.setOpaque(false); + p.add(tr); + f.add(p, BorderLayout.CENTER); + JPanel bp = new JPanel(); + JButton bt1 = new JButton("Single Click"); + bt1.addActionListener(e -> { + tr.setToggleClickCount(1); + if (tr.getToggleClickCount() != 1) { + throw new RuntimeException("ToggleClickCount doesn't set..."); + } + }); + JButton bt2 = new JButton("Double Click"); + bt2.addActionListener(e -> { + tr.setToggleClickCount(2); + if (tr.getToggleClickCount() != 2) { + throw new RuntimeException("ToggleClickCount doesn't set..."); + } + }); + bp.setLayout(new GridLayout(1, 2)); + bp.add(bt1); + bp.add(bt2); + f.add(bp, BorderLayout.SOUTH); + f.setSize(300, 200); + return f; + } +} diff --git a/test/jdk/javax/swing/JTree/bug4169215.java b/test/jdk/javax/swing/JTree/bug4169215.java new file mode 100644 index 00000000000..0b8780b3939 --- /dev/null +++ b/test/jdk/javax/swing/JTree/bug4169215.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4169215 + * @summary Accessibility hierarchy JTree node test. + * @run main bug4169215 + */ + +import javax.accessibility.AccessibleContext; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; + +public class bug4169215 { + public static void main(String[] args) { + // create the tree + DefaultMutableTreeNode root = new DefaultMutableTreeNode("top"); + DefaultMutableTreeNode nodeA = new DefaultMutableTreeNode("A"); + DefaultMutableTreeNode nodeB = new DefaultMutableTreeNode("B"); + root.add(nodeA); + root.add(nodeB); + JTree tree = new JTree(root); + + // find the AccessibleContext of the tree + AccessibleContext actree = tree.getAccessibleContext(); + + // find the AccessibleContext of top node of the tree + AccessibleContext act = actree.getAccessibleChild(0).getAccessibleContext(); + + // find the AccessibleContext of the first child of the table -> + // the AccessibleContext of nodeA + AccessibleContext accA = act.getAccessibleChild(0).getAccessibleContext(); + + // find the AccessibleContext of the next sibling of nodeA, by getting + // child+1 of the parent (the table) + AccessibleContext accB = act.getAccessibleChild( + accA.getAccessibleIndexInParent()+1).getAccessibleContext(); + + // look to see who the sibling is. + if (accB.getAccessibleName().compareTo("B") != 0) { + throw new RuntimeException("Parent node is a sibling instead!"); + } + } +} diff --git a/test/jdk/javax/swing/JTree/bug4196987.java b/test/jdk/javax/swing/JTree/bug4196987.java new file mode 100644 index 00000000000..1387b669b05 --- /dev/null +++ b/test/jdk/javax/swing/JTree/bug4196987.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4196987 + * @summary Test Metal L&F JTree expander icons transparency. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4196987 + */ + +import java.awt.Color; +import java.awt.GridLayout; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.UIManager; + +public class bug4196987 { + static final String INSTRUCTIONS = """ + If the background of tree icons are red, the test PASSES. + Otherwise the test FAILS. + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + PassFailJFrame.builder() + .title("bug4196987 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4196987::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("JTree Icon Transparency Test"); + JPanel p = new JPanel(); + p.setBackground(Color.red); + p.setLayout(new GridLayout(1, 1)); + JTree t = new JTree(); + t.setOpaque(false); + p.add(t); + f.add(p); + f.setSize(200, 200); + return f; + } +} diff --git a/test/jdk/javax/swing/JTree/bug4270654.java b/test/jdk/javax/swing/JTree/bug4270654.java new file mode 100644 index 00000000000..413626d7881 --- /dev/null +++ b/test/jdk/javax/swing/JTree/bug4270654.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4270654 + * @summary Tests that selection change in JTree does not cause unnecessary + scrolling. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4270654 + */ + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; + +public class bug4270654 { + static final String INSTRUCTIONS = """ + Select the "dan" node and scroll to the right a little using the + scrollbar. Then press down arrow key. If the tree unscrolls back + to the left, the test FAILS. Otherwise, the test PASSES. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4270654 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4270654::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("JTree Scroll Back Test"); + DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); + String[] lev1 = {"foo", "bar", "dan"}; + String[][] lev2 = { + {}, + {"small", "a nice big node for testing"}, + {"xyz", "pqd", "a really really big node for testing"}}; + for (int i = 0; i < lev1.length; i++) { + DefaultMutableTreeNode child = new DefaultMutableTreeNode(lev1[i]); + root.add(child); + for (int j = 0; j < lev2[i].length; j++) + child.add(new DefaultMutableTreeNode(lev2[i][j])); + } + final JTree tree = new JTree(root); + tree.expandRow(3); + f.add(new JScrollPane(tree)); + f.setSize(200, 200); + return f; + } +} diff --git a/test/jdk/javax/swing/JTree/bug4618767.java b/test/jdk/javax/swing/JTree/bug4618767.java new file mode 100644 index 00000000000..d8aa52c3952 --- /dev/null +++ b/test/jdk/javax/swing/JTree/bug4618767.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4618767 + * @summary First letter navigation in JTree interferes with mnemonics + * @key headful + * @run main bug4618767 + */ + +import java.awt.Robot; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JTree; +import javax.swing.SwingUtilities; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; + +public class bug4618767 { + private static JFrame f; + private static final JTree tree = new + JTree(new String[] {"one", "two", "three", "four"}); + private static boolean menuSelected; + private static CountDownLatch listGainedFocusLatch = new CountDownLatch(1); + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("bug4618767 Test"); + JMenu menu = new JMenu("File"); + menu.setMnemonic('F'); + JMenuItem menuItem = new JMenuItem("item"); + menu.add(menuItem); + JMenuBar menuBar = new JMenuBar(); + menuBar.add(menu); + f.setJMenuBar(menuBar); + + menu.addMenuListener(new MenuListener() { + public void menuCanceled(MenuEvent e) {} + public void menuDeselected(MenuEvent e) {} + public void menuSelected(MenuEvent e) { + menuSelected = true; + } + }); + + tree.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + listGainedFocusLatch.countDown(); + } + }); + f.add(tree); + f.pack(); + f.setLocationRelativeTo(null); + f.setAlwaysOnTop(true); + f.setVisible(true); + }); + runTest(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + private static void runTest() throws Exception { + if (!listGainedFocusLatch.await(3, TimeUnit.SECONDS)) { + throw new RuntimeException("Waited too long, but can't gain" + + " focus for list"); + } + Robot robot = new Robot(); + robot.setAutoDelay(200); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_O); + robot.keyRelease(KeyEvent.VK_O); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_F); + robot.keyRelease(KeyEvent.VK_F); + robot.keyRelease(KeyEvent.VK_ALT); + + SwingUtilities.invokeAndWait(() -> { + if (menuSelected && !tree.getSelectionPath() + .getLastPathComponent().toString().equals("one")) { + throw new RuntimeException("Mnemonics interferes with JTree" + + " item selection using KeyEvent"); + } + }); + } +} From 76dec47f00230214e9ba58714be5a3ad26f8308d Mon Sep 17 00:00:00 2001 From: Harshitha Onkar Date: Fri, 18 Apr 2025 21:35:17 +0000 Subject: [PATCH 013/901] 8354340: Open source Swing Tests - Set 6 Reviewed-by: azvegint, achung --- .../JViewport/ScrollRectToVisibleTest3.java | 165 ++++++++++++++++++ .../javax/swing/JViewport/SetViewRepaint.java | 114 ++++++++++++ 2 files changed, 279 insertions(+) create mode 100644 test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java create mode 100644 test/jdk/javax/swing/JViewport/SetViewRepaint.java diff --git a/test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java b/test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java new file mode 100644 index 00000000000..bf96ab2fc46 --- /dev/null +++ b/test/jdk/javax/swing/JViewport/ScrollRectToVisibleTest3.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key headful + * @bug 4217252 + * @summary Verify that scrolling beyond the visible region and scrolling + * a component smaller than the viewport is not allowed. + * @library /javax/swing/regtesthelpers + * @build Util + * @run main/othervm -Dsun.java2d.uiScale=1 ScrollRectToVisibleTest3 + */ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.AbstractTableModel; + +public class ScrollRectToVisibleTest3 { + private static JFrame frame; + private static JTable table; + private static JButton scrollButton; + private static volatile int clickCount = 0; + private static final String[] EXPECTED_TEXT = {"99 x 0", "98 x 0", + "97 x 0", "96 x 0"}; + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + SwingUtilities.invokeAndWait(ScrollRectToVisibleTest3::createTestUI); + robot.waitForIdle(); + robot.delay(1000); + + Rectangle frameBounds = Util.invokeOnEDT(() -> getComponentBounds(frame)); + robot.delay(100); + Point scrollBtnLoc = Util.getCenterPoint(scrollButton); + + robot.mouseMove(scrollBtnLoc.x, scrollBtnLoc.y); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(50); + + int rowHeight = Util.invokeOnEDT(() -> table.getRowHeight()); + for (int i = 1; i <= 4; i++) { + robot.mouseMove(frameBounds.x + 50, + frameBounds.y + frameBounds.height - (rowHeight * i + 2)); + robot.delay(300); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + // 500 ms delay added so that current mouseClicked event + // is processed successfully before proceeding to the next + robot.delay(500); + } + if (clickCount != 4) { + throw new RuntimeException("Test Failed! Expected 4 mouse clicks" + + " but got " + clickCount); + } + } + + private static void createTestUI() { + frame = new JFrame("ScrollRectToVisibleTest3"); + table = new JTable(new TestModel()); + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + JTable testTable = (JTable) e.getComponent(); + int row = testTable.getSelectedRow(); + int column = testTable.getSelectedColumn(); + String cellContent = testTable.getValueAt(row, column).toString(); + if (!EXPECTED_TEXT[clickCount].equals(cellContent)) { + throw new RuntimeException(("Test failed! Table Cell Content" + + " at (row %d , col %d)\n Expected: %s vs Actual: %s") + .formatted(row, column, + EXPECTED_TEXT[clickCount], cellContent)); + } + clickCount++; + } + }); + + scrollButton = new JButton("Scroll"); + scrollButton.addActionListener(ae -> { + Rectangle bounds = table.getBounds(); + bounds.y = bounds.height + table.getRowHeight(); + bounds.height = table.getRowHeight(); + System.out.println("scrolling: " + bounds); + table.scrollRectToVisible(bounds); + System.out.println("bounds: " + table.getVisibleRect()); + }); + + frame.add(scrollButton, BorderLayout.NORTH); + frame.add(new JScrollPane(table), BorderLayout.CENTER); + frame.setSize(400, 300); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + + private static class TestModel extends AbstractTableModel { + @Override + public String getColumnName(int column) { + return Integer.toString(column); + } + + @Override + public int getRowCount() { + return 100; + } + + @Override + public int getColumnCount() { + return 5; + } + + @Override + public Object getValueAt(int row, int col) { + return row + " x " + col; + } + + @Override + public boolean isCellEditable(int row, int column) { return false; } + + @Override + public void setValueAt(Object value, int row, int col) { + } + } + + private static Rectangle getComponentBounds(Component c) { + Point locationOnScreen = c.getLocationOnScreen(); + Dimension size = c.getSize(); + return new Rectangle(locationOnScreen, size); + } +} diff --git a/test/jdk/javax/swing/JViewport/SetViewRepaint.java b/test/jdk/javax/swing/JViewport/SetViewRepaint.java new file mode 100644 index 00000000000..379a3e4e33b --- /dev/null +++ b/test/jdk/javax/swing/JViewport/SetViewRepaint.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4128110 + * @summary Verify that JViewport.setViewportView() and JScrollPane.setViewport() + * force a re-layout and a repaint. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetViewRepaint + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JViewport; + +public class SetViewRepaint { + private static final String INSTRUCTIONS = """ + Verify the following two cases: + + 1) Press "JViewport.setViewportView()" button and verify that + the blue label is replaced by a scrolling list. + + 2) Press "JScrollPane.setViewport()" button and verify that + the red label is replaced by a scrolling list as well. + + In either case the display should update automatically after + pressing the button. + + If the above is true, press PASS else press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(30) + .testUI(SetViewRepaint::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("SetViewRepaint"); + JPanel p1 = new JPanel(new BorderLayout()); + JPanel p2 = new JPanel(new BorderLayout()); + + JLabel label1 = new ColorLabel(Color.BLUE, "Blue Label"); + final JList list1 = new JList(new String[]{"one", "two", "three", "four"}); + final JScrollPane sp1 = new JScrollPane(label1); + ActionListener doSetViewportView = e -> sp1.setViewportView(list1); + JButton b1 = new JButton("JViewport.setViewportView()"); + b1.addActionListener(doSetViewportView); + p1.add(sp1, BorderLayout.CENTER); + p1.add(b1, BorderLayout.SOUTH); + + JLabel label2 = new ColorLabel(Color.RED, "Red Label"); + final JList list2 = new JList(new String[]{"five", "six", "seven", "eight"}); + final JScrollPane sp2 = new JScrollPane(label2); + ActionListener doSetViewport = e -> { + JViewport vp = new JViewport(); + vp.setView(list2); + sp2.setViewport(vp); + }; + JButton b2 = new JButton("JScrollPane.setViewport()"); + b2.addActionListener(doSetViewport); + p2.add(sp2, BorderLayout.CENTER); + p2.add(b2, BorderLayout.SOUTH); + frame.setLayout(new GridLayout(1, 2)); + frame.add(p1); + frame.add(p2); + frame.setResizable(false); + frame.setSize(500, 120); + return frame; + } + + private static class ColorLabel extends JLabel { + ColorLabel(Color color, String text) { + super(text); + setForeground(Color.WHITE); + setBackground(color); + setOpaque(true); + setHorizontalAlignment(CENTER); + } + } +} From bd73127d7495244f93f941530db32b4559d45689 Mon Sep 17 00:00:00 2001 From: Harshitha Onkar Date: Fri, 18 Apr 2025 23:29:53 +0000 Subject: [PATCH 014/901] 8354532: Open source JFileChooser Tests - Set 7 Reviewed-by: prr --- .../javax/swing/JFileChooser/bug4357012.java | 99 +++++++++++++++ .../javax/swing/JFileChooser/bug4926884.java | 114 ++++++++++++++++++ .../javax/swing/JFileChooser/bug5045464.java | 68 +++++++++++ .../javax/swing/JFileChooser/bug6515169.java | 106 ++++++++++++++++ 4 files changed, 387 insertions(+) create mode 100644 test/jdk/javax/swing/JFileChooser/bug4357012.java create mode 100644 test/jdk/javax/swing/JFileChooser/bug4926884.java create mode 100644 test/jdk/javax/swing/JFileChooser/bug5045464.java create mode 100644 test/jdk/javax/swing/JFileChooser/bug6515169.java diff --git a/test/jdk/javax/swing/JFileChooser/bug4357012.java b/test/jdk/javax/swing/JFileChooser/bug4357012.java new file mode 100644 index 00000000000..2dfdcd336d5 --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4357012.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4357012 + * @requires (os.family == "windows") + * @summary JFileChooser.showSaveDialog inconsistent with Windows Save Dialog + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4357012 + */ + +import java.io.File; +import java.io.IOException; +import javax.swing.JComponent; +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4357012 { + private static File workDir = null; + private static File dir = null; + private static File file = null; + private static final String INSTRUCTIONS = """ + + Test is for Windows LAF only +

In JFileChooser's files list : +

    +
  1. Select directory. Verify that the directory name doesn't + appear in "file name" field.
  2. +
  3. Select file. Verify that the file name appears in + "file name" field.
  4. +
  5. Select directory again. Verify that the previous file name + remains in file name field.
  6. +
+

+ + """; + + public static void main(String[] argv) throws Exception { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + createTestDir(); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(10) + .columns(40) + .testUI(bug4357012::createTestUI) + .build() + .awaitAndCheck(); + } finally { + if (workDir != null) { + System.out.println("Deleting '" + file + "': " + file.delete()); + System.out.println("Deleting '" + dir + "': " + dir.delete()); + System.out.println("Deleting '" + workDir + "': " + workDir.delete()); + } + } + } + + private static void createTestDir() throws IOException { + String tempDir = "."; + String fs = System.getProperty("file.separator"); + + workDir = new File(tempDir + fs + "bug4357012"); + System.out.println("Creating '" + workDir + "': " + workDir.mkdir()); + + dir = new File(workDir + fs + "Directory"); + System.out.println("Creating '" + dir + "': " + dir.mkdir()); + + file = new File(workDir + fs + "File.txt"); + System.out.println("Creating '" + file + "': " + file.createNewFile()); + } + + private static JComponent createTestUI() { + JFileChooser fc = new JFileChooser(workDir); + fc.setDialogType(JFileChooser.SAVE_DIALOG); + return fc; + } +} diff --git a/test/jdk/javax/swing/JFileChooser/bug4926884.java b/test/jdk/javax/swing/JFileChooser/bug4926884.java new file mode 100644 index 00000000000..29d6c4e9134 --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4926884.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2011, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4926884 + * @requires (os.family == "windows") + * @summary Win L&F: JFileChooser problems with "My Documents" folder + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4926884 + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4926884 { + private static final String INSTRUCTIONS = """ + Validate next statements step by step: + + 1. In the file list there are several dirs and files (like "ski", + "Snowboard" etc.) + 2. Select "Details" view mode. + 3. Make file list in focus (e.g. by pressing mouse button) + 4. Press key "w" several times with delay LESS than 1 second. + Selection should be changed across files started with letter "w" + (without case sensitive). + 5. Press key "w" several times with delay MORE than 1 second. + Selection should be changed across files started with letter "w" + (without case sensitive). + 6. Type "winnt" (with delay less than 1 second between letters) - + directory "winnt" should be selected. + 7. Change conditions: + - Move column "Name" to the second position + - Change sort mode by clicking column "Size" + 8. Repeat items 4-6 + + If above is true press PASS else FAIL + """; + + private static final String[] DIRS = {"www", "winnt", "ski"}; + private static final String[] FILES = {"Window", "weel", "mice", + "Wall", "Snowboard", "wood"}; + private static final File testDir = new File("."); + + public static void main(String[] argv) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + try { + createTestDir(); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(() -> new JFileChooser(testDir)) + .build() + .awaitAndCheck(); + } finally { + deleteTempDir(); + } + } + + private static void createTestDir() throws IOException { + testDir.mkdir(); + + for (String dir : DIRS) { + new File(testDir, dir).mkdir(); + } + + for (int i = 0; i < FILES.length; i++) { + + try (OutputStream outputStream = new FileOutputStream( + new File(testDir, FILES[i]))) { + for (int j = 0; j < i * 1024; j++) { + outputStream.write('#'); + } + } + } + } + + private static void deleteTempDir() { + File[] files = testDir.listFiles(); + + for (File file : files) { + if (file != null) { + file.delete(); + } + } + + testDir.delete(); + } +} diff --git a/test/jdk/javax/swing/JFileChooser/bug5045464.java b/test/jdk/javax/swing/JFileChooser/bug5045464.java new file mode 100644 index 00000000000..0fbeedcec6b --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug5045464.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5045464 + * @requires (os.family == "linux") + * @summary Regression: GTK L&F, JFileChooser shows "null/" in folder list + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug5045464 + */ + +import javax.swing.JComponent; +import javax.swing.JFileChooser; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class bug5045464 { + private static final String INSTRUCTIONS = """ + When the filechooser appears check the directory list (the left list). + If it starts with two items: "./" (current directory) + and "../" (parent directory) press PASS. + If something else is here (e.g. "null/" instead of "./") + press FAIL. + """; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug5045464::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + JFileChooser fc = new JFileChooser(); + fc.setControlButtonsAreShown(false); + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + } catch (Exception ex) { + throw new RuntimeException("Test Failed!", ex); + } + SwingUtilities.updateComponentTreeUI(fc); + return fc; + } +} diff --git a/test/jdk/javax/swing/JFileChooser/bug6515169.java b/test/jdk/javax/swing/JFileChooser/bug6515169.java new file mode 100644 index 00000000000..98cd813eefb --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug6515169.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2011, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6515169 + * @requires (os.family == "windows") + * @summary wrong grid header in JFileChooser + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug6515169 + */ + +import javax.swing.ButtonGroup; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class bug6515169 { + private static JFrame frame; + private static final String INSTRUCTIONS = """ + This test is to verify JFileChooser on Windows and Metal LAF. + Use the "Change LaF" menu to switch between the 2 LaF + and verify the following. + + a. Change view mode to "Details" + b. Check that 4 columns appear: Name, Size, Type and Date Modified + c. Change current directory by pressing any available subdirectory + or by pressing button "Up One Level". + d. Check that still four columns exist. + + Change LaF and repeat the steps a-d. + If all conditions are true press PASS, else FAIL. + """; + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug6515169::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + frame = new JFrame("bug6515169"); + JMenuBar bar = new JMenuBar(); + JMenu lafMenu = new JMenu("Change LaF"); + ButtonGroup lafGroup = new ButtonGroup(); + JCheckBoxMenuItem lafItem1 = new JCheckBoxMenuItem("Window LaF"); + lafItem1.addActionListener(e -> + setLaF(UIManager.getSystemLookAndFeelClassName())); + lafGroup.add(lafItem1); + lafMenu.add(lafItem1); + + JCheckBoxMenuItem lafItem2 = new JCheckBoxMenuItem("Metal LaF"); + lafItem2.addActionListener(e -> + setLaF(UIManager.getCrossPlatformLookAndFeelClassName())); + lafGroup.add(lafItem2); + lafMenu.add(lafItem2); + + bar.add(lafMenu); + frame.setJMenuBar(bar); + + String dir = "."; + JFileChooser fc = new JFileChooser(dir); + fc.setControlButtonsAreShown(false); + frame.add(fc); + frame.pack(); + + return frame; + } + + private static void setLaF(String laf) { + try { + UIManager.setLookAndFeel(laf); + SwingUtilities.updateComponentTreeUI(frame); + } catch (Exception e) { + throw new RuntimeException("Test Failed!", e); + } + } +} From 4f58af0a8dd5eced77259bed180f6af36501f502 Mon Sep 17 00:00:00 2001 From: Alexey Bakhtin Date: Sat, 19 Apr 2025 00:30:37 +0000 Subject: [PATCH 015/901] 8259540: MissingResourceException for key cvc-complex-type.2.4.d.1 Reviewed-by: joehw --- .../apache/xerces/internal/impl/msg/XMLSchemaMessages.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties index f6402e8f65e..4f15b428c8b 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties @@ -56,6 +56,7 @@ cvc-complex-type.2.4.b = cvc-complex-type.2.4.b: The content of element ''{0}'' is not complete. One of ''{1}'' is expected. cvc-complex-type.2.4.c = cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ''{0}''. cvc-complex-type.2.4.d = cvc-complex-type.2.4.d: Invalid content was found starting with element ''{0}''. No child element is expected at this point. + cvc-complex-type.2.4.d.1 = cvc-complex-type.2.4.d: Invalid content was found starting with element ''{0}''. No child element ''{1}'' is expected at this point. cvc-complex-type.2.4.e = cvc-complex-type.2.4.e: ''{0}'' can occur a maximum of ''{2}'' times in the current sequence. This limit was exceeded. At this point one of ''{1}'' is expected. cvc-complex-type.2.4.f = cvc-complex-type.2.4.f: ''{0}'' can occur a maximum of ''{1}'' times in the current sequence. This limit was exceeded. No child element is expected at this point. cvc-complex-type.2.4.g = cvc-complex-type.2.4.g: Invalid content was found starting with element ''{0}''. ''{1}'' is expected to occur a minimum of ''{2}'' times in the current sequence. One more instance is required to satisfy this constraint. From c7c77eb6aa25cbf84ba4b7519e16c092c222e504 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Sat, 19 Apr 2025 07:48:54 +0000 Subject: [PATCH 016/901] 8354077: Get rid of offscreenSharingEnabled windows flag Reviewed-by: prr --- .../sun/java2d/windows/WindowsFlags.java | 32 ++----------------- .../libawt/java2d/windows/WindowsFlags.cpp | 9 +----- .../libawt/java2d/windows/WindowsFlags.h | 4 +-- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java b/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java index 5bf2ba3227f..7333eeda3dd 100644 --- a/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java +++ b/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -55,16 +55,6 @@ public class WindowsFlags { * This flag can force us to use d3d * anyway in these situations. Or, this flag can force us to * not use d3d in a situation where we would use it otherwise. - * offscreenSharingEnabled: usage: "-Dsun.java2d.offscreenSharing=true" - * Turns on the ability to share a hardware-accelerated - * offscreen surface through the JAWT interface. See - * src/windows/native/sun/windows/awt_DrawingSurface.* for - * more information. This capability is disabled by default - * pending more testing and time to work out the right - * solution; we do not want to expose more public JAWT api - * without being very sure that we will be willing to support - * that API in the future regardless of other native - * rendering pipeline changes. * magPresent: usage: "-Djavax.accessibility.screen_magnifier_present" * This flag is set either on the command line or in the * properties file. It tells Swing whether the user is @@ -101,7 +91,6 @@ public class WindowsFlags { private static boolean d3dOnScreenEnabled; private static boolean oglEnabled; private static boolean oglVerbose; - private static boolean offscreenSharingEnabled; private static boolean magPresent; private static boolean setHighDPIAware; // TODO: other flags, including nopixfmt @@ -206,8 +195,6 @@ private static void initJavaFlags() { if (d3dSet) { d3dVerbose = isBooleanPropTrueVerbose("sun.java2d.d3d"); } - offscreenSharingEnabled = - getBooleanProp("sun.java2d.offscreenSharing", false); String dpiOverride = System.getProperty("sun.java2d.dpiaware"); if (dpiOverride != null) { setHighDPIAware = dpiOverride.equalsIgnoreCase("true"); @@ -217,16 +204,6 @@ private static void initJavaFlags() { setHighDPIAware = sunLauncherProperty.equalsIgnoreCase("SUN_STANDARD"); } - /* - // Output info based on some non-default flags: - if (offscreenSharingEnabled) { - System.out.println( - "Warning: offscreenSharing has been enabled. " + - "The use of this capability will change in future " + - "releases and applications that depend on it " + - "may not work correctly"); - } - */ /* System.out.println("WindowsFlags (Java):"); System.out.println(" ddEnabled: " + ddEnabled + "\n" + @@ -235,8 +212,7 @@ private static void initJavaFlags() { " d3dSet: " + d3dSet + "\n" + " oglEnabled: " + oglEnabled + "\n" + " oglVerbose: " + oglVerbose + "\n" + - " gdiBlitEnabled: " + gdiBlitEnabled + "\n" + - " offscreenSharingEnabled: " + offscreenSharingEnabled); + " gdiBlitEnabled: " + gdiBlitEnabled); */ } @@ -260,10 +236,6 @@ public static boolean isGdiBlitEnabled() { return gdiBlitEnabled; } - public static boolean isOffscreenSharingEnabled() { - return offscreenSharingEnabled; - } - public static boolean isMagPresent() { return magPresent; } diff --git a/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp b/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp index 528e95e326a..9ed0f38bd10 100644 --- a/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp +++ b/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -30,7 +30,6 @@ BOOL useD3D = TRUE; // d3d enabled flag // initially is TRUE to allow D3D preloading BOOL forceD3DUsage; // force d3d on or off -jboolean g_offscreenSharing; // JAWT accelerated surface sharing BOOL setHighDPIAware; // Whether to set the high-DPI awareness flag extern WCHAR *j2dAccelKey; // Name of java2d root key @@ -89,10 +88,6 @@ void GetFlagValues(JNIEnv *env, jclass wFlagsClass) } useD3D = d3dEnabled; forceD3DUsage = d3dSet; - g_offscreenSharing = GetStaticBoolean(env, wFlagsClass, - "offscreenSharingEnabled"); - JNU_CHECK_EXCEPTION(env); - setHighDPIAware = (IS_WINVISTA && GetStaticBoolean(env, wFlagsClass, "setHighDPIAware")); JNU_CHECK_EXCEPTION(env); @@ -102,8 +97,6 @@ void GetFlagValues(JNIEnv *env, jclass wFlagsClass) (useD3D ? "true" : "false")); J2dTraceLn1(J2D_TRACE_INFO, " d3dSet = %s", (forceD3DUsage ? "true" : "false")); - J2dTraceLn1(J2D_TRACE_INFO, " offscreenSharing = %s", - (g_offscreenSharing ? "true" : "false")); J2dTraceLn1(J2D_TRACE_INFO, " setHighDPIAware = %s", (setHighDPIAware ? "true" : "false")); } diff --git a/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h b/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h index 85ba1657000..d5e34fdaa69 100644 --- a/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h +++ b/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h @@ -1,6 +1,5 @@ - /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -29,7 +28,6 @@ extern BOOL useD3D; // d3d enabled flag extern BOOL forceD3DUsage; // force d3d on or off -extern jboolean g_offscreenSharing; // JAWT accelerated surface sharing extern BOOL setHighDPIAware; // whether to set High DPI Aware flag on Vista void SetD3DEnabledFlag(JNIEnv *env, BOOL d3dEnabled, BOOL d3dSet); From 128f2d1cadae3cf91e4c590e6dabe2086737b7dd Mon Sep 17 00:00:00 2001 From: Liming Liu Date: Sat, 19 Apr 2025 10:02:13 +0000 Subject: [PATCH 017/901] 8354572: Turn off AlwaysMergeDMB for Ampere CPU by default Reviewed-by: shade --- src/hotspot/cpu/aarch64/vm_version_aarch64.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp index c555e393ca5..b2d34553487 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -161,6 +161,9 @@ void VM_Version::initialize() { (_model == CPU_MODEL_AMPERE_1A || _model == CPU_MODEL_AMPERE_1B)) { FLAG_SET_DEFAULT(CodeEntryAlignment, 32); } + if (FLAG_IS_DEFAULT(AlwaysMergeDMB)) { + FLAG_SET_DEFAULT(AlwaysMergeDMB, false); + } } // ThunderX From 4dd64b49716144cc697fb461ff88860e2cbcaaea Mon Sep 17 00:00:00 2001 From: Emanuel Peter Date: Mon, 21 Apr 2025 11:41:45 +0000 Subject: [PATCH 018/901] 8354477: C2 SuperWord: make use of memory edges more explicit Reviewed-by: kvn, roland --- .../share/opto/superwordVTransformBuilder.cpp | 89 +++++++++---------- .../share/opto/superwordVTransformBuilder.hpp | 14 +-- src/hotspot/share/opto/vectorization.cpp | 4 + src/hotspot/share/opto/vectorization.hpp | 5 ++ src/hotspot/share/opto/vtransform.hpp | 5 +- 5 files changed, 62 insertions(+), 55 deletions(-) diff --git a/src/hotspot/share/opto/superwordVTransformBuilder.cpp b/src/hotspot/share/opto/superwordVTransformBuilder.cpp index d356fcd5109..83496f9d0be 100644 --- a/src/hotspot/share/opto/superwordVTransformBuilder.cpp +++ b/src/hotspot/share/opto/superwordVTransformBuilder.cpp @@ -34,9 +34,9 @@ void SuperWordVTransformBuilder::build() { // Connect all vtnodes with their inputs. Possibly create vtnodes for input // nodes that are outside the loop. - VectorSet vtn_dependencies; // Shared, but cleared for every vtnode. - build_inputs_for_vector_vtnodes(vtn_dependencies); - build_inputs_for_scalar_vtnodes(vtn_dependencies); + VectorSet vtn_memory_dependencies; // Shared, but cleared for every vtnode. + build_inputs_for_vector_vtnodes(vtn_memory_dependencies); + build_inputs_for_scalar_vtnodes(vtn_memory_dependencies); } void SuperWordVTransformBuilder::build_vector_vtnodes_for_packed_nodes() { @@ -58,75 +58,77 @@ void SuperWordVTransformBuilder::build_scalar_vtnodes_for_non_packed_nodes() { } } -void SuperWordVTransformBuilder::build_inputs_for_vector_vtnodes(VectorSet& vtn_dependencies) { +void SuperWordVTransformBuilder::build_inputs_for_vector_vtnodes(VectorSet& vtn_memory_dependencies) { for (int i = 0; i < _packset.length(); i++) { Node_List* pack = _packset.at(i); Node* p0 = pack->at(0); VTransformVectorNode* vtn = get_vtnode(p0)->isa_Vector(); assert(vtn != nullptr, "all packs must have vector vtnodes"); - vtn_dependencies.clear(); // Add every dependency only once per vtn. + vtn_memory_dependencies.clear(); // Add every memory dependency only once per vtn. if (p0->is_Load()) { - set_req_with_scalar(p0, vtn, vtn_dependencies, MemNode::Address); + set_req_with_scalar(p0, vtn, MemNode::Address); + for (uint k = 0; k < pack->size(); k++) { + add_memory_dependencies_of_node_to_vtnode(pack->at(k), vtn, vtn_memory_dependencies); + } } else if (p0->is_Store()) { - set_req_with_scalar(p0, vtn, vtn_dependencies, MemNode::Address); - set_req_with_vector(pack, vtn, vtn_dependencies, MemNode::ValueIn); + set_req_with_scalar(p0, vtn, MemNode::Address); + set_req_with_vector(pack, vtn, MemNode::ValueIn); + for (uint k = 0; k < pack->size(); k++) { + add_memory_dependencies_of_node_to_vtnode(pack->at(k), vtn, vtn_memory_dependencies); + } } else if (vtn->isa_ReductionVector() != nullptr) { - set_req_with_scalar(p0, vtn, vtn_dependencies, 1); // scalar init - set_req_with_vector(pack, vtn, vtn_dependencies, 2); // vector + set_req_with_scalar(p0, vtn, 1); // scalar init + set_req_with_vector(pack, vtn, 2); // vector } else { assert(vtn->isa_ElementWiseVector() != nullptr, "all other vtnodes are handled above"); if (VectorNode::is_scalar_rotate(p0) && p0->in(2)->is_Con() && Matcher::supports_vector_constant_rotates(p0->in(2)->get_int())) { - set_req_with_vector(pack, vtn, vtn_dependencies, 1); - set_req_with_scalar(p0, vtn, vtn_dependencies, 2); // constant rotation + set_req_with_vector(pack, vtn, 1); + set_req_with_scalar(p0, vtn, 2); // constant rotation } else if (VectorNode::is_roundopD(p0)) { - set_req_with_vector(pack, vtn, vtn_dependencies, 1); - set_req_with_scalar(p0, vtn, vtn_dependencies, 2); // constant rounding mode + set_req_with_vector(pack, vtn, 1); + set_req_with_scalar(p0, vtn, 2); // constant rounding mode } else if (p0->is_CMove()) { // Cmp + Bool + CMove -> VectorMaskCmp + VectorBlend. - set_all_req_with_vectors(pack, vtn, vtn_dependencies); + set_all_req_with_vectors(pack, vtn); VTransformBoolVectorNode* vtn_mask_cmp = vtn->in(1)->isa_BoolVector(); if (vtn_mask_cmp->test()._is_negated) { vtn->swap_req(2, 3); // swap if test was negated. } } else { - set_all_req_with_vectors(pack, vtn, vtn_dependencies); + set_all_req_with_vectors(pack, vtn); } } - - for (uint k = 0; k < pack->size(); k++) { - add_dependencies_of_node_to_vtnode(pack->at(k), vtn, vtn_dependencies); - } } } -void SuperWordVTransformBuilder::build_inputs_for_scalar_vtnodes(VectorSet& vtn_dependencies) { +void SuperWordVTransformBuilder::build_inputs_for_scalar_vtnodes(VectorSet& vtn_memory_dependencies) { for (int i = 0; i < _vloop_analyzer.body().body().length(); i++) { Node* n = _vloop_analyzer.body().body().at(i); VTransformScalarNode* vtn = get_vtnode(n)->isa_Scalar(); if (vtn == nullptr) { continue; } - vtn_dependencies.clear(); // Add every dependency only once per vtn. + vtn_memory_dependencies.clear(); // Add every dependency only once per vtn. if (n->is_Load()) { - set_req_with_scalar(n, vtn, vtn_dependencies, MemNode::Address); + set_req_with_scalar(n, vtn, MemNode::Address); + add_memory_dependencies_of_node_to_vtnode(n, vtn, vtn_memory_dependencies); } else if (n->is_Store()) { - set_req_with_scalar(n, vtn, vtn_dependencies, MemNode::Address); - set_req_with_scalar(n, vtn, vtn_dependencies, MemNode::ValueIn); + set_req_with_scalar(n, vtn, MemNode::Address); + set_req_with_scalar(n, vtn, MemNode::ValueIn); + add_memory_dependencies_of_node_to_vtnode(n, vtn, vtn_memory_dependencies); } else if (n->is_CountedLoop()) { continue; // Is "root", has no dependency. } else if (n->is_Phi()) { // CountedLoop Phi's: ignore backedge (and entry value). assert(n->in(0) == _vloop.cl(), "only Phi's from the CountedLoop allowed"); - set_req_with_scalar(n, vtn, vtn_dependencies, 0); + set_req_with_scalar(n, vtn, 0); continue; } else { - set_all_req_with_scalars(n, vtn, vtn_dependencies); + set_all_req_with_scalars(n, vtn); } - - add_dependencies_of_node_to_vtnode(n, vtn, vtn_dependencies); } } @@ -175,10 +177,9 @@ VTransformVectorNode* SuperWordVTransformBuilder::make_vector_vtnode_for_pack(co return vtn; } -void SuperWordVTransformBuilder::set_req_with_scalar(Node* n, VTransformNode* vtn, VectorSet& vtn_dependencies, const int index) { +void SuperWordVTransformBuilder::set_req_with_scalar(Node* n, VTransformNode* vtn, const int index) { VTransformNode* req = get_vtnode_or_wrap_as_input_scalar(n->in(index)); vtn->set_req(index, req); - vtn_dependencies.set(req->_idx); } // Either get the existing vtnode vector input (when input is a pack), or else make a @@ -273,46 +274,42 @@ VTransformNode* SuperWordVTransformBuilder::get_vtnode_or_wrap_as_input_scalar(N return vtn; } -void SuperWordVTransformBuilder::set_req_with_vector(const Node_List* pack, VTransformNode* vtn, VectorSet& vtn_dependencies, int j) { +void SuperWordVTransformBuilder::set_req_with_vector(const Node_List* pack, VTransformNode* vtn, int j) { VTransformNode* req = get_or_make_vtnode_vector_input_at_index(pack, j); vtn->set_req(j, req); - vtn_dependencies.set(req->_idx); } -void SuperWordVTransformBuilder::set_all_req_with_scalars(Node* n, VTransformNode* vtn, VectorSet& vtn_dependencies) { +void SuperWordVTransformBuilder::set_all_req_with_scalars(Node* n, VTransformNode* vtn) { assert(vtn->req() == n->req(), "scalars must have same number of reqs"); for (uint j = 0; j < n->req(); j++) { Node* def = n->in(j); if (def == nullptr) { continue; } - set_req_with_scalar(n, vtn, vtn_dependencies, j); + set_req_with_scalar(n, vtn, j); } } -void SuperWordVTransformBuilder::set_all_req_with_vectors(const Node_List* pack, VTransformNode* vtn, VectorSet& vtn_dependencies) { +void SuperWordVTransformBuilder::set_all_req_with_vectors(const Node_List* pack, VTransformNode* vtn) { Node* p0 = pack->at(0); assert(vtn->req() <= p0->req(), "must have at at most as many reqs"); // Vectors have no ctrl, so ignore it. for (uint j = 1; j < vtn->req(); j++) { Node* def = p0->in(j); if (def == nullptr) { continue; } - set_req_with_vector(pack, vtn, vtn_dependencies, j); + set_req_with_vector(pack, vtn, j); } } -void SuperWordVTransformBuilder::add_dependencies_of_node_to_vtnode(Node*n, VTransformNode* vtn, VectorSet& vtn_dependencies) { +void SuperWordVTransformBuilder::add_memory_dependencies_of_node_to_vtnode(Node*n, VTransformNode* vtn, VectorSet& vtn_memory_dependencies) { for (VLoopDependencyGraph::PredsIterator preds(_vloop_analyzer.dependency_graph(), n); !preds.done(); preds.next()) { Node* pred = preds.current(); if (!_vloop.in_bb(pred)) { continue; } + if (!preds.is_current_memory_edge()) { continue; } - // Only add memory dependencies to memory nodes. All others are taken care of with the req. - if (n->is_Mem() && !pred->is_Mem()) { continue; } - + // Only track every memory edge once. VTransformNode* dependency = get_vtnode(pred); + if (vtn_memory_dependencies.test_set(dependency->_idx)) { continue; } - // Reduction self-cycle? - if (vtn == dependency && _vloop_analyzer.reductions().is_marked_reduction(n)) { continue; } - - if (vtn_dependencies.test_set(dependency->_idx)) { continue; } - vtn->add_dependency(dependency); // Add every dependency only once per vtn. + assert(n->is_Mem() && pred->is_Mem(), "only memory edges"); + vtn->add_memory_dependency(dependency); // Add every dependency only once per vtn. } } diff --git a/src/hotspot/share/opto/superwordVTransformBuilder.hpp b/src/hotspot/share/opto/superwordVTransformBuilder.hpp index 847f870bef6..bff900377f6 100644 --- a/src/hotspot/share/opto/superwordVTransformBuilder.hpp +++ b/src/hotspot/share/opto/superwordVTransformBuilder.hpp @@ -54,8 +54,8 @@ class SuperWordVTransformBuilder : public StackObj { void build(); void build_vector_vtnodes_for_packed_nodes(); void build_scalar_vtnodes_for_non_packed_nodes(); - void build_inputs_for_vector_vtnodes(VectorSet& vtn_dependencies); - void build_inputs_for_scalar_vtnodes(VectorSet& vtn_dependencies); + void build_inputs_for_vector_vtnodes(VectorSet& vtn_memory_dependencies); + void build_inputs_for_scalar_vtnodes(VectorSet& vtn_memory_dependencies); // Helper methods for building VTransform. VTransformNode* get_vtnode_or_null(Node* n) const { @@ -77,11 +77,11 @@ class SuperWordVTransformBuilder : public StackObj { VTransformVectorNode* make_vector_vtnode_for_pack(const Node_List* pack) const; VTransformNode* get_or_make_vtnode_vector_input_at_index(const Node_List* pack, const int index); VTransformNode* get_vtnode_or_wrap_as_input_scalar(Node* n); - void set_req_with_scalar(Node* n, VTransformNode* vtn, VectorSet& vtn_dependencies, const int index); - void set_req_with_vector(const Node_List* pack, VTransformNode* vtn, VectorSet& vtn_dependencies, const int index); - void set_all_req_with_scalars(Node* n, VTransformNode* vtn, VectorSet& vtn_dependencies); - void set_all_req_with_vectors(const Node_List* pack, VTransformNode* vtn, VectorSet& vtn_dependencies); - void add_dependencies_of_node_to_vtnode(Node* n, VTransformNode* vtn, VectorSet& vtn_dependencies); + void set_req_with_scalar(Node* n, VTransformNode* vtn, const int index); + void set_req_with_vector(const Node_List* pack, VTransformNode* vtn, const int index); + void set_all_req_with_scalars(Node* n, VTransformNode* vtn); + void set_all_req_with_vectors(const Node_List* pack, VTransformNode* vtn); + void add_memory_dependencies_of_node_to_vtnode(Node* n, VTransformNode* vtn, VectorSet& vtn_memory_dependencies); }; #endif // SHARE_OPTO_SUPERWORD_VTRANSFORM_BUILDER_HPP diff --git a/src/hotspot/share/opto/vectorization.cpp b/src/hotspot/share/opto/vectorization.cpp index e607a1065dd..d2cb62c92c9 100644 --- a/src/hotspot/share/opto/vectorization.cpp +++ b/src/hotspot/share/opto/vectorization.cpp @@ -399,6 +399,7 @@ VLoopDependencyGraph::PredsIterator::PredsIterator(const VLoopDependencyGraph& d _node(node), _dependency_node(dependency_graph.dependency_node(node)), _current(nullptr), + _is_current_memory_edge(false), _next_pred(0), _end_pred(node->req()), _next_memory_pred(0), @@ -418,11 +419,14 @@ VLoopDependencyGraph::PredsIterator::PredsIterator(const VLoopDependencyGraph& d void VLoopDependencyGraph::PredsIterator::next() { if (_next_pred < _end_pred) { _current = _node->in(_next_pred++); + _is_current_memory_edge = false; } else if (_next_memory_pred < _end_memory_pred) { int pred_bb_idx = _dependency_node->memory_pred_edge(_next_memory_pred++); _current = _dependency_graph._body.body().at(pred_bb_idx); + _is_current_memory_edge = true; } else { _current = nullptr; // done + _is_current_memory_edge = false; } } diff --git a/src/hotspot/share/opto/vectorization.hpp b/src/hotspot/share/opto/vectorization.hpp index d4b78515312..9d0887a993f 100644 --- a/src/hotspot/share/opto/vectorization.hpp +++ b/src/hotspot/share/opto/vectorization.hpp @@ -648,6 +648,7 @@ class VLoopDependencyGraph : public StackObj { const DependencyNode* _dependency_node; Node* _current; + bool _is_current_memory_edge; // Iterate in node->in(i) int _next_pred; @@ -665,6 +666,10 @@ class VLoopDependencyGraph : public StackObj { assert(!done(), "not done yet"); return _current; } + bool is_current_memory_edge() const { + assert(!done(), "not done yet"); + return _is_current_memory_edge; + } }; }; diff --git a/src/hotspot/share/opto/vtransform.hpp b/src/hotspot/share/opto/vtransform.hpp index 588da3cd56e..555f565360d 100644 --- a/src/hotspot/share/opto/vtransform.hpp +++ b/src/hotspot/share/opto/vtransform.hpp @@ -264,7 +264,8 @@ class VTransformNode : public ArenaObj { const VTransformNodeIDX _idx; private: - // _in is split into required inputs (_req), and additional dependencies. + // _in is split into required inputs (_req, i.e. all data dependencies), + // and memory dependencies. const uint _req; GrowableArray _in; GrowableArray _out; @@ -294,7 +295,7 @@ class VTransformNode : public ArenaObj { _in.at_put(j, tmp); } - void add_dependency(VTransformNode* n) { + void add_memory_dependency(VTransformNode* n) { assert(n != nullptr, "no need to add nullptr"); _in.push(n); n->add_out(this); From cd2d49f7119459f07844ce8201ca2320850cd51f Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Mon, 21 Apr 2025 17:37:58 +0000 Subject: [PATCH 019/901] 8354472: Clean up and open source KeyEvent related tests (Part 3) Reviewed-by: honkar --- .../awt/event/KeyEvent/CharUndefinedTest.java | 95 +++++++++++++ .../awt/event/KeyEvent/ExtendedKeysTest.java | 66 +++++++++ .../event/KeyEvent/KeyDownCaptureTest.java | 111 +++++++++++++++ .../event/KeyEvent/KeyEventToLightweight.java | 125 ++++++++++++++++ .../java/awt/event/KeyEvent/KeyModifiers.java | 134 ++++++++++++++++++ 5 files changed, 531 insertions(+) create mode 100644 test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java create mode 100644 test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java create mode 100644 test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java create mode 100644 test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java create mode 100644 test/jdk/java/awt/event/KeyEvent/KeyModifiers.java diff --git a/test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java b/test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java new file mode 100644 index 00000000000..bc58bdab14a --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/CharUndefinedTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4115484 4164672 4167893 + * @summary Ensures that KeyEvent has right keyChar for modifier and action keys. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CharUndefinedTest + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +public class CharUndefinedTest extends Frame implements KeyListener { + + static String INSTRUCTIONS = """ + Click on the text field inside the window named "Check KeyChar values". + Of any of the keys mentioned in this list that exist on your keyboard + press each of the listed keys once and also press them in two-key combinations such as + Control-Shift or Alt-Control. + The list of keys is: "Control, Shift, Meta, Alt, Command, Option". + After that press all function keys from F1 to F12 once, + Insert, Home, End, PageUp, PageDown and four arrow keys. + Check the log area below. If there are no messages starting with word "ERROR" + press "Pass" otherwise press "Fail". + """; + + public CharUndefinedTest() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + tf.addKeyListener(this); + add(tf, BorderLayout.CENTER); + pack(); + tf.requestFocus(); + } + + public void keyPressed(KeyEvent e) { + if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { + PassFailJFrame.log("ERROR: KeyPressed: keyChar = " + e.getKeyChar() + + " keyCode = " + e.getKeyCode() + " " + e.getKeyText(e.getKeyCode())); + } + } + + public void keyTyped(KeyEvent e) { + if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { + PassFailJFrame.log("ERROR: KeyTyped: keyChar = " + e.getKeyChar() + + " keyCode = " + e.getKeyCode() + " " + e.getKeyText(e.getKeyCode())); + } + } + + public void keyReleased(KeyEvent e) { + if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { + PassFailJFrame.log("ERROR: KeyReleased: keyChar = " + e.getKeyChar() + + " keyCode = " + e.getKeyCode() + " " + e.getKeyText(e.getKeyCode())); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .logArea(10) + .testUI(CharUndefinedTest::new) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java b/test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java new file mode 100644 index 00000000000..1423b2a007e --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/ExtendedKeysTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4218892 4191924 4199284 + * @summary Unable to enter some chars via european keyboard layout(s) + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ExtendedKeysTest + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextArea; +import java.lang.reflect.InvocationTargetException; + +public class ExtendedKeysTest extends Frame { + static String INSTRUCTIONS = """ + This test requires Swiss German input. If the Swiss German input + can not be installed or configured press "Pass" to skip testing. + Click on the text area inside the window named "Check input". + Switch to Swiss German input and press key with "\\" on it + (usually this key is above or to the left of the main "Enter" key). + If you see a dollar sign press "Pass". + If you see any other character or question mark press "Fail". + """; + + public ExtendedKeysTest() { + super("Check input"); + setLayout(new BorderLayout()); + add(new TextArea(20, 20), "Center"); + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .logArea(10) + .testUI(ExtendedKeysTest::new) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java b/test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java new file mode 100644 index 00000000000..bf2ab7ae958 --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/KeyDownCaptureTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4093998 + * @summary keyDown not called on subclasses of Component + * @key headful + * @run main KeyDownCaptureTest + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.atomic.AtomicBoolean; + +public class KeyDownCaptureTest extends Frame implements KeyListener { + static AtomicBoolean passed = new AtomicBoolean(false); + + public KeyDownCaptureTest() { + super("Key Down Capture Test"); + } + + public void initUI() { + setLayout (new BorderLayout()); + setSize(200, 200); + setLocationRelativeTo(null); + Canvas canvas = new Canvas(); + canvas.setBackground(Color.RED); + canvas.addKeyListener(this); + add(canvas, BorderLayout.CENTER); + setVisible(true); + } + + public void middle(Point p) { + Point loc = getLocationOnScreen(); + Dimension size = getSize(); + p.setLocation(loc.x + (size.width / 2), loc.y + (size.height / 2)); + } + + @Override + public void keyTyped(KeyEvent ignore) {} + + @Override + public void keyPressed(KeyEvent e) { + passed.set(true); + } + + @Override + public void keyReleased(KeyEvent ignore) {} + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + KeyDownCaptureTest test = new KeyDownCaptureTest(); + try { + EventQueue.invokeAndWait((test::initUI)); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(500); + robot.waitForIdle(); + Point target = new Point(); + EventQueue.invokeAndWait(() -> { + test.middle(target); + }); + robot.mouseMove(target.x, target.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyPress(KeyEvent.VK_SPACE); + robot.keyRelease(KeyEvent.VK_SPACE); + robot.delay(100); + robot.waitForIdle(); + if (!passed.get()) { + throw new RuntimeException("KeyPressed has not arrived to canvas"); + } + } finally { + if (test != null) { + EventQueue.invokeAndWait(test::dispose); + } + } + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java b/test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java new file mode 100644 index 00000000000..de832bf2e6d --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/KeyEventToLightweight.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4397557 + * @summary Check that focused lightweight component gets key events + * even if mouse is outside of it or on top of heavyweight component + * @key headful + * @run main KeyEventToLightweight + */ + +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.swing.JButton; + +public class KeyEventToLightweight extends Frame { + JButton lwbutton = new JButton("Select Me"); + Button hwbutton = new Button("Heavyweight"); + + AtomicBoolean aTyped = new AtomicBoolean(false); + AtomicBoolean bTyped = new AtomicBoolean(false); + AtomicBoolean cTyped = new AtomicBoolean(false); + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + KeyEventToLightweight test = new KeyEventToLightweight(); + try { + EventQueue.invokeAndWait(test::initUI); + test.performTest(); + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } + + public void initUI() { + this.setLayout(new FlowLayout()); + add(lwbutton); + add(hwbutton); + setSize(200, 200); + setLocationRelativeTo(null); + lwbutton.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_A) { + aTyped.set(true); + } else if (e.getKeyCode() == KeyEvent.VK_B) { + bTyped.set(true); + } else if (e.getKeyCode() == KeyEvent.VK_C) { + cTyped.set(true); + } + } + }); + setVisible(true); + } + + public void middleOf(Component c, Point p) { + Point loc = c.getLocationOnScreen(); + Dimension size = c.getSize(); + p.setLocation(loc.x + (size.width / 2), loc.y + (size.height / 2)); + } + + public void performTest() throws AWTException, InterruptedException, + InvocationTargetException { + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(500); + robot.waitForIdle(); + Point target = new Point(); + EventQueue.invokeAndWait(() -> middleOf(lwbutton, target)); + robot.mouseMove(target.x, target.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(500); + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + robot.mouseMove(target.x - 200, target.y); + robot.keyPress(KeyEvent.VK_B); + robot.keyRelease(KeyEvent.VK_B); + robot.waitForIdle(); + robot.delay(500); + EventQueue.invokeAndWait(() -> middleOf(hwbutton, target)); + robot.mouseMove(target.x, target.y); + robot.keyPress(KeyEvent.VK_C); + robot.keyRelease(KeyEvent.VK_C); + if (!aTyped.get() || !bTyped.get() || !cTyped.get()) { + throw new RuntimeException("Key event was not delivered, case 1: " + + aTyped.get() + ", case 2: " + bTyped.get() + ", case 3: " + + cTyped.get()); + } + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/KeyModifiers.java b/test/jdk/java/awt/event/KeyEvent/KeyModifiers.java new file mode 100644 index 00000000000..13cc35581db --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/KeyModifiers.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4193779 4174399 + * @summary Ensures that KeyEvents have the right modifiers set + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jdk.test.lib.Platform + * @run main/manual KeyModifiers + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +import jdk.test.lib.Platform; + + +public class KeyModifiers extends Frame implements KeyListener { + public KeyModifiers() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + tf.addKeyListener(this); + add(tf, BorderLayout.CENTER); + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + + String keys; + if (Platform.isWindows()) { + keys = "\"Shift-n\", \"Alt-n\"\n"; + } else if (Platform.isOSX()) { + keys = "\"Shift-n\", \"Alt-n\", \"Command-n\"\n"; + } else { + keys = "\"Shift-n\", \"Alt-n\", \"Meta-n\"\n"; + } + + String INSTRUCTIONS1 = """ + Click on the text field in the window named "Check KeyChar values" + and type the following key combinations: + """; + String INSTRUCTIONS2 = """ + After each combination check that the KeyPressed and KeyTyped modifiers + are correctly displayed. If modifiers are correct press "Pass", + otherwise press "Fail". + """; + PassFailJFrame.builder() + .title("KeyModifiers Test Instructions") + .instructions(INSTRUCTIONS1 + keys + INSTRUCTIONS2) + .columns(45) + .logArea(10) + .testUI(KeyModifiers::new) + .build() + .awaitAndCheck(); + } + + public void keyPressed(KeyEvent evt) { + int kc = evt.getKeyCode(); + + if (kc == KeyEvent.VK_CONTROL) { + return; + } + + if ((kc == KeyEvent.VK_SHIFT) || (kc == KeyEvent.VK_META) || + (kc == KeyEvent.VK_ALT) || (kc == KeyEvent.VK_ALT_GRAPH)) { + PassFailJFrame.log("Key pressed= " + KeyEvent.getKeyText(kc) + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } else { + PassFailJFrame.log("Key pressed = " + evt.getKeyChar() + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } + } + + public void keyTyped(KeyEvent evt) { + int kc = evt.getKeyCode(); + + if (kc == KeyEvent.VK_CONTROL) { + return; + } + + if ((kc == KeyEvent.VK_SHIFT) || (kc == KeyEvent.VK_META) || + (kc == KeyEvent.VK_ALT) || (kc == KeyEvent.VK_ALT_GRAPH)) { + PassFailJFrame.log("Key typed = " + KeyEvent.getKeyText(kc) + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } else { + PassFailJFrame.log("Key typed = " + evt.getKeyChar() + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } + } + + public void keyReleased(KeyEvent evt) { + int kc = evt.getKeyCode(); + + if (kc == KeyEvent.VK_CONTROL) + return; + + if ((kc == KeyEvent.VK_SHIFT) || (kc == KeyEvent.VK_META) || + (kc == KeyEvent.VK_ALT) || (kc == KeyEvent.VK_ALT_GRAPH)) { + PassFailJFrame.log("Key = released " + KeyEvent.getKeyText(kc) + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } else { + PassFailJFrame.log("Key released = " + evt.getKeyChar() + + " modifiers = " + InputEvent.getModifiersExText(evt.getModifiersEx())); + } + } +} From ecb54a05c6774e1a93d76b1181bda734129b6ace Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Mon, 21 Apr 2025 17:43:09 +0000 Subject: [PATCH 020/901] 8354523: runtime/Monitor/SyncOnValueBasedClassTest.java triggers SIGSEGV Co-authored-by: Martin Doerr Co-authored-by: Fei Yang Co-authored-by: Amit Kumar Reviewed-by: coleenp, aboldtch --- .../cpu/aarch64/c1_MacroAssembler_aarch64.cpp | 15 ++++++++------- .../cpu/aarch64/c2_MacroAssembler_aarch64.cpp | 2 +- .../cpu/aarch64/interp_masm_aarch64.cpp | 15 ++++++++------- .../cpu/aarch64/macroAssembler_aarch64.cpp | 9 ++++++++- src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp | 15 ++++++++------- src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp | 15 ++++++++------- src/hotspot/cpu/ppc/macroAssembler_ppc.cpp | 18 +++++++++++++----- .../cpu/riscv/c1_MacroAssembler_riscv.cpp | 15 ++++++++------- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 2 +- src/hotspot/cpu/riscv/interp_masm_riscv.cpp | 15 ++++++++------- src/hotspot/cpu/riscv/macroAssembler_riscv.cpp | 9 ++++++++- .../cpu/s390/c1_MacroAssembler_s390.cpp | 13 +++++++------ src/hotspot/cpu/s390/interp_masm_s390.cpp | 12 ++++++------ src/hotspot/cpu/s390/macroAssembler_s390.cpp | 10 ++++++++-- src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp | 13 +++++++------ src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp | 2 +- src/hotspot/cpu/x86/interp_masm_x86.cpp | 12 ++++++------ src/hotspot/cpu/x86/macroAssembler_x86.cpp | 8 +++++++- 18 files changed, 121 insertions(+), 79 deletions(-) diff --git a/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp index 6b1a5a7f1e0..afa2ddb47b4 100644 --- a/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp @@ -72,16 +72,17 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr null_check_offset = offset(); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(hdr, obj); - ldrb(hdr, Address(hdr, Klass::misc_flags_offset())); - tst(hdr, KlassFlags::_misc_is_value_based_class); - br(Assembler::NE, slow_case); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(disp_hdr, obj, hdr, temp, rscratch2, slow_case); } else if (LockingMode == LM_LEGACY) { + + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(hdr, obj); + ldrb(hdr, Address(hdr, Klass::misc_flags_offset())); + tst(hdr, KlassFlags::_misc_is_value_based_class); + br(Assembler::NE, slow_case); + } + Label done; // Load object header ldr(hdr, Address(obj, hdr_offset)); diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 605a05a44a7..56a91310dcd 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -360,7 +360,7 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Regist Label slow_path; if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. str(zr, Address(box, BasicLock::object_monitor_cache_offset_in_bytes())); } diff --git a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp index d5ba85da989..dd1d7d1d2e1 100644 --- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp @@ -693,17 +693,18 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg) // Load object pointer into obj_reg %c_rarg3 ldr(obj_reg, Address(lock_reg, obj_offset)); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(tmp, obj_reg); - ldrb(tmp, Address(tmp, Klass::misc_flags_offset())); - tst(tmp, KlassFlags::_misc_is_value_based_class); - br(Assembler::NE, slow_case); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(lock_reg, obj_reg, tmp, tmp2, tmp3, slow_case); b(done); } else if (LockingMode == LM_LEGACY) { + + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(tmp, obj_reg); + ldrb(tmp, Address(tmp, Klass::misc_flags_offset())); + tst(tmp, KlassFlags::_misc_is_value_based_class); + br(Assembler::NE, slow_case); + } + // Load (object->mark() | 1) into swap_reg ldr(rscratch1, Address(obj_reg, oopDesc::mark_offset_in_bytes())); orr(swap_reg, rscratch1, 1); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 1e226c70420..9a4b8e243a9 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -7034,10 +7034,17 @@ void MacroAssembler::lightweight_lock(Register basic_lock, Register obj, Registe ldr(mark, Address(obj, oopDesc::mark_offset_in_bytes())); if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. str(zr, Address(basic_lock, BasicObjectLock::lock_offset() + in_ByteSize((BasicLock::object_monitor_cache_offset_in_bytes())))); } + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(t1, obj); + ldrb(t1, Address(t1, Klass::misc_flags_offset())); + tst(t1, KlassFlags::_misc_is_value_based_class); + br(Assembler::NE, slow); + } + // Check if the lock-stack is full. ldrw(top, Address(rthread, JavaThread::lock_stack_top_offset())); cmpw(top, (unsigned)LockStack::end_offset()); diff --git a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp index ac9c5984de0..77d3653aefd 100644 --- a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp @@ -83,16 +83,17 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox // Save object being locked into the BasicObjectLock... std(Roop, in_bytes(BasicObjectLock::obj_offset()), Rbox); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(Rscratch, Roop); - lbz(Rscratch, in_bytes(Klass::misc_flags_offset()), Rscratch); - testbitdi(CR0, R0, Rscratch, exact_log2(KlassFlags::_misc_is_value_based_class)); - bne(CR0, slow_int); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(Rbox, Roop, Rmark, Rscratch, slow_int); } else if (LockingMode == LM_LEGACY) { + + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(Rscratch, Roop); + lbz(Rscratch, in_bytes(Klass::misc_flags_offset()), Rscratch); + testbitdi(CR0, R0, Rscratch, exact_log2(KlassFlags::_misc_is_value_based_class)); + bne(CR0, slow_int); + } + // ... and mark it unlocked. ori(Rmark, Rmark, markWord::unlocked_value); diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index 7a75dfd3de1..b51a0739d63 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -958,17 +958,18 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) { // markWord displaced_header = obj->mark().set_unlocked(); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(tmp, object); - lbz(tmp, in_bytes(Klass::misc_flags_offset()), tmp); - testbitdi(CR0, R0, tmp, exact_log2(KlassFlags::_misc_is_value_based_class)); - bne(CR0, slow_case); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(monitor, object, header, tmp, slow_case); b(done); } else if (LockingMode == LM_LEGACY) { + + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(tmp, object); + lbz(tmp, in_bytes(Klass::misc_flags_offset()), tmp); + testbitdi(CR0, R0, tmp, exact_log2(KlassFlags::_misc_is_value_based_class)); + bne(CR0, slow_case); + } + // Load markWord from object into header. ld(header, oopDesc::mark_offset_in_bytes(), object); diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp index f82395b14fb..ca0a1344d14 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp @@ -3000,7 +3000,7 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister fla Label slow_path; if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. li(tmp1, 0); std(tmp1, in_bytes(BasicObjectLock::lock_offset()) + BasicLock::object_monitor_cache_offset_in_bytes(), box); } @@ -4999,19 +4999,27 @@ void MacroAssembler::atomically_flip_locked_state(bool is_unlock, Register obj, // - t1, t2: temporary register void MacroAssembler::lightweight_lock(Register box, Register obj, Register t1, Register t2, Label& slow) { assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking"); - assert_different_registers(box, obj, t1, t2); + assert_different_registers(box, obj, t1, t2, R0); Label push; - const Register top = t1; - const Register mark = t2; const Register t = R0; if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. li(t, 0); std(t, in_bytes(BasicObjectLock::lock_offset()) + BasicLock::object_monitor_cache_offset_in_bytes(), box); } + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(t1, obj); + lbz(t1, in_bytes(Klass::misc_flags_offset()), t1); + testbitdi(CR0, R0, t1, exact_log2(KlassFlags::_misc_is_value_based_class)); + bne(CR0, slow); + } + + const Register top = t1; + const Register mark = t2; + // Check if the lock-stack is full. lwz(top, in_bytes(JavaThread::lock_stack_top_offset()), R16_thread); cmplwi(CR0, top, LockStack::end_offset()); diff --git a/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp index 76089e8dd45..29bf3e5f2ed 100644 --- a/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp @@ -61,16 +61,17 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr null_check_offset = offset(); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(hdr, obj); - lbu(hdr, Address(hdr, Klass::misc_flags_offset())); - test_bit(temp, hdr, exact_log2(KlassFlags::_misc_is_value_based_class)); - bnez(temp, slow_case, true /* is_far */); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(disp_hdr, obj, hdr, temp, t1, slow_case); } else if (LockingMode == LM_LEGACY) { + + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(hdr, obj); + lbu(hdr, Address(hdr, Klass::misc_flags_offset())); + test_bit(temp, hdr, exact_log2(KlassFlags::_misc_is_value_based_class)); + bnez(temp, slow_case, /* is_far */ true); + } + Label done; // Load object header ld(hdr, Address(obj, hdr_offset)); diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 99cbcedb8ff..39a49f8f1eb 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -289,7 +289,7 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Label slow_path; if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. sd(zr, Address(box, BasicLock::object_monitor_cache_offset_in_bytes())); } diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp index f1f9414d98a..8be5408cb2b 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp @@ -736,17 +736,18 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg) // Load object pointer into obj_reg c_rarg3 ld(obj_reg, Address(lock_reg, obj_offset)); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(tmp, obj_reg); - lbu(tmp, Address(tmp, Klass::misc_flags_offset())); - test_bit(tmp, tmp, exact_log2(KlassFlags::_misc_is_value_based_class)); - bnez(tmp, slow_case); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(lock_reg, obj_reg, tmp, tmp2, tmp3, slow_case); j(done); } else if (LockingMode == LM_LEGACY) { + + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(tmp, obj_reg); + lbu(tmp, Address(tmp, Klass::misc_flags_offset())); + test_bit(tmp, tmp, exact_log2(KlassFlags::_misc_is_value_based_class)); + bnez(tmp, slow_case); + } + // Load (object->mark() | 1) into swap_reg ld(t0, Address(obj_reg, oopDesc::mark_offset_in_bytes())); ori(swap_reg, t0, 1); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index b5c311c341d..c6393be0714 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -6362,10 +6362,17 @@ void MacroAssembler::lightweight_lock(Register basic_lock, Register obj, Registe ld(mark, Address(obj, oopDesc::mark_offset_in_bytes())); if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. sd(zr, Address(basic_lock, BasicObjectLock::lock_offset() + in_ByteSize((BasicLock::object_monitor_cache_offset_in_bytes())))); } + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(tmp1, obj); + lbu(tmp1, Address(tmp1, Klass::misc_flags_offset())); + test_bit(tmp1, tmp1, exact_log2(KlassFlags::_misc_is_value_based_class)); + bnez(tmp1, slow, /* is_far */ true); + } + // Check if the lock-stack is full. lwu(top, Address(xthread, JavaThread::lock_stack_top_offset())); mv(t, (unsigned)LockStack::end_offset()); diff --git a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp index 5691a2055b3..0e873250dca 100644 --- a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp @@ -69,17 +69,18 @@ void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox // Save object being locked into the BasicObjectLock... z_stg(Roop, Address(Rbox, BasicObjectLock::obj_offset())); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(tmp, Roop); - z_tm(Address(tmp, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); - branch_optimized(Assembler::bcondAllOne, slow_case); - } - assert(LockingMode != LM_MONITOR, "LM_MONITOR is already handled, by emit_lock()"); if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(Rbox, Roop, Rmark, tmp, slow_case); } else if (LockingMode == LM_LEGACY) { + + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(tmp, Roop); + z_tm(Address(tmp, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); + branch_optimized(Assembler::bcondAllOne, slow_case); + } + NearLabel done; // Load object header. diff --git a/src/hotspot/cpu/s390/interp_masm_s390.cpp b/src/hotspot/cpu/s390/interp_masm_s390.cpp index 48f4c7293a2..4ba99eb9e88 100644 --- a/src/hotspot/cpu/s390/interp_masm_s390.cpp +++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp @@ -1002,16 +1002,16 @@ void InterpreterMacroAssembler::lock_object(Register monitor, Register object) { // markWord header = obj->mark().set_unlocked(); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(tmp, object); - z_tm(Address(tmp, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); - z_btrue(slow_case); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(monitor, object, header, tmp, slow_case); } else if (LockingMode == LM_LEGACY) { + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(tmp, object); + z_tm(Address(tmp, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); + z_btrue(slow_case); + } + // Load markWord from object into header. z_lg(header, hdr_offset, object); diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index 88aedd1b5c0..0129e604978 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -6363,11 +6363,17 @@ void MacroAssembler::lightweight_lock(Register basic_lock, Register obj, Registe z_lg(mark, Address(obj, mark_offset)); if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. const Address om_cache_addr = Address(basic_lock, BasicObjectLock::lock_offset() + in_ByteSize((BasicLock::object_monitor_cache_offset_in_bytes()))); z_mvghi(om_cache_addr, 0); } + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(temp1, obj); + z_tm(Address(temp1, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); + z_brne(slow); + } + // First we need to check if the lock-stack has room for pushing the object reference. z_lgf(top, Address(Z_thread, ls_top_offset)); @@ -6501,7 +6507,7 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(Register obj, Registe NearLabel slow_path; if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. z_mvghi(Address(box, BasicLock::object_monitor_cache_offset_in_bytes()), 0); } diff --git a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp index b8873758b61..684347e35fa 100644 --- a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp @@ -55,16 +55,17 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr null_check_offset = offset(); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(hdr, obj, rscratch1); - testb(Address(hdr, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); - jcc(Assembler::notZero, slow_case); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(disp_hdr, obj, hdr, tmp, slow_case); } else if (LockingMode == LM_LEGACY) { Label done; + + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(hdr, obj, rscratch1); + testb(Address(hdr, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); + jcc(Assembler::notZero, slow_case); + } + // Load object header movptr(hdr, Address(obj, hdr_offset)); // and mark it as unlocked diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index a7967d83a4e..574bc081fce 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -476,7 +476,7 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Regist Label slow_path; if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. movptr(Address(box, BasicLock::object_monitor_cache_offset_in_bytes()), 0); } diff --git a/src/hotspot/cpu/x86/interp_masm_x86.cpp b/src/hotspot/cpu/x86/interp_masm_x86.cpp index bd029f2e4ac..d982495d883 100644 --- a/src/hotspot/cpu/x86/interp_masm_x86.cpp +++ b/src/hotspot/cpu/x86/interp_masm_x86.cpp @@ -1023,15 +1023,15 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg) { // Load object pointer into obj_reg movptr(obj_reg, Address(lock_reg, obj_offset)); - if (DiagnoseSyncOnValueBasedClasses != 0) { - load_klass(tmp_reg, obj_reg, rklass_decode_tmp); - testb(Address(tmp_reg, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); - jcc(Assembler::notZero, slow_case); - } - if (LockingMode == LM_LIGHTWEIGHT) { lightweight_lock(lock_reg, obj_reg, swap_reg, tmp_reg, slow_case); } else if (LockingMode == LM_LEGACY) { + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(tmp_reg, obj_reg, rklass_decode_tmp); + testb(Address(tmp_reg, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); + jcc(Assembler::notZero, slow_case); + } + // Load immediate 1 into swap_reg %rax movl(swap_reg, 1); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 25de76a7e40..4d3bd12ed66 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -9584,10 +9584,16 @@ void MacroAssembler::lightweight_lock(Register basic_lock, Register obj, Registe movptr(reg_rax, Address(obj, oopDesc::mark_offset_in_bytes())); if (UseObjectMonitorTable) { - // Clear cache in case fast locking succeeds. + // Clear cache in case fast locking succeeds or we need to take the slow-path. movptr(Address(basic_lock, BasicObjectLock::lock_offset() + in_ByteSize((BasicLock::object_monitor_cache_offset_in_bytes()))), 0); } + if (DiagnoseSyncOnValueBasedClasses != 0) { + load_klass(tmp, obj, rscratch1); + testb(Address(tmp, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class); + jcc(Assembler::notZero, slow); + } + // Load top. movl(top, Address(thread, JavaThread::lock_stack_top_offset())); From 684d3b336e9cb31707d35e75f9b785e04e1fdbee Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Mon, 21 Apr 2025 18:25:59 +0000 Subject: [PATCH 021/901] 8354774: DocumentBuilderFactory getAttribute throws NPE Reviewed-by: naoto, lancea --- .../xsltc/trax/TransformerFactoryImpl.java | 15 +- .../xerces/internal/impl/PropertyManager.java | 34 +--- .../jaxp/DocumentBuilderFactoryImpl.java | 26 +-- .../internal/jaxp/DocumentBuilderImpl.java | 15 +- .../xerces/internal/jaxp/SAXParserImpl.java | 34 +--- .../jaxp/validation/XMLSchemaFactory.java | 22 +-- .../XMLSchemaValidatorComponentManager.java | 22 +-- .../classes/jdk/xml/internal/JdkXmlUtils.java | 43 ++++- .../jdk/xml/internal/XMLSecurityManager.java | 2 +- .../jaxp/libs/jaxp/library/JUnitTestUtil.java | 13 ++ .../jaxp/unittest/common/PropertiesTest.java | 162 ++++++++++++++++++ 11 files changed, 268 insertions(+), 120 deletions(-) create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/PropertiesTest.java diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java index 747ec8473fe..ee730d3900a 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java @@ -371,17 +371,10 @@ else if (name.equals(ENABLE_INLINING)) { return _cdataChunkSize; } - /** Check to see if the property is managed by the security manager **/ - String propertyValue = (_xmlSecurityManager != null) ? - _xmlSecurityManager.getLimitAsString(name) : null; - if (propertyValue != null) { - return propertyValue; - } else { - propertyValue = (_xmlSecurityPropertyMgr != null) ? - _xmlSecurityPropertyMgr.getValue(name) : null; - if (propertyValue != null) { - return propertyValue; - } + //check if the property is managed by security manager + String value; + if ((value = JdkXmlUtils.getProperty(_xmlSecurityManager, _xmlSecurityPropertyMgr, name)) != null) { + return value; } // Throw an exception for all other attributes diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java index 2167c22e001..8d83f039617 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java @@ -27,13 +27,10 @@ import com.sun.xml.internal.stream.StaxEntityResolverWrapper; import java.util.HashMap; import javax.xml.XMLConstants; -import javax.xml.catalog.CatalogFeatures; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLResolver; -import jdk.xml.internal.FeaturePropertyBase; import jdk.xml.internal.JdkConstants; -import jdk.xml.internal.JdkProperty; import jdk.xml.internal.JdkXmlUtils; import jdk.xml.internal.XMLSecurityManager; import jdk.xml.internal.XMLSecurityPropertyManager; @@ -188,20 +185,13 @@ public Object getProperty(String property) { if (XMLInputFactory.SUPPORT_DTD.equals(property)) { return fSecurityManager.is(XMLSecurityManager.Limit.STAX_SUPPORT_DTD); } - /** - * Check to see if the property is managed by the security manager * - */ - String propertyValue = (fSecurityManager != null) - ? fSecurityManager.getLimitAsString(property) : null; - /** - * Check to see if the property is managed by the security property - * manager - */ - if (propertyValue == null) { - propertyValue = (fSecurityPropertyMgr != null) - ? fSecurityPropertyMgr.getValue(property) : null; + + //check if the property is managed by security manager + String value; + if ((value = JdkXmlUtils.getProperty(fSecurityManager, fSecurityPropertyMgr, property)) != null) { + return value; } - return propertyValue != null ? propertyValue : supportedProps.get(property); + return supportedProps.get(property); } /** @@ -250,15 +240,9 @@ public void setProperty(String property, Object value) { return; } - //check if the property is managed by security manager - if (fSecurityManager == null - || !fSecurityManager.setLimit(property, JdkProperty.State.APIPROPERTY, value)) { - //check if the property is managed by security property manager - if (fSecurityPropertyMgr == null - || !fSecurityPropertyMgr.setValue(property, FeaturePropertyBase.State.APIPROPERTY, value)) { - //fall back to the existing property manager - supportedProps.put(property, value); - } + if (!JdkXmlUtils.setProperty(fSecurityManager, fSecurityPropertyMgr, property, value)) { + //fall back to the existing property manager + supportedProps.put(property, value); } if (equivalentProperty != null) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java index 6909f2b51ff..2939058e7d4 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java @@ -29,7 +29,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.validation.Schema; -import jdk.xml.internal.JdkProperty; +import jdk.xml.internal.JdkXmlUtils; import jdk.xml.internal.XMLSecurityManager; import jdk.xml.internal.XMLSecurityPropertyManager; import org.xml.sax.SAXException; @@ -114,20 +114,13 @@ public void setAttribute(String name, Object value) attributes = new HashMap<>(); } - //check if the property is managed by security manager - String pName; - if ((pName = fSecurityManager.find(name)) != null) { - // as the qName is deprecated, let the manager decide whether the - // value shall be changed - fSecurityManager.setLimit(name, JdkProperty.State.APIPROPERTY, value); - attributes.put(pName, fSecurityManager.getLimitAsString(pName)); + if (JdkXmlUtils.setProperty(fSecurityManager, fSecurityPropertyMgr, name, value)) { + // necessary as DocumentBuilder recreate property manager + // remove this line once that's changed + attributes.put(name, value); // no need to create a DocumentBuilderImpl return; - } else if ((pName = fSecurityPropertyMgr.find(name)) != null) { - attributes.put(pName, value); - return; } - attributes.put(name, value); // Test the attribute name by possibly throwing an exception @@ -146,13 +139,10 @@ public void setAttribute(String name, Object value) public Object getAttribute(String name) throws IllegalArgumentException { - //check if the property is managed by security manager - String pName; - if ((pName = fSecurityManager.find(name)) != null) { - return fSecurityManager.getLimitAsString(pName); - } else if ((pName = fSecurityPropertyMgr.find(name)) != null) { - return attributes.get(pName); + String value; + if ((value = JdkXmlUtils.getProperty(fSecurityManager, fSecurityPropertyMgr, name)) != null) { + return value; } // See if it's in the attributes Map diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java index a8af265c325..43b986b9939 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java @@ -43,7 +43,7 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; import jdk.xml.internal.FeaturePropertyBase.State; import jdk.xml.internal.JdkConstants; -import jdk.xml.internal.JdkProperty; +import jdk.xml.internal.JdkXmlUtils; import jdk.xml.internal.XMLSecurityManager; import jdk.xml.internal.XMLSecurityPropertyManager; import jdk.xml.internal.XMLSecurityPropertyManager.Property; @@ -297,17 +297,10 @@ private void setDocumentBuilderFactoryAttributes( Map dbfAttrs) } } } else { - //check if the property is managed by security manager - if (fSecurityManager == null || - !fSecurityManager.setLimit(name, JdkProperty.State.APIPROPERTY, val)) { - //check if the property is managed by security property manager - if (fSecurityPropertyMgr == null || - !fSecurityPropertyMgr.setValue(name, State.APIPROPERTY, val)) { - //fall back to the existing property manager - domParser.setProperty(name, val); - } + if (!JdkXmlUtils.setProperty(fSecurityManager, fSecurityPropertyMgr, name, val)) { + //fall back to the existing property manager + domParser.setProperty(name, val); } - } } } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java index 053718c657d..fe435aabbcc 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java @@ -43,7 +43,7 @@ import javax.xml.validation.Schema; import jdk.xml.internal.FeaturePropertyBase; import jdk.xml.internal.JdkConstants; -import jdk.xml.internal.JdkProperty; +import jdk.xml.internal.JdkXmlUtils; import jdk.xml.internal.XMLSecurityManager; import jdk.xml.internal.XMLSecurityPropertyManager; import org.xml.sax.EntityResolver; @@ -569,20 +569,13 @@ else if (JAXP_SCHEMA_SOURCE.equals(name)) { super.setProperty(name, value); } - //check if the property is managed by security manager - if (fSecurityManager == null || - !fSecurityManager.setLimit(name, JdkProperty.State.APIPROPERTY, value)) { - //check if the property is managed by security property manager - if (fSecurityPropertyMgr == null || - !fSecurityPropertyMgr.setValue(name, FeaturePropertyBase.State.APIPROPERTY, value)) { - //fall back to the existing property manager - if (!fInitProperties.containsKey(name)) { - fInitProperties.put(name, super.getProperty(name)); - } - super.setProperty(name, value); + if (!JdkXmlUtils.setProperty(fSecurityManager, fSecurityPropertyMgr, name, value)) { + //fall back to the existing property manager + if (!fInitProperties.containsKey(name)) { + fInitProperties.put(name, super.getProperty(name)); } + super.setProperty(name, value); } - } public synchronized Object getProperty(String name) @@ -596,19 +589,10 @@ public synchronized Object getProperty(String name) return fSAXParser.schemaLanguage; } - /** Check to see if the property is managed by the security manager **/ - String propertyValue = (fSecurityManager != null) ? - fSecurityManager.getLimitAsString(name) : null; - if (propertyValue != null) { - return propertyValue; - } else { - propertyValue = (fSecurityPropertyMgr != null) ? - fSecurityPropertyMgr.getValue(name) : null; - if (propertyValue != null) { - return propertyValue; - } + String value; + if ((value = JdkXmlUtils.getProperty(fSecurityManager, fSecurityPropertyMgr, name)) != null) { + return value; } - return super.getProperty(name); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java index 753fdea25cd..82960821f4d 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java @@ -40,7 +40,6 @@ import java.io.InputStream; import java.io.Reader; import javax.xml.XMLConstants; -import javax.xml.catalog.CatalogFeatures.Feature; import javax.xml.stream.XMLEventReader; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; @@ -404,10 +403,11 @@ else if (name.equals(XMLGRAMMAR_POOL)) { } try { /** Check to see if the property is managed by the security manager **/ - String propertyValue = (fSecurityManager != null) ? - fSecurityManager.getLimitAsString(name) : null; - return propertyValue != null ? propertyValue : - fXMLSchemaLoader.getProperty(name); + String value; + if ((value = JdkXmlUtils.getProperty(fSecurityManager, fSecurityPropertyMgr, name)) != null) { + return value; + } + return fXMLSchemaLoader.getProperty(name); } catch (XMLConfigurationException e) { String identifier = e.getIdentifier(); @@ -513,15 +513,9 @@ else if (name.equals(XMLGRAMMAR_POOL)) { "property-not-supported", new Object [] {name})); } try { - //check if the property is managed by security manager - if (fSecurityManager == null || - !fSecurityManager.setLimit(name, JdkProperty.State.APIPROPERTY, object)) { - //check if the property is managed by security property manager - if (fSecurityPropertyMgr == null || - !fSecurityPropertyMgr.setValue(name, FeaturePropertyBase.State.APIPROPERTY, object)) { - //fall back to the existing property manager - fXMLSchemaLoader.setProperty(name, object); - } + if (!JdkXmlUtils.setProperty(fSecurityManager, fSecurityPropertyMgr, name, object)) { + //fall back to the existing property manager + fXMLSchemaLoader.setProperty(name, object); } } catch (XMLConfigurationException e) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java index bb4296349eb..419bfe4b250 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java @@ -48,7 +48,7 @@ import javax.xml.catalog.CatalogFeatures; import jdk.xml.internal.FeaturePropertyBase; import jdk.xml.internal.JdkConstants; -import jdk.xml.internal.JdkProperty; +import jdk.xml.internal.JdkXmlUtils; import jdk.xml.internal.XMLSecurityManager; import jdk.xml.internal.XMLSecurityPropertyManager; import org.w3c.dom.ls.LSResourceResolver; @@ -353,7 +353,7 @@ else if (SCHEMA_ELEMENT_DEFAULT.equals(featureId)) { * Set the state of a feature. * * @param featureId The unique identifier (URI) of the feature. - * @param state The requested state of the feature (true or false). + * @param value The value of the feature (true or false). * * @exception XMLConfigurationException If the requested feature is not known. */ @@ -361,7 +361,7 @@ public void setFeature(String featureId, boolean value) throws XMLConfigurationE if (PARSER_SETTINGS.equals(featureId)) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } - else if (value == false && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) { + else if (!value && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) { throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId); } else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) { @@ -452,18 +452,12 @@ else if (LOCALE.equals(propertyId)) { fComponents.put(propertyId, value); return; } - //check if the property is managed by security manager - if (fInitSecurityManager == null || - !fInitSecurityManager.setLimit(propertyId, JdkProperty.State.APIPROPERTY, value)) { - //check if the property is managed by security property manager - if (fSecurityPropertyMgr == null || - !fSecurityPropertyMgr.setValue(propertyId, FeaturePropertyBase.State.APIPROPERTY, value)) { - //fall back to the existing property manager - if (!fInitProperties.containsKey(propertyId)) { - fInitProperties.put(propertyId, super.getProperty(propertyId)); - } - super.setProperty(propertyId, value); + if (!JdkXmlUtils.setProperty(fInitSecurityManager, fSecurityPropertyMgr, propertyId, value)) { + //fall back to the existing property manager + if (!fInitProperties.containsKey(propertyId)) { + fInitProperties.put(propertyId, super.getProperty(propertyId)); } + super.setProperty(propertyId, value); } } diff --git a/src/java.xml/share/classes/jdk/xml/internal/JdkXmlUtils.java b/src/java.xml/share/classes/jdk/xml/internal/JdkXmlUtils.java index 1654c1b6cd5..93b63a746f1 100644 --- a/src/java.xml/share/classes/jdk/xml/internal/JdkXmlUtils.java +++ b/src/java.xml/share/classes/jdk/xml/internal/JdkXmlUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, 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 @@ -98,6 +98,47 @@ private static class DefaultSAXFactory { private static final SAXParserFactory instance = getSAXFactory(false); } + /** + * Sets the property if it's managed by either XMLSecurityManager or XMLSecurityPropertyManager. + * @param xsm the XMLSecurityManager + * @param xspm the XMLSecurityPropertyManager + * @param property the property + * @param value the value + * @return true if the property is managed by either XMLSecurityManager or + * XMLSecurityPropertyManager, false otherwise + */ + public static boolean setProperty(XMLSecurityManager xsm, XMLSecurityPropertyManager xspm, + String property, Object value) { + if (xsm != null && xsm.find(property) != null) { + return xsm.setLimit(property, JdkProperty.State.APIPROPERTY, value); + + } else if (xspm != null && xspm.find(property) != null) { + return xspm.setValue(property, FeaturePropertyBase.State.APIPROPERTY, value); + } + return false; + } + + /** + * Returns the value of the property if it's managed by either XMLSecurityManager + * or XMLSecurityPropertyManager. + * @param xsm the XMLSecurityManager + * @param xspm the XMLSecurityPropertyManager + * @param property the property + * @return the value of the property if it's managed by either XMLSecurityManager + * or XMLSecurityPropertyManager, null otherwise + */ + public static String getProperty(XMLSecurityManager xsm, XMLSecurityPropertyManager xspm, + String property) { + String value = null; + if (xsm != null && (value = xsm.getLimitAsString(property)) != null) { + return value; + } + if (xspm != null) { + value = xspm.getValue(property); + } + return value; + } + /** * Returns the value. * diff --git a/src/java.xml/share/classes/jdk/xml/internal/XMLSecurityManager.java b/src/java.xml/share/classes/jdk/xml/internal/XMLSecurityManager.java index 394bf28e02a..90c222de40e 100644 --- a/src/java.xml/share/classes/jdk/xml/internal/XMLSecurityManager.java +++ b/src/java.xml/share/classes/jdk/xml/internal/XMLSecurityManager.java @@ -361,7 +361,7 @@ public String find(String propertyName) { for (Limit limit : Limit.values()) { if (limit.is(propertyName)) { // current spec: new property name == systemProperty - return limit.systemProperty(); + return (limit.systemProperty != null) ? limit.systemProperty : limit.apiProperty; } } //ENTITYCOUNT's new name is qName diff --git a/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JUnitTestUtil.java b/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JUnitTestUtil.java index a31963f21de..f4eb3188242 100644 --- a/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JUnitTestUtil.java +++ b/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JUnitTestUtil.java @@ -32,6 +32,19 @@ public class JUnitTestUtil { public static final String CLS_DIR = System.getProperty("test.classes"); public static final String SRC_DIR = System.getProperty("test.src"); + // as in the Processors table in java.xml module summary + public enum Processor { + DOM, + SAX, + XMLREADER, + StAX, + VALIDATION, + TRANSFORM, + XSLTC, + DOMLS, + XPATH + }; + /** * Returns the System identifier (URI) of the source. * @param path the path to the source diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/PropertiesTest.java b/test/jaxp/javax/xml/jaxp/unittest/common/PropertiesTest.java new file mode 100644 index 00000000000..1550c53794a --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/PropertiesTest.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package common; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.stream.XMLInputFactory; +import javax.xml.transform.TransformerFactory; +import javax.xml.validation.SchemaFactory; +import java.util.EnumSet; +import java.util.Set; +import java.util.stream.Stream; +import jaxp.library.JUnitTestUtil.Processor; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.xml.sax.XMLReader; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/* + * @test + * @bug 8354774 + * @summary Verifies JAXP API Properties as specified in the java.xml module. + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest /test/lib + * @run junit/othervm common.PropertiesTest + */ +public class PropertiesTest { + private static final String ACCESS_EXTERNAL_DTD = XMLConstants.ACCESS_EXTERNAL_DTD; + private static final String ACCESS_EXTERNAL_SCHEMA = XMLConstants.ACCESS_EXTERNAL_SCHEMA; + private static final String ACCESS_EXTERNAL_STYLESHEET = XMLConstants.ACCESS_EXTERNAL_STYLESHEET; + private static final String SP_ACCESS_EXTERNAL_DTD = "javax.xml.accessExternalDTD"; + private static final String SP_ACCESS_EXTERNAL_SCHEMA = "javax.xml.accessExternalSchema"; + private static final String SP_ACCESS_EXTERNAL_STYLESHEET = "javax.xml.accessExternalStylesheet"; + private static final String DEFAULT_VALUE = "all"; + /** + * Returns test data for testAccessExternalProperties + * @return test data for testAccessExternalProperties + */ + private static Stream testData() { + // Supported processors for Access External Properties + Set supportedProcessors1 = EnumSet.of(Processor.DOM, Processor.SAX, Processor.XMLREADER, + Processor.StAX, Processor.VALIDATION); + Set supportedProcessors2 = EnumSet.of(Processor.TRANSFORM); + + return Stream.of( + Arguments.of(supportedProcessors1, ACCESS_EXTERNAL_DTD, null, SP_ACCESS_EXTERNAL_DTD, null, DEFAULT_VALUE), + Arguments.of(supportedProcessors1, ACCESS_EXTERNAL_DTD, "http", SP_ACCESS_EXTERNAL_DTD, null, "http"), + Arguments.of(supportedProcessors1, ACCESS_EXTERNAL_DTD, null, SP_ACCESS_EXTERNAL_DTD, "https", "https"), + Arguments.of(supportedProcessors1, ACCESS_EXTERNAL_DTD, "http", SP_ACCESS_EXTERNAL_DTD, "https", "http"), + Arguments.of(supportedProcessors1, ACCESS_EXTERNAL_SCHEMA, null, SP_ACCESS_EXTERNAL_SCHEMA, null, DEFAULT_VALUE), + Arguments.of(supportedProcessors1, ACCESS_EXTERNAL_SCHEMA, "http", SP_ACCESS_EXTERNAL_SCHEMA, null, "http"), + Arguments.of(supportedProcessors1, ACCESS_EXTERNAL_SCHEMA, null, SP_ACCESS_EXTERNAL_SCHEMA, "https", "https"), + Arguments.of(supportedProcessors1, ACCESS_EXTERNAL_SCHEMA, "http", SP_ACCESS_EXTERNAL_SCHEMA, "https", "http"), + Arguments.of(supportedProcessors2, ACCESS_EXTERNAL_STYLESHEET, null, SP_ACCESS_EXTERNAL_STYLESHEET, null, DEFAULT_VALUE), + Arguments.of(supportedProcessors2, ACCESS_EXTERNAL_STYLESHEET, "http", SP_ACCESS_EXTERNAL_STYLESHEET, null, "http"), + Arguments.of(supportedProcessors2, ACCESS_EXTERNAL_STYLESHEET, null, SP_ACCESS_EXTERNAL_STYLESHEET, "https", "https"), + Arguments.of(supportedProcessors2, ACCESS_EXTERNAL_STYLESHEET, "http", SP_ACCESS_EXTERNAL_STYLESHEET, "https", "http") + ); + } + + /** + * Verifies that the Access External Properties are supported throughout the + * JAXP APIs. + * @param supportedProcessors the supported processors for the property + * @param apiProperty the API property + * @param apiValue the value of the API property + * @param sysProperty the System property corresponding to the API property + * @param sysValue the value of the System property + * @param expected the expected result + * @throws Exception if the test fails due to test configuration issues other + * than the expected result + */ + @ParameterizedTest + @MethodSource("testData") + public void testAccessExternalProperties(Set supportedProcessors, + String apiProperty, String apiValue, String sysProperty, String sysValue, + String expected) throws Exception { + for (Processor p : supportedProcessors) { + testProperties(p, apiProperty, apiValue, sysProperty, sysValue, + expected); + } + } + + /** + * Verifies that properties can be set via the JAXP APIs and their corresponding + * System Properties. + * @param processor the processor type + * @param apiProperty the API property + * @param apiValue the value to be set via the API property + * @param sysProperty the System Property + * @param sysValue the value to be set via the System property + * @param expected the expected result + * @throws Exception if the test fails, which can only happen if the property + * is set incorrectly. + */ + void testProperties(Processor processor, String apiProperty, String apiValue, + String sysProperty, String sysValue, String expected) + throws Exception { + Object ret1 = null; + if (sysValue != null) { + System.setProperty(sysProperty, sysValue); + } + switch (processor) { + case DOM: + DocumentBuilderFactory dbf = DocumentBuilderFactory.newDefaultInstance(); + if (apiValue != null) dbf.setAttribute(apiProperty, apiValue); + ret1 = dbf.getAttribute(apiProperty); + break; + case SAX: + SAXParser sp = SAXParserFactory.newDefaultInstance().newSAXParser(); + if (apiValue != null) sp.setProperty(apiProperty, apiValue); + ret1 = sp.getProperty(apiProperty); + break; + case XMLREADER: + XMLReader reader = SAXParserFactory.newDefaultInstance().newSAXParser().getXMLReader(); + if (apiValue != null) reader.setProperty(apiProperty, apiValue); + ret1 = reader.getProperty(apiProperty); + break; + case StAX: + XMLInputFactory xif = XMLInputFactory.newDefaultFactory(); + if (apiValue != null) xif.setProperty(apiProperty, apiValue); + ret1 = xif.getProperty(apiProperty); + break; + case VALIDATION: + SchemaFactory sf = SchemaFactory.newDefaultInstance(); + if (apiValue != null) sf.setProperty(apiProperty, apiValue); + ret1 = sf.getProperty(apiProperty); + break; + case TRANSFORM: + TransformerFactory tf = TransformerFactory.newDefaultInstance(); + if (apiValue != null) tf.setAttribute(apiProperty, apiValue); + ret1 = tf.getAttribute(apiProperty); + break; + } + + if (sysValue != null) System.clearProperty(sysProperty); + // property value is as expected + assertEquals(expected, ret1); + } +} From a7128d86eac2c40dbfa79811234ab6226fb4d080 Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Mon, 21 Apr 2025 20:19:45 +0000 Subject: [PATCH 022/901] 8354653: Clean up and open source KeyEvent related tests (Part 4) Reviewed-by: serb --- .../java/awt/event/KeyEvent/AltGrTest.java | 90 +++++++++++++ test/jdk/java/awt/event/KeyEvent/CRTest.java | 124 ++++++++++++++++++ .../java/awt/event/KeyEvent/NumpadTest2.java | 108 +++++++++++++++ .../event/KeyEvent/TestDoubleKeyEvent.java | 87 ++++++++++++ 4 files changed, 409 insertions(+) create mode 100644 test/jdk/java/awt/event/KeyEvent/AltGrTest.java create mode 100644 test/jdk/java/awt/event/KeyEvent/CRTest.java create mode 100644 test/jdk/java/awt/event/KeyEvent/NumpadTest2.java create mode 100644 test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java diff --git a/test/jdk/java/awt/event/KeyEvent/AltGrTest.java b/test/jdk/java/awt/event/KeyEvent/AltGrTest.java new file mode 100644 index 00000000000..9f771ea7e19 --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/AltGrTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4122687 4209844 + * @summary Characters typed with AltGr have Alt bit set on + * KEY_TYPED events + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual AltGrTest + */ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +public class AltGrTest extends Frame implements KeyListener { + static String INSTRUCTIONS = """ + Switch to German (Germany) keyboard layout and type + few characters using key. + Note: on windows keyboards without an AltGr key, + you should use Ctrl-Alt to synthesize AltGr. + For example, on German keyboards, `@' is AltGr-Q + `{' is AltGr-7 and '[' is AltGr-8 + If you see the corresponding symbols appear in the text field + and there are no entries in log area starting with word "FAIL:" + press "Pass", otherwise press "Fail". + """; + + public AltGrTest() { + setLayout(new BorderLayout()); + TextField entry = new TextField(); + entry.addKeyListener(this); + add(entry, BorderLayout.CENTER); + pack(); + } + + public void keyTyped(KeyEvent e) { + PassFailJFrame.log("----"); + PassFailJFrame.log("Got " + e); + + if (e.isControlDown() || e.isAltDown()) { + PassFailJFrame.log("FAIL: character typed has following modifiers bits set:"); + PassFailJFrame.log((e.isControlDown() ? " Control" : "") + + (e.isAltDown() ? " Alt" : "")); + } + + if (!(e.isAltGraphDown())) { + PassFailJFrame.log("FAIL: AltGraph modifier is missing"); + } + } + + public void keyPressed(KeyEvent ignore) {} + public void keyReleased(KeyEvent ignore) {} + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(AltGrTest::new) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/CRTest.java b/test/jdk/java/awt/event/KeyEvent/CRTest.java new file mode 100644 index 00000000000..0cc17fd568e --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/CRTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4257434 + * @summary Ensures that the right results are produced by the + * carriage return keys. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CRTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.atomic.AtomicBoolean; + +public class CRTest extends Frame implements KeyListener, ActionListener { + StringBuilder error = new StringBuilder(); + AtomicBoolean actionCompleted = new AtomicBoolean(false); + static String INSTRUCTIONS = """ + This test requires keyboard with the numeric keypad (numpad). + If your keyboard does not have numpad press "Pass" to skip testing. + Click on the text field in window named "Check KeyChar values". + Press Enter on keypad. Then press Return key on a standard keyboard. + Then click on "Done" button. Test will pass or fail automatically. + """; + + public CRTest() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + + tf.addKeyListener(this); + tf.addActionListener(this); + + add(tf, BorderLayout.CENTER); + + Button done = new Button("Done"); + done.addActionListener((event) -> { + checkAndComplete(); + }); + add(done, BorderLayout.SOUTH); + pack(); + } + + public void checkAndComplete() { + if (!actionCompleted.get()) { + error.append("\nNo action received!"); + } + + if (!error.isEmpty()) { + PassFailJFrame.forceFail(error.toString()); + } else { + PassFailJFrame.forcePass(); + } + } + + public void keyPressed(KeyEvent evt) { + if ((evt.getKeyChar() != '\n') || (evt.getKeyCode() != KeyEvent.VK_ENTER)) { + error.append("\nKeyPressed: Unexpected code " + evt.getKeyCode()); + } else { + PassFailJFrame.log("KeyPressed Test PASSED"); + } + } + + public void keyTyped(KeyEvent evt) { + if ((evt.getKeyChar() != '\n') || (evt.getKeyCode() != KeyEvent.VK_UNDEFINED)) { + error.append("\nKeyTyped: Unexpected code " + evt.getKeyCode()); + } else { + PassFailJFrame.log("KeyTyped Test PASSED"); + } + } + + public void keyReleased(KeyEvent evt) { + if ((evt.getKeyChar() != '\n') || (evt.getKeyCode() != KeyEvent.VK_ENTER)) { + error.append("\nKeyReleased: Unexpected code " + evt.getKeyCode()); + } else { + PassFailJFrame.log("KeyReleased Test PASSED"); + } + } + + public void actionPerformed(ActionEvent evt) { + PassFailJFrame.log("ActionPerformed Test PASSED"); + actionCompleted.set(true); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(CRTest::new) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/NumpadTest2.java b/test/jdk/java/awt/event/KeyEvent/NumpadTest2.java new file mode 100644 index 00000000000..1ee47354318 --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/NumpadTest2.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4279566 + * @summary Tests that numpad keys produce the correct key codes and + * key chars when both the NumLock and CapsLock are on. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NumpadTest2 +*/ + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.lang.reflect.InvocationTargetException; + +public class NumpadTest2 extends Frame implements KeyListener { + static String INSTRUCTIONS = """ + Make sure that the NumLock and CapsLock are both ON. + Click on the text field inside the window named "Check KeyChar values" + Then, type the NumPad 7 key (not the regular 7 key). + Verify that the keyChar and keyCode is correct for each key pressed. + Remember that the keyCode for the KEY_TYPED event should be zero. + If 7 appears in the text field and the key code printed is correct + press "Pass", otherwise press "Fail". + + Key Name keyChar Keycode + ------------------------------------------------- + Numpad-7 Numpad-7 55 103 + """; + + public NumpadTest2() { + super("Check KeyChar values"); + setLayout(new BorderLayout()); + TextField tf = new TextField(30); + tf.addKeyListener(this); + add(tf, BorderLayout.CENTER); + pack(); + } + + public void keyPressed(KeyEvent evt) { + printKey(evt); + } + + public void keyTyped(KeyEvent evt) { + printKey(evt); + } + + public void keyReleased(KeyEvent evt) { + printKey(evt); + } + + protected void printKey(KeyEvent evt) { + switch (evt.getID()) { + case KeyEvent.KEY_TYPED: + break; + case KeyEvent.KEY_PRESSED: + break; + case KeyEvent.KEY_RELEASED: + break; + default: + System.out.println("Other Event "); + return; + } + + if (evt.isActionKey()) { + PassFailJFrame.log("params= " + evt.paramString() + " KeyChar: " + + (int) evt.getKeyChar() + " Action Key"); + } else { + PassFailJFrame.log("params= " + evt.paramString() + " KeyChar: " + + (int) evt.getKeyChar()); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(NumpadTest2::new) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java b/test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java new file mode 100644 index 00000000000..24e0bd553c8 --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/TestDoubleKeyEvent.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4495473 + * @summary Tests that when you press key on canvas-type heavyweight only one key event arrives + * @key headful + * @run main TestDoubleKeyEvent + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; +import javax.swing.JFrame; +import javax.swing.JWindow; +import javax.swing.JTextField; + +public class TestDoubleKeyEvent extends JFrame { + JWindow w; + JTextField tf; + + public void initUI() { + setLayout(new BorderLayout()); + setTitle("Double Key Event Test"); + setLocationRelativeTo(null); + setVisible(true); + w = new JWindow(this); + w.setLayout(new FlowLayout()); + tf = new JTextField(20); + w.add(tf); + w.pack(); + w.setLocationRelativeTo(null); + w.setVisible(true); + tf.requestFocus(); + } + + public void testAndClean() { + String str = tf.getText(); + w.dispose(); + dispose(); + if (str.length() != str.chars().distinct().count()) { + throw new RuntimeException("Duplicate characters found!"); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + TestDoubleKeyEvent test = new TestDoubleKeyEvent(); + EventQueue.invokeAndWait(test::initUI); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.waitForIdle(); + robot.delay(1000); + for (int i = 0; i < 15; i++) { + robot.keyPress(KeyEvent.VK_A + i); + robot.keyRelease(KeyEvent.VK_A + i); + robot.waitForIdle(); + } + robot.delay(1000); + EventQueue.invokeAndWait(test::testAndClean); + } +} From 8270cd0ad2e0df72f063f36853328a935595f71f Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Mon, 21 Apr 2025 20:23:15 +0000 Subject: [PATCH 023/901] 8353470: Clean up and open source couple AWT Graphics related tests (Part 2) Reviewed-by: serb --- test/jdk/ProblemList.txt | 1 + .../Graphics/GDIResourceExhaustionTest.java | 121 ++++++++++ .../awt/Graphics/RepeatedRepaintTest.java | 137 +++++++++++ .../java/awt/Graphics/SmallPrimitives.java | 224 ++++++++++++++++++ test/jdk/java/awt/Graphics/TextAfterXor.java | 123 ++++++++++ 5 files changed, 606 insertions(+) create mode 100644 test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java create mode 100644 test/jdk/java/awt/Graphics/RepeatedRepaintTest.java create mode 100644 test/jdk/java/awt/Graphics/SmallPrimitives.java create mode 100644 test/jdk/java/awt/Graphics/TextAfterXor.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 075ce0e9c10..e1e0a695ebc 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -143,6 +143,7 @@ java/awt/Focus/TestDisabledAutoTransfer.java 8159871 macosx-all,windows-all java/awt/Focus/TestDisabledAutoTransferSwing.java 6962362 windows-all java/awt/Focus/ActivateOnProperAppContextTest.java 8136516 macosx-all java/awt/Focus/FocusPolicyTest.java 7160904 linux-all +java/awt/Graphics/SmallPrimitives.java 8047070 macosx-all,linux-all java/awt/EventQueue/6980209/bug6980209.java 8198615 macosx-all java/awt/EventQueue/PushPopDeadlock/PushPopDeadlock.java 8024034 generic-all java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java 7080150 macosx-all diff --git a/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java b/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java new file mode 100644 index 00000000000..b8ba155da60 --- /dev/null +++ b/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.imageio.ImageIO; +import java.awt.AWTException; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4191297 + * @summary Tests that unreferenced GDI resources are correctly + * destroyed when no longer needed. + * @key headful + * @run main GDIResourceExhaustionTest + */ + +public class GDIResourceExhaustionTest extends Frame { + public void initUI() { + setSize(200, 200); + setUndecorated(true); + setLocationRelativeTo(null); + Panel labelPanel = new Panel(); + Label label = new Label("Red label"); + label.setBackground(Color.red); + labelPanel.add(label); + labelPanel.setLocation(20, 50); + add(labelPanel); + setVisible(true); + } + + public void paint(Graphics graphics) { + super.paint(graphics); + for (int rgb = 0; rgb <= 0xfff; rgb++) { + graphics.setColor(new Color(rgb)); + graphics.fillRect(0, 0, 5, 5); + } + } + + public void requestCoordinates(Rectangle r) { + Insets insets = getInsets(); + Point location = getLocationOnScreen(); + Dimension size = getSize(); + r.x = location.x + insets.left; + r.y = location.y + insets.top; + r.width = size.width - (insets.left + insets.right); + r.height = size.height - (insets.top + insets.bottom); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException, IOException { + GDIResourceExhaustionTest test = new GDIResourceExhaustionTest(); + try { + EventQueue.invokeAndWait(test::initUI); + Robot robot = new Robot(); + robot.delay(2000); + Rectangle coords = new Rectangle(); + EventQueue.invokeAndWait(() -> { + test.requestCoordinates(coords); + }); + robot.mouseMove(coords.x - 50, coords.y - 50); + robot.waitForIdle(); + robot.delay(5000); + BufferedImage capture = robot.createScreenCapture(coords); + robot.delay(500); + boolean redFound = false; + int redRGB = Color.red.getRGB(); + for (int y = 0; y < capture.getHeight(); y++) { + for (int x = 0; x < capture.getWidth(); x++) { + if (capture.getRGB(x, y) == redRGB) { + redFound = true; + break; + } + if (redFound) { + break; + } + } + } + if (!redFound) { + File errorImage = new File("screenshot.png"); + ImageIO.write(capture, "png", errorImage); + throw new RuntimeException("Red label is not detected, possibly GDI resources exhausted"); + } + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } +} diff --git a/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java b/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java new file mode 100644 index 00000000000..140cb48630d --- /dev/null +++ b/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4081126 4129709 + * @summary Test for proper repainting on multiprocessor systems. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RepeatedRepaintTest + */ +public class RepeatedRepaintTest extends Frame { + private Font font = null; + private Image background; + + static String INSTRUCTIONS = """ + The frame next to this window called "AWT Draw Test" has + some elements drawn on it. Move this window partially outside of the + screen bounds and then drag it back. Repeat it couple of times. + Drag the instructions window over the frame partially obscuring it. + If after number of attempts the frame content stops repainting + press "Fail", otherwise press "Pass". + """; + + public RepeatedRepaintTest() { + setTitle("AWT Draw Test"); + setSize(300, 300); + background = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB); + Graphics g = background.getGraphics(); + g.setColor(Color.black); + g.fillRect(0, 0, 300, 300); + g.dispose(); + } + + public void paint(Graphics g) { + Dimension dim = this.getSize(); + super.paint(g); + g.drawImage(background, 0, 0, dim.width, dim.height, null); + g.setColor(Color.white); + if (font == null) { + font = new Font("SansSerif", Font.PLAIN, 24); + } + g.setFont(font); + FontMetrics metrics = g.getFontMetrics(); + String message = "Draw Test"; + g.drawString(message, (dim.width / 2) - (metrics.stringWidth(message) / 2), + (dim.height / 2) + (metrics.getHeight() / 2)); + + int counter = 50; + for (int i = 0; i < 50; i++) { + counter += 4; + g.drawOval(counter, 50, i, i); + } + + counter = 20; + for (int i = 0; i < 100; i++) { + counter += 4; + g.drawOval(counter, 150, i, i); + } + g.setColor(Color.black); + g.drawLine(0, dim.height - 25, dim.width, dim.height - 25); + g.setColor(Color.gray); + g.drawLine(0, dim.height - 24, dim.width, dim.height - 24); + g.setColor(Color.lightGray); + g.drawLine(0, dim.height - 23, dim.width, dim.height - 23); + g.fillRect(0, dim.height - 22, dim.width, dim.height); + + + g.setXORMode(Color.blue); + g.fillRect(0, 0, 25, dim.height - 26); + g.setColor(Color.red); + g.fillRect(0, 0, 25, dim.height - 26); + g.setColor(Color.green); + g.fillRect(0, 0, 25, dim.height - 26); + g.setPaintMode(); + + Image img = createImage(50, 50); + Graphics imgGraphics = img.getGraphics(); + imgGraphics.setColor(Color.magenta); + imgGraphics.fillRect(0, 0, 50, 50); + imgGraphics.setColor(Color.yellow); + imgGraphics.drawString("offscreen", 0, 20); + imgGraphics.drawString("image", 0, 30); + + g.drawImage(img, dim.width - 100, dim.height - 100, Color.blue, null); + + g.setXORMode(Color.white); + drawAt(g, 100, 100, 50, 50); + drawAt(g, 105, 105, 50, 50); + drawAt(g, 110, 110, 50, 50); + } + + public void drawAt(Graphics g, int x, int y, int width, int height) { + g.setColor(Color.magenta); + g.fillRect(x, y, width, height); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Repeated Repaint Test Instructions") + .instructions(INSTRUCTIONS) + .testUI(RepeatedRepaintTest::new) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Graphics/SmallPrimitives.java b/test/jdk/java/awt/Graphics/SmallPrimitives.java new file mode 100644 index 00000000000..7eb267cf0b9 --- /dev/null +++ b/test/jdk/java/awt/Graphics/SmallPrimitives.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.Polygon; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4411814 4298688 4205762 4524760 4067534 + * @summary Check that Graphics rendering primitives function + * correctly when fed small and degenerate shapes + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SmallPrimitives + */ + + +public class SmallPrimitives extends Panel { + + static String INSTRUCTIONS = """ + In the borderless frame next to this window there should be a + set of tiny narrow blue polygons painted next to the green rectangles. + If rectangle is vertical the corresponding polygon is painted to the right of it, + if rectangle is horizontal the polygon is painted below it. + The length of the polygon should be roughly the same as the length of the + green rectangle next to it. If size is significantly different or any of the + polygons is not painted press "Fail" otherwise press "Pass". + Note: one may consider using screen magnifier to compare sizes. + """; + + public void paint(Graphics g) { + Dimension d = getSize(); + Polygon p; + GeneralPath gp; + + g.setColor(Color.white); + g.fillRect(0, 0, d.width, d.height); + + // Reposition for horizontal tests (below) + g.translate(0, 20); + + // Reference shapes + g.setColor(Color.green); + g.fillRect(10, 7, 11, 1); + g.fillRect(10, 17, 11, 2); + g.fillRect(10, 27, 11, 1); + g.fillRect(10, 37, 11, 1); + g.fillRect(10, 47, 11, 2); + g.fillRect(10, 57, 11, 2); + g.fillRect(10, 67, 11, 1); + g.fillRect(10, 77, 11, 2); + g.fillRect(10, 87, 11, 1); + g.fillRect(10, 97, 11, 1); + g.fillRect(10, 107, 11, 1); + g.fillRect(10, 117, 6, 1); g.fillRect(20, 117, 6, 1); + + // Potentially problematic test shapes + g.setColor(Color.blue); + g.drawRect(10, 10, 10, 0); + g.drawRect(10, 20, 10, 1); + g.drawRoundRect(10, 30, 10, 0, 0, 0); + g.drawRoundRect(10, 40, 10, 0, 4, 4); + g.drawRoundRect(10, 50, 10, 1, 0, 0); + g.drawRoundRect(10, 60, 10, 1, 4, 4); + g.drawOval(10, 70, 10, 0); + g.drawOval(10, 80, 10, 1); + p = new Polygon(); + p.addPoint(10, 90); + p.addPoint(20, 90); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + p = new Polygon(); + p.addPoint(10, 100); + p.addPoint(20, 100); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + ((Graphics2D) g).draw(new Line2D.Double(10, 110, 20, 110)); + gp = new GeneralPath(); + gp.moveTo(10, 120); + gp.lineTo(15, 120); + gp.moveTo(20, 120); + gp.lineTo(25, 120); + ((Graphics2D) g).draw(gp); + + // Polygon limit tests + p = new Polygon(); + trypoly(g, p); + p.addPoint(10, 120); + trypoly(g, p); + + // Reposition for vertical tests (below) + g.translate(20, -20); + + // Reference shapes + g.setColor(Color.green); + g.fillRect(7, 10, 1, 11); + g.fillRect(17, 10, 2, 11); + g.fillRect(27, 10, 1, 11); + g.fillRect(37, 10, 1, 11); + g.fillRect(47, 10, 2, 11); + g.fillRect(57, 10, 2, 11); + g.fillRect(67, 10, 1, 11); + g.fillRect(77, 10, 2, 11); + g.fillRect(87, 10, 1, 11); + g.fillRect(97, 10, 1, 11); + g.fillRect(107, 10, 1, 11); + g.fillRect(117, 10, 1, 6); g.fillRect(117, 20, 1, 6); + + // Potentially problematic test shapes + g.setColor(Color.blue); + g.drawRect(10, 10, 0, 10); + g.drawRect(20, 10, 1, 10); + g.drawRoundRect(30, 10, 0, 10, 0, 0); + g.drawRoundRect(40, 10, 0, 10, 4, 4); + g.drawRoundRect(50, 10, 1, 10, 0, 0); + g.drawRoundRect(60, 10, 1, 10, 4, 4); + g.drawOval(70, 10, 0, 10); + g.drawOval(80, 10, 1, 10); + p = new Polygon(); + p.addPoint(90, 10); + p.addPoint(90, 20); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + p = new Polygon(); + p.addPoint(100, 10); + p.addPoint(100, 20); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + ((Graphics2D) g).draw(new Line2D.Double(110, 10, 110, 20)); + gp = new GeneralPath(); + gp.moveTo(120, 10); + gp.lineTo(120, 15); + gp.moveTo(120, 20); + gp.lineTo(120, 25); + ((Graphics2D) g).draw(gp); + + // Polygon limit tests + p = new Polygon(); + trypoly(g, p); + p.addPoint(110, 10); + trypoly(g, p); + + // Reposition for oval tests + g.translate(0, 20); + + for (int i = 0, xy = 8; i < 11; i++) { + g.setColor(Color.green); + g.fillRect(xy, 5, i, 1); + g.fillRect(5, xy, 1, i); + g.setColor(Color.blue); + g.fillOval(xy, 8, i, 1); + g.fillOval(8, xy, 1, i); + xy += i + 2; + } + + g.translate(10, 10); + for (int i = 0, xy = 9; i < 6; i++) { + g.setColor(Color.green); + g.fillRect(xy, 5, i, 2); + g.fillRect(5, xy, 2, i); + g.setColor(Color.blue); + g.fillOval(xy, 8, i, 2); + g.fillOval(8, xy, 2, i); + xy += i + 2; + } + } + + public static void trypoly(Graphics g, Polygon p) { + g.drawPolygon(p); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + g.fillPolygon(p); + g.fillPolygon(p.xpoints, p.ypoints, p.npoints); + } + + public Dimension getPreferredSize() { + return new Dimension(150, 150); + } + + public static Frame createFrame() { + Frame f = new Frame(); + SmallPrimitives sp = new SmallPrimitives(); + sp.setLocation(0, 0); + f.add(sp); + f.setUndecorated(true); + f.pack(); + return f; + } + + public static void main(String argv[]) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Small Primitives Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(SmallPrimitives::createFrame) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Graphics/TextAfterXor.java b/test/jdk/java/awt/Graphics/TextAfterXor.java new file mode 100644 index 00000000000..c9dc56d8b80 --- /dev/null +++ b/test/jdk/java/awt/Graphics/TextAfterXor.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.RenderingHints; +import java.awt.image.VolatileImage; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4505650 + * @summary Check that you can render solid text after doing XOR mode + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TextAfterXor + */ + +public class TextAfterXor extends Panel { + public static final int TESTW = 300; + public static final int TESTH = 100; + static String INSTRUCTIONS = """ + In the window called "Text After XOR Test" there should be two + composite components, at the bottom of each component the green text + "Test passes if this is green!" should be visible. + + On the top component this text should be green on all platforms. + On the bottom component it is possible that on non-Windows + platforms text can be of other color or not visible at all. + That does not constitute a problem. + + So if platform is Windows and green text appears twice or on any + other platform green text appears at least once press "Pass", + otherwise press "Fail". + """; + + VolatileImage vimg; + + public void paint(Graphics g) { + render(g); + g.drawString("(Drawing to screen)", 10, 60); + if (vimg == null) { + vimg = createVolatileImage(TESTW, TESTH); + } + do { + vimg.validate(null); + Graphics g2 = vimg.getGraphics(); + render(g2); + String not = vimg.getCapabilities().isAccelerated() ? "" : "not "; + g2.drawString("Image was " + not + "accelerated", 10, 55); + g2.drawString("(only matters on Windows)", 10, 65); + g2.dispose(); + g.drawImage(vimg, 0, TESTH, null); + } while (vimg.contentsLost()); + } + + public void render(Graphics g) { + g.setColor(Color.black); + g.fillRect(0, 0, TESTW, TESTH); + g.setColor(Color.white); + g.fillRect(5, 5, TESTW-10, TESTH-10); + + g.setColor(Color.black); + g.drawString("Test only passes if green string appears", 10, 20); + + g.setColor(Color.white); + g.setXORMode(Color.blue); + g.drawRect(30, 30, 10, 10); + g.setPaintMode(); + g.setColor(Color.green); + + ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g.drawString("Test passes if this is green!", 10, 80); + + g.setColor(Color.black); + } + + public Dimension getPreferredSize() { + return new Dimension(TESTW, TESTH*2); + } + + public static Frame createFrame() { + Frame f = new Frame("Text After XOR Test"); + f.add(new TextAfterXor()); + f.pack(); + return f; + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Text After XOR Instructions") + .instructions(INSTRUCTIONS) + .testUI(TextAfterXor::createFrame) + .build() + .awaitAndCheck(); + } +} From 1526dd81d9b5bf4abaac1546c370cf7a056d01dc Mon Sep 17 00:00:00 2001 From: Justin Lu Date: Mon, 21 Apr 2025 20:24:20 +0000 Subject: [PATCH 024/901] 8354344: Test behavior after cut-over for future ISO 4217 currency Reviewed-by: naoto --- .../java/util/Currency/ValidateISO4217.java | 135 +++++++++++++++++- .../java/util/Currency/currency.properties | 2 + 2 files changed, 132 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/util/Currency/ValidateISO4217.java b/test/jdk/java/util/Currency/ValidateISO4217.java index cd6e4f41a9f..607faefcfa4 100644 --- a/test/jdk/java/util/Currency/ValidateISO4217.java +++ b/test/jdk/java/util/Currency/ValidateISO4217.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2025, 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 @@ -26,18 +26,44 @@ * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759 * 8039317 8074350 8074351 8145952 8187946 8193552 8202026 8204269 * 8208746 8209775 8264792 8274658 8283277 8296239 8321480 8334653 + * 8354344 * @summary Validate ISO 4217 data for Currency class. * @modules java.base/java.util:open * jdk.localedata - * @run junit ValidateISO4217 + * @library /test/lib + * @run junit/othervm -DMOCKED.TIME=setup ValidateISO4217 + * @run main/othervm --patch-module java.base=${test.class.path} + * -DMOCKED.TIME=check -Djava.util.currency.data=${test.src}/currency.properties ValidateISO4217 + * @run junit/othervm --patch-module java.base=${test.class.path} + * -DMOCKED.TIME=true ValidateISO4217 + */ + +/* The run invocation order is important. The first invocation will generate + * class files for Currency that mock System.currentTimeMillis() as Long.MAX_VALUE, + * which is required by the subsequent invocations. The second invocation ensures that + * the module patch and mocked time are functioning correctly; it does not run any tests. + * The third invocation using the modded class files via a module patch allow us + * to test any cut-over dates after the transition. + * Valid MOCKED.TIME values are "setup", "check", and "true". */ import java.io.BufferedReader; import java.io.File; +import java.io.FileOutputStream; import java.io.FileReader; +import java.io.IOException; +import java.lang.classfile.ClassFile; +import java.lang.classfile.ClassTransform; +import java.lang.classfile.CodeTransform; +import java.lang.classfile.MethodTransform; +import java.lang.classfile.instruction.InvokeInstruction; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Currency; import java.util.HashSet; import java.util.List; @@ -45,6 +71,7 @@ import java.util.Set; import java.util.StringTokenizer; import java.util.TimeZone; +import java.util.stream.Stream; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -113,10 +140,102 @@ public class ValidateISO4217 { {"XK", "EUR", "978", "2"}, // Kosovo }; private static SimpleDateFormat format = null; + private static final String MODULE_PATCH_LOCATION = + System.getProperty("test.classes") + "/java/util/"; + private static final String MOCKED_TIME = System.getProperty("MOCKED.TIME"); + + // Classes that should mock System.currentTimeMillis() + private static final String[] CLASSES = + Stream.concat( + Stream.of("Currency.class"), + Arrays.stream(Currency.class.getDeclaredClasses()) + .map(c -> "Currency$" + c.getSimpleName() + ".class") + ).toArray(String[]::new); + + // "check" invocation only runs the main method (and not any tests) to determine if the + // future time checking is correct + public static void main(String[] args) { + if (MOCKED_TIME.equals("check")) { + // Check that the module patch class files exist + checkModulePatchExists(); + // Check time is mocked + // Override for PK=PKR in test/currency.properties is PKZ - simple + // Override for PW=USD in test/currency.properties is MWP - special + assertEquals("PKZ", Currency.getInstance(Locale.of("", "PK")).getCurrencyCode(), + "Mocked time / module patch not working"); + assertEquals("MWP", Currency.getInstance(Locale.of("", "PW")).getCurrencyCode(), + "Mocked time / module patch not working"); + // Properly working. Do nothing and move to third invocation + } else { + throw new RuntimeException( + "Incorrect usage of ValidateISO4217. Main method invoked without proper system property value"); + } + } + + @BeforeAll + static void setUp() throws Exception { + checkUsage(); + setUpPatchedClasses(); + setUpTestingData(); + } + + // Enforce correct usage of ValidateISO4217 + static void checkUsage() { + if (MOCKED_TIME == null + || (!MOCKED_TIME.equals("setup") && !MOCKED_TIME.equals("true"))) { + throw new RuntimeException( + "Incorrect usage of ValidateISO4217. Missing \"MOCKED.TIME\" system property"); + } + if (MOCKED_TIME.equals("true")) { + checkModulePatchExists(); + } + } + + static void checkModulePatchExists() { + // Check that the module patch class files exist + for (String className : CLASSES) { + var file = new File(MODULE_PATCH_LOCATION + className); + assertTrue(file.isFile(), "Module patch class files missing"); + } + } + + // Patch the relevant classes required for module patch + static void setUpPatchedClasses() throws IOException { + if (MOCKED_TIME.equals("setup")) { + new File(MODULE_PATCH_LOCATION).mkdirs(); + for (String s : CLASSES) { + patchClass(s); + } + } + } + + // Mock calls of System.currentTimeMillis() within Currency to Long.MAX_VALUE. + // This effectively ensures that we are always past any cut-over dates. + private static void patchClass(String name) throws IOException { + CodeTransform codeTransform = (codeBuilder, e) -> { + switch (e) { + case InvokeInstruction i when + i.owner().asInternalName().equals("java/lang/System") + && i.name().equalsString("currentTimeMillis") -> + codeBuilder.loadConstant(Long.MAX_VALUE); // mock + default -> codeBuilder.accept(e); + } + }; + MethodTransform methodTransform = MethodTransform.transformingCode(codeTransform); + ClassTransform classTransform = ClassTransform.transformingMethods(methodTransform); + ClassFile cf = ClassFile.of(); + byte[] newBytes = cf.transformClass(cf.parse( + Files.readAllBytes(Paths.get(URI.create("jrt:/java.base/java/util/" + name)))), classTransform); + + String patchedClass = MODULE_PATCH_LOCATION + name; + var file = new File(patchedClass); + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(newBytes); + } + } // Sets up the following test data: // ISO4217Codes, additionalCodes, testCurrencies, codes - @BeforeAll static void setUpTestingData() throws Exception { // These functions laterally setup 'testCurrencies' and 'codes' // at the same time @@ -169,8 +288,8 @@ private static void processColumns(StringTokenizer tokens, String country) throw if (format == null) { createDateFormat(); } - // If the cut-over already passed, use the new curency for ISO4217Codes - if (format.parse(tokens.nextToken()).getTime() < System.currentTimeMillis()) { + // If the cut-over already passed, use the new currency for ISO4217Codes + if (format.parse(tokens.nextToken()).getTime() < currentTimeMillis()) { currency = tokens.nextToken(); numeric = tokens.nextToken(); minorUnit = tokens.nextToken(); @@ -320,4 +439,10 @@ private static String getSetDiffs(Set jreCurrencies, Set tes bldr.append("\n"); return bldr.toString(); } + + // Either the current system time, or a mocked value equal to Long.MAX_VALUE + static long currentTimeMillis() { + var mocked = MOCKED_TIME.equals("true"); + return mocked ? Long.MAX_VALUE : System.currentTimeMillis(); + } } diff --git a/test/jdk/java/util/Currency/currency.properties b/test/jdk/java/util/Currency/currency.properties index ff5259e5933..0420d9cb501 100644 --- a/test/jdk/java/util/Currency/currency.properties +++ b/test/jdk/java/util/Currency/currency.properties @@ -13,6 +13,8 @@ MD=MDD,555,7 ME=MEE,555,8 MF=MFF,555,9 NO=EUR ,978 ,2, 2099-01-01T00:00:00 +PK=PKZ,999,0,3000-01-01T00:00:00 +PW=MWP,999,0,5000-01-01T00:00:00 SB=EUR,111,2, 2099-01-01T00:00:00 US=euR,978,2,2001-01-01T00:00:00 ZZ\t=\tZZZ\t,\t999\t,\t3 From f7155183d7f7c6fcea2090f906de69e02973a6d9 Mon Sep 17 00:00:00 2001 From: Harshitha Onkar Date: Mon, 21 Apr 2025 22:35:17 +0000 Subject: [PATCH 025/901] 8353011: Open source Swing JButton tests - Set 1 Reviewed-by: serb --- test/jdk/javax/swing/JButton/bug4151763.java | 94 +++++++++++++++ test/jdk/javax/swing/JButton/bug4415505.java | 77 +++++++++++++ test/jdk/javax/swing/JButton/bug4978274.java | 108 ++++++++++++++++++ .../javax/swing/JRadioButton/bug4673850.java | 104 +++++++++++++++++ test/jdk/javax/swing/JTable/bug4188504.java | 71 ++++++++++++ 5 files changed, 454 insertions(+) create mode 100644 test/jdk/javax/swing/JButton/bug4151763.java create mode 100644 test/jdk/javax/swing/JButton/bug4415505.java create mode 100644 test/jdk/javax/swing/JButton/bug4978274.java create mode 100644 test/jdk/javax/swing/JRadioButton/bug4673850.java create mode 100644 test/jdk/javax/swing/JTable/bug4188504.java diff --git a/test/jdk/javax/swing/JButton/bug4151763.java b/test/jdk/javax/swing/JButton/bug4151763.java new file mode 100644 index 00000000000..d04b623ec4e --- /dev/null +++ b/test/jdk/javax/swing/JButton/bug4151763.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4151763 + * @summary Tests that button icon is not drawn upon button border + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @run main/manual bug4151763 + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.UIManager; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; +import jtreg.SkippedException; + +public class bug4151763 { + private static final int IMAGE_SIZE = 150; + private static final String INSTRUCTIONS = """ + Verify that image icon is NOT painted outside + the black rectangle. + + If above is true press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4151763::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + } catch (Exception e) { + throw new SkippedException("Unsupported LaF", e); + } + + JFrame frame = new JFrame("bug4151763"); + final JButton b = new JButton(createImageIcon()); + b.setBorder(new CompoundBorder( + new EmptyBorder(20, 20, 20, 20), + new LineBorder(Color.BLACK))); + b.setPreferredSize(new Dimension(100, 100)); + + frame.setLayout(new FlowLayout()); + frame.add(b); + frame.setSize(400, 300); + return frame; + } + + private static ImageIcon createImageIcon() { + BufferedImage redImg = new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, + BufferedImage.TYPE_INT_RGB); + Graphics2D g = redImg.createGraphics(); + g.setColor(Color.RED); + g.fillRect(0, 0, IMAGE_SIZE, IMAGE_SIZE); + g.dispose(); + return new ImageIcon(redImg); + } +} diff --git a/test/jdk/javax/swing/JButton/bug4415505.java b/test/jdk/javax/swing/JButton/bug4415505.java new file mode 100644 index 00000000000..58ba56e1b74 --- /dev/null +++ b/test/jdk/javax/swing/JButton/bug4415505.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4415505 + * @requires (os.family == "windows") + * @summary Tests JButton appearance under Windows LAF + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4415505 + */ + +import java.awt.FlowLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JToggleButton; +import javax.swing.UIManager; + +public class bug4415505 { + private static final String INSTRUCTIONS = """ + +

This test is for Windows LaF. + Press the button named "Button" using mouse and check that it has + "pressed" look. It should look like the selected toggle button + near it.

+ +

If above is true press PASS else FAIL.

+ + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(5) + .columns(40) + .testUI(bug4415505::createAndShowUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JButton button = new JButton("Button"); + button.setFocusPainted(false); + JToggleButton tbutton = new JToggleButton("ToggleButton"); + tbutton.setSelected(true); + + JFrame jFrame = new JFrame("bug4415505"); + jFrame.setLayout(new FlowLayout(FlowLayout.CENTER)); + jFrame.add(button); + jFrame.add(tbutton); + jFrame.setSize(300, 100); + return jFrame; + } +} diff --git a/test/jdk/javax/swing/JButton/bug4978274.java b/test/jdk/javax/swing/JButton/bug4978274.java new file mode 100644 index 00000000000..6b152259caa --- /dev/null +++ b/test/jdk/javax/swing/JButton/bug4978274.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4978274 + * @summary Tests that JButton is painted with same visible height + * as toggle buttons + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4978274 + */ + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JToggleButton; +import javax.swing.UIManager; +import javax.swing.border.EmptyBorder; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.plaf.metal.OceanTheme; + +public class bug4978274 { + private static final String INSTRUCTIONS = """ + The toggle buttons must be painted to the same visible + height as button. In addition to that verify the following: + + a) All three buttons - "Button", "Toggle Btn" and + "Selected Toggle Btn" have the same border. + + b) Verify that when "Button" is pressed and moused over + it has the EXACT same border as "Toggle Btn" and + "Selected Toggle Btn" on press & mouse over. + + c) Click to the test window (panel) to disable/enable all + three buttons. In disabled state verify that all three + buttons have the exact same border. + + If all of the above conditions are true press PASS, else FAIL. + """; + + public static void main(String[] args) throws Exception { + MetalLookAndFeel.setCurrentTheme(new OceanTheme()); + UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(createAndShowUI()) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4978274"); + frame.setLayout(new BorderLayout()); + + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + panel.setBorder(new EmptyBorder(12, 12, 12, 12)); + JButton jButton = new JButton("Button"); + JToggleButton jToggleButton = new JToggleButton("Selected Toggle Btn"); + jToggleButton.setSelected(true); + + panel.add(jButton); + panel.add(new JToggleButton("Toggle Btn")); + panel.add(jToggleButton); + + panel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent event) { + jButton.setEnabled(!jButton.isEnabled()); + jToggleButton.setEnabled(jButton.isEnabled()); + for(int i = 0; i < panel.getComponentCount(); i++) { + panel.getComponent(i).setEnabled(jButton.isEnabled()); + } + } + }); + + frame.add(panel); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/javax/swing/JRadioButton/bug4673850.java b/test/jdk/javax/swing/JRadioButton/bug4673850.java new file mode 100644 index 00000000000..4f9058e978e --- /dev/null +++ b/test/jdk/javax/swing/JRadioButton/bug4673850.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4673850 + * @summary Tests that JRadioButton and JCheckBox checkmarks are painted entirely + * inside circular/rectangle checkboxes for Motif LaF. + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException + * @run main/manual bug4673850 + */ + +import java.awt.FlowLayout; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JRadioButton; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import jtreg.SkippedException; + +public class bug4673850 { + private static final String INSTRUCTIONS = """ + + + + + +

This test is for Motif LaF.

+ +

+ When the test starts, you'll see 2 radio buttons and 2 check boxes + with the checkmarks painted.

+ +

+ Ensure that all the button's checkmarks are painted entirely + within the circular/rectangle checkbox, NOT over them or outside them. +

+ + """; + + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + } catch (Exception e) { + throw new SkippedException("Unsupported LaF", e); + } + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(10) + .columns(45) + .testUI(createAndShowUI()) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4673850"); + frame.setLayout(new FlowLayout()); + + JRadioButton rb = new JRadioButton("RadioButt"); + rb.setSelected(true); + frame.add(rb); + JRadioButton rb2 = new JRadioButton("RadioButt"); + rb2.setHorizontalTextPosition(SwingConstants.LEFT); + rb2.setSelected(true); + frame.add(rb2); + + JCheckBox cb = new JCheckBox("CheckBox"); + cb.setSelected(true); + frame.add(cb); + JCheckBox cb2 = new JCheckBox("CheckBox"); + cb2.setHorizontalTextPosition(SwingConstants.LEFT); + cb2.setSelected(true); + frame.add(cb2); + frame.setSize(200, 150); + return frame; + } +} \ No newline at end of file diff --git a/test/jdk/javax/swing/JTable/bug4188504.java b/test/jdk/javax/swing/JTable/bug4188504.java new file mode 100644 index 00000000000..b58ee7def03 --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4188504.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4188504 + * @summary setResizable for specified column. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4188504 + */ + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +public class bug4188504 { + private static final String INSTRUCTIONS = """ + 1. A table is displayed with 3 columns - A, B, C. + + 2. Try to resize second column of table (Move mouse to the position + between "B" and "C" headers, press left mouse button and move to + right/left). + PLEASE NOTE: You may be able to swap the columns but make sure the + width of column B stays the same. + + 3. If the second column does not change its width then press PASS + otherwise press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(createAndShowUI()) + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame jFrame = new JFrame("bug4188504"); + JTable tableView = new JTable(4, 3); + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tableView.getColumnModel().getColumn(1).setResizable(false); + + jFrame.add(new JScrollPane(tableView)); + jFrame.setSize(300, 150); + return jFrame; + } +} From 9a0cff692d6f96b8c89b1510cd2b4b1a8e318b6e Mon Sep 17 00:00:00 2001 From: Harshitha Onkar Date: Mon, 21 Apr 2025 23:11:03 +0000 Subject: [PATCH 026/901] 8353942: Open source Swing Tests - Set 5 Reviewed-by: serb, dnguyen --- .../DataTransfer/DragOverFeedbackTest.java | 117 +++++++++++++++++ .../ListDragOverFeedbackTest.java | 119 ++++++++++++++++++ .../javax/swing/DataTransfer/bug4655513.java | 106 ++++++++++++++++ .../swing/SwingUtilities/bug4369355.java | 87 +++++++++++++ .../swing/SwingUtilities/bug4967768.java | 66 ++++++++++ 5 files changed, 495 insertions(+) create mode 100644 test/jdk/javax/swing/DataTransfer/DragOverFeedbackTest.java create mode 100644 test/jdk/javax/swing/DataTransfer/ListDragOverFeedbackTest.java create mode 100644 test/jdk/javax/swing/DataTransfer/bug4655513.java create mode 100644 test/jdk/javax/swing/SwingUtilities/bug4369355.java create mode 100644 test/jdk/javax/swing/SwingUtilities/bug4967768.java diff --git a/test/jdk/javax/swing/DataTransfer/DragOverFeedbackTest.java b/test/jdk/javax/swing/DataTransfer/DragOverFeedbackTest.java new file mode 100644 index 00000000000..824f651a1a0 --- /dev/null +++ b/test/jdk/javax/swing/DataTransfer/DragOverFeedbackTest.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4514071 + * @summary Tests that JTable, JList and JTree provide drag-over feedback. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DragOverFeedbackTest + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.datatransfer.DataFlavor; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.TransferHandler; + +public class DragOverFeedbackTest { + private static final String INSTRUCTIONS = """ + This test is designed to make sure that JTable, JTree, and JList + provide visual feedback when a DnD drag operation occurs over them. + + Click on the label where it says "DRAG FROM HERE" and begin dragging. + Drag over each of the three components (JTable, JTree, JList). + While you're dragging over them, they should visually indicate the + location where a drop would occur. This visual indication may use the + selection but could be some other visual. + + If above is true press PASS else press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(DragOverFeedbackTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static final TransferHandler handler = new TransferHandler() { + public boolean canImport(JComponent comp, DataFlavor[] flavors) { + return true; + } + }; + + private static JFrame createTestUI() { + JFrame frame = new JFrame("DragOverFeedbackTest"); + final JLabel label = new JLabel("DRAG FROM HERE"); + label.setPreferredSize(new Dimension(400, 25)); + label.setTransferHandler(new TransferHandler("text")); + label.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + label.getTransferHandler().exportAsDrag(label, me, TransferHandler.COPY); + } + }); + JTable table = new JTable( + new String[][] {{"one"}, {"two"}, {"three"}, {"four"}}, + new String[] {"1"}); + table.setRowSelectionInterval(1, 1); + table.setTransferHandler(handler); + + JList list = new JList(new String[] {"one", "two", "three", "four"}); + list.setSelectedIndex(1); + list.setTransferHandler(handler); + + JTree tree = new JTree(); + tree.setSelectionRow(1); + tree.setTransferHandler(handler); + + frame.add(label, BorderLayout.NORTH); + + JPanel wrapper = new JPanel(); + wrapper.setLayout(new GridLayout(3, 1)); + table.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + wrapper.add(table); + list.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + wrapper.add(list); + tree.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + wrapper.add(tree); + frame.add(wrapper); + frame.setSize(500, 500); + return frame; + } +} diff --git a/test/jdk/javax/swing/DataTransfer/ListDragOverFeedbackTest.java b/test/jdk/javax/swing/DataTransfer/ListDragOverFeedbackTest.java new file mode 100644 index 00000000000..b41327a106e --- /dev/null +++ b/test/jdk/javax/swing/DataTransfer/ListDragOverFeedbackTest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4546134 + * @summary Tests that JList shows the right drop location when it has multiple columns. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListDragOverFeedbackTest + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.datatransfer.DataFlavor; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.TransferHandler; + +public class ListDragOverFeedbackTest { + private static final String INSTRUCTIONS = """ + JList should provide visual feedback when a DnD drag operation is + occurring over it. This test is to check that it provides the + feedback about the drop location correctly. + + Click on the label where it says "DRAG FROM HERE" and begin dragging. + Drag over each column in each of the three JLists and make sure that + the drop location indicated is appropriate for the mouse location. For + instance, if the mouse is in the first column, the drop location should + also be indicated in that first column. + + If above is true press PASS else press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(ListDragOverFeedbackTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static final TransferHandler handler = new TransferHandler() { + public boolean canImport(JComponent comp, DataFlavor[] flavors) { + return true; + } + }; + + private static JFrame createTestUI() { + String[] vals = new String[] { + "one", "two", "three", "four", "five", "six", "seven", "eight", + "nine", "ten", "eleven", "twelve", "thirteen", "fourteen"}; + + JFrame frame = new JFrame("ListDragOverFeedbackTest"); + final JLabel label = new JLabel("DRAG FROM HERE"); + label.setPreferredSize(new Dimension(400, 25)); + label.setTransferHandler(new TransferHandler("text")); + label.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + label.getTransferHandler().exportAsDrag(label, me, + TransferHandler.COPY); + } + }); + + JList list1 = new JList(vals); + list1.setTransferHandler(handler); + list1.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + + JList list2 = new JList(vals); + list2.setLayoutOrientation(JList.VERTICAL_WRAP); + list2.setTransferHandler(handler); + list2.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + + JList list3 = new JList(vals); + list3.setLayoutOrientation(JList.HORIZONTAL_WRAP); + list3.setTransferHandler(handler); + list3.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + + JPanel wrapper = new JPanel(); + wrapper.setLayout(new GridLayout(3, 1)); + wrapper.add(list1); + wrapper.add(list2); + wrapper.add(list3); + + frame.add(label, BorderLayout.NORTH); + frame.add(wrapper); + frame.setSize(400, 500); + return frame; + } +} diff --git a/test/jdk/javax/swing/DataTransfer/bug4655513.java b/test/jdk/javax/swing/DataTransfer/bug4655513.java new file mode 100644 index 00000000000..c9f49f98939 --- /dev/null +++ b/test/jdk/javax/swing/DataTransfer/bug4655513.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key headful + * @bug 4655513 + * @summary TransferHandler doesn't recognize ACTION_LINK + as a valid drop action + * @library /javax/swing/regtesthelpers + * @build Util + * @run main bug4655513 + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.StringSelection; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; + +public class bug4655513 { + private static final String LINK_URL = "http://www.example.com/"; + private static volatile JEditorPane editor; + private static volatile JLabel dragSource; + private static JFrame frame; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(bug4655513::createAndShowGUI); + robot.waitForIdle(); + robot.delay(1000); + + Point dragStartLoc = Util.getCenterPoint(dragSource); + Point dragEndLoc = Util.getCenterPoint(editor); + robot.mouseMove(dragStartLoc.x, dragStartLoc.y); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + for (int y = dragStartLoc.y; y < dragEndLoc.y; y += 3) { + robot.mouseMove(dragStartLoc.x, y); + robot.delay(50); + } + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(500); + + SwingUtilities.invokeAndWait(() -> { + if (!editor.getText().contains(LINK_URL)) { + throw new RuntimeException("Test Failed! Drag & Drop did not work."); + } + }); + } finally { + SwingUtilities.invokeAndWait(frame::dispose); + } + } + + private static void createAndShowGUI() { + frame = new JFrame("Bug4655513 - Data Transfer"); + dragSource = new JLabel("To Test DnD, drag this label."); + dragSource.setForeground(Color.RED); + dragSource.setPreferredSize(new Dimension(250, 50)); + frame.add(dragSource, BorderLayout.NORTH); + + editor = new JEditorPane("text/plain", "Drop here."); + editor.setPreferredSize(new Dimension(250, 50)); + frame.add(new JScrollPane(editor), BorderLayout.CENTER); + + DragSource ds = new DragSource(); + DragGestureRecognizer rec = + ds.createDefaultDragGestureRecognizer(dragSource, + DnDConstants.ACTION_LINK, + dge -> dge.startDrag(null, new StringSelection(LINK_URL))); + frame.setSize(300, 150); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/SwingUtilities/bug4369355.java b/test/jdk/javax/swing/SwingUtilities/bug4369355.java new file mode 100644 index 00000000000..f55d888ef31 --- /dev/null +++ b/test/jdk/javax/swing/SwingUtilities/bug4369355.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key headful + * @bug 4369355 + * @summary To verify if SwingUtilities.convertPointToScreen() (for invisible frame) + * and SwingUtilities.convertPointFromScreen() return correct values + * @run main bug4369355 + */ + +import java.awt.Point; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class bug4369355 { + private static JFrame frame; + + private static volatile Point frameToScreenLoc; + private static volatile Point frameFromScreenLoc; + + private static final Point EXPECTED_FROM_SCREEN_LOC = new Point(0, 0); + private static final Point EXPECTED_TO_SCREEN_LOC = new Point(100, 100); + + public static void main (String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug4369355"); + frame.setBounds(100, 100, 100, 100); + }); + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + frameToScreenLoc = new Point(0, 0); + SwingUtilities.convertPointToScreen(frameToScreenLoc, frame); + }); + robot.delay(100); + + if (!frameToScreenLoc.equals(EXPECTED_TO_SCREEN_LOC)) { + throw new RuntimeException("SwingUtilities.convertPointToScreen()" + + " returns incorrect point " + frameToScreenLoc + "\n" + + "Should be " + EXPECTED_TO_SCREEN_LOC); + } + + SwingUtilities.invokeAndWait(() -> frame.setVisible(true)); + robot.delay(500); + + SwingUtilities.invokeAndWait(() -> { + frameFromScreenLoc = frame.getLocationOnScreen(); + SwingUtilities.convertPointFromScreen(frameFromScreenLoc, frame); + }); + robot.delay(100); + + if (!frameFromScreenLoc.equals(EXPECTED_FROM_SCREEN_LOC)) { + throw new RuntimeException("SwingUtilities.convertPointFromScreen()" + + " returns incorrect point " + frameFromScreenLoc + "\n" + + "Should be " + EXPECTED_FROM_SCREEN_LOC); + } + } finally { + SwingUtilities.invokeAndWait(frame::dispose); + } + } +} diff --git a/test/jdk/javax/swing/SwingUtilities/bug4967768.java b/test/jdk/javax/swing/SwingUtilities/bug4967768.java new file mode 100644 index 00000000000..43f9f7cabfb --- /dev/null +++ b/test/jdk/javax/swing/SwingUtilities/bug4967768.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4967768 + * @requires (os.family != "mac") + * @summary Tests that underline is painted correctly in mnemonics + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4967768 + */ + +import java.awt.Font; +import javax.swing.JButton; +import javax.swing.JPanel; + +public class bug4967768 { + private static final String INSTRUCTIONS = """ + When the test starts you'll see a button "Oops" + with the "p" letter underlined at the bottom + of the instruction frame. + + Ensure the underline cuts through the descender + of letter "p", i.e. the underline is painted + not below the letter but below the baseline. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .splitUIBottom(bug4967768::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JPanel createTestUI() { + JPanel panel = new JPanel(); + JButton but = new JButton("Oops"); + but.setFont(new Font("Dialog", Font.BOLD, 24)); + but.setMnemonic('p'); + panel.add(but); + return panel; + } +} From 47f78a7529a2b290a07394e053bcfaff4907b7e5 Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Tue, 22 Apr 2025 00:27:25 +0000 Subject: [PATCH 027/901] 8354990: Improve negative tests coverage for jpackage signing 8354989: Bug in MacCertificate class Reviewed-by: almatvee --- .../jdk/jpackage/internal/MacAppBundler.java | 2 +- .../jdk/jpackage/internal/MacCertificate.java | 18 +- .../jdk/jpackage/internal/MacPkgBundler.java | 2 +- .../helpers/jdk/jpackage/test/MacSign.java | 375 +++++++++++++++--- .../jdk/jpackage/test/MacSignVerify.java | 226 +++++++++++ .../tools/jpackage/macosx/MacSignTest.java | 193 ++++++++- .../jpackage/macosx/base/SigningBase.java | 248 +++++------- 7 files changed, 823 insertions(+), 241 deletions(-) create mode 100644 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java index 5da01aa293c..733321dec46 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java @@ -74,7 +74,7 @@ public MacAppBundler() { } if (result != null) { - MacCertificate certificate = new MacCertificate(result); + MacCertificate certificate = new MacCertificate(result, keychain); if (!certificate.isValid()) { Log.error(MessageFormat.format(I18N.getString( diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacCertificate.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacCertificate.java index 90f3a8c765b..c9dab481e0e 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacCertificate.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacCertificate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, 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 @@ -39,21 +39,25 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.HexFormat; import java.util.List; import java.util.Locale; -import java.util.HexFormat; +import java.util.Objects; +import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; public final class MacCertificate { private final String certificate; + private final Optional keychainName; - public MacCertificate(String certificate) { - this.certificate = certificate; + public MacCertificate(String certificate, String keychainName) { + this.certificate = Objects.requireNonNull(certificate); + this.keychainName = Optional.ofNullable(keychainName); } public boolean isValid() { - return verifyCertificate(this.certificate); + return verifyCertificate(); } public static String findCertificateKey(String keyPrefix, String teamName, @@ -295,7 +299,7 @@ private Date findCertificateDate(String filename) { return result; } - private boolean verifyCertificate(String certificate) { + private boolean verifyCertificate() { boolean result = false; try { @@ -303,7 +307,7 @@ private boolean verifyCertificate(String certificate) { Date certificateDate = null; try { - file = getFindCertificateOutputPEM(certificate, null); + file = getFindCertificateOutputPEM(certificate, keychainName.orElse(null)); if (file != null) { certificateDate = findCertificateDate( diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java index 2aca9bd0e1f..8328fa07851 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java @@ -130,7 +130,7 @@ public class MacPkgBundler extends MacBaseInstallerBundler { } if (result != null) { - MacCertificate certificate = new MacCertificate(result); + MacCertificate certificate = new MacCertificate(result, keychain); if (!certificate.isValid()) { Log.error(MessageFormat.format( diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java index 1d5dd16fe37..67ac921b919 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java @@ -29,9 +29,9 @@ import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toSet; -import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction; import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier; +import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.UncheckedIOException; @@ -42,7 +42,9 @@ import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; import java.security.MessageDigest; +import java.security.cert.CertificateExpiredException; import java.security.cert.CertificateFactory; +import java.security.cert.CertificateNotYetValidException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Base64; @@ -63,6 +65,7 @@ import javax.naming.ldap.Rdn; import jdk.jpackage.internal.util.function.ExceptionBox; import jdk.jpackage.internal.util.function.ThrowingConsumer; +import jdk.jpackage.internal.util.function.ThrowingSupplier; /** * Utilities to setup identities and keychains for sign testing. @@ -393,15 +396,52 @@ Keychain createKeyPair(String name) { } List findCertificates() { - final var in = new ByteArrayInputStream( - security("find-certificate", "-ap", name).saveOutput().execute().getOutput().stream().collect(joining("\n")).getBytes(StandardCharsets.UTF_8)); - return toFunction(CERT_FACTORY::generateCertificates).apply(in).stream().map(X509Certificate.class::cast).toList(); + final List certs = new ArrayList<>(); + try (final var in = new BufferedInputStream(new ByteArrayInputStream( + security("find-certificate", "-ap", name).executeAndGetOutput().stream().collect(joining("\n")).getBytes(StandardCharsets.UTF_8)))) { + while (in.available() > 0) { + final X509Certificate cert; + try { + cert = (X509Certificate) CERT_FACTORY.generateCertificate(in); + } catch (Exception ex) { + TKit.trace("Failed to parse certificate data: " + ex); + continue; + } + certs.add(cert); + } + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + return certs; } public static void addToSearchList(Collection keychains) { security("list-keychains", "-d", "user", "-s", "login.keychain") - .addArguments(keychains.stream().map(Keychain::name).toList()) - .execute(); + .addArguments(keychains.stream().map(Keychain::name).toList()) + .execute(); + } + + public static void withAddedKeychains(Collection keychains, Runnable runnable) { + final var curKeychains = activeKeychainFiles(); + addToSearchList(keychains); + try { + runnable.run(); + } finally { + security("list-keychains", "-d", "user", "-s") + .addArguments(curKeychains.stream().map(Path::toString).toList()) + .execute(); + } + } + + private static List activeKeychainFiles() { + // $ security list-keychains + // "/Users/alexeysemenyuk/Library/Keychains/login.keychain-db" + // "/Library/Keychains/System.keychain" + return security("list-keychains", "-d", "user").executeAndGetOutput().stream().map(line -> { + return line.stripLeading(); + }).filter(line -> { + return line.charAt(0) == '"' && line.charAt(line.length() - 1) == '"'; + }).map(line -> line.substring(1, line.length() - 1)).map(Path::of).toList(); } private Executor createExecutor(String command) { @@ -409,40 +449,57 @@ private Executor createExecutor(String command) { } } - record ResolvedCertificateRequest(CertificateRequest request, X509Certificate cert, VerifyStatus verifyStatus) { + private enum VerifyStatus { + VERIFY_OK, + VERIFY_EXPIRED, + VERIFY_ERROR, + VERIFY_UNTRUSTED, + VERIFY_EXPIRED_UNTRUSTED, + UNVERIFIED + } + + private record ResolvedCertificateRequest(InstalledCertificate installed, X509Certificate cert, VerifyStatus verifyStatus) { ResolvedCertificateRequest { - Objects.requireNonNull(request); + Objects.requireNonNull(installed); Objects.requireNonNull(cert); Objects.requireNonNull(verifyStatus); } - enum VerifyStatus { - VERIFY_OK, - VERIFY_ERROR, - UNVERIFIED + CertificateRequest request() { + if (!verified()) { + throw new IllegalStateException(); + } + return new CertificateRequest(installed.name(), installed.type(), installed.days(), installed.expired(), + Set.of(VerifyStatus.VERIFY_OK, VerifyStatus.VERIFY_EXPIRED).contains(verifyStatus)); } ResolvedCertificateRequest(X509Certificate cert) { - this(new CertificateRequest(cert), cert, VerifyStatus.UNVERIFIED); + this(new InstalledCertificate(cert), cert, VerifyStatus.UNVERIFIED); } - ResolvedCertificateRequest copyVerified(boolean verifySuccess) { - return new ResolvedCertificateRequest(request, cert, - verifySuccess ? VerifyStatus.VERIFY_OK : VerifyStatus.VERIFY_ERROR); + ResolvedCertificateRequest copyVerified(VerifyStatus verifyStatus) { + if (verifyStatus == VerifyStatus.UNVERIFIED) { + throw new IllegalArgumentException(); + } + return new ResolvedCertificateRequest(installed, cert, verifyStatus); + } + + private boolean verified() { + return verifyStatus != VerifyStatus.UNVERIFIED; } } - record CertificateStats(List allResolvedCertificateRequests, - List allCertificates, List knownCertificateRequests, + private record CertificateStats(List allResolvedCertificateRequests, + List knownCertificateRequests, Map unmappedCertificates) { - private static CertificateStats get(KeychainWithCertsSpec spec) { + static CertificateStats get(KeychainWithCertsSpec spec) { return CACHE.computeIfAbsent(spec, CertificateStats::create); } Map> mapKnownCertificateRequests() { return knownCertificateRequests.stream().collect(groupingBy(x -> x, mapping(certificateRequest -> { - return allResolvedCertificateRequests.stream().filter(v -> { + return allVerifiedResolvedCertificateRequest().filter(v -> { return v.request().equals(certificateRequest); }).map(ResolvedCertificateRequest::cert); }, flatMapping(x -> x, toList())))); @@ -450,15 +507,19 @@ Map> mapKnownCertificateRequests() { Set verifyFailedCertificateRequests() { return knownCertificateRequests.stream().filter(certificateRequest -> { - return allResolvedCertificateRequests.stream().anyMatch(v -> { - return v.request().equals(certificateRequest) && v.verifyStatus() == ResolvedCertificateRequest.VerifyStatus.VERIFY_ERROR; + return allVerifiedResolvedCertificateRequest().anyMatch(v -> { + return v.request().equals(certificateRequest) && v.verifyStatus() != certificateRequest.expectedVerifyStatus(); }); }).collect(toSet()); } Set unmappedCertificateRequests() { return Comm.compare(Set.copyOf(knownCertificateRequests), - allResolvedCertificateRequests.stream().map(ResolvedCertificateRequest::request).collect(toSet())).unique1(); + allVerifiedResolvedCertificateRequest().map(ResolvedCertificateRequest::request).collect(toSet())).unique1(); + } + + private Stream allVerifiedResolvedCertificateRequest() { + return allResolvedCertificateRequests.stream().filter(ResolvedCertificateRequest::verified); } private static CertificateStats create(KeychainWithCertsSpec spec) { @@ -482,24 +543,24 @@ private static CertificateStats create(KeychainWithCertsSpec spec) { continue; } - if (spec.certificateRequests().contains(resolvedCertificateRequest.request)) { + if (spec.certificateRequests().stream().anyMatch(resolvedCertificateRequest.installed()::match)) { final var certFile = workDir.resolve(CertificateHash.of(cert).toString() + ".pem"); - final var verifySuccess = verifyCertificate(resolvedCertificateRequest, spec.keychain(), certFile); - resolvedCertificateRequest = resolvedCertificateRequest.copyVerified(verifySuccess); + final var verifyStatus = verifyCertificate(resolvedCertificateRequest, spec.keychain(), certFile); + resolvedCertificateRequest = resolvedCertificateRequest.copyVerified(verifyStatus); } allResolvedCertificateRequests.add(resolvedCertificateRequest); } }); - return new CertificateStats(allResolvedCertificateRequests, List.copyOf(allCertificates), + return new CertificateStats(allResolvedCertificateRequests, List.copyOf(spec.certificateRequests()), unmappedCertificates); } private static final Map CACHE = new ConcurrentHashMap<>(); } - record PemData(String label, byte[] data) { + private record PemData(String label, byte[] data) { PemData { Objects.requireNonNull(label); Objects.requireNonNull(data); @@ -532,23 +593,41 @@ private static String frame(String str) { return String.format("-----%s-----\n", Objects.requireNonNull(str)); } - private final static Base64.Encoder ENCODER = Base64.getMimeEncoder(64, "\n".getBytes()); + private static final Base64.Encoder ENCODER = Base64.getMimeEncoder(64, "\n".getBytes()); } - public record CertificateHash(byte[] value) { + public enum DigestAlgorithm { + SHA1(20, () -> MessageDigest.getInstance("SHA-1")), + SHA256(32, () -> MessageDigest.getInstance("SHA-256")); + + DigestAlgorithm(int hashLength, ThrowingSupplier createDigest) { + this.hashLength = hashLength; + this.createDigest = createDigest; + } + + final int hashLength; + final ThrowingSupplier createDigest; + } + + public record CertificateHash(byte[] value, DigestAlgorithm alg) { public CertificateHash { Objects.requireNonNull(value); - if (value.length != 20) { - throw new IllegalArgumentException("Invalid SHA-1 hash"); + Objects.requireNonNull(alg); + if (value.length != alg.hashLength) { + throw new IllegalArgumentException(String.format("Invalid %s hash", alg)); } } public static CertificateHash of(X509Certificate cert) { + return of(cert, DigestAlgorithm.SHA1); + } + + public static CertificateHash of(X509Certificate cert, DigestAlgorithm alg) { return new CertificateHash(toSupplier(() -> { - final MessageDigest md = MessageDigest.getInstance("SHA-1"); + final MessageDigest md = alg.createDigest.get(); md.update(cert.getEncoded()); return md.digest(); - }).get()); + }).get(), alg); } @Override @@ -601,14 +680,61 @@ String verifyPolicy() { private final String verifyPolicy; } - public record CertificateRequest(String name, CertificateType type, int days) implements Comparable{ + public enum StandardCertificateNamePrefix { + CODE_SIGND("Developer ID Application: "), + INSTALLER("Developer ID Installer: "); + + StandardCertificateNamePrefix(String value) { + this.value = Objects.requireNonNull(value); + } + + public String value() { + return value; + } + + private final String value; + } + + public record NameWithPrefix(String prefix, String name) { + public NameWithPrefix { + Objects.requireNonNull(prefix); + Objects.requireNonNull(name); + } + } + + public record CertificateRequest(String name, CertificateType type, int days, boolean expired, boolean trusted) + implements Comparable { + public CertificateRequest { Objects.requireNonNull(name); Objects.requireNonNull(type); + if (days <= 0) { + throw new IllegalArgumentException(); + } } - CertificateRequest(X509Certificate cert) { - this(getSubjectCN(cert), getType(cert), getDurationInDays(cert)); + public String shortName() { + return nameWithPrefix().map(NameWithPrefix::name).orElseThrow(); + } + + public Optional nameWithPrefix() { + return Stream.of(StandardCertificateNamePrefix.values()).map(StandardCertificateNamePrefix::value).filter(prefix -> { + return name.startsWith(prefix); + }).map(prefix -> { + return new NameWithPrefix(prefix, name.substring(prefix.length())); + }).findAny(); + } + + VerifyStatus expectedVerifyStatus() { + if (expired && !trusted) { + return VerifyStatus.VERIFY_EXPIRED_UNTRUSTED; + } else if (!trusted) { + return VerifyStatus.VERIFY_UNTRUSTED; + } else if (expired) { + return VerifyStatus.VERIFY_EXPIRED; + } else { + return VerifyStatus.VERIFY_OK; + } } @Override @@ -623,8 +749,8 @@ public Builder userName(String v) { return this; } - public Builder commonName(String v) { - commonName = v; + public Builder subjectCommonName(String v) { + subjectCommonName = v; return this; } @@ -638,8 +764,26 @@ public Builder days(int v) { return this; } + public Builder expired(boolean v) { + expired = v; + return this; + } + + public Builder expired() { + return expired(true); + } + + public Builder trusted(boolean v) { + trusted = v; + return this; + } + + public Builder untrusted() { + return trusted(false); + } + public CertificateRequest create() { - return new CertificateRequest(validatedCN(), type, days); + return new CertificateRequest(validatedCN(), type, days, expired, trusted); } private String validatedUserName() { @@ -647,13 +791,13 @@ private String validatedUserName() { } private String validatedCN() { - return Optional.ofNullable(commonName).orElseGet(() -> { + return Optional.ofNullable(subjectCommonName).orElseGet(() -> { switch (type) { case CODE_SIGN -> { - return "Developer ID Application: " + validatedUserName(); + return StandardCertificateNamePrefix.CODE_SIGND.value() + validatedUserName(); } case INSTALLER -> { - return "Developer ID Installer: " + validatedUserName(); + return StandardCertificateNamePrefix.INSTALLER.value() + validatedUserName(); } default -> { throw new UnsupportedOperationException(); @@ -663,9 +807,41 @@ private String validatedCN() { } private String userName; - private String commonName; // CN + private String subjectCommonName; // CN private CertificateType type = CertificateType.CODE_SIGN; private int days = 365; + private boolean expired; + private boolean trusted = true; + } + + private static final Comparator COMPARATOR = + Comparator.comparing(CertificateRequest::name) + .thenComparing(Comparator.comparing(CertificateRequest::type)) + .thenComparing(Comparator.comparingInt(CertificateRequest::days)) + .thenComparing(Comparator.comparing(CertificateRequest::expired, Boolean::compare)) + .thenComparing(Comparator.comparing(CertificateRequest::trusted, Boolean::compare)); + } + + private record InstalledCertificate(String name, CertificateType type, int days, boolean expired) implements Comparable { + InstalledCertificate { + Objects.requireNonNull(name); + Objects.requireNonNull(type); + if (days <= 0) { + throw new IllegalArgumentException(); + } + } + + InstalledCertificate(X509Certificate cert) { + this(getSubjectCN(cert), getType(cert), getDurationInDays(cert), getExpired(cert)); + } + + boolean match(CertificateRequest request) { + return name.equals(request.name()) && type.equals(request.type()) && days == request.days() && expired == request.expired(); + } + + @Override + public int compareTo(InstalledCertificate o) { + return COMPARATOR.compare(this, o); } private static String getSubjectCN(X509Certificate cert) { @@ -697,13 +873,23 @@ private static CertificateType getType(X509Certificate cert) { private static int getDurationInDays(X509Certificate cert) { final var notBefore = cert.getNotBefore(); final var notAfter = cert.getNotAfter(); - return (int)TimeUnit.DAYS.convert(notAfter.getTime() - notBefore.getTime(), TimeUnit.MILLISECONDS); + return (int) TimeUnit.DAYS.convert(notAfter.getTime() - notBefore.getTime(), TimeUnit.MILLISECONDS); } - private static final Comparator COMPARATOR = - Comparator.comparing(CertificateRequest::name) - .thenComparing(Comparator.comparing(CertificateRequest::type)) - .thenComparing(Comparator.comparingInt(CertificateRequest::days)); + private static boolean getExpired(X509Certificate cert) { + try { + cert.checkValidity(); + return false; + } catch (CertificateExpiredException | CertificateNotYetValidException ex) { + return true; + } + } + + private static final Comparator COMPARATOR = + Comparator.comparing(InstalledCertificate::name) + .thenComparing(Comparator.comparing(InstalledCertificate::type)) + .thenComparing(Comparator.comparingInt(InstalledCertificate::days)) + .thenComparing(Comparator.comparing(InstalledCertificate::expired, Boolean::compare)); } /** @@ -715,8 +901,10 @@ private static int getDurationInDays(X509Certificate cert) { * Created certificates will be imported into the keychains, and every * certificate will be marked as trusted. *

- * The user will be prompted to enter the user login password as - * many times as the number of unique certificates this function will create. + * The user will be prompted to enter the user login password as many times as + * the number of unique certificates this function will create. + *

+ * Created keychains will NOT be added to the keychain search list. * * @param specs the keychains and signing identities configuration */ @@ -767,14 +955,14 @@ public static void setUp(List specs) { "-A").execute(); }); - trustConfig.put(certPemFile.getValue(), keychains.getFirst()); + if (certPemFile.getKey().trusted()) { + trustConfig.put(certPemFile.getValue(), keychains.getFirst()); + } } // Trust certificates. trustCertificates(trustConfig); }); - - Keychain.addToSearchList(specs.stream().map(KeychainWithCertsSpec::keychain).toList()); } /** @@ -820,11 +1008,11 @@ public static boolean isDeployed(List specs) { TKit.trace(String.format("In [%s] keychain:", keychain.name())); final var certificateStat = certificateStats.get(keychain); final var resolvedCertificateRequests = certificateStat.allResolvedCertificateRequests().stream() - .sorted(Comparator.comparing(ResolvedCertificateRequest::request)).toList(); + .sorted(Comparator.comparing(ResolvedCertificateRequest::installed)).toList(); for (final var resolvedCertificateRequest : resolvedCertificateRequests) { TKit.trace(String.format(" Certificate with hash=%s: %s[%s]", CertificateHash.of(resolvedCertificateRequest.cert()), - resolvedCertificateRequest.request(), + resolvedCertificateRequest.installed(), resolvedCertificateRequest.verifyStatus())); } @@ -849,7 +1037,31 @@ public static boolean isDeployed(List specs) { return !missingKeychain && !missingCertificates && !invalidCertificates; } - public static Map mapCertificateRequests(KeychainWithCertsSpec spec) { + public final static class ResolvedKeychain { + public ResolvedKeychain(KeychainWithCertsSpec spec) { + this.spec = Objects.requireNonNull(spec); + } + + public KeychainWithCertsSpec spec() { + return spec; + } + + public Map mapCertificateRequests() { + if (certMap == null) { + synchronized (this) { + if (certMap == null) { + certMap = MacSign.mapCertificateRequests(spec); + } + } + } + return certMap; + } + + private final KeychainWithCertsSpec spec; + private volatile Map certMap; + } + + private static Map mapCertificateRequests(KeychainWithCertsSpec spec) { return CertificateStats.get(spec).mapKnownCertificateRequests().entrySet().stream().collect(toMap(Map.Entry::getKey, e -> { return e.getValue().stream().reduce((x, y) -> { throw new IllegalStateException(String.format( @@ -876,18 +1088,39 @@ private static void validate(List specs) { }); } - private static boolean verifyCertificate(ResolvedCertificateRequest resolvedCertificateRequest, Keychain keychain, Path certFile) { + private static VerifyStatus verifyCertificate(ResolvedCertificateRequest resolvedCertificateRequest, Keychain keychain, Path certFile) { PemData.of(resolvedCertificateRequest.cert()).save(certFile, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); - for (final var mode : List.of("-q", "-v")) { - final var ok = security("verify-cert", "-L", "-n", mode, + Executor.Result result = null; + for (final var quite : List.of(true, false)) { + result = security("verify-cert", "-L", "-n", + quite ? "-q" : "-v", "-c", certFile.normalize().toString(), "-k", keychain.name(), - "-p", resolvedCertificateRequest.request().type().verifyPolicy()).executeWithoutExitCodeCheck().getExitCode() == 0; - if (ok) { - return true; + "-p", resolvedCertificateRequest.installed().type().verifyPolicy()).saveOutput(!quite).executeWithoutExitCodeCheck(); + if (result.exitCode() == 0) { + return VerifyStatus.VERIFY_OK; } } - return false; + + final var expired = result.getOutput().stream().anyMatch(line -> { + // Look up for "Certificate has expired, or is not yet valid (check date) [TemporalValidity]" string + return line.contains(" Certificate has expired, or is not yet valid (check date) [TemporalValidity]"); + }); + + final var untrusted = result.getOutput().stream().anyMatch(line -> { + // Look up for "The root of the certificate chain is not trusted [AnchorTrusted]" string + return line.contains(" The root of the certificate chain is not trusted [AnchorTrusted]"); + }); + + if (expired && untrusted) { + return VerifyStatus.VERIFY_EXPIRED_UNTRUSTED; + } else if (untrusted) { + return VerifyStatus.VERIFY_UNTRUSTED; + } else if (expired) { + return VerifyStatus.VERIFY_EXPIRED; + } else { + return VerifyStatus.VERIFY_ERROR; + } } private static void traceSigningEnvironment(Collection specs) { @@ -968,7 +1201,15 @@ private static Map createCertificates(Keychain private "CN=" + certificateRequest.name() )); - final var openssl = Executor.of(OPENSSL.toString(), "req", + final Executor openssl; + if (certificateRequest.expired()) { + final var format = String.format("-%dd", certificateRequest.days + 1); + openssl = Executor.of(FAKETIME.toString(), "-f", format, OPENSSL.toString()); + } else { + openssl = Executor.of(OPENSSL.toString()); + } + + openssl.addArguments("req", "-x509", "-utf8", "-sha256", "-nodes", "-new", // Prevents LibreSSL variant of openssl command from hanging "-days", Integer.toString(certificateRequest.days()), @@ -1040,4 +1281,8 @@ static Executor security(String... args) { // /usr/bin/openssl will preempt /usr/local/bin/openssl. // To workaround this jtreg behavior support specifying path to openssl command. private static final Path OPENSSL = Path.of(Optional.ofNullable(TKit.getConfigProperty("openssl")).orElse("openssl")); + + // faketime is not a standard macOS command. + // One way to get it is with Homebrew. + private static final Path FAKETIME = Path.of(Optional.ofNullable(TKit.getConfigProperty("faketime")).orElse("faketime")); } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java new file mode 100644 index 00000000000..9fcd54d1566 --- /dev/null +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jpackage.test; + +import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier; +import static jdk.jpackage.test.MacSign.DigestAlgorithm.SHA256; + +import java.nio.file.Path; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.HexFormat; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Pattern; +import jdk.jpackage.internal.util.PListReader; +import jdk.jpackage.test.MacSign.CertificateHash; +import jdk.jpackage.test.MacSign.CertificateRequest; + +/** + * Utilities to verify sign signatures. + */ +public final class MacSignVerify { + + public static void assertSigned(Path path, CertificateRequest certRequest) { + assertSigned(path); + TKit.assertEquals(certRequest.name(), findCodesignSignOrigin(path).orElse(null), + String.format("Check [%s] signed with certificate", path)); + } + + public static void assertAdhocSigned(Path path) { + assertSigned(path); + TKit.assertEquals(ADHOC_SIGN_ORIGIN, findCodesignSignOrigin(path).orElse(null), + String.format("Check [%s] signed with adhoc signature", path)); + } + + public static void assertUnsigned(Path path) { + TKit.assertTrue(findSpctlSignOrigin(SpctlType.EXEC, path).isEmpty(), + String.format("Check [%s] unsigned", path)); + } + + public static void assertPkgSigned(Path path, CertificateRequest certRequest, X509Certificate cert) { + final var expectedCertChain = List.of(new SignIdentity(certRequest.name(), CertificateHash.of(cert, SHA256))); + final var actualCertChain = getPkgCertificateChain(path); + TKit.assertStringListEquals( + expectedCertChain.stream().map(SignIdentity::toString).toList(), + actualCertChain.stream().map(SignIdentity::toString).toList(), + String.format("Check certificate chain of [%s] is as expected", path)); + TKit.assertEquals(certRequest.name(), findSpctlSignOrigin(SpctlType.INSTALL, path).orElse(null), + String.format("Check [%s] signed for installation", path)); + } + + public enum SpctlType { + EXEC("exec"), INSTALL("install"); + + SpctlType(String value) { + this.value = Objects.requireNonNull(value); + } + + public String value() { + return value; + } + + final private String value; + } + + public static final String ADHOC_SIGN_ORIGIN = "-"; + + public static Optional findSpctlSignOrigin(SpctlType type, Path path) { + final var exec = Executor.of("/usr/sbin/spctl", "-vv", "--raw", "--assess", "--type", type.value(), path.toString()).saveOutput().discardStderr(); + final var result = exec.executeWithoutExitCodeCheck(); + TKit.assertTrue(Set.of(0, 3).contains(result.exitCode()), + String.format("Check exit code of command %s is either 0 or 3", exec.getPrintableCommandLine())); + return toSupplier(() -> { + try { + return Optional.of(new PListReader(String.join("", result.getOutput()).getBytes()).queryValue("assessment:originator")); + } catch (NoSuchElementException ex) { + return Optional.empty(); + } + }).get(); + } + + public static Optional findCodesignSignOrigin(Path path) { + final var exec = Executor.of("/usr/bin/codesign", "--display", "--verbose=4", path.toString()).saveOutput(); + final var result = exec.executeWithoutExitCodeCheck(); + if (result.getExitCode() == 0) { + return Optional.of(result.getOutput().stream().map(line -> { + if (line.equals("Signature=adhoc")) { + return ADHOC_SIGN_ORIGIN; + } else if (line.startsWith("Authority=")) { + return line.substring("Authority=".length()); + } else { + return null; + } + }).filter(Objects::nonNull).reduce((x, y) -> { + throw new UnsupportedOperationException(String.format( + "Both adhoc [%s] and certificate [%s] signatures found in codesign output", x, y)); + }).orElseThrow(() -> { + final var msg = "Neither adhoc nor certificate signatures found in codesign output"; + TKit.trace(msg + ":"); + result.getOutput().forEach(TKit::trace); + TKit.trace("Done"); + return new UnsupportedOperationException(msg); + })); + } else if (result.getExitCode() == 1 && result.getFirstLineOfOutput().endsWith("code object is not signed at all")) { + return Optional.empty(); + } else { + reportUnexpectedCommandOutcome(exec.getPrintableCommandLine(), result); + return null; // Unreachable + } + } + + public static void assertSigned(Path path) { + final var verifier = TKit.assertTextStream(": valid on disk").predicate(String::endsWith).andThen(TKit.assertTextStream(": satisfies its Designated Requirement").predicate(String::endsWith)); + verifier.apply(Executor.of("/usr/bin/codesign", "--verify", "--deep", + "--strict", "--verbose=2", path.toString()).executeAndGetOutput().stream()); + } + + public static List getPkgCertificateChain(Path path) { + // + // Typical output of `/usr/sbin/pkgutil --check-signature`: + // Package "foo.pkg": + // Status: signed by a developer certificate issued by Apple for distribution + // Notarization: trusted by the Apple notary service + // Signed with a trusted timestamp on: 2022-05-10 19:54:56 +0000 + // Certificate Chain: + // 1. Developer ID Installer: Foo + // SHA256 Fingerprint: + // 4A A9 4A 85 20 2A DE 02 B2 9B 36 DA 45 00 B4 40 CF 31 43 4E 96 02 + // 60 6A 6D BC 02 F4 5D 3A 86 4A + // ------------------------------------------------------------------------ + // 2. Developer ID Certification Authority + // Expires: 2027-02-01 22:12:15 +0000 + // SHA256 Fingerprint: + // 7A FC 9D 01 A6 2F 03 A2 DE 96 37 93 6D 4A FE 68 09 0D 2D E1 8D 03 + // F2 9C 88 CF B0 B1 BA 63 58 7F + // ------------------------------------------------------------------------ + // 3. Apple Root CA + // Expires: 2035-02-09 21:40:36 +0000 + // SHA256 Fingerprint: + // B0 B1 73 0E CB C7 FF 45 05 14 2C 49 F1 29 5E 6E DA 6B CA ED 7E 2C + // 68 C5 BE 91 B5 A1 10 01 F0 24 + final var exec = Executor.of("/usr/sbin/pkgutil", "--check-signature", path.toString()).saveOutput(); + final var result = exec.executeWithoutExitCodeCheck(); + if (result.getExitCode() == 0) { + try { + final List signIdentities = new ArrayList<>(); + final var lineIt = result.getOutput().iterator(); + while (!lineIt.next().endsWith("Certificate Chain:")) { + + } + do { + final var m = SIGN_IDENTITY_NAME_REGEXP.matcher(lineIt.next()); + m.find(); + final var name = m.group(1); + while (!lineIt.next().endsWith("SHA256 Fingerprint:")) { + + } + final var digest = new StringBuilder(); + do { + final var line = lineIt.next().strip(); + if (line.endsWith("----") || line.isEmpty()) { + break; + } + digest.append(" " + line.strip()); + } while (lineIt.hasNext()); + final var fingerprint = new CertificateHash( + FINGERPRINT_FORMAT.parseHex(digest.substring(1)), SHA256); + signIdentities.add(new SignIdentity(name, fingerprint)); + } while (lineIt.hasNext()); + return signIdentities; + } catch (Throwable t) { + t.printStackTrace(); + reportUnexpectedCommandOutcome(exec.getPrintableCommandLine(), result); + return null; // Unreachable + } + } else if (result.getExitCode() == 1 && result.getOutput().getLast().endsWith("Status: no signature")) { + return List.of(); + } else { + reportUnexpectedCommandOutcome(exec.getPrintableCommandLine(), result); + return null; // Unreachable + } + } + + public record SignIdentity(String name, CertificateHash fingerprint) { + public SignIdentity { + Objects.requireNonNull(name); + Objects.requireNonNull(fingerprint); + } + } + + private static void reportUnexpectedCommandOutcome(String printableCommandLine, Executor.Result result) { + Objects.requireNonNull(printableCommandLine); + Objects.requireNonNull(result); + TKit.trace(String.format("Command %s exited with exit code %d and the following output:", + printableCommandLine, result.getExitCode())); + result.getOutput().forEach(TKit::trace); + TKit.trace("Done"); + TKit.assertUnexpected(String.format("Outcome of command %s", printableCommandLine)); + } + + private static final Pattern SIGN_IDENTITY_NAME_REGEXP = Pattern.compile("^\\s+\\d+\\.\\s+(.*)$"); + private static final HexFormat FINGERPRINT_FORMAT = HexFormat.ofDelimiter(" ").withUpperCase(); +} diff --git a/test/jdk/tools/jpackage/macosx/MacSignTest.java b/test/jdk/tools/jpackage/macosx/MacSignTest.java index 4313f1900e2..7b2e06dc7ca 100644 --- a/test/jdk/tools/jpackage/macosx/MacSignTest.java +++ b/test/jdk/tools/jpackage/macosx/MacSignTest.java @@ -24,12 +24,23 @@ import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Objects; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Stream; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.Annotations.ParameterSupplier; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.CannedFormattedString; import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.JPackageStringBundle; import jdk.jpackage.test.MacHelper; +import jdk.jpackage.test.MacSign; +import jdk.jpackage.test.MacSign.CertificateRequest; +import jdk.jpackage.test.MacSignVerify; +import jdk.jpackage.test.PackageType; import jdk.jpackage.test.TKit; /* @@ -64,23 +75,173 @@ public static void testAppContentWarning() throws IOException { expectedStrings.add(xcodeWarning); } - // --app-content and --type app-image - // Expect `message.codesign.failed.reason.app.content` message in the log. - // This is not a fatal error, just a warning. - // To make jpackage fail, specify bad additional content. - final var cmd = JPackageCommand.helloAppImage() - .ignoreDefaultVerbose(true) - .validateOutput(expectedStrings.toArray(CannedFormattedString[]::new)) - .addArguments("--app-content", appContent) - .addArguments("--mac-sign") - .addArguments("--mac-signing-keychain", SigningBase.StandardKeychain.MAIN.spec().keychain().name()) - .addArguments("--mac-app-image-sign-identity", SigningBase.StandardCertificateRequest.APP_IMAGE.spec().name()); - - if (MacHelper.isXcodeDevToolsInstalled()) { - // Check there is no warning about missing xcode command line developer tools. - cmd.validateOutput(TKit.assertTextStream(xcodeWarning.getValue()).negate()); + final var keychain = SigningBase.StandardKeychain.EXPIRED.spec().keychain(); + + MacSign.Keychain.withAddedKeychains(List.of(keychain), () -> { + // --app-content and --type app-image + // Expect `message.codesign.failed.reason.app.content` message in the log. + // This is not a fatal error, just a warning. + // To make jpackage fail, specify bad additional content. + final var cmd = JPackageCommand.helloAppImage() + .ignoreDefaultVerbose(true) + .validateOutput(expectedStrings.toArray(CannedFormattedString[]::new)) + .addArguments("--app-content", appContent) + .addArguments("--mac-sign") + .addArguments("--mac-signing-keychain", keychain.name()) + .addArguments("--mac-app-image-sign-identity", SigningBase.StandardCertificateRequest.CODESIGN.spec().name()); + + if (MacHelper.isXcodeDevToolsInstalled()) { + // Check there is no warning about missing xcode command line developer tools. + cmd.validateOutput(TKit.assertTextStream(xcodeWarning.getValue()).negate()); + } + + cmd.execute(1); + }); + } + + @Test + @Parameter({"IMAGE", "EXPIRED_SIGNING_KEY_USER_NAME"}) + @Parameter({"MAC_DMG", "EXPIRED_SIGNING_KEY_USER_NAME"}) + @Parameter({"MAC_PKG", "EXPIRED_SIGNING_KEY_USER_NAME", "EXPIRED_SIGNING_KEY_USER_NAME_PKG"}) + + @Parameter({"IMAGE", "EXPIRED_SIGN_IDENTITY"}) + @Parameter({"MAC_DMG", "EXPIRED_SIGN_IDENTITY"}) + @Parameter({"MAC_PKG", "EXPIRED_SIGN_IDENTITY"}) + + @Parameter({"IMAGE", "EXPIRED_CODESIGN_SIGN_IDENTITY"}) + @Parameter({"MAC_DMG", "EXPIRED_CODESIGN_SIGN_IDENTITY"}) + @Parameter({"MAC_PKG", "EXPIRED_CODESIGN_SIGN_IDENTITY"}) + + @Parameter({"MAC_PKG", "GOOD_CODESIGN_SIGN_IDENTITY", "EXPIRED_PKG_SIGN_IDENTITY"}) + @Parameter({"MAC_PKG", "EXPIRED_CODESIGN_SIGN_IDENTITY", "GOOD_PKG_SIGN_IDENTITY"}) + public static void testExpiredCertificate(PackageType type, SignOption... options) { + + final var keychain = SigningBase.StandardKeychain.EXPIRED.spec().keychain(); + + MacSign.Keychain.withAddedKeychains(List.of(keychain), () -> { + final var cmd = JPackageCommand.helloAppImage() + .ignoreDefaultVerbose(true) + .addArguments("--mac-sign") + .addArguments("--mac-signing-keychain", keychain.name()) + .addArguments(Stream.of(options).map(SignOption::args).flatMap(List::stream).toList()) + .setPackageType(type); + + SignOption.configureOutputValidation(cmd, Stream.of(options).filter(SignOption::expired).toList(), opt -> { + return JPackageStringBundle.MAIN.cannedFormattedString("error.certificate.expired", opt.identityName()); + }).execute(1); + }); + } + + @Test + @Parameter({"IMAGE", "GOOD_SIGNING_KEY_USER_NAME"}) + @Parameter({"MAC_DMG", "GOOD_SIGNING_KEY_USER_NAME"}) + @Parameter({"MAC_PKG", "GOOD_SIGNING_KEY_USER_NAME_PKG", "GOOD_SIGNING_KEY_USER_NAME"}) + + @Parameter({"IMAGE", "GOOD_CODESIGN_SIGN_IDENTITY"}) + @Parameter({"MAC_PKG", "GOOD_CODESIGN_SIGN_IDENTITY", "GOOD_PKG_SIGN_IDENTITY"}) + @Parameter({"MAC_PKG", "GOOD_PKG_SIGN_IDENTITY"}) + public static void testMultipleCertificates(PackageType type, SignOption... options) { + + final var keychain = SigningBase.StandardKeychain.DUPLICATE.spec().keychain(); + + MacSign.Keychain.withAddedKeychains(List.of(keychain), () -> { + final var cmd = JPackageCommand.helloAppImage() + .ignoreDefaultVerbose(true) + .addArguments("--mac-sign") + .addArguments("--mac-signing-keychain", keychain.name()) + .addArguments(Stream.of(options).map(SignOption::args).flatMap(List::stream).toList()) + .setPackageType(type); + + SignOption.configureOutputValidation(cmd, List.of(options), opt -> { + return JPackageStringBundle.MAIN.cannedFormattedString("error.multiple.certs.found", opt.identityName(), keychain.name()); + }).execute(1); + }); + } + + @Test + @ParameterSupplier + public static void testSelectSigningIdentity(String signingKeyUserName, CertificateRequest certRequest) { + + final var keychain = SigningBase.StandardKeychain.MAIN.spec().keychain(); + + MacSign.Keychain.withAddedKeychains(List.of(keychain), () -> { + final var cmd = JPackageCommand.helloAppImage() + .setFakeRuntime() + .addArguments("--mac-sign") + .addArguments("--mac-signing-keychain", keychain.name()) + .addArguments("--mac-signing-key-user-name", signingKeyUserName); + + cmd.executeAndAssertHelloAppImageCreated(); + + MacSignVerify.assertSigned(cmd.outputBundle(), certRequest); + }); + } + + public static Collection testSelectSigningIdentity() { + return Stream.of( + SigningBase.StandardCertificateRequest.CODESIGN, + SigningBase.StandardCertificateRequest.CODESIGN_UNICODE + ).map(SigningBase.StandardCertificateRequest::spec).mapMulti((certRequest, acc) -> { + acc.accept(new Object[] {certRequest.shortName(), certRequest}); + acc.accept(new Object[] {certRequest.name(), certRequest}); + }).toList(); + } + + enum SignOption { + EXPIRED_SIGNING_KEY_USER_NAME("--mac-signing-key-user-name", SigningBase.StandardCertificateRequest.CODESIGN_EXPIRED.spec(), true, false), + EXPIRED_SIGNING_KEY_USER_NAME_PKG("--mac-signing-key-user-name", SigningBase.StandardCertificateRequest.PKG_EXPIRED.spec(), true, false), + EXPIRED_SIGN_IDENTITY("--mac-signing-key-user-name", SigningBase.StandardCertificateRequest.CODESIGN_EXPIRED.spec(), false, false), + EXPIRED_CODESIGN_SIGN_IDENTITY("--mac-app-image-sign-identity", SigningBase.StandardCertificateRequest.CODESIGN_EXPIRED.spec(), false, true), + EXPIRED_PKG_SIGN_IDENTITY("--mac-installer-sign-identity", SigningBase.StandardCertificateRequest.PKG_EXPIRED.spec(), false, true), + GOOD_SIGNING_KEY_USER_NAME("--mac-signing-key-user-name", SigningBase.StandardCertificateRequest.CODESIGN.spec(), true, false), + GOOD_SIGNING_KEY_USER_NAME_PKG("--mac-signing-key-user-name", SigningBase.StandardCertificateRequest.PKG.spec(), true, false), + GOOD_CODESIGN_SIGN_IDENTITY("--mac-app-image-sign-identity", SigningBase.StandardCertificateRequest.CODESIGN.spec(), false, true), + GOOD_PKG_SIGN_IDENTITY("--mac-app-image-sign-identity", SigningBase.StandardCertificateRequest.PKG.spec(), false, true); + + SignOption(String option, MacSign.CertificateRequest cert, boolean shortName, boolean passThrough) { + this.option = Objects.requireNonNull(option); + this.cert = Objects.requireNonNull(cert); + this.shortName = shortName; + this.passThrough = passThrough; + } + + boolean passThrough() { + return passThrough; + } + + boolean expired() { + return cert.expired(); + } + + String identityName() { + return cert.name(); + } + + List args() { + return List.of(option, shortName ? cert.shortName() : cert.name()); + } + + static JPackageCommand configureOutputValidation(JPackageCommand cmd, List options, + Function conv) { + options.stream().filter(SignOption::passThrough) + .map(conv) + .map(CannedFormattedString::getValue) + .map(TKit::assertTextStream) + .map(TKit.TextStreamVerifier::negate) + .forEach(cmd::validateOutput); + + options.stream().filter(Predicate.not(SignOption::passThrough)) + .map(conv) + .map(CannedFormattedString::getValue) + .map(TKit::assertTextStream) + .forEach(cmd::validateOutput); + + return cmd; } - cmd.execute(1); + private final String option; + private final MacSign.CertificateRequest cert; + private final boolean shortName; + private final boolean passThrough; } } diff --git a/test/jdk/tools/jpackage/macosx/base/SigningBase.java b/test/jdk/tools/jpackage/macosx/base/SigningBase.java index e3237197c74..5484245f111 100644 --- a/test/jdk/tools/jpackage/macosx/base/SigningBase.java +++ b/test/jdk/tools/jpackage/macosx/base/SigningBase.java @@ -22,16 +22,18 @@ */ import java.nio.file.Path; +import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.stream.Stream; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.Executor.Result; import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.MacSign; -import jdk.jpackage.test.MacSign.CertificateType; import jdk.jpackage.test.MacSign.CertificateRequest; +import jdk.jpackage.test.MacSign.CertificateType; import jdk.jpackage.test.MacSign.KeychainWithCertsSpec; +import jdk.jpackage.test.MacSign.ResolvedKeychain; +import jdk.jpackage.test.MacSignVerify; import jdk.jpackage.test.TKit; @@ -64,10 +66,14 @@ public class SigningBase { public enum StandardCertificateRequest { - APP_IMAGE(cert().userName(DEV_NAMES[CertIndex.ASCII_INDEX.value()])), - INSTALLER(cert().type(CertificateType.INSTALLER).userName(DEV_NAMES[CertIndex.ASCII_INDEX.value()])), - APP_IMAGE_UNICODE(cert().userName(DEV_NAMES[CertIndex.UNICODE_INDEX.value()])), - INSTALLER_UNICODE(cert().type(CertificateType.INSTALLER).userName(DEV_NAMES[CertIndex.UNICODE_INDEX.value()])); + CODESIGN(cert().userName(DEV_NAMES[CertIndex.ASCII_INDEX.value()])), + CODESIGN_COPY(cert().days(100).userName(DEV_NAMES[CertIndex.ASCII_INDEX.value()])), + PKG(cert().type(CertificateType.INSTALLER).userName(DEV_NAMES[CertIndex.ASCII_INDEX.value()])), + PKG_COPY(cert().type(CertificateType.INSTALLER).days(100).userName(DEV_NAMES[CertIndex.ASCII_INDEX.value()])), + CODESIGN_UNICODE(cert().userName(DEV_NAMES[CertIndex.UNICODE_INDEX.value()])), + PKG_UNICODE(cert().type(CertificateType.INSTALLER).userName(DEV_NAMES[CertIndex.UNICODE_INDEX.value()])), + CODESIGN_EXPIRED(cert().expired().userName("expired jpackage test")), + PKG_EXPIRED(cert().expired().type(CertificateType.INSTALLER).userName("expired jpackage test")); StandardCertificateRequest(CertificateRequest.Builder specBuilder) { this.spec = specBuilder.create(); @@ -85,7 +91,21 @@ private static CertificateRequest.Builder cert() { } public enum StandardKeychain { - MAIN(DEFAULT_KEYCHAIN, StandardCertificateRequest.values()); + MAIN(DEFAULT_KEYCHAIN, + StandardCertificateRequest.CODESIGN, + StandardCertificateRequest.PKG, + StandardCertificateRequest.CODESIGN_UNICODE, + StandardCertificateRequest.PKG_UNICODE), + EXPIRED("jpackagerTest-expired.keychain", + StandardCertificateRequest.CODESIGN, + StandardCertificateRequest.PKG, + StandardCertificateRequest.CODESIGN_EXPIRED, + StandardCertificateRequest.PKG_EXPIRED), + DUPLICATE("jpackagerTest-duplicate.keychain", + StandardCertificateRequest.CODESIGN, + StandardCertificateRequest.PKG, + StandardCertificateRequest.CODESIGN_COPY, + StandardCertificateRequest.PKG_COPY); StandardKeychain(String keychainName, StandardCertificateRequest... certs) { this(keychainName, certs[0].spec(), Stream.of(certs).skip(1).map(StandardCertificateRequest::spec).toArray(CertificateRequest[]::new)); @@ -94,11 +114,15 @@ public enum StandardKeychain { StandardKeychain(String keychainName, CertificateRequest cert, CertificateRequest... otherCerts) { final var builder = keychain(keychainName).addCert(cert); List.of(otherCerts).forEach(builder::addCert); - this.spec = builder.create(); + this.spec = new ResolvedKeychain(builder.create()); } public KeychainWithCertsSpec spec() { - return spec; + return spec.spec(); + } + + public X509Certificate mapCertificateRequest(CertificateRequest certRequest) { + return Objects.requireNonNull(spec.mapCertificateRequests().get(certRequest)); } private static KeychainWithCertsSpec.Builder keychain(String name) { @@ -113,7 +137,7 @@ private static List signingEnv() { return Stream.of(values()).map(StandardKeychain::spec).toList(); } - private final KeychainWithCertsSpec spec; + private final ResolvedKeychain spec; } public static void setUp() { @@ -131,7 +155,7 @@ public static void verifySignTestEnvReady() { } private final class Inner { - private final static boolean SIGN_ENV_READY = MacSign.isDeployed(StandardKeychain.signingEnv()); + private static final boolean SIGN_ENV_READY = MacSign.isDeployed(StandardKeychain.signingEnv()); } enum CertIndex { @@ -199,165 +223,60 @@ public static String getKeyChain() { return DEFAULT_KEYCHAIN; } - // Note: It is not clear if we can combine "--verify" and "--display", so - // we testing them separately. Since JDK-8298488 unsigned app images are - // actually signed with adhoc signature and it will pass "--verify", so in - // addition we will check certificate name which was used to sign. - private static enum CodesignCheckType { - VERIFY, // Runs codesign with "--verify" to check signature and 0 exit code - VERIFY_UNSIGNED, // Runs codesign with "--verify" to check signature and 1 exit code - DISPLAY // Runs codesign with "--display --verbose=4" to get info about signature - }; - - private static void checkString(List result, String lookupString) { - TKit.assertTextStream(lookupString).predicate( - (line, what) -> line.trim().contains(what)).apply(result.stream()); - } - - @SuppressWarnings("fallthrough") - private static List codesignResult(Path target, CodesignCheckType type) { - int exitCode = 0; - Executor executor = new Executor().setExecutable("/usr/bin/codesign"); - switch (type) { - case VERIFY_UNSIGNED: - exitCode = 1; - case VERIFY: - executor.addArguments("--verify", "--deep", "--strict", - "--verbose=2", target.toString()); - break; - case DISPLAY: - executor.addArguments("--display", "--verbose=4", target.toString()); - break; - default: - TKit.error("Unknown CodesignCheckType: " + type); - break; - } - return executor.saveOutput().execute(exitCode).getOutput(); - } - - private static void verifyCodesignResult(List result, Path target, - boolean signed, CodesignCheckType type, int certIndex) { - result.stream().forEachOrdered(TKit::trace); - String lookupString; - switch (type) { - case VERIFY: - lookupString = target.toString() + ": valid on disk"; - checkString(result, lookupString); - lookupString = target.toString() + ": satisfies its Designated Requirement"; - checkString(result, lookupString); - break; - case VERIFY_UNSIGNED: - lookupString = target.toString() + ": code object is not signed at all"; - checkString(result, lookupString); - break; - case DISPLAY: - if (signed) { - lookupString = "Authority=" + getAppCert(certIndex); - } else { - lookupString = "Signature=adhoc"; - } - checkString(result, lookupString); - break; - default: - TKit.error("Unknown CodesignCheckType: " + type); - break; - } - } - - private static Result spctlResult(Path target, String type) { - Result result = new Executor() - .setExecutable("/usr/sbin/spctl") - .addArguments("-vvv", "--assess", "--type", type, - target.toString()) - .saveOutput() - .executeWithoutExitCodeCheck(); - - // allow exit code 3 for not being notarized - if (result.getExitCode() != 3) { - result.assertExitCodeIsZero(); - } - return result; - } - - private static void verifySpctlResult(List output, Path target, - String type, int exitCode, int certIndex) { - output.stream().forEachOrdered(TKit::trace); - String lookupString; - - if (exitCode == 0) { - lookupString = target.toString() + ": accepted"; - checkString(output, lookupString); - } else if (exitCode == 3) { - // allow failure purely for not being notarized - lookupString = target.toString() + ": rejected"; - checkString(output, lookupString); - } - - if (type.equals("install")) { - lookupString = "origin=" + getInstallerCert(certIndex); - } else { - lookupString = "origin=" + getAppCert(certIndex); - } - checkString(output, lookupString); - } - - private static List pkgutilResult(Path target, boolean signed) { - List result = new Executor() - .setExecutable("/usr/sbin/pkgutil") - .addArguments("--check-signature", - target.toString()) - .saveOutput() - .execute(signed ? 0 : 1) - .getOutput(); - - return result; - } - - private static void verifyPkgutilResult(List result, boolean signed, - int certIndex) { - result.stream().forEachOrdered(TKit::trace); + public static void verifyCodesign(Path target, boolean signed, int certIndex) { if (signed) { - String lookupString = "Status: signed by"; - checkString(result, lookupString); - lookupString = "1. " + getInstallerCert(certIndex); - checkString(result, lookupString); + final var certRequest = getCertRequest(certIndex); + MacSignVerify.assertSigned(target, certRequest); } else { - String lookupString = "Status: no signature"; - checkString(result, lookupString); + MacSignVerify.assertAdhocSigned(target); } } - public static void verifyCodesign(Path target, boolean signed, int certIndex) { - List result = codesignResult(target, CodesignCheckType.VERIFY); - verifyCodesignResult(result, target, signed, CodesignCheckType.VERIFY, certIndex); - - result = codesignResult(target, CodesignCheckType.DISPLAY); - verifyCodesignResult(result, target, signed, CodesignCheckType.DISPLAY, certIndex); - } - // Since we no longer have unsigned app image, but we need to check // DMG which is not adhoc or certificate signed and we cannot use verifyCodesign // for this. verifyDMG() is introduced to check that DMG is unsigned. // Should not be used to validated anything else. public static void verifyDMG(Path target) { if (!target.toString().toLowerCase().endsWith(".dmg")) { - TKit.error("Unexpected target: " + target); + throw new IllegalArgumentException("Unexpected target: " + target); } - List result = codesignResult(target, CodesignCheckType.VERIFY_UNSIGNED); - verifyCodesignResult(result, target, false, CodesignCheckType.VERIFY_UNSIGNED, -1); + MacSignVerify.assertUnsigned(target); } public static void verifySpctl(Path target, String type, int certIndex) { - Result result = spctlResult(target, type); - List output = result.getOutput(); + final var standardCertIndex = Stream.of(CertIndex.values()).filter(v -> { + return v.value() == certIndex; + }).findFirst().orElseThrow(); + + final var standardType = Stream.of(MacSignVerify.SpctlType.values()).filter(v -> { + return v.value().equals(type); + }).findFirst().orElseThrow(); + + final String expectedSignOrigin; + if (standardCertIndex == CertIndex.INVALID_INDEX) { + expectedSignOrigin = null; + } else if (standardType == MacSignVerify.SpctlType.EXEC) { + expectedSignOrigin = getCertRequest(certIndex).name(); + } else if (standardType == MacSignVerify.SpctlType.INSTALL) { + expectedSignOrigin = getPkgCertRequest(certIndex).name(); + } else { + throw new IllegalArgumentException(); + } + + final var signOrigin = MacSignVerify.findSpctlSignOrigin(standardType, target).orElse(null); - verifySpctlResult(output, target, type, result.getExitCode(), certIndex); + TKit.assertEquals(signOrigin, expectedSignOrigin, + String.format("Check [%s] has sign origin as expected", target)); } public static void verifyPkgutil(Path target, boolean signed, int certIndex) { - List result = pkgutilResult(target, signed); - verifyPkgutilResult(result, signed, certIndex); + if (signed) { + final var certRequest = getPkgCertRequest(certIndex); + MacSignVerify.assertPkgSigned(target, certRequest, StandardKeychain.MAIN.mapCertificateRequest(certRequest)); + } else { + MacSignVerify.assertUnsigned(target); + } } public static void verifyAppImageSignature(JPackageCommand appImageCmd, @@ -378,4 +297,31 @@ public static void verifyAppImageSignature(JPackageCommand appImageCmd, } } + private static CertificateRequest getCertRequest(int certIndex) { + switch (CertIndex.values()[certIndex]) { + case ASCII_INDEX -> { + return StandardCertificateRequest.CODESIGN.spec(); + } + case UNICODE_INDEX -> { + return StandardCertificateRequest.CODESIGN_UNICODE.spec(); + } + default -> { + throw new IllegalArgumentException(); + } + } + } + + private static CertificateRequest getPkgCertRequest(int certIndex) { + switch (CertIndex.values()[certIndex]) { + case ASCII_INDEX -> { + return StandardCertificateRequest.PKG.spec(); + } + case UNICODE_INDEX -> { + return StandardCertificateRequest.PKG_UNICODE.spec(); + } + default -> { + throw new IllegalArgumentException(); + } + } + } } From 7a72f0fac9a0704c4a0ada781f1cadd7c4903b3e Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 01:03:45 +0000 Subject: [PATCH 028/901] 8354465: Open some JTable bugs 8 Reviewed-by: serb, kizune --- .../swing/JTable/CheckBoxFirstClick.java | 185 +++++++++++++++++ .../swing/JTable/IllegalStateException.java | 187 ++++++++++++++++++ test/jdk/javax/swing/JTable/bug4139910.java | 68 +++++++ test/jdk/javax/swing/JTable/bug4226181.java | 87 ++++++++ test/jdk/javax/swing/JTable/bug4239157.java | 85 ++++++++ 5 files changed, 612 insertions(+) create mode 100644 test/jdk/javax/swing/JTable/CheckBoxFirstClick.java create mode 100644 test/jdk/javax/swing/JTable/IllegalStateException.java create mode 100644 test/jdk/javax/swing/JTable/bug4139910.java create mode 100644 test/jdk/javax/swing/JTable/bug4226181.java create mode 100644 test/jdk/javax/swing/JTable/bug4239157.java diff --git a/test/jdk/javax/swing/JTable/CheckBoxFirstClick.java b/test/jdk/javax/swing/JTable/CheckBoxFirstClick.java new file mode 100644 index 00000000000..91f8930103e --- /dev/null +++ b/test/jdk/javax/swing/JTable/CheckBoxFirstClick.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.BevelBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4115930 + * @summary Verify checkboxes in the table respond to first click. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual CheckBoxFirstClick + */ + +public class CheckBoxFirstClick { + private static final String INSTRUCTIONS = """ + Click over the checkbox in the table. It should change state + on the first click. If not - press 'fail'. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(CheckBoxFirstClick::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("ListSizeBug"); + + // Take the dummy data from SwingSet. + final String[] names = {"First Name", "Last Name", "Favorite Color", + "Favorite Number", "Vegetarian"}; + final Object[][] data = { + {"Mark", "Andrews", "Red", 2, true}, + {"Tom", "Ball", "Blue", 99, false}, + {"Alan", "Chung", "Green", 838, false}, + {"Jeff", "Dinkins", "Turquois", 8, true}, + {"Amy", "Fowler", "Yellow", 3, false}, + {"Brian", "Gerhold", "Green", 0, false}, + {"James", "Gosling", "Pink", 21, false}, + {"David", "Karlton", "Red", 1, false}, + {"Dave", "Kloba", "Yellow", 14, false}, + {"Peter", "Korn", "Purple", 12, false}, + {"Phil", "Milne", "Purple", 3, false}, + {"Dave", "Moore", "Green", 88, false}, + {"Hans", "Muller", "Maroon", 5, false}, + {"Rick", "Levenson", "Blue", 2, false}, + {"Tim", "Prinzing", "Blue", 22, false}, + {"Chester", "Rose", "Black", 0, false}, + {"Ray", "Ryan", "Gray", 77, false}, + {"Georges", "Saab", "Red", 4, false}, + {"Willie", "Walker", "Phthalo Blue", 4, false}, + {"Kathy", "Walrath", "Blue", 8, false}, + {"Arnaud", "Weber", "Green", 44, false} + }; + + // Create a model of the data. + TableModel dataModel = new AbstractTableModel() { + // These methods always need to be implemented. + public int getColumnCount() { + return names.length; + } + + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + // The default implementations of these methods in + // AbstractTableModel would work, but we can refine them. + public String getColumnName(int column) { + return names[column]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public boolean isCellEditable(int row, int col) { + return true; + } + + public void setValueAt(Object aValue, int row, int column) { + System.out.println("Setting value to: " + aValue); + data[row][column] = aValue; + } + }; + + // Create the table + JTable tableView = new JTable(dataModel); + // Turn off auto-resizing so that we can set column sizes programmatically. + // In this mode, all columns will get their preferred widths, as set blow. + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // Create a combo box to show that you can use one in a table. + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Red"); + comboBox.addItem("Orange"); + comboBox.addItem("Yellow"); + comboBox.addItem("Green"); + comboBox.addItem("Blue"); + comboBox.addItem("Indigo"); + comboBox.addItem("Violet"); + + TableColumn colorColumn = tableView.getColumn("Favorite Color"); + // Use the combo box as the editor in the "Favorite Color" column. + colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + // Set a pink background and tooltip for the Color column renderer. + DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer(); + colorColumnRenderer.setBackground(Color.pink); + colorColumnRenderer.setToolTipText("Click for combo box"); + colorColumn.setCellRenderer(colorColumnRenderer); + + // Set a tooltip for the header of the colors column. + TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer(); + if (headerRenderer instanceof DefaultTableCellRenderer) + ((DefaultTableCellRenderer) headerRenderer).setToolTipText("Hi Mom!"); + + // Set the width of the "Vegetarian" column. + TableColumn vegetarianColumn = tableView.getColumn("Vegetarian"); + vegetarianColumn.setPreferredWidth(100); + + // Show the values in the "Favorite Number" column in different colors. + TableColumn numbersColumn = tableView.getColumn("Favorite Number"); + DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() { + public void setValue(Object value) { + int cellValue = (value instanceof Number) ? ((Number) value).intValue() : 0; + setForeground((cellValue > 30) ? Color.black : Color.red); + setText((value == null) ? "" : value.toString()); + } + }; + numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT); + numbersColumn.setCellRenderer(numberColumnRenderer); + numbersColumn.setPreferredWidth(110); + + // Finish setting up the table. + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + + frame.add(scrollpane); + frame.setSize(500, 200); + return frame; + } +} diff --git a/test/jdk/javax/swing/JTable/IllegalStateException.java b/test/jdk/javax/swing/JTable/IllegalStateException.java new file mode 100644 index 00000000000..427b81ab2d9 --- /dev/null +++ b/test/jdk/javax/swing/JTable/IllegalStateException.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.BevelBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4133143 + * @summary Illegal State exception in ComboBox editor in table + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual IllegalStateException + */ + +public class IllegalStateException { + private static final String INSTRUCTIONS = """ + Click on a cell in the first column, delete the contents but leave the editor with focus. + Click on the third column popping up a combo box. + Verify that the text editor loses focus. + If it does, press "pass", otherwise press "fail". + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(IllegalStateException::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("IllegalStateException"); + + // Take the dummy data from SwingSet. + final String[] names = {"First Name", "Last Name", "Favorite Color", + "Favorite Number", "Vegetarian"}; + final Object[][] data = { + {"Mark", "Andrews", "Red", 2, true}, + {"Tom", "Ball", "Blue", 99, false}, + {"Alan", "Chung", "Green", 838, false}, + {"Jeff", "Dinkins", "Turquois", 8, true}, + {"Amy", "Fowler", "Yellow", 3, false}, + {"Brian", "Gerhold", "Green", 0, false}, + {"James", "Gosling", "Pink", 21, false}, + {"David", "Karlton", "Red", 1, false}, + {"Dave", "Kloba", "Yellow", 14, false}, + {"Peter", "Korn", "Purple", 12, false}, + {"Phil", "Milne", "Purple", 3, false}, + {"Dave", "Moore", "Green", 88, false}, + {"Hans", "Muller", "Maroon", 5, false}, + {"Rick", "Levenson", "Blue", 2, false}, + {"Tim", "Prinzing", "Blue", 22, false}, + {"Chester", "Rose", "Black", 0, false}, + {"Ray", "Ryan", "Gray", 77, false}, + {"Georges", "Saab", "Red", 4, false}, + {"Willie", "Walker", "Phthalo Blue", 4, false}, + {"Kathy", "Walrath", "Blue", 8, false}, + {"Arnaud", "Weber", "Green", 44, false} + }; + + // Create a model of the data. + TableModel dataModel = new AbstractTableModel() { + // These methods always need to be implemented. + public int getColumnCount() { + return names.length; + } + + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + // The default implementations of these methods in + // AbstractTableModel would work, but we can refine them. + public String getColumnName(int column) { + return names[column]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public boolean isCellEditable(int row, int col) { + return true; + } + + public void setValueAt(Object aValue, int row, int column) { + System.out.println("Setting value to: " + aValue); + data[row][column] = aValue; + } + }; + + // Create the table + JTable tableView = new JTable(dataModel); + // Turn off auto-resizing so that we can set column sizes programmatically. + // In this mode, all columns will get their preferred widths, as set blow. + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // Create a combo box to show that you can use one in a table. + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Red"); + comboBox.addItem("Orange"); + comboBox.addItem("Yellow"); + comboBox.addItem("Green"); + comboBox.addItem("Blue"); + comboBox.addItem("Indigo"); + comboBox.addItem("Violet"); + + TableColumn colorColumn = tableView.getColumn("Favorite Color"); + // Use the combo box as the editor in the "Favorite Color" column. + colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + // Set a pink background and tooltip for the Color column renderer. + DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer(); + colorColumnRenderer.setBackground(Color.pink); + colorColumnRenderer.setToolTipText("Click for combo box"); + colorColumn.setCellRenderer(colorColumnRenderer); + + // Set a tooltip for the header of the colors column. + TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer(); + if (headerRenderer instanceof DefaultTableCellRenderer) + ((DefaultTableCellRenderer) headerRenderer).setToolTipText("Hi Mom!"); + + // Set the width of the "Vegetarian" column. + TableColumn vegetarianColumn = tableView.getColumn("Vegetarian"); + vegetarianColumn.setPreferredWidth(100); + + // Show the values in the "Favorite Number" column in different colors. + TableColumn numbersColumn = tableView.getColumn("Favorite Number"); + DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() { + public void setValue(Object value) { + int cellValue = (value instanceof Number) ? ((Number) value).intValue() : 0; + setForeground((cellValue > 30) ? Color.black : Color.red); + setText((value == null) ? "" : value.toString()); + } + }; + numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT); + numbersColumn.setCellRenderer(numberColumnRenderer); + numbersColumn.setPreferredWidth(110); + + // Finish setting up the table. + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + + frame.add(scrollpane); + frame.setSize(500, 200); + return frame; + } +} diff --git a/test/jdk/javax/swing/JTable/bug4139910.java b/test/jdk/javax/swing/JTable/bug4139910.java new file mode 100644 index 00000000000..c9d6d62cf0c --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4139910.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +/* + * @test + * @bug 4139910 + * @summary Column resize mouse pointer doesn't display in non-resizable JTable. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4139910 + */ + +public class bug4139910 { + private static final String INSTRUCTIONS = """ + Move mouse pointer to the position between "A" and "B" headers. + If mouse pointer does not change its shape then test passes. If + it does then test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4139910::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4139910"); + + String[] colName = {"A", "B"}; + JTable tbl = new JTable(new DefaultTableModel(colName, 6)); + tbl.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + tbl.getTableHeader().setReorderingAllowed(false); + tbl.getTableHeader().setResizingAllowed(false); + JScrollPane sp = new JScrollPane(tbl); + frame.add(sp); + + frame.pack(); + return frame; + } +} diff --git a/test/jdk/javax/swing/JTable/bug4226181.java b/test/jdk/javax/swing/JTable/bug4226181.java new file mode 100644 index 00000000000..70749cf5d55 --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4226181.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; + +/* + * @test + * @bug 4226181 + * @summary Tests that JTable setModel() correctly re-sizes and counts columns + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4226181 + */ + +public class bug4226181 { + private static final String INSTRUCTIONS = """ + Take a look at the table and remember the number of columns you see. + Now press the "setModel" button. If the number of columns has changed, + then test fails, otherwise it passes. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4226181::createTestUI) + .build() + .awaitAndCheck(); + } + + static class TestModel extends AbstractTableModel { + public int getRowCount() { + return 5; + } + + public int getColumnCount() { + return 7; + } + + public Object getValueAt(int row, int column) { + return row + ":" + column; + } + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4226181"); + TestModel testModel = new TestModel(); + final JTable t = new JTable(testModel); + JButton b = new JButton("setModel"); + b.addActionListener(ae -> t.setModel(new TestModel())); + t.setCellSelectionEnabled(true); + JPanel p1 = new JPanel(new GridLayout(1, 2)); + p1.add(new JLabel("dummy")); + p1.add(t); + frame.add(p1); + frame.add(b, BorderLayout.SOUTH); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/javax/swing/JTable/bug4239157.java b/test/jdk/javax/swing/JTable/bug4239157.java new file mode 100644 index 00000000000..025af1615e0 --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4239157.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.DefaultCellEditor; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; + +/* + * @test + * @bug 4239157 + * @summary Tests that JTable performs cell validation properly + * (i.e. does not accept entries for which stopCellEditing() + * returns false) + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4239157 + */ + +public class bug4239157 { + private static final String INSTRUCTIONS = """ + You see a JTable having one row and two columns. + Click in the very first cell (where "click here" is displayed). + Edit its content (e.g. type some letters) and press right arrow key. + The edited cell should stay active, its content shouldn't change. + The right cell (that with text "inactive forever") shouldn't become active. + The same should be true when you press Tab key. + If it is so, test passes, otherwise it fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4239157::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4239157"); + JTable table = new JTable(new Object[][]{{"click here", + "inactive forever"}}, + new Object[]{"1", "2"}); + frame.add("Center", table); + TableColumn column = table.getColumn("1"); + TableCellEditor editor = new TestEditor(new JTextField()); + column.setCellEditor(editor); + + frame.pack(); + return frame; + } + + static class TestEditor extends DefaultCellEditor { + public TestEditor(JTextField tf) { + super(tf); + } + + public boolean stopCellEditing() { + return false; + } + } +} From ade67df0f363cb95434832f750ac901c1c75c29c Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 01:04:48 +0000 Subject: [PATCH 029/901] 8354233: Open some JTable bugs 6 Reviewed-by: kizune --- test/jdk/javax/swing/JTable/bug4129401.java | 87 ++++++++++++ test/jdk/javax/swing/JTable/bug4193727.java | 135 ++++++++++++++++++ test/jdk/javax/swing/JTable/bug4242631.java | 144 ++++++++++++++++++++ 3 files changed, 366 insertions(+) create mode 100644 test/jdk/javax/swing/JTable/bug4129401.java create mode 100644 test/jdk/javax/swing/JTable/bug4193727.java create mode 100644 test/jdk/javax/swing/JTable/bug4242631.java diff --git a/test/jdk/javax/swing/JTable/bug4129401.java b/test/jdk/javax/swing/JTable/bug4129401.java new file mode 100644 index 00000000000..37765d34698 --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4129401.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.TableColumn; + +/* + * @test + * @bug 4129401 + * @summary Tests that keystroking for combobox cell editor in JTable works + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4129401 + */ + +public class bug4129401 { + private static final String INSTRUCTIONS = """ + 1. Move the mouse cursor to the cell "CELL 2 1", + which contains JComboBox and click left mouse button + to drop down combobox list. + 2. Change selected item in the combobox list + using up and down arrows. + 3. Press Esc. JComboBox drop down list should hide. + If all was successful then test passes, else test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4129401::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + Object data[][] = new Object[4][2]; + JComboBox cb = new JComboBox(); + cb.addItem("Item1"); + cb.addItem("Item2"); + cb.addItem("Item3"); + cb.addItem("Item4"); + data[0][0] = "CELL 0 0"; + data[0][1] = "CELL 0 1"; + data[1][0] = "CELL 1 0"; + data[1][1] = "CELL 1 1"; + data[2][0] = "CELL 2 0"; + data[2][1] = "CELL 2 1"; + data[3][0] = "CELL 3 0"; + data[3][1] = "CELL 3 1"; + String[] str = {"Column 0", "Column 1"}; + JTable tbl = new JTable(data, str); + JScrollPane sp = new JScrollPane(tbl); + + TableColumn col = tbl.getColumn("Column 1"); + col.setCellEditor(new DefaultCellEditor(cb)); + + JFrame f = new JFrame("4129401 test"); + f.getContentPane().add(sp); + f.setBounds(100, 100, 300, 300); + return f; + } +} diff --git a/test/jdk/javax/swing/JTable/bug4193727.java b/test/jdk/javax/swing/JTable/bug4193727.java new file mode 100644 index 00000000000..2ef4159e90c --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4193727.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FontMetrics; +import java.util.Vector; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +/* + * @test + * @bug 4193727 + * @summary Tests that resizing JTable via TableColumn's + * setWidth(int) repaints correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4193727 + */ + +public class bug4193727 { + static EnhancedJTable tblResults; + static JButton bTest = new JButton("Resize"); + + private static final String INSTRUCTIONS = """ + Push button "Resize". + If either of the following happen, test fails: + 1) The size of the columns change + 2) The JTable is not repainted correctly + + Otherwise test passes. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4193727::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4193727"); + Vector v = new Vector(); + Vector data = new Vector(); + Vector cols = new Vector(); + + cols.add("Name"); + cols.add("Address"); + data.add("Steve"); + data.add("100 East Main Street"); + v.add(data); + + data.add("Richard"); + data.add("99 Main Road"); + v.add(data); + + frame.setLayout(new BorderLayout()); + tblResults = new EnhancedJTable(v, cols); + MyTableHeader mth = new MyTableHeader(); + for (int i = 0; i < tblResults.getColumnCount(); i++) + tblResults.getColumnModel().getColumn(i).setHeaderRenderer(mth.getTHR()); + tblResults.setAutoResizeMode(EnhancedJTable.AUTO_RESIZE_OFF); + + JScrollPane pane = new JScrollPane(tblResults); + frame.add(pane, BorderLayout.CENTER); + JPanel panel = new JPanel(); + panel.add(bTest); + frame.add(panel, BorderLayout.EAST); + bTest.addActionListener(e -> tblResults.autoSizeColumns()); + frame.setSize(300, 200); + return frame; + } +} + +class MyTableHeader extends TableColumn { + public TableCellRenderer getTHR() { + return createDefaultHeaderRenderer(); + } +} + +class EnhancedJTable extends JTable { + public EnhancedJTable(Vector data, Vector colNames) { + super(data, colNames); + } + + public synchronized void autoSizeColumns() { + setAutoResizeMode(AUTO_RESIZE_OFF); + int colcnt = getColumnCount(); + int rowcnt = getRowCount(); + + for (int i = 0; i < colcnt; i++) { + // get the max column width needed + Component cell = getColumnModel().getColumn(i).getHeaderRenderer() + .getTableCellRendererComponent(this, null, false, false, -1, i); + FontMetrics fm = cell.getFontMetrics(cell.getFont()); + int max = SwingUtilities.computeStringWidth(fm, getColumnModel().getColumn(i).getHeaderValue() + .toString() + " "); + for (int j = 0; j < rowcnt; j++) { + // add 2 spaces to account for gutter + int width = SwingUtilities.computeStringWidth(fm, getValueAt(j, i).toString() + " "); + if (max < width) max = width; + } + // set the new column width + getColumnModel().getColumn(i).setWidth(max); + } + } +} diff --git a/test/jdk/javax/swing/JTable/bug4242631.java b/test/jdk/javax/swing/JTable/bug4242631.java new file mode 100644 index 00000000000..6e9d1eddc32 --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4242631.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.util.ArrayList; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; + +/* + * @test + * @bug 4242631 + * @summary Tests that JTable repaints itself correctly after a record + * has been removed and added to the table model. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4242631 + */ + +public class bug4242631 { + private static JButton addButton; + private static JButton removeButton; + private static JButton bothButton; + private static SimpleTableModel tableModel; + + private static final String INSTRUCTIONS = """ + Press Add button to add a record to the table. The record added should + have number 0. Then press Remove/Add button some times. The record number + should increase as you press. If it does not, test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4242631::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4242631"); + GridBagLayout grid = new GridBagLayout(); + + frame.setLayout(grid); + GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(2, 2, 2, 2); + + // Add button. + c.gridx = 0; + c.gridy = 0; + grid.setConstraints(addButton = new JButton("Add"), c); + frame.add(addButton); + + // Edit button. + c.gridx = 1; + c.gridy = 0; + grid.setConstraints(removeButton = new JButton("Remove"), c); + frame.add(removeButton); + + // Remove button. + c.gridx = 2; + c.gridy = 0; + grid.setConstraints(bothButton = new JButton("Remove/Add"), c); + frame.add(bothButton); + + // Table. + c.gridx = 0; + c.gridy = 1; + c.gridwidth = 6; + c.gridheight = 0; + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1.0; + c.weighty = 1.0; + JScrollPane scroll = null; + tableModel = new SimpleTableModel(); + grid.setConstraints(scroll = new JScrollPane(new JTable(tableModel)), c); + frame.add(scroll); + + // Create some action listeners. + addButton.addActionListener(event -> tableModel.addRow()); + removeButton.addActionListener(event -> tableModel.removeRow()); + bothButton.addActionListener(event -> tableModel.removeThenAddRow()); + + frame.pack(); + return frame; + } + + static class SimpleTableModel extends AbstractTableModel { + int counter = 0; + ArrayList list = new ArrayList(); + + public SimpleTableModel() {} + public int getColumnCount() { return 1; } + public int getRowCount() { return list.size(); } + + public Object getValueAt(int row, int col) { + String str = (String) list.get(row); + return str;// + "." + col; + } + + public void addRow() { + list.add("" + counter++); + fireTableRowsInserted(list.size() - 1, list.size() - 1); + } + + public void removeRow() { + if (list.size() == 0) return; + list.remove(list.size() - 1); + fireTableRowsDeleted(list.size(), list.size()); + } + + public void removeThenAddRow() { + if (list.size() == 0) return; + removeRow(); + addRow(); + } + } +} From f880fa91dce7b8844cfa4e95caa3a982e280165a Mon Sep 17 00:00:00 2001 From: Tejesh R Date: Tue, 22 Apr 2025 03:09:45 +0000 Subject: [PATCH 030/901] 8352793: Open source several AWT TextComponent tests - Batch 1 Reviewed-by: prr, serb --- .../awt/TextComponent/BackgroundTest.java | 127 ++++++++++++++++++ .../java/awt/TextComponent/DisableTest.java | 98 ++++++++++++++ .../java/awt/TextComponent/ModifiersTest.java | 85 ++++++++++++ .../awt/TextComponent/TextFieldMargin.java | 67 +++++++++ 4 files changed, 377 insertions(+) create mode 100644 test/jdk/java/awt/TextComponent/BackgroundTest.java create mode 100644 test/jdk/java/awt/TextComponent/DisableTest.java create mode 100644 test/jdk/java/awt/TextComponent/ModifiersTest.java create mode 100644 test/jdk/java/awt/TextComponent/TextFieldMargin.java diff --git a/test/jdk/java/awt/TextComponent/BackgroundTest.java b/test/jdk/java/awt/TextComponent/BackgroundTest.java new file mode 100644 index 00000000000..543f2cfd893 --- /dev/null +++ b/test/jdk/java/awt/TextComponent/BackgroundTest.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4258667 4405602 + * @summary Make sure TextComponents are grayed out when non-editable + * if the background color has not been set by client code. + * Make sure TextComponents are not grayed out when non-editable + * if the background color has been set by client code. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual BackgroundTest + */ + +import java.awt.Button; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.TextArea; +import java.awt.TextField; + +public class BackgroundTest { + private static final String enableString = "EnableText"; + private static final String disableString = "DisableText"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. When the frame appears, it should have a blue background. + 2. The first TextField and TextArea will be the default color. + The second TextField and TextArea will be green. + 3. Press the "DisableText" button. + The first TextField and TextArea should change colors to the + default disabled color. On Windows, this is usually gray. + On linux and macos it will match the environment settings. + If the TextField or the TextArea do not change colors as described, + the test FAILS. + 4. The second TextField and TextArea should still be green. + If either of them are not green, the test FAILS. + Press the "EnableText" button (same button as before). + The first TextField and TextArea should return to their + original colors as described in the first paragraph. If they + do not, the test FAILS. + 5. The second TextField and TextArea should still be green. + If either of them are not green, the test FAILS. + Otherwise, the test PASSES. + """; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(BackgroundTest::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Background Test"); + frame.setLayout(new FlowLayout()); + TextField tf = new TextField(30); + TextArea ta = new TextArea(4, 30); + TextField setTf = new TextField(30); + TextArea setTa = new TextArea(4, 30); + Button enableButton = new Button(disableString); + + enableButton.setBackground(Color.red); + frame.setSize(500, 250); + + frame.setBackground(Color.blue); + + tf.setText("Background not set - should be default"); + tf.setEditable(true); + frame.add(tf); + ta.setText("Background not set - should be default"); + ta.setEditable(true); + frame.add(ta); + + setTf.setText("Background is set - should be Green"); + setTf.setBackground(Color.green); + setTf.setEditable(true); + frame.add(setTf); + setTa.setText("Background is set - should be Green"); + setTa.setBackground(Color.green); + setTa.setEditable(true); + frame.add(setTa); + + enableButton.addActionListener(e -> { + boolean currentlyEditable = tf.isEditable(); + + if (currentlyEditable) { + tf.setEditable(false); + ta.setEditable(false); + setTf.setEditable(false); + setTa.setEditable(false); + enableButton.setLabel(enableString); + } else { + tf.setEditable(true); + ta.setEditable(true); + setTf.setEditable(true); + setTa.setEditable(true); + enableButton.setLabel(disableString); + } + }); + frame.add(enableButton); + return frame; + } +} \ No newline at end of file diff --git a/test/jdk/java/awt/TextComponent/DisableTest.java b/test/jdk/java/awt/TextComponent/DisableTest.java new file mode 100644 index 00000000000..820b9c8bd30 --- /dev/null +++ b/test/jdk/java/awt/TextComponent/DisableTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2005, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5042122 + * @summary Verifies the TextComponent is grayed out when disabled + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DisableTest + */ + +import javax.swing.BoxLayout; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Component; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ActionListener; +import java.util.Vector; +import java.util.Iterator; + +public class DisableTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click "Enable" and "Disable" buttons and verify the text + components are disabled and enabled correctly. + 2. Verify that the disabled text components are grayed + out and are uneditable. + 3. Click PASS or FAIL accordingly. + """; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(DisableTest::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("TextComponent Disabled test"); + frame.setLayout(new BorderLayout()); + frame.setSize(200, 200); + final Vector comps = new Vector(); + comps.add(new TextField("TextField")); + TextArea ta = new TextArea("TextArea", 2, 100, TextArea.SCROLLBARS_NONE); + comps.add(ta); + Panel pc = new Panel(); + pc.setLayout(new BoxLayout(pc, BoxLayout.Y_AXIS)); + Iterator iter = comps.iterator(); + while (iter.hasNext()) { + Component c = (Component) iter.next(); + c.setEnabled(false); + pc.add(c); + } + frame.add(pc, BorderLayout.CENTER); + Panel p = new Panel(); + final Button be = new Button("Enable"); + final Button bd = new Button("Disable"); + p.add(be); + p.add(bd); + ActionListener al = ev -> { + boolean enable = (ev.getSource() == be); + Iterator iterator = comps.iterator(); + while (iterator.hasNext()) { + Component c = (Component) iterator.next(); + c.setEnabled(enable); + } + }; + be.addActionListener(al); + bd.addActionListener(al); + frame.add(p, BorderLayout.SOUTH); + return frame; + } +} diff --git a/test/jdk/java/awt/TextComponent/ModifiersTest.java b/test/jdk/java/awt/TextComponent/ModifiersTest.java new file mode 100644 index 00000000000..e9e76a9b694 --- /dev/null +++ b/test/jdk/java/awt/TextComponent/ModifiersTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4035364 + * @summary Checks that Caps Lock key works + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ModifiersTest + */ + +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.TextArea; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class ModifiersTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Type some text in the TextArea in upper and lowercase, + using the Caps Lock ON/OFF. + 2. If Caps Lock toggles correctly and you are able to type in + both cases, the test PASS. Else Test FAILS. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ModifiersTest::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Modifiers Test"); + frame.setLayout(new GridLayout(1, 1)); + frame.addKeyListener(new KeyChecker()); + frame.setLayout(new GridLayout(2, 1)); + Label label = new Label("See if you can type in upper and lowercase using Caps Lock:"); + frame.add(label); + TextArea ta = new TextArea(); + frame.add(ta); + ta.addKeyListener(new KeyChecker()); + ta.requestFocus(); + frame.setSize(400, 300); + return frame; + } +} + +// a KeyListener for debugging purposes +class KeyChecker extends KeyAdapter { + public void keyPressed(KeyEvent ev) { + System.out.println(ev); + } + + public void keyReleased(KeyEvent ev) { + System.out.println(ev); + } + + public void keyTyped(KeyEvent ev) { + System.out.println(ev); + } +} diff --git a/test/jdk/java/awt/TextComponent/TextFieldMargin.java b/test/jdk/java/awt/TextComponent/TextFieldMargin.java new file mode 100644 index 00000000000..6baf144254c --- /dev/null +++ b/test/jdk/java/awt/TextComponent/TextFieldMargin.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4129511 + * @summary Tests that TextField margins are not exceedingly wide + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TextFieldMargin + */ + +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.TextArea; +import java.awt.TextField; + +public class TextFieldMargin { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Examine the TextField, Label, and TextArea to see + that the text is vertically aligned along the left + 2. If all are aligned along the left, then test PASS, + else test FAILS. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(TextFieldMargin::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Frame with a text field & a label"); + frame.setLayout(new GridLayout(5, 1)); + TextField text_field = new TextField("Left Textfield"); + frame.add(text_field); + Label label = new Label("Left Label"); + frame.add(label); + TextArea text_area = new TextArea("Left Textfield"); + frame.add(text_area); + frame.setBounds(50, 50, 300, 300); + return frame; + } +} From 0be3f163ed12db305673928d97f975d6f6bb6b1c Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Tue, 22 Apr 2025 03:29:59 +0000 Subject: [PATCH 031/901] 8341608: jdeps in JDK 23 crashes when parsing signatures while jdeps in JDK 22 works fine Reviewed-by: jpai, henryjen --- .../com/sun/tools/jdeps/ClassFileReader.java | 190 +++++------------- .../com/sun/tools/jdeps/Dependencies.java | 2 +- .../com/sun/tools/jdeps/DependencyFinder.java | 12 +- .../tools/jdeps/MalformedClassesTest.java | 129 ++++++++++++ test/langtools/tools/jdeps/TEST.properties | 2 + .../com/sun/tools/jdeps/JdepsAccess.java | 34 ++++ .../lib/compiler/InMemoryJavaCompiler.java | 8 +- test/lib/jdk/test/lib/util/JarUtils.java | 20 +- 8 files changed, 241 insertions(+), 156 deletions(-) create mode 100644 test/langtools/tools/jdeps/MalformedClassesTest.java create mode 100644 test/langtools/tools/jdeps/TEST.properties create mode 100644 test/langtools/tools/jdeps/jdk.jdeps/com/sun/tools/jdeps/JdepsAccess.java diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java index fc1bf5302d6..72dc4e72899 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, 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 @@ -41,10 +41,9 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; -import java.util.NoSuchElementException; import java.util.Set; +import java.util.function.Consumer; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.stream.Collectors; @@ -102,6 +101,10 @@ public List skippedEntries() { return skippedEntries; } + protected void skipEntry(Throwable ex, String entryPath) { + skippedEntries.add(String.format("%s: %s", ex.toString(), entryPath)); + } + /** * Returns all entries in this archive. */ @@ -135,8 +138,15 @@ public ClassModel getClassFile(String name) throws IOException { return null; } - public Iterable getClassFiles() throws IOException { - return FileIterator::new; + public void forEachClassFile(Consumer handler) throws IOException { + if (baseFileName.endsWith(".class")) { + // propagate ClassFileError for single file + try { + handler.accept(readClassFile(path)); + } catch (ClassFileError ex) { + skipEntry(ex, path.toString()); + } + } } protected ClassModel readClassFile(Path p) throws IOException { @@ -167,33 +177,6 @@ static boolean isClass(Path file) { public void close() throws IOException { } - class FileIterator implements Iterator { - int count; - FileIterator() { - this.count = 0; - } - public boolean hasNext() { - return count == 0 && baseFileName.endsWith(".class"); - } - - public ClassModel next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - try { - ClassModel cf = readClassFile(path); - count++; - return cf; - } catch (IOException e) { - throw new ClassFileError(e); - } - } - - public void remove() { - throw new UnsupportedOperationException("Not supported yet."); - } - } - public String toString() { return path.toString(); } @@ -241,42 +224,17 @@ public ClassModel getClassFile(String name) throws IOException { return null; } - public Iterable getClassFiles() throws IOException { - final Iterator iter = new DirectoryIterator(); - return () -> iter; - } - - class DirectoryIterator implements Iterator { - private final List entries; - private int index = 0; - DirectoryIterator() throws IOException { - List paths = null; - try (Stream stream = Files.walk(path, Integer.MAX_VALUE)) { - paths = stream.filter(ClassFileReader::isClass).toList(); - - } - this.entries = paths; - this.index = 0; - } - - public boolean hasNext() { - return index != entries.size(); - } - - public ClassModel next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - Path path = entries.get(index++); - try { - return readClassFile(path); - } catch (IOException e) { - throw new ClassFileError(e); - } - } - - public void remove() { - throw new UnsupportedOperationException("Not supported yet."); + @Override + public void forEachClassFile(Consumer handler) throws IOException { + try (Stream stream = Files.walk(path, Integer.MAX_VALUE)) { + stream.filter(ClassFileReader::isClass) + .forEach(e -> { + try { + handler.accept(readClassFile(e)); + } catch (ClassFileError | IOException ex) { + skipEntry(ex, e.toString()); + } + }); } } } @@ -314,14 +272,15 @@ private static JarFile openJarFile(File f, Runtime.Version version) return jf; } + private static boolean isJarEntryClass(JarEntry e) { + return e.getName().endsWith(".class"); + } + protected Set scan() { - try (JarFile jf = openJarFile(path.toFile(), version)) { - return jf.versionedStream().map(JarEntry::getName) - .filter(n -> n.endsWith(".class")) - .collect(Collectors.toSet()); - } catch (IOException e) { - throw new UncheckedIOException(e); - } + return jarfile.versionedStream() + .filter(JarFileReader::isJarEntryClass) + .map(JarEntry::getName) + .collect(Collectors.toSet()); } public ClassModel getClassFile(String name) throws IOException { @@ -358,76 +317,17 @@ protected ClassModel readClassFile(JarFile jarfile, JarEntry e) throws IOExcepti } } - public Iterable getClassFiles() throws IOException { - final Iterator iter = new JarFileIterator(this, jarfile); - return () -> iter; - } - } - - class JarFileIterator implements Iterator { - protected final JarFileReader reader; - protected Iterator entries; - protected JarFile jf; - protected JarEntry nextEntry; - protected ClassModel cf; - JarFileIterator(JarFileReader reader) { - this(reader, null); - } - JarFileIterator(JarFileReader reader, JarFile jarfile) { - this.reader = reader; - setJarFile(jarfile); - } - - void setJarFile(JarFile jarfile) { - if (jarfile == null) return; - - this.jf = jarfile; - this.entries = jarfile.versionedStream().iterator(); - this.nextEntry = nextEntry(); - } - - public boolean hasNext() { - if (nextEntry != null && cf != null) { - return true; - } - while (nextEntry != null) { - try { - cf = reader.readClassFile(jf, nextEntry); - return true; - } catch (ClassFileError | IOException ex) { - skippedEntries.add(String.format("%s: %s (%s)", - ex.getMessage(), - nextEntry.getName(), - jf.getName())); - } - nextEntry = nextEntry(); - } - return false; - } - - public ClassModel next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - ClassModel classFile = cf; - cf = null; - nextEntry = nextEntry(); - return classFile; - } - - protected JarEntry nextEntry() { - while (entries.hasNext()) { - JarEntry e = entries.next(); - String name = e.getName(); - if (name.endsWith(".class")) { - return e; - } - } - return null; - } - - public void remove() { - throw new UnsupportedOperationException("Not supported yet."); + @Override + public void forEachClassFile(Consumer handler) throws IOException { + jarfile.versionedStream() + .filter(JarFileReader::isJarEntryClass) + .forEach(e -> { + try { + handler.accept(readClassFile(jarfile, e)); + } catch (ClassFileError | IOException ex) { + skipEntry(ex, e.getName() + " (" + jarfile.getName() + ")"); + } + }); } } } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Dependencies.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Dependencies.java index 90682c478c7..d7df5ba77c2 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Dependencies.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Dependencies.java @@ -79,7 +79,7 @@ public static class ClassFileError extends Error { private static final long serialVersionUID = 4111110813961313203L; public ClassFileError(Throwable cause) { - initCause(cause); + super(cause.getMessage(), cause); } } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java index 179043bc578..d2bf83a50b0 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/DependencyFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, 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 @@ -173,9 +173,9 @@ private Optional>> parse(Archive archive, Finder finder trace("parsing %s %s%n", archive.getName(), archive.getPathName()); FutureTask> task = new FutureTask<>(() -> { Set targets = new HashSet<>(); - for (var cf : archive.reader().getClassFiles()) { + archive.reader().forEachClassFile(cf -> { if (cf.isModuleInfo()) - continue; + return; String classFileName; try { @@ -187,11 +187,11 @@ private Optional>> parse(Archive archive, Finder finder // filter source class/archive String cn = classFileName.replace('/', '.'); if (!finder.accept(archive, cn, cf.flags())) - continue; + return; // tests if this class matches the -include if (!filter.matches(cn)) - continue; + return; for (Dependency d : finder.findDependencies(cf)) { if (filter.accepts(d)) { @@ -203,7 +203,7 @@ private Optional>> parse(Archive archive, Finder finder } parsedClasses.putIfAbsent(d.getOrigin(), archive); } - } + }); return targets; }); tasks.add(task); diff --git a/test/langtools/tools/jdeps/MalformedClassesTest.java b/test/langtools/tools/jdeps/MalformedClassesTest.java new file mode 100644 index 00000000000..baa94ad78e2 --- /dev/null +++ b/test/langtools/tools/jdeps/MalformedClassesTest.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8341608 + * @summary Tests for jdeps tool with jar files with malformed classes + * @library lib /test/lib + * @build jdk.jdeps/com.sun.tools.jdeps.* + * @run junit MalformedClassesTest + */ + +import java.io.IOException; +import java.lang.classfile.ClassFile; +import java.lang.classfile.ClassTransform; +import java.lang.classfile.attribute.SignatureAttribute; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + +import com.sun.tools.jdeps.JdepsAccess; +import jdk.test.lib.compiler.InMemoryJavaCompiler; +import jdk.test.lib.helpers.ClassFileInstaller; +import jdk.test.lib.util.JarUtils; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class MalformedClassesTest { + + static Stream invalidArchives() throws Exception { + var jarPath = Path.of("malformed-signature.jar"); + var compiledClasses = InMemoryJavaCompiler.compile(Map.ofEntries( + Map.entry("one.One", """ + package one; + + import java.util.Optional; + + class One { + Optional st = Optional.empty(); + } + """), + Map.entry("two.Two", """ + package two; + + import java.lang.invoke.*; + + class Two { + int i; + static final VarHandle I; + + static { + try { + I = MethodHandles.lookup().findVarHandle(Two.class, "i", int.class); + } catch (ReflectiveOperationException ex) { + throw new ExceptionInInitializerError(ex); + } + } + } + """) + )); + var updated = ClassFile.of().transformClass(ClassFile.of().parse(compiledClasses.get("one.One")), + ClassTransform.transformingFields((fb, fe) -> { + if (fe instanceof SignatureAttribute) { + fb.with(SignatureAttribute.of(fb.constantPool().utf8Entry("Invalid string"))); + } else { + fb.with(fe); + } + })); + var classes = new HashMap<>(compiledClasses); + classes.put("one.One", updated); + JarUtils.createJarFromClasses(jarPath, classes); + + Path flatDir = Path.of("flatDir"); + Files.createDirectories(flatDir); + for (var entry : classes.entrySet()) { + ClassFileInstaller.writeClassToDisk(entry.getKey(), entry.getValue(), flatDir.toString()); + } + + return Stream.of( + Arguments.of("directory", flatDir, "One.class"), + Arguments.of("jar", jarPath, "one/One.class (malformed-signature.jar)") + ); + } + + @ParameterizedTest + @MethodSource("invalidArchives") + public void testMalformedSignature(String kind, Path path, String entryName) throws IOException { + try (var jdeps = JdepsUtil.newCommand("jdeps")) { + jdeps.addRoot(path); + var analyzer = jdeps.getDepsAnalyzer(); + analyzer.run(); + var archives = JdepsAccess.depsAnalyzerArchives(analyzer); + assertEquals(1, archives.size(), archives::toString); + var archive = archives.iterator().next(); + var skippedEntries = archive.reader().skippedEntries(); + assertEquals(1, skippedEntries.size(), skippedEntries::toString); + var message = skippedEntries.getFirst(); + assertTrue(message.contains("ClassFileError"), message); + assertTrue(message.contains("Invalid string"), message); + assertTrue(message.contains(entryName), "\"" + message + "\" does not contain \"" + entryName + "\""); + } + } +} diff --git a/test/langtools/tools/jdeps/TEST.properties b/test/langtools/tools/jdeps/TEST.properties new file mode 100644 index 00000000000..56b5043d3c1 --- /dev/null +++ b/test/langtools/tools/jdeps/TEST.properties @@ -0,0 +1,2 @@ +modules = \ + jdk.jdeps/com.sun.tools.jdeps diff --git a/test/langtools/tools/jdeps/jdk.jdeps/com/sun/tools/jdeps/JdepsAccess.java b/test/langtools/tools/jdeps/jdk.jdeps/com/sun/tools/jdeps/JdepsAccess.java new file mode 100644 index 00000000000..16229153e13 --- /dev/null +++ b/test/langtools/tools/jdeps/jdk.jdeps/com/sun/tools/jdeps/JdepsAccess.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.jdeps; + +import java.util.Set; + +public final class JdepsAccess { + public static Set depsAnalyzerArchives(DepsAnalyzer analyzer) { + return analyzer.archives; + } + + private JdepsAccess() {} +} diff --git a/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java b/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java index 4722ef3b67a..7a289bbcce5 100644 --- a/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java +++ b/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, 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 @@ -208,8 +208,10 @@ public String getClassName() { } /** - * Compiles the list of classes with the given map of name and source code. - * This overloaded version of compile is useful for batch compile use cases. + * Compiles the list of classes with the given map of binary name and source code. + * This overloaded version of compile is useful for batch compile use cases, or + * if a compilation unit produces multiple class files. Returns a map from + * class binary names to class file content. * * @param inputMap The map containing the name of the class and corresponding source code * @throws RuntimeException if the compilation did not succeed diff --git a/test/lib/jdk/test/lib/util/JarUtils.java b/test/lib/jdk/test/lib/util/JarUtils.java index 3aa4ada5197..9a3d73ee410 100644 --- a/test/lib/jdk/test/lib/util/JarUtils.java +++ b/test/lib/jdk/test/lib/util/JarUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, 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 @@ -131,6 +131,24 @@ public static void createJarFile(Path jarfile, Path dir, String... input) createJarFile(jarfile, dir, paths); } + + /** + * Creates a JAR file from a map of class binary name to class bytes. + * + * @see jdk.test.lib.compiler.InMemoryJavaCompiler#compile(Map) + */ + public static void createJarFromClasses(Path jarfile, Map classes) throws IOException { + try (OutputStream out = Files.newOutputStream(jarfile); + JarOutputStream jos = new JarOutputStream(out)) { + for (var entry : classes.entrySet()) { + String name = entry.getKey().replace('.', '/') + ".class"; + jos.putNextEntry(new JarEntry(name)); + jos.write(entry.getValue()); + jos.closeEntry(); + } + } + } + /** * Updates a JAR file. * From e2cb64674f5b6b4f000ab1e903fbb75416218bb3 Mon Sep 17 00:00:00 2001 From: Tejesh R Date: Tue, 22 Apr 2025 05:56:07 +0000 Subject: [PATCH 032/901] 8343977: Convert java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest to main Reviewed-by: prr, achung --- .../HoveringAndDraggingTest.html | 43 --- .../HoveringAndDraggingTest.java | 285 ++++++------------ 2 files changed, 99 insertions(+), 229 deletions(-) delete mode 100644 test/jdk/java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.html diff --git a/test/jdk/java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.html b/test/jdk/java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.html deleted file mode 100644 index 9fc7f55ceba..00000000000 --- a/test/jdk/java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - HoveringAndDraggingTest - - - -

HoveringAndDraggingTest
Bug ID: 6497109

- -

See the dialog box (usually in upper left corner) for instructions

- - - - diff --git a/test/jdk/java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.java b/test/jdk/java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.java index 753fc490967..646bc6aa6b9 100644 --- a/test/jdk/java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.java +++ b/test/jdk/java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -21,71 +21,122 @@ * questions. */ -/* - test - @bug 6497109 - @summary Mouse cursor icons for TextArea should be correct in case of hovering or dragging mouse over different subcomponents. - @author Konstantin Voloshin: area=awt.TextArea - @run applet/manual=yesno HoveringAndDraggingTest.html -*/ - -/** - * HoveringAndDraggingTest.java - * - * summary: Mouse cursor icons for TextArea should be correct in case - * of hovering or dragging mouse over different subcomponents. - */ - +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; import java.awt.Frame; -import java.awt.Panel; +import java.awt.GridBagLayout; import java.awt.GridLayout; +import java.awt.Panel; import java.awt.TextArea; -import java.awt.Dialog; +import java.util.concurrent.CountDownLatch; -public class HoveringAndDraggingTest extends java.applet.Applet { - public void start() { - String[] instructions = new String[] { - "1. Notice components in test window: main-panel, box-for-text," - +" 2 scroll-sliders, and 4 scroll-buttons.", - "2. Hover mouse over box-for-text." - +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").", - "3. Hover mouse over each of components (see item 1), except for box-for-text." - +" Make sure, that cursor is DefaultCursor (arrow).", - "4. Drag mouse (using any mouse button) from box-for-text to every" - +" component in item 1, and also outside application window." - +" Make sure, that cursor remains TextCursor while mouse button is pressed.", - "5. Repeat item 4 for each other component in item 1, except for box-for-text," - +" _but_ now make sure that cursor is DefaultCursor.", - "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed." - }; - Sysout.createDialogWithInstructions( instructions ); +/* + * @test + * @bug 6497109 + * @summary Mouse cursor icons for TextArea should be correct in case of + * hovering or dragging mouse over different subcomponents. + * @run main/manual HoveringAndDraggingTest + */ + +public class HoveringAndDraggingTest { + static Frame frame; + static Frame instructionsFrame; + static CountDownLatch countDownLatch; + public static CountDownLatch createCountDownLatch() { + return new CountDownLatch(1); + } + public static void main(String[] args) throws Exception { + countDownLatch = createCountDownLatch(); + EventQueue.invokeAndWait(() -> { + initialize(); + showInstructionFrame(); + }); + countDownLatch.await(); + System.out.println("Test Pass"); + } + + public static void initialize() { Panel panel = new Panel(); - panel.setLayout( new GridLayout(3,3) ); + panel.setLayout(new GridLayout(3, 3)); - for( int y=0; y<3; ++y ) { - for( int x=0; x<3; ++x ) { - if( x==1 && y==1 ) { - panel.add( new TextArea( bigString() ) ); + for (int y = 0; y < 3; ++y) { + for (int x = 0; x < 3; ++x) { + if (x == 1 && y == 1) { + panel.add(new TextArea(bigString())); } else { - panel.add( new Panel() ); + panel.add(new Panel()); } } } - Frame frame = new Frame( "TextArea cursor icon test" ); - frame.setSize( 300, 300 ); - frame.add( panel ); - frame.setVisible( true ); + frame = new Frame("TextArea cursor icon test"); + frame.setSize(300, 300); + frame.setLocation(450, 400); + frame.add(panel); + frame.setVisible(true); + } + + static void showInstructionFrame() { + String INSTRUCTIONS = """ + 1. Notice components in test window: main-panel,box-for-text, + 2 scroll-sliders, and 4 scroll-buttons. + 2. Hover mouse over box-for-text. + Make sure, that mouse cursor is TextCursor(a.k.a. \"beam\"). + 3. Hover mouse over each of components (see item 1), + except for box-for-text. + Make sure, that cursor is DefaultCursor (arrow). + 4. Drag mouse (using any mouse button) from box-for-text to every" + component in item 1, and also outside application window." + Make sure, that cursor remains TextCursor + while mouse button is pressed. + 5. Repeat item 4 for each other component in item 1, + except for box-for-text + _but_ now make sure that cursor is DefaultCursor. + 6. If cursor behaves as described in items 2-3-4-5, + then test is PASS otherwise it FAILED. + """; + TextArea textArea = new TextArea(INSTRUCTIONS, 16, 65, TextArea.SCROLLBARS_NONE); + Button passBtn = new Button("PASS"); + Button failBtn = new Button("FAIL"); + Panel btnPanel = new Panel(new GridBagLayout()); + Panel panel = new Panel(new GridBagLayout()); + instructionsFrame = new Frame("Test Instructions"); + passBtn.setMaximumSize(new Dimension(100, 30)); + failBtn.setMaximumSize(new Dimension(100, 30)); + btnPanel.add(passBtn); + btnPanel.add(failBtn); + passBtn.addActionListener(e -> disposeFrames()); + failBtn.addActionListener(e -> { + disposeFrames(); + throw new RuntimeException("Test Failed"); + }); + panel.add(textArea); + panel.add(btnPanel); + instructionsFrame.add(panel); + instructionsFrame.pack(); + instructionsFrame.setLocation(300, 100); + instructionsFrame.setVisible(true); + } + + static void disposeFrames() { + countDownLatch.countDown(); + if (frame != null) { + frame.dispose(); + } + if (instructionsFrame != null) { + instructionsFrame.dispose(); + } } static String bigString() { String s = ""; - for( int lines=0; ; ++lines ) { - for( int symbols=0; symbols<100; ++symbols ) { + for (int lines = 0; ; ++lines) { + for (int symbols = 0; symbols < 100; ++symbols) { s += "0"; } - if( lines<50 ) { + if (lines < 50) { s += "\n"; } else { break; @@ -94,141 +145,3 @@ static String bigString() { return s; } } - - -/**************************************************** - Standard Test Machinery - DO NOT modify anything below -- it's a standard - chunk of code whose purpose is to make user - interaction uniform, and thereby make it simpler - to read and understand someone else's test. - ****************************************************/ - -/** - This is part of the standard test machinery. - It creates a dialog (with the instructions), and is the interface - for sending text messages to the user. - To print the instructions, send an array of strings to Sysout.createDialog - WithInstructions method. Put one line of instructions per array entry. - To display a message for the tester to see, simply call Sysout.println - with the string to be displayed. - This mimics System.out.println but works within the test harness as well - as standalone. - */ - -class Sysout -{ - private static TestDialog dialog; - - public static void createDialogWithInstructions( String[] instructions ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - dialog.printInstructions( instructions ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); - } - - public static void createDialog( ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - String[] defInstr = { "Instructions will appear here. ", "" } ; - dialog.printInstructions( defInstr ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); - } - - - public static void printInstructions( String[] instructions ) - { - dialog.printInstructions( instructions ); - } - - - public static void println( String messageIn ) - { - dialog.displayMessage( messageIn ); - } - -}// Sysout class - -/** - This is part of the standard test machinery. It provides a place for the - test instructions to be displayed, and a place for interactive messages - to the user to be displayed. - To have the test instructions displayed, see Sysout. - To have a message to the user be displayed, see Sysout. - Do not call anything in this dialog directly. - */ -class TestDialog extends Dialog -{ - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog( Frame frame, String name ) - { - super( frame, name ); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); - add( "North", instructionsText ); - - messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); - add("Center", messageText); - - pack(); - - setVisible(true); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions( String[] instructions ) - { - //Clear out any current instructions - instructionsText.setText( "" ); - - //Go down array of instruction strings - - String printStr, remainingStr; - for( int i=0; i < instructions.length; i++ ) - { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i ]; - while( remainingStr.length() > 0 ) - { - //if longer than max then chop off first max chars to print - if( remainingStr.length() >= maxStringLength ) - { - //Try to chop on a word boundary - int posOfSpace = remainingStr. - lastIndexOf( ' ', maxStringLength - 1 ); - - if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; - - printStr = remainingStr.substring( 0, posOfSpace + 1 ); - remainingStr = remainingStr.substring( posOfSpace + 1 ); - } - //else just print - else - { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append( printStr + "\n" ); - - }// while - - }// for - - }//printInstructions() - - //DO NOT call this directly, go through Sysout - public void displayMessage( String messageIn ) - { - messageText.append( messageIn + "\n" ); - System.out.println(messageIn); - } - -}// TestDialog class From d1d7d2569c1745aef778c9b5a62c1bd50735e8a7 Mon Sep 17 00:00:00 2001 From: Tejesh R Date: Tue, 22 Apr 2025 06:23:24 +0000 Subject: [PATCH 033/901] 8353957: Open source several AWT ScrollPane tests - Batch 1 Reviewed-by: psadhukhan --- test/jdk/ProblemList.txt | 1 + .../awt/ScrollPane/ScrollPaneFlicker.java | 215 ++++++++++++++++++ .../java/awt/ScrollPane/ScrollPanePaint.java | 132 +++++++++++ .../awt/ScrollPane/ScrollPositionTest.java | 100 ++++++++ .../ScrollPane/ScrollbarsAsNeededTest.java | 72 ++++++ 5 files changed, 520 insertions(+) create mode 100644 test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java create mode 100644 test/jdk/java/awt/ScrollPane/ScrollPanePaint.java create mode 100644 test/jdk/java/awt/ScrollPane/ScrollPositionTest.java create mode 100644 test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index e1e0a695ebc..3fe0bcf8cdc 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -443,6 +443,7 @@ java/awt/Focus/TranserFocusToWindow/TranserFocusToWindow.java 6848810 macosx-all java/awt/FileDialog/ModalFocus/FileDialogModalFocusTest.java 8194751 linux-all java/awt/image/VolatileImage/BitmaskVolatileImage.java 8133102 linux-all java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java 8203004 linux-all +java/awt/ScrollPane/ScrollPositionTest.java 8040070 linux-all java/awt/ScrollPane/ScrollPaneScrollType/ScrollPaneEventType.java 8296516 macosx-all java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java 7107528 linux-all,macosx-all java/awt/Mouse/MouseDragEvent/MouseDraggedTest.java 8080676 linux-all diff --git a/test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java b/test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java new file mode 100644 index 00000000000..3594ff50f54 --- /dev/null +++ b/test/jdk/java/awt/ScrollPane/ScrollPaneFlicker.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4073822 + * @summary ScrollPane repaints entire window when scrolling fast + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPaneFlicker + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; +import java.awt.Rectangle; +import java.awt.ScrollPane; +import java.awt.Scrollbar; +import java.awt.TextArea; +import java.awt.TextField; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollBar; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +public class ScrollPaneFlicker { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + When scrolling a ScrollPane fast(i.e. holding the down/up arrow + down for a while), the ScrollPane would inexplicably refresh + the entire window. + + 1. Select a type of ScrollPane content from the content menu. + 2. Scroll the content using the up/down/left/right arrows on + the scroll bar. Try scrolling the entire content area using + the scroll arrows-- from top to bottom and left to right. + 3. Verify that the entire pane does not refresh when scrolling + - only the newly exposed areas should be repainting. + 4. Repeat for all content types. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ScrollPaneFlicker::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + return new FlickerFrame(); + } +} + +class FlickerFrame extends Frame { + ScrollPane pane; + + public FlickerFrame() { + super("ScrollPane Flicker Test"); + TextPanel textPanel = new TextPanel(); + GradientPanel gradientPanel = new GradientPanel(); + ComponentPanel componentPanel = new ComponentPanel(); + SwingPanel swingPanel = new SwingPanel(); + MenuBar menubar = new MenuBar(); + Menu testMenu = new Menu("Test Options"); + + pane = new ScrollPane(); + pane.getHAdjustable().setUnitIncrement(8); + pane.getVAdjustable().setUnitIncrement(16); + pane.add(textPanel); + add(pane); + + testMenu.add(makeContentItem("Text Lines", textPanel)); + testMenu.add(makeContentItem("Gradient Fill", gradientPanel)); + testMenu.add(makeContentItem("AWT Components", componentPanel)); + testMenu.add(makeContentItem("Swing Components", swingPanel)); + menubar.add(testMenu); + + setMenuBar(menubar); + setSize(400, 300); + } + + public MenuItem makeContentItem(String title, final Component content) { + MenuItem menuItem = new MenuItem(title); + menuItem.addActionListener( + ev -> { + pane.add(content); + pane.validate(); + } + ); + return menuItem; + } +} + +class GradientPanel extends Canvas { + public void paint(Graphics g) { + // just paint something that'll take a while + int x, y; + int width = getSize().width; + int height = getSize().height; + int step = 8; + + for (x = 0; x < width; x += step) { + for (y = 0; y < height; y += step) { + int red = (255 * y) / height; + int green = (255 * x * y) / (width * height); + int blue = (255 * x) / width; + Rectangle bounds = g.getClipBounds(); + Rectangle fbounds = new Rectangle(x, y, x + step, y + step); + if (bounds.intersects(fbounds)) { + Color color = new Color(red, green, blue); + g.setColor(color); + g.fillRect(x, y, x + step, y + step); + } + } + } + } + + public Dimension getPreferredSize() { + return new Dimension(200, 1000); + } +} + +class TextPanel extends Canvas { + public void paint(Graphics g) { + Font font = new Font("SanSerif", Font.ITALIC, 12); + + g.setFont(font); + // just paint something that'll take a while + int x, y; + int width = getWidth(); + int height = getHeight(); + int step = 16; + + for (x = y = 0; y < height; y += step) { + Rectangle bounds = g.getClipBounds(); + Rectangle tbounds = new Rectangle(x, y - 16, x + width, y); + if (bounds.intersects(tbounds)) { + g.drawString(y + " : The quick brown fox jumps over the lazy dog. " + + "The rain in Spain falls mainly on the plain.", x, y); + } + } + } + + public Dimension getPreferredSize() { + return new Dimension(640, 1000); + } +} + +class ComponentPanel extends Panel { + ComponentPanel() { + add(new Label("Label")); + add(new Button("Button")); + add(new Checkbox("Checkbox")); + Choice c = new Choice(); + c.add("choice"); + java.awt.List l = new java.awt.List(); + l.add("list"); + add(new Scrollbar()); + add(new TextField("TextField")); + add(new TextArea("TextArea")); + add(new Panel()); + add(new Canvas()); + } +} + +class SwingPanel extends JPanel { + SwingPanel() { + add(new JLabel("JLabel")); + add(new JButton("JButton")); + add(new JCheckBox("JCheckBox")); + JComboBox c = new JComboBox(); + JList l = new JList(); + add(new JScrollBar()); + add(new JTextField("This is a JTextField with some text in it to make it longer.")); + add(new JTextArea("This is a JTextArea with some text in it to make it longer.")); + } +} diff --git a/test/jdk/java/awt/ScrollPane/ScrollPanePaint.java b/test/jdk/java/awt/ScrollPane/ScrollPanePaint.java new file mode 100644 index 00000000000..0d7b7779018 --- /dev/null +++ b/test/jdk/java/awt/ScrollPane/ScrollPanePaint.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * Licensed Materials - Property of IBM + * + * (C) Copyright IBM Corporation 1998 All Rights Reserved. + * + * US Government Users Restricted Rights - Use, duplication or disclosure + * restricted by GSA ADP Schedule Contract with IBM Corp. + */ + +/* + * @test + * @bug 4160721 + * @summary AWT ScrollPane painting problem + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollPanePaint + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +public class ScrollPanePaint { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Press the button marked "Toggle" a few times. + 2. The contents of the frame should alternate between + a red panel and a scroll pane containing a green panel. + If this does not happen (specifically, if the scroll + pane does not consistently contain a green panel), + then the test has FAILED. + """; + ScrollPaintTest scrollPaintTest = new ScrollPaintTest(); + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(scrollPaintTest::initialize) + .positionTestUI(WindowLayouts::rightOneColumn) + .build() + .awaitAndCheck(); + } + + private static class ScrollPaintTest implements ActionListener { + static Frame f; + static boolean showScroll; + + public List initialize() { + Frame frame = new Frame("Scrollpane paint test"); + frame.setLayout(new BorderLayout()); + f = new Frame("Scrollpane paint test"); + f.setLayout(new GridLayout(0, 1)); + + Button b = new Button("Toggle"); + b.addActionListener(this); + + frame.add(b, BorderLayout.CENTER); + frame.pack(); + + showScroll = false; + actionPerformed(null); + return List.of(frame, f); + } + + public void actionPerformed(ActionEvent e) { + Container c; + if (!showScroll) { + c = (Container) new TestPanel(new Dimension(100, 100)); + c.setBackground(Color.red); + } else { + c = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); + Panel p = new TestPanel(new Dimension(20, 20)); + p.setBackground(Color.green); + c.add(p); + } + + f.removeAll(); + f.add("Center", c); + f.pack(); + showScroll = !showScroll; + } + } + + private static class TestPanel extends Panel { + Dimension dim; + + TestPanel(Dimension d) { + dim = d; + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + public Dimension getPreferredSize() { + return dim; + } + } + +} diff --git a/test/jdk/java/awt/ScrollPane/ScrollPositionTest.java b/test/jdk/java/awt/ScrollPane/ScrollPositionTest.java new file mode 100644 index 00000000000..9c082a8dfc9 --- /dev/null +++ b/test/jdk/java/awt/ScrollPane/ScrollPositionTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2003, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4008152 + * @summary ScrollPane position does not return correct values + * @key headful + * @run main ScrollPositionTest + */ + +import java.awt.Adjustable; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.ScrollPane; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; + +public class ScrollPositionTest { + static Frame frame; + static int i = 0; + static Point p; + static ScrollPane sp; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() -> { + frame = new Frame("Scroll Position Test"); + frame.setLayout(new BorderLayout()); + frame.setSize(200, 200); + sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); + Canvas canvas = new Canvas(); + canvas.setSize(300, 300); + sp.add(canvas); + frame.add("Center", sp); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + Adjustable saH = sp.getHAdjustable(); + saH.addAdjustmentListener(new TestAdjustmentListener()); + }); + for (i = 0; i < 1000; i++) { + EventQueue.invokeAndWait(() -> { + p = new Point(i % 100, i % 100); + sp.setScrollPosition(p); + }); + + robot.waitForIdle(); + robot.delay(10); + EventQueue.invokeAndWait(() -> { + if (!sp.getScrollPosition().equals(p)) { + throw new RuntimeException("Test failed. " + i + " : " + + "Expected " + p + ", but Returned: " + sp.getScrollPosition()); + } + }); + } + System.out.println("Test Passed."); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static class TestAdjustmentListener implements AdjustmentListener { + public void adjustmentValueChanged(AdjustmentEvent e) { + System.out.println("AdjEvent caught:" + e); + } + } +} diff --git a/test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java b/test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java new file mode 100644 index 00000000000..c5f48f80007 --- /dev/null +++ b/test/jdk/java/awt/ScrollPane/ScrollbarsAsNeededTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4094248 + * @summary Test initial appearance of SCROLLBARS_AS_NEEDED policy + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ScrollbarsAsNeededTest + */ + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.ScrollPane; + +public class ScrollbarsAsNeededTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. A Frame window with a ScrollPane that is + initially created with the SCROLLBARS_AS_NEEDED policy. + 2. If there are no scrollbars around the ScrollPane then + the test PASS. Otherwise the test FAILS. + """; + PassFailJFrame.builder() + .title("Test Instructions") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ScrollbarsAsNeededTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame frame = new Frame("Scrollbar as needed test"); + ScrollPane scrollPane = new ScrollPane() { + @Override + public void paint(Graphics g) { + super.paint(g); + g.drawString("ScrollPane", 10, 50); + } + }; + scrollPane.setBackground(Color.WHITE); + frame.setBackground(Color.GRAY); + frame.setSize(200, 200); + frame.setLayout(new FlowLayout()); + frame.add(scrollPane); + return frame; + } +} From 33bdc807b18914bb57ca7853ab45d4fa8fdefd47 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 22 Apr 2025 06:51:18 +0000 Subject: [PATCH 034/901] 8355241: Move NativeDialogToFrontBackTest.java PL test to manual category Reviewed-by: psadhukhan --- test/jdk/ProblemList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 3fe0bcf8cdc..841b1110506 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -392,7 +392,6 @@ java/awt/Modal/MultipleDialogs/MultipleDialogs2Test.java 8198665 macosx-all java/awt/Modal/MultipleDialogs/MultipleDialogs3Test.java 8198665 macosx-all java/awt/Modal/MultipleDialogs/MultipleDialogs4Test.java 8198665 macosx-all java/awt/Modal/MultipleDialogs/MultipleDialogs5Test.java 8198665 macosx-all -java/awt/Modal/NativeDialogToFrontBackTest.java 7188049 windows-all,linux-all java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java 8177326 macosx-all java/awt/Mouse/EnterExitEvents/ResizingFrameTest.java 8005021 macosx-all java/awt/Mouse/EnterExitEvents/FullscreenEnterEventTest.java 8051455 macosx-all @@ -820,3 +819,4 @@ java/awt/Checkbox/CheckboxBoxSizeTest.java 8340870 windows-all java/awt/Checkbox/CheckboxIndicatorSizeTest.java 8340870 windows-all java/awt/Checkbox/CheckboxNullLabelTest.java 8340870 windows-all java/awt/dnd/WinMoveFileToShellTest.java 8341665 windows-all +java/awt/Modal/NativeDialogToFrontBackTest.java 7188049 windows-all,linux-all From a55ccd267cdfbb7a52c0647fa3b2f93b36b1805f Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 07:04:26 +0000 Subject: [PATCH 035/901] 8352905: Open some JComboBox bugs 1 Reviewed-by: honkar, psadhukhan --- .../jdk/javax/swing/JComboBox/bug4166593.java | 98 ++++++++++++ .../jdk/javax/swing/JComboBox/bug4180054.java | 112 +++++++++++++ .../jdk/javax/swing/JComboBox/bug4530952.java | 147 ++++++++++++++++++ .../jdk/javax/swing/JComboBox/bug4530953.java | 98 ++++++++++++ 4 files changed, 455 insertions(+) create mode 100644 test/jdk/javax/swing/JComboBox/bug4166593.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4180054.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4530952.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4530953.java diff --git a/test/jdk/javax/swing/JComboBox/bug4166593.java b/test/jdk/javax/swing/JComboBox/bug4166593.java new file mode 100644 index 00000000000..850aab2261f --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4166593.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Robot; +import java.awt.event.ActionListener; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4166593 + * @summary Tests that JComboBox fires action events every time the user does an action + * @key headful + * @run main bug4166593 + */ + +public class bug4166593 { + static JFrame frame; + static JComboBox comboBox; + static volatile int numberOfActionEvents = 0; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(250); + + // change selected index 3 times + SwingUtilities.invokeAndWait(() -> { + comboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(3); + comboBox.setSelectedIndex(2); + }); + robot.waitForIdle(); + robot.delay(250); + + if (numberOfActionEvents != 3) { + throw new RuntimeException("Unexpected number of Action Events!\n" + + "Expected: 3\nActual: " + numberOfActionEvents); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + comboBox = new JComboBox(new Object[]{ + "Bob", "Fred", "Hank", "Joe", "Mildred", "Agatha", "Buffy" + }); + JPanel panel = new JPanel(); + JLabel label = new JLabel("0"); + frame = new JFrame("bug4166593"); + comboBox.setEditable(true); + + ActionListener actionCounter = e -> { + ++numberOfActionEvents; + label.setText(Integer.toString(numberOfActionEvents)); + }; + + comboBox.addActionListener(actionCounter); + + panel.add(comboBox); + panel.add(label); + + frame.add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4180054.java b/test/jdk/javax/swing/JComboBox/bug4180054.java new file mode 100644 index 00000000000..cee68dfcb9c --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4180054.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Robot; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; + +/* + * @test + * @bug 4180054 + * @summary Tests that DefaultComboBoxModel doesn't fire a "contents changed" unnecessarily + * @key headful + * @run main bug4180054 + */ + +public class bug4180054 { + static JFrame frame; + static JComboBox comboBox; + static volatile int numberOfContentsChangedEvents = 0; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(250); + + // change selected index 3 times + SwingUtilities.invokeAndWait(() -> { + comboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(3); + comboBox.setSelectedIndex(2); + comboBox.setSelectedIndex(2); + }); + robot.waitForIdle(); + robot.delay(250); + + if (numberOfContentsChangedEvents != 3) { + throw new RuntimeException("Unexpected number of Contents Changed Events!\n" + + "Expected: 3\nActual: " + numberOfContentsChangedEvents); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4180054"); + JPanel panel = new JPanel(); + JLabel label = new JLabel("0"); + + DefaultComboBoxModel model = new DefaultComboBoxModel(); + for (int i = 0; i < 100; ++i) { + model.addElement(Integer.toString(i)); + } + comboBox = new JComboBox(model); + comboBox.setEditable(true); + + ListDataListener contentsCounter = new ListDataListener() { + public void contentsChanged(ListDataEvent e) { + ++numberOfContentsChangedEvents; + label.setText(Integer.toString(numberOfContentsChangedEvents)); + } + + public void intervalAdded(ListDataEvent e) { + } + + public void intervalRemoved(ListDataEvent e) { + } + }; + + comboBox.getModel().addListDataListener(contentsCounter); + + panel.add(comboBox); + panel.add(label); + + frame.add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4530952.java b/test/jdk/javax/swing/JComboBox/bug4530952.java new file mode 100644 index 00000000000..cf960d64c9a --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4530952.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +/* + * @test + * @bug 4530952 + * @summary Tests that double mouse clicks invoke Event + * @key headful + * @run main bug4530952 + */ + +public class bug4530952 { + static JFrame frame; + static JButton btnAction; + static JComboBox cmbAction; + static volatile Point loc; + static volatile Dimension btnSize; + + private static volatile boolean flag; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + // enter some text in combo box + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + robot.delay(250); + + // find and click action button + SwingUtilities.invokeAndWait(() -> { + loc = btnAction.getLocationOnScreen(); + btnSize = btnAction.getSize(); + }); + robot.waitForIdle(); + robot.delay(250); + + robot.mouseMove(loc.x + btnSize.width / 2, + loc.y + btnSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(1000); + + if (!flag) { + throw new RuntimeException("Failed: button action was not fired"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4530952"); + frame.setLayout(new FlowLayout()); + + btnAction = new JButton("Action"); + cmbAction = new JComboBox(); + + flag = false; + + ActionListener al = e -> flag = true; + DocumentListener dl = new DocumentListener() { + @Override + public void changedUpdate(DocumentEvent evt) { + resetButtons(); + } + + @Override + public void insertUpdate(DocumentEvent evt) { + resetButtons(); + } + + @Override + public void removeUpdate(DocumentEvent evt) { + resetButtons(); + } + }; + + // Add an editable combo box + cmbAction.setEditable(true); + frame.add(cmbAction); + + btnAction.setEnabled(false); + frame.add(btnAction); + + btnAction.addActionListener(al); + ((JTextField) cmbAction.getEditor().getEditorComponent()). + getDocument().addDocumentListener(dl); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void resetButtons() { + int length = ((JTextField) cmbAction.getEditor().getEditorComponent()). + getDocument().getLength(); + btnAction.setEnabled(length > 0); + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4530953.java b/test/jdk/javax/swing/JComboBox/bug4530953.java new file mode 100644 index 00000000000..a9f0c70b9bc --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4530953.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4530953 + * @summary Tests that highlighted Item appears after automatically scrolling to the item + * @key headful + * @run main bug4530953 + */ + +public class bug4530953 { + static JFrame frame; + static JComboBox combo; + static String[] data = {"Apple", "Orange", "Cherry"}; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(250); + + // enter some text in combo box editor + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.waitForIdle(); + robot.delay(250); + + // select orange in combo box + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.waitForIdle(); + robot.delay(250); + + String currSelection = (String) combo.getEditor().getItem(); + if (!currSelection.equals("Orange")) { + throw new RuntimeException("Unexpected Selection.\n" + + "Expected: Orange\nActual: " + currSelection); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4530953"); + combo = new JComboBox(data); + combo.setEditable(true); + combo.setSelectedIndex(1); + frame.setLayout(new FlowLayout()); + frame.add(combo); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} From 2f7806ffe5b5b4b2f7caa14d4559943968c34678 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Tue, 22 Apr 2025 07:07:31 +0000 Subject: [PATCH 036/901] 8355034: [JVMCI] assert(static_cast(_jvmci_data_size) == align_up(compiler->is_jvmci() ? jvmci_data->size() : 0, oopSize)) failed: failed: 104 != 16777320 Reviewed-by: never, yzheng, cslucas --- src/hotspot/share/code/nmethod.cpp | 2 +- .../share/jvmci/jvmciCodeInstaller.cpp | 8 ++- .../classes/jdk/vm/ci/code/InstalledCode.java | 19 ++++++- .../vm/ci/code/test/InstalledCodeTest.java | 57 +++++++++++++++++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InstalledCodeTest.java diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 01ace66f4de..56ba76a806e 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -112,7 +112,7 @@ // Cast from int value to narrow type #define CHECKED_CAST(result, T, thing) \ result = static_cast(thing); \ - assert(static_cast(result) == thing, "failed: %d != %d", static_cast(result), thing); + guarantee(static_cast(result) == thing, "failed: %d != %d", static_cast(result), thing); //--------------------------------------------------------------------------------- // NMethod statistics diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp index 79aaacec809..3a9fbc54bf9 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp @@ -825,7 +825,13 @@ JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler, // Since this compilation didn't pass through the broker it wasn't logged yet. if (PrintCompilation) { ttyLocker ttyl; - CompileTask::print(tty, nm, "(hosted JVMCI compilation)"); + if (name != nullptr) { + stringStream st; + st.print_cr("(hosted JVMCI compilation: %s)", name); + CompileTask::print(tty, nm, st.as_string()); + } else { + CompileTask::print(tty, nm, "(hosted JVMCI compilation)"); + } } } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java index 489cca81c7b..62c0b609146 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2025, 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 @@ -46,7 +46,24 @@ public class InstalledCode { protected final String name; + /** + * The maximum length of an InstalledCode name. This name is typically installed into + * the code cache so it should have a reasonable limit. + */ + public static final int MAX_NAME_LENGTH = 2048; + + /** + * @param name the name to be associated with the installed code. Can be null and + * must be no longer than {@link #MAX_NAME_LENGTH}. + * + * @throws IllegalArgumentException if {@code name.length >} {@link #MAX_NAME_LENGTH} + */ public InstalledCode(String name) { + if (name != null && name.length() > MAX_NAME_LENGTH) { + String msg = String.format("name length (%d) is greater than %d (name[0:%s] = %s)", + name.length(), MAX_NAME_LENGTH, MAX_NAME_LENGTH, name.substring(0, MAX_NAME_LENGTH)); + throw new IllegalArgumentException(msg); + } this.name = name; } diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InstalledCodeTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InstalledCodeTest.java new file mode 100644 index 00000000000..f7e68043da7 --- /dev/null +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InstalledCodeTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test 8355034 + * @requires vm.jvmci + * @modules jdk.internal.vm.ci/jdk.vm.ci.code + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.InstalledCodeTest + */ + +package jdk.vm.ci.code.test; + +import jdk.vm.ci.code.InstalledCode; +import org.junit.Assert; +import org.junit.Test; + +public class InstalledCodeTest { + + @Test + public void testNullName() { + new InstalledCode(null); + } + + @Test + public void testTooLongName() { + String longName = new String(new char[InstalledCode.MAX_NAME_LENGTH]).replace('\0', 'A'); + new InstalledCode(longName); + try { + String tooLongName = longName + "X"; + new InstalledCode(tooLongName); + } catch (IllegalArgumentException iae) { + // Threw IllegalArgumentException as expected. + return; + } + Assert.fail("expected IllegalArgumentException"); + } +} From 17b080b2c90f7fd9986fe38daebb76363d012469 Mon Sep 17 00:00:00 2001 From: Tejesh R Date: Tue, 22 Apr 2025 07:44:44 +0000 Subject: [PATCH 037/901] 8353446: Open source several AWT Menu tests - Batch 2 Reviewed-by: abhiscxk --- .../Menu/DestroyMenuTest/DestroyMenuTest.java | 139 ++++++++++++++ .../awt/Menu/DestroyMenuTest/MenuTest.java | 172 ++++++++++++++++++ .../jdk/java/awt/Menu/MenuAddRemoveCrash.java | 102 +++++++++++ test/jdk/java/awt/Menu/MenuZOrderTest.java | 80 ++++++++ .../java/awt/Menu/OnFlyRepaintMenuTest.java | 103 +++++++++++ 5 files changed, 596 insertions(+) create mode 100644 test/jdk/java/awt/Menu/DestroyMenuTest/DestroyMenuTest.java create mode 100644 test/jdk/java/awt/Menu/DestroyMenuTest/MenuTest.java create mode 100644 test/jdk/java/awt/Menu/MenuAddRemoveCrash.java create mode 100644 test/jdk/java/awt/Menu/MenuZOrderTest.java create mode 100644 test/jdk/java/awt/Menu/OnFlyRepaintMenuTest.java diff --git a/test/jdk/java/awt/Menu/DestroyMenuTest/DestroyMenuTest.java b/test/jdk/java/awt/Menu/DestroyMenuTest/DestroyMenuTest.java new file mode 100644 index 00000000000..b75ba047dfb --- /dev/null +++ b/test/jdk/java/awt/Menu/DestroyMenuTest/DestroyMenuTest.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4209511 + * @summary Regression test DestroyMenuTest.java Failing + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual DestroyMenuTest + */ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Canvas; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Scrollbar; +import java.awt.TextField; + +public class DestroyMenuTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Create many windows by randomly clicking 'Show Menu Test 1', + 'Show Menu Test 2', 'Show Menu Test 3' buttons. + 2. Ignore the contents of the windows. + Go to the windows created and select menu items inside the menus. + 3. Close the windows by selecting menu item File--> Quit. + 4. Do the above menu item selections as quickly as possible. + If the program crashes when you select File--> Quit, + then the test FAILS. Otherwise the test is PASS. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(38) + .testUI(DestroyMenuTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame f = new Frame("Destroy Menu Test"); + Button launchButton = new Button("Show Menu Test 1..."); + Button launchButton2 = new Button("Show Menu Test 2..."); + Button launchButton3 = new Button("Show Menu Test 3..."); + f.setLayout(new FlowLayout()); + f.add(launchButton); + f.add(launchButton2); + f.add(launchButton3); + + launchButton.addActionListener(event -> { + MenuTest frame = new MenuTest("Menu Test 1"); + frame.setBounds(300, 300, 300, 300); + frame.setVisible(true); + }); + + launchButton2.addActionListener(event -> { + MenuTest frame = new MenuTest("Menu Test 2"); + + Button closeButton = new Button("Close"); + + Panel X = new Panel(); + X.setLayout(new BorderLayout()); + + Panel topPanel = new Panel(); + Panel bottomPanel = new Panel(); + + bottomPanel.add(closeButton); + + Scrollbar vScrollbar = new Scrollbar(Scrollbar.VERTICAL); + Scrollbar hScrollbar = new Scrollbar(Scrollbar.HORIZONTAL); + hScrollbar.setValues(hScrollbar.getValue(), 0, 0, 50); + vScrollbar.setValues(vScrollbar.getValue(), 0, 0, 50); + topPanel.setLayout(new BorderLayout()); + topPanel.add(vScrollbar, BorderLayout.EAST); + topPanel.add(hScrollbar, BorderLayout.SOUTH); + + X.add(topPanel, BorderLayout.NORTH); + X.add(bottomPanel, BorderLayout.SOUTH); + frame.add(X, BorderLayout.SOUTH); + frame.setBounds(350, 350, 300, 250); + frame.setVisible(true); + }); + + launchButton3.addActionListener(event -> { + MenuTest frame = new MenuTest("Menu Test 3"); + frame.setBounds(400, 400, 300, 300); + + mySimpleCanvas clock = new mySimpleCanvas(); + frame.add(clock, BorderLayout.CENTER); + + Panel p = new Panel(); + Button closeButton = new Button("Close"); + p.add(closeButton); + + p.add(new Label("Label")); + TextField textField = new TextField(8); + p.add(textField); + f.add(p, BorderLayout.EAST); + + frame.add(p, BorderLayout.SOUTH); + frame.setVisible(true); + }); + f.pack(); + return f; + } + + static class mySimpleCanvas extends Canvas { + @Override + public void paint(Graphics g) { + g.drawOval(0, 0, 100, 100); + g.drawOval(2, 2, 100, 100); + g.drawOval(4, 4, 100, 100); + } + } +} diff --git a/test/jdk/java/awt/Menu/DestroyMenuTest/MenuTest.java b/test/jdk/java/awt/Menu/DestroyMenuTest/MenuTest.java new file mode 100644 index 00000000000..95569f13fa2 --- /dev/null +++ b/test/jdk/java/awt/Menu/DestroyMenuTest/MenuTest.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Canvas; +import java.awt.CardLayout; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Panel; + +public class MenuTest extends Frame { + private MenuItem quitItem; + private final Panel cards; + private final CardLayout layout; + + public MenuTest(String s) { + super(s); + MenuBar mbar = new MenuBar(); + createMenus(mbar); + setMenuBar(mbar); + + cards = new Panel(); + layout = new CardLayout(); + cards.setLayout(layout); + + cards.add(new MyPanelOne("Options"), "Options"); + cards.add(new MyRectCanvas(), "MyRectCanvas"); + cards.add(new MycircleCanvas(), "MyCircleCanvas"); + + add(cards, "Center"); + } + + public void createMenus(MenuBar mbar) { + mbar.add(createFileMenu()); + mbar.add(createEditMenu()); + mbar.add(createOptionMenu1()); + mbar.add(createOptionMenu2()); + mbar.add(createOptionMenu3()); + mbar.add(createOptionMenu4()); + } + + private Menu createFileMenu() { + Menu fileMenu = new Menu("File"); + fileMenu.add(quitItem = new MenuItem("Quit")); + + quitItem.addActionListener(event -> { + MenuItem item = (MenuItem) event.getSource(); + if (item == quitItem) { + dispose(); + } + }); + return fileMenu; + } + + private Menu createEditMenu() { + Menu editMenu = new Menu("Edit"); + + editMenu.add("Cut"); + editMenu.add("Copy"); + editMenu.add("Paste"); + editMenu.addSeparator(); + editMenu.add("Select all"); + editMenu.addSeparator(); + editMenu.add("Find"); + editMenu.add("Find again"); + + return editMenu; + } + + private Menu createOptionMenu1() { + Menu optionMenu1 = new Menu("Option1"); + MenuItem item1, item2, item3; + optionMenu1.add(item1 = new MenuItem("Item1")); + optionMenu1.add(item2 = new MenuItem("Item2")); + optionMenu1.add(item3 = new MenuItem("Item3")); + + item1.addActionListener(event -> { + MenuItem mItem = (MenuItem) event.getSource(); + if (mItem == item1) { + layout.show(cards, "Options"); + } + }); + item2.addActionListener(event -> { + MenuItem mItem = (MenuItem) event.getSource(); + if (mItem == item2) { + layout.show(cards, "MyRectCanvas"); + } + }); + item3.addActionListener(event -> { + MenuItem mItem = (MenuItem) event.getSource(); + if (mItem == item3) { + layout.show(cards, "MyCircleCanvas"); + } + }); + return optionMenu1; + } + + private Menu createOptionMenu2() { + Menu optionMenu2 = new Menu("Option2"); + + optionMenu2.add("Item1"); + optionMenu2.add("Item2"); + + return optionMenu2; + } + + private Menu createOptionMenu3() { + Menu optionMenu3 = new Menu("Option3"); + + optionMenu3.add("Item1"); + optionMenu3.add("Item2"); + optionMenu3.add("Item3"); + optionMenu3.add("Item4"); + + return optionMenu3; + } + + private Menu createOptionMenu4() { + Menu optionMenu4 = new Menu("Option3"); + + optionMenu4.add("Item1"); + optionMenu4.add("Item2"); + optionMenu4.add("Item3"); + + return optionMenu4; + } +} + +class MyRectCanvas extends Canvas { + @Override + public void paint(Graphics g) { + g.drawRect(0, 0, 100, 100); + } +} + +class MyPanelOne extends Panel { + MyPanelOne(String name) { + add(new Label(name + " panel goes here")); + } +} + +class MycircleCanvas extends Canvas { + @Override + public void paint(Graphics g) { + g.drawOval(0, 0, 100, 100); + g.drawOval(2, 2, 100, 100); + g.drawOval(4, 4, 100, 100); + } +} diff --git a/test/jdk/java/awt/Menu/MenuAddRemoveCrash.java b/test/jdk/java/awt/Menu/MenuAddRemoveCrash.java new file mode 100644 index 00000000000..d5c80c27a4f --- /dev/null +++ b/test/jdk/java/awt/Menu/MenuAddRemoveCrash.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4410477 + * @summary Tests that menu does not crash during simultaneous drawing + * and removal of items. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuAddRemoveCrash + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +public class MenuAddRemoveCrash { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Move and resize the frame. + 2. If the test crashes the test is FAILED. + Otherwise it is PASSED. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(MenuAddRemoveCrash::initialize) + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + final TestGui myTestGui = new TestGui(); + Thread test = new Thread() { + public void run() { + while (!Thread.interrupted()) { + myTestGui.changeMenuItems(); + } + } + }; + test.setDaemon(true); + test.start(); + return myTestGui; + } +} + +class TestGui extends Frame { + Menu myMenu1; + Menu myMenu2; + + public TestGui() { + this.setTitle("Try to resize this frame!"); + + this.setSize(300, 300); + this.setVisible(true); + + MenuBar myMenuBar = new MenuBar(); + myMenu1 = new Menu("DemoMenu1"); + myMenu2 = new Menu("DemoMenu2"); + + myMenuBar.add(myMenu1); + myMenuBar.add(myMenu2); + + this.setMenuBar(myMenuBar); + } + + public void changeMenuItems() { + myMenu1.removeAll(); + + for (int i = 0; i < 10; i++) { + MenuItem myMenuItem1 = new MenuItem("DemoMenuItem" + i); + myMenu1.add(myMenuItem1); + } + try { + Thread.sleep(100); + } catch (Exception e) { + throw new RuntimeException("Failed :" + e); + } + } +} diff --git a/test/jdk/java/awt/Menu/MenuZOrderTest.java b/test/jdk/java/awt/Menu/MenuZOrderTest.java new file mode 100644 index 00000000000..fefd3d64c28 --- /dev/null +++ b/test/jdk/java/awt/Menu/MenuZOrderTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2005, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6267182 + * @summary Menu is not visible after showing and disposing a file dialog. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuZOrderTest + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class MenuZOrderTest { + static class Listener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + Frame f = new Frame("Menu Z order test frame"); + f.setBounds(200, 200, 200, 200); + f.setVisible(true); + } + } + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Choose Menu 1 --> Menu Item 1 several times. + 2. If menu window is shown correctly and each click + creates new frame - press PASS. + 3. If menu window is obscured by frame - press FAIL. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(MenuZOrderTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame mf = new Frame("Menu Z order test"); + Listener l = new Listener(); + MenuBar mb = new MenuBar(); + Menu m1 = new Menu("Menu 1"); + MenuItem mi1 = new MenuItem("Menu Item 1"); + + mf.setSize(200, 200); + mi1.addActionListener(l); + m1.add(mi1); + mb.add(m1); + mf.setMenuBar(mb); + mf.setVisible(true); + return mf; + } +} diff --git a/test/jdk/java/awt/Menu/OnFlyRepaintMenuTest.java b/test/jdk/java/awt/Menu/OnFlyRepaintMenuTest.java new file mode 100644 index 00000000000..617d640d907 --- /dev/null +++ b/test/jdk/java/awt/Menu/OnFlyRepaintMenuTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5024051 + * @summary Tests if menu is repainted in enabling/disabling it and + * changing its label while it is visible, either on MenuBar + * or in other Menu. Menu items are covered as well + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual OnFlyRepaintMenuTest + */ + +import java.awt.Button; +import java.awt.CheckboxMenuItem; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +public class OnFlyRepaintMenuTest { + static boolean menuEnabled = true; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click the button 'Change state' and wait for 5 secs. + 2. If menu is repainted correctly after its setLabel() + and setEnabled() methods called test PASSED, else FAILED. + (During a 5 secs delay you may select the menu to see + the effect for menu items and submenu) + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(OnFlyRepaintMenuTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame f = new Frame("OnFly Menu Repaint Test"); + + f.setSize(200, 100); + + MenuBar mb = new MenuBar(); + Menu menu = new Menu("Menu"); + MenuItem menuItem = new MenuItem("MenuItem"); + menu.add(menuItem); + Menu submenu = new Menu("SubMenu"); + MenuItem submenuItem = new MenuItem("SubmenuItem"); + submenu.add(submenuItem); + CheckboxMenuItem checkMenuItem = new CheckboxMenuItem("CheckboxmenuItem"); + checkMenuItem.setState(true); + menu.add(checkMenuItem); + menu.add(submenu); + mb.add(menu); + f.setMenuBar(mb); + + Button b = new Button("Change state"); + b.addActionListener(ev -> new Thread(() -> { + try { + Thread.sleep(5000); + } catch (Exception e) { + } + menuEnabled = !menuEnabled; + String label = menuEnabled ? "Enabled" : "Disabled"; + menu.setLabel(label); + menuItem.setLabel(label); + submenu.setLabel(label); + submenuItem.setLabel(label); + checkMenuItem.setLabel(label); + checkMenuItem.setEnabled(menuEnabled); + checkMenuItem.setState(menuEnabled); + submenuItem.setEnabled(menuEnabled); + submenu.setEnabled(menuEnabled); + menuItem.setEnabled(menuEnabled); + menu.setEnabled(menuEnabled); + }).start()); + f.add(b); + return f; + } +} From 0b2a2f38d0b0133a562a898836d7a1b2dbd73a5e Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 07:45:56 +0000 Subject: [PATCH 038/901] 8353685: Open some JComboBox bugs 4 Reviewed-by: honkar, kizune --- .../jdk/javax/swing/JComboBox/bug4212498.java | 86 +++++++++++++++++ .../jdk/javax/swing/JComboBox/bug4459267.java | 75 +++++++++++++++ .../jdk/javax/swing/JComboBox/bug4519269.java | 94 +++++++++++++++++++ 3 files changed, 255 insertions(+) create mode 100644 test/jdk/javax/swing/JComboBox/bug4212498.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4459267.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4519269.java diff --git a/test/jdk/javax/swing/JComboBox/bug4212498.java b/test/jdk/javax/swing/JComboBox/bug4212498.java new file mode 100644 index 00000000000..b60470fdd32 --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4212498.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + +/* + * @test + * @bug 4212498 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4212498 + */ + +public class bug4212498 { + static JPanel panel = new JPanel(); + static JComboBox comboBox = new JComboBox(new Object[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea"}); + + private static final String INSTRUCTIONS = """ + Edit the value in the text field (without using the popup) + and then press the tab key. If the number doesn't increase, + then test fails. + + Also, try tabbing out without making a change. The number + should NOT increase unless the user changes something. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4212498::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4212498"); + comboBox.setEditable(true); + + final JLabel label = new JLabel("0"); + + ActionListener actionListener = + e -> label.setText("" + (Integer.parseInt(label.getText()) + 1)); + + comboBox.addActionListener(actionListener); + + panel.add(comboBox); + panel.add(label); + panel.add(new JButton("B")); + + frame.getContentPane().add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + return frame; + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4459267.java b/test/jdk/javax/swing/JComboBox/bug4459267.java new file mode 100644 index 00000000000..85049936ea7 --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4459267.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4459267 + * @summary Tests that pressing PageUp in combo popup list doesn't cause + * stack overflow + * @key headful + * @run main bug4459267 + */ + +public class bug4459267 { + static JFrame frame; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(250); + + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + robot.keyPress(KeyEvent.VK_PAGE_UP); + robot.keyRelease(KeyEvent.VK_PAGE_UP); + robot.waitForIdle(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4459267"); + JComboBox jcmb = new JComboBox(); + jcmb.addItem("JComobo1"); + jcmb.addItem("Item2"); + jcmb.addItem("Item3"); + frame.getContentPane().add(jcmb, BorderLayout.NORTH); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4519269.java b/test/jdk/javax/swing/JComboBox/bug4519269.java new file mode 100644 index 00000000000..29147998d0a --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4519269.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4519269 + * @summary Tests that DefaultKeySelectionManager doesn't throw NPE + * @key headful + * @run main bug4519269 + */ + +public class bug4519269 { + static JFrame frame; + static JComboBox combo; + static Point p; + static Object[] data = {new CustomString("Item 1"), new CustomString("Item 2"), + new CustomString("Item 3"), new CustomString("Item 4")}; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(250); + + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> p = combo.getLocationOnScreen()); + robot.mouseMove(p.x + 5, p.y + 5); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + robot.keyPress(KeyEvent.VK_SHIFT); + robot.keyRelease(KeyEvent.VK_SHIFT); + robot.waitForIdle(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4519269"); + combo = new JComboBox(data); + frame.getContentPane().add(combo); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + static class CustomString { + String string; + + public CustomString(String s) { + string = s; + } + + public String toString() { + return null; + } + } +} From 7eab2d9f9140a27f7a5c5e0a57b9e6a256558690 Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 07:58:30 +0000 Subject: [PATCH 039/901] 8354095: Open some JTable bugs 5 Reviewed-by: kizune, honkar --- .../swing/JTable/InternationalCharacters.java | 172 +++++++++++++++++ .../javax/swing/JTable/NullTableHeader.java | 44 +++++ test/jdk/javax/swing/JTable/bug4118307.java | 182 ++++++++++++++++++ test/jdk/javax/swing/JTable/bug4138158.java | 62 ++++++ 4 files changed, 460 insertions(+) create mode 100644 test/jdk/javax/swing/JTable/InternationalCharacters.java create mode 100644 test/jdk/javax/swing/JTable/NullTableHeader.java create mode 100644 test/jdk/javax/swing/JTable/bug4118307.java create mode 100644 test/jdk/javax/swing/JTable/bug4138158.java diff --git a/test/jdk/javax/swing/JTable/InternationalCharacters.java b/test/jdk/javax/swing/JTable/InternationalCharacters.java new file mode 100644 index 00000000000..1d8fc2c4576 --- /dev/null +++ b/test/jdk/javax/swing/JTable/InternationalCharacters.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.BevelBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4179066 + * @summary Tests that JTable prints AltGr characters (~\@|{}[]²µ³) + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual InternationalCharacters + */ + +public class InternationalCharacters { + private static final String INSTRUCTIONS = """ + Double-click an entry in the JTable. + Press Alt-Gr or Option with any key to type an international character. + Verify that the international character appears in the table. + If it does, press "pass", otherwise press "fail". + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(InternationalCharacters::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("InternationalCharacters test"); + // Take the dummy data from SwingSet. + final String[] names = {"First Name", "Last Name", "Favorite Color", + "Favorite Number", "Vegetarian"}; + final Object[][] data = { + {"Mark", "Andrews", "Red", 2, true}, + {"Tom", "Ball", "Blue", 99, false}, + {"Alan", "Chung", "Green", 838, false}, + {"Jeff", "Dinkins", "Turquois", 8, true}, + {"Amy", "Fowler", "Yellow", 3, false}, + {"Brian", "Gerhold", "Green", 0, false}, + {"James", "Gosling", "Pink", 21, false}, + {"David", "Karlton", "Red", 1, false}, + {"Dave", "Kloba", "Yellow", 14, false}, + {"Peter", "Korn", "Purple", 12, false}, + {"Phil", "Milne", "Purple", 3, false}, + {"Dave", "Moore", "Green", 88, false}, + {"Hans", "Muller", "Maroon", 5, false}, + {"Rick", "Levenson", "Blue", 2, false}, + {"Tim", "Prinzing", "Blue", 22, false}, + {"Chester", "Rose", "Black", 0, false}, + {"Ray", "Ryan", "Gray", 77, false}, + {"Georges", "Saab", "Red", 4, false}, + {"Willie", "Walker", "Phthalo Blue", 4, false}, + {"Kathy", "Walrath", "Blue", 8, false}, + {"Arnaud", "Weber", "Green", 44, false} + }; + + // Create a model of the data. + TableModel dataModel = new AbstractTableModel() { + // These methods always need to be implemented. + public int getColumnCount() { return names.length; } + public int getRowCount() { return data.length;} + public Object getValueAt(int row, int col) {return data[row][col];} + + // The default implementations of these methods in + // AbstractTableModel would work, but we can refine them. + public String getColumnName(int column) {return names[column];} + public Class getColumnClass(int c) {return getValueAt(0, c).getClass();} + public boolean isCellEditable(int row, int col) {return true;} + public void setValueAt(Object aValue, int row, int column) { + System.out.println("Setting value to: " + aValue); + data[row][column] = aValue; + } + }; + + // Create the table + JTable tableView = new JTable(dataModel); + // Turn off auto-resizing so that we can set column sizes programmatically. + // In this mode, all columns will get their preferred widths, as set blow. + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // Create a combo box to show that you can use one in a table. + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Red"); + comboBox.addItem("Orange"); + comboBox.addItem("Yellow"); + comboBox.addItem("Green"); + comboBox.addItem("Blue"); + comboBox.addItem("Indigo"); + comboBox.addItem("Violet"); + + TableColumn colorColumn = tableView.getColumn("Favorite Color"); + // Use the combo box as the editor in the "Favorite Color" column. + colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + // Set a pink background and tooltip for the Color column renderer. + DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer(); + colorColumnRenderer.setBackground(Color.pink); + colorColumnRenderer.setToolTipText("Click for combo box"); + colorColumn.setCellRenderer(colorColumnRenderer); + + // Set a tooltip for the header of the colors column. + TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer(); + if (headerRenderer instanceof DefaultTableCellRenderer) + ((DefaultTableCellRenderer)headerRenderer).setToolTipText("Hi Mom!"); + + // Set the width of the "Vegetarian" column. + TableColumn vegetarianColumn = tableView.getColumn("Vegetarian"); + vegetarianColumn.setPreferredWidth(100); + + // Show the values in the "Favorite Number" column in different colors. + TableColumn numbersColumn = tableView.getColumn("Favorite Number"); + DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() { + public void setValue(Object value) { + int cellValue = (value instanceof Number) ? ((Number)value).intValue() : 0; + setForeground((cellValue > 30) ? Color.black : Color.red); + setText((value == null) ? "" : value.toString()); + } + }; + numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT); + numbersColumn.setCellRenderer(numberColumnRenderer); + numbersColumn.setPreferredWidth(110); + + // Finish setting up the table. + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + + frame.add(scrollpane); + frame.setSize(500, 200); + return frame; + } +} diff --git a/test/jdk/javax/swing/JTable/NullTableHeader.java b/test/jdk/javax/swing/JTable/NullTableHeader.java new file mode 100644 index 00000000000..dc62b975d04 --- /dev/null +++ b/test/jdk/javax/swing/JTable/NullTableHeader.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4129409 + * @summary Tests that JTable.setTableHeader(null) doesn't break AutoResize + * @key headful + * @run main NullTableHeader + */ + +public class NullTableHeader { + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + JTable tableView = new JTable(); + tableView.setTableHeader(null); + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + }); + } +} diff --git a/test/jdk/javax/swing/JTable/bug4118307.java b/test/jdk/javax/swing/JTable/bug4118307.java new file mode 100644 index 00000000000..537e92176ef --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4118307.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4118307 + * @summary Tests that JTable's cell editor for Number and Date work correctly + * @key headful + * @run main bug4118307 + */ + +public class bug4118307 { + static JFrame frame; + static MyTable tbl; + static Point tableLoc; + static Point p; + private static volatile boolean flag; + static final String[] columnNames = {"Integer", "Double"}; + static final Object[][] data = { + {5, 3.14}, + {10, 2.71}, + {70, 3.14}, + {200, 2.71}, + }; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(250); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + tableLoc = tbl.getLocationOnScreen(); + p = tbl.getCellRect(0, 0, true).getLocation(); + }); + robot.waitForIdle(); + + robot.mouseMove(tableLoc.x + p.x + 10, tableLoc.y + p.y + 10); + robot.waitForIdle(); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> + p = tbl.getCellRect(1, 1, true).getLocation()); + robot.waitForIdle(); + + robot.mouseMove(tableLoc.x + p.x + 10, tableLoc.y + p.y + 10); + robot.waitForIdle(); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> + p = tbl.getCellRect(1, 0, true).getLocation()); + robot.waitForIdle(); + + robot.mouseMove(tableLoc.x + p.x + 10, tableLoc.y + p.y + 10); + robot.waitForIdle(); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(5000); + + if (!flag) { + throw new RuntimeException("Test Failed."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4118307"); + MyTableModel myModel = new MyTableModel(); + tbl = new MyTable(myModel); + JScrollPane sp = new JScrollPane(tbl); + flag = true; + + frame.add(sp, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + static class MyTable extends JTable { + public MyTable(TableModel tm) { + super(tm); + } + + public Component prepareRenderer(TableCellRenderer rend, int row, int col) { + try { + return super.prepareRenderer(rend, row, col); + } catch (Exception e) { + e.printStackTrace(); + flag = false; + return null; + } + } + } + + static class MyTableModel extends AbstractTableModel { + public int getColumnCount() { + return columnNames.length; + } + + public int getRowCount() { + return data.length; + } + + @Override + public String getColumnName(int col) { + return columnNames[col]; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + public void setValueAt(Object value, int row, int col) { + data[row][col] = value; + } + } +} diff --git a/test/jdk/javax/swing/JTable/bug4138158.java b/test/jdk/javax/swing/JTable/bug4138158.java new file mode 100644 index 00000000000..400b8b1952e --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4138158.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +/* + * @test + * @bug 4138158 + * @summary Tests that setAutoscrolls(false) locks autoscroll + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4138158 + */ + +public class bug4138158 { + private static final String INSTRUCTIONS = """ + Move mouse to beginning of table, press left mouse button and drag mouse down + below the frame. If the table isn't scrolled down then test passes. + If the table is scrolled then test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4138158::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4138158"); + JTable table = new JTable(20, 3); + table.setAutoscrolls(false); + JScrollPane sp = new JScrollPane(table); + frame.add(sp); + frame.setSize(200, 200); + return frame; + } +} From 367bcc5df83722231106b635068a17f92404477b Mon Sep 17 00:00:00 2001 From: Tejesh R Date: Tue, 22 Apr 2025 07:59:45 +0000 Subject: [PATCH 040/901] 8353445: Open source several AWT Menu tests - Batch 1 Reviewed-by: abhiscxk, prr --- test/jdk/ProblemList.txt | 1 + .../java/awt/Menu/MenuActionEventTest.java | 98 +++++++++++ .../jdk/java/awt/Menu/MenuVisibilityTest.java | 71 ++++++++ test/jdk/java/awt/Menu/RmInHideTest.java | 152 ++++++++++++++++++ test/jdk/java/awt/Menu/SetShortCutTest.java | 132 +++++++++++++++ 5 files changed, 454 insertions(+) create mode 100644 test/jdk/java/awt/Menu/MenuActionEventTest.java create mode 100644 test/jdk/java/awt/Menu/MenuVisibilityTest.java create mode 100644 test/jdk/java/awt/Menu/RmInHideTest.java create mode 100644 test/jdk/java/awt/Menu/SetShortCutTest.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 841b1110506..fe0657ff165 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -819,4 +819,5 @@ java/awt/Checkbox/CheckboxBoxSizeTest.java 8340870 windows-all java/awt/Checkbox/CheckboxIndicatorSizeTest.java 8340870 windows-all java/awt/Checkbox/CheckboxNullLabelTest.java 8340870 windows-all java/awt/dnd/WinMoveFileToShellTest.java 8341665 windows-all +java/awt/Menu/MenuVisibilityTest.java 8161110 macosx-all java/awt/Modal/NativeDialogToFrontBackTest.java 7188049 windows-all,linux-all diff --git a/test/jdk/java/awt/Menu/MenuActionEventTest.java b/test/jdk/java/awt/Menu/MenuActionEventTest.java new file mode 100644 index 00000000000..70fcc81ac86 --- /dev/null +++ b/test/jdk/java/awt/Menu/MenuActionEventTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4094620 + * @summary MenuItem.enableEvents does not work + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuActionEventTest + */ + +import java.awt.AWTEvent; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.event.ActionEvent; + +public class MenuActionEventTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Click on the Menu and then on Menuitem on the frame. + 2. If you find the following message being printed in + the test log area:, + _MenuItem: action event", + click PASS, else click FAIL" + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(MenuActionEventTest::initialize) + .logArea() + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame f = new Frame("Menu Action Event Test"); + f.setLayout(new BorderLayout()); + f.setMenuBar(new MenuBar()); + Menu m = new _Menu("Menu"); + MenuBar mb = f.getMenuBar(); + mb.add(m); + MenuItem mi = new _MenuItem("Menuitem"); + m.add(mi); + f.setBounds(204, 152, 396, 300); + return f; + } + + static class _Menu extends Menu { + public _Menu(String text) { + super(text); + enableEvents(AWTEvent.ACTION_EVENT_MASK); + } + + @Override + protected void processActionEvent(ActionEvent e) { + PassFailJFrame.log("_Menu: action event"); + super.processActionEvent(e); + } + } + + static class _MenuItem extends MenuItem { + public _MenuItem(String text) { + super(text); + enableEvents(AWTEvent.ACTION_EVENT_MASK); + } + + @Override + protected void processActionEvent(ActionEvent e) { + PassFailJFrame.log("_MenuItem: action event"); + super.processActionEvent(e); + } + } + +} diff --git a/test/jdk/java/awt/Menu/MenuVisibilityTest.java b/test/jdk/java/awt/Menu/MenuVisibilityTest.java new file mode 100644 index 00000000000..cb74cd56e1a --- /dev/null +++ b/test/jdk/java/awt/Menu/MenuVisibilityTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5046491 6423258 + * @summary CheckboxMenuItem: menu text is missing from test frame + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MenuVisibilityTest +*/ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; + +public class MenuVisibilityTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. Press on a MenuBar with a long name. + 2. Select "First item" in an opened menu. + If you see that "First menu item was pressed" in + the test log area, press PASS + Otherwise press FAIL" + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(MenuVisibilityTest::initialize) + .logArea() + .build() + .awaitAndCheck(); + } + + public static Frame initialize() { + Frame frame = new Frame("Menu visibility test"); + String menuTitle = "I_have_never_seen_so_long_Menu_Title_" + + "!_ehe-eha-ehu-ehi_ugu-gu!!!_;)_BANG_BANG..."; + MenuBar menubar = new MenuBar(); + Menu menu = new Menu(menuTitle); + MenuItem menuItem = new MenuItem("First item"); + menuItem.addActionListener(e -> + PassFailJFrame.log("First menu item was pressed.")); + menu.add(menuItem); + menubar.add(menu); + frame.setMenuBar(menubar); + frame.setSize(100, 200); + return frame; + } +} diff --git a/test/jdk/java/awt/Menu/RmInHideTest.java b/test/jdk/java/awt/Menu/RmInHideTest.java new file mode 100644 index 00000000000..b2d68400647 --- /dev/null +++ b/test/jdk/java/awt/Menu/RmInHideTest.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4039387 + * @summary Checks that calling Frame.remove() within hide() doesn't + * cause SEGV + * @key headful + * @run main RmInHideTest + */ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; + +public class RmInHideTest { + static volatile Point point; + static RmInHideTestFrame frame; + static volatile Dimension dimension; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() -> { + frame = new RmInHideTestFrame(); + frame.setSize(200, 200); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + point = frame.getButtonLocation(); + dimension = frame.getButtonDimension(); + }); + robot.mouseMove(point.x + dimension.width / 2, point.y + dimension.height / 2); + robot.mousePress(MouseEvent.BUTTON2_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON2_DOWN_MASK); + robot.waitForIdle(); + robot.delay(100); + System.out.println("Test pass"); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + static class RmInHideTestFrame extends Frame implements ActionListener { + MenuBar menubar = null; + Button b; + + public RmInHideTestFrame() { + super("RmInHideTest"); + b = new Button("Hide"); + b.setActionCommand("hide"); + b.addActionListener(this); + add("Center", b); + + MenuBar bar = new MenuBar(); + + Menu menu = new Menu("Test1", true); + menu.add(new MenuItem("Test1A")); + menu.add(new MenuItem("Test1B")); + menu.add(new MenuItem("Test1C")); + bar.add(menu); + + menu = new Menu("Test2", true); + menu.add(new MenuItem("Test2A")); + menu.add(new MenuItem("Test2B")); + menu.add(new MenuItem("Test2C")); + bar.add(menu); + setMenuBar(bar); + } + + @Override + public Dimension minimumSize() { + return new Dimension(200, 200); + } + + @Override + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + if (cmd.equals("hide")) { + hide(); + try { + Thread.currentThread().sleep(2000); + } catch (InterruptedException ex) { + // do nothing + } + show(); + } + } + + @Override + public void hide() { + menubar = getMenuBar(); + if (menubar != null) { + remove(menubar); + } + super.hide(); + } + + + @Override + public void show() { + if (menubar != null) { + setMenuBar(menubar); + } + super.show(); + } + + public Point getButtonLocation() { + return b.getLocationOnScreen(); + } + + public Dimension getButtonDimension() { + return b.getSize(); + } + } +} diff --git a/test/jdk/java/awt/Menu/SetShortCutTest.java b/test/jdk/java/awt/Menu/SetShortCutTest.java new file mode 100644 index 00000000000..b60b83dff9a --- /dev/null +++ b/test/jdk/java/awt/Menu/SetShortCutTest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4203208 + * @summary setShortcut method does not display proper text on Menu component + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SetShortCutTest + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; + +import static java.awt.event.KeyEvent.VK_META; +import static java.awt.event.KeyEvent.VK_SHIFT; + +public class SetShortCutTest { + public static void main(String[] args) throws Exception { + boolean isMac = System.getProperty("os.name").startsWith("Mac"); + String shortcut = "Ctrl+Shift+"; + if (isMac) { + shortcut = KeyEvent.getKeyText(VK_SHIFT) + "+" + KeyEvent.getKeyText(VK_META); + } + + String INSTRUCTIONS = """ + 1. Select menuitem 'Stuff -> Second' once to remove 'File -> First'. + 2. Select menuitem 'Stuff -> Second' again to add 'File -> First'. + 3. If menuitem 'File -> First' reads First """ + shortcut + """ + 'C', press PASS. Otherwise press FAIL. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(SetShortCutTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + return new TestMenuShortCut(); + } + + static class TestMenuShortCut extends Frame implements ActionListener { + Menu menu1; + MenuItem item1; + MenuItem item2; + boolean beenHere; + + public TestMenuShortCut() { + setTitle("Set ShortCut test"); + beenHere = false; + MenuBar mTopMenu = buildMenu(); + setSize(300, 300); + this.setMenuBar(mTopMenu); + } + + public MenuBar buildMenu() { + MenuBar bar; + bar = new MenuBar(); + menu1 = new Menu("File"); + item1 = new MenuItem("First"); + menu1.add(item1); + item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); + bar.add(menu1); + + // Stuff menu + item2 = new MenuItem("Second"); + Menu menu2 = new Menu("Stuff"); + menu2.add(item2); + item2.setShortcut(new MenuShortcut(KeyEvent.VK_C, false)); + bar.add(menu2); + + item1.addActionListener(this); + item2.addActionListener(this); + return bar; + } + + @Override + public void actionPerformed(ActionEvent event) { + if (event.getSource() == item1) { + Frame temp = new Frame("Accelerator key is working for 'First'"); + temp.setSize(300, 50); + temp.setVisible(true); + } + + // Click on the "Stuff" menu to remove the "first" menu item + else if (event.getSource() == item2) { + // If the item has not been removed from the menu, + // then remove "First" from the "File" menu + if (beenHere == false) { + item1.removeActionListener(this); + menu1.remove(item1); + beenHere = true; + } else { + item1 = new MenuItem("First"); + menu1.add(item1); + item1.addActionListener(this); + item1.setShortcut(new MenuShortcut(KeyEvent.VK_C, true)); + beenHere = false; + } + } + } + } +} From 50358d1ca49c26d100c5c658de29c75f864fdc60 Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Tue, 22 Apr 2025 08:00:01 +0000 Subject: [PATCH 041/901] 8354929: ZGC: Update collection stats while holding page allocator lock Reviewed-by: stefank, tschatzl, aboldtch --- src/hotspot/share/gc/z/zGeneration.cpp | 5 +-- src/hotspot/share/gc/z/zPageAllocator.cpp | 49 ++++++++++++----------- src/hotspot/share/gc/z/zPageAllocator.hpp | 6 ++- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/hotspot/share/gc/z/zGeneration.cpp b/src/hotspot/share/gc/z/zGeneration.cpp index f3cd3393fc5..e74d7a8e9f3 100644 --- a/src/hotspot/share/gc/z/zGeneration.cpp +++ b/src/hotspot/share/gc/z/zGeneration.cpp @@ -279,7 +279,6 @@ void ZGeneration::reset_statistics() { _freed = 0; _promoted = 0; _compacted = 0; - _page_allocator->reset_statistics(_id); } size_t ZGeneration::freed() const { @@ -860,7 +859,7 @@ void ZGenerationYoung::mark_start() { _remembered.flip(); // Update statistics - stat_heap()->at_mark_start(_page_allocator->stats(this)); + stat_heap()->at_mark_start(_page_allocator->update_and_stats(this)); } void ZGenerationYoung::mark_roots() { @@ -1209,7 +1208,7 @@ void ZGenerationOld::mark_start() { _mark.start(); // Update statistics - stat_heap()->at_mark_start(_page_allocator->stats(this)); + stat_heap()->at_mark_start(_page_allocator->update_and_stats(this)); // Note that we start a marking cycle. // Unlike other GCs, the color switch implicitly changes the nmethods diff --git a/src/hotspot/share/gc/z/zPageAllocator.cpp b/src/hotspot/share/gc/z/zPageAllocator.cpp index a0d2c46c414..7bb1dcdcf81 100644 --- a/src/hotspot/share/gc/z/zPageAllocator.cpp +++ b/src/hotspot/share/gc/z/zPageAllocator.cpp @@ -1373,9 +1373,25 @@ size_t ZPageAllocator::unused() const { return unused > 0 ? (size_t)unused : 0; } -ZPageAllocatorStats ZPageAllocator::stats(ZGeneration* generation) const { - ZLocker locker(&_lock); +void ZPageAllocator::update_collection_stats(ZGenerationId id) { + assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); +#ifdef ASSERT + size_t total_used = 0; + + ZPartitionIterator iter(&_partitions); + for (ZPartition* partition; iter.next(&partition);) { + total_used += partition->_used; + } + + assert(total_used == _used, "Must be consistent %zu == %zu", total_used, _used); +#endif + + _collection_stats[(int)id]._used_high = _used; + _collection_stats[(int)id]._used_low = _used; +} + +ZPageAllocatorStats ZPageAllocator::stats_inner(ZGeneration* generation) const { return ZPageAllocatorStats(_min_capacity, _max_capacity, soft_max_capacity(), @@ -1390,29 +1406,16 @@ ZPageAllocatorStats ZPageAllocator::stats(ZGeneration* generation) const { _stalled.size()); } -void ZPageAllocator::reset_statistics(ZGenerationId id) { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); -#ifdef ASSERT - { - // We may free without safepoint synchronization, take the lock to get - // consistent values. - ZLocker locker(&_lock); - size_t total_used = 0; - - ZPartitionIterator iter(&_partitions); - for (ZPartition* partition; iter.next(&partition);) { - total_used += partition->_used; - } - - assert(total_used == _used, "Must be consistent at safepoint %zu == %zu", total_used, _used); - } -#endif +ZPageAllocatorStats ZPageAllocator::stats(ZGeneration* generation) const { + ZLocker locker(&_lock); + return stats_inner(generation); +} - // Read once, we may have concurrent writers. - const size_t used = Atomic::load(&_used); +ZPageAllocatorStats ZPageAllocator::update_and_stats(ZGeneration* generation) { + ZLocker locker(&_lock); - _collection_stats[(int)id]._used_high = used; - _collection_stats[(int)id]._used_low = used; + update_collection_stats(generation->id()); + return stats_inner(generation); } void ZPageAllocator::increase_used_generation(ZGenerationId id, size_t size) { diff --git a/src/hotspot/share/gc/z/zPageAllocator.hpp b/src/hotspot/share/gc/z/zPageAllocator.hpp index 05b0d6774d9..5cd08aee94c 100644 --- a/src/hotspot/share/gc/z/zPageAllocator.hpp +++ b/src/hotspot/share/gc/z/zPageAllocator.hpp @@ -235,6 +235,9 @@ class ZPageAllocator { void notify_out_of_memory(); void restart_gc() const; + void update_collection_stats(ZGenerationId id); + ZPageAllocatorStats stats_inner(ZGeneration* generation) const; + void print_on_inner(outputStream* st) const; public: @@ -262,8 +265,7 @@ class ZPageAllocator { void promote_used(const ZPage* from, const ZPage* to); ZPageAllocatorStats stats(ZGeneration* generation) const; - - void reset_statistics(ZGenerationId id); + ZPageAllocatorStats update_and_stats(ZGeneration* generation); ZPage* alloc_page(ZPageType type, size_t size, ZAllocationFlags flags, ZPageAge age); void safe_destroy_page(ZPage* page); From bcc33d5ef3bdbfaee51c45014851c54028da03f1 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Tue, 22 Apr 2025 08:32:03 +0000 Subject: [PATCH 042/901] 8352504: RISC-V: implement and enable CMoveI/L 8346786: RISC-V: Reconsider ConditionalMoveLimit when adding conditional move Reviewed-by: fyang, fjiang --- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 30 ++++ .../cpu/riscv/c2_MacroAssembler_riscv.hpp | 4 + src/hotspot/cpu/riscv/c2_globals_riscv.hpp | 2 +- .../cpu/riscv/macroAssembler_riscv.cpp | 124 ++++++++++++++ .../cpu/riscv/macroAssembler_riscv.hpp | 5 + src/hotspot/cpu/riscv/riscv.ad | 103 ++++++++++-- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 8 - .../os_cpu/linux_riscv/riscv_hwprobe.cpp | 5 +- .../c2/irTests/ModINodeIdealizationTests.java | 6 +- .../c2/irTests/ModLNodeIdealizationTests.java | 6 +- .../c2/irTests/TestConv2BExpansion.java | 8 + .../compiler/c2/irTests/TestFPComparison.java | 1 - .../compiler/c2/irTests/TestIfMinMax.java | 17 +- .../lib/ir_framework/TestFramework.java | 1 + .../compiler/vectorapi/TestVectorTest.java | 3 +- .../bench/java/lang/ClassComparison.java | 101 +++++++++++ .../openjdk/bench/java/lang/FPComparison.java | 159 +++++++++++++++++- .../bench/java/lang/IntegerComparison.java | 153 +++++++++++++++++ .../bench/java/lang/LongComparison.java | 152 +++++++++++++++++ .../bench/java/lang/PointerComparison.java | 101 +++++++++++ 20 files changed, 940 insertions(+), 49 deletions(-) create mode 100644 test/micro/org/openjdk/bench/java/lang/ClassComparison.java create mode 100644 test/micro/org/openjdk/bench/java/lang/IntegerComparison.java create mode 100644 test/micro/org/openjdk/bench/java/lang/LongComparison.java create mode 100644 test/micro/org/openjdk/bench/java/lang/PointerComparison.java diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 39a49f8f1eb..0dc39744741 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -2156,6 +2156,36 @@ void C2_MacroAssembler::enc_cmove(int cmpFlag, Register op1, Register op2, Regis } } +void C2_MacroAssembler::enc_cmove_cmp_fp(int cmpFlag, FloatRegister op1, FloatRegister op2, Register dst, Register src, bool is_single) { + int op_select = cmpFlag & (~unsigned_branch_mask); + + switch (op_select) { + case BoolTest::eq: + cmov_cmp_fp_eq(op1, op2, dst, src, is_single); + break; + case BoolTest::ne: + cmov_cmp_fp_ne(op1, op2, dst, src, is_single); + break; + case BoolTest::le: + cmov_cmp_fp_le(op1, op2, dst, src, is_single); + break; + case BoolTest::ge: + assert(false, "Should go to BoolTest::le case"); + ShouldNotReachHere(); + break; + case BoolTest::lt: + cmov_cmp_fp_lt(op1, op2, dst, src, is_single); + break; + case BoolTest::gt: + assert(false, "Should go to BoolTest::lt case"); + ShouldNotReachHere(); + break; + default: + assert(false, "unsupported compare condition"); + ShouldNotReachHere(); + } +} + // Set dst to NaN if any NaN input. void C2_MacroAssembler::minmax_fp(FloatRegister dst, FloatRegister src1, FloatRegister src2, FLOAT_TYPE ft, bool is_min) { diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp index a650174d90f..73fceea3805 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp @@ -129,6 +129,10 @@ Register op1, Register op2, Register dst, Register src); + void enc_cmove_cmp_fp(int cmpFlag, + FloatRegister op1, FloatRegister op2, + Register dst, Register src, bool is_single); + void spill(Register r, bool is64, int offset) { is64 ? sd(r, Address(sp, offset)) : sw(r, Address(sp, offset)); diff --git a/src/hotspot/cpu/riscv/c2_globals_riscv.hpp b/src/hotspot/cpu/riscv/c2_globals_riscv.hpp index de3c1b17c8e..79bdc4917c9 100644 --- a/src/hotspot/cpu/riscv/c2_globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/c2_globals_riscv.hpp @@ -43,7 +43,7 @@ define_pd_global(bool, TieredCompilation, COMPILER1_PRESENT(true) NOT define_pd_global(intx, CompileThreshold, 10000); define_pd_global(intx, OnStackReplacePercentage, 140); -define_pd_global(intx, ConditionalMoveLimit, 0); +define_pd_global(intx, ConditionalMoveLimit, 3); define_pd_global(intx, FreqInlineSize, 325); define_pd_global(intx, MinJumpTableSize, 10); define_pd_global(intx, InteriorEntryAlignment, 16); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index c6393be0714..218da7cde03 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -1267,6 +1267,130 @@ void MacroAssembler::cmov_gtu(Register cmp1, Register cmp2, Register dst, Regist bind(no_set); } +// ----------- cmove, compare float ----------- + +// Move src to dst only if cmp1 == cmp2, +// otherwise leave dst unchanged, including the case where one of them is NaN. +// Clarification: +// java code : cmp1 != cmp2 ? dst : src +// transformed to : CMove dst, (cmp1 eq cmp2), dst, src +void MacroAssembler::cmov_cmp_fp_eq(FloatRegister cmp1, FloatRegister cmp2, Register dst, Register src, bool is_single) { + if (UseZicond) { + if (is_single) { + feq_s(t0, cmp1, cmp2); + } else { + feq_d(t0, cmp1, cmp2); + } + czero_nez(dst, dst, t0); + czero_eqz(t0 , src, t0); + orr(dst, dst, t0); + return; + } + Label no_set; + if (is_single) { + // jump if cmp1 != cmp2, including the case of NaN + // not jump (i.e. move src to dst) if cmp1 == cmp2 + float_bne(cmp1, cmp2, no_set); + } else { + double_bne(cmp1, cmp2, no_set); + } + mv(dst, src); + bind(no_set); +} + +// Keep dst unchanged only if cmp1 == cmp2, +// otherwise move src to dst, including the case where one of them is NaN. +// Clarification: +// java code : cmp1 == cmp2 ? dst : src +// transformed to : CMove dst, (cmp1 ne cmp2), dst, src +void MacroAssembler::cmov_cmp_fp_ne(FloatRegister cmp1, FloatRegister cmp2, Register dst, Register src, bool is_single) { + if (UseZicond) { + if (is_single) { + feq_s(t0, cmp1, cmp2); + } else { + feq_d(t0, cmp1, cmp2); + } + czero_eqz(dst, dst, t0); + czero_nez(t0 , src, t0); + orr(dst, dst, t0); + return; + } + Label no_set; + if (is_single) { + // jump if cmp1 == cmp2 + // not jump (i.e. move src to dst) if cmp1 != cmp2, including the case of NaN + float_beq(cmp1, cmp2, no_set); + } else { + double_beq(cmp1, cmp2, no_set); + } + mv(dst, src); + bind(no_set); +} + +// When cmp1 <= cmp2 or any of them is NaN then dst = src, otherwise, dst = dst +// Clarification +// scenario 1: +// java code : cmp2 < cmp1 ? dst : src +// transformed to : CMove dst, (cmp1 le cmp2), dst, src +// scenario 2: +// java code : cmp1 > cmp2 ? dst : src +// transformed to : CMove dst, (cmp1 le cmp2), dst, src +void MacroAssembler::cmov_cmp_fp_le(FloatRegister cmp1, FloatRegister cmp2, Register dst, Register src, bool is_single) { + if (UseZicond) { + if (is_single) { + flt_s(t0, cmp2, cmp1); + } else { + flt_d(t0, cmp2, cmp1); + } + czero_eqz(dst, dst, t0); + czero_nez(t0 , src, t0); + orr(dst, dst, t0); + return; + } + Label no_set; + if (is_single) { + // jump if cmp1 > cmp2 + // not jump (i.e. move src to dst) if cmp1 <= cmp2 or either is NaN + float_bgt(cmp1, cmp2, no_set); + } else { + double_bgt(cmp1, cmp2, no_set); + } + mv(dst, src); + bind(no_set); +} + +// When cmp1 < cmp2 or any of them is NaN then dst = src, otherwise, dst = dst +// Clarification +// scenario 1: +// java code : cmp2 <= cmp1 ? dst : src +// transformed to : CMove dst, (cmp1 lt cmp2), dst, src +// scenario 2: +// java code : cmp1 >= cmp2 ? dst : src +// transformed to : CMove dst, (cmp1 lt cmp2), dst, src +void MacroAssembler::cmov_cmp_fp_lt(FloatRegister cmp1, FloatRegister cmp2, Register dst, Register src, bool is_single) { + if (UseZicond) { + if (is_single) { + fle_s(t0, cmp2, cmp1); + } else { + fle_d(t0, cmp2, cmp1); + } + czero_eqz(dst, dst, t0); + czero_nez(t0 , src, t0); + orr(dst, dst, t0); + return; + } + Label no_set; + if (is_single) { + // jump if cmp1 >= cmp2 + // not jump (i.e. move src to dst) if cmp1 < cmp2 or either is NaN + float_bge(cmp1, cmp2, no_set); + } else { + double_bge(cmp1, cmp2, no_set); + } + mv(dst, src); + bind(no_set); +} + // Float compare branch instructions #define INSN(NAME, FLOATCMP, BRANCH) \ diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index b390fb236c2..c47200579c7 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -657,6 +657,11 @@ class MacroAssembler: public Assembler { void cmov_gt(Register cmp1, Register cmp2, Register dst, Register src); void cmov_gtu(Register cmp1, Register cmp2, Register dst, Register src); + void cmov_cmp_fp_eq(FloatRegister cmp1, FloatRegister cmp2, Register dst, Register src, bool is_single); + void cmov_cmp_fp_ne(FloatRegister cmp1, FloatRegister cmp2, Register dst, Register src, bool is_single); + void cmov_cmp_fp_le(FloatRegister cmp1, FloatRegister cmp2, Register dst, Register src, bool is_single); + void cmov_cmp_fp_lt(FloatRegister cmp1, FloatRegister cmp2, Register dst, Register src, bool is_single); + public: // We try to follow risc-v asm menomics. // But as we don't layout a reachable GOT, diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 1eb1464e7d9..2e9d25c8156 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -1933,6 +1933,12 @@ bool Matcher::match_rule_supported(int opcode) { case Op_SubHF: case Op_SqrtHF: return UseZfh; + + case Op_CMoveF: + case Op_CMoveD: + case Op_CMoveP: + case Op_CMoveN: + return false; } return true; // Per default match rules are supported. @@ -9938,12 +9944,15 @@ instruct far_cmpP_narrowOop_imm0_branch(cmpOpEqNe cmp, iRegN op1, immP0 zero, la // ============================================================================ // Conditional Move Instructions + +// --------- CMoveI --------- + instruct cmovI_cmpI(iRegINoSp dst, iRegI src, iRegI op1, iRegI op2, cmpOp cop) %{ match(Set dst (CMoveI (Binary cop (CmpI op1 op2)) (Binary dst src))); ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpI\n\t" + "CMoveI $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpI\n\t" %} ins_encode %{ @@ -9960,7 +9969,7 @@ instruct cmovI_cmpU(iRegINoSp dst, iRegI src, iRegI op1, iRegI op2, cmpOpU cop) ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpU\n\t" + "CMoveI $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpU\n\t" %} ins_encode %{ @@ -9977,7 +9986,7 @@ instruct cmovI_cmpL(iRegINoSp dst, iRegI src, iRegL op1, iRegL op2, cmpOp cop) % ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpL\n\t" + "CMoveI $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpL\n\t" %} ins_encode %{ @@ -9994,7 +10003,7 @@ instruct cmovI_cmpUL(iRegINoSp dst, iRegI src, iRegL op1, iRegL op2, cmpOpU cop) ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpUL\n\t" + "CMoveI $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpUL\n\t" %} ins_encode %{ @@ -10006,12 +10015,46 @@ instruct cmovI_cmpUL(iRegINoSp dst, iRegI src, iRegL op1, iRegL op2, cmpOpU cop) ins_pipe(pipe_class_compare); %} +instruct cmovI_cmpF(iRegINoSp dst, iRegI src, fRegF op1, fRegF op2, cmpOp cop) %{ + match(Set dst (CMoveI (Binary cop (CmpF op1 op2)) (Binary dst src))); + ins_cost(ALU_COST + BRANCH_COST); + + format %{ + "CMoveI $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpF\n\t" + %} + + ins_encode %{ + __ enc_cmove_cmp_fp($cop$$cmpcode, + as_FloatRegister($op1$$reg), as_FloatRegister($op2$$reg), + as_Register($dst$$reg), as_Register($src$$reg), true /* is_single */); + %} + + ins_pipe(pipe_class_compare); +%} + +instruct cmovI_cmpD(iRegINoSp dst, iRegI src, fRegD op1, fRegD op2, cmpOp cop) %{ + match(Set dst (CMoveI (Binary cop (CmpD op1 op2)) (Binary dst src))); + ins_cost(ALU_COST + BRANCH_COST); + + format %{ + "CMoveI $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpD\n\t" + %} + + ins_encode %{ + __ enc_cmove_cmp_fp($cop$$cmpcode | C2_MacroAssembler::double_branch_mask, + as_FloatRegister($op1$$reg), as_FloatRegister($op2$$reg), + as_Register($dst$$reg), as_Register($src$$reg), false /* is_single */); + %} + + ins_pipe(pipe_class_compare); +%} + instruct cmovI_cmpN(iRegINoSp dst, iRegI src, iRegN op1, iRegN op2, cmpOpU cop) %{ match(Set dst (CMoveI (Binary cop (CmpN op1 op2)) (Binary dst src))); ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpN\n\t" + "CMoveI $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpN\n\t" %} ins_encode %{ @@ -10028,7 +10071,7 @@ instruct cmovI_cmpP(iRegINoSp dst, iRegI src, iRegP op1, iRegP op2, cmpOpU cop) ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpP\n\t" + "CMoveI $dst, ($op1 $cop $op2), $dst, $src\t#@cmovI_cmpP\n\t" %} ins_encode %{ @@ -10040,12 +10083,14 @@ instruct cmovI_cmpP(iRegINoSp dst, iRegI src, iRegP op1, iRegP op2, cmpOpU cop) ins_pipe(pipe_class_compare); %} +// --------- CMoveL --------- + instruct cmovL_cmpL(iRegLNoSp dst, iRegL src, iRegL op1, iRegL op2, cmpOp cop) %{ match(Set dst (CMoveL (Binary cop (CmpL op1 op2)) (Binary dst src))); ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpL\n\t" + "CMoveL $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpL\n\t" %} ins_encode %{ @@ -10062,7 +10107,7 @@ instruct cmovL_cmpUL(iRegLNoSp dst, iRegL src, iRegL op1, iRegL op2, cmpOpU cop) ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpUL\n\t" + "CMoveL $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpUL\n\t" %} ins_encode %{ @@ -10079,7 +10124,7 @@ instruct cmovL_cmpI(iRegLNoSp dst, iRegL src, iRegI op1, iRegI op2, cmpOp cop) % ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpI\n\t" + "CMoveL $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpI\n\t" %} ins_encode %{ @@ -10096,7 +10141,7 @@ instruct cmovL_cmpU(iRegLNoSp dst, iRegL src, iRegI op1, iRegI op2, cmpOpU cop) ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpU\n\t" + "CMoveL $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpU\n\t" %} ins_encode %{ @@ -10108,12 +10153,46 @@ instruct cmovL_cmpU(iRegLNoSp dst, iRegL src, iRegI op1, iRegI op2, cmpOpU cop) ins_pipe(pipe_class_compare); %} +instruct cmovL_cmpF(iRegLNoSp dst, iRegL src, fRegF op1, fRegF op2, cmpOp cop) %{ + match(Set dst (CMoveL (Binary cop (CmpF op1 op2)) (Binary dst src))); + ins_cost(ALU_COST + BRANCH_COST); + + format %{ + "CMoveL $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpF\n\t" + %} + + ins_encode %{ + __ enc_cmove_cmp_fp($cop$$cmpcode, + as_FloatRegister($op1$$reg), as_FloatRegister($op2$$reg), + as_Register($dst$$reg), as_Register($src$$reg), true /* is_single */); + %} + + ins_pipe(pipe_class_compare); +%} + +instruct cmovL_cmpD(iRegLNoSp dst, iRegL src, fRegD op1, fRegD op2, cmpOp cop) %{ + match(Set dst (CMoveL (Binary cop (CmpD op1 op2)) (Binary dst src))); + ins_cost(ALU_COST + BRANCH_COST); + + format %{ + "CMoveL $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpD\n\t" + %} + + ins_encode %{ + __ enc_cmove_cmp_fp($cop$$cmpcode | C2_MacroAssembler::double_branch_mask, + as_FloatRegister($op1$$reg), as_FloatRegister($op2$$reg), + as_Register($dst$$reg), as_Register($src$$reg), false /* is_single */); + %} + + ins_pipe(pipe_class_compare); +%} + instruct cmovL_cmpN(iRegLNoSp dst, iRegL src, iRegN op1, iRegN op2, cmpOpU cop) %{ match(Set dst (CMoveL (Binary cop (CmpN op1 op2)) (Binary dst src))); ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpN\n\t" + "CMoveL $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpN\n\t" %} ins_encode %{ @@ -10130,7 +10209,7 @@ instruct cmovL_cmpP(iRegLNoSp dst, iRegL src, iRegP op1, iRegP op2, cmpOpU cop) ins_cost(ALU_COST + BRANCH_COST); format %{ - "CMove $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpP\n\t" + "CMoveL $dst, ($op1 $cop $op2), $dst, $src\t#@cmovL_cmpP\n\t" %} ins_encode %{ diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index a0de9d767bf..8dcffc9c646 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -248,14 +248,6 @@ void VM_Version::common_initialize() { #ifdef COMPILER2 void VM_Version::c2_initialize() { - if (UseCMoveUnconditionally) { - FLAG_SET_DEFAULT(UseCMoveUnconditionally, false); - } - - if (ConditionalMoveLimit > 0) { - FLAG_SET_DEFAULT(ConditionalMoveLimit, 0); - } - if (!UseRVV) { FLAG_SET_DEFAULT(MaxVectorSize, 0); } else { diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp index 06d6aaf109f..d19128cafc2 100644 --- a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp +++ b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp @@ -233,10 +233,13 @@ void RiscvHwprobe::add_features_from_query_result() { if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZACAS)) { VM_Version::ext_Zacas.enable_feature(); } -#endif + // Currently tests shows that cmove using Zicond instructions will bring + // performance regression, but to get a test coverage all the time, will + // still prefer to enabling it in debug version. if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZICOND)) { VM_Version::ext_Zicond.enable_feature(); } +#endif if (is_valid(RISCV_HWPROBE_KEY_CPUPERF_0)) { VM_Version::unaligned_access.enable_feature( query[RISCV_HWPROBE_KEY_CPUPERF_0].value & RISCV_HWPROBE_MISALIGNED_MASK); diff --git a/test/hotspot/jtreg/compiler/c2/irTests/ModINodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/ModINodeIdealizationTests.java index dffafea7ea8..d19e2562779 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/ModINodeIdealizationTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/ModINodeIdealizationTests.java @@ -121,10 +121,8 @@ public int powerOf2Random(int x) { } @Test - @IR(applyIfPlatform = {"riscv64", "false"}, - failOn = {IRNode.MOD_I}) - @IR(applyIfPlatform = {"riscv64", "false"}, - counts = {IRNode.AND_I, ">=1", IRNode.RSHIFT, ">=1", IRNode.CMP_I, "2"}) + @IR(failOn = {IRNode.MOD_I}) + @IR(counts = {IRNode.AND_I, ">=1", IRNode.RSHIFT, ">=1", IRNode.CMP_I, "2"}) // Special optimization for the case 2^k-1 for bigger k public int powerOf2Minus1(int x) { return x % 127; diff --git a/test/hotspot/jtreg/compiler/c2/irTests/ModLNodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/ModLNodeIdealizationTests.java index e931ff87c09..fc08ef60603 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/ModLNodeIdealizationTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/ModLNodeIdealizationTests.java @@ -105,10 +105,8 @@ public long powerOf2Random(long x) { } @Test - @IR(applyIfPlatform = {"riscv64", "false"}, - failOn = {IRNode.MOD_L}) - @IR(applyIfPlatform = {"riscv64", "false"}, - counts = {IRNode.AND_L, ">=1", IRNode.RSHIFT, ">=1", IRNode.CMP_L, "2"}) + @IR(failOn = {IRNode.MOD_L}) + @IR(counts = {IRNode.AND_L, ">=1", IRNode.RSHIFT, ">=1", IRNode.CMP_L, "2"}) // Special optimization for the case 2^k-1 for bigger k public long powerOf2Minus1(long x) { return x % ((1L << 33) - 1); diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestConv2BExpansion.java b/test/hotspot/jtreg/compiler/c2/irTests/TestConv2BExpansion.java index de32b7b21f6..35d676b6ddb 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestConv2BExpansion.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestConv2BExpansion.java @@ -42,6 +42,14 @@ public static void main(String[] args) { TestFramework.run(); } + // These IR checks do not apply on riscv64, as riscv64 supports Conv2B, e.g. for `return x == 0`, + // the graph looks like: + // Return (XorI (Conv2B ConI(#int: 1))) + // On other platforms, e.g. x86_64 which does not supports Conv2B, the graph looks like: + // Return (CMoveI (Bool (CompI (Param1 ConI(#int: 0))) ConI(#int: 1) ConI(#int: 0))) + // On riscv64, current graph is more efficient than `CMoveI`, as it + // 1. generates less code + // 2. even when zicond is not supported, it does not introduce branches. @Test @IR(counts = {IRNode.CMOVE_I, "1"}, failOn = {IRNode.XOR}) public boolean testIntEquals0(int x) { diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestFPComparison.java b/test/hotspot/jtreg/compiler/c2/irTests/TestFPComparison.java index 8445c856b4e..a06cb45d59e 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestFPComparison.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestFPComparison.java @@ -31,7 +31,6 @@ * @summary Test that code generation for fp comparison works as intended * @library /test/lib / * @run driver compiler.c2.irTests.TestFPComparison - * @requires os.arch != "riscv64" */ public class TestFPComparison { static final double[] DOUBLES = new double[] { diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestIfMinMax.java b/test/hotspot/jtreg/compiler/c2/irTests/TestIfMinMax.java index e232895257a..bb0a1200a7f 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestIfMinMax.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestIfMinMax.java @@ -33,7 +33,6 @@ * @bug 8324655 8329797 8331090 * @key randomness * @summary Test that if expressions are properly folded into min/max nodes - * @requires os.arch != "riscv64" * @library /test/lib / * @run driver compiler.c2.irTests.TestIfMinMax */ @@ -228,7 +227,7 @@ static Object[] setupLongArrays() { @Test @IR(applyIf = { "SuperWordReductions", "true" }, - applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true"}, + applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true", "rvv", "true"}, counts = { IRNode.MAX_REDUCTION_V, "> 0" }) @Arguments(setup = "setupIntArrays") public Object[] testMaxIntReduction(int[] a, int[] b) { @@ -262,7 +261,7 @@ public void checkTestMaxIntReduction(Object[] vals) { @Test @IR(applyIf = { "SuperWordReductions", "true" }, - applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true"}, + applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true", "rvv", "true"}, counts = { IRNode.MIN_REDUCTION_V, "> 0" }) @Arguments(setup = "setupIntArrays") public Object[] testMinIntReduction(int[] a, int[] b) { @@ -297,7 +296,7 @@ public void checkTestMinIntReduction(Object[] vals) { @Test @IR(applyIf = { "SuperWordReductions", "true" }, - applyIfCPUFeatureOr = { "avx512", "true" }, + applyIfCPUFeatureOr = { "avx512", "true", "rvv", "true" }, counts = { IRNode.MAX_REDUCTION_V, "> 0" }) @Arguments(setup = "setupLongArrays") public Object[] testMaxLongReduction(long[] a, long[] b) { @@ -332,7 +331,7 @@ public void checkTestMaxLongReduction(Object[] vals) { @Test @IR(applyIf = { "SuperWordReductions", "true" }, - applyIfCPUFeatureOr = { "avx512", "true" }, + applyIfCPUFeatureOr = { "avx512", "true", "rvv", "true" }, counts = { IRNode.MIN_REDUCTION_V, "> 0" }) @Arguments(setup = "setupLongArrays") public Object[] testMinLongReduction(long[] a, long[] b) { @@ -366,7 +365,7 @@ public void checkTestMinLongReduction(Object[] vals) { } @Test - @IR(applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true"}, + @IR(applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true", "rvv", "true"}, counts = { IRNode.MAX_VI, "> 0" }) @Arguments(setup = "setupIntArrays") public Object[] testMaxIntVector(int[] a, int[] b) { @@ -401,7 +400,7 @@ public void checkTestMaxIntVector(Object[] vals) { } @Test - @IR(applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true"}, + @IR(applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true", "rvv", "true"}, counts = { IRNode.MIN_VI, "> 0" }) @Arguments(setup = "setupIntArrays") public Object[] testMinIntVector(int[] a, int[] b) { @@ -436,7 +435,7 @@ public void checkTestMinIntVector(Object[] vals) { } @Test - @IR(applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true"}, + @IR(applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true", "rvv", "true"}, counts = { IRNode.MAX_VL, "> 0" }) @Arguments(setup = "setupLongArrays") public Object[] testMaxLongVector(long[] a, long[] b) { @@ -471,7 +470,7 @@ public void checkTestMaxLongVector(Object[] vals) { } @Test - @IR(applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true"}, + @IR(applyIfCPUFeatureOr = { "sse4.1", "true" , "asimd" , "true", "rvv", "true"}, counts = { IRNode.MIN_VL, "> 0" }) @Arguments(setup = "setupLongArrays") public Object[] testMinLongVector(long[] a, long[] b) { diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java b/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java index 8f70ad9b7d0..a6d738b3a09 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java @@ -146,6 +146,7 @@ public class TestFramework { "UseRVV", "UseZbb", "UseZfh", + "UseZicond", "UseZvbb" ) ); diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorTest.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorTest.java index 35f357c22f2..c6329c70f65 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/TestVectorTest.java +++ b/test/hotspot/jtreg/compiler/vectorapi/TestVectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -35,6 +35,7 @@ * @library /test/lib / * @requires (os.simpleArch == "x64" & vm.cpu.features ~= ".*sse4.*" & (vm.opt.UseSSE == "null" | vm.opt.UseSSE > 3)) * | os.arch == "aarch64" + * | (os.arch == "riscv64" & vm.cpu.features ~= ".*rvv.*") * @run driver compiler.vectorapi.TestVectorTest */ public class TestVectorTest { diff --git a/test/micro/org/openjdk/bench/java/lang/ClassComparison.java b/test/micro/org/openjdk/bench/java/lang/ClassComparison.java new file mode 100644 index 00000000000..2a768f243e2 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/ClassComparison.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025, Rivos Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.bench.java.lang; + +import org.openjdk.jmh.annotations.*; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.random.RandomGenerator; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 1) +@Fork(3) +public class ClassComparison { + static final int INVOCATIONS = 1024; + + Class[] c1; + Class[] c2; + int[] res; + long[] resLong; + Object[] resObject; + Object ro1; + Object ro2; + Object[] resClass; + Class rc1; + Class rc2; + + @Setup + public void setup() { + var random = RandomGenerator.getDefault(); + c1 = new Class[INVOCATIONS]; + c2 = new Class[INVOCATIONS]; + res = new int[INVOCATIONS]; + resLong = new long[INVOCATIONS]; + resObject = new Object[INVOCATIONS]; + ro1 = new Object(); + ro2 = new Object(); + resClass = new Class[INVOCATIONS]; + rc1 = Float.class; + rc2 = Double.class; + for (int i = 0; i < INVOCATIONS; i++) { + c1[i] = random.nextBoolean() ? Float.class : Double.class; + } + List list = Arrays.asList(c1); + Collections.shuffle(list); + list.toArray(c2); + } + + @Benchmark + public void equalClass() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (c1[i] == c2[i]) ? 1 : 2; + } + } + + @Benchmark + public void notEqualClass() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (c1[i] != c2[i]) ? 1 : 2; + } + } + + public void equalClassResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (c1[i] == c2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void notEqualClassResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (c1[i] != c2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } +} diff --git a/test/micro/org/openjdk/bench/java/lang/FPComparison.java b/test/micro/org/openjdk/bench/java/lang/FPComparison.java index 9fe88b934f8..8074ada3257 100644 --- a/test/micro/org/openjdk/bench/java/lang/FPComparison.java +++ b/test/micro/org/openjdk/bench/java/lang/FPComparison.java @@ -23,6 +23,7 @@ package org.openjdk.bench.java.lang; import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; import java.util.concurrent.TimeUnit; import java.util.random.RandomGenerator; @@ -41,6 +42,13 @@ public class FPComparison { float[] f2; double[] d2; int[] res; + long[] resLong; + Object[] resObject; + Object ro1; + Object ro2; + Class[] resClass; + Class rc1; + Class rc2; @Setup public void setup() { @@ -50,6 +58,13 @@ public void setup() { f2 = new float[INVOCATIONS]; d2 = new double[INVOCATIONS]; res = new int[INVOCATIONS]; + resLong = new long[INVOCATIONS]; + resObject = new Object[INVOCATIONS]; + ro1 = new Object(); + ro2 = new Object(); + resClass = new Class[INVOCATIONS]; + rc1 = Float.class; + rc2 = Double.class; for (int i = 0; i < INVOCATIONS; i++) { int type = random.nextInt(5); if (type == 1) { @@ -79,56 +94,184 @@ public void setup() { @Benchmark public void isNanFloat() { for (int i = 0; i < INVOCATIONS; i++) { - res[i] = Float.isNaN(f1[i]) ? 1 : 0; + res[i] = Float.isNaN(f1[i]) ? 1 : 2; } } @Benchmark public void isNanDouble() { for (int i = 0; i < INVOCATIONS; i++) { - res[i] = Double.isNaN(d1[i]) ? 1 : 0; + res[i] = Double.isNaN(d1[i]) ? 1 : 2; } } @Benchmark public void isInfiniteFloat() { for (int i = 0; i < INVOCATIONS; i++) { - res[i] = Float.isInfinite(f1[i]) ? 1 : 0; + res[i] = Float.isInfinite(f1[i]) ? 1 : 2; } } @Benchmark public void isInfiniteDouble() { for (int i = 0; i < INVOCATIONS; i++) { - res[i] = Double.isInfinite(d1[i]) ? 1 : 0; + res[i] = Double.isInfinite(d1[i]) ? 1 : 2; } } @Benchmark public void isFiniteFloat() { for (int i = 0; i < INVOCATIONS; i++) { - res[i] = Float.isFinite(f1[i]) ? 1 : 0; + res[i] = Float.isFinite(f1[i]) ? 1 : 2; } } @Benchmark public void isFiniteDouble() { for (int i = 0; i < INVOCATIONS; i++) { - res[i] = Double.isFinite(d1[i]) ? 1 : 0; + res[i] = Double.isFinite(d1[i]) ? 1 : 2; } } @Benchmark public void equalFloat() { for (int i = 0; i < INVOCATIONS; i++) { - res[i] = (f1[i] == f2[i]) ? 1 : 0; + res[i] = (f1[i] == f2[i]) ? 1 : 2; } } @Benchmark public void equalDouble() { for (int i = 0; i < INVOCATIONS; i++) { - res[i] = (d1[i] == d2[i]) ? 1 : 0; + res[i] = (d1[i] == d2[i]) ? 1 : 2; + } + } + + @Benchmark + public void lessFloat() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (f1[i] < f2[i]) ? 1 : 2; + } + } + + @Benchmark + public void lessDouble() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (d1[i] < d2[i]) ? 1 : 2; + } + } + + @Benchmark + public void lessEqualFloat() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (f1[i] <= f2[i]) ? 1 : 2; + } + } + + @Benchmark + public void lessEqualDouble() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (d1[i] <= d2[i]) ? 1 : 2; + } + } + + @Benchmark + public void greaterFloat() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (f1[i] > f2[i]) ? 1 : 2; + } + } + + @Benchmark + public void greaterDouble() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (d1[i] > d2[i]) ? 1 : 2; + } + } + + @Benchmark + public void greaterEqualFloat() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (f1[i] >= f2[i]) ? 1 : 2; + } + } + + @Benchmark + public void greaterEqualDouble() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (d1[i] >= d2[i]) ? 1 : 2; + } + } + + // --------- result: long --------- + + @Benchmark + public void equalFloatResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (f1[i] == f2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void equalDoubleResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (d1[i] == d2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void lessFloatResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (f1[i] < f2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void lessDoubleResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (d1[i] < d2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void lessEqualFloatResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (f1[i] <= f2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void lessEqualDoubleResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (d1[i] <= d2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void greaterFloatResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (f1[i] > f2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void greaterDoubleResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (d1[i] > d2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void greaterEqualFloatResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (f1[i] >= f2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void greaterEqualDoubleResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (d1[i] >= d2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; } } } diff --git a/test/micro/org/openjdk/bench/java/lang/IntegerComparison.java b/test/micro/org/openjdk/bench/java/lang/IntegerComparison.java new file mode 100644 index 00000000000..1853be8497d --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/IntegerComparison.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2025, Rivos Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.bench.java.lang; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; + +import java.util.concurrent.TimeUnit; +import java.util.random.RandomGenerator; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 1) +@Fork(3) +public class IntegerComparison { + static final int INVOCATIONS = 1024; + + int[] i1; + int[] i2; + int[] res; + long[] resLong; + Object[] resObject; + Object ro1; + Object ro2; + Object[] resClass; + Class rc1; + Class rc2; + + @Setup + public void setup() { + var random = RandomGenerator.getDefault(); + i1 = new int[INVOCATIONS]; + i2 = new int[INVOCATIONS]; + res = new int[INVOCATIONS]; + resLong = new long[INVOCATIONS]; + resObject = new Object[INVOCATIONS]; + ro1 = new Object(); + ro2 = new Object(); + resClass = new Class[INVOCATIONS]; + rc1 = Float.class; + rc2 = Double.class; + for (int i = 0; i < INVOCATIONS; i++) { + i1[i] = random.nextInt(INVOCATIONS); + i2[i] = random.nextInt(INVOCATIONS); + } + } + + @Benchmark + public void equalInteger() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (i1[i] == i2[i]) ? 1 : 2; + } + } + + @Benchmark + public void notEqualInteger() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (i1[i] != i2[i]) ? 1 : 2; + } + } + + @Benchmark + public void lessInteger() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (i1[i] < i2[i]) ? 1 : 2; + } + } + + @Benchmark + public void lessEqualInteger() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (i1[i] <= i2[i]) ? 1 : 2; + } + } + + @Benchmark + public void greaterInteger() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (i1[i] > i2[i]) ? 1 : 2; + } + } + + @Benchmark + public void greaterEqualInteger() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (i1[i] >= i2[i]) ? 1 : 2; + } + } + + // --------- result: long --------- + + public void equalIntegerResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (i1[i] == i2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void notEqualIntegerResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (i1[i] != i2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + public void lessIntegerResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (i1[i] < i2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void lessEqualIntegerResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (i1[i] <= i2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + public void greaterIntegerResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (i1[i] > i2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void greaterEqualIntegerResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (i1[i] >= i2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } +} diff --git a/test/micro/org/openjdk/bench/java/lang/LongComparison.java b/test/micro/org/openjdk/bench/java/lang/LongComparison.java new file mode 100644 index 00000000000..bed5ee245b2 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/LongComparison.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2025, Rivos Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.bench.java.lang; + +import org.openjdk.jmh.annotations.*; + +import java.util.concurrent.TimeUnit; +import java.util.random.RandomGenerator; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 1) +@Fork(3) +public class LongComparison { + static final int INVOCATIONS = 1024; + + long[] l1; + long[] l2; + int[] res; + long[] resLong; + Object[] resObject; + Object ro1; + Object ro2; + Object[] resClass; + Class rc1; + Class rc2; + + @Setup + public void setup() { + var random = RandomGenerator.getDefault(); + l1 = new long[INVOCATIONS]; + l2 = new long[INVOCATIONS]; + res = new int[INVOCATIONS]; + resLong = new long[INVOCATIONS]; + resObject = new Object[INVOCATIONS]; + ro1 = new Object(); + ro2 = new Object(); + resClass = new Class[INVOCATIONS]; + rc1 = Float.class; + rc2 = Double.class; + for (int i = 0; i < INVOCATIONS; i++) { + l1[i] = random.nextLong(INVOCATIONS); + l2[i] = random.nextLong(INVOCATIONS); + } + } + + @Benchmark + public void equalLong() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (l1[i] == l2[i]) ? 1 : 2; + } + } + + @Benchmark + public void notEqualLong() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (l1[i] != l2[i]) ? 1 : 2; + } + } + + @Benchmark + public void lessLong() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (l1[i] < l2[i]) ? 1 : 2; + } + } + + @Benchmark + public void lessEqualLong() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (l1[i] <= l2[i]) ? 1 : 2; + } + } + + @Benchmark + public void greaterLong() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (l1[i] > l2[i]) ? 1 : 2; + } + } + + @Benchmark + public void greaterEqualLong() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (l1[i] >= l2[i]) ? 1 : 2; + } + } + + // --------- result: long --------- + + public void equalLongResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (l1[i] == l2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void notEqualLongResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (l1[i] != l2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + public void lessLongResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (l1[i] < l2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void lessEqualLongResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (l1[i] <= l2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + public void greaterLongResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (l1[i] > l2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void greaterEqualLongResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (l1[i] >= l2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } +} diff --git a/test/micro/org/openjdk/bench/java/lang/PointerComparison.java b/test/micro/org/openjdk/bench/java/lang/PointerComparison.java new file mode 100644 index 00000000000..b6bcf008619 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/PointerComparison.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025, Rivos Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.bench.java.lang; + +import org.openjdk.jmh.annotations.*; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.random.RandomGenerator; + +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 1) +@Fork(3) +public class PointerComparison { + static final int INVOCATIONS = 1024; + + Object[] o1; + Object[] o2; + int[] res; + long[] resLong; + Object[] resObject; + Object ro1; + Object ro2; + Object[] resClass; + Class rc1; + Class rc2; + + @Setup + public void setup() { + var random = RandomGenerator.getDefault(); + o1 = new Object[INVOCATIONS]; + o2 = new Object[INVOCATIONS]; + res = new int[INVOCATIONS]; + resLong = new long[INVOCATIONS]; + resObject = new Object[INVOCATIONS]; + ro1 = new Object(); + ro2 = new Object(); + resClass = new Class[INVOCATIONS]; + rc1 = Float.class; + rc2 = Double.class; + for (int i = 0; i < INVOCATIONS; i++) { + o1[i] = new Object(); + } + List list = Arrays.asList(o1); + Collections.shuffle(list); + list.toArray(o2); + } + + @Benchmark + public void equalObject() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (o1[i] == o2[i]) ? 1 : 2; + } + } + + @Benchmark + public void notEqualObject() { + for (int i = 0; i < INVOCATIONS; i++) { + res[i] = (o1[i] != o2[i]) ? 1 : 2; + } + } + + public void equalObjectResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (o1[i] == o2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } + + @Benchmark + public void notEqualObjectResLong() { + for (int i = 0; i < INVOCATIONS; i++) { + resLong[i] = (o1[i] != o2[i]) ? Long.MAX_VALUE : Long.MIN_VALUE; + } + } +} From 7cd084cf350f66fd6ed5b6f5ba9fda71072963fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C5=A0ipka?= Date: Tue, 22 Apr 2025 08:46:52 +0000 Subject: [PATCH 043/901] 8350442: Update copyright Reviewed-by: naoto, jlu --- test/jdk/sun/nio/cs/Test6392804.java | 2 +- test/jdk/sun/nio/cs/TestUTF_32.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/sun/nio/cs/Test6392804.java b/test/jdk/sun/nio/cs/Test6392804.java index a98428c3e7f..63da96162c4 100644 --- a/test/jdk/sun/nio/cs/Test6392804.java +++ b/test/jdk/sun/nio/cs/Test6392804.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2025, 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 diff --git a/test/jdk/sun/nio/cs/TestUTF_32.java b/test/jdk/sun/nio/cs/TestUTF_32.java index ba042494fd2..10de9084b00 100644 --- a/test/jdk/sun/nio/cs/TestUTF_32.java +++ b/test/jdk/sun/nio/cs/TestUTF_32.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2025, 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 From 9eeb86d972ac4cc38d923b2b868b426bbd27a4e8 Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 08:58:42 +0000 Subject: [PATCH 044/901] 8354341: Open some JTable bugs 7 Reviewed-by: kizune, serb --- test/jdk/javax/swing/JTable/ShiftClick.java | 187 ++++++++++++++++++++ test/jdk/javax/swing/JTable/bug4128506.java | 84 +++++++++ test/jdk/javax/swing/JTable/bug4190222.java | 103 +++++++++++ test/jdk/javax/swing/JTable/bug4224179.java | 74 ++++++++ 4 files changed, 448 insertions(+) create mode 100644 test/jdk/javax/swing/JTable/ShiftClick.java create mode 100644 test/jdk/javax/swing/JTable/bug4128506.java create mode 100644 test/jdk/javax/swing/JTable/bug4190222.java create mode 100644 test/jdk/javax/swing/JTable/bug4224179.java diff --git a/test/jdk/javax/swing/JTable/ShiftClick.java b/test/jdk/javax/swing/JTable/ShiftClick.java new file mode 100644 index 00000000000..4d617b5eeda --- /dev/null +++ b/test/jdk/javax/swing/JTable/ShiftClick.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.border.BevelBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4201917 + * @summary Shift Click in table before making selection + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ShiftClick + */ + +public class ShiftClick { + private static final String INSTRUCTIONS = """ + Shift click in the table. Check that all cells + from the first through where you clicked are selected. + If the cells are selected, press pass, otherwise fail. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(ShiftClick::createTestUI) + .logArea(6) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("ShiftClick"); + + // Take the dummy data from SwingSet. + final String[] names = {"First Name", "Last Name", "Favorite Color", + "Favorite Number", "Vegetarian"}; + final Object[][] data = { + {"Mark", "Andrews", "Red", 2, true}, + {"Tom", "Ball", "Blue", 99, false}, + {"Alan", "Chung", "Green", 838, false}, + {"Jeff", "Dinkins", "Turquois", 8, true}, + {"Amy", "Fowler", "Yellow", 3, false}, + {"Brian", "Gerhold", "Green", 0, false}, + {"James", "Gosling", "Pink", 21, false}, + {"David", "Karlton", "Red", 1, false}, + {"Dave", "Kloba", "Yellow", 14, false}, + {"Peter", "Korn", "Purple", 12, false}, + {"Phil", "Milne", "Purple", 3, false}, + {"Dave", "Moore", "Green", 88, false}, + {"Hans", "Muller", "Maroon", 5, false}, + {"Rick", "Levenson", "Blue", 2, false}, + {"Tim", "Prinzing", "Blue", 22, false}, + {"Chester", "Rose", "Black", 0, false}, + {"Ray", "Ryan", "Gray", 77, false}, + {"Georges", "Saab", "Red", 4, false}, + {"Willie", "Walker", "Phthalo Blue", 4, false}, + {"Kathy", "Walrath", "Blue", 8, false}, + {"Arnaud", "Weber", "Green", 44, false} + }; + + // Create a model of the data. + TableModel dataModel = new AbstractTableModel() { + // These methods always need to be implemented. + public int getColumnCount() { + return names.length; + } + + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + // The default implementations of these methods in + // AbstractTableModel would work, but we can refine them. + public String getColumnName(int column) { + return names[column]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public boolean isCellEditable(int row, int col) { + return true; + } + + public void setValueAt(Object aValue, int row, int column) { + System.out.println("Setting value to: " + aValue); + data[row][column] = aValue; + } + }; + + // Create the table + JTable tableView = new JTable(dataModel); + // Turn off auto-resizing so that we can set column sizes programmatically. + // In this mode, all columns will get their preferred widths, as set blow. + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + // Create a combo box to show that you can use one in a table. + JComboBox comboBox = new JComboBox(); + comboBox.addItem("Red"); + comboBox.addItem("Orange"); + comboBox.addItem("Yellow"); + comboBox.addItem("Green"); + comboBox.addItem("Blue"); + comboBox.addItem("Indigo"); + comboBox.addItem("Violet"); + + TableColumn colorColumn = tableView.getColumn("Favorite Color"); + // Use the combo box as the editor in the "Favorite Color" column. + colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); + + // Set a pink background and tooltip for the Color column renderer. + DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer(); + colorColumnRenderer.setBackground(Color.pink); + colorColumnRenderer.setToolTipText("Click for combo box"); + colorColumn.setCellRenderer(colorColumnRenderer); + + // Set a tooltip for the header of the colors column. + TableCellRenderer headerRenderer = colorColumn.getHeaderRenderer(); + if (headerRenderer instanceof DefaultTableCellRenderer) + ((DefaultTableCellRenderer) headerRenderer).setToolTipText("Hi Mom!"); + + // Set the width of the "Vegetarian" column. + TableColumn vegetarianColumn = tableView.getColumn("Vegetarian"); + vegetarianColumn.setPreferredWidth(100); + + // Show the values in the "Favorite Number" column in different colors. + TableColumn numbersColumn = tableView.getColumn("Favorite Number"); + DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer() { + public void setValue(Object value) { + int cellValue = (value instanceof Number) ? ((Number) value).intValue() : 0; + setForeground((cellValue > 30) ? Color.black : Color.red); + setText((value == null) ? "" : value.toString()); + } + }; + numberColumnRenderer.setHorizontalAlignment(JLabel.RIGHT); + numbersColumn.setCellRenderer(numberColumnRenderer); + numbersColumn.setPreferredWidth(110); + + // Finish setting up the table. + JScrollPane scrollpane = new JScrollPane(tableView); + scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED)); + scrollpane.setPreferredSize(new Dimension(430, 200)); + + frame.add(scrollpane); + frame.setSize(500, 200); + return frame; + } +} diff --git a/test/jdk/javax/swing/JTable/bug4128506.java b/test/jdk/javax/swing/JTable/bug4128506.java new file mode 100644 index 00000000000..21273c6f318 --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4128506.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableModel; + +/* + * @test + * @bug 4128506 + * @summary Tests that JTable with AUTO_RESIZE_ALL_COLUMNS correctly compute width of columns + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4128506 + */ + +public class bug4128506 { + private static final String INSTRUCTIONS = """ + If the columns of JTable have the same width the test passes, else test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4128506::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + final Object[][] data = { + {"cell_1_1", "cell_1_2", "cell_1_3"}, + {"cell_2_1", "cell_2_2", "cell_2_3"}, + {"cell_3_1", "cell_3_2", "cell_3_3"}, + {"cell_4_1", "cell_4_2", "cell_4_3"}, + }; + + TableModel dataModel = new AbstractTableModel() { + public int getColumnCount() { + return 3; + } + + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + }; + + JFrame frame = new JFrame("bug4128506"); + JTable tableView = new JTable(dataModel); + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + tableView.getColumnModel().getColumn(1).setMinWidth(5); + JScrollPane scrollpane = new JScrollPane(tableView); + frame.add(scrollpane); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/javax/swing/JTable/bug4190222.java b/test/jdk/javax/swing/JTable/bug4190222.java new file mode 100644 index 00000000000..5d6fcd2b0cc --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4190222.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.Robot; +import java.util.Vector; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableModel; + +/* + * @test + * @bug 4190222 + * @summary Setting data vector on the model correctly repaint table + * @key headful + * @run main bug4190222 + */ + +public class bug4190222 { + static JFrame frame; + static DefaultTableModel dtm; + static JTable tbl; + + static Vector data; + static Vector colNames; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(250); + + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + Dimension preResize = tbl.getSize(); + dtm.setDataVector(data, colNames); + + if (!preResize.equals(tbl.getSize())) { + throw new RuntimeException("Size of table changed after resizing."); + } + }); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4190222"); + + data = new Vector(1, 1); + colNames = new Vector(3); + for (int i = 1; i < 4; i++) { + Vector row = new Vector(1, 1); + row.addElement("Row " + i + ", Col 1"); + row.addElement("Row " + i + ", Col 2"); + row.addElement("Row " + i + ", Col 3"); + data.addElement(row); + } + colNames.addElement("Col 1"); + colNames.addElement("Col 2"); + colNames.addElement("Col 3"); + + dtm = new DefaultTableModel(data, colNames); + tbl = new JTable(dtm); + JScrollPane scrollPane = new JScrollPane(tbl); + frame.add("Center", scrollPane); + JPanel panel = new JPanel(); + frame.add("South", panel); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JTable/bug4224179.java b/test/jdk/javax/swing/JTable/bug4224179.java new file mode 100644 index 00000000000..b223f3f4716 --- /dev/null +++ b/test/jdk/javax/swing/JTable/bug4224179.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +/* + * @test + * @bug 4224179 + * @summary Tests if Table default cell editor doesn't handle % (percent) character correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4224179 + */ + +public class bug4224179 { + private static final String INSTRUCTIONS = """ + 1. Click ONCE on the center cell ("Huml") + 2. Type the following symbols one after another: a%b + + If the center cell doesn't read "Humla%b" the test fails. + + 3. After the above, press the ESCAPE key and note that the cell + reverts back to "Huml" + 4. Do the stuff in part 1 again + 5. Press the ESCAPE key + + If the center cell now reads "Huml" as it initially was, + the test passed and fails otherwise. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4224179::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4224179"); + JTable table = new JTable(3, 3); + table.setValueAt("Huml", 1, 1); + table.setPreferredScrollableViewportSize(new Dimension(500, 70)); + JScrollPane scrollPane = new JScrollPane(table); + frame.add(scrollPane, BorderLayout.CENTER); + frame.pack(); + return frame; + } +} From 0f1c448ca15485cd7270cf0607acfceacdcefaff Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 22 Apr 2025 11:23:40 +0000 Subject: [PATCH 045/901] 8354922: ZGC: Use MAP_FIXED_NOREPLACE when reserving memory Reviewed-by: aboldtch, eosterlund --- src/hotspot/os/linux/gc/z/zSyscall_linux.hpp | 4 ++++ src/hotspot/os/posix/gc/z/zVirtualMemoryManager_posix.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hotspot/os/linux/gc/z/zSyscall_linux.hpp b/src/hotspot/os/linux/gc/z/zSyscall_linux.hpp index 1e1becf5a14..e5978c8d93a 100644 --- a/src/hotspot/os/linux/gc/z/zSyscall_linux.hpp +++ b/src/hotspot/os/linux/gc/z/zSyscall_linux.hpp @@ -35,6 +35,10 @@ #define MPOL_F_ADDR (1<<1) #endif +#ifndef MAP_FIXED_NOREPLACE +#define MAP_FIXED_NOREPLACE 0x100000 +#endif + class ZSyscall : public AllStatic { public: static int memfd_create(const char* name, unsigned int flags); diff --git a/src/hotspot/os/posix/gc/z/zVirtualMemoryManager_posix.cpp b/src/hotspot/os/posix/gc/z/zVirtualMemoryManager_posix.cpp index 4eea35c8a2e..89bde0557ec 100644 --- a/src/hotspot/os/posix/gc/z/zVirtualMemoryManager_posix.cpp +++ b/src/hotspot/os/posix/gc/z/zVirtualMemoryManager_posix.cpp @@ -24,6 +24,9 @@ #include "gc/z/zAddress.inline.hpp" #include "gc/z/zVirtualMemoryManager.hpp" #include "logging/log.hpp" +#ifdef LINUX +#include "gc/z/zSyscall_linux.hpp" +#endif #include @@ -32,7 +35,9 @@ void ZVirtualMemoryReserver::pd_register_callbacks(ZVirtualMemoryRegistry* regis } bool ZVirtualMemoryReserver::pd_reserve(zaddress_unsafe addr, size_t size) { - void* const res = mmap((void*)untype(addr), size, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0); + const int flags = MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE LINUX_ONLY(|MAP_FIXED_NOREPLACE); + + void* const res = mmap((void*)untype(addr), size, PROT_NONE, flags, -1, 0); if (res == MAP_FAILED) { // Failed to reserve memory return false; From f2587d9bd2e86c46c49ad972790c60ec394848da Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 22 Apr 2025 11:48:46 +0000 Subject: [PATCH 046/901] 8354938: ZGC: Disable UseNUMA when ZFakeNUMA is used Reviewed-by: aboldtch, jsikstro --- src/hotspot/share/gc/z/zArguments.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/gc/z/zArguments.cpp b/src/hotspot/share/gc/z/zArguments.cpp index 67b9f6f0bb9..2c70d8417c9 100644 --- a/src/hotspot/share/gc/z/zArguments.cpp +++ b/src/hotspot/share/gc/z/zArguments.cpp @@ -121,9 +121,19 @@ void ZArguments::select_max_gc_threads() { void ZArguments::initialize() { GCArguments::initialize(); - // Enable NUMA by default - if (FLAG_IS_DEFAULT(UseNUMA) && FLAG_IS_DEFAULT(ZFakeNUMA)) { - FLAG_SET_DEFAULT(UseNUMA, true); + // NUMA settings + if (FLAG_IS_DEFAULT(ZFakeNUMA)) { + // Enable NUMA by default + if (FLAG_IS_DEFAULT(UseNUMA)) { + FLAG_SET_DEFAULT(UseNUMA, true); + } + } else { + if (UseNUMA) { + if (!FLAG_IS_DEFAULT(UseNUMA)) { + warning("ZFakeNUMA is enabled; turning off UseNUMA"); + } + FLAG_SET_ERGO(UseNUMA, false); + } } select_max_gc_threads(); From 5264d80bea25a1ef98dae4633b04b16e8de6120f Mon Sep 17 00:00:00 2001 From: Martin Balao Date: Tue, 22 Apr 2025 14:37:10 +0000 Subject: [PATCH 047/901] 8350661: PKCS11 HKDF throws ProviderException when requesting a 31-byte AES key Reviewed-by: fferrari, valeriep, djelinski --- .../classes/sun/security/pkcs11/P11HKDF.java | 43 ++++-- .../sun/security/pkcs11/P11KeyGenerator.java | 38 ++--- .../security/pkcs11/P11SecretKeyFactory.java | 138 ++++++++++++------ .../pkcs11/wrapper/PKCS11Constants.java | 4 - .../jdk/sun/security/pkcs11/KDF/TestHKDF.java | 49 +++++++ 5 files changed, 200 insertions(+), 72 deletions(-) diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11HKDF.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11HKDF.java index 43a036da6f3..e8bef222d88 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11HKDF.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11HKDF.java @@ -38,6 +38,7 @@ import static sun.security.pkcs11.TemplateManager.*; import sun.security.pkcs11.wrapper.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; +import static sun.security.pkcs11.wrapper.PKCS11Exception.RV.CKR_KEY_SIZE_RANGE; final class P11HKDF extends KDFSpi { private final Token token; @@ -157,6 +158,15 @@ private T derive(String alg, AlgorithmParameterSpec derivationSpec, " instance, instead of " + derivationSpec.getClass()); } + P11SecretKeyFactory.KeyInfo ki = P11SecretKeyFactory.getKeyInfo(alg); + if (ki == null) { + throw new InvalidAlgorithmParameterException("A PKCS #11 key " + + "type (CKK_*) was not found for a key of the algorithm '" + + alg + "'."); + } + checkDerivedKeyType(ki, alg); + P11KeyGenerator.checkKeySize(ki.keyGenMech, outLen * 8, token); + P11Key p11BaseKey = convertKey(baseKey, (isExtract ? "IKM" : "PRK") + " could not be converted to a token key for HKDF derivation."); @@ -174,17 +184,10 @@ private T derive(String alg, AlgorithmParameterSpec derivationSpec, "token as service."; } - P11SecretKeyFactory.KeyInfo ki = P11SecretKeyFactory.getKeyInfo(alg); - if (ki == null) { - throw new InvalidAlgorithmParameterException("A PKCS #11 key " + - "type (CKK_*) was not found for a key of the algorithm '" + - alg + "'."); - } - long derivedKeyType = ki.keyType; long derivedKeyClass = isData ? CKO_DATA : CKO_SECRET_KEY; CK_ATTRIBUTE[] attrs = new CK_ATTRIBUTE[] { new CK_ATTRIBUTE(CKA_CLASS, derivedKeyClass), - new CK_ATTRIBUTE(CKA_KEY_TYPE, derivedKeyType), + new CK_ATTRIBUTE(CKA_KEY_TYPE, ki.keyType), new CK_ATTRIBUTE(CKA_VALUE_LEN, outLen) }; Session session = null; @@ -195,7 +198,7 @@ private T derive(String alg, AlgorithmParameterSpec derivationSpec, svcKi.hmacMech, saltType, saltBytes, p11SaltKey != null ? p11SaltKey.getKeyID() : 0L, info); attrs = token.getAttributes(O_GENERATE, derivedKeyClass, - derivedKeyType, attrs); + ki.keyType, attrs); long derivedObjectID = token.p11.C_DeriveKey(session.id(), new CK_MECHANISM(mechanism, params), baseKeyID, attrs); Object ret; @@ -216,6 +219,11 @@ private T derive(String alg, AlgorithmParameterSpec derivationSpec, } return retType.cast(ret); } catch (PKCS11Exception e) { + if (e.match(CKR_KEY_SIZE_RANGE)) { + throw new InvalidAlgorithmParameterException("Invalid key " + + "size (" + outLen + " bytes) for algorithm '" + alg + + "'.", e); + } throw new ProviderException("HKDF derivation for algorithm '" + alg + "' failed.", e); } finally { @@ -227,6 +235,23 @@ private T derive(String alg, AlgorithmParameterSpec derivationSpec, } } + private static boolean canDeriveKeyInfoType(long t) { + return (t == CKK_DES || t == CKK_DES3 || t == CKK_AES || + t == CKK_RC4 || t == CKK_BLOWFISH || t == CKK_CHACHA20 || + t == CKK_GENERIC_SECRET); + } + + private void checkDerivedKeyType(P11SecretKeyFactory.KeyInfo ki, String alg) + throws InvalidAlgorithmParameterException { + Class kiClass = ki.getClass(); + if (!kiClass.equals(P11SecretKeyFactory.TLSKeyInfo.class) && + !(kiClass.equals(P11SecretKeyFactory.KeyInfo.class) && + canDeriveKeyInfoType(ki.keyType))) { + throw new InvalidAlgorithmParameterException("A key of algorithm " + + "'" + alg + "' is not valid for derivation."); + } + } + private P11Key.P11SecretKey convertKey(SecretKey key, String errorMessage) { try { return (P11Key.P11SecretKey) P11SecretKeyFactory.convertKey(token, diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyGenerator.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyGenerator.java index 3ec2cfba655..9bfe55b2509 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyGenerator.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -75,9 +75,10 @@ final class P11KeyGenerator extends KeyGeneratorSpi { // java-specific lower limit; returned values are in bits private static CK_MECHANISM_INFO getSupportedRange(Token token, long mech) throws ProviderException { - // No need to query for fix-length algorithms - if (mech == CKM_DES_KEY_GEN || mech == CKM_DES2_KEY_GEN || - mech == CKM_DES3_KEY_GEN) { + // No need to query if the mechanism is not available or for + // fix-length algorithms + if (mech == CK_UNAVAILABLE_INFORMATION || mech == CKM_DES_KEY_GEN || + mech == CKM_DES2_KEY_GEN || mech == CKM_DES3_KEY_GEN) { return null; } @@ -115,7 +116,7 @@ private static CK_MECHANISM_INFO getSupportedRange(Token token, * and within the supported range. Return the significant key size * upon successful validation. * @param keyGenMech the PKCS#11 key generation mechanism. - * @param keySize the to-be-checked key size for this mechanism. + * @param keySize the to-be-checked key size (in bits) for this mechanism. * @param token token which provides this mechanism. * @return the significant key size (in bits) corresponding to the * specified key size. @@ -123,7 +124,7 @@ private static CK_MECHANISM_INFO getSupportedRange(Token token, * @throws ProviderException if this mechanism isn't supported by SunPKCS11 * or underlying native impl. */ - // called by P11SecretKeyFactory to check key size + // called by P11SecretKeyFactory and P11HKDF to check key size static int checkKeySize(long keyGenMech, int keySize, Token token) throws InvalidAlgorithmParameterException, ProviderException { CK_MECHANISM_INFO range = getSupportedRange(token, keyGenMech); @@ -136,8 +137,8 @@ private static int checkKeySize(long keyGenMech, int keySize, switch ((int)keyGenMech) { case (int)CKM_DES_KEY_GEN: if ((keySize != 64) && (keySize != 56)) { - throw new InvalidAlgorithmParameterException - ("DES key length must be 56 bits"); + throw new InvalidAlgorithmParameterException("DES key " + + "length was " + keySize + " but must be 56 bits"); } sigKeySize = 56; break; @@ -148,23 +149,26 @@ private static int checkKeySize(long keyGenMech, int keySize, } else if ((keySize == 168) || (keySize == 192)) { sigKeySize = 168; } else { - throw new InvalidAlgorithmParameterException - ("DESede key length must be 112, or 168 bits"); + throw new InvalidAlgorithmParameterException("DESede key " + + "length was " + keySize + " but must be 112, or " + + "168 bits"); } break; default: // Handle all variable-key-length algorithms here - if (range != null && keySize < range.iMinKeySize - || keySize > range.iMaxKeySize) { - throw new InvalidAlgorithmParameterException - ("Key length must be between " + range.iMinKeySize + - " and " + range.iMaxKeySize + " bits"); + if (range != null && (keySize < range.iMinKeySize + || keySize > range.iMaxKeySize)) { + throw new InvalidAlgorithmParameterException("Key length " + + "was " + keySize + " but must be between " + + range.iMinKeySize + " and " + range.iMaxKeySize + + " bits"); } if (keyGenMech == CKM_AES_KEY_GEN) { if ((keySize != 128) && (keySize != 192) && (keySize != 256)) { - throw new InvalidAlgorithmParameterException - ("AES key length must be 128, 192, or 256 bits"); + throw new InvalidAlgorithmParameterException("AES key" + + " length was " + keySize + " but must be 128," + + " 192, or 256 bits"); } } sigKeySize = keySize; diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java index 6c67e641438..bc0a7d10cf1 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11SecretKeyFactory.java @@ -103,13 +103,37 @@ private static void putKeyInfo(KeyInfo ki) { keyInfo.put(ki.algo.toUpperCase(Locale.ENGLISH), ki); } - static sealed class KeyInfo permits PBEKeyInfo, HMACKeyInfo, HKDFKeyInfo { + /* + * The KeyInfo class represents information about a symmetric PKCS #11 key + * type or about the output of a key-based computation (e.g. HMAC). A + * KeyInfo instance may describe the key/output itself, or the type of + * key/output that a service accepts/produces. Used by P11SecretKeyFactory, + * P11PBECipher, P11Mac, and P11HKDF. + */ + static sealed class KeyInfo permits PBEKeyInfo, HMACKeyInfo, HKDFKeyInfo, + TLSKeyInfo { + // Java Standard Algorithm Name. public final String algo; + + // Key type (CKK_*). public final long keyType; + // Mechanism for C_GenerateKey to generate a key of this type (CKM_*). + // While keys may be generated with other APIs and mechanisms (e.g. AES + // key generated with C_DeriveKey and CKM_HKDF_DERIVE instead of + // C_GenerateKey and CKM_AES_KEY_GEN), this information is used by + // P11KeyGenerator::checkKeySize in a best-effort attempt to validate + // that the key size is within a valid range (see CK_MECHANISM_INFO). + public final long keyGenMech; + KeyInfo(String algo, long keyType) { + this(algo, keyType, CK_UNAVAILABLE_INFORMATION); + } + + KeyInfo(String algo, long keyType, long keyGenMech) { this.algo = algo; this.keyType = keyType; + this.keyGenMech = keyGenMech; } // The P11SecretKeyFactory::convertKey method needs to know if a service @@ -134,8 +158,26 @@ static boolean checkUse(KeyInfo ki, KeyInfo si) { } } + /* + * KeyInfo specialization for keys that are either input or result of a TLS + * key derivation. Keys of this type are typically handled by JSSE and their + * algorithm name start with "Tls". Used by P11HKDF. + */ + static final class TLSKeyInfo extends KeyInfo { + TLSKeyInfo(String algo) { + super(algo, CKK_GENERIC_SECRET); + } + } + + /* + * KeyInfo specialization for outputs of a HMAC computation. Used by + * P11SecretKeyFactory and P11Mac. + */ static final class HMACKeyInfo extends KeyInfo { + // HMAC mechanism (CKM_*) to generate the output. public final long mech; + + // HMAC output length (in bits). public final int keyLen; HMACKeyInfo(String algo, long mech, int keyLen) { @@ -145,6 +187,10 @@ static final class HMACKeyInfo extends KeyInfo { } } + /* + * KeyInfo specialization for HKDF key derivation. Used by + * P11SecretKeyFactory and P11HKDF. + */ static final class HKDFKeyInfo extends KeyInfo { public static final long UNKNOWN_KEY_TYPE = -1; public final long hmacMech; @@ -157,6 +203,10 @@ static final class HKDFKeyInfo extends KeyInfo { } } + /* + * KeyInfo specialization for PBE key derivation. Used by + * P11SecretKeyFactory, P11PBECipher and P11Mac. + */ abstract static sealed class PBEKeyInfo extends KeyInfo permits AESPBEKeyInfo, PBKDF2KeyInfo, P12MacPBEKeyInfo { public static final long INVALID_PRF = -1; @@ -204,24 +254,39 @@ static final class P12MacPBEKeyInfo extends PBEKeyInfo { } static { - putKeyInfo(new KeyInfo("RC4", CKK_RC4)); - putKeyInfo(new KeyInfo("ARCFOUR", CKK_RC4)); - putKeyInfo(new KeyInfo("DES", CKK_DES)); - putKeyInfo(new KeyInfo("DESede", CKK_DES3)); - putKeyInfo(new KeyInfo("AES", CKK_AES)); - putKeyInfo(new KeyInfo("Blowfish", CKK_BLOWFISH)); - putKeyInfo(new KeyInfo("ChaCha20", CKK_CHACHA20)); - putKeyInfo(new KeyInfo("ChaCha20-Poly1305", CKK_CHACHA20)); + putKeyInfo(new KeyInfo("RC4", CKK_RC4, CKM_RC4_KEY_GEN)); + putKeyInfo(new KeyInfo("ARCFOUR", CKK_RC4, CKM_RC4_KEY_GEN)); + putKeyInfo(new KeyInfo("DES", CKK_DES, CKM_DES_KEY_GEN)); + putKeyInfo(new KeyInfo("DESede", CKK_DES3, CKM_DES3_KEY_GEN)); + putKeyInfo(new KeyInfo("AES", CKK_AES, CKM_AES_KEY_GEN)); + putKeyInfo(new KeyInfo("Blowfish", CKK_BLOWFISH, CKM_BLOWFISH_KEY_GEN)); + putKeyInfo(new KeyInfo("ChaCha20", CKK_CHACHA20, CKM_CHACHA20_KEY_GEN)); + putKeyInfo(new KeyInfo("ChaCha20-Poly1305", CKK_CHACHA20, + CKM_CHACHA20_KEY_GEN)); // we don't implement RC2 or IDEA, but we want to be able to generate // keys for those SSL/TLS ciphersuites. - putKeyInfo(new KeyInfo("RC2", CKK_RC2)); - putKeyInfo(new KeyInfo("IDEA", CKK_IDEA)); - - putKeyInfo(new KeyInfo("TlsPremasterSecret", PCKK_TLSPREMASTER)); - putKeyInfo(new KeyInfo("TlsRsaPremasterSecret", PCKK_TLSRSAPREMASTER)); - putKeyInfo(new KeyInfo("TlsMasterSecret", PCKK_TLSMASTER)); - putKeyInfo(new KeyInfo("Generic", CKK_GENERIC_SECRET)); + putKeyInfo(new KeyInfo("RC2", CKK_RC2, CKM_RC2_KEY_GEN)); + putKeyInfo(new KeyInfo("IDEA", CKK_IDEA, CKM_IDEA_KEY_GEN)); + + putKeyInfo(new TLSKeyInfo("TlsPremasterSecret")); + putKeyInfo(new TLSKeyInfo("TlsRsaPremasterSecret")); + putKeyInfo(new TLSKeyInfo("TlsMasterSecret")); + putKeyInfo(new TLSKeyInfo("TlsBinderKey")); + putKeyInfo(new TLSKeyInfo("TlsClientAppTrafficSecret")); + putKeyInfo(new TLSKeyInfo("TlsClientHandshakeTrafficSecret")); + putKeyInfo(new TLSKeyInfo("TlsEarlySecret")); + putKeyInfo(new TLSKeyInfo("TlsFinishedSecret")); + putKeyInfo(new TLSKeyInfo("TlsHandshakeSecret")); + putKeyInfo(new TLSKeyInfo("TlsKey")); + putKeyInfo(new TLSKeyInfo("TlsResumptionMasterSecret")); + putKeyInfo(new TLSKeyInfo("TlsSaltSecret")); + putKeyInfo(new TLSKeyInfo("TlsServerAppTrafficSecret")); + putKeyInfo(new TLSKeyInfo("TlsServerHandshakeTrafficSecret")); + putKeyInfo(new TLSKeyInfo("TlsUpdateNplus1")); + + putKeyInfo(new KeyInfo("Generic", CKK_GENERIC_SECRET, + CKM_GENERIC_SECRET_KEY_GEN)); HMACKeyInfo hmacSHA1 = new HMACKeyInfo("HmacSHA1", CKM_SHA_1_HMAC, 160); @@ -549,34 +614,23 @@ private static P11Key createKey(Token token, byte[] encoded, long keyType = ki.keyType; try { switch ((int) keyType) { - case (int) CKK_DES -> { - keyLength = - P11KeyGenerator.checkKeySize(CKM_DES_KEY_GEN, n, token); - fixDESParity(encoded, 0); - } - case (int) CKK_DES3 -> { - keyLength = - P11KeyGenerator.checkKeySize(CKM_DES3_KEY_GEN, n, token); - fixDESParity(encoded, 0); - fixDESParity(encoded, 8); - if (keyLength == 112) { - keyType = CKK_DES2; - } else { - keyType = CKK_DES3; - fixDESParity(encoded, 16); + case (int) CKK_DES, (int) CKK_DES3, (int) CKK_AES, (int) CKK_RC4, + (int) CKK_BLOWFISH, (int) CKK_CHACHA20 -> { + keyLength = P11KeyGenerator.checkKeySize(ki.keyGenMech, n, + token); + if (keyType == CKK_DES || keyType == CKK_DES3) { + fixDESParity(encoded, 0); + if (keyType == CKK_DES3) { + fixDESParity(encoded, 8); + if (keyLength == 112) { + keyType = CKK_DES2; + } else { + fixDESParity(encoded, 16); + } + } } } - case (int) CKK_AES -> keyLength = - P11KeyGenerator.checkKeySize(CKM_AES_KEY_GEN, n, token); - case (int) CKK_RC4 -> keyLength = - P11KeyGenerator.checkKeySize(CKM_RC4_KEY_GEN, n, token); - case (int) CKK_BLOWFISH -> keyLength = - P11KeyGenerator.checkKeySize(CKM_BLOWFISH_KEY_GEN, n, - token); - case (int) CKK_CHACHA20 -> keyLength = P11KeyGenerator.checkKeySize( - CKM_CHACHA20_KEY_GEN, n, token); - case (int) CKK_GENERIC_SECRET, (int) PCKK_TLSPREMASTER, (int) PCKK_TLSRSAPREMASTER, (int) PCKK_TLSMASTER -> - keyType = CKK_GENERIC_SECRET; + case (int) CKK_GENERIC_SECRET -> {} default -> throw new InvalidKeyException("Unknown algorithm " + algorithm); } diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11Constants.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11Constants.java index 3cd1ca12563..924bfbcc226 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11Constants.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11Constants.java @@ -311,10 +311,6 @@ public interface PKCS11Constants { // pseudo key type ANY (for template manager) public static final long PCKK_ANY = 0x7FFFFF22L; - public static final long PCKK_TLSPREMASTER = 0x7FFFFF25L; - public static final long PCKK_TLSRSAPREMASTER = 0x7FFFFF26L; - public static final long PCKK_TLSMASTER = 0x7FFFFF27L; - /* Uncomment when actually used public static final long CK_CERTIFICATE_CATEGORY_UNSPECIFIED = 0L; public static final long CK_CERTIFICATE_CATEGORY_TOKEN_USER = 1L; diff --git a/test/jdk/sun/security/pkcs11/KDF/TestHKDF.java b/test/jdk/sun/security/pkcs11/KDF/TestHKDF.java index 5a3e8163600..638d4aa2bb1 100644 --- a/test/jdk/sun/security/pkcs11/KDF/TestHKDF.java +++ b/test/jdk/sun/security/pkcs11/KDF/TestHKDF.java @@ -302,6 +302,23 @@ private static void executeTest(String testHeader, String hkdfAlg, executeDerivation(ctx, KdfParamSpecType.EXPAND); } + private static void executeInvalidKeyDerivationTest(String testHeader, + String keyAlg, int keySize, String errorMsg) { + printTestHeader(testHeader); + try { + KDF k = KDF.getInstance("HKDF-SHA256", p11Provider); + k.deriveKey(keyAlg, HKDFParameterSpec.ofExtract() + .thenExpand(null, keySize)); + throw new Exception("No exception thrown."); + } catch (InvalidAlgorithmParameterException iape) { + // Expected. + } catch (Exception e) { + reportTestFailure(new Exception(errorMsg + " expected to throw " + + "InvalidAlgorithmParameterException for key algorithm '" + + keyAlg + "'.", e)); + } + } + private static void printTestHeader(String testHeader) { debugPrinter.println(); debugPrinter.println("=".repeat(testHeader.length())); @@ -610,6 +627,38 @@ private static void test_HKDF_after_ECDH_HkdfSHA256() throws Exception { "6e09"); } + private static void test_unknown_key_algorithm_derivation() { + executeInvalidKeyDerivationTest( + "Test derivation of an unknown key algorithm", + "UnknownAlgorithm", + 32, + "Derivation of an unknown key algorithm"); + } + + private static void test_invalid_key_algorithm_derivation() { + executeInvalidKeyDerivationTest( + "Test derivation of an invalid key algorithm", + "PBKDF2WithHmacSHA1", + 32, + "Derivation of an invalid key algorithm"); + } + + private static void test_invalid_aes_key_algorithm_derivation() { + executeInvalidKeyDerivationTest( + "Test derivation of an invalid AES key", + "PBEWithHmacSHA224AndAES_256", + 32, + "Derivation of an invalid AES key"); + } + + private static void test_invalid_AES_key_size() { + executeInvalidKeyDerivationTest( + "Test derivation of an invalid AES key size", + "AES", + 31, + "Derivation of an AES key of invalid size (31 bytes)"); + } + public void main(Provider p) throws Exception { p11Provider = p; p11GenericSkf = SecretKeyFactory.getInstance("Generic", p11Provider); From 072b8273a4c7bd75bce440e5f1184e2926ed0f78 Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Tue, 22 Apr 2025 15:10:26 +0000 Subject: [PATCH 048/901] 8354300: Mark String.hash field @Stable Reviewed-by: liach, shade, vlivanov --- .../share/classes/java/lang/String.java | 7 +- .../bench/java/lang/StringHashCodeStatic.java | 93 +++++++++++++++++++ 2 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 test/micro/org/openjdk/bench/java/lang/StringHashCodeStatic.java diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index 033d32611b0..0632785d899 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2025, 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 @@ -173,11 +173,14 @@ public final class String private final byte coder; /** Cache the hash code for the string */ + @Stable private int hash; // Default to 0 /** * Cache if the hash has been calculated as actually being zero, enabling - * us to avoid recalculating this. + * us to avoid recalculating this. This field is _not_ annotated @Stable as + * the `hashCode()` method reads the field `hash` first anyhow and if `hash` + * is the default zero value, is not trusted. */ private boolean hashIsZero; // Default to false; diff --git a/test/micro/org/openjdk/bench/java/lang/StringHashCodeStatic.java b/test/micro/org/openjdk/bench/java/lang/StringHashCodeStatic.java new file mode 100644 index 00000000000..8f4d22a1d86 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/StringHashCodeStatic.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.java.lang; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * Performance test of String.hashCode() function with constant folding. + * The tests are using a Map that holds a MethodHandle to better expose + * any potential lack of constant folding. + */ +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 1) +@Fork(value = 3) +public class StringHashCodeStatic { + + private static final String HASHCODE = "abcdefghijkl"; + private static final String HASHCODE_0 = new String(new char[]{72, 90, 100, 89, 105, 2, 72, 90, 100, 89, 105, 2}); + private static final String EMPTY = new String(); + + private static final Map MAP = Map.of( + HASHCODE, mh(HASHCODE.hashCode()), + HASHCODE_0, mh(HASHCODE_0.hashCode()), + EMPTY, mh(EMPTY.hashCode())); + + /** + * Benchmark testing String.hashCode() with a regular 12 char string with + * the result possibly cached in String + */ + @Benchmark + public int nonZero() throws Throwable { + return (int)MAP.get(HASHCODE).invokeExact(); + } + + /** + * Benchmark testing String.hashCode() with a 12 char string with the + * hashcode = 0. + */ + @Benchmark + public int zero() throws Throwable { + return (int)MAP.get(HASHCODE_0).invokeExact(); + } + + /** + * Benchmark testing String.hashCode() with the empty string. an + * empty String has hashCode = 0. + */ + @Benchmark + public int empty() throws Throwable { + return (int)MAP.get(EMPTY).invokeExact(); + } + + static MethodHandle mh(int value) { + return MethodHandles.constant(int.class, value); + } + +} \ No newline at end of file From da16c839735bbf79ece4967f95a98208f74b7f73 Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 15:26:59 +0000 Subject: [PATCH 049/901] 8354466: Open some misc Swing bugs 9 Reviewed-by: kizune, honkar --- .../swing/JPasswordField/bug4382819.java | 86 +++++++++++++++++ .../javax/swing/JSplitPane/bug4820080.java | 94 +++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 test/jdk/javax/swing/JPasswordField/bug4382819.java create mode 100644 test/jdk/javax/swing/JSplitPane/bug4820080.java diff --git a/test/jdk/javax/swing/JPasswordField/bug4382819.java b/test/jdk/javax/swing/JPasswordField/bug4382819.java new file mode 100644 index 00000000000..3a8799a2d52 --- /dev/null +++ b/test/jdk/javax/swing/JPasswordField/bug4382819.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.event.ItemListener; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JPasswordField; + +/* + * @test + * @bug 4382819 + * @summary Tests the correctness of color used for the disabled passwordField. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4382819 + */ + +public class bug4382819 { + static JCheckBox enabledCheckBox; + static JPasswordField passwordField; + + private static final String INSTRUCTIONS = """ + Clear the "enabled" checkbox. + If the JPasswordField's foreground color changes to + light gray press Pass. If it stays black press Fail. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4382819::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame mainFrame = new JFrame("bug4382819"); + enabledCheckBox = new javax.swing.JCheckBox(); + enabledCheckBox.setSelected(true); + enabledCheckBox.setText("enabled"); + enabledCheckBox.setActionCommand("enabled"); + mainFrame.add(enabledCheckBox); + + passwordField = new javax.swing.JPasswordField(); + passwordField.setText("blahblahblah"); + mainFrame.add(passwordField); + SymItem lSymItem = new SymItem(); + enabledCheckBox.addItemListener(lSymItem); + + mainFrame.setSize(300, 100); + mainFrame.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + return mainFrame; + } + + static class SymItem implements ItemListener { + public void itemStateChanged(java.awt.event.ItemEvent event) { + Object object = event.getSource(); + if (object == enabledCheckBox) { + passwordField.setEnabled(enabledCheckBox.isSelected()); + } + } + } +} + diff --git a/test/jdk/javax/swing/JSplitPane/bug4820080.java b/test/jdk/javax/swing/JSplitPane/bug4820080.java new file mode 100644 index 00000000000..0702a3a2f59 --- /dev/null +++ b/test/jdk/javax/swing/JSplitPane/bug4820080.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2003, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Panel; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.JSplitPane; +import javax.swing.UIManager; + +/* + * @test + * @bug 4820080 7175397 + * @summary RFE: Cannot Change the JSplitPane Divider Color while dragging + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4820080 + */ + +public class bug4820080 { + private static final String INSTRUCTIONS = """ + Drag the dividers of the splitpanes (both top and bottom). If the divider + color is green while dragging then test passes, otherwise test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4820080::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4820080"); + UIManager.put("SplitPaneDivider.draggingColor", Color.GREEN); + + Box box = new Box(BoxLayout.Y_AXIS); + frame.add(box); + + JPanel jleft = new JPanel(); + jleft.setBackground(Color.DARK_GRAY); + jleft.setPreferredSize(new Dimension(100, 100)); + JPanel jright = new JPanel(); + jright.setBackground(Color.DARK_GRAY); + jright.setPreferredSize(new Dimension(100, 100)); + + JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jleft, jright); + jsp.setContinuousLayout(false); + box.add(jsp); + + box.add(Box.createVerticalStrut(5)); + box.add(new JSeparator()); + box.add(Box.createVerticalStrut(5)); + + Panel left = new Panel(); + left.setBackground(Color.DARK_GRAY); + left.setPreferredSize(new Dimension(100, 100)); + Panel right = new Panel(); + right.setBackground(Color.DARK_GRAY); + right.setPreferredSize(new Dimension(100, 100)); + + JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right); + sp.setContinuousLayout(false); + box.add(sp); + frame.pack(); + return frame; + } +} From a4c5ed8144376f7ba0d2cb992da63b3e53d51f8b Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 22 Apr 2025 15:46:04 +0000 Subject: [PATCH 050/901] 8354561: Open source several swing tests batch0 Reviewed-by: prr, psadhukhan --- .../jdk/javax/swing/JComboBox/bug4139900.java | 119 +++++++++++++++++ .../jdk/javax/swing/JComboBox/bug4174876.java | 78 +++++++++++ .../jdk/javax/swing/JComboBox/bug4474400.java | 78 +++++++++++ .../swing/border/TransparentTitleTest.java | 122 ++++++++++++++++++ 4 files changed, 397 insertions(+) create mode 100644 test/jdk/javax/swing/JComboBox/bug4139900.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4174876.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4474400.java create mode 100644 test/jdk/javax/swing/border/TransparentTitleTest.java diff --git a/test/jdk/javax/swing/JComboBox/bug4139900.java b/test/jdk/javax/swing/JComboBox/bug4139900.java new file mode 100644 index 00000000000..a9ed685d5ab --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4139900.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4139900 + * @summary height of combobox may differ + * @key headful + * @run main bug4139900 +*/ + +import java.awt.Dimension; +import java.awt.Robot; +import java.awt.event.ActionListener; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +public class bug4139900 { + static JButton button; + static JFrame frame; + static JComboBox comboBox; + static int initialHeight; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(bug4139900::init); + test(); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void test() throws Exception { + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(500); + + SwingUtilities.invokeAndWait(() -> initialHeight = comboBox.getHeight()); + + for (int i = 0; i < 10; i++) { + SwingUtilities.invokeAndWait(() -> button.doClick()); + robot.waitForIdle(); + robot.delay(200); + SwingUtilities.invokeAndWait(() -> { + if (comboBox.getHeight() != initialHeight) { + throw new RuntimeException( + "Test failed: height differs from initial %d != %d" + .formatted(comboBox.getHeight(), initialHeight) + ); + } + }); + } + } + + public static void init() { + frame = new JFrame("bug4139900"); + + DefaultComboBoxModel model = + new DefaultComboBoxModel<>(new String[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea" + }); + + comboBox = new JComboBox<>(); + comboBox.setEditable(true); + + button = new JButton("Add/Remove Items"); + + ActionListener actionListener = e -> { + if (comboBox.getModel() == model) { + comboBox.setModel(new DefaultComboBoxModel<>()); + } else { + comboBox.setModel(model); + } + }; + + button.addActionListener(actionListener); + + JPanel panel = new JPanel(); + panel.setPreferredSize(new Dimension(300, 100)); + panel.add(comboBox); + panel.add(button); + + frame.add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4174876.java b/test/jdk/javax/swing/JComboBox/bug4174876.java new file mode 100644 index 00000000000..349dfa4b159 --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4174876.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4174876 + * @summary JComboBox tooltips do not work properly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4174876 + */ + +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JPanel; + +public class bug4174876 { + private static final String INSTRUCTIONS = """ + Hold the mouse over both combo boxes. + A tool tip should appear over every area of both of them. + Notably, if you hold the mouse over the button on the right one, + a tool tip should appear. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("TransparentTitleTest Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .splitUIBottom(bug4174876::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + JComboBox comboBox1 = new JComboBox<>(new String[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea" + }); + JComboBox comboBox2 = new JComboBox<>(new String[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea" + }); + + comboBox1.setToolTipText("Combo Box #1"); + comboBox2.setToolTipText("Combo Box #2"); + comboBox2.setEditable(true); + + JPanel panel = new JPanel(); + panel.add(comboBox1); + panel.add(comboBox2); + return panel; + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4474400.java b/test/jdk/javax/swing/JComboBox/bug4474400.java new file mode 100644 index 00000000000..ea52d0c71b5 --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4474400.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4474400 + * @summary Tests JTextArea wrapping with font change + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4474400 + */ + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +public class bug4474400 { + private static final String INSTRUCTIONS = """ + Press the "Change Font" button. The two lines of text should be + properly drawn using the larger font, there should be empty line + between them. If display is garbled, test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4474400 Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .splitUIRight(bug4474400::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + Font smallFont = new Font("SansSerif", Font.PLAIN, 12); + Font largeFont = new Font("SansSerif", Font.PLAIN, 36); + + JTextArea textArea = new JTextArea("This is the first line\n\nThis is the third line"); + textArea.setFont(smallFont); + textArea.setEditable(false); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + + JButton b = new JButton("Change Font"); + b.addActionListener((e) -> textArea.setFont(largeFont)); + + JPanel panel = new JPanel(new BorderLayout()); + panel.setPreferredSize(new Dimension(200, 300)); + panel.add(textArea, BorderLayout.CENTER); + panel.add(b, BorderLayout.SOUTH); + + return panel; + } +} diff --git a/test/jdk/javax/swing/border/TransparentTitleTest.java b/test/jdk/javax/swing/border/TransparentTitleTest.java new file mode 100644 index 00000000000..49a32a5890c --- /dev/null +++ b/test/jdk/javax/swing/border/TransparentTitleTest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4154572 + * @summary Tests that the area behind a TitledBorder's title string is transparent, + * allowing the component's background to show through + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TransparentTitleTest + */ + +import java.awt.GridLayout; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Color; +import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; +import javax.swing.border.LineBorder; + +public class TransparentTitleTest { + private static final String INSTRUCTIONS = """ + If all panels are correctly painted such that the title of the + border allows the underlying panel image (green rectangle) + to show through the background of the text, + then this test passes; else it fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("TransparentTitleTest Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(TransparentTitleTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createTestUI() { + JFrame frame = new JFrame("TransparentTitleTest"); + + frame.setLayout(new GridLayout(3, 6, 5, 5)); + + frame.add(new ImagePanel(TitledBorder.TOP, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.TOP, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.TOP, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.ABOVE_TOP, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.ABOVE_TOP, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.ABOVE_TOP, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.BELOW_TOP, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.BELOW_TOP, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.BELOW_TOP, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.BOTTOM, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.BOTTOM, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.BOTTOM, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.ABOVE_BOTTOM, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.ABOVE_BOTTOM, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.ABOVE_BOTTOM, TitledBorder.RIGHT)); + frame.add(new ImagePanel(TitledBorder.BELOW_BOTTOM, TitledBorder.LEFT)); + frame.add(new ImagePanel(TitledBorder.BELOW_BOTTOM, TitledBorder.CENTER)); + frame.add(new ImagePanel(TitledBorder.BELOW_BOTTOM, TitledBorder.RIGHT)); + + frame.pack(); + return frame; + } +} + +class ImagePanel extends JPanel { + + private final ImageIcon imageIcon; + + private static final BufferedImage bufferedImage = + new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB); + + static { + Graphics g = bufferedImage.getGraphics(); + g.setColor(Color.GREEN); + g.fillRect(0, 0, 128, 128); + } + + public ImagePanel(int titlePos, int titleJust) { + imageIcon = new ImageIcon(bufferedImage); + + TitledBorder b = new TitledBorder(new LineBorder(Color.black,3), "title text"); + b.setTitlePosition(titlePos); + b.setTitleJustification(titleJust); + b.setTitleColor(Color.black); + setBorder(b); + } + + public Dimension getPreferredSize() { + return new Dimension(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + } + + public void paintComponent(Graphics g) { + imageIcon.paintIcon(this, g, 0, 0); + } +} From 477da161e62040d77079196ea27d24b27de75b64 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 22 Apr 2025 15:50:58 +0000 Subject: [PATCH 051/901] 8352638: Enhance code consistency: java.desktop/windows Reviewed-by: prr --- .../plaf/windows/AnimationController.java | 9 ++- .../sun/java/swing/plaf/windows/TMSchema.java | 3 + .../swing/plaf/windows/WindowsBorders.java | 17 +++-- .../swing/plaf/windows/WindowsButtonUI.java | 9 ++- .../windows/WindowsCheckBoxMenuItemUI.java | 5 +- .../swing/plaf/windows/WindowsCheckBoxUI.java | 5 +- .../windows/WindowsClassicLookAndFeel.java | 3 +- .../swing/plaf/windows/WindowsComboBoxUI.java | 32 +++++++--- .../plaf/windows/WindowsDesktopIconUI.java | 8 ++- .../plaf/windows/WindowsDesktopManager.java | 3 +- .../plaf/windows/WindowsDesktopPaneUI.java | 5 +- .../plaf/windows/WindowsEditorPaneUI.java | 3 +- .../plaf/windows/WindowsFileChooserUI.java | 62 ++++++++++++++++--- .../plaf/windows/WindowsGraphicsUtils.java | 2 +- .../plaf/windows/WindowsIconFactory.java | 56 +++++++++++++---- .../WindowsInternalFrameTitlePane.java | 24 ++++++- .../plaf/windows/WindowsInternalFrameUI.java | 12 +++- .../swing/plaf/windows/WindowsLabelUI.java | 4 +- .../plaf/windows/WindowsLookAndFeel.java | 58 ++++++++++++----- .../swing/plaf/windows/WindowsMenuBarUI.java | 5 +- .../swing/plaf/windows/WindowsMenuItemUI.java | 5 +- .../swing/plaf/windows/WindowsMenuUI.java | 13 +++- .../plaf/windows/WindowsOptionPaneUI.java | 2 +- .../plaf/windows/WindowsPasswordFieldUI.java | 3 +- .../windows/WindowsPopupMenuSeparatorUI.java | 4 +- .../plaf/windows/WindowsPopupMenuUI.java | 7 ++- .../plaf/windows/WindowsPopupWindow.java | 5 +- .../plaf/windows/WindowsProgressBarUI.java | 11 +++- .../windows/WindowsRadioButtonMenuItemUI.java | 5 +- .../plaf/windows/WindowsRadioButtonUI.java | 5 ++ .../swing/plaf/windows/WindowsRootPaneUI.java | 5 +- .../plaf/windows/WindowsScrollBarUI.java | 17 ++++- .../plaf/windows/WindowsScrollPaneUI.java | 2 +- .../plaf/windows/WindowsSeparatorUI.java | 2 +- .../swing/plaf/windows/WindowsSliderUI.java | 17 ++++- .../swing/plaf/windows/WindowsSpinnerUI.java | 5 +- .../plaf/windows/WindowsSplitPaneDivider.java | 3 +- .../plaf/windows/WindowsSplitPaneUI.java | 3 +- .../plaf/windows/WindowsTabbedPaneUI.java | 8 ++- .../plaf/windows/WindowsTableHeaderUI.java | 13 +++- .../swing/plaf/windows/WindowsTextAreaUI.java | 3 +- .../plaf/windows/WindowsTextFieldUI.java | 11 +++- .../swing/plaf/windows/WindowsTextPaneUI.java | 3 +- .../swing/plaf/windows/WindowsTextUI.java | 8 ++- .../plaf/windows/WindowsToggleButtonUI.java | 9 ++- .../windows/WindowsToolBarSeparatorUI.java | 5 +- .../swing/plaf/windows/WindowsToolBarUI.java | 7 ++- .../swing/plaf/windows/WindowsTreeUI.java | 11 +++- .../sun/java/swing/plaf/windows/XPStyle.java | 26 ++++++-- .../classes/sun/awt/PlatformGraphicsInfo.java | 2 +- .../classes/sun/awt/Win32ColorModel24.java | 4 +- .../classes/sun/awt/Win32FontManager.java | 5 ++ .../classes/sun/awt/Win32GraphicsConfig.java | 1 + .../classes/sun/awt/Win32GraphicsDevice.java | 2 +- .../sun/awt/Win32GraphicsEnvironment.java | 4 ++ .../sun/awt/shell/Win32ShellFolder2.java | 27 +++++++- .../awt/shell/Win32ShellFolderManager2.java | 8 ++- .../awt/windows/TranslucentWindowPainter.java | 4 +- .../sun/awt/windows/WComponentPeer.java | 1 + .../sun/awt/windows/WDataTransferer.java | 2 +- .../sun/awt/windows/WDefaultFontCharset.java | 2 +- .../sun/awt/windows/WDesktopProperties.java | 5 +- .../awt/windows/WDragSourceContextPeer.java | 3 + .../sun/awt/windows/WEmbeddedFrame.java | 7 ++- .../sun/awt/windows/WEmbeddedFramePeer.java | 2 +- .../classes/sun/awt/windows/WLabelPeer.java | 7 +++ .../awt/windows/WLightweightFramePeer.java | 3 +- .../sun/awt/windows/WMenuItemPeer.java | 4 ++ .../sun/awt/windows/WMouseInfoPeer.java | 2 + .../sun/awt/windows/WPopupMenuPeer.java | 1 + .../classes/sun/awt/windows/WPrinterJob.java | 4 +- .../sun/awt/windows/WScrollPanePeer.java | 4 +- .../sun/awt/windows/WScrollbarPeer.java | 7 +++ .../classes/sun/awt/windows/WToolkit.java | 2 +- .../sun/awt/windows/WTrayIconPeer.java | 2 +- .../classes/sun/awt/windows/WWindowPeer.java | 4 +- .../classes/sun/awt/windows/WingDings.java | 2 +- .../windows/classes/sun/font/NativeFont.java | 11 +++- .../classes/sun/font/NativeStrike.java | 8 +++ .../java2d/WindowsSurfaceManagerFactory.java | 3 +- .../classes/sun/java2d/d3d/D3DBlitLoops.java | 51 +++++++++------ .../classes/sun/java2d/d3d/D3DBufImgOps.java | 2 +- .../classes/sun/java2d/d3d/D3DContext.java | 2 +- .../classes/sun/java2d/d3d/D3DDrawImage.java | 2 +- .../sun/java2d/d3d/D3DGraphicsConfig.java | 4 +- .../sun/java2d/d3d/D3DGraphicsDevice.java | 4 +- .../classes/sun/java2d/d3d/D3DMaskBlit.java | 2 +- .../classes/sun/java2d/d3d/D3DMaskFill.java | 2 +- .../classes/sun/java2d/d3d/D3DPaints.java | 8 +-- .../sun/java2d/d3d/D3DRenderQueue.java | 4 +- .../classes/sun/java2d/d3d/D3DRenderer.java | 15 ++++- .../java2d/d3d/D3DScreenUpdateManager.java | 3 +- .../sun/java2d/d3d/D3DSurfaceData.java | 17 ++++- .../sun/java2d/d3d/D3DSurfaceDataProxy.java | 2 +- .../sun/java2d/d3d/D3DTextRenderer.java | 3 +- .../java2d/d3d/D3DVolatileSurfaceManager.java | 5 +- .../sun/java2d/opengl/WGLGraphicsConfig.java | 14 ++--- .../sun/java2d/opengl/WGLSurfaceData.java | 11 +++- .../opengl/WGLVolatileSurfaceManager.java | 4 +- .../sun/java2d/windows/GDIBlitLoops.java | 3 +- .../sun/java2d/windows/GDIRenderer.java | 29 ++++++++- .../java2d/windows/GDIWindowSurfaceData.java | 8 ++- .../sun/java2d/windows/WindowsFlags.java | 2 +- .../sun/print/PlatformPrinterJobProxy.java | 2 +- .../sun/print/PrintServiceLookupProvider.java | 6 +- .../classes/sun/print/Win32MediaTray.java | 4 +- .../classes/sun/print/Win32PrintJob.java | 10 ++- .../classes/sun/print/Win32PrintService.java | 33 ++++++++-- .../plaf/windows/ClassicSortArrowIcon.java | 5 +- 109 files changed, 743 insertions(+), 200 deletions(-) diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java index a71b3b8367f..a91e1a97ee1 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java @@ -62,7 +62,7 @@ * * @author Igor Kushnirskiy */ -class AnimationController implements ActionListener, PropertyChangeListener { +final class AnimationController implements ActionListener, PropertyChangeListener { private static final boolean VISTA_ANIMATION_DISABLED = Boolean.getBoolean("swing.disablevistaanimation"); @@ -253,6 +253,7 @@ static void paintSkin(JComponent component, Skin skin, } } + @Override public synchronized void propertyChange(PropertyChangeEvent e) { if ("lookAndFeel" == e.getPropertyName() && ! (e.getNewValue() instanceof WindowsLookAndFeel) ) { @@ -260,6 +261,7 @@ public synchronized void propertyChange(PropertyChangeEvent e) { } } + @Override public synchronized void actionPerformed(ActionEvent e) { java.util.List componentsToRemove = null; java.util.List partsToRemove = null; @@ -319,7 +321,7 @@ private synchronized void dispose() { } } - private static class AnimationState { + private static final class AnimationState { private final State startState; //animation duration in nanoseconds @@ -407,7 +409,7 @@ boolean isDone() { } } - private static class PartUIClientPropertyKey + private static final class PartUIClientPropertyKey implements UIClientPropertyKey { private static final Map map = @@ -426,6 +428,7 @@ static synchronized PartUIClientPropertyKey getKey(Part part) { private PartUIClientPropertyKey(Part part) { this.part = part; } + @Override public String toString() { return part.toString(); } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java index 90c7f797043..93628d85766 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java @@ -221,6 +221,7 @@ public String getControlName(Component component) { return str + control.toString(); } + @Override public String toString() { return control.toString()+"."+name(); } @@ -531,6 +532,7 @@ public int getValue() { return value; } + @Override public String toString() { return name()+"["+type.getName()+"] = "+value; } @@ -559,6 +561,7 @@ private TypeEnum(Prop prop, String enumName, int value) { private final String enumName; private final int value; + @Override public String toString() { return prop+"="+enumName+"="+value; } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java index 1e10ccce1bf..31a490bebcc 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java @@ -43,7 +43,7 @@ * @author Rich Schiavi */ -public class WindowsBorders { +public final class WindowsBorders { /** * Returns a border instance for a Windows Progress Bar @@ -115,7 +115,7 @@ public static Border getInternalFrameBorder() { } @SuppressWarnings("serial") // Superclass is not serializable across versions - public static class ProgressBarBorder extends AbstractBorder implements UIResource { + public static final class ProgressBarBorder extends AbstractBorder implements UIResource { protected Color shadow; protected Color highlight; @@ -124,6 +124,7 @@ public ProgressBarBorder(Color shadow, Color highlight) { this.shadow = shadow; } + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { g.setColor(shadow); @@ -134,6 +135,7 @@ public void paintBorder(Component c, Graphics g, int x, int y, g.drawLine(width-1,y, width-1,height-1); // draw right } + @Override public Insets getBorderInsets(Component c, Insets insets) { insets.set(1,1,1,1); return insets; @@ -146,7 +148,7 @@ public Insets getBorderInsets(Component c, Insets insets) { * @since 1.4 */ @SuppressWarnings("serial") // Superclass is not serializable across versions - public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants { + public static final class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants { protected Color shadow; protected Color highlight; @@ -155,6 +157,7 @@ public ToolBarBorder(Color shadow, Color highlight) { this.shadow = shadow; } + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (!(c instanceof JToolBar)) { @@ -224,6 +227,7 @@ public void paintBorder(Component c, Graphics g, int x, int y, g.translate(-x, -y); } + @Override public Insets getBorderInsets(Component c, Insets insets) { insets.set(1,1,1,1); if (!(c instanceof JToolBar)) { @@ -259,6 +263,7 @@ public DashedBorder(Color color, int thickness) { super(color, thickness); } + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Color oldColor = g.getColor(); int i; @@ -276,7 +281,7 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he * of the component's background color. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - static class ComplementDashedBorder extends LineBorder implements UIResource { + static final class ComplementDashedBorder extends LineBorder implements UIResource { private Color origColor; private Color paintColor; @@ -284,6 +289,7 @@ public ComplementDashedBorder() { super(null); } + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Color color = c.getBackground(); @@ -302,7 +308,7 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he * @since 1.4 */ @SuppressWarnings("serial") // Superclass is not serializable across versions - public static class InternalFrameLineBorder extends LineBorder implements + public static final class InternalFrameLineBorder extends LineBorder implements UIResource { protected Color activeColor; protected Color inactiveColor; @@ -315,6 +321,7 @@ public InternalFrameLineBorder(Color activeBorderColor, inactiveColor = inactiveBorderColor; } + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java index b1f7f3902e2..33dea2b3b08 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java @@ -58,7 +58,7 @@ * * @author Jeff Dinkins */ -public class WindowsButtonUI extends BasicButtonUI +public final class WindowsButtonUI extends BasicButtonUI { protected int dashedRectGapX; protected int dashedRectGapY; @@ -89,6 +89,7 @@ public static ComponentUI createUI(JComponent c) { // ******************************** // Defaults // ******************************** + @Override protected void installDefaults(AbstractButton b) { super.installDefaults(b); if(!defaults_initialized) { @@ -108,6 +109,7 @@ protected void installDefaults(AbstractButton b) { } } + @Override protected void uninstallDefaults(AbstractButton b) { super.uninstallDefaults(b); defaults_initialized = false; @@ -124,10 +126,12 @@ protected Color getFocusColor() { /** * Overridden method to render the text without the mnemonic */ + @Override protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) { WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset()); } + @Override protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){ // focus painted same color as text on Basic?? @@ -138,6 +142,7 @@ protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rect width - dashedRectGapWidth, height - dashedRectGapHeight); } + @Override protected void paintButtonPressed(Graphics g, AbstractButton b){ setTextShiftOffset(); } @@ -145,6 +150,7 @@ protected void paintButtonPressed(Graphics g, AbstractButton b){ // ******************************** // Layout Methods // ******************************** + @Override public Dimension getPreferredSize(JComponent c) { Dimension d = super.getPreferredSize(c); @@ -167,6 +173,7 @@ public Dimension getPreferredSize(JComponent c) { */ private Rectangle viewRect = new Rectangle(); + @Override public void paint(Graphics g, JComponent c) { if (XPStyle.getXP() != null) { WindowsButtonUI.paintXPButtonBackground(g, c); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java index c7007bec3db..6b85a88e50c 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java @@ -41,11 +41,12 @@ /** * Windows check box menu item. */ -public class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI { +public final class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI { final WindowsMenuItemUIAccessor accessor = new WindowsMenuItemUIAccessor() { + @Override public JMenuItem getMenuItem() { return menuItem; } @@ -54,6 +55,7 @@ public State getState(JMenuItem menuItem) { return WindowsMenuItemUI.getState(this, menuItem); } + @Override public Part getPart(JMenuItem menuItem) { return WindowsMenuItemUI.getPart(this, menuItem); } @@ -80,6 +82,7 @@ protected void paintBackground(Graphics g, JMenuItem menuItem, * @param text String to render * @since 1.4 */ + @Override protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { if (WindowsMenuItemUI.isVistaPainting()) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java index f94b58c5610..3ead1228b0e 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java @@ -37,7 +37,7 @@ * * @author Jeff Dinkins */ -public class WindowsCheckBoxUI extends WindowsRadioButtonUI +public final class WindowsCheckBoxUI extends WindowsRadioButtonUI { // NOTE: WindowsCheckBoxUI inherits from WindowsRadioButtonUI instead // of BasicCheckBoxUI because we want to pick up all the @@ -64,6 +64,7 @@ public static ComponentUI createUI(JComponent c) { } + @Override public String getPropertyPrefix() { return propertyPrefix; } @@ -71,6 +72,7 @@ public String getPropertyPrefix() { // ******************************** // Defaults // ******************************** + @Override public void installDefaults(AbstractButton b) { super.installDefaults(b); if(!defaults_initialized) { @@ -79,6 +81,7 @@ public void installDefaults(AbstractButton b) { } } + @Override public void uninstallDefaults(AbstractButton b) { super.uninstallDefaults(b); defaults_initialized = false; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java index 6a2c9eeae31..59eace01a4c 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsClassicLookAndFeel.java @@ -31,7 +31,8 @@ * @since 1.5 */ @SuppressWarnings("serial") // Superclass is not serializable across versions -public class WindowsClassicLookAndFeel extends WindowsLookAndFeel { +public final class WindowsClassicLookAndFeel extends WindowsLookAndFeel { + @Override public String getName() { return "Windows Classic"; } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java index 1a601f40332..f37ce17d876 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java @@ -75,7 +75,7 @@ * @author Tom Santos * @author Igor Kushnirskiy */ -public class WindowsComboBoxUI extends BasicComboBoxUI { +public final class WindowsComboBoxUI extends BasicComboBoxUI { private static final MouseListener rolloverListener = new MouseAdapter() { @@ -162,6 +162,7 @@ public static ComponentUI createUI(JComponent c) { return new WindowsComboBoxUI(); } + @Override public void installUI( JComponent c ) { super.installUI( c ); isRollover = false; @@ -176,6 +177,7 @@ public void installUI( JComponent c ) { } } + @Override public void uninstallUI(JComponent c ) { comboBox.removeMouseListener(rolloverListener); if(arrowButton != null) { @@ -215,6 +217,7 @@ protected void uninstallListeners() { * {@inheritDoc} * @since 1.6 */ + @Override protected void configureEditor() { super.configureEditor(); if (XPStyle.getXP() != null) { @@ -226,6 +229,7 @@ protected void configureEditor() { * {@inheritDoc} * @since 1.6 */ + @Override protected void unconfigureEditor() { super.unconfigureEditor(); editor.removeMouseListener(rolloverListener); @@ -235,6 +239,7 @@ protected void unconfigureEditor() { * {@inheritDoc} * @since 1.6 */ + @Override public void paint(Graphics g, JComponent c) { if (XPStyle.getXP() != null) { paintXPComboBoxBackground(g, c); @@ -283,6 +288,7 @@ private void paintXPComboBoxBackground(Graphics g, JComponent c) { * @throws NullPointerException if any of the arguments are null. * @since 1.5 */ + @Override public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { XPStyle xp = XPStyle.getXP(); @@ -347,6 +353,7 @@ public void paintCurrentValue(Graphics g, Rectangle bounds, * {@inheritDoc} * @since 1.6 */ + @Override public void paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus) { if (XPStyle.getXP() == null) { @@ -354,6 +361,7 @@ public void paintCurrentValueBackground(Graphics g, Rectangle bounds, } } + @Override public Dimension getMinimumSize( JComponent c ) { Dimension d = super.getMinimumSize(c); if (XPStyle.getXP() != null) { @@ -380,6 +388,7 @@ public Dimension getMinimumSize( JComponent c ) { * * @return an instance of a layout manager */ + @Override protected LayoutManager createLayoutManager() { return new BasicComboBoxUI.ComboBoxLayoutManager() { public void layoutContainer(Container parent) { @@ -407,10 +416,12 @@ public void layoutContainer(Container parent) { }; } + @Override protected void installKeyboardActions() { super.installKeyboardActions(); } + @Override protected ComboPopup createPopup() { return new WinComboPopUp(comboBox); } @@ -423,6 +434,7 @@ protected ComboPopup createPopup() { * @return a ComboBoxEditor used for the combo box * @see javax.swing.JComboBox#setEditor */ + @Override protected ComboBoxEditor createEditor() { return new WindowsComboBoxEditor(); } @@ -447,6 +459,7 @@ protected ListCellRenderer createRenderer() { * * @return a button which represents the popup control */ + @Override protected JButton createArrowButton() { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -457,7 +470,7 @@ protected JButton createArrowButton() { } @SuppressWarnings("serial") // Superclass is not serializable across versions - private class XPComboBoxButton extends XPStyle.GlyphButton { + private final class XPComboBoxButton extends XPStyle.GlyphButton { private State prevState = null; public XPComboBoxButton(XPStyle xp) { @@ -504,6 +517,7 @@ protected State getState() { return rv; } + @Override public Dimension getPreferredSize() { return new Dimension(17, 21); } @@ -518,7 +532,7 @@ WindowsComboBoxUI getWindowsComboBoxUI() { } @SuppressWarnings("serial") // Same-version serialization only - protected class WinComboPopUp extends BasicComboPopup { + protected final class WinComboPopUp extends BasicComboPopup { private Skin listBoxBorder = null; private XPStyle xp; @@ -531,16 +545,18 @@ public WinComboPopUp(JComboBox combo) { } } + @Override protected KeyListener createKeyListener() { return new InvocationKeyHandler(); } - protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler { + protected final class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler { protected InvocationKeyHandler() { WinComboPopUp.this.super(); } } + @Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (this.listBoxBorder != null) { @@ -554,13 +570,14 @@ protected void paintComponent(Graphics g) { /** * Subclassed to highlight selected item in an editable combo box. */ - public static class WindowsComboBoxEditor + public static final class WindowsComboBoxEditor extends BasicComboBoxEditor.UIResource { /** * {@inheritDoc} * @since 1.6 */ + @Override protected JTextField createEditorComponent() { JTextField editor = super.createEditorComponent(); Border border = (Border)UIManager.get("ComboBox.editorBorder"); @@ -572,6 +589,7 @@ protected JTextField createEditorComponent() { return editor; } + @Override public void setItem(Object item) { super.setItem(item); Object focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); @@ -586,14 +604,14 @@ public void setItem(Object item) { * and to show border for focused cells. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - private static class WindowsComboBoxRenderer + private static final class WindowsComboBoxRenderer extends BasicComboBoxRenderer.UIResource { private static final Object BORDER_KEY = new StringUIClientPropertyKey("BORDER_KEY"); private static final Border NULL_BORDER = new EmptyBorder(0, 0, 0, 0); // Create own version of DashedBorder with more space on left side - private static class WindowsComboBoxDashedBorder extends DashedBorder { + private static final class WindowsComboBoxDashedBorder extends DashedBorder { public WindowsComboBoxDashedBorder(Color color, int thickness) { super(color, thickness); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java index 564ae5b9f71..8da4bd7921b 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopIconUI.java @@ -36,18 +36,20 @@ /** * Windows icon for a minimized window on the desktop. */ -public class WindowsDesktopIconUI extends BasicDesktopIconUI { +public final class WindowsDesktopIconUI extends BasicDesktopIconUI { private int width; public static ComponentUI createUI(JComponent c) { return new WindowsDesktopIconUI(); } + @Override public void installDefaults() { super.installDefaults(); width = UIManager.getInt("DesktopIcon.width"); } + @Override public void installUI(JComponent c) { super.installUI(c); @@ -55,6 +57,7 @@ public void installUI(JComponent c) { } // Uninstall the listeners added by the WindowsInternalFrameTitlePane + @Override public void uninstallUI(JComponent c) { WindowsInternalFrameTitlePane thePane = (WindowsInternalFrameTitlePane)iconPane; @@ -62,6 +65,7 @@ public void uninstallUI(JComponent c) { thePane.uninstallListeners(); } + @Override protected void installComponents() { iconPane = new WindowsInternalFrameTitlePane(frame); desktopIcon.setLayout(new BorderLayout()); @@ -72,6 +76,7 @@ protected void installComponents() { } } + @Override public Dimension getPreferredSize(JComponent c) { // Windows desktop icons can not be resized. Therefore, we should // always return the minimum size of the desktop icon. See @@ -83,6 +88,7 @@ public Dimension getPreferredSize(JComponent c) { * Windows desktop icons are restricted to a width of 160 pixels by * default. This value is retrieved by the DesktopIcon.width property. */ + @Override public Dimension getMinimumSize(JComponent c) { Dimension dim = super.getMinimumSize(c); dim.width = width; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java index 82708f571e5..355f70b4607 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopManager.java @@ -52,7 +52,7 @@ * @author Thomas Ball */ @SuppressWarnings("serial") // JDK-implementation class -public class WindowsDesktopManager extends DefaultDesktopManager +public final class WindowsDesktopManager extends DefaultDesktopManager implements java.io.Serializable, javax.swing.plaf.UIResource { /* The frame which is currently selected/activated. @@ -60,6 +60,7 @@ public class WindowsDesktopManager extends DefaultDesktopManager */ private WeakReference currentFrameRef; + @Override public void activateFrame(JInternalFrame f) { JInternalFrame currentFrame = currentFrameRef != null ? currentFrameRef.get() : null; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java index 3ceea2d31dc..49ab809dddd 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsDesktopPaneUI.java @@ -34,12 +34,13 @@ * * @author David Kloba */ -public class WindowsDesktopPaneUI extends BasicDesktopPaneUI +public final class WindowsDesktopPaneUI extends BasicDesktopPaneUI { public static ComponentUI createUI(JComponent c) { return new WindowsDesktopPaneUI(); } + @Override protected void installDesktopManager() { desktopManager = desktop.getDesktopManager(); if(desktopManager == null) { @@ -48,10 +49,12 @@ protected void installDesktopManager() { } } + @Override protected void installDefaults() { super.installDefaults(); } + @Override @SuppressWarnings("deprecation") protected void installKeyboardActions() { super.installKeyboardActions(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java index 2f5c45633d4..abccb6b9a48 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsEditorPaneUI.java @@ -33,7 +33,7 @@ /** * Windows rendition of the component. */ -public class WindowsEditorPaneUI extends BasicEditorPaneUI +public final class WindowsEditorPaneUI extends BasicEditorPaneUI { /** @@ -54,6 +54,7 @@ public static ComponentUI createUI(JComponent c) { * * @return the caret object */ + @Override protected Caret createCaret() { return new WindowsTextUI.WindowsCaret(); } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java index 7065e3db19b..37d45bbf902 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java @@ -101,7 +101,7 @@ * * @author Jeff Dinkins */ -public class WindowsFileChooserUI extends BasicFileChooserUI { +public final class WindowsFileChooserUI extends BasicFileChooserUI { // The following are private because the implementation of the // Windows FileChooser L&F is not complete yet. @@ -194,61 +194,75 @@ public WindowsFileChooserUI(JFileChooser filechooser) { super(filechooser); } + @Override public void installUI(JComponent c) { super.installUI(c); } + @Override public void uninstallComponents(JFileChooser fc) { fc.removeAll(); } - private class WindowsFileChooserUIAccessor implements FilePane.FileChooserUIAccessor { + private final class WindowsFileChooserUIAccessor implements FilePane.FileChooserUIAccessor { + @Override public JFileChooser getFileChooser() { return WindowsFileChooserUI.this.getFileChooser(); } + @Override public BasicDirectoryModel getModel() { return WindowsFileChooserUI.this.getModel(); } + @Override public JPanel createList() { return WindowsFileChooserUI.this.createList(getFileChooser()); } + @Override public JPanel createDetailsView() { return WindowsFileChooserUI.this.createDetailsView(getFileChooser()); } + @Override public boolean isDirectorySelected() { return WindowsFileChooserUI.this.isDirectorySelected(); } + @Override public File getDirectory() { return WindowsFileChooserUI.this.getDirectory(); } + @Override public Action getChangeToParentDirectoryAction() { return WindowsFileChooserUI.this.getChangeToParentDirectoryAction(); } + @Override public Action getApproveSelectionAction() { return WindowsFileChooserUI.this.getApproveSelectionAction(); } + @Override public Action getNewFolderAction() { return WindowsFileChooserUI.this.getNewFolderAction(); } + @Override public MouseListener createDoubleClickListener(JList list) { return WindowsFileChooserUI.this.createDoubleClickListener(getFileChooser(), list); } + @Override public ListSelectionListener createListSelectionListener() { return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser()); } } + @Override public void installComponents(JFileChooser fc) { filePane = new FilePane(new WindowsFileChooserUIAccessor()); fc.addPropertyChangeListener(filePane); @@ -584,6 +598,7 @@ protected JPanel getBottomPanel() { return bottomPanel; } + @Override protected void installStrings(JFileChooser fc) { super.installStrings(fc); @@ -615,6 +630,7 @@ private Integer getMnemonic(String key, Locale l) { return SwingUtilities2.getUIDefaultsInt(key, l); } + @Override protected void installListeners(JFileChooser fc) { super.installListeners(fc); ActionMap actionMap = getActionMap(); @@ -645,10 +661,12 @@ protected JPanel createDetailsView(JFileChooser fc) { * @param fc a JFileChooser * @return a ListSelectionListener */ + @Override public ListSelectionListener createListSelectionListener(JFileChooser fc) { return super.createListSelectionListener(fc); } + @Override public void uninstallUI(JComponent c) { // Remove listeners c.removePropertyChangeListener(filterComboBoxModel); @@ -859,6 +877,7 @@ private void doControlButtonsChanged(PropertyChangeEvent e) { * Listen for filechooser property changes, such as * the selected file changing, or the type of the dialog changing. */ + @Override public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) { return new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { @@ -913,14 +932,17 @@ protected void addControlButtons() { getBottomPanel().add(getButtonPanel()); } + @Override public void ensureFileIsVisible(JFileChooser fc, File f) { filePane.ensureFileIsVisible(fc, f); } + @Override public void rescanCurrentDirectory(JFileChooser fc) { filePane.rescanCurrentDirectory(); } + @Override public String getFileName() { if(filenameTextField != null) { return filenameTextField.getText(); @@ -929,6 +951,7 @@ public String getFileName() { } } + @Override public void setFileName(String filename) { if(filenameTextField != null) { filenameTextField.setText(filename); @@ -942,6 +965,7 @@ public void setFileName(String filename) { * @param directorySelected if a directory is currently selected. * @since 1.4 */ + @Override protected void setDirectorySelected(boolean directorySelected) { super.setDirectorySelected(directorySelected); JFileChooser chooser = getFileChooser(); @@ -956,11 +980,13 @@ protected void setDirectorySelected(boolean directorySelected) { } } + @Override public String getDirectoryName() { // PENDING(jeff) - get the name from the directory combobox return null; } + @Override public void setDirectoryName(String dirname) { // PENDING(jeff) - set the name in the directory combobox } @@ -1032,8 +1058,9 @@ public void focusLost(FocusEvent e) { // Renderer for DirectoryComboBox // @SuppressWarnings("serial") // Superclass is not serializable across versions - class DirectoryComboBoxRenderer extends DefaultListCellRenderer { + final class DirectoryComboBoxRenderer extends DefaultListCellRenderer { IndentIcon ii = new IndentIcon(); + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -1056,11 +1083,12 @@ public Component getListCellRendererComponent(JList list, Object value, } static final int space = 10; - static class IndentIcon implements Icon { + static final class IndentIcon implements Icon { Icon icon = null; int depth = 0; + @Override public void paintIcon(Component c, Graphics g, int x, int y) { if (c.getComponentOrientation().isLeftToRight()) { icon.paintIcon(c, g, x+depth*space, y); @@ -1069,10 +1097,12 @@ public void paintIcon(Component c, Graphics g, int x, int y) { } } + @Override public int getIconWidth() { return icon.getIconWidth() + depth*space; } + @Override public int getIconHeight() { return icon.getIconHeight(); } @@ -1090,7 +1120,7 @@ protected DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc) { * Data model for a type-face selection combo-box. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel { + protected final class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel { Vector directories = new Vector(); int[] depths = null; File selectedDirectory = null; @@ -1187,19 +1217,23 @@ public int getDepth(int i) { return (depths != null && i >= 0 && i < depths.length) ? depths[i] : 0; } + @Override public void setSelectedItem(Object selectedDirectory) { this.selectedDirectory = (File)selectedDirectory; fireContentsChanged(this, -1, -1); } + @Override public Object getSelectedItem() { return selectedDirectory; } + @Override public int getSize() { return directories.size(); } + @Override public File getElementAt(int index) { return directories.elementAt(index); } @@ -1216,7 +1250,8 @@ protected FilterComboBoxRenderer createFilterComboBoxRenderer() { * Render different type sizes and styles. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - public class FilterComboBoxRenderer extends DefaultListCellRenderer { + public final class FilterComboBoxRenderer extends DefaultListCellRenderer { + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -1242,7 +1277,7 @@ protected FilterComboBoxModel createFilterComboBoxModel() { * Data model for a type-face selection combo-box. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, + protected final class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener { protected FileFilter[] filters; protected FilterComboBoxModel() { @@ -1250,6 +1285,7 @@ protected FilterComboBoxModel() { filters = getFileChooser().getChoosableFileFilters(); } + @Override public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if(prop == JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY) { @@ -1260,6 +1296,7 @@ public void propertyChange(PropertyChangeEvent e) { } } + @Override public void setSelectedItem(Object filter) { if(filter != null) { getFileChooser().setFileFilter((FileFilter) filter); @@ -1267,6 +1304,7 @@ public void setSelectedItem(Object filter) { } } + @Override public Object getSelectedItem() { // Ensure that the current filter is in the list. // NOTE: we shouldn't have to do this, since JFileChooser adds @@ -1288,6 +1326,7 @@ public Object getSelectedItem() { return getFileChooser().getFileFilter(); } + @Override public int getSize() { if(filters != null) { return filters.length; @@ -1296,6 +1335,7 @@ public int getSize() { } } + @Override public FileFilter getElementAt(int index) { if(index > getSize() - 1) { // This shouldn't happen. Try to recover gracefully. @@ -1320,21 +1360,24 @@ public void valueChanged(ListSelectionEvent e) { /** * Acts when DirectoryComboBox has changed the selected item. */ - protected class DirectoryComboBoxAction implements ActionListener { + protected final class DirectoryComboBoxAction implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { File f = (File)directoryComboBox.getSelectedItem(); getFileChooser().setCurrentDirectory(f); } } + @Override protected JButton getApproveButton(JFileChooser fc) { return approveButton; } + @Override public FileView getFileView(JFileChooser fc) { return fileView; } @@ -1342,9 +1385,10 @@ public FileView getFileView(JFileChooser fc) { // *********************** // * FileView operations * // *********************** - protected class WindowsFileView extends BasicFileView { + protected final class WindowsFileView extends BasicFileView { /* FileView type descriptions */ + @Override public Icon getIcon(File f) { Icon icon = getCachedIcon(f); if (icon != null) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java index cb4b5caa86d..b5859b08ea8 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java @@ -58,7 +58,7 @@ * @author Mark Davidson * @since 1.4 */ -public class WindowsGraphicsUtils { +public final class WindowsGraphicsUtils { /** * Renders a text String in Windows without the mnemonic. diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java index 072ff606b5b..cf2fd119423 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java @@ -63,7 +63,7 @@ * @author Rich Schiavi */ @SuppressWarnings("serial") // Same-version serialization only -public class WindowsIconFactory implements Serializable +public final class WindowsIconFactory implements Serializable { private static Icon frame_closeIcon; private static Icon frame_iconifyIcon; @@ -173,13 +173,14 @@ public static Icon createFrameResizeIcon() { @SuppressWarnings("serial") // Same-version serialization only - private static class FrameButtonIcon implements Icon, Serializable { + private static final class FrameButtonIcon implements Icon, Serializable { private final Part part; private FrameButtonIcon(Part part) { this.part = part; } + @Override public void paintIcon(Component c, Graphics g, int x0, int y0) { int width = getIconWidth(); int height = getIconHeight(); @@ -281,6 +282,7 @@ public void paintIcon(Component c, Graphics g, int x0, int y0) { } } + @Override public int getIconWidth() { int width; if (XPStyle.getXP() != null) { @@ -293,6 +295,7 @@ public int getIconWidth() { return width; } + @Override public int getIconHeight() { int height = UIManager.getInt("InternalFrame.titleButtonHeight")-4; return height; @@ -302,7 +305,8 @@ public int getIconHeight() { @SuppressWarnings("serial") // Same-version serialization only - private static class ResizeIcon implements Icon, Serializable { + private static final class ResizeIcon implements Icon, Serializable { + @Override public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(UIManager.getColor("InternalFrame.resizeIconHighlight")); g.drawLine(0, 11, 11, 0); @@ -317,14 +321,17 @@ public void paintIcon(Component c, Graphics g, int x, int y) { g.drawLine(9, 11, 11, 9); g.drawLine(10, 11, 11, 10); } + @Override public int getIconWidth() { return 13; } + @Override public int getIconHeight() { return 13; } } @SuppressWarnings("serial") // Same-version serialization only - private static class CheckBoxIcon implements Icon, Serializable + private static final class CheckBoxIcon implements Icon, Serializable { static final int csize = 13; + @Override public void paintIcon(Component c, Graphics g, int x, int y) { JCheckBox cb = (JCheckBox) c; ButtonModel model = cb.getModel(); @@ -425,6 +432,7 @@ public void paintIcon(Component c, Graphics g, int x, int y) { } } + @Override public int getIconWidth() { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -434,6 +442,7 @@ public int getIconWidth() { } } + @Override public int getIconHeight() { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -445,8 +454,9 @@ public int getIconHeight() { } @SuppressWarnings("serial") // Same-version serialization only - private static class RadioButtonIcon implements Icon, UIResource, Serializable + private static final class RadioButtonIcon implements Icon, UIResource, Serializable { + @Override public void paintIcon(Component c, Graphics g, int x, int y) { AbstractButton b = (AbstractButton) c; ButtonModel model = b.getModel(); @@ -579,6 +589,7 @@ public void paintIcon(Component c, Graphics g, int x, int y) { } } + @Override public int getIconWidth() { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -588,6 +599,7 @@ public int getIconWidth() { } } + @Override public int getIconHeight() { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -600,8 +612,9 @@ public int getIconHeight() { @SuppressWarnings("serial") // Same-version serialization only - private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable + private static final class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable { + @Override public void paintIcon(Component c, Graphics g, int x, int y) { AbstractButton b = (AbstractButton) c; ButtonModel model = b.getModel(); @@ -619,15 +632,18 @@ public void paintIcon(Component c, Graphics g, int x, int y) { g.drawLine(x+3, y+6, x+4, y+6); } } + @Override public int getIconWidth() { return 9; } + @Override public int getIconHeight() { return 9; } } // End class CheckBoxMenuItemIcon @SuppressWarnings("serial") // Same-version serialization only - private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable + private static final class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable { + @Override public void paintIcon(Component c, Graphics g, int x, int y) { AbstractButton b = (AbstractButton) c; ButtonModel model = b.getModel(); @@ -636,14 +652,17 @@ public void paintIcon(Component c, Graphics g, int x, int y) { 4, 4); } } + @Override public int getIconWidth() { return 12; } + @Override public int getIconHeight() { return 12; } } // End class RadioButtonMenuItemIcon @SuppressWarnings("serial") // Same-version serialization only - private static class MenuItemCheckIcon implements Icon, UIResource, Serializable{ + private static final class MenuItemCheckIcon implements Icon, UIResource, Serializable{ + @Override public void paintIcon(Component c, Graphics g, int x, int y) { /* For debugging: Color oldColor = g.getColor(); @@ -652,13 +671,16 @@ public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(oldColor); */ } + @Override public int getIconWidth() { return 9; } + @Override public int getIconHeight() { return 9; } } // End class MenuItemCheckIcon @SuppressWarnings("serial") // Same-version serialization only - private static class MenuItemArrowIcon implements Icon, UIResource, Serializable { + private static final class MenuItemArrowIcon implements Icon, UIResource, Serializable { + @Override public void paintIcon(Component c, Graphics g, int x, int y) { /* For debugging: Color oldColor = g.getColor(); @@ -667,13 +689,16 @@ public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(oldColor); */ } + @Override public int getIconWidth() { return 4; } + @Override public int getIconHeight() { return 8; } } // End class MenuItemArrowIcon @SuppressWarnings("serial") // Same-version serialization only - private static class MenuArrowIcon implements Icon, UIResource, Serializable { + private static final class MenuArrowIcon implements Icon, UIResource, Serializable { + @Override public void paintIcon(Component c, Graphics g, int x, int y) { XPStyle xp = XPStyle.getXP(); if (WindowsMenuItemUI.isVistaPainting(xp)) { @@ -708,6 +733,7 @@ public void paintIcon(Component c, Graphics g, int x, int y) { g.translate(-x,-y); } } + @Override public int getIconWidth() { XPStyle xp = XPStyle.getXP(); if (WindowsMenuItemUI.isVistaPainting(xp)) { @@ -717,6 +743,7 @@ public int getIconWidth() { return 4; } } + @Override public int getIconHeight() { XPStyle xp = XPStyle.getXP(); if (WindowsMenuItemUI.isVistaPainting(xp)) { @@ -728,14 +755,16 @@ public int getIconHeight() { } } // End class MenuArrowIcon - static class VistaMenuItemCheckIconFactory + static final class VistaMenuItemCheckIconFactory implements MenuItemCheckIconFactory { private static final int OFFSET = 3; + @Override public Icon getIcon(JMenuItem component) { return new VistaMenuItemCheckIcon(component); } + @Override public boolean isCompatible(Object icon, String prefix) { return icon instanceof VistaMenuItemCheckIcon && ((VistaMenuItemCheckIcon) icon).type == getType(prefix); @@ -788,7 +817,7 @@ private static Class getType(String type) { * Note: to be used on Vista only. */ @SuppressWarnings("serial") // Same-version serialization only - private static class VistaMenuItemCheckIcon + private static final class VistaMenuItemCheckIcon implements Icon, UIResource, Serializable { private final JMenuItem menuItem; @@ -803,6 +832,7 @@ private static class VistaMenuItemCheckIcon this.menuItem = null; } + @Override public int getIconHeight() { Icon lafIcon = getLaFIcon(); if (lafIcon != null) { @@ -825,6 +855,7 @@ public int getIconHeight() { return height; } + @Override public int getIconWidth() { Icon lafIcon = getLaFIcon(); if (lafIcon != null) { @@ -840,6 +871,7 @@ public int getIconWidth() { return width; } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { Icon lafIcon = getLaFIcon(); if (lafIcon != null) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java index 083563b4464..ba4bde12122 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java @@ -83,6 +83,7 @@ public WindowsInternalFrameTitlePane(JInternalFrame f) { super(f); } + @Override protected void addSubComponents() { add(systemLabel); add(iconButton); @@ -90,6 +91,7 @@ protected void addSubComponents() { add(closeButton); } + @Override protected void installDefaults() { super.installDefaults(); @@ -117,11 +119,13 @@ protected void installDefaults() { UIManager.getColor("InternalFrame.inactiveTitleGradient"); } + @Override protected void uninstallListeners() { // Get around protected method in superclass super.uninstallListeners(); } + @Override protected void createButtons() { super.createButtons(); if (XPStyle.getXP() != null) { @@ -131,6 +135,7 @@ protected void createButtons() { } } + @Override protected void setButtonIcons() { super.setButtonIcons(); @@ -142,6 +147,7 @@ protected void setButtonIcons() { } + @Override public void paintComponent(Graphics g) { XPStyle xp = XPStyle.getXP(); @@ -224,10 +230,12 @@ public void paintComponent(Graphics g) { } } + @Override public Dimension getPreferredSize() { return getMinimumSize(); } + @Override public Dimension getMinimumSize() { Dimension d = new Dimension(super.getMinimumSize()); d.height = titlePaneHeight + 2; @@ -245,6 +253,7 @@ public Dimension getMinimumSize() { return d; } + @Override protected void paintTitleBackground(Graphics g) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -285,6 +294,7 @@ protected void paintTitleBackground(Graphics g) { } } + @Override protected void assembleSystemMenu() { systemPopupMenu = new JPopupMenu(); addSystemMenuItems(systemPopupMenu); @@ -372,6 +382,7 @@ private static int getButtonMnemonic(String button) { } } + @Override protected void showSystemMenu(){ showSystemPopupMenu(systemLabel); } @@ -397,15 +408,17 @@ private void showSystemPopupMenu(Component invoker){ } } + @Override protected PropertyChangeListener createPropertyChangeListener() { return new WindowsPropertyChangeHandler(); } + @Override protected LayoutManager createLayout() { return new WindowsTitlePaneLayout(); } - public class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout { + public final class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout { private Insets captionMargin = null; private Insets contentMargin = null; private XPStyle xp = XPStyle.getXP(); @@ -439,6 +452,7 @@ private int layoutButton(JComponent button, Part part, return x; } + @Override public void layoutContainer(Container c) { boolean leftToRight = WindowsGraphicsUtils.isLeftToRight(frame); int x, y; @@ -492,7 +506,8 @@ public void layoutContainer(Container c) { } } // end WindowsTitlePaneLayout - public class WindowsPropertyChangeHandler extends PropertyChangeHandler { + public final class WindowsPropertyChangeHandler extends PropertyChangeHandler { + @Override public void propertyChange(PropertyChangeEvent evt) { String prop = evt.getPropertyName(); @@ -515,7 +530,7 @@ public void propertyChange(PropertyChangeEvent evt) { *

* Note: We assume here that icons are square. */ - public static class ScalableIconUIResource implements Icon, UIResource { + public static final class ScalableIconUIResource implements Icon, UIResource { // We can use an arbitrary size here because we scale to it in paintIcon() private static final int SIZE = 16; @@ -562,6 +577,7 @@ protected Icon getBestIcon(int size) { } } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D)g.create(); // Calculate how big our drawing area is in pixels @@ -580,10 +596,12 @@ public void paintIcon(Component c, Graphics g, int x, int y) { g2d.dispose(); } + @Override public int getIconWidth() { return SIZE; } + @Override public int getIconHeight() { return SIZE; } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java index 19169f6e424..5c331533af9 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameUI.java @@ -45,10 +45,11 @@ /** * Windows rendition of the component. */ -public class WindowsInternalFrameUI extends BasicInternalFrameUI +public final class WindowsInternalFrameUI extends BasicInternalFrameUI { XPStyle xp = XPStyle.getXP(); + @Override public void installDefaults() { super.installDefaults(); @@ -59,6 +60,7 @@ public void installDefaults() { } } + @Override public void installUI(JComponent c) { super.installUI(c); @@ -66,6 +68,7 @@ public void installUI(JComponent c) { xp == null? Boolean.TRUE : Boolean.FALSE); } + @Override public void uninstallDefaults() { frame.setBorder(null); super.uninstallDefaults(); @@ -79,17 +82,19 @@ public WindowsInternalFrameUI(JInternalFrame w){ super(w); } + @Override protected DesktopManager createDesktopManager(){ return new WindowsDesktopManager(); } + @Override protected JComponent createNorthPane(JInternalFrame w) { titlePane = new WindowsInternalFrameTitlePane(w); return titlePane; } @SuppressWarnings("serial") // Superclass is not serializable across versions - private class XPBorder extends AbstractBorder { + private final class XPBorder extends AbstractBorder { private Skin leftSkin = xp.getSkin(frame, Part.WP_FRAMELEFT); private Skin rightSkin = xp.getSkin(frame, Part.WP_FRAMERIGHT); private Skin bottomSkin = xp.getSkin(frame, Part.WP_FRAMEBOTTOM); @@ -100,6 +105,7 @@ private class XPBorder extends AbstractBorder { * @param width the width of the painted border * @param height the height of the painted border */ + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { State state = ((JInternalFrame)c).isSelected() ? State.ACTIVE : State.INACTIVE; int topBorderHeight = (titlePane != null) ? titlePane.getSize().height : 0; @@ -118,6 +124,7 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he } + @Override public Insets getBorderInsets(Component c, Insets insets) { insets.top = 4; insets.left = leftSkin.getWidth(); @@ -127,6 +134,7 @@ public Insets getBorderInsets(Component c, Insets insets) { return insets; } + @Override public boolean isBorderOpaque() { return true; } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java index 6266772dcf4..d10f3f47c3c 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java @@ -41,7 +41,7 @@ /** * Windows rendition of the component. */ -public class WindowsLabelUI extends BasicLabelUI { +public final class WindowsLabelUI extends BasicLabelUI { private static final Object WINDOWS_LABEL_UI_KEY = new Object(); @@ -59,6 +59,7 @@ public static ComponentUI createUI(JComponent c) { return windowsLabelUI; } + @Override protected void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); @@ -72,6 +73,7 @@ protected void paintEnabledText(JLabel l, Graphics g, String s, textX, textY); } + @Override protected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) { int mnemonicIndex = l.getDisplayedMnemonicIndex(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java index 72ad51535ff..d1ee714f362 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java @@ -145,26 +145,32 @@ public class WindowsLookAndFeel extends BasicLookAndFeel */ private int baseUnitY; + @Override public String getName() { return "Windows"; } + @Override public String getDescription() { return "The Microsoft Windows Look and Feel"; } + @Override public String getID() { return "Windows"; } + @Override public boolean isNativeLookAndFeel() { return OSInfo.getOSType() == OSInfo.OSType.WINDOWS; } + @Override public boolean isSupportedLookAndFeel() { return isNativeLookAndFeel(); } + @Override public void initialize() { super.initialize(); @@ -206,6 +212,7 @@ public void initialize() { * * @see BasicLookAndFeel#getDefaults */ + @Override protected void initClassDefaults(UIDefaults table) { super.initClassDefaults(table); @@ -260,6 +267,7 @@ protected void initClassDefaults(UIDefaults table) * values, otherwise we create color objects whose values match * the defaults Windows95 colors. */ + @Override protected void initSystemColorDefaults(UIDefaults table) { String[] defaultSystemColors = { @@ -310,6 +318,7 @@ private void initResourceBundle(UIDefaults table) { // XXX - there are probably a lot of redundant values that could be removed. // ie. Take a look at RadioButtonBorder, etc... + @Override protected void initComponentDefaults(UIDefaults table) { super.initComponentDefaults( table ); @@ -1893,6 +1902,7 @@ public Object createValue(UIDefaults table) { return lazyDefaults; } + @Override public void uninitialize() { super.uninitialize(); @@ -1944,6 +1954,7 @@ public static boolean isClassicWindows() { * * @see javax.swing.LookAndFeel#provideErrorFeedback */ + @Override public void provideErrorFeedback(Component component) { super.provideErrorFeedback(component); } @@ -1951,6 +1962,7 @@ public void provideErrorFeedback(Component component) { /** * {@inheritDoc} */ + @Override public LayoutStyle getLayoutStyle() { LayoutStyle style = this.style; if (style == null) { @@ -1981,6 +1993,7 @@ public LayoutStyle getLayoutStyle() { * @see #playSound(Action) * @since 1.4 */ + @Override protected Action createAudioAction(Object key) { if (key != null) { String audioKey = (String)key; @@ -2018,7 +2031,7 @@ static void repaintRootPane(Component c) { * @since 1.4 */ @SuppressWarnings("serial") // Superclass is not serializable across versions - private static class AudioAction extends AbstractAction { + private static final class AudioAction extends AbstractAction { private Runnable audioRunnable; private String audioResource; /** @@ -2029,6 +2042,7 @@ public AudioAction(String name, String resource) { super(name); audioResource = resource; } + @Override public void actionPerformed(ActionEvent e) { if (audioRunnable == null) { audioRunnable = (Runnable)Toolkit.getDefaultToolkit().getDesktopProperty(audioResource); @@ -2045,7 +2059,7 @@ public void actionPerformed(ActionEvent e) { * Gets an Icon from the native libraries if available, * otherwise gets it from an image resource file. */ - private static class LazyWindowsIcon implements UIDefaults.LazyValue { + private static final class LazyWindowsIcon implements UIDefaults.LazyValue { private String nativeImage; private String resource; @@ -2054,6 +2068,7 @@ private static class LazyWindowsIcon implements UIDefaults.LazyValue { this.resource = resource; } + @Override public Object createValue(UIDefaults table) { if (nativeImage != null) { Image image = (Image)ShellFolder.get(nativeImage); @@ -2072,7 +2087,7 @@ public Object createValue(UIDefaults table) { * Gets an Icon from the native libraries if available. * A desktop property is used to trigger reloading the icon when needed. */ - private static class ActiveWindowsIcon implements UIDefaults.ActiveValue { + private static final class ActiveWindowsIcon implements UIDefaults.ActiveValue { private Icon icon; private String nativeImageName; private String fallbackName; @@ -2117,7 +2132,7 @@ public Object createValue(UIDefaults table) { /** * Icon backed-up by XP Skin. */ - private static class SkinIcon implements Icon, UIResource { + private static final class SkinIcon implements Icon, UIResource { private final Part part; private final State state; SkinIcon(Part part, State state) { @@ -2130,6 +2145,7 @@ private static class SkinIcon implements Icon, UIResource { * may use the Component argument to get properties useful for * painting, e.g. the foreground or background color. */ + @Override public void paintIcon(Component c, Graphics g, int x, int y) { XPStyle xp = XPStyle.getXP(); assert xp != null; @@ -2144,6 +2160,7 @@ public void paintIcon(Component c, Graphics g, int x, int y) { * * @return an int specifying the fixed width of the icon. */ + @Override public int getIconWidth() { int width = 0; XPStyle xp = XPStyle.getXP(); @@ -2160,6 +2177,7 @@ public int getIconWidth() { * * @return an int specifying the fixed height of the icon. */ + @Override public int getIconHeight() { int height = 0; XPStyle xp = XPStyle.getXP(); @@ -2176,11 +2194,12 @@ public int getIconHeight() { * WindowsDesktopProperty for fonts. If a font with the name 'MS Sans Serif' * is returned, it is mapped to 'Microsoft Sans Serif'. */ - private static class WindowsFontProperty extends WindowsDesktopProperty { + private static final class WindowsFontProperty extends WindowsDesktopProperty { WindowsFontProperty(String key, Object backup) { super(key, backup); } + @Override public void invalidate(LookAndFeel laf) { if ("win.defaultGUI.font.height".equals(getKey())) { ((WindowsLookAndFeel)laf).style = null; @@ -2188,6 +2207,7 @@ public void invalidate(LookAndFeel laf) { super.invalidate(laf); } + @Override protected Object configureValue(Object value) { if (value instanceof Font) { Font font = (Font)value; @@ -2236,7 +2256,7 @@ protected Object configureValue(Object value) { * WindowsDesktopProperty for fonts that only gets sizes from the desktop, * font name and style are passed into the constructor */ - private static class WindowsFontSizeProperty extends + private static final class WindowsFontSizeProperty extends WindowsDesktopProperty { private String fontName; private int fontSize; @@ -2250,6 +2270,7 @@ private static class WindowsFontSizeProperty extends this.fontStyle = fontStyle; } + @Override protected Object configureValue(Object value) { if (value == null) { value = new FontUIResource(fontName, fontStyle, fontSize); @@ -2278,6 +2299,7 @@ private static class XPValue implements UIDefaults.ActiveValue { this.classicValue = classicValue; } + @Override public Object createValue(UIDefaults table) { Object value = null; if (XPStyle.getXP() != null) { @@ -2313,7 +2335,7 @@ private Object recursiveCreateValue(Object value, UIDefaults table) { } } - private static class XPBorderValue extends XPValue { + private static final class XPBorderValue extends XPValue { private final Border extraMargin; XPBorderValue(Part xpValue, Object classicValue) { @@ -2325,6 +2347,7 @@ private static class XPBorderValue extends XPValue { this.extraMargin = extraMargin; } + @Override public Object getXPValue(UIDefaults table) { XPStyle xp = XPStyle.getXP(); Border xpBorder = xp != null ? xp.getBorder(null, (Part)xpValue) : null; @@ -2337,18 +2360,19 @@ public Object getXPValue(UIDefaults table) { } } - private static class XPColorValue extends XPValue { + private static final class XPColorValue extends XPValue { XPColorValue(Part part, State state, Prop prop, Object classicValue) { super(new XPColorValueKey(part, state, prop), classicValue); } + @Override public Object getXPValue(UIDefaults table) { XPColorValueKey key = (XPColorValueKey)xpValue; XPStyle xp = XPStyle.getXP(); return xp != null ? xp.getColor(key.skin, key.prop, null) : null; } - private static class XPColorValueKey { + private static final class XPColorValueKey { Skin skin; Prop prop; @@ -2359,7 +2383,7 @@ private static class XPColorValueKey { } } - private class XPDLUValue extends XPValue { + private final class XPDLUValue extends XPValue { private int direction; XPDLUValue(int xpdlu, int classicdlu, int direction) { @@ -2367,11 +2391,13 @@ private class XPDLUValue extends XPValue { this.direction = direction; } + @Override public Object getXPValue(UIDefaults table) { int px = dluToPixels(((Integer)xpValue).intValue(), direction); return Integer.valueOf(px); } + @Override public Object getClassicValue(UIDefaults table) { int px = dluToPixels(((Integer)classicValue).intValue(), direction); return Integer.valueOf(px); @@ -2387,6 +2413,7 @@ private static class TriggerDesktopProperty extends WindowsDesktopProperty { getValueFromDesktop(); } + @Override protected void updateUI() { super.updateUI(); @@ -2395,11 +2422,12 @@ protected void updateUI() { } } - private static class FontDesktopProperty extends TriggerDesktopProperty { + private static final class FontDesktopProperty extends TriggerDesktopProperty { FontDesktopProperty(String key) { super(key); } + @Override protected void updateUI() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); SwingUtilities2.putAATextInfo(true, defaults); @@ -2410,7 +2438,7 @@ protected void updateUI() { // Windows LayoutStyle. From: // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp @SuppressWarnings("fallthrough") - private class WindowsLayoutStyle extends DefaultLayoutStyle { + private final class WindowsLayoutStyle extends DefaultLayoutStyle { @Override public int getPreferredGap(JComponent component1, JComponent component2, ComponentPlacement type, int position, @@ -2504,6 +2532,7 @@ private void calculateBaseUnits() { * * @since 1.6 */ + @Override public Icon getDisabledIcon(JComponent component, Icon icon) { // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY // client property set to Boolean.TRUE, then use the new @@ -2525,10 +2554,11 @@ public Icon getDisabledIcon(JComponent component, Icon icon) { return super.getDisabledIcon(component, icon); } - private static class RGBGrayFilter extends RGBImageFilter { + private static final class RGBGrayFilter extends RGBImageFilter { public RGBGrayFilter() { canFilterIndexColorModel = true; } + @Override public int filterRGB(int x, int y, int rgb) { // find the average of red, green, and blue float avg = (((rgb >> 16) & 0xff) / 255f + @@ -2547,7 +2577,7 @@ public int filterRGB(int x, int y, int rgb) { } } - private static class FocusColorProperty extends WindowsDesktopProperty { + private static final class FocusColorProperty extends WindowsDesktopProperty { public FocusColorProperty () { // Fallback value is never used because of the configureValue method doesn't return null super("win.3d.backgroundColor", Color.BLACK); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java index 8c6cbdff541..f663d8d1e90 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuBarUI.java @@ -57,7 +57,7 @@ /** * Windows rendition of the component. */ -public class WindowsMenuBarUI extends BasicMenuBarUI +public final class WindowsMenuBarUI extends BasicMenuBarUI { /* to be accessed on the EDT only */ private WindowListener windowListener = null; @@ -125,6 +125,7 @@ public void hierarchyChanged(HierarchyEvent e) { super.installListeners(); } + @Override protected void installKeyboardActions() { super.installKeyboardActions(); ActionMap map = SwingUtilities.getUIActionMap(menuBar); @@ -140,7 +141,7 @@ protected void installKeyboardActions() { * Unlike BasicMenuBarUI.TakeFocus, this Action will not show menu popup. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - private static class TakeFocus extends AbstractAction { + private static final class TakeFocus extends AbstractAction { @Override public void actionPerformed(ActionEvent e) { JMenuBar menuBar = (JMenuBar)e.getSource(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java index 2f76f929133..2ee1b2d119f 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java @@ -54,7 +54,7 @@ * * @author Igor Kushnirskiy */ -public class WindowsMenuItemUI extends BasicMenuItemUI { +public final class WindowsMenuItemUI extends BasicMenuItemUI { /** * The instance of {@code PropertyChangeListener}. */ @@ -63,6 +63,7 @@ public class WindowsMenuItemUI extends BasicMenuItemUI { final WindowsMenuItemUIAccessor accessor = new WindowsMenuItemUIAccessor() { + @Override public JMenuItem getMenuItem() { return menuItem; } @@ -71,6 +72,7 @@ public State getState(JMenuItem menuItem) { return WindowsMenuItemUI.getState(this, menuItem); } + @Override public Part getPart(JMenuItem menuItem) { return WindowsMenuItemUI.getPart(this, menuItem); } @@ -141,6 +143,7 @@ protected void uninstallListeners() { * @param textRect Bounding rectangle to render the text. * @param text String to render */ + @Override protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { if (WindowsMenuItemUI.isVistaPainting()) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java index 4195b4e85ca..5562ce60388 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java @@ -50,13 +50,14 @@ /** * Windows rendition of the component. */ -public class WindowsMenuUI extends BasicMenuUI { +public final class WindowsMenuUI extends BasicMenuUI { protected Integer menuBarHeight; protected boolean hotTrackingOn; final WindowsMenuItemUIAccessor accessor = new WindowsMenuItemUIAccessor() { + @Override public JMenuItem getMenuItem() { return menuItem; } @@ -106,6 +107,7 @@ public State getState(JMenuItem menu) { return state; } + @Override public Part getPart(JMenuItem menuItem) { return ((JMenu) menuItem).isTopLevelMenu() ? Part.MP_BARITEM : Part.MP_POPUPITEM; @@ -115,6 +117,7 @@ public static ComponentUI createUI(JComponent x) { return new WindowsMenuUI(); } + @Override protected void installDefaults() { super.installDefaults(); if (!WindowsLookAndFeel.isClassicWindows()) { @@ -131,6 +134,7 @@ protected void installDefaults() { * Draws the background of the menu. * @since 1.4 */ + @Override protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { if (WindowsMenuItemUI.isVistaPainting()) { WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor); @@ -210,6 +214,7 @@ protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { * @param text String to render * @since 1.4 */ + @Override protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { if (WindowsMenuItemUI.isVistaPainting()) { @@ -245,6 +250,7 @@ protected void paintText(Graphics g, JMenuItem menuItem, g.setColor(oldColor); } + @Override protected MouseInputListener createMouseInputListener(JComponent c) { return new WindowsMouseInputHandler(); } @@ -254,7 +260,8 @@ protected MouseInputListener createMouseInputListener(JComponent c) { * true when the mouse enters the menu and false when it exits. * @since 1.4 */ - protected class WindowsMouseInputHandler extends BasicMenuUI.MouseInputHandler { + protected final class WindowsMouseInputHandler extends BasicMenuUI.MouseInputHandler { + @Override public void mouseEntered(MouseEvent evt) { super.mouseEntered(evt); @@ -265,6 +272,7 @@ public void mouseEntered(MouseEvent evt) { } } + @Override public void mouseExited(MouseEvent evt) { super.mouseExited(evt); @@ -277,6 +285,7 @@ public void mouseExited(MouseEvent evt) { } } + @Override protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java index 2755cc76c96..5ced1659adf 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsOptionPaneUI.java @@ -30,5 +30,5 @@ /** * Windows rendition of the component. */ -public class WindowsOptionPaneUI extends BasicOptionPaneUI { +public final class WindowsOptionPaneUI extends BasicOptionPaneUI { } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java index baf0997ceff..1f64c18e61f 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPasswordFieldUI.java @@ -33,7 +33,7 @@ /** * Windows rendition of the component. */ -public class WindowsPasswordFieldUI extends BasicPasswordFieldUI { +public final class WindowsPasswordFieldUI extends BasicPasswordFieldUI { /** * Creates a UI for a JPasswordField @@ -54,6 +54,7 @@ public static ComponentUI createUI(JComponent c) { * * @return the caret object */ + @Override protected Caret createCaret() { return new WindowsTextUI.WindowsCaret(); } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java index ed31f00a89b..9d67278526a 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuSeparatorUI.java @@ -42,12 +42,13 @@ * @author Igor Kushnirskiy */ -public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { +public final class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { public static ComponentUI createUI(JComponent c) { return new WindowsPopupMenuSeparatorUI(); } + @Override public void paint(Graphics g, JComponent c) { Dimension s = c.getSize(); XPStyle xp = XPStyle.getXP(); @@ -82,6 +83,7 @@ public void paint(Graphics g, JComponent c) { } } + @Override public Dimension getPreferredSize(JComponent c) { int fontHeight = 0; Font font = c.getFont(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java index 3bf214aff37..4df236115fb 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupMenuUI.java @@ -57,7 +57,7 @@ * * @author Igor Kushnirskiy */ -public class WindowsPopupMenuUI extends BasicPopupMenuUI { +public final class WindowsPopupMenuUI extends BasicPopupMenuUI { static MnemonicListener mnemonicListener = null; static final Object GUTTER_OFFSET_KEY = @@ -67,6 +67,7 @@ public static ComponentUI createUI(JComponent c) { return new WindowsPopupMenuUI(); } + @Override public void installListeners() { super.installListeners(); if (! UIManager.getBoolean("Button.showMnemonics") && @@ -88,14 +89,16 @@ public void installListeners() { * @return Popup that will show the JPopupMenu * @since 1.4 */ + @Override public Popup getPopup(JPopupMenu popupMenu, int x, int y) { PopupFactory popupFactory = PopupFactory.getSharedInstance(); return popupFactory.getPopup(popupMenu.getInvoker(), popupMenu, x, y); } - static class MnemonicListener implements ChangeListener { + static final class MnemonicListener implements ChangeListener { JRootPane repaintRoot = null; + @Override public void stateChanged(ChangeEvent ev) { MenuSelectionManager msm = (MenuSelectionManager)ev.getSource(); MenuElement[] path = msm.getSelectedPath(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java index f23cb31dff0..b58ad07a57b 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java @@ -45,7 +45,7 @@ * @author Amy Fowler */ @SuppressWarnings("serial") // Superclass is not serializable across versions -class WindowsPopupWindow extends JWindow { +final class WindowsPopupWindow extends JWindow { static final int UNDEFINED_WINDOW_TYPE = 0; static final int TOOLTIP_WINDOW_TYPE = 1; @@ -69,10 +69,12 @@ int getWindowType() { return windowType; } + @Override public void update(Graphics g) { paint(g); } + @Override @SuppressWarnings("deprecation") public void hide() { super.hide(); @@ -85,6 +87,7 @@ public void hide() { removeNotify(); } + @Override @SuppressWarnings("deprecation") public void show() { super.show(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java index 790dc85166b..9cc7d277ff1 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java @@ -51,7 +51,7 @@ * * @author Michael C. Albers */ -public class WindowsProgressBarUI extends BasicProgressBarUI +public final class WindowsProgressBarUI extends BasicProgressBarUI { private Rectangle previousFullBox; @@ -62,6 +62,7 @@ public static ComponentUI createUI(JComponent x) { } + @Override protected void installDefaults() { super.installDefaults(); @@ -80,6 +81,7 @@ protected void installDefaults() { * @see javax.swing.JComponent#getBaseline(int, int) * @since 1.6 */ + @Override public int getBaseline(JComponent c, int width, int height) { int baseline = super.getBaseline(c, width, height); if (XPStyle.getXP() != null && progressBar.isStringPainted() && @@ -102,6 +104,7 @@ public int getBaseline(JComponent c, int width, int height) { return baseline; } + @Override protected Dimension getPreferredInnerHorizontal() { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -113,6 +116,7 @@ protected Dimension getPreferredInnerHorizontal() { return super.getPreferredInnerHorizontal(); } + @Override protected Dimension getPreferredInnerVertical() { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -124,6 +128,7 @@ protected Dimension getPreferredInnerVertical() { return super.getPreferredInnerVertical(); } + @Override protected void paintDeterminate(Graphics g, JComponent c) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -218,6 +223,7 @@ protected void paintDeterminate(Graphics g, JComponent c) { * {@inheritDoc} * @since 1.6 */ + @Override protected void setAnimationIndex(int newValue) { super.setAnimationIndex(newValue); XPStyle xp = XPStyle.getXP(); @@ -241,6 +247,7 @@ protected void setAnimationIndex(int newValue) { * {@inheritDoc} * @since 1.6 */ + @Override protected int getBoxLength(int availableLength, int otherDimension) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -253,6 +260,7 @@ protected int getBoxLength(int availableLength, int otherDimension) { * {@inheritDoc} * @since 1.6 */ + @Override protected Rectangle getBox(Rectangle r) { Rectangle rect = super.getBox(r); @@ -298,6 +306,7 @@ protected Rectangle getBox(Rectangle r) { } + @Override protected void paintIndeterminate(Graphics g, JComponent c) { XPStyle xp = XPStyle.getXP(); if (xp != null) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java index 584a0f1622b..f6f3d4f06d1 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java @@ -41,11 +41,12 @@ /** * Windows rendition of the component. */ -public class WindowsRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI { +public final class WindowsRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI { final WindowsMenuItemUIAccessor accessor = new WindowsMenuItemUIAccessor() { + @Override public JMenuItem getMenuItem() { return menuItem; } @@ -54,6 +55,7 @@ public State getState(JMenuItem menuItem) { return WindowsMenuItemUI.getState(this, menuItem); } + @Override public Part getPart(JMenuItem menuItem) { return WindowsMenuItemUI.getPart(this, menuItem); } @@ -81,6 +83,7 @@ protected void paintBackground(Graphics g, JMenuItem menuItem, * @param text String to render * @since 1.4 */ + @Override protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { if (WindowsMenuItemUI.isVistaPainting()) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java index dd0a93c95a1..8fdc1a315c9 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java @@ -73,6 +73,7 @@ public static ComponentUI createUI(JComponent c) { // ******************************** // Defaults // ******************************** + @Override public void installDefaults(AbstractButton b) { super.installDefaults(b); if(!initialized) { @@ -88,6 +89,7 @@ public void installDefaults(AbstractButton b) { } } + @Override protected void uninstallDefaults(AbstractButton b) { super.uninstallDefaults(b); initialized = false; @@ -104,11 +106,13 @@ protected Color getFocusColor() { /** * Overridden method to render the text without the mnemonic */ + @Override protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) { WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset()); } + @Override protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){ g.setColor(getFocusColor()); BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height); @@ -117,6 +121,7 @@ protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){ // ******************************** // Layout Methods // ******************************** + @Override public Dimension getPreferredSize(JComponent c) { Dimension d = super.getPreferredSize(c); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java index f05da909ac1..19bfad0a1da 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java @@ -70,7 +70,7 @@ * @author Mark Davidson * @since 1.4 */ -public class WindowsRootPaneUI extends BasicRootPaneUI { +public final class WindowsRootPaneUI extends BasicRootPaneUI { private static final WindowsRootPaneUI windowsRootPaneUI = new WindowsRootPaneUI(); static final AltProcessor altProcessor = new AltProcessor(); @@ -79,7 +79,7 @@ public static ComponentUI createUI(JComponent c) { return windowsRootPaneUI; } - static class AltProcessor implements KeyEventPostProcessor { + static final class AltProcessor implements KeyEventPostProcessor { static boolean altKeyPressed = false; static boolean menuCanceledOnPress = false; static JRootPane root = null; @@ -166,6 +166,7 @@ void altReleased(KeyEvent ev) { } + @Override public boolean postProcessKeyEvent(KeyEvent ev) { if (ev.isConsumed()) { if (ev.getKeyCode() != KeyEvent.VK_ALT) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java index a3dd04362b9..c8d62e52834 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollBarUI.java @@ -55,7 +55,7 @@ /** * Windows rendition of the component. */ -public class WindowsScrollBarUI extends BasicScrollBarUI { +public final class WindowsScrollBarUI extends BasicScrollBarUI { private Grid thumbGrid; private Grid highlightGrid; private Dimension horizontalThumbSize; @@ -71,6 +71,7 @@ public static ComponentUI createUI(JComponent c) { return new WindowsScrollBarUI(); } + @Override protected void installDefaults() { super.installDefaults(); @@ -100,11 +101,13 @@ protected Dimension getMinimumThumbSize() { : verticalThumbSize; } + @Override public void uninstallUI(JComponent c) { super.uninstallUI(c); thumbGrid = highlightGrid = null; } + @Override protected void configureScrollBarColors() { super.configureScrollBarColors(); Color color = UIManager.getColor("ScrollBar.trackForeground"); @@ -118,6 +121,7 @@ protected void configureScrollBarColors() { } } + @Override protected JButton createDecreaseButton(int orientation) { return new WindowsArrowButton(orientation, UIManager.getColor("ScrollBar.thumb"), @@ -126,6 +130,7 @@ protected JButton createDecreaseButton(int orientation) { UIManager.getColor("ScrollBar.thumbHighlight")); } + @Override protected JButton createIncreaseButton(int orientation) { return new WindowsArrowButton(orientation, UIManager.getColor("ScrollBar.thumb"), @@ -161,6 +166,7 @@ private void repaint() { } } + @Override protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds){ boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL); @@ -189,6 +195,7 @@ else if (trackHighlight == INCREASE_HIGHLIGHT) { } } + @Override protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL); @@ -231,6 +238,7 @@ protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { } + @Override protected void paintDecreaseHighlight(Graphics g) { if (highlightGrid == null) { super.paintDecreaseHighlight(g); @@ -257,6 +265,7 @@ protected void paintDecreaseHighlight(Graphics g) { } + @Override protected void paintIncreaseHighlight(Graphics g) { if (highlightGrid == null) { super.paintDecreaseHighlight(g); @@ -304,7 +313,7 @@ protected void setThumbRollover(boolean active) { * preferred size is always a square. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - private class WindowsArrowButton extends BasicArrowButton { + private final class WindowsArrowButton extends BasicArrowButton { public WindowsArrowButton(int direction, Color background, Color shadow, Color darkShadow, Color highlight) { @@ -315,6 +324,7 @@ public WindowsArrowButton(int direction) { super(direction); } + @Override public void paint(Graphics g) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -370,6 +380,7 @@ public void paint(Graphics g) { } } + @Override public Dimension getPreferredSize() { int size = 16; if (scrollbar != null) { @@ -398,7 +409,7 @@ public Dimension getPreferredSize() { * a WeakRef so that it can be freed when no longer needed. As the * Grid is rather expensive to draw, it is drawn in a BufferedImage. */ - private static class Grid { + private static final class Grid { private static final int BUFFER_SIZE = 64; private static HashMap> map; diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java index 6c89eabc894..393f7595402 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsScrollPaneUI.java @@ -30,5 +30,5 @@ /** * Windows rendition of the component. */ -public class WindowsScrollPaneUI extends BasicScrollPaneUI +public final class WindowsScrollPaneUI extends BasicScrollPaneUI {} diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java index 65526a40c1b..9ce5db3b4ef 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSeparatorUI.java @@ -30,4 +30,4 @@ /** * Windows Separator. */ -public class WindowsSeparatorUI extends BasicSeparatorUI { } +public final class WindowsSeparatorUI extends BasicSeparatorUI { } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java index ceaf878cbca..88dc91d572b 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSliderUI.java @@ -44,7 +44,7 @@ /** * Windows rendition of the component. */ -public class WindowsSliderUI extends BasicSliderUI +public final class WindowsSliderUI extends BasicSliderUI { private boolean rollover = false; private boolean pressed = false; @@ -63,32 +63,38 @@ public static ComponentUI createUI(JComponent b) { * the HOT, PRESSED, and FOCUSED states. * @since 1.6 */ + @Override protected TrackListener createTrackListener(JSlider slider) { return new WindowsTrackListener(); } - private class WindowsTrackListener extends TrackListener { + private final class WindowsTrackListener extends TrackListener { + @Override public void mouseMoved(MouseEvent e) { updateRollover(thumbRect.contains(e.getX(), e.getY())); super.mouseMoved(e); } + @Override public void mouseEntered(MouseEvent e) { updateRollover(thumbRect.contains(e.getX(), e.getY())); super.mouseEntered(e); } + @Override public void mouseExited(MouseEvent e) { updateRollover(false); super.mouseExited(e); } + @Override public void mousePressed(MouseEvent e) { updatePressed(thumbRect.contains(e.getX(), e.getY())); super.mousePressed(e); } + @Override public void mouseReleased(MouseEvent e) { updatePressed(false); super.mouseReleased(e); @@ -119,6 +125,7 @@ public void updateRollover(boolean newRollover) { } + @Override public void paintTrack(Graphics g) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -141,6 +148,7 @@ public void paintTrack(Graphics g) { } + @Override protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -149,6 +157,7 @@ protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, i super.paintMinorTickForHorizSlider(g, tickBounds, x); } + @Override protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -157,6 +166,7 @@ protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, i super.paintMajorTickForHorizSlider(g, tickBounds, x); } + @Override protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -165,6 +175,7 @@ protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, in super.paintMinorTickForVertSlider(g, tickBounds, y); } + @Override protected void paintMajorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -174,6 +185,7 @@ protected void paintMajorTickForVertSlider( Graphics g, Rectangle tickBounds, in } + @Override public void paintThumb(Graphics g) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -199,6 +211,7 @@ public void paintThumb(Graphics g) { } } + @Override protected Dimension getThumbSize() { XPStyle xp = XPStyle.getXP(); if (xp != null) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java index c17328e50cc..bad66ce3a04 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSpinnerUI.java @@ -37,7 +37,7 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin; -public class WindowsSpinnerUI extends BasicSpinnerUI { +public final class WindowsSpinnerUI extends BasicSpinnerUI { public static ComponentUI createUI(JComponent c) { return new WindowsSpinnerUI(); } @@ -46,6 +46,7 @@ public static ComponentUI createUI(JComponent c) { * {@inheritDoc} * @since 1.6 */ + @Override public void paint(Graphics g, JComponent c) { if (XPStyle.getXP() != null) { paintXPBackground(g, c); @@ -71,6 +72,7 @@ private void paintXPBackground(Graphics g, JComponent c) { skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state); } + @Override protected Component createPreviousButton() { if (XPStyle.getXP() != null) { JButton xpButton = new XPStyle.GlyphButton(spinner, Part.SPNP_DOWN); @@ -83,6 +85,7 @@ protected Component createPreviousButton() { return super.createPreviousButton(); } + @Override protected Component createNextButton() { if (XPStyle.getXP() != null) { JButton xpButton = new XPStyle.GlyphButton(spinner, Part.SPNP_UP); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java index 04eeb726f90..95062ef586f 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneDivider.java @@ -39,7 +39,7 @@ * @author Jeff Dinkins */ @SuppressWarnings("serial") // Superclass is not serializable across versions -public class WindowsSplitPaneDivider extends BasicSplitPaneDivider +public final class WindowsSplitPaneDivider extends BasicSplitPaneDivider { /** @@ -52,6 +52,7 @@ public WindowsSplitPaneDivider(BasicSplitPaneUI ui) { /** * Paints the divider. */ + @Override public void paint(Graphics g) { Color bgColor = (splitPane.hasFocus()) ? UIManager.getColor("SplitPane.shadow") : diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java index 9305e46c36f..8c50e391164 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsSplitPaneUI.java @@ -33,7 +33,7 @@ /** * Windows rendition of the component. */ -public class WindowsSplitPaneUI extends BasicSplitPaneUI +public final class WindowsSplitPaneUI extends BasicSplitPaneUI { public WindowsSplitPaneUI() { @@ -50,6 +50,7 @@ public static ComponentUI createUI(JComponent x) { /** * Creates the default divider. */ + @Override public BasicSplitPaneDivider createDefaultDivider() { return new WindowsSplitPaneDivider(this); } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java index 9b4e22102eb..86e2ee1fc52 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTabbedPaneUI.java @@ -48,7 +48,7 @@ /** * Windows rendition of the component. */ -public class WindowsTabbedPaneUI extends BasicTabbedPaneUI { +public final class WindowsTabbedPaneUI extends BasicTabbedPaneUI { /** * Keys to use for forward focus traversal when the JComponent is * managing focus. @@ -63,6 +63,7 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI { private boolean contentOpaque = true; + @Override @SuppressWarnings("deprecation") protected void installDefaults() { super.installDefaults(); @@ -82,6 +83,7 @@ protected void installDefaults() { tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys); } + @Override protected void uninstallDefaults() { // sets the focus forward and backward traversal keys to null // to restore the defaults @@ -94,6 +96,7 @@ public static ComponentUI createUI(JComponent c) { return new WindowsTabbedPaneUI(); } + @Override protected void setRolloverTab(int index) { // Rollover is only supported on XP if (XPStyle.getXP() != null) { @@ -119,6 +122,7 @@ protected void setRolloverTab(int index) { } } + @Override protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) { XPStyle xp = XPStyle.getXP(); if (xp != null && (contentOpaque || tabPane.isOpaque())) { @@ -155,6 +159,7 @@ protected void paintContentBorder(Graphics g, int tabPlacement, int selectedInde super.paintContentBorder(g, tabPlacement, selectedIndex); } + @Override protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected ) { if (XPStyle.getXP() == null) { @@ -162,6 +167,7 @@ protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, } } + @Override protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected ) { XPStyle xp = XPStyle.getXP(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java index 507990812cc..b670bd294b0 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTableHeaderUI.java @@ -50,13 +50,14 @@ import static com.sun.java.swing.plaf.windows.TMSchema.State; import static com.sun.java.swing.plaf.windows.XPStyle.Skin; -public class WindowsTableHeaderUI extends BasicTableHeaderUI { +public final class WindowsTableHeaderUI extends BasicTableHeaderUI { private TableCellRenderer originalHeaderRenderer; public static ComponentUI createUI(JComponent h) { return new WindowsTableHeaderUI(); } + @Override public void installUI(JComponent c) { super.installUI(c); @@ -68,6 +69,7 @@ public void installUI(JComponent c) { } } + @Override public void uninstallUI(JComponent c) { if (header.getDefaultRenderer() instanceof XPDefaultRenderer) { header.setDefaultRenderer(originalHeaderRenderer); @@ -84,7 +86,7 @@ protected void rolloverColumnUpdated(int oldColumn, int newColumn) { } @SuppressWarnings("serial") // JDK-implementation class - private class XPDefaultRenderer extends DefaultTableCellHeaderRenderer { + private final class XPDefaultRenderer extends DefaultTableCellHeaderRenderer { Skin skin; boolean isSelected, hasFocus, hasRollover; int column; @@ -93,6 +95,7 @@ private class XPDefaultRenderer extends DefaultTableCellHeaderRenderer { setHorizontalAlignment(LEADING); } + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { @@ -181,6 +184,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, return this; } + @Override public void paint(Graphics g) { Dimension size = getSize(); State state = State.NORMAL; @@ -227,7 +231,7 @@ public void paint(Graphics g) { * A border with an Icon at the middle of the top side. * Outer insets can be provided for this border. */ - private static class IconBorder implements Border, UIResource{ + private static final class IconBorder implements Border, UIResource{ private final Icon icon; private final int top; private final int left; @@ -246,12 +250,15 @@ public IconBorder(Icon icon, int top, int left, this.bottom = bottom; this.right = right; } + @Override public Insets getBorderInsets(Component c) { return new Insets(icon.getIconHeight() + top, left, bottom, right); } + @Override public boolean isBorderOpaque() { return false; } + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { icon.paintIcon(c, g, diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java index 6aca81225ea..e695d9f6708 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextAreaUI.java @@ -33,7 +33,7 @@ /** * Windows rendition of the component. */ -public class WindowsTextAreaUI extends BasicTextAreaUI { +public final class WindowsTextAreaUI extends BasicTextAreaUI { /** * Creates the object to use for a caret. By default an * instance of WindowsCaret is created. This method @@ -42,6 +42,7 @@ public class WindowsTextAreaUI extends BasicTextAreaUI { * * @return the caret object */ + @Override protected Caret createCaret() { return new WindowsTextUI.WindowsCaret(); } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java index be3e6276161..508d260895c 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextFieldUI.java @@ -62,7 +62,7 @@ * * @author Timothy Prinzing */ -public class WindowsTextFieldUI extends BasicTextFieldUI +public final class WindowsTextFieldUI extends BasicTextFieldUI { /** * Creates a UI for a JTextField. @@ -82,6 +82,7 @@ public static ComponentUI createUI(JComponent c) { * * @param g the graphics context */ + @Override protected void paintBackground(Graphics g) { super.paintBackground(g); } @@ -91,6 +92,7 @@ protected void paintBackground(Graphics g) { * * @return the caret */ + @Override protected Caret createCaret() { return new WindowsFieldCaret(); } @@ -100,7 +102,7 @@ protected Caret createCaret() { * DefaultCaret. */ @SuppressWarnings("serial") // Superclass is not serializable across versions - static class WindowsFieldCaret extends DefaultCaret implements UIResource { + static final class WindowsFieldCaret extends DefaultCaret implements UIResource { public WindowsFieldCaret() { super(); @@ -112,6 +114,7 @@ public WindowsFieldCaret() { * caret out into the field by about a quarter of * a field length if not visible. */ + @Override protected void adjustVisibility(Rectangle r) { SwingUtilities.invokeLater(new SafeScroller(r)); } @@ -121,16 +124,18 @@ protected void adjustVisibility(Rectangle r) { * * @return the painter */ + @Override protected Highlighter.HighlightPainter getSelectionPainter() { return WindowsTextUI.WindowsPainter; } - private class SafeScroller implements Runnable { + private final class SafeScroller implements Runnable { SafeScroller(Rectangle r) { this.r = r; } + @Override @SuppressWarnings("deprecation") public void run() { JTextField field = (JTextField) getComponent(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java index 372563f74f4..7858a1195e8 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextPaneUI.java @@ -33,7 +33,7 @@ /** * Windows rendition of the component. */ -public class WindowsTextPaneUI extends BasicTextPaneUI +public final class WindowsTextPaneUI extends BasicTextPaneUI { /** * Creates a UI for a JTextPane. @@ -53,6 +53,7 @@ public static ComponentUI createUI(JComponent c) { * * @return the caret object */ + @Override protected Caret createCaret() { return new WindowsTextUI.WindowsCaret(); } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java index b73b38385f2..89180ffdd5f 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTextUI.java @@ -55,6 +55,7 @@ public abstract class WindowsTextUI extends BasicTextUI { * * @return the caret object */ + @Override protected Caret createCaret() { return new WindowsCaret(); } @@ -64,20 +65,21 @@ protected Caret createCaret() { /* public */ @SuppressWarnings("serial") // Superclass is not serializable across versions - static class WindowsCaret extends DefaultCaret + static final class WindowsCaret extends DefaultCaret implements UIResource { /** * Gets the painter for the Highlighter. * * @return the painter */ + @Override protected Highlighter.HighlightPainter getSelectionPainter() { return WindowsTextUI.WindowsPainter; } } /* public */ - static class WindowsHighlightPainter extends + static final class WindowsHighlightPainter extends DefaultHighlighter.DefaultHighlightPainter { WindowsHighlightPainter(Color c) { super(c); @@ -94,6 +96,7 @@ static class WindowsHighlightPainter extends * @param bounds the bounding box for the highlight * @param c the editor */ + @Override @SuppressWarnings("deprecation") public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) { Rectangle alloc = bounds.getBounds(); @@ -167,6 +170,7 @@ else if (secondIsDot) { * @param view View painting for * @return region drawing occurred in */ + @Override public Shape paintLayer(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c, View view) { Color color = getColor(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java index feee0c0aaef..0f468fdf6b1 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java @@ -45,7 +45,7 @@ * * @author Jeff Dinkins */ -public class WindowsToggleButtonUI extends BasicToggleButtonUI +public final class WindowsToggleButtonUI extends BasicToggleButtonUI { protected int dashedRectGapX; protected int dashedRectGapY; @@ -73,6 +73,7 @@ public static ComponentUI createUI(JComponent b) { // ******************************** // Defaults // ******************************** + @Override protected void installDefaults(AbstractButton b) { super.installDefaults(b); if(!defaults_initialized) { @@ -93,6 +94,7 @@ protected void installDefaults(AbstractButton b) { } } + @Override protected void uninstallDefaults(AbstractButton b) { super.uninstallDefaults(b); defaults_initialized = false; @@ -112,6 +114,7 @@ protected Color getFocusColor() { private transient Color cachedBackgroundColor = null; private transient Color cachedHighlightColor = null; + @Override protected void paintButtonPressed(Graphics g, AbstractButton b) { if (XPStyle.getXP() == null && b.isContentAreaFilled()) { Color oldColor = g.getColor(); @@ -135,6 +138,7 @@ protected void paintButtonPressed(Graphics g, AbstractButton b) { } } + @Override public void paint(Graphics g, JComponent c) { if (XPStyle.getXP() != null) { WindowsButtonUI.paintXPButtonBackground(g, c); @@ -146,10 +150,12 @@ public void paint(Graphics g, JComponent c) { /** * Overridden method to render the text without the mnemonic */ + @Override protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) { WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset()); } + @Override protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { g.setColor(getFocusColor()); @@ -161,6 +167,7 @@ protected void paintFocus(Graphics g, AbstractButton b, // ******************************** // Layout Methods // ******************************** + @Override public Dimension getPreferredSize(JComponent c) { Dimension d = super.getPreferredSize(c); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java index ffd6daa3ad8..5350de9ae5c 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarSeparatorUI.java @@ -40,12 +40,13 @@ * * @author Mark Davidson */ -public class WindowsToolBarSeparatorUI extends BasicToolBarSeparatorUI { +public final class WindowsToolBarSeparatorUI extends BasicToolBarSeparatorUI { public static ComponentUI createUI( JComponent c ) { return new WindowsToolBarSeparatorUI(); } + @Override public Dimension getPreferredSize(JComponent c) { Dimension size = ((JToolBar.Separator)c).getSeparatorSize(); @@ -71,6 +72,7 @@ public Dimension getPreferredSize(JComponent c) { return size; } + @Override public Dimension getMaximumSize(JComponent c) { Dimension pref = getPreferredSize(c); if (((JSeparator)c).getOrientation() == SwingConstants.VERTICAL) { @@ -80,6 +82,7 @@ public Dimension getMaximumSize(JComponent c) { } } + @Override public void paint( Graphics g, JComponent c ) { boolean vertical = ((JSeparator)c).getOrientation() == SwingConstants.VERTICAL; Dimension size = c.getSize(); diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java index a34ce0cf6a5..68e077fa350 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsToolBarUI.java @@ -45,12 +45,13 @@ import static com.sun.java.swing.plaf.windows.TMSchema.Part; -public class WindowsToolBarUI extends BasicToolBarUI { +public final class WindowsToolBarUI extends BasicToolBarUI { public static ComponentUI createUI(JComponent c) { return new WindowsToolBarUI(); } + @Override protected void installDefaults() { if (XPStyle.getXP() != null) { setRolloverBorders(true); @@ -58,6 +59,7 @@ protected void installDefaults() { super.installDefaults(); } + @Override protected Border createRolloverBorder() { if (XPStyle.getXP() != null) { return new EmptyBorder(3, 3, 3, 3); @@ -66,6 +68,7 @@ protected Border createRolloverBorder() { } } + @Override protected Border createNonRolloverBorder() { if (XPStyle.getXP() != null) { return new EmptyBorder(3, 3, 3, 3); @@ -74,6 +77,7 @@ protected Border createNonRolloverBorder() { } } + @Override public void paint(Graphics g, JComponent c) { XPStyle xp = XPStyle.getXP(); if (xp != null) { @@ -88,6 +92,7 @@ public void paint(Graphics g, JComponent c) { * {@inheritDoc} * @since 1.6 */ + @Override protected Border getRolloverBorder(AbstractButton b) { XPStyle xp = XPStyle.getXP(); if (xp != null) { diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java index 5bef0e075a4..6ab2352641f 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java @@ -60,6 +60,7 @@ public static ComponentUI createUI( JComponent c ) * Ensures that the rows identified by beginRow through endRow are * visible. */ + @Override protected void ensureRowsAreVisible(int beginRow, int endRow) { if(tree != null && beginRow >= 0 && endRow < getRowCount(tree)) { Rectangle visRect = tree.getVisibleRect(); @@ -108,6 +109,7 @@ protected void ensureRowsAreVisible(int beginRow, int endRow) { * Returns the default cell renderer that is used to do the * stamping of each node. */ + @Override protected TreeCellRenderer createDefaultCellRenderer() { return new WindowsTreeCellRenderer(); } @@ -127,6 +129,7 @@ Skin getSkin(Component c) { return (xp != null) ? xp.getSkin(c, Part.TVP_GLYPH) : null; } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { Skin skin = getSkin(c); if (skin != null) { @@ -147,11 +150,13 @@ public void paintIcon(Component c, Graphics g, int x, int y) { g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE); } + @Override public int getIconWidth() { Skin skin = getSkin(null); return (skin != null) ? skin.getWidth() : SIZE; } + @Override public int getIconHeight() { Skin skin = getSkin(null); return (skin != null) ? skin.getHeight() : SIZE; @@ -162,11 +167,12 @@ public int getIconHeight() { * The plus sign button icon */ @SuppressWarnings("serial") // Superclass is not serializable across versions - public static class CollapsedIcon extends ExpandedIcon { + public static final class CollapsedIcon extends ExpandedIcon { public static Icon createCollapsedIcon() { return new CollapsedIcon(); } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { Skin skin = getSkin(c); if (skin != null) { @@ -179,7 +185,7 @@ public void paintIcon(Component c, Graphics g, int x, int y) { } @SuppressWarnings("serial") // Superclass is not serializable across versions - public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer { + public final class WindowsTreeCellRenderer extends DefaultTreeCellRenderer { /** * Configures the renderer based on the passed in components. @@ -189,6 +195,7 @@ public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer { * The foreground color is set based on the selection and the icon * is set based on on leaf and expanded. */ + @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java index f8f5e3628fb..89751f6dc94 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java @@ -90,7 +90,7 @@ * * @author Leif Samuelsson */ -class XPStyle { +final class XPStyle { // Singleton instance of this class private static XPStyle xp; @@ -331,6 +331,7 @@ private static class XPFillBorder extends LineBorder implements UIResource { super(color, thickness); } + @Override public Insets getBorderInsets(Component c, Insets insets) { Insets margin = null; // @@ -355,7 +356,7 @@ public Insets getBorderInsets(Component c, Insets insets) { } @SuppressWarnings("serial") // Superclass is not serializable across versions - private class XPStatefulFillBorder extends XPFillBorder { + private final class XPStatefulFillBorder extends XPFillBorder { private final Part part; private final Prop prop; XPStatefulFillBorder(Color color, int thickness, Part part, Prop prop) { @@ -364,6 +365,7 @@ private class XPStatefulFillBorder extends XPFillBorder { this.prop = prop; } + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { State state = State.NORMAL; // special casing for comboboxes. @@ -383,18 +385,20 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he } @SuppressWarnings("serial") // Superclass is not serializable across versions - private class XPImageBorder extends AbstractBorder implements UIResource { + private final class XPImageBorder extends AbstractBorder implements UIResource { Skin skin; XPImageBorder(Component c, Part part) { this.skin = getSkin(c, part); } + @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { skin.paintSkin(g, x, y, width, height, null); } + @Override public Insets getBorderInsets(Component c, Insets insets) { Insets margin = null; Insets borderInsets = skin.getContentMargin(); @@ -423,11 +427,12 @@ public Insets getBorderInsets(Component c, Insets insets) { } @SuppressWarnings("serial") // Superclass is not serializable across versions - private static class XPEmptyBorder extends EmptyBorder implements UIResource { + private static final class XPEmptyBorder extends EmptyBorder implements UIResource { XPEmptyBorder(Insets m) { super(m.top+2, m.left+2, m.bottom+2, m.right+2); } + @Override public Insets getBorderInsets(Component c, Insets insets) { insets = super.getBorderInsets(c, insets); @@ -494,7 +499,7 @@ long getThemeTransitionDuration(Component c, Part part, State stateFrom, * (component type) and which provides methods for painting backgrounds * and glyphs */ - static class Skin { + static final class Skin { final Component component; final Part part; final State state; @@ -566,14 +571,17 @@ int getHeight() { return getHeight((state != null) ? state : State.NORMAL); } + @Override public String toString() { return string; } + @Override public boolean equals(Object obj) { return (obj instanceof Skin && ((Skin)obj).string.equals(string)); } + @Override public int hashCode() { return string.hashCode(); } @@ -675,16 +683,18 @@ void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state, } } - private static class SkinPainter extends CachedPainter { + private static final class SkinPainter extends CachedPainter { SkinPainter() { super(30); flush(); } + @Override public void flush() { super.flush(); } + @Override protected void paintToImage(Component c, Image image, Graphics g, int w, int h, Object[] args) { Skin skin = (Skin)args[0]; @@ -717,6 +727,7 @@ protected void paintToImage(Component c, Image image, Graphics g, SunWritableRaster.markDirty(dbi); } + @Override protected Image createImage(Component c, int w, int h, GraphicsConfiguration config, Object[] args) { return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); @@ -737,6 +748,7 @@ public GlyphButton(Component parent, Part part) { setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); } + @Override @SuppressWarnings("deprecation") public boolean isFocusTraversable() { return false; @@ -754,6 +766,7 @@ protected State getState() { return state; } + @Override public void paintComponent(Graphics g) { if (XPStyle.getXP() == null || skin == null) { return; @@ -769,6 +782,7 @@ public void setPart(Component parent, Part part) { repaint(); } + @Override protected void paintBorder(Graphics g) { } diff --git a/src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java b/src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java index 642f98b0df2..c888106d779 100644 --- a/src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java +++ b/src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java @@ -30,7 +30,7 @@ import sun.awt.windows.WToolkit; -public class PlatformGraphicsInfo { +public final class PlatformGraphicsInfo { private static final boolean hasDisplays; diff --git a/src/java.desktop/windows/classes/sun/awt/Win32ColorModel24.java b/src/java.desktop/windows/classes/sun/awt/Win32ColorModel24.java index ec86bce8c69..fe55cacf833 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32ColorModel24.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32ColorModel24.java @@ -40,7 +40,7 @@ * in the reverse order from the base ComponentColorModel to match * the ordering on a Windows 24-bit display. */ -public class Win32ColorModel24 extends ComponentColorModel { +public final class Win32ColorModel24 extends ComponentColorModel { public Win32ColorModel24() { super(ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] {8, 8, 8}, false, false, @@ -53,6 +53,7 @@ public Win32ColorModel24() { * @see WritableRaster * @see SampleModel */ + @Override public WritableRaster createCompatibleWritableRaster (int w, int h) { int[] bOffs = {2, 1, 0}; return Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, @@ -65,6 +66,7 @@ public WritableRaster createCompatibleWritableRaster (int w, int h) { * has a data layout compatible with this ColorModel. * @see SampleModel */ + @Override public SampleModel createCompatibleSampleModel(int w, int h) { int[] bOffs = {2, 1, 0}; return new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, diff --git a/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java b/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java index c2532ff38b3..5084d0bcabe 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java @@ -70,6 +70,7 @@ public final class Win32FontManager extends SunFontManager { */ private static native String getEUDCFontFile(); + @Override public TrueTypeFont getEUDCFont() { return eudcFont; } @@ -88,6 +89,7 @@ public Win32FontManager() { * Whether registerFontFile expects absolute or relative * font file names. */ + @Override protected boolean useAbsoluteFontFileNames() { return false; } @@ -98,6 +100,7 @@ protected boolean useAbsoluteFontFileNames() { * class reports these back to the GraphicsEnvironment, so these * are the componentFileNames of CompositeFonts. */ + @Override protected void registerFontFile(String fontFileName, String[] nativeNames, int fontRank, boolean defer) { @@ -175,6 +178,7 @@ public FontConfiguration createFontConfiguration(boolean preferLocaleFonts, preferLocaleFonts,preferPropFonts); } + @Override protected void populateFontFileNameMap(HashMap fontToFileMap, HashMap fontToFamilyNameMap, @@ -194,6 +198,7 @@ public FontConfiguration createFontConfiguration(boolean preferLocaleFonts, familyToFontListMap, Locale locale); + @Override protected synchronized native String getFontPath(boolean noType1Fonts); @Override diff --git a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsConfig.java b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsConfig.java index 6e740de6a9b..31fc0847d3b 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsConfig.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsConfig.java @@ -214,6 +214,7 @@ public AffineTransform getNormalizingTransform() { return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0); } + @Override public String toString() { return (super.toString()+"[dev="+device+",pixfmt="+visual+"]"); } diff --git a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java index 973eb916a5c..865fe480853 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java @@ -590,7 +590,7 @@ public ColorModel getColorModel() { * The listener restores the default display mode when window is iconified * and sets it back to the one set by the user on de-iconification. */ - private static class Win32FSWindowAdapter extends WindowAdapter { + private static final class Win32FSWindowAdapter extends WindowAdapter { private Win32GraphicsDevice device; private DisplayMode dm; diff --git a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java index cb7ab363cdf..09768148f3d 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java @@ -92,9 +92,11 @@ public final class Win32GraphicsEnvironment extends SunGraphicsEnvironment { public Win32GraphicsEnvironment() { } + @Override protected native int getNumScreens(); private native int getDefaultScreen(); + @Override public GraphicsDevice getDefaultScreenDevice() { GraphicsDevice[] screens = getScreenDevices(); if (screens.length == 0) { @@ -207,6 +209,7 @@ public void displayChanged() { * ----END DISPLAY CHANGE SUPPORT---- */ + @Override protected GraphicsDevice makeScreenDevice(int screennum) { GraphicsDevice device = null; if (WindowsFlags.isD3DEnabled()) { @@ -218,6 +221,7 @@ protected GraphicsDevice makeScreenDevice(int screennum) { return device; } + @Override public boolean isDisplayLocal() { return true; } diff --git a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java index c85c2d4ced9..1777e408ea6 100644 --- a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java +++ b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java @@ -212,7 +212,7 @@ static final class KnownLibraries { static final List INSTANCE = getLibraries(); } - static class FolderDisposer implements sun.java2d.DisposerRecord { + static final class FolderDisposer implements sun.java2d.DisposerRecord { /* * This is cached as a concession to getFolderType(), which needs * an absolute PIDL. @@ -226,6 +226,7 @@ static class FolderDisposer implements sun.java2d.DisposerRecord { long relativePIDL; boolean disposed; + @Override public void dispose() { if (disposed) return; invoke(new Callable() { @@ -387,6 +388,7 @@ public void setIsPersonal() { * is a not a normal directory, then returns the first non-removable * drive (normally "C:\"). */ + @Override @Serial protected Object writeReplace() throws java.io.ObjectStreamException { return invoke(new Callable() { @@ -541,6 +543,7 @@ private static boolean pathsEqual(String path1, String path2) { /** * Check to see if two ShellFolder objects are the same */ + @Override public boolean equals(Object o) { if (!(o instanceof Win32ShellFolder2 rhs)) { // Short-circuit circuitous delegation path @@ -588,6 +591,7 @@ public Boolean call() { /** * @return Whether this is a file system shell folder */ + @Override public boolean isFileSystem() { if (cachedIsFileSystem == null) { cachedIsFileSystem = hasAttribute(ATTRIB_FILESYSTEM); @@ -682,10 +686,12 @@ private static boolean isNetworkRoot(String path) { * @return The parent shell folder of this shell folder, null if * there is no parent */ + @Override public File getParentFile() { return parent; } + @Override public boolean isDirectory() { if (isDir == null) { // Folders with SFGAO_BROWSABLE have "shell extension" handlers and are @@ -742,6 +748,7 @@ private native long getEnumObjects(long pIShellFolder, boolean isDesktop, * object. The array will be empty if the folder is empty. Returns * {@code null} if this shellfolder does not denote a directory. */ + @Override public File[] listFiles(final boolean includeHiddenFiles) { try { @@ -851,6 +858,7 @@ public Win32ShellFolder2 call() throws InterruptedException { * symbolic links and junctions. */ + @Override public boolean isLink() { if (cachedIsLink == null) { cachedIsLink = hasAttribute(ATTRIB_LINK) @@ -864,6 +872,7 @@ public boolean isLink() { /** * @return Whether this shell folder is marked as hidden */ + @Override public boolean isHidden() { return hasAttribute(ATTRIB_HIDDEN); } @@ -878,6 +887,7 @@ private static native long getLinkLocation(long parentIShellFolder, * @return The shell folder linked to by this shell folder, or null * if this shell folder is not a link or is a broken or invalid link */ + @Override public ShellFolder getLinkLocation() { return getLinkLocation(true); } @@ -933,6 +943,7 @@ private static native String getDisplayNameOf(long parentIShellFolder, /** * @return The name used to display this shell folder */ + @Override public String getDisplayName() { if (displayName == null) { displayName = @@ -953,6 +964,7 @@ public String call() { /** * @return The type of shell folder as a string */ + @Override public String getFolderType() { if (folderType == null) { final long absolutePIDL = getAbsolutePIDL(); @@ -972,6 +984,7 @@ public String call() { /** * @return The executable type as a string */ + @Override public String getExecutableType() { if (!isFileSystem()) { return null; @@ -1047,6 +1060,7 @@ private static Image makeIcon(long hIcon) { /** * @return The icon image used to display this shell folder */ + @Override public Image getIcon(final boolean getLargeIcon) { Image icon = getLargeIcon ? largeIcon : smallIcon; int size = getLargeIcon ? LARGE_ICON_SIZE : SMALL_ICON_SIZE; @@ -1140,6 +1154,7 @@ public Image call() { /** * @return The icon image of specified size used to display this shell folder */ + @Override public Image getIcon(int width, int height) { int size = Math.max(width, height); return invoke(() -> { @@ -1236,6 +1251,7 @@ static Image getShell32Icon(int iconID, int size) { * * @see java.io.File#getCanonicalFile */ + @Override public File getCanonicalFile() throws IOException { return this; } @@ -1252,6 +1268,7 @@ public boolean isSpecial() { * * @see sun.awt.shell.ShellFolder#compareTo(File) */ + @Override public int compareTo(File file2) { if (!(file2 instanceof Win32ShellFolder2)) { if (isFileSystem() && !isSpecial()) { @@ -1268,6 +1285,7 @@ public int compareTo(File file2) { private static final int LVCFMT_RIGHT = 1; private static final int LVCFMT_CENTER = 2; + @Override public ShellFolderColumnInfo[] getFolderColumns() { ShellFolder library = resolveLibrary(); if (library != null) return library.getFolderColumns(); @@ -1300,6 +1318,7 @@ public ShellFolderColumnInfo[] call() { }); } + @Override public Object getFolderColumnValue(final int column) { if(!isLibrary()) { ShellFolder library = resolveLibrary(); @@ -1342,6 +1361,7 @@ private ShellFolder resolveLibrary() { private static native int compareIDsByColumn(long pParentIShellFolder, long pidl1, long pidl2, int columnIdx); + @Override public void sortChildren(final List files) { // To avoid loads of synchronizations with Invoker and improve performance we // synchronize the whole code of the sort method once @@ -1354,7 +1374,7 @@ public Void call() { }); } - private static class ColumnComparator implements Comparator { + private static final class ColumnComparator implements Comparator { private final Win32ShellFolder2 shellFolder; private final int columnIdx; @@ -1365,6 +1385,7 @@ public ColumnComparator(Win32ShellFolder2 shellFolder, int columnIdx) { } // compares 2 objects within this folder by the specified column + @Override public int compare(final File o, final File o1) { Integer result = invoke(new Callable() { public Integer call() { @@ -1405,7 +1426,7 @@ public List call() throws Exception { }); } - static class MultiResolutionIconImage extends AbstractMultiResolutionImage { + static final class MultiResolutionIconImage extends AbstractMultiResolutionImage { final int baseSize; final Map resolutionVariants = new HashMap<>(); diff --git a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java index d8bb2146798..075e3d0db50 100644 --- a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java +++ b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java @@ -75,6 +75,7 @@ final class Win32ShellFolderManager2 extends ShellFolderManager { sun.awt.windows.WToolkit.loadLibraries(); } + @Override public ShellFolder createShellFolder(File file) throws FileNotFoundException { try { return createShellFolder(getDesktop(), file); @@ -264,6 +265,7 @@ static Win32ShellFolder2 getPersonal() { * * @return An Object matching the key string. */ + @Override public Object get(String key) { if (key.equals("fileChooserDefaultFolder")) { File file = getPersonal(); @@ -408,6 +410,7 @@ public Object get(String key) { * Does {@code dir} represent a "computer" such as a node on the network, or * "My Computer" on the desktop. */ + @Override public boolean isComputerNode(final File dir) { if (dir != null && dir == getDrives()) { return true; @@ -418,6 +421,7 @@ public boolean isComputerNode(final File dir) { } } + @Override public boolean isFileSystemRoot(File dir) { //Note: Removable drives don't "exist" but are listed in "My Computer" if (dir != null) { @@ -498,7 +502,7 @@ protected Invoker createInvoker() { return new ComInvoker(); } - private static class ComInvoker extends ThreadPoolExecutor implements ThreadFactory, ShellFolder.Invoker { + private static final class ComInvoker extends ThreadPoolExecutor implements ThreadFactory, ShellFolder.Invoker { private static Thread comThread; private ComInvoker() { @@ -512,6 +516,7 @@ private ComInvoker() { Runtime.getRuntime().addShutdownHook(t); } + @Override public synchronized Thread newThread(final Runnable task) { final Runnable comRun = new Runnable() { public void run() { @@ -539,6 +544,7 @@ leads to memory consumption when listDrives() function is called return comThread; } + @Override public T invoke(Callable task) throws Exception { if (Thread.currentThread() == comThread) { // if it's already called from the COM diff --git a/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java b/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java index 6b9d54aaa28..94a2c4df0a9 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java @@ -355,7 +355,7 @@ public void run() { } } - private static class VIOptD3DWindowPainter extends VIOptWindowPainter { + private static final class VIOptD3DWindowPainter extends VIOptWindowPainter { protected VIOptD3DWindowPainter(WWindowPeer peer) { super(peer); @@ -370,7 +370,7 @@ protected boolean updateWindowAccel(long psdops, int w, int h) { } } - private static class VIOptWGLWindowPainter extends VIOptWindowPainter { + private static final class VIOptWGLWindowPainter extends VIOptWindowPainter { protected VIOptWGLWindowPainter(WWindowPeer peer) { super(peer); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java index c07d116abfb..8b3218de667 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java @@ -789,6 +789,7 @@ public VolatileImage createVolatileImage(int width, int height) { // Object overrides + @Override public String toString() { return getClass().getName() + "[" + target + "]"; } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WDataTransferer.java b/src/java.desktop/windows/classes/sun/awt/windows/WDataTransferer.java index 8aca12d268f..068d577995f 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WDataTransferer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WDataTransferer.java @@ -541,7 +541,7 @@ public static EHTMLReadMode getEHTMLReadMode (DataFlavor df) { * * on encode: static convertToHTMLFormat is responsible for HTML clipboard header creation */ -class HTMLCodec extends InputStream { +final class HTMLCodec extends InputStream { public static final String VERSION = "Version:"; public static final String START_HTML = "StartHTML:"; diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WDefaultFontCharset.java b/src/java.desktop/windows/classes/sun/awt/windows/WDefaultFontCharset.java index 7632e172b73..09c317c81f2 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WDefaultFontCharset.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WDefaultFontCharset.java @@ -46,7 +46,7 @@ public CharsetEncoder newEncoder() { return new Encoder(); } - private class Encoder extends AWTCharset.Encoder { + private final class Encoder extends AWTCharset.Encoder { @Override public boolean canEncode(char c){ return canConvert(c); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WDesktopProperties.java b/src/java.desktop/windows/classes/sun/awt/windows/WDesktopProperties.java index d9b169160b4..6e3de090ee8 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WDesktopProperties.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WDesktopProperties.java @@ -198,7 +198,7 @@ private synchronized void setSoundProperty(String key, String winEventName) { */ private native void playWindowsSound(String winEventName); - class WinPlaySound implements Runnable { + final class WinPlaySound implements Runnable { String winEventName; WinPlaySound(String winEventName) { @@ -210,10 +210,12 @@ public void run() { WDesktopProperties.this.playWindowsSound(winEventName); } + @Override public String toString() { return "WinPlaySound("+winEventName+")"; } + @Override public boolean equals(Object o) { if (o == this) { return true; @@ -225,6 +227,7 @@ public boolean equals(Object o) { } } + @Override public int hashCode() { return winEventName.hashCode(); } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WDragSourceContextPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WDragSourceContextPeer.java index f4ab5fe0a34..43a91c3c7ab 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WDragSourceContextPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WDragSourceContextPeer.java @@ -54,9 +54,11 @@ */ final class WDragSourceContextPeer extends SunDragSourceContextPeer { + @Override public void startSecondaryEventLoop(){ WToolkit.startSecondaryEventLoop(); } + @Override public void quitSecondaryEventLoop(){ WToolkit.quitSecondaryEventLoop(); } @@ -168,6 +170,7 @@ native void doDragDrop( int imgWidth, int imgHight, int offsetX, int offsetY); + @Override protected native void setNativeCursor(long nativeCtxt, Cursor c, int cType); } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java b/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java index e5db1d432cf..ad0745a2733 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java @@ -36,7 +36,7 @@ import java.awt.peer.FramePeer; @SuppressWarnings("serial") // JDK-implementation class -public class WEmbeddedFrame extends EmbeddedFrame { +public final class WEmbeddedFrame extends EmbeddedFrame { static { initIDs(); @@ -79,6 +79,7 @@ public WEmbeddedFrame(long handle) { } } + @Override public void addNotify() { if (!isDisplayable()) { WToolkit toolkit = (WToolkit)Toolkit.getDefaultToolkit(); @@ -224,6 +225,7 @@ private native void printBand(long hdc, byte[] data, int offset, int sx, public void activateEmbeddingTopLevel() { } + @Override public void synthesizeWindowActivation(final boolean activate) { final FramePeer peer = AWTAccessor.getComponentAccessor().getPeer(this); if (!activate || EventQueue.isDispatchThread()) { @@ -241,7 +243,9 @@ public void run() { } } + @Override public void registerAccelerator(AWTKeyStroke stroke) {} + @Override public void unregisterAccelerator(AWTKeyStroke stroke) {} /** @@ -256,6 +260,7 @@ public void unregisterAccelerator(AWTKeyStroke stroke) {} * NOTE: This method may be called by privileged threads. * DO NOT INVOKE CLIENT CODE ON THIS THREAD! */ + @Override public void notifyModalBlocked(Dialog blocker, boolean blocked) { try { ComponentPeer thisPeer = (ComponentPeer)WToolkit.targetToPeer(this); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java index 4d5219cf34e..bab79c38ff4 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFramePeer.java @@ -32,7 +32,7 @@ import sun.awt.EmbeddedFrame; import sun.awt.Win32GraphicsEnvironment; -public class WEmbeddedFramePeer extends WFramePeer { +public final class WEmbeddedFramePeer extends WFramePeer { public WEmbeddedFramePeer(EmbeddedFrame target) { super(target); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WLabelPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WLabelPeer.java index 259329d4f6d..c5267e52793 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WLabelPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WLabelPeer.java @@ -31,6 +31,7 @@ final class WLabelPeer extends WComponentPeer implements LabelPeer { // ComponentPeer overrides + @Override public Dimension getMinimumSize() { FontMetrics fm = getFontMetrics(((Label)target).getFont()); String label = ((Label)target).getText(); @@ -40,6 +41,7 @@ public Dimension getMinimumSize() { } native void lazyPaint(); + @Override synchronized void start() { super.start(); // if need then paint label @@ -47,11 +49,14 @@ synchronized void start() { } // LabelPeer implementation + @Override public boolean shouldClearRectBeforePaint() { return false; } + @Override public native void setText(String label); + @Override public native void setAlignment(int alignment); // Toolkit & peer internals @@ -60,8 +65,10 @@ public boolean shouldClearRectBeforePaint() { super(target); } + @Override native void create(WComponentPeer parent); + @Override void initialize() { Label l = (Label)target; diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WLightweightFramePeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WLightweightFramePeer.java index ff77a5c188c..994b81e372e 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WLightweightFramePeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WLightweightFramePeer.java @@ -36,7 +36,7 @@ import sun.swing.JLightweightFrame; import sun.swing.SwingAccessor; -public class WLightweightFramePeer extends WFramePeer implements OverrideNativeWindowHandle { +public final class WLightweightFramePeer extends WFramePeer implements OverrideNativeWindowHandle { public WLightweightFramePeer(LightweightFrame target) { super(target); @@ -100,6 +100,7 @@ public void updateCursorImmediately() { SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget()); } + @Override public boolean isLightweightFramePeer() { return true; } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java index 43d4d2b907a..f2961f79a04 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java @@ -46,11 +46,13 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { // MenuItemPeer implementation private synchronized native void _dispose(); + @Override protected void disposeImpl() { WToolkit.targetDisposedPeer(target, this); _dispose(); } + @Override public void setEnabled(boolean b) { enable(b); } @@ -69,6 +71,7 @@ private void readShortcutLabel() { } } + @Override public void setLabel(String label) { //Fix for 6288578: PIT. Windows: Shortcuts displayed for the menuitems in a popup menu readShortcutLabel(); @@ -165,6 +168,7 @@ static Font getDefaultFont() { private native void _setFont(Font f); + @Override public void setFont(final Font f) { _setFont(f); } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WMouseInfoPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WMouseInfoPeer.java index e5bef4fe1b9..4b785aaba69 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WMouseInfoPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WMouseInfoPeer.java @@ -43,8 +43,10 @@ public final class WMouseInfoPeer implements MouseInfoPeer { WMouseInfoPeer() { } + @Override public native int fillPointWithCoords(Point point); + @Override public native boolean isWindowUnderMouse(Window w); } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java index 69b62325670..d89cbcfa53a 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WPopupMenuPeer.java @@ -70,6 +70,7 @@ final class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer { private native void createMenu(WComponentPeer parent); + @Override @SuppressWarnings("deprecation") public void show(Event e) { Component origin = (Component)e.target; diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java b/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java index d7efc54ffd4..e50cfcff33b 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java @@ -264,7 +264,7 @@ public final class WPrinterJob extends RasterPrinterJob /* The HandleRecord holds the native resources that need to be freed * when this WPrinterJob is GC'd. */ - static class HandleRecord implements DisposerRecord { + static final class HandleRecord implements DisposerRecord { /** * The Windows device context we will print into. * This variable is set after the Print dialog @@ -2269,7 +2269,7 @@ private void setPrinterNameAttrib(String printerName) { } @SuppressWarnings("serial") // JDK-implementation class -static class PrintToFileErrorDialog extends Dialog implements ActionListener { +static final class PrintToFileErrorDialog extends Dialog implements ActionListener { public PrintToFileErrorDialog(Frame parent, String title, String message, String buttonText) { super(parent, title, true); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java index e305654d91f..3a0d7bf3a71 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java @@ -167,7 +167,7 @@ private void postScrollEvent(int orient, int type, * operation. */ @SuppressWarnings("serial") // JDK-implementation class - static class ScrollEvent extends PeerEvent { + static final class ScrollEvent extends PeerEvent { ScrollEvent(Object source, Runnable runnable) { super(source, runnable, 0L); } @@ -187,7 +187,7 @@ public PeerEvent coalesceEvents(PeerEvent newEvent) { /* * Runnable for the ScrollEvent that performs the adjustment. */ - class Adjustor implements Runnable { + final class Adjustor implements Runnable { int orient; // selects scrollbar int type; // adjustment type int pos; // new position (only used for absolute) diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WScrollbarPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WScrollbarPeer.java index 055f2523cea..cfc227d29d6 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WScrollbarPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WScrollbarPeer.java @@ -35,6 +35,7 @@ final class WScrollbarPeer extends WComponentPeer implements ScrollbarPeer { static native int getScrollbarSize(int orientation); // ComponentPeer overrides + @Override public Dimension getMinimumSize() { if (((Scrollbar)target).getOrientation() == Scrollbar.VERTICAL) { return new Dimension(getScrollbarSize(Scrollbar.VERTICAL), 50); @@ -46,9 +47,12 @@ public Dimension getMinimumSize() { // ScrollbarPeer implementation + @Override public native void setValues(int value, int visible, int minimum, int maximum); + @Override public native void setLineIncrement(int l); + @Override public native void setPageIncrement(int l); @@ -58,8 +62,10 @@ public native void setValues(int value, int visible, super(target); } + @Override native void create(WComponentPeer parent); + @Override void initialize() { Scrollbar sb = (Scrollbar)target; setValues(sb.getValue(), sb.getVisibleAmount(), @@ -136,6 +142,7 @@ public void run() { }); } + @Override public boolean shouldClearRectBeforePaint() { return false; } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java index e151a69a0f1..0fdc4c6005b 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java @@ -186,7 +186,7 @@ public static void loadLibraries() { } } - static class ToolkitDisposer implements sun.java2d.DisposerRecord { + static final class ToolkitDisposer implements sun.java2d.DisposerRecord { @Override public void dispose() { WToolkit.postDispose(); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java index 90fbd880446..d6c311d3f48 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WTrayIconPeer.java @@ -199,7 +199,7 @@ native void setNativeIcon(int[] rData, byte[] andMask, int nScanStride, native void _displayMessage(String caption, String text, String messageType); - class IconObserver implements ImageObserver { + final class IconObserver implements ImageObserver { @Override public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) { if (image != ((TrayIcon)target).getImage() || // if the image has been changed diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java index 997db36beac..0ba2217dde5 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java @@ -849,7 +849,7 @@ private static void initActiveWindowsTracking(Window w) { * it removes the list of the active windows from the disposed AppContext and * unregisters ActiveWindowListener listener. */ - private static class GuiDisposedListener implements PropertyChangeListener { + private static final class GuiDisposedListener implements PropertyChangeListener { @Override public void propertyChange(PropertyChangeEvent e) { boolean isDisposed = (Boolean)e.getNewValue(); @@ -875,7 +875,7 @@ public void propertyChange(PropertyChangeEvent e) { * window is always at the end of the list. The list is stored in AppContext. */ @SuppressWarnings("unchecked") - private static class ActiveWindowListener implements PropertyChangeListener { + private static final class ActiveWindowListener implements PropertyChangeListener { @Override public void propertyChange(PropertyChangeEvent e) { Window w = (Window)e.getNewValue(); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WingDings.java b/src/java.desktop/windows/classes/sun/awt/windows/WingDings.java index 55c5236594c..ae7573ac4e2 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WingDings.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WingDings.java @@ -52,7 +52,7 @@ public boolean contains(Charset cs) { return cs instanceof WingDings; } - private static class Encoder extends CharsetEncoder { + private static final class Encoder extends CharsetEncoder { public Encoder(Charset cs) { super(cs, 1.0f, 1.0f); } diff --git a/src/java.desktop/windows/classes/sun/font/NativeFont.java b/src/java.desktop/windows/classes/sun/font/NativeFont.java index 7a5c29c7c73..9b0e6492d67 100644 --- a/src/java.desktop/windows/classes/sun/font/NativeFont.java +++ b/src/java.desktop/windows/classes/sun/font/NativeFont.java @@ -37,7 +37,7 @@ * and the font is ignored. */ -public class NativeFont extends PhysicalFont { +public final class NativeFont extends PhysicalFont { /** * Verifies native font is accessible. @@ -53,6 +53,7 @@ static boolean hasExternalBitmaps(String platName) { return false; } + @Override public CharToGlyphMapper getMapper() { return null; } @@ -61,6 +62,7 @@ PhysicalFont getDelegateFont() { return null; } + @Override FontStrike createStrike(FontStrikeDesc desc) { return null; } @@ -69,16 +71,19 @@ public Rectangle2D getMaxCharBounds(FontRenderContext frc) { return null; } + @Override StrikeMetrics getFontMetrics(long pScalerContext) { return null; } + @Override public GeneralPath getGlyphOutline(long pScalerContext, int glyphCode, float x, float y) { return null; } + @Override public GeneralPath getGlyphVectorOutline(long pScalerContext, int[] glyphs, int numGlyphs, float x, float y) { @@ -86,20 +91,24 @@ public GeneralPath getGlyphVectorOutline(long pScalerContext, } + @Override long getGlyphImage(long pScalerContext, int glyphCode) { return 0L; } + @Override void getGlyphMetrics(long pScalerContext, int glyphCode, Point2D.Float metrics) { } + @Override float getGlyphAdvance(long pScalerContext, int glyphCode) { return 0f; } + @Override Rectangle2D.Float getGlyphOutlineBounds(long pScalerContext, int glyphCode) { return new Rectangle2D.Float(0f, 0f, 0f, 0f); diff --git a/src/java.desktop/windows/classes/sun/font/NativeStrike.java b/src/java.desktop/windows/classes/sun/font/NativeStrike.java index a28c47911ed..7b2b947d722 100644 --- a/src/java.desktop/windows/classes/sun/font/NativeStrike.java +++ b/src/java.desktop/windows/classes/sun/font/NativeStrike.java @@ -48,9 +48,11 @@ public class NativeStrike extends PhysicalStrike { } + @Override void getGlyphImagePtrs(int[] glyphCodes, long[] images,int len) { } + @Override long getGlyphImagePtr(int glyphCode) { return 0L; } @@ -59,26 +61,32 @@ long getGlyphImagePtrNoCache(int glyphCode) { return 0L; } + @Override void getGlyphImageBounds(int glyphcode, Point2D.Float pt, Rectangle result) { } + @Override Point2D.Float getGlyphMetrics(int glyphCode) { return null; } + @Override float getGlyphAdvance(int glyphCode) { return 0f; } + @Override Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) { return null; } + @Override GeneralPath getGlyphOutline(int glyphCode, float x, float y) { return null; } + @Override GeneralPath getGlyphVectorOutline(int[] glyphs, float x, float y) { return null; } diff --git a/src/java.desktop/windows/classes/sun/java2d/WindowsSurfaceManagerFactory.java b/src/java.desktop/windows/classes/sun/java2d/WindowsSurfaceManagerFactory.java index 4512492350d..4abb8c823f6 100644 --- a/src/java.desktop/windows/classes/sun/java2d/WindowsSurfaceManagerFactory.java +++ b/src/java.desktop/windows/classes/sun/java2d/WindowsSurfaceManagerFactory.java @@ -38,7 +38,7 @@ * The SurfaceManagerFactory that creates VolatileSurfaceManager * implementations for the Windows volatile images. */ -public class WindowsSurfaceManagerFactory extends SurfaceManagerFactory { +public final class WindowsSurfaceManagerFactory extends SurfaceManagerFactory { /** * Creates a new instance of a VolatileSurfaceManager given any @@ -49,6 +49,7 @@ public class WindowsSurfaceManagerFactory extends SurfaceManagerFactory { * For Windows platforms, this method returns a Windows-specific * VolatileSurfaceManager. */ + @Override public VolatileSurfaceManager createVolatileManager(SunVolatileImage vImg, Object context) { diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DBlitLoops.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DBlitLoops.java index 8f4da91eef2..9aa9837b191 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DBlitLoops.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DBlitLoops.java @@ -358,7 +358,7 @@ static void IsoBlit(SurfaceData srcData, SurfaceData dstData, } } -class D3DSurfaceToSurfaceBlit extends Blit { +final class D3DSurfaceToSurfaceBlit extends Blit { D3DSurfaceToSurfaceBlit() { super(D3DSurfaceData.D3DSurface, @@ -366,6 +366,7 @@ class D3DSurfaceToSurfaceBlit extends Blit { D3DSurfaceData.D3DSurface); } + @Override public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) @@ -380,7 +381,7 @@ public void Blit(SurfaceData src, SurfaceData dst, } } -class D3DSurfaceToSurfaceScale extends ScaledBlit { +final class D3DSurfaceToSurfaceScale extends ScaledBlit { D3DSurfaceToSurfaceScale() { super(D3DSurfaceData.D3DSurface, @@ -388,6 +389,7 @@ class D3DSurfaceToSurfaceScale extends ScaledBlit { D3DSurfaceData.D3DSurface); } + @Override public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, @@ -405,7 +407,7 @@ public void Scale(SurfaceData src, SurfaceData dst, } } -class D3DSurfaceToSurfaceTransform extends TransformBlit { +final class D3DSurfaceToSurfaceTransform extends TransformBlit { D3DSurfaceToSurfaceTransform() { super(D3DSurfaceData.D3DSurface, @@ -413,6 +415,7 @@ class D3DSurfaceToSurfaceTransform extends TransformBlit { D3DSurfaceData.D3DSurface); } + @Override public void Transform(SurfaceData src, SurfaceData dst, Composite comp, Region clip, AffineTransform at, int hint, @@ -428,7 +431,7 @@ public void Transform(SurfaceData src, SurfaceData dst, } } -class D3DRTTSurfaceToSurfaceBlit extends Blit { +final class D3DRTTSurfaceToSurfaceBlit extends Blit { D3DRTTSurfaceToSurfaceBlit() { super(D3DSurfaceData.D3DSurfaceRTT, @@ -436,6 +439,7 @@ class D3DRTTSurfaceToSurfaceBlit extends Blit { D3DSurfaceData.D3DSurface); } + @Override public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) @@ -450,7 +454,7 @@ public void Blit(SurfaceData src, SurfaceData dst, } } -class D3DRTTSurfaceToSurfaceScale extends ScaledBlit { +final class D3DRTTSurfaceToSurfaceScale extends ScaledBlit { D3DRTTSurfaceToSurfaceScale() { super(D3DSurfaceData.D3DSurfaceRTT, @@ -458,6 +462,7 @@ class D3DRTTSurfaceToSurfaceScale extends ScaledBlit { D3DSurfaceData.D3DSurface); } + @Override public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, @@ -475,7 +480,7 @@ public void Scale(SurfaceData src, SurfaceData dst, } } -class D3DRTTSurfaceToSurfaceTransform extends TransformBlit { +final class D3DRTTSurfaceToSurfaceTransform extends TransformBlit { D3DRTTSurfaceToSurfaceTransform() { super(D3DSurfaceData.D3DSurfaceRTT, @@ -483,6 +488,7 @@ class D3DRTTSurfaceToSurfaceTransform extends TransformBlit { D3DSurfaceData.D3DSurface); } + @Override public void Transform(SurfaceData src, SurfaceData dst, Composite comp, Region clip, AffineTransform at, int hint, @@ -497,7 +503,7 @@ public void Transform(SurfaceData src, SurfaceData dst, } } -class D3DSurfaceToSwBlit extends Blit { +final class D3DSurfaceToSwBlit extends Blit { private int typeval; private WeakReference srcTmp; @@ -567,6 +573,7 @@ private synchronized void complexClipBlit(SurfaceData src, SurfaceData dst, } } + @Override public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, @@ -629,7 +636,7 @@ public void Blit(SurfaceData src, SurfaceData dst, } } -class D3DSwToSurfaceBlit extends Blit { +final class D3DSwToSurfaceBlit extends Blit { private int typeval; @@ -640,6 +647,7 @@ class D3DSwToSurfaceBlit extends Blit { this.typeval = typeval; } + @Override public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) @@ -653,7 +661,7 @@ public void Blit(SurfaceData src, SurfaceData dst, } } -class D3DSwToSurfaceScale extends ScaledBlit { +final class D3DSwToSurfaceScale extends ScaledBlit { private int typeval; @@ -664,6 +672,7 @@ class D3DSwToSurfaceScale extends ScaledBlit { this.typeval = typeval; } + @Override public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, @@ -680,7 +689,7 @@ public void Scale(SurfaceData src, SurfaceData dst, } } -class D3DSwToSurfaceTransform extends TransformBlit { +final class D3DSwToSurfaceTransform extends TransformBlit { private int typeval; @@ -691,6 +700,7 @@ class D3DSwToSurfaceTransform extends TransformBlit { this.typeval = typeval; } + @Override public void Transform(SurfaceData src, SurfaceData dst, Composite comp, Region clip, AffineTransform at, int hint, @@ -704,7 +714,7 @@ public void Transform(SurfaceData src, SurfaceData dst, } } -class D3DSwToTextureBlit extends Blit { +final class D3DSwToTextureBlit extends Blit { private int typeval; @@ -715,6 +725,7 @@ class D3DSwToTextureBlit extends Blit { this.typeval = typeval; } + @Override public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) @@ -728,7 +739,7 @@ public void Blit(SurfaceData src, SurfaceData dst, } } -class D3DTextureToSurfaceBlit extends Blit { +final class D3DTextureToSurfaceBlit extends Blit { D3DTextureToSurfaceBlit() { super(D3DSurfaceData.D3DTexture, @@ -736,6 +747,7 @@ class D3DTextureToSurfaceBlit extends Blit { D3DSurfaceData.D3DSurface); } + @Override public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) @@ -750,7 +762,7 @@ public void Blit(SurfaceData src, SurfaceData dst, } } -class D3DTextureToSurfaceScale extends ScaledBlit { +final class D3DTextureToSurfaceScale extends ScaledBlit { D3DTextureToSurfaceScale() { super(D3DSurfaceData.D3DTexture, @@ -758,6 +770,7 @@ class D3DTextureToSurfaceScale extends ScaledBlit { D3DSurfaceData.D3DSurface); } + @Override public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, @@ -775,7 +788,7 @@ public void Scale(SurfaceData src, SurfaceData dst, } } -class D3DTextureToSurfaceTransform extends TransformBlit { +final class D3DTextureToSurfaceTransform extends TransformBlit { D3DTextureToSurfaceTransform() { super(D3DSurfaceData.D3DTexture, @@ -783,6 +796,7 @@ class D3DTextureToSurfaceTransform extends TransformBlit { D3DSurfaceData.D3DSurface); } + @Override public void Transform(SurfaceData src, SurfaceData dst, Composite comp, Region clip, AffineTransform at, int hint, @@ -804,7 +818,7 @@ public void Transform(SurfaceData src, SurfaceData dst, * IntArgbPre->D3DSurface/Texture loop to get the intermediate * (premultiplied) surface down to D3D using simple blit. */ -class D3DGeneralBlit extends Blit { +final class D3DGeneralBlit extends Blit { private final Blit performop; private WeakReference srcTmp; @@ -817,6 +831,7 @@ class D3DGeneralBlit extends Blit { this.performop = performop; } + @Override public synchronized void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, @@ -917,7 +932,7 @@ public synchronized void Transform(SurfaceData src, SurfaceData dst, * */ -class D3DSurfaceToGDIWindowSurfaceBlit extends Blit { +final class D3DSurfaceToGDIWindowSurfaceBlit extends Blit { D3DSurfaceToGDIWindowSurfaceBlit() { super(D3DSurfaceData.D3DSurface, @@ -935,7 +950,7 @@ public void Blit(SurfaceData src, SurfaceData dst, } -class D3DSurfaceToGDIWindowSurfaceScale extends ScaledBlit { +final class D3DSurfaceToGDIWindowSurfaceScale extends ScaledBlit { D3DSurfaceToGDIWindowSurfaceScale() { super(D3DSurfaceData.D3DSurface, @@ -955,7 +970,7 @@ public void Scale(SurfaceData src, SurfaceData dst, } } -class D3DSurfaceToGDIWindowSurfaceTransform extends TransformBlit { +final class D3DSurfaceToGDIWindowSurfaceTransform extends TransformBlit { D3DSurfaceToGDIWindowSurfaceTransform() { super(D3DSurfaceData.D3DSurface, diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DBufImgOps.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DBufImgOps.java index 890bb87d66b..7ca0130391b 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DBufImgOps.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DBufImgOps.java @@ -37,7 +37,7 @@ import sun.java2d.pipe.BufferedBufImgOps; import static sun.java2d.d3d.D3DContext.D3DContextCaps.*; -class D3DBufImgOps extends BufferedBufImgOps { +final class D3DBufImgOps extends BufferedBufImgOps { /** * This method is called from D3DDrawImage.transformImage() only. It diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DContext.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DContext.java index 055e636bb69..5d9b6c30b5b 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DContext.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DContext.java @@ -106,7 +106,7 @@ D3DGraphicsDevice getDevice() { return device; } - static class D3DContextCaps extends ContextCapabilities { + static final class D3DContextCaps extends ContextCapabilities { /** * Indicates the presence of pixel shaders (v2.0 or greater). * This cap will only be set if the hardware supports the minimum number diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DDrawImage.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DDrawImage.java index f814dc2f613..e847c7ba7cd 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DDrawImage.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DDrawImage.java @@ -37,7 +37,7 @@ import sun.java2d.loops.TransformBlit; import sun.java2d.pipe.DrawImage; -public class D3DDrawImage extends DrawImage { +public final class D3DDrawImage extends DrawImage { @Override protected void renderImageXform(SunGraphics2D sg, Image img, diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java index 53d64017a3e..aab6b720d6a 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsConfig.java @@ -223,7 +223,7 @@ public void flip(WComponentPeer peer, } } - private static class D3DBufferCaps extends BufferCapabilities { + private static final class D3DBufferCaps extends BufferCapabilities { public D3DBufferCaps() { // REMIND: should we indicate that the front-buffer // (the on-screen rendering) is not accelerated? @@ -244,7 +244,7 @@ public BufferCapabilities getBufferCapabilities() { return bufferCaps; } - private static class D3DImageCaps extends ImageCapabilities { + private static final class D3DImageCaps extends ImageCapabilities { private D3DImageCaps() { super(true); } diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java index e9f02a5d98c..1c838d0d32d 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java @@ -128,7 +128,7 @@ public void run() { return d3dCaps != null ? d3dCaps : new D3DContextCaps(CAPS_EMPTY, null); } - public final boolean isCapPresent(int cap) { + public boolean isCapPresent(int cap) { return ((d3dCaps.getCaps() & cap) != 0); } @@ -234,7 +234,7 @@ public void run() { * REMIND: we create an instance per each full-screen device while a single * instance would suffice (but requires more management). */ - private static class D3DFSWindowAdapter extends WindowAdapter { + private static final class D3DFSWindowAdapter extends WindowAdapter { @Override @SuppressWarnings("static") public void windowDeactivated(WindowEvent e) { diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DMaskBlit.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DMaskBlit.java index 835bcb733ad..6ba766d2b13 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DMaskBlit.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DMaskBlit.java @@ -36,7 +36,7 @@ import static sun.java2d.loops.CompositeType.*; import static sun.java2d.loops.SurfaceType.*; -class D3DMaskBlit extends BufferedMaskBlit { +final class D3DMaskBlit extends BufferedMaskBlit { static void register() { GraphicsPrimitive[] primitives = { diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DMaskFill.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DMaskFill.java index fb78616a98f..d00e3fe2ee1 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DMaskFill.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DMaskFill.java @@ -36,7 +36,7 @@ import static sun.java2d.loops.CompositeType.*; import static sun.java2d.loops.SurfaceType.*; -class D3DMaskFill extends BufferedMaskFill { +final class D3DMaskFill extends BufferedMaskFill { static void register() { GraphicsPrimitive[] primitives = { diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DPaints.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DPaints.java index 7d5bd4423ea..74b7cfc6967 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DPaints.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DPaints.java @@ -76,7 +76,7 @@ static boolean isValid(SunGraphics2D sg2d) { /************************* GradientPaint support ****************************/ - private static class Gradient extends D3DPaints { + private static final class Gradient extends D3DPaints { private Gradient() {} /** @@ -96,7 +96,7 @@ boolean isPaintValid(SunGraphics2D sg2d) { /************************** TexturePaint support ****************************/ - private static class Texture extends D3DPaints { + private static final class Texture extends D3DPaints { private Texture() {} /** @@ -201,7 +201,7 @@ boolean isPaintValid(SunGraphics2D sg2d) { /********************** LinearGradientPaint support *************************/ - private static class LinearGradient extends MultiGradient { + private static final class LinearGradient extends MultiGradient { private LinearGradient() {} @Override @@ -228,7 +228,7 @@ boolean isPaintValid(SunGraphics2D sg2d) { /********************** RadialGradientPaint support *************************/ - private static class RadialGradient extends MultiGradient { + private static final class RadialGradient extends MultiGradient { private RadialGradient() {} } } diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DRenderQueue.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DRenderQueue.java index d77e90456df..be20e1c4e4c 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DRenderQueue.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DRenderQueue.java @@ -33,7 +33,7 @@ /** * D3D-specific implementation of RenderQueue. */ -public class D3DRenderQueue extends RenderQueue { +public final class D3DRenderQueue extends RenderQueue { private static D3DRenderQueue theInstance; private static Thread rqThread; @@ -132,11 +132,13 @@ public static void disposeGraphicsConfig(long pConfigInfo) { } } + @Override public void flushNow() { // assert lock.isHeldByCurrentThread(); flushBuffer(null); } + @Override public void flushAndInvokeNow(Runnable r) { // assert lock.isHeldByCurrentThread(); flushBuffer(r); diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DRenderer.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DRenderer.java index fd63d758548..7361a09973b 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DRenderer.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DRenderer.java @@ -87,6 +87,7 @@ void copyArea(SunGraphics2D sg2d, } } + @Override protected native void drawPoly(int[] xPoints, int[] yPoints, int nPoints, boolean isClosed, int transX, int transY); @@ -95,12 +96,13 @@ D3DRenderer traceWrap() { return new Tracer(this); } - private static class Tracer extends D3DRenderer { + private static final class Tracer extends D3DRenderer { private D3DRenderer d3dr; Tracer(D3DRenderer d3dr) { super(d3dr.rq); this.d3dr = d3dr; } + @Override public ParallelogramPipe getAAParallelogramPipe() { final ParallelogramPipe realpipe = d3dr.getAAParallelogramPipe(); return new ParallelogramPipe() { @@ -133,19 +135,23 @@ public void drawParallelogram(SunGraphics2D sg2d, }; } + @Override protected void validateContext(SunGraphics2D sg2d) { d3dr.validateContext(sg2d); } + @Override public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) { GraphicsPrimitive.tracePrimitive("D3DDrawLine"); d3dr.drawLine(sg2d, x1, y1, x2, y2); } + @Override public void drawRect(SunGraphics2D sg2d, int x, int y, int w, int h) { GraphicsPrimitive.tracePrimitive("D3DDrawRect"); d3dr.drawRect(sg2d, x, y, w, h); } + @Override protected void drawPoly(SunGraphics2D sg2d, int[] xPoints, int[] yPoints, int nPoints, boolean isClosed) @@ -153,28 +159,33 @@ protected void drawPoly(SunGraphics2D sg2d, GraphicsPrimitive.tracePrimitive("D3DDrawPoly"); d3dr.drawPoly(sg2d, xPoints, yPoints, nPoints, isClosed); } + @Override public void fillRect(SunGraphics2D sg2d, int x, int y, int w, int h) { GraphicsPrimitive.tracePrimitive("D3DFillRect"); d3dr.fillRect(sg2d, x, y, w, h); } + @Override protected void drawPath(SunGraphics2D sg2d, Path2D.Float p2df, int transx, int transy) { GraphicsPrimitive.tracePrimitive("D3DDrawPath"); d3dr.drawPath(sg2d, p2df, transx, transy); } + @Override protected void fillPath(SunGraphics2D sg2d, Path2D.Float p2df, int transx, int transy) { GraphicsPrimitive.tracePrimitive("D3DFillPath"); d3dr.fillPath(sg2d, p2df, transx, transy); } + @Override protected void fillSpans(SunGraphics2D sg2d, SpanIterator si, int transx, int transy) { GraphicsPrimitive.tracePrimitive("D3DFillSpans"); d3dr.fillSpans(sg2d, si, transx, transy); } + @Override public void fillParallelogram(SunGraphics2D sg2d, double ux1, double uy1, double ux2, double uy2, @@ -187,6 +198,7 @@ public void fillParallelogram(SunGraphics2D sg2d, ux1, uy1, ux2, uy2, x, y, dx1, dy1, dx2, dy2); } + @Override public void drawParallelogram(SunGraphics2D sg2d, double ux1, double uy1, double ux2, double uy2, @@ -200,6 +212,7 @@ public void drawParallelogram(SunGraphics2D sg2d, ux1, uy1, ux2, uy2, x, y, dx1, dy1, dx2, dy2, lw1, lw2); } + @Override public void copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java index a1afb5cd4c4..58dfd17dea7 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java @@ -58,7 +58,7 @@ * There are some restrictions to which windows we would use this for. * @see #createScreenSurface */ -public class D3DScreenUpdateManager extends ScreenUpdateManager +public final class D3DScreenUpdateManager extends ScreenUpdateManager implements Runnable { /** @@ -401,6 +401,7 @@ public void runUpdateNow() { } } + @Override public void run() { while (!done) { synchronized (runLock) { diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java index c8e082b59d6..374fce63db0 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java @@ -441,6 +441,7 @@ public void run() { * Returns the D3DContext for the GraphicsConfig associated with this * surface. */ + @Override public final D3DContext getContext() { return graphicsDevice.getContext(); } @@ -448,6 +449,7 @@ public final D3DContext getContext() { /** * Returns one of the surface type constants defined above. */ + @Override public final int getType() { return type; } @@ -455,7 +457,7 @@ public final int getType() { private static native int dbGetPixelNative(long pData, int x, int y); private static native void dbSetPixelNative(long pData, int x, int y, int pixel); - static class D3DDataBufferNative extends DataBufferNative { + static final class D3DDataBufferNative extends DataBufferNative { int pixel; protected D3DDataBufferNative(SurfaceData sData, int type, int w, int h) @@ -463,6 +465,7 @@ protected D3DDataBufferNative(SurfaceData sData, super(sData, type, w, h); } + @Override protected int getElem(final int x, final int y, final SurfaceData sData) { @@ -486,6 +489,7 @@ public void run() { return retPixel; } + @Override protected void setElem(final int x, final int y, final int pixel, final SurfaceData sData) { @@ -508,6 +512,7 @@ public void run() { } } + @Override public synchronized Raster getRaster(int x, int y, int w, int h) { if (wrn == null) { DirectColorModel dcm = (DirectColorModel)getColorModel(); @@ -541,6 +546,7 @@ public synchronized Raster getRaster(int x, int y, int w, int h) { * - the source color is opaque * - and the destination is opaque */ + @Override public boolean canRenderLCDText(SunGraphics2D sg2d) { return graphicsDevice.isCapPresent(CAPS_LCD_SHADER) && @@ -564,6 +570,7 @@ void disableAccelerationForSurface() { } } + @Override public void validatePipe(SunGraphics2D sg2d) { TextPipe textpipe; boolean validated = false; @@ -803,10 +810,12 @@ public void run() { /** * Returns destination Image associated with this SurfaceData. */ + @Override public Object getDestination() { return offscreenImage; } + @Override public Rectangle getBounds() { if (type == FLIP_BACKBUFFER || type == WINDOW) { double scaleX = getDefaultScaleX(); @@ -821,6 +830,7 @@ public Rectangle getBounds() { } } + @Override public Rectangle getNativeBounds() { D3DRenderQueue rq = D3DRenderQueue.getInstance(); // need to lock to make sure nativeWidth and Height are consistent @@ -836,10 +846,12 @@ public Rectangle getNativeBounds() { } + @Override public GraphicsConfiguration getDeviceConfiguration() { return graphicsDevice.getDefaultConfiguration(); } + @Override public SurfaceData getReplacement() { return restoreContents(offscreenImage); } @@ -909,6 +921,7 @@ public void setSurfaceLost(boolean lost) { * such resource doesn't exist or can not be retrieved. * @see sun.java2d.pipe.hw.AccelSurface#getNativeResource */ + @Override public long getNativeResource(int resType) { return getNativeResourceNative(getNativeOps(), resType); } @@ -920,7 +933,7 @@ public long getNativeResource(int resType) { * * @see D3DScreenUpdateManager */ - public static class D3DWindowSurfaceData extends D3DSurfaceData { + public static final class D3DWindowSurfaceData extends D3DSurfaceData { StateTracker dirtyTracker; public D3DWindowSurfaceData(WComponentPeer peer, diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java index 66e98882a19..6ea095666b3 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceDataProxy.java @@ -38,7 +38,7 @@ * SurfaceData with a cached D3D Texture and the code to create * the accelerated surfaces. */ -public class D3DSurfaceDataProxy extends SurfaceDataProxy { +public final class D3DSurfaceDataProxy extends SurfaceDataProxy { public static SurfaceDataProxy createProxy(SurfaceData srcData, D3DGraphicsConfig dstConfig) diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DTextRenderer.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DTextRenderer.java index b892ed4b10c..31b2cc207cd 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DTextRenderer.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DTextRenderer.java @@ -59,10 +59,11 @@ D3DTextRenderer traceWrap() { return new Tracer(this); } - private static class Tracer extends D3DTextRenderer { + private static final class Tracer extends D3DTextRenderer { Tracer(D3DTextRenderer d3dtr) { super(d3dtr.rq); } + @Override protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) { GraphicsPrimitive.tracePrimitive("D3DDrawGlyphs"); super.drawGlyphList(sg2d, gl); diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java index 4aac1c248a6..0fedb478362 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DVolatileSurfaceManager.java @@ -48,7 +48,7 @@ import static sun.java2d.pipe.hw.AccelSurface.TEXTURE; import static sun.java2d.pipe.hw.AccelSurface.UNDEFINED; -public class D3DVolatileSurfaceManager +public final class D3DVolatileSurfaceManager extends VolatileSurfaceManager { private boolean accelerationEnabled; @@ -75,6 +75,7 @@ public D3DVolatileSurfaceManager(SunVolatileImage vImg, Object context) { gd.isCapPresent(CAPS_RT_TEXTURE_ALPHA))); } + @Override protected boolean isAccelerationEnabled() { return accelerationEnabled; } @@ -86,6 +87,7 @@ public void setAccelerationEnabled(boolean accelerationEnabled) { * Create a pbuffer-based SurfaceData object (or init the backbuffer * of an existing window if this is a double buffered GraphicsConfig). */ + @Override protected SurfaceData initAcceleratedSurface() { SurfaceData sData; Component comp = vImg.getComponent(); @@ -124,6 +126,7 @@ protected SurfaceData initAcceleratedSurface() { return sData; } + @Override protected boolean isConfigValid(GraphicsConfiguration gc) { return ((gc == null) || (gc == vImg.getGraphicsConfig())); } diff --git a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java index 768f2df08ad..c6658bf2914 100644 --- a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java +++ b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java @@ -158,7 +158,7 @@ public void run() { * This is a small helper class that allows us to execute * getWGLConfigInfo() on the queue flushing thread. */ - private static class WGLGetConfigInfo implements Runnable { + private static final class WGLGetConfigInfo implements Runnable { private int screen; private int pixfmt; private long cfginfo; @@ -184,21 +184,21 @@ public static boolean isWGLAvailable() { * See OGLContext.java for a list of supported capabilities. */ @Override - public final boolean isCapPresent(int cap) { + public boolean isCapPresent(int cap) { return ((oglCaps.getCaps() & cap) != 0); } @Override - public final long getNativeConfigInfo() { + public long getNativeConfigInfo() { return pConfigInfo; } @Override - public final OGLContext getContext() { + public OGLContext getContext() { return context; } - private static class WGLGCDisposerRecord implements DisposerRecord { + private static final class WGLGCDisposerRecord implements DisposerRecord { private long pCfgInfo; public WGLGCDisposerRecord(long pCfgInfo) { this.pCfgInfo = pCfgInfo; @@ -374,7 +374,7 @@ public void flip(WComponentPeer peer, } } - private static class WGLBufferCaps extends BufferCapabilities { + private static final class WGLBufferCaps extends BufferCapabilities { public WGLBufferCaps(boolean dblBuf) { super(imageCaps, imageCaps, dblBuf ? FlipContents.UNDEFINED : null); @@ -390,7 +390,7 @@ public BufferCapabilities getBufferCapabilities() { return bufferCaps; } - private static class WGLImageCaps extends ImageCapabilities { + private static final class WGLImageCaps extends ImageCapabilities { private WGLImageCaps() { super(true); } diff --git a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java index fa4cb6a3cc2..8f97980811f 100644 --- a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java +++ b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java @@ -75,6 +75,7 @@ public double getDefaultScaleY() { return scaleY; } + @Override public GraphicsConfiguration getDeviceConfiguration() { return graphicsConfig; } @@ -151,7 +152,7 @@ public static WGLGraphicsConfig getGC(WComponentPeer peer) { } } - public static class WGLWindowSurfaceData extends WGLSurfaceData { + public static final class WGLWindowSurfaceData extends WGLSurfaceData { public WGLWindowSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc) @@ -159,10 +160,12 @@ public WGLWindowSurfaceData(WComponentPeer peer, super(peer, gc, peer.getColorModel(), WINDOW); } + @Override public SurfaceData getReplacement() { return peer.getSurfaceData(); } + @Override public Rectangle getBounds() { Rectangle r = peer.getBounds(); r.x = r.y = 0; @@ -174,6 +177,7 @@ public Rectangle getBounds() { /** * Returns destination Component associated with this SurfaceData. */ + @Override public Object getDestination() { return peer.getTarget(); } @@ -188,7 +192,7 @@ public Object getDestination() { * belongs to is showed, it is first copied to the real private * FLIP_BACKBUFFER, which is then flipped. */ - public static class WGLVSyncOffScreenSurfaceData extends + public static final class WGLVSyncOffScreenSurfaceData extends WGLOffScreenSurfaceData { private WGLOffScreenSurfaceData flipSurface; @@ -235,10 +239,12 @@ public WGLOffScreenSurfaceData(WComponentPeer peer, initSurface(this.width, this.height); } + @Override public SurfaceData getReplacement() { return restoreContents(offscreenImage); } + @Override public Rectangle getBounds() { if (type == FLIP_BACKBUFFER) { Rectangle r = peer.getBounds(); @@ -254,6 +260,7 @@ public Rectangle getBounds() { /** * Returns destination Image associated with this SurfaceData. */ + @Override public Object getDestination() { return offscreenImage; } diff --git a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java index 750bb94df08..c90f8102e7e 100644 --- a/src/java.desktop/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java +++ b/src/java.desktop/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java @@ -43,7 +43,7 @@ import sun.java2d.pipe.hw.ExtendedBufferCapabilities; import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*; -public class WGLVolatileSurfaceManager extends VolatileSurfaceManager { +public final class WGLVolatileSurfaceManager extends VolatileSurfaceManager { private final boolean accelerationEnabled; @@ -62,6 +62,7 @@ public WGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) { && transparency != Transparency.BITMASK; } + @Override protected boolean isAccelerationEnabled() { return accelerationEnabled; } @@ -70,6 +71,7 @@ protected boolean isAccelerationEnabled() { * Create a FBO-based SurfaceData object (or init the backbuffer * of an existing window if this is a double buffered GraphicsConfig). */ + @Override protected SurfaceData initAcceleratedSurface() { SurfaceData sData; Component comp = vImg.getComponent(); diff --git a/src/java.desktop/windows/classes/sun/java2d/windows/GDIBlitLoops.java b/src/java.desktop/windows/classes/sun/java2d/windows/GDIBlitLoops.java index 3f1996309cd..18d44ea6a49 100644 --- a/src/java.desktop/windows/classes/sun/java2d/windows/GDIBlitLoops.java +++ b/src/java.desktop/windows/classes/sun/java2d/windows/GDIBlitLoops.java @@ -43,7 +43,7 @@ * that is faster than our current fallback (which creates * a temporary GDI DIB) */ -public class GDIBlitLoops extends Blit { +public final class GDIBlitLoops extends Blit { // Store these values to be passed to native code int rmask, gmask, bmask; @@ -134,6 +134,7 @@ public native void nativeBlit(SurfaceData src, SurfaceData dst, * Composite data because we only register these loops for * SrcNoEa composite operations. */ + @Override public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) diff --git a/src/java.desktop/windows/classes/sun/java2d/windows/GDIRenderer.java b/src/java.desktop/windows/classes/sun/java2d/windows/GDIRenderer.java index f08273c76fb..9bb3ba38b20 100644 --- a/src/java.desktop/windows/classes/sun/java2d/windows/GDIRenderer.java +++ b/src/java.desktop/windows/classes/sun/java2d/windows/GDIRenderer.java @@ -50,6 +50,7 @@ native void doDrawLine(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x1, int y1, int x2, int y2); + @Override public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) { @@ -68,6 +69,7 @@ native void doDrawRect(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h); + @Override public void drawRect(SunGraphics2D sg2d, int x, int y, int width, int height) { @@ -85,6 +87,7 @@ native void doDrawRoundRect(GDIWindowSurfaceData sData, int x, int y, int w, int h, int arcW, int arcH); + @Override public void drawRoundRect(SunGraphics2D sg2d, int x, int y, int width, int height, int arcWidth, int arcHeight) @@ -103,6 +106,7 @@ native void doDrawOval(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h); + @Override public void drawOval(SunGraphics2D sg2d, int x, int y, int width, int height) { @@ -120,6 +124,7 @@ native void doDrawArc(GDIWindowSurfaceData sData, int x, int y, int w, int h, int angleStart, int angleExtent); + @Override public void drawArc(SunGraphics2D sg2d, int x, int y, int width, int height, int startAngle, int arcAngle) @@ -140,6 +145,7 @@ native void doDrawPoly(GDIWindowSurfaceData sData, int[] xpoints, int[] ypoints, int npoints, boolean isclosed); + @Override public void drawPolyline(SunGraphics2D sg2d, int[] xpoints, int[] ypoints, int npoints) @@ -153,6 +159,7 @@ public void drawPolyline(SunGraphics2D sg2d, } } + @Override public void drawPolygon(SunGraphics2D sg2d, int[] xpoints, int[] ypoints, int npoints) @@ -170,6 +177,7 @@ native void doFillRect(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h); + @Override public void fillRect(SunGraphics2D sg2d, int x, int y, int width, int height) { @@ -187,6 +195,7 @@ native void doFillRoundRect(GDIWindowSurfaceData sData, int x, int y, int w, int h, int arcW, int arcH); + @Override public void fillRoundRect(SunGraphics2D sg2d, int x, int y, int width, int height, int arcWidth, int arcHeight) @@ -205,6 +214,7 @@ native void doFillOval(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h); + @Override public void fillOval(SunGraphics2D sg2d, int x, int y, int width, int height) { @@ -222,6 +232,7 @@ native void doFillArc(GDIWindowSurfaceData sData, int x, int y, int w, int h, int angleStart, int angleExtent); + @Override public void fillArc(SunGraphics2D sg2d, int x, int y, int width, int height, int startAngle, int arcAngle) @@ -242,6 +253,7 @@ native void doFillPoly(GDIWindowSurfaceData sData, int[] xpoints, int[] ypoints, int npoints); + @Override public void fillPolygon(SunGraphics2D sg2d, int[] xpoints, int[] ypoints, int npoints) @@ -303,6 +315,7 @@ public void doFillSpans(SunGraphics2D sg2d, SpanIterator si) { } } + @Override public void draw(SunGraphics2D sg2d, Shape s) { if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) { doShape(sg2d, s, false); @@ -318,6 +331,7 @@ public void draw(SunGraphics2D sg2d, Shape s) { } } + @Override public void fill(SunGraphics2D sg2d, Shape s) { doShape(sg2d, s, true); } @@ -331,7 +345,8 @@ public GDIRenderer traceWrap() { return new Tracer(); } - public static class Tracer extends GDIRenderer { + public static final class Tracer extends GDIRenderer { + @Override void doDrawLine(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x1, int y1, int x2, int y2) @@ -339,6 +354,7 @@ void doDrawLine(GDIWindowSurfaceData sData, GraphicsPrimitive.tracePrimitive("GDIDrawLine"); super.doDrawLine(sData, clip, comp, color, x1, y1, x2, y2); } + @Override void doDrawRect(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h) @@ -346,6 +362,7 @@ void doDrawRect(GDIWindowSurfaceData sData, GraphicsPrimitive.tracePrimitive("GDIDrawRect"); super.doDrawRect(sData, clip, comp, color, x, y, w, h); } + @Override void doDrawRoundRect(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h, @@ -355,6 +372,7 @@ void doDrawRoundRect(GDIWindowSurfaceData sData, super.doDrawRoundRect(sData, clip, comp, color, x, y, w, h, arcW, arcH); } + @Override void doDrawOval(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h) @@ -362,6 +380,7 @@ void doDrawOval(GDIWindowSurfaceData sData, GraphicsPrimitive.tracePrimitive("GDIDrawOval"); super.doDrawOval(sData, clip, comp, color, x, y, w, h); } + @Override void doDrawArc(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h, @@ -371,6 +390,7 @@ void doDrawArc(GDIWindowSurfaceData sData, super.doDrawArc(sData, clip, comp, color, x, y, w, h, angleStart, angleExtent); } + @Override void doDrawPoly(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int transx, int transy, @@ -381,6 +401,7 @@ void doDrawPoly(GDIWindowSurfaceData sData, super.doDrawPoly(sData, clip, comp, color, transx, transy, xpoints, ypoints, npoints, isclosed); } + @Override void doFillRect(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h) @@ -388,6 +409,7 @@ void doFillRect(GDIWindowSurfaceData sData, GraphicsPrimitive.tracePrimitive("GDIFillRect"); super.doFillRect(sData, clip, comp, color, x, y, w, h); } + @Override void doFillRoundRect(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h, @@ -397,6 +419,7 @@ void doFillRoundRect(GDIWindowSurfaceData sData, super.doFillRoundRect(sData, clip, comp, color, x, y, w, h, arcW, arcH); } + @Override void doFillOval(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h) @@ -404,6 +427,7 @@ void doFillOval(GDIWindowSurfaceData sData, GraphicsPrimitive.tracePrimitive("GDIFillOval"); super.doFillOval(sData, clip, comp, color, x, y, w, h); } + @Override void doFillArc(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int x, int y, int w, int h, @@ -413,6 +437,7 @@ void doFillArc(GDIWindowSurfaceData sData, super.doFillArc(sData, clip, comp, color, x, y, w, h, angleStart, angleExtent); } + @Override void doFillPoly(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int transx, int transy, @@ -423,6 +448,7 @@ void doFillPoly(GDIWindowSurfaceData sData, super.doFillPoly(sData, clip, comp, color, transx, transy, xpoints, ypoints, npoints); } + @Override void doShape(GDIWindowSurfaceData sData, Region clip, Composite comp, int color, int transX, int transY, @@ -434,6 +460,7 @@ void doShape(GDIWindowSurfaceData sData, super.doShape(sData, clip, comp, color, transX, transY, p2df, isfill); } + @Override public void devCopyArea(GDIWindowSurfaceData sData, int srcx, int srcy, int dx, int dy, diff --git a/src/java.desktop/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java b/src/java.desktop/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java index 52e0d47c55d..38b57f77bce 100644 --- a/src/java.desktop/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java +++ b/src/java.desktop/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java @@ -51,7 +51,7 @@ import sun.java2d.loops.RenderLoops; import sun.java2d.loops.XORComposite; -public class GDIWindowSurfaceData extends SurfaceData { +public final class GDIWindowSurfaceData extends SurfaceData { private WComponentPeer peer; private Win32GraphicsConfig graphicsConfig; private RenderLoops solidloops; @@ -139,6 +139,7 @@ public SurfaceDataProxy makeProxyFor(SurfaceData srcData) { return SurfaceDataProxy.UNCACHED; } + @Override public Raster getRaster(int x, int y, int w, int h) { throw new InternalError("not implemented yet"); } @@ -155,6 +156,7 @@ public Raster getRaster(int x, int y, int w, int h) { } + @Override public void validatePipe(SunGraphics2D sg2d) { if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR && @@ -223,6 +225,7 @@ public void validatePipe(SunGraphics2D sg2d) { } } + @Override public RenderLoops getRenderLoops(SunGraphics2D sg2d) { if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR && sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY) @@ -232,6 +235,7 @@ public RenderLoops getRenderLoops(SunGraphics2D sg2d) { return super.getRenderLoops(sg2d); } + @Override public GraphicsConfiguration getDeviceConfiguration() { return graphicsConfig; } @@ -299,6 +303,7 @@ public SurfaceData getReplacement() { return mgr.getReplacementScreenSurface(peer, this); } + @Override public Rectangle getBounds() { Rectangle r = peer.getBounds(); r.x = r.y = 0; @@ -307,6 +312,7 @@ public Rectangle getBounds() { return r; } + @Override public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { diff --git a/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java b/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java index 7333eeda3dd..b5b1e6376e9 100644 --- a/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java +++ b/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java @@ -28,7 +28,7 @@ import sun.awt.windows.WToolkit; import sun.java2d.opengl.WGLGraphicsConfig; -public class WindowsFlags { +public final class WindowsFlags { /** * Description of command-line flags. All flags with [true|false] diff --git a/src/java.desktop/windows/classes/sun/print/PlatformPrinterJobProxy.java b/src/java.desktop/windows/classes/sun/print/PlatformPrinterJobProxy.java index f9ac7621aa4..677831a9245 100644 --- a/src/java.desktop/windows/classes/sun/print/PlatformPrinterJobProxy.java +++ b/src/java.desktop/windows/classes/sun/print/PlatformPrinterJobProxy.java @@ -27,7 +27,7 @@ import java.awt.print.PrinterJob; -public class PlatformPrinterJobProxy { +public final class PlatformPrinterJobProxy { public static PrinterJob getPrinterJob() { return new sun.awt.windows.WPrinterJob(); diff --git a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java index 4dbcf3a4701..7af6f1b61f8 100644 --- a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java @@ -43,7 +43,7 @@ import sun.awt.util.ThreadGroupUtils; -public class PrintServiceLookupProvider extends PrintServiceLookup { +public final class PrintServiceLookupProvider extends PrintServiceLookup { private PrintService defaultPrintService; private PrintService[] printServices; /* includes the default printer */ @@ -105,6 +105,7 @@ public PrintServiceLookupProvider() { * This isn't required by the API and there's a risk doing this will * lead people to assume its guaranteed. */ + @Override public synchronized PrintService[] getPrintServices() { if (printServices == null) { refreshServices(); @@ -199,6 +200,7 @@ boolean matchingService(PrintService service, return true; } + @Override public PrintService[] getPrintServices(DocFlavor flavor, AttributeSet attributes) { @@ -260,6 +262,7 @@ public PrintService[] getPrintServices(DocFlavor flavor, /* * return empty array as don't support multi docs */ + @Override public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) { @@ -267,6 +270,7 @@ public PrintService[] getPrintServices(DocFlavor flavor, } + @Override public synchronized PrintService getDefaultPrintService() { // Windows does not have notification for a change in default diff --git a/src/java.desktop/windows/classes/sun/print/Win32MediaTray.java b/src/java.desktop/windows/classes/sun/print/Win32MediaTray.java index 43ce6a19d6a..3cb8c858e39 100644 --- a/src/java.desktop/windows/classes/sun/print/Win32MediaTray.java +++ b/src/java.desktop/windows/classes/sun/print/Win32MediaTray.java @@ -35,7 +35,7 @@ * It also implements driver-defined trays. **/ @SuppressWarnings("serial") // JDK implementation class -public class Win32MediaTray extends MediaTray { +public final class Win32MediaTray extends MediaTray { static final Win32MediaTray ENVELOPE_MANUAL = new Win32MediaTray(0, 6); //DMBIN_ENVMANUAL @@ -96,6 +96,7 @@ protected static int getTraySize() { return (myStringTable.length+winStringTable.size()); } + @Override protected String[] getStringTable() { ArrayList completeList = new ArrayList<>(); for (int i=0; i < myStringTable.length; i++) { @@ -106,6 +107,7 @@ protected String[] getStringTable() { return completeList.toArray(nameTable); } + @Override protected EnumSyntax[] getEnumValueTable() { ArrayList completeList = new ArrayList<>(); for (int i=0; i < myEnumValueTable.length; i++) { diff --git a/src/java.desktop/windows/classes/sun/print/Win32PrintJob.java b/src/java.desktop/windows/classes/sun/print/Win32PrintJob.java index f8ee2d3db0b..cd4eec9926b 100644 --- a/src/java.desktop/windows/classes/sun/print/Win32PrintJob.java +++ b/src/java.desktop/windows/classes/sun/print/Win32PrintJob.java @@ -73,7 +73,7 @@ import java.awt.print.*; -public class Win32PrintJob implements CancelablePrintJob { +public final class Win32PrintJob implements CancelablePrintJob { private transient ArrayList jobListeners; private transient ArrayList attrListeners; @@ -113,10 +113,12 @@ public class Win32PrintJob implements CancelablePrintJob { this.service = service; } + @Override public PrintService getPrintService() { return service; } + @Override public PrintJobAttributeSet getAttributes() { synchronized (this) { if (jobAttrSet == null) { @@ -129,6 +131,7 @@ public PrintJobAttributeSet getAttributes() { } } + @Override public void addPrintJobListener(PrintJobListener listener) { synchronized (this) { if (listener == null) { @@ -141,6 +144,7 @@ public void addPrintJobListener(PrintJobListener listener) { } } + @Override public void removePrintJobListener(PrintJobListener listener) { synchronized (this) { if (listener == null || jobListeners == null ) { @@ -254,6 +258,7 @@ private void notifyEvent(int reason) { } } + @Override public void addPrintJobAttributeListener( PrintJobAttributeListener listener, PrintJobAttributeSet attributes) { @@ -273,6 +278,7 @@ public void addPrintJobAttributeListener( } } + @Override public void removePrintJobAttributeListener( PrintJobAttributeListener listener) { synchronized (this) { @@ -293,6 +299,7 @@ public void removePrintJobAttributeListener( } } + @Override public void print(Doc doc, PrintRequestAttributeSet attributes) throws PrintException { @@ -697,6 +704,7 @@ private native boolean startPrintRawData(String printerName, private native boolean endPrintRawData(); /* Cancel PrinterJob jobs that haven't yet completed. */ + @Override public void cancel() throws PrintException { synchronized (this) { if (!printing) { diff --git a/src/java.desktop/windows/classes/sun/print/Win32PrintService.java b/src/java.desktop/windows/classes/sun/print/Win32PrintService.java index 7d85755bf0c..3bca5b581bb 100644 --- a/src/java.desktop/windows/classes/sun/print/Win32PrintService.java +++ b/src/java.desktop/windows/classes/sun/print/Win32PrintService.java @@ -78,7 +78,7 @@ import javax.print.event.PrintServiceAttributeListener; import sun.awt.windows.WPrinterJob; -public class Win32PrintService implements PrintService, AttributeUpdater, +public final class Win32PrintService implements PrintService, AttributeUpdater, SunPrinterJobService { public static MediaSize[] predefMedia = Win32MediaSize.getPredefMedia(); @@ -242,6 +242,7 @@ public void invalidateService() { isInvalid = true; } + @Override public String getName() { return printer; } @@ -857,6 +858,7 @@ private boolean isSupportedResolution(PrinterResolution res) { return false; } + @Override public DocPrintJob createPrintJob() { return new Win32PrintJob(this); } @@ -868,6 +870,7 @@ private PrintServiceAttributeSet getDynamicAttributes() { return attrs; } + @Override public PrintServiceAttributeSet getUpdatedAttributes() { PrintServiceAttributeSet currSet = getDynamicAttributes(); if (lastSet == null) { @@ -896,6 +899,7 @@ public void wakeNotifier() { } } + @Override public void addPrintServiceAttributeListener(PrintServiceAttributeListener listener) { synchronized (this) { @@ -909,6 +913,7 @@ public void addPrintServiceAttributeListener(PrintServiceAttributeListener } } + @Override public void removePrintServiceAttributeListener( PrintServiceAttributeListener listener) { synchronized (this) { @@ -923,6 +928,7 @@ public void removePrintServiceAttributeListener( } } + @Override @SuppressWarnings("unchecked") public T getAttribute(Class category) @@ -955,6 +961,7 @@ public void removePrintServiceAttributeListener( } } + @Override public PrintServiceAttributeSet getAttributes() { PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet(); @@ -979,6 +986,7 @@ public PrintServiceAttributeSet getAttributes() { return AttributeSetUtilities.unmodifiableView(attrs); } + @Override public DocFlavor[] getSupportedDocFlavors() { int len = supportedFlavors.length; DocFlavor[] supportedDocFlavors; @@ -998,6 +1006,7 @@ public DocFlavor[] getSupportedDocFlavors() { return supportedDocFlavors; } + @Override public boolean isDocFlavorSupported(DocFlavor flavor) { /* To avoid a native query which may be time-consuming * do not invoke native unless postscript support is being queried. @@ -1017,6 +1026,7 @@ public boolean isDocFlavorSupported(DocFlavor flavor) { return false; } + @Override public Class[] getSupportedAttributeCategories() { ArrayList> categList = new ArrayList<>(otherAttrCats.length+3); for (int i=0; i < otherAttrCats.length; i++) { @@ -1049,6 +1059,7 @@ public Class[] getSupportedAttributeCategories() { return categList.toArray(new Class[categList.size()]); } + @Override public boolean isAttributeCategorySupported(Class category) { @@ -1072,6 +1083,7 @@ public Class[] getSupportedAttributeCategories() { return false; } + @Override public Object getDefaultAttributeValue(Class category) { @@ -1255,6 +1267,7 @@ private boolean isAutoSense(DocFlavor flavor) { } } + @Override public Object getSupportedAttributeValues(Class category, DocFlavor flavor, @@ -1457,6 +1470,7 @@ private boolean isAutoSense(DocFlavor flavor) { } } + @Override public boolean isAttributeValueSupported(Attribute attr, DocFlavor flavor, AttributeSet attributes) { @@ -1586,6 +1600,7 @@ else if (category == Chromaticity.class) { return true; } + @Override public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes) { @@ -1622,7 +1637,7 @@ else if (!isAttributeValueSupported(attr, flavor, attributes)) { private Win32DocumentPropertiesUI docPropertiesUI = null; - private static class Win32DocumentPropertiesUI + private static final class Win32DocumentPropertiesUI extends DocumentPropertiesUI { Win32PrintService service; @@ -1631,6 +1646,7 @@ private Win32DocumentPropertiesUI(Win32PrintService s) { service = s; } + @Override public PrintRequestAttributeSet showDocumentProperties(PrinterJob job, Window owner, @@ -1649,7 +1665,7 @@ private synchronized DocumentPropertiesUI getDocumentPropertiesUI() { return new Win32DocumentPropertiesUI(this); } - private static class Win32ServiceUIFactory extends ServiceUIFactory { + private static final class Win32ServiceUIFactory extends ServiceUIFactory { Win32PrintService service; @@ -1657,6 +1673,7 @@ private static class Win32ServiceUIFactory extends ServiceUIFactory { service = s; } + @Override public Object getUI(int role, String ui) { if (role <= ServiceUIFactory.MAIN_UIROLE) { return null; @@ -1669,6 +1686,7 @@ public Object getUI(int role, String ui) { throw new IllegalArgumentException("Unsupported role"); } + @Override public String[] getUIClassNamesForRole(int role) { if (role <= ServiceUIFactory.MAIN_UIROLE) { @@ -1685,6 +1703,7 @@ public String[] getUIClassNamesForRole(int role) { private Win32ServiceUIFactory uiFactory = null; + @Override public synchronized ServiceUIFactory getServiceUIFactory() { if (uiFactory == null) { uiFactory = new Win32ServiceUIFactory(this); @@ -1692,20 +1711,24 @@ public synchronized ServiceUIFactory getServiceUIFactory() { return uiFactory; } + @Override public String toString() { return "Win32 Printer : " + getName(); } + @Override public boolean equals(Object obj) { return (obj == this || (obj instanceof Win32PrintService && ((Win32PrintService)obj).getName().equals(getName()))); } + @Override public int hashCode() { return this.getClass().hashCode()+getName().hashCode(); } + @Override public boolean usesClass(Class c) { return (c == sun.awt.windows.WPrinterJob.class); } @@ -1727,7 +1750,7 @@ private native float[] getMediaPrintableArea(String printerName, } @SuppressWarnings("serial") // JDK implementation class -class Win32MediaSize extends MediaSizeName { +final class Win32MediaSize extends MediaSizeName { private static ArrayList winStringTable = new ArrayList<>(); private static ArrayList winEnumTable = new ArrayList<>(); private static MediaSize[] predefMedia; @@ -1787,11 +1810,13 @@ int getDMPaper() { return dmPaperID; } + @Override protected String[] getStringTable() { String[] nameTable = new String[winStringTable.size()]; return winStringTable.toArray(nameTable); } + @Override protected EnumSyntax[] getEnumValueTable() { MediaSizeName[] enumTable = new MediaSizeName[winEnumTable.size()]; return winEnumTable.toArray(enumTable); diff --git a/src/java.desktop/windows/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java b/src/java.desktop/windows/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java index 6430a71f06e..f1180b3ae38 100644 --- a/src/java.desktop/windows/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java +++ b/src/java.desktop/windows/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java @@ -37,7 +37,7 @@ * */ @SuppressWarnings("serial") // JDK-implementation class -public class ClassicSortArrowIcon implements Icon, UIResource, Serializable{ +public final class ClassicSortArrowIcon implements Icon, UIResource, Serializable{ private static final int X_OFFSET = 9; private boolean ascending; @@ -45,6 +45,7 @@ public ClassicSortArrowIcon(boolean ascending) { this.ascending = ascending; } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { x += X_OFFSET; if (ascending) { @@ -89,9 +90,11 @@ private void drawSide(Graphics g, int x, int y, int xIncrement) { g.fillRect(x, y, 1, 2); } + @Override public int getIconWidth() { return X_OFFSET + 8; } + @Override public int getIconHeight() { return 9; } From 1889dacb1981d3d15174bc5a201e683a6cdab725 Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 16:01:34 +0000 Subject: [PATCH 052/901] 8353007: Open some JComboBox bugs 2 Reviewed-by: kizune, honkar --- .../jdk/javax/swing/JComboBox/bug4185024.java | 109 +++++++++++++++ .../jdk/javax/swing/JComboBox/bug4201964.java | 77 +++++++++++ .../jdk/javax/swing/JComboBox/bug4249732.java | 72 ++++++++++ .../jdk/javax/swing/JComboBox/bug4368848.java | 129 ++++++++++++++++++ 4 files changed, 387 insertions(+) create mode 100644 test/jdk/javax/swing/JComboBox/bug4185024.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4201964.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4249732.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4368848.java diff --git a/test/jdk/javax/swing/JComboBox/bug4185024.java b/test/jdk/javax/swing/JComboBox/bug4185024.java new file mode 100644 index 00000000000..da0360143d6 --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4185024.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import java.awt.Point; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JPanel; + +/* + * @test + * @bug 4185024 + * @summary Tests that Heavyweight combo boxes on JDesktop work correctly + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4185024 + */ + +public class bug4185024 { + private static final String INSTRUCTIONS = """ + Click on the JComboBox button inside the JInternalFrame to bring up the menu. + Select one of the menu items and verify that the choice is highlighted correctly. + Click and drag the menu's scroll bar down and verify that it causes the menu to scroll down. + + Inside JInternalFrame: + This test is for the JComboBox in the JInternalFrame. + To test, please click on the combobox and check the following: + Does the selection in the popup list follow the mouse? + Does the popup list respond to clicking and dragging the scroll bar? + If so, press PASS, otherwise, press FAIL. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4185024::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4185024"); + JPanel p = new JPanel(); + p.setLayout(new BorderLayout()); + JDesktopPane desktop = new JDesktopPane(); + p.add(desktop); + frame.add(p); + + JComboBox months = new JComboBox(); + months.addItem("January"); + months.addItem("February"); + months.addItem("March"); + months.addItem("April"); + months.addItem("May"); + months.addItem("June"); + months.addItem("July"); + months.addItem("August"); + months.addItem("September"); + months.addItem("October"); + months.addItem("November"); + months.addItem("December"); + months.getAccessibleContext().setAccessibleName("Months"); + months.getAccessibleContext().setAccessibleDescription("Choose a month of the year"); + + // Set this to true and the popup works correctly... + months.setLightWeightPopupEnabled(false); + + addFrame("Months", desktop, months); + + frame.setSize(300, 300); + return frame; + } + + private static void addFrame(String title, JDesktopPane desktop, JComponent component) { + JInternalFrame jf = new JInternalFrame(title); + Point newPos = new Point(20, 20); + jf.setResizable(true); + jf.add(component); + jf.setLocation(newPos); + desktop.add(jf); + + jf.pack(); + jf.show(); + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4201964.java b/test/jdk/javax/swing/JComboBox/bug4201964.java new file mode 100644 index 00000000000..5c3a0f30199 --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4201964.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.UIManager; + +/* + * @test + * @bug 4201964 + * @summary Tests that JComboBox's arrow button isn't drawn too wide in Windows Look&Feel + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4201964 + */ + +public class bug4201964 { + private static final String INSTRUCTIONS = """ + Does the arrow look too large? If not, it passes. + """; + + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + PassFailJFrame.forceFail("Couldn't load the Windows look and feel."); + } + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(8) + .columns(30) + .testUI(bug4201964::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4201964"); + JPanel panel = new JPanel(); + JComboBox comboBox; + + comboBox = new JComboBox(new Object[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea"}); + + panel.add(comboBox); + + frame.add(panel); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4249732.java b/test/jdk/javax/swing/JComboBox/bug4249732.java new file mode 100644 index 00000000000..b8de7fa48b7 --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4249732.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.BorderLayout; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.UIManager; + +/* + * @test + * @bug 4249732 + * @requires (os.family == "windows") + * @summary Tests that Windows editable combo box selects text picked from its list + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4249732 + */ + +public class bug4249732 { + private static final String INSTRUCTIONS = """ + Click on combo box arrow button to open its dropdown list, and + select an item from there. The text in the combo box editor should + be selected, otherwise test fails. + """; + + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } catch (Exception e) { + PassFailJFrame.forceFail("Couldn't load the Windows look and feel."); + } + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(8) + .columns(40) + .testUI(bug4249732::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4249732"); + + JComboBox cb = new JComboBox(new Object[]{"foo", "bar", "baz"}); + cb.setEditable(true); + + frame.add(cb, BorderLayout.NORTH); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4368848.java b/test/jdk/javax/swing/JComboBox/bug4368848.java new file mode 100644 index 00000000000..1673c458cac --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4368848.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.DefaultCellEditor; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; + +/* + * @test + * @bug 4368848 + * @summary Tests that mouse wheel events cancel popups + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4368848 + */ + +public class bug4368848 { + static final String[] names = {"First Name", "Last Name", "Veggy"}; + static Object[][] data = { + {"Mark", "Andrews", false}, + {"Tom", "Ball", false}, + {"Alan", "Chung", false}, + {"Jeff", "Dinkins", false}, + {"Amy", "Fowler", false}, + {"Brian", "Gerhold", false}, + {"James", "Gosling", false}, + {"David", "Karlton", false}, + {"Dave", "Kloba", false}, + {"Peter", "Korn", false}, + {"Phil", "Milne", false}, + {"Dave", "Moore", false}, + {"Hans", "Muller", false}, + {"Rick", "Levenson", false}, + {"Tim", "Prinzing", false}, + {"Chester", "Rose", false}, + {"Ray", "Ryan", false}, + {"Georges", "Saab", false}, + {"Willie", "Walker", false}, + {"Kathy", "Walrath", false}, + {"Arnaud", "Weber", false} + }; + + private static final String INSTRUCTIONS = """ + Click any cell in the 'Veggy' column, so that combo box appears. + Make sure mouse pointer is over the table, but _not_ over the combo + box. Try scrolling the table using the mouse wheel. The combo popup + should disappear. If it stays visible, test fails. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4368848::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4368848"); + ExampleTableModel dataModel = new ExampleTableModel(); + + JComboBox _editor = new JComboBox(); + _editor.addItem(false); + _editor.addItem(true); + + JTable tableView = new JTable(dataModel); + tableView.setDefaultEditor(Boolean.class, new DefaultCellEditor(_editor)); + + frame.add(new JScrollPane(tableView)); + frame.setSize(200, 200); + return frame; + } + + static class ExampleTableModel extends AbstractTableModel { + // These methods always need to be implemented. + @Override + public int getColumnCount() { + return names.length; + } + + @Override + public int getRowCount() { + return data.length; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + @Override + public boolean isCellEditable(int row, int col) { + return true; + } + + @Override + public String getColumnName(int column) { + return names[column]; + } + + @Override + public Class getColumnClass(int col) { + return getValueAt(0, col).getClass(); + } + } +} From 6a310613392b9d619ae1bbe3e663cb4a022165d9 Mon Sep 17 00:00:00 2001 From: Tejesh R Date: Tue, 22 Apr 2025 16:11:55 +0000 Subject: [PATCH 053/901] 8354248: Open source several AWT GridBagLayout and List tests Reviewed-by: abhiscxk --- test/jdk/ProblemList.txt | 2 + .../awt/GridBagLayout/ComponentShortage.java | 99 +++++++++ .../awt/List/ListScrollbarCursorTest.java | 70 +++++++ test/jdk/java/awt/List/ListScrollbarTest.java | 197 ++++++++++++++++++ 4 files changed, 368 insertions(+) create mode 100644 test/jdk/java/awt/GridBagLayout/ComponentShortage.java create mode 100644 test/jdk/java/awt/List/ListScrollbarCursorTest.java create mode 100644 test/jdk/java/awt/List/ListScrollbarTest.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index fe0657ff165..56224181b0a 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -464,6 +464,7 @@ java/awt/TrayIcon/RightClickWhenBalloonDisplayed/RightClickWhenBalloonDisplayed. java/awt/PopupMenu/PopupMenuLocation.java 8259913,8315878 windows-all,macosx-aarch64 java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.java 8238720,8324782 windows-all,macosx-all java/awt/GridLayout/ChangeGridSize/ChangeGridSize.java 8238720,8324782 windows-all,macosx-all +java/awt/GridBagLayout/ComponentShortage.java 8355280 windows-all,linux-all java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsoluteCoordsTest.java 8238720 windows-all # Several tests which fail sometimes on macos11 @@ -815,6 +816,7 @@ java/awt/PopupMenu/PopupHangTest.java 8340022 windows-all java/awt/Focus/MinimizeNonfocusableWindowTest.java 8024487 windows-all java/awt/Focus/InactiveFocusRace.java 8023263 linux-all java/awt/List/HandlingKeyEventIfMousePressedTest.java 6848358 macosx-all,windows-all +java/awt/List/ListScrollbarCursorTest.java 8066410 generic-all java/awt/Checkbox/CheckboxBoxSizeTest.java 8340870 windows-all java/awt/Checkbox/CheckboxIndicatorSizeTest.java 8340870 windows-all java/awt/Checkbox/CheckboxNullLabelTest.java 8340870 windows-all diff --git a/test/jdk/java/awt/GridBagLayout/ComponentShortage.java b/test/jdk/java/awt/GridBagLayout/ComponentShortage.java new file mode 100644 index 00000000000..dd641bbf066 --- /dev/null +++ b/test/jdk/java/awt/GridBagLayout/ComponentShortage.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2008, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4238932 + * @summary JTextField in gridBagLayout does not properly set MinimumSize + * @key headful + * @run main ComponentShortage + */ + +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.JTextField; + +public class ComponentShortage { + static final int WIDTH_REDUCTION = 50; + static JFrame frame; + static JTextField jtf; + static volatile Dimension size; + static volatile Dimension fSize; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() -> { + frame = new JFrame(); + frame.setLayout(new GridBagLayout()); + GridBagConstraints gBC = new GridBagConstraints(); + + gBC.gridx = 1; + gBC.gridy = 0; + gBC.gridwidth = 1; + gBC.gridheight = 1; + gBC.weightx = 1.0; + gBC.weighty = 0.0; + gBC.fill = GridBagConstraints.NONE; + gBC.anchor = GridBagConstraints.NORTHWEST; + jtf = new JTextField(16); + frame.add(jtf, gBC); + frame.pack(); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + size = jtf.getSize(); + }); + System.out.println("TextField size before Frame's width reduction : " + size); + + EventQueue.invokeAndWait(() -> { + frame.setSize(frame.getSize().width - WIDTH_REDUCTION, frame.getSize().height); + }); + frame.repaint(); + + EventQueue.invokeAndWait(() -> { + size = jtf.getSize(); + fSize = frame.getSize(); + }); + System.out.println("TextField size after Frame's width reduction : " + size); + + if (size.width < fSize.width - WIDTH_REDUCTION) { + throw new RuntimeException("Width of JTextField is too small to be visible."); + } + System.out.println("Test passed."); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff --git a/test/jdk/java/awt/List/ListScrollbarCursorTest.java b/test/jdk/java/awt/List/ListScrollbarCursorTest.java new file mode 100644 index 00000000000..fc832029b13 --- /dev/null +++ b/test/jdk/java/awt/List/ListScrollbarCursorTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4290684 + * @summary Tests that cursor on the scrollbar of the list is set to default. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListScrollbarCursorTest + */ + +import java.awt.Cursor; +import java.awt.Frame; +import java.awt.List; +import java.awt.Panel; + +public class ListScrollbarCursorTest { + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. You see the list in the middle of the panel. + This list has two scrollbars. + 2. The cursor should have a shape of hand over the main area + and a shape of arrow over scrollbars. + 3. Move the mouse cursor to either horizontal or vertical scrollbar. + 4. Press PASS if you see the default arrow cursor else press FAIL. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ListScrollbarCursorTest::initialize) + .build() + .awaitAndCheck(); + } + + static Frame initialize() { + Frame frame = new Frame("List Scrollbar Cursor Test"); + Panel panel = new Panel(); + List list = new List(3); + list.add("List item with a very long name" + + "(just to make the horizontal scrollbar visible)"); + list.add("Item 2"); + list.add("Item 3"); + list.setCursor(new Cursor(Cursor.HAND_CURSOR)); + panel.add(list); + frame.add(panel); + frame.setSize(200, 200); + return frame; + } +} diff --git a/test/jdk/java/awt/List/ListScrollbarTest.java b/test/jdk/java/awt/List/ListScrollbarTest.java new file mode 100644 index 00000000000..b676303b927 --- /dev/null +++ b/test/jdk/java/awt/List/ListScrollbarTest.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4096445 + * @summary Test to verify List Scollbar appears/disappears automatically + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ListScrollbarTest + */ + +import java.awt.Button; +import java.awt.Component; +import java.awt.Event; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.List; + +public class ListScrollbarTest extends Frame { + static final int ITEMS = 10; + List ltList; + List rtList; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + 1. There are two lists added to the Frame separated by + a column of buttons + 2. Double click on any item(s) on the left list, you would see + a '*' added at the end of the item + 3. Keep double clicking on the same item till the length of the + item exceeds the width of the list + 4. Now, if you don't get the horizontal scrollbar on + the left list click FAIL. + 5. If you get horizontal scrollbar, select the item + (that you double clicked) and press the '>' button + to move the item to the right list. + 6. If horizontal scroll bar appears on the right list + as well as disappears from the left list [only if both + happen] proceed with step 8 else click FAIL + 7. Now move the same item to the left list, by pressing + '<' button + 8. If the horizontal scrollbar appears on the left list + and disappears from the right list[only if both happen] + click PASS else click FAIL. + """; + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ListScrollbarTest::new) + .build() + .awaitAndCheck(); + } + + public ListScrollbarTest() { + super("List scroll bar test"); + GridBagLayout gbl = new GridBagLayout(); + ltList = new List(ITEMS, true); + rtList = new List(0, true); + setLayout(gbl); + add(ltList, 0, 0, 1, 5, 1.0, 1.0); + add(rtList, 2, 0, 1, 5, 1.0, 1.0); + add(new Button(">"), 1, 0, 1, 1, 0, 1.0); + add(new Button(">>"), 1, 1, 1, 1, 0, 1.0); + add(new Button("<"), 1, 2, 1, 1, 0, 1.0); + add(new Button("<<"), 1, 3, 1, 1, 0, 1.0); + add(new Button("!"), 1, 4, 1, 1, 0, 1.0); + + for (int i = 0; i < ITEMS; i++) { + ltList.addItem("item " + i); + } + setSize(220, 250); + } + + void add(Component comp, int x, int y, int w, int h, double weightx, double weighty) { + GridBagLayout gbl = (GridBagLayout) getLayout(); + GridBagConstraints c = new GridBagConstraints(); + c.fill = GridBagConstraints.BOTH; + c.gridx = x; + c.gridy = y; + c.gridwidth = w; + c.gridheight = h; + c.weightx = weightx; + c.weighty = weighty; + add(comp); + gbl.setConstraints(comp, c); + } + + void reverseSelections(List l) { + for (int i = 0; i < l.countItems(); i++) { + if (l.isSelected(i)) { + l.deselect(i); + } else { + l.select(i); + } + } + } + + void deselectAll(List l) { + for (int i = 0; i < l.countItems(); i++) { + l.deselect(i); + } + } + + void replaceItem(List l, String item) { + for (int i = 0; i < l.countItems(); i++) { + if (l.getItem(i).equals(item)) { + l.replaceItem(item + "*", i); + } + } + } + + void move(List l1, List l2, boolean all) { + + // if all the items are to be moved + if (all) { + for (int i = 0; i < l1.countItems(); i++) { + l2.addItem(l1.getItem(i)); + } + l1.delItems(0, l1.countItems() - 1); + } else { // else move the selected items + String[] items = l1.getSelectedItems(); + int[] itemIndexes = l1.getSelectedIndexes(); + + deselectAll(l2); + for (int i = 0; i < items.length; i++) { + l2.addItem(items[i]); + l2.select(l2.countItems() - 1); + if (i == 0) { + l2.makeVisible(l2.countItems() - 1); + } + } + for (int i = itemIndexes.length - 1; i >= 0; i--) { + l1.delItem(itemIndexes[i]); + } + } + } + + @Override + public boolean action(Event evt, Object arg) { + if (">".equals(arg)) { + move(ltList, rtList, false); + } else if (">>".equals(arg)) { + move(ltList, rtList, true); + } else if ("<".equals(arg)) { + move(rtList, ltList, false); + } else if ("<<".equals(arg)) { + move(rtList, ltList, true); + } else if ("!".equals(arg)) { + if (ltList.getSelectedItems().length > 0) { + reverseSelections(ltList); + } else if (rtList.getSelectedItems().length > 0) { + reverseSelections(rtList); + } + } else if (evt.target == rtList || evt.target == ltList) { + replaceItem((List) evt.target, (String) arg); + } else { + return false; + } + return true; + } + + @Override + public boolean handleEvent(Event evt) { + if (evt.id == Event.LIST_SELECT + || evt.id == Event.LIST_DESELECT) { + if (evt.target == ltList) { + deselectAll(rtList); + } else if (evt.target == rtList) { + deselectAll(ltList); + } + return true; + } + return super.handleEvent(evt); + } +} From d783a940988677dc91975f884adeaf9f047f7e07 Mon Sep 17 00:00:00 2001 From: Boris Ulasevich Date: Tue, 22 Apr 2025 16:46:44 +0000 Subject: [PATCH 054/901] 8332368: ubsan aarch64: immediate_aarch64.cpp:298:31: runtime error: shift exponent 32 is too large for 32-bit type 'int' Reviewed-by: adinn --- src/hotspot/share/adlc/output_h.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/adlc/output_h.cpp b/src/hotspot/share/adlc/output_h.cpp index a4ab29008f0..dd149064a5a 100644 --- a/src/hotspot/share/adlc/output_h.cpp +++ b/src/hotspot/share/adlc/output_h.cpp @@ -870,7 +870,8 @@ void ArchDesc::declare_pipe_classes(FILE *fp_hpp) { fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " void step(uint cycles) {\n"); fprintf(fp_hpp, " _used = 0;\n"); - fprintf(fp_hpp, " _mask <<= cycles;\n"); + fprintf(fp_hpp, " uint max_shift = 8 * sizeof(_mask) - 1;\n"); + fprintf(fp_hpp, " _mask <<= (cycles < max_shift) ? cycles : max_shift;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " friend class Pipeline_Use;\n"); fprintf(fp_hpp, "};\n\n"); From 594b26516e5c01d7daa331db59bdbe8ab7dc0a6d Mon Sep 17 00:00:00 2001 From: Jamil Nimeh Date: Tue, 22 Apr 2025 16:49:29 +0000 Subject: [PATCH 055/901] 8350126: Regression ~3% on Crypto-ChaCha20Poly1305.encrypt for MacOSX aarch64 Reviewed-by: aph --- .../cpu/aarch64/macroAssembler_aarch64.hpp | 16 +- .../aarch64/macroAssembler_aarch64_chacha.cpp | 149 +++++-- .../cpu/aarch64/stubGenerator_aarch64.cpp | 408 +++++++++--------- 3 files changed, 315 insertions(+), 258 deletions(-) diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp index 11d1985e50b..af09f97e938 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1611,11 +1611,15 @@ class MacroAssembler: public Assembler { void aes_round(FloatRegister input, FloatRegister subkey); // ChaCha20 functions support block - void cc20_quarter_round(FloatRegister aVec, FloatRegister bVec, - FloatRegister cVec, FloatRegister dVec, FloatRegister scratch, - FloatRegister tbl); - void cc20_shift_lane_org(FloatRegister bVec, FloatRegister cVec, - FloatRegister dVec, bool colToDiag); + void cc20_qr_add4(FloatRegister (&addFirst)[4], + FloatRegister (&addSecond)[4]); + void cc20_qr_xor4(FloatRegister (&firstElem)[4], + FloatRegister (&secondElem)[4], FloatRegister (&result)[4]); + void cc20_qr_lrot4(FloatRegister (&sourceReg)[4], + FloatRegister (&destReg)[4], int bits, FloatRegister table); + void cc20_set_qr_registers(FloatRegister (&vectorSet)[4], + const FloatRegister (&stateVectors)[16], int idx1, int idx2, + int idx3, int idx4); // Place an ISB after code may have been modified due to a safepoint. void safepoint_isb(); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64_chacha.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64_chacha.cpp index 1f7bb8f46f6..083e81af5d9 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64_chacha.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64_chacha.cpp @@ -28,60 +28,119 @@ #include "runtime/stubRoutines.hpp" /** - * Perform the quarter round calculations on values contained within - * four SIMD registers. + * Perform the vectorized add for a group of 4 quarter round operations. + * In the ChaCha20 quarter round, there are two add ops: a += b and c += d. + * Each parameter is a set of 4 registers representing the 4 registers + * for the each addend in the add operation for each of the quarter rounds. + * (e.g. for "a" it would consist of v0/v1/v2/v3). The result of the add + * is placed into the vectors in the "addFirst" array. * - * @param aVec the SIMD register containing only the "a" values - * @param bVec the SIMD register containing only the "b" values - * @param cVec the SIMD register containing only the "c" values - * @param dVec the SIMD register containing only the "d" values - * @param scratch scratch SIMD register used for 12 and 7 bit left rotations - * @param table the SIMD register used as a table for 8 bit left rotations + * @param addFirst array of SIMD registers representing the first addend. + * @param addSecond array of SIMD registers representing the second addend. */ -void MacroAssembler::cc20_quarter_round(FloatRegister aVec, FloatRegister bVec, - FloatRegister cVec, FloatRegister dVec, FloatRegister scratch, - FloatRegister table) { +void MacroAssembler::cc20_qr_add4(FloatRegister (&addFirst)[4], + FloatRegister (&addSecond)[4]) { + for (int i = 0; i < 4; i++) { + addv(addFirst[i], T4S, addFirst[i], addSecond[i]); + } +} + + +/** + * Perform the vectorized XOR for a group of 4 quarter round operations. + * In the ChaCha20 quarter round, there are two XOR ops: d ^= a and b ^= c + * Each parameter is a set of 4 registers representing the 4 registers + * for the each element in the xor operation for each of the quarter rounds. + * (e.g. for "a" it would consist of v0/v1/v2/v3) + * Note: because the b ^= c ops precede a non-byte-aligned left-rotation, + * there is a third parameter which can take a set of scratch registers + * for the result, which facilitates doing the subsequent operations for + * the left rotation. + * + * @param firstElem array of SIMD registers representing the first element. + * @param secondElem array of SIMD registers representing the second element. + * @param result array of SIMD registers representing the destination. + * May be the same as firstElem or secondElem, or a separate array. + */ +void MacroAssembler::cc20_qr_xor4(FloatRegister (&firstElem)[4], + FloatRegister (&secondElem)[4], FloatRegister (&result)[4]) { + for (int i = 0; i < 4; i++) { + eor(result[i], T16B, firstElem[i], secondElem[i]); + } +} + +/** + * Perform the vectorized left-rotation on 32-bit lanes for a group of + * 4 quarter round operations. + * Each parameter is a set of 4 registers representing the 4 registers + * for the each element in the source and destination for each of the quarter + * rounds (e.g. for "d" it would consist of v12/v13/v14/v15 on columns and + * v15/v12/v13/v14 on diagonal alignments). + * + * @param sourceReg array of SIMD registers representing the source + * @param destReg array of SIMD registers representing the destination + * @param bits the distance of the rotation in bits, must be 16/12/8/7 per + * the ChaCha20 specification. + */ +void MacroAssembler::cc20_qr_lrot4(FloatRegister (&sourceReg)[4], + FloatRegister (&destReg)[4], int bits, FloatRegister table) { + switch (bits) { + case 16: // reg <<<= 16, in-place swap of half-words + for (int i = 0; i < 4; i++) { + rev32(destReg[i], T8H, sourceReg[i]); + } + break; - // a += b, d ^= a, d <<<= 16 - addv(aVec, T4S, aVec, bVec); - eor(dVec, T16B, dVec, aVec); - rev32(dVec, T8H, dVec); + case 7: // reg <<<= (12 || 7) + case 12: // r-shift src -> dest, l-shift src & ins to dest + for (int i = 0; i < 4; i++) { + ushr(destReg[i], T4S, sourceReg[i], 32 - bits); + } - // c += d, b ^= c, b <<<= 12 - addv(cVec, T4S, cVec, dVec); - eor(scratch, T16B, bVec, cVec); - ushr(bVec, T4S, scratch, 20); - sli(bVec, T4S, scratch, 12); + for (int i = 0; i < 4; i++) { + sli(destReg[i], T4S, sourceReg[i], bits); + } + break; - // a += b, d ^= a, d <<<= 8 - addv(aVec, T4S, aVec, bVec); - eor(dVec, T16B, dVec, aVec); - tbl(dVec, T16B, dVec, 1, table); + case 8: // reg <<<= 8, simulate left rotation with table reorg + for (int i = 0; i < 4; i++) { + tbl(destReg[i], T16B, sourceReg[i], 1, table); + } + break; - // c += d, b ^= c, b <<<= 7 - addv(cVec, T4S, cVec, dVec); - eor(scratch, T16B, bVec, cVec); - ushr(bVec, T4S, scratch, 25); - sli(bVec, T4S, scratch, 7); + default: + // The caller shouldn't be sending bit rotation values outside + // of the 16/12/8/7 as defined in the specification. + ShouldNotReachHere(); + } } /** - * Shift the b, c, and d vectors between columnar and diagonal representations. - * Note that the "a" vector does not shift. + * Set the FloatRegisters for a 4-vector register set. These will be used + * during various quarter round transformations (adds, xors and left-rotations). + * This method itself does not result in the output of any assembly + * instructions. It just organizes the vectors so they can be in columnar or + * diagonal alignments. * - * @param bVec the SIMD register containing only the "b" values - * @param cVec the SIMD register containing only the "c" values - * @param dVec the SIMD register containing only the "d" values - * @param colToDiag true if moving columnar to diagonal, false if - * moving diagonal back to columnar. + * @param vectorSet a 4-vector array to be altered into a new alignment + * @param stateVectors the 16-vector array that represents the current + * working state. The indices of this array match up with the + * organization of the ChaCha20 state per RFC 7539 (e.g. stateVectors[12] + * would contain the vector that holds the 32-bit counter, etc.) + * @param idx1 the index of the stateVectors array to be assigned to the + * first vectorSet element. + * @param idx2 the index of the stateVectors array to be assigned to the + * second vectorSet element. + * @param idx3 the index of the stateVectors array to be assigned to the + * third vectorSet element. + * @param idx4 the index of the stateVectors array to be assigned to the + * fourth vectorSet element. */ -void MacroAssembler::cc20_shift_lane_org(FloatRegister bVec, FloatRegister cVec, - FloatRegister dVec, bool colToDiag) { - int bShift = colToDiag ? 4 : 12; - int cShift = 8; - int dShift = colToDiag ? 12 : 4; - - ext(bVec, T16B, bVec, bVec, bShift); - ext(cVec, T16B, cVec, cVec, cShift); - ext(dVec, T16B, dVec, dVec, dShift); +void MacroAssembler::cc20_set_qr_registers(FloatRegister (&vectorSet)[4], + const FloatRegister (&stateVectors)[16], int idx1, int idx2, + int idx3, int idx4) { + vectorSet[0] = stateVectors[idx1]; + vectorSet[1] = stateVectors[idx2]; + vectorSet[2] = stateVectors[idx3]; + vectorSet[3] = stateVectors[idx4]; } diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index 467505ed337..a6cc757f6a0 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -4405,89 +4405,44 @@ class StubGenerator: public StubCodeGenerator { return start; } - /** - * Arguments: - * - * Inputs: - * c_rarg0 - int crc - * c_rarg1 - byte* buf - * c_rarg2 - int length - * - * Output: - * rax - int crc result - */ - address generate_updateBytesCRC32() { - assert(UseCRC32Intrinsics, "what are we doing here?"); - - __ align(CodeEntryAlignment); - StubGenStubId stub_id = StubGenStubId::updateBytesCRC32_id; - StubCodeMark mark(this, stub_id); - - address start = __ pc(); - - const Register crc = c_rarg0; // crc - const Register buf = c_rarg1; // source java byte array address - const Register len = c_rarg2; // length - const Register table0 = c_rarg3; // crc_table address - const Register table1 = c_rarg4; - const Register table2 = c_rarg5; - const Register table3 = c_rarg6; - const Register tmp3 = c_rarg7; - - BLOCK_COMMENT("Entry:"); - __ enter(); // required for proper stackwalking of RuntimeStub frame - - __ kernel_crc32(crc, buf, len, - table0, table1, table2, table3, rscratch1, rscratch2, tmp3); - - __ leave(); // required for proper stackwalking of RuntimeStub frame - __ ret(lr); - - return start; - } - - // ChaCha20 block function. This version parallelizes 4 quarter - // round operations at a time. It uses 16 SIMD registers to - // produce 4 blocks of key stream. + // ChaCha20 block function. This version parallelizes the 32-bit + // state elements on each of 16 vectors, producing 4 blocks of + // keystream at a time. // // state (int[16]) = c_rarg0 // keystream (byte[256]) = c_rarg1 - // return - number of bytes of keystream (always 256) + // return - number of bytes of produced keystream (always 256) // - // In this approach, we load the 512-bit start state sequentially into - // 4 128-bit vectors. We then make 4 4-vector copies of that starting - // state, with each successive set of 4 vectors having a +1 added into - // the first 32-bit lane of the 4th vector in that group (the counter). - // By doing this, we can perform the block function on 4 512-bit blocks - // within one run of this intrinsic. - // The alignment of the data across the 4-vector group is such that at - // the start it is already aligned for the first round of each two-round - // loop iteration. In other words, the corresponding lanes of each vector - // will contain the values needed for that quarter round operation (e.g. - // elements 0/4/8/12, 1/5/9/13, 2/6/10/14, etc.). - // In between each full round, a lane shift must occur. Within a loop - // iteration, between the first and second rounds, the 2nd, 3rd, and 4th - // vectors are rotated left 32, 64 and 96 bits, respectively. The result - // is effectively a diagonal orientation in columnar form. After the - // second full round, those registers are left-rotated again, this time - // 96, 64, and 32 bits - returning the vectors to their columnar organization. - // After all 10 iterations, the original state is added to each 4-vector - // working state along with the add mask, and the 4 vector groups are - // sequentially written to the memory dedicated for the output key stream. - // - // For a more detailed explanation, see Goll and Gueron, "Vectorization of - // ChaCha Stream Cipher", 2014 11th Int. Conf. on Information Technology: - // New Generations, Las Vegas, NV, USA, April 2014, DOI: 10.1109/ITNG.2014.33 - address generate_chacha20Block_qrpar() { - Label L_Q_twoRounds, L_Q_cc20_const; + // This implementation takes each 32-bit integer from the state + // array and broadcasts it across all 4 32-bit lanes of a vector register + // (e.g. state[0] is replicated on all 4 lanes of v4, state[1] to all 4 lanes + // of v5, etc.). Once all 16 elements have been broadcast onto 16 vectors, + // the quarter round schedule is implemented as outlined in RFC 7539 section + // 2.3. However, instead of sequentially processing the 3 quarter round + // operations represented by one QUARTERROUND function, we instead stack all + // the adds, xors and left-rotations from the first 4 quarter rounds together + // and then do the same for the second set of 4 quarter rounds. This removes + // some latency that would otherwise be incurred by waiting for an add to + // complete before performing an xor (which depends on the result of the + // add), etc. An adjustment happens between the first and second groups of 4 + // quarter rounds, but this is done only in the inputs to the macro functions + // that generate the assembly instructions - these adjustments themselves are + // not part of the resulting assembly. + // The 4 registers v0-v3 are used during the quarter round operations as + // scratch registers. Once the 20 rounds are complete, these 4 scratch + // registers become the vectors involved in adding the start state back onto + // the post-QR working state. After the adds are complete, each of the 16 + // vectors write their first lane back to the keystream buffer, followed + // by the second lane from all vectors and so on. + address generate_chacha20Block_blockpar() { + Label L_twoRounds, L_cc20_const; // The constant data is broken into two 128-bit segments to be loaded - // onto SIMD registers. The first 128 bits are a counter add overlay - // that adds +1/+0/+0/+0 to the vectors holding replicated state[12]. + // onto FloatRegisters. The first 128 bits are a counter add overlay + // that adds +0/+1/+2/+3 to the vector holding replicated state[12]. // The second 128-bits is a table constant used for 8-bit left rotations. - // on 32-bit lanes within a SIMD register. - __ BIND(L_Q_cc20_const); - __ emit_int64(0x0000000000000001UL); - __ emit_int64(0x0000000000000000UL); + __ BIND(L_cc20_const); + __ emit_int64(0x0000000100000000UL); + __ emit_int64(0x0000000300000002UL); __ emit_int64(0x0605040702010003UL); __ emit_int64(0x0E0D0C0F0A09080BUL); @@ -4497,144 +4452,142 @@ class StubGenerator: public StubCodeGenerator { address start = __ pc(); __ enter(); + int i, j; const Register state = c_rarg0; const Register keystream = c_rarg1; const Register loopCtr = r10; const Register tmpAddr = r11; + const FloatRegister ctrAddOverlay = v28; + const FloatRegister lrot8Tbl = v29; + + // Organize SIMD registers in an array that facilitates + // putting repetitive opcodes into loop structures. It is + // important that each grouping of 4 registers is monotonically + // increasing to support the requirements of multi-register + // instructions (e.g. ld4r, st4, etc.) + const FloatRegister workSt[16] = { + v4, v5, v6, v7, v16, v17, v18, v19, + v20, v21, v22, v23, v24, v25, v26, v27 + }; - const FloatRegister aState = v0; - const FloatRegister bState = v1; - const FloatRegister cState = v2; - const FloatRegister dState = v3; - const FloatRegister a1Vec = v4; - const FloatRegister b1Vec = v5; - const FloatRegister c1Vec = v6; - const FloatRegister d1Vec = v7; - // Skip the callee-saved registers v8 - v15 - const FloatRegister a2Vec = v16; - const FloatRegister b2Vec = v17; - const FloatRegister c2Vec = v18; - const FloatRegister d2Vec = v19; - const FloatRegister a3Vec = v20; - const FloatRegister b3Vec = v21; - const FloatRegister c3Vec = v22; - const FloatRegister d3Vec = v23; - const FloatRegister a4Vec = v24; - const FloatRegister b4Vec = v25; - const FloatRegister c4Vec = v26; - const FloatRegister d4Vec = v27; - const FloatRegister scratch = v28; - const FloatRegister addMask = v29; - const FloatRegister lrot8Tbl = v30; - - // Load the initial state in the first 4 quadword registers, - // then copy the initial state into the next 4 quadword registers - // that will be used for the working state. - __ ld1(aState, bState, cState, dState, __ T16B, Address(state)); - - // Load the index register for 2 constant 128-bit data fields. - // The first represents the +1/+0/+0/+0 add mask. The second is - // the 8-bit left rotation. - __ adr(tmpAddr, L_Q_cc20_const); - __ ldpq(addMask, lrot8Tbl, Address(tmpAddr)); - - __ mov(a1Vec, __ T16B, aState); - __ mov(b1Vec, __ T16B, bState); - __ mov(c1Vec, __ T16B, cState); - __ mov(d1Vec, __ T16B, dState); - - __ mov(a2Vec, __ T16B, aState); - __ mov(b2Vec, __ T16B, bState); - __ mov(c2Vec, __ T16B, cState); - __ addv(d2Vec, __ T4S, d1Vec, addMask); - - __ mov(a3Vec, __ T16B, aState); - __ mov(b3Vec, __ T16B, bState); - __ mov(c3Vec, __ T16B, cState); - __ addv(d3Vec, __ T4S, d2Vec, addMask); - - __ mov(a4Vec, __ T16B, aState); - __ mov(b4Vec, __ T16B, bState); - __ mov(c4Vec, __ T16B, cState); - __ addv(d4Vec, __ T4S, d3Vec, addMask); - - // Set up the 10 iteration loop + // Pull in constant data. The first 16 bytes are the add overlay + // which is applied to the vector holding the counter (state[12]). + // The second 16 bytes is the index register for the 8-bit left + // rotation tbl instruction. + __ adr(tmpAddr, L_cc20_const); + __ ldpq(ctrAddOverlay, lrot8Tbl, Address(tmpAddr)); + + // Load from memory and interlace across 16 SIMD registers, + // With each word from memory being broadcast to all lanes of + // each successive SIMD register. + // Addr(0) -> All lanes in workSt[i] + // Addr(4) -> All lanes workSt[i + 1], etc. + __ mov(tmpAddr, state); + for (i = 0; i < 16; i += 4) { + __ ld4r(workSt[i], workSt[i + 1], workSt[i + 2], workSt[i + 3], __ T4S, + __ post(tmpAddr, 16)); + } + __ addv(workSt[12], __ T4S, workSt[12], ctrAddOverlay); // Add ctr overlay + + // Before entering the loop, create 5 4-register arrays. These + // will hold the 4 registers that represent the a/b/c/d fields + // in the quarter round operation. For instance the "b" field + // for the first 4 quarter round operations is the set of v16/v17/v18/v19, + // but in the second 4 quarter rounds it gets adjusted to v17/v18/v19/v16 + // since it is part of a diagonal organization. The aSet and scratch + // register sets are defined at declaration time because they do not change + // organization at any point during the 20-round processing. + FloatRegister aSet[4] = { v4, v5, v6, v7 }; + FloatRegister bSet[4]; + FloatRegister cSet[4]; + FloatRegister dSet[4]; + FloatRegister scratch[4] = { v0, v1, v2, v3 }; + + // Set up the 10 iteration loop and perform all 8 quarter round ops __ mov(loopCtr, 10); - __ BIND(L_Q_twoRounds); - - // The first set of operations on the vectors covers the first 4 quarter - // round operations: - // Qround(state, 0, 4, 8,12) - // Qround(state, 1, 5, 9,13) - // Qround(state, 2, 6,10,14) - // Qround(state, 3, 7,11,15) - __ cc20_quarter_round(a1Vec, b1Vec, c1Vec, d1Vec, scratch, lrot8Tbl); - __ cc20_quarter_round(a2Vec, b2Vec, c2Vec, d2Vec, scratch, lrot8Tbl); - __ cc20_quarter_round(a3Vec, b3Vec, c3Vec, d3Vec, scratch, lrot8Tbl); - __ cc20_quarter_round(a4Vec, b4Vec, c4Vec, d4Vec, scratch, lrot8Tbl); - - // Shuffle the b1Vec/c1Vec/d1Vec to reorganize the state vectors to - // diagonals. The a1Vec does not need to change orientation. - __ cc20_shift_lane_org(b1Vec, c1Vec, d1Vec, true); - __ cc20_shift_lane_org(b2Vec, c2Vec, d2Vec, true); - __ cc20_shift_lane_org(b3Vec, c3Vec, d3Vec, true); - __ cc20_shift_lane_org(b4Vec, c4Vec, d4Vec, true); - - // The second set of operations on the vectors covers the second 4 quarter - // round operations, now acting on the diagonals: - // Qround(state, 0, 5,10,15) - // Qround(state, 1, 6,11,12) - // Qround(state, 2, 7, 8,13) - // Qround(state, 3, 4, 9,14) - __ cc20_quarter_round(a1Vec, b1Vec, c1Vec, d1Vec, scratch, lrot8Tbl); - __ cc20_quarter_round(a2Vec, b2Vec, c2Vec, d2Vec, scratch, lrot8Tbl); - __ cc20_quarter_round(a3Vec, b3Vec, c3Vec, d3Vec, scratch, lrot8Tbl); - __ cc20_quarter_round(a4Vec, b4Vec, c4Vec, d4Vec, scratch, lrot8Tbl); - - // Before we start the next iteration, we need to perform shuffles - // on the b/c/d vectors to move them back to columnar organizations - // from their current diagonal orientation. - __ cc20_shift_lane_org(b1Vec, c1Vec, d1Vec, false); - __ cc20_shift_lane_org(b2Vec, c2Vec, d2Vec, false); - __ cc20_shift_lane_org(b3Vec, c3Vec, d3Vec, false); - __ cc20_shift_lane_org(b4Vec, c4Vec, d4Vec, false); + __ BIND(L_twoRounds); + + // Set to columnar organization and do the following 4 quarter-rounds: + // QUARTERROUND(0, 4, 8, 12) + // QUARTERROUND(1, 5, 9, 13) + // QUARTERROUND(2, 6, 10, 14) + // QUARTERROUND(3, 7, 11, 15) + __ cc20_set_qr_registers(bSet, workSt, 4, 5, 6, 7); + __ cc20_set_qr_registers(cSet, workSt, 8, 9, 10, 11); + __ cc20_set_qr_registers(dSet, workSt, 12, 13, 14, 15); + + __ cc20_qr_add4(aSet, bSet); // a += b + __ cc20_qr_xor4(dSet, aSet, dSet); // d ^= a + __ cc20_qr_lrot4(dSet, dSet, 16, lrot8Tbl); // d <<<= 16 + + __ cc20_qr_add4(cSet, dSet); // c += d + __ cc20_qr_xor4(bSet, cSet, scratch); // b ^= c (scratch) + __ cc20_qr_lrot4(scratch, bSet, 12, lrot8Tbl); // b <<<= 12 + + __ cc20_qr_add4(aSet, bSet); // a += b + __ cc20_qr_xor4(dSet, aSet, dSet); // d ^= a + __ cc20_qr_lrot4(dSet, dSet, 8, lrot8Tbl); // d <<<= 8 + + __ cc20_qr_add4(cSet, dSet); // c += d + __ cc20_qr_xor4(bSet, cSet, scratch); // b ^= c (scratch) + __ cc20_qr_lrot4(scratch, bSet, 7, lrot8Tbl); // b <<<= 12 + + // Set to diagonal organization and do the next 4 quarter-rounds: + // QUARTERROUND(0, 5, 10, 15) + // QUARTERROUND(1, 6, 11, 12) + // QUARTERROUND(2, 7, 8, 13) + // QUARTERROUND(3, 4, 9, 14) + __ cc20_set_qr_registers(bSet, workSt, 5, 6, 7, 4); + __ cc20_set_qr_registers(cSet, workSt, 10, 11, 8, 9); + __ cc20_set_qr_registers(dSet, workSt, 15, 12, 13, 14); + + __ cc20_qr_add4(aSet, bSet); // a += b + __ cc20_qr_xor4(dSet, aSet, dSet); // d ^= a + __ cc20_qr_lrot4(dSet, dSet, 16, lrot8Tbl); // d <<<= 16 + + __ cc20_qr_add4(cSet, dSet); // c += d + __ cc20_qr_xor4(bSet, cSet, scratch); // b ^= c (scratch) + __ cc20_qr_lrot4(scratch, bSet, 12, lrot8Tbl); // b <<<= 12 + + __ cc20_qr_add4(aSet, bSet); // a += b + __ cc20_qr_xor4(dSet, aSet, dSet); // d ^= a + __ cc20_qr_lrot4(dSet, dSet, 8, lrot8Tbl); // d <<<= 8 + + __ cc20_qr_add4(cSet, dSet); // c += d + __ cc20_qr_xor4(bSet, cSet, scratch); // b ^= c (scratch) + __ cc20_qr_lrot4(scratch, bSet, 7, lrot8Tbl); // b <<<= 12 // Decrement and iterate __ sub(loopCtr, loopCtr, 1); - __ cbnz(loopCtr, L_Q_twoRounds); - - // Once the counter reaches zero, we fall out of the loop - // and need to add the initial state back into the working state - // represented by the a/b/c/d1Vec registers. This is destructive - // on the dState register but we no longer will need it. - __ addv(a1Vec, __ T4S, a1Vec, aState); - __ addv(b1Vec, __ T4S, b1Vec, bState); - __ addv(c1Vec, __ T4S, c1Vec, cState); - __ addv(d1Vec, __ T4S, d1Vec, dState); - - __ addv(a2Vec, __ T4S, a2Vec, aState); - __ addv(b2Vec, __ T4S, b2Vec, bState); - __ addv(c2Vec, __ T4S, c2Vec, cState); - __ addv(dState, __ T4S, dState, addMask); - __ addv(d2Vec, __ T4S, d2Vec, dState); - - __ addv(a3Vec, __ T4S, a3Vec, aState); - __ addv(b3Vec, __ T4S, b3Vec, bState); - __ addv(c3Vec, __ T4S, c3Vec, cState); - __ addv(dState, __ T4S, dState, addMask); - __ addv(d3Vec, __ T4S, d3Vec, dState); - - __ addv(a4Vec, __ T4S, a4Vec, aState); - __ addv(b4Vec, __ T4S, b4Vec, bState); - __ addv(c4Vec, __ T4S, c4Vec, cState); - __ addv(dState, __ T4S, dState, addMask); - __ addv(d4Vec, __ T4S, d4Vec, dState); - - // Write the final state back to the result buffer - __ st1(a1Vec, b1Vec, c1Vec, d1Vec, __ T16B, __ post(keystream, 64)); - __ st1(a2Vec, b2Vec, c2Vec, d2Vec, __ T16B, __ post(keystream, 64)); - __ st1(a3Vec, b3Vec, c3Vec, d3Vec, __ T16B, __ post(keystream, 64)); - __ st1(a4Vec, b4Vec, c4Vec, d4Vec, __ T16B, __ post(keystream, 64)); + __ cbnz(loopCtr, L_twoRounds); + + __ mov(tmpAddr, state); + + // Add the starting state back to the post-loop keystream + // state. We read/interlace the state array from memory into + // 4 registers similar to what we did in the beginning. Then + // add the counter overlay onto workSt[12] at the end. + for (i = 0; i < 16; i += 4) { + __ ld4r(v0, v1, v2, v3, __ T4S, __ post(tmpAddr, 16)); + __ addv(workSt[i], __ T4S, workSt[i], v0); + __ addv(workSt[i + 1], __ T4S, workSt[i + 1], v1); + __ addv(workSt[i + 2], __ T4S, workSt[i + 2], v2); + __ addv(workSt[i + 3], __ T4S, workSt[i + 3], v3); + } + __ addv(workSt[12], __ T4S, workSt[12], ctrAddOverlay); // Add ctr overlay + + // Write working state into the keystream buffer. This is accomplished + // by taking the lane "i" from each of the four vectors and writing + // it to consecutive 4-byte offsets, then post-incrementing by 16 and + // repeating with the next 4 vectors until all 16 vectors have been used. + // Then move to the next lane and repeat the process until all lanes have + // been written. + for (i = 0; i < 4; i++) { + for (j = 0; j < 16; j += 4) { + __ st4(workSt[j], workSt[j + 1], workSt[j + 2], workSt[j + 3], __ S, i, + __ post(keystream, 16)); + } + } __ mov(r0, 256); // Return length of output keystream __ leave(); @@ -7008,6 +6961,47 @@ class StubGenerator: public StubCodeGenerator { return start; } + /** + * Arguments: + * + * Inputs: + * c_rarg0 - int crc + * c_rarg1 - byte* buf + * c_rarg2 - int length + * + * Output: + * rax - int crc result + */ + address generate_updateBytesCRC32() { + assert(UseCRC32Intrinsics, "what are we doing here?"); + + __ align(CodeEntryAlignment); + StubGenStubId stub_id = StubGenStubId::updateBytesCRC32_id; + StubCodeMark mark(this, stub_id); + + address start = __ pc(); + + const Register crc = c_rarg0; // crc + const Register buf = c_rarg1; // source java byte array address + const Register len = c_rarg2; // length + const Register table0 = c_rarg3; // crc_table address + const Register table1 = c_rarg4; + const Register table2 = c_rarg5; + const Register table3 = c_rarg6; + const Register tmp3 = c_rarg7; + + BLOCK_COMMENT("Entry:"); + __ enter(); // required for proper stackwalking of RuntimeStub frame + + __ kernel_crc32(crc, buf, len, + table0, table1, table2, table3, rscratch1, rscratch2, tmp3); + + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(lr); + + return start; + } + /** * Arguments: * @@ -11403,7 +11397,7 @@ class StubGenerator: public StubCodeGenerator { #endif // COMPILER2 if (UseChaCha20Intrinsics) { - StubRoutines::_chacha20Block = generate_chacha20Block_qrpar(); + StubRoutines::_chacha20Block = generate_chacha20Block_blockpar(); } if (UseKyberIntrinsics) { From e020752ea4a6f74c321bc83597fadac51332e188 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Tue, 22 Apr 2025 16:55:11 +0000 Subject: [PATCH 056/901] 8354484: SIGSEGV when supertype of an AOT-cached class is excluded Reviewed-by: ccheung, shade --- src/hotspot/share/cds/aotArtifactFinder.cpp | 29 +++++++++++++++++++-- src/hotspot/share/cds/aotArtifactFinder.hpp | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/cds/aotArtifactFinder.cpp b/src/hotspot/share/cds/aotArtifactFinder.cpp index 95d242c2089..65eb06ca7f0 100644 --- a/src/hotspot/share/cds/aotArtifactFinder.cpp +++ b/src/hotspot/share/cds/aotArtifactFinder.cpp @@ -207,11 +207,36 @@ void AOTArtifactFinder::add_aot_inited_class(InstanceKlass* ik) { } } +void AOTArtifactFinder::append_to_all_cached_classes(Klass* k) { + precond(!SystemDictionaryShared::should_be_excluded(k)); + _all_cached_classes->append(k); +} + void AOTArtifactFinder::add_cached_instance_class(InstanceKlass* ik) { + if (CDSConfig::is_dumping_dynamic_archive() && ik->is_shared()) { + // This class is already included in the base archive. No need to cache + // it again in the dynamic archive. + return; + } + bool created; _seen_classes->put_if_absent(ik, &created); if (created) { - _all_cached_classes->append(ik); + append_to_all_cached_classes(ik); + + // All super types must be added. + InstanceKlass* s = ik->java_super(); + if (s != nullptr) { + add_cached_instance_class(s); + } + + Array* interfaces = ik->local_interfaces(); + int len = interfaces->length(); + for (int i = 0; i < len; i++) { + InstanceKlass* intf = interfaces->at(i); + add_cached_instance_class(intf); + } + if (CDSConfig::is_dumping_final_static_archive() && ik->is_shared_unregistered_class()) { // The following are not appliable to unregistered classes return; @@ -229,7 +254,7 @@ void AOTArtifactFinder::add_cached_type_array_class(TypeArrayKlass* tak) { bool created; _seen_classes->put_if_absent(tak, &created); if (created) { - _all_cached_classes->append(tak); + append_to_all_cached_classes(tak); scan_oops_in_array_class(tak); } } diff --git a/src/hotspot/share/cds/aotArtifactFinder.hpp b/src/hotspot/share/cds/aotArtifactFinder.hpp index d890d874af9..5d293f20af0 100644 --- a/src/hotspot/share/cds/aotArtifactFinder.hpp +++ b/src/hotspot/share/cds/aotArtifactFinder.hpp @@ -79,6 +79,7 @@ class AOTArtifactFinder : AllStatic { static void scan_oops_in_array_class(ArrayKlass* ak); static void add_cached_type_array_class(TypeArrayKlass* tak); static void add_cached_instance_class(InstanceKlass* ik); + static void append_to_all_cached_classes(Klass* k); public: static void initialize(); static void find_artifacts(); From f98af0ad617a445362859e58af48258bfd5bed03 Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 22 Apr 2025 17:31:31 +0000 Subject: [PATCH 057/901] 8354701: Open source few JToolTip tests Reviewed-by: honkar --- .../jdk/javax/swing/JToolTip/TooltipTest.java | 90 +++++++++++++++++++ test/jdk/javax/swing/JToolTip/bug4225314.java | 72 +++++++++++++++ test/jdk/javax/swing/JToolTip/bug4255441.java | 64 +++++++++++++ 3 files changed, 226 insertions(+) create mode 100644 test/jdk/javax/swing/JToolTip/TooltipTest.java create mode 100644 test/jdk/javax/swing/JToolTip/bug4225314.java create mode 100644 test/jdk/javax/swing/JToolTip/bug4255441.java diff --git a/test/jdk/javax/swing/JToolTip/TooltipTest.java b/test/jdk/javax/swing/JToolTip/TooltipTest.java new file mode 100644 index 00000000000..c081730a8d7 --- /dev/null +++ b/test/jdk/javax/swing/JToolTip/TooltipTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4207474 4218495 4375928 + * @summary Tests various tooltip issues: HTML tooltips, long tooltip text + * and mnemonic keys displayed in tooltips + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TooltipTest + */ + +import java.awt.FlowLayout; +import java.awt.event.KeyEvent; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.UIManager; + +public class TooltipTest { + private static final String INSTRUCTIONS = """ + 1. Move the mouse over the button labeled "Red tip" and let it stay + still in order to test HTML in JToolTip. If the tooltip has some + text which is red then test passes, otherwise it fails (bug 4207474). + + 2. Move the mouse over the button labeled "Long tip". + If the last letter of the tooltip appears clipped, + then the test fails. If you can see the entire last character, + then the test passes (bug 4218495). + + 3. Verify that "M" is underlined on the button labeled "Mnemonic" + Move the mouse pointer over the button labeled "Mnemonic" and look + at tooltip when it appears. It should read "hint". + If the above is true test passes else test fails (bug 4375928). + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + + PassFailJFrame.builder() + .title("TooltipTest Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(TooltipTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + + JButton b = new JButton("Red tip"); + b.setToolTipText("

Here is some " + + "red text.
"); + panel.add(b); + + b = new JButton("Long tip"); + b.setToolTipText("Is the last letter clipped?"); + panel.add(b); + + b = new JButton("Mnemonic"); + b.setMnemonic(KeyEvent.VK_M); + b.setToolTipText("hint"); + panel.add(b); + + return panel; + } +} diff --git a/test/jdk/javax/swing/JToolTip/bug4225314.java b/test/jdk/javax/swing/JToolTip/bug4225314.java new file mode 100644 index 00000000000..d36bd461272 --- /dev/null +++ b/test/jdk/javax/swing/JToolTip/bug4225314.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4225314 + * @summary Tests that tooltip is painted properly when it has thick border + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4225314 + */ + +import java.awt.Color; +import java.awt.FlowLayout; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JToolTip; +import javax.swing.border.LineBorder; + +public class bug4225314 { + private static final String INSTRUCTIONS = """ + The word "Tooltip" in both tooltips should not be clipped by the + black border and be fully visible for this test to pass. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4225314 Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4225314::createTestUI) + .build() + .awaitAndCheck(); + } + + private static JComponent createTestUI() { + JToolTip tt1 = new JToolTip(); + tt1.setTipText("Tooltip"); + tt1.setBorder(new LineBorder(Color.BLACK, 10)); + + JToolTip tt2 = new JToolTip(); + tt2.setTipText("Tooltip"); + tt2.setBorder(new LineBorder(Color.BLACK, 10)); + + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + panel.add(tt1); + panel.add(tt2); + + return panel; + } +} diff --git a/test/jdk/javax/swing/JToolTip/bug4255441.java b/test/jdk/javax/swing/JToolTip/bug4255441.java new file mode 100644 index 00000000000..4a90c975502 --- /dev/null +++ b/test/jdk/javax/swing/JToolTip/bug4255441.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4255441 + * @summary Tests that tooltip appears inside AWT Frame + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4255441 + */ + +import java.awt.FlowLayout; +import java.awt.Frame; +import javax.swing.JButton; + +public class bug4255441 { + private static final String INSTRUCTIONS = """ + Move mouse pointer inside the button. + If a tooltip with "Tooltip text" appears, the test passes. + """; + + private static Frame createTestUI() { + Frame fr = new Frame("bug4255441"); + fr.setLayout(new FlowLayout()); + + JButton bt = new JButton("Button"); + bt.setToolTipText("Tooltip text"); + fr.add(bt); + + fr.setSize(200, 200); + return fr; + } + + public static void main(String[] argv) throws Exception { + PassFailJFrame.builder() + .title("bug4255441 Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4255441::createTestUI) + .build() + .awaitAndCheck(); + } +} From 486a66469bc0c814d07e03ce0e7231b408a4d579 Mon Sep 17 00:00:00 2001 From: Harshitha Onkar Date: Tue, 22 Apr 2025 17:49:52 +0000 Subject: [PATCH 058/901] 8353486: Open source Swing Tests - Set 4 Reviewed-by: azvegint, dnguyen, tr --- .../javax/swing/JFileChooser/bug4464774.java | 62 +++++++++ .../javax/swing/JFileChooser/bug4522756.java | 64 +++++++++ .../javax/swing/JFileChooser/bug4759934.java | 124 ++++++++++++++++++ .../javax/swing/JFileChooser/bug4943900.java | 118 +++++++++++++++++ .../javax/swing/JOptionPane/bug4194862.java | 94 +++++++++++++ 5 files changed, 462 insertions(+) create mode 100644 test/jdk/javax/swing/JFileChooser/bug4464774.java create mode 100644 test/jdk/javax/swing/JFileChooser/bug4522756.java create mode 100644 test/jdk/javax/swing/JFileChooser/bug4759934.java create mode 100644 test/jdk/javax/swing/JFileChooser/bug4943900.java create mode 100644 test/jdk/javax/swing/JOptionPane/bug4194862.java diff --git a/test/jdk/javax/swing/JFileChooser/bug4464774.java b/test/jdk/javax/swing/JFileChooser/bug4464774.java new file mode 100644 index 00000000000..368063e46cd --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4464774.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2003, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4464774 + * @requires (os.family == "windows") + * @summary JFileChooser: selection of left-side folder buttons shown incorrectly + in Windows L&F + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4464774 + */ + +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4464774 { + private static final String INSTRUCTIONS = """ + Click any button from the buttons to the left + ("Documents", "Desktop", "My Computer" etc.) in FileChooser dialog. + When the button is toggled, it should be lowered and + should NOT have focus painted inside it (black dotted frame). + + If the above is true, press PASS else FAIL. + """; + + public static void main(String[] argv) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(65) + .rows(10) + .testUI(() -> { + JFileChooser jfc = new JFileChooser(); + jfc.setControlButtonsAreShown(false); + return jfc; + }) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/javax/swing/JFileChooser/bug4522756.java b/test/jdk/javax/swing/JFileChooser/bug4522756.java new file mode 100644 index 00000000000..87c430cfb1d --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4522756.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2002, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4522756 + * @requires (os.family == "windows") + * @summary Verifies that the Desktop icon is not missing when + JFileChooser is opened for the first time. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4522756 + */ + +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4522756 { + private static final String INSTRUCTIONS = """ + Verify the following: + + 1. If Desktop icon image is present on the Desktop button + on the left panel of JFileChooser. + 2. Press Desktop button. Check that you actually + go up to the desktop. + + If the above is true, press PASS else FAIL. + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(50) + .rows(12) + .testUI(() -> { + JFileChooser jfc = new JFileChooser(); + jfc.setControlButtonsAreShown(false); + return jfc; + }) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/javax/swing/JFileChooser/bug4759934.java b/test/jdk/javax/swing/JFileChooser/bug4759934.java new file mode 100644 index 00000000000..08ccdebfb2b --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4759934.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2003, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key headful + * @bug 4759934 + * @summary windows activation problem + * @library /javax/swing/regtesthelpers + * @build Util + * @run main bug4759934 + */ + +import java.awt.Dialog; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class bug4759934 { + private static JFrame fr; + private static Dialog dlg; + private static JFileChooser jfc; + + private static JButton frameBtn; + private static JButton dialogBtn; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(bug4759934::createTestUI); + robot.waitForIdle(); + robot.delay(1000); + + Point frameBtnLoc = Util.getCenterPoint(frameBtn); + robot.mouseMove(frameBtnLoc.x, frameBtnLoc.y); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(500); + + Point dlgBtnLoc = Util.getCenterPoint(dialogBtn); + robot.mouseMove(dlgBtnLoc.x , dlgBtnLoc.y); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(500); + + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.delay(500); + + SwingUtilities.invokeAndWait(() -> { + if (frameBtn.hasFocus() && !dialogBtn.hasFocus()) { + throw new RuntimeException("Test failed! Focus was passed back" + + " to Frame instead of Dialog"); + } + }); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (dlg != null) { + dlg.dispose(); + } + if (fr != null) { + fr.dispose(); + } + }); + } + } + + private static void createTestUI() { + fr = new JFrame("bug4759934 - JFrame"); + + frameBtn = new JButton("Show Dialog"); + frameBtn.addActionListener(e -> createDialog()); + fr.add(frameBtn); + + fr.setSize(300, 200); + fr.setLocationRelativeTo(null); + fr.setVisible(true); + } + + private static void createDialog() { + dlg = new JDialog(fr, "bug4759934 - JDialog"); + + dialogBtn = new JButton("Show FileChooser"); + dlg.add(dialogBtn); + + dialogBtn.addActionListener(e -> { + jfc = new JFileChooser(); + jfc.showOpenDialog(dlg); + }); + + dlg.setSize(300, 200); + dlg.setLocation(fr.getX() + fr.getWidth() + 10, fr.getY()); + dlg.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JFileChooser/bug4943900.java b/test/jdk/javax/swing/JFileChooser/bug4943900.java new file mode 100644 index 00000000000..0cea17e764c --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4943900.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4943900 + * @summary Tests that FileFilter combo box is shown in FileChooser + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4943900 + */ + +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.UIManager; +import javax.swing.filechooser.FileFilter; + +public class bug4943900 { + private static final String INSTRUCTIONS = """ + +
    +
  1. When the test runs, a JFileChooser will be displayed. +
  2. Ensure that there is a filter combo box with these two items: +
      +
    • Text Files (*.txt) + — [must be selected when the dialog opens] +
    • All Files +
    +
  3. Leave the Text files item selected and check that the + filter works: only *.txt files can appear in the file list. + You can navigate directories in the file chooser and find one + that contains some *.txt files to ensure they are shown in + the file list. On macOS when the text filter is applied verify + that the non-text files are greyed out. +
  4. Try switching the filters and ensure that the file list + is updated properly. +
  5. If the FileFilter works correctly, + press Pass else press Fail. +
+ + """; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + + PassFailJFrame.builder() + .title("bug4943900 Test Instructions") + .instructions(INSTRUCTIONS) + .rows(14) + .columns(50) + .testUI(bug4943900::createAndShowUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createAndShowUI() { + JFileChooser fc = new JFileChooser(); + fc.setControlButtonsAreShown(false); + TextFileFilter filter = new TextFileFilter(); + fc.setFileFilter(filter); + + JFrame frame = new JFrame("bug4943900 - JFileChooser"); + frame.add(fc); + frame.pack(); + return frame; + } + + private static final class TextFileFilter extends FileFilter { + @Override + public boolean accept(File f) { + if (f != null) { + if (f.isDirectory()) { + return true; + } + String extension = getExtension(f); + return extension != null && extension.equals("txt"); + } + return false; + } + + @Override + public String getDescription() { + return "Text Files (*.txt)"; + } + + private static String getExtension(File f) { + if (f != null) { + String filename = f.getName(); + int i = filename.lastIndexOf('.'); + if (i > 0 && i < filename.length() - 1) { + return filename.substring(i + 1).toLowerCase(); + } + } + return null; + } + } +} diff --git a/test/jdk/javax/swing/JOptionPane/bug4194862.java b/test/jdk/javax/swing/JOptionPane/bug4194862.java new file mode 100644 index 00000000000..2a2822ebf1d --- /dev/null +++ b/test/jdk/javax/swing/JOptionPane/bug4194862.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4194862 + * @summary Tests that internal frame-based dialogs are centered relative + to their parents + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4194862 + */ + +import javax.swing.JButton; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; + +public class bug4194862 { + private static final String INSTRUCTIONS = """ + In the internal frame titled "Main", + click the "Show JOptionPane Dialog" button. + A dialog will appear. It should be centered with + respect to the JInternalFrame - "Main". + + If the above is true then click on JOptionPane's "YES" button + to PASS else click JOptionPane's "NO" button to FAIL the test. + """; + + public static void main(String[] args) throws Exception{ + PassFailJFrame.builder() + .title("Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4194862::createAndShowUI) + .screenCapture() + .build() + .awaitAndCheck(); + } + + private static JFrame createAndShowUI() { + JFrame frame = new JFrame("bug4194862 - JInternalFrame JOptionPane"); + JDesktopPane desktop = new JDesktopPane(); + frame.add(desktop); + JInternalFrame jInternalFrame = new JInternalFrame("Main", true); + desktop.add(jInternalFrame); + jInternalFrame.setBounds(5, 30, 390, 240); + jInternalFrame.setVisible(true); + + JButton b = new JButton("Show JOptionPane Dialog"); + b.addActionListener(e -> { + int retVal = JOptionPane.showInternalConfirmDialog( + jInternalFrame, "Am I centered?", + "bug4194862 JOptionPane", JOptionPane.YES_NO_OPTION); + switch (retVal) { + case JOptionPane.YES_OPTION -> PassFailJFrame.forcePass(); + case JOptionPane.NO_OPTION -> + PassFailJFrame.forceFail("JOptionPane isn't centered" + + " within JInternalFrame \"Main\""); + } + }); + jInternalFrame.add(b); + + for (int i = 0; i < 4; i++) { + JInternalFrame f = new JInternalFrame("JIF: "+ i); + f.setBounds(i * 50, i * 33, 120, 120); + f.setVisible(true); + desktop.add(f); + } + frame.setSize(450, 400); + return frame; + } +} From d61765f64d6361b6e71c6f783c8c5a127b1ac745 Mon Sep 17 00:00:00 2001 From: Alisen Chung Date: Tue, 22 Apr 2025 17:56:04 +0000 Subject: [PATCH 059/901] 8353488: Open some JComboBox bugs 3 Reviewed-by: kizune --- .../jdk/javax/swing/JComboBox/bug4135833.java | 62 ++++++++++++ .../jdk/javax/swing/JComboBox/bug4171819.java | 89 +++++++++++++++++ .../jdk/javax/swing/JComboBox/bug4248128.java | 80 ++++++++++++++++ .../jdk/javax/swing/JComboBox/bug4436376.java | 95 +++++++++++++++++++ 4 files changed, 326 insertions(+) create mode 100644 test/jdk/javax/swing/JComboBox/bug4135833.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4171819.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4248128.java create mode 100644 test/jdk/javax/swing/JComboBox/bug4436376.java diff --git a/test/jdk/javax/swing/JComboBox/bug4135833.java b/test/jdk/javax/swing/JComboBox/bug4135833.java new file mode 100644 index 00000000000..3b2888c862d --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4135833.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JPanel; + +/* + * @test + * @bug 4135833 + * @summary Tests that JComboBox draws correctly if the first item in list is an empty string + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4135833 + */ + +public class bug4135833 { + private static final String INSTRUCTIONS = """ + Press the combo box. If the popup is readable and appears to be sized properly, + then it passes. The First item is blank intentionally. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4135833::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + JFrame frame = new JFrame("bug4135833"); + JPanel panel = new JPanel(); + JComboBox comboBox = new JComboBox(new Object[]{"", "Bob", "Hank", "Joe", "Fred"}); + panel.add(comboBox); + frame.add(panel); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4171819.java b/test/jdk/javax/swing/JComboBox/bug4171819.java new file mode 100644 index 00000000000..108512edf7e --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4171819.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 1998, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.UIManager; + +/* + * @test + * @bug 4171819 + * @summary Tests that JComboBox uses a lower bevel border in windows + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4171819 + */ + +public class bug4171819 { + static boolean lafOk = true; + + private static final String INSTRUCTIONS = """ + This test is for Windows L&F only. If you see + "No Windows L&F installed" label just press "Pass". + + Look at the combo box. If the border around it looks like it's + lowered rather than raised, it passes the test. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("Instructions") + .instructions(INSTRUCTIONS) + .columns(50) + .testUI(bug4171819::createTestUI) + .build() + .awaitAndCheck(); + } + + public static JFrame createTestUI() { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + System.out.println("succeeded"); + } catch (Exception e) { + System.err.println("Couldn't load the Windows Look and Feel"); + lafOk = false; + } + + JFrame frame = new JFrame("bug4171819"); + JPanel panel = new JPanel(); + JComboBox comboBox; + + if (lafOk) { + comboBox = new JComboBox(new Object[]{ + "Coma Berenices", + "Triangulum", + "Camelopardis", + "Cassiopea"}); + panel.add(comboBox); + } else { + JLabel label = new JLabel("No Windows L&F installed"); + panel.add(label); + } + frame.add(panel); + frame.pack(); + return frame; + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4248128.java b/test/jdk/javax/swing/JComboBox/bug4248128.java new file mode 100644 index 00000000000..311cae4b61a --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4248128.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Robot; +import java.awt.event.KeyEvent; +import javax.swing.BoxLayout; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4248128 7148092 + * @summary Tests that alt+down arrow pulls down JComboBox popup + * @key headful + * @run main bug4248128 + */ + +public class bug4248128 { + static JFrame frame; + static volatile JComboBox combo; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(250); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_ALT); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + if (!combo.isPopupVisible()) { + throw new RuntimeException("Popup did not appear."); + } + }); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("4248128 Test"); + Object[] fruits = {"Banana", "Pear", "Apple"}; + combo = new JComboBox(fruits); + frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.X_AXIS)); + frame.add(combo); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JComboBox/bug4436376.java b/test/jdk/javax/swing/JComboBox/bug4436376.java new file mode 100644 index 00000000000..064efe8c958 --- /dev/null +++ b/test/jdk/javax/swing/JComboBox/bug4436376.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.awt.event.InputEvent; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/* + * @test + * @bug 4436376 + * @key headful + * @summary Tests that ComboBox items can't be deselected with Ctrl+click + * @run main bug4436376 + */ + +public class bug4436376 { + static JFrame frame; + static volatile Point p; + static volatile JComboBox combo; + + final static int SELECTED_INDEX = 2; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(250); + SwingUtilities.invokeAndWait(() -> createTestUI()); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> p = combo.getLocationOnScreen()); + robot.waitForIdle(); + + robot.mouseMove(p.x + 10, p.y + 10); + robot.waitForIdle(); + + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + if (combo.getSelectedIndex() != SELECTED_INDEX) { + throw new RuntimeException("Failed: selected index has been changed"); + } + }); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public static void createTestUI() { + frame = new JFrame("bug4436376"); + String[] items = new String[]{"One", "Two", "Three", "Four"}; + combo = new JComboBox(items); + combo.setSelectedIndex(SELECTED_INDEX); + + frame.setLayout(new FlowLayout()); + frame.add(combo); + frame.setLocationRelativeTo(null); + frame.pack(); + frame.setVisible(true); + } +} From 239760ac09c78a9c989df54f6526b67448540eda Mon Sep 17 00:00:00 2001 From: Eric Caspole Date: Tue, 22 Apr 2025 19:59:41 +0000 Subject: [PATCH 060/901] 8355233: Add a DMB related benchmark Reviewed-by: kvn --- .../openjdk/bench/vm/compiler/DMBCheck.java | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 test/micro/org/openjdk/bench/vm/compiler/DMBCheck.java diff --git a/test/micro/org/openjdk/bench/vm/compiler/DMBCheck.java b/test/micro/org/openjdk/bench/vm/compiler/DMBCheck.java new file mode 100644 index 00000000000..0552e52fb02 --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/compiler/DMBCheck.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.bench.vm.compiler; + +import java.util.concurrent.TimeUnit; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.CompilerControl; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Group; +import org.openjdk.jmh.annotations.GroupThreads; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OperationsPerInvocation; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; + +@BenchmarkMode(Mode.Throughput) +@State(Scope.Benchmark) +@OutputTimeUnit(TimeUnit.MICROSECONDS) +@Warmup(iterations = 8, time = 4) +@Measurement(iterations = 6, time = 3) +public class DMBCheck { + + // The allocations of DoubleDMB$A and DoubleDMB$C + // will cause aarch64 dmb barrier instructions. + // The different latency of the dmb ish/ishst/ishld modes + // may make a noticeable difference in the benchmark results. + // These modes may be set by cpu defaults or XX options. + + class A { + + final String b = new String("Hi there"); + } + + class C { + + private A a; + + public A getA() { + if (a == null) { + a = new A(); + } + return a; + } + } + + static C c = null; + + @Setup + public void setup() { + c = new C(); + } + + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + void action(Blackhole b) throws Exception { + c = new C(); + + if (c.getA().b == null) { + throw new Exception("a should not be null"); + } + b.consume(c); + } + + @Benchmark + @Fork(value = 1, jvmArgs = { + "-XX:+UnlockDiagnosticVMOptions", "-XX:+AlwaysMergeDMB", "-XX:+IgnoreUnrecognizedVMOptions"}) + public void plusAlwaysMergeDMB(Blackhole b) throws Exception { + + action(b); + } + + @Benchmark + @Fork(value = 1, jvmArgs = { + "-XX:+UnlockDiagnosticVMOptions", "-XX:-AlwaysMergeDMB", "-XX:+IgnoreUnrecognizedVMOptions"}) + public void minusAlwaysMergeDMB(Blackhole b) throws Exception { + + action(b); + } + +} From 1b8f760d1b60e63c1391dcad42753a7ebb3f80ec Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Tue, 22 Apr 2025 20:17:01 +0000 Subject: [PATCH 061/901] 8354928: Clean up and open source some miscellaneous AWT tests Reviewed-by: prr, dnguyen --- .../event/InputEvent/InputEventTimeTest.java | 115 +++++++++++++ .../event/MouseWheelEvent/HWWheelScroll.java | 160 ++++++++++++++++++ .../MouseWheelEvent/WheelEventCoord.java | 95 +++++++++++ .../MouseWheelEvent/WheelScrollEnabled.java | 129 ++++++++++++++ 4 files changed, 499 insertions(+) create mode 100644 test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java create mode 100644 test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java create mode 100644 test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java create mode 100644 test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java diff --git a/test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java b/test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java new file mode 100644 index 00000000000..38339f8e877 --- /dev/null +++ b/test/jdk/java/awt/event/InputEvent/InputEventTimeTest.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4176525 + * @summary InputEvent.getWhen() returns the wrong event time. + * @key headful + * @run main InputEventTimeTest + */ + +import java.awt.AWTEvent; +import java.awt.AWTException; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; +import java.util.Date; + +public class InputEventTimeTest extends Frame { + public void initUI() { + setTitle("Input Event Time Test"); + enableEvents(AWTEvent.MOUSE_EVENT_MASK); + enableEvents(AWTEvent.KEY_EVENT_MASK); + setSize(200, 200); + setLocationRelativeTo(null); + setVisible(true); + } + + public void center(Point point) { + Point loc = getLocationOnScreen(); + Dimension size = getSize(); + point.setLocation(loc.x + (size.width / 2), loc.y + (size.height / 2)); + } + + public void processEvent(AWTEvent e) { + long currentTime; + long eventTime; + long difference; + + if (!(e instanceof InputEvent)) { + return; + } + + currentTime = (new Date()).getTime(); + eventTime = ((InputEvent) e).getWhen(); + difference = currentTime - eventTime; + + if ((difference > 5000) || (difference < -5000)) { + throw new RuntimeException("The difference between current time" + + " and event creation time is " + difference + "ms"); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException { + InputEventTimeTest test = new InputEventTimeTest(); + try { + EventQueue.invokeAndWait(test::initUI); + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.waitForIdle(); + robot.delay(1000); + Point center = new Point(); + EventQueue.invokeAndWait(() -> test.center(center)); + robot.mouseMove(center.x, center.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON2_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + for (int i = 0; i < 6; i++) { + robot.keyPress(KeyEvent.VK_A + i); + robot.keyRelease(KeyEvent.VK_A + i); + robot.waitForIdle(); + } + for (int i = 0; i < 150; i += 5) { + robot.mouseMove(center.x - i, center.y - i); + } + for (int i = 150; i > 0; i -= 5) { + robot.mouseMove(center.x - i, center.y - i); + } + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } +} diff --git a/test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java b/test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java new file mode 100644 index 00000000000..2851ff668fe --- /dev/null +++ b/test/jdk/java/awt/event/MouseWheelEvent/HWWheelScroll.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4425654 + * @summary Test wheel scrolling of heavyweight components + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual HWWheelScroll + */ + +import java.awt.Choice; +import java.awt.FileDialog; +import java.awt.Frame; +import java.awt.List; +import java.awt.TextArea; +import java.awt.Window; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; + +public class HWWheelScroll { + public static final int TEXT_TALL = 0; + public static final int TEXT_WIDE = 1; + public static final int TEXT_SMALL = 2; + public static final int TEXT_BIG = 3; + static String INSTRUCTIONS = """ + Test for mouse wheel scrolling of heavyweight components with built-in + scrollbars or similar functionality that is controlled by guestures + such as Apple Magic Mouse or trackpad scrolling guesture. + Several windows containing either a TextArea, List, Choice, or a + FileDialog will appear. For each window, use the mouse wheel to + scroll its content, and then minimize it or move away + and continue with the next window. + Do not close any of the opened windows except the FileDialog. + For the FileDialog, first change to a directory with enough items that a + scrollbar appears. + Some of the other windows don't have enough text to warrant scrollbars, + but should be tested anyway to make sure no crash or hang occurs. + If all scrollbars scroll correctly, press "Pass", otherwise press "Fail". + """; + + public static ArrayList initUI() { + ArrayList retValue = new ArrayList<>(); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_BOTH, TEXT_BIG)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_BOTH, TEXT_TALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_BOTH, TEXT_SMALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_BOTH, TEXT_WIDE)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_VERTICAL_ONLY, TEXT_TALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_VERTICAL_ONLY, TEXT_SMALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_HORIZONTAL_ONLY, TEXT_SMALL)); + retValue.add(makeTextFrame(TextArea.SCROLLBARS_HORIZONTAL_ONLY, TEXT_WIDE)); + retValue.add(makeListFrame(TEXT_TALL)); + retValue.add(makeListFrame(TEXT_WIDE)); + retValue.add(makeListFrame(TEXT_SMALL)); + Frame f = new Frame("File Dialog Owner"); + f.setSize(150, 150); + f.setLocationRelativeTo(null); + FileDialog fd = new FileDialog(f, "FileDialog"); + fd.setDirectory("."); + retValue.add(fd); + retValue.add(f); + Frame choiceFrame = new Frame("Choice"); + Choice c = new Choice(); + for (int i = 0; i < 50; i++) { + c.add(i + " choice item"); + } + choiceFrame.add(c); + choiceFrame.setSize(150, 150); + choiceFrame.setLocationRelativeTo(null); + retValue.add(choiceFrame); + return retValue; + } + + public static Frame makeTextFrame(int policy, int textShape) { + Frame f = new Frame("TextArea"); + f.add(makeTextArea(policy, textShape)); + f.setSize(150, 150); + f.setLocationRelativeTo(null); + return f; + } + + public static Frame makeListFrame(int textShape) { + Frame f = new Frame("List"); + f.add(makeList(textShape)); + f.setSize(150, 150); + f.setLocationRelativeTo(null); + return f; + } + + public static TextArea makeTextArea(int policy, int textShape) { + TextArea ta = new TextArea("", 0, 0, policy); + if (textShape == TEXT_TALL) { + for (int i = 0; i < 50 ; i++) { + ta.append(i + "\n"); + } + } else if (textShape == TEXT_WIDE) { + for (int i = 0; i < 2; i++) { + ta.append(i + "very, very, very, very, very, very, very, long line of text number\n"); + } + } else if (textShape == TEXT_SMALL) { + ta.append("text"); + } else if (textShape == TEXT_BIG) { + for (int i = 0; i < 50 ; i++) { + ta.append(i + "very, very, very, very, very, very, very, long line of text number\n"); + } + } + return ta; + } + + public static List makeList(int textShape) { + java.awt.List l = new java.awt.List(); + if (textShape == TEXT_TALL) { + for (int i = 0; i < 50 ; i++) { + l.add(" " + i + " "); + } + } else if (textShape == TEXT_WIDE) { + for (int i = 0; i < 2 ; i++) { + l.add(i + "very, very, very, very, very, very, very, long line of text number"); + } + } else if (textShape == TEXT_SMALL) { + l.add("text"); + } else if (textShape == TEXT_BIG) { + for (int i = 0; i < 50 ; i++) { + l.add(i + "very, very, very, very, very, very, very, long line of text number"); + } + } + return l; + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(HWWheelScroll::initUI) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java b/test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java new file mode 100644 index 00000000000..418151d3798 --- /dev/null +++ b/test/jdk/java/awt/event/MouseWheelEvent/WheelEventCoord.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4492456 + * @summary MouseWheelEvent coordinates are wrong + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WheelEventCoord + */ + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GridLayout; +import java.lang.reflect.InvocationTargetException; + +public class WheelEventCoord extends Frame { + static String INSTRUCTIONS = """ + This test requires mouse with scrolling wheel or device, + that has capability to simulate scrolling wheel with gestures + such as Apple mouse or a trackpad with gesture control. + If you do not have such device press "Pass". + Move mouse to the top of the button named "Button 1". + While constantly turning mouse wheel up and down slowly move + mouse cursor until it reaches bottom of the button named "Button 3". + While doing so look at the log area. + If despite the wheel direction y coordinate is steadily increases + as you move the mouse down press "Pass". + If y coordinate decreases when cursor is moving down or suddenly jumps + by more than 50 points when crossing to another button press "Fail". + """; + + public WheelEventCoord() { + super("Wheel Event Coordinates"); + setLayout(new GridLayout(3, 1)); + + add(new BigButton("Button 1")); + add(new BigButton("Button 2")); + add(new BigButton("Button 3")); + + addMouseWheelListener(e -> PassFailJFrame.log("Mouse y coordinate = " + e.getY())); + pack(); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Wheel Event Coordinates Instructions") + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(WheelEventCoord::new) + .build() + .awaitAndCheck(); + } +} + +class BigButton extends Button { + public BigButton(String label) { + super(label); + } + + public Dimension getPreferredSize() { + return new Dimension(300, 100); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + public Dimension getMaximumSize() { + return getPreferredSize(); + } +} diff --git a/test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java b/test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java new file mode 100644 index 00000000000..cbdd7676e94 --- /dev/null +++ b/test/jdk/java/awt/event/MouseWheelEvent/WheelScrollEnabled.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4372477 + * @summary Test disabling of wheel scrolling + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual WheelScrollEnabled + */ + +import java.awt.BorderLayout; +import java.awt.Checkbox; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.Panel; +import java.awt.ScrollPane; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.lang.reflect.InvocationTargetException; + +public class WheelScrollEnabled extends Frame { + static String INSTRUCTIONS = """ + This test requires mouse with a scrolling wheel or + device that is able to simulate scrolling using gestures. + If you do not have such device press "Pass" to skip testing. + You should see a ScrollPane with some labels in it and two checkboxes. + For each of the four combinations of the two checkboxes, + move the cursor over the ScrollPane and rotate the mouse wheel. + When (and ONLY when) the 'WheelListener added' checkbox is checked, + scrolling the mouse wheel should produce a text message in the log area. + When (and ONLY when) the 'Wheel scrolling enabled' checkbox is checked, + the ScrollPane should scroll when mouse wheel is scrolled on top of it. + If all four checkbox combinations work properly press "Pass", + otherwise press "Fail". + """; + MouseWheelListener mwl; + Checkbox cb; + Checkbox cb2; + ScrollPane sp; + + public WheelScrollEnabled() { + setLayout(new BorderLayout()); + Panel pnl = new Panel(); + pnl.setLayout(new GridLayout(10, 10)); + for (int i = 0; i < 100; i++) { + pnl.add(new Label("Label " + i)); + } + sp = new ScrollPane(); + sp.add(pnl); + sp.setWheelScrollingEnabled(false); + mwl = new MouseWheelListener() { + int i; + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + PassFailJFrame.log("mouseWheelMoved " + i++); + } + }; + sp.addMouseWheelListener(mwl); + add(sp, BorderLayout.CENTER); + + Panel pl2 = new Panel(); + ItemListener il = new ControlListener(); + + cb = new Checkbox("WheelListener added", true); + cb.addItemListener(il); + pl2.add(cb); + + cb2 = new Checkbox("Wheel scrolling enabled", false); + cb2.addItemListener(il); + pl2.add(cb2); + + add(pl2, BorderLayout.SOUTH); + setSize(400, 200); + } + + class ControlListener implements ItemListener { + public void itemStateChanged(ItemEvent e) { + if (e.getSource() == cb) { + boolean state = cb.getState(); + if (state) { + sp.addMouseWheelListener(mwl); + } + else { + sp.removeMouseWheelListener(mwl); + } + } + if (e.getSource() == cb2) { + sp.setWheelScrollingEnabled(cb2.getState()); + } + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Wheel Scroll Enabled Instructions") + .instructions(INSTRUCTIONS) + .logArea(10) + .testUI(WheelScrollEnabled::new) + .build() + .awaitAndCheck(); + } +} + From cc9148ddef95c6ca27ff9fee4c17fb0d4ba7f88e Mon Sep 17 00:00:00 2001 From: Damon Nguyen Date: Tue, 22 Apr 2025 20:27:17 +0000 Subject: [PATCH 062/901] 8354695: Open source several swing tests batch7 Reviewed-by: kizune, achung --- .../jdk/javax/swing/JRootPane/bug4403624.java | 106 +++ .../HorizScrollers.java | 234 ++++++ .../RTLScrollers.java | 684 ++++++++++++++++++ .../javax/swing/JScrollPane/bug4166037.java | 167 +++++ .../javax/swing/JScrollPane/bug4237517.java | 69 ++ .../javax/swing/JScrollPane/bug4237560.java | 77 ++ .../javax/swing/JScrollPane/bug4244899.java | 99 +++ 7 files changed, 1436 insertions(+) create mode 100644 test/jdk/javax/swing/JRootPane/bug4403624.java create mode 100644 test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java create mode 100644 test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/RTLScrollers.java create mode 100644 test/jdk/javax/swing/JScrollPane/bug4166037.java create mode 100644 test/jdk/javax/swing/JScrollPane/bug4237517.java create mode 100644 test/jdk/javax/swing/JScrollPane/bug4237560.java create mode 100644 test/jdk/javax/swing/JScrollPane/bug4244899.java diff --git a/test/jdk/javax/swing/JRootPane/bug4403624.java b/test/jdk/javax/swing/JRootPane/bug4403624.java new file mode 100644 index 00000000000..1c3ba3ddd2a --- /dev/null +++ b/test/jdk/javax/swing/JRootPane/bug4403624.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2001, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4403624 + * @summary Tests JRootPane layout with invisible menubar + * @key headful + * @run main bug4403624 + */ + +import java.awt.Color; +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.SwingUtilities; + +public class bug4403624 { + private static JFrame f; + private static Container c; + private static JButton b; + private static volatile Point p; + private static volatile int bWidth; + private static volatile int bHeight; + private static final int OFFSET = 2; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + f = new JFrame("bug4403624 Test"); + JMenuBar mbar; + mbar = new JMenuBar(); + mbar.add(new JMenu("Menu")); + f.setJMenuBar(mbar); + b = new JButton("Hide Menu"); + b.addActionListener(e -> mbar.setVisible(false)); + c = f.getContentPane(); + c.setLayout(new FlowLayout()); + c.setBackground(Color.GREEN); + c.add(b); + f.pack(); + f.setLocationRelativeTo(null); + f.setAlwaysOnTop(true); + f.setVisible(true); + }); + + Robot r = new Robot(); + r.setAutoDelay(200); + r.waitForIdle(); + r.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + p = b.getLocationOnScreen(); + bWidth = b.getWidth(); + bHeight = b.getHeight(); + }); + + r.mouseMove(p.x + (bWidth / 2), p.y + (bHeight / 2)); + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + SwingUtilities.invokeAndWait(() -> p = c.getLocationOnScreen()); + + Color c = r.getPixelColor(p.x + OFFSET, p.y + OFFSET); + + if (c.getGreen() < 240 && c.getBlue() > 10 && c.getRed() > 10) { + System.out.println("EXPECTED: " + Color.GREEN); + System.out.println("ACTUAL: " + c); + throw new RuntimeException("Failure to hide menu bar."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} diff --git a/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java b/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java new file mode 100644 index 00000000000..b584fd66da3 --- /dev/null +++ b/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 5078454 + * @summary Test horizontal wheel scroll behavior of (including RTL) + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual HorizScrollers + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; + +public class HorizScrollers { + private static final String INSTRUCTIONS = """ + This is a semi-automatic test with three phases. + For each phase, you will need to change the mouse setting, as + directed by a dialog. Once the correct setting is confirmed, + the next test phase will run automatically. + DO NOT TOUCH ANYTHING DURING TESTING! + + The test will automatically FAIL during testing if something + fails. Otherwise, the test will automatically PASS after the + third testing phase. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("HorizScrollers Instructions") + .instructions(INSTRUCTIONS) + .columns(45) + .testTimeOut(10) + .splitUIRight(ConfigPanel::new) + .logArea(6) + .build() + .awaitAndCheck(); + } + + private static final int[] SCROLLAMTS = {1, 30, 3}; + private static final String[] CONFIG_MSGS = { + "Set the scrolling speed to the slowest value (1 line).", + "Set the scrolling speed to the fastest value (30 lines).", + "Set the scrolling speed to two ticks above the slowest value (3 lines)." + }; + + private static int current = 0; + private static final String MW_TEXT = "Rotate the mouse wheel here"; + private static final String CONFIG_INSTRUCTION_TEMPLATE = """ + Configure Mouse Wheel for Phase %d + + Open the Mouse Control Panel and go to the 'Wheel' tab. + If 'Wheel' tab is not available just press Pass. + + %s + + Test the setting on the area below. + Once the mouse is setup correctly, the area will turn green. + When you're ready for the next part of the test to run, press GO! + """; + + static class ConfigPanel extends JPanel + implements ActionListener, MouseWheelListener { + JTextArea msg; + JButton goBtn; + JLabel mwArea; + int scrollAmount; + + private final Color defaultBg; + + ConfigPanel() { + this.scrollAmount = SCROLLAMTS[current]; + Container content = this; + content.setLayout(new BorderLayout()); + msg = new JTextArea(); + msg.setMargin(new Insets(5, 5, 5, 5)); + msg.setEditable(false); + msg.setLineWrap(true); + msg.setWrapStyleWord(true); + content.add(msg, BorderLayout.NORTH); + + mwArea = new JLabel(MW_TEXT, SwingConstants.CENTER); + mwArea.setPreferredSize(new Dimension(200, 250)); + mwArea.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + mwArea.setOpaque(true); + mwArea.addMouseWheelListener(this); + content.add(mwArea, BorderLayout.CENTER); + + defaultBg = mwArea.getBackground(); + setPhase(current); + + goBtn = new JButton("GO!"); + goBtn.setEnabled(false); + goBtn.addActionListener(this); + JPanel flowPanel = new JPanel(); + flowPanel.setLayout(new FlowLayout()); + flowPanel.add(goBtn); + content.add(flowPanel, BorderLayout.SOUTH); + + setPreferredSize(new Dimension(600, 400)); + } + + public void setPhase(int phase) { + if (phase < 3) { + setVisible(true); + PassFailJFrame.log("Phase %d scroll speed %d" + .formatted(phase + 1, SCROLLAMTS[phase])); + PassFailJFrame.log(CONFIG_MSGS[phase]); + + scrollAmount = SCROLLAMTS[phase]; + msg.setText(CONFIG_INSTRUCTION_TEMPLATE + .formatted(phase + 1, CONFIG_MSGS[phase])); + mwArea.setBackground(defaultBg); + mwArea.setText(MW_TEXT); + } else { + // all cases passed + showFinalReminderIfNeeded(false); + } + } + + private void showFinalReminderIfNeeded(boolean isFailure) { + if (scrollAmount != 3) { + JOptionPane.showMessageDialog( + ConfigPanel.this.getTopLevelAncestor(), + ("Test %s. please make sure you have restored " + + "the original speed value blah blah") + .formatted(isFailure + ? "failed" + : "passed"), + isFailure + ? "Failure" + : "Success", + isFailure + ? JOptionPane.WARNING_MESSAGE + : JOptionPane.INFORMATION_MESSAGE + ); + } + + if (isFailure) { + PassFailJFrame.forceFail(); + } else { + PassFailJFrame.forcePass(); + } + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == goBtn) { + goBtn.setEnabled(false); + + new Thread(() -> { // new thread to avoid running robot on EDT + boolean passed; + try { + passed = RTLScrollers.runTest(SCROLLAMTS[current]); + } catch (Exception ex) { + PassFailJFrame.log("Failure: " + ex); + SwingUtilities.invokeLater(() -> + showFinalReminderIfNeeded(true)); + return; + } + + PassFailJFrame.log("Phase %d passed: %b\n" + .formatted(current + 1, passed)); + if (passed) { + SwingUtilities.invokeLater(() -> { + goBtn.setEnabled(true); + setPhase(++current); + }); + } else { + SwingUtilities.invokeLater(() -> + showFinalReminderIfNeeded(true)); + } + }).start(); + } + } + + public void mouseWheelMoved(MouseWheelEvent e) { + int eventScrollAmt = e.getScrollAmount(); + if (eventScrollAmt == scrollAmount) { + mwArea.setBackground(Color.GREEN); + mwArea.setText("Mouse wheel configured - press Go"); + goBtn.setEnabled(true); + goBtn.requestFocusInWindow(); + PassFailJFrame.log("Proceed to the test with go button"); + return; + } + if (eventScrollAmt < scrollAmount) { + mwArea.setText("Increase the scroll speed. (Want:" + + scrollAmount + " Got:" + eventScrollAmt + ")"); + } else { + mwArea.setText("Decrease the scroll speed. (Want:" + + scrollAmount + " Got:" + eventScrollAmt + ")"); + } + } + } +} \ No newline at end of file diff --git a/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/RTLScrollers.java b/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/RTLScrollers.java new file mode 100644 index 00000000000..24e8df6fad8 --- /dev/null +++ b/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/RTLScrollers.java @@ -0,0 +1,684 @@ +/* + * Copyright (c) 2004, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// A few Swing components which use the mouse wheel to scroll + +import java.awt.AWTException; +import java.awt.Color; +import java.awt.ComponentOrientation; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.awt.image.BufferedImage; +import java.lang.reflect.InvocationTargetException; + +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.ListModel; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +public class RTLScrollers extends JDialog + implements MouseWheelListener, ActionListener { + private static final int ROWS = 5; + private static final int COLUMNS = 150; + private static final int WINWIDTH = 1000; + + static RTLScrollers rtl; + static volatile RTLScrollers f; + static volatile boolean retVal; + static volatile JScrollPane jsp; + static volatile JScrollBar hsb; + static volatile JScrollBar sb; + static volatile Point loc; + static volatile Dimension size; + TestList list; + JScrollPane listScroller; + JTextArea text; + JScrollPane textScroller; + TestTable table; + JScrollPane tableScroller; + JCheckBoxMenuItem rightToLeft; + ImageIcon photoIcon; + int scrollAmount; + + private static Robot robot; + private static BufferedImage logo = genIcon(166, 39, Color.PINK); + private static BufferedImage photo = genIcon(59, 80, Color.MAGENTA); + private static BufferedImage photo2 = genIcon(80, 53, Color.ORANGE); + + private static BufferedImage genIcon(int width, int height, Color color) { + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics g = image.getGraphics(); + g.setColor(color); + g.fillRect(0, 0, width, height); + + return image; + } + + public RTLScrollers() { + this(0); + } + + public RTLScrollers(int scrollAmount) { + super(new JFrame(), "RTLScrollers", false); + + this.scrollAmount = scrollAmount; + Container content = getContentPane(); + content.setLayout(new GridBagLayout()); + + DefaultListModel listModel = new DefaultListModel<>(); + + photoIcon = new ImageIcon(photo); + for (int i = 0; i < COLUMNS / 4 ; i++) { + for (int j = 0; j < ROWS; j++) { + listModel.addElement(new ImageIcon(logo)); + } + for (int j = 0; j < ROWS; j++) { + listModel.addElement(photoIcon); + } + for (int j = 0; j < ROWS; j++) { + listModel.addElement(new ImageIcon(photo2)); + } + for (int j = 0; j < ROWS; j++) { + listModel.addElement("Text Item " + ((1 + i) * 3)); + } + } + + list = new TestList(listModel); + list.setVisibleRowCount(ROWS); + list.setLayoutOrientation(JList.VERTICAL_WRAP); + listScroller = new JScrollPane(list); + listScroller.addMouseWheelListener(this); + + text = new JTextArea(); + for (int j = 0; j < ROWS ; j++) { + for (int i = 0; i < COLUMNS ; i++) { + text.append(i + " some text, some more text, a really long line of text "); + } + text.append("\n"); + } + + textScroller = new JScrollPane(text); + textScroller.addMouseWheelListener(this); + + DefaultTableModel model = new DefaultTableModel(ROWS, COLUMNS); + table = new TestTable(model); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + for (int i = 0; i < COLUMNS; i++) { + for (int j = 0; j < ROWS; j++) { + table.setValueAt(j + ", " + i, j, i); + } + + TableColumn column = table.getColumnModel().getColumn(i); + + if (i % 4 == 0) { + column.setMinWidth(0); + column.setPreferredWidth(0); + column.setMaxWidth(0); + } + else if ((i + 1) % 4 == 0) { + column.setMinWidth(95); + column.setPreferredWidth(95); + column.setMaxWidth(95); + } + else if ((i + 2) % 4 == 0) { + column.setMinWidth(26); + column.setPreferredWidth(26); + column.setMaxWidth(26); + } + else { + column.setMinWidth(50); + column.setPreferredWidth(50); + column.setMaxWidth(50); + } + } + tableScroller = new JScrollPane(table); + tableScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + tableScroller.addMouseWheelListener(this); + + GridBagConstraints tableGBC = new GridBagConstraints(0, + 0, + 1, + 1, + 1.0, + 0.3, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(0,0,0,0), + 0, + 0); + content.add(tableScroller, tableGBC); + GridBagConstraints textGBC = new GridBagConstraints(0, + 1, + 1, + 1, + 1.0, + 0.3, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(0,0,0,0), + 0, + 0); + content.add(textScroller, textGBC); + + GridBagConstraints listGBC = new GridBagConstraints(0, + 2, + 1, + 5, + 1.0, + 1.2, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(0,0,0,0), + 0, + 0); + + content.add(listScroller, listGBC); + + rightToLeft = new JCheckBoxMenuItem("Right-To-Left", false); + rightToLeft.addActionListener(this); + JMenu menu = new JMenu("Component Orientation"); + menu.add(rightToLeft); + + JMenuItem close = new JMenuItem("Close"); + close.addActionListener(e -> RTLScrollers.this.setVisible(false)); + menu.add(close); + + JMenuBar mb = new JMenuBar(); + mb.add(menu); + setJMenuBar(mb); + setBounds(0, 0, WINWIDTH, 760); + setLocationRelativeTo(null); + } + + public void actionPerformed(ActionEvent e) { + if (rightToLeft.getState()) { + applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } + else { + applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); + } + } + public void mouseWheelMoved(MouseWheelEvent e) { + System.out.println("Rotation: " + e.getWheelRotation()); + } + + public static boolean runTest(int scrollAmount) + throws InterruptedException, InvocationTargetException { + System.out.println("RTLS.runTest()"); + if (robot == null) { + try { + robot = new Robot(); + robot.setAutoDelay(150); + robot.setAutoWaitForIdle(true); + } + catch (AWTException e) { + e.printStackTrace(); + return false; + } + } + + SwingUtilities.invokeAndWait(() -> { + rtl = new RTLScrollers(scrollAmount); + rtl.setVisible(true); + }); + robot.delay(100); + + SwingUtilities.invokeAndWait(() -> { + try { + retVal = rtl.runTests(scrollAmount); + } catch (Exception e) { + e.printStackTrace(); + } finally { + rtl.setVisible(false); + rtl.dispose(); + } + }); + + robot.delay(100); + System.out.println("RTLS.runTest(): " + retVal); + return retVal; + } + + private boolean runTests(int scrollAmount) + throws InterruptedException, InvocationTargetException { + if (robot == null) { + try { + robot = new Robot(); + robot.setAutoDelay(150); + robot.setAutoWaitForIdle(true); + } + catch (AWTException e) { + e.printStackTrace(); + return false; + } + } + + // + // run robot tests + // + robot.delay(500); + + System.out.println("Testing Table"); + testComp(table, scrollAmount); + + System.out.println("Testing List"); + testComp(list, scrollAmount); + + SwingUtilities.invokeAndWait(() -> { + applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + }); + robot.delay(100); + + System.out.println("Testing RTL Table"); + testComp(table, scrollAmount); + + System.out.println("Testing RTL List"); + testComp(list, scrollAmount); + + return true; + } + + public boolean testComp(TestTools comp, int scrollAmount) + throws InterruptedException, InvocationTargetException { + // Make sure we start from the beginning + SwingUtilities.invokeAndWait(() -> { + jsp = (JScrollPane)((JComponent)comp).getParent().getParent(); + hsb = jsp.getHorizontalScrollBar(); + hsb.setValue(hsb.getMinimum()); + + loc = jsp.getLocationOnScreen(); + size = jsp.getSize(); + }); + int midx = loc.x + size.width / 2; + int midy = loc.y + size.height / 2; + int maxIdx = 0; + robot.mouseMove(midx, midy); + + // Don't bother for max scroll w/ RTL JList, because the block increment is broken + if (scrollAmount != 30 || !(comp instanceof TestList) + || getComponentOrientation().isLeftToRight()) { + scrollToMiddle(jsp, robot); + + // check that we're lined up + comp.checkTopCellIsLinedUp(); + + int startVal = hsb.getValue(); + int leadingCell = comp.getLeadingCell().y; + System.out.println("leadingCell is " + leadingCell); + + // become unaligned + int width = comp.getLeadingCellWidth(); + int midVal = startVal + width / 2; + System.out.println("becoming unaligned: startVal is " + + startVal + ", midVal is " + midVal); + SwingUtilities.invokeAndWait(() -> hsb.setValue(midVal)); + + // + // Check partial inc up + // + robot.mouseWheel(-1); + + if (scrollAmount == 30) { // hack for max scroll amount + comp.checkTopCellIsMax(maxIdx++); + } + else { + comp.checkTopCellIs(leadingCell, -scrollAmount + 1); + } + comp.checkTopCellIsLinedUp(); + + // + // Check partial inc down + // + SwingUtilities.invokeAndWait(() -> hsb.setValue(midVal)); + robot.delay(100); + robot.mouseWheel(1); + + if (scrollAmount == 30) { // hack for max scroll amount + comp.checkTopCellIsMax(maxIdx++); + } + else { + comp.checkTopCellIs(leadingCell, scrollAmount); + } + comp.checkTopCellIsLinedUp(); + + // + // Check full inc down (3 times) + // + SwingUtilities.invokeAndWait(() -> hsb.setValue(startVal)); + leadingCell = comp.getLeadingCell().y; + + // Once... + robot.mouseWheel(1); + if (scrollAmount == 30) { // hack for max scroll amount + comp.checkTopCellIsMax(maxIdx++); + } + else { + comp.checkTopCellIs(leadingCell, scrollAmount); + } + comp.checkTopCellIsLinedUp(); + + // Twice... + robot.mouseWheel(1); + if (scrollAmount == 30) { // hack for max scroll amount + comp.checkTopCellIsMax(maxIdx++); + } + else { + comp.checkTopCellIs(leadingCell, (2 * scrollAmount)); + } + + comp.checkTopCellIsLinedUp(); + + // Thrice... + robot.mouseWheel(1); + if (scrollAmount == 30) { // hack for max scroll amount + comp.checkTopCellIsMax(maxIdx++); + } + else { + comp.checkTopCellIs(leadingCell, (3 * scrollAmount)); + + } + comp.checkTopCellIsLinedUp(); + + // + // Check full inc up (3 times) + // + leadingCell = comp.getLeadingCell().y; + + // Once... + robot.mouseWheel(-1); + if (scrollAmount == 30) { // hack for max scroll amount + comp.checkTopCellIsMax(maxIdx++); + } + else { + comp.checkTopCellIs(leadingCell, -scrollAmount); + } + comp.checkTopCellIsLinedUp(); + + // Twice... + robot.mouseWheel(-1); + if (scrollAmount == 30) { // hack for max scroll amount + comp.checkTopCellIsMax(maxIdx++); + } + else { + comp.checkTopCellIs(leadingCell, -(2 * scrollAmount)); + } + comp.checkTopCellIsLinedUp(); + + // Thrice... + robot.mouseWheel(-1); + if (scrollAmount == 30) { // hack for max scroll amount + comp.checkTopCellIsMax(maxIdx++); + } + else { + comp.checkTopCellIs(leadingCell, -(3 * scrollAmount)); + } + comp.checkTopCellIsLinedUp(); + } + + // + // Test acceleration for max scrolling + // (this part should still work for RTL JList) + if (scrollAmount == 30) { + SwingUtilities.invokeAndWait(() -> { + hsb.setValue(hsb.getMinimum()); + }); + robot.delay(100); + robot.mouseWheel(2); + robot.mouseWheel(2); + robot.mouseWheel(2); + if (hsb.getValue() < hsb.getMaximum() - hsb.getVisibleAmount()) { + throw new RuntimeException("Wheel acceleration for max " + + "scrolling doesn't work: hsb value (" + hsb.getValue() + + " < hsb max (" + hsb.getMaximum() + + ") - hsb vis (" + hsb.getVisibleAmount() + ")"); + } + robot.delay(100); + robot.mouseWheel(-2); + robot.mouseWheel(-2); + robot.mouseWheel(-2); + if (hsb.getValue() > hsb.getMinimum()) { + throw new RuntimeException("Wheel acceleration for max " + + "scrolling doesn't work: hsb value (" + + hsb.getValue() + " > hsb min (" + hsb.getMinimum() + ")"); + } + } + + return true; + } + + class TestTable extends JTable implements TestTools { + final int[] MAXVALS = {23, 67, 67, 89, 111, 89, 66, 45}; //Lookup table + public TestTable(TableModel model) { + super(model); + } + + public void checkTopCellIsLinedUp() { + boolean isLeftToRight = getComponentOrientation().isLeftToRight(); + Point leading = getLeadingCell(); + Rectangle visRect = getVisibleRect(); + Rectangle cellRect = getCellRect(leading.x, leading.y, true); + + if (isLeftToRight) { + if (cellRect.x != visRect.x) { + throw new RuntimeException("leading cell is not aligned!"); + } + } + else { + if (cellRect.x + cellRect.width != visRect.x + visRect.width) { + throw new RuntimeException("leading cell is not aligned!"); + } + } + } + + public void checkTopCellIs(int col) { + Point cell = getLeadingCell(); + if (cell.y != col) { + throw new RuntimeException("leading cell (" + cell.y + + ") is not " + col); + } + } + + /* + * Account for 0-width cells + * + * shift is a non-0 number of visible cells to shift. The shift is + * augmented for zero-width cells, and the new sum is passed into + * checkTopCellIs(). + */ + public void checkTopCellIs(int col, int shift) { + if (shift == 0) { + checkTopCellIs(col); + return; + } + + int row = getLeadingCell().x; + int newShift = 0; + int foundCells = 0; + int direction = shift > 0 ? 1 : -1; + int index = col; + Rectangle cellRect; + + while (foundCells < Math.abs(shift)) { + index += direction; + cellRect = getCellRect(row, index, true); + if (cellRect.width > 0) { + foundCells++; + } + newShift++; + } + + checkTopCellIs(col + (direction*newShift)); + } + + public void checkTopCellIsMax(int idx) { + checkTopCellIs(MAXVALS[idx]); + } + + public int getLeadingCellWidth() { + Point leading = getLeadingCell(); + Rectangle cellRect = getCellRect(leading.x, leading.y, true); + return cellRect.width; + } + + public Point getLeadingCell() { + boolean isLeftToRight = getComponentOrientation().isLeftToRight(); + Rectangle visRect = getVisibleRect(); + int row = rowAtPoint(visRect.getLocation()); + int column; + if (isLeftToRight) { + column = columnAtPoint(visRect.getLocation()); + } + else { + column = columnAtPoint(new Point(visRect.x + visRect.width - 1, visRect.y)); + } + return new Point(row, column); + } + } + + class TestList extends JList implements TestTools { + final int[] MAXVALS = {5, 16, 15, 20, 25, 20, 15, 10 }; + public TestList(ListModel model) { + super(model); + } + + // Note - implemented in terms of columns + public Point getLeadingCell() { + System.out.println("TL.gLC(): first vis index is " + + getFirstVisibleIndex()); + return new Point(getFirstVisibleIndex() / ROWS, + getFirstVisibleIndex() / ROWS); + } + public void checkTopCellIsLinedUp() { + boolean isLeftToRight = getComponentOrientation().isLeftToRight(); + int visIdx = getFirstVisibleIndex(); + Rectangle cellRect = getCellBounds(visIdx, visIdx); + Rectangle visRect = getVisibleRect(); + if (isLeftToRight) { + if (cellRect.x != visRect.x) { + throw new RuntimeException("leading cell is not aligned!"); + } + } + else { + if (cellRect.x + cellRect.width != visRect.x + visRect.width) { + throw new RuntimeException("leading cell is not aligned!"); + } + } + } + public void checkTopCellIs(int col) { + int firstVis = getLeadingCell().y; + if (firstVis != col) { + throw new RuntimeException("leading cell (" + + firstVis + ") is not " + col); + } + } + public void checkTopCellIs(int idx, int shift) { + checkTopCellIs(idx + shift); + + } + public void checkTopCellIsMax(int idx) { + checkTopCellIs(MAXVALS[idx]); + } + public int getLeadingCellWidth() { + int visIdx = getFirstVisibleIndex(); + Rectangle cellRect = getCellBounds(visIdx, visIdx); + System.out.println("TL.gLCW(): leading cell width is " + cellRect.width); + return cellRect.width; + } + } + + private interface TestTools { + /** + * Throws a runtime exception if the top cell isn't lined up + */ + void checkTopCellIsLinedUp(); + void checkTopCellIs(int col); + void checkTopCellIs(int col, int shift); + int getLeadingCellWidth(); + Point getLeadingCell(); + + void checkTopCellIsMax(int idx); + } + + public void scrollToMiddle(JScrollPane jsp, Robot robot) + throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(() -> { + sb = jsp.getHorizontalScrollBar(); + loc = sb.getLocationOnScreen(); + size = sb.getSize(); + }); + robot.setAutoDelay(250); + + robot.mouseMove(loc.x + size.width / 2, + loc.y + size.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + SwingUtilities.invokeAndWait(() -> { + if (jsp == listScroller) { + int idx = list.getFirstVisibleIndex(); + list.ensureIndexIsVisible(idx); + } + }); + } + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> f = new RTLScrollers()); + } finally { + SwingUtilities.invokeAndWait(() -> { + f.setVisible(true); + f.dispose(); + }); + } + } +} diff --git a/test/jdk/javax/swing/JScrollPane/bug4166037.java b/test/jdk/javax/swing/JScrollPane/bug4166037.java new file mode 100644 index 00000000000..e2ce75867a7 --- /dev/null +++ b/test/jdk/javax/swing/JScrollPane/bug4166037.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2000, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4166037 + * @summary Tests if changes to JScrollPane propagate to ScrollPaneLayout + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4166037 + */ + +import java.awt.Color; + +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneLayout; + +public class bug4166037 { + static final String INSTRUCTIONS = """ + Press button "Never". Scroll bars should disappear. + Press button "Always". Scroll bars should appear. + Press button "Colhead". Label ColumnHeader should + get replaced with yellow rectangles. + Press button "Corner". You should see 4 green + rectangles in the corners of the scroll pane. + Press button "Rowhead". Label RowHeader should get + replaced with yellow rectangles. + Press button "Viewport". Viewport (the rest of the + area except scrollbars) should get replaced with yellow + rectangles. + If the behavior is as described, the test PASSES. + Otherwise, this test FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4166037 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4166037::createUI) + .logArea() + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("JScrollPane in JScrollLayout Test"); + JScrollPane scroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + JPanel p = new JPanel(); + scroll.setSize(200, 200); + f.add(scroll); + f.setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS)); + JButton bn = new JButton("Never"); + bn.addActionListener(e -> { + PassFailJFrame.log("pane before: " + + scroll.getVerticalScrollBarPolicy() + + scroll.getHorizontalScrollBarPolicy()); + PassFailJFrame.log("layout before: " + + ((ScrollPaneLayout) scroll.getLayout()).getVerticalScrollBarPolicy() + + ((ScrollPaneLayout) scroll.getLayout()).getHorizontalScrollBarPolicy()); + scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); + scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + PassFailJFrame.log("pane after: " + + scroll.getVerticalScrollBarPolicy() + + scroll.getHorizontalScrollBarPolicy()); + PassFailJFrame.log("layout after: " + + ((ScrollPaneLayout) scroll.getLayout()).getVerticalScrollBarPolicy() + + ((ScrollPaneLayout) scroll.getLayout()).getHorizontalScrollBarPolicy()); + }); + JButton ba = new JButton("Always"); + ba.addActionListener(e -> { + PassFailJFrame.log("pane before: " + + scroll.getVerticalScrollBarPolicy() + + scroll.getHorizontalScrollBarPolicy()); + PassFailJFrame.log("layout before: " + + ((ScrollPaneLayout) scroll.getLayout()).getVerticalScrollBarPolicy() + + ((ScrollPaneLayout) scroll.getLayout()).getHorizontalScrollBarPolicy()); + scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + PassFailJFrame.log("pane after: " + + scroll.getVerticalScrollBarPolicy() + + scroll.getHorizontalScrollBarPolicy()); + PassFailJFrame.log("layout after: " + + ((ScrollPaneLayout) scroll.getLayout()).getVerticalScrollBarPolicy() + + ((ScrollPaneLayout) scroll.getLayout()).getHorizontalScrollBarPolicy()); + }); + JLabel ch = new JLabel("ColumnHeader"); + scroll.setColumnHeaderView(ch); + JButton b1 = new JButton("Colhead"); + b1.addActionListener(e -> { + JPanel filler = new JPanel(); + filler.setSize(150, 150); + filler.setBackground(Color.yellow); + scroll.getColumnHeader().add(filler); + }); + JButton b2 = new JButton("Corners"); + b2.addActionListener(e -> { + JPanel filler1 = new JPanel(); + filler1.setSize(150, 150); + filler1.setBackground(Color.green); + scroll.setCorner(JScrollPane.LOWER_RIGHT_CORNER, filler1); + JPanel filler2 = new JPanel(); + filler2.setSize(150, 150); + filler2.setBackground(Color.green); + scroll.setCorner(JScrollPane.LOWER_LEFT_CORNER, filler2); + JPanel filler3 = new JPanel(); + filler3.setSize(150, 150); + filler3.setBackground(Color.green); + scroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, filler3); + JPanel filler4 = new JPanel(); + filler4.setSize(150, 150); + filler4.setBackground(Color.green); + scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, filler4); + }); + JLabel rh = new JLabel("RowHeader"); + scroll.setRowHeaderView(rh); + JButton b3 = new JButton("Rowhead"); + b3.addActionListener(e -> { + JPanel filler = new JPanel(); + filler.setSize(150, 150); + filler.setBackground(Color.yellow); + scroll.getRowHeader().add(filler); + }); + JButton b4 = new JButton("Viewport"); + b4.addActionListener(e -> { + JPanel filler = new JPanel(); + filler.setSize(150, 150); + filler.setBackground(Color.yellow); + scroll.getViewport().add(filler); + }); + + p.add(bn); + p.add(ba); + p.add(b1); + p.add(b2); + p.add(b3); + p.add(b4); + f.add(p); + f.setSize(300, 300); + return f; + } +} diff --git a/test/jdk/javax/swing/JScrollPane/bug4237517.java b/test/jdk/javax/swing/JScrollPane/bug4237517.java new file mode 100644 index 00000000000..4e1d1356199 --- /dev/null +++ b/test/jdk/javax/swing/JScrollPane/bug4237517.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4237517 + * @summary Tests that scrolling with blit draws the right thing + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4237517 + */ + +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JScrollPane; + +public class bug4237517 { + static final String INSTRUCTIONS = """ + Select the first item in the list and hit PageDown + key two times. If the list is redrawn correctly, + i.e. if the digits go in order, then the test PASSES. + Otherwise, the test FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4237517 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4237517::createUI) + .build() + .awaitAndCheck(); + } + + static JFrame createUI() { + JFrame f = new JFrame("Scrolling Window Blit Test"); + String[] data = new String[100]; + + for (int counter = 0; counter < data.length; counter++) { + data[counter] = Integer.toString(counter); + } + JList list = new JList(data); + JScrollPane sp = new JScrollPane(list); + sp.getViewport().putClientProperty("EnableWindowBlit", Boolean.TRUE); + f.add(sp); + f.setSize(200, 200); + return f; + } +} diff --git a/test/jdk/javax/swing/JScrollPane/bug4237560.java b/test/jdk/javax/swing/JScrollPane/bug4237560.java new file mode 100644 index 00000000000..4f8f27683e5 --- /dev/null +++ b/test/jdk/javax/swing/JScrollPane/bug4237560.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4237560 + * @summary Tests that JScrollPane do not distort TAB order in an HTML page + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4237560 + */ + +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.JScrollPane; + +public class bug4237560 { + static final String INSTRUCTIONS = """ + A JEditorPane contains 10 input fields and is inserted into + JScrollPane. Click text field #8 so that it is selected. Press + TAB three times (even if text field #9 and #10 are not visible in + the ScrollPane). If this gives focus to the first text field (#1) + the test PASSES, else it FAILS. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4237560 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4237560::createUI) + .build() + .awaitAndCheck(); + } + + private static final String TEXT = "
\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "
"; + + private static JFrame createUI() { + JFrame frame = new JFrame("JScrollPane HTML TAB Test"); + JEditorPane viewer = new JEditorPane("text/html", TEXT); + viewer.setEditable(false); + frame.add(new JScrollPane(viewer)); + frame.setSize(300, 300); + return frame; + } +} diff --git a/test/jdk/javax/swing/JScrollPane/bug4244899.java b/test/jdk/javax/swing/JScrollPane/bug4244899.java new file mode 100644 index 00000000000..4cb5367f4f5 --- /dev/null +++ b/test/jdk/javax/swing/JScrollPane/bug4244899.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4244899 + * @summary Tests whether scrolling with blit has artifacts + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual bug4244899 + */ + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; + +public class bug4244899 { + static final String INSTRUCTIONS = """ + Widen the first column of the table, so that + you get a horizontal scrollbar. Click in the + scrollbar (not on the thumb, but in the track). + If you notice some artifacts/flashing at + the bottom of the frame, the test FAILS. + Otherwise, the test PASSES. + """; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("bug4244899 Test Instructions") + .instructions(INSTRUCTIONS) + .columns(40) + .testUI(bug4244899::createUI) + .build() + .awaitAndCheck(); + } + + static class TestModel extends AbstractTableModel { + private final int rows = 20; + private final int cols = 5; + + private Integer[][] data; + + public TestModel() { + data = new Integer[rows][]; + int realCount = 0; + for (int counter = 0; counter < rows; counter++) { + data[counter] = new Integer[cols]; + for (int y = 0; y < cols; y++) { + data[counter][y] = Integer.valueOf(realCount); + realCount = (realCount + 1) % 23; + } + } + } + + public int getRowCount() { + return data.length; + } + + public int getColumnCount() { + return data[0].length; + } + + public Object getValueAt(int row, int column) { + return data[row][column]; + } + } + + static JFrame createUI() { + JFrame f = new JFrame("Scrolling Blit Artifact Test"); + JTable table = new JTable(new TestModel()); + JScrollPane sp = new JScrollPane(table); + sp.getViewport().putClientProperty("EnableWindowBlit", Boolean.TRUE); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + f.add(sp); + f.setSize(400, 400); + return f; + } +} From b7e8952ad6def4ebae8c8c3c04cf6793f472b029 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Tue, 22 Apr 2025 23:21:26 +0000 Subject: [PATCH 063/901] 8355071: Fix nsk/jdi test to not require lookup of main thread in order to set the breakpoint used for communication Reviewed-by: lmesnik, amenkov --- .../BooleanType/_itself_/booleantype001.java | 11 +---- .../addInstanceFilter/instancefilter002.java | 12 +----- .../addInstanceFilter/instancefilter003.java | 12 +----- .../addThreadFilter/threadfilter002.java | 12 +----- .../addThreadFilter/threadfilter003.java | 12 +----- .../location/location001.java | 13 +----- .../jdi/ByteType/_itself_/bytetype001.java | 11 +---- .../jdi/CharType/_itself_/chartype001.java | 11 +---- .../definedClasses/definedclasses001.java | 11 +---- .../visibleClasses/visibleclasses001.java | 11 +---- .../addClassExclusionFilter/filter003.java | 15 ++----- .../addClassFilter_rt/filter_rt002.java | 12 +----- .../addClassFilter_s/filter_s002.java | 13 +----- .../DoubleType/_itself_/doubletype001.java | 11 +---- .../nsk/jdi/Event/request/request001.java | 13 +----- .../EventIterator/nextEvent/nextevent001.java | 13 +----- .../nsk/jdi/EventQueue/remove/remove004.java | 15 +------ .../jdi/EventQueue/remove_l/remove_l004.java | 15 +------ .../addCountFilter/addcountfilter001.java | 12 +----- .../jdi/EventRequest/disable/disable002.java | 12 +----- .../jdi/EventRequest/enable/enable001.java | 12 +----- .../jdi/EventRequest/enable/enable002.java | 12 +----- .../getProperty/getproperty001.java | 12 +----- .../EventRequest/isEnabled/isenabled001.java | 12 +----- .../putProperty/putproperty001.java | 12 +----- .../setEnabled/setenabled001.java | 12 +----- .../setEnabled/setenabled002.java | 12 +----- .../setEnabled/setenabled003.java | 12 +----- .../setSuspendPolicy/setsuspendpolicy001.java | 12 +----- .../suspendPolicy/suspendpolicy001.java | 12 +----- .../accwtchpreq002.java | 12 +----- .../breakpointRequests/breakpreq002.java | 12 +----- .../classPrepareRequests/clsprepreq002.java | 12 +----- .../classUnloadRequests/clsunlreq002.java | 12 +----- .../craccwtchpreq003.java | 12 +----- .../crbreakpreq003.java | 12 +----- .../createClassPrepareRequest/cpreg001.java | 12 +----- .../createClassUnloadRequest/cureg001.java | 12 +----- .../createExceptionRequest/crexreq009.java | 12 +----- .../createExceptionRequest/crexreq010.java | 12 +----- .../createMethodEntryRequest/menreg001.java | 12 +----- .../createMethodExitRequest/mexreg001.java | 12 +----- .../crmodwtchpreq003.java | 12 +----- .../createStepRequest/crstepreq002.java | 12 +----- .../createStepRequest/crstepreq003.java | 10 +---- .../createStepRequest/crstepreq004.java | 6 +-- .../createThreadDeathRequest/tdreg001.java | 12 +----- .../createThreadStartRequest/tsreg001.java | 12 +----- .../createVMDeathRequest/vmdreg001.java | 12 +----- .../deleteAllBreakpoints/delallbreakp002.java | 12 +----- .../deleteEventRequest/delevtreq002.java | 12 +----- .../deleteEventRequests/delevtreqs002.java | 12 +----- .../exceptionRequests/excreq002.java | 12 +----- .../methodEntryRequests/methentreq002.java | 12 +----- .../methodExitRequests/methexitreq002.java | 12 +----- .../modwtchpreq002.java | 12 +----- .../stepRequests/stepreq002.java | 12 +----- .../threadDeathRequests/thrdeathreq002.java | 12 +----- .../threadStartRequests/thrstartreq002.java | 12 +----- .../vmDeathRequests/vmdeathreq001.java | 12 +----- .../eventIterator/eventiterator001.java | 13 +----- .../eventIterator/eventiterator002.java | 14 ++----- .../eventIterator/eventiterator003.java | 11 +---- .../eventIterator/eventiterator004.java | 13 +----- .../nsk/jdi/EventSet/resume/resume002.java | 13 ++---- .../nsk/jdi/EventSet/resume/resume003.java | 12 ++---- .../nsk/jdi/EventSet/resume/resume004.java | 12 ++---- .../nsk/jdi/EventSet/resume/resume005.java | 12 ++---- .../nsk/jdi/EventSet/resume/resume006.java | 12 ++---- .../nsk/jdi/EventSet/resume/resume007.java | 12 ++---- .../nsk/jdi/EventSet/resume/resume010.java | 12 ++---- .../nsk/jdi/EventSet/resume/resume011.java | 12 ++---- .../nsk/jdi/EventSet/resume/resume012.java | 12 ++---- .../nsk/jdi/EventSet/resume/resume013.java | 12 ++---- .../suspendPolicy/suspendpolicy001.java | 12 ++---- .../suspendPolicy/suspendpolicy002.java | 12 ++---- .../suspendPolicy/suspendpolicy003.java | 12 ++---- .../suspendPolicy/suspendpolicy004.java | 12 ++---- .../suspendPolicy/suspendpolicy005.java | 12 ++---- .../suspendPolicy/suspendpolicy006.java | 12 ++---- .../suspendPolicy/suspendpolicy007.java | 12 ++---- .../suspendPolicy/suspendpolicy008.java | 12 ++---- .../suspendPolicy/suspendpolicy009.java | 12 ++---- .../suspendPolicy/suspendpolicy010.java | 12 ++---- .../suspendPolicy/suspendpolicy011.java | 12 ++---- .../suspendPolicy/suspendpolicy012.java | 12 ++---- .../suspendPolicy/suspendpolicy013.java | 12 ++---- .../suspendPolicy/suspendpolicy014.java | 12 ++---- .../suspendPolicy/suspendpolicy015.java | 12 ++---- .../suspendPolicy/suspendpolicy016.java | 12 ++---- .../suspendPolicy/suspendpolicy017.java | 12 ++---- .../addClassExclusionFilter/filter002.java | 12 +----- .../addClassFilter_rt/filter_rt002.java | 12 +----- .../addClassFilter_s/filter_s002.java | 12 +----- .../addInstanceFilter/instancefilter002.java | 12 +----- .../addInstanceFilter/instancefilter003.java | 12 +----- .../addThreadFilter/threadfilter002.java | 12 +----- .../addThreadFilter/threadfilter003.java | 12 +----- .../exception/exception001.java | 12 +----- .../notifyCaught/notifycaught001.java | 12 +----- .../notifyUncaught/notifyuncaught001.java | 12 +----- .../jdi/FloatType/_itself_/floattype001.java | 11 +---- .../IntegerType/_itself_/integertype001.java | 11 +---- .../jdi/LocatableEvent/thread/thread001.java | 11 +---- .../jdi/LongType/_itself_/longtype001.java | 11 +---- .../jdi/Method/isObsolete/isobsolete001.java | 17 +++----- .../jdi/Method/isObsolete/isobsolete002.java | 17 +++----- .../addClassExclusionFilter/filter002.java | 12 +----- .../addClassFilter_rt/filter_rt002.java | 12 +----- .../addClassFilter_s/filter_s002.java | 12 +----- .../addInstanceFilter/instancefilter002.java | 12 +----- .../addInstanceFilter/instancefilter003.java | 12 +----- .../addThreadFilter/threadfilter002.java | 12 +----- .../addThreadFilter/threadfilter003.java | 12 +----- .../addClassExclusionFilter/filter002.java | 12 +----- .../addClassFilter_rt/filter_rt002.java | 12 +----- .../addClassFilter_s/filter_s002.java | 12 +----- .../addInstanceFilter/instancefilter002.java | 12 +----- .../addInstanceFilter/instancefilter003.java | 12 +----- .../addThreadFilter/threadfilter002.java | 12 +----- .../addThreadFilter/threadfilter003.java | 12 +----- .../_itself_/mwevent001.java | 12 +----- .../disablecollection002.java | 11 +---- .../classPath/classpath001.java | 15 +------ .../_itself_/primitivetype001.java | 11 +---- .../classLoader/classloader001.java | 15 +------ .../ReferenceType/getValue/getvalue001.java | 15 +------ .../ReferenceType/getValue/getvalue002.java | 15 +------ .../ReferenceType/getValue/getvalue003.java | 15 +------ .../ReferenceType/getValues/getvalues001.java | 15 +------ .../jdi/ReferenceType/isFinal/isfinal001.java | 15 +------ .../ReferenceType/isStatic/isstatic001.java | 11 +---- .../ReferenceType/isStatic/isstatic002.java | 11 +---- .../nestedTypes/nestedtypes001.java | 15 +------ .../nestedTypes/nestedtypes002.java | 15 +------ .../jdi/ShortType/_itself_/shorttype001.java | 11 +---- .../addClassExclusionFilter/filter002.java | 16 ++----- .../addClassFilter_rt/filter_rt002.java | 12 +----- .../addClassFilter_s/filter_s002.java | 12 +----- .../addInstanceFilter/instancefilter002.java | 12 +----- .../addInstanceFilter/instancefilter003.java | 12 +----- .../nsk/jdi/StepRequest/depth/depth001.java | 12 +----- .../nsk/jdi/StepRequest/depth/depth002.java | 12 +----- .../nsk/jdi/StepRequest/depth/depth003.java | 12 +----- .../nsk/jdi/StepRequest/size/size001.java | 12 +----- .../nsk/jdi/StepRequest/size/size002.java | 12 +----- .../nsk/jdi/StepRequest/thread/thread001.java | 12 +----- .../addThreadFilter/addthreadfilter001.java | 13 +----- .../addThreadFilter/addthreadfilter002.java | 14 ++----- .../addThreadFilter/addthreadfilter003.java | 11 +---- .../addThreadFilter/addthreadfilter005.java | 12 +----- .../popFrames/popframes001.java | 15 +------ .../popFrames/popframes002.java | 14 +------ .../popFrames/popframes003.java | 19 ++------- .../popFrames/popframes004.java | 12 +----- .../popFrames/popframes005.java | 12 +----- .../addThreadFilter/addthreadfilter001.java | 13 +----- .../addThreadFilter/addthreadfilter003.java | 11 +---- .../addThreadFilter/addthreadfilter005.java | 12 +----- .../jdi/VMDeathEvent/_itself_/vmdeath002.java | 11 +---- .../jdi/VMDeathEvent/_itself_/vmdeath003.java | 11 +---- .../allClasses/allclasses001.java | 15 +------ .../canAddMethod/canaddmethod001.java | 15 +------ .../canPopFrames/canpopframes001.java | 15 +------ .../canredefineclasses001.java | 15 +------ .../canreqvmdev001.java | 15 +------ .../curc001.java | 15 +------ .../canusefilters001.java | 15 +------ .../canwatchaccess001.java | 15 +------ .../canwatchmod001.java | 15 +------ .../redefineClasses/redefineclasses001.java | 25 ++++------- .../jdi/VoidType/_itself_/voidtype001.java | 11 +---- .../addClassExclusionFilter/filter003.java | 12 +----- .../addClassExclusionFilter/filter004.java | 12 +----- .../addClassFilter_rt/filter_rt003.java | 12 +----- .../addClassFilter_rt/filter_rt004.java | 12 +----- .../addClassFilter_s/filter_s003.java | 12 +----- .../addClassFilter_s/filter_s004.java | 12 +----- .../addInstanceFilter/instancefilter003.java | 12 +----- .../addInstanceFilter/instancefilter004.java | 12 +----- .../addInstanceFilter/instancefilter005.java | 12 +----- .../addInstanceFilter/instancefilter006.java | 12 +----- .../addThreadFilter/addthreadfilter003.java | 12 +----- .../addThreadFilter/addthreadfilter004.java | 12 +----- .../addThreadFilter/addthreadfilter005.java | 12 +----- .../addThreadFilter/addthreadfilter006.java | 12 +----- .../jdi/WatchpointRequest/field/field001.java | 13 +----- .../jdi/WatchpointRequest/field/field002.java | 12 +----- .../vmTestbase/nsk/share/jdi/JDIBase.java | 42 ++++++++++++++++++- 189 files changed, 462 insertions(+), 1923 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanType/_itself_/booleantype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanType/_itself_/booleantype001.java index 92bb93ad15c..49c0b778c76 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanType/_itself_/booleantype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanType/_itself_/booleantype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,14 +244,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java index e37ee7eacbe..31dd6718177 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -257,15 +257,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003.java index 612792a417b..5562d2c4239 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -245,15 +245,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java index 6d39e3d31c1..b76ccc799f2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -252,15 +252,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003.java index 421ffc26185..ff18b6b6cf5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -252,15 +252,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java index f2d2de73210..325159b6eb5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,16 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ByteType/_itself_/bytetype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ByteType/_itself_/bytetype001.java index 4c56c75ad13..36666e3b08e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ByteType/_itself_/bytetype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ByteType/_itself_/bytetype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,14 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharType/_itself_/chartype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharType/_itself_/chartype001.java index 66579c598b7..3b0d71619ae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharType/_itself_/chartype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharType/_itself_/chartype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,14 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001.java index 59fc1a0ab11..c7b9cb92858 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,14 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001.java index 63b6fec010c..1d561c27b95 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -255,14 +255,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java index cabaf723c14..c0bfe91a750 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,18 +244,9 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; + setupBreakpointForCommunication(debuggeeClass); - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); - - //------------------------------------------------------ testing section + //------------------------------------------------------ testing section log1(" TESTING BEGINS"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java index dfaaa176977..9be0d89a4b9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -248,15 +248,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java index c175dff4e2f..1cc0dff5c99 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,16 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/DoubleType/_itself_/doubletype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/DoubleType/_itself_/doubletype001.java index c7aa128fa94..99ddbbdcbcc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/DoubleType/_itself_/doubletype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/DoubleType/_itself_/doubletype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,14 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001.java index c6d7b7292e7..970aedb047d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -308,16 +308,7 @@ private void testRun() log2("......setting up ClassPrepareEvent"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001.java index 11b6e4824fc..a6018450771 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -306,16 +306,7 @@ private void testRun() log2("......setting up ClassPrepareEvent"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java index a5d74ff3d95..f6cf40dad38 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -243,18 +243,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java index 056030aab3d..9a84dd3f0fe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,18 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java index 41411b88ac9..f4e41409cae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -248,15 +248,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java index 2bf6c911e6d..b46bf2ee1a2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,15 +244,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java index 109ab148806..615cf46c746 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,15 +244,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java index f4f9a14ac1d..767f069438f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java index 886993a4bb0..b4b9f0edcbc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java index 3ef5500e4ab..d91db9a5a6a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -245,15 +245,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java index fcedeca850b..479c40904e7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java index 1d7c80dfa34..57ed8454eda 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -243,15 +243,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java index c7bcfaa47b7..25b665dbed9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -247,15 +247,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003.java index 8e129027b51..7ebe5b99a1f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java index e1b315519fd..04995ea0b13 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -248,15 +248,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java index 7f927de1577..b11a291b2f5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,15 +244,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002.java index f27f6a12e31..c7b1af9d79b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -245,15 +245,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002.java index 4046560e444..69979345382 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -240,15 +240,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002.java index c9719ba3a54..b2905b6527e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,15 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002.java index b6bc52f154e..c185b8b398e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,15 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003.java index 2be4f8afc9d..9326ce5c7d9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,15 +244,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003.java index 610a691b269..b4af90a642c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,15 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001.java index dd0848af06c..62761b58d33 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -240,15 +240,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001.java index bba4427d531..4cedae783cf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -239,15 +239,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009.java index 4ba4bba13a3..fa92b0e5b96 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -242,15 +242,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010.java index 6d466265ddf..28a787d957f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -243,15 +243,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001.java index e744ec1e8f8..7bfeb11932a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -239,15 +239,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001.java index 9d107ee60b0..94b97da9c0e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,15 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003.java index 24198633580..6059dead131 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -243,15 +243,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java index da62eaea146..a5dd9023dfd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -243,15 +243,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003.java index 129d9470730..d712fb34c42 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2025, 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 @@ -157,14 +157,6 @@ private int runThis(String argv[], PrintStream out) { //--------------------------------------------------------- mutable common methods private void execTest() { - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); -/* - BreakpointRequest bpRequest = setBreakpoint( mainThread, - debuggeeClass, - "methodForCommunication", - 2, - "breakpointForCommunication"); -*/ BreakpointRequest bpRequest = setBreakpoint( null, debuggeeClass, "breakInThread", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004.java index 24305ec29f2..1ab0ce68af8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2025, 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 @@ -158,9 +158,7 @@ private int runThis(String argv[], PrintStream out) { //--------------------------------------------------------- mutable common methods private void execTest() { - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = setBreakpoint( mainThread, + BreakpointRequest bpRequest = setBreakpoint( null, debuggeeClass, "methodForCommunication", lineForBreakInThread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001.java index 5c650112f56..e2045f9a94d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -239,15 +239,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001.java index 8b594d43285..ed81b00561e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,15 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001.java index dcc5c1b680c..29f1cacf7e7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,15 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002.java index 072277425cc..9ed87be5e11 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -240,15 +240,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002.java index 9cfafaea23e..5b5481af063 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002.java index 8a53a91e8e1..03e5e38a3ec 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,15 +244,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/exceptionRequests/excreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/exceptionRequests/excreq002.java index 7c59958fb89..78219909d03 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/exceptionRequests/excreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/exceptionRequests/excreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -242,15 +242,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002.java index 2b37b6e47fa..95a9b36d826 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,15 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002.java index e63a1cd4349..f975441a9ba 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -240,15 +240,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002.java index fe60b2c3963..8a9d5fcbd34 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -247,15 +247,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq002.java index b4354995389..e1f2677c429 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,15 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002.java index ab46a848c8e..9e1b9d8edec 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,15 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java index f7607b22e08..d192c61470d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001.java index 7f839dcc192..3f740b2f30e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -241,15 +241,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator001.java index f16ab02ddfe..e56fb00108d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -266,16 +266,7 @@ private void testRun() cpRequest.disable(); debuggeeClass = event.referenceType(); - - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); - + setupBreakpointForCommunication(debuggeeClass); } else if (property.equals("TestClassPrepareRequest")) { nn2++; if (nn2 > 1) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator002.java index e0a32aa0aa2..0d374f39e37 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -255,16 +255,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section @@ -286,6 +277,7 @@ private void testRun() vm.resume(); breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator003.java index 323dea95fe7..35a9eedfd4d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -251,14 +251,7 @@ private void testRun() throws JDITestRuntimeException, Exception { log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - bpRequest = settingBreakpoint(mainThread, debuggeeClass, bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator004.java index 084db7b6676..20686736deb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -276,16 +276,7 @@ private void testRun() log2("......setting up ClassPrepareEvent"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java index 09bcb91cbdd..b391036fa26 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -260,14 +260,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -287,10 +280,10 @@ private void testRun() ReferenceType testClassReference = null; - for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java index 3ea05a0c7d9..0e13529f5e1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -260,14 +260,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -291,6 +284,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java index 413309e92ad..398e6f074a0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -253,14 +253,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -285,6 +278,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java index 13e0344dd3f..7074828dc8d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -253,14 +253,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -285,6 +278,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java index ef87bba8a0d..492afad89ca 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -253,14 +253,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -282,6 +275,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java index 235fe36c35c..8052c193954 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -253,14 +253,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -282,6 +275,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java index d49e0c516a3..443b7e94286 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -253,14 +253,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -281,6 +274,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume011.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume011.java index fb9c1e6fde4..0eb923321bd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume011.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume011.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -254,14 +254,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -280,6 +273,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume012.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume012.java index 3d153675ee8..32f30882efb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume012.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume012.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -255,14 +255,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -281,6 +274,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume013.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume013.java index d1fc3cb68bb..6019903d6b8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume013.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume013.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -255,14 +255,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -280,6 +273,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy001.java index dd51b0d0390..d145bf46136 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -257,14 +257,8 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy002.java index 01be6ad55c4..93f0a5ca627 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -258,14 +258,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -300,6 +293,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy003.java index 522d6019f25..5c0052e84f9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -265,14 +265,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -308,6 +301,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy004.java index cddb7ace5b0..d6b6a76be19 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -259,14 +259,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -303,6 +296,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy005.java index 9d0c7604aba..cfdb6513482 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -259,14 +259,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -303,6 +296,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy006.java index 068dd94eead..660f4bbbc36 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -258,14 +258,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -301,6 +294,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy007.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy007.java index 4601a0039fa..71abca720e1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy007.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy007.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -258,14 +258,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -300,6 +293,7 @@ private void testRun() breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008.java index d507d8c6a38..f0838067241 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -258,14 +258,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -295,6 +288,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java index ca284271be8..21bffce5cf3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -258,14 +258,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -295,6 +288,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(debuggeeName); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy010.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy010.java index ec015576277..7bd3b660b93 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy010.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy010.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -257,14 +257,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -294,6 +287,7 @@ private void testRun() for (int i = 0; ; i++) { breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy011.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy011.java index 03d7677c0fb..47025717ed7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy011.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy011.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -266,14 +266,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -300,6 +293,7 @@ private void testRun() int policy = 0; breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy012.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy012.java index bb5488d9eb6..420b2fe6c87 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy012.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy012.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -265,14 +265,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -299,6 +292,7 @@ private void testRun() int policy = 0; breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy013.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy013.java index d78655d1b2a..db3a15f3571 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy013.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy013.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -266,14 +266,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -300,6 +293,7 @@ private void testRun() int policy = 0; breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy014.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy014.java index 511dc1ddcc1..d1258b93b0d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy014.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy014.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -267,14 +267,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -301,6 +294,7 @@ private void testRun() int policy = 0; breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy015.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy015.java index a3961c1d005..a14f2485129 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy015.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy015.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -267,14 +267,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -301,6 +294,7 @@ private void testRun() int policy = 0; breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy016.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy016.java index 0b6257f34ef..3c270b547fb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy016.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy016.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -265,14 +265,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -299,6 +292,7 @@ private void testRun() int policy = 0; breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy017.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy017.java index c7589574ee5..171db5a9bb6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy017.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy017.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -267,14 +267,7 @@ private void testRun() log2("......setting up ClassPrepareEvent for breakpointForCommunication"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); @@ -301,6 +294,7 @@ private void testRun() int policy = 0; breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002.java index d0dac294c8b..9402145c3a0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -249,15 +249,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002.java index c3a39e40d0b..ea0e2d36891 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002.java index 8fa62d0edfc..c5cad69c37d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002.java index 6f62f5b08d5..c39f6c8c15d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -257,15 +257,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003.java index f1e9f6607ff..80f8c4024e2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -245,15 +245,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002.java index d641750204c..bb20c736a06 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -252,15 +252,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003.java index 467a66f52fc..0d6f85304c8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -252,15 +252,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/exception/exception001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/exception/exception001.java index 4c0d1824812..ef0bf984182 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/exception/exception001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/exception/exception001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,15 +244,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); vm.resume(); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001.java index ad747876586..fd3410f5d4c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -242,15 +242,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001.java index 883e020caa6..557f60138ba 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -242,15 +242,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatType/_itself_/floattype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatType/_itself_/floattype001.java index 156d4b471ba..5a051ad546f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatType/_itself_/floattype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatType/_itself_/floattype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,14 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerType/_itself_/integertype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerType/_itself_/integertype001.java index 206882b2768..e40dbb1b784 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerType/_itself_/integertype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerType/_itself_/integertype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,14 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocatableEvent/thread/thread001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocatableEvent/thread/thread001.java index 543123066cf..f2031008b2f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocatableEvent/thread/thread001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocatableEvent/thread/thread001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -253,14 +253,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LongType/_itself_/longtype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LongType/_itself_/longtype001.java index 05d5baf3a66..a483e04e5d9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LongType/_itself_/longtype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LongType/_itself_/longtype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,14 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete001.java index 02ce3f5e020..6ccbbca659c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -261,16 +261,7 @@ private void testRun() return; } - - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByName("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section @@ -288,6 +279,7 @@ private void testRun() vm.resume(); breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); @@ -315,7 +307,8 @@ private void testRun() log2(" : isObsolete() == false for m2 method before redefineClasses() invocation "); // Create breakpoint request to have isobsolete002b.m2 on the top of the stack. - bpRequest = debuggee.makeBreakpoint(redefClass, methodName, brkpLineNumber); + BreakpointRequest bpRequest = + debuggee.makeBreakpoint(redefClass, methodName, brkpLineNumber); bpRequest.addThreadFilter(mainThread); bpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); bpRequest.putProperty("number", "one"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete002.java index 1693a63843e..35f59f55524 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -259,16 +259,7 @@ private void testRun() return; } - - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - ThreadReference mainThread = debuggee.threadByName("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section @@ -284,6 +275,7 @@ private void testRun() vm.resume(); breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); @@ -315,7 +307,8 @@ private void testRun() log2(" : isObsolete() == false for m2 method before redefineClasses() invocation"); // Create breakpoint request to have isobsolete002b.m2 on the top of the stack. - bpRequest = debuggee.makeBreakpoint(redefClass, methodName, brkpLineNumber); + BreakpointRequest bpRequest = + debuggee.makeBreakpoint(redefClass, methodName, brkpLineNumber); bpRequest.addThreadFilter(mainThread); bpRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); bpRequest.putProperty("number", "one"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002.java index 5fef3066c44..6e293a98670 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -249,15 +249,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002.java index 1d83e104b72..b34e5c577db 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002.java index 7cb4c40ee47..215639d825f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -249,15 +249,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002.java index 3f013618ac9..02cdff05b4e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -257,15 +257,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003.java index 67009ca963d..a6386045f20 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -248,15 +248,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002.java index b889d75510b..a5a2b16318e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -252,15 +252,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003.java index 161190a7abd..da83ab4ece4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -252,15 +252,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002.java index 75f7ad3a523..3fd039e10d1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -249,15 +249,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002.java index 374ebace2ff..4dedd0debb0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -249,15 +249,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002.java index 3d243865d1a..917bc96c467 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -249,15 +249,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002.java index 25ccf74fe0d..a00e92c32e9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -257,15 +257,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003.java index 33d8d261291..c5414ae5ae1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002.java index b87bfba5fa6..8d2dab19a45 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -251,15 +251,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003.java index b09d7f46f9e..0067f7dde19 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -251,15 +251,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001.java index 42a1e08eb3b..ef10699b5fe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -252,15 +252,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/disableCollection/disablecollection002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/disableCollection/disablecollection002.java index 89dcfde4d99..b7ea4154fec 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/disableCollection/disablecollection002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/disableCollection/disablecollection002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -261,14 +261,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001.java index 97908175e7b..f67e21a7cdd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -244,18 +244,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/PrimitiveType/_itself_/primitivetype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/PrimitiveType/_itself_/primitivetype001.java index a3c32fb0d27..bb3d23352a1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/PrimitiveType/_itself_/primitivetype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/PrimitiveType/_itself_/primitivetype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -237,14 +237,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/classLoader/classloader001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/classLoader/classloader001.java index 644e60f4844..1040f7eba69 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/classLoader/classloader001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/classLoader/classloader001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -230,18 +230,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue001.java index bcd64b0b460..ad2be88a6db 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -231,18 +231,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue002.java index 5d7439b2f8c..8c9aae8802b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -230,18 +230,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue003.java index b81bfd78729..46411cb9d74 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -230,18 +230,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues001.java index b14d687b411..4e7fb04fe0d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -234,18 +234,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal001.java index 885e1ec17a4..88d0d5d8138 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -218,18 +218,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic001.java index e6e901f31e5..d72a6480dbf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,14 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic002.java index d07705fe4c6..b3cf2483d80 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,14 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes001.java index 69d2a8ed24b..7369b663876 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -224,18 +224,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes002.java index 344e1fd199a..dce3f638f28 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -225,18 +225,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch (Exception e) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001.java index fea3e5c78b4..54e297f27e8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -238,14 +238,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002.java index e53f12004cf..d64fa09323c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -248,15 +248,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section @@ -271,6 +263,7 @@ private void testRun() vm.resume(); breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); @@ -287,8 +280,7 @@ private void testRun() switch (i) { case 0: - ThreadReference thread1 = debuggee.threadByNameOrThrow("main"); - eventRequest1 = setting23StepRequest(thread1, testedClassName1, + eventRequest1 = setting23StepRequest(mainThread, testedClassName1, EventRequest.SUSPEND_NONE, property1); eventRequest1.enable(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java index e12e48e9ebf..23be3eab4c9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java index db080ef80ed..d4ff86268da 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002.java index e75a998a07c..19ddd279425 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -257,15 +257,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003.java index f4fa3e1bf68..1f8236db782 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java index 99d24970e6d..de63a0af86b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java index 09b0fa297b4..5cd109f6fa3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java index ef3668a66e8..03b8f415b56 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java index 33b2c02e8eb..db59bf6e498 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java index 5a0df354569..09b0c53ea8c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -246,15 +246,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java index 8bb9711d37b..a8d3769c6c2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -248,15 +248,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001.java index 542a5280d4b..020c04c05d5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -243,16 +243,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002.java index 4d572e1d12c..961a38a6393 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -240,16 +240,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section @@ -259,6 +250,7 @@ private void testRun() vm.resume(); breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003.java index 70d9e87fee4..3a5770ff03c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -254,14 +254,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005.java index 30fac8e0aaa..d07758242ec 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -254,15 +254,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java index 69c30d0aa24..3091f510977 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -260,18 +260,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java index 2e5b28c2dfc..c47358e96f8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -111,7 +111,6 @@ public static int run (String argv[], PrintStream out) { //====================================================== test program - BreakpointRequest bpRequest; BreakpointRequest breakpointRequest2; BreakpointRequest breakpointRequest3; @@ -259,16 +258,7 @@ private void testRun() return; } - - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - log2("......setting BreakpointRequest (bpRequest) in main thread"); - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - log2("bpRequest.enable();"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java index 27866885bdb..84ee5996a77 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -110,7 +110,6 @@ public static int run (String argv[], PrintStream out) { //====================================================== test program - BreakpointRequest bpRequest; MethodEntryRequest meRequest; BreakpointRequest bpRequest2; @@ -260,18 +259,7 @@ private void testRun() return; } - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference threadMainRef = debuggee.threadByNameOrThrow("main"); - try { - bpRequest = settingBreakpoint(threadMainRef, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section @@ -284,9 +272,10 @@ private void testRun() vm.resume(); breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() log2("......setting MethodEntryRequest (meRequest) in ForCommunication.methodForCommunication"); - meRequest = settingMethodEntryRequest(threadMainRef, + meRequest = settingMethodEntryRequest(mainThread, debuggeeName + "$ForCommunication", "zero"); log2("meRequest.enable();"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java index 5e06aec1810..eb46fac37da 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -258,15 +258,7 @@ private void testRun() return; } - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - log2("......setting BreakpointRequest (bpRequest) in main thread"); - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - log2("bpRequest.enable();"); - bpRequest.enable(); + bpRequest = setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java index 7618a200e28..ec499eba24d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -262,15 +262,7 @@ private void testRun() return; } - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - log2("......setting BreakpointRequest (bpRequest) in main thread"); - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - log2("bpRequest.enable();"); - bpRequest.enable(); + bpRequest = setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001.java index ace63e511aa..b9a15b2c377 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -243,16 +243,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003.java index 21cf8a9d164..cacda11b6c4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -254,14 +254,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005.java index 8dad0781d16..255984d7a01 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -248,15 +248,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002.java index 1fa254e7d4a..12804532315 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -237,14 +237,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003.java index 8070d8143c1..26b4693d696 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -242,14 +242,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001.java index 44477e156f9..e5981bf0b34 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -236,18 +236,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001.java index f0eea0731c0..d31f547f80d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -225,18 +225,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001.java index 03f38b66f1f..31e29c10240 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -225,18 +225,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001.java index 88e54ac79a4..b1023026c47 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -225,18 +225,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001.java index 8d057c809cb..aa43d39b559 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -225,18 +225,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001.java index 62d44d8c7bb..b95f5a19a31 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -225,18 +225,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001.java index c03cef0d05c..ad337dd54f5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -225,18 +225,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001.java index 466c2c6ed78..6b0d64d9781 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -236,18 +236,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001.java index b64d346994d..07410545e9f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -237,18 +237,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - try { - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { - throw e; - } - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001.java index 5db62c170de..aab5c173f30 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -264,15 +264,7 @@ private void testRun() return; } - - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section @@ -293,6 +285,7 @@ private void testRun() vm.resume(); breakpointForCommunication(); + ThreadReference mainThread = bpEvent.thread(); // bpEvent saved by breakpointForCommunication() int instruction = ((IntegerValue) (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); @@ -310,9 +303,9 @@ private void testRun() case 0: List classes = vm.classesByName(bpClassName); bpClass = (ReferenceType) classes.get(0); - bpRequest2 = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - bpClass, - bpMethodName, bpLineName, "one"); + bpRequest2 = settingBreakpoint(mainThread, + bpClass, + bpMethodName, bpLineName, "one"); bpRequest2.enable(); vm.resume(); @@ -335,9 +328,9 @@ private void testRun() case 1: - bpRequest3 = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - bpClass, - bpMethodName, bpLineName, "one"); + bpRequest3 = settingBreakpoint(mainThread, + bpClass, + bpMethodName, bpLineName, "one"); bpRequest3.enable(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001.java index f3e0c7f583d..90da9975df4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -237,14 +237,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - BreakpointRequest bpRequest; - - bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003.java index 7b77beedc1a..d7a182cba79 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004.java index 6be78f1d596..0b8d7135cfb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003.java index 1fd6ae0ffde..0d2176b0910 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004.java index 1e37d5cac41..0bd09aca339 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003.java index 92234071cc6..d2ea9213899 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004.java index 21030c2bf40..3790d2e7dcc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -250,15 +250,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003.java index 1d71e9990d3..5b3184ded80 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -258,15 +258,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004.java index 12a0fdac2c8..dd02ed1c67f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -258,15 +258,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005.java index 005367911af..9e690424420 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -247,15 +247,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006.java index e479bb104eb..21756dfd59c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -247,15 +247,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003.java index 344d0e36428..75f4e45345d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -261,15 +261,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004.java index c875dcaa034..b4c7b60971b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -261,15 +261,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005.java index e5bc8a555ed..9e371abf8ee 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -261,15 +261,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006.java index 3ee70ff8202..8f24855f9af 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -262,15 +262,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field001.java index 36af014db0b..0b6d1b67a42 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -248,16 +248,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); - + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section log1(" TESTING BEGINS"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field002.java index 3fbbeb5915b..314b0b32cc7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -249,15 +249,7 @@ private void testRun() log2(" received: ClassPrepareEvent for debuggeeClass"); - String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; - - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); - - BreakpointRequest bpRequest = settingBreakpoint(mainThread, - debuggeeClass, - bPointMethod, lineForComm, "zero"); - bpRequest.enable(); + setupBreakpointForCommunication(debuggeeClass); //------------------------------------------------------ testing section diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java index bc722844afd..ac99b121651 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -89,12 +89,33 @@ public final void log3(String message) { protected Location breakpLocation = null; protected BreakpointEvent bpEvent; + protected final BreakpointRequest settingBreakpoint( + ReferenceType testedClass, + String methodName, + String bpLine, + String property) + throws JDITestRuntimeException { + return settingBreakpoint_private(null, testedClass, methodName, bpLine, property); + } + protected final BreakpointRequest settingBreakpoint(ThreadReference thread, ReferenceType testedClass, String methodName, String bpLine, String property) throws JDITestRuntimeException { + if (thread == null) { + log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): thread is null"); + } + return settingBreakpoint_private(thread, testedClass, methodName, bpLine, property); + } + + private final BreakpointRequest settingBreakpoint_private(ThreadReference thread, + ReferenceType testedClass, + String methodName, + String bpLine, + String property) + throws JDITestRuntimeException { log2("......setting up a breakpoint:"); log2(" thread: " + thread + "; class: " + testedClass + @@ -119,11 +140,14 @@ protected final BreakpointRequest settingBreakpoint(ThreadReference thread, try { breakpRequest = eventRManager.createBreakpointRequest(lineLocation); breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); + if (thread != null) { + breakpRequest.addThreadFilter(thread); + } breakpRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); } catch (Exception e1) { log3("ERROR: inner Exception within settingBreakpoint() : " + e1); breakpRequest = null; + e1.printStackTrace(logHandler.getOutStream()); } } } catch (Exception e2) { @@ -188,6 +212,19 @@ protected void getEventSetForThreadStartDeath(String threadName) throws JDITestR eventIterator = eventSet.eventIterator(); } + // Sets up the standard breakpoint for communication. The breakpoint is set on + // methodForCommunication() using the line number stored in the "lineForComm" + // local variable. The breakpoint is enabled. + protected BreakpointRequest setupBreakpointForCommunication(ReferenceType debuggeeClass) { + String bPointMethod = "methodForCommunication"; + String lineForComm = "lineForComm"; + + BreakpointRequest bpRequest = + settingBreakpoint(debuggeeClass, bPointMethod, lineForComm, "zero"); + bpRequest.enable(); + return bpRequest; + } + protected void breakpointForCommunication() throws JDITestRuntimeException { log2("breakpointForCommunication"); @@ -219,6 +256,7 @@ protected void breakpointForCommunication(String debuggeeName) throws JDITestRun Event event = eventIterator.nextEvent(); if (event instanceof BreakpointEvent) { + bpEvent = (BreakpointEvent) event; return; } if (EventFilters.filtered(event, debuggeeName)) { From 53924882326d3756a4ec52f37a59c8a81059a069 Mon Sep 17 00:00:00 2001 From: Damon Nguyen Date: Wed, 23 Apr 2025 00:13:09 +0000 Subject: [PATCH 064/901] 8355332: Fix failing semi-manual test EDT issue Reviewed-by: azvegint --- .../HorizScrollers.java | 7 +++--- .../RTLScrollers.java | 24 ++++++++----------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java b/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java index b584fd66da3..61124ea1e97 100644 --- a/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java +++ b/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java @@ -161,8 +161,9 @@ private void showFinalReminderIfNeeded(boolean isFailure) { if (scrollAmount != 3) { JOptionPane.showMessageDialog( ConfigPanel.this.getTopLevelAncestor(), - ("Test %s. please make sure you have restored " + - "the original speed value blah blah") + ("Test %s. Please make sure you have restored " + + "the original scrolling speed in the " + + "Mouse settings.") .formatted(isFailure ? "failed" : "passed"), @@ -231,4 +232,4 @@ public void mouseWheelMoved(MouseWheelEvent e) { } } } -} \ No newline at end of file +} diff --git a/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/RTLScrollers.java b/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/RTLScrollers.java index 24e8df6fad8..da395282bf5 100644 --- a/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/RTLScrollers.java +++ b/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/RTLScrollers.java @@ -265,22 +265,21 @@ public static boolean runTest(int scrollAmount) } } + robot.delay(1000); SwingUtilities.invokeAndWait(() -> { rtl = new RTLScrollers(scrollAmount); rtl.setVisible(true); }); robot.delay(100); - SwingUtilities.invokeAndWait(() -> { - try { - retVal = rtl.runTests(scrollAmount); - } catch (Exception e) { - e.printStackTrace(); - } finally { + try { + retVal = rtl.runTests(scrollAmount); + } finally { + SwingUtilities.invokeAndWait(() -> { rtl.setVisible(false); rtl.dispose(); - } - }); + }); + } robot.delay(100); System.out.println("RTLS.runTest(): " + retVal); @@ -312,9 +311,8 @@ private boolean runTests(int scrollAmount) System.out.println("Testing List"); testComp(list, scrollAmount); - SwingUtilities.invokeAndWait(() -> { - applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - }); + SwingUtilities.invokeAndWait(() -> + applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)); robot.delay(100); System.out.println("Testing RTL Table"); @@ -467,9 +465,7 @@ public boolean testComp(TestTools comp, int scrollAmount) // Test acceleration for max scrolling // (this part should still work for RTL JList) if (scrollAmount == 30) { - SwingUtilities.invokeAndWait(() -> { - hsb.setValue(hsb.getMinimum()); - }); + SwingUtilities.invokeAndWait(() -> hsb.setValue(hsb.getMinimum())); robot.delay(100); robot.mouseWheel(2); robot.mouseWheel(2); From 4c373703d9ed63dfc85df7cdcc04ecad5b02ade0 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Wed, 23 Apr 2025 02:04:46 +0000 Subject: [PATCH 065/901] 8354668: Missing REX2 prefix accounting in ZGC barriers leads to incorrect encoding Reviewed-by: aboldtch, sviswanathan --- .../cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp | 14 +++++++------- .../cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp | 2 +- src/hotspot/cpu/x86/gc/z/z_x86_64.ad | 4 ++-- src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp index 9cdf0b229c0..0891d303563 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp @@ -391,8 +391,8 @@ void ZBarrierSetAssembler::store_barrier_fast(MacroAssembler* masm, if (rnew_zaddress != noreg) { // noreg means null; no need to color __ movptr(rnew_zpointer, rnew_zaddress); - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shlq(rnew_zpointer, barrier_Relocation::unpatched); + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); __ orq_imm32(rnew_zpointer, barrier_Relocation::unpatched); __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr); } @@ -969,13 +969,13 @@ void ZBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, #define __ ce->masm()-> static void z_uncolor(LIR_Assembler* ce, LIR_Opr ref) { - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shrq(ref->as_register(), barrier_Relocation::unpatched); + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); } static void z_color(LIR_Assembler* ce, LIR_Opr ref) { - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shlq(ref->as_register(), barrier_Relocation::unpatched); + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); __ orq_imm32(ref->as_register(), barrier_Relocation::unpatched); __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr); } @@ -1278,8 +1278,8 @@ void ZBarrierSetAssembler::generate_c2_store_barrier_stub(MacroAssembler* masm, static int patch_barrier_relocation_offset(int format) { switch (format) { - case ZBarrierRelocationFormatLoadGoodBeforeShl: - return 3; + case ZBarrierRelocationFormatLoadGoodAfterShX: + return -1; case ZBarrierRelocationFormatStoreGoodAfterCmp: return -2; @@ -1300,7 +1300,7 @@ static int patch_barrier_relocation_offset(int format) { static uint16_t patch_barrier_relocation_value(int format) { switch (format) { - case ZBarrierRelocationFormatLoadGoodBeforeShl: + case ZBarrierRelocationFormatLoadGoodAfterShX: return (uint16_t)ZPointerLoadShift; case ZBarrierRelocationFormatMarkBadAfterTest: @@ -1327,7 +1327,7 @@ void ZBarrierSetAssembler::patch_barrier_relocation(address addr, int format) { const int offset = patch_barrier_relocation_offset(format); const uint16_t value = patch_barrier_relocation_value(format); uint8_t* const patch_addr = (uint8_t*)addr + offset; - if (format == ZBarrierRelocationFormatLoadGoodBeforeShl) { + if (format == ZBarrierRelocationFormatLoadGoodAfterShX) { *patch_addr = (uint8_t)value; } else { *(uint16_t*)patch_addr = value; diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp index 8bb653ec5fb..6976452bd63 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp @@ -49,7 +49,7 @@ class ZLoadBarrierStubC2; class ZStoreBarrierStubC2; #endif // COMPILER2 -const int ZBarrierRelocationFormatLoadGoodBeforeShl = 0; +const int ZBarrierRelocationFormatLoadGoodAfterShX = 0; const int ZBarrierRelocationFormatLoadBadAfterTest = 1; const int ZBarrierRelocationFormatMarkBadAfterTest = 2; const int ZBarrierRelocationFormatStoreGoodAfterCmp = 3; diff --git a/src/hotspot/cpu/x86/gc/z/z_x86_64.ad b/src/hotspot/cpu/x86/gc/z/z_x86_64.ad index 045aa5d5381..e2484a71e7d 100644 --- a/src/hotspot/cpu/x86/gc/z/z_x86_64.ad +++ b/src/hotspot/cpu/x86/gc/z/z_x86_64.ad @@ -35,15 +35,15 @@ source %{ #include "gc/z/zBarrierSetAssembler.hpp" static void z_color(MacroAssembler* masm, const MachNode* node, Register ref) { - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shlq(ref, barrier_Relocation::unpatched); + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); __ orq_imm32(ref, barrier_Relocation::unpatched); __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr); } static void z_uncolor(MacroAssembler* masm, const MachNode* node, Register ref) { - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shrq(ref, barrier_Relocation::unpatched); + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); } static void z_keep_alive_load_barrier(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref) { diff --git a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp b/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp index 9e6a4789dc2..7e239a68983 100644 --- a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp +++ b/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp @@ -221,7 +221,7 @@ bool CodeInstaller::pd_relocate(address pc, jint mark) { return true; #if INCLUDE_ZGC case Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_SHL: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); + _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); return true; case Z_BARRIER_RELOCATION_FORMAT_LOAD_BAD_AFTER_TEST: _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadBadAfterTest); From a8c6ff161c2c4f1dcf0f8588c9d007994c84e703 Mon Sep 17 00:00:00 2001 From: Fei Yang Date: Wed, 23 Apr 2025 02:10:25 +0000 Subject: [PATCH 066/901] 8355239: RISC-V: Do not support subword scatter store Reviewed-by: mli, fjiang --- src/hotspot/cpu/riscv/riscv_v.ad | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hotspot/cpu/riscv/riscv_v.ad b/src/hotspot/cpu/riscv/riscv_v.ad index 7c1ca4f8960..6fea439954c 100644 --- a/src/hotspot/cpu/riscv/riscv_v.ad +++ b/src/hotspot/cpu/riscv/riscv_v.ad @@ -89,6 +89,8 @@ source %{ return UseZvbb; case Op_LoadVectorGather: case Op_LoadVectorGatherMasked: + case Op_StoreVectorScatter: + case Op_StoreVectorScatterMasked: if (is_subword_type(bt)) { return false; } From bc518a6cbb9fadc47b00239b4d721c1c62dc5dad Mon Sep 17 00:00:00 2001 From: Shaojin Wen Date: Wed, 23 Apr 2025 02:32:36 +0000 Subject: [PATCH 067/901] 8355240: Remove unused Import in StringUTF16 Reviewed-by: rgiulietti --- src/java.base/share/classes/java/lang/StringUTF16.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/lang/StringUTF16.java b/src/java.base/share/classes/java/lang/StringUTF16.java index 99226ac1012..a07c022040f 100644 --- a/src/java.base/share/classes/java/lang/StringUTF16.java +++ b/src/java.base/share/classes/java/lang/StringUTF16.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, 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 @@ -39,7 +39,6 @@ import jdk.internal.vm.annotation.IntrinsicCandidate; import static java.lang.String.UTF16; -import static java.lang.String.LATIN1; final class StringUTF16 { From 8c89fb95351ea0bc5ffdd920c18f9e820231f233 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 23 Apr 2025 03:40:26 +0000 Subject: [PATCH 068/901] 8355179: Reinstate javax/swing/JScrollBar/4865918/bug4865918.java headful and macos run Reviewed-by: abhiscxk, serb --- .../swing/JScrollBar/4865918/bug4865918.java | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java b/test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java index 96b1034c943..d68f1bff597 100644 --- a/test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java +++ b/test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java @@ -24,14 +24,16 @@ /* * @test * @bug 4865918 - * @requires (os.family != "mac") + * @key headful * @summary REGRESSION:JCK1.4a-runtime api/javax_swing/interactive/JScrollBarTests.html#JScrollBar * @run main bug4865918 */ import java.awt.Dimension; +import java.awt.Robot; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import javax.swing.JFrame; import javax.swing.JScrollBar; import javax.swing.SwingUtilities; import java.util.concurrent.CountDownLatch; @@ -41,24 +43,33 @@ public class bug4865918 { + private static JFrame frame; private static TestScrollBar sbar; private static final CountDownLatch mousePressLatch = new CountDownLatch(1); public static void main(String[] argv) throws Exception { - String osName = System.getProperty("os.name"); - if (osName.toLowerCase().contains("os x")) { - System.out.println("This test is not for MacOS, considered passed."); - return; - } - SwingUtilities.invokeAndWait(() -> setupTest()); + try { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> createAndShowGUI()); - SwingUtilities.invokeAndWait(() -> sbar.pressMouse()); - if (!mousePressLatch.await(2, TimeUnit.SECONDS)) { - throw new RuntimeException("Timed out waiting for mouse press"); - } + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> sbar.pressMouse()); + if (!mousePressLatch.await(2, TimeUnit.SECONDS)) { + throw new RuntimeException("Timed out waiting for mouse press"); + } - if (getValue() != 9) { - throw new RuntimeException("The scrollbar block increment is incorrect"); + if (getValue() != 9) { + throw new RuntimeException("The scrollbar block increment " + + getValue() + " is incorrect"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); } } @@ -73,8 +84,8 @@ private static int getValue() throws Exception { return result[0]; } - private static void setupTest() { - + private static void createAndShowGUI() { + frame = new JFrame("bug4865918"); sbar = new TestScrollBar(JScrollBar.HORIZONTAL, -1, 10, -100, 100); sbar.setPreferredSize(new Dimension(200, 20)); sbar.setBlockIncrement(10); @@ -83,7 +94,11 @@ public void mousePressed(MouseEvent e) { mousePressLatch.countDown(); } }); - + frame.getContentPane().add(sbar); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.toFront(); } static class TestScrollBar extends JScrollBar { From 9a2b425b13cc468d8627c1548d1d39015ce17af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Jeli=C5=84ski?= Date: Wed, 23 Apr 2025 05:17:41 +0000 Subject: [PATCH 069/901] 8354920: SA core file support on Linux only prints error messages when debug logging is enabled Reviewed-by: cjplummer, kevinw --- .../linux/native/libsaproc/libproc_impl.c | 4 +- .../linux/native/libsaproc/ps_core.c | 89 ++++++++++++------- .../linux/native/libsaproc/ps_proc.c | 34 +++++-- .../macosx/native/libsaproc/libproc_impl.c | 4 +- .../macosx/native/libsaproc/ps_core.c | 43 +++++---- .../share/native/libsaproc/ps_core_common.c | 2 + 6 files changed, 114 insertions(+), 62 deletions(-) diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c index 977347048a3..74563aa0d6c 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -349,7 +349,7 @@ const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* p thread_info* add_thread_info(struct ps_prochandle* ph, lwpid_t lwp_id) { thread_info* newthr; if ( (newthr = (thread_info*) calloc(1, sizeof(thread_info))) == NULL) { - print_debug("can't allocate memory for thread_info\n"); + print_error("can't allocate memory for thread_info\n"); return NULL; } diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c index b1b69c81e2e..808ef42e069 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -30,6 +30,7 @@ #include #include #include +#include #include "libproc_impl.h" #include "ps_core_common.h" #include "proc_service.h" @@ -67,7 +68,7 @@ static bool sort_map_array(struct ps_prochandle* ph) { // allocate map_array map_info** array; if ( (array = (map_info**) malloc(sizeof(map_info*) * num_maps)) == NULL) { - print_debug("can't allocate memory for map array\n"); + print_error("can't allocate memory for map array\n"); return false; } @@ -189,8 +190,10 @@ static bool core_handle_prstatus(struct ps_prochandle* ph, const char* buf, size prstatus_t* prstat = (prstatus_t*) buf; thread_info* newthr; print_debug("got integer regset for lwp %d\n", prstat->pr_pid); - if((newthr = add_thread_info(ph, prstat->pr_pid)) == NULL) + if((newthr = add_thread_info(ph, prstat->pr_pid)) == NULL) { + print_error("failed to add thread info\n"); return false; + } // copy regs memcpy(&newthr->regs, prstat->pr_reg, sizeof(struct user_regs_struct)); @@ -256,20 +259,20 @@ static bool core_handle_note(struct ps_prochandle* ph, ELF_PHDR* note_phdr) { // we are interested in just prstatus entries. we will ignore the rest. // Advance the seek pointer to the start of the PT_NOTE data if (lseek(ph->core->core_fd, note_phdr->p_offset, SEEK_SET) == (off_t)-1) { - print_debug("failed to lseek to PT_NOTE data\n"); + print_error("failed to lseek to PT_NOTE data\n"); return false; } // Now process the PT_NOTE structures. Each one is preceded by // an Elf{32/64}_Nhdr structure describing its type and size. if ( (buf = (char*) malloc(size)) == NULL) { - print_debug("can't allocate memory for reading core notes\n"); + print_error("can't allocate memory for reading core notes\n"); goto err; } // read notes into buffer if (read(ph->core->core_fd, buf, size) != size) { - print_debug("failed to read notes, core file must have been truncated\n"); + print_error("failed to read notes, core file must have been truncated\n"); goto err; } @@ -282,6 +285,7 @@ static bool core_handle_note(struct ps_prochandle* ph, ELF_PHDR* note_phdr) { if (notep->n_type == NT_PRSTATUS) { if (core_handle_prstatus(ph, descdata, notep->n_descsz) != true) { + print_error("failed to handle NT_PRSTATUS note\n"); return false; } } else if (notep->n_type == NT_AUXV) { @@ -314,8 +318,10 @@ static bool read_core_segments(struct ps_prochandle* ph, ELF_EHDR* core_ehdr) { ELF_PHDR* phbuf = NULL; ELF_PHDR* core_php = NULL; - if ((phbuf = read_program_header_table(ph->core->core_fd, core_ehdr)) == NULL) + if ((phbuf = read_program_header_table(ph->core->core_fd, core_ehdr)) == NULL) { + print_error("failed to read program header table\n"); return false; + } /* * Now iterate through the program headers in the core file. @@ -344,6 +350,7 @@ static bool read_core_segments(struct ps_prochandle* ph, ELF_EHDR* core_ehdr) { switch (core_php->p_type) { case PT_NOTE: if (core_handle_note(ph, core_php) != true) { + print_error("failed to read note segment\n"); goto err; } break; @@ -351,7 +358,10 @@ static bool read_core_segments(struct ps_prochandle* ph, ELF_EHDR* core_ehdr) { case PT_LOAD: { if (core_php->p_filesz != 0) { if (add_map_info(ph, ph->core->core_fd, core_php->p_offset, - core_php->p_vaddr, core_php->p_filesz, core_php->p_flags) == NULL) goto err; + core_php->p_vaddr, core_php->p_filesz, core_php->p_flags) == NULL) { + print_error("failed to add map info\n"); + goto err; + } } break; } @@ -376,6 +386,7 @@ static bool read_lib_segments(struct ps_prochandle* ph, int lib_fd, ELF_EHDR* li int page_size = sysconf(_SC_PAGE_SIZE); if ((phbuf = read_program_header_table(lib_fd, lib_ehdr)) == NULL) { + print_error("failed to read program header table\n"); return false; } @@ -391,6 +402,7 @@ static bool read_lib_segments(struct ps_prochandle* ph, int lib_fd, ELF_EHDR* li if (existing_map == NULL){ if (add_map_info(ph, lib_fd, lib_php->p_offset, target_vaddr, lib_php->p_memsz, lib_php->p_flags) == NULL) { + print_error("failed to add map info\n"); goto err; } } else if (lib_php->p_flags != existing_map->flags) { @@ -412,7 +424,7 @@ static bool read_lib_segments(struct ps_prochandle* ph, int lib_fd, ELF_EHDR* li (existing_map->fd != lib_fd) && (ROUNDUP(existing_map->memsz, page_size) != ROUNDUP(lib_php->p_memsz, page_size))) { - print_debug("address conflict @ 0x%lx (existing map size = %ld, size = %ld, flags = %d)\n", + print_error("address conflict @ 0x%lx (existing map size = %ld, size = %ld, flags = %d)\n", target_vaddr, existing_map->memsz, lib_php->p_memsz, lib_php->p_flags); goto err; } @@ -442,12 +454,12 @@ static bool read_interp_segments(struct ps_prochandle* ph) { ELF_EHDR interp_ehdr; if (read_elf_header(ph->core->interp_fd, &interp_ehdr) != true) { - print_debug("interpreter is not a valid ELF file\n"); + print_error("interpreter is not a valid ELF file\n"); return false; } if (read_lib_segments(ph, ph->core->interp_fd, &interp_ehdr, ph->core->ld_base_addr) != true) { - print_debug("can't read segments of interpreter\n"); + print_error("can't read segments of interpreter\n"); return false; } @@ -463,6 +475,7 @@ static uintptr_t read_exec_segments(struct ps_prochandle* ph, ELF_EHDR* exec_ehd uintptr_t result = 0L; if ((phbuf = read_program_header_table(ph->core->exec_fd, exec_ehdr)) == NULL) { + print_error("failed to read program header table\n"); return 0L; } @@ -473,7 +486,10 @@ static uintptr_t read_exec_segments(struct ps_prochandle* ph, ELF_EHDR* exec_ehd case PT_LOAD: { // add only non-writable segments of non-zero filesz if (!(exec_php->p_flags & PF_W) && exec_php->p_filesz != 0) { - if (add_map_info(ph, ph->core->exec_fd, exec_php->p_offset, exec_php->p_vaddr, exec_php->p_filesz, exec_php->p_flags) == NULL) goto err; + if (add_map_info(ph, ph->core->exec_fd, exec_php->p_offset, exec_php->p_vaddr, exec_php->p_filesz, exec_php->p_flags) == NULL) { + print_error("failed to add map info\n"); + goto err; + } } break; } @@ -484,18 +500,19 @@ static uintptr_t read_exec_segments(struct ps_prochandle* ph, ELF_EHDR* exec_ehd // BUF_SIZE is PATH_MAX + NAME_MAX + 1. if (exec_php->p_filesz > BUF_SIZE) { + print_error("Invalid ELF interpreter info\n"); goto err; } if (pread(ph->core->exec_fd, interp_name, exec_php->p_filesz, exec_php->p_offset) != exec_php->p_filesz) { - print_debug("Unable to read in the ELF interpreter\n"); + print_error("Unable to read in the ELF interpreter\n"); goto err; } interp_name[exec_php->p_filesz] = '\0'; print_debug("ELF interpreter %s\n", interp_name); // read interpreter segments as well if ((ph->core->interp_fd = pathmap_open(interp_name)) < 0) { - print_debug("can't open runtime loader\n"); + print_error("can't open runtime loader\n"); goto err; } break; @@ -555,7 +572,7 @@ static uintptr_t calc_prelinked_load_address(struct ps_prochandle* ph, int lib_f phbuf = read_program_header_table(lib_fd, elf_ehdr); if (phbuf == NULL) { - print_debug("can't read program header of shared object\n"); + print_error("can't read program header of shared object\n"); return INVALID_LOAD_ADDRESS; } @@ -571,7 +588,7 @@ static uintptr_t calc_prelinked_load_address(struct ps_prochandle* ph, int lib_f if (ps_pdread(ph, (psaddr_t)link_map_addr + LINK_MAP_LD_OFFSET, &lib_ld, sizeof(uintptr_t)) != PS_OK) { - print_debug("can't read address of dynamic section in shared object\n"); + print_error("can't read address of dynamic section in shared object\n"); return INVALID_LOAD_ADDRESS; } @@ -607,7 +624,7 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { dyn.d_tag = DT_NULL; while (dyn.d_tag != DT_DEBUG) { if (ps_pdread(ph, (psaddr_t) addr, &dyn, sizeof(ELF_DYN)) != PS_OK) { - print_debug("can't read debug info from _DYNAMIC\n"); + print_error("can't read debug info from _DYNAMIC\n"); return false; } addr += sizeof(ELF_DYN); @@ -618,14 +635,14 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { // at debug_base we have struct r_debug. This has first link map in r_map field if (ps_pdread(ph, (psaddr_t) debug_base + FIRST_LINK_MAP_OFFSET, &first_link_map_addr, sizeof(uintptr_t)) != PS_OK) { - print_debug("can't read first link map address\n"); + print_error("can't read first link map address\n"); return false; } // read ld_base address from struct r_debug if (ps_pdread(ph, (psaddr_t) debug_base + LD_BASE_OFFSET, &ld_base_addr, sizeof(uintptr_t)) != PS_OK) { - print_debug("can't read ld base address\n"); + print_error("can't read ld base address\n"); return false; } ph->core->ld_base_addr = ld_base_addr; @@ -634,11 +651,13 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { // now read segments from interp (i.e ld.so or ld-linux.so or ld-elf.so) if (read_interp_segments(ph) != true) { + print_error("failed to read interp segments\n"); return false; } // after adding interpreter (ld.so) mappings sort again if (sort_map_array(ph) != true) { + print_error("failed to sort segment map array\n"); return false; } @@ -654,14 +673,14 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_ADDR_OFFSET, &lib_base_diff, sizeof(uintptr_t)) != PS_OK) { - print_debug("can't read shared object base address diff\n"); + print_error("can't read shared object base address diff\n"); return false; } // read address of the name if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_NAME_OFFSET, &lib_name_addr, sizeof(uintptr_t)) != PS_OK) { - print_debug("can't read address of shared object name\n"); + print_error("can't read address of shared object name\n"); return false; } @@ -687,6 +706,7 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { lib_base_diff = calc_prelinked_load_address(ph, lib_fd, &elf_ehdr, link_map_addr); if (lib_base_diff == INVALID_LOAD_ADDRESS) { close(lib_fd); + print_error("failed to calculate load address\n"); return false; } } @@ -696,15 +716,17 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { lib_name, lib_base, lib_base_diff); // while adding library mappings we need to use "base difference". if (! read_lib_segments(ph, lib_fd, &elf_ehdr, lib_base_diff)) { - print_debug("can't read shared object's segments\n"); + print_error("can't read shared object's segments\n"); close(lib_fd); return false; } add_lib_info_fd(ph, lib_name, lib_fd, lib_base); // Map info is added for the library (lib_name) so // we need to re-sort it before calling the p_pdread. - if (sort_map_array(ph) != true) + if (sort_map_array(ph) != true) { + print_error("failed to sort segment map array\n"); return false; + } } else { print_debug("can't read ELF header for shared object %s\n", lib_name); close(lib_fd); @@ -716,7 +738,7 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { // read next link_map address if (ps_pdread(ph, (psaddr_t) link_map_addr + LINK_MAP_NEXT_OFFSET, &link_map_addr, sizeof(uintptr_t)) != PS_OK) { - print_debug("can't read next link in link_map\n"); + print_error("can't read next link in link_map\n"); return false; } } @@ -732,13 +754,13 @@ Pgrab_core(const char* exec_file, const char* core_file) { struct ps_prochandle* ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle)); if (ph == NULL) { - print_debug("can't allocate ps_prochandle\n"); + print_error("can't allocate ps_prochandle\n"); return NULL; } if ((ph->core = (struct core_data*) calloc(1, sizeof(struct core_data))) == NULL) { free(ph); - print_debug("can't allocate ps_prochandle\n"); + print_error("can't allocate ps_prochandle\n"); return NULL; } @@ -750,39 +772,42 @@ Pgrab_core(const char* exec_file, const char* core_file) { // open the core file if ((ph->core->core_fd = open(core_file, O_RDONLY)) < 0) { - print_debug("can't open core file\n"); + print_error("can't open core file: %s\n", strerror(errno)); goto err; } // read core file ELF header if (read_elf_header(ph->core->core_fd, &core_ehdr) != true || core_ehdr.e_type != ET_CORE) { - print_debug("core file is not a valid ELF ET_CORE file\n"); + print_error("core file is not a valid ELF ET_CORE file\n"); goto err; } if ((ph->core->exec_fd = open(exec_file, O_RDONLY)) < 0) { - print_debug("can't open executable file\n"); + print_error("can't open executable file: %s\n", strerror(errno)); goto err; } if (read_elf_header(ph->core->exec_fd, &exec_ehdr) != true || ((exec_ehdr.e_type != ET_EXEC) && (exec_ehdr.e_type != ET_DYN))) { - print_debug("executable file is not a valid ELF file\n"); + print_error("executable file is not a valid ELF file\n"); goto err; } // process core file segments if (read_core_segments(ph, &core_ehdr) != true) { + print_error("failed to read core segments\n"); goto err; } // process exec file segments uintptr_t exec_base_addr = read_exec_segments(ph, &exec_ehdr); if (exec_base_addr == 0L) { + print_error("failed to read exec segments\n"); goto err; } print_debug("exec_base_addr = 0x%lx\n", exec_base_addr); if (add_lib_info_fd(ph, exec_file, ph->core->exec_fd, exec_base_addr) == NULL) { + print_error("failed to add lib info\n"); goto err; } @@ -790,19 +815,23 @@ Pgrab_core(const char* exec_file, const char* core_file) { // here because read_shared_lib_info needs to read from debuggee // address space if (sort_map_array(ph) != true) { + print_error("failed to sort segment map array\n"); goto err; } if (read_shared_lib_info(ph) != true) { + print_error("failed to read libraries\n"); goto err; } // sort again because we have added more mappings from shared objects if (sort_map_array(ph) != true) { + print_error("failed to sort segment map array\n"); goto err; } if (init_classsharing_workaround(ph) != true) { + print_error("failed to workaround class sharing\n"); goto err; } diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c index de81e962d8a..fdaa30c3f5d 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -349,7 +349,7 @@ static bool read_lib_info(struct ps_prochandle* ph) { snprintf(fname, sizeof(fname), "/proc/%d/maps", ph->pid); fp = fopen(fname, "r"); if (fp == NULL) { - print_debug("can't open /proc/%d/maps file\n", ph->pid); + print_error("can't open /proc/%d/maps file\n", ph->pid); return false; } @@ -447,13 +447,14 @@ Pgrab(pid_t pid, char* err_buf, size_t err_buf_len) { if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) { snprintf(err_buf, err_buf_len, "can't allocate memory for ps_prochandle"); - print_debug("%s\n", err_buf); + print_error("%s\n", err_buf); return NULL; } if ((attach_status = ptrace_attach(pid, err_buf, err_buf_len)) != ATTACH_SUCCESS) { if (attach_status == ATTACH_THREAD_DEAD) { - print_error("The process with pid %d does not exist.\n", pid); + snprintf(err_buf, err_buf_len, "The process with pid %d does not exist.", pid); + print_error("%s\n", err_buf); } free(ph); return NULL; @@ -461,7 +462,12 @@ Pgrab(pid_t pid, char* err_buf, size_t err_buf_len) { // initialize ps_prochandle ph->pid = pid; - add_thread_info(ph, ph->pid); + if (add_thread_info(ph, ph->pid) == NULL) { + snprintf(err_buf, err_buf_len, "failed to add thread info"); + print_error("%s\n", err_buf); + free(ph); + return NULL; + } // initialize vtable ph->ops = &process_ops; @@ -469,7 +475,10 @@ Pgrab(pid_t pid, char* err_buf, size_t err_buf_len) { // read library info and symbol tables, must do this before attaching threads, // as the symbols in the pthread library will be used to figure out // the list of threads within the same process. - read_lib_info(ph); + if (read_lib_info(ph) == false) { + snprintf(err_buf, err_buf_len, "failed to read lib info"); + goto err; + } /* * Read thread info. @@ -491,7 +500,10 @@ Pgrab(pid_t pid, char* err_buf, size_t err_buf_len) { continue; } if (!process_doesnt_exist(lwp_id)) { - add_thread_info(ph, lwp_id); + if (add_thread_info(ph, lwp_id) == NULL) { + snprintf(err_buf, err_buf_len, "failed to add thread info"); + goto err; + } } } closedir(dirp); @@ -510,11 +522,15 @@ Pgrab(pid_t pid, char* err_buf, size_t err_buf_len) { delete_thread_info(ph, current_thr); } else { - Prelease(ph); - return NULL; + snprintf(err_buf, err_buf_len, "Failed to attach to the thread with lwp_id %d.", current_thr->lwp_id); + goto err; } // ATTACH_THREAD_DEAD } // !ATTACH_SUCCESS } } return ph; +err: + print_error("%s\n", err_buf); + Prelease(ph); + return NULL; } diff --git a/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.c b/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.c index ff48c402f8d..8bcd09d40ce 100644 --- a/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.c +++ b/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, 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 @@ -323,7 +323,7 @@ const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* p sa_thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) { sa_thread_info* newthr; if ( (newthr = (sa_thread_info*) calloc(1, sizeof(sa_thread_info))) == NULL) { - print_debug("can't allocate memory for thread_info\n"); + print_error("can't allocate memory for thread_info\n"); return NULL; } diff --git a/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c b/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c index e07b3a8fd97..149997dc4bb 100644 --- a/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c +++ b/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -74,7 +74,7 @@ static bool sort_map_array(struct ps_prochandle* ph) { // allocate map_array map_info** array; if ( (array = (map_info**) malloc(sizeof(map_info*) * num_maps)) == NULL) { - print_debug("can't allocate memory for map array\n"); + print_error("can't allocate memory for map array\n"); return false; } @@ -280,6 +280,7 @@ static bool read_core_segments(struct ps_prochandle* ph) { lseek(fd, offset, SEEK_SET); if(read(fd, (void *)&fhead, sizeof(mach_header_64)) != sizeof(mach_header_64)) { + print_error("Failed to read program header table\n"); goto err; } print_debug("total commands: %d\n", fhead.ncmds); @@ -287,6 +288,7 @@ static bool read_core_segments(struct ps_prochandle* ph) { for (i = 0; i < fhead.ncmds; i++) { lseek(fd, offset, SEEK_SET); if (read(fd, (void *)&lcmd, sizeof(load_command)) != sizeof(load_command)) { + print_error("Failed to read command\n"); goto err; } offset += lcmd.cmdsize; // next command position @@ -294,14 +296,14 @@ static bool read_core_segments(struct ps_prochandle* ph) { if (lcmd.cmd == LC_SEGMENT_64) { lseek(fd, -sizeof(load_command), SEEK_CUR); if (read(fd, (void *)&segcmd, sizeof(segment_command_64)) != sizeof(segment_command_64)) { - print_debug("failed to read LC_SEGMENT_64 i = %d!\n", i); + print_error("failed to read LC_SEGMENT_64 i = %d!\n", i); goto err; } // The base of the library is offset by a random amount which ends up as a load command with a // filesize of 0. This must be ignored otherwise the base address of the library is wrong. if (segcmd.filesize != 0) { if (add_map_info(ph, fd, segcmd.fileoff, segcmd.vmaddr, segcmd.vmsize, segcmd.flags) == NULL) { - print_debug("Failed to add map_info at i = %d\n", i); + print_error("Failed to add map_info at i = %d\n", i); goto err; } } @@ -318,7 +320,7 @@ static bool read_core_segments(struct ps_prochandle* ph) { uint32_t size = sizeof(load_command); while (size < lcmd.cmdsize) { if (read(fd, (void *)&fc, sizeof(thread_fc)) != sizeof(thread_fc)) { - printf("Reading flavor, count failed.\n"); + print_error("Reading flavor, count failed.\n"); goto err; } size += sizeof(thread_fc); @@ -326,14 +328,14 @@ static bool read_core_segments(struct ps_prochandle* ph) { if (fc.flavor == x86_THREAD_STATE) { x86_thread_state_t thrstate; if (read(fd, (void *)&thrstate, sizeof(x86_thread_state_t)) != sizeof(x86_thread_state_t)) { - printf("Reading flavor, count failed.\n"); + print_error("Reading flavor, count failed.\n"); goto err; } size += sizeof(x86_thread_state_t); // create thread info list, update lwp_id later sa_thread_info* newthr = add_thread_info(ph, (pthread_t) -1, (lwpid_t) num_threads++); if (newthr == NULL) { - printf("create thread_info failed\n"); + print_error("create thread_info failed\n"); goto err; } @@ -370,14 +372,14 @@ static bool read_core_segments(struct ps_prochandle* ph) { } else if (fc.flavor == x86_FLOAT_STATE) { x86_float_state_t flstate; if (read(fd, (void *)&flstate, sizeof(x86_float_state_t)) != sizeof(x86_float_state_t)) { - print_debug("Reading flavor, count failed.\n"); + print_error("Reading flavor, count failed.\n"); goto err; } size += sizeof(x86_float_state_t); } else if (fc.flavor == x86_EXCEPTION_STATE) { x86_exception_state_t excpstate; if (read(fd, (void *)&excpstate, sizeof(x86_exception_state_t)) != sizeof(x86_exception_state_t)) { - printf("Reading flavor, count failed.\n"); + print_error("Reading flavor, count failed.\n"); goto err; } size += sizeof(x86_exception_state_t); @@ -387,14 +389,14 @@ static bool read_core_segments(struct ps_prochandle* ph) { if (fc.flavor == ARM_THREAD_STATE64) { arm_thread_state64_t thrstate; if (read(fd, (void *)&thrstate, sizeof(arm_thread_state64_t)) != sizeof(arm_thread_state64_t)) { - printf("Reading flavor, count failed.\n"); + print_error("Reading flavor, count failed.\n"); goto err; } size += sizeof(arm_thread_state64_t); // create thread info list, update lwp_id later sa_thread_info* newthr = add_thread_info(ph, (pthread_t) -1, (lwpid_t) num_threads++); if (newthr == NULL) { - printf("create thread_info failed\n"); + print_error("create thread_info failed\n"); goto err; } @@ -443,21 +445,21 @@ static bool read_core_segments(struct ps_prochandle* ph) { } else if (fc.flavor == ARM_NEON_STATE64) { arm_neon_state64_t flstate; if (read(fd, (void *)&flstate, sizeof(arm_neon_state64_t)) != sizeof(arm_neon_state64_t)) { - printf("Reading flavor, count failed.\n"); + print_error("Reading flavor, count failed.\n"); goto err; } size += sizeof(arm_neon_state64_t); } else if (fc.flavor == ARM_EXCEPTION_STATE64) { arm_exception_state64_t excpstate; if (read(fd, (void *)&excpstate, sizeof(arm_exception_state64_t)) != sizeof(arm_exception_state64_t)) { - printf("Reading flavor, count failed.\n"); + print_error("Reading flavor, count failed.\n"); goto err; } size += sizeof(arm_exception_state64_t); } else if (fc.flavor == ARM_DEBUG_STATE64) { arm_debug_state64_t dbgstate; if (read(fd, (void *)&dbgstate, sizeof(arm_debug_state64_t)) != sizeof(arm_debug_state64_t)) { - printf("Reading flavor, count failed.\n"); + print_error("Reading flavor, count failed.\n"); goto err; } size += sizeof(arm_debug_state64_t); @@ -631,6 +633,7 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { lseek(fd, -sizeof(uint32_t), SEEK_CUR); // This is the beginning of the mach-o file in the segment. if (read(fd, (void *)&header, sizeof(mach_header_64)) != sizeof(mach_header_64)) { + print_error("Failed to file header\n"); goto err; } fpos = ltell(fd); @@ -641,6 +644,7 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { // LC_ID_DYLIB is the file itself for a .dylib lseek(fd, fpos, SEEK_SET); if (read(fd, (void *)&lcmd, sizeof(load_command)) != sizeof(load_command)) { + print_error("Failed to read command\n"); return false; // error } fpos += lcmd.cmdsize; // next command position @@ -652,6 +656,7 @@ static bool read_shared_lib_info(struct ps_prochandle* ph) { if (lcmd.cmd == LC_ID_DYLIB) { lseek(fd, -sizeof(load_command), SEEK_CUR); if (read(fd, (void *)&dylibcmd, sizeof(dylib_command)) != sizeof(dylib_command)) { + print_error("Failed to read command\n"); return false; } /**** name stored at dylib_command.dylib.name.offset, is a C string */ @@ -710,13 +715,13 @@ struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) { struct ps_prochandle* ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle)); if (ph == NULL) { - print_debug("can't allocate ps_prochandle\n"); + print_error("can't allocate ps_prochandle\n"); return NULL; } if ((ph->core = (struct core_data*) calloc(1, sizeof(struct core_data))) == NULL) { free(ph); - print_debug("can't allocate ps_prochandle\n"); + print_error("can't allocate ps_prochandle\n"); return NULL; } @@ -738,12 +743,12 @@ struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) { // read core file header if (read_macho64_header(ph->core->core_fd, &core_header) != true || core_header.filetype != MH_CORE) { - print_debug("core file is not a valid Mach-O file\n"); + print_error("core file is not a valid Mach-O file\n"); goto err; } if ((ph->core->exec_fd = open(exec_file, O_RDONLY)) < 0) { - print_error("can't open executable file\n"); + print_error("can't open executable file: %s\n", strerror(errno)); goto err; } @@ -779,7 +784,7 @@ struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) { } if (init_classsharing_workaround(ph) != true) { - print_error("failed to workaround classshareing\n"); + print_error("failed to workaround class sharing\n"); goto err; } diff --git a/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c b/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c index 3c244aab0f3..40757a346fe 100644 --- a/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c +++ b/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c @@ -141,6 +141,7 @@ map_info* add_map_info(struct ps_prochandle* ph, int fd, off_t offset, uintptr_t vaddr, size_t memsz, uint32_t flags) { map_info* map; if ((map = allocate_init_map(fd, offset, vaddr, memsz, flags)) == NULL) { + print_error("failed to allocate map\n"); return NULL; } @@ -158,6 +159,7 @@ static map_info* add_class_share_map_info(struct ps_prochandle* ph, off_t offset map_info* map; if ((map = allocate_init_map(ph->core->classes_jsa_fd, offset, vaddr, memsz, MAP_R_FLAG)) == NULL) { + print_debug("failed to allocate class share map\n"); return NULL; } From 27faf45422082009f23463984b8a6e43c15e9e71 Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Wed, 23 Apr 2025 06:22:30 +0000 Subject: [PATCH 070/901] 8354826: Make ResolverConfigurationImpl.lock field final Reviewed-by: dfuchs, jpai --- .../unix/classes/sun/net/dns/ResolverConfigurationImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java index a466331de93..2f633ad711d 100644 --- a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java +++ b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2025, 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 @@ -41,7 +41,7 @@ public final class ResolverConfigurationImpl extends ResolverConfiguration { // Lock helds whilst loading configuration or checking - private static Object lock = new Object(); + private static final Object lock = new Object(); // Time of last refresh. private static long lastRefresh = -1; From 263983d0fb9ca567b03d2be4c82cf9fe3d0e6f61 Mon Sep 17 00:00:00 2001 From: Fredrik Bredberg Date: Wed, 23 Apr 2025 08:04:57 +0000 Subject: [PATCH 071/901] 8298733: Reconsider monitors_on_stack assert Reviewed-by: pchilanomate, coleenp --- .../share/runtime/continuationFreezeThaw.cpp | 59 +++++++++++++------ src/hotspot/share/runtime/stackWatermark.hpp | 3 +- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 12a75c6c62e..d20cfde09ca 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -565,10 +565,50 @@ void FreezeBase::copy_to_chunk(intptr_t* from, intptr_t* to, int size) { #endif } +static void assert_frames_in_continuation_are_safe(JavaThread* thread) { +#ifdef ASSERT + StackWatermark* watermark = StackWatermarkSet::get(thread, StackWatermarkKind::gc); + if (watermark == nullptr) { + return; + } + ContinuationEntry* ce = thread->last_continuation(); + RegisterMap map(thread, + RegisterMap::UpdateMap::include, + RegisterMap::ProcessFrames::skip, + RegisterMap::WalkContinuation::skip); + map.set_include_argument_oops(false); + for (frame f = thread->last_frame(); Continuation::is_frame_in_continuation(ce, f); f = f.sender(&map)) { + watermark->assert_is_frame_safe(f); + } +#endif // ASSERT +} + +#ifdef ASSERT +static bool monitors_on_stack(JavaThread* thread) { + assert_frames_in_continuation_are_safe(thread); + ContinuationEntry* ce = thread->last_continuation(); + RegisterMap map(thread, + RegisterMap::UpdateMap::include, + RegisterMap::ProcessFrames::skip, + RegisterMap::WalkContinuation::skip); + map.set_include_argument_oops(false); + for (frame f = thread->last_frame(); Continuation::is_frame_in_continuation(ce, f); f = f.sender(&map)) { + if ((f.is_interpreted_frame() && ContinuationHelper::InterpretedFrame::is_owning_locks(f)) || + (f.is_compiled_frame() && ContinuationHelper::CompiledFrame::is_owning_locks(map.thread(), &map, f)) || + (f.is_native_frame() && ContinuationHelper::NativeFrame::is_owning_locks(map.thread(), f))) { + return true; + } + } + return false; +} +#endif // ASSERT + // Called _after_ the last possible safepoint during the freeze operation (chunk allocation) void FreezeBase::unwind_frames() { ContinuationEntry* entry = _cont.entry(); entry->flush_stack_processing(_thread); + assert_frames_in_continuation_are_safe(_thread); + assert(LockingMode != LM_LEGACY || !monitors_on_stack(_thread), "unexpected monitors on stack"); set_anchor_to_entry(_thread, entry); } @@ -1621,23 +1661,6 @@ static void jvmti_mount_end(JavaThread* current, ContinuationWrapper& cont, fram #endif // INCLUDE_JVMTI #ifdef ASSERT -static bool monitors_on_stack(JavaThread* thread) { - ContinuationEntry* ce = thread->last_continuation(); - RegisterMap map(thread, - RegisterMap::UpdateMap::include, - RegisterMap::ProcessFrames::include, - RegisterMap::WalkContinuation::skip); - map.set_include_argument_oops(false); - for (frame f = thread->last_frame(); Continuation::is_frame_in_continuation(ce, f); f = f.sender(&map)) { - if ((f.is_interpreted_frame() && ContinuationHelper::InterpretedFrame::is_owning_locks(f)) || - (f.is_compiled_frame() && ContinuationHelper::CompiledFrame::is_owning_locks(map.thread(), &map, f)) || - (f.is_native_frame() && ContinuationHelper::NativeFrame::is_owning_locks(map.thread(), f))) { - return true; - } - } - return false; -} - // There are no interpreted frames if we're not called from the interpreter and we haven't ancountered an i2c // adapter or called Deoptimization::unpack_frames. As for native frames, upcalls from JNI also go through the // interpreter (see JavaCalls::call_helper), while the UpcallLinker explicitly sets cont_fastpath. @@ -1714,8 +1737,6 @@ static inline freeze_result freeze_internal(JavaThread* current, intptr_t* const assert(entry->is_virtual_thread() == (entry->scope(current) == java_lang_VirtualThread::vthread_scope()), ""); - assert(LockingMode != LM_LEGACY || (monitors_on_stack(current) == ((current->held_monitor_count() - current->jni_monitor_count()) > 0)), - "Held monitor count and locks on stack invariant: " INT64_FORMAT " JNI: " INT64_FORMAT, (int64_t)current->held_monitor_count(), (int64_t)current->jni_monitor_count()); assert(LockingMode == LM_LEGACY || (current->held_monitor_count() == 0 && current->jni_monitor_count() == 0), "Held monitor count should only be used for LM_LEGACY: " INT64_FORMAT " JNI: " INT64_FORMAT, (int64_t)current->held_monitor_count(), (int64_t)current->jni_monitor_count()); diff --git a/src/hotspot/share/runtime/stackWatermark.hpp b/src/hotspot/share/runtime/stackWatermark.hpp index 8d51f694a1d..4f1c65c903c 100644 --- a/src/hotspot/share/runtime/stackWatermark.hpp +++ b/src/hotspot/share/runtime/stackWatermark.hpp @@ -102,7 +102,6 @@ class StackWatermark : public CHeapObj { void yield_processing(); static bool has_barrier(const frame& f); void ensure_safe(const frame& f); - void assert_is_frame_safe(const frame& f) NOT_DEBUG_RETURN; bool is_frame_safe(const frame& f); // API for consumers of the stack watermark barrier. @@ -151,6 +150,8 @@ class StackWatermark : public CHeapObj { void on_safepoint(); void start_processing(); void finish_processing(void* context); + + void assert_is_frame_safe(const frame& f) NOT_DEBUG_RETURN; }; #endif // SHARE_RUNTIME_STACKWATERMARK_HPP From c2e90bcc8026fb2047b42deae6cdad738d6d01b8 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Wed, 23 Apr 2025 08:21:07 +0000 Subject: [PATCH 072/901] 8355363: [BACKOUT] 8354668: Missing REX2 prefix accounting in ZGC barriers leads to incorrect encoding Reviewed-by: chagedorn --- .../cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp | 14 +++++++------- .../cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp | 2 +- src/hotspot/cpu/x86/gc/z/z_x86_64.ad | 4 ++-- src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp index 0891d303563..9cdf0b229c0 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp @@ -391,8 +391,8 @@ void ZBarrierSetAssembler::store_barrier_fast(MacroAssembler* masm, if (rnew_zaddress != noreg) { // noreg means null; no need to color __ movptr(rnew_zpointer, rnew_zaddress); + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shlq(rnew_zpointer, barrier_Relocation::unpatched); - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); __ orq_imm32(rnew_zpointer, barrier_Relocation::unpatched); __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr); } @@ -969,13 +969,13 @@ void ZBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, #define __ ce->masm()-> static void z_uncolor(LIR_Assembler* ce, LIR_Opr ref) { + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shrq(ref->as_register(), barrier_Relocation::unpatched); - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); } static void z_color(LIR_Assembler* ce, LIR_Opr ref) { + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shlq(ref->as_register(), barrier_Relocation::unpatched); - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); __ orq_imm32(ref->as_register(), barrier_Relocation::unpatched); __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr); } @@ -1278,8 +1278,8 @@ void ZBarrierSetAssembler::generate_c2_store_barrier_stub(MacroAssembler* masm, static int patch_barrier_relocation_offset(int format) { switch (format) { - case ZBarrierRelocationFormatLoadGoodAfterShX: - return -1; + case ZBarrierRelocationFormatLoadGoodBeforeShl: + return 3; case ZBarrierRelocationFormatStoreGoodAfterCmp: return -2; @@ -1300,7 +1300,7 @@ static int patch_barrier_relocation_offset(int format) { static uint16_t patch_barrier_relocation_value(int format) { switch (format) { - case ZBarrierRelocationFormatLoadGoodAfterShX: + case ZBarrierRelocationFormatLoadGoodBeforeShl: return (uint16_t)ZPointerLoadShift; case ZBarrierRelocationFormatMarkBadAfterTest: @@ -1327,7 +1327,7 @@ void ZBarrierSetAssembler::patch_barrier_relocation(address addr, int format) { const int offset = patch_barrier_relocation_offset(format); const uint16_t value = patch_barrier_relocation_value(format); uint8_t* const patch_addr = (uint8_t*)addr + offset; - if (format == ZBarrierRelocationFormatLoadGoodAfterShX) { + if (format == ZBarrierRelocationFormatLoadGoodBeforeShl) { *patch_addr = (uint8_t)value; } else { *(uint16_t*)patch_addr = value; diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp index 6976452bd63..8bb653ec5fb 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.hpp @@ -49,7 +49,7 @@ class ZLoadBarrierStubC2; class ZStoreBarrierStubC2; #endif // COMPILER2 -const int ZBarrierRelocationFormatLoadGoodAfterShX = 0; +const int ZBarrierRelocationFormatLoadGoodBeforeShl = 0; const int ZBarrierRelocationFormatLoadBadAfterTest = 1; const int ZBarrierRelocationFormatMarkBadAfterTest = 2; const int ZBarrierRelocationFormatStoreGoodAfterCmp = 3; diff --git a/src/hotspot/cpu/x86/gc/z/z_x86_64.ad b/src/hotspot/cpu/x86/gc/z/z_x86_64.ad index e2484a71e7d..045aa5d5381 100644 --- a/src/hotspot/cpu/x86/gc/z/z_x86_64.ad +++ b/src/hotspot/cpu/x86/gc/z/z_x86_64.ad @@ -35,15 +35,15 @@ source %{ #include "gc/z/zBarrierSetAssembler.hpp" static void z_color(MacroAssembler* masm, const MachNode* node, Register ref) { + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shlq(ref, barrier_Relocation::unpatched); - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); __ orq_imm32(ref, barrier_Relocation::unpatched); __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr); } static void z_uncolor(MacroAssembler* masm, const MachNode* node, Register ref) { + __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); __ shrq(ref, barrier_Relocation::unpatched); - __ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); } static void z_keep_alive_load_barrier(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref) { diff --git a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp b/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp index 7e239a68983..9e6a4789dc2 100644 --- a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp +++ b/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp @@ -221,7 +221,7 @@ bool CodeInstaller::pd_relocate(address pc, jint mark) { return true; #if INCLUDE_ZGC case Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_SHL: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodAfterShX); + _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); return true; case Z_BARRIER_RELOCATION_FORMAT_LOAD_BAD_AFTER_TEST: _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadBadAfterTest); From e76f20301c3dcd65610e982fc98b7a08ebf0c8f1 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Wed, 23 Apr 2025 10:13:26 +0000 Subject: [PATCH 073/901] 8354309: Sort GC includes Reviewed-by: eosterlund, iwalulya, kbarrett --- .../c1/shenandoahBarrierSetC1_aarch64.cpp | 2 +- .../shenandoahBarrierSetAssembler_aarch64.cpp | 6 ++--- .../cpu/aarch64/gc/z/zAddress_aarch64.cpp | 2 +- .../arm/gc/g1/g1BarrierSetAssembler_arm.cpp | 1 - .../arm/gc/shared/barrierSetNMethod_arm.cpp | 2 +- .../ppc/gc/shared/barrierSetNMethod_ppc.cpp | 2 +- .../c1/shenandoahBarrierSetC1_ppc.cpp | 2 +- .../shenandoahBarrierSetAssembler_ppc.cpp | 6 ++--- src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp | 2 +- .../gc/shared/barrierSetNMethod_riscv.cpp | 2 +- .../c1/shenandoahBarrierSetC1_riscv.cpp | 2 +- .../shenandoahBarrierSetAssembler_riscv.cpp | 6 ++--- src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp | 2 +- .../s390/gc/g1/g1BarrierSetAssembler_s390.cpp | 4 +-- .../c1/shenandoahBarrierSetC1_x86.cpp | 2 +- .../shenandoahBarrierSetAssembler_x86.cpp | 4 +-- .../os/windows/gc/z/zSyscall_windows.hpp | 1 - .../gc/epsilon/epsilonMonitoringSupport.cpp | 2 +- src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp | 2 +- src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp | 2 +- src/hotspot/share/gc/g1/g1AllocRegion.cpp | 2 +- src/hotspot/share/gc/g1/g1Allocator.cpp | 2 +- .../gc/g1/g1AnalyticsSequences.inline.hpp | 1 + src/hotspot/share/gc/g1/g1BarrierSet.hpp | 2 +- .../share/gc/g1/g1BlockOffsetTable.inline.hpp | 3 ++- src/hotspot/share/gc/g1/g1CardSet.inline.hpp | 1 + .../gc/g1/g1CardSetContainers.inline.hpp | 1 + .../share/gc/g1/g1CardSetMemory.inline.hpp | 1 + src/hotspot/share/gc/g1/g1CollectedHeap.cpp | 6 ++--- src/hotspot/share/gc/g1/g1CollectedHeap.hpp | 2 +- .../share/gc/g1/g1CollectionSet.inline.hpp | 1 + src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 2 +- src/hotspot/share/gc/g1/g1ConcurrentMark.hpp | 2 +- ...ConcurrentMarkObjArrayProcessor.inline.hpp | 2 +- .../gc/g1/g1ConcurrentRebuildAndScrub.cpp | 3 +-- .../share/gc/g1/g1ConcurrentRefine.cpp | 1 + src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp | 2 +- src/hotspot/share/gc/g1/g1EdenRegions.hpp | 2 +- .../gc/g1/g1EvacFailureRegions.inline.hpp | 3 ++- src/hotspot/share/gc/g1/g1EvacStats.cpp | 2 +- src/hotspot/share/gc/g1/g1EvacStats.hpp | 2 +- src/hotspot/share/gc/g1/g1FullCollector.cpp | 2 +- src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp | 4 +-- .../share/gc/g1/g1HeapRegionManager.cpp | 2 +- src/hotspot/share/gc/g1/g1InitLogger.cpp | 2 +- .../share/gc/g1/g1MonitoringSupport.cpp | 2 +- .../share/gc/g1/g1MonitoringSupport.hpp | 2 +- .../share/gc/g1/g1MonotonicArena.inline.hpp | 1 + .../gc/g1/g1MonotonicArenaFreeMemoryTask.cpp | 2 +- src/hotspot/share/gc/g1/g1NMethodClosure.cpp | 2 +- .../share/gc/g1/g1OopClosures.inline.hpp | 2 +- .../share/gc/g1/g1ParScanThreadState.hpp | 2 +- src/hotspot/share/gc/g1/g1Policy.cpp | 7 +++--- src/hotspot/share/gc/g1/g1Policy.hpp | 2 +- src/hotspot/share/gc/g1/g1RemSet.cpp | 4 +-- src/hotspot/share/gc/g1/g1ServiceThread.cpp | 2 +- src/hotspot/share/gc/g1/g1SurvivorRegions.cpp | 2 +- src/hotspot/share/gc/g1/g1Trace.cpp | 2 +- src/hotspot/share/gc/g1/g1VMOperations.cpp | 2 +- src/hotspot/share/gc/g1/g1YoungCollector.cpp | 6 ++--- .../share/gc/g1/g1YoungGCPreEvacuateTasks.cpp | 2 +- .../share/gc/parallel/parallelInitLogger.cpp | 2 +- .../gc/parallel/psAdaptiveSizePolicy.cpp | 2 +- src/hotspot/share/gc/parallel/psCardTable.cpp | 2 +- .../share/gc/parallel/psCompactionManager.cpp | 2 +- .../share/gc/parallel/psCompactionManager.hpp | 2 +- src/hotspot/share/gc/parallel/psScavenge.cpp | 6 ++--- src/hotspot/share/gc/parallel/psScavenge.hpp | 2 +- .../share/gc/parallel/psVMOperations.cpp | 2 +- .../share/gc/serial/serialArguments.cpp | 4 +-- src/hotspot/share/gc/serial/serialFullGC.cpp | 4 +-- .../gc/serial/tenuredGeneration.inline.hpp | 1 + src/hotspot/share/gc/shared/ageTable.cpp | 2 +- .../gc/shared/barrierSetConfig.inline.hpp | 2 +- .../share/gc/shared/barrierSetNMethod.cpp | 2 +- src/hotspot/share/gc/shared/bufferNode.cpp | 2 +- .../share/gc/shared/c1/barrierSetC1.hpp | 2 +- .../share/gc/shared/c2/barrierSetC2.cpp | 2 +- .../gc/shared/c2/cardTableBarrierSetC2.cpp | 2 +- .../share/gc/shared/c2/modRefBarrierSetC2.cpp | 2 +- src/hotspot/share/gc/shared/cardTable.cpp | 2 +- src/hotspot/share/gc/shared/collectedHeap.cpp | 6 ++--- src/hotspot/share/gc/shared/gcHeapSummary.hpp | 2 +- src/hotspot/share/gc/shared/gcInitLogger.cpp | 2 +- src/hotspot/share/gc/shared/gcLocker.cpp | 4 +-- src/hotspot/share/gc/shared/gcLogPrecious.hpp | 2 +- .../share/gc/shared/gcOverheadChecker.hpp | 4 +-- .../share/gc/shared/gcPolicyCounters.cpp | 2 +- src/hotspot/share/gc/shared/gcTimer.cpp | 2 +- src/hotspot/share/gc/shared/gcTraceTime.cpp | 2 +- .../share/gc/shared/gcVMOperations.cpp | 2 +- .../share/gc/shared/locationPrinter.cpp | 2 +- src/hotspot/share/gc/shared/memAllocator.cpp | 2 +- .../share/gc/shared/parallelCleaning.cpp | 3 +-- .../share/gc/shared/partialArrayState.cpp | 1 + .../shared/partialArrayTaskStepper.inline.hpp | 3 ++- .../shared/referenceProcessorPhaseTimes.cpp | 2 +- src/hotspot/share/gc/shared/satbMarkQueue.cpp | 2 +- .../gc/shared/stringdedup/stringDedup.cpp | 2 +- .../shared/stringdedup/stringDedupTable.cpp | 4 +-- .../shared/stringdedup/stringDedupTable.hpp | 2 +- .../share/gc/shared/taskTerminator.cpp | 2 +- src/hotspot/share/gc/shared/taskqueue.cpp | 2 +- .../shared/threadLocalAllocBuffer.inline.hpp | 2 +- src/hotspot/share/gc/shared/weakProcessor.cpp | 2 +- .../shenandoah/c1/shenandoahBarrierSetC1.cpp | 2 +- .../shenandoah/c2/shenandoahBarrierSetC2.cpp | 6 ++--- .../gc/shenandoah/c2/shenandoahSupport.cpp | 2 +- .../shenandoahAdaptiveHeuristics.cpp | 2 +- .../shenandoahAdaptiveHeuristics.hpp | 2 +- .../shenandoahCompactHeuristics.cpp | 2 +- .../shenandoahGenerationalHeuristics.cpp | 3 +-- .../heuristics/shenandoahGlobalHeuristics.cpp | 3 +-- .../heuristics/shenandoahHeuristics.cpp | 2 +- .../heuristics/shenandoahYoungHeuristics.cpp | 1 - .../mode/shenandoahGenerationalMode.cpp | 2 +- .../shenandoah/mode/shenandoahPassiveMode.cpp | 2 +- .../gc/shenandoah/shenandoahBarrierSet.cpp | 2 +- .../shenandoahBarrierSet.inline.hpp | 2 +- .../shenandoah/shenandoahClosures.inline.hpp | 4 +-- .../gc/shenandoah/shenandoahCodeRoots.hpp | 2 +- .../gc/shenandoah/shenandoahConcurrentGC.cpp | 6 ++--- .../shenandoah/shenandoahConcurrentMark.cpp | 4 +-- .../gc/shenandoah/shenandoahControlThread.cpp | 6 ++--- .../gc/shenandoah/shenandoahControlThread.hpp | 4 +-- .../gc/shenandoah/shenandoahController.cpp | 3 +-- .../gc/shenandoah/shenandoahController.hpp | 2 +- .../gc/shenandoah/shenandoahDegeneratedGC.cpp | 4 +-- .../gc/shenandoah/shenandoahEvacTracker.cpp | 4 +-- .../share/gc/shenandoah/shenandoahFreeSet.cpp | 2 +- .../share/gc/shenandoah/shenandoahFreeSet.hpp | 2 +- .../share/gc/shenandoah/shenandoahFullGC.cpp | 13 +++++----- .../share/gc/shenandoah/shenandoahGC.hpp | 2 +- .../gc/shenandoah/shenandoahGeneration.cpp | 5 ++-- .../gc/shenandoah/shenandoahGeneration.hpp | 2 +- .../shenandoah/shenandoahGenerationSizer.cpp | 2 +- .../shenandoahGenerationalControlThread.cpp | 8 +++--- .../shenandoahGenerationalEvacuationTask.cpp | 2 +- .../shenandoahGenerationalFullGC.cpp | 4 +-- .../shenandoah/shenandoahGenerationalHeap.cpp | 2 +- .../shenandoah/shenandoahGlobalGeneration.cpp | 2 +- .../shenandoah/shenandoahGlobalGeneration.hpp | 2 +- .../share/gc/shenandoah/shenandoahHeap.cpp | 25 ++++++++----------- .../share/gc/shenandoah/shenandoahHeap.hpp | 8 +++--- .../gc/shenandoah/shenandoahHeap.inline.hpp | 14 +++++------ .../gc/shenandoah/shenandoahHeapRegion.cpp | 6 ++--- .../shenandoahHeapRegion.inline.hpp | 3 ++- .../shenandoahHeapRegionCounters.cpp | 2 +- .../shenandoahHeapRegionCounters.hpp | 2 +- .../gc/shenandoah/shenandoahHeapRegionSet.cpp | 2 +- .../gc/shenandoah/shenandoahHeapRegionSet.hpp | 2 +- .../gc/shenandoah/shenandoahInitLogger.cpp | 4 +-- .../share/gc/shenandoah/shenandoahLock.cpp | 3 +-- .../share/gc/shenandoah/shenandoahMark.hpp | 2 +- .../gc/shenandoah/shenandoahMarkBitMap.cpp | 2 +- .../shenandoah/shenandoahMarkingContext.cpp | 1 - .../shenandoahMarkingContext.inline.hpp | 1 + .../gc/shenandoah/shenandoahMemoryPool.cpp | 2 +- .../share/gc/shenandoah/shenandoahMetrics.cpp | 4 +-- .../gc/shenandoah/shenandoahMmuTracker.cpp | 2 +- .../shenandoahMonitoringSupport.cpp | 2 +- .../share/gc/shenandoah/shenandoahOldGC.cpp | 2 +- .../gc/shenandoah/shenandoahOldGeneration.cpp | 2 +- .../gc/shenandoah/shenandoahPhaseTimings.cpp | 4 +-- .../gc/shenandoah/shenandoahPhaseTimings.hpp | 4 +-- .../shenandoahReferenceProcessor.cpp | 4 +-- .../gc/shenandoah/shenandoahRootProcessor.cpp | 2 +- .../shenandoahRootProcessor.inline.hpp | 2 +- .../gc/shenandoah/shenandoahRootVerifier.cpp | 6 ++--- .../share/gc/shenandoah/shenandoahRuntime.cpp | 2 +- .../shenandoahScanRemembered.inline.hpp | 11 ++++---- .../gc/shenandoah/shenandoahSimpleBitMap.hpp | 4 +-- .../shenandoahStringDedup.inline.hpp | 3 ++- .../gc/shenandoah/shenandoahTaskqueue.hpp | 2 +- .../shenandoah/shenandoahThreadLocalData.hpp | 8 +++--- .../share/gc/shenandoah/shenandoahUnload.cpp | 4 +-- .../share/gc/shenandoah/shenandoahUtils.cpp | 2 +- .../share/gc/shenandoah/shenandoahUtils.hpp | 2 +- .../gc/shenandoah/shenandoahVerifier.cpp | 2 +- .../gc/shenandoah/shenandoahWorkGroup.cpp | 3 +-- .../shenandoah/shenandoahYoungGeneration.cpp | 2 +- .../shenandoah/shenandoahYoungGeneration.hpp | 2 +- .../gc/shenandoah/vmStructs_shenandoah.hpp | 2 +- src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp | 2 +- src/hotspot/share/gc/z/zHeapIterator.hpp | 2 +- src/hotspot/share/gc/z/zMarkContext.hpp | 2 +- src/hotspot/share/gc/z/zMarkingSMR.hpp | 2 +- src/hotspot/share/gc/z/zNMT.cpp | 2 +- src/hotspot/share/gc/z/zNMT.hpp | 2 +- src/hotspot/share/gc/z/zNMethod.cpp | 2 +- src/hotspot/share/gc/z/zNMethodTable.cpp | 2 +- src/hotspot/share/gc/z/zObjArrayAllocator.cpp | 2 +- src/hotspot/share/gc/z/zRuntimeWorkers.cpp | 2 +- src/hotspot/share/gc/z/zStat.cpp | 2 +- .../share/gc/z/zUncoloredRoot.inline.hpp | 2 +- src/hotspot/share/gc/z/zVerify.cpp | 2 +- .../gc/z/zVirtualMemoryManager.inline.hpp | 2 +- 197 files changed, 281 insertions(+), 284 deletions(-) diff --git a/src/hotspot/cpu/aarch64/gc/shenandoah/c1/shenandoahBarrierSetC1_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shenandoah/c1/shenandoahBarrierSetC1_aarch64.cpp index e33ef47cf3c..e4db8a9ab1f 100644 --- a/src/hotspot/cpu/aarch64/gc/shenandoah/c1/shenandoahBarrierSetC1_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/shenandoah/c1/shenandoahBarrierSetC1_aarch64.cpp @@ -27,9 +27,9 @@ #include "c1/c1_MacroAssembler.hpp" #include "compiler/compilerDefinitions.inline.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" -#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #define __ masm->masm()-> diff --git a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp index ac22b43faaf..a2b3f44c68b 100644 --- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp @@ -23,6 +23,8 @@ * */ +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" #include "gc/shenandoah/shenandoahForwarding.hpp" @@ -30,10 +32,8 @@ #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahRuntime.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" -#include "interpreter/interpreter.hpp" #include "interpreter/interp_masm.hpp" +#include "interpreter/interpreter.hpp" #include "runtime/javaThread.hpp" #include "runtime/sharedRuntime.hpp" #ifdef COMPILER1 diff --git a/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp index 20e37528c04..7008615ed43 100644 --- a/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/z/zAddress_aarch64.cpp @@ -21,8 +21,8 @@ * questions. */ -#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcLogPrecious.hpp" #include "gc/z/zAddress.hpp" #include "gc/z/zBarrierSetAssembler.hpp" #include "gc/z/zGlobals.hpp" diff --git a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp index 466dcc8fe66..049477cda76 100644 --- a/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/gc/g1/g1BarrierSetAssembler_arm.cpp @@ -26,7 +26,6 @@ #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" -#include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1HeapRegion.hpp" #include "gc/g1/g1ThreadLocalData.hpp" diff --git a/src/hotspot/cpu/arm/gc/shared/barrierSetNMethod_arm.cpp b/src/hotspot/cpu/arm/gc/shared/barrierSetNMethod_arm.cpp index 224a499ff54..c6cc0ce406e 100644 --- a/src/hotspot/cpu/arm/gc/shared/barrierSetNMethod_arm.cpp +++ b/src/hotspot/cpu/arm/gc/shared/barrierSetNMethod_arm.cpp @@ -29,8 +29,8 @@ #include "memory/resourceArea.hpp" #include "runtime/frame.inline.hpp" #include "runtime/javaThread.hpp" -#include "runtime/sharedRuntime.hpp" #include "runtime/registerMap.hpp" +#include "runtime/sharedRuntime.hpp" #include "utilities/align.hpp" #include "utilities/debug.hpp" diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetNMethod_ppc.cpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetNMethod_ppc.cpp index 19084ed27c7..1b44a169e67 100644 --- a/src/hotspot/cpu/ppc/gc/shared/barrierSetNMethod_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetNMethod_ppc.cpp @@ -23,8 +23,8 @@ */ #include "code/codeBlob.hpp" -#include "code/nmethod.hpp" #include "code/nativeInst.hpp" +#include "code/nmethod.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "gc/shared/barrierSetNMethod.hpp" diff --git a/src/hotspot/cpu/ppc/gc/shenandoah/c1/shenandoahBarrierSetC1_ppc.cpp b/src/hotspot/cpu/ppc/gc/shenandoah/c1/shenandoahBarrierSetC1_ppc.cpp index 48422bc6621..5b24259103f 100644 --- a/src/hotspot/cpu/ppc/gc/shenandoah/c1/shenandoahBarrierSetC1_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shenandoah/c1/shenandoahBarrierSetC1_ppc.cpp @@ -26,9 +26,9 @@ #include "asm/macroAssembler.inline.hpp" #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" +#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" -#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #define __ masm->masm()-> diff --git a/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp index 842201e1584..ec5b98bd4c5 100644 --- a/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shenandoah/shenandoahBarrierSetAssembler_ppc.cpp @@ -24,8 +24,10 @@ */ #include "asm/macroAssembler.inline.hpp" -#include "gc/shared/gcArguments.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcArguments.hpp" +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" #include "gc/shenandoah/shenandoahForwarding.hpp" @@ -34,8 +36,6 @@ #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahRuntime.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "interpreter/interpreter.hpp" #include "macroAssembler_ppc.hpp" #include "runtime/javaThread.hpp" diff --git a/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp b/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp index 2e3eed8ec60..f3a7a948f70 100644 --- a/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/z/zAddress_ppc.cpp @@ -21,8 +21,8 @@ * questions. */ -#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcLogPrecious.hpp" #include "gc/z/zAddress.inline.hpp" #include "gc/z/zGlobals.hpp" #include "runtime/globals.hpp" diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp index 39da77181c6..f24e4f789bc 100644 --- a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp @@ -31,8 +31,8 @@ #include "memory/resourceArea.hpp" #include "runtime/frame.inline.hpp" #include "runtime/javaThread.hpp" -#include "runtime/sharedRuntime.hpp" #include "runtime/registerMap.hpp" +#include "runtime/sharedRuntime.hpp" #include "utilities/align.hpp" #include "utilities/debug.hpp" #if INCLUDE_JVMCI diff --git a/src/hotspot/cpu/riscv/gc/shenandoah/c1/shenandoahBarrierSetC1_riscv.cpp b/src/hotspot/cpu/riscv/gc/shenandoah/c1/shenandoahBarrierSetC1_riscv.cpp index 2a96bd32cf8..11c4e5dc81b 100644 --- a/src/hotspot/cpu/riscv/gc/shenandoah/c1/shenandoahBarrierSetC1_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shenandoah/c1/shenandoahBarrierSetC1_riscv.cpp @@ -26,9 +26,9 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" -#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #define __ masm->masm()-> diff --git a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp index 3021351cca8..4c1056e75a5 100644 --- a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp @@ -23,6 +23,8 @@ * */ +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" #include "gc/shenandoah/shenandoahForwarding.hpp" @@ -30,10 +32,8 @@ #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahRuntime.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" -#include "interpreter/interpreter.hpp" #include "interpreter/interp_masm.hpp" +#include "interpreter/interpreter.hpp" #include "runtime/javaThread.hpp" #include "runtime/sharedRuntime.hpp" #ifdef COMPILER1 diff --git a/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp index 1f2f0146f04..5f783e6fb8b 100644 --- a/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/z/zAddress_riscv.cpp @@ -22,8 +22,8 @@ * questions. */ -#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcLogPrecious.hpp" #include "gc/z/zAddress.hpp" #include "gc/z/zBarrierSetAssembler.hpp" #include "gc/z/zGlobals.hpp" diff --git a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp index 2054c3db36c..dea3317270e 100644 --- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp @@ -24,16 +24,16 @@ */ #include "asm/macroAssembler.inline.hpp" -#include "registerSaver_s390.hpp" -#include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" +#include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1HeapRegion.hpp" #include "gc/g1/g1SATBMarkQueueSet.hpp" #include "gc/g1/g1ThreadLocalData.hpp" #include "interpreter/interp_masm.hpp" +#include "registerSaver_s390.hpp" #include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "utilities/macros.hpp" diff --git a/src/hotspot/cpu/x86/gc/shenandoah/c1/shenandoahBarrierSetC1_x86.cpp b/src/hotspot/cpu/x86/gc/shenandoah/c1/shenandoahBarrierSetC1_x86.cpp index 298e5640b27..66fb4cbb8c7 100644 --- a/src/hotspot/cpu/x86/gc/shenandoah/c1/shenandoahBarrierSetC1_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shenandoah/c1/shenandoahBarrierSetC1_x86.cpp @@ -26,9 +26,9 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" -#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #define __ masm->masm()-> diff --git a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp index 45e4c46161f..deb8111adad 100644 --- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp @@ -23,6 +23,8 @@ * */ +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" #include "gc/shenandoah/shenandoahForwarding.hpp" @@ -30,8 +32,6 @@ #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahRuntime.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "interpreter/interpreter.hpp" #include "runtime/javaThread.hpp" #include "runtime/sharedRuntime.hpp" diff --git a/src/hotspot/os/windows/gc/z/zSyscall_windows.hpp b/src/hotspot/os/windows/gc/z/zSyscall_windows.hpp index d6174de7d88..3d20fa5a924 100644 --- a/src/hotspot/os/windows/gc/z/zSyscall_windows.hpp +++ b/src/hotspot/os/windows/gc/z/zSyscall_windows.hpp @@ -27,7 +27,6 @@ #include "utilities/globalDefinitions.hpp" #include -#include class ZSyscall { private: diff --git a/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp b/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp index 540ede9dd83..a2ae6f8a14a 100644 --- a/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp +++ b/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp @@ -22,8 +22,8 @@ * */ -#include "gc/epsilon/epsilonMonitoringSupport.hpp" #include "gc/epsilon/epsilonHeap.hpp" +#include "gc/epsilon/epsilonMonitoringSupport.hpp" #include "gc/shared/generationCounters.hpp" #include "memory/allocation.hpp" #include "memory/metaspaceCounters.hpp" diff --git a/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp b/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp index a0eb218dd6c..c4791311e9b 100644 --- a/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp +++ b/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp @@ -22,8 +22,8 @@ * */ -#include "c1/c1_LIRGenerator.hpp" #include "c1/c1_CodeStubs.hpp" +#include "c1/c1_LIRGenerator.hpp" #include "gc/g1/c1/g1BarrierSetC1.hpp" #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BarrierSetAssembler.hpp" diff --git a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp index 57e481668f8..bca2255479b 100644 --- a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp +++ b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp @@ -29,8 +29,8 @@ #include "gc/g1/g1BarrierSetAssembler.hpp" #include "gc/g1/g1BarrierSetRuntime.hpp" #include "gc/g1/g1CardTable.hpp" -#include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/g1HeapRegion.hpp" +#include "gc/g1/g1ThreadLocalData.hpp" #include "opto/arraycopynode.hpp" #include "opto/block.hpp" #include "opto/compile.hpp" diff --git a/src/hotspot/share/gc/g1/g1AllocRegion.cpp b/src/hotspot/share/gc/g1/g1AllocRegion.cpp index 29907cbc051..7e748cf7e9f 100644 --- a/src/hotspot/share/gc/g1/g1AllocRegion.cpp +++ b/src/hotspot/share/gc/g1/g1AllocRegion.cpp @@ -23,8 +23,8 @@ */ #include "gc/g1/g1AllocRegion.inline.hpp" -#include "gc/g1/g1EvacStats.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1EvacStats.inline.hpp" #include "gc/shared/tlab_globals.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" diff --git a/src/hotspot/share/gc/g1/g1Allocator.cpp b/src/hotspot/share/gc/g1/g1Allocator.cpp index 49a4958f718..c44234fa11c 100644 --- a/src/hotspot/share/gc/g1/g1Allocator.cpp +++ b/src/hotspot/share/gc/g1/g1Allocator.cpp @@ -24,9 +24,9 @@ #include "gc/g1/g1Allocator.inline.hpp" #include "gc/g1/g1AllocRegion.inline.hpp" +#include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1EvacInfo.hpp" #include "gc/g1/g1EvacStats.inline.hpp" -#include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "gc/g1/g1HeapRegionPrinter.hpp" #include "gc/g1/g1HeapRegionSet.inline.hpp" diff --git a/src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp b/src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp index cd59cac80b4..9fae49320bc 100644 --- a/src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp +++ b/src/hotspot/share/gc/g1/g1AnalyticsSequences.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_G1_G1ANALYTICSSEQUENCES_INLINE_HPP #include "gc/g1/g1AnalyticsSequences.hpp" + #include "gc/g1/g1Predictions.hpp" bool G1PhaseDependentSeq::enough_samples_to_use_mixed_seq() const { diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.hpp b/src/hotspot/share/gc/g1/g1BarrierSet.hpp index 3212aec2780..8c2605b9746 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp +++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp @@ -27,9 +27,9 @@ #include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1SATBMarkQueueSet.hpp" +#include "gc/shared/bufferNode.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" -#include "gc/shared/bufferNode.hpp" class G1CardTable; diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp index 7e6b0e56d93..e35ae08dfad 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp @@ -26,11 +26,12 @@ #define SHARE_GC_G1_G1BLOCKOFFSETTABLE_INLINE_HPP #include "gc/g1/g1BlockOffsetTable.hpp" + #include "gc/g1/g1HeapRegion.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/memset_with_concurrent_readers.hpp" -#include "runtime/atomic.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.hpp" inline HeapWord* G1BlockOffsetTable::block_start_reaching_into_card(const void* addr) const { assert(_reserved.contains(addr), "invalid address"); diff --git a/src/hotspot/share/gc/g1/g1CardSet.inline.hpp b/src/hotspot/share/gc/g1/g1CardSet.inline.hpp index 7d753f00bfb..4909e922c6b 100644 --- a/src/hotspot/share/gc/g1/g1CardSet.inline.hpp +++ b/src/hotspot/share/gc/g1/g1CardSet.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_G1_G1CARDSET_INLINE_HPP #include "gc/g1/g1CardSet.hpp" + #include "gc/g1/g1CardSetContainers.inline.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/gc/g1/g1CardSetContainers.inline.hpp b/src/hotspot/share/gc/g1/g1CardSetContainers.inline.hpp index 61707dcf012..0efc44dea12 100644 --- a/src/hotspot/share/gc/g1/g1CardSetContainers.inline.hpp +++ b/src/hotspot/share/gc/g1/g1CardSetContainers.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_G1_G1CARDSETCONTAINERS_INLINE_HPP #include "gc/g1/g1CardSetContainers.hpp" + #include "gc/g1/g1GCPhaseTimes.hpp" #include "utilities/bitMap.inline.hpp" #include "utilities/checkedCast.hpp" diff --git a/src/hotspot/share/gc/g1/g1CardSetMemory.inline.hpp b/src/hotspot/share/gc/g1/g1CardSetMemory.inline.hpp index 8c0fab3fd11..7bb618e79b4 100644 --- a/src/hotspot/share/gc/g1/g1CardSetMemory.inline.hpp +++ b/src/hotspot/share/gc/g1/g1CardSetMemory.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_G1_G1CARDSETMEMORY_INLINE_HPP #include "gc/g1/g1CardSetMemory.hpp" + #include "gc/g1/g1CardSetContainers.inline.hpp" #include "gc/g1/g1MonotonicArena.inline.hpp" #include "utilities/globalCounter.inline.hpp" diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 31f0cc12aa5..8b36bf124f2 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -35,16 +35,16 @@ #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectionSetCandidates.hpp" #include "gc/g1/g1CollectorState.hpp" +#include "gc/g1/g1ConcurrentMarkThread.inline.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1ConcurrentRefineThread.hpp" -#include "gc/g1/g1ConcurrentMarkThread.inline.hpp" #include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1EvacStats.inline.hpp" #include "gc/g1/g1FullCollector.hpp" #include "gc/g1/g1GCCounters.hpp" #include "gc/g1/g1GCParPhaseTimesTracker.hpp" -#include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1GCPauseType.hpp" +#include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "gc/g1/g1HeapRegionPrinter.hpp" #include "gc/g1/g1HeapRegionRemSet.inline.hpp" @@ -91,8 +91,8 @@ #include "gc/shared/taskqueue.inline.hpp" #include "gc/shared/taskTerminator.hpp" #include "gc/shared/tlab_globals.hpp" -#include "gc/shared/workerPolicy.hpp" #include "gc/shared/weakProcessor.inline.hpp" +#include "gc/shared/workerPolicy.hpp" #include "logging/log.hpp" #include "memory/allocation.hpp" #include "memory/heapInspection.hpp" diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp index 8d449ceedc6..0f583e8dcbf 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -27,8 +27,8 @@ #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1BiasedArray.hpp" -#include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1CardSet.hpp" +#include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.hpp" diff --git a/src/hotspot/share/gc/g1/g1CollectionSet.inline.hpp b/src/hotspot/share/gc/g1/g1CollectionSet.inline.hpp index f295eff3edd..717f6860eb6 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSet.inline.hpp +++ b/src/hotspot/share/gc/g1/g1CollectionSet.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_G1_G1COLLECTIONSET_INLINE_HPP #include "gc/g1/g1CollectionSet.hpp" + #include "gc/g1/g1HeapRegionRemSet.hpp" template diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index 0b8e66f9043..ef62587d868 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -52,8 +52,8 @@ #include "gc/shared/referencePolicy.hpp" #include "gc/shared/strongRootsScope.hpp" #include "gc/shared/suspendibleThreadSet.hpp" -#include "gc/shared/taskTerminator.hpp" #include "gc/shared/taskqueue.inline.hpp" +#include "gc/shared/taskTerminator.hpp" #include "gc/shared/weakProcessor.inline.hpp" #include "gc/shared/workerPolicy.hpp" #include "jvm.h" diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp index d54f9bc96f1..2fb9732b88e 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp @@ -31,8 +31,8 @@ #include "gc/g1/g1HeapVerifier.hpp" #include "gc/g1/g1RegionMarkStatsCache.hpp" #include "gc/shared/gcCause.hpp" -#include "gc/shared/taskTerminator.hpp" #include "gc/shared/taskqueue.hpp" +#include "gc/shared/taskTerminator.hpp" #include "gc/shared/verifyOption.hpp" #include "gc/shared/workerThread.hpp" #include "gc/shared/workerUtils.hpp" diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.inline.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.inline.hpp index d51c5c74082..bc2fd565aab 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.inline.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkObjArrayProcessor.inline.hpp @@ -27,9 +27,9 @@ #include "gc/g1/g1ConcurrentMarkObjArrayProcessor.hpp" +#include "gc/shared/gc_globals.hpp" #include "oops/oop.inline.hpp" #include "oops/oopsHierarchy.hpp" -#include "gc/shared/gc_globals.hpp" inline bool G1CMObjArrayProcessor::should_be_sliced(oop obj) { return obj->is_objArray() && ((objArrayOop)obj)->size() >= 2 * ObjArrayMarkingStride; diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRebuildAndScrub.cpp b/src/hotspot/share/gc/g1/g1ConcurrentRebuildAndScrub.cpp index 993df8b47ce..0633e18411d 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRebuildAndScrub.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRebuildAndScrub.cpp @@ -23,10 +23,9 @@ */ -#include "gc/g1/g1ConcurrentRebuildAndScrub.hpp" - #include "gc/g1/g1ConcurrentMark.inline.hpp" #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp" +#include "gc/g1/g1ConcurrentRebuildAndScrub.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "gc/g1/g1HeapRegionManager.inline.hpp" #include "gc/shared/gc_globals.hpp" diff --git a/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp b/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp index ce4738d784e..dc88f09f980 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp @@ -38,6 +38,7 @@ #include "runtime/mutexLocker.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" + #include G1ConcurrentRefineThread* G1ConcurrentRefineThreadControl::create_refinement_thread(uint worker_id, bool initializing) { diff --git a/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp index ce2f88c9b48..6beb536df87 100644 --- a/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp +++ b/src/hotspot/share/gc/g1/g1DirtyCardQueue.hpp @@ -25,9 +25,9 @@ #ifndef SHARE_GC_G1_G1DIRTYCARDQUEUE_HPP #define SHARE_GC_G1_G1DIRTYCARDQUEUE_HPP -#include "gc/g1/g1FreeIdSet.hpp" #include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1ConcurrentRefineStats.hpp" +#include "gc/g1/g1FreeIdSet.hpp" #include "gc/shared/bufferNode.hpp" #include "gc/shared/bufferNodeList.hpp" #include "gc/shared/ptrQueue.hpp" diff --git a/src/hotspot/share/gc/g1/g1EdenRegions.hpp b/src/hotspot/share/gc/g1/g1EdenRegions.hpp index 81d02381c9b..a6e005ff2dc 100644 --- a/src/hotspot/share/gc/g1/g1EdenRegions.hpp +++ b/src/hotspot/share/gc/g1/g1EdenRegions.hpp @@ -25,8 +25,8 @@ #ifndef SHARE_GC_G1_G1EDENREGIONS_HPP #define SHARE_GC_G1_G1EDENREGIONS_HPP -#include "gc/g1/g1RegionsOnNodes.hpp" #include "gc/g1/g1HeapRegion.hpp" +#include "gc/g1/g1RegionsOnNodes.hpp" #include "runtime/globals.hpp" #include "utilities/debug.hpp" diff --git a/src/hotspot/share/gc/g1/g1EvacFailureRegions.inline.hpp b/src/hotspot/share/gc/g1/g1EvacFailureRegions.inline.hpp index 0d4f5091d9e..6d5084a1447 100644 --- a/src/hotspot/share/gc/g1/g1EvacFailureRegions.inline.hpp +++ b/src/hotspot/share/gc/g1/g1EvacFailureRegions.inline.hpp @@ -25,8 +25,9 @@ #ifndef SHARE_GC_G1_G1EVACFAILUREREGIONS_INLINE_HPP #define SHARE_GC_G1_G1EVACFAILUREREGIONS_INLINE_HPP -#include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1EvacFailureRegions.hpp" + +#include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "runtime/atomic.hpp" diff --git a/src/hotspot/share/gc/g1/g1EvacStats.cpp b/src/hotspot/share/gc/g1/g1EvacStats.cpp index b0e5f7b6864..049175a4ecc 100644 --- a/src/hotspot/share/gc/g1/g1EvacStats.cpp +++ b/src/hotspot/share/gc/g1/g1EvacStats.cpp @@ -23,8 +23,8 @@ */ #include "gc/g1/g1EvacStats.hpp" -#include "gc/shared/gcId.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcId.hpp" #include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "runtime/globals.hpp" diff --git a/src/hotspot/share/gc/g1/g1EvacStats.hpp b/src/hotspot/share/gc/g1/g1EvacStats.hpp index 8b7360f55e3..4227cbab936 100644 --- a/src/hotspot/share/gc/g1/g1EvacStats.hpp +++ b/src/hotspot/share/gc/g1/g1EvacStats.hpp @@ -25,8 +25,8 @@ #ifndef SHARE_GC_G1_G1EVACSTATS_HPP #define SHARE_GC_G1_G1EVACSTATS_HPP -#include "gc/shared/plab.hpp" #include "gc/shared/gcUtil.hpp" +#include "gc/shared/plab.hpp" // Records various memory allocation statistics gathered during evacuation. All sizes // are in HeapWords. diff --git a/src/hotspot/share/gc/g1/g1FullCollector.cpp b/src/hotspot/share/gc/g1/g1FullCollector.cpp index e9d6d23149f..a1e1d152fd8 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.cpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp @@ -35,9 +35,9 @@ #include "gc/g1/g1OopClosures.hpp" #include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RegionMarkStatsCache.inline.hpp" +#include "gc/shared/classUnloadingContext.hpp" #include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/preservedMarks.inline.hpp" -#include "gc/shared/classUnloadingContext.hpp" #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/verifyOption.hpp" #include "gc/shared/weakProcessor.inline.hpp" diff --git a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp index ebe77b2551d..5b0d5ca8eb9 100644 --- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp +++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp @@ -31,11 +31,11 @@ #include "gc/shared/oopStorageSet.hpp" #include "gc/shared/tlab_globals.hpp" #include "gc/shared/workerDataArray.inline.hpp" -#include "memory/resourceArea.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" -#include "runtime/timer.hpp" +#include "memory/resourceArea.hpp" #include "runtime/os.hpp" +#include "runtime/timer.hpp" #include "utilities/enumIterator.hpp" #include "utilities/macros.hpp" diff --git a/src/hotspot/share/gc/g1/g1HeapRegionManager.cpp b/src/hotspot/share/gc/g1/g1HeapRegionManager.cpp index 016b2046265..0098839c1a4 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegionManager.cpp +++ b/src/hotspot/share/gc/g1/g1HeapRegionManager.cpp @@ -24,8 +24,8 @@ #include "gc/g1/g1Arguments.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1CommittedRegionMap.inline.hpp" +#include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1HeapRegion.hpp" #include "gc/g1/g1HeapRegionManager.inline.hpp" #include "gc/g1/g1HeapRegionPrinter.hpp" diff --git a/src/hotspot/share/gc/g1/g1InitLogger.cpp b/src/hotspot/share/gc/g1/g1InitLogger.cpp index 1e09eed9043..1838b55e4d3 100644 --- a/src/hotspot/share/gc/g1/g1InitLogger.cpp +++ b/src/hotspot/share/gc/g1/g1InitLogger.cpp @@ -23,8 +23,8 @@ */ #include "gc/g1/g1InitLogger.hpp" -#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcLogPrecious.hpp" #include "runtime/globals.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp index 03bd1840206..6d1ffdb7c00 100644 --- a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp +++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp @@ -23,9 +23,9 @@ */ #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1MemoryPool.hpp" #include "gc/g1/g1MonitoringSupport.hpp" #include "gc/g1/g1Policy.hpp" -#include "gc/g1/g1MemoryPool.hpp" #include "gc/shared/hSpaceCounters.hpp" #include "memory/metaspaceCounters.hpp" #include "runtime/mutexLocker.hpp" diff --git a/src/hotspot/share/gc/g1/g1MonitoringSupport.hpp b/src/hotspot/share/gc/g1/g1MonitoringSupport.hpp index f22581ad9b1..62c502d497c 100644 --- a/src/hotspot/share/gc/g1/g1MonitoringSupport.hpp +++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.hpp @@ -27,9 +27,9 @@ #include "gc/shared/collectorCounters.hpp" #include "gc/shared/generationCounters.hpp" +#include "runtime/mutex.hpp" #include "services/memoryManager.hpp" #include "services/memoryService.hpp" -#include "runtime/mutex.hpp" class CollectorCounters; class G1CollectedHeap; diff --git a/src/hotspot/share/gc/g1/g1MonotonicArena.inline.hpp b/src/hotspot/share/gc/g1/g1MonotonicArena.inline.hpp index f01248424a0..4ded4bcccae 100644 --- a/src/hotspot/share/gc/g1/g1MonotonicArena.inline.hpp +++ b/src/hotspot/share/gc/g1/g1MonotonicArena.inline.hpp @@ -27,6 +27,7 @@ #define SHARE_GC_G1_G1MONOTONICARENA_INLINE_HPP #include "gc/g1/g1MonotonicArena.hpp" + #include "runtime/atomic.hpp" #include "utilities/globalCounter.inline.hpp" diff --git a/src/hotspot/share/gc/g1/g1MonotonicArenaFreeMemoryTask.cpp b/src/hotspot/share/gc/g1/g1MonotonicArenaFreeMemoryTask.cpp index cc857a53969..40c199dee49 100644 --- a/src/hotspot/share/gc/g1/g1MonotonicArenaFreeMemoryTask.cpp +++ b/src/hotspot/share/gc/g1/g1MonotonicArenaFreeMemoryTask.cpp @@ -28,8 +28,8 @@ #include "gc/g1/g1HeapRegionRemSet.hpp" #include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp" #include "gc/g1/g1MonotonicArenaFreePool.hpp" -#include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/suspendibleThreadSet.hpp" #include "runtime/os.hpp" diff --git a/src/hotspot/share/gc/g1/g1NMethodClosure.cpp b/src/hotspot/share/gc/g1/g1NMethodClosure.cpp index 8dc817f1452..d74aa5eae1d 100644 --- a/src/hotspot/share/gc/g1/g1NMethodClosure.cpp +++ b/src/hotspot/share/gc/g1/g1NMethodClosure.cpp @@ -23,11 +23,11 @@ */ #include "code/nmethod.hpp" -#include "gc/g1/g1NMethodClosure.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1ConcurrentMark.inline.hpp" #include "gc/g1/g1HeapRegion.hpp" #include "gc/g1/g1HeapRegionRemSet.inline.hpp" +#include "gc/g1/g1NMethodClosure.hpp" #include "gc/shared/barrierSetNMethod.hpp" #include "oops/access.inline.hpp" #include "oops/compressedOops.inline.hpp" diff --git a/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp b/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp index 5ab1f58bce1..8d84f144f02 100644 --- a/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp +++ b/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp @@ -38,8 +38,8 @@ #include "memory/iterator.inline.hpp" #include "oops/access.inline.hpp" #include "oops/compressedOops.inline.hpp" -#include "oops/oopsHierarchy.hpp" #include "oops/oop.inline.hpp" +#include "oops/oopsHierarchy.hpp" #include "runtime/prefetch.inline.hpp" #include "utilities/align.hpp" diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp index 94ca0878df8..4d569622238 100644 --- a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp +++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp @@ -26,8 +26,8 @@ #define SHARE_GC_G1_G1PARSCANTHREADSTATE_HPP #include "gc/g1/g1CollectedHeap.hpp" -#include "gc/g1/g1RedirtyCardsQueue.hpp" #include "gc/g1/g1OopClosures.hpp" +#include "gc/g1/g1RedirtyCardsQueue.hpp" #include "gc/g1/g1YoungGCAllocationFailureInjector.hpp" #include "gc/shared/ageTable.hpp" #include "gc/shared/copyFailedInfo.hpp" diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp index deb67656a41..6488bf44e41 100644 --- a/src/hotspot/share/gc/g1/g1Policy.cpp +++ b/src/hotspot/share/gc/g1/g1Policy.cpp @@ -28,20 +28,21 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectionSetCandidates.inline.hpp" +#include "gc/g1/g1CollectionSetChooser.hpp" #include "gc/g1/g1ConcurrentMark.hpp" #include "gc/g1/g1ConcurrentMarkThread.inline.hpp" #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1ConcurrentRefineStats.hpp" -#include "gc/g1/g1CollectionSetChooser.hpp" +#include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HeapRegion.inline.hpp" #include "gc/g1/g1HeapRegionRemSet.inline.hpp" #include "gc/g1/g1IHOPControl.hpp" -#include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1Policy.hpp" #include "gc/g1/g1SurvivorRegions.hpp" #include "gc/g1/g1YoungGenSizer.hpp" #include "gc/shared/concurrentGCBreakpoints.hpp" #include "gc/shared/gcPolicyCounters.hpp" +#include "gc/shared/gcTraceTime.inline.hpp" #include "logging/log.hpp" #include "runtime/java.hpp" #include "runtime/mutexLocker.hpp" @@ -49,8 +50,6 @@ #include "utilities/growableArray.hpp" #include "utilities/pair.hpp" -#include "gc/shared/gcTraceTime.inline.hpp" - G1Policy::G1Policy(STWGCTimer* gc_timer) : _predictor((100 - G1ConfidencePercent) / 100.0), _analytics(new G1Analytics(&_predictor)), diff --git a/src/hotspot/share/gc/g1/g1Policy.hpp b/src/hotspot/share/gc/g1/g1Policy.hpp index fb24b5ab72b..37d66ee6535 100644 --- a/src/hotspot/share/gc/g1/g1Policy.hpp +++ b/src/hotspot/share/gc/g1/g1Policy.hpp @@ -31,8 +31,8 @@ #include "gc/g1/g1HeapRegionAttr.hpp" #include "gc/g1/g1MMUTracker.hpp" #include "gc/g1/g1OldGenAllocationTracker.hpp" -#include "gc/g1/g1RemSetTrackingPolicy.hpp" #include "gc/g1/g1Predictions.hpp" +#include "gc/g1/g1RemSetTrackingPolicy.hpp" #include "gc/g1/g1YoungGenSizer.hpp" #include "gc/shared/gcCause.hpp" #include "runtime/atomic.hpp" diff --git a/src/hotspot/share/gc/g1/g1RemSet.cpp b/src/hotspot/share/gc/g1/g1RemSet.cpp index a25fce2d006..c4f84b02d01 100644 --- a/src/hotspot/share/gc/g1/g1RemSet.cpp +++ b/src/hotspot/share/gc/g1/g1RemSet.cpp @@ -40,12 +40,12 @@ #include "gc/g1/g1HeapRegionRemSet.inline.hpp" #include "gc/g1/g1OopClosures.inline.hpp" #include "gc/g1/g1Policy.hpp" -#include "gc/g1/g1RootClosures.hpp" #include "gc/g1/g1RemSet.hpp" +#include "gc/g1/g1RootClosures.hpp" #include "gc/shared/bufferNode.hpp" #include "gc/shared/bufferNodeList.hpp" -#include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcTraceTime.inline.hpp" #include "jfr/jfrEvents.hpp" #include "memory/iterator.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/share/gc/g1/g1ServiceThread.cpp b/src/hotspot/share/gc/g1/g1ServiceThread.cpp index 5f664cfba3a..22675ec2a64 100644 --- a/src/hotspot/share/gc/g1/g1ServiceThread.cpp +++ b/src/hotspot/share/gc/g1/g1ServiceThread.cpp @@ -26,8 +26,8 @@ #include "logging/log.hpp" #include "runtime/cpuTimeCounters.hpp" #include "runtime/mutexLocker.hpp" -#include "runtime/timer.hpp" #include "runtime/os.hpp" +#include "runtime/timer.hpp" G1SentinelTask::G1SentinelTask() : G1ServiceTask("Sentinel Task") { set_time(max_jlong); diff --git a/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp b/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp index dd3323f4079..edd4f35d5ed 100644 --- a/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp +++ b/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp @@ -24,8 +24,8 @@ #include "gc/g1/g1HeapRegion.hpp" #include "gc/g1/g1SurvivorRegions.hpp" -#include "utilities/growableArray.hpp" #include "utilities/debug.hpp" +#include "utilities/growableArray.hpp" G1SurvivorRegions::G1SurvivorRegions() : _regions(new (mtGC) GrowableArray(8, mtGC)), diff --git a/src/hotspot/share/gc/g1/g1Trace.cpp b/src/hotspot/share/gc/g1/g1Trace.cpp index 3cc8a8a28e1..6c9a87e4d98 100644 --- a/src/hotspot/share/gc/g1/g1Trace.cpp +++ b/src/hotspot/share/gc/g1/g1Trace.cpp @@ -23,9 +23,9 @@ */ #include "gc/g1/g1EvacInfo.hpp" +#include "gc/g1/g1GCPauseType.hpp" #include "gc/g1/g1HeapRegionTraceType.hpp" #include "gc/g1/g1Trace.hpp" -#include "gc/g1/g1GCPauseType.hpp" #include "gc/shared/gcHeapSummary.hpp" #include "jfr/jfrEvents.hpp" #if INCLUDE_JFR diff --git a/src/hotspot/share/gc/g1/g1VMOperations.cpp b/src/hotspot/share/gc/g1/g1VMOperations.cpp index 9552bd6d418..260817f7a57 100644 --- a/src/hotspot/share/gc/g1/g1VMOperations.cpp +++ b/src/hotspot/share/gc/g1/g1VMOperations.cpp @@ -25,8 +25,8 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1ConcurrentMarkThread.inline.hpp" #include "gc/g1/g1Policy.hpp" -#include "gc/g1/g1VMOperations.hpp" #include "gc/g1/g1Trace.hpp" +#include "gc/g1/g1VMOperations.hpp" #include "gc/shared/concurrentGCBreakpoints.hpp" #include "gc/shared/gcCause.hpp" #include "gc/shared/gcId.hpp" diff --git a/src/hotspot/share/gc/g1/g1YoungCollector.cpp b/src/hotspot/share/gc/g1/g1YoungCollector.cpp index 44803564de1..69586b4ebf2 100644 --- a/src/hotspot/share/gc/g1/g1YoungCollector.cpp +++ b/src/hotspot/share/gc/g1/g1YoungCollector.cpp @@ -32,9 +32,9 @@ #include "gc/g1/g1CollectionSetCandidates.inline.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.hpp" -#include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1EvacFailureRegions.inline.hpp" #include "gc/g1/g1EvacInfo.hpp" +#include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HeapRegionPrinter.hpp" #include "gc/g1/g1MonitoringSupport.hpp" #include "gc/g1/g1ParScanThreadState.inline.hpp" @@ -49,9 +49,9 @@ #include "gc/g1/g1YoungGCPostEvacuateTasks.hpp" #include "gc/g1/g1YoungGCPreEvacuateTasks.hpp" #include "gc/shared/concurrentGCBreakpoints.hpp" -#include "gc/shared/gcTraceTime.inline.hpp" -#include "gc/shared/gcTimer.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcTimer.hpp" +#include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/weakProcessor.inline.hpp" #include "gc/shared/workerPolicy.hpp" diff --git a/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp b/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp index 63e77979812..839b70d93af 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGCPreEvacuateTasks.cpp @@ -25,9 +25,9 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1ConcurrentRefineStats.hpp" #include "gc/g1/g1DirtyCardQueue.hpp" -#include "gc/g1/g1YoungGCPreEvacuateTasks.hpp" #include "gc/g1/g1RegionPinCache.inline.hpp" #include "gc/g1/g1ThreadLocalData.hpp" +#include "gc/g1/g1YoungGCPreEvacuateTasks.hpp" #include "gc/shared/barrierSet.inline.hpp" #include "gc/shared/threadLocalAllocBuffer.inline.hpp" #include "memory/allocation.inline.hpp" diff --git a/src/hotspot/share/gc/parallel/parallelInitLogger.cpp b/src/hotspot/share/gc/parallel/parallelInitLogger.cpp index b28f0385c51..1d9c9f840ba 100644 --- a/src/hotspot/share/gc/parallel/parallelInitLogger.cpp +++ b/src/hotspot/share/gc/parallel/parallelInitLogger.cpp @@ -23,8 +23,8 @@ */ #include "gc/parallel/parallelInitLogger.hpp" -#include "gc/shared/genArguments.hpp" #include "gc/shared/gcLogPrecious.hpp" +#include "gc/shared/genArguments.hpp" void ParallelInitLogger::print_heap() { log_info_p(gc, init)("Alignments:" diff --git a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp index 3bb0c0bf119..b4f860e053f 100644 --- a/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp +++ b/src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp @@ -27,8 +27,8 @@ #include "gc/parallel/psGCAdaptivePolicyCounters.hpp" #include "gc/parallel/psScavenge.hpp" #include "gc/shared/gcCause.hpp" -#include "gc/shared/gcUtil.hpp" #include "gc/shared/gcPolicyCounters.hpp" +#include "gc/shared/gcUtil.hpp" #include "logging/log.hpp" #include "runtime/timer.hpp" #include "utilities/align.hpp" diff --git a/src/hotspot/share/gc/parallel/psCardTable.cpp b/src/hotspot/share/gc/parallel/psCardTable.cpp index f8841b9a164..22a38d816f6 100644 --- a/src/hotspot/share/gc/parallel/psCardTable.cpp +++ b/src/hotspot/share/gc/parallel/psCardTable.cpp @@ -32,8 +32,8 @@ #include "oops/access.inline.hpp" #include "oops/oop.inline.hpp" #include "runtime/prefetch.inline.hpp" -#include "utilities/spinYield.hpp" #include "utilities/align.hpp" +#include "utilities/spinYield.hpp" // Checks an individual oop for missing precise marks. Mark // may be either dirty or newgen. diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.cpp b/src/hotspot/share/gc/parallel/psCompactionManager.cpp index f00e18c3297..ba936277821 100644 --- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp +++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp @@ -23,8 +23,8 @@ */ #include "gc/parallel/objectStartArray.hpp" -#include "gc/parallel/parMarkBitMap.inline.hpp" #include "gc/parallel/parallelScavengeHeap.hpp" +#include "gc/parallel/parMarkBitMap.inline.hpp" #include "gc/parallel/psCompactionManager.inline.hpp" #include "gc/parallel/psOldGen.hpp" #include "gc/parallel/psParallelCompact.inline.hpp" diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.hpp b/src/hotspot/share/gc/parallel/psCompactionManager.hpp index 739d2cb1cc7..b013238a9f8 100644 --- a/src/hotspot/share/gc/parallel/psCompactionManager.hpp +++ b/src/hotspot/share/gc/parallel/psCompactionManager.hpp @@ -28,8 +28,8 @@ #include "classfile/classLoaderData.hpp" #include "gc/parallel/psParallelCompact.hpp" #include "gc/shared/partialArraySplitter.hpp" -#include "gc/shared/partialArrayTaskStats.hpp" #include "gc/shared/partialArrayState.hpp" +#include "gc/shared/partialArrayTaskStats.hpp" #include "gc/shared/preservedMarks.hpp" #include "gc/shared/stringdedup/stringDedup.hpp" #include "gc/shared/taskqueue.hpp" diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp index be31da5b05d..661bc3da3e1 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.cpp +++ b/src/hotspot/share/gc/parallel/psScavenge.cpp @@ -44,8 +44,8 @@ #include "gc/shared/gcVMOperations.hpp" #include "gc/shared/isGCActiveMark.hpp" #include "gc/shared/oopStorage.inline.hpp" -#include "gc/shared/oopStorageSetParState.inline.hpp" #include "gc/shared/oopStorageParState.inline.hpp" +#include "gc/shared/oopStorageSetParState.inline.hpp" #include "gc/shared/referencePolicy.hpp" #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/referenceProcessorPhaseTimes.hpp" @@ -57,18 +57,18 @@ #include "gc/shared/workerPolicy.hpp" #include "gc/shared/workerThread.hpp" #include "gc/shared/workerUtils.hpp" +#include "logging/log.hpp" #include "memory/iterator.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" -#include "logging/log.hpp" #include "oops/access.inline.hpp" #include "oops/compressedOops.inline.hpp" #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/threadCritical.hpp" #include "runtime/threads.hpp" -#include "runtime/vmThread.hpp" #include "runtime/vmOperations.hpp" +#include "runtime/vmThread.hpp" #include "services/memoryService.hpp" #include "utilities/stack.inline.hpp" diff --git a/src/hotspot/share/gc/parallel/psScavenge.hpp b/src/hotspot/share/gc/parallel/psScavenge.hpp index 55abdfd3cf3..8da555a8bb4 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.hpp +++ b/src/hotspot/share/gc/parallel/psScavenge.hpp @@ -28,8 +28,8 @@ #include "gc/parallel/psCardTable.hpp" #include "gc/parallel/psVirtualspace.hpp" #include "gc/shared/collectorCounters.hpp" -#include "gc/shared/referenceProcessor.hpp" #include "gc/shared/gcTrace.hpp" +#include "gc/shared/referenceProcessor.hpp" #include "memory/allStatic.hpp" #include "oops/oop.hpp" #include "utilities/stack.hpp" diff --git a/src/hotspot/share/gc/parallel/psVMOperations.cpp b/src/hotspot/share/gc/parallel/psVMOperations.cpp index 4873853a3dd..dc96d9506e2 100644 --- a/src/hotspot/share/gc/parallel/psVMOperations.cpp +++ b/src/hotspot/share/gc/parallel/psVMOperations.cpp @@ -22,8 +22,8 @@ * */ -#include "gc/parallel/psParallelCompact.inline.hpp" #include "gc/parallel/parallelScavengeHeap.inline.hpp" +#include "gc/parallel/psParallelCompact.inline.hpp" #include "gc/parallel/psScavenge.hpp" #include "gc/parallel/psVMOperations.hpp" #include "gc/shared/gcLocker.hpp" diff --git a/src/hotspot/share/gc/serial/serialArguments.cpp b/src/hotspot/share/gc/serial/serialArguments.cpp index 9b55e0cd9f6..aed1c2353b4 100644 --- a/src/hotspot/share/gc/serial/serialArguments.cpp +++ b/src/hotspot/share/gc/serial/serialArguments.cpp @@ -22,10 +22,10 @@ * */ -#include "gc/shared/fullGCForwarding.hpp" -#include "gc/shared/gcArguments.hpp" #include "gc/serial/serialArguments.hpp" #include "gc/serial/serialHeap.hpp" +#include "gc/shared/fullGCForwarding.hpp" +#include "gc/shared/gcArguments.hpp" void SerialArguments::initialize() { GCArguments::initialize(); diff --git a/src/hotspot/share/gc/serial/serialFullGC.cpp b/src/hotspot/share/gc/serial/serialFullGC.cpp index 9d0dc1932fc..15468704547 100644 --- a/src/hotspot/share/gc/serial/serialFullGC.cpp +++ b/src/hotspot/share/gc/serial/serialFullGC.cpp @@ -22,8 +22,8 @@ * */ -#include "classfile/classLoaderDataGraph.hpp" #include "classfile/classLoaderData.inline.hpp" +#include "classfile/classLoaderDataGraph.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" @@ -43,11 +43,11 @@ #include "gc/shared/collectedHeap.inline.hpp" #include "gc/shared/continuationGCSupport.inline.hpp" #include "gc/shared/fullGCForwarding.inline.hpp" +#include "gc/shared/gc_globals.hpp" #include "gc/shared/gcHeapSummary.hpp" #include "gc/shared/gcTimer.hpp" #include "gc/shared/gcTrace.hpp" #include "gc/shared/gcTraceTime.inline.hpp" -#include "gc/shared/gc_globals.hpp" #include "gc/shared/modRefBarrierSet.hpp" #include "gc/shared/preservedMarks.inline.hpp" #include "gc/shared/referencePolicy.hpp" diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp index c6a6a0ae716..d88b2566299 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_GC_SERIAL_TENUREDGENERATION_INLINE_HPP #include "gc/serial/tenuredGeneration.hpp" + #include "gc/shared/space.hpp" inline size_t TenuredGeneration::capacity() const { diff --git a/src/hotspot/share/gc/shared/ageTable.cpp b/src/hotspot/share/gc/shared/ageTable.cpp index f5b62466556..2ed6ea967db 100644 --- a/src/hotspot/share/gc/shared/ageTable.cpp +++ b/src/hotspot/share/gc/shared/ageTable.cpp @@ -28,11 +28,11 @@ #include "gc/shared/gc_globals.hpp" #include "jvm.h" #include "logging/log.hpp" +#include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" #include "runtime/perfData.hpp" #include "utilities/copy.hpp" -#include "logging/logStream.hpp" /* Copyright (c) 1992, 2025, Oracle and/or its affiliates, and Stanford University. See the LICENSE file for license information. */ diff --git a/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp b/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp index 38c568889d1..f637c227ee1 100644 --- a/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp +++ b/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp @@ -27,8 +27,8 @@ #include "gc/shared/barrierSetConfig.hpp" -#include "gc/shared/modRefBarrierSet.inline.hpp" #include "gc/shared/cardTableBarrierSet.inline.hpp" +#include "gc/shared/modRefBarrierSet.inline.hpp" #if INCLUDE_EPSILONGC #include "gc/epsilon/epsilonBarrierSet.hpp" diff --git a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp index c5d8a7e5401..41eb0a24b62 100644 --- a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp +++ b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp @@ -35,8 +35,8 @@ #include "oops/method.inline.hpp" #include "runtime/frame.inline.hpp" #include "runtime/javaThread.hpp" -#include "runtime/threadWXSetters.inline.hpp" #include "runtime/threads.hpp" +#include "runtime/threadWXSetters.inline.hpp" #include "utilities/debug.hpp" #if INCLUDE_JVMCI #include "jvmci/jvmciRuntime.hpp" diff --git a/src/hotspot/share/gc/shared/bufferNode.cpp b/src/hotspot/share/gc/shared/bufferNode.cpp index e27b1279c79..b064f9c7efe 100644 --- a/src/hotspot/share/gc/shared/bufferNode.cpp +++ b/src/hotspot/share/gc/shared/bufferNode.cpp @@ -23,8 +23,8 @@ */ #include "gc/shared/bufferNode.hpp" -#include "utilities/debug.hpp" #include "memory/allocation.inline.hpp" +#include "utilities/debug.hpp" #include diff --git a/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp b/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp index 3d0621cdc7a..e618a81b26b 100644 --- a/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp +++ b/src/hotspot/share/gc/shared/c1/barrierSetC1.hpp @@ -26,9 +26,9 @@ #define SHARE_GC_SHARED_C1_BARRIERSETC1_HPP #include "c1/c1_Decorators.hpp" -#include "c1/c1_LIRGenerator.hpp" #include "c1/c1_Instruction.hpp" #include "c1/c1_LIR.hpp" +#include "c1/c1_LIRGenerator.hpp" #include "memory/allocation.hpp" class LIRGenerator; diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp index 92154e7a46e..f0ed9687f11 100644 --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.cpp @@ -24,8 +24,8 @@ #include "code/vmreg.inline.hpp" #include "gc/shared/barrierSet.hpp" -#include "gc/shared/tlab_globals.hpp" #include "gc/shared/c2/barrierSetC2.hpp" +#include "gc/shared/tlab_globals.hpp" #include "opto/arraycopynode.hpp" #include "opto/block.hpp" #include "opto/convertnode.hpp" diff --git a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp index 7df210d9fb6..536cd6da1ef 100644 --- a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp @@ -23,9 +23,9 @@ */ #include "ci/ciUtilities.hpp" +#include "gc/shared/c2/cardTableBarrierSetC2.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" -#include "gc/shared/c2/cardTableBarrierSetC2.hpp" #include "gc/shared/gc_globals.hpp" #include "opto/arraycopynode.hpp" #include "opto/graphKit.hpp" diff --git a/src/hotspot/share/gc/shared/c2/modRefBarrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/modRefBarrierSetC2.cpp index cf5d3fc7e16..ddc9caedd71 100644 --- a/src/hotspot/share/gc/shared/c2/modRefBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/modRefBarrierSetC2.cpp @@ -22,10 +22,10 @@ * */ +#include "gc/shared/c2/modRefBarrierSetC2.hpp" #include "opto/arraycopynode.hpp" #include "opto/graphKit.hpp" #include "opto/idealKit.hpp" -#include "gc/shared/c2/modRefBarrierSetC2.hpp" Node* ModRefBarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) const { DecoratorSet decorators = access.decorators(); diff --git a/src/hotspot/share/gc/shared/cardTable.cpp b/src/hotspot/share/gc/shared/cardTable.cpp index 3236d73933c..e5dbbcc0746 100644 --- a/src/hotspot/share/gc/shared/cardTable.cpp +++ b/src/hotspot/share/gc/shared/cardTable.cpp @@ -24,8 +24,8 @@ #include "gc/shared/cardTable.hpp" #include "gc/shared/collectedHeap.hpp" -#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/space.hpp" #include "logging/log.hpp" #include "memory/memoryReserver.hpp" diff --git a/src/hotspot/share/gc/shared/collectedHeap.cpp b/src/hotspot/share/gc/shared/collectedHeap.cpp index 9c55a894ee7..ec9872bf402 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.cpp +++ b/src/hotspot/share/gc/shared/collectedHeap.cpp @@ -29,15 +29,15 @@ #include "gc/shared/barrierSet.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectedHeap.inline.hpp" -#include "gc/shared/gcLocker.hpp" +#include "gc/shared/gc_globals.hpp" #include "gc/shared/gcHeapSummary.hpp" -#include "gc/shared/stringdedup/stringDedup.hpp" +#include "gc/shared/gcLocker.hpp" #include "gc/shared/gcTrace.hpp" #include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/gcVMOperations.hpp" #include "gc/shared/gcWhen.hpp" -#include "gc/shared/gc_globals.hpp" #include "gc/shared/memAllocator.hpp" +#include "gc/shared/stringdedup/stringDedup.hpp" #include "gc/shared/tlab_globals.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" diff --git a/src/hotspot/share/gc/shared/gcHeapSummary.hpp b/src/hotspot/share/gc/shared/gcHeapSummary.hpp index fb048d06a41..ae08f60d3a6 100644 --- a/src/hotspot/share/gc/shared/gcHeapSummary.hpp +++ b/src/hotspot/share/gc/shared/gcHeapSummary.hpp @@ -26,8 +26,8 @@ #define SHARE_GC_SHARED_GCHEAPSUMMARY_HPP #include "memory/allocation.hpp" -#include "memory/metaspaceStats.hpp" #include "memory/metaspaceChunkFreeListSummary.hpp" +#include "memory/metaspaceStats.hpp" class VirtualSpaceSummary : public StackObj { HeapWord* _start; diff --git a/src/hotspot/share/gc/shared/gcInitLogger.cpp b/src/hotspot/share/gc/shared/gcInitLogger.cpp index f2d9fffdc11..91bebf726c1 100644 --- a/src/hotspot/share/gc/shared/gcInitLogger.cpp +++ b/src/hotspot/share/gc/shared/gcInitLogger.cpp @@ -22,9 +22,9 @@ * */ +#include "gc/shared/gc_globals.hpp" #include "gc/shared/gcInitLogger.hpp" #include "gc/shared/gcLogPrecious.hpp" -#include "gc/shared/gc_globals.hpp" #include "logging/log.hpp" #include "oops/compressedOops.hpp" #include "runtime/globals.hpp" diff --git a/src/hotspot/share/gc/shared/gcLocker.cpp b/src/hotspot/share/gc/shared/gcLocker.cpp index caf752f70c8..fbc953512bb 100644 --- a/src/hotspot/share/gc/shared/gcLocker.cpp +++ b/src/hotspot/share/gc/shared/gcLocker.cpp @@ -25,15 +25,15 @@ #include "gc/shared/collectedHeap.hpp" #include "gc/shared/gcLocker.hpp" #include "gc/shared/gcTrace.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" -#include "logging/log.hpp" #include "runtime/atomic.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaThread.inline.hpp" #include "runtime/safepoint.hpp" -#include "utilities/spinYield.hpp" #include "runtime/threadSMR.hpp" +#include "utilities/spinYield.hpp" #include "utilities/ticks.hpp" // GCLockerTimingDebugLogger tracks specific timing information for GC lock waits. diff --git a/src/hotspot/share/gc/shared/gcLogPrecious.hpp b/src/hotspot/share/gc/shared/gcLogPrecious.hpp index ec8b1c670f3..8aa70252b3d 100644 --- a/src/hotspot/share/gc/shared/gcLogPrecious.hpp +++ b/src/hotspot/share/gc/shared/gcLogPrecious.hpp @@ -24,10 +24,10 @@ #ifndef SHARE_GC_SHARED_GCLOGPRECIOUS_HPP #define SHARE_GC_SHARED_GCLOGPRECIOUS_HPP -#include "utilities/globalDefinitions.hpp" #include "logging/logHandle.hpp" #include "memory/allStatic.hpp" #include "utilities/debug.hpp" +#include "utilities/globalDefinitions.hpp" class Mutex; class stringStream; diff --git a/src/hotspot/share/gc/shared/gcOverheadChecker.hpp b/src/hotspot/share/gc/shared/gcOverheadChecker.hpp index d4a9b5cd70d..e29ae2ab911 100644 --- a/src/hotspot/share/gc/shared/gcOverheadChecker.hpp +++ b/src/hotspot/share/gc/shared/gcOverheadChecker.hpp @@ -26,9 +26,9 @@ #ifndef SHARE_GC_SHARED_GCOVERHEADCHECKER_HPP #define SHARE_GC_SHARED_GCOVERHEADCHECKER_HPP -#include "memory/allocation.hpp" -#include "gc/shared/gcCause.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcCause.hpp" +#include "memory/allocation.hpp" #include "runtime/globals.hpp" class SoftRefPolicy; diff --git a/src/hotspot/share/gc/shared/gcPolicyCounters.cpp b/src/hotspot/share/gc/shared/gcPolicyCounters.cpp index d24ad745aa1..343ad6ca41e 100644 --- a/src/hotspot/share/gc/shared/gcPolicyCounters.cpp +++ b/src/hotspot/share/gc/shared/gcPolicyCounters.cpp @@ -22,8 +22,8 @@ * */ -#include "gc/shared/gcPolicyCounters.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcPolicyCounters.hpp" #include "memory/resourceArea.hpp" GCPolicyCounters::GCPolicyCounters(const char* name, int collectors, diff --git a/src/hotspot/share/gc/shared/gcTimer.cpp b/src/hotspot/share/gc/shared/gcTimer.cpp index 85859750151..a5bc7bfb02f 100644 --- a/src/hotspot/share/gc/shared/gcTimer.cpp +++ b/src/hotspot/share/gc/shared/gcTimer.cpp @@ -22,8 +22,8 @@ * */ -#include "gc/shared/gcTimer.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcTimer.hpp" #include "utilities/growableArray.hpp" // the "time" parameter for most functions diff --git a/src/hotspot/share/gc/shared/gcTraceTime.cpp b/src/hotspot/share/gc/shared/gcTraceTime.cpp index def8a3f3f5c..5839027b585 100644 --- a/src/hotspot/share/gc/shared/gcTraceTime.cpp +++ b/src/hotspot/share/gc/shared/gcTraceTime.cpp @@ -23,8 +23,8 @@ */ #include "gc/shared/collectedHeap.hpp" -#include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/gcTrace.hpp" +#include "gc/shared/gcTraceTime.inline.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" #include "memory/universe.hpp" diff --git a/src/hotspot/share/gc/shared/gcVMOperations.cpp b/src/hotspot/share/gc/shared/gcVMOperations.cpp index 8e5768ce6a9..1632dca61d5 100644 --- a/src/hotspot/share/gc/shared/gcVMOperations.cpp +++ b/src/hotspot/share/gc/shared/gcVMOperations.cpp @@ -25,10 +25,10 @@ #include "classfile/classLoaderData.hpp" #include "classfile/javaClasses.hpp" #include "gc/shared/allocTracer.hpp" +#include "gc/shared/gc_globals.hpp" #include "gc/shared/gcId.hpp" #include "gc/shared/gcLocker.hpp" #include "gc/shared/gcVMOperations.hpp" -#include "gc/shared/gc_globals.hpp" #include "gc/shared/softRefPolicy.hpp" #include "interpreter/oopMapCache.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/gc/shared/locationPrinter.cpp b/src/hotspot/share/gc/shared/locationPrinter.cpp index b5efb540d45..85fdcd37524 100644 --- a/src/hotspot/share/gc/shared/locationPrinter.cpp +++ b/src/hotspot/share/gc/shared/locationPrinter.cpp @@ -25,9 +25,9 @@ #include "gc/shared/collectedHeap.hpp" #include "gc/shared/locationPrinter.hpp" #include "memory/universe.hpp" -#include "runtime/os.hpp" #include "oops/klass.hpp" #include "oops/oop.inline.hpp" +#include "runtime/os.hpp" bool LocationPrinter::is_valid_obj(void* obj) { if (!is_object_aligned(obj)) { diff --git a/src/hotspot/share/gc/shared/memAllocator.cpp b/src/hotspot/share/gc/shared/memAllocator.cpp index 64ca4635718..74ef1f66184 100644 --- a/src/hotspot/share/gc/shared/memAllocator.cpp +++ b/src/hotspot/share/gc/shared/memAllocator.cpp @@ -35,8 +35,8 @@ #include "prims/jvmtiExport.hpp" #include "runtime/continuationJavaClasses.inline.hpp" #include "runtime/handles.inline.hpp" -#include "runtime/sharedRuntime.hpp" #include "runtime/javaThread.hpp" +#include "runtime/sharedRuntime.hpp" #include "services/lowMemoryDetector.hpp" #include "utilities/align.hpp" #include "utilities/copy.hpp" diff --git a/src/hotspot/share/gc/shared/parallelCleaning.cpp b/src/hotspot/share/gc/shared/parallelCleaning.cpp index 1b1eaf4d79a..8cb09939f22 100644 --- a/src/hotspot/share/gc/shared/parallelCleaning.cpp +++ b/src/hotspot/share/gc/shared/parallelCleaning.cpp @@ -22,13 +22,12 @@ * */ -#include "classfile/symbolTable.hpp" #include "classfile/stringTable.hpp" +#include "classfile/symbolTable.hpp" #include "code/codeCache.hpp" #include "gc/shared/parallelCleaning.hpp" #include "logging/log.hpp" #include "memory/resourceArea.hpp" -#include "logging/log.hpp" #include "runtime/atomic.hpp" CodeCacheUnloadingTask::CodeCacheUnloadingTask(uint num_workers, bool unloading_occurred) : diff --git a/src/hotspot/share/gc/shared/partialArrayState.cpp b/src/hotspot/share/gc/shared/partialArrayState.cpp index f79e012a36d..8db39281a05 100644 --- a/src/hotspot/share/gc/shared/partialArrayState.cpp +++ b/src/hotspot/share/gc/shared/partialArrayState.cpp @@ -32,6 +32,7 @@ #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" + #include PartialArrayState::PartialArrayState(oop src, oop dst, diff --git a/src/hotspot/share/gc/shared/partialArrayTaskStepper.inline.hpp b/src/hotspot/share/gc/shared/partialArrayTaskStepper.inline.hpp index 1d43578b5fe..9d127697e58 100644 --- a/src/hotspot/share/gc/shared/partialArrayTaskStepper.inline.hpp +++ b/src/hotspot/share/gc/shared/partialArrayTaskStepper.inline.hpp @@ -25,8 +25,9 @@ #ifndef SHARE_GC_SHARED_PARTIALARRAYTASKSTEPPER_INLINE_HPP #define SHARE_GC_SHARED_PARTIALARRAYTASKSTEPPER_INLINE_HPP -#include "gc/shared/partialArrayState.hpp" #include "gc/shared/partialArrayTaskStepper.hpp" + +#include "gc/shared/partialArrayState.hpp" #include "runtime/atomic.hpp" #include "utilities/checkedCast.hpp" #include "utilities/debug.hpp" diff --git a/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp b/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp index 83eaccd9813..fd2bd8f3edc 100644 --- a/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp +++ b/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp @@ -23,8 +23,8 @@ */ #include "gc/shared/gcTimer.hpp" -#include "gc/shared/referenceProcessorPhaseTimes.hpp" #include "gc/shared/referenceProcessor.inline.hpp" +#include "gc/shared/referenceProcessorPhaseTimes.hpp" #include "gc/shared/workerDataArray.inline.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" diff --git a/src/hotspot/share/gc/shared/satbMarkQueue.cpp b/src/hotspot/share/gc/shared/satbMarkQueue.cpp index 6e33d27897c..915eaa116fb 100644 --- a/src/hotspot/share/gc/shared/satbMarkQueue.cpp +++ b/src/hotspot/share/gc/shared/satbMarkQueue.cpp @@ -22,8 +22,8 @@ * */ -#include "gc/shared/satbMarkQueue.hpp" #include "gc/shared/collectedHeap.hpp" +#include "gc/shared/satbMarkQueue.hpp" #include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "oops/oop.inline.hpp" diff --git a/src/hotspot/share/gc/shared/stringdedup/stringDedup.cpp b/src/hotspot/share/gc/shared/stringdedup/stringDedup.cpp index 9ad8decec7e..b3f96da1cce 100644 --- a/src/hotspot/share/gc/shared/stringdedup/stringDedup.cpp +++ b/src/hotspot/share/gc/shared/stringdedup/stringDedup.cpp @@ -25,9 +25,9 @@ #include "classfile/javaClasses.inline.hpp" #include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" +#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/oopStorage.hpp" #include "gc/shared/oopStorageSet.hpp" -#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/stringdedup/stringDedup.hpp" #include "gc/shared/stringdedup/stringDedupConfig.hpp" #include "gc/shared/stringdedup/stringDedupProcessor.hpp" diff --git a/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp b/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp index 5c6628cba5c..83c6fea8c5b 100644 --- a/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp +++ b/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp @@ -33,10 +33,10 @@ #include "gc/shared/stringdedup/stringDedupConfig.hpp" #include "gc/shared/stringdedup/stringDedupStat.hpp" #include "gc/shared/stringdedup/stringDedupTable.hpp" -#include "memory/allocation.hpp" -#include "memory/resourceArea.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" +#include "memory/allocation.hpp" +#include "memory/resourceArea.hpp" #include "oops/access.hpp" #include "oops/oopsHierarchy.hpp" #include "oops/typeArrayOop.inline.hpp" diff --git a/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.hpp b/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.hpp index 19df8184a05..a163319e84c 100644 --- a/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.hpp +++ b/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.hpp @@ -25,9 +25,9 @@ #ifndef SHARE_GC_SHARED_STRINGDEDUP_STRINGDEDUPTABLE_HPP #define SHARE_GC_SHARED_STRINGDEDUP_STRINGDEDUPTABLE_HPP -#include "memory/allStatic.hpp" #include "gc/shared/stringdedup/stringDedup.hpp" #include "gc/shared/stringdedup/stringDedupStat.hpp" +#include "memory/allStatic.hpp" #include "oops/typeArrayOop.hpp" #include "oops/weakHandle.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/gc/shared/taskTerminator.cpp b/src/hotspot/share/gc/shared/taskTerminator.cpp index 1353c3f8c8a..cc84665087b 100644 --- a/src/hotspot/share/gc/shared/taskTerminator.cpp +++ b/src/hotspot/share/gc/shared/taskTerminator.cpp @@ -24,8 +24,8 @@ */ #include "gc/shared/gc_globals.hpp" -#include "gc/shared/taskTerminator.hpp" #include "gc/shared/taskqueue.hpp" +#include "gc/shared/taskTerminator.hpp" #include "logging/log.hpp" #include "runtime/globals.hpp" #include "runtime/javaThread.hpp" diff --git a/src/hotspot/share/gc/shared/taskqueue.cpp b/src/hotspot/share/gc/shared/taskqueue.cpp index a244ba45415..162eadc3cf0 100644 --- a/src/hotspot/share/gc/shared/taskqueue.cpp +++ b/src/hotspot/share/gc/shared/taskqueue.cpp @@ -23,8 +23,8 @@ */ #include "gc/shared/taskqueue.hpp" -#include "oops/oop.inline.hpp" #include "logging/log.hpp" +#include "oops/oop.inline.hpp" #include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" #include "runtime/os.hpp" diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp index 32a830a2bb1..22d19b77806 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.inline.hpp @@ -29,8 +29,8 @@ #include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" -#include "memory/universe.hpp" #include "logging/log.hpp" +#include "memory/universe.hpp" #include "runtime/javaThread.hpp" #include "runtime/osThread.hpp" #include "utilities/copy.hpp" diff --git a/src/hotspot/share/gc/shared/weakProcessor.cpp b/src/hotspot/share/gc/shared/weakProcessor.cpp index d7de8b5d8a8..bc7e9ad6375 100644 --- a/src/hotspot/share/gc/shared/weakProcessor.cpp +++ b/src/hotspot/share/gc/shared/weakProcessor.cpp @@ -27,8 +27,8 @@ #include "gc/shared/oopStorage.inline.hpp" #include "gc/shared/oopStorageParState.inline.hpp" #include "gc/shared/oopStorageSet.hpp" -#include "gc/shared/weakProcessor.inline.hpp" #include "gc/shared/oopStorageSetParState.inline.hpp" +#include "gc/shared/weakProcessor.inline.hpp" #include "gc/shared/weakProcessorTimes.hpp" #include "memory/allocation.inline.hpp" #include "memory/iterator.hpp" diff --git a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp index 9a12e0ed1a1..9f58016a6f1 100644 --- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp +++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp @@ -26,6 +26,7 @@ #include "c1/c1_IR.hpp" #include "gc/shared/satbMarkQueue.hpp" +#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" @@ -33,7 +34,6 @@ #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahRuntime.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" #ifdef ASSERT #define __ gen->lir(__FILE__, __LINE__)-> diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp index 8df4413cc2f..d71e84d33b0 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp @@ -25,15 +25,15 @@ #include "classfile/javaClasses.hpp" #include "gc/shared/barrierSet.hpp" +#include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp" +#include "gc/shenandoah/c2/shenandoahSupport.hpp" +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahCardTable.hpp" #include "gc/shenandoah/shenandoahForwarding.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahRuntime.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp" -#include "gc/shenandoah/c2/shenandoahSupport.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "opto/arraycopynode.hpp" #include "opto/escape.hpp" #include "opto/graphKit.hpp" diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index 4652dbce0e3..56d88d44d27 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -25,8 +25,8 @@ #include "classfile/javaClasses.hpp" -#include "gc/shenandoah/c2/shenandoahSupport.hpp" #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp" +#include "gc/shenandoah/c2/shenandoahSupport.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" #include "gc/shenandoah/shenandoahForwarding.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp index 5280e9b2ac4..eb87a9dc4c1 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp @@ -26,9 +26,9 @@ #include "gc/shared/gcCause.hpp" +#include "gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp" #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/heuristics/shenandoahSpaceInfo.hpp" -#include "gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp index a47024f3a4b..68e540960c7 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp @@ -26,10 +26,10 @@ #ifndef SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHADAPTIVEHEURISTICS_HPP #define SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHADAPTIVEHEURISTICS_HPP -#include "memory/allocation.hpp" #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahSharedVariables.hpp" +#include "memory/allocation.hpp" #include "utilities/numberSeq.hpp" class ShenandoahAllocationRate : public CHeapObj { diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp index 9d211314474..403405b984d 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp @@ -24,8 +24,8 @@ */ -#include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/heuristics/shenandoahCompactHeuristics.hpp" +#include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp index afc9abc496e..08fd4599346 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.cpp @@ -26,13 +26,12 @@ #include "gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" +#include "gc/shenandoah/shenandoahEvacInfo.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" -#include "gc/shenandoah/shenandoahEvacInfo.hpp" #include "gc/shenandoah/shenandoahTrace.hpp" - #include "logging/log.hpp" ShenandoahGenerationalHeuristics::ShenandoahGenerationalHeuristics(ShenandoahGeneration* generation) diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp index 919f6c88afa..b8d85de0487 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahGlobalHeuristics.cpp @@ -25,10 +25,9 @@ #include "gc/shenandoah/heuristics/shenandoahGlobalHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" -#include "gc/shenandoah/shenandoahGlobalGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" +#include "gc/shenandoah/shenandoahGlobalGeneration.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" - #include "utilities/quickSort.hpp" ShenandoahGlobalHeuristics::ShenandoahGlobalHeuristics(ShenandoahGlobalGeneration* generation) diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp index 4c7ed07b2a0..b151a75e6e7 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp @@ -25,10 +25,10 @@ */ #include "gc/shared/gcCause.hpp" +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" #include "runtime/globals_extension.hpp" diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp index 9f8c6225d23..ba09eeb8794 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahYoungHeuristics.cpp @@ -30,7 +30,6 @@ #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" - #include "utilities/quickSort.hpp" ShenandoahYoungHeuristics::ShenandoahYoungHeuristics(ShenandoahYoungGeneration* generation) diff --git a/src/hotspot/share/gc/shenandoah/mode/shenandoahGenerationalMode.cpp b/src/hotspot/share/gc/shenandoah/mode/shenandoahGenerationalMode.cpp index 6c885834155..fa784d5bb90 100644 --- a/src/hotspot/share/gc/shenandoah/mode/shenandoahGenerationalMode.cpp +++ b/src/hotspot/share/gc/shenandoah/mode/shenandoahGenerationalMode.cpp @@ -22,8 +22,8 @@ * */ -#include "gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp" #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp" #include "gc/shenandoah/mode/shenandoahGenerationalMode.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" diff --git a/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp b/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp index 893321db1dc..296a1979b01 100644 --- a/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp +++ b/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp @@ -23,8 +23,8 @@ */ #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" -#include "gc/shenandoah/heuristics/shenandoahSpaceInfo.hpp" #include "gc/shenandoah/heuristics/shenandoahPassiveHeuristics.hpp" +#include "gc/shenandoah/heuristics/shenandoahSpaceInfo.hpp" #include "gc/shenandoah/mode/shenandoahPassiveMode.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp index 446e1914407..5d19a6a34e3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp @@ -24,8 +24,8 @@ */ #include "gc/shared/barrierSetNMethod.hpp" -#include "gc/shenandoah/shenandoahBarrierSetClone.inline.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" +#include "gc/shenandoah/shenandoahBarrierSetClone.inline.hpp" #include "gc/shenandoah/shenandoahBarrierSetNMethod.hpp" #include "gc/shenandoah/shenandoahBarrierSetStackChunk.hpp" #include "gc/shenandoah/shenandoahCardTable.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp index 20937b9d08e..b176446452a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp @@ -30,6 +30,7 @@ #include "gc/shared/accessBarrierSupport.inline.hpp" #include "gc/shared/cardTable.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahCardTable.hpp" #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp" @@ -40,7 +41,6 @@ #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "memory/iterator.inline.hpp" #include "oops/oop.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp index c08c9501201..725e4e6e3e9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp @@ -31,10 +31,10 @@ #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp" -#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" -#include "gc/shenandoah/shenandoahNMethod.inline.hpp" #include "gc/shenandoah/shenandoahMark.inline.hpp" +#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" +#include "gc/shenandoah/shenandoahNMethod.inline.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" #include "memory/iterator.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp index 34db132ab83..d29c446f210 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp @@ -26,9 +26,9 @@ #define SHARE_GC_SHENANDOAH_SHENANDOAHCODEROOTS_HPP #include "code/codeCache.hpp" -#include "gc/shenandoah/shenandoahSharedVariables.hpp" #include "gc/shenandoah/shenandoahLock.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" +#include "gc/shenandoah/shenandoahSharedVariables.hpp" #include "memory/allStatic.hpp" #include "memory/iterator.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp index 7b9aafad149..5b5fe2c1af6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp @@ -35,11 +35,10 @@ #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" -#include "gc/shenandoah/shenandoahOldGeneration.hpp" -#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "gc/shenandoah/shenandoahLock.hpp" #include "gc/shenandoah/shenandoahMark.inline.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" +#include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" @@ -47,8 +46,9 @@ #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahVerifier.hpp" #include "gc/shenandoah/shenandoahVMOperations.hpp" -#include "gc/shenandoah/shenandoahWorkGroup.hpp" #include "gc/shenandoah/shenandoahWorkerPolicy.hpp" +#include "gc/shenandoah/shenandoahWorkGroup.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "memory/allocation.hpp" #include "prims/jvmtiTagMap.hpp" #include "runtime/vmThread.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp index 4a0f43226d7..facba2236be 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp @@ -33,13 +33,13 @@ #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahMark.inline.hpp" +#include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" -#include "gc/shenandoah/shenandoahPhaseTimings.hpp" +#include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" #include "gc/shenandoah/shenandoahStringDedup.hpp" #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" -#include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" #include "memory/iterator.inline.hpp" #include "memory/resourceArea.hpp" #include "runtime/continuation.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp index 0b20b4ddf9f..6975bd9f350 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp @@ -23,6 +23,8 @@ * */ +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahConcurrentGC.hpp" #include "gc/shenandoah/shenandoahControlThread.hpp" @@ -34,11 +36,9 @@ #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" #include "gc/shenandoah/shenandoahPacer.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "logging/log.hpp" -#include "memory/metaspaceUtils.hpp" #include "memory/metaspaceStats.hpp" +#include "memory/metaspaceUtils.hpp" ShenandoahControlThread::ShenandoahControlThread() : ShenandoahController(), diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp index be99ef1d865..9d95b5df7ed 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp @@ -25,10 +25,10 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCONTROLTHREAD_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHCONTROLTHREAD_HPP -#include "gc/shared/gcCause.hpp" #include "gc/shared/concurrentGCThread.hpp" -#include "gc/shenandoah/shenandoahGC.hpp" +#include "gc/shared/gcCause.hpp" #include "gc/shenandoah/shenandoahController.hpp" +#include "gc/shenandoah/shenandoahGC.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" #include "gc/shenandoah/shenandoahSharedVariables.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahController.cpp b/src/hotspot/share/gc/shenandoah/shenandoahController.cpp index c430981bfe6..52182b092c9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahController.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahController.cpp @@ -24,9 +24,8 @@ */ #include "gc/shared/gc_globals.hpp" +#include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahController.hpp" - -#include "shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahController.hpp b/src/hotspot/share/gc/shenandoah/shenandoahController.hpp index 83cde94f509..d24f52cb3f1 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahController.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahController.hpp @@ -25,8 +25,8 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCONTROLLER_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHCONTROLLER_HPP -#include "gc/shared/gcCause.hpp" #include "gc/shared/concurrentGCThread.hpp" +#include "gc/shared/gcCause.hpp" #include "gc/shenandoah/shenandoahAllocRequest.hpp" #include "gc/shenandoah/shenandoahSharedVariables.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp index 8cc4e2de8ea..7aaf7bd9f48 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp @@ -39,9 +39,9 @@ #include "gc/shenandoah/shenandoahSTWMark.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahVerifier.hpp" -#include "gc/shenandoah/shenandoahYoungGeneration.hpp" -#include "gc/shenandoah/shenandoahWorkerPolicy.hpp" #include "gc/shenandoah/shenandoahVMOperations.hpp" +#include "gc/shenandoah/shenandoahWorkerPolicy.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "runtime/vmThread.hpp" #include "utilities/events.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahEvacTracker.cpp b/src/hotspot/share/gc/shenandoah/shenandoahEvacTracker.cpp index 3ddc8bf636e..d393c17f64a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahEvacTracker.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahEvacTracker.cpp @@ -24,11 +24,11 @@ */ #include "gc/shenandoah/shenandoahAgeCensus.hpp" -#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahEvacTracker.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "runtime/threadSMR.inline.hpp" #include "runtime/thread.hpp" +#include "runtime/threadSMR.inline.hpp" ShenandoahEvacuationStats::ShenandoahEvacuationStats() : _evacuations_completed(0), _bytes_completed(0), diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp index e87c771dec4..9787611d4fb 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp @@ -31,9 +31,9 @@ #include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" -#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "gc/shenandoah/shenandoahSimpleBitMap.hpp" #include "gc/shenandoah/shenandoahSimpleBitMap.inline.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "runtime/orderAccess.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp index 80954af6d1a..902e6547afd 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp @@ -26,8 +26,8 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHFREESET_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHFREESET_HPP -#include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "gc/shenandoah/shenandoahSimpleBitMap.hpp" // Each ShenandoahHeapRegion is associated with a ShenandoahFreeSetPartitionId. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp index 9436f09cbe0..f017b3de962 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp @@ -34,23 +34,22 @@ #include "gc/shared/workerThread.hpp" #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahClosures.inline.hpp" -#include "gc/shenandoah/shenandoahCollectorPolicy.hpp" -#include "gc/shenandoah/shenandoahConcurrentGC.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" +#include "gc/shenandoah/shenandoahConcurrentGC.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahFullGC.hpp" #include "gc/shenandoah/shenandoahGenerationalFullGC.hpp" #include "gc/shenandoah/shenandoahGlobalGeneration.hpp" -#include "gc/shenandoah/shenandoahPhaseTimings.hpp" -#include "gc/shenandoah/shenandoahMark.inline.hpp" -#include "gc/shenandoah/shenandoahMonitoringSupport.hpp" -#include "gc/shenandoah/shenandoahHeapRegionClosures.hpp" -#include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" +#include "gc/shenandoah/shenandoahHeapRegionClosures.hpp" +#include "gc/shenandoah/shenandoahHeapRegionSet.hpp" +#include "gc/shenandoah/shenandoahMark.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahMetrics.hpp" +#include "gc/shenandoah/shenandoahMonitoringSupport.hpp" +#include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" #include "gc/shenandoah/shenandoahSTWMark.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGC.hpp b/src/hotspot/share/gc/shenandoah/shenandoahGC.hpp index f10d5eef969..f08bdce0a20 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGC.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGC.hpp @@ -25,8 +25,8 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHGC_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHGC_HPP -#include "memory/allocation.hpp" #include "gc/shared/gcCause.hpp" +#include "memory/allocation.hpp" /* * Base class of three Shenandoah GC modes diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp index ad91119ddad..9a511de939c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp @@ -23,8 +23,9 @@ * */ -#include "gc/shenandoah/shenandoahCollectorPolicy.hpp" +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectionSetPreselector.hpp" +#include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" @@ -37,8 +38,6 @@ #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahVerifier.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" - #include "utilities/quickSort.hpp" template diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp index 31c86985c6f..242acbdea8c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp @@ -25,12 +25,12 @@ #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHGENERATION_HPP #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHGENERATION_HPP -#include "memory/allocation.hpp" #include "gc/shenandoah/heuristics/shenandoahSpaceInfo.hpp" #include "gc/shenandoah/shenandoahAffiliation.hpp" #include "gc/shenandoah/shenandoahGenerationType.hpp" #include "gc/shenandoah/shenandoahLock.hpp" #include "gc/shenandoah/shenandoahMarkingContext.hpp" +#include "memory/allocation.hpp" class ShenandoahCollectionSet; class ShenandoahHeap; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationSizer.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationSizer.cpp index c6827878cd1..17f3d2f199f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationSizer.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationSizer.cpp @@ -23,13 +23,13 @@ * */ +#include "gc/shared/gc_globals.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationSizer.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" -#include "gc/shared/gc_globals.hpp" #include "logging/log.hpp" #include "runtime/globals_extension.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp index 4d291ba50f7..2f2f13ca87b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp @@ -27,22 +27,22 @@ #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahConcurrentGC.hpp" -#include "gc/shenandoah/shenandoahGenerationalControlThread.hpp" #include "gc/shenandoah/shenandoahDegeneratedGC.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahFullGC.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" +#include "gc/shenandoah/shenandoahGenerationalControlThread.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" -#include "gc/shenandoah/shenandoahOldGC.hpp" -#include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" +#include "gc/shenandoah/shenandoahOldGC.hpp" +#include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahPacer.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "logging/log.hpp" -#include "memory/metaspaceUtils.hpp" #include "memory/metaspaceStats.hpp" +#include "memory/metaspaceUtils.hpp" #include "runtime/atomic.hpp" #include "utilities/events.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp index 6a845afa4fd..ba9ef5979a8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalEvacuationTask.cpp @@ -31,8 +31,8 @@ #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahPacer.hpp" #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" -#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" class ShenandoahConcurrentEvacuator : public ObjectClosure { private: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalFullGC.cpp index 3387ed9d7a8..142c2d47989 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalFullGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalFullGC.cpp @@ -25,14 +25,14 @@ #include "gc/shared/fullGCForwarding.inline.hpp" #include "gc/shared/preservedMarks.inline.hpp" +#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationalFullGC.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" -#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" -#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #ifdef ASSERT void assert_regions_used_not_more_than_capacity(ShenandoahGeneration* generation) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp index 09b985e3b8d..1f84feb20e8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp @@ -40,9 +40,9 @@ #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahRegulatorThread.hpp" #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" +#include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahWorkerPolicy.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" -#include "gc/shenandoah/shenandoahUtils.hpp" #include "logging/log.hpp" #include "utilities/events.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.cpp index 230fff16252..a16a71b8175 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.cpp @@ -22,8 +22,8 @@ * */ -#include "gc/shenandoah/shenandoahAgeCensus.hpp" #include "gc/shenandoah/heuristics/shenandoahGlobalHeuristics.hpp" +#include "gc/shenandoah/shenandoahAgeCensus.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahGlobalGeneration.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.hpp b/src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.hpp index d51a77fdf8f..5857170d4cc 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.hpp @@ -26,8 +26,8 @@ #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHGLOBALGENERATION_HPP #include "gc/shenandoah/shenandoahGeneration.hpp" -#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" // A "generation" that represents the whole heap. class ShenandoahGlobalGeneration : public ShenandoahGeneration { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 045f485090d..82c6cdb8971 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -27,7 +27,6 @@ #include "cds/archiveHeapWriter.hpp" #include "classfile/systemDictionary.hpp" - #include "gc/shared/classUnloadingContext.hpp" #include "gc/shared/fullGCForwarding.hpp" #include "gc/shared/gcArguments.hpp" @@ -37,24 +36,26 @@ #include "gc/shared/memAllocator.hpp" #include "gc/shared/plab.hpp" #include "gc/shared/tlab_globals.hpp" - #include "gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp" #include "gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp" +#include "gc/shenandoah/mode/shenandoahGenerationalMode.hpp" +#include "gc/shenandoah/mode/shenandoahPassiveMode.hpp" +#include "gc/shenandoah/mode/shenandoahSATBMode.hpp" #include "gc/shenandoah/shenandoahAllocRequest.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" +#include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahCodeRoots.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahConcurrentMark.hpp" #include "gc/shenandoah/shenandoahControlThread.hpp" -#include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahGenerationalEvacuationTask.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" #include "gc/shenandoah/shenandoahGlobalGeneration.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" -#include "gc/shenandoah/shenandoahHeapRegionClosures.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" +#include "gc/shenandoah/shenandoahHeapRegionClosures.hpp" #include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "gc/shenandoah/shenandoahInitLogger.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" @@ -73,18 +74,9 @@ #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahVerifier.hpp" #include "gc/shenandoah/shenandoahVMOperations.hpp" -#include "gc/shenandoah/shenandoahWorkGroup.hpp" #include "gc/shenandoah/shenandoahWorkerPolicy.hpp" +#include "gc/shenandoah/shenandoahWorkGroup.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" -#include "gc/shenandoah/mode/shenandoahGenerationalMode.hpp" -#include "gc/shenandoah/mode/shenandoahPassiveMode.hpp" -#include "gc/shenandoah/mode/shenandoahSATBMode.hpp" - -#if INCLUDE_JFR -#include "gc/shenandoah/shenandoahJfrSupport.hpp" -#endif - -#include "memory/allocation.hpp" #include "memory/allocation.hpp" #include "memory/classLoaderMetaspace.hpp" #include "memory/memoryReserver.hpp" @@ -103,9 +95,12 @@ #include "runtime/stackWatermarkSet.hpp" #include "runtime/threads.hpp" #include "runtime/vmThread.hpp" -#include "utilities/globalDefinitions.hpp" #include "utilities/events.hpp" +#include "utilities/globalDefinitions.hpp" #include "utilities/powerOfTwo.hpp" +#if INCLUDE_JFR +#include "gc/shenandoah/shenandoahJfrSupport.hpp" +#endif class ShenandoahPretouchHeapTask : public WorkerTask { private: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 46f8a134051..4f24b9e1abd 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -27,19 +27,19 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_HPP +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/markBitMap.hpp" #include "gc/shared/softRefPolicy.hpp" -#include "gc/shared/collectedHeap.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahAllocRequest.hpp" #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahController.hpp" -#include "gc/shenandoah/shenandoahLock.hpp" #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp" #include "gc/shenandoah/shenandoahEvacTracker.hpp" -#include "gc/shenandoah/shenandoahGenerationType.hpp" #include "gc/shenandoah/shenandoahGenerationSizer.hpp" +#include "gc/shenandoah/shenandoahGenerationType.hpp" +#include "gc/shenandoah/shenandoahLock.hpp" #include "gc/shenandoah/shenandoahMmuTracker.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" #include "gc/shenandoah/shenandoahSharedVariables.hpp" #include "gc/shenandoah/shenandoahUnload.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index f4ef186743c..cf9d808f7ce 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -30,28 +30,28 @@ #include "gc/shenandoah/shenandoahHeap.hpp" #include "classfile/javaClasses.inline.hpp" -#include "gc/shared/markBitMap.inline.hpp" -#include "gc/shared/threadLocalAllocBuffer.inline.hpp" #include "gc/shared/continuationGCSupport.inline.hpp" +#include "gc/shared/markBitMap.inline.hpp" #include "gc/shared/suspendibleThreadSet.hpp" +#include "gc/shared/threadLocalAllocBuffer.inline.hpp" #include "gc/shared/tlab_globals.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp" #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp" #include "gc/shenandoah/shenandoahForwarding.inline.hpp" -#include "gc/shenandoah/shenandoahWorkGroup.hpp" -#include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp" -#include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" +#include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" +#include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" +#include "gc/shenandoah/shenandoahWorkGroup.hpp" #include "oops/compressedOops.inline.hpp" #include "oops/oop.inline.hpp" #include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" -#include "runtime/prefetch.inline.hpp" #include "runtime/objectMonitor.inline.hpp" +#include "runtime/prefetch.inline.hpp" #include "utilities/copy.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp index a25e2dfd88f..d00a99ee728 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp @@ -29,14 +29,14 @@ #include "gc/shared/tlab_globals.hpp" #include "gc/shenandoah/shenandoahCardTable.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" -#include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp" +#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" +#include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" -#include "gc/shenandoah/shenandoahGeneration.hpp" -#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "jfr/jfrEvents.hpp" #include "memory/allocation.hpp" #include "memory/iterator.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp index 7f29a8628aa..0df482c1e2d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp @@ -27,8 +27,9 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGION_INLINE_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGION_INLINE_HPP -#include "gc/shenandoah/shenandoahGenerationalHeap.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" + +#include "gc/shenandoah/shenandoahGenerationalHeap.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahPacer.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp index 360c7d2d649..918e6bf1be6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.cpp @@ -28,8 +28,8 @@ #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" -#include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "gc/shenandoah/shenandoahHeapRegionCounters.hpp" +#include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "runtime/atomic.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.hpp index c139980af41..508b40e49a8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionCounters.hpp @@ -26,8 +26,8 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONCOUNTERS_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONCOUNTERS_HPP -#include "memory/allocation.hpp" #include "logging/logFileStreamOutput.hpp" +#include "memory/allocation.hpp" /** * This provides the following in JVMStat: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp index 46d54c70fe1..368738fe5ea 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp @@ -23,9 +23,9 @@ * */ -#include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" +#include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "runtime/atomic.hpp" #include "utilities/copy.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.hpp index d933fda60b1..f81bf77d26e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.hpp @@ -25,10 +25,10 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP -#include "memory/allocation.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" +#include "memory/allocation.hpp" #include "utilities/globalDefinitions.hpp" class ShenandoahHeapRegionSet; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp b/src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp index b4ea327965b..b5e5e6fd698 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahInitLogger.cpp @@ -24,11 +24,11 @@ * */ +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahInitLogger.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "logging/log.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp b/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp index 47a144a638f..fcfe0d1d5d6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahLock.cpp @@ -23,12 +23,11 @@ */ -#include "runtime/os.hpp" - #include "gc/shenandoah/shenandoahLock.hpp" #include "runtime/atomic.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaThread.hpp" +#include "runtime/os.hpp" #include "runtime/os.inline.hpp" void ShenandoahLock::contended_lock(bool allow_block_for_safepoint) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMark.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMark.hpp index ae8d52a3d0e..4aef14f2c9a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMark.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMark.hpp @@ -29,9 +29,9 @@ #include "gc/shared/ageTable.hpp" #include "gc/shared/stringdedup/stringDedup.hpp" #include "gc/shared/taskTerminator.hpp" +#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationType.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" -#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahTaskqueue.hpp" enum StringDedupMode { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp index 9986afc6f20..34e6af41b42 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp @@ -24,8 +24,8 @@ * */ -#include "gc/shenandoah/shenandoahMarkBitMap.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" +#include "gc/shenandoah/shenandoahMarkBitMap.inline.hpp" #include "runtime/os.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp index 399db525cf9..0babeaffd3e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp @@ -27,7 +27,6 @@ #include "gc/shared/markBitMap.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.hpp" - #include "shenandoahGlobalGeneration.hpp" ShenandoahMarkingContext::ShenandoahMarkingContext(MemRegion heap_region, MemRegion bitmap_region, size_t num_regions) : diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp index d9bddd5fbb6..e3ba774283c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp @@ -28,6 +28,7 @@ #define SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_INLINE_HPP #include "gc/shenandoah/shenandoahMarkingContext.hpp" + #include "gc/shenandoah/shenandoahMarkBitMap.inline.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp index e9aa69b5555..ebfe5267160 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMemoryPool.cpp @@ -25,8 +25,8 @@ */ #include "gc/shenandoah/shenandoahMemoryPool.hpp" -#include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" +#include "gc/shenandoah/shenandoahYoungGeneration.hpp" ShenandoahMemoryPool::ShenandoahMemoryPool(ShenandoahHeap* heap, const char* name) : diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp index 32386e6aec0..edd4f875be4 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp @@ -23,10 +23,10 @@ * */ -#include "gc/shenandoah/shenandoahMetrics.hpp" +#include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" -#include "gc/shenandoah/shenandoahFreeSet.hpp" +#include "gc/shenandoah/shenandoahMetrics.hpp" ShenandoahMetricsSnapshot::ShenandoahMetricsSnapshot() { _heap = ShenandoahHeap::heap(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp index 663864b1294..5867478d734 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMmuTracker.cpp @@ -24,8 +24,8 @@ */ #include "gc/shenandoah/shenandoahAsserts.hpp" -#include "gc/shenandoah/shenandoahMmuTracker.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" +#include "gc/shenandoah/shenandoahMmuTracker.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp index 31265addda8..6b72cbdd62b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp @@ -25,9 +25,9 @@ #include "gc/shared/collectorCounters.hpp" #include "gc/shared/generationCounters.hpp" #include "gc/shared/hSpaceCounters.hpp" -#include "gc/shenandoah/shenandoahMonitoringSupport.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegionCounters.hpp" +#include "gc/shenandoah/shenandoahMonitoringSupport.hpp" #include "memory/metaspaceCounters.hpp" #include "services/memoryService.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOldGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahOldGC.cpp index 7c28378bf24..1724fc2849f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOldGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOldGC.cpp @@ -25,11 +25,11 @@ #include "gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp" #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" +#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" #include "gc/shenandoah/shenandoahOldGC.hpp" -#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" #include "prims/jvmtiTagMap.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp index b0c42c7b40f..35d963f1801 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOldGeneration.cpp @@ -26,6 +26,7 @@ #include "gc/shenandoah/heuristics/shenandoahOldHeuristics.hpp" #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahCardTable.hpp" +#include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" @@ -35,7 +36,6 @@ #include "gc/shenandoah/shenandoahHeapRegionClosures.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" -#include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp index e16275b480a..62a25881b5a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp @@ -25,11 +25,11 @@ #include "gc/shared/workerDataArray.inline.hpp" +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" -#include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" +#include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "runtime/orderAccess.hpp" #include "utilities/ostream.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp index 9100ad2b220..0a456151318 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp @@ -26,9 +26,9 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHPHASETIMINGS_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHPHASETIMINGS_HPP -#include "jfr/jfrEvents.hpp" -#include "gc/shenandoah/shenandoahNumberSeq.hpp" #include "gc/shared/workerDataArray.hpp" +#include "gc/shenandoah/shenandoahNumberSeq.hpp" +#include "jfr/jfrEvents.hpp" #include "memory/allocation.hpp" class ShenandoahCollectorPolicy; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp index 0e10e8c819f..2bbce179af8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp @@ -26,14 +26,14 @@ #include "classfile/javaClasses.hpp" #include "gc/shared/workerThread.hpp" -#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahClosures.inline.hpp" +#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" -#include "runtime/atomic.hpp" #include "logging/log.hpp" +#include "runtime/atomic.hpp" static ReferenceType reference_type(oop reference) { return InstanceKlass::cast(reference->klass())->reference_type(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp index b3b5109f6b3..8693046297d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp @@ -26,9 +26,9 @@ #include "classfile/classLoaderData.hpp" #include "code/nmethod.hpp" #include "gc/shenandoah/shenandoahClosures.inline.hpp" -#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" +#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" #include "gc/shenandoah/shenandoahStackWatermark.hpp" #include "memory/iterator.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp index f1544c1762e..fa3fa90b2f5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp @@ -29,11 +29,11 @@ #include "classfile/classLoaderDataGraph.hpp" #include "gc/shared/oopStorageSetParState.inline.hpp" +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "memory/resourceArea.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp index 4c7ae68fdbe..11ff92cd9cc 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp @@ -28,16 +28,16 @@ #include "classfile/classLoaderDataGraph.hpp" #include "code/codeCache.hpp" +#include "gc/shared/oopStorage.inline.hpp" +#include "gc/shared/oopStorageSet.hpp" #include "gc/shenandoah/shenandoahAsserts.hpp" -#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahRootVerifier.hpp" #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" #include "gc/shenandoah/shenandoahStringDedup.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" -#include "gc/shared/oopStorage.inline.hpp" -#include "gc/shared/oopStorageSet.hpp" #include "runtime/javaThread.hpp" #include "runtime/jniHandles.hpp" #include "runtime/threads.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp index 2984debd9f8..d2a5f71bca6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp @@ -26,8 +26,8 @@ #include "gc/shenandoah/shenandoahBarrierSetClone.inline.hpp" #include "gc/shenandoah/shenandoahRuntime.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#include "runtime/interfaceSupport.inline.hpp" #include "oops/oop.inline.hpp" +#include "runtime/interfaceSupport.inline.hpp" #include "utilities/copy.hpp" JRT_LEAF(void, ShenandoahRuntime::arraycopy_barrier_oop(oop* src, oop* dst, size_t length)) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp index b0fc55631e0..68bec5c2071 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp @@ -26,18 +26,19 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHSCANREMEMBEREDINLINE_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHSCANREMEMBEREDINLINE_HPP -#include "memory/iterator.hpp" -#include "oops/oop.hpp" -#include "oops/objArrayOop.hpp" +#include "gc/shenandoah/shenandoahScanRemembered.hpp" + #include "gc/shared/collectorCounters.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahCardStats.hpp" #include "gc/shenandoah/shenandoahCardTable.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" -#include "gc/shenandoah/shenandoahScanRemembered.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "logging/log.hpp" +#include "memory/iterator.hpp" +#include "oops/objArrayOop.hpp" +#include "oops/oop.hpp" // Process all objects starting within count clusters beginning with first_cluster and for which the start address is // less than end_of_range. For any non-array object whose header lies on a dirty card, scan the entire object, diff --git a/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.hpp index 55d21b06e4b..3a4cb8cf742 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahSimpleBitMap.hpp @@ -25,10 +25,10 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHSIMPLEBITMAP_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHSIMPLEBITMAP_HPP -#include - #include "gc/shenandoah/shenandoahAsserts.hpp" +#include + // TODO: Merge the enhanced capabilities of ShenandoahSimpleBitMap into src/hotspot/share/utilities/bitMap.hpp // and deprecate ShenandoahSimpleBitMap. The key enhanced capabilities to be integrated include: // diff --git a/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.inline.hpp index 042143254bc..1559dd81849 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.inline.hpp @@ -25,9 +25,10 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHSTRINGDEDUP_INLINE_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHSTRINGDEDUP_INLINE_HPP +#include "gc/shenandoah/shenandoahStringDedup.hpp" + #include "classfile/javaClasses.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" -#include "gc/shenandoah/shenandoahStringDedup.hpp" #include "oops/markWord.hpp" bool ShenandoahStringDedup::is_string_candidate(oop obj) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp index 10887ad8c19..342b599caf5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp @@ -26,8 +26,8 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP -#include "gc/shared/taskTerminator.hpp" #include "gc/shared/taskqueue.hpp" +#include "gc/shared/taskTerminator.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" #include "nmt/memTag.hpp" #include "runtime/atomic.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp index 933cc501562..c1cebdf1dde 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp @@ -26,16 +26,16 @@ #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP #define SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP -#include "gc/shared/plab.hpp" -#include "gc/shared/gcThreadLocalData.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcThreadLocalData.hpp" +#include "gc/shared/plab.hpp" +#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahCardTable.hpp" #include "gc/shenandoah/shenandoahCodeRoots.hpp" -#include "gc/shenandoah/shenandoahGenerationalHeap.hpp" #include "gc/shenandoah/shenandoahEvacTracker.hpp" +#include "gc/shenandoah/shenandoahGenerationalHeap.hpp" #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp" -#include "gc/shenandoah/mode/shenandoahMode.hpp" #include "runtime/javaThread.hpp" #include "utilities/debug.hpp" #include "utilities/sizes.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp index 6bd50154b4f..83151313f75 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp @@ -29,11 +29,11 @@ #include "code/codeBehaviours.hpp" #include "code/codeCache.hpp" #include "code/dependencyContext.hpp" -#include "gc/shared/gcBehaviours.hpp" #include "gc/shared/classUnloadingContext.hpp" +#include "gc/shared/gcBehaviours.hpp" #include "gc/shared/suspendibleThreadSet.hpp" -#include "gc/shenandoah/shenandoahNMethod.inline.hpp" #include "gc/shenandoah/shenandoahLock.hpp" +#include "gc/shenandoah/shenandoahNMethod.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahRootProcessor.hpp" #include "gc/shenandoah/shenandoahUnload.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp index ecca550d553..176baa133c8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp @@ -24,7 +24,6 @@ */ -#include "jfr/jfrEvents.hpp" #include "gc/shared/gcCause.hpp" #include "gc/shared/gcTrace.hpp" #include "gc/shared/gcWhen.hpp" @@ -36,6 +35,7 @@ #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" +#include "jfr/jfrEvents.hpp" #include "utilities/debug.hpp" ShenandoahPhaseTimings::Phase ShenandoahTimingsTracker::_current_phase = ShenandoahPhaseTimings::_invalid_phase; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp index fd30279d318..8a508c4afd8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.hpp @@ -37,8 +37,8 @@ #include "jfr/jfrEvents.hpp" #include "memory/allocation.hpp" #include "runtime/safepoint.hpp" -#include "runtime/vmThread.hpp" #include "runtime/vmOperations.hpp" +#include "runtime/vmThread.hpp" #include "services/memoryService.hpp" class GCTimer; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp index 37951c311ed..cdf78485207 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp @@ -27,11 +27,11 @@ #include "gc/shared/tlab_globals.hpp" #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahForwarding.inline.hpp" -#include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahOldGeneration.hpp" +#include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahRootProcessor.hpp" #include "gc/shenandoah/shenandoahScanRemembered.inline.hpp" #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahWorkGroup.cpp b/src/hotspot/share/gc/shenandoah/shenandoahWorkGroup.cpp index d6c47339f28..f2431a5ad0a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahWorkGroup.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahWorkGroup.cpp @@ -25,10 +25,9 @@ #include "gc/shenandoah/shenandoahHeap.inline.hpp" +#include "gc/shenandoah/shenandoahTaskqueue.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" #include "gc/shenandoah/shenandoahWorkGroup.hpp" -#include "gc/shenandoah/shenandoahTaskqueue.hpp" - #include "logging/log.hpp" #include "runtime/threads.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp b/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp index 8663515d019..daf5d456af5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.cpp @@ -22,13 +22,13 @@ * */ +#include "gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp" #include "gc/shenandoah/shenandoahAgeCensus.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahHeapRegionClosures.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahYoungGeneration.hpp" -#include "gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp" ShenandoahYoungGeneration::ShenandoahYoungGeneration(uint max_queues, size_t max_capacity, size_t soft_max_capacity) : ShenandoahGeneration(YOUNG, max_queues, max_capacity, soft_max_capacity), diff --git a/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp b/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp index 1237e28c06e..a8ebab507b6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahYoungGeneration.hpp @@ -25,8 +25,8 @@ #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHYOUNGGENERATION_HPP #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHYOUNGGENERATION_HPP -#include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp" +#include "gc/shenandoah/shenandoahGeneration.hpp" class ShenandoahYoungGeneration : public ShenandoahGeneration { private: diff --git a/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp b/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp index 851fa394722..a245f91fa71 100644 --- a/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp +++ b/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp @@ -24,9 +24,9 @@ #ifndef SHARE_GC_SHENANDOAH_VMSTRUCTS_SHENANDOAH_HPP #define SHARE_GC_SHENANDOAH_VMSTRUCTS_SHENANDOAH_HPP -#include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahGeneration.hpp" #include "gc/shenandoah/shenandoahGenerationalHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" diff --git a/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp b/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp index f3643c0a325..7bd24955910 100644 --- a/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp +++ b/src/hotspot/share/gc/z/c1/zBarrierSetC1.cpp @@ -21,12 +21,12 @@ * questions. */ +#include "c1/c1_CodeStubs.hpp" #include "c1/c1_FrameMap.hpp" #include "c1/c1_LIR.hpp" #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_LIRGenerator.hpp" #include "c1/c1_MacroAssembler.hpp" -#include "c1/c1_CodeStubs.hpp" #include "gc/z/c1/zBarrierSetC1.hpp" #include "gc/z/zBarrierSet.hpp" #include "gc/z/zBarrierSetAssembler.hpp" diff --git a/src/hotspot/share/gc/z/zHeapIterator.hpp b/src/hotspot/share/gc/z/zHeapIterator.hpp index fb58e3abe5f..2b570e98f1c 100644 --- a/src/hotspot/share/gc/z/zHeapIterator.hpp +++ b/src/hotspot/share/gc/z/zHeapIterator.hpp @@ -25,8 +25,8 @@ #define SHARE_GC_Z_ZHEAPITERATOR_HPP #include "gc/shared/collectedHeap.hpp" -#include "gc/shared/taskTerminator.hpp" #include "gc/shared/taskqueue.hpp" +#include "gc/shared/taskTerminator.hpp" #include "gc/z/zGranuleMap.hpp" #include "gc/z/zLock.hpp" #include "gc/z/zRootsIterator.hpp" diff --git a/src/hotspot/share/gc/z/zMarkContext.hpp b/src/hotspot/share/gc/z/zMarkContext.hpp index 009252e524d..788e17cae8f 100644 --- a/src/hotspot/share/gc/z/zMarkContext.hpp +++ b/src/hotspot/share/gc/z/zMarkContext.hpp @@ -24,8 +24,8 @@ #ifndef SHARE_GC_Z_ZMARKCONTEXT_HPP #define SHARE_GC_Z_ZMARKCONTEXT_HPP -#include "gc/z/zMarkCache.hpp" #include "gc/shared/stringdedup/stringDedup.hpp" +#include "gc/z/zMarkCache.hpp" #include "memory/allocation.hpp" class ZMarkStripe; diff --git a/src/hotspot/share/gc/z/zMarkingSMR.hpp b/src/hotspot/share/gc/z/zMarkingSMR.hpp index a6c5afe76c9..26670d95959 100644 --- a/src/hotspot/share/gc/z/zMarkingSMR.hpp +++ b/src/hotspot/share/gc/z/zMarkingSMR.hpp @@ -26,8 +26,8 @@ #include "gc/z/zArray.hpp" #include "gc/z/zValue.hpp" -#include "utilities/globalDefinitions.hpp" #include "memory/allocation.hpp" +#include "utilities/globalDefinitions.hpp" class ZMarkStackListNode; diff --git a/src/hotspot/share/gc/z/zNMT.cpp b/src/hotspot/share/gc/z/zNMT.cpp index 76e164308dd..1019bcfdd96 100644 --- a/src/hotspot/share/gc/z/zNMT.cpp +++ b/src/hotspot/share/gc/z/zNMT.cpp @@ -24,9 +24,9 @@ #include "gc/z/zAddress.inline.hpp" #include "gc/z/zGlobals.hpp" #include "gc/z/zNMT.hpp" +#include "nmt/memoryFileTracker.hpp" #include "nmt/memTag.hpp" #include "nmt/memTracker.hpp" -#include "nmt/memoryFileTracker.hpp" #include "utilities/nativeCallStack.hpp" MemoryFileTracker::MemoryFile* ZNMT::_device = nullptr; diff --git a/src/hotspot/share/gc/z/zNMT.hpp b/src/hotspot/share/gc/z/zNMT.hpp index b5b1aa07870..5fea74ee8ae 100644 --- a/src/hotspot/share/gc/z/zNMT.hpp +++ b/src/hotspot/share/gc/z/zNMT.hpp @@ -27,8 +27,8 @@ #include "gc/z/zAddress.hpp" #include "gc/z/zGlobals.hpp" #include "memory/allStatic.hpp" -#include "nmt/memTracker.hpp" #include "nmt/memoryFileTracker.hpp" +#include "nmt/memTracker.hpp" #include "utilities/globalDefinitions.hpp" class ZNMT : public AllStatic { diff --git a/src/hotspot/share/gc/z/zNMethod.cpp b/src/hotspot/share/gc/z/zNMethod.cpp index 4ae440ea231..bf592c20fa2 100644 --- a/src/hotspot/share/gc/z/zNMethod.cpp +++ b/src/hotspot/share/gc/z/zNMethod.cpp @@ -22,8 +22,8 @@ */ #include "code/codeCache.hpp" -#include "code/relocInfo.hpp" #include "code/nmethod.hpp" +#include "code/relocInfo.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/barrierSetNMethod.hpp" #include "gc/shared/classUnloadingContext.hpp" diff --git a/src/hotspot/share/gc/z/zNMethodTable.cpp b/src/hotspot/share/gc/z/zNMethodTable.cpp index 0aec0d5a9c7..bbc8f56b654 100644 --- a/src/hotspot/share/gc/z/zNMethodTable.cpp +++ b/src/hotspot/share/gc/z/zNMethodTable.cpp @@ -21,8 +21,8 @@ * questions. */ -#include "code/relocInfo.hpp" #include "code/nmethod.hpp" +#include "code/relocInfo.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/barrierSetNMethod.hpp" #include "gc/z/zHash.inline.hpp" diff --git a/src/hotspot/share/gc/z/zObjArrayAllocator.cpp b/src/hotspot/share/gc/z/zObjArrayAllocator.cpp index a4484ba1023..ddb0ca49278 100644 --- a/src/hotspot/share/gc/z/zObjArrayAllocator.cpp +++ b/src/hotspot/share/gc/z/zObjArrayAllocator.cpp @@ -21,8 +21,8 @@ * questions. */ -#include "gc/z/zThreadLocalData.hpp" #include "gc/z/zObjArrayAllocator.hpp" +#include "gc/z/zThreadLocalData.hpp" #include "gc/z/zUtils.inline.hpp" #include "oops/arrayKlass.hpp" #include "runtime/interfaceSupport.inline.hpp" diff --git a/src/hotspot/share/gc/z/zRuntimeWorkers.cpp b/src/hotspot/share/gc/z/zRuntimeWorkers.cpp index f19e5cd5469..c8c4cde9ba0 100644 --- a/src/hotspot/share/gc/z/zRuntimeWorkers.cpp +++ b/src/hotspot/share/gc/z/zRuntimeWorkers.cpp @@ -21,8 +21,8 @@ * questions. */ -#include "gc/shared/gcLogPrecious.hpp" #include "gc/shared/gc_globals.hpp" +#include "gc/shared/gcLogPrecious.hpp" #include "gc/z/zRuntimeWorkers.hpp" #include "runtime/java.hpp" diff --git a/src/hotspot/share/gc/z/zStat.cpp b/src/hotspot/share/gc/z/zStat.cpp index 558ccdf105a..a6b2bd0930d 100644 --- a/src/hotspot/share/gc/z/zStat.cpp +++ b/src/hotspot/share/gc/z/zStat.cpp @@ -24,9 +24,9 @@ #include "gc/shared/gc_globals.hpp" #include "gc/z/zAbort.inline.hpp" #include "gc/z/zCollectedHeap.hpp" +#include "gc/z/zCPU.inline.hpp" #include "gc/z/zDirector.hpp" #include "gc/z/zDriver.hpp" -#include "gc/z/zCPU.inline.hpp" #include "gc/z/zGeneration.inline.hpp" #include "gc/z/zGlobals.hpp" #include "gc/z/zNMethodTable.hpp" diff --git a/src/hotspot/share/gc/z/zUncoloredRoot.inline.hpp b/src/hotspot/share/gc/z/zUncoloredRoot.inline.hpp index f0b3dfcb42c..0d9fccde87c 100644 --- a/src/hotspot/share/gc/z/zUncoloredRoot.inline.hpp +++ b/src/hotspot/share/gc/z/zUncoloredRoot.inline.hpp @@ -27,9 +27,9 @@ #include "gc/z/zUncoloredRoot.hpp" #include "gc/z/zAddress.inline.hpp" +#include "gc/z/zBarrier.hpp" #include "gc/z/zBarrier.inline.hpp" #include "gc/z/zHeap.inline.hpp" -#include "gc/z/zBarrier.hpp" #include "oops/oop.hpp" template diff --git a/src/hotspot/share/gc/z/zVerify.cpp b/src/hotspot/share/gc/z/zVerify.cpp index 117d27997ee..68290c2c009 100644 --- a/src/hotspot/share/gc/z/zVerify.cpp +++ b/src/hotspot/share/gc/z/zVerify.cpp @@ -32,8 +32,8 @@ #include "gc/z/zResurrection.hpp" #include "gc/z/zRootsIterator.hpp" #include "gc/z/zStackWatermark.hpp" -#include "gc/z/zStoreBarrierBuffer.inline.hpp" #include "gc/z/zStat.hpp" +#include "gc/z/zStoreBarrierBuffer.inline.hpp" #include "gc/z/zVerify.hpp" #include "memory/allocation.hpp" #include "memory/iterator.inline.hpp" diff --git a/src/hotspot/share/gc/z/zVirtualMemoryManager.inline.hpp b/src/hotspot/share/gc/z/zVirtualMemoryManager.inline.hpp index 78f966d0f84..27159b4eff8 100644 --- a/src/hotspot/share/gc/z/zVirtualMemoryManager.inline.hpp +++ b/src/hotspot/share/gc/z/zVirtualMemoryManager.inline.hpp @@ -26,8 +26,8 @@ #include "gc/z/zVirtualMemoryManager.hpp" -#include "utilities/globalDefinitions.hpp" #include "gc/z/zRangeRegistry.inline.hpp" +#include "utilities/globalDefinitions.hpp" inline bool ZVirtualMemoryManager::is_multi_partition_enabled() const { From 82c249446f2bd6f3b0e612c5ef3e6bfcab388c3b Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Wed, 23 Apr 2025 10:40:45 +0000 Subject: [PATCH 074/901] 8354228: Parallel: Set correct minimum of InitialSurvivorRatio Reviewed-by: tschatzl, gli --- .../share/gc/parallel/parallelArguments.cpp | 23 ++++++++++--------- src/hotspot/share/gc/shared/gc_globals.hpp | 2 +- .../TestMinAndInitialSurvivorRatioFlags.java | 2 -- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/hotspot/share/gc/parallel/parallelArguments.cpp b/src/hotspot/share/gc/parallel/parallelArguments.cpp index 6309f52c82e..2cddbafd871 100644 --- a/src/hotspot/share/gc/parallel/parallelArguments.cpp +++ b/src/hotspot/share/gc/parallel/parallelArguments.cpp @@ -66,6 +66,18 @@ void ParallelArguments::initialize() { } } + if (InitialSurvivorRatio < MinSurvivorRatio) { + if (FLAG_IS_CMDLINE(InitialSurvivorRatio)) { + if (FLAG_IS_CMDLINE(MinSurvivorRatio)) { + jio_fprintf(defaultStream::error_stream(), + "Inconsistent MinSurvivorRatio vs InitialSurvivorRatio: %d vs %d\n", MinSurvivorRatio, InitialSurvivorRatio); + } + FLAG_SET_DEFAULT(MinSurvivorRatio, InitialSurvivorRatio); + } else { + FLAG_SET_DEFAULT(InitialSurvivorRatio, MinSurvivorRatio); + } + } + // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the // SurvivorRatio has been set, reset their default values to SurvivorRatio + // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger. @@ -101,17 +113,6 @@ void ParallelArguments::initialize_alignments() { void ParallelArguments::initialize_heap_flags_and_sizes_one_pass() { // Do basic sizing work GenArguments::initialize_heap_flags_and_sizes(); - - // The survivor ratio's are calculated "raw", unlike the - // default gc, which adds 2 to the ratio value. We need to - // make sure the values are valid before using them. - if (MinSurvivorRatio < 3) { - FLAG_SET_ERGO(MinSurvivorRatio, 3); - } - - if (InitialSurvivorRatio < 3) { - FLAG_SET_ERGO(InitialSurvivorRatio, 3); - } } void ParallelArguments::initialize_heap_flags_and_sizes() { diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index ba29daf2fe1..56b8bc4e4ff 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -412,7 +412,7 @@ \ product(uintx, InitialSurvivorRatio, 8, \ "Initial ratio of young generation/survivor space size") \ - range(0, max_uintx) \ + range(3, max_uintx) \ \ product(bool, UseGCOverheadLimit, true, \ "Use policy to limit of proportion of time spent in GC " \ diff --git a/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java b/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java index 0e91f7f20ab..5f585575e7a 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java @@ -65,8 +65,6 @@ public static void main(String args[]) throws Exception { testSurvivorRatio(-1, 15, 3, options, true); testSurvivorRatio(-1, 15, 3, options, false); testSurvivorRatio(-1, 10, 10, options, true); - testSurvivorRatio(-1, 3, 15, options, true); - testSurvivorRatio(-1, 3, 15, options, false); } /** From ef0cd1823d7d57e42e66255a0e80bfa495a7102d Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Wed, 23 Apr 2025 11:48:48 +0000 Subject: [PATCH 075/901] 8354949: JFR: Split up the EventInstrumentation class Reviewed-by: mgronlun, liach --- .../jdk/jfr/internal/ClassInspector.java | 361 +++++++++ .../jfr/internal/EventInstrumentation.java | 759 ++++++------------ .../classes/jdk/jfr/internal/JVMUpcalls.java | 16 +- .../jdk/jfr/internal/util/Bytecode.java | 9 +- .../jdk/jfr/internal/util/ImplicitFields.java | 5 +- 5 files changed, 621 insertions(+), 529 deletions(-) create mode 100644 src/jdk.jfr/share/classes/jdk/jfr/internal/ClassInspector.java diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/ClassInspector.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/ClassInspector.java new file mode 100644 index 00000000000..e7e0eac54ff --- /dev/null +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/ClassInspector.java @@ -0,0 +1,361 @@ +/* + * Copyright (c) 2016, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jfr.internal; + +import static jdk.jfr.internal.util.Bytecode.classDesc; + +import java.lang.classfile.Annotation; +import java.lang.classfile.AnnotationElement; +import java.lang.classfile.AnnotationValue; +import java.lang.classfile.Attribute; +import java.lang.classfile.ClassFile; +import java.lang.classfile.ClassModel; +import java.lang.classfile.FieldModel; +import java.lang.classfile.MethodModel; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.constant.ClassDesc; +import java.lang.constant.MethodTypeDesc; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.constant.ConstantDescs; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import jdk.jfr.Enabled; +import jdk.jfr.Name; +import jdk.jfr.Registered; +import jdk.jfr.SettingControl; +import jdk.jfr.SettingDefinition; +import jdk.jfr.internal.util.Bytecode; +import jdk.jfr.internal.util.ImplicitFields; +import jdk.jfr.internal.util.Bytecode.FieldDesc; +import jdk.jfr.internal.util.Bytecode.MethodDesc; +import jdk.jfr.internal.util.Bytecode.SettingDesc; +import jdk.jfr.internal.util.Utils; + +final class ClassInspector { + private static final ClassDesc TYPE_SETTING_DEFINITION = Bytecode.classDesc(SettingDefinition.class); + private static final ClassDesc ANNOTATION_REGISTERED = classDesc(Registered.class); + private static final ClassDesc ANNOTATION_NAME = classDesc(Name.class); + private static final ClassDesc ANNOTATION_ENABLED = classDesc(Enabled.class); + private static final ClassDesc ANNOTATION_REMOVE_FIELDS = classDesc(RemoveFields.class); + + private final ClassModel classModel; + private final Class superClass; + private final boolean isJDK; + private final ImplicitFields implicitFields; + private final List settingsDescs = new ArrayList<>(); + private final List fieldDescs = new ArrayList<>(); + private final String className; + + ClassInspector(Class superClass, byte[] bytes, boolean isJDK) { + this.superClass = superClass; + this.classModel = ClassFile.of().parse(bytes); + this.isJDK = isJDK; + this.className = classModel.thisClass().asInternalName().replace("/", "."); + this.implicitFields = determineImplicitFields(); + } + + String getClassName() { + return className; + } + + MethodDesc findStaticCommitMethod() { + if (!isJDK) { + return null; + } + StringBuilder sb = new StringBuilder(); + sb.append("("); + for (FieldDesc field : fieldDescs) { + sb.append(field.type().descriptorString()); + } + sb.append(")V"); + MethodDesc m = MethodDesc.of("commit", sb.toString()); + for (MethodModel method : classModel.methods()) { + if (m.matches(method)) { + return m; + } + } + return null; + } + + String getEventName() { + String name = annotationValue(ANNOTATION_NAME, String.class); + return name == null ? getClassName() : name; + } + + boolean isRegistered() { + Boolean result = annotationValue(ANNOTATION_REGISTERED, Boolean.class); + if (result != null) { + return result.booleanValue(); + } + if (superClass != null) { + Registered r = superClass.getAnnotation(Registered.class); + if (r != null) { + return r.value(); + } + } + return true; + } + + boolean isEnabled() { + Boolean result = annotationValue(ANNOTATION_ENABLED, Boolean.class); + if (result != null) { + return result.booleanValue(); + } + if (superClass != null) { + Enabled e = superClass.getAnnotation(Enabled.class); + if (e != null) { + return e.value(); + } + } + return true; + } + + boolean hasStaticMethod(MethodDesc method) { + for (MethodModel m : classModel.methods()) { + if (Modifier.isStatic(m.flags().flagsMask())) { + return method.matches(m); + } + } + return false; + } + + static boolean isValidField(int access, ClassDesc classDesc) { + String className = classDesc.packageName(); + if (!className.isEmpty()) { + className = className + "."; + } + className += classDesc.displayName(); + return isValidField(access, className); + } + + static boolean isValidField(int access, String className) { + if (Modifier.isTransient(access) || Modifier.isStatic(access)) { + return false; + } + return Type.isValidJavaFieldType(className); + } + + List getSettings() { + return settingsDescs; + } + + List getFields() { + return fieldDescs; + } + + boolean hasDuration() { + return implicitFields.hasDuration(); + } + + boolean hasStackTrace() { + return implicitFields.hasStackTrace(); + } + + boolean hasEventThread() { + return implicitFields.hasEventThread(); + } + + ClassDesc getClassDesc() { + return classModel.thisClass().asSymbol(); + } + + ClassModel getClassModel() { + return classModel; + } + + boolean isJDK() { + return isJDK; + } + + private ImplicitFields determineImplicitFields() { + if (isJDK) { + Class eventClass = MirrorEvents.find(isJDK, getClassName()); + if (eventClass != null) { + return new ImplicitFields(eventClass); + } + } + ImplicitFields ifs = new ImplicitFields(superClass); + String[] value = annotationValue(ANNOTATION_REMOVE_FIELDS, String[].class); + if (value != null) { + ifs.removeFields(value); + } + return ifs; + } + + private List getAnnotationValues(ClassDesc classDesc) { + List list = new ArrayList<>(); + for (Attribute attribute: classModel.attributes()) { + if (attribute instanceof RuntimeVisibleAnnotationsAttribute rvaa) { + for (Annotation a : rvaa.annotations()) { + if (a.classSymbol().equals(classDesc) && a.elements().size() == 1) { + AnnotationElement ae = a.elements().getFirst(); + if (ae.name().equalsString("value")) { + list.add(ae.value()); + } + } + } + } + } + return list; + } + + @SuppressWarnings("unchecked") + // Only supports String, String[] and Boolean values + private T annotationValue(ClassDesc classDesc, Class type) { + for (AnnotationValue a : getAnnotationValues(classDesc)) { + if (a instanceof AnnotationValue.OfBoolean ofb && type.equals(Boolean.class)) { + Boolean b = ofb.booleanValue(); + return (T) b; + } + if (a instanceof AnnotationValue.OfString ofs && type.equals(String.class)) { + String s = ofs.stringValue(); + return (T) s; + } + if (a instanceof AnnotationValue.OfArray ofa && type.equals(String[].class)) { + List list = ofa.values(); + String[] array = new String[list.size()]; + int index = 0; + for (AnnotationValue av : list) { + var avs = (AnnotationValue.OfString) av; + array[index++] = avs.stringValue(); + } + return (T) array; + } + } + return null; + } + + void buildSettings() { + Set foundMethods = new HashSet<>(); + buildClassSettings(foundMethods); + buildSuperClassSettings(foundMethods); + } + + private void buildClassSettings(Set foundMethods) { + for (MethodModel m : classModel.methods()) { + for (Attribute attribute : m.attributes()) { + if (attribute instanceof RuntimeVisibleAnnotationsAttribute rvaa) { + for (Annotation a : rvaa.annotations()) { + // We can't really validate the method at this + // stage. We would need to check that the parameter + // is an instance of SettingControl. + if (a.classSymbol().equals(TYPE_SETTING_DEFINITION)) { + String name = m.methodName().stringValue(); + // Use @Name if it exists + for (Annotation nameCandidate : rvaa.annotations()) { + if (nameCandidate.className().equalsString(ANNOTATION_NAME.descriptorString())) { + if (nameCandidate.elements().size() == 1) { + AnnotationElement ae = nameCandidate.elements().getFirst(); + if (ae.name().equalsString("value")) { + if (ae.value() instanceof AnnotationValue.OfString s) { + name = Utils.validJavaIdentifier(s.stringValue(), name); + } + } + } + } + } + // Add setting if method returns boolean and has one parameter + MethodTypeDesc mtd = m.methodTypeSymbol(); + if (ConstantDescs.CD_boolean.equals(mtd.returnType())) { + if (mtd.parameterList().size() == 1) { + ClassDesc type = mtd.parameterList().getFirst(); + if (type.isClassOrInterface()) { + String methodName = m.methodName().stringValue(); + foundMethods.add(methodName); + settingsDescs.add(new SettingDesc(type, methodName)); + } + } + } + } + } + } + } + } + } + + private void buildSuperClassSettings(Set foundMethods) { + for (Class c = superClass; jdk.internal.event.Event.class != c; c = c.getSuperclass()) { + for (java.lang.reflect.Method method : c.getDeclaredMethods()) { + if (!foundMethods.contains(method.getName())) { + buildSettingsMethod(foundMethods, method); + } + } + } + } + + private void buildSettingsMethod(Set foundMethods, java.lang.reflect.Method method) { + // Skip private methods in base classes + if (!Modifier.isPrivate(method.getModifiers())) { + if (method.getReturnType().equals(Boolean.TYPE)) { + if (method.getParameterCount() == 1) { + Class type = method.getParameters()[0].getType(); + if (SettingControl.class.isAssignableFrom(type)) { + ClassDesc paramType = Bytecode.classDesc(type); + foundMethods.add(method.getName()); + settingsDescs.add(new SettingDesc(paramType, method.getName())); + } + } + } + } + } + + void buildFields() { + Set foundFields = new HashSet<>(); + // These two fields are added by native as 'transient' so they will be + // ignored by the loop below. + // The benefit of adding them manually is that we can + // control in which order they occur and we can add @Name, @Description + // in Java, instead of in native. It also means code for adding implicit + // fields for native can be reused by Java. + fieldDescs.add(ImplicitFields.FIELD_START_TIME); + if (implicitFields.hasDuration()) { + fieldDescs.add(ImplicitFields.FIELD_DURATION); + } + for (FieldModel field : classModel.fields()) { + if (!foundFields.contains(field.fieldName().stringValue()) && isValidField(field.flags().flagsMask(), field.fieldTypeSymbol())) { + fieldDescs.add(FieldDesc.of(field.fieldTypeSymbol(), field.fieldName().stringValue())); + foundFields.add(field.fieldName().stringValue()); + } + } + for (Class c = superClass; jdk.internal.event.Event.class != c; c = c.getSuperclass()) { + for (Field field : c.getDeclaredFields()) { + // Skip private fields in base classes + if (!Modifier.isPrivate(field.getModifiers())) { + if (isValidField(field.getModifiers(), field.getType().getName())) { + String fieldName = field.getName(); + if (!foundFields.contains(fieldName)) { + fieldDescs.add(FieldDesc.of(field.getType(), fieldName)); + foundFields.add(fieldName); + } + } + } + } + } + } +} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java index 7567aea664c..96e6f36e5c8 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java @@ -25,71 +25,49 @@ package jdk.jfr.internal; -import java.lang.constant.ClassDesc; -import java.lang.constant.MethodTypeDesc; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; +import static jdk.jfr.internal.util.Bytecode.classDesc; +import static jdk.jfr.internal.util.Bytecode.getfield; +import static jdk.jfr.internal.util.Bytecode.invokestatic; +import static jdk.jfr.internal.util.Bytecode.invokevirtual; +import static jdk.jfr.internal.util.Bytecode.putfield; -import java.lang.classfile.Annotation; -import java.lang.classfile.AnnotationElement; -import java.lang.classfile.AnnotationValue; +import java.lang.classfile.ClassBuilder; import java.lang.classfile.ClassElement; -import java.lang.classfile.ClassModel; import java.lang.classfile.ClassFile; import java.lang.classfile.CodeBuilder; import java.lang.classfile.CodeBuilder.BlockCodeBuilder; import java.lang.classfile.FieldModel; import java.lang.classfile.Label; import java.lang.classfile.MethodModel; +import java.lang.classfile.MethodTransform; import java.lang.classfile.TypeKind; -import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; -import jdk.jfr.internal.event.EventConfiguration; -import jdk.jfr.internal.event.EventWriter; -import jdk.jfr.Enabled; +import java.lang.constant.ClassDesc; +import java.lang.constant.MethodTypeDesc; +import java.util.List; +import java.util.function.Consumer; + import jdk.jfr.Event; -import jdk.jfr.Name; -import jdk.jfr.Registered; import jdk.jfr.SettingControl; -import jdk.jfr.SettingDefinition; -import jdk.jfr.internal.util.Utils; +import jdk.jfr.internal.event.EventConfiguration; +import jdk.jfr.internal.event.EventWriter; import jdk.jfr.internal.util.Bytecode; -import jdk.jfr.internal.util.ImplicitFields; import jdk.jfr.internal.util.Bytecode.FieldDesc; import jdk.jfr.internal.util.Bytecode.MethodDesc; -import static jdk.jfr.internal.util.Bytecode.invokevirtual; -import static jdk.jfr.internal.util.Bytecode.invokestatic; -import static jdk.jfr.internal.util.Bytecode.getfield; -import static jdk.jfr.internal.util.Bytecode.putfield; -import static jdk.jfr.internal.util.Bytecode.classDesc; +import jdk.jfr.internal.util.Bytecode.SettingDesc; +import jdk.jfr.internal.util.ImplicitFields; /** * Class responsible for adding instrumentation to a subclass of {@link Event}. * */ final class EventInstrumentation { + private static final FieldDesc FIELD_EVENT_CONFIGURATION = FieldDesc.of(Object.class, "eventConfiguration"); - private record SettingDesc(ClassDesc paramType, String methodName) { - } - - private static final FieldDesc FIELD_DURATION = FieldDesc.of(long.class, ImplicitFields.DURATION); - private static final FieldDesc FIELD_EVENT_CONFIGURATION = FieldDesc.of(Object.class, "eventConfiguration");; - private static final FieldDesc FIELD_START_TIME = FieldDesc.of(long.class, ImplicitFields.START_TIME); - private static final ClassDesc ANNOTATION_ENABLED = classDesc(Enabled.class); - private static final ClassDesc ANNOTATION_NAME = classDesc(Name.class); - private static final ClassDesc ANNOTATION_REGISTERED = classDesc(Registered.class); - private static final ClassDesc ANNOTATION_REMOVE_FIELDS = classDesc(RemoveFields.class); private static final ClassDesc TYPE_EVENT_CONFIGURATION = classDesc(EventConfiguration.class); - private static final ClassDesc TYPE_ISE = Bytecode.classDesc(IllegalStateException.class); + private static final ClassDesc TYPE_ISE = classDesc(IllegalStateException.class); private static final ClassDesc TYPE_EVENT_WRITER = classDesc(EventWriter.class); - private static final ClassDesc TYPE_OBJECT = Bytecode.classDesc(Object.class); - private static final ClassDesc TYPE_SETTING_DEFINITION = Bytecode.classDesc(SettingDefinition.class); + private static final ClassDesc TYPE_OBJECT = classDesc(Object.class); + private static final MethodDesc METHOD_BEGIN = MethodDesc.of("begin", "()V"); private static final MethodDesc METHOD_COMMIT = MethodDesc.of("commit", "()V"); private static final MethodDesc METHOD_DURATION = MethodDesc.of("duration", "(J)J"); @@ -104,446 +82,242 @@ private record SettingDesc(ClassDesc paramType, String methodName) { private static final MethodDesc METHOD_SHOULD_COMMIT_LONG = MethodDesc.of("shouldCommit", "(J)Z"); private static final MethodDesc METHOD_TIME_STAMP = MethodDesc.of("timestamp", "()J"); - private final ClassModel classModel; - private final List settingDescs; - private final List fieldDescs;; - private final String eventName; - private final String className; - private final Class superClass; - private final boolean untypedEventConfiguration; - private final MethodDesc staticCommitMethod; + private final ClassInspector inspector; private final long eventTypeId; + private final ClassDesc eventClassDesc; + private final MethodDesc staticCommitMethod; + private final boolean untypedEventConfiguration; private final boolean guardEventConfiguration; - private final boolean isJDK; - private final Map> methodUpdates = new LinkedHashMap<>(); - private final ImplicitFields implicitFields; - EventInstrumentation(Class superClass, byte[] bytes, long id, boolean isJDK, boolean guardEventConfiguration) { + /** + * Creates an EventInstrumentation object. + * + * @param inspector class inspector + * @param id the event type ID to use + * @param guardEventConfiguration guard against event configuration being null. + * Needed when instrumentation is added before + * registration (bytesForEagerInstrumentation) + */ + EventInstrumentation(ClassInspector inspector, long id, boolean guardEventConfiguration) { + inspector.buildFields(); + if (!inspector.isJDK()) { + // Only user-defined events have custom settings. + inspector.buildSettings(); + } + this.inspector = inspector; this.eventTypeId = id; - this.superClass = superClass; - this.isJDK = isJDK; - this.classModel = createClassModel(bytes); - this.className = classModel.thisClass().asInternalName().replace("/", "."); - String name = annotationValue(classModel, ANNOTATION_NAME, String.class); - this.eventName = name == null ? className : name; - this.implicitFields = determineImplicitFields(); - this.settingDescs = buildSettingDescs(superClass, classModel); - this.fieldDescs = buildFieldDescs(superClass, classModel); - this.staticCommitMethod = isJDK ? findStaticCommitMethod(classModel, fieldDescs) : null; - this.untypedEventConfiguration = hasUntypedConfiguration(); - // Corner case when we are forced to generate bytecode - // (bytesForEagerInstrumentation) - // We can't reference EventConfiguration::isEnabled() before event class has - // been registered, - // so we add a guard against a null reference. this.guardEventConfiguration = guardEventConfiguration; + this.eventClassDesc = inspector.getClassDesc(); + this.staticCommitMethod = inspector.findStaticCommitMethod(); + this.untypedEventConfiguration = hasUntypedConfiguration(); } - private ImplicitFields determineImplicitFields() { - if (isJDK) { - Class eventClass = MirrorEvents.find(isJDK, className); - if (eventClass != null) { - return new ImplicitFields(eventClass); - } - } - ImplicitFields ifs = new ImplicitFields(superClass); - String[] value = annotationValue(classModel, ANNOTATION_REMOVE_FIELDS, String[].class); - if (value != null) { - ifs.removeFields(value); - } - return ifs; + byte[] buildInstrumented() { + return ClassFile.of().transformClass(inspector.getClassModel(), this::transform); } - static MethodDesc findStaticCommitMethod(ClassModel classModel, List fields) { - StringBuilder sb = new StringBuilder(); - sb.append("("); - for (FieldDesc field : fields) { - sb.append(field.type().descriptorString()); - } - sb.append(")V"); - MethodDesc m = MethodDesc.of("commit", sb.toString()); - for (MethodModel method : classModel.methods()) { - String d = method.methodTypeSymbol().descriptorString(); - if (method.methodName().equalsString("commit") && m.descriptor().descriptorString().equals(d)) { - return m; - } + private void transform(ClassBuilder clb, ClassElement cle) { + if (cle instanceof MethodModel method && instrumentable(method) instanceof Consumer modification) { + clb.transformMethod(method, MethodTransform.transformingCode((codeBuilder, _) -> modification.accept(codeBuilder))); + } else { + clb.with(cle); } - return null; } - private boolean hasUntypedConfiguration() { - for (FieldModel f : classModel.fields()) { - if (f.fieldName().equalsString(FIELD_EVENT_CONFIGURATION.name())) { - return f.fieldType().equalsString(TYPE_OBJECT.descriptorString()); - } + private Consumer instrumentable(MethodModel method) { + if (isMethod(method, METHOD_IS_ENABLED)) { + return this::methodIsEnabled; } - throw new InternalError("Class missing configuration field"); - } - - public String getClassName() { - return classModel.thisClass().asInternalName().replace("/", "."); - } - - private ClassModel createClassModel(byte[] bytes) { - return ClassFile.of().parse(bytes); - } - - boolean isRegistered() { - Boolean result = annotationValue(classModel, ANNOTATION_REGISTERED, Boolean.class); - if (result != null) { - return result.booleanValue(); + if (isMethod(method, METHOD_BEGIN)) { + return this::methodBegin; } - if (superClass != null) { - Registered r = superClass.getAnnotation(Registered.class); - if (r != null) { - return r.value(); - } + if (isMethod(method, METHOD_END)) { + return this::methodEnd; } - return true; - } - - boolean isEnabled() { - Boolean result = annotationValue(classModel, ANNOTATION_ENABLED, Boolean.class); - if (result != null) { - return result.booleanValue(); + if (isMethod(method, METHOD_EVENT_SHOULD_COMMIT)) { + return this::methodShouldCommit; } - if (superClass != null) { - Enabled e = superClass.getAnnotation(Enabled.class); - if (e != null) { - return e.value(); - } + if (staticCommitMethod == null && isMethod(method, METHOD_COMMIT)) { + return this::methodCommit; } - return true; - } - - @SuppressWarnings("unchecked") - // Only supports String, String[] and Boolean values - private static T annotationValue(ClassModel classModel, ClassDesc classDesc, Class type) { - String typeDescriptor = classDesc.descriptorString(); - for (ClassElement ce : classModel) { - if (ce instanceof RuntimeVisibleAnnotationsAttribute rvaa) { - for (Annotation a : rvaa.annotations()) { - if (a.className().equalsString(typeDescriptor)) { - if (a.elements().size() == 1) { - AnnotationElement ae = a.elements().getFirst(); - if (ae.name().equalsString("value")) { - if (ae.value() instanceof AnnotationValue.OfBoolean ofb && type.equals(Boolean.class)) { - Boolean b = ofb.booleanValue(); - return (T)b; - } - if (ae.value() instanceof AnnotationValue.OfString ofs && type.equals(String.class)) { - String s = ofs.stringValue(); - return (T)s; - } - if (ae.value() instanceof AnnotationValue.OfArray ofa && type.equals(String[].class)) { - List list = ofa.values(); - String[] array = new String[list.size()]; - int index = 0; - for (AnnotationValue av : list) { - var avs = (AnnotationValue.OfString)av; - array[index++] = avs.stringValue(); - } - return (T)array; - } - } - } - } - } + if (inspector.isJDK() && isStatic(method)) { + if (isMethod(method, METHOD_ENABLED)) { + return this::methodEnabledStatic; } - } - return null; - } - - private static List buildSettingDescs(Class superClass, ClassModel classModel) { - Set methodSet = new HashSet<>(); - List settingDescs = new ArrayList<>(); - for (MethodModel m : classModel.methods()) { - for (var me : m) { - if (me instanceof RuntimeVisibleAnnotationsAttribute rvaa) { - for (Annotation a : rvaa.annotations()) { - // We can't really validate the method at this - // stage. We would need to check that the parameter - // is an instance of SettingControl. - if (a.className().equalsString(TYPE_SETTING_DEFINITION.descriptorString())) { - String name = m.methodName().stringValue(); - // Use @Name if it exists - for (Annotation nameCandidate : rvaa.annotations()) { - if (nameCandidate.className().equalsString(ANNOTATION_NAME.descriptorString())) { - if (nameCandidate.elements().size() == 1) { - AnnotationElement ae = nameCandidate.elements().getFirst(); - if (ae.name().equalsString("value")) { - if (ae.value() instanceof AnnotationValue.OfString s) { - name = Utils.validJavaIdentifier(s.stringValue(), name); - } - } - } - } - } - // Add setting if method returns boolean and has one parameter - MethodTypeDesc mtd = m.methodTypeSymbol(); - if ("Z".equals(mtd.returnType().descriptorString())) { - if (mtd.parameterList().size() == 1) { - ClassDesc type = mtd.parameterList().getFirst(); - if (type.isClassOrInterface()) { - String methodName = m.methodName().stringValue(); - methodSet.add(methodName); - settingDescs.add(new SettingDesc(type, methodName)); - } - } - } - } - } - } + if (isMethod(method, METHOD_SHOULD_COMMIT_LONG)) { + return this::methodShouldCommitStatic; } - } - for (Class c = superClass; jdk.internal.event.Event.class != c; c = c.getSuperclass()) { - for (java.lang.reflect.Method method : c.getDeclaredMethods()) { - if (!methodSet.contains(method.getName())) { - // skip private method in base classes - if (!Modifier.isPrivate(method.getModifiers())) { - if (method.getReturnType().equals(Boolean.TYPE)) { - if (method.getParameterCount() == 1) { - Class type = method.getParameters()[0].getType(); - if (SettingControl.class.isAssignableFrom(type)) { - ClassDesc paramType = Bytecode.classDesc(type); - methodSet.add(method.getName()); - settingDescs.add(new SettingDesc(paramType, method.getName())); - } - } - } - } - } + if (isMethod(method, METHOD_TIME_STAMP)) { + return this::methodTimestamp; + } + if (staticCommitMethod != null && isMethod(method, staticCommitMethod)) { + return this::methodCommit; } } - return settingDescs; + return null; } - private List buildFieldDescs(Class superClass, ClassModel classModel) { - Set fieldSet = new HashSet<>(); - List fieldDescs = new ArrayList<>(classModel.fields().size()); - // These two fields are added by native as 'transient' so they will be - // ignored by the loop below. - // The benefit of adding them manually is that we can - // control in which order they occur and we can add @Name, @Description - // in Java, instead of in native. It also means code for adding implicit - // fields for native can be reused by Java. - fieldDescs.add(FIELD_START_TIME); - if (implicitFields.hasDuration()) { - fieldDescs.add(FIELD_DURATION); - } - for (FieldModel field : classModel.fields()) { - if (!fieldSet.contains(field.fieldName().stringValue()) && isValidField(field.flags().flagsMask(), field.fieldTypeSymbol())) { - FieldDesc fi = FieldDesc.of(field.fieldTypeSymbol(), field.fieldName().stringValue()); - fieldDescs.add(fi); - fieldSet.add(field.fieldName().stringValue()); - } + private void methodIsEnabled(CodeBuilder codeBuilder) { + Label nullLabel = codeBuilder.newLabel(); + if (guardEventConfiguration) { + getEventConfiguration(codeBuilder); + codeBuilder.ifnull(nullLabel); } - for (Class c = superClass; jdk.internal.event.Event.class != c; c = c.getSuperclass()) { - for (Field field : c.getDeclaredFields()) { - // skip private field in base classes - if (!Modifier.isPrivate(field.getModifiers())) { - if (isValidField(field.getModifiers(), field.getType().getName())) { - String fieldName = field.getName(); - if (!fieldSet.contains(fieldName)) { - fieldDescs.add(FieldDesc.of(field.getType(), fieldName)); - fieldSet.add(fieldName); - } - } - } - } + getEventConfiguration(codeBuilder); + invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_IS_ENABLED); + codeBuilder.ireturn(); + if (guardEventConfiguration) { + codeBuilder.labelBinding(nullLabel); + codeBuilder.iconst_0(); + codeBuilder.ireturn(); } - return fieldDescs; } - public static boolean isValidField(int access, ClassDesc classDesc) { - String className = classDesc.packageName(); - if (!className.isEmpty()) { - className = className + "."; + private void methodBegin(CodeBuilder codeBuilder) { + if (!inspector.hasDuration()) { + throwMissingDuration(codeBuilder, "begin"); + } else { + codeBuilder.aload(0); + invokestatic(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_TIME_STAMP); + putfield(codeBuilder, eventClassDesc, ImplicitFields.FIELD_START_TIME); + codeBuilder.return_(); } - className += classDesc.displayName(); - return isValidField(access, className); } - public static boolean isValidField(int access, String className) { - if (Modifier.isTransient(access) || Modifier.isStatic(access)) { - return false; + private void methodEnd(CodeBuilder codeBuilder) { + if (!inspector.hasDuration()) { + throwMissingDuration(codeBuilder, "end"); + } else { + codeBuilder.aload(0); + codeBuilder.aload(0); + getfield(codeBuilder, eventClassDesc, ImplicitFields.FIELD_START_TIME); + invokestatic(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_DURATION); + putfield(codeBuilder, eventClassDesc, ImplicitFields.FIELD_DURATION); + codeBuilder.return_(); } - return Type.isValidJavaFieldType(className); - } - - public byte[] buildInstrumented() { - makeInstrumented(); - return toByteArray(); } - byte[] toByteArray() { - return ClassFile.of().build(classModel.thisClass().asSymbol(), classBuilder -> { - for (ClassElement ce : classModel) { - boolean updated = false; - if (ce instanceof MethodModel method) { - Consumer methodUpdate = findMethodUpdate(method); - if (methodUpdate != null) { - classBuilder.withMethod(method.methodName().stringValue(), method.methodTypeSymbol(), method.flags().flagsMask(), methodBuilder -> { - methodBuilder.withCode(methodUpdate); - }); - updated = true; - } - } - if (!updated) { - classBuilder.with(ce); - } - } - }); - } - - public byte[] buildUninstrumented() { - makeUninstrumented(); - return toByteArray(); - } - - private void throwMissingDuration(CodeBuilder codeBuilder, String method) { - String message = "Cannot use method " + method + " when event lacks duration field"; - Bytecode.throwException(codeBuilder, TYPE_ISE, message); - } - - private void makeInstrumented() { - // MyEvent#isEnabled() - updateEnabledMethod(METHOD_IS_ENABLED); - - // MyEvent#begin() - updateMethod(METHOD_BEGIN, codeBuilder -> { - if (!implicitFields.hasDuration()) { - throwMissingDuration(codeBuilder, "begin"); - } else { - codeBuilder.aload(0); - invokestatic(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_TIME_STAMP); - putfield(codeBuilder, getEventClassDesc(), FIELD_START_TIME); - codeBuilder.return_(); - } - }); - - // MyEvent#end() - updateMethod(METHOD_END, codeBuilder -> { - if (!implicitFields.hasDuration()) { - throwMissingDuration(codeBuilder, "end"); + private void methodShouldCommit(CodeBuilder codeBuilder) { + Label fail = codeBuilder.newLabel(); + if (guardEventConfiguration) { + getEventConfiguration(codeBuilder); + codeBuilder.ifnull(fail); + } + // if (!eventConfiguration.shouldCommit(duration) goto fail; + getEventConfiguration(codeBuilder); + codeBuilder.aload(0); + getfield(codeBuilder, eventClassDesc, ImplicitFields.FIELD_DURATION); + invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_EVENT_CONFIGURATION_SHOULD_COMMIT); + codeBuilder.ifeq(fail); + List settingDescs = inspector.getSettings(); + for (int index = 0; index < settingDescs.size(); index++) { + SettingDesc sd = settingDescs.get(index); + // if (!settingsMethod(eventConfiguration.settingX)) goto fail; + codeBuilder.aload(0); + getEventConfiguration(codeBuilder); + codeBuilder.loadConstant(index); + invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_EVENT_CONFIGURATION_GET_SETTING); + MethodTypeDesc mdesc = MethodTypeDesc.ofDescriptor("(" + sd.paramType().descriptorString() + ")Z"); + codeBuilder.checkcast(sd.paramType()); + codeBuilder.invokevirtual(eventClassDesc, sd.methodName(), mdesc); + codeBuilder.ifeq(fail); + } + // return true + codeBuilder.iconst_1(); + codeBuilder.ireturn(); + // return false + codeBuilder.labelBinding(fail); + codeBuilder.iconst_0(); + codeBuilder.ireturn(); + } + + private void methodCommit(CodeBuilder codeBuilder) { + Label excluded = codeBuilder.newLabel(); + Label end = codeBuilder.newLabel(); + codeBuilder.trying(blockCodeBuilder -> { + if (staticCommitMethod != null) { + updateStaticCommit(blockCodeBuilder, excluded); } else { - codeBuilder.aload(0); - codeBuilder.aload(0); - getfield(codeBuilder, getEventClassDesc(), FIELD_START_TIME); - invokestatic(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_DURATION); - putfield(codeBuilder, getEventClassDesc(), FIELD_DURATION); - codeBuilder.return_(); + updateInstanceCommit(blockCodeBuilder, end, excluded); } - }); - - // MyEvent#commit() or static MyEvent#commit(...) - MethodDesc m = staticCommitMethod == null ? METHOD_COMMIT : staticCommitMethod; - updateMethod(m, codeBuilder -> { - Label excluded = codeBuilder.newLabel(); - Label end = codeBuilder.newLabel(); - codeBuilder.trying(blockCodeBuilder -> { - if (staticCommitMethod != null) { - updateStaticCommit(blockCodeBuilder, excluded); - } else { - updateInstanceCommit(blockCodeBuilder, end, excluded); - } - // stack: [integer] - // notified -> restart event write attempt - blockCodeBuilder.ifeq(blockCodeBuilder.startLabel()); - // stack: [] - blockCodeBuilder.goto_(end); - }, catchBuilder -> { - catchBuilder.catchingAll(catchAllHandler -> { - getEventWriter(catchAllHandler); - // stack: [ex] [EW] - catchAllHandler.dup(); - // stack: [ex] [EW] [EW] - Label rethrow = catchAllHandler.newLabel(); - catchAllHandler.ifnull(rethrow); - // stack: [ex] [EW] - catchAllHandler.dup(); - // stack: [ex] [EW] [EW] - invokevirtual(catchAllHandler, TYPE_EVENT_WRITER, METHOD_RESET); - catchAllHandler.labelBinding(rethrow); - // stack:[ex] [EW] - catchAllHandler.pop(); - // stack:[ex] - catchAllHandler.athrow(); - }); - }); - codeBuilder.labelBinding(excluded); - // stack: [EW] - codeBuilder.pop(); - codeBuilder.labelBinding(end); + // stack: [integer] + // notified -> restart event write attempt + blockCodeBuilder.ifeq(blockCodeBuilder.startLabel()); // stack: [] - codeBuilder.return_(); + blockCodeBuilder.goto_(end); + }, catchBuilder -> { + catchBuilder.catchingAll(catchAllHandler -> { + getEventWriter(catchAllHandler); + // stack: [ex] [EW] + catchAllHandler.dup(); + // stack: [ex] [EW] [EW] + Label rethrow = catchAllHandler.newLabel(); + catchAllHandler.ifnull(rethrow); + // stack: [ex] [EW] + catchAllHandler.dup(); + // stack: [ex] [EW] [EW] + invokevirtual(catchAllHandler, TYPE_EVENT_WRITER, METHOD_RESET); + catchAllHandler.labelBinding(rethrow); + // stack:[ex] [EW] + catchAllHandler.pop(); + // stack:[ex] + catchAllHandler.athrow(); + }); }); + codeBuilder.labelBinding(excluded); + // stack: [EW] + codeBuilder.pop(); + codeBuilder.labelBinding(end); + // stack: [] + codeBuilder.return_(); + } - // MyEvent#shouldCommit() - updateMethod(METHOD_EVENT_SHOULD_COMMIT, codeBuilder -> { - Label fail = codeBuilder.newLabel(); - if (guardEventConfiguration) { - getEventConfiguration(codeBuilder); - codeBuilder.ifnull(fail); - } - // if (!eventConfiguration.shouldCommit(duration) goto fail; + private void methodEnabledStatic(CodeBuilder codeBuilder) { + Label nullLabel = codeBuilder.newLabel(); + if (guardEventConfiguration) { getEventConfiguration(codeBuilder); - codeBuilder.aload(0); - getfield(codeBuilder, getEventClassDesc(), FIELD_DURATION); - invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_EVENT_CONFIGURATION_SHOULD_COMMIT); - codeBuilder.ifeq(fail); - for (int index = 0; index < settingDescs.size(); index++) { - SettingDesc sd = settingDescs.get(index); - // if (!settingsMethod(eventConfiguration.settingX)) goto fail; - codeBuilder.aload(0); - getEventConfiguration(codeBuilder); - codeBuilder.loadConstant(index); - invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_EVENT_CONFIGURATION_GET_SETTING); - MethodTypeDesc mdesc = MethodTypeDesc.ofDescriptor("(" + sd.paramType().descriptorString() + ")Z"); - codeBuilder.checkcast(sd.paramType()); - codeBuilder.invokevirtual(getEventClassDesc(), sd.methodName(), mdesc); - codeBuilder.ifeq(fail); - } - // return true - codeBuilder.iconst_1(); - codeBuilder.ireturn(); - // return false - codeBuilder.labelBinding(fail); + codeBuilder.ifnull(nullLabel); + } + getEventConfiguration(codeBuilder); + invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_IS_ENABLED); + codeBuilder.ireturn(); + if (guardEventConfiguration) { + codeBuilder.labelBinding(nullLabel); codeBuilder.iconst_0(); codeBuilder.ireturn(); - }); + } + } - if (isJDK) { - if (hasStaticMethod(METHOD_ENABLED)) { - updateEnabledMethod(METHOD_ENABLED); - } + private void methodTimestamp(CodeBuilder codeBuilder) { + invokestatic(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_TIME_STAMP); + codeBuilder.lreturn(); + } - updateIfStaticMethodExists(METHOD_SHOULD_COMMIT_LONG, codeBuilder -> { - Label fail = codeBuilder.newLabel(); - if (guardEventConfiguration) { - // if (eventConfiguration == null) goto fail; - getEventConfiguration(codeBuilder); - codeBuilder.ifnull(fail); - } - // return eventConfiguration.shouldCommit(duration); - getEventConfiguration(codeBuilder); - codeBuilder.lload(0); - codeBuilder.invokevirtual(TYPE_EVENT_CONFIGURATION, METHOD_EVENT_CONFIGURATION_SHOULD_COMMIT.name(), METHOD_EVENT_CONFIGURATION_SHOULD_COMMIT.descriptor()); - codeBuilder.ireturn(); - // fail: - codeBuilder.labelBinding(fail); - // return false - codeBuilder.iconst_0(); - codeBuilder.ireturn(); - }); - updateIfStaticMethodExists(METHOD_TIME_STAMP, codeBuilder -> { - invokestatic(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_TIME_STAMP); - codeBuilder.lreturn(); - }); + private void methodShouldCommitStatic(CodeBuilder codeBuilder) { + Label fail = codeBuilder.newLabel(); + if (guardEventConfiguration) { + // if (eventConfiguration == null) goto fail; + getEventConfiguration(codeBuilder); + codeBuilder.ifnull(fail); } + // return eventConfiguration.shouldCommit(duration); + getEventConfiguration(codeBuilder); + codeBuilder.lload(0); + codeBuilder.invokevirtual(TYPE_EVENT_CONFIGURATION, METHOD_EVENT_CONFIGURATION_SHOULD_COMMIT.name(), METHOD_EVENT_CONFIGURATION_SHOULD_COMMIT.descriptor()); + codeBuilder.ireturn(); + // fail: + codeBuilder.labelBinding(fail); + // return false + codeBuilder.iconst_0(); + codeBuilder.ireturn(); + } + + private void throwMissingDuration(CodeBuilder codeBuilder, String method) { + String message = "Cannot use method " + method + " when event lacks duration field"; + Bytecode.throwException(codeBuilder, TYPE_ISE, message); } - void updateStaticCommit(BlockCodeBuilder blockCodeBuilder, Label excluded) { + private void updateStaticCommit(BlockCodeBuilder blockCodeBuilder, Label excluded) { // indexes the argument type array, the argument type array does not include // 'this' int argIndex = 0; @@ -576,7 +350,7 @@ void updateStaticCommit(BlockCodeBuilder blockCodeBuilder, Label excluded) { invokevirtual(blockCodeBuilder, TYPE_EVENT_WRITER, EventWriterMethod.PUT_LONG.method()); fieldIndex++; // stack: [EW] - if (implicitFields.hasDuration()) { + if (inspector.hasDuration()) { // write duration blockCodeBuilder.dup(); // stack: [EW], [EW] @@ -588,14 +362,14 @@ void updateStaticCommit(BlockCodeBuilder blockCodeBuilder, Label excluded) { fieldIndex++; } // stack: [EW] - if (implicitFields.hasEventThread()) { + if (inspector.hasEventThread()) { // write eventThread blockCodeBuilder.dup(); // stack: [EW], [EW] invokevirtual(blockCodeBuilder, TYPE_EVENT_WRITER, EventWriterMethod.PUT_EVENT_THREAD.method()); } // stack: [EW] - if (implicitFields.hasStackTrace()) { + if (inspector.hasStackTrace()) { // write stackTrace blockCodeBuilder.dup(); // stack: [EW], [EW] @@ -603,6 +377,7 @@ void updateStaticCommit(BlockCodeBuilder blockCodeBuilder, Label excluded) { } // stack: [EW] // write custom fields + List fieldDescs = inspector.getFields(); while (fieldIndex < fieldDescs.size()) { blockCodeBuilder.dup(); // stack: [EW], [EW] @@ -622,19 +397,19 @@ void updateStaticCommit(BlockCodeBuilder blockCodeBuilder, Label excluded) { // stack: [int] } - void updateInstanceCommit(BlockCodeBuilder blockCodeBuilder, Label end, Label excluded) { + private void updateInstanceCommit(BlockCodeBuilder blockCodeBuilder, Label end, Label excluded) { // if (!isEnable()) { // return; // } blockCodeBuilder.aload(0); - invokevirtual(blockCodeBuilder, getEventClassDesc(), METHOD_IS_ENABLED); + invokevirtual(blockCodeBuilder, eventClassDesc, METHOD_IS_ENABLED); Label l0 = blockCodeBuilder.newLabel(); blockCodeBuilder.ifne(l0); blockCodeBuilder.return_(); blockCodeBuilder.labelBinding(l0); // long startTime = this.startTime blockCodeBuilder.aload(0); - getfield(blockCodeBuilder, getEventClassDesc(), FIELD_START_TIME); + getfield(blockCodeBuilder, eventClassDesc, ImplicitFields.FIELD_START_TIME); blockCodeBuilder.lstore(1); // if (startTime == 0) { // startTime = EventWriter.timestamp(); @@ -654,7 +429,7 @@ void updateInstanceCommit(BlockCodeBuilder blockCodeBuilder, Label end, Label ex // } blockCodeBuilder.labelBinding(durationEvent); blockCodeBuilder.aload(0); - getfield(blockCodeBuilder, getEventClassDesc(), FIELD_DURATION); + getfield(blockCodeBuilder, eventClassDesc, ImplicitFields.FIELD_DURATION); blockCodeBuilder.lconst_0(); blockCodeBuilder.lcmp(); blockCodeBuilder.ifne(commit); @@ -662,11 +437,11 @@ void updateInstanceCommit(BlockCodeBuilder blockCodeBuilder, Label end, Label ex invokestatic(blockCodeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_TIME_STAMP); blockCodeBuilder.lload(1); blockCodeBuilder.lsub(); - putfield(blockCodeBuilder, getEventClassDesc(), FIELD_DURATION); + putfield(blockCodeBuilder, eventClassDesc, ImplicitFields.FIELD_DURATION); blockCodeBuilder.labelBinding(commit); // if (shouldCommit()) { blockCodeBuilder.aload(0); - invokevirtual(blockCodeBuilder, getEventClassDesc(), METHOD_EVENT_SHOULD_COMMIT); + invokevirtual(blockCodeBuilder, eventClassDesc, METHOD_EVENT_SHOULD_COMMIT); blockCodeBuilder.ifeq(end); getEventWriter(blockCodeBuilder); // stack: [EW] @@ -687,39 +462,40 @@ void updateInstanceCommit(BlockCodeBuilder blockCodeBuilder, Label end, Label ex invokevirtual(blockCodeBuilder, TYPE_EVENT_WRITER, EventWriterMethod.PUT_LONG.method()); fieldIndex++; // stack: [EW] - if (implicitFields.hasDuration()) { + if (inspector.hasDuration()) { // write duration blockCodeBuilder.dup(); // stack: [EW] [EW] blockCodeBuilder.aload(0); // stack: [EW] [EW] [this] - getfield(blockCodeBuilder, getEventClassDesc(), FIELD_DURATION); + getfield(blockCodeBuilder, eventClassDesc, ImplicitFields.FIELD_DURATION); // stack: [EW] [EW] [long] invokevirtual(blockCodeBuilder, TYPE_EVENT_WRITER, EventWriterMethod.PUT_LONG.method()); fieldIndex++; } // stack: [EW] - if (implicitFields.hasEventThread()) { + if (inspector.hasEventThread()) { // write eventThread blockCodeBuilder.dup(); // stack: [EW] [EW] invokevirtual(blockCodeBuilder, TYPE_EVENT_WRITER, EventWriterMethod.PUT_EVENT_THREAD.method()); } // stack: [EW] - if (implicitFields.hasStackTrace()) { + if (inspector.hasStackTrace()) { // write stack trace blockCodeBuilder.dup(); // stack: [EW] [EW] invokevirtual(blockCodeBuilder, TYPE_EVENT_WRITER, EventWriterMethod.PUT_STACK_TRACE.method()); } // stack: [EW] + List fieldDescs = inspector.getFields(); while (fieldIndex < fieldDescs.size()) { FieldDesc field = fieldDescs.get(fieldIndex); blockCodeBuilder.dup(); // stack: [EW] [EW] blockCodeBuilder.aload(0); // stack: [EW] [EW] [this] - getfield(blockCodeBuilder, getEventClassDesc(), field); + getfield(blockCodeBuilder, eventClassDesc, field); // stack: [EW] [EW] EventWriterMethod eventMethod = EventWriterMethod.lookupMethod(field); invokevirtual(blockCodeBuilder, TYPE_EVENT_WRITER, eventMethod.method()); @@ -731,90 +507,33 @@ void updateInstanceCommit(BlockCodeBuilder blockCodeBuilder, Label end, Label ex // stack:[int] } - private void updateEnabledMethod(MethodDesc method) { - updateMethod(method, codeBuilder -> { - Label nullLabel = codeBuilder.newLabel(); - if (guardEventConfiguration) { - getEventConfiguration(codeBuilder); - codeBuilder.ifnull(nullLabel); - } - getEventConfiguration(codeBuilder); - invokevirtual(codeBuilder, TYPE_EVENT_CONFIGURATION, METHOD_IS_ENABLED); - codeBuilder.ireturn(); - if (guardEventConfiguration) { - codeBuilder.labelBinding(nullLabel); - codeBuilder.iconst_0(); - codeBuilder.ireturn(); - } - }); - } - - private void updateIfStaticMethodExists(MethodDesc method, Consumer code) { - if (hasStaticMethod(method)) { - updateMethod(method, code); - } + private static boolean isStatic(MethodModel method) { + return (method.flags().flagsMask() & ClassFile.ACC_STATIC) != 0; } - private boolean hasStaticMethod(MethodDesc method) { - for (MethodModel m : classModel.methods()) { - if (m.methodName().equalsString(method.name()) && m.methodTypeSymbol().equals(method.descriptor())) { - return Modifier.isStatic(m.flags().flagsMask()); - } - } - return false; + private static boolean isMethod(MethodModel m, MethodDesc desc) { + return desc.matches(m); } - private void getEventWriter(CodeBuilder codeBuilder) { + private static void getEventWriter(CodeBuilder codeBuilder) { invokestatic(codeBuilder, TYPE_EVENT_WRITER, METHOD_GET_EVENT_WRITER); } private void getEventConfiguration(CodeBuilder codeBuilder) { if (untypedEventConfiguration) { - codeBuilder.getstatic(getEventClassDesc(), FIELD_EVENT_CONFIGURATION.name(), TYPE_OBJECT); + codeBuilder.getstatic(eventClassDesc, FIELD_EVENT_CONFIGURATION.name(), TYPE_OBJECT); codeBuilder.checkcast(TYPE_EVENT_CONFIGURATION); } else { - codeBuilder.getstatic(getEventClassDesc(), FIELD_EVENT_CONFIGURATION.name(), TYPE_EVENT_CONFIGURATION); + codeBuilder.getstatic(eventClassDesc, FIELD_EVENT_CONFIGURATION.name(), TYPE_EVENT_CONFIGURATION); } } - private void makeUninstrumented() { - updateExistingWithReturnFalse(METHOD_EVENT_SHOULD_COMMIT); - updateExistingWithReturnFalse(METHOD_IS_ENABLED); - updateExistingWithEmptyVoidMethod(METHOD_COMMIT); - if (staticCommitMethod != null) { - updateExistingWithEmptyVoidMethod(staticCommitMethod); + private boolean hasUntypedConfiguration() { + for (FieldModel f : inspector.getClassModel().fields()) { + if (f.fieldName().equalsString(FIELD_EVENT_CONFIGURATION.name())) { + return f.fieldType().equalsString(TYPE_OBJECT.descriptorString()); + } } - updateExistingWithEmptyVoidMethod(METHOD_BEGIN); - updateExistingWithEmptyVoidMethod(METHOD_END); - } - - private final void updateExistingWithEmptyVoidMethod(MethodDesc voidMethod) { - updateMethod(voidMethod, codeBuilder -> { - codeBuilder.return_(); - }); - } - - private final void updateExistingWithReturnFalse(MethodDesc voidMethod) { - updateMethod(voidMethod, codeBuilder -> { - codeBuilder.iconst_0(); - codeBuilder.ireturn(); - }); - } - - private Consumer findMethodUpdate(MethodModel mm) { - MethodDesc m = MethodDesc.of(mm.methodName().stringValue(), mm.methodType().stringValue()); - return methodUpdates.get(m); - } - - private void updateMethod(MethodDesc method, Consumer codeBuilder) { - methodUpdates.put(method, codeBuilder); - } - - private ClassDesc getEventClassDesc() { - return classModel.thisClass().asSymbol(); - } - - public String getEventName() { - return eventName; + throw new InternalError("Class missing configuration field"); } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java index 36dc2259be9..18b76cc3ff9 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVMUpcalls.java @@ -72,7 +72,8 @@ static byte[] onRetransform(long traceId, boolean dummy1, boolean dummy2, Class< } boolean jdkClass = Utils.isJDKClass(clazz); Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding instrumentation to event class " + clazz.getName() + " using retransform"); - EventInstrumentation ei = new EventInstrumentation(clazz.getSuperclass(), oldBytes, traceId, jdkClass, false); + ClassInspector c = new ClassInspector(clazz.getSuperclass(), oldBytes, jdkClass); + EventInstrumentation ei = new EventInstrumentation(c, traceId, false); byte[] bytes = ei.buildInstrumented(); Bytecode.log(clazz.getName(), bytes); return bytes; @@ -105,9 +106,9 @@ static byte[] bytesForEagerInstrumentation(long traceId, boolean forceInstrument } String eventName = ""; try { - EventInstrumentation ei = new EventInstrumentation(superClass, oldBytes, traceId, bootClassLoader, true); - eventName = ei.getEventName(); - if (!JVMSupport.shouldInstrument(bootClassLoader, ei.getEventName())) { + ClassInspector c = new ClassInspector(superClass, oldBytes, bootClassLoader); + eventName = c.getEventName(); + if (!JVMSupport.shouldInstrument(bootClassLoader, c.getEventName())) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Skipping instrumentation for " + eventName + " since container support is missing"); return oldBytes; } @@ -118,14 +119,15 @@ static byte[] bytesForEagerInstrumentation(long traceId, boolean forceInstrument // No need to generate bytecode if: // 1) Event class is disabled, and there is not an external configuration that overrides. // 2) Event class has @Registered(false) - if (!mr.isEnabled(ei.getEventName()) && !ei.isEnabled() || !ei.isRegistered()) { + if (!mr.isEnabled(c.getEventName()) && !c.isEnabled() || !c.isRegistered()) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Skipping instrumentation for event type " + eventName + " since event was disabled on class load"); return oldBytes; } } - Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding " + (forceInstrumentation ? "forced " : "") + "instrumentation for event type " + eventName + " during initial class load"); + EventInstrumentation ei = new EventInstrumentation(c, traceId, true); byte[] bytes = ei.buildInstrumented(); - Bytecode.log(ei.getClassName() + "(" + traceId + ")", bytes); + Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding " + (forceInstrumentation ? "forced " : "") + "instrumentation for event type " + eventName + " during initial class load"); + Bytecode.log(c.getClassName() + "(" + traceId + ")", bytes); return bytes; } catch (Throwable t) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Unexpected error when adding instrumentation for event type " + eventName + ". " + t.getMessage()); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Bytecode.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Bytecode.java index 1241993e762..3cea5e80643 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Bytecode.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Bytecode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -33,6 +33,7 @@ import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; import java.lang.classfile.CodeBuilder; +import java.lang.classfile.MethodModel; import java.lang.classfile.ClassModel; import java.lang.classfile.ClassFile; import jdk.internal.classfile.components.ClassPrinter; @@ -74,6 +75,12 @@ public static MethodDesc of(String methodName, Class returnType, Class... MethodTypeDesc mtd = MethodTypeDesc.of(returnDesc, parameterDesc); return new MethodDesc(methodName, mtd); } + + public boolean matches(MethodModel m) { + return this.descriptor().equals(m.methodTypeSymbol()) && m.methodName().equalsString(this.name()); + } + } + public record SettingDesc(ClassDesc paramType, String methodName) { } public static ClassDesc classDesc(ValueDescriptor v) { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/ImplicitFields.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/ImplicitFields.java index c97efe0bdb9..4c82569a83f 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/ImplicitFields.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/ImplicitFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -28,6 +28,7 @@ import java.util.List; import jdk.jfr.internal.RemoveFields; +import jdk.jfr.internal.util.Bytecode.FieldDesc; /** * Class that describes fields that was not directly named * in the event definition. @@ -37,6 +38,8 @@ public final class ImplicitFields { public static final String DURATION = "duration"; public static final String EVENT_THREAD = "eventThread"; public static final String STACK_TRACE = "stackTrace"; + public static final FieldDesc FIELD_DURATION = FieldDesc.of(long.class, DURATION); + public static final FieldDesc FIELD_START_TIME = FieldDesc.of(long.class, START_TIME); private final List fields = new ArrayList<>(4); From 44c5aca54d1e0aaf0616f77845c5b3b1e2fccf5a Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Wed, 23 Apr 2025 11:53:09 +0000 Subject: [PATCH 076/901] 8341491: Reserve and commit memory operations should be protected by NMT lock Reviewed-by: stuefe, stefank --- src/hotspot/share/runtime/os.cpp | 10 ++++ test/hotspot/gtest/runtime/test_os.cpp | 68 ++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index e4bab3410c1..943f81d752c 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -2251,6 +2251,11 @@ void os::commit_memory_or_exit(char* addr, size_t size, size_t alignment_hint, MemTracker::record_virtual_memory_commit((address)addr, size, CALLER_PC); } +// The scope of NmtVirtualMemoryLocker covers both pd_uncommit_memory and record_virtual_memory_uncommit because +// these operations must happen atomically to avoid races causing NMT to fall out os sync with the OS reality. +// We do not have the same lock protection for pd_commit_memory and record_virtual_memory_commit. +// We assume that there is some external synchronization that prevents a region from being uncommitted +// before it is finished being committed. bool os::uncommit_memory(char* addr, size_t bytes, bool executable) { assert_nonempty_range(addr, bytes); bool res; @@ -2273,6 +2278,11 @@ bool os::uncommit_memory(char* addr, size_t bytes, bool executable) { return res; } +// The scope of NmtVirtualMemoryLocker covers both pd_release_memory and record_virtual_memory_release because +// these operations must happen atomically to avoid races causing NMT to fall out os sync with the OS reality. +// We do not have the same lock protection for pd_reserve_memory and record_virtual_memory_reserve. +// We assume that there is some external synchronization that prevents a region from being released +// before it is finished being reserved. bool os::release_memory(char* addr, size_t bytes) { assert_nonempty_range(addr, bytes); bool res; diff --git a/test/hotspot/gtest/runtime/test_os.cpp b/test/hotspot/gtest/runtime/test_os.cpp index ee6d1427d0b..04d71a55a49 100644 --- a/test/hotspot/gtest/runtime/test_os.cpp +++ b/test/hotspot/gtest/runtime/test_os.cpp @@ -28,6 +28,7 @@ #include "runtime/os.inline.hpp" #include "runtime/thread.hpp" #include "runtime/threads.hpp" +#include "testutils.hpp" #include "utilities/align.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" @@ -1113,3 +1114,70 @@ TEST_VM(os, free_without_uncommit) { os::release_memory(base, size); } #endif + +TEST_VM(os, commit_memory_or_exit) { + const size_t page_sz = os::vm_page_size(); + const size_t size = 16 * page_sz; + const char* letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + char* base = os::reserve_memory(size, false, mtTest); + ASSERT_NOT_NULL(base); + os::commit_memory_or_exit(base, size, false, "Commit failed."); + strcpy(base, letters); + ASSERT_TRUE(os::uncommit_memory(base, size, false)); + os::commit_memory_or_exit(base, size, page_sz, false, "Commit with alignment hint failed."); + strcpy(base, letters); + ASSERT_TRUE(os::uncommit_memory(base, size, false)); + EXPECT_TRUE(os::release_memory(base, size)); +} + +#if !defined(_AIX) + +TEST_VM(os, map_memory_to_file) { + const char* letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const size_t size = strlen(letters) +1; + + int fd = os::open("map_memory_to_file.txt", O_RDWR | O_CREAT, 0666); + EXPECT_TRUE(fd > 0); + EXPECT_TRUE(os::write(fd, letters, size)); + + char* result = os::map_memory_to_file(size, fd, mtTest); + ASSERT_NOT_NULL(result); + EXPECT_EQ(strcmp(letters, result), 0); + EXPECT_TRUE(os::unmap_memory(result, size)); + ::close(fd); +} + +TEST_VM(os, map_unmap_memory) { + const char* letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const char* path = "map_unmap_memory.txt"; + const size_t size = strlen(letters) + 1; + int fd = os::open(path, O_RDWR | O_CREAT, 0666); + EXPECT_TRUE(fd > 0); + EXPECT_TRUE(os::write(fd, letters, size)); + ::close(fd); + + fd = os::open(path, O_RDONLY, 0666); + char* result = os::map_memory(fd, path, 0, nullptr, size, true, false, mtTest); + ASSERT_NOT_NULL(result); + EXPECT_EQ(strcmp(letters, result), 0); + EXPECT_TRUE(os::unmap_memory(result, size)); + ::close(fd); +} + +TEST_VM(os, map_memory_to_file_aligned) { + const char* letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const size_t size = strlen(letters) + 1; + + int fd = os::open("map_memory_to_file.txt", O_RDWR | O_CREAT, 0666); + EXPECT_TRUE(fd > 0); + EXPECT_TRUE(os::write(fd, letters, size)); + + char* result = os::map_memory_to_file_aligned(os::vm_allocation_granularity(), os::vm_allocation_granularity(), fd, mtTest); + ASSERT_NOT_NULL(result); + EXPECT_EQ(strcmp(letters, result), 0); + EXPECT_TRUE(os::unmap_memory(result, os::vm_allocation_granularity())); + ::close(fd); +} + +#endif // !defined(_AIX) From c873837da6e373613866f5f5c0017f0fccb97b57 Mon Sep 17 00:00:00 2001 From: Shaojin Wen Date: Wed, 23 Apr 2025 13:01:42 +0000 Subject: [PATCH 077/901] 8355300: Add final to BitSieve Reviewed-by: liach, pminborg --- src/java.base/share/classes/java/math/BitSieve.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/java.base/share/classes/java/math/BitSieve.java b/src/java.base/share/classes/java/math/BitSieve.java index 8d0d370f9be..4403d79a22f 100644 --- a/src/java.base/share/classes/java/math/BitSieve.java +++ b/src/java.base/share/classes/java/math/BitSieve.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, 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 @@ -44,22 +44,22 @@ * @author Michael McCloskey * @since 1.3 */ -class BitSieve { +final class BitSieve { /** * Stores the bits in this bitSieve. */ - private long bits[]; + private final long[] bits; /** * Length is how many bits this sieve holds. */ - private int length; + private final int length; /** * A small sieve used to filter out multiples of small primes in a search * sieve. */ - private static BitSieve smallSieve = new BitSieve(); + private static final BitSieve smallSieve = new BitSieve(); /** * Construct a "small sieve" with a base of 0. This constructor is From a372937d8480404e69eff43682c91506997fd8ee Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Wed, 23 Apr 2025 13:22:57 +0000 Subject: [PATCH 078/901] 8350983: JShell LocalExecutionControl only needs stopCheck() on backward branches Reviewed-by: jlahoda, liach, asotona --- .../execution/LocalExecutionControl.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControl.java b/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControl.java index 1f4dae2df38..5f547b25178 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControl.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/execution/LocalExecutionControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, 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 @@ -29,11 +29,16 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; import java.lang.classfile.ClassFile; import java.lang.classfile.ClassTransform; +import java.lang.classfile.CodeTransform; +import java.lang.classfile.Label; import java.lang.classfile.instruction.BranchInstruction; +import java.lang.classfile.instruction.LabelTarget; /** * An implementation of {@link jdk.jshell.spi.ExecutionControl} which executes @@ -90,11 +95,19 @@ public void load(ClassBytecodes[] cbcs) private static byte[] instrument(byte[] classFile) { var cc = ClassFile.of(); return cc.transformClass(cc.parse(classFile), - ClassTransform.transformingMethodBodies((cob, coe) -> { - if (coe instanceof BranchInstruction) - cob.invokestatic(CD_Cancel, "stopCheck", ConstantDescs.MTD_void); - cob.with(coe); - })); + ClassTransform.transformingMethodBodies( + CodeTransform.ofStateful(() -> { + Set