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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void G1GCPhaseTimes::trace_phase(WorkerDataArray<double>* phase, bool print_sum,
}
}

#define TIME_FORMAT "%.1lfms"
#define TIME_FORMAT "%.2lfms"

void G1GCPhaseTimes::info_time(const char* name, double value) const {
log_info(gc, phases)(" %s: " TIME_FORMAT, name, value);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/weakProcessorTimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static const char* indent_str(size_t i) {
return indents[MIN2(i, max_indents_index)];
}

#define TIME_FORMAT "%.1lfms"
#define TIME_FORMAT "%.2lfms"

void WeakProcessorTimes::log_summary(OopStorageSet::WeakId id, uint indent) const {
LogTarget(Debug, gc, phases) lt;
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/share/gc/shared/workerDataArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ double WorkerDataArray<double>::uninitialized() {
return -1.0;
}

#define WDA_TIME_FORMAT "%4.2lf"

template <>
void WorkerDataArray<double>::WDAPrinter::summary(outputStream* out, double time) {
out->print_cr(" %.1lfms", time * MILLIUNITS);
Expand All @@ -48,9 +50,10 @@ void WorkerDataArray<size_t>::WDAPrinter::summary(outputStream* out, size_t valu

template <>
void WorkerDataArray<double>::WDAPrinter::summary(outputStream* out, double min, double avg, double max, double diff, double sum, bool print_sum) {
out->print(" Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf", min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
out->print(" Min: " WDA_TIME_FORMAT ", Avg: " WDA_TIME_FORMAT ", Max: " WDA_TIME_FORMAT ", Diff: " WDA_TIME_FORMAT,
min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
if (print_sum) {
out->print(", Sum: %4.1lf", sum * MILLIUNITS);
out->print(", Sum: " WDA_TIME_FORMAT, sum * MILLIUNITS);
}
}

Expand All @@ -68,7 +71,7 @@ void WorkerDataArray<double>::WDAPrinter::details(const WorkerDataArray<double>*
for (uint i = 0; i < phase->_length; ++i) {
double value = phase->get(i);
if (value != phase->uninitialized()) {
out->print(" %4.1lf", phase->get(i) * 1000.0);
out->print(" " WDA_TIME_FORMAT, phase->get(i) * 1000.0);
} else {
out->print(" -");
}
Expand Down
8 changes: 4 additions & 4 deletions src/java.base/share/classes/java/util/regex/Pattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -5364,10 +5364,10 @@ boolean match(Matcher matcher, int i, CharSequence seq) {
* they are ignored for purposes of finding word boundaries.
*/
static final class Bound extends Node {
static int LEFT = 0x1;
static int RIGHT= 0x2;
static int BOTH = 0x3;
static int NONE = 0x4;
static final int LEFT = 0x1;
static final int RIGHT= 0x2;
static final int BOTH = 0x3;
static final int NONE = 0x4;
int type;
boolean useUWORD;
Bound(int n, boolean useUWORD) {
Expand Down
1 change: 0 additions & 1 deletion src/java.base/share/classes/sun/nio/cs/StreamDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ int implRead(char[] cbuf, int off, int end) throws IOException {
eof = true;
if ((cb.position() == 0) && (!bb.hasRemaining()))
break;
decoder.reset();
}
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,15 @@ public void paintIcon(Component c, Graphics g, int x, int y) {
}
}
if (icon != null) {
icon.paintIcon(c, g, x + VistaMenuItemCheckIconFactory.getIconWidth(),
y + OFFSET);
if (WindowsGraphicsUtils.isLeftToRight(c)) {
icon.paintIcon(c, g,
x + VistaMenuItemCheckIconFactory.getIconWidth(),
y + OFFSET);
} else {
icon.paintIcon(c, g,
x - VistaMenuItemCheckIconFactory.getIconWidth() + 2 * OFFSET,
y + OFFSET);
}
}
}
private static WindowsMenuItemUIAccessor getAccessor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
Expand Down Expand Up @@ -215,8 +216,17 @@ static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,

if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
Rectangle rect = lr.getTextRect();

rect.x += lh.getAfterCheckIconGap();
if (menuItem.getComponentOrientation().isLeftToRight()) {
if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING
&& menuItem.getHorizontalTextPosition() != SwingConstants.LEFT) {
rect.x += lh.getAfterCheckIconGap();
}
} else {
if (menuItem.getHorizontalTextPosition() != SwingConstants.LEADING
&& menuItem.getHorizontalTextPosition() != SwingConstants.RIGHT) {
rect.x -= lh.getAfterCheckIconGap();
}
}

lr.setTextRect(rect);
}
Expand All @@ -232,7 +242,11 @@ static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,
}
if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
Rectangle rect = lr.getAccRect();
rect.x += lh.getAfterCheckIconGap();
if (menuItem.getComponentOrientation().isLeftToRight()) {
rect.x += lh.getAfterCheckIconGap();
} else {
rect.x -= lh.getAfterCheckIconGap();
}
lr.setAccRect(rect);
}
SwingUtilities3.paintAccText(g, lh, lr, disabledForeground,
Expand Down
25 changes: 24 additions & 1 deletion src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2024, 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
Expand Down Expand Up @@ -210,6 +210,16 @@ class RunExecutorWithMsgLoop {
};


void enableConsoleCtrlHandler(bool enable) {
if (!SetConsoleCtrlHandler(NULL, enable ? FALSE : TRUE)) {
JP_THROW(SysError(tstrings::any() << "SetConsoleCtrlHandler(NULL, "
<< (enable ? "FALSE" : "TRUE")
<< ") failed",
SetConsoleCtrlHandler));
}
}


void launchApp() {
// [RT-31061] otherwise UI can be left in back of other windows.
::AllowSetForegroundWindow(ASFW_ANY);
Expand Down Expand Up @@ -256,6 +266,19 @@ void launchApp() {
exec.arg(arg);
});

exec.afterProcessCreated([&](HANDLE pid) {
//
// Ignore Ctrl+C in the current process.
// This will prevent child process termination without allowing
// it to handle Ctrl+C events.
//
// Disable the default Ctrl+C handler *after* the child process
// has been created as it is inheritable and we want the child
// process to have the default handler.
//
enableConsoleCtrlHandler(false);
});

DWORD exitCode = RunExecutorWithMsgLoop::apply(exec);

exit(exitCode);
Expand Down
6 changes: 5 additions & 1 deletion src/jdk.jpackage/windows/native/common/Executor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 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
Expand Down Expand Up @@ -161,6 +161,10 @@ UniqueHandle Executor::startProcess(UniqueHandle* threadHandle) const {
}
}

if (afterProcessCreatedCallback) {
afterProcessCreatedCallback(processInfo.hProcess);
}

// Return process handle.
return UniqueHandle(processInfo.hProcess);
}
13 changes: 12 additions & 1 deletion src/jdk.jpackage/windows/native/common/Executor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 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
Expand All @@ -26,6 +26,8 @@
#ifndef EXECUTOR_H
#define EXECUTOR_H

#include <functional>

#include "tstrings.h"
#include "UniqueHandle.h"

Expand Down Expand Up @@ -97,6 +99,14 @@ class Executor {
*/
int execAndWaitForExit() const;

/**
* Call provided function after the process hass been created.
*/
Executor& afterProcessCreated(const std::function<void(HANDLE)>& v) {
afterProcessCreatedCallback = v;
return *this;
}

private:
UniqueHandle startProcess(UniqueHandle* threadHandle=0) const;

Expand All @@ -106,6 +116,7 @@ class Executor {
HANDLE jobHandle;
tstring_array argsArray;
std::wstring appPath;
std::function<void(HANDLE)> afterProcessCreatedCallback;
};

#endif // #ifndef EXECUTOR_H
10 changes: 5 additions & 5 deletions test/hotspot/gtest/gc/shared/test_workerDataArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ const char* WorkerDataArrayTest<double>::format_summary(
double min, double avg, double max, double diff, double sum, size_t workers) {

stringStream out;
out.print(" Min: %4.1lf"
", Avg: %4.1lf, Max: %4.1lf"
", Diff: %4.1lf, Sum: %4.1lf"
out.print(" Min: %4.2lf"
", Avg: %4.2lf, Max: %4.2lf"
", Diff: %4.2lf, Sum: %4.2lf"
", Workers: " SIZE_FORMAT "\n",
min, avg, max, diff, sum, workers);
return out.as_string();
Expand Down Expand Up @@ -278,12 +278,12 @@ class UninitializedDoubleElementWorkerDataArrayTest : public WorkerDataArrayTest

private:
virtual const char* expected_summary() {
return format_summary(5.1, 6.1, 7.2, 2.1, 12.3, 2);
return format_summary(5.10, 6.15, 7.20, 2.10, 12.30, 2);
}

virtual const char* expected_details() {
stringStream out;
out.print(" %4.1lf - %4.1lf\n", 5.1, 7.2);
out.print(" %4.2lf - %4.2lf\n", 5.1, 7.2);
return out.as_string();
}
};
Expand Down
79 changes: 79 additions & 0 deletions test/jdk/java/io/InputStreamReader/StatefulDecoderNearEOF.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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 8292043
* @run testng StatefulDecoderNearEOF
* @summary Check MalformedInputException is thrown with stateful decoders
* with malformed input before EOF
*/

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.MalformedInputException;
import java.nio.charset.StandardCharsets;
import java.util.stream.IntStream;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertThrows;

@Test
public class StatefulDecoderNearEOF {

@DataProvider
public Object[][] inputs() {
return new Object[][] {
// BOM, followed by High surrogate (in UTF-16LE).
// First read() should throw an exception.
{new byte[] {(byte)0xff, (byte)0xfe, 0, (byte)0xd8}, 0},

// BOM, followed by 'A', 'B', 'C', then by High surrogate (in UTF-16LE).
// Fourth read() should throw an exception.
{new byte[] {(byte)0xff, (byte)0xfe, (byte)0x41, 0, (byte)0x42, 0, (byte)0x43, 0, 0, (byte)0xd8}, 3},
};
}

@Test (dataProvider = "inputs")
public void testStatefulDecoderNearEOF(byte[] ba, int numSucessReads) throws IOException {
try (var r = new InputStreamReader(
new ByteArrayInputStream(ba),
StandardCharsets.UTF_16.newDecoder().onMalformedInput(CodingErrorAction.REPORT))) {
// Issue read() as many as numSucessReads which should not fail
IntStream.rangeClosed(1, numSucessReads).forEach(i -> {
try {
assertEquals(r.read(), (int)ba[i * 2]);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});

// Final dangling high surrogate should throw an exception
assertThrows(MalformedInputException.class, () -> r.read());
}
}
}
Loading
Loading