jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c
author michaelm
Thu, 08 Mar 2012 14:38:26 +0000
changeset 12050 28109b684ac0
parent 12047 320a714614e9
child 16862 247af361e9ca
permissions -rw-r--r--
7152186: java.awt.HeadlessException when running AWT apps [macosx] Reviewed-by: anthony
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <stdio.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <jni_util.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <jvm.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "gdefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <sys/param.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include <sys/utsname.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "awt_Plugin.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define VERBOSE_AWT_DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
static void *awtHandle = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
typedef JNIEXPORT jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/* Initialize the Java VM instance variable when the library is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
   first loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
JavaVM *jvm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
JNIEXPORT jboolean JNICALL AWTIsHeadless() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    static JNIEnv *env = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    static jboolean isHeadless;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    jmethodID headlessFn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    jclass graphicsEnvClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    if (env == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        graphicsEnvClass = (*env)->FindClass(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                                             "java/awt/GraphicsEnvironment");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        if (graphicsEnvClass == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        headlessFn = (*env)->GetStaticMethodID(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                                               graphicsEnvClass, "isHeadless", "()Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        if (headlessFn == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        isHeadless = (*env)->CallStaticBooleanMethod(env, graphicsEnvClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                                                     headlessFn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    return isHeadless;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    76
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    77
 * Pathnames to the various awt toolkits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    78
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    79
12050
28109b684ac0 7152186: java.awt.HeadlessException when running AWT apps [macosx]
michaelm
parents: 12047
diff changeset
    80
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    81
#ifdef MACOSX
12050
28109b684ac0 7152186: java.awt.HeadlessException when running AWT apps [macosx]
michaelm
parents: 12047
diff changeset
    82
  #define XAWT_PATH "/libawt_xawt.dylib"
28109b684ac0 7152186: java.awt.HeadlessException when running AWT apps [macosx]
michaelm
parents: 12047
diff changeset
    83
  #define LWAWT_PATH "/libawt_lwawt.dylib"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    84
  #define DEFAULT_PATH LWAWT_PATH
12050
28109b684ac0 7152186: java.awt.HeadlessException when running AWT apps [macosx]
michaelm
parents: 12047
diff changeset
    85
  #define HEADLESS_PATH "/libawt_headless.dylib"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    86
#else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    87
  #define XAWT_PATH "/libawt_xawt.so"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    88
  #define DEFAULT_PATH XAWT_PATH
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    89
  #define HEADLESS_PATH "/libawt_headless.so"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    90
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    91
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
jint
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
AWT_OnLoad(JavaVM *vm, void *reserved)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    Dl_info dlinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    char buf[MAXPATHLEN];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    int32_t len;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    98
    char *p, *tk;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    JNI_OnLoad_type *JNI_OnLoad_ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    struct utsname name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(vm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    void *v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    char *envvar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    int xt_before_xm = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    int XAWT = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    jstring toolkit = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    jstring propname = NULL;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   108
    jstring fmanager = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   109
    jstring fmProp = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    if (awtHandle != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        /* Avoid several loading attempts */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        return JNI_VERSION_1_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    jvm = vm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /* Get address of this library and the directory containing it. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    dladdr((void *)JNI_OnLoad, &dlinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    realpath((char *)dlinfo.dli_fname, buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    len = strlen(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    p = strrchr(buf, '/');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * The code below is responsible for:
11665
98dad53a8ba1 7110002: Rename xawt/libmawt.so and headless/libmawt.so so they can be colocated with libawt
chegar
parents: 9203
diff changeset
   126
     * 1. Loading appropriate awt library, i.e. libawt_xawt or libawt_headless
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * 2. Setting "awt.toolkit" system property to use the appropriate Java toolkit class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *    (if user has specified the toolkit in env varialble)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    propname = (*env)->NewStringUTF(env, "awt.toolkit");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   132
    fmProp = (*env)->NewStringUTF(env, "sun.font.fontmanager");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   133
    tk = DEFAULT_PATH; /* default value, may be changed below */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   134
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /* Check if toolkit is specified in env variable */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    envvar = getenv("AWT_TOOLKIT");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   137
    if (envvar && (strstr(envvar, "XToolkit"))) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   138
        toolkit = (*env)->NewStringUTF(env, "sun.awt.X11.XToolkit");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   139
        tk = XAWT_PATH;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   140
        fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   141
#ifdef MACOSX
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   142
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   143
        fmanager = (*env)->NewStringUTF(env, "sun.font.CFontManager");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   144
        tk = LWAWT_PATH;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   145
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   146
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   147
    /* If user specified toolkit then set java system property */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   148
    if (toolkit && propname) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   149
        JNU_CallStaticMethodByName (env,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   150
                    NULL,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   151
                    "java/lang/System",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   152
                    "setProperty",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   153
                    "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   154
                    propname,toolkit);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   155
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   156
    if (fmanager && fmProp) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   157
        JNU_CallStaticMethodByName (env,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   158
                    NULL,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   159
                    "java/lang/System",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   160
                        "setProperty",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   161
                    "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   162
                    fmProp, fmanager);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
