Skip to content

Commit 8a2c27b

Browse files
authored
Merge branch 'master' into goetz_backport_8357253
2 parents 1d9925e + 6d190cb commit 8a2c27b

File tree

42 files changed

+1690
-968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1690
-968
lines changed

src/java.base/share/classes/sun/security/ssl/SignatureAlgorithmsExtension.java

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package sun.security.ssl;
2727

28+
import static sun.security.ssl.SignatureScheme.CERTIFICATE_SCOPE;
2829
import static sun.security.ssl.SignatureScheme.HANDSHAKE_SCOPE;
2930

3031
import java.io.IOException;
@@ -33,6 +34,7 @@
3334
import java.util.Arrays;
3435
import java.util.List;
3536
import java.util.Locale;
37+
import javax.net.ssl.SSLException;
3638
import javax.net.ssl.SSLProtocolException;
3739
import sun.security.ssl.SSLExtension.ExtensionConsumer;
3840
import sun.security.ssl.SSLExtension.SSLExtensionSpec;
@@ -276,30 +278,8 @@ public void consume(ConnectionContext context,
276278
return;
277279
}
278280

279-
// update the context
280-
List<SignatureScheme> sss =
281-
SignatureScheme.getSupportedAlgorithms(
282-
shc.sslConfig,
283-
shc.algorithmConstraints, shc.negotiatedProtocol,
284-
spec.signatureSchemes,
285-
HANDSHAKE_SCOPE);
286-
287-
if (sss == null || sss.isEmpty()) {
288-
throw shc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
289-
"No supported signature algorithm");
290-
}
291-
shc.peerRequestedSignatureSchemes = sss;
292-
293-
// If no "signature_algorithms_cert" extension is present, then
294-
// the "signature_algorithms" extension also applies to
295-
// signatures appearing in certificates.
296-
SignatureSchemesSpec certSpec =
297-
(SignatureSchemesSpec)shc.handshakeExtensions.get(
298-
SSLExtension.CH_SIGNATURE_ALGORITHMS_CERT);
299-
if (certSpec == null) {
300-
shc.peerRequestedCertSignSchemes = sss;
301-
shc.handshakeSession.setPeerSupportedSignatureAlgorithms(sss);
302-
}
281+
updateHandshakeContext(shc, spec.signatureSchemes,
282+
SSLExtension.CH_SIGNATURE_ALGORITHMS_CERT);
303283

304284
if (!shc.isResumption &&
305285
shc.negotiatedProtocol.useTLS13PlusSpec()) {
@@ -507,30 +487,8 @@ public void consume(ConnectionContext context,
507487
return;
508488
}
509489

510-
// update the context
511-
List<SignatureScheme> sss =
512-
SignatureScheme.getSupportedAlgorithms(
513-
chc.sslConfig,
514-
chc.algorithmConstraints, chc.negotiatedProtocol,
515-
spec.signatureSchemes,
516-
HANDSHAKE_SCOPE);
517-
518-
if (sss == null || sss.isEmpty()) {
519-
throw chc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
520-
"No supported signature algorithm");
521-
}
522-
chc.peerRequestedSignatureSchemes = sss;
523-
524-
// If no "signature_algorithms_cert" extension is present, then
525-
// the "signature_algorithms" extension also applies to
526-
// signatures appearing in certificates.
527-
SignatureSchemesSpec certSpec =
528-
(SignatureSchemesSpec)chc.handshakeExtensions.get(
529-
SSLExtension.CR_SIGNATURE_ALGORITHMS_CERT);
530-
if (certSpec == null) {
531-
chc.peerRequestedCertSignSchemes = sss;
532-
chc.handshakeSession.setPeerSupportedSignatureAlgorithms(sss);
533-
}
490+
updateHandshakeContext(chc, spec.signatureSchemes,
491+
SSLExtension.CR_SIGNATURE_ALGORITHMS_CERT);
534492
}
535493
}
536494

