Compare commits

..

16 Commits

Author SHA1 Message Date
Vitaly Provodin
0b382484ee Revert "JBR-4306 Robot doesn't work as expected in some cases on macOS"
This reverts commit 803039d6db.
2022-03-27 08:47:16 +07:00
Mikhail Grishchenko
b45b8c9913 JBR-3975 add processing of "." java version separator 2022-03-24 08:55:51 +07:00
Artem Semenov
f6cf71ce68 JBR-4325 Implement creating an event to call NSAccessibilityShowMenuAction 2022-03-23 21:29:36 +03:00
Dmitry Batrak
803039d6db JBR-4306 Robot doesn't work as expected in some cases on macOS
(cherry picked from commit 7d69734465)
2022-03-23 12:53:42 +03:00
Vladimir Dvorak
436223316f JBR-4312 - fix crash call ResolvedMethodTable from ServiceThread
adjust_metod_entries_dcevm incorrectly changed the hashes of resolved
method oops stored in ResolvedMethodTable. Now all oops of old methods
are first removed, then updated and then added to table again
2022-03-23 11:08:36 +07:00
Dmitry Batrak
9a0ab296fe better handle multi-monitor configurations in tests related to macOS spaces
Detect the presence of an additional space by looking at number of spaces for the first monitor, not at the total number of spaces.
The latter is larger than one in a multi-monitor configuration, as each monitor corresponds to a separate space.
This approach should be better than the original one, but it relies on the primary (default) monitor to be mentioned first
in the plist file, which isn't known to be always true.

(cherry picked from commit 9040fd56cd)
2022-03-21 21:30:12 +03:00
Artem Semenov
bf4a191246 JBR-4318 On MacOS, some context menu items are not voiced 2022-03-21 15:40:18 +03:00
Andrew Leonard
cdfff8f6ac JBR-4062 8283315: jrt-fs.jar not always deterministically built
Reviewed-by: ihse
2022-03-21 14:03:00 +03:00
Alexey Ushakov
6d6de1034a JBR-3827 SIGILL at [libsystem_kernel] __kill in Java Exception at -[CDragSource convertData:]
Added check for drag source
2022-03-18 18:36:10 +01:00
Vitaly Provodin
2333999906 JBR-4303 add a regression test
(cherry picked from commit bc7cb5711b)
2022-03-18 09:50:29 +07:00
Alexey Ushakov
6ffcd2bf91 JBR-3366 SIGILL at [libsystem_kernel] __kill in NSWindowStyleMaskFullScreen cleared on a window outside of a full screen transition
Wrapped the native exception and added logging
2022-03-17 18:09:49 +01:00
Artem Semenov
822b4a8c49 JBR-4235 Context menu not readable after opening on Mac OS 2022-03-17 16:34:39 +03:00
Dmitry Batrak
debc6336c0 JBR-4314 2022.1 EAP version's JBR use incorrect fallback font to render Chinese characters in macOS
(cherry picked from commit 82048d1d73)
2022-03-17 15:15:34 +03:00
Mikhail Grishchenko
1f93154f62 JBR-3975 add PASSED message in check_jbr_size.sh 2022-03-17 03:35:05 +07:00
Mikhail Grishchenko
9f069ca59e JBR-3975 Fix regexp in check_jbr_size.sh
(cherry picked from commit 23131fc435)
2022-03-17 01:45:51 +07:00
Vladimir Kempik
53f1a647fd JBR-4309: jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java fails after JBR-4291 2022-03-14 11:27:16 +03:00
14 changed files with 385 additions and 87 deletions

View File

