提交 3ec1c1d7 编写于 作者: P pchelko

8031001: [Parfait] warnings from b121 for jdk/src/solaris/native/sun/awt: JNI-related warnings

Reviewed-by: serb, anthony
上级 5a865e63
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -213,6 +213,8 @@ Java_sun_print_CUPSPrinter_getMedia(JNIEnv *env,
name = (*env)->GetStringUTFChars(env, printer, NULL);
if (name == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
return NULL;
}
......@@ -220,12 +222,10 @@ Java_sun_print_CUPSPrinter_getMedia(JNIEnv *env,
// unlink() must be caled to remove the file when finished using it.
filename = j2d_cupsGetPPD(name);
(*env)->ReleaseStringUTFChars(env, printer, name);
CHECK_NULL_RETURN(filename, NULL);
cls = (*env)->FindClass(env, "java/lang/String");
if (filename == NULL) {
return NULL;
}
CHECK_NULL_RETURN(cls, NULL);
if ((ppd = j2d_ppdOpenFile(filename)) == NULL) {
unlink(filename);
......@@ -249,6 +249,7 @@ Java_sun_print_CUPSPrinter_getMedia(JNIEnv *env,
unlink(filename);
j2d_ppdClose(ppd);
DPRINTF("CUPSfuncs::bad alloc new array\n", "")
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
return NULL;
}
......@@ -323,6 +324,11 @@ Java_sun_print_CUPSPrinter_getPageSizes(JNIEnv *env,
ppd_size_t *size;
const char *name = (*env)->GetStringUTFChars(env, printer, NULL);
if (name == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
return NULL;
}
const char *filename;
int i;
jobjectArray sizeArray = NULL;
......@@ -332,9 +338,7 @@ Java_sun_print_CUPSPrinter_getPageSizes(JNIEnv *env,
// unlink() must be called to remove the file after using it.
filename = j2d_cupsGetPPD(name);
(*env)->ReleaseStringUTFChars(env, printer, name);
if (filename == NULL) {
return NULL;
}
CHECK_NULL_RETURN(filename, NULL);
if ((ppd = j2d_ppdOpenFile(filename)) == NULL) {
unlink(filename);
DPRINTF("unable to open PPD %s\n", filename)
......@@ -350,11 +354,19 @@ Java_sun_print_CUPSPrinter_getPageSizes(JNIEnv *env,
unlink(filename);
j2d_ppdClose(ppd);
DPRINTF("CUPSfuncs::bad alloc new float array\n", "")
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
return NULL;
}
dims = (*env)->GetFloatArrayElements(env, sizeArray, NULL);
if (dims == NULL) {
unlink(filename);
j2d_ppdClose(ppd);
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not create printer name");
return NULL;
}
for (i = 0; i<option->num_choices; i++) {
choice = (option->choices)+i;
size = j2d_ppdPageSize(ppd, choice->choice);
......
/*
* Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
......@@ -892,11 +892,10 @@ jobject getColorSpace(JNIEnv* env, jint csID) {
jmethodID mid;
clazz = (*env)->FindClass(env,"java/awt/color/ColorSpace");
CHECK_NULL_RETURN(clazz, NULL);
mid = (*env)->GetStaticMethodID(env, clazz, "getInstance",
"(I)Ljava/awt/color/ColorSpace;");
if (mid == NULL) {
return NULL;
}
CHECK_NULL_RETURN(mid, NULL);
/* SECURITY: This is safe, because static methods cannot
* be overridden, and this method does not invoke
......@@ -919,6 +918,11 @@ jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData)
(aData->awt_depth >= 15))
{
clazz = (*env)->FindClass(env,"java/awt/image/DirectColorModel");
if (clazz == NULL) {
(*env)->PopLocalFrame(env, 0);
return NULL;
}
if (!aData->isTranslucencySupported) {
mid = (*env)->GetMethodID(env,clazz,"<init>","(IIIII)V");
......@@ -1005,6 +1009,10 @@ jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData)
}
clazz = (*env)->FindClass(env,"java/awt/image/ComponentColorModel");
if (clazz == NULL) {
(*env)->PopLocalFrame(env, 0);
return NULL;
}
mid = (*env)->GetMethodID(env,clazz,"<init>",
"(Ljava/awt/color/ColorSpace;[IZZII)V");
......@@ -1253,6 +1261,7 @@ int awtJNI_GetColorForVis (JNIEnv *env,jobject this, AwtGraphicsConfigDataPtr aw
if (!JNU_IsNull(env,this))
{
SYSCLR_class = (*env)->FindClass(env, "java/awt/SystemColor");
CHECK_NULL_RETURN(SYSCLR_class, 0);
if ((*env)->IsInstanceOf(env, this, SYSCLR_class)) {
/* SECURITY: This is safe, because there is no way
......@@ -1264,6 +1273,7 @@ int awtJNI_GetColorForVis (JNIEnv *env,jobject this, AwtGraphicsConfigDataPtr aw
,this
,"getRGB"
,"()I").i;
JNU_CHECK_EXCEPTION_RETURN(env, 0);
} else {
col = (int)(*env)->GetIntField(env,this,colorValueID);
}
......@@ -1370,6 +1380,8 @@ awtJNI_CreateColorData(JNIEnv *env, AwtGraphicsConfigDataPtr adata,
AWT_UNLOCK ();
}
sysColors = (*env)->FindClass (env, "java/awt/SystemColor");
CHECK_NULL(sysColors);
if (lock) {
AWT_LOCK ();
}
......@@ -1377,6 +1389,13 @@ awtJNI_CreateColorData(JNIEnv *env, AwtGraphicsConfigDataPtr adata,
"systemColors",
"[I");
if (colorID == NULL) {
if (lock) {
AWT_UNLOCK();
}
return;
}
colors = (jintArray) (*env)->GetStaticObjectField
(env, sysColors, colorID);
......
/*
* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
......@@ -77,8 +77,22 @@ extern void awt_output_flush();
#define AWT_LOCK_IMPL() \
(*env)->CallStaticVoidMethod(env, tkClass, awtLockMID)
#define AWT_NOFLUSH_UNLOCK_IMPL() \
(*env)->CallStaticVoidMethod(env, tkClass, awtUnlockMID)
do { \
jthrowable pendingException; \
if ((pendingException = (*env)->ExceptionOccurred(env)) != NULL) { \
(*env)->ExceptionClear(env); \
} \
(*env)->CallStaticVoidMethod(env, tkClass, awtUnlockMID); \
if (pendingException) { \
if ((*env)->ExceptionCheck(env)) { \
(*env)->ExceptionDescribe(env); \
(*env)->ExceptionClear(env); \
} \
(*env)->Throw(env, pendingException); \
} \
} while (0)
#define AWT_WAIT_IMPL(tm) \
(*env)->CallStaticVoidMethod(env, tkClass, awtWaitMID, (jlong)(tm))
#define AWT_NOTIFY_IMPL() \
......
/*
* Copyright (c) 1998, 2011, 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
......@@ -49,22 +49,22 @@ struct KeyEventIDs keyEventIDs;
JNIEXPORT void JNICALL
Java_java_awt_AWTEvent_initIDs(JNIEnv *env, jclass cls)
{
awtEventIDs.bdata = (*env)->GetFieldID(env, cls, "bdata", "[B");
awtEventIDs.consumed = (*env)->GetFieldID(env, cls, "consumed", "Z");
awtEventIDs.id = (*env)->GetFieldID(env, cls, "id", "I");
CHECK_NULL(awtEventIDs.bdata = (*env)->GetFieldID(env, cls, "bdata", "[B"));
CHECK_NULL(awtEventIDs.consumed = (*env)->GetFieldID(env, cls, "consumed", "Z"));
CHECK_NULL(awtEventIDs.id = (*env)->GetFieldID(env, cls, "id", "I"));
}
JNIEXPORT void JNICALL
Java_java_awt_event_InputEvent_initIDs(JNIEnv *env, jclass cls)
{
inputEventIDs.modifiers = (*env)->GetFieldID(env, cls, "modifiers", "I");
CHECK_NULL(inputEventIDs.modifiers = (*env)->GetFieldID(env, cls, "modifiers", "I"));
}
JNIEXPORT void JNICALL
Java_java_awt_event_KeyEvent_initIDs(JNIEnv *env, jclass cls)
{
keyEventIDs.keyCode = (*env)->GetFieldID(env, cls, "keyCode", "I");
keyEventIDs.keyChar = (*env)->GetFieldID(env, cls, "keyChar", "C");
CHECK_NULL(keyEventIDs.keyCode = (*env)->GetFieldID(env, cls, "keyCode", "I"));
CHECK_NULL(keyEventIDs.keyChar = (*env)->GetFieldID(env, cls, "keyChar", "C"));
}
JNIEXPORT void JNICALL
......
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
......@@ -78,6 +78,8 @@ JNIEXPORT jint JNICALL awt_DrawingSurface_Lock(JAWT_DrawingSurface* ds)
/* Make sure the target is a java.awt.Component */
componentClass = (*env)->FindClass(env, "java/awt/Component");
CHECK_NULL_RETURN(componentClass, (jint)JAWT_LOCK_ERROR);
if (!(*env)->IsInstanceOf(env, target, componentClass)) {
#ifdef DEBUG
fprintf(stderr, "Target is not a component\n");
......@@ -126,6 +128,8 @@ JNIEXPORT int32_t JNICALL
/* Make sure the target is a java.awt.Component */
componentClass = (*env)->FindClass(env, "java/awt/Component");
CHECK_NULL_RETURN(componentClass, (int32_t) 0);
if (!(*env)->IsInstanceOf(env, target, componentClass)) {
#ifdef DEBUG
fprintf(stderr, "DrawingSurface target must be a component\n");
......@@ -195,6 +199,8 @@ awt_DrawingSurface_GetDrawingSurfaceInfo(JAWT_DrawingSurface* ds)
/* Make sure the target is a java.awt.Component */
componentClass = (*env)->FindClass(env, "java/awt/Component");
CHECK_NULL_RETURN(componentClass, NULL);
if (!(*env)->IsInstanceOf(env, target, componentClass)) {
#ifdef DEBUG
fprintf(stderr, "DrawingSurface target must be a component\n");
......@@ -292,6 +298,8 @@ JNIEXPORT JAWT_DrawingSurface* JNICALL
/* Make sure the target component is a java.awt.Component */
componentClass = (*env)->FindClass(env, "java/awt/Component");
CHECK_NULL_RETURN(componentClass, NULL);
if (!(*env)->IsInstanceOf(env, target, componentClass)) {
#ifdef DEBUG
fprintf(stderr,
......@@ -354,6 +362,10 @@ JNIEXPORT jobject JNICALL
if (window != None) {
peer = JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit",
"windowToXWindow", "(J)Lsun/awt/X11/XBaseWindow;", (jlong)window).l;
if ((*env)->ExceptionCheck(env)) {
AWT_UNLOCK();
return (jobject)NULL;
}
}
if ((peer != NULL) &&
(JNU_IsInstanceOfByName(env, peer, "sun/awt/X11/XWindow") == 1)) {
......@@ -361,6 +373,7 @@ JNIEXPORT jobject JNICALL
}
if (target == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowNullPointerException(env, "NullPointerException");
AWT_UNLOCK();
return (jobject)NULL;
......
/*
* Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
......@@ -86,14 +86,13 @@ Java_java_awt_Font_initIDs
#ifndef HEADLESS
/** We call "NoClientCode" methods because they won't invoke client
code on the privileged toolkit thread **/
fontIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J");
fontIDs.style = (*env)->GetFieldID(env, cls, "style", "I");
fontIDs.size = (*env)->GetFieldID(env, cls, "size", "I");
fontIDs.getPeer = (*env)->GetMethodID(env, cls, "getPeer_NoClientCode",
"()Ljava/awt/peer/FontPeer;");
fontIDs.getFamily =
(*env)->GetMethodID(env, cls, "getFamily_NoClientCode",
"()Ljava/lang/String;");
CHECK_NULL(fontIDs.pData = (*env)->GetFieldID(env, cls, "pData", "J"));
CHECK_NULL(fontIDs.style = (*env)->GetFieldID(env, cls, "style", "I"));
CHECK_NULL(fontIDs.size = (*env)->GetFieldID(env, cls, "size", "I"));
CHECK_NULL(fontIDs.getPeer = (*env)->GetMethodID(env, cls, "getPeer_NoClientCode",
"()Ljava/awt/peer/FontPeer;"));
CHECK_NULL(fontIDs.getFamily = (*env)->GetMethodID(env, cls, "getFamily_NoClientCode",
"()Ljava/lang/String;"));
#endif /* !HEADLESS */
}
......@@ -120,12 +119,10 @@ Java_sun_awt_FontDescriptor_initIDs
(JNIEnv *env, jclass cls)
{
#ifndef HEADLESS
fontDescriptorIDs.nativeName =
(*env)->GetFieldID(env, cls, "nativeName",
"Ljava/lang/String;");
fontDescriptorIDs.charsetName =
(*env)->GetFieldID(env, cls, "charsetName",
"Ljava/lang/String;");
CHECK_NULL(fontDescriptorIDs.nativeName =
(*env)->GetFieldID(env, cls, "nativeName", "Ljava/lang/String;"));
CHECK_NULL(fontDescriptorIDs.charsetName =
(*env)->GetFieldID(env, cls, "charsetName", "Ljava/lang/String;"));
#endif /* !HEADLESS */
}
......@@ -144,20 +141,18 @@ Java_sun_awt_PlatformFont_initIDs
(JNIEnv *env, jclass cls)
{
#ifndef HEADLESS
platformFontIDs.componentFonts =
(*env)->GetFieldID(env, cls, "componentFonts",
"[Lsun/awt/FontDescriptor;");
platformFontIDs.fontConfig =
(*env)->GetFieldID(env,cls, "fontConfig",
"Lsun/awt/FontConfiguration;");
platformFontIDs.makeConvertedMultiFontString =
(*env)->GetMethodID(env, cls, "makeConvertedMultiFontString",
"(Ljava/lang/String;)[Ljava/lang/Object;");
platformFontIDs.makeConvertedMultiFontChars =
(*env)->GetMethodID(env, cls, "makeConvertedMultiFontChars",
"([CII)[Ljava/lang/Object;");
CHECK_NULL(platformFontIDs.componentFonts =
(*env)->GetFieldID(env, cls, "componentFonts",
"[Lsun/awt/FontDescriptor;"));
CHECK_NULL(platformFontIDs.fontConfig =
(*env)->GetFieldID(env,cls, "fontConfig",
"Lsun/awt/FontConfiguration;"));
CHECK_NULL(platformFontIDs.makeConvertedMultiFontString =
(*env)->GetMethodID(env, cls, "makeConvertedMultiFontString",
"(Ljava/lang/String;)[Ljava/lang/Object;"));
CHECK_NULL(platformFontIDs.makeConvertedMultiFontChars =
(*env)->GetMethodID(env, cls, "makeConvertedMultiFontChars",
"([CII)[Ljava/lang/Object;"));
#endif /* !HEADLESS */
}
......@@ -385,6 +380,11 @@ awtJNI_FontName(JNIEnv * env, jstring name, char **foundry, char **facename, cha
return 0;
}
cname = (char *) JNU_GetStringPlatformChars(env, name, NULL);
if (cname == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not create font name");
return 0;
}
/* additional default font names */
if (strcmp(cname, "serif") == 0) {
......@@ -448,6 +448,8 @@ awtJNI_GetFontData(JNIEnv * env, jobject font, char **errmsg)
}
if (!JNU_IsNull(env, font) && awtJNI_IsMultiFont(env, font)) {
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
struct FontData *fdata = NULL;
int32_t i, size;
char *fontsetname = NULL;
......@@ -513,6 +515,11 @@ awtJNI_GetFontData(JNIEnv * env, jobject font, char **errmsg)
fdata->flist[i].charset_name = (char *)
JNU_GetStringPlatformChars(env, charsetName, NULL);
if (fdata->flist[i].charset_name == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not create charset name");
return NULL;
}
/* We are done with the objects. */
(*env)->DeleteLocalRef(env, fontDescriptor);
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
......@@ -152,8 +152,11 @@ Java_sun_awt_X11GraphicsConfig_initIDs (JNIEnv *env, jclass cls)
x11GraphicsConfigIDs.screen = NULL;
x11GraphicsConfigIDs.aData = (*env)->GetFieldID (env, cls, "aData", "J");
CHECK_NULL(x11GraphicsConfigIDs.aData);
x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I");
CHECK_NULL(x11GraphicsConfigIDs.bitsPerPixel);
x11GraphicsConfigIDs.screen = (*env)->GetFieldID (env, cls, "screen", "Lsun/awt/X11GraphicsDevice;");
CHECK_NULL(x11GraphicsConfigIDs.screen);
if (x11GraphicsConfigIDs.aData == NULL ||
x11GraphicsConfigIDs.bitsPerPixel == NULL ||
......@@ -1346,7 +1349,6 @@ JNIEnv *env, jobject this)
/* Make Color Model object for this GraphicsConfiguration */
colorModel = awtJNI_GetColorModel (env, adata);
AWT_UNLOCK ();
return colorModel;
......@@ -1374,6 +1376,7 @@ Java_sun_awt_X11GraphicsConfig_pGetBounds(JNIEnv *env, jobject this, jint screen
JNU_GetLongFieldAsPtr(env, this, x11GraphicsConfigIDs.aData);
clazz = (*env)->FindClass(env, "java/awt/Rectangle");
CHECK_NULL_RETURN(clazz, NULL);
mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
if (mid != NULL) {
if (usingXinerama) {
......@@ -1543,7 +1546,7 @@ Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals(JNIEnv *env,
clazz = (*env)->GetObjectClass(env, this);
midAddVisual = (*env)->GetMethodID(env, clazz, "addDoubleBufferVisual",
"(I)V");
CHECK_NULL(midAddVisual);
AWT_LOCK();
rootWindow = RootWindow(awt_display, xinawareScreen);
visScreenInfo = XdbeGetVisualInfo(awt_display, &rootWindow, &n);
......@@ -1739,6 +1742,7 @@ X11GD_CreateDisplayMode(JNIEnv *env, jint width, jint height,
jint validRefreshRate = refreshRate;
displayModeClass = (*env)->FindClass(env, "java/awt/DisplayMode");
CHECK_NULL_RETURN(displayModeClass, NULL);
if (JNU_IsNull(env, displayModeClass)) {
JNU_ThrowInternalError(env,
"Could not get display mode class");
......@@ -1746,6 +1750,7 @@ X11GD_CreateDisplayMode(JNIEnv *env, jint width, jint height,
}
cid = (*env)->GetMethodID(env, displayModeClass, "<init>", "(IIII)V");
CHECK_NULL_RETURN(cid, NULL);
if (cid == NULL) {
JNU_ThrowInternalError(env,
"Could not get display mode constructor");
......@@ -1779,6 +1784,7 @@ X11GD_AddDisplayMode(JNIEnv *env, jobject arrayList,
}
mid = (*env)->GetMethodID(env, arrayListClass, "add",
"(Ljava/lang/Object;)Z");
CHECK_NULL(mid);
if (mid == NULL) {
JNU_ThrowInternalError(env,
"Could not get method java.util.ArrayList.add()");
......@@ -1955,6 +1961,9 @@ Java_sun_awt_X11GraphicsDevice_enumDisplayModes
size.height,
BIT_DEPTH_MULTI,
rates[j]);
if ((*env)->ExceptionCheck(env)) {
break;
}
}
}
}
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
......@@ -319,6 +319,7 @@ static X11InputMethodData * getX11InputMethodData(JNIEnv * env, jobject imInstan
JNU_CallMethodByName(env, NULL, pX11IMData->x11inputmethod,
"flushText",
"()V");
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
/* IMPORTANT:
The order of the following calls is critical since "imInstance" may
point to the global reference itself, if "freeX11InputMethodData" is called
......@@ -1120,6 +1121,9 @@ PreeditDrawCallback(XIC ic, XPointer client_data,
if (text->string.multi_byte != NULL) {
if (pre_draw->text->encoding_is_wchar == False) {
javastr = JNU_NewStringPlatform(env, (const char *)text->string.multi_byte);
if (javastr == NULL) {
goto finally;
}
} else {
char *mbstr = wcstombsdmp(text->string.wide_char, text->length);
if (mbstr == NULL) {
......@@ -1127,6 +1131,9 @@ PreeditDrawCallback(XIC ic, XPointer client_data,
}
javastr = JNU_NewStringPlatform(env, (const char *)mbstr);
free(mbstr);
if (javastr == NULL) {
goto finally;
}
}
}
if (text->feedback != NULL) {
......@@ -1135,6 +1142,7 @@ PreeditDrawCallback(XIC ic, XPointer client_data,
style = (*env)->NewIntArray(env, text->length);
if (JNU_IsNull(env, style)) {
(*env)->ExceptionClear(env);
THROW_OUT_OF_MEMORY_ERROR();
goto finally;
}
......@@ -1395,14 +1403,17 @@ Java_sun_awt_X11_XInputMethod_createXICNative(JNIEnv *env,
pX11IMData->lookup_buf = 0;
pX11IMData->lookup_buf_len = 0;
if (createXIC(env, pX11IMData, (Window)window)
== False) {
if (createXIC(env, pX11IMData, (Window)window) == False) {
destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
pX11IMData = (X11InputMethodData *) NULL;
if ((*env)->ExceptionCheck(env)) {
goto finally;
}
}
setX11InputMethodData(env, this, pX11IMData);
finally:
AWT_UNLOCK();
return (pX11IMData != NULL);
}
......
/*
* Copyright (c) 1998, 2001, 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
......@@ -34,8 +34,8 @@ struct InsetsIDs insetsIDs;
JNIEXPORT void JNICALL
Java_java_awt_Insets_initIDs(JNIEnv *env, jclass cls)
{
insetsIDs.top = (*env)->GetFieldID(env, cls, "top", "I");
insetsIDs.bottom = (*env)->GetFieldID(env, cls, "bottom", "I");
insetsIDs.left = (*env)->GetFieldID(env, cls, "left", "I");
insetsIDs.right = (*env)->GetFieldID(env, cls, "right", "I");
CHECK_NULL(insetsIDs.top = (*env)->GetFieldID(env, cls, "top", "I"));
CHECK_NULL(insetsIDs.bottom = (*env)->GetFieldID(env, cls, "bottom", "I"));
CHECK_NULL(insetsIDs.left = (*env)->GetFieldID(env, cls, "left", "I"));
CHECK_NULL(insetsIDs.right = (*env)->GetFieldID(env, cls, "right", "I"));
}
......@@ -77,11 +77,16 @@ JNIEXPORT jboolean JNICALL AWTIsHeadless() {
return isHeadless;
}
#define CHECK_EXCEPTION_FATAL(env, message) \
if ((*env)->ExceptionCheck(env)) { \
(*env)->ExceptionClear(env); \
(*env)->FatalError(env, message); \
}
/*
* Pathnames to the various awt toolkits
*/
#ifdef MACOSX
#define LWAWT_PATH "/libawt_lwawt.dylib"
#define DEFAULT_PATH LWAWT_PATH
......@@ -125,6 +130,8 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
*/
fmProp = (*env)->NewStringUTF(env, "sun.font.fontmanager");
CHECK_EXCEPTION_FATAL(env, "Could not allocate font manager property");
#ifdef MACOSX
fmanager = (*env)->NewStringUTF(env, "sun.font.CFontManager");
tk = LWAWT_PATH;
......@@ -132,10 +139,13 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
tk = XAWT_PATH;
#endif
CHECK_EXCEPTION_FATAL(env, "Could not allocate font manager name");
if (fmanager && fmProp) {
JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "setProperty",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
fmProp, fmanager);
CHECK_EXCEPTION_FATAL(env, "Could not allocate set properties");
}
#ifndef MACOSX
......@@ -154,9 +164,11 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
(*env)->DeleteLocalRef(env, fmanager);
}
jstring jbuf = JNU_NewStringPlatform(env, buf);
CHECK_EXCEPTION_FATAL(env, "Could not allocate library name");
JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load",
"(Ljava/lang/String;)V",
JNU_NewStringPlatform(env, buf));
jbuf);
awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
......
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
......@@ -175,10 +175,13 @@ Java_sun_awt_X11_XRobotPeer_setup (JNIEnv * env, jclass cls, jint numberOfButton
num_buttons = numberOfButtons;
tmp = (*env)->GetIntArrayElements(env, buttonDownMasks, JNI_FALSE);
CHECK_NULL(tmp);
masks = (jint *)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(jint), num_buttons);
if (masks == (jint *) NULL) {
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
(*env)->ExceptionClear(env);
(*env)->ReleaseIntArrayElements(env, buttonDownMasks, tmp, 0);
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
return;
}
for (i = 0; i < num_buttons; i++) {
......
/*
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 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
......@@ -98,6 +98,7 @@ jboolean _icon_upcall(JNIEnv *env, jobject this, GdkPixbuf *pixbuf)
(*env)->GetObjectClass(env, this));
icon_upcall_method = (*env)->GetMethodID(env, this_class,
"loadIconCallback", "([BIIIIIZ)V");
CHECK_NULL_RETURN(icon_upcall_method, JNI_FALSE);
}
if (pixbuf != NULL)
......@@ -112,6 +113,8 @@ jboolean _icon_upcall(JNIEnv *env, jobject this, GdkPixbuf *pixbuf)
/* Copy the data array into a Java structure so we can pass it back. */
jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
(*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
(jbyte *)pixbuf_data);
......
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
......@@ -76,6 +76,7 @@ awtJNI_ThreadYield(JNIEnv *env) {
Boolean err = FALSE;
if (threadClass == NULL) {
jclass tc = (*env)->FindClass(env, "java/lang/Thread");
CHECK_NULL(tc);
threadClass = (*env)->NewGlobalRef(env, tc);
(*env)->DeleteLocalRef(env, tc);
if (threadClass != NULL) {
......
/*
* 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 @@ jboolean isDisplayLocal(JNIEnv *env) {
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 @@ Java_sun_font_FontConfigManager_getFontConfig
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");
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(fcFontClass);
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 @@ Java_sun_font_FontConfigManager_getFontConfig
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 @@ Java_sun_font_FontConfigManager_getFontConfig
}
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++) {
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
......@@ -47,9 +47,6 @@ Java_java_awt_Color_initIDs
(JNIEnv *env, jclass clazz)
{
colorValueID = (*env)->GetFieldID(env, clazz, "value", "I");
if(colorValueID == NULL)
JNU_ThrowNullPointerException (env, "Can't get java/awt/Color.value fieldID");
}
JNIEXPORT void JNICALL
......
/*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
......@@ -74,7 +74,7 @@ awtJNI_GetFontDescriptorNumber(JNIEnv * env
jobject temp = NULL;
jboolean validRet = JNI_FALSE;
if ((*env)->EnsureLocalCapacity(env, 2) < 0)
if ((*env)->EnsureLocalCapacity(env, 2) < 0 || (*env)->ExceptionCheck(env))
goto done;
peer = (*env)->CallObjectMethod(env,font,fontIDs.getPeer);
......@@ -162,7 +162,7 @@ awtJNI_IsMultiFontMetrics(JNIEnv * env, jobject this)
font = JNU_CallMethodByName(env, NULL, this, "getFont_NoClientCode",
"()Ljava/awt/Font;").l;
if (JNU_IsNull(env, font)) {
if (JNU_IsNull(env, font) || (*env)->ExceptionCheck(env)) {
return JNI_FALSE;
}
......@@ -318,6 +318,10 @@ awtJNI_GetMFStringWidth(JNIEnv * env, jcharArray s, int offset, int sLength, job
}
fdata = awtJNI_GetFontData(env, font, &err);
if ((*env)->ExceptionCheck(env)) {
(*env)->DeleteLocalRef(env, dataArray);
return 0;
}
stringCount = (*env)->GetArrayLength(env, dataArray);
......@@ -336,6 +340,11 @@ awtJNI_GetMFStringWidth(JNIEnv * env, jcharArray s, int offset, int sLength, job
}
j = awtJNI_GetFontDescriptorNumber(env, font, fontDescriptor);
if ((*env)->ExceptionCheck(env)) {
(*env)->DeleteLocalRef(env, fontDescriptor);
(*env)->DeleteLocalRef(env, data);
break;
}
if (fdata->flist[j].load == 0) {
xf = loadFont(awt_display,
......@@ -356,6 +365,14 @@ awtJNI_GetMFStringWidth(JNIEnv * env, jcharArray s, int offset, int sLength, job
stringData =
(unsigned char *)(*env)->GetPrimitiveArrayCritical(env, data,NULL);
if (stringData == NULL) {
(*env)->DeleteLocalRef(env, fontDescriptor);
(*env)->DeleteLocalRef(env, data);
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not get string data");
break;
}
length = (stringData[0] << 24) | (stringData[1] << 16) |
(stringData[2] << 8) | stringData[3];
offsetStringData = (char *)(stringData + (4 * sizeof(char)));
......
/*
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
......@@ -45,10 +45,12 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs
filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx,
"filenameFilterCallback", "(Ljava/lang/String;)Z");
DASSERT(filenameFilterCallbackMethodID != NULL);
CHECK_NULL(filenameFilterCallbackMethodID);
setFileInternalMethodID = (*env)->GetMethodID(env, cx,
"setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V");
DASSERT(setFileInternalMethodID != NULL);
CHECK_NULL(setFileInternalMethodID);
widgetFieldID = (*env)->GetFieldID(env, cx, "widget", "J");
DASSERT(widgetFieldID != NULL);
......@@ -63,6 +65,7 @@ static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gp
env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
filename = (*env)->NewStringUTF(env, filter_info->filename);
JNU_CHECK_EXCEPTION_RETURN(env, FALSE);
return (*env)->CallBooleanMethod(env, obj, filenameFilterCallbackMethodID,
filename);
......@@ -173,13 +176,14 @@ static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list)
stringCls = (*env)->FindClass(env, "java/lang/String");
if (stringCls == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowInternalError(env, "Could not get java.lang.String class");
return NULL;
}
array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
NULL);
array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, NULL);
if (array == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowInternalError(env, "Could not instantiate array files array");
return NULL;
}
......@@ -189,7 +193,9 @@ static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list)
entry = (char*) iterator->data;
entry = strrchr(entry, '/') + 1;
str = (*env)->NewStringUTF(env, entry);
(*env)->SetObjectArrayElement(env, array, i, str);
if (str && !(*env)->ExceptionCheck(env)) {
(*env)->SetObjectArrayElement(env, array, i, str);
}
i++;
}
......@@ -215,13 +221,14 @@ static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
stringCls = (*env)->FindClass(env, "java/lang/String");
if (stringCls == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowInternalError(env, "Could not get java.lang.String class");
return NULL;
}
array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
NULL);
array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, NULL);
if (array == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowInternalError(env, "Could not instantiate array files array");
return NULL;
}
......@@ -236,7 +243,9 @@ static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
}
str = (*env)->NewStringUTF(env, entry);
(*env)->SetObjectArrayElement(env, array, i, str);
if (str && !(*env)->ExceptionCheck(env)) {
(*env)->SetObjectArrayElement(env, array, i, str);
}
i++;
}
......@@ -268,16 +277,17 @@ static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
if (full_path_names) {
//This is a hack for use with "Recent Folders" in gtk where each
//file could have its own directory.
jcurrent_folder = (*env)->NewStringUTF(env, "/");
jfilenames = toPathAndFilenamesArray(env, filenames);
jcurrent_folder = (*env)->NewStringUTF(env, "/");
} else {
jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
jfilenames = toFilenamesArray(env, filenames);
jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
}
if (!(*env)->ExceptionCheck(env)) {
(*env)->CallVoidMethod(env, obj, setFileInternalMethodID,
jcurrent_folder, jfilenames);
}
(*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder,
jfilenames);
fp_g_free(current_folder);
quit(env, (jobject)obj, TRUE);
}
......@@ -296,11 +306,17 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
if (jvm == NULL) {
(*env)->GetJavaVM(env, &jvm);
JNU_CHECK_EXCEPTION(env);
}
fp_gdk_threads_enter();
const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0);
if (title == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not get title");
return;
}
if (mode == java_awt_FileDialog_SAVE) {
/* Save action */
......@@ -328,6 +344,11 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
/* Set the directory */
if (jdir != NULL) {
const char *dir = (*env)->GetStringUTFChars(env, jdir, 0);
if (dir == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not get dir");
return;
}
fp_gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
(*env)->ReleaseStringUTFChars(env, jdir, dir);
}
......@@ -335,6 +356,11 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
/* Set the filename */
if (jfile != NULL) {
const char *filename = (*env)->GetStringUTFChars(env, jfile, 0);
if (filename == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowOutOfMemoryError(env, "Could not get filename");
return;
}
if (mode == java_awt_FileDialog_SAVE) {
fp_gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册