@@ -553,4 +511,49 @@ public void absent(ConnectionContext context,
553511
"received CertificateRequest handshake message");
554512
}
555513
}
514+
515+
// Updates given HandshakeContext with peer signature schemes.
516+
private static void updateHandshakeContext(HandshakeContext hc,
517+
int[] signatureSchemes, SSLExtension signatureAlgorithmsCertExt)
518+
throws SSLException {
519+
List<SignatureScheme> handshakeSS =
520+
SignatureScheme.getSupportedAlgorithms(
521+
hc.sslConfig,
522+
hc.algorithmConstraints,
523+
hc.negotiatedProtocol,
524+
signatureSchemes,
525+
HANDSHAKE_SCOPE);
526+
527+
if (handshakeSS.isEmpty()) {
528+
throw hc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
529+
"No supported signature algorithm");
530+
}
531+
532+
hc.peerRequestedSignatureSchemes = handshakeSS;
533+
534+
// If no "signature_algorithms_cert" extension is present, then
535+
// the "signature_algorithms" extension also applies to
536+
// signatures appearing in certificates.
537+
SignatureSchemesSpec certSpec =
538+
(SignatureSchemesSpec) hc.handshakeExtensions.get(
539+
signatureAlgorithmsCertExt);
540+
541+
if (certSpec == null) {
542+
List<SignatureScheme> certSS =
543+
SignatureScheme.getSupportedAlgorithms(
544+
hc.sslConfig,
545+
hc.algorithmConstraints,
546+
hc.negotiatedProtocol,
547+
signatureSchemes,
548+
CERTIFICATE_SCOPE);
549+
550+
if (certSS.isEmpty()) {
551+
throw hc.conContext.fatal(Alert.HANDSHAKE_FAILURE,
552+
"No supported signature algorithm");
553+
}
554+
555+
hc.peerRequestedCertSignSchemes = certSS;
556+
hc.handshakeSession.setPeerSupportedSignatureAlgorithms(certSS);
557+
}
558+
}
556559
}

src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -60,9 +60,11 @@
6060
import javax.swing.JComponent;
6161
import javax.swing.JEditorPane;
6262
import javax.swing.JLabel;
63+
import javax.swing.JMenu;
6364
import javax.swing.JMenuItem;
6465
import javax.swing.JTextArea;
6566
import javax.swing.JList;
67+
import javax.swing.JPopupMenu;
6668
import javax.swing.JTree;
6769
import javax.swing.KeyStroke;
6870

@@ -813,6 +815,34 @@ public Object[] call() throws Exception {
813815
}, c);
814816
}
815817

818+
private static Accessible getCurrentAccessiblePopupMenu(Accessible a, Component c) {
819+
if (a == null) return null;
820+
821+
return invokeAndWait(new Callable<Accessible>() {
822+
@Override
823+
public Accessible call() throws Exception {
824+
return traversePopupMenu(a);
825+
}
826+
}, c);
827+
}
828+
829+
private static Accessible traversePopupMenu(Accessible a) {
830+
// a is root level popupmenu
831+
AccessibleContext ac = a.getAccessibleContext();
832+
if (ac != null) {
833+
for (int i = 0; i < ac.getAccessibleChildrenCount(); i++) {
834+
Accessible child = ac.getAccessibleChild(i);
835+
if (child instanceof JMenu subMenu) {
836+
JPopupMenu popup = subMenu.getPopupMenu();
837+
if (popup.isVisible()) {
838+
return traversePopupMenu((Accessible) popup);
839+
}
840+
}
841+
}
842+
}
843+
return a;
844+
}
845+
816846
@Native private static final int JAVA_AX_ROWS = 1;
817847
@Native private static final int JAVA_AX_COLS = 2;
818848

src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/MenuAccessibility.m

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,10 @@
2424
*/
2525

2626
#import "MenuAccessibility.h"
27+
#import "ThreadUtilities.h"
28+
#import "sun_lwawt_macosx_CAccessibility.h"
29+
30+
static jclass sjc_CAccessibility = NULL;
2731

