changeset 9450:a2ef778afcbb

Merge
author coffeys
date Tue, 01 Apr 2014 10:01:50 +0100
parents d11491ec9c07 94096aaa86cb
children 8b0d235c0d54 834e2159bd2a
files
diffstat 9 files changed, 162 insertions(+), 141 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/CTextPipe.m	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/macosx/native/sun/awt/CTextPipe.m	Tue Apr 01 10:01:50 2014 +0100
@@ -147,7 +147,7 @@
 
     CGAffineTransform invTx = CGAffineTransformInvert(strike->fTx);
 
-    NSUInteger i;
+    NSInteger i;
     for (i = 0; i < length; i++)
     {
         CGGlyph glyph = glyphs[i];
@@ -355,19 +355,31 @@
     static JNF_CLASS_CACHE(jc_StandardGlyphVector_GlyphTransformInfo, "sun/font/StandardGlyphVector$GlyphTransformInfo");
     static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_transforms, jc_StandardGlyphVector_GlyphTransformInfo, "transforms", "[D");
     jdoubleArray g_gtiTransformsArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_transforms); //(*env)->GetObjectField(env, gti, g_gtiTransforms);
+    if (g_gtiTransformsArray == NULL) {
+        return;
+    } 
     jdouble *g_gvTransformsAsDoubles = (*env)->GetPrimitiveArrayCritical(env, g_gtiTransformsArray, NULL);
+    if (g_gvTransformsAsDoubles == NULL) {
+        (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
+        return;
+    } 
 
     static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_indices, jc_StandardGlyphVector_GlyphTransformInfo, "indices", "[I");
     jintArray g_gtiTXIndicesArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_indices);
     jint *g_gvTXIndicesAsInts = (*env)->GetPrimitiveArrayCritical(env, g_gtiTXIndicesArray, NULL);
