Compare commits

..

16 Commits

Author SHA1 Message Date
Anton Tarasov
f39235b231 JBR-3525 SIGSEGV at sun.lwawt.macosx.CAccessible.unregisterFromCocoaAXSystem with enabled VO 2021-07-08 12:52:07 +03:00
Anton Tarasov
8678f41971 JBR-3337 jb/java/jcef/HandleJSQueryTest3314.sh: fails on macOS-aarch64 with "JS Query was not handled in 2nd opened browser" 2021-06-23 18:03:55 +03:00
Denis Konoplev
752c0e5a49 JBR-3544: Generate popup invoked instead of New in this directory
Fix logical error
2021-06-23 12:00:03 +03:00
Denis Konoplev
3ea7913eaf JBR-3544: Generate popup invoked instead of New in this directory
CR: change duplicate Ctrl to Cmd
2021-06-21 22:31:04 +03:00
Anton Tarasov
9b4f72ad18 JBR-3545 Window.setMinimumSize does not respect DPI scaling 2021-06-21 20:42:49 +03:00
Denis Konoplev
d5fa37b63f JBR-3544: Generate popup invoked instead of New in this directory
Fix duplicate system shortcut
2021-06-21 18:26:25 +03:00
Denis Fokin
6a42bb54bd JRE-408 JBR-3515 fix NullPointerException in MetalRootPaneUI.installWindowListeners
(cherry picked from commit 584d554af529cff445b0f09bc2d57be55e138b7a)
2021-06-18 07:18:59 +07:00
Alexey Ushakov
3b03c698ce JBR-2207 TitledBorder leaks PropertyChangeListener
Added a separate pass with sending setVisible(false) to the frames holding TitledBorder references in order to get WINDOW_DEACTIVATED (to clear KeyBoardFocusManager.activeWindow field)
2021-06-16 16:00:55 +03:00
Vitaly Provodin
a56060d465 exclude the test failing because of JDK-8268678 2021-06-15 05:30:09 +07:00
Maxim Kartashev
97ddad2e99 JBR-3516 IDEA doesn't start when located in folder with cyrillic characters
Fix failing Windows x86 builds.
Fixes commit cad1ad4ba1
2021-06-11 11:40:28 +03:00
Maxim Kartashev
01ea54d751 JBR-3520 Correct stack-use-after-scope in jni_NewObjectA
Casting a variable to a non-reference type technically makes the
resulting expression a prvalue, which then gets bound to a reference
that is alive up until the end of the function. The prvalue is then
touched in the destructor of DTraceReturnProbeMark_NewObjectA and this
is detected by Address Sanitizer as stack-use-after-scope.

The fix is to cast to a reference type thus avoiding the creation of the
prvalue and lifetime issues connected with that.
2021-06-09 11:48:37 +03:00
Maxim Kartashev
cad1ad4ba1 JBR-3516 IDEA doesn't start when located in folder with cyrillic characters
Make JVM_LoadLibrary() use new os::dll_load_utf8() interface that
supports UTF-8 path names, leaving other users of os::dll_load()
unaffected.
2021-06-08 12:21:53 +03:00
Alexey Ushakov
c0be778e20 JBR-3344 "Exit Full Screen" action doesn't work, the only way is mouse click on window's native "green" button.
Restored JBR-1931 fix partially reverted by JBR-1718
2021-06-07 20:54:10 +03:00
Vitaly Provodin
0b659fef1b JBR-3500 exclude ClassCastExceptionForInvalidSurface test only causing Xwayland crash 2021-06-01 04:44:33 +07:00
Vitaly Provodin
e62fb2762f JBR-3500 exclude ClassCastExceptionForInvalidSurface test only causing Xwayland crash 2021-06-01 04:43:20 +07:00
Vitaly Provodin
90fff7bb1e JBR-3500 exclude tests related to JBR-3167 causing Xwayland crash 2021-06-01 04:40:40 +07:00
25 changed files with 365 additions and 105 deletions

View File