9203
8fa112dbabaa 7029832: Buffer overrun at awt_LoadLibrary.c (and java_props_md.c)
dav
parents: 5506
diff changeset
   165
    /* Calculate library name to load */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    if (AWTIsHeadless()) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   167
        tk = HEADLESS_PATH;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   169
    strncpy(p, tk, MAXPATHLEN-len-1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    if (toolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        (*env)->DeleteLocalRef(env, toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    if (propname) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        (*env)->DeleteLocalRef(env, propname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   177
    if (fmProp) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   178
        (*env)->DeleteLocalRef(env, fmProp);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   179
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   180
    if (fmanager) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   181
        (*env)->DeleteLocalRef(env, fmanager);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   182
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                               "(Ljava/lang/String;)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                               JNU_NewStringPlatform(env, buf));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    return JNI_VERSION_1_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
JNI_OnLoad(JavaVM *vm, void *reserved)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    return AWT_OnLoad(vm, reserved);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * This entry point must remain in libawt.so as part of a contract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * with the CDE variant of Java Media Framework. (sdtjmplay)
11665
98dad53a8ba1 7110002: Rename xawt/libmawt.so and headless/libmawt.so so they can be colocated with libawt
chegar
parents: 9203
diff changeset
   202
 * Reflect this call over to the correct libawt_<toolkit>.so.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                     jobject frame, jstring jcommand)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /* type of the old backdoor function */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    typedef JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        XsessionWMcommand_type(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                               jobject frame, jstring jcommand);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    static XsessionWMcommand_type *XsessionWMcommand = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    if (XsessionWMcommand == NULL && awtHandle == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    XsessionWMcommand = (XsessionWMcommand_type *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        dlsym(awtHandle, "Java_sun_awt_motif_XsessionWMcommand");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    if (XsessionWMcommand == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    (*XsessionWMcommand)(env, this, frame, jcommand);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
 * This entry point must remain in libawt.so as part of a contract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
 * with the CDE variant of Java Media Framework. (sdtjmplay)
11665
98dad53a8ba1 7110002: Rename xawt/libmawt.so and headless/libmawt.so so they can be colocated with libawt
chegar
parents: 9203
diff changeset
   232
 * Reflect this call over to the correct libawt_<toolkit>.so.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    typedef JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        XsessionWMcommand_New_type(JNIEnv *env, jobjectArray jargv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    static XsessionWMcommand_New_type *XsessionWMcommand = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    if (XsessionWMcommand == NULL && awtHandle == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    XsessionWMcommand = (XsessionWMcommand_New_type *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        dlsym(awtHandle, "Java_sun_awt_motif_XsessionWMcommand_New");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    if (XsessionWMcommand == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    (*XsessionWMcommand)(env, jargv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
#define REFLECT_VOID_FUNCTION(name, arglist, paramlist)                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
typedef name##_type arglist;                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
void name arglist                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
{                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    static name##_type *name##_ptr = NULL;                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    if (name##_ptr == NULL && awtHandle == NULL) {                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return;                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    name##_ptr = (name##_type *)                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        dlsym(awtHandle, #name);                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    if (name##_ptr == NULL) {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return;                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    (*name##_ptr)paramlist;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#define REFLECT_FUNCTION(return_type, name, arglist, paramlist)         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
typedef return_type name##_type arglist;                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
return_type name arglist                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
{                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    static name##_type *name##_ptr = NULL;                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    if (name##_ptr == NULL && awtHandle == NULL) {                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        return NULL;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    name##_ptr = (name##_type *)                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        dlsym(awtHandle, #name);                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    if (name##_ptr == NULL) {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return NULL;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    return (*name##_ptr)paramlist;                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
 * These entry point must remain in libawt.so ***for Java Plugin ONLY***
11665
98dad53a8ba1 7110002: Rename xawt/libmawt.so and headless/libmawt.so so they can be colocated with libawt
chegar
parents: 9203
diff changeset
   291
 * Reflect this call over to the correct libawt_<toolkit>.so.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
REFLECT_VOID_FUNCTION(getAwtLockFunctions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                      (void (**AwtLock)(JNIEnv *), void (**AwtUnlock)(JNIEnv *),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                       void (**AwtNoFlushUnlock)(JNIEnv *), void *reserved),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                      (AwtLock, AwtUnlock, AwtNoFlushUnlock, reserved))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
REFLECT_VOID_FUNCTION(getAwtData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                      (int32_t *awt_depth, Colormap *awt_cmap, Visual **awt_visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                       int32_t *awt_num_colors, void *pReserved),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                      (awt_depth, awt_cmap, awt_visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                       awt_num_colors, pReserved))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
REFLECT_FUNCTION(Display *, getAwtDisplay, (void), ())