8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
authorserb
Mon, 17 Mar 2014 16:33:28 +0400
changeset 23659 ac5179bc5c63
parent 23658 866c3d52a4df
child 23660 371d2d8dadc9
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending Reviewed-by: pchelko, azvegint
jdk/src/share/native/com/sun/media/sound/DirectAudioDevice.c
jdk/src/share/native/com/sun/media/sound/DirectAudioDeviceProvider.c
jdk/src/share/native/com/sun/media/sound/PortMixer.c
jdk/src/share/native/com/sun/media/sound/PortMixerProvider.c
--- a/jdk/src/share/native/com/sun/media/sound/DirectAudioDevice.c	Mon Mar 17 15:31:58 2014 +0400
+++ b/jdk/src/share/native/com/sun/media/sound/DirectAudioDevice.c	Mon Mar 17 16:33:28 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -32,6 +32,7 @@
 
 
 #include <jni.h>
+#include <jni_util.h>
 // for malloc
 #ifdef _ALLBSD_SOURCE
 #include <stdlib.h>
@@ -603,6 +604,7 @@
     if (len == 0) return 0;
     if (info && info->handle) {
         data = (UINT8*) ((*env)->GetByteArrayElements(env, jData, &didCopy));
+        CHECK_NULL_RETURN(data, ret);
         dataOffset = data;
         dataOffset += (int) offset;
         convertedData = dataOffset;
@@ -671,6 +673,7 @@
     }
     if (info && info->handle) {
         data = (char*) ((*env)->GetByteArrayElements(env, jData, NULL));
+        CHECK_NULL_RETURN(data, ret);
         dataOffset = data;
         dataOffset += (int) offset;
         ret = DAUDIO_Read(info->handle, dataOffset, (int) len);
--- a/jdk/src/share/native/com/sun/media/sound/DirectAudioDeviceProvider.c	Mon Mar 17 15:31:58 2014 +0400
+++ b/jdk/src/share/native/com/sun/media/sound/DirectAudioDeviceProvider.c	Mon Mar 17 16:33:28 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -28,6 +28,7 @@
 
 
 #include <jni.h>
+#include <jni_util.h>
 #include "SoundDefs.h"
 #include "DirectAudio.h"
 #include "Utilities.h"
@@ -70,6 +71,11 @@
     jmethodID directAudioDeviceInfoConstructor;
     DirectAudioDeviceDescription desc;
     jobject info = NULL;
+    jstring name;
+    jstring vendor;
+    jstring description;
+    jstring version;
+
     TRACE1("Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo(%d).\n", mixerIndex);
 
     // retrieve class and constructor of DirectAudioDeviceProvider.DirectAudioDeviceInfo
@@ -89,14 +95,18 @@
 
     if (getDirectAudioDeviceDescription(mixerIndex, &desc)) {
         // create a new DirectAudioDeviceInfo object and return it
-        info = (*env)->NewObject(env, directAudioDeviceInfoClass, directAudioDeviceInfoConstructor,
-                                 mixerIndex,
-                                 desc.deviceID,
-                                 desc.maxSimulLines,
-                                 (*env)->NewStringUTF(env, desc.name),
-                                 (*env)->NewStringUTF(env, desc.vendor),
-                                 (*env)->NewStringUTF(env, desc.description),
-                                 (*env)->NewStringUTF(env, desc.version));
+        name = (*env)->NewStringUTF(env, desc.name);
+        CHECK_NULL_RETURN(name, info);
+        vendor = (*env)->NewStringUTF(env, desc.vendor);
+        CHECK_NULL_RETURN(vendor, info);
+        description = (*env)->NewStringUTF(env, desc.description);
+        CHECK_NULL_RETURN(description, info);
+        version = (*env)->NewStringUTF(env, desc.version);
+        CHECK_NULL_RETURN(version, info);
+        info = (*env)->NewObject(env, directAudioDeviceInfoClass,
+                                 directAudioDeviceInfoConstructor, mixerIndex,
+                                 desc.deviceID, desc.maxSimulLines,
+                                 name, vendor, description, version);
     } else {
         ERROR1("ERROR: getDirectAudioDeviceDescription(%d, desc) returned FALSE!\n", mixerIndex);
     }
--- a/jdk/src/share/native/com/sun/media/sound/PortMixer.c	Mon Mar 17 15:31:58 2014 +0400
+++ b/jdk/src/share/native/com/sun/media/sound/PortMixer.c	Mon Mar 17 16:33:28 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -28,6 +28,7 @@
 
 
 #include <jni.h>
+#include <jni_util.h>
 #include "SoundDefs.h"
 #include "Ports.h"
 #include "Utilities.h"
@@ -170,6 +171,7 @@
 void* PORT_NewBooleanControl(void* creatorV, void* controlID, char* type) {
     ControlCreatorJNI* creator = (ControlCreatorJNI*) creatorV;
     jobject ctrl = NULL;
+    jstring typeString;
 
 #ifdef USE_TRACE
     if (((UINT_PTR) type) <= CONTROL_TYPE_MAX) {
@@ -199,8 +201,11 @@
         type = "Select";
     }
 
-    ctrl = (*creator->env)->NewObject(creator->env, creator->boolCtrlClass, creator->boolCtrlConstructor,
-        (jlong) (UINT_PTR) controlID, (*creator->env)->NewStringUTF(creator->env, type));
+    typeString = (*creator->env)->NewStringUTF(creator->env, type);
+    CHECK_NULL_RETURN(typeString, (void*) ctrl);
+    ctrl = (*creator->env)->NewObject(creator->env, creator->boolCtrlClass,
+                                      creator->boolCtrlConstructor,
+                                      (jlong) (UINT_PTR) controlID, typeString);
     if (!ctrl) {
         ERROR0("PORT_NewBooleanControl: ctrl is NULL\n");
     }
@@ -216,6 +221,7 @@
     jobject ctrl = NULL;
     jobjectArray controlArray;
     int i;
+    jstring typeString;
 
     TRACE2("PORT_NewCompoundControl: creating '%s' with %d controls\n", type, controlCount);
     if (!creator->compCtrlClass) {
@@ -250,8 +256,11 @@
         (*creator->env)->SetObjectArrayElement(creator->env, controlArray, i, (jobject) controls[i]);
     }
     TRACE0("PORT_NewCompoundControl: creating compound control\n");
-    ctrl = (*creator->env)->NewObject(creator->env, creator->compCtrlClass, creator->compCtrlConstructor,
-              (*creator->env)->NewStringUTF(creator->env, type), controlArray);
+    typeString = (*creator->env)->NewStringUTF(creator->env, type);
+    CHECK_NULL_RETURN(typeString, (void*) ctrl);
+    ctrl = (*creator->env)->NewObject(creator->env, creator->compCtrlClass,
+                                      creator->compCtrlConstructor,
+                                      typeString, controlArray);
     if (!ctrl) {
         ERROR0("PORT_NewCompoundControl: ctrl is NULL\n");
     }
@@ -266,6 +275,8 @@
                            float min, float max, float precision, char* units) {
     ControlCreatorJNI* creator = (ControlCreatorJNI*) creatorV;
     jobject ctrl = NULL;
+    jstring unitsString;
+    jstring typeString;
 
 #ifdef USE_TRACE
     if (((UINT_PTR) type) <= CONTROL_TYPE_MAX) {
@@ -294,18 +305,24 @@
             return NULL;
         }
     }
+    unitsString = (*creator->env)->NewStringUTF(creator->env, units);
+    CHECK_NULL_RETURN(unitsString, (void*) ctrl);
     if (((UINT_PTR) type) <= CONTROL_TYPE_MAX) {
         // constructor with int parameter
         TRACE1("PORT_NewFloatControl: calling constructor2 with type %d\n", (int) (UINT_PTR) type);
-        ctrl = (*creator->env)->NewObject(creator->env, creator->floatCtrlClass, creator->floatCtrlConstructor2,
-                  (jlong) (UINT_PTR) controlID, (jint) (UINT_PTR) type,
-                  min, max, precision, (*creator->env)->NewStringUTF(creator->env, units));
+        ctrl = (*creator->env)->NewObject(creator->env, creator->floatCtrlClass,
+                                          creator->floatCtrlConstructor2,
+                                          (jlong) (UINT_PTR) controlID, (jint) (UINT_PTR) type,
+                                          min, max, precision, unitsString);
     } else {
         TRACE0("PORT_NewFloatControl: calling constructor1\n");
         // constructor with string parameter
-        ctrl = (*creator->env)->NewObject(creator->env, creator->floatCtrlClass, creator->floatCtrlConstructor1,
-                  (jlong) (UINT_PTR) controlID, (*creator->env)->NewStringUTF(creator->env, type),
-                  min, max, precision, (*creator->env)->NewStringUTF(creator->env, units));
+        typeString = (*creator->env)->NewStringUTF(creator->env, type);
+        CHECK_NULL_RETURN(typeString, (void*) ctrl);
+        ctrl = (*creator->env)->NewObject(creator->env, creator->floatCtrlClass,
+                                          creator->floatCtrlConstructor1,
+                                          (jlong) (UINT_PTR) controlID, typeString,
+                                          min, max, precision, unitsString);
     }
     if (!ctrl) {
         ERROR0("PORT_NewFloatControl: ctrl is NULL!\n");
--- a/jdk/src/share/native/com/sun/media/sound/PortMixerProvider.c	Mon Mar 17 15:31:58 2014 +0400
+++ b/jdk/src/share/native/com/sun/media/sound/PortMixerProvider.c	Mon Mar 17 16:33:28 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -27,6 +27,7 @@
 
 
 #include <jni.h>
+#include <jni_util.h>
 #include "SoundDefs.h"
 #include "Ports.h"
 #include "Utilities.h"
@@ -65,6 +66,11 @@
     jmethodID portMixerInfoConstructor;
     PortMixerDescription desc;
     jobject info = NULL;
+    jstring name;
+    jstring vendor;
+    jstring description;
+    jstring version;
+
     TRACE1("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo(%d).\n", mixerIndex);
 
     // retrieve class and constructor of PortMixerProvider.PortMixerInfo
@@ -82,11 +88,17 @@
 
     if (getPortMixerDescription(mixerIndex, &desc)) {
         // create a new PortMixerInfo object and return it
-        info = (*env)->NewObject(env, portMixerInfoClass, portMixerInfoConstructor, mixerIndex,
-                                 (*env)->NewStringUTF(env, desc.name),
-                                 (*env)->NewStringUTF(env, desc.vendor),
-                                 (*env)->NewStringUTF(env, desc.description),
-                                 (*env)->NewStringUTF(env, desc.version));
+        name = (*env)->NewStringUTF(env, desc.name);
+        CHECK_NULL_RETURN(name, info);
+        vendor = (*env)->NewStringUTF(env, desc.vendor);
+        CHECK_NULL_RETURN(vendor, info);
+        description = (*env)->NewStringUTF(env, desc.description);
+        CHECK_NULL_RETURN(description, info);
+        version = (*env)->NewStringUTF(env, desc.version);
+        CHECK_NULL_RETURN(version, info);
+        info = (*env)->NewObject(env, portMixerInfoClass,
+                                 portMixerInfoConstructor, mixerIndex,
+                                 name, vendor, description, version);
     }
 
     TRACE0("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo succeeded.\n");