< prev index next >

src/share/bin/java.h

Print this page
rev 11229 : 8068033: JNI exception pending in jdk/src/share/bin/java.c
Reviewed-by: mchung, serb
   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 238     int    argc;
 239     char **argv;
 240     int    mode;
 241     char  *what;
 242     InvocationFunctions ifn;
 243 } JavaMainArgs;
 244 
 245 #define NULL_CHECK_RETURN_VALUE(NCRV_check_pointer, NCRV_return_value) \
 246     do { \
 247         if ((NCRV_check_pointer) == NULL) { \
 248             JLI_ReportErrorMessage(JNI_ERROR); \
 249             return NCRV_return_value; \
 250         } \
 251     } while (JNI_FALSE)
 252 
 253 #define NULL_CHECK0(NC0_check_pointer) \
 254     NULL_CHECK_RETURN_VALUE(NC0_check_pointer, 0)
 255 
 256 #define NULL_CHECK(NC_check_pointer) \
 257     NULL_CHECK_RETURN_VALUE(NC_check_pointer, )







 258 
 259 /*
 260  * For JNI calls :
 261  *  - check for thrown exceptions
 262  *  - check for null return
 263  *
 264  *  JNI calls can return null and/or throw an exception.  Check for these.
 265  *
 266  *  : CHECK_JNI_RETURN_EXCEPTION()
 267  *    return the specified RETURNVALUE if exception was generated
 268  *  : CHECK_JNI_RETURN_0(JNISTATEMENT)        : check if JNISTATEMENT was successful, return 0 if not
 269  *  : CHECK_JNI_RETURN_VOID(JNISTATEMENT)     : check if JNISTATEMENT was successful, return void if not
 270  *  : CHECK_JNI_RETURN_VALUE(JNISTATEMENT,n)  : check if JNISTATEMENT was successful, return n if not
 271  *
 272  *  These macros need at least one parameter, the JNI statement [ JNISTATEMENT ].
 273  *
 274  *  E.G.: check the JNI statement, and specify a value to return if a failure was detected.
 275  *
 276  *      CHECK_JNI_RETURN_VALUE(str = (*env)->CallStaticObjectMethod(env, cls,
 277  *                                               makePlatformStringMID, USE_STDERR, ary), -1);


   1 /*
   2  * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 238     int    argc;
 239     char **argv;
 240     int    mode;
 241     char  *what;
 242     InvocationFunctions ifn;
 243 } JavaMainArgs;
 244 
 245 #define NULL_CHECK_RETURN_VALUE(NCRV_check_pointer, NCRV_return_value) \
 246     do { \
 247         if ((NCRV_check_pointer) == NULL) { \
 248             JLI_ReportErrorMessage(JNI_ERROR); \
 249             return NCRV_return_value; \
 250         } \
 251     } while (JNI_FALSE)
 252 
 253 #define NULL_CHECK0(NC0_check_pointer) \
 254     NULL_CHECK_RETURN_VALUE(NC0_check_pointer, 0)
 255 
 256 #define NULL_CHECK(NC_check_pointer) \
 257     NULL_CHECK_RETURN_VALUE(NC_check_pointer, )
 258 
 259 #define CHECK_EXCEPTION_RETURN() \
 260     do { \
 261         if ((*env)->ExceptionOccurred(env)) { \
 262             return; \
 263         } \
 264     } while (JNI_FALSE)
 265 
 266 /*
 267  * For JNI calls :
 268  *  - check for thrown exceptions
 269  *  - check for null return
 270  *
 271  *  JNI calls can return null and/or throw an exception.  Check for these.
 272  *
 273  *  : CHECK_JNI_RETURN_EXCEPTION()
 274  *    return the specified RETURNVALUE if exception was generated
 275  *  : CHECK_JNI_RETURN_0(JNISTATEMENT)        : check if JNISTATEMENT was successful, return 0 if not
 276  *  : CHECK_JNI_RETURN_VOID(JNISTATEMENT)     : check if JNISTATEMENT was successful, return void if not
 277  *  : CHECK_JNI_RETURN_VALUE(JNISTATEMENT,n)  : check if JNISTATEMENT was successful, return n if not
 278  *
 279  *  These macros need at least one parameter, the JNI statement [ JNISTATEMENT ].
 280  *
 281  *  E.G.: check the JNI statement, and specify a value to return if a failure was detected.
 282  *
 283  *      CHECK_JNI_RETURN_VALUE(str = (*env)->CallStaticObjectMethod(env, cls,
 284  *                                               makePlatformStringMID, USE_STDERR, ary), -1);


< prev index next >