-
+    if (g_gvTXIndicesAsInts == NULL) {
+        (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
+        (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
+        (*env)->DeleteLocalRef(env, g_gtiTXIndicesArray);
+        return;
+    }
     // slowest case, we have per-glyph transforms, and possibly glyph substitution as well
     JavaCT_DrawGlyphVector(qsdo, strike, useSubstituion, uniChars, glyphs, advances, g_gvTXIndicesAsInts, g_gvTransformsAsDoubles, length);
 
     (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
+    (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTXIndicesArray, g_gvTXIndicesAsInts, JNI_ABORT);
+
     (*env)->DeleteLocalRef(env, g_gtiTransformsArray);
-
-    (*env)->ReleasePrimitiveArrayCritical(env, g_gtiTXIndicesArray, g_gvTXIndicesAsInts, JNI_ABORT);
     (*env)->DeleteLocalRef(env, g_gtiTXIndicesArray);
 }
 
@@ -403,6 +415,9 @@
 {
     // fill the glyph buffer
     jint *glyphsAsInts = (*env)->GetPrimitiveArrayCritical(env, glyphsArray, NULL);
+    if (glyphsAsInts == NULL) {
+        return;
+    }
 
     // if a glyph code from Java is negative, that means it is really a unicode value
     // which we can use in CoreText to strike the character in another font
@@ -429,11 +444,15 @@
     // fill the advance buffer
     static JNF_MEMBER_CACHE(jm_StandardGlyphVector_positions, jc_StandardGlyphVector, "positions", "[F");
     jfloatArray posArray = JNFGetObjectField(env, gVector, jm_StandardGlyphVector_positions);
-    if (posArray != NULL)
-    {
+    jfloat *positions = NULL;
+    if (posArray != NULL) {
         // in this case, the positions have already been pre-calculated for us on the Java side
-
-        jfloat *positions = (*env)->GetPrimitiveArrayCritical(env, posArray, NULL);
+        positions = (*env)->GetPrimitiveArrayCritical(env, posArray, NULL);
+        if (positions == NULL) {
+            (*env)->DeleteLocalRef(env, posArray);
+        }
+    }
+    if (positions != NULL) {
         CGPoint prev;
         prev.x = positions[0];
         prev.y = positions[1];
--- a/src/macosx/native/sun/awt/ImageSurfaceData.m	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/macosx/native/sun/awt/ImageSurfaceData.m	Tue Apr 01 10:01:50 2014 +0100
@@ -849,7 +849,7 @@
                     indexOfBest = 0;
                     distanceOfBest = DBL_MAX;
 
-                    for (i=0; i<lutDataSize; i++)
+                    for (i=0; (unsigned)i<lutDataSize; i++)
                     {
                         p2 = lutdata[i];
 
@@ -899,7 +899,7 @@
 {
     if (data != NULL)
     {
-        free(data);
+        free((void*)data);
     }
 }
 
@@ -1577,7 +1577,9 @@
     {
         static char *bimgName = "java/awt/image/BufferedImage";
         jclass bimg = (*env)->FindClass(env, bimgName);
+        CHECK_NULL_RETURN(bimg, NULL);
         sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
+        CHECK_NULL_RETURN(sDataID, NULL);
     }
 
     return (*env)->GetObjectField(env, bufImg, sDataID);
@@ -1591,7 +1593,9 @@
     {
         static char *bimgName = "java/awt/image/BufferedImage";
         jclass bimg = (*env)->FindClass(env, bimgName);
+        CHECK_NULL(bimg);
         sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
+        CHECK_NULL(sDataID);
     }
 
     (*env)->SetObjectField(env, bufImg, sDataID, sData);
@@ -1610,18 +1614,11 @@
         return;
         }
 
-        icm = (*env)->FindClass(env, icmName);
-        if (icm == NULL) {
-            return;
-        }
-
-        rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I");
-        allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z");
-        mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I");
-        CMpDataID = (*env)->GetFieldID(env, icm, "pData", "J");
-        if (allGrayID == 0 || rgbID == 0 || mapSizeID == 0 || CMpDataID == 0) {
-        JNU_ThrowInternalError(env, "Could not get field IDs");
-        }
+        CHECK_NULL(icm = (*env)->FindClass(env, icmName));
+        CHECK_NULL(rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I"));
+        CHECK_NULL(allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z"));
+        CHECK_NULL(mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I"));
+        CHECK_NULL(CMpDataID = (*env)->GetFieldID(env, icm, "pData", "J"));
     }
 
     gColorspaceRGB = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
@@ -1795,6 +1792,7 @@
         //bisdo->sdOps.Dispose = BufImg_Dispose;
 
         bisdo->array = (*env)->NewWeakGlobalRef(env, array);
+        if (array != NULL) CHECK_NULL(bisdo->array);
         bisdo->offset = offset;
         //bisdo->scanStr = scanStr;
         bisdo->scanStr = scanStride;
@@ -1807,8 +1805,10 @@
         } else {
         jobject lutarray = (*env)->GetObjectField(env, icm, rgbID);
         bisdo->lutarray = (*env)->NewWeakGlobalRef(env, lutarray);
+            if (lutarray != NULL) CHECK_NULL(bisdo->lutarray);
         bisdo->lutsize = (*env)->GetIntField(env, icm, mapSizeID);
         bisdo->icm = (*env)->NewWeakGlobalRef(env, icm);
+            if (icm != NULL) CHECK_NULL(bisdo->icm);
         }
         bisdo->rasbounds.x1 = 0;
         bisdo->rasbounds.y1 = 0;
@@ -1887,7 +1887,7 @@
                         Pixel32bit* src = lutdata;
                         Pixel32bit* dst = isdo->lutData;
                         jint i;
-                        for (i=0; i<isdo->lutDataSize; i++)
+                        for (i=0; (unsigned)i<isdo->lutDataSize; i++)
                         {
                             if (i != transparent_index)
                             {
@@ -1919,7 +1919,7 @@
                         Pixel32bit* src = lutdata;
                         Pixel32bit* dst = isdo->lutData;
                         jint i;
-                        for (i=0; i<isdo->lutDataSize; i++)
+                        for (i=0; (unsigned)i<isdo->lutDataSize; i++)
                         {
                             *dst = *src | mask;
                             dst++; src++;
--- a/src/macosx/native/sun/awt/QuartzRenderer.m	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/macosx/native/sun/awt/QuartzRenderer.m	Tue Apr 01 10:01:50 2014 +0100
@@ -438,6 +438,9 @@
 {
     SDRenderType renderType = SD_Nothing;
 
+    if (xpointsarray == NULL || ypointsarray == NULL) {
+        return SD_Nothing;
+    }
     if (npoints > 1)
     {
         if (fill == YES)
@@ -452,7 +455,14 @@
         jint i;
 
         jint* xpoints = (jint*)(*env)->GetPrimitiveArrayCritical(env, xpointsarray, NULL);
+        if (xpoints == NULL) {
+            return SD_Nothing;
+        }
         jint* ypoints = (jint*)(*env)->GetPrimitiveArrayCritical(env, ypointsarray, NULL);
+        if (ypoints == NULL) {
+            (*env)->ReleasePrimitiveArrayCritical(env, xpointsarray, xpoints, 0);
+            return SD_Nothing;
+        }
 
         CGContextMoveToPoint(cgRef, xpoints[0]+offsetX, ypoints[0]+offsetY);
 
--- a/src/macosx/native/sun/awt/QuartzSurfaceData.m	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/macosx/native/sun/awt/QuartzSurfaceData.m	Tue Apr 01 10:01:50 2014 +0100
@@ -778,6 +778,10 @@
             qsdo->graphicsStateInfo.simpleStroke = NO;
             jint length = (*env)->GetArrayLength(env, dasharray);
             jfloat* jdashes = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, dasharray, NULL);
+            if (jdashes == NULL) {
+                CGContextSetLineDash(cgRef, 0, NULL, 0);
+                return;
+            }
             CGFloat* dashes = (CGFloat*)malloc(sizeof(CGFloat)*length);
             if (dashes != NULL)
             {
--- a/src/macosx/native/sun/font/AWTStrike.m	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/macosx/native/sun/font/AWTStrike.m	Tue Apr 01 10:01:50 2014 +0100
@@ -127,6 +127,9 @@
     }
 
     jdouble *txPtr = (*env)->GetPrimitiveArrayCritical(env, txArray, NULL);
+    if (txPtr == NULL) {
+        return CGAffineTransformIdentity;
+    }
 
     CGAffineTransform tx =
         CGAffineTransformMake(txPtr[0], txPtr[1], txPtr[2],
@@ -311,18 +314,22 @@
 
     jlong *glyphInfos =
         (*env)->GetPrimitiveArrayCritical(env, glyphInfoLongArray, NULL);
+    if (glyphInfos != NULL) {
     jint *rawGlyphCodes =
         (*env)->GetPrimitiveArrayCritical(env, glyphCodes, NULL);
 
+        if (rawGlyphCodes != NULL) {
     CGGlyphImages_GetGlyphImagePtrs(glyphInfos, awtStrike,
                                     rawGlyphCodes, len);
 
     (*env)->ReleasePrimitiveArrayCritical(env, glyphCodes,
                                           rawGlyphCodes, JNI_ABORT);
+        }
     // Do not use JNI_COMMIT, as that will not free the buffer copy
     // when +ProtectJavaHeap is on.
     (*env)->ReleasePrimitiveArrayCritical(env, glyphInfoLongArray,
                                           glyphInfos, 0);
+    }
 
 JNF_COCOA_EXIT(env);
 }
--- a/src/macosx/native/sun/font/CCharToGlyphMapper.m	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/macosx/native/sun/font/CCharToGlyphMapper.m	Tue Apr 01 10:01:50 2014 +0100
@@ -101,10 +101,13 @@
     jchar *unicodesAsChars =
         (*env)->GetPrimitiveArrayCritical(env, unicodes, NULL);
 
-    AllocateGlyphBuffer(env, awtFont, count, (UniChar *)unicodesAsChars, glyphs);
+    if (unicodesAsChars != NULL) {
+        AllocateGlyphBuffer(env, awtFont, count,
+                           (UniChar *)unicodesAsChars, glyphs);
 
     (*env)->ReleasePrimitiveArrayCritical(env, unicodes,
                                           unicodesAsChars, JNI_ABORT);
+    }
 
 JNF_COCOA_EXIT(env);
 }
--- a/src/share/native/sun/font/FontInstanceAdapter.cpp	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/share/native/sun/font/FontInstanceAdapter.cpp	Tue Apr 01 10:01:50 2014 +0100
@@ -222,10 +222,16 @@
     jobject pt = env->NewObject(sunFontIDs.pt2DFloatClass,
                                 sunFontIDs.pt2DFloatCtr,
                                 adjustment.fX, adjustment.fY);
+    if (pt == NULL) {
+        env->ExceptionClear();
+        adjustment.fX = 0.0f;
+        adjustment.fY = 0.0f;
+    } else {
     env->CallObjectMethod(fontStrike, sunFontIDs.adjustPointMID, pt);
     adjustment.fX = env->GetFloatField(pt, sunFontIDs.xFID);
     adjustment.fY = env->GetFloatField(pt, sunFontIDs.yFID);
 }
+}
 
 void FontInstanceAdapter::getWideGlyphAdvance(le_uint32 glyph, LEPoint &advance) const
 {
--- a/src/share/native/sun/font/layout/SunLayoutEngine.cpp	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/share/native/sun/font/layout/SunLayoutEngine.cpp	Tue Apr 01 10:01:50 2014 +0100
@@ -56,50 +56,13 @@
 JNIEXPORT void JNICALL
 Java_sun_font_SunLayoutEngine_initGVIDs
     (JNIEnv *env, jclass cls) {
-    gvdClass = env->FindClass(gvdClassName);
-    if (!gvdClass) {
-        JNU_ThrowClassNotFoundException(env, gvdClassName);
-        return;
-    }
-    gvdClass = (jclass)env->NewGlobalRef(gvdClass);
-      if (!gvdClass) {
-        JNU_ThrowInternalError(env, "could not create global ref");
-        return;
-    }
-    gvdCountFID = env->GetFieldID(gvdClass, "_count", "I");
-    if (!gvdCountFID) {
-      gvdClass = 0;
-      JNU_ThrowNoSuchFieldException(env, "_count");
-      return;
-    }
-
-    gvdFlagsFID = env->GetFieldID(gvdClass, "_flags", "I");
-    if (!gvdFlagsFID) {
-      gvdClass = 0;
-      JNU_ThrowNoSuchFieldException(env, "_flags");
-      return;
-    }
-
-    gvdGlyphsFID = env->GetFieldID(gvdClass, "_glyphs", "[I");
-    if (!gvdGlyphsFID) {
-      gvdClass = 0;
-      JNU_ThrowNoSuchFieldException(env, "_glyphs");
-      return;
-    }
-
-    gvdPositionsFID = env->GetFieldID(gvdClass, "_positions", "[F");
-    if (!gvdPositionsFID) {
-      gvdClass = 0;
-      JNU_ThrowNoSuchFieldException(env, "_positions");
-      return;
-    }
-
+    CHECK_NULL(gvdClass = env->FindClass(gvdClassName));
+    CHECK_NULL(gvdClass = (jclass)env->NewGlobalRef(gvdClass));
+    CHECK_NULL(gvdCountFID = env->GetFieldID(gvdClass, "_count", "I"));
+    CHECK_NULL(gvdFlagsFID = env->GetFieldID(gvdClass, "_flags", "I"));
+    CHECK_NULL(gvdGlyphsFID = env->GetFieldID(gvdClass, "_glyphs", "[I"));
+    CHECK_NULL(gvdPositionsFID = env->GetFieldID(gvdClass, "_positions", "[F"));
     gvdIndicesFID = env->GetFieldID(gvdClass, "_indices", "[I");
-    if (!gvdIndicesFID) {
-      gvdClass = 0;
-      JNU_ThrowNoSuchFieldException(env, "_indices");
-      return;
-    }
 }
 
 int putGV(JNIEnv* env, jint gmask, jint baseIndex, jobject gvdata, const LayoutEngine* engine, int glyphCount) {
@@ -195,7 +158,7 @@
   jchar* chars = buffer;
   if (len > 256) {
     size_t size = len * sizeof(jchar);
-    if (size / sizeof(jchar) != len) {
+    if (size / sizeof(jchar) != (size_t)len) {
       return;
     }
     chars = (jchar*)malloc(size);
@@ -220,10 +183,12 @@
        env->SetIntField(gvdata, gvdCountFID, -1); // flag failure
    } else {
       if (putGV(env, gmask, baseIndex, gvdata, engine, glyphCount)) {
+          if (!(env->ExceptionCheck())) {
         // !!! hmmm, could use current value in positions array of GVData...
         putFloat(env, pt, x, y);
       }
    }
+   }
 
   if (chars != buffer) {
     free(chars);
--- a/src/share/native/sun/font/sunFont.c	Tue Mar 25 20:32:07 2014 -0400
+++ b/src/share/native/sun/font/sunFont.c	Tue Apr 01 10:01:50 2014 +0100
@@ -27,6 +27,7 @@
 #include "string.h"
 #include "gdefs.h"
 #include "jlong.h"
+#include "jni_util.h"
 #include "sunfontids.h"
 #include "fontscalerdefs.h"
 #include "sun_font_SunFontManager.h"
@@ -81,100 +82,106 @@
      if (initialisedFontIDs) {
         return;
      }
-     tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont");
-     sunFontIDs.ttReadBlockMID =
+     CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont"));
+     CHECK_NULL(sunFontIDs.ttReadBlockMID =
          (*env)->GetMethodID(env, tmpClass, "readBlock",
-                             "(Ljava/nio/ByteBuffer;II)I");
-     sunFontIDs.ttReadBytesMID =
-         (*env)->GetMethodID(env, tmpClass, "readBytes", "(II)[B");
+                             "(Ljava/nio/ByteBuffer;II)I"));
+     CHECK_NULL(sunFontIDs.ttReadBytesMID =
+         (*env)->GetMethodID(env, tmpClass, "readBytes", "(II)[B"));
 
-     tmpClass = (*env)->FindClass(env, "sun/font/Type1Font");
-     sunFontIDs.readFileMID =
+     CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/Type1Font"));
+     CHECK_NULL(sunFontIDs.readFileMID =
          (*env)->GetMethodID(env, tmpClass,
-                             "readFile", "(Ljava/nio/ByteBuffer;)V");
+                             "readFile", "(Ljava/nio/ByteBuffer;)V"));
 
-     tmpClass = (*env)->FindClass(env, "java/awt/geom/Point2D$Float");
+     CHECK_NULL(tmpClass =
+         (*env)->FindClass(env, "java/awt/geom/Point2D$Float"));
      sunFontIDs.pt2DFloatClass = (jclass)(*env)->NewGlobalRef(env, tmpClass);
-     sunFontIDs.pt2DFloatCtr =
-         (*env)->GetMethodID(env, sunFontIDs.pt2DFloatClass, "<init>","(FF)V");
+     CHECK_NULL(sunFontIDs.pt2DFloatCtr =
+         (*env)->GetMethodID(env, sunFontIDs.pt2DFloatClass, "<init>","(FF)V"));
 
-     sunFontIDs.xFID =
-         (*env)->GetFieldID(env, sunFontIDs.pt2DFloatClass, "x", "F");
-     sunFontIDs.yFID =
-         (*env)->GetFieldID(env, sunFontIDs.pt2DFloatClass, "y", "F");
+     CHECK_NULL(sunFontIDs.xFID =
+         (*env)->GetFieldID(env, sunFontIDs.pt2DFloatClass, "x", "F"));
+     CHECK_NULL(sunFontIDs.yFID =
+         (*env)->GetFieldID(env, sunFontIDs.pt2DFloatClass, "y", "F"));
 
-     tmpClass = (*env)->FindClass(env, "sun/font/StrikeMetrics");
-     sunFontIDs.strikeMetricsClass=(jclass)(*env)->NewGlobalRef(env, tmpClass);
+     CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/StrikeMetrics"));
+     CHECK_NULL(sunFontIDs.strikeMetricsClass =
+         (jclass)(*env)->NewGlobalRef(env, tmpClass));
 
-     sunFontIDs.strikeMetricsCtr =
+     CHECK_NULL(sunFontIDs.strikeMetricsCtr =
          (*env)->GetMethodID(env, sunFontIDs.strikeMetricsClass,
-                             "<init>", "(FFFFFFFFFF)V");
+                             "<init>", "(FFFFFFFFFF)V"));
 
-     tmpClass = (*env)->FindClass(env, "java/awt/geom/Rectangle2D$Float");
+     CHECK_NULL(tmpClass =
+         (*env)->FindClass(env, "java/awt/geom/Rectangle2D$Float"));
      sunFontIDs.rect2DFloatClass = (jclass)(*env)->NewGlobalRef(env, tmpClass);
-     sunFontIDs.rect2DFloatCtr =
-       (*env)->GetMethodID(env, sunFontIDs.rect2DFloatClass, "<init>", "()V");
-     sunFontIDs.rect2DFloatCtr4 =
+     CHECK_NULL(sunFontIDs.rect2DFloatCtr =
+         (*env)->GetMethodID(env, sunFontIDs.rect2DFloatClass, "<init>", "()V"));
+     CHECK_NULL(sunFontIDs.rect2DFloatCtr4 =
        (*env)->GetMethodID(env, sunFontIDs.rect2DFloatClass,
-                           "<init>", "(FFFF)V");
-     sunFontIDs.rectF2DX =
-         (*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "x", "F");
-     sunFontIDs.rectF2DY =
-         (*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "y", "F");
-     sunFontIDs.rectF2DWidth =
-         (*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "width", "F");
-     sunFontIDs.rectF2DHeight =
-         (*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "height", "F");
+                            "<init>", "(FFFF)V"));
+     CHECK_NULL(sunFontIDs.rectF2DX =
+         (*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "x", "F"));
+     CHECK_NULL(sunFontIDs.rectF2DY =
+         (*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "y", "F"));
+     CHECK_NULL(sunFontIDs.rectF2DWidth =
+         (*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "width", "F"));
+     CHECK_NULL(sunFontIDs.rectF2DHeight =
+         (*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "height", "F"));
 
-     tmpClass = (*env)->FindClass(env, "java/awt/geom/GeneralPath");
+     CHECK_NULL(tmpClass = (*env)->FindClass(env, "java/awt/geom/GeneralPath"));
      sunFontIDs.gpClass = (jclass)(*env)->NewGlobalRef(env, tmpClass);
-     sunFontIDs.gpCtr =
-       (*env)->GetMethodID(env, sunFontIDs.gpClass, "<init>", "(I[BI[FI)V");
-     sunFontIDs.gpCtrEmpty =
-       (*env)->GetMethodID(env, sunFontIDs.gpClass, "<init>", "()V");
+     CHECK_NULL(sunFontIDs.gpCtr =
+         (*env)->GetMethodID(env, sunFontIDs.gpClass, "<init>", "(I[BI[FI)V"));
+     CHECK_NULL(sunFontIDs.gpCtrEmpty =
+         (*env)->GetMethodID(env, sunFontIDs.gpClass, "<init>", "()V"));
 
-     tmpClass = (*env)->FindClass(env, "sun/font/Font2D");
-     sunFontIDs.f2dCharToGlyphMID =
-         (*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I");
-     sunFontIDs.getMapperMID =
+     CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/Font2D"));
+     CHECK_NULL(sunFontIDs.f2dCharToGlyphMID =
+         (*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I"));
+     CHECK_NULL(sunFontIDs.getMapperMID =
          (*env)->GetMethodID(env, tmpClass, "getMapper",
-                             "()Lsun/font/CharToGlyphMapper;");
-     sunFontIDs.getTableBytesMID =
-         (*env)->GetMethodID(env, tmpClass, "getTableBytes", "(I)[B");
-     sunFontIDs.canDisplayMID =
-         (*env)->GetMethodID(env, tmpClass, "canDisplay", "(C)Z");
+                             "()Lsun/font/CharToGlyphMapper;"));
+     CHECK_NULL(sunFontIDs.getTableBytesMID =
+         (*env)->GetMethodID(env, tmpClass, "getTableBytes", "(I)[B"));
+     CHECK_NULL(sunFontIDs.canDisplayMID =
+         (*env)->GetMethodID(env, tmpClass, "canDisplay", "(C)Z"));
 
-     tmpClass = (*env)->FindClass(env, "sun/font/CharToGlyphMapper");
-     sunFontIDs.charToGlyphMID =
-        (*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I");
+     CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/CharToGlyphMapper"));
+     CHECK_NULL(sunFontIDs.charToGlyphMID =
+        (*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I"));
 
-     tmpClass = (*env)->FindClass(env, "sun/font/PhysicalStrike");
-     sunFontIDs.getGlyphMetricsMID =
+     CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/PhysicalStrike"));
+     CHECK_NULL(sunFontIDs.getGlyphMetricsMID =
          (*env)->GetMethodID(env, tmpClass, "getGlyphMetrics",
-                             "(I)Ljava/awt/geom/Point2D$Float;");
-     sunFontIDs.getGlyphPointMID =
+                             "(I)Ljava/awt/geom/Point2D$Float;"));
+     CHECK_NULL(sunFontIDs.getGlyphPointMID =
          (*env)->GetMethodID(env, tmpClass, "getGlyphPoint",
-                             "(II)Ljava/awt/geom/Point2D$Float;");
-     sunFontIDs.adjustPointMID =
+                             "(II)Ljava/awt/geom/Point2D$Float;"));
+     CHECK_NULL(sunFontIDs.adjustPointMID =
          (*env)->GetMethodID(env, tmpClass, "adjustPoint",
-                             "(Ljava/awt/geom/Point2D$Float;)V");
-     sunFontIDs.pScalerContextFID =
-         (*env)->GetFieldID(env, tmpClass, "pScalerContext", "J");
+                             "(Ljava/awt/geom/Point2D$Float;)V"));
+     CHECK_NULL(sunFontIDs.pScalerContextFID =
+         (*env)->GetFieldID(env, tmpClass, "pScalerContext", "J"));
 
-     tmpClass = (*env)->FindClass(env, "sun/font/GlyphList");
-     sunFontIDs.glyphListX = (*env)->GetFieldID(env, tmpClass, "x", "F");
-     sunFontIDs.glyphListY = (*env)->GetFieldID(env, tmpClass, "y", "F");
-     sunFontIDs.glyphListLen = (*env)->GetFieldID(env, tmpClass, "len", "I");
-     sunFontIDs.glyphImages =
-         (*env)->GetFieldID(env, tmpClass, "images", "[J");
-     sunFontIDs.glyphListUsePos =
-         (*env)->GetFieldID(env, tmpClass, "usePositions", "Z");
-     sunFontIDs.glyphListPos =
-         (*env)->GetFieldID(env, tmpClass, "positions", "[F");
-     sunFontIDs.lcdRGBOrder =
-         (*env)->GetFieldID(env, tmpClass, "lcdRGBOrder", "Z");
-     sunFontIDs.lcdSubPixPos =
-         (*env)->GetFieldID(env, tmpClass, "lcdSubPixPos", "Z");
+     CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/GlyphList"));
+     CHECK_NULL(sunFontIDs.glyphListX =
+         (*env)->GetFieldID(env, tmpClass, "x", "F"));
+     CHECK_NULL(sunFontIDs.glyphListY =
+         (*env)->GetFieldID(env, tmpClass, "y", "F"));
+     CHECK_NULL(sunFontIDs.glyphListLen =
+         (*env)->GetFieldID(env, tmpClass, "len", "I"));
+     CHECK_NULL(sunFontIDs.glyphImages =
+         (*env)->GetFieldID(env, tmpClass, "images", "[J"));
+     CHECK_NULL(sunFontIDs.glyphListUsePos =
+         (*env)->GetFieldID(env, tmpClass, "usePositions", "Z"));
+     CHECK_NULL(sunFontIDs.glyphListPos =
+         (*env)->GetFieldID(env, tmpClass, "positions", "[F"));
+     CHECK_NULL(sunFontIDs.lcdRGBOrder =
+         (*env)->GetFieldID(env, tmpClass, "lcdRGBOrder", "Z"));
+     CHECK_NULL(sunFontIDs.lcdSubPixPos =
+         (*env)->GetFieldID(env, tmpClass, "lcdSubPixPos", "Z"));
 
      initLCDGammaTables();