@@ -25,16 +25,39 @@ case "${unameOut}" in
echo "Unknown machine: ${unameOut}"
exit 1
esac
FILENAME=$(basename ${NEWFILEPATH})
#
# Get pattern of artifact name
# Base filename pattern: <BUNDLE_TYPE>-<JDK_VERSION>-<OS>-<ARCH>-b<BUILD>.tar.gz: jbr_dcevm-17.0.2-osx-x64-b1234.tar.gz
# BUNDLE_TYPE: jbr, jbrsdk, jbr_dcevm, jbrsdk_jcef etc.
# OS_ARCH_PATTERN - <os_architecture>: osx-x64, linux-aarch64, windows-x64 etc.
echo "New size of $NEWFILEPATH = $NEWFILESIZE bytes."
BUNDLE_TYPE=jbrsdk
OS_ARCH_PATTERN=""
re='(jbr[a-z_]*).+[0-9_\.]+-(.+)-b.+\.tar\.gz'
if [[ $FILENAME =~ $re ]]; then
BUNDLE_TYPE=${BASH_REMATCH[1]}
OS_ARCH_PATTERN=${BASH_REMATCH[2]}
fi
echo "BUNDLE_TYPE: " $BUNDLE_TYPE
echo "OS_ARCH_PATTERN: " $OS_ARCH_PATTERN
echo "New size of $FILENAME = $NEWFILESIZE bytes."
# example: IntellijCustomJdk_Jdk17_Master_LinuxX64jcef
#
# Get previous successful build ID
# Example:
# CONFIGID=IntellijCustomJdk_Jdk17_Master_LinuxX64jcef
# BUILDID=12345678
#
# expected return value
# id="123".number="567"
#
CURL_RESPONSE=$(curl --header "Authorization: Bearer $TOKEN" "https://buildserver.labs.intellij.net/app/rest/builds/?locator=buildType:(id:$CONFIGID),status:success,count:1,finishDate:(build:$BUILDID,condition:before)")
re='id=\"([0-9]+)\".+number=\"([0-9\.]+)\"'
re='id=\"([0-9]+)\".+number=\"([0-9]+)\"'
# ID: Previous successful build id
ID=0
if [[ $CURL_RESPONSE =~ $re ]]; then
ID=${BASH_REMATCH[1]}
echo "BUILD Number: ${BASH_REMATCH[2]}"
@@ -44,13 +67,18 @@ else
exit 1
fi
#
# Get artifacts from previous successful build
#
# expected return value
# name="jbrsdk_jcef*.tar.gz size="123'
#
CURL_RESPONSE=$(curl --header "Authorization: Bearer $TOKEN" "https://buildserver.labs.intellij.net/app/rest/builds/$ID?fields=id,number,artifacts(file(name,size))")
echo "Atrifacts of last pinned build of $CONFIGID :\n"
echo "Atrifacts of previous build of $CONFIGID :"
echo $CURL_RESPONSE
# Find size (in response) with reg exp
re='name=\"(jbrsdk_jcef[^\"]+\.tar\.gz)\" size=\"([0-9]+)\"'
# Find binary size (in response) with reg exp
re='name=\"('$BUNDLE_TYPE'[^\"]+'${OS_ARCH_PATTERN}'[^\"]+\.tar\.gz)\" size=\"([0-9]+)\"'
if [[ $CURL_RESPONSE =~ $re ]]; then
OLDFILENAME=${BASH_REMATCH[1]}
@@ -63,6 +91,8 @@ if [[ $CURL_RESPONSE =~ $re ]]; then
if [[ "$NEWFILESIZE" -gt "$allowedSize" ]]; then
echo "ERROR: new size is significally greater than prev size (need to investigate)"
exit 1
else
echo "PASSED"
fi
else
echo "ERROR: can't find string with size in xml response:"

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 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
@@ -193,7 +193,8 @@ define SetupJarArchiveBody
$1_UPDATE_CONTENTS=\
if [ "`$(WC) -l $$($1_BIN)/_the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'`" -gt "0" ]; then \
$(ECHO) " updating" `$(WC) -l $$($1_BIN)/_the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \
$$($1_JAR_CMD) --update $$($1_JAR_OPTIONS) --file $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents; \
$(SORT) $$($1_BIN)/_the.$$($1_JARNAME)_contents > $$($1_BIN)/_the.$$($1_JARNAME)_contents_sorted && \
$$($1_JAR_CMD) --update $$($1_JAR_OPTIONS) --file $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents_sorted; \
fi $$(NEWLINE)
# The s-variants of the above macros are used when the jar is created from scratch.
# NOTICE: please leave the parentheses space separated otherwise the AIX build will break!
@@ -212,7 +213,9 @@ define SetupJarArchiveBody
| $(SED) 's|$$(src)/|-C $$(src) |g' >> \
$$($1_BIN)/_the.$$($1_JARNAME)_contents) $$(NEWLINE) )
endif
$1_SUPDATE_CONTENTS=$$($1_JAR_CMD) --update $$($1_JAR_OPTIONS) --file $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents $$(NEWLINE)
$1_SUPDATE_CONTENTS=\
$(SORT) $$($1_BIN)/_the.$$($1_JARNAME)_contents > $$($1_BIN)/_the.$$($1_JARNAME)_contents_sorted && \
$$($1_JAR_CMD) --update $$($1_JAR_OPTIONS) --file $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents_sorted $$(NEWLINE)
# Use a slightly shorter name for logging, but with enough path to identify this jar.
$1_NAME:=$$(subst $$(OUTPUTDIR)/,,$$($1_JAR))

View File

@@ -372,10 +372,12 @@ public:
};
class AdjustMethodEntriesDcevm : public StackObj {
bool* _trace_name_printed;
GrowableArray<oop>* _oops_to_add;
GrowableArray<oop>* _oops_to_update;
GrowableArray<Method*>* _old_methods;
public:
AdjustMethodEntriesDcevm(GrowableArray<oop>* oops_to_add, bool* trace_name_printed) : _trace_name_printed(trace_name_printed), _oops_to_add(oops_to_add) {};
AdjustMethodEntriesDcevm(GrowableArray<oop>* oops_to_update, GrowableArray<Method*>* old_methods) :
_oops_to_update(oops_to_update), _old_methods(old_methods) {};
bool operator()(WeakHandle* entry) {
oop mem_name = entry->peek();
if (mem_name == NULL) {
@@ -386,46 +388,8 @@ public:
Method* old_method = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(mem_name);
if (old_method->is_old()) {
InstanceKlass* newer_klass = InstanceKlass::cast(old_method->method_holder()->new_version());
Method* newer_method;
// Method* new_method;
if (old_method->is_deleted()) {
newer_method = Universe::throw_no_such_method_error();
} else {
newer_method = newer_klass->method_with_idnum(old_method->orig_method_idnum());
log_debug(redefine, class, update)("Adjusting method: '%s' of new class %s", newer_method->name_and_sig_as_C_string(), newer_klass->name()->as_C_string());
assert(newer_klass == newer_method->method_holder(), "call after swapping redefined guts");
assert(newer_method != NULL, "method_with_idnum() should not be NULL");
assert(old_method != newer_method, "sanity check");
Thread* thread = Thread::current();
ResolvedMethodTableLookup lookup(thread, method_hash(newer_method), newer_method);
ResolvedMethodGet rmg(thread, newer_method);
if (_local_table->get(thread, lookup, rmg)) {
// old method was already adjusted if new method exists in _the_table
return true;
}
}
java_lang_invoke_ResolvedMethodName::set_vmtarget(mem_name, newer_method);
java_lang_invoke_ResolvedMethodName::set_vmholder(mem_name, newer_method->method_holder()->java_mirror());
newer_klass->set_has_resolved_methods();
_oops_to_add->append(mem_name);
ResourceMark rm;
if (!(*_trace_name_printed)) {
log_debug(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
*_trace_name_printed = true;
}
log_debug(redefine, class, update, constantpool)
("ResolvedMethod method update: %s(%s)",
newer_method->name()->as_C_string(), newer_method->signature()->as_C_string());
_oops_to_update->append(mem_name);
_old_methods->append(old_method);
}
return true;
@@ -440,36 +404,70 @@ void ResolvedMethodTable::adjust_method_entries(bool * trace_name_printed) {
_local_table->do_safepoint_scan(adjust);
}
// It is called at safepoint only for RedefineClasses
// It is called at safepoint only for EnhancedRedefineClasses
void ResolvedMethodTable::adjust_method_entries_dcevm(bool * trace_name_printed) {
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
// For each entry in RMT, change to new method
GrowableArray<oop> oops_to_add(0);
AdjustMethodEntriesDcevm adjust(&oops_to_add, trace_name_printed);
GrowableArray<oop> oops_to_update(0);
GrowableArray<Method*> old_methods(0);
AdjustMethodEntriesDcevm adjust(&oops_to_update, &old_methods);
_local_table->do_safepoint_scan(adjust);
Thread* thread = Thread::current();
for (int i = 0; i < oops_to_add.length(); i++) {
oop mem_name = oops_to_add.at(i);
Method* method = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(mem_name);
// The hash table takes ownership of the WeakHandle, even if it's not inserted.
for (int i = 0; i < oops_to_update.length(); i++) {
oop mem_name = oops_to_update.at(i);
Method *old_method = old_methods.at(i);
ResolvedMethodTableLookup lookup(thread, method_hash(method), method);
ResolvedMethodGet rmg(thread, method);
// 1. Remove old method, since we are going to update class that could be used for hash evaluation in parallel running ServiceThread
ResolvedMethodTableLookup lookup(thread, method_hash(old_method), old_method);
_local_table->remove(thread, lookup);
InstanceKlass* newer_klass = InstanceKlass::cast(old_method->method_holder()->new_version());
Method* newer_method;
// Method* new_method;
if (old_method->is_deleted()) {
newer_method = Universe::throw_no_such_method_error();
} else {
newer_method = newer_klass->method_with_idnum(old_method->orig_method_idnum());
assert(newer_method != NULL, "method_with_idnum() should not be NULL");
assert(newer_klass == newer_method->method_holder(), "call after swapping redefined guts");
assert(old_method != newer_method, "sanity check");
Thread* thread = Thread::current();
ResolvedMethodTableLookup lookup(thread, method_hash(newer_method), newer_method);
ResolvedMethodGet rmg(thread, newer_method);
while (true) {
if (_local_table->get(thread, lookup, rmg)) {
break;
}
WeakHandle wh(_oop_storage, mem_name);
// The hash table takes ownership of the WeakHandle, even if it's not inserted.
if (_local_table->insert(thread, lookup, wh)) {
log_insert(method);
wh.resolve();
break;
// old method was already adjusted if new method exists in _the_table
continue;
}
}
log_debug(redefine, class, update)("Adjusting method: '%s' of new class %s", newer_method->name_and_sig_as_C_string(), newer_klass->name()->as_C_string());
// 2. Update method
java_lang_invoke_ResolvedMethodName::set_vmtarget(mem_name, newer_method);
java_lang_invoke_ResolvedMethodName::set_vmholder(mem_name, newer_method->method_holder()->java_mirror());
newer_klass->set_has_resolved_methods();
ResourceMark rm;
if (!(*trace_name_printed)) {
log_debug(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
*trace_name_printed = true;
}
log_debug(redefine, class, update, constantpool)
("ResolvedMethod method update: %s(%s)",
newer_method->name()->as_C_string(), newer_method->signature()->as_C_string());
// 3. add updated method to table again
add_method(newer_method, Handle(thread, mem_name));
}
}
#endif // INCLUDE_JVMTI

View File

@@ -2501,6 +2501,10 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
if (res != JNI_OK) {
return res;
}
} else if (match_option(option, "--illegal-access=", &tail)) {
char version[256];
JDK_Version::jdk(17).to_string(version, sizeof(version));
warning("Ignoring option %s; support was removed in %s", option->optionString, version);
} else if (match_option(option, "--jbr-illegal-access", &tail)) {
warning("Option --jbr-illegal-access is deprecated and will be removed in a future release.");
if (!create_module_property("jdk.module.illegalAccess", "permit", ExternalProperty)) {

View File

@@ -76,6 +76,7 @@ import sun.lwawt.LWWindowPeer;
class CAccessibility implements PropertyChangeListener {
private static Set<String> ignoredRoles;
private static final int INVOKE_TIMEOUT_SECONDS;
private static final boolean ENABLE_SHOW_CONTEXT_MENU_EVENT;
static {
// (-1) for the infinite timeout
@@ -87,6 +88,28 @@ class CAccessibility implements PropertyChangeListener {
return Integer.getInteger("sun.lwawt.macosx.CAccessibility.invokeTimeoutSeconds", 1);
});
INVOKE_TIMEOUT_SECONDS = value;
@SuppressWarnings("removal")
boolean enableShowContextMenuEvent = java.security.AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
return Boolean.getBoolean("sun.lwawt.macosx.CAccessibility.enableShowContextMenuEvent");
});
ENABLE_SHOW_CONTEXT_MENU_EVENT = enableShowContextMenuEvent;
}
private static boolean isEnableShowContextMenuEvent() {
return ENABLE_SHOW_CONTEXT_MENU_EVENT;
}
private static void accessibleShowContextMenuEvent(Accessible a, Component c) {
if (a == null) return;
invokeLater(new Runnable() {
@Override
public void run() {
AccessibleContext ac = a.getAccessibleContext();
if (ac != null) {
ac.firePropertyChange("accessibleContextMenuShow", null, null);
}
}
}, c);
}
static CAccessibility sAccessibility;

View File

@@ -205,8 +205,10 @@ class CAccessible extends CFRetainedResource implements Accessible {
} else if (oldValue != null &&
((AccessibleState) oldValue) == AccessibleState.VISIBLE) {
execute(ptr -> menuClosed(ptr));
execute(ptr -> unregisterFromCocoaAXSystem(ptr));
}
} else if (thisRole == AccessibleRole.MENU_ITEM) {
} else if (thisRole == AccessibleRole.MENU_ITEM ||
((parentRole == AccessibleRole.POPUP_MENU) && (thisRole == AccessibleRole.MENU))) {
if (newValue != null &&
((AccessibleState) newValue) == AccessibleState.FOCUSED) {
execute(ptr -> menuItemSelected(ptr));

View File

@@ -1653,7 +1653,15 @@ JNI_COCOA_ENTER(env);
// resets the NSWindow's style mask if the mask intersects any of those bits
if (mask & MASK(_STYLE_PROP_BITMASK)) {
[nsWindow setStyleMask:[AWTWindow styleMaskForStyleBits:newBits]];
NSWindowStyleMask styleMask = [AWTWindow styleMaskForStyleBits:newBits];
@try {
[nsWindow setStyleMask:styleMask];
} @catch (NSException *e) {
NSLog(@"WARNING: suppressed exception from [NSWindow setStyleMask] in CPlatformWindow"
".nativeSetNSWindowStyleBits");
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
[NSApplicationAWT logException:e forProcess:processInfo];
}
}
// calls methods on NSWindow to change other properties, based on the mask

View File

@@ -237,7 +237,7 @@ static BOOL sNeedsEnter;
jobject transferer = [self dataTransferer:env];
jbyteArray data = nil;
if (transferer != NULL) {
if (transferer != NULL && fComponent != NULL) {
GET_DT_CLASS_RETURN(NULL);
DECLARE_METHOD_RETURN(convertDataMethod, DataTransfererClass, "convertData", "(Ljava/lang/Object;Ljava/awt/datatransfer/Transferable;JLjava/util/Map;Z)[B", NULL);
data = (*env)->CallObjectMethod(env, transferer, convertDataMethod, fComponent, fTransferable, format, fFormatMap, (jboolean) TRUE);

View File

@@ -126,7 +126,7 @@ static jobject sAccessibilityClass = NULL;
/*
* Here we should keep all the mapping between the accessibility roles and implementing classes
*/
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:51];
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:50];
[rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"];
[rolesMap setObject:@"ImageAccessibility" forKey:@"icon"];
@@ -158,7 +158,6 @@ static jobject sAccessibilityClass = NULL;
[rolesMap setObject:@"TableAccessibility" forKey:@"table"];
[rolesMap setObject:@"MenuBarAccessibility" forKey:@"menubar"];
[rolesMap setObject:@"MenuAccessibility" forKey:@"menu"];
[rolesMap setObject:@"MenuItemAccessibility" forKey:@"menuitem"];
[rolesMap setObject:@"MenuAccessibility" forKey:@"popupmenu"];
[rolesMap setObject:@"ProgressIndicatorAccessibility" forKey:@"progressbar"];
@@ -186,10 +185,11 @@ static jobject sAccessibilityClass = NULL;
[rolesMap setObject:IgnoreClassName forKey:@"viewport"];
[rolesMap setObject:IgnoreClassName forKey:@"window"];
rowRolesMapForParent = [[NSMutableDictionary alloc] initWithCapacity:2];
rowRolesMapForParent = [[NSMutableDictionary alloc] initWithCapacity:3];
[rowRolesMapForParent setObject:@"ListRowAccessibility" forKey:@"ListAccessibility"];
[rowRolesMapForParent setObject:@"OutlineRowAccessibility" forKey:@"OutlineAccessibility"];
[rowRolesMapForParent setObject:@"MenuItemAccessibility" forKey:@"MenuAccessibility"];
/*
* Initialize CAccessibility instance
@@ -1186,7 +1186,25 @@ static jobject sAccessibilityClass = NULL;
// NSAccessibilityActions methods
- (BOOL)isEnableShowMenuEvent
{
static NSNumber *sEnableShowContextMenuEvent = nil;
if (sEnableShowContextMenuEvent == nil) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
GET_CACCESSIBILITY_CLASS_RETURN(NO);
DECLARE_STATIC_METHOD_RETURN(sjm_enableShowMenuEvent, sjc_CAccessibility, "isEnableShowContextMenuEvent", "()Z", NO);
sEnableShowContextMenuEvent = [[NSNumber alloc] initWithBool:(*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, sjm_enableShowMenuEvent)];
CHECK_EXCEPTION();
}
return sEnableShowContextMenuEvent.boolValue;
}
- (BOOL)isAccessibilitySelectorAllowed:(SEL)selector {
if ([self isEnableShowMenuEvent] &&
[NSStringFromSelector(selector) isEqualToString:@"accessibilityPerformShowMenu"]) {
return YES;
}
if ([sAllActionSelectors containsObject:NSStringFromSelector(selector)] &&
![[self actionSelectors] containsObject:NSStringFromSelector(selector)]) {
return NO;
@@ -1203,6 +1221,14 @@ static jobject sAccessibilityClass = NULL;
}
- (BOOL)accessibilityPerformShowMenu {
if ([self isEnableShowMenuEvent]) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
GET_CACCESSIBILITY_CLASS_RETURN(NO);
DECLARE_STATIC_METHOD_RETURN(sjm_accessibleShowContextMenuEvent, sjc_CAccessibility, "accessibleShowContextMenuEvent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V", NO);
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, sjm_accessibleShowContextMenuEvent, fAccessible, fComponent);
CHECK_EXCEPTION();
return YES;
}
return [self accessiblePerformAction:NSAccessibilityShowMenuAction];
}

View File

@@ -39,7 +39,7 @@
- (BOOL)isAccessibilityElement
{
return YES;
return [[[self accessibilityParent] accessibilityRole] isEqualToString:NSAccessibilityComboBoxRole];
}
@end

View File

@@ -3371,7 +3371,7 @@ JNI_COCOA_ENTER(env);
anotherBaseFont = true;
}
CTFontRef font = (CTFontRef)nsFont;
CFArrayRef codes = CFLocaleCopyISOLanguageCodes();
CFArrayRef codes = CFLocaleCopyPreferredLanguages();
CFArrayRef fds = CTFontCopyDefaultCascadeListForLanguages(font, codes);
CFRelease(codes);

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, JetBrains s.r.o.. All rights reserved.
* 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
* @summary Test implementation of NSAccessibilityMenu and NSAccessibilityMenuItem roles peer
* @author Artem.Semenov@jetbrains.com
* @run main/manual AccessibleJPopupMenuTest
* @requires (os.family == "mac")
*/
import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.concurrent.CountDownLatch;
public class AccessibleJPopupMenuTest extends AccessibleComponentTest {
@Override
public CountDownLatch createCountDownLatch() {
return new CountDownLatch(1);
}
private static JPopupMenu createPopup() {
JPopupMenu popup = new JPopupMenu("MENU");
popup.add("One");
popup.add("Two");
popup.add("Three");
popup.addSeparator();
JMenu menu = new JMenu("For submenu");
menu.add("subOne");
menu.add("subTwo");
menu.add("subThree");
popup.add(menu);
return popup;
}
public void createTest() {
INSTRUCTIONS = "INSTRUCTIONS:\n"
+ "Check a11y of JPopupMenu.\n\n"
+ "Turn screen reader on, and Tab to the show button and press space.\n"
+ "Press the up and down arrow buttons to move through the menu, and open submenu.\n\n"
+ "If you can hear popup menu items tab further and press PASS, otherwise press FAIL.\n";
JPanel frame = new JPanel();
JButton button = new JButton("show");
button.setPreferredSize(new Dimension(100, 35));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
createPopup().show(button, button.getX(), button.getY());
}
});
frame.setLayout(new FlowLayout());
frame.add(button);
exceptionString = "Accessible JPopupMenu test failed!";
super.createUI(frame, "Accessible JPopupMenu test");
}
public static void main(String[] args) throws Exception {
AccessibleJPopupMenuTest a11yTest = new AccessibleJPopupMenuTest();
CountDownLatch countDownLatch = a11yTest.createCountDownLatch();
SwingUtilities.invokeLater(a11yTest::createTest);
countDownLatch.await();
if (!testResult) {
throw new RuntimeException(a11yTest.exceptionString);
}
}
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright 2000-2022 JetBrains s.r.o.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@key headful
@summary a regression test for JBR-4303.
@run main GetPointerInfoTest
*/
import java.awt.*;
/**
* The test checks <code>MouseInfo.getPointerInfo()</code> for all locations with the steps <code>X_STEP</code> and
* <code>Y_STEP</code> on all graphic devices.
* It moves mouse to the current location via <code>Robot.mouseMove()</code> and checks that
* <code>MouseInfo.getPointerInfo()</code> is not NULL.
* It also checks <code>MouseInfo.getPointerInfo().getLocation()</code> returns expected values.
*/
public class GetPointerInfoTest {
public static int X_STEP = 100;
public static int Y_STEP = 100;
static boolean isPassed = true;
public static void main(String[] args) throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] graphicsDevices = ge.getScreenDevices();
for (GraphicsDevice gd : graphicsDevices) {
String name = gd.getIDstring();
int width = gd.getDisplayMode().getWidth();
int height = gd.getDisplayMode().getHeight();
System.out.println("Check for device: " + name + " " + width + "x" + height);
Robot robot = new Robot(gd);
robot.setAutoDelay(0);
robot.setAutoWaitForIdle(true);
robot.delay(10);
robot.waitForIdle();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
for (double y = bounds.getY(); y < bounds.getY() + bounds.getHeight(); y += Y_STEP) {
for (double x = bounds.getX(); x < bounds.getX() + bounds.getWidth(); x += X_STEP) {
Point p = new Point((int)x, (int)y);
System.out.println("\tmouse move to x=" + p.x + " y=" + p.y);
robot.mouseMove(p.x, p.y);
System.out.print("\t\tMouseInfo.getPointerInfo.getLocation");
PointerInfo pi = MouseInfo.getPointerInfo();
if (pi == null) {
throw new RuntimeException("Test failed. getPointerInfo() returned null value.");
}
Point piLocation = pi.getLocation();
if (piLocation.x != p.x || piLocation.y != p.y) {
System.out.println(" - ***FAILED*** x=" + piLocation.x + " y=" + piLocation.y);
isPassed = false;
} else {
System.out.println(" x=" + p.x + ", y=" + p.y + " - passed");
}
}
}
}
if ( !isPassed )
throw new RuntimeException("PointerInfo.getLocation() returns unexpected value(s).");
System.out.println("Test PASSED.");
}
}

View File

@@ -33,7 +33,7 @@ public class MacSpacesUtil {
return Runtime.getRuntime().exec(new String[]{
"plutil",
"-extract",
"SpacesDisplayConfiguration.Space Properties.1",
"SpacesDisplayConfiguration.Management Data.Monitors.0.Spaces.1",
"json",
"-o",
"-",
@@ -45,13 +45,15 @@ public class MacSpacesUtil {
toggleMissionControl();
// press button at top right corner to add a new space
int screenWidth = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
.getDefaultConfiguration().getBounds().width;
Rectangle screenBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
.getDefaultConfiguration().getBounds();
int rightX = screenBounds.x + screenBounds.width;
int topY = screenBounds.y;
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.mouseMove(screenWidth, 0);
robot.mouseMove(screenWidth - 5, 5);
robot.mouseMove(screenWidth - 10, 10);
robot.mouseMove(rightX, topY);
robot.mouseMove(rightX - 5, topY + 5);
robot.mouseMove(rightX - 10, topY + 10);
robot.delay(1000);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);