jdk/src/solaris/native/sun/awt/fontpath.c
changeset 24130 db72fc72f87b
parent 22597 7515a991bb37
--- a/jdk/src/solaris/native/sun/awt/fontpath.c	Mon Mar 24 23:02:05 2014 +0400
+++ b/jdk/src/solaris/native/sun/awt/fontpath.c	Tue Mar 25 16:31:02 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, 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
@@ -161,17 +161,22 @@
 
     if (! isLocalSet) {
       jclass geCls = (*env)->FindClass(env, "java/awt/GraphicsEnvironment");
+      CHECK_NULL_RETURN(geCls, JNI_FALSE);
       jmethodID getLocalGE = (*env)->GetStaticMethodID(env, geCls,
                                                  "getLocalGraphicsEnvironment",
                                            "()Ljava/awt/GraphicsEnvironment;");
+      CHECK_NULL_RETURN(getLocalGE, JNI_FALSE);
       jobject ge = (*env)->CallStaticObjectMethod(env, geCls, getLocalGE);
+      JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
 
       jclass sgeCls = (*env)->FindClass(env,
                                         "sun/java2d/SunGraphicsEnvironment");
+      CHECK_NULL_RETURN(sgeCls, JNI_FALSE);
       if ((*env)->IsInstanceOf(env, ge, sgeCls)) {
         jmethodID isDisplayLocal = (*env)->GetMethodID(env, sgeCls,
                                                        "isDisplayLocal",
                                                        "()Z");
+        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
         isLocal = (*env)->CallBooleanMethod(env, ge, isDisplayLocal);
       } else {
         isLocal = True;
@@ -1005,50 +1010,38 @@
     jmethodID fcFontCons;
     char* debugMinGlyphsStr = getenv("J2D_DEBUG_MIN_GLYPHS");
 
+    CHECK_NULL(fcInfoObj);
+    CHECK_NULL(fcCompFontArray);
+
     jclass fcInfoClass =
         (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigInfo");
+    CHECK_NULL(fcInfoClass);
     jclass fcCompFontClass =
         (*env)->FindClass(env, "sun/font/FontConfigManager$FcCompFont");
+    CHECK_NULL(fcCompFontClass);
     jclass fcFontClass =
          (*env)->FindClass(env, "sun/font/FontConfigManager$FontConfigFont");
-
-    if (fcInfoObj == NULL || fcCompFontArray == NULL || fcInfoClass == NULL ||
-        fcCompFontClass == NULL || fcFontClass == NULL) {
-        return;
-    }
-
-    fcVersionID = (*env)->GetFieldID(env, fcInfoClass, "fcVersion", "I");
+    CHECK_NULL(fcFontClass);
 
-    fcCacheDirsID = (*env)->GetFieldID(env, fcInfoClass, "cacheDirs",
-                                       "[Ljava/lang/String;");
-
-    fcNameID = (*env)->GetFieldID(env, fcCompFontClass,
-                                  "fcName", "Ljava/lang/String;");
-    fcFirstFontID =
-        (*env)->GetFieldID(env, fcCompFontClass, "firstFont",
-                           "Lsun/font/FontConfigManager$FontConfigFont;");
 
-    fcAllFontsID =
-        (*env)->GetFieldID(env, fcCompFontClass, "allFonts",
-                           "[Lsun/font/FontConfigManager$FontConfigFont;");
-
-    fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V");
-
-    familyNameID = (*env)->GetFieldID(env, fcFontClass,
-                                      "familyName", "Ljava/lang/String;");
-    styleNameID = (*env)->GetFieldID(env, fcFontClass,
-                                    "styleStr", "Ljava/lang/String;");
-    fullNameID = (*env)->GetFieldID(env, fcFontClass,
-                                    "fullName", "Ljava/lang/String;");
-    fontFileID = (*env)->GetFieldID(env, fcFontClass,
-                                    "fontFile", "Ljava/lang/String;");
-
-    if (fcVersionID == NULL || fcCacheDirsID == NULL || fcNameID == NULL ||
-        fcFirstFontID == NULL || fcAllFontsID == NULL || fcFontCons == NULL ||
-        familyNameID == NULL || styleNameID == NULL || fullNameID == NULL ||
-        fontFileID == NULL) {
-        return;
-    }
+    CHECK_NULL(fcVersionID = (*env)->GetFieldID(env, fcInfoClass, "fcVersion", "I"));
+    CHECK_NULL(fcCacheDirsID = (*env)->GetFieldID(env, fcInfoClass, "cacheDirs",
+                                                  "[Ljava/lang/String;"));
+    CHECK_NULL(fcNameID = (*env)->GetFieldID(env, fcCompFontClass,
+                                             "fcName", "Ljava/lang/String;"));
+    CHECK_NULL(fcFirstFontID = (*env)->GetFieldID(env, fcCompFontClass, "firstFont",
+                                        "Lsun/font/FontConfigManager$FontConfigFont;"));
+    CHECK_NULL(fcAllFontsID = (*env)->GetFieldID(env, fcCompFontClass, "allFonts",
+                                        "[Lsun/font/FontConfigManager$FontConfigFont;"));
+    CHECK_NULL(fcFontCons = (*env)->GetMethodID(env, fcFontClass, "<init>", "()V"));
+    CHECK_NULL(familyNameID = (*env)->GetFieldID(env, fcFontClass,
+                                      "familyName", "Ljava/lang/String;"));
+    CHECK_NULL(styleNameID = (*env)->GetFieldID(env, fcFontClass,
+                                    "styleStr", "Ljava/lang/String;"));
+    CHECK_NULL(fullNameID = (*env)->GetFieldID(env, fcFontClass,
+                                    "fullName", "Ljava/lang/String;"));
+    CHECK_NULL(fontFileID = (*env)->GetFieldID(env, fcFontClass,
+                                    "fontFile", "Ljava/lang/String;"));
 
     if ((libfontconfig = openFontConfig()) == NULL) {
         return;
@@ -1129,6 +1122,8 @@
         if (cacheDirs != NULL) {
             while ((cnt < max) && (cacheDir = (*FcStrListNext)(cacheDirs))) {
                 jstr = (*env)->NewStringUTF(env, (const char*)cacheDir);
+                JNU_CHECK_EXCEPTION(env);
+
                 (*env)->SetObjectArrayElement(env, cacheDirArray, cnt++, jstr);
             }
             (*FcStrListDone)(cacheDirs);
@@ -1136,6 +1131,11 @@
     }
 
     locale = (*env)->GetStringUTFChars(env, localeStr, 0);
+    if (locale == NULL) {
+        (*env)->ExceptionClear(env);
+        JNU_ThrowOutOfMemoryError(env, "Could not create locale");
+        return;
+    }
 
     arrlen = (*env)->GetArrayLength(env, fcCompFontArray);
     for (i=0; i<arrlen; i++) {