8263490: [macos] Crash occurs on JPasswordField with activated InputMethod

Reviewed-by: dmarkov, serb, kizune
This commit is contained in:
Toshio Nakamura 2021-03-15 09:20:34 +00:00 committed by Dmitry Markov
parent 8afec70c28
commit 32c7fcc670

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, 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
@ -1164,8 +1164,12 @@ static jclass jc_CInputMethod = NULL;
#ifdef IM_DEBUG
fprintf(stderr, "AWTView InputMethod Selector Called : [attributedSubstringFromRange] location=%lu, length=%lu\n", (unsigned long)theRange.location, (unsigned long)theRange.length);
#endif // IM_DEBUG
if (!fInputMethodLOCKABLE) {
return nil;
}
JNIEnv *env = [ThreadUtilities getJNIEnv];
GET_CIM_CLASS_RETURN(nil);
DECLARE_METHOD_RETURN(jm_substringFromRange, jc_CInputMethod, "attributedSubstringFromRange", "(II)Ljava/lang/String;", nil);
jobject theString = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length);
CHECK_EXCEPTION_NULL_RETURN(theString, nil);