2832
/*
2933
* Implementing a protocol that represents menus both as submenu and as a
@@ -51,4 +55,31 @@ - (id _Nullable)accessibilityValue
5155
return NULL;
5256
}
5357

58+
/*
59+
* Return all non-ignored children.
60+
*/
61+
- (NSArray *)accessibilityChildren {
62+
JNIEnv *env = [ThreadUtilities getJNIEnv];
63+
GET_CACCESSIBILITY_CLASS_RETURN(nil);
64+
DECLARE_STATIC_METHOD_RETURN(sjm_getCurrentAccessiblePopupMenu, sjc_CAccessibility,
65+
"getCurrentAccessiblePopupMenu",
66+
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/Accessible;", nil);
67+
jobject axComponent = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
68+
sjm_getCurrentAccessiblePopupMenu,
69+
fAccessible, fComponent);
70+
71+
CommonComponentAccessibility *currentElement = [CommonComponentAccessibility createWithAccessible:axComponent
72+
withEnv:env withView:self->fView isCurrent:YES];
73+
74+
NSArray *children = [CommonComponentAccessibility childrenOfParent:currentElement
75+
withEnv:env
76+
withChildrenCode:sun_lwawt_macosx_CAccessibility_JAVA_AX_ALL_CHILDREN
77+
allowIgnored:NO];
78+
79+
if ([children count] == 0) {
80+
return nil;
81+
} else {
82+
return children;
83+
}
84+
}
5485
@end

src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import java.awt.image.WritableRaster;
5151
import java.io.BufferedReader;
5252
import java.io.IOException;
53-
import java.io.InputStreamReader;
5453
import java.security.AccessController;
5554
import java.security.PrivilegedAction;
5655
import java.util.Arrays;
@@ -276,14 +275,12 @@ public boolean shouldDisableSystemTray() {
276275
return result;
277276
}
278277