@@ -1352,6 +1352,10 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
return NULL;
}
void * os::dll_load_utf8(const char *filename, char *ebuf, int ebuflen) {
return os::dll_load(filename, ebuf, ebuflen);
}
void* os::dll_lookup(void* handle, const char* name) {
void* res = dlsym(handle, name);
return res;

View File

@@ -1521,6 +1521,10 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
}
#endif // !__APPLE__
void * os::dll_load_utf8(const char *filename, char *ebuf, int ebuflen) {
return os::dll_load(filename, ebuf, ebuflen);
}
void* os::get_default_process_handle() {
#ifdef __APPLE__
// MacOS X needs to use RTLD_FIRST instead of RTLD_LAZY

View File

@@ -1944,6 +1944,10 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
return NULL;
}
void * os::dll_load_utf8(const char *filename, char *ebuf, int ebuflen) {
return os::dll_load(filename, ebuf, ebuflen);
}
void * os::Linux::dlopen_helper(const char *filename, char *ebuf,
int ebuflen) {
void * result = ::dlopen(filename, RTLD_LAZY);

View File

@@ -1679,6 +1679,10 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
return NULL;
}
void * os::dll_load_utf8(const char *filename, char *ebuf, int ebuflen) {
return os::dll_load(filename, ebuf, ebuflen);
}
void* os::dll_lookup(void* handle, const char* name) {
return dlsym(handle, name);
}

View File

