From 0ce605c9111b7361792060d2d789bd6f322a07b7 Mon Sep 17 00:00:00 2001 From: jchen Date: Thu, 3 Oct 2013 13:49:52 -0700 Subject: [PATCH] 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11 Reviewed-by: prr, jgodinez --- src/solaris/native/sun/java2d/x11/X11Renderer.c | 17 ++++++----------- .../native/sun/java2d/x11/X11SurfaceData.c | 8 ++++++-- .../native/sun/java2d/x11/XRBackendNative.c | 10 ++++++++++ .../native/sun/java2d/x11/XRSurfaceData.c | 6 ++++++ 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/solaris/native/sun/java2d/x11/X11Renderer.c b/src/solaris/native/sun/java2d/x11/X11Renderer.c index cfae03c92..bbe32a07b 100644 --- a/src/solaris/native/sun/java2d/x11/X11Renderer.c +++ b/src/solaris/native/sun/java2d/x11/X11Renderer.c @@ -465,9 +465,7 @@ JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawPoly points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy, pTmp, (int *)&npoints, isclosed); - if (points == 0) { - JNU_ThrowOutOfMemoryError(env, "translated coordinate array"); - } else { + if (points != 0) { if (npoints == 2) { /* * Some X11 implementations fail to draw anything for @@ -588,6 +586,7 @@ Java_sun_java2d_x11_X11Renderer_XDoPath NULL }; PHStroke stroke; + jboolean ok = JNI_TRUE; if (xsdo == NULL) { return; @@ -625,8 +624,6 @@ Java_sun_java2d_x11_X11Renderer_XDoPath types = (jbyte*) (*env)->GetPrimitiveArrayCritical(env, typesArray, NULL); if (types != NULL) { - jboolean ok; - if (isFill) { drawHandler.pDrawScanline = &drawScanline; ok = doFillPath(&drawHandler, @@ -643,14 +640,14 @@ Java_sun_java2d_x11_X11Renderer_XDoPath types, numTypes, stroke); } - if (!ok) { - JNU_ThrowArrayIndexOutOfBoundsException(env, "coords array"); - } (*env)->ReleasePrimitiveArrayCritical(env, typesArray, types, JNI_ABORT); } (*env)->ReleasePrimitiveArrayCritical(env, coordsArray, coords, JNI_ABORT); + if (!ok) { + JNU_ThrowArrayIndexOutOfBoundsException(env, "coords array"); + } } XDHD_FREE_POINTS(&dHData); @@ -893,9 +890,7 @@ JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillPoly points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy, pTmp, (int *)&npoints, JNI_FALSE); - if (points == 0) { - JNU_ThrowOutOfMemoryError(env, "translated coordinate array"); - } else { + if (points != 0) { if (npoints > 2) { XFillPolygon(awt_display, xsdo->drawable, (GC) xgc, points, npoints, Complex, CoordModeOrigin); diff --git a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c index f944cff7e..a35d6fd30 100644 --- a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c +++ b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c @@ -227,7 +227,7 @@ Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable(JNIEnv *env, jobject this) #if defined(HEADLESS) || !defined(MITSHM) return JNI_FALSE; #else - return useMitShmPixmaps; + return (jboolean)useMitShmPixmaps; #endif /* HEADLESS, MITSHM */ } @@ -258,6 +258,7 @@ Java_sun_java2d_x11_XSurfaceData_initOps(JNIEnv *env, jobject xsd, { #ifndef HEADLESS X11SDOps *xsdo = (X11SDOps*)SurfaceData_InitOps(env, xsd, sizeof(X11SDOps)); + jboolean hasException; if (xsdo == NULL) { JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); return; @@ -270,7 +271,10 @@ Java_sun_java2d_x11_XSurfaceData_initOps(JNIEnv *env, jobject xsd, xsdo->ReleasePixmapWithBg = X11SD_ReleasePixmapWithBg; xsdo->widget = NULL; if (peer != NULL) { - xsdo->drawable = JNU_CallMethodByName(env, NULL, peer, "getWindow", "()J").j; + xsdo->drawable = JNU_CallMethodByName(env, &hasException, peer, "getWindow", "()J").j; + if (hasException) { + return; + } } else { xsdo->drawable = 0; } diff --git a/src/solaris/native/sun/java2d/x11/XRBackendNative.c b/src/solaris/native/sun/java2d/x11/XRBackendNative.c index 1705c28f4..3a5c9caca 100644 --- a/src/solaris/native/sun/java2d/x11/XRBackendNative.c +++ b/src/solaris/native/sun/java2d/x11/XRBackendNative.c @@ -326,7 +326,13 @@ Java_sun_java2d_xr_XRBackendNative_initIDs(JNIEnv *env, jclass cls) { jlong fmt32; jfieldID a8ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_A8", "J"); + if (a8ID == NULL) { + return; + } jfieldID argb32ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_ARGB32", "J"); + if (argb32ID == NULL) { + return; + } if (awt_display == (Display *)NULL) { return; @@ -346,6 +352,10 @@ Java_sun_java2d_xr_XRBackendNative_initIDs(JNIEnv *env, jclass cls) { defaultImg = XCreateImage(awt_display, NULL, 8, ZPixmap, 0, maskData, 32, 32, 8, 0); defaultImg->data = maskData; //required? maskImgID = (*env)->GetStaticFieldID(env, cls, "MASK_XIMG", "J"); + if (maskImgID == NULL) { + return; + } + (*env)->SetStaticLongField(env, cls, maskImgID, ptr_to_jlong(defaultImg)); } diff --git a/src/solaris/native/sun/java2d/x11/XRSurfaceData.c b/src/solaris/native/sun/java2d/x11/XRSurfaceData.c index b598a22ab..a9c762f87 100644 --- a/src/solaris/native/sun/java2d/x11/XRSurfaceData.c +++ b/src/solaris/native/sun/java2d/x11/XRSurfaceData.c @@ -88,7 +88,13 @@ Java_sun_java2d_xr_XRSurfaceData_initIDs(JNIEnv *env, jclass xsd) J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initIDs"); pictID = (*env)->GetFieldID(env, xsd, "picture", "I"); + if (pictID == NULL) { + return; + } xidID = (*env)->GetFieldID(env, xsd, "xid", "I"); + if (xidID == NULL) { + return; + } XShared_initIDs(env, JNI_FALSE); #endif /* !HEADLESS */ -- GitLab