static Boolean initGVIDs(JNIEnv *env, jobject gv) {
    if (g_gvClass == NULL) {
        g_gvClass = env->GetObjectClass(gv);

        if (g_gvClass == NULL) {
            JNU_ThrowClassNotFoundException(env, "No GlyphVector class");
            return false;
        }
    }

    if (g_gvPositions != NULL && g_gvGlyphs != NULL) {
        return true;
    }

    g_gvPositions   = env->GetFieldID(g_gvClass, "positions", "[F");
    g_gvGlyphs      = env->GetFieldID(g_gvClass, "glyphs", "[I");
    g_gvCharIndices = env->GetFieldID(g_gvClass, "charIndices", "[I");

    if (g_gvPositions == NULL || g_gvGlyphs == NULL || g_gvCharIndices == NULL) {
        JNU_ThrowNoSuchFieldException(env,
                                      "GlyphVector positions, glyphs, or charIndices");
        return false;
    }

    return true;
}
Exemple #2
0
/*
 * Find a class for the given class name and return a global reference to the
 * class.
 */
static jobject
findClass(const char *className)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    jclass classClass;
    jobject objectClass;

    classClass = (*env)->FindClass(env, className);
    objectClass = (*env)->NewGlobalRef(env,classClass);

    if (JNU_IsNull(env, objectClass)) {
        JNU_ThrowClassNotFoundException(env, className);
    }
    return objectClass;
}
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;
    }

    gvdIndicesFID = env->GetFieldID(gvdClass, "_indices", "[I");
    if (!gvdIndicesFID) {
      gvdClass = 0;
      JNU_ThrowNoSuchFieldException(env, "_indices");
      return;
    }
}
/*
 * Class:     sun_awt_X11RemoteOffScreenImage
 * Method:    initIDs
 * Signature: ()V
 */
JNIEXPORT void JNICALL
Java_sun_awt_motif_X11RemoteOffScreenImage_initIDs(JNIEnv *env, jclass bisd)
{
    static char *bimgName = "java/awt/image/BufferedImage";
    jclass bimg = (*env)->FindClass(env, bimgName);
    if (JNU_IsNull(env, bimg)) {
	JNU_ThrowClassNotFoundException(env, bimgName);
	return;
    }
    sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
    if (sDataID == 0) {
	JNU_ThrowInternalError(env, "Could not get field IDs");
    }

    rasterID = (*env)->GetFieldID(env, bimg, "raster", "Ljava/awt/image/WritableRaster;");
    if (rasterID == 0) {
	JNU_ThrowInternalError(env, "Could not get field IDs");
    }
}