@@ -1355,25 +1355,26 @@ static int _print_module(const char* fname, address base_address,
}
static errno_t convert_to_UTF16(char const* source_str, UINT source_encoding, LPWSTR* dest_utf16_str) {
const int flag_source_str_is_null_terminated = -1;
const int flag_estimate_chars_count = 0;
int utf16_chars_count_estimated = MultiByteToWideChar(source_encoding,
MB_ERR_INVALID_CHARS,
source_str, flag_source_str_is_null_terminated,
NULL, flag_estimate_chars_count);
if (utf16_chars_count_estimated == 0) {
const int len_estimated = MultiByteToWideChar(source_encoding,
MB_ERR_INVALID_CHARS,
source_str,
-1, // source is null-terminated
NULL,
0); // estimate characters count
if (len_estimated == 0) {
// Probably source_str contains characters that cannot be represented in the source_encoding given.
*dest_utf16_str = NULL;
return EINVAL;
}
*dest_utf16_str = NEW_C_HEAP_ARRAY(WCHAR, utf16_chars_count_estimated, mtInternal);
*dest_utf16_str = NEW_C_HEAP_ARRAY(WCHAR, len_estimated, mtInternal);
int utf16_chars_count_real = MultiByteToWideChar(source_encoding,
MB_ERR_INVALID_CHARS,
source_str, flag_source_str_is_null_terminated,
*dest_utf16_str, utf16_chars_count_estimated);
assert(utf16_chars_count_real == utf16_chars_count_estimated, "length already checked above");
const int len_real = MultiByteToWideChar(source_encoding,
MB_ERR_INVALID_CHARS,
source_str,
-1, // source is null-terminated
*dest_utf16_str, len_estimated);
assert(len_real == len_estimated, "length already checked above");
return ERROR_SUCCESS;
}
@@ -1391,24 +1392,26 @@ static errno_t convert_UTF8_to_UTF16(char const* utf8_str, LPWSTR* utf16_str) {
// Unless the platform encoding is UTF-8, not all characters in the source string can be represented in the dest string.
// The function succeeds in this case anyway and just replaces these with a certain character.
static errno_t convert_UTF16_to_platform(LPWSTR source_utf16_str, char*& dest_str) {
const int flag_source_str_is_null_terminated = -1;
const int flag_estimate_chars_count = 0;
int chars_count_estimated = WideCharToMultiByte(CP_ACP,
0,
source_utf16_str, flag_source_str_is_null_terminated,
NULL, flag_estimate_chars_count, NULL, NULL);
if (chars_count_estimated == 0) {
const int len_estimated = WideCharToMultiByte(CP_ACP,
0,
source_utf16_str,
-1, // source is null-terminated
NULL,
0, // estimate characters count
NULL, NULL);
if (len_estimated == 0) {
dest_str = NULL;
return EINVAL;
}
dest_str = NEW_C_HEAP_ARRAY(CHAR, chars_count_estimated, mtInternal);
dest_str = NEW_C_HEAP_ARRAY(CHAR, len_estimated, mtInternal);
int chars_count_real = WideCharToMultiByte(CP_ACP,
0,
source_utf16_str, flag_source_str_is_null_terminated,
dest_str, chars_count_estimated, NULL, NULL);
assert(chars_count_real == chars_count_estimated, "length already checked above");
const int len_real = WideCharToMultiByte(CP_ACP,
0,
source_utf16_str,
-1, // source is null-terminated
dest_str, len_estimated, NULL, NULL);
assert(len_real == len_estimated, "length already checked above");
return ERROR_SUCCESS;
}
@@ -1435,7 +1438,7 @@ public:
// in case of error it checks if .dll/.so was built for the
// same architecture as Hotspot is running on
// The name given is in UTF-8.
void * os::dll_load(const char *utf8_name, char *ebuf, int ebuflen) {
void * os::dll_load_utf8(const char *utf8_name, char *ebuf, int ebuflen) {
LPWSTR utf16_name = NULL;
errno_t err = convert_UTF8_to_UTF16(utf8_name, &utf16_name);
MemoryReleaserW release_utf16_name(utf16_name);
@@ -1564,6 +1567,122 @@ void * os::dll_load(const char *utf8_name, char *ebuf, int ebuflen) {
return NULL;
}
void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
log_info(os)("attempting shared library load of %s", name);
void * result = LoadLibrary(name);
if (result != NULL) {
Events::log(NULL, "Loaded shared library %s", name);
// Recalculate pdb search path if a DLL was loaded successfully.
SymbolEngine::recalc_search_path();
log_info(os)("shared library load of %s was successful", name);
return result;
}
DWORD errcode = GetLastError();
// Read system error message into ebuf
// It may or may not be overwritten below (in the for loop and just above)
lasterror(ebuf, (size_t) ebuflen);
ebuf[ebuflen - 1] = '\0';
Events::log(NULL, "Loading shared library %s failed, error code %lu", name, errcode);
log_info(os)("shared library load of %s failed, error code %lu", name, errcode);
if (errcode == ERROR_MOD_NOT_FOUND) {
strncpy(ebuf, "Can't find dependent libraries", ebuflen - 1);
ebuf[ebuflen - 1] = '\0';
return NULL;
}
// Parsing dll below
// If we can read dll-info and find that dll was built
// for an architecture other than Hotspot is running in
// - then print to buffer "DLL was built for a different architecture"
// else call os::lasterror to obtain system error message
int fd = ::open(name, O_RDONLY | O_BINARY, 0);
if (fd < 0) {
return NULL;
}
uint32_t signature_offset;
uint16_t lib_arch = 0;
bool failed_to_get_lib_arch =
( // Go to position 3c in the dll
(os::seek_to_file_offset(fd, IMAGE_FILE_PTR_TO_SIGNATURE) < 0)
||
// Read location of signature
(sizeof(signature_offset) !=
(os::read(fd, (void*)&signature_offset, sizeof(signature_offset))))
||
// Go to COFF File Header in dll
// that is located after "signature" (4 bytes long)
(os::seek_to_file_offset(fd,
signature_offset + IMAGE_FILE_SIGNATURE_LENGTH) < 0)
||
// Read field that contains code of architecture
// that dll was built for
(sizeof(lib_arch) != (os::read(fd, (void*)&lib_arch, sizeof(lib_arch))))
);
::close(fd);
if (failed_to_get_lib_arch) {
// file i/o error - report os::lasterror(...) msg
return NULL;
}
typedef struct {
uint16_t arch_code;
char* arch_name;
} arch_t;
static const arch_t arch_array[] = {
{IMAGE_FILE_MACHINE_I386, (char*)"IA 32"},
{IMAGE_FILE_MACHINE_AMD64, (char*)"AMD 64"}
};
#if (defined _M_AMD64)
static const uint16_t running_arch = IMAGE_FILE_MACHINE_AMD64;
#elif (defined _M_IX86)
static const uint16_t running_arch = IMAGE_FILE_MACHINE_I386;
#else
#error Method os::dll_load requires that one of following \
is defined :_M_AMD64 or _M_IX86
#endif
// Obtain a string for printf operation
// lib_arch_str shall contain string what platform this .dll was built for
// running_arch_str shall string contain what platform Hotspot was built for
char *running_arch_str = NULL, *lib_arch_str = NULL;
for (unsigned int i = 0; i < ARRAY_SIZE(arch_array); i++) {
if (lib_arch == arch_array[i].arch_code) {
lib_arch_str = arch_array[i].arch_name;
}
if (running_arch == arch_array[i].arch_code) {
running_arch_str = arch_array[i].arch_name;
}
}
assert(running_arch_str,
"Didn't find running architecture code in arch_array");
// If the architecture is right
// but some other error took place - report os::lasterror(...) msg
if (lib_arch == running_arch) {
return NULL;
}
if (lib_arch_str != NULL) {
::_snprintf(ebuf, ebuflen - 1,
"Can't load %s-bit .dll on a %s-bit platform",
lib_arch_str, running_arch_str);
} else {
// don't know what architecture this dll was build for
::_snprintf(ebuf, ebuflen - 1,
"Can't load this .dll (machine code=0x%x) on a %s-bit platform",
lib_arch, running_arch_str);
}
return NULL;
}
void os::print_dll_info(outputStream *st) {
st->print_cr("Dynamic libraries:");
get_loaded_modules_info(_print_module, (void *)st);

View File

@@ -1227,7 +1227,7 @@ JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID,
HOTSPOT_JNI_NEWOBJECTA_ENTRY(env, clazz, (uintptr_t) methodID);
jobject obj = NULL;
DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj);
DT_RETURN_MARK(NewObjectA, jobject, (const jobject&)obj);
instanceOop i = alloc_object(clazz, CHECK_NULL);
obj = JNIHandles::make_local(env, i);

View File

@@ -3451,7 +3451,7 @@ JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name))
{
ThreadToNativeFromVM ttnfvm(thread);
Thread::WXWriteVerifier wx_write;
load_result = os::dll_load(name, ebuf, sizeof ebuf);
load_result = os::dll_load_utf8(name, ebuf, sizeof ebuf);
}
if (load_result == NULL) {
char msg[1024];

View File

@@ -646,6 +646,7 @@ class os: AllStatic {
// same architecture as HotSpot is running on
// in case of an error NULL is returned and an error message is stored in ebuf
static void* dll_load(const char *name, char *ebuf, int ebuflen);
static void* dll_load_utf8(const char *name, char *ebuf, int ebuflen);
// lookup symbol in a shared library
static void* dll_lookup(void* handle, const char* name);

View File

@@ -346,15 +346,15 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load0
if (!initIDs(env))
return JNI_FALSE;
char cname_buf[128];
char * cname = getUTF(env, name, cname_buf, sizeof(cname_buf));
if (cname == 0)
return JNI_FALSE;
handle = isBuiltin ? procHandle : JVM_LoadLibrary(cname);
const char * utf8_name = GetStringUTF8Chars(env, name);
if (utf8_name == NULL)
return JNI_FALSE;
handle = isBuiltin ? procHandle : JVM_LoadLibrary(utf8_name);
if (handle) {
JNI_OnLoad_t JNI_OnLoad;
// TODO:
JNI_OnLoad = (JNI_OnLoad_t)findJniFunction(env, handle,
isBuiltin ? cname : NULL,
isBuiltin ? utf8_name: NULL,
JNI_TRUE);
if (JNI_OnLoad) {
JavaVM *jvm;
@@ -379,7 +379,7 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load0
char msg[256];
jio_snprintf(msg, sizeof(msg),
"unsupported JNI version 0x%08X required by %s",
jniVersion, cname);
jniVersion, utf8_name);
JNU_ThrowByName(env, "java/lang/UnsatisfiedLinkError", msg);
if (!isBuiltin) {
JVM_UnloadLibrary(handle);
@@ -400,9 +400,7 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load0
loaded = JNI_TRUE;
done:
if (cname != NULL && cname != cname_buf) {
free(cname);
}
ReleaseStringUTF8Chars(env, name, utf8_name);
return loaded;
}

View File

@@ -693,8 +693,8 @@ static jmethodID String_getBytes_ID; /* String.getBytes(enc) */
static jfieldID String_coder_ID; /* String.coder */
static jfieldID String_value_ID; /* String.value */
static jboolean isJNUEncodingSupported = JNI_FALSE;
static jboolean jnuEncodingSupported(JNIEnv *env) {
static jboolean isJNUEncodingSupported = JNI_FALSE;
jboolean exe;
if (isJNUEncodingSupported == JNI_TRUE) {
return JNI_TRUE;
@@ -875,14 +875,37 @@ GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy)
return JNU_GetStringPlatformChars(env, jstr, isCopy);
}
static const char* getStringBytes(JNIEnv *env, jstring jstr) {
static inline jstring getUTF8String(JNIEnv *env) {
static jstring utf8Str = NULL; /* Java String "UTF-8" */
if (utf8Str == NULL) {
jstring utf8TempStr = (*env)->NewStringUTF(env, "UTF-8");
if (utf8TempStr == NULL) {
return NULL;
}
utf8Str = (jstring)(*env)->NewGlobalRef(env, utf8TempStr);
(*env)->DeleteLocalRef(env, utf8TempStr);
}
return utf8Str;
}
/* Convert the given Java string into a null-terminated byte sequence according
* to the platform encoding (if needUTF8 is false) or to UTF-8 encoding (if
* needUTF8 is true).
*/
static const char* getStringBytes(JNIEnv *env, jstring jstr, jboolean needUTF8) {
char *result = NULL;
jbyteArray hab = 0;
if ((*env)->EnsureLocalCapacity(env, 2) < 0)
return 0;
if (jnuEncodingSupported(env)) {
if (needUTF8) {
if (getUTF8String(env) == NULL)
return NULL;
hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, getUTF8String(env));
} else if (!needUTF8 && jnuEncodingSupported(env)) {
hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, jnuEncoding);
} else {
jmethodID mid;
@@ -923,7 +946,8 @@ getStringUTF8(JNIEnv *env, jstring jstr)
int ri;
jbyte coder = (*env)->GetByteField(env, jstr, String_coder_ID);
if (coder != java_lang_String_LATIN1) {
return getStringBytes(env, jstr);
const jboolean forceUTF8 = (fastEncoding != FAST_UTF_8);
return getStringBytes(env, jstr, forceUTF8);
}
if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
return NULL;
@@ -966,6 +990,18 @@ getStringUTF8(JNIEnv *env, jstring jstr)
return result;
}
JNIEXPORT const char *
GetStringUTF8Chars(JNIEnv *env, jstring jstr)
{
return getStringUTF8(env, jstr);
}
JNIEXPORT void
ReleaseStringUTF8Chars(JNIEnv* env, jstring jstr, const char *str)
{
free((void *)str);
}
JNIEXPORT const char * JNICALL
JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy)
{
@@ -985,7 +1021,7 @@ JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy)
JNU_ThrowInternalError(env, "platform encoding not initialized");
return 0;
} else
return getStringBytes(env, jstr);
return getStringBytes(env, jstr, JNI_FALSE /* Need platform encoding */);
}
JNIEXPORT void JNICALL

View File

@@ -126,6 +126,13 @@ NewStringPlatform(JNIEnv *env, const char *str);
JNIEXPORT const char *
GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
/* Convert the Java string to UTF-8 (not "modified UTF-8") */
JNIEXPORT const char *
GetStringUTF8Chars(JNIEnv *env, jstring jstr);
JNIEXPORT void
ReleaseStringUTF8Chars(JNIEnv* env, jstring jstr, const char *str);
JNIEXPORT jstring JNICALL
JNU_NewStringPlatform(JNIEnv *env, const char *str);

View File

@@ -424,4 +424,19 @@ public class Application {
((CPlatformWindow)platformWindow).toggleFullScreen();
}
public void requestEnterFullScreen(final Window window) {
final Object peer = AWTAccessor.getComponentAccessor().getPeer(window);
if (!(peer instanceof LWWindowPeer)) return;
Object platformWindow = ((LWWindowPeer) peer).getPlatformWindow();
if (!(platformWindow instanceof CPlatformWindow)) return;
((CPlatformWindow)platformWindow).enterFullScreen();
}
public void requestLeaveFullScreen(final Window window) {
final Object peer = AWTAccessor.getComponentAccessor().getPeer(window);
if (!(peer instanceof LWWindowPeer)) return;
Object platformWindow = ((LWWindowPeer) peer).getPlatformWindow();
if (!(platformWindow instanceof CPlatformWindow)) return;
((CPlatformWindow)platformWindow).leaveFullScreen();
}
}

View File

@@ -63,6 +63,9 @@ class CAccessible extends CFRetainedResource implements Accessible {
return newCAX;
}
@Override
protected native void nativeCFRelease(final long ptr, final boolean disposeOnAppKitThread);
private static native void unregisterFromCocoaAXSystem(long ptr);
private static native void valueChanged(long ptr);
private static native void selectedTextChanged(long ptr);

View File

@@ -34,7 +34,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
* correct AppKit threading and Objective-C GC semantics.
*/
public class CFRetainedResource {
private static native void nativeCFRelease(final long ptr, final boolean disposeOnAppKitThread);
protected native void nativeCFRelease(final long ptr, final boolean disposeOnAppKitThread);
private final boolean disposeOnAppKitThread;
// TODO this pointer should be private and accessed via CFNativeAction class

View File

@@ -369,15 +369,20 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
}
AWTToolkit.latestPerformKeyEquivalentEvent = event;
NSUInteger modFlags = [event modifierFlags] &
(NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask);
// Workaround for JBR-3544
// When tabbing mode is on, macOS sends "Ctrl N" and "Cmd N" when "Ctrl Opt N" and "Cmd Opt N" are pressed
if ([event keyCode] == 45 && ((modFlags == NSControlKeyMask) || (modFlags == NSCommandKeyMask))) {
return NO;
}
// if IM is active key events should be ignored
if (![self hasMarkedText] && !fInPressAndHold) {
[self deliverJavaKeyEventHelper: event];
}
// Workaround for 8020209: special case for "Cmd =" and "Cmd ."
// because Cocoa calls performKeyEquivalent twice for these keystrokes
NSUInteger modFlags = [event modifierFlags] &
(NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask);
if (modFlags == NSCommandKeyMask) {
NSString *eventChars = [event charactersIgnoringModifiers];
if ([eventChars length] == 1) {

View File

@@ -28,6 +28,28 @@
#import "sun_lwawt_macosx_CFRetainedResource.h"
void nativeCFRelease(JNIEnv *env, jlong ptr, jboolean releaseOnAppKitThread, bool (^condition)(jlong))
{
JNF_COCOA_ENTER(env);
if (releaseOnAppKitThread) {
// Releasing resources on the main AppKit message loop only
// Releasing resources on the nested loops may cause dangling
// pointers after the nested loop is exited
if ([NSApp respondsToSelector:@selector(postRunnableEvent:)]) {
[NSApp postRunnableEvent:^() {
if (condition(ptr)) CFRelease(jlong_to_ptr(ptr));
}];
} else {
// could happen if we are embedded inside SWT/FX application,
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
if (condition(ptr)) CFRelease(jlong_to_ptr(ptr));
}];
}
} else {
if (condition(ptr)) CFRelease(jlong_to_ptr(ptr));
}
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CFRetainedResource
@@ -35,29 +57,7 @@
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CFRetainedResource_nativeCFRelease
(JNIEnv *env, jclass clazz, jlong ptr, jboolean releaseOnAppKitThread)
(JNIEnv *env, jobject peer, jlong ptr, jboolean releaseOnAppKitThread)
{
if (releaseOnAppKitThread) {
// Releasing resources on the main AppKit message loop only
// Releasing resources on the nested loops may cause dangling
// pointers after the nested loop is exited
if ([NSApp respondsToSelector:@selector(postRunnableEvent:)]) {
[NSApp postRunnableEvent:^() {
CFRelease(jlong_to_ptr(ptr));
}];
} else {
// could happen if we are embedded inside SWT/FX application,
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
CFRelease(jlong_to_ptr(ptr));
}];
}
} else {
JNF_COCOA_ENTER(env);
CFRelease(jlong_to_ptr(ptr));
JNF_COCOA_EXIT(env);
}
nativeCFRelease(env, ptr, true, ^bool (jlong ptr) { return true; });
}

View File

@@ -55,6 +55,8 @@
// for example, for AccessibleJTreeNode, whose currentComponent has index -1
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view isCurrent:(BOOL)current;
+ (bool) isAllocated:(long)ptr;
@property(readonly) jobject accessible;
@property(readonly) jobject component;
@property(readonly) jint index;

View File

@@ -46,6 +46,8 @@ static JNF_MEMBER_CACHE(jm_getAccessibleContext, sjc_CAccessible, "getAccessible
static jobject sAccessibilityClass = NULL;
NSMutableArray *sJavaComponentAccessibilityPtrs = nil; // a list of pointers to allocated JavaComponentAccessibility objects
static void RaiseMustOverrideException(NSString *method)
{
@throw [NSException exceptionWithName:NSInternalInconsistencyException
@@ -55,6 +57,24 @@ static void RaiseMustOverrideException(NSString *method)
@implementation JavaComponentAccessibility
- (instancetype)init
{
if (self = [super init]) {
if (sJavaComponentAccessibilityPtrs == nil) {
sJavaComponentAccessibilityPtrs = [[NSMutableArray alloc] init];
[sJavaComponentAccessibilityPtrs retain]; // per-process persistent
}
[sJavaComponentAccessibilityPtrs addObject:[NSNumber numberWithLong:(jlong)self]];
}
return self;
}
+ (bool) isAllocated:(long)ptr
{
assert([NSThread isMainThread]);
return [sJavaComponentAccessibilityPtrs containsObject:[NSNumber numberWithLong:ptr]];
}
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole
{
self = [self init];
@@ -94,6 +114,8 @@ static void RaiseMustOverrideException(NSString *method)
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
[sJavaComponentAccessibilityPtrs removeObject:[NSNumber numberWithLong:(jlong)self]];
(*env)->DeleteWeakGlobalRef(env, fAccessible);
fAccessible = NULL;
@@ -1152,9 +1174,29 @@ JNF_COCOA_EXIT(env);
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_unregisterFromCocoaAXSystem
(JNIEnv *env, jclass jklass, jlong element)
(JNIEnv *env, jclass jklass, jlong ptr)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(unregisterFromCocoaAXSystem) on:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
[ThreadUtilities performOnMainThreadWaiting:NO block:^() {
if ([JavaComponentAccessibility isAllocated:ptr]) {
[(JavaComponentAccessibility *)jlong_to_ptr(ptr) unregisterFromCocoaAXSystem];
}
}];
JNF_COCOA_EXIT(env);
}
extern void nativeCFRelease(JNIEnv *env, jlong ptr, jboolean releaseOnAppKitThread, bool (^condition)(jlong));
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: nativeCFRelease
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_nativeCFRelease
(JNIEnv *env, jobject peer, jlong ptr, jboolean releaseOnAppKitThread)
{
assert(releaseOnAppKitThread);
nativeCFRelease(env, ptr, true, ^bool (jlong ptr) {
return [JavaComponentAccessibility isAllocated:ptr];
});
}

View File

@@ -210,6 +210,7 @@ public class MetalRootPaneUI extends BasicRootPaneUI
* @param parent The parent of the JRootPane
*/
private void installWindowListeners(JRootPane root, Component parent) {
if (parent == null) return;
if (parent instanceof Window) {
window = (Window)parent;
}

View File

@@ -1968,8 +1968,8 @@ MsgRouting AwtWindow::WmGetMinMaxInfo(LPMINMAXINFO lpmmi)
if ((m_minSize.x == 0) && (m_minSize.y == 0)) {
return r;
}
lpmmi->ptMinTrackSize.x = m_minSize.x;
lpmmi->ptMinTrackSize.y = m_minSize.y;
lpmmi->ptMinTrackSize.x = ScaleUpX(m_minSize.x);
lpmmi->ptMinTrackSize.y = ScaleUpY(m_minSize.y);
return mrConsume;
}

View File

@@ -1,17 +1,25 @@
/*
* Copyright 2021 JetBrains s.r.o.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, JetBrains s.r.o.. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 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.
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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).
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
import java.nio.file.Files;
@@ -25,19 +33,15 @@ public class LoadLibraryUnicode {
static native int giveANumber();
private static final String NON_LATIN_PATH_NAME = "ka-\u1889-omega-\u03c9";
// Use non-Latin characters from basic (\u1889) and supplementary (\uD844\uDDD9) Unicode planes
private static final String NON_LATIN_PATH_NAME = "ka-\u1889-supp-\uD844\uDDD9";
private static String toPlatformLibraryName(String name) {
return (Platform.isWindows() ? "" : "lib") + name + "." + Platform.sharedLibraryExt();
}
public static void verifySystemLoad() throws Exception {
String osDependentLibraryFileName = null;
if (Platform.isLinux()) {
osDependentLibraryFileName = "libLoadLibraryUnicode.so";
} else if (Platform.isOSX()) {
osDependentLibraryFileName = "libLoadLibraryUnicode.dylib";
} else if (Platform.isWindows()) {
osDependentLibraryFileName = "LoadLibraryUnicode.dll";
} else {
throw new Error("Unsupported OS");
}
final String osDependentLibraryFileName = toPlatformLibraryName("LoadLibraryUnicode");
String testNativePath = LoadLibraryUnicodeTest.getSystemProperty("test.nativepath");
Path origLibraryPath = Paths.get(testNativePath).resolve(osDependentLibraryFileName);

View File

@@ -66,6 +66,12 @@ public class TestTitledBorderLeak {
System.err.println("TOTAL_TITLEDBORDER != weakRefArrTB.size()");
}
Thread.sleep(3000);
SwingUtilities.invokeAndWait(() -> {
for (int i = 0; i < TOTAL_TITLEDBORDER; i++) {
frame[i].setVisible(false);
}
});
Thread.sleep(3000);
SwingUtilities.invokeAndWait(() -> {
for (int i = 0; i < TOTAL_TITLEDBORDER; i++) {
frame[i].dispose();

View File

@@ -6,6 +6,7 @@ import org.cef.browser.CefMessageRouter;
import org.cef.handler.CefLoadHandlerAdapter;
import org.cef.callback.CefQueryCallback;
import org.cef.handler.CefMessageRouterHandlerAdapter;
import org.cef.network.CefRequest.TransitionType;
import javax.swing.*;
import java.awt.event.WindowAdapter;
@@ -17,7 +18,6 @@ import java.util.concurrent.TimeUnit;
/**
* @test
* @key headful
* @requires (os.arch == "amd64" | os.arch == "x86_64" | (os.arch == "aarch64" & os.family == "mac"))
* @summary Regression test for JBR-2430. The test checks that JS Query is handled in 2nd opened browser.
* @run main/othervm HandleJSQueryTest
*/
@@ -32,10 +32,10 @@ public class HandleJSQueryTest {
try {
SwingUtilities.invokeLater(firstBrowser::initUI);
firstLatch.await(3, TimeUnit.SECONDS);
firstLatch.await(10, TimeUnit.SECONDS);
SwingUtilities.invokeLater(secondBrowser::initUI);
secondLatch.await(3, TimeUnit.SECONDS);
secondLatch.await(10, TimeUnit.SECONDS);
if (CefBrowserFrame.callbackCounter < 2) {
throw new RuntimeException("Test FAILED. JS Query was not handled in 2nd opened browser");
@@ -54,8 +54,8 @@ public class HandleJSQueryTest {
class CefBrowserFrame extends JFrame {
static int callbackCounter;
static int browserNumber;
static volatile int callbackCounter;
static volatile int browserNumber;
private final JBCefBrowser browser = new JBCefBrowser();
@@ -86,9 +86,13 @@ class CefBrowserFrame extends JFrame {
browser.getCefClient().addMessageRouter(msgRouter);
browser.getCefClient().addLoadHandler(new CefLoadHandlerAdapter() {
@Override
public void onLoadStart(CefBrowser browser, CefFrame frame, TransitionType transitionType) {
System.out.println("onLoadStart: Browser " + browserNumber);
}
@Override
public void onLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode) {
System.out.println("Browser " + browserNumber + " is loaded.");
System.out.println("onLoadEnd: Browser " + browserNumber);
String jsFunc = "cef_query_" + browserNumber;
String jsQuery = "window." + jsFunc + "({request: '" + jsFunc + "'});";
browser.executeJavaScript(jsQuery, "", 0);

View File

@@ -43,7 +43,7 @@ fi
curdir=$(pwd)
cd ${TESTSRC}
${TESTJAVA}/bin/javac -d ${TESTCLASSES} HandleJSQueryTest.java
${TESTJAVA}/bin/javac -d ${TESTCLASSES} JBCefApp.java JBCefBrowser.java HandleJSQueryTest.java
cd $curdir
i=0

View File

@@ -700,9 +700,9 @@ java/awt/xembed/server/RunTestXEmbed.java
sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all
sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all
# Fedora & ArchLinux (Wayland)
# Fedora & ArchLinux (Wayland) & Ubuntu 21.04
sun/java2d/AcceleratedXORModeTest.java JBR-3167 linux-5.10.12-200.fc33.x86_64,linux-5.11.6-arch1-1
sun/java2d/ClassCastExceptionForInvalidSurface.java JBR-3167 linux-5.10.12-200.fc33.x86_64,linux-5.11.6-arch1-1
sun/java2d/ClassCastExceptionForInvalidSurface.java JBR-3167 linux-5.10.12-200.fc33.x86_64,linux-5.11.6-arch1-1,5.11.0-17-generic
sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java 8022403 generic-all
sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all
@@ -847,6 +847,7 @@ sun/security/pkcs11/KeyStore/SecretKeysBasic.sh
security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java 8224768 generic-all
security/infra/java/security/cert/CertPathValidator/certification/GlobalSignR6CA.java 8249176 generic-all
security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java 8268678 generic-all
security/infra/java/security/cert/CertPathValidator/certification/LuxTrustCA.java 8237888 generic-all
############################################################################