< prev index next >
src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m
Print this page
rev 54094 : 8257853: Remove dependencies on JNF's JNI utility functions in AWT and 2D code
@@ -21,50 +21,49 @@
* 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 <JavaNativeFoundation/JavaNativeFoundation.h>
+#import "JNIUtilities.h"
#import "AWTSurfaceLayers.h"
-#import "jni_util.h"
JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo
(JAWT_DrawingSurface* ds)
{
JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*)malloc(sizeof(JAWT_DrawingSurfaceInfo));
JNIEnv *env = ds->env;
jobject target = ds->target;
- static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
- static JNF_MEMBER_CACHE(jf_peer, jc_Component, "peer", "Ljava/awt/peer/ComponentPeer;");
- jobject peer = JNFGetObjectField(env, target, jf_peer);
-
- static JNF_CLASS_CACHE(jc_ComponentPeer, "sun/lwawt/LWComponentPeer");
- static JNF_MEMBER_CACHE(jf_platformComponent, jc_ComponentPeer,
- "platformComponent", "Lsun/lwawt/PlatformComponent;");
- jobject platformComponent = JNFGetObjectField(env, peer, jf_platformComponent);
-
- static JNF_CLASS_CACHE(jc_PlatformComponent, "sun/lwawt/macosx/CPlatformComponent");
- static JNF_MEMBER_CACHE(jm_getPointer, jc_PlatformComponent, "getPointer", "()J");
- AWTSurfaceLayers *surfaceLayers = jlong_to_ptr(JNFCallLongMethod(env, platformComponent, jm_getPointer));
+ DECLARE_CLASS_RETURN(jc_Component, "java/awt/Component", NULL);
+ DECLARE_FIELD_RETURN(jf_peer, jc_Component, "peer", "Ljava/awt/peer/ComponentPeer;", NULL);
+ jobject peer = (*env)->GetObjectField(env, target, jf_peer);
+
+ DECLARE_CLASS_RETURN(jc_ComponentPeer, "sun/lwawt/LWComponentPeer", NULL);
+ DECLARE_FIELD_RETURN(jf_platformComponent, jc_ComponentPeer,
+ "platformComponent", "Lsun/lwawt/PlatformComponent;", NULL);
+ jobject platformComponent = (*env)->GetObjectField(env, peer, jf_platformComponent);
+
+ DECLARE_CLASS_RETURN(jc_PlatformComponent, "sun/lwawt/macosx/CPlatformComponent", NULL);
+ DECLARE_METHOD_RETURN(jm_getPointer, jc_PlatformComponent, "getPointer", "()J", NULL);
+ AWTSurfaceLayers *surfaceLayers = jlong_to_ptr((*env)->CallLongMethod(env, platformComponent, jm_getPointer));
// REMIND: assert(surfaceLayers)
dsi->platformInfo = surfaceLayers;
dsi->ds = ds;
- static JNF_MEMBER_CACHE(jf_x, jc_Component, "x", "I");
- static JNF_MEMBER_CACHE(jf_y, jc_Component, "y", "I");
- static JNF_MEMBER_CACHE(jf_width, jc_Component, "width", "I");
- static JNF_MEMBER_CACHE(jf_height, jc_Component, "height", "I");
-
- dsi->bounds.x = JNFGetIntField(env, target, jf_x);
- dsi->bounds.y = JNFGetIntField(env, target, jf_y);
- dsi->bounds.width = JNFGetIntField(env, target, jf_width);
- dsi->bounds.height = JNFGetIntField(env, target, jf_height);
+ DECLARE_FIELD_RETURN(jf_x, jc_Component, "x", "I", NULL);
+ DECLARE_FIELD_RETURN(jf_y, jc_Component, "y", "I", NULL);
+ DECLARE_FIELD_RETURN(jf_width, jc_Component, "width", "I", NULL);
+ DECLARE_FIELD_RETURN(jf_height, jc_Component, "height", "I", NULL);
+
+ dsi->bounds.x = (*env)->GetIntField(env, target, jf_x);
+ dsi->bounds.y = (*env)->GetIntField(env, target, jf_y);
+ dsi->bounds.width = (*env)->GetIntField(env, target, jf_width);
+ dsi->bounds.height = (*env)->GetIntField(env, target, jf_height);
dsi->clipSize = 1;
dsi->clip = &(dsi->bounds);
return dsi;
@@ -146,11 +145,13 @@
cls = (*env)->FindClass(env, embeddedClassName);
CHECK_NULL_RETURN(cls, NULL);
mid = (*env)->GetMethodID(env, cls, "<init>", "(J)V");
CHECK_NULL_RETURN(mid, NULL);
}
- return (*env)->NewObject(env, cls, mid, platformInfo);
+ jobject o = (*env)->NewObject(env, cls, mid, platformInfo);
+ CHECK_EXCEPTION();
+ return o;
}
JNIEXPORT void JNICALL awt_SetBounds
(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h)
{
@@ -160,10 +161,11 @@
CHECK_NULL(cls);
mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V");
CHECK_NULL(mid);
}
(*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h);
+ CHECK_EXCEPTION();
}
JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
(JNIEnv *env, jobject embeddedFrame, jboolean doActivate)
{
@@ -173,6 +175,7 @@
CHECK_NULL(cls);
mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V");
CHECK_NULL(mid);
}
(*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate);
+ CHECK_EXCEPTION();
}
< prev index next >