Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8257853: Remove dependencies on JNF's JNI utility functions in AWT and 2D code #1679

Closed
wants to merge 10 commits into from
Closed
@@ -572,7 +572,7 @@ -(NSMutableString *) parseString : (id) complexString {
- (jobject)awtComponent:(JNIEnv*)env
{
DECLARE_CLASS_RETURN(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView", NULL);
DECLARE_METHOD_RETURN(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;", NULL);
DECLARE_FIELD_RETURN(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;", NULL);
if ((env == NULL) || (m_cPlatformView == NULL)) {
NSLog(@"Apple AWT : Error AWTView:awtComponent given bad parameters.");
if (env != NULL)
@@ -589,7 +589,7 @@ - (jobject)awtComponent:(JNIEnv*)env
(*env)->DeleteLocalRef(env, jlocal);
}
DECLARE_CLASS_RETURN(jc_LWWindowPeer, "sun/lwawt/LWWindowPeer", NULL);
DECLARE_METHOD_RETURN(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;", NULL);
DECLARE_FIELD_RETURN(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;", NULL);
if (peer == NULL) {
NSLog(@"Apple AWT : Error AWTView:awtComponent got null peer from CPlatformView");
JNFDumpJavaStack(env);
This conversation was marked as resolved by prrace

This comment has been minimized.

@prsadhuk

prsadhuk Dec 17, 2020
Contributor

and this JNFDumpJavaStack?

This comment has been minimized.

@prrace

prrace Dec 17, 2020
Author Contributor

It will get removed eventually when we stop importing JavaNativeFoundation but does not need to be removed yet

@@ -55,7 +55,7 @@ NSSize getAxComponentSize(JNIEnv *env, jobject axComponent, jobject component)
DECLARE_CLASS_RETURN(jc_Dimension, "java/awt/Dimension", NSZeroSize);
DECLARE_FIELD_RETURN(jf_width, jc_Dimension, "width", "I", NSZeroSize);
DECLARE_FIELD_RETURN(jf_height, jc_Dimension, "height", "I", NSZeroSize);
DECLARE_METHOD_RETURN(jm_getSize, sjc_CAccessibility, "getSize",
DECLARE_STATIC_METHOD_RETURN(jm_getSize, sjc_CAccessibility, "getSize",
"(Ljavax/accessibility/AccessibleComponent;Ljava/awt/Component;)Ljava/awt/Dimension;", NSZeroSize);

jobject dimension = (*env)->CallStaticObjectMethod(env, jc_Dimension, jm_getSize, axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
@@ -68,7 +68,7 @@ NSSize getAxComponentSize(JNIEnv *env, jobject axComponent, jobject component)
NSString *getJavaRole(JNIEnv *env, jobject axComponent, jobject component)
{
GET_CACCESSIBILITY_CLASS_RETURN(nil);
DECLARE_METHOD_RETURN(sjm_getAccessibleRole, sjc_CAccessibility, "getAccessibleRole",
DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleRole, sjc_CAccessibility, "getAccessibleRole",
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil);
jobject axRole = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleRole,
axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
@@ -83,7 +83,7 @@ NSSize getAxComponentSize(JNIEnv *env, jobject axComponent, jobject component)
jobject getAxSelection(JNIEnv *env, jobject axContext, jobject component)
{
GET_CACCESSIBILITY_CLASS_RETURN(nil);
DECLARE_METHOD_RETURN(jm_getAccessibleSelection, sjc_CAccessibility, "getAccessibleSelection",
DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleSelection, sjc_CAccessibility, "getAccessibleSelection",
"(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleSelection;", nil);
jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleSelection,
axContext, component); // AWT_THREADING Safe (AWTRunLoopMode)
@@ -94,7 +94,7 @@ jobject getAxSelection(JNIEnv *env, jobject axContext, jobject component)
jobject getAxContextSelection(JNIEnv *env, jobject axContext, jint index, jobject component)
{
GET_CACCESSIBILITY_CLASS_RETURN(nil);
DECLARE_METHOD_RETURN(jm_ax_getAccessibleSelection, sjc_CAccessibility, "ax_getAccessibleSelection",
DECLARE_STATIC_METHOD_RETURN(jm_ax_getAccessibleSelection, sjc_CAccessibility, "ax_getAccessibleSelection",
"(Ljavax/accessibility/AccessibleContext;ILjava/awt/Component;)Ljavax/accessibility/Accessible;", nil);
return (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_ax_getAccessibleSelection,
axContext, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
@@ -104,7 +104,7 @@ jobject getAxContextSelection(JNIEnv *env, jobject axContext, jint index, jobjec
void setAxContextSelection(JNIEnv *env, jobject axContext, jint index, jobject component)
{
GET_CACCESSIBILITY_CLASS();
DECLARE_METHOD(jm_addAccessibleSelection, sjc_CAccessibility, "addAccessibleSelection",
DECLARE_STATIC_METHOD(jm_addAccessibleSelection, sjc_CAccessibility, "addAccessibleSelection",
"(Ljavax/accessibility/AccessibleContext;ILjava/awt/Component;)V");
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_addAccessibleSelection,
axContext, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
@@ -114,7 +114,7 @@ void setAxContextSelection(JNIEnv *env, jobject axContext, jint index, jobject c
jobject getAxContext(JNIEnv *env, jobject accessible, jobject component)
{
GET_CACCESSIBILITY_CLASS_RETURN(nil);
DECLARE_METHOD_RETURN(jm_getAccessibleContext, sjc_CAccessibility, "getAccessibleContext",
DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleContext, sjc_CAccessibility, "getAccessibleContext",
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleContext;", nil);
jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleContext,
accessible, component); // AWT_THREADING Safe (AWTRunLoopMode)
@@ -125,7 +125,7 @@ jobject getAxContext(JNIEnv *env, jobject accessible, jobject component)
BOOL isChildSelected(JNIEnv *env, jobject accessible, jint index, jobject component)
{
GET_CACCESSIBILITY_CLASS_RETURN(NO);
DECLARE_METHOD_RETURN(jm_isAccessibleChildSelected, sjc_CAccessibility, "isAccessibleChildSelected",
DECLARE_STATIC_METHOD_RETURN(jm_isAccessibleChildSelected, sjc_CAccessibility, "isAccessibleChildSelected",
"(Ljavax/accessibility/Accessible;ILjava/awt/Component;)Z", NO);
jboolean b = (*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_isAccessibleChildSelected,
accessible, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
@@ -136,7 +136,7 @@ BOOL isChildSelected(JNIEnv *env, jobject accessible, jint index, jobject compon
jobject getAxStateSet(JNIEnv *env, jobject axContext, jobject component)
{
GET_CACCESSIBILITY_CLASS_RETURN(nil);
DECLARE_METHOD_RETURN(jm_getAccessibleStateSet, sjc_CAccessibility, "getAccessibleStateSet",
DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleStateSet, sjc_CAccessibility, "getAccessibleStateSet",
"(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleStateSet;", nil);
jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleStateSet,
axContext, component); // AWT_THREADING Safe (AWTRunLoopMode)
@@ -147,9 +147,9 @@ jobject getAxStateSet(JNIEnv *env, jobject axContext, jobject component)
BOOL containsAxState(JNIEnv *env, jobject axContext, jobject axState, jobject component)
{
GET_CACCESSIBILITY_CLASS_RETURN(NO);
DECLARE_METHOD_RETURN(jm_contains, sjc_CAccessibility, "contains",
DECLARE_STATIC_METHOD_RETURN(jm_contains, sjc_CAccessibility, "contains",
"(Ljavax/accessibility/AccessibleContext;Ljavax/accessibility/AccessibleState;Ljava/awt/Component;)Z", NO);
jboolean b = (*env)->CallStaticBooleanMethod(env, jm_contains, axContext, axState, component); // AWT_THREADING Safe (AWTRunLoopMode)
jboolean b = (*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_contains, axContext, axState, component); // AWT_THREADING Safe (AWTRunLoopMode)
CHECK_EXCEPTION();
return b;
}
@@ -209,7 +209,7 @@ NSPoint getAxComponentLocationOnScreen(JNIEnv *env, jobject axComponent, jobject
DECLARE_CLASS_RETURN(sjc_Point, "java/awt/Point", NSZeroPoint);
DECLARE_FIELD_RETURN(sjf_X, sjc_Point, "x", "I", NSZeroPoint);
DECLARE_FIELD_RETURN(sjf_Y, sjc_Point, "y", "I", NSZeroPoint);
jobject jpoint = (*env)->CallStaticObjectMethod(env, sjc_Point, jm_getLocationOnScreen,
jobject jpoint = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getLocationOnScreen,
axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
CHECK_EXCEPTION();
if (jpoint == NULL) return NSZeroPoint;
@@ -60,13 +60,13 @@
static jmethodID sjm_getAccessibleName = NULL;
#define GET_ACCESSIBLENAME_METHOD_RETURN(ret) \
GET_CACCESSIBILITY_CLASS_RETURN(ret); \
GET_METHOD_RETURN(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", \
GET_STATIC_METHOD_RETURN(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", \
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", ret);

static jmethodID jm_getChildrenAndRoles = NULL;
#define GET_CHILDRENANDROLES_METHOD_RETURN(ret) \
GET_CACCESSIBILITY_CLASS_RETURN(ret); \
GET_METHOD_RETURN(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles",\
GET_STATIC_METHOD_RETURN(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles",\
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZ)[Ljava/lang/Object;", ret);

static jmethodID sjm_getAccessibleComponent = NULL;
@@ -1256,7 +1256,7 @@ - (NSString *)accessibilityTitleAttribute
JNIEnv* env = [ThreadUtilities getJNIEnv];

GET_ACCESSIBLENAME_METHOD_RETURN(nil);
jobject val = (*env)->CallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
jobject val = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
CHECK_EXCEPTION();
if (val == NULL) {
return nil;