279-
private Integer getGnomeShellMajorVersion() {
278+
public Integer getGnomeShellMajorVersion() {
280279
try {
281280
Process process =
282281
new ProcessBuilder("/usr/bin/gnome-shell", "--version")
283282
.start();
284-
try (InputStreamReader isr = new InputStreamReader(process.getInputStream());
285-
BufferedReader reader = new BufferedReader(isr)) {
286-
283+
try (BufferedReader reader = process.inputReader()) {
287284
if (process.waitFor(2, SECONDS) && process.exitValue() == 0) {
288285
String line = reader.readLine();
289286
if (line != null) {

src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,15 +36,13 @@
3636
import sun.awt.X11GraphicsConfig;
3737
import sun.awt.X11GraphicsDevice;
3838
import sun.awt.screencast.ScreencastHelper;
39+
import sun.awt.screencast.XdgDesktopPortal;
3940
import sun.security.action.GetPropertyAction;
4041

4142
@SuppressWarnings("removal")
4243
final class XRobotPeer implements RobotPeer {
4344

4445
private static final boolean tryGtk;
45-
private static final String screenshotMethod;
46-
private static final String METHOD_X11 = "x11";
47-
private static final String METHOD_SCREENCAST = "dbusScreencast";
4846

4947
static {
5048
loadNativeLibraries();
@@ -54,20 +52,6 @@ final class XRobotPeer implements RobotPeer {
5452
new GetPropertyAction("awt.robot.gtk",
5553
"true")
5654
));
57-
58-
boolean isOnWayland = false;
59-
60-
if (Toolkit.getDefaultToolkit() instanceof SunToolkit sunToolkit) {
61-
isOnWayland = sunToolkit.isRunningOnWayland();
62-
}
63-
64-
screenshotMethod = AccessController.doPrivileged(
65-
new GetPropertyAction(
66-
"awt.robot.screenshotMethod",
67-
isOnWayland
68-
? METHOD_SCREENCAST
69-
: METHOD_X11
70-
));
7155
}
7256

7357
private static volatile boolean useGtk;
@@ -92,39 +76,63 @@ final class XRobotPeer implements RobotPeer {
9276
@Override
9377
public void mouseMove(int x, int y) {
9478
mouseMoveImpl(xgc, xgc.scaleUp(x), xgc.scaleUp(y));
79+
if (XdgDesktopPortal.isRemoteDesktop() && ScreencastHelper.isAvailable()) {
80+
// We still call mouseMoveImpl on purpose to change the mouse position
81+
// within the XWayland server so that we can retrieve it later.
82+
ScreencastHelper.remoteDesktopMouseMove(xgc.scaleUp(x), xgc.scaleUp(y));
83+
}
9584
}
9685

9786
@Override
9887
public void mousePress(int buttons) {
99-
mousePressImpl(buttons);
88+
if (XdgDesktopPortal.isRemoteDesktop() && ScreencastHelper.isAvailable()) {
89+
ScreencastHelper.remoteDesktopMouseButton(true, buttons);
90+
} else {
91+
mousePressImpl(buttons);
92+
}
10093
}
10194

10295
@Override
10396
public void mouseRelease(int buttons) {
104-
mouseReleaseImpl(buttons);
97+
if (XdgDesktopPortal.isRemoteDesktop() && ScreencastHelper.isAvailable()) {
98+
ScreencastHelper.remoteDesktopMouseButton(false, buttons);
99+
} else {
100+
mouseReleaseImpl(buttons);
101+
}
105102
}
106103

107104
@Override
108105
public void mouseWheel(int wheelAmt) {
109-
mouseWheelImpl(wheelAmt);
106+
if (XdgDesktopPortal.isRemoteDesktop() && ScreencastHelper.isAvailable()) {
107+
ScreencastHelper.remoteDesktopMouseWheel(wheelAmt);
108+
} else {
109+
mouseWheelImpl(wheelAmt);
110+
}
110111
}
111112

112113
@Override
113114
public void keyPress(int keycode) {
114-
keyPressImpl(keycode);
115+
if (XdgDesktopPortal.isRemoteDesktop() && ScreencastHelper.isAvailable()) {
116+
ScreencastHelper.remoteDesktopKey(true, keycode);
117+
} else {
118+
keyPressImpl(keycode);
119+
}
115120
}
116121

117122
@Override
118123
public void keyRelease(int keycode) {
119-
keyReleaseImpl(keycode);
124+
if (XdgDesktopPortal.isRemoteDesktop() && ScreencastHelper.isAvailable()) {
125+
ScreencastHelper.remoteDesktopKey(false, keycode);
126+
} else {
127+
keyReleaseImpl(keycode);
128+
}
120129
}
121130

122131
@Override
123132
public int getRGBPixel(int x, int y) {
124133
int[] pixelArray = new int[1];
125-
if (screenshotMethod.equals(METHOD_SCREENCAST)
126-
&& ScreencastHelper.isAvailable()) {
127-
134+
if ((XdgDesktopPortal.isScreencast()
135+
|| XdgDesktopPortal.isRemoteDesktop()) && ScreencastHelper.isAvailable()) {
128136
ScreencastHelper.getRGBPixels(x, y, 1, 1, pixelArray);
129137
} else {
130138
getRGBPixelsImpl(xgc, x, y, 1, 1, pixelArray, useGtk);
@@ -135,8 +143,8 @@ public int getRGBPixel(int x, int y) {
135143
@Override
136144
public int[] getRGBPixels(Rectangle bounds) {
137145
int[] pixelArray = new int[bounds.width * bounds.height];
138-
if (screenshotMethod.equals(METHOD_SCREENCAST)
139-
&& ScreencastHelper.isAvailable()) {
146+
if ((XdgDesktopPortal.isScreencast()
147+
|| XdgDesktopPortal.isRemoteDesktop()) && ScreencastHelper.isAvailable()) {
140148

141149
ScreencastHelper.getRGBPixels(bounds.x, bounds.y,
142150
bounds.width, bounds.height,

0 commit comments

Comments
 (0)