Skip to content

Commit ca8ca8c

Browse files
Steven LoomisRadekCap
authored andcommitted
8195675: Call to insertText with single character from custom Input Method ignored
Backport-of: b8f2ec9091f9f7e5f4611991d04dd8aa113b94fd
1 parent 6a9eb07 commit ca8ca8c

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
// keyboard layout
4040
static NSString *kbdLayout;
4141

42+
// Constant for keyman layouts
43+
#define KEYMAN_LAYOUT "keyman"
44+
4245
@interface AWTView()
4346
@property (retain) CDropTarget *_dropTarget;
4447
@property (retain) CDragSource *_dragSource;
@@ -281,7 +284,7 @@ - (void) scrollWheel: (NSEvent*) event {
281284

282285
- (void) keyDown: (NSEvent *)event {
283286
fProcessingKeystroke = YES;
284-
fKeyEventsNeeded = YES;
287+
fKeyEventsNeeded = ![(NSString *)kbdLayout containsString:@KEYMAN_LAYOUT];
285288

286289
// Allow TSM to look at the event and potentially send back NSTextInputClient messages.
287290
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
@@ -989,7 +992,7 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
989992

990993
if ((utf16Length > 2) ||
991994
((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:codePoint]) ||
992-
((codePoint == 0x5c) && ([(NSString *)kbdLayout containsString:@"Kotoeri"]))) {
995+
[(NSString *)kbdLayout containsString:@KEYMAN_LAYOUT]) {
993996
aStringIsComplex = YES;
994997
}
995998

test/jdk/sun/security/pkcs11/PKCS11Test.java

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, 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
@@ -56,9 +56,7 @@
5656
import java.util.ServiceConfigurationError;
5757
import java.util.ServiceLoader;
5858
import java.util.Set;
59-
import java.util.regex.Matcher;
60-
import java.util.regex.Pattern;
61-
import java.util.stream.Collectors;
59+
import java.util.stream.Stream;
6260

6361
import jdk.test.lib.Platform;
6462
import jdk.test.lib.artifacts.Artifact;
@@ -383,19 +381,13 @@ private static Path getNSSLibPath() throws Exception {
383381

384382
static Path getNSSLibPath(String library) throws Exception {
385383
String osid = getOsId();
386-
String nssLibDir = fetchNssLib(osid);
387-
if (nssLibDir == null) {
384+
Path libraryName = Path.of(System.mapLibraryName(library));
385+
Path nssLibPath = fetchNssLib(osid, libraryName);
386+
if (nssLibPath == null) {
388387
throw new SkippedException("Warning: unsupported OS: " + osid
389388
+ ", please initialize NSS library location, skipping test");
390389
}
391-
392-
String libraryName = System.mapLibraryName(library);
393-
Path libPath = Paths.get(nssLibDir).resolve(libraryName);
394-
if (!Files.exists(libPath)) {
395-
throw new SkippedException("NSS library \"" + libraryName + "\" was not found in " + nssLibDir);
396-
}
397-
398-
return libPath;
390+
return nssLibPath;
399391
}
400392

401393
private static String getOsId() {
@@ -834,42 +826,42 @@ static byte[] generateData(int length) {
834826
return data;
835827
}
836828

837-
private static String fetchNssLib(String osId) {
829+
private static Path fetchNssLib(String osId, Path libraryName) {
838830
switch (osId) {
839831
case "Windows-amd64-64":
840-
return fetchNssLib(WINDOWS_X64.class);
832+
return fetchNssLib(WINDOWS_X64.class, libraryName);
841833

842834
case "MacOSX-x86_64-64":
843-
return fetchNssLib(MACOSX_X64.class);
835+
return fetchNssLib(MACOSX_X64.class, libraryName);
844836

845837
case "MacOSX-aarch64-64":
846-
return fetchNssLib(MACOSX_AARCH64.class);
838+
return fetchNssLib(MACOSX_AARCH64.class, libraryName);
847839

848840
case "Linux-amd64-64":
849841
if (Platform.isOracleLinux7()) {
850842
throw new SkippedException("Skipping Oracle Linux prior to v8");
851843
} else {
852-
return fetchNssLib(LINUX_X64.class);
844+
return fetchNssLib(LINUX_X64.class, libraryName);
853845
}
854846

855847
case "Linux-aarch64-64":
856848
if (Platform.isOracleLinux7()) {
857849
throw new SkippedException("Skipping Oracle Linux prior to v8");
858850
} else {
859-
return fetchNssLib(LINUX_AARCH64.class);
851+
return fetchNssLib(LINUX_AARCH64.class, libraryName);
860852
}
861853
default:
862854
return null;
863855
}
864856
}
865857

866-
private static String fetchNssLib(Class<?> clazz) {
867-
String path = null;
858+
private static Path fetchNssLib(Class<?> clazz, Path libraryName) {
859+
Path path = null;
868860
try {
869-
path = ArtifactResolver.resolve(clazz).entrySet().stream()
870-
.findAny().get().getValue() + File.separator + "nss"
871-
+ File.separator + "lib" + File.separator;
872-
} catch (ArtifactResolverException e) {
861+
Path p = ArtifactResolver.resolve(clazz).entrySet().stream()
862+
.findAny().get().getValue();
863+
path = findNSSLibrary(p, libraryName);
864+
} catch (ArtifactResolverException | IOException e) {
873865
Throwable cause = e.getCause();
874866
if (cause == null) {
875867
System.out.println("Cannot resolve artifact, "
@@ -883,6 +875,16 @@ private static String fetchNssLib(Class<?> clazz) {
883875
return path;
884876
}
885877

878+
private static Path findNSSLibrary(Path path, Path libraryName) throws IOException {
879+
try(Stream<Path> files = Files.find(path, 10,
880+
(tp, attr) -> tp.getFileName().equals(libraryName))) {
881+
882+
return files.findAny()
883+
.orElseThrow(() -> new SkippedException(
884+
"NSS library \"" + libraryName + "\" was not found in " + path));
885+
}
886+
}
887+
886888
public abstract void main(Provider p) throws Exception;
887889

888890
protected boolean skipTest(Provider p) {

0 commit comments

Comments
 (0)