src/share/bin/java.c
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -147,16 +147,19 @@
static void GrowKnownVMs();
static int KnownVMIndex(const char* name);
static void FreeKnownVMs();
static jboolean IsWildCardEnabled();
-#define ARG_CHECK(n, f, a) if (n < 1) { \
- JLI_ReportErrorMessage(f, a); \
+#define ARG_CHECK(AC_arg_count, AC_failure_message, AC_questionable_arg) \
+ do { \
+ if (AC_arg_count < 1) { \
+ JLI_ReportErrorMessage(AC_failure_message, AC_questionable_arg); \
printUsage = JNI_TRUE; \
*pret = 1; \
return JNI_TRUE; \
-}
+ } \
+ } while (JNI_FALSE)
/*
* Running Java code in primordial thread caused many problems. We will
* create a new thread to invoke JVM. See 6316197 for more information.
*/
@@ -308,33 +311,41 @@
* thread from the one that executed main, even though they are
* the same C thread. This allows mainThread.join() and
* mainThread.isAlive() to work as expected.
*/
#define LEAVE() \
- if ((*vm)->DetachCurrentThread(vm) != 0) { \
+ do { \
+ if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \
JLI_ReportErrorMessage(JVM_ERROR2); \
ret = 1; \
} \
+ if (JNI_TRUE) { \
(*vm)->DestroyJavaVM(vm); \
- return ret \
+ return ret; \
+ } \
+ } while (JNI_FALSE)
-#define CHECK_EXCEPTION_NULL_LEAVE(e) \
+#define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \
+ do { \
if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \
LEAVE(); \
} \
- if ((e) == NULL) { \
+ if ((CENL_exception) == NULL) { \
JLI_ReportErrorMessage(JNI_ERROR); \
LEAVE(); \
- }
+ } \
+ } while (JNI_FALSE)
-#define CHECK_EXCEPTION_LEAVE(rv) \
+#define CHECK_EXCEPTION_LEAVE(CEL_return_value) \
+ do { \
if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \
- ret = (rv); \
+ ret = (CEL_return_value); \
LEAVE(); \
- }
+ } \
+ } while (JNI_FALSE)
int JNICALL
JavaMain(void * _args)
{
JavaMainArgs *args = (JavaMainArgs *)_args;
@@ -432,11 +443,11 @@
* JavaFX application with no main method, the mainClass will not be the
* applications own main class but rather a helper class. To keep things
* consistent in the UI we need to track and report the application main class.
*/
appClass = GetApplicationClass(env);
- NULL_CHECK(appClass);
+ NULL_CHECK_RETURN_VALUE(appClass, -1);
/*
* PostJVMInit uses the class name as the application name for GUI purposes,
* for example, on OSX this sets the application name in the menu bar for
* both SWT and JavaFX. So we'll pass the actual application class here
* instead of mainClass as that may be a launcher or helper class instead