+#include "jvm.h"
/*
* Stack allocated by thread when doing blocking operation
@@ -387,61 +388,61 @@ int NET_SocketClose(int fd) {
/************** Basic I/O operations here ***************/
/*
- * Macro to perform a blocking IO operation. Restarts
- * automatically if interrupted by signal (other than
- * our wakeup signal)
+ * Macro to perform a blocking IO operation.
+ * If interrupted by signal (other than our wakeup signal), and if RETRY is true,
+ * then restarts automatically
*/
-#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \
- int ret; \
- threadEntry_t self; \
- fdEntry_t *fdEntry = getFdEntry(FD); \
- if (fdEntry == NULL) { \
- errno = EBADF; \
- return -1; \
- } \
- do { \
- startOp(fdEntry, &self); \
- ret = FUNC; \
- endOp(fdEntry, &self); \
- } while (ret == -1 && errno == EINTR); \
- return ret; \
+#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \
+ int ret; \
+ threadEntry_t self; \
+ fdEntry_t *fdEntry = getFdEntry(FD); \
+ if (fdEntry == NULL) { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ do { \
+ startOp(fdEntry, &self); \
+ ret = FUNC; \
+ endOp(fdEntry, &self); \
+ } while ((RETRY) && ret == -1 && errno == EINTR); \
+ return ret; \
}
int NET_Read(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE );
}
int NET_NonBlockingRead(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK));
+ BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK), JNI_TRUE );
}
int NET_ReadV(int s, const struct iovec * vector, int count) {
- BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
+ BLOCKING_IO_RETURN_INT( s, readv(s, vector, count), JNI_TRUE );
}
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, int *fromlen) {
socklen_t socklen = *fromlen;
- BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, &socklen) );
+ BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, &socklen), JNI_TRUE );
*fromlen = socklen;
}
int NET_Send(int s, void *msg, int len, unsigned int flags) {
- BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) );
+ BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE );
}
int NET_WriteV(int s, const struct iovec * vector, int count) {
- BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) );
+ BLOCKING_IO_RETURN_INT( s, writev(s, vector, count), JNI_TRUE );
}
int NET_SendTo(int s, const void *msg, int len, unsigned int
flags, const struct sockaddr *to, int tolen) {
- BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
+ BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE );
}
int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
socklen_t socklen = *addrlen;
- BLOCKING_IO_RETURN_INT( s, accept(s, addr, &socklen) );
+ BLOCKING_IO_RETURN_INT( s, accept(s, addr, &socklen), JNI_TRUE );
*addrlen = socklen;
}
@@ -500,7 +501,7 @@ int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
}
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
- BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
+ BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE );
}
/*
diff --git a/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java b/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java
index b50fb2ae1b2..624733ac41c 100644
--- a/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java
+++ b/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, 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
@@ -36,11 +36,20 @@
import java.applet.Applet;
import java.awt.AWTEvent;
import java.awt.EventQueue;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
import java.awt.Window;
+import javax.swing.ButtonModel;
+import javax.swing.Icon;
import javax.swing.JComponent;
+import javax.swing.JMenu;
import javax.swing.RepaintManager;
+import sun.swing.MenuItemLayoutHelper;
+import sun.swing.SwingUtilities2;
/**
* A collection of utility methods for Swing.
@@ -113,6 +122,119 @@ public static boolean isVsyncRequested(Container rootContainer) {
return Boolean.TRUE == vsyncedMap.get(rootContainer);
}
+ public static void applyInsets(Rectangle rect, Insets insets) {
+ if (insets != null) {
+ rect.x += insets.left;
+ rect.y += insets.top;
+ rect.width -= (insets.right + rect.x);
+ rect.height -= (insets.bottom + rect.y);
+ }
+ }
+
+ public static void paintCheckIcon(Graphics g, MenuItemLayoutHelper lh,
+ MenuItemLayoutHelper.LayoutResult lr,
+ Color holdc, Color foreground) {
+ if (lh.getCheckIcon() != null) {
+ ButtonModel model = lh.getMenuItem().getModel();
+ if (model.isArmed() || (lh.getMenuItem() instanceof JMenu
+ && model.isSelected())) {
+ g.setColor(foreground);
+ } else {
+ g.setColor(holdc);
+ }
+ if (lh.useCheckAndArrow()) {
+ lh.getCheckIcon().paintIcon(lh.getMenuItem(), g,
+ lr.getCheckRect().x, lr.getCheckRect().y);
+ }
+ g.setColor(holdc);
+ }
+ }
+
+ public static void paintIcon(Graphics g, MenuItemLayoutHelper lh,
+ MenuItemLayoutHelper.LayoutResult lr, Color holdc) {
+ if (lh.getIcon() != null) {
+ Icon icon;
+ ButtonModel model = lh.getMenuItem().getModel();
+ if (!model.isEnabled()) {
+ icon = lh.getMenuItem().getDisabledIcon();
+ } else if (model.isPressed() && model.isArmed()) {
+ icon = lh.getMenuItem().getPressedIcon();
+ if (icon == null) {
+ // Use default icon
+ icon = lh.getMenuItem().getIcon();
+ }
+ } else {
+ icon = lh.getMenuItem().getIcon();
+ }
+
+ if (icon != null) {
+ icon.paintIcon(lh.getMenuItem(), g, lr.getIconRect().x,
+ lr.getIconRect().y);
+ g.setColor(holdc);
+ }
+ }
+ }
+
+
+ public static void paintAccText(Graphics g, MenuItemLayoutHelper lh,
+ MenuItemLayoutHelper.LayoutResult lr,
+ Color disabledForeground,
+ Color acceleratorSelectionForeground,
+ Color acceleratorForeground) {
+ if (!lh.getAccText().isEmpty()) {
+ ButtonModel model = lh.getMenuItem().getModel();
+ g.setFont(lh.getAccFontMetrics().getFont());
+ if (!model.isEnabled()) {
+
+ // paint the accText disabled
+ if (disabledForeground != null) {
+ g.setColor(disabledForeground);
+ SwingUtilities2.drawString(lh.getMenuItem(), g,
+ lh.getAccText(), lr.getAccRect().x,
+ lr.getAccRect().y + lh.getAccFontMetrics().getAscent());
+ } else {
+ g.setColor(lh.getMenuItem().getBackground().brighter());
+ SwingUtilities2.drawString(lh.getMenuItem(), g,
+ lh.getAccText(), lr.getAccRect().x,
+ lr.getAccRect().y + lh.getAccFontMetrics().getAscent());
+ g.setColor(lh.getMenuItem().getBackground().darker());
+ SwingUtilities2.drawString(lh.getMenuItem(), g,
+ lh.getAccText(), lr.getAccRect().x - 1,
+ lr.getAccRect().y + lh.getFontMetrics().getAscent() - 1);
+ }
+ } else {
+
+ // paint the accText normally
+ if (model.isArmed()
+ || (lh.getMenuItem() instanceof JMenu
+ && model.isSelected())) {
+ g.setColor(acceleratorSelectionForeground);
+ } else {
+ g.setColor(acceleratorForeground);
+ }
+ SwingUtilities2.drawString(lh.getMenuItem(), g, lh.getAccText(),
+ lr.getAccRect().x, lr.getAccRect().y +
+ lh.getAccFontMetrics().getAscent());
+ }
+ }
+ }
+
+ public static void paintArrowIcon(Graphics g, MenuItemLayoutHelper lh,
+ MenuItemLayoutHelper.LayoutResult lr,
+ Color foreground) {
+ if (lh.getArrowIcon() != null) {
+ ButtonModel model = lh.getMenuItem().getModel();
+ if (model.isArmed() || (lh.getMenuItem() instanceof JMenu
+ && model.isSelected())) {
+ g.setColor(foreground);
+ }
+ if (lh.useCheckAndArrow()) {
+ lh.getArrowIcon().paintIcon(lh.getMenuItem(), g,
+ lr.getArrowRect().x, lr.getArrowRect().y);
+ }
+ }
+ }
+
/**
* Returns delegate {@code RepaintManager} for {@code component} hierarchy.
*/
diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java
index ab1a1bce0b6..9efdc860d6d 100644
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxMenuItemUI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -74,6 +74,26 @@ protected void paintBackground(Graphics g, JMenuItem menuItem,
}
super.paintBackground(g, menuItem, bgColor);
}
+
+ /**
+ * Paint MenuItem.
+ */
+ protected void paintMenuItem(Graphics g, JComponent c,
+ Icon checkIcon, Icon arrowIcon,
+ Color background, Color foreground,
+ int defaultTextIconGap) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintMenuItem(accessor, g, c, checkIcon,
+ arrowIcon, background, foreground,
+ disabledForeground, acceleratorSelectionForeground,
+ acceleratorForeground, defaultTextIconGap,
+ menuItem, getPropertyPrefix());
+ return;
+ }
+ super.paintMenuItem(g, c, checkIcon, arrowIcon, background,
+ foreground, defaultTextIconGap);
+ }
+
/**
* Method which renders the text of the current menu item.
*
diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java
index 90bdc929383..7fda45b254f 100644
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -785,6 +785,7 @@ public void paintIcon(Component c, Graphics g, int x, int y) {
}
assert menuItem == null || c == menuItem;
Icon icon = getIcon();
+
if (type == JCheckBoxMenuItem.class
|| type == JRadioButtonMenuItem.class) {
AbstractButton b = (AbstractButton) c;
@@ -808,19 +809,18 @@ public void paintIcon(Component c, Graphics g, int x, int y) {
}
XPStyle xp = XPStyle.getXP();
if (xp != null) {
- Skin skin;
- skin = xp.getSkin(c, backgroundPart);
- skin.paintSkin(g, x, y,
- getIconWidth(), getIconHeight(), backgroundState);
- if (icon == null) {
- skin = xp.getSkin(c, part);
+ Skin skin = xp.getSkin(c, part);
+ if (icon == null || icon.getIconHeight() <= 16) {
skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
+ } else {
+ skin.paintSkin(g, x + OFFSET, y + icon.getIconHeight() / 2, state);
}
}
}
}
if (icon != null) {
- icon.paintIcon(c, g, x + OFFSET, y + OFFSET);
+ icon.paintIcon(c, g, x + VistaMenuItemCheckIconFactory.getIconWidth(),
+ y + OFFSET);
}
}
private static WindowsMenuItemUIAccessor getAccessor(
diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java
index dddbeeb5074..c74f0490eea 100644
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,11 @@
import javax.swing.plaf.basic.*;
import sun.swing.SwingUtilities2;
+import sun.swing.MenuItemLayoutHelper;
import com.sun.java.swing.plaf.windows.TMSchema.*;
import com.sun.java.swing.plaf.windows.XPStyle.*;
+import com.sun.java.swing.SwingUtilities3;
/**
* Windows rendition of the component.
@@ -47,8 +49,8 @@
*
* @author Igor Kushnirskiy
*/
-
public class WindowsMenuItemUI extends BasicMenuItemUI {
+
final WindowsMenuItemUIAccessor accessor =
new WindowsMenuItemUIAccessor() {
@@ -68,6 +70,112 @@ public static ComponentUI createUI(JComponent c) {
return new WindowsMenuItemUI();
}
+ protected void installDefaults() {
+ super.installDefaults();
+ String prefix = getPropertyPrefix();
+
+ if (acceleratorSelectionForeground == null ||
+ acceleratorSelectionForeground instanceof UIResource) {
+ acceleratorSelectionForeground =
+ UIManager.getColor(prefix + ".acceleratorSelectionForeground");
+ }
+ if (acceleratorForeground == null ||
+ acceleratorForeground instanceof UIResource) {
+ acceleratorForeground =
+ UIManager.getColor(prefix + ".acceleratorForeground");
+ }
+ if (disabledForeground == null ||
+ disabledForeground instanceof UIResource) {
+ disabledForeground =
+ UIManager.getColor(prefix + ".disabledForeground");
+ }
+ }
+
+
+ protected void paintMenuItem(Graphics g, JComponent c,
+ Icon checkIcon, Icon arrowIcon,
+ Color background, Color foreground,
+ int defaultTextIconGap) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintMenuItem(accessor, g, c, checkIcon,
+ arrowIcon, background, foreground,
+ disabledForeground, acceleratorSelectionForeground,
+ acceleratorForeground, defaultTextIconGap, menuItem,
+ getPropertyPrefix());
+ return;
+ }
+ super.paintMenuItem(g, c, checkIcon, arrowIcon, background,
+ foreground, defaultTextIconGap);
+ }
+
+ static void paintMenuItem(WindowsMenuItemUIAccessor accessor, Graphics g,
+ JComponent c, Icon checkIcon, Icon arrowIcon,
+ Color background, Color foreground,
+ Color disabledForeground,
+ Color acceleratorSelectionForeground,
+ Color acceleratorForeground,
+ int defaultTextIconGap, JMenuItem menuItem, String prefix) {
+ // Save original graphics font and color
+ Font holdf = g.getFont();
+ Color holdc = g.getColor();
+
+ JMenuItem mi = (JMenuItem) c;
+ g.setFont(mi.getFont());
+
+ Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
+ SwingUtilities3.applyInsets(viewRect, mi.getInsets());
+
+ String acceleratorDelimiter =
+ UIManager.getString("MenuItem.acceleratorDelimiter");
+ if (acceleratorDelimiter == null) { acceleratorDelimiter = "+"; }
+ Font acceleratorFont = UIManager.getFont("MenuItem.acceleratorFont");
+ if (acceleratorFont == null) {
+ acceleratorFont = UIManager.getFont("MenuItem.font");
+ }
+
+ MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
+ arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter,
+ mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
+ acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem),
+ prefix);
+ MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
+
+ paintBackground(accessor, g, mi, background);
+ SwingUtilities3.paintCheckIcon(g, lh, lr, holdc, foreground);
+ SwingUtilities3.paintIcon(g, lh, lr, holdc);
+
+ if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
+ Rectangle rect = lr.getTextRect();
+
+ rect.x += lh.getAfterCheckIconGap();
+
+ lr.setTextRect(rect);
+ }
+ if (!lh.getText().isEmpty()) {
+ if (lh.getHtmlView() != null) {
+ // Text is HTML
+ lh.getHtmlView().paint(g, lr.getTextRect());
+ } else {
+ // Text isn't HTML
+ paintText(accessor, g, lh.getMenuItem(),
+ lr.getTextRect(), lh.getText());
+ }
+ }
+ if (lh.getCheckIcon() != null && lh.useCheckAndArrow()) {
+ Rectangle rect = lr.getAccRect();
+ rect.x += lh.getAfterCheckIconGap();
+ lr.setAccRect(rect);
+ }
+ SwingUtilities3.paintAccText(g, lh, lr, disabledForeground,
+ acceleratorSelectionForeground,
+ acceleratorForeground);
+ SwingUtilities3.paintArrowIcon(g, lh, lr, foreground);
+
+ // Restore original graphics font and color
+ g.setColor(holdc);
+ g.setFont(holdf);
+ }
+
/**
* Method which renders the text of the current menu item.
*
diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java
index a2e7795cfe3..c5bd54edf2f 100644
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsMenuUI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -123,6 +123,26 @@ protected void installDefaults() {
hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
}
+ /**
+ * Paint MenuItem.
+ */
+ protected void paintMenuItem(Graphics g, JComponent c,
+ Icon checkIcon, Icon arrowIcon,
+ Color background, Color foreground,
+ int defaultTextIconGap) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintMenuItem(accessor, g, c, checkIcon, arrowIcon,
+ background, foreground,
+ disabledForeground, acceleratorSelectionForeground,
+ acceleratorForeground, defaultTextIconGap, menuItem,
+ getPropertyPrefix());
+ return;
+ }
+ super.paintMenuItem(g, c, checkIcon, arrowIcon, background,
+ foreground, defaultTextIconGap);
+ }
+
+
/**
* Draws the background of the menu.
* @since 1.4
diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java
index c43876f38b4..41bcfb7b868 100644
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonMenuItemUI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -74,6 +74,25 @@ protected void paintBackground(Graphics g, JMenuItem menuItem,
super.paintBackground(g, menuItem, bgColor);
}
+ /**
+ * Paint MenuItem.
+ */
+ protected void paintMenuItem(Graphics g, JComponent c,
+ Icon checkIcon, Icon arrowIcon,
+ Color background, Color foreground,
+ int defaultTextIconGap) {
+ if (WindowsMenuItemUI.isVistaPainting()) {
+ WindowsMenuItemUI.paintMenuItem(accessor, g, c, checkIcon,
+ arrowIcon, background, foreground,
+ disabledForeground, acceleratorSelectionForeground,
+ acceleratorForeground, defaultTextIconGap,
+ menuItem, getPropertyPrefix());
+ return;
+ }
+ super.paintMenuItem(g, c, checkIcon, arrowIcon, background,
+ foreground, defaultTextIconGap);
+ }
+
/**
* Method which renders the text of the current menu item.
*
diff --git a/jdk/src/share/classes/java/util/Currency.java b/jdk/src/share/classes/java/util/Currency.java
index 09d97f89fac..5305a3a38cc 100644
--- a/jdk/src/share/classes/java/util/Currency.java
+++ b/jdk/src/share/classes/java/util/Currency.java
@@ -147,33 +147,13 @@ public final class Currency implements Serializable {
// - bits 0-4: final char for currency code for simple country, or ID of special case
// - special case IDs:
// - 0: country has no currency
- // - other: index into sc* arrays + 1
- // - scCutOverTimes: cut-over time in millis as returned by
- // System.currentTimeMillis for special case countries that are changing
- // currencies; Long.MAX_VALUE for countries that are not changing currencies
- // - scOldCurrencies: old currencies for special case countries
- // - scNewCurrencies: new currencies for special case countries that are
- // changing currencies; null for others
- // - scOldCurrenciesDFD: default fraction digits for old currencies
- // - scNewCurrenciesDFD: default fraction digits for new currencies, 0 for
- // countries that are not changing currencies
- // - otherCurrencies: concatenation of all currency codes that are not the
- // main currency of a simple country, separated by "-"
- // - otherCurrenciesDFD: decimal format digits for currencies in otherCurrencies, same order
+ // - other: index into specialCasesList
static int formatVersion;
static int dataVersion;
static int[] mainTable;
- static long[] scCutOverTimes;
- static String[] scOldCurrencies;
- static String[] scNewCurrencies;
- static int[] scOldCurrenciesDFD;
- static int[] scNewCurrenciesDFD;
- static int[] scOldCurrenciesNumericCode;
- static int[] scNewCurrenciesNumericCode;
- static String otherCurrencies;
- static int[] otherCurrenciesDFD;
- static int[] otherCurrenciesNumericCode;
+ static List specialCasesList;
+ static List otherCurrenciesList;
// handy constants - must match definitions in GenerateCurrencyData
// magic number
@@ -208,7 +188,7 @@ public final class Currency implements Serializable {
private static final int NUMERIC_CODE_SHIFT = 10;
// Currency data format version
- private static final int VALID_FORMAT_VERSION = 2;
+ private static final int VALID_FORMAT_VERSION = 3;
static {
AccessController.doPrivileged(new PrivilegedAction() {
@@ -231,17 +211,9 @@ public Void run() {
dataVersion = dis.readInt();
mainTable = readIntArray(dis, A_TO_Z * A_TO_Z);
int scCount = dis.readInt();
- scCutOverTimes = readLongArray(dis, scCount);
- scOldCurrencies = readStringArray(dis, scCount);
- scNewCurrencies = readStringArray(dis, scCount);
- scOldCurrenciesDFD = readIntArray(dis, scCount);
- scNewCurrenciesDFD = readIntArray(dis, scCount);
- scOldCurrenciesNumericCode = readIntArray(dis, scCount);
- scNewCurrenciesNumericCode = readIntArray(dis, scCount);
+ specialCasesList = readSpecialCases(dis, scCount);
int ocCount = dis.readInt();
- otherCurrencies = dis.readUTF();
- otherCurrenciesDFD = readIntArray(dis, ocCount);
- otherCurrenciesNumericCode = readIntArray(dis, ocCount);
+ otherCurrenciesList = readOtherCurrencies(dis, ocCount);
}
} catch (IOException e) {
throw new InternalError(e);
@@ -324,6 +296,7 @@ private static Currency getInstance(String currencyCode, int defaultFractionDigi
// Currency code not internally generated, need to verify first
// A currency code must have 3 characters and exist in the main table
// or in the list of other currencies.
+ boolean found = false;
if (currencyCode.length() != 3) {
throw new IllegalArgumentException();
}
@@ -335,17 +308,23 @@ private static Currency getInstance(String currencyCode, int defaultFractionDigi
&& currencyCode.charAt(2) - 'A' == (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK)) {
defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT;
numericCode = (tableEntry & NUMERIC_CODE_MASK) >> NUMERIC_CODE_SHIFT;
- } else {
- // Check for '-' separately so we don't get false hits in the table.
- if (currencyCode.charAt(2) == '-') {
- throw new IllegalArgumentException();
+ found = true;
+ } else { //special case
+ int[] fractionAndNumericCode = SpecialCaseEntry.findEntry(currencyCode);
+ if (fractionAndNumericCode != null) {
+ defaultFractionDigits = fractionAndNumericCode[0];
+ numericCode = fractionAndNumericCode[1];
+ found = true;
}
- int index = otherCurrencies.indexOf(currencyCode);
- if (index == -1) {
+ }
+
+ if (!found) {
+ OtherCurrencyEntry ocEntry = OtherCurrencyEntry.findEntry(currencyCode);
+ if (ocEntry == null) {
throw new IllegalArgumentException();
}
- defaultFractionDigits = otherCurrenciesDFD[index / 4];
- numericCode = otherCurrenciesNumericCode[index / 4];
+ defaultFractionDigits = ocEntry.fraction;
+ numericCode = ocEntry.numericCode;
}
}
@@ -405,13 +384,17 @@ public static Currency getInstance(Locale locale) {
if (tableEntry == COUNTRY_WITHOUT_CURRENCY_ENTRY) {
return null;
} else {
- int index = (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA;
- if (scCutOverTimes[index] == Long.MAX_VALUE || System.currentTimeMillis() < scCutOverTimes[index]) {
- return getInstance(scOldCurrencies[index], scOldCurrenciesDFD[index],
- scOldCurrenciesNumericCode[index]);
+ int index = SpecialCaseEntry.toIndex(tableEntry);
+ SpecialCaseEntry scEntry = specialCasesList.get(index);
+ if (scEntry.cutOverTime == Long.MAX_VALUE
+ || System.currentTimeMillis() < scEntry.cutOverTime) {
+ return getInstance(scEntry.oldCurrency,
+ scEntry.oldCurrencyFraction,
+ scEntry.oldCurrencyNumericCode);
} else {
- return getInstance(scNewCurrencies[index], scNewCurrenciesDFD[index],
- scNewCurrenciesNumericCode[index]);
+ return getInstance(scEntry.newCurrency,
+ scEntry.newCurrencyFraction,
+ scEntry.newCurrencyNumericCode);
}
}
}
@@ -446,14 +429,29 @@ public static Set getAvailableCurrencies() {
sb.append(c2);
sb.append(finalChar);
available.add(getInstance(sb.toString(), defaultFractionDigits, numericCode));
+ } else if ((tableEntry & COUNTRY_TYPE_MASK) == SPECIAL_CASE_COUNTRY_MASK
+ && tableEntry != INVALID_COUNTRY_ENTRY
+ && tableEntry != COUNTRY_WITHOUT_CURRENCY_ENTRY) {
+ int index = SpecialCaseEntry.toIndex(tableEntry);
+ SpecialCaseEntry scEntry = specialCasesList.get(index);
+
+ if (scEntry.cutOverTime == Long.MAX_VALUE
+ || System.currentTimeMillis() < scEntry.cutOverTime) {
+ available.add(getInstance(scEntry.oldCurrency,
+ scEntry.oldCurrencyFraction,
+ scEntry.oldCurrencyNumericCode));
+ } else {
+ available.add(getInstance(scEntry.newCurrency,
+ scEntry.newCurrencyFraction,
+ scEntry.newCurrencyNumericCode));
+ }
}
}
}
// Now add other currencies
- StringTokenizer st = new StringTokenizer(otherCurrencies, "-");
- while (st.hasMoreElements()) {
- available.add(getInstance((String)st.nextElement()));
+ for (OtherCurrencyEntry entry : otherCurrenciesList) {
+ available.add(getInstance(entry.currencyCode));
}
}
}
@@ -659,22 +657,55 @@ private static int[] readIntArray(DataInputStream dis, int count) throws IOExcep
return ret;
}
- private static long[] readLongArray(DataInputStream dis, int count) throws IOException {
- long[] ret = new long[count];
+ private static List readSpecialCases(DataInputStream dis,
+ int count)
+ throws IOException {
+
+ List list = new ArrayList<>(count);
+ long cutOverTime;
+ String oldCurrency;
+ String newCurrency;
+ int oldCurrencyFraction;
+ int newCurrencyFraction;
+ int oldCurrencyNumericCode;
+ int newCurrencyNumericCode;
+
for (int i = 0; i < count; i++) {
- ret[i] = dis.readLong();
+ cutOverTime = dis.readLong();
+ oldCurrency = dis.readUTF();
+ newCurrency = dis.readUTF();
+ oldCurrencyFraction = dis.readInt();
+ newCurrencyFraction = dis.readInt();
+ oldCurrencyNumericCode = dis.readInt();
+ newCurrencyNumericCode = dis.readInt();
+ SpecialCaseEntry sc = new SpecialCaseEntry(cutOverTime,
+ oldCurrency, newCurrency,
+ oldCurrencyFraction, newCurrencyFraction,
+ oldCurrencyNumericCode, newCurrencyNumericCode);
+ list.add(sc);
}
-
- return ret;
+ return list;
}
- private static String[] readStringArray(DataInputStream dis, int count) throws IOException {
- String[] ret = new String[count];
+ private static List readOtherCurrencies(DataInputStream dis,
+ int count)
+ throws IOException {
+
+ List list = new ArrayList<>(count);
+ String currencyCode;
+ int fraction;
+ int numericCode;
+
for (int i = 0; i < count; i++) {
- ret[i] = dis.readUTF();
+ currencyCode = dis.readUTF();
+ fraction = dis.readInt();
+ numericCode = dis.readInt();
+ OtherCurrencyEntry oc = new OtherCurrencyEntry(currencyCode,
+ fraction,
+ numericCode);
+ list.add(oc);
}
-
- return ret;
+ return list;
}
/**
@@ -732,21 +763,27 @@ private static void replaceCurrencyData(Pattern pattern, String ctry, String cur
return;
}
- int index;
- for (index = 0; index < scOldCurrencies.length; index++) {
- if (scOldCurrencies[index].equals(code)) {
- break;
- }
+ int index = SpecialCaseEntry.indexOf(code, fraction, numeric);
+
+ /* if a country switches from simple case to special case or
+ * one special case to other special case which is not present
+ * in the sc arrays then insert the new entry in special case arrays
+ */
+ if (index == -1 && (ctry.charAt(0) != code.charAt(0)
+ || ctry.charAt(1) != code.charAt(1))) {
+
+ specialCasesList.add(new SpecialCaseEntry(code, fraction, numeric));
+ index = specialCasesList.size() - 1;
}
- if (index == scOldCurrencies.length) {
+ if (index == -1) {
// simple case
- entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT) |
- (code.charAt(2) - 'A');
+ entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT)
+ | (code.charAt(2) - 'A');
} else {
// special case
- entry |= SPECIAL_CASE_COUNTRY_MASK |
- (index + SPECIAL_CASE_COUNTRY_INDEX_DELTA);
+ entry = SPECIAL_CASE_COUNTRY_MASK
+ | (index + SPECIAL_CASE_COUNTRY_INDEX_DELTA);
}
setMainTableEntry(ctry.charAt(0), ctry.charAt(1), entry);
}
@@ -780,4 +817,126 @@ private static void info(String message, Throwable t) {
}
}
}
+
+ /* Used to represent a special case currency entry
+ * - cutOverTime: cut-over time in millis as returned by
+ * System.currentTimeMillis for special case countries that are changing
+ * currencies; Long.MAX_VALUE for countries that are not changing currencies
+ * - oldCurrency: old currencies for special case countries
+ * - newCurrency: new currencies for special case countries that are
+ * changing currencies; null for others
+ * - oldCurrencyFraction: default fraction digits for old currencies
+ * - newCurrencyFraction: default fraction digits for new currencies, 0 for
+ * countries that are not changing currencies
+ * - oldCurrencyNumericCode: numeric code for old currencies
+ * - newCurrencyNumericCode: numeric code for new currencies, 0 for countries
+ * that are not changing currencies
+ */
+ private static class SpecialCaseEntry {
+
+ final private long cutOverTime;
+ final private String oldCurrency;
+ final private String newCurrency;
+ final private int oldCurrencyFraction;
+ final private int newCurrencyFraction;
+ final private int oldCurrencyNumericCode;
+ final private int newCurrencyNumericCode;
+
+ private SpecialCaseEntry(long cutOverTime, String oldCurrency, String newCurrency,
+ int oldCurrencyFraction, int newCurrencyFraction,
+ int oldCurrencyNumericCode, int newCurrencyNumericCode) {
+ this.cutOverTime = cutOverTime;
+ this.oldCurrency = oldCurrency;
+ this.newCurrency = newCurrency;
+ this.oldCurrencyFraction = oldCurrencyFraction;
+ this.newCurrencyFraction = newCurrencyFraction;
+ this.oldCurrencyNumericCode = oldCurrencyNumericCode;
+ this.newCurrencyNumericCode = newCurrencyNumericCode;
+ }
+
+ private SpecialCaseEntry(String currencyCode, int fraction,
+ int numericCode) {
+ this(Long.MAX_VALUE, currencyCode, "", fraction, 0, numericCode, 0);
+ }
+
+ //get the index of the special case entry
+ private static int indexOf(String code, int fraction, int numeric) {
+ int size = specialCasesList.size();
+ for (int index = 0; index < size; index++) {
+ SpecialCaseEntry scEntry = specialCasesList.get(index);
+ if (scEntry.oldCurrency.equals(code)
+ && scEntry.oldCurrencyFraction == fraction
+ && scEntry.oldCurrencyNumericCode == numeric
+ && scEntry.cutOverTime == Long.MAX_VALUE) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ // get the fraction and numericCode of the sc currencycode
+ private static int[] findEntry(String code) {
+ int[] fractionAndNumericCode = null;
+ int size = specialCasesList.size();
+ for (int index = 0; index < size; index++) {
+ SpecialCaseEntry scEntry = specialCasesList.get(index);
+ if (scEntry.oldCurrency.equals(code) && (scEntry.cutOverTime == Long.MAX_VALUE
+ || System.currentTimeMillis() < scEntry.cutOverTime)) {
+ //consider only when there is no new currency or cutover time is not passed
+ fractionAndNumericCode = new int[2];
+ fractionAndNumericCode[0] = scEntry.oldCurrencyFraction;
+ fractionAndNumericCode[1] = scEntry.oldCurrencyNumericCode;
+ break;
+ } else if (scEntry.newCurrency.equals(code)
+ && System.currentTimeMillis() >= scEntry.cutOverTime) {
+ //consider only if the cutover time is passed
+ fractionAndNumericCode = new int[2];
+ fractionAndNumericCode[0] = scEntry.newCurrencyFraction;
+ fractionAndNumericCode[1] = scEntry.newCurrencyNumericCode;
+ break;
+ }
+ }
+ return fractionAndNumericCode;
+ }
+
+ // convert the special case entry to sc arrays index
+ private static int toIndex(int tableEntry) {
+ return (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA;
+ }
+
+ }
+
+ /* Used to represent Other currencies
+ * - currencyCode: currency codes that are not the main currency
+ * of a simple country
+ * - otherCurrenciesDFD: decimal format digits for other currencies
+ * - otherCurrenciesNumericCode: numeric code for other currencies
+ */
+ private static class OtherCurrencyEntry {
+
+ final private String currencyCode;
+ final private int fraction;
+ final private int numericCode;
+
+ private OtherCurrencyEntry(String currencyCode, int fraction,
+ int numericCode) {
+ this.currencyCode = currencyCode;
+ this.fraction = fraction;
+ this.numericCode = numericCode;
+ }
+
+ //get the instance of the other currency code
+ private static OtherCurrencyEntry findEntry(String code) {
+ int size = otherCurrenciesList.size();
+ for (int index = 0; index < size; index++) {
+ OtherCurrencyEntry ocEntry = otherCurrenciesList.get(index);
+ if (ocEntry.currencyCode.equalsIgnoreCase(code)) {
+ return ocEntry;
+ }
+ }
+ return null;
+ }
+
+ }
+
}
diff --git a/jdk/src/share/classes/java/util/CurrencyData.properties b/jdk/src/share/classes/java/util/CurrencyData.properties
index 79becc3e6d0..7d1b74b5d1a 100644
--- a/jdk/src/share/classes/java/util/CurrencyData.properties
+++ b/jdk/src/share/classes/java/util/CurrencyData.properties
@@ -26,12 +26,13 @@
# Version of the currency data format.
# 1: initial
# 2: Change in minor unit (allowing 4-9 digits)
-formatVersion=2
+# 3: Change in the order of special case and other currency entries
+formatVersion=3
# Version of the currency code information in this class.
# It is a serial number that accompanies with each amendment.
-dataVersion=179
+dataVersion=180
# List of all valid ISO 4217 currency codes.
# To ensure compatibility, do not remove codes.
@@ -146,7 +147,7 @@ IO=USD
# BRUNEI DARUSSALAM
BN=BND
# BULGARIA
-BG=BGN
+BG=BGN;2025-12-31-22-00-00;EUR
# BURKINA FASO
BF=XOF
# BURUNDI
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
index 54994b61e3b..0467cf11d4d 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,52 @@
package javax.swing.plaf.basic;
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.*;
+import javax.swing.ButtonModel;
+import javax.swing.Icon;
+import javax.swing.InputMap;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.KeyStroke;
+import javax.swing.LookAndFeel;
+import javax.swing.MenuElement;
+import javax.swing.MenuSelectionManager;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.event.MenuDragMouseEvent;
+import javax.swing.event.MenuDragMouseListener;
+import javax.swing.event.MenuKeyListener;
+
+import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ComponentInputMapUIResource;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuItemUI;
+import javax.swing.plaf.UIResource;
import javax.swing.text.View;
-import sun.swing.*;
+import com.sun.java.swing.SwingUtilities3;
+import sun.swing.MenuItemCheckIconFactory;
+import sun.swing.MenuItemLayoutHelper;
+import sun.swing.SwingUtilities2;
+import sun.swing.UIAction;
+
/**
* BasicMenuItem implementation
@@ -561,84 +596,21 @@ protected void paintMenuItem(Graphics g, JComponent c,
private void paintIcon(Graphics g, MenuItemLayoutHelper lh,
MenuItemLayoutHelper.LayoutResult lr, Color holdc) {
- if (lh.getIcon() != null) {
- Icon icon;
- ButtonModel model = lh.getMenuItem().getModel();
- if (!model.isEnabled()) {
- icon = lh.getMenuItem().getDisabledIcon();
- } else if (model.isPressed() && model.isArmed()) {
- icon = lh.getMenuItem().getPressedIcon();
- if (icon == null) {
- // Use default icon
- icon = lh.getMenuItem().getIcon();
- }
- } else {
- icon = lh.getMenuItem().getIcon();
- }
-
- if (icon != null) {
- icon.paintIcon(lh.getMenuItem(), g, lr.getIconRect().x,
- lr.getIconRect().y);
- g.setColor(holdc);
- }
- }
+ SwingUtilities3.paintIcon(g, lh, lr, holdc);
}
private void paintCheckIcon(Graphics g, MenuItemLayoutHelper lh,
MenuItemLayoutHelper.LayoutResult lr,
Color holdc, Color foreground) {
- if (lh.getCheckIcon() != null) {
- ButtonModel model = lh.getMenuItem().getModel();
- if (model.isArmed() || (lh.getMenuItem() instanceof JMenu
- && model.isSelected())) {
- g.setColor(foreground);
- } else {
- g.setColor(holdc);
- }
- if (lh.useCheckAndArrow()) {
- lh.getCheckIcon().paintIcon(lh.getMenuItem(), g,
- lr.getCheckRect().x, lr.getCheckRect().y);
- }
- g.setColor(holdc);
- }
+ SwingUtilities3.paintCheckIcon(g, lh, lr, holdc, foreground);
}
private void paintAccText(Graphics g, MenuItemLayoutHelper lh,
MenuItemLayoutHelper.LayoutResult lr) {
- if (!lh.getAccText().equals("")) {
- ButtonModel model = lh.getMenuItem().getModel();
- g.setFont(lh.getAccFontMetrics().getFont());
- if (!model.isEnabled()) {
- // *** paint the accText disabled
- if (disabledForeground != null) {
- g.setColor(disabledForeground);
- SwingUtilities2.drawString(lh.getMenuItem(), g,
- lh.getAccText(), lr.getAccRect().x,
- lr.getAccRect().y + lh.getAccFontMetrics().getAscent());
- } else {
- g.setColor(lh.getMenuItem().getBackground().brighter());
- SwingUtilities2.drawString(lh.getMenuItem(), g,
- lh.getAccText(), lr.getAccRect().x,
- lr.getAccRect().y + lh.getAccFontMetrics().getAscent());
- g.setColor(lh.getMenuItem().getBackground().darker());
- SwingUtilities2.drawString(lh.getMenuItem(), g,
- lh.getAccText(), lr.getAccRect().x - 1,
- lr.getAccRect().y + lh.getFontMetrics().getAscent() - 1);
- }
- } else {
- // *** paint the accText normally
- if (model.isArmed()
- || (lh.getMenuItem() instanceof JMenu
- && model.isSelected())) {
- g.setColor(acceleratorSelectionForeground);
- } else {
- g.setColor(acceleratorForeground);
- }
- SwingUtilities2.drawString(lh.getMenuItem(), g, lh.getAccText(),
- lr.getAccRect().x, lr.getAccRect().y +
- lh.getAccFontMetrics().getAscent());
- }
- }
+ SwingUtilities3.paintAccText(g, lh, lr,
+ disabledForeground,
+ acceleratorSelectionForeground,
+ acceleratorForeground);
}
private void paintText(Graphics g, MenuItemLayoutHelper lh,
@@ -657,26 +629,11 @@ private void paintText(Graphics g, MenuItemLayoutHelper lh,
private void paintArrowIcon(Graphics g, MenuItemLayoutHelper lh,
MenuItemLayoutHelper.LayoutResult lr,
Color foreground) {
- if (lh.getArrowIcon() != null) {
- ButtonModel model = lh.getMenuItem().getModel();
- if (model.isArmed() || (lh.getMenuItem() instanceof JMenu
- && model.isSelected())) {
- g.setColor(foreground);
- }
- if (lh.useCheckAndArrow()) {
- lh.getArrowIcon().paintIcon(lh.getMenuItem(), g,
- lr.getArrowRect().x, lr.getArrowRect().y);
- }
- }
+ SwingUtilities3.paintArrowIcon(g, lh, lr, foreground);
}
private void applyInsets(Rectangle rect, Insets insets) {
- if(insets != null) {
- rect.x += insets.left;
- rect.y += insets.top;
- rect.width -= (insets.right + rect.x);
- rect.height -= (insets.bottom + rect.y);
- }
+ SwingUtilities3.applyInsets(rect, insets);
}
/**
diff --git a/jdk/src/share/classes/sun/security/util/DerValue.java b/jdk/src/share/classes/sun/security/util/DerValue.java
index b7d1714769e..2dd262ba993 100644
--- a/jdk/src/share/classes/sun/security/util/DerValue.java
+++ b/jdk/src/share/classes/sun/security/util/DerValue.java
@@ -822,6 +822,22 @@ public boolean equals(Object o) {
doEquals(other, this);
}
+ /**
+ * Checks that the BMPString does not contain any surrogate characters,
+ * which are outside the Basic Multilingual Plane.
+ *
+ * @throws IOException if illegal characters are detected
+ */
+ public void validateBMPString() throws IOException {
+ String bmpString = getBMPString();
+ for (int i = 0; i < bmpString.length(); i++) {
+ if (Character.isSurrogate(bmpString.charAt(i))) {
+ throw new IOException(
+ "Illegal character in BMPString, index: " + i);
+ }
+ }
+ }
+
/**
* Helper for public method equals()
*/
diff --git a/jdk/src/share/classes/sun/security/validator/EntrustTLSPolicy.java b/jdk/src/share/classes/sun/security/validator/EntrustTLSPolicy.java
index 7a67199a1a3..51b6450072e 100644
--- a/jdk/src/share/classes/sun/security/validator/EntrustTLSPolicy.java
+++ b/jdk/src/share/classes/sun/security/validator/EntrustTLSPolicy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* 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,19 +75,7 @@ final class EntrustTLSPolicy {
// OU=(c) 1999 Entrust.net Limited,
// OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),
// O=Entrust.net
- "6DC47172E01CBCB0BF62580D895FE2B8AC9AD4F873801E0C10B9C837D21EB177",
- // cacerts alias: affirmtrustcommercialca
- // DN: CN=AffirmTrust Commercial, O=AffirmTrust, C=US
- "0376AB1D54C5F9803CE4B2E201A0EE7EEF7B57B636E8A93C9B8D4860C96F5FA7",
- // cacerts alias: affirmtrustnetworkingca
- // DN: CN=AffirmTrust Networking, O=AffirmTrust, C=US
- "0A81EC5A929777F145904AF38D5D509F66B5E2C58FCDB531058B0E17F3F0B41B",
- // cacerts alias: affirmtrustpremiumca
- // DN: CN=AffirmTrust Premium, O=AffirmTrust, C=US
- "70A73F7F376B60074248904534B11482D5BF0E698ECC498DF52577EBF2E93B9A",
- // cacerts alias: affirmtrustpremiumeccca
- // DN: CN=AffirmTrust Premium ECC, O=AffirmTrust, C=US
- "BD71FDF6DA97E4CF62D1647ADD2581B07D79ADF8397EB4ECBA9C5E8488821423"
+ "6DC47172E01CBCB0BF62580D895FE2B8AC9AD4F873801E0C10B9C837D21EB177"
)));
// Any TLS Server certificate that is anchored by one of the Entrust
diff --git a/jdk/src/share/classes/sun/security/x509/AVA.java b/jdk/src/share/classes/sun/security/x509/AVA.java
index 8665745c350..f896b8d6e8e 100644
--- a/jdk/src/share/classes/sun/security/x509/AVA.java
+++ b/jdk/src/share/classes/sun/security/x509/AVA.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
* 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,9 +30,14 @@
import java.io.OutputStream;
import java.io.Reader;
import java.security.AccessController;
+import java.nio.charset.Charset;
import java.text.Normalizer;
import java.util.*;
+import static java.nio.charset.StandardCharsets.ISO_8859_1;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.nio.charset.StandardCharsets.UTF_16BE;
+
import sun.security.action.GetBooleanAction;
import sun.security.util.*;
import sun.security.pkcs.PKCS9Attribute;
@@ -606,6 +611,10 @@ private static boolean trailingSpace(Reader in) throws IOException {
throw new IOException("AVA, extra bytes = "
+ derval.data.available());
}
+
+ if (value.tag == DerValue.tag_BMPString) {
+ value.validateBMPString();
+ }
}
AVA(DerInputStream in) throws IOException {
@@ -753,7 +762,7 @@ public String toRFC2253String(Map oidMap) {
*/
String valStr = null;
try {
- valStr = new String(value.getDataBytes(), "UTF8");
+ valStr = new String(value.getDataBytes(), getCharset(value, false));
} catch (IOException ie) {
throw new IllegalArgumentException("DER Value conversion");
}
@@ -906,7 +915,7 @@ public String toRFC2253CanonicalString() {
*/
String valStr = null;
try {
- valStr = new String(value.getDataBytes(), "UTF8");
+ valStr = new String(value.getDataBytes(), getCharset(value, true));
} catch (IOException ie) {
throw new IllegalArgumentException("DER Value conversion");
}
@@ -1026,6 +1035,46 @@ private static boolean isDerString(DerValue value, boolean canonical) {
}
}
+ /*
+ * Returns the charset that should be used to decode each DN string type.
+ *
+ * This method ensures that multi-byte (UTF8String and BMPString) types
+ * are decoded using the correct charset and the String forms represent
+ * the correct characters. For 8-bit ASCII-based types (PrintableString
+ * and IA5String), we return ISO_8859_1 rather than ASCII, so that the
+ * complete range of characters can be represented, as many certificates
+ * do not comply with the Internationalized Domain Name ACE format.
+ *
+ * NOTE: this method only supports DirectoryStrings of the types returned
+ * by isDerString().
+ */
+ private static Charset getCharset(DerValue value, boolean canonical) {
+ if (canonical) {
+ switch (value.tag) {
+ case DerValue.tag_PrintableString:
+ return ISO_8859_1;
+ case DerValue.tag_UTF8String:
+ return UTF_8;
+ default:
+ throw new Error("unexpected tag: " + value.tag);
+ }
+ }
+
+ switch (value.tag) {
+ case DerValue.tag_PrintableString:
+ case DerValue.tag_T61String:
+ case DerValue.tag_IA5String:
+ case DerValue.tag_GeneralString:
+ return ISO_8859_1;
+ case DerValue.tag_BMPString:
+ return UTF_16BE;
+ case DerValue.tag_UTF8String:
+ return UTF_8;
+ default:
+ throw new Error("unexpected tag: " + value.tag);
+ }
+ }
+
boolean hasRFC2253Keyword() {
return AVAKeyword.hasKeyword(oid, RFC2253);
}
diff --git a/jdk/src/share/native/common/check_code.c b/jdk/src/share/native/common/check_code.c
index 799b8c654c0..0889c57f49d 100644
--- a/jdk/src/share/native/common/check_code.c
+++ b/jdk/src/share/native/common/check_code.c
@@ -396,7 +396,8 @@ static jboolean is_superclass(context_type *, fullinfo_type);
static void initialize_exception_table(context_type *);
static int instruction_length(unsigned char *iptr, unsigned char *end);
-static jboolean isLegalTarget(context_type *, int offset);
+static jboolean isLegalOffset(context_type *, int bci, int offset);
+static jboolean isLegalTarget(context_type *, int target);
static void verify_constant_pool_type(context_type *, int, unsigned);
static void initialize_dataflow(context_type *);
@@ -1161,9 +1162,9 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
case JVM_OPC_goto: {
/* Set the ->operand to be the instruction number of the target. */
int jump = (((signed char)(code[offset+1])) << 8) + code[offset+2];
- int target = offset + jump;
- if (!isLegalTarget(context, target))
+ if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal target of jump or branch");
+ int target = offset + jump;
this_idata->operand.i = code_data[target];
break;
}
@@ -1177,9 +1178,9 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
int jump = (((signed char)(code[offset+1])) << 24) +
(code[offset+2] << 16) + (code[offset+3] << 8) +
(code[offset + 4]);
- int target = offset + jump;
- if (!isLegalTarget(context, target))
+ if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal target of jump or branch");
+ int target = offset + jump;
this_idata->operand.i = code_data[target];
break;
}
@@ -1218,13 +1219,16 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
}
}
saved_operand = NEW(int, keys + 2);
- if (!isLegalTarget(context, offset + _ck_ntohl(lpc[0])))
+ int jump = _ck_ntohl(lpc[0]);
+ if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal default target in switch");
- saved_operand[keys + 1] = code_data[offset + _ck_ntohl(lpc[0])];
+ int target = offset + jump;
+ saved_operand[keys + 1] = code_data[target];
for (k = keys, lptr = &lpc[3]; --k >= 0; lptr += delta) {
- int target = offset + _ck_ntohl(lptr[0]);
- if (!isLegalTarget(context, target))
+ jump = _ck_ntohl(lptr[0]);
+ if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal branch in tableswitch");
+ target = offset + jump;
saved_operand[k + 1] = code_data[target];
}
saved_operand[0] = keys + 1; /* number of successors */
@@ -1746,11 +1750,24 @@ static int instruction_length(unsigned char *iptr, unsigned char *end)
/* Given the target of a branch, make sure that it's a legal target. */
static jboolean
-isLegalTarget(context_type *context, int offset)
+isLegalTarget(context_type *context, int target)
+{
+ int code_length = context->code_length;
+ int *code_data = context->code_data;
+ return (target >= 0 && target < code_length && code_data[target] >= 0);
+}
+
+/* Given a bci and offset, make sure the offset is valid and the target is legal */
+static jboolean
+isLegalOffset(context_type *context, int bci, int offset)
{
int code_length = context->code_length;
int *code_data = context->code_data;
- return (offset >= 0 && offset < code_length && code_data[offset] >= 0);
+ int max_offset = 65535; // JVMS 4.11
+ int min_offset = -65535;
+ if (offset < min_offset || offset > max_offset) return JNI_FALSE;
+ int target = bci + offset;
+ return (target >= 0 && target < code_length && code_data[target] >= 0);
}
diff --git a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
index a9b8aa6fb61..6b67fc75479 100644
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
@@ -321,37 +321,33 @@ Java_java_net_Inet4AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
*/
JNIEXPORT jstring JNICALL
Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
- char hostname[NI_MAXHOST+1];
+ char hostname[NI_MAXHOST + 1];
hostname[0] = '\0';
if (gethostname(hostname, NI_MAXHOST)) {
- /* Something went wrong, maybe networking is not setup? */
strcpy(hostname, "localhost");
} else {
+#if defined(__solaris__)
+ // try to resolve hostname via nameservice
+ // if it is known but getnameinfo fails, hostname will still be the
+ // value from gethostname
struct addrinfo hints, *res;
- int error;
+ // make sure string is null-terminated
hostname[NI_MAXHOST] = '\0';
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_INET;
- error = getaddrinfo(hostname, NULL, &hints, &res);
-
- if (error == 0) {/* host is known to name service */
- getnameinfo(res->ai_addr,
- res->ai_addrlen,
- hostname,
- NI_MAXHOST,
- NULL,
- 0,
- NI_NAMEREQD);
-
- /* if getnameinfo fails hostname is still the value
- from gethostname */
-
+ if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
+ getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST,
+ NULL, 0, NI_NAMEREQD);
freeaddrinfo(res);
}
+#else
+ // make sure string is null-terminated
+ hostname[NI_MAXHOST] = '\0';
+#endif
}
return (*env)->NewStringUTF(env, hostname);
}
diff --git a/jdk/src/solaris/native/java/net/bsd_close.c b/jdk/src/solaris/native/java/net/bsd_close.c
index 14739b12caf..cb9447d8415 100644
--- a/jdk/src/solaris/native/java/net/bsd_close.c
+++ b/jdk/src/solaris/native/java/net/bsd_close.c
@@ -39,6 +39,7 @@
#include
#include
#include
+#include "jvm.h"
/*
* Stack allocated by thread when doing blocking operation
@@ -347,66 +348,66 @@ int NET_SocketClose(int fd) {
/************** Basic I/O operations here ***************/
/*
- * Macro to perform a blocking IO operation. Restarts
- * automatically if interrupted by signal (other than
- * our wakeup signal)
+ * Macro to perform a blocking IO operation.
+ * If interrupted by signal (other than our wakeup signal), and if RETRY is true,
+ * then restarts automatically
*/
-#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \
- int ret; \
- threadEntry_t self; \
- fdEntry_t *fdEntry = getFdEntry(FD); \
- if (fdEntry == NULL) { \
- errno = EBADF; \
- return -1; \
- } \
- do { \
- startOp(fdEntry, &self); \
- ret = FUNC; \
- endOp(fdEntry, &self); \
- } while (ret == -1 && errno == EINTR); \
- return ret; \
+#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \
+ int ret; \
+ threadEntry_t self; \
+ fdEntry_t *fdEntry = getFdEntry(FD); \
+ if (fdEntry == NULL) { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ do { \
+ startOp(fdEntry, &self); \
+ ret = FUNC; \
+ endOp(fdEntry, &self); \
+ } while ((RETRY) && ret == -1 && errno == EINTR); \
+ return ret; \
}
int NET_Read(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE );
}
int NET_NonBlockingRead(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT));
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT), JNI_TRUE );
}
int NET_ReadV(int s, const struct iovec * vector, int count) {
- BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
+ BLOCKING_IO_RETURN_INT( s, readv(s, vector, count), JNI_TRUE );
}
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen) {
- BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
+ BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen), JNI_TRUE );
}
int NET_Send(int s, void *msg, int len, unsigned int flags) {
- BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) );
+ BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE );
}
int NET_WriteV(int s, const struct iovec * vector, int count) {
- BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) );
+ BLOCKING_IO_RETURN_INT( s, writev(s, vector, count), JNI_TRUE );
}
int NET_SendTo(int s, const void *msg, int len, unsigned int
flags, const struct sockaddr *to, int tolen) {
- BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
+ BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE );
}
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
- BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen), JNI_TRUE );
}
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
- BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen), JNI_TRUE );
}
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
- BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
+ BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE );
}
/*
diff --git a/jdk/src/solaris/native/java/net/linux_close.c b/jdk/src/solaris/native/java/net/linux_close.c
index d20239ffe9c..fbfd8443e2f 100644
--- a/jdk/src/solaris/native/java/net/linux_close.c
+++ b/jdk/src/solaris/native/java/net/linux_close.c
@@ -37,6 +37,7 @@
#include
#include
#include
+#include "jvm.h"
/*
* Stack allocated by thread when doing blocking operation
@@ -343,66 +344,66 @@ int NET_SocketClose(int fd) {
/************** Basic I/O operations here ***************/
/*
- * Macro to perform a blocking IO operation. Restarts
- * automatically if interrupted by signal (other than
- * our wakeup signal)
+ * Macro to perform a blocking IO operation.
+ * If interrupted by signal (other than our wakeup signal), and if RETRY is true,
+ * then restarts automatically
*/
-#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \
- int ret; \
- threadEntry_t self; \
- fdEntry_t *fdEntry = getFdEntry(FD); \
- if (fdEntry == NULL) { \
- errno = EBADF; \
- return -1; \
- } \
- do { \
- startOp(fdEntry, &self); \
- ret = FUNC; \
- endOp(fdEntry, &self); \
- } while (ret == -1 && errno == EINTR); \
- return ret; \
+#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \
+ int ret; \
+ threadEntry_t self; \
+ fdEntry_t *fdEntry = getFdEntry(FD); \
+ if (fdEntry == NULL) { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ do { \
+ startOp(fdEntry, &self); \
+ ret = FUNC; \
+ endOp(fdEntry, &self); \
+ } while ((RETRY) && ret == -1 && errno == EINTR); \
+ return ret; \
}
int NET_Read(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE );
}
int NET_NonBlockingRead(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT) );
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT), JNI_TRUE );
}
int NET_ReadV(int s, const struct iovec * vector, int count) {
- BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
+ BLOCKING_IO_RETURN_INT( s, readv(s, vector, count), JNI_TRUE );
}
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen) {
- BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
+ BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen), JNI_TRUE );
}
int NET_Send(int s, void *msg, int len, unsigned int flags) {
- BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) );
+ BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE );
}
int NET_WriteV(int s, const struct iovec * vector, int count) {
- BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) );
+ BLOCKING_IO_RETURN_INT( s, writev(s, vector, count), JNI_TRUE );
}
int NET_SendTo(int s, const void *msg, int len, unsigned int
flags, const struct sockaddr *to, int tolen) {
- BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
+ BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE );
}
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
- BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen), JNI_TRUE );
}
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
- BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen), JNI_TRUE );
}
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
- BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
+ BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE );
}
/*
diff --git a/jdk/src/windows/native/java/lang/java_props_md.c b/jdk/src/windows/native/java/lang/java_props_md.c
index 4768b060763..912c6fba0bc 100644
--- a/jdk/src/windows/native/java/lang/java_props_md.c
+++ b/jdk/src/windows/native/java/lang/java_props_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -480,6 +480,8 @@ GetJavaProperties(JNIEnv* env)
* where (buildNumber > 17762)
* Windows Server 2022 10 0 (!VER_NT_WORKSTATION)
* where (buildNumber > 20347)
+ * Windows Server 2025 10 0 (!VER_NT_WORKSTATION)
+ * where (buildNumber > 26039)
*
* This mapping will presumably be augmented as new Windows
* versions are released.
@@ -563,7 +565,10 @@ GetJavaProperties(JNIEnv* env)
case 0:
/* Windows server 2019 GA 10/2018 build number is 17763 */
/* Windows server 2022 build number is 20348 */
- if (buildNumber > 20347) {
+ /* Windows server 2025 Preview build is 26040 */
+ if (buildNumber > 26039) {
+ sprops.os_name = "Windows Server 2025";
+ } else if (buildNumber > 20347) {
sprops.os_name = "Windows Server 2022";
} else if (buildNumber > 17676) {
sprops.os_name = "Windows Server 2019";
diff --git a/jdk/src/windows/native/sun/java2d/d3d/D3DBadHardware.h b/jdk/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
index 83aedad8f74..78164472aa9 100644
--- a/jdk/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
+++ b/jdk/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
@@ -54,6 +54,9 @@ static const ADAPTER_INFO badHardware[] = {
// All Intel Chips.
{ 0x8086, ALL_DEVICEIDS, NO_VERSION, OS_ALL },
+ // Microsoft Basic Render Driver (as maybe used in VMs such as VirtualBox)
+ { 0x1414, 0x008c, NO_VERSION, OS_ALL },
+
// ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350
// Reason: workaround for 6613066, 6687166
// X1300 (four sub ids)
diff --git a/jdk/test/TEST.ROOT b/jdk/test/TEST.ROOT
index bc8d32e9ccb..89c3727fae7 100644
--- a/jdk/test/TEST.ROOT
+++ b/jdk/test/TEST.ROOT
@@ -13,9 +13,11 @@
# randomness tests.
#
# A "headful" test requires a graphical environment to meaningfully
-# run. Tests that are not headful are "headless."
+# run. Tests that are not headful are "headless".
+# A test flagged with key "printer" requires a printer to succeed, else
+# throws a PrinterException or the like.
-keys=2d dnd i18n intermittent randomness headful jfr
+keys=2d dnd headful i18n intermittent printer randomness jfr
# Tests that must run in othervm mode
othervm.dirs=java/awt java/beans java/rmi javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces sun/rmi
diff --git a/jdk/test/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java b/jdk/test/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java
index 0ca31c4f6b7..943b494a3b3 100644
--- a/jdk/test/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java
+++ b/jdk/test/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* 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,8 +21,9 @@
* questions.
*/
-/*
+/**
* @test
+ * @key headful
* @bug 8007267
* @summary [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
* @requires (os.family == "mac")
diff --git a/jdk/test/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java b/jdk/test/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java
index 8aabcae42c7..9971967bbb6 100644
--- a/jdk/test/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java
+++ b/jdk/test/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -20,13 +20,16 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-/*
+
+/**
* @test
+ * @key headful
* @bug 8158325
* @summary Memory leak in com.apple.laf.ScreenMenu: removed JMenuItems are still referenced
* @requires (os.family == "mac")
* @run main/timeout=300/othervm -Xmx16m ScreenMenuMemoryLeakTest
*/
+
import java.awt.EventQueue;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
@@ -102,4 +105,4 @@ private static void removeMenuItemFromMenu() {
Objects.requireNonNull(menuItem, "The menu item should still be available at this point");
sMenu.remove(menuItem);
}
-}
\ No newline at end of file
+}
diff --git a/jdk/test/java/awt/Desktop/DesktopGtkLoadTest/DesktopGtkLoadTest.java b/jdk/test/java/awt/Desktop/DesktopGtkLoadTest/DesktopGtkLoadTest.java
index 8a463554ad2..61bd013b9d3 100644
--- a/jdk/test/java/awt/Desktop/DesktopGtkLoadTest/DesktopGtkLoadTest.java
+++ b/jdk/test/java/awt/Desktop/DesktopGtkLoadTest/DesktopGtkLoadTest.java
@@ -21,7 +21,9 @@
* questions.
*/
-/* @test
+/**
+ * @test
+ * @key headful
* @bug 8157827
* @summary AWT_Desktop/Automated/Exceptions/BasicTest loads incorrect GTK
* version when jdk.gtk.version=3
diff --git a/jdk/test/java/awt/Dialog/CloseDialog/CloseDialogTest.java b/jdk/test/java/awt/Dialog/CloseDialog/CloseDialogTest.java
index 0a6288d896d..694d6e3fbd7 100644
--- a/jdk/test/java/awt/Dialog/CloseDialog/CloseDialogTest.java
+++ b/jdk/test/java/awt/Dialog/CloseDialog/CloseDialogTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* 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 @@
/**
* @test
+ * @key headful
* @bug 8043705
* @summary Can't exit color chooser dialog when running as an applet
* @run main CloseDialogTest
diff --git a/jdk/test/java/awt/EmbeddedFrame/DisplayChangedTest/DisplayChangedTest.java b/jdk/test/java/awt/EmbeddedFrame/DisplayChangedTest/DisplayChangedTest.java
index 04f2f24b414..5f347c8f0d5 100644
--- a/jdk/test/java/awt/EmbeddedFrame/DisplayChangedTest/DisplayChangedTest.java
+++ b/jdk/test/java/awt/EmbeddedFrame/DisplayChangedTest/DisplayChangedTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* 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,21 +21,17 @@
* questions.
*/
-/*
- @test
- @bug 4980592
- @summary switching user in XP causes an NPE in
- sun.awt.windows.WWindowPeer.displayChanged
- @requires (os.family == "windows")
- @author son@sparc.spb.su: area=embedded
- @run main DisplayChangedTest
- */
/**
- * DisplayChangedTest.java
- *
- * summary: switching user in XP causes an NPE in
- * sun.awt.windows.WWindowPeer.displayChanged
+ * @test
+ * @key headful
+ * @bug 4980592
+ * @summary switching user in XP causes an NPE in
+ * sun.awt.windows.WWindowPeer.displayChanged
+ * @requires (os.family == "windows")
+ * @author son@sparc.spb.su: area=embedded
+ * @run main DisplayChangedTest
*/
+
import java.awt.Frame;
import java.awt.Dialog;
import java.awt.TextArea;
diff --git a/jdk/test/java/awt/EmbeddedFrame/EmbeddedFrameGrabTest/EmbeddedFrameGrabTest.java b/jdk/test/java/awt/EmbeddedFrame/EmbeddedFrameGrabTest/EmbeddedFrameGrabTest.java
index 1613a804263..cce03537750 100644
--- a/jdk/test/java/awt/EmbeddedFrame/EmbeddedFrameGrabTest/EmbeddedFrameGrabTest.java
+++ b/jdk/test/java/awt/EmbeddedFrame/EmbeddedFrameGrabTest/EmbeddedFrameGrabTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* 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,19 +21,16 @@
* questions.
*/
-/*
- @test
- @bug 6345002
- @summary grab problems with EmbeddedFrame
- @requires (os.family == "windows")
- @author Oleg.Semenov@sun.com area=EmbeddedFrame
- @run main EmbeddedFrameGrabTest
- */
/**
- * EmbeddedFrameGrabTest.java
- *
- * summary: grab problems with EmbeddedFrame
+ * @test
+ * @key headful
+ * @bug 6345003
+ * @summary grab problems with EmbeddedFrame
+ * @requires (os.family == "windows")
+ * @author Oleg.Semenov@sun.com area=EmbeddedFrame
+ * @run main EmbeddedFrameGrabTest
*/
+
import java.awt.Frame;
import java.awt.peer.FramePeer;
import javax.swing.JComboBox;
diff --git a/jdk/test/java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html b/jdk/test/java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html
index 3e8611d2e02..31e7015c17a 100644
--- a/jdk/test/java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html
+++ b/jdk/test/java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html
@@ -1,5 +1,5 @@