< prev index next >

src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c

Print this page


   1 /*
   2  * Copyright (c) 2000, 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


  32 #include <jvm.h>
  33 #include "gdefs.h"
  34 
  35 #include <sys/param.h>
  36 #include <sys/utsname.h>
  37 
  38 #ifdef AIX
  39 #include "porting_aix.h" /* For the 'dladdr' function. */
  40 #endif
  41 
  42 #ifdef DEBUG
  43 #define VERBOSE_AWT_DEBUG
  44 #endif
  45 
  46 static void *awtHandle = NULL;
  47 
  48 typedef jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved);
  49 
  50 /* Initialize the Java VM instance variable when the library is
  51    first loaded */
  52 JavaVM *jvm;
  53 
  54 JNIEXPORT jboolean JNICALL AWTIsHeadless() {
  55     static JNIEnv *env = NULL;
  56     static jboolean isHeadless;
  57     jmethodID headlessFn;
  58     jclass graphicsEnvClass;
  59 
  60     if (env == NULL) {
  61         env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  62         graphicsEnvClass = (*env)->FindClass(env,
  63                                              "java/awt/GraphicsEnvironment");
  64         if (graphicsEnvClass == NULL) {
  65             return JNI_TRUE;
  66         }
  67         headlessFn = (*env)->GetStaticMethodID(env,
  68                                                graphicsEnvClass, "isHeadless", "()Z");
  69         if (headlessFn == NULL) {
  70             return JNI_TRUE;
  71         }
  72         isHeadless = (*env)->CallStaticBooleanMethod(env, graphicsEnvClass,


   1 /*
   2  * Copyright (c) 2000, 2018, 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


  32 #include <jvm.h>
  33 #include "gdefs.h"
  34 
  35 #include <sys/param.h>
  36 #include <sys/utsname.h>
  37 
  38 #ifdef AIX
  39 #include "porting_aix.h" /* For the 'dladdr' function. */
  40 #endif
  41 
  42 #ifdef DEBUG
  43 #define VERBOSE_AWT_DEBUG
  44 #endif
  45 
  46 static void *awtHandle = NULL;
  47 
  48 typedef jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved);
  49 
  50 /* Initialize the Java VM instance variable when the library is
  51    first loaded */
  52 JNIEXPORT JavaVM *jvm;
  53 
  54 JNIEXPORT jboolean JNICALL AWTIsHeadless() {
  55     static JNIEnv *env = NULL;
  56     static jboolean isHeadless;
  57     jmethodID headlessFn;
  58     jclass graphicsEnvClass;
  59 
  60     if (env == NULL) {
  61         env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
  62         graphicsEnvClass = (*env)->FindClass(env,
  63                                              "java/awt/GraphicsEnvironment");
  64         if (graphicsEnvClass == NULL) {
  65             return JNI_TRUE;
  66         }
  67         headlessFn = (*env)->GetStaticMethodID(env,
  68                                                graphicsEnvClass, "isHeadless", "()Z");
  69         if (headlessFn == NULL) {
  70             return JNI_TRUE;
  71         }
  72         isHeadless = (*env)->CallStaticBooleanMethod(env, graphicsEnvClass,


< prev index next >