jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c
author simonis
Tue, 26 Nov 2013 16:40:31 +0100
changeset 22597 7515a991bb37
parent 20453 e480eb64d2c2
child 23010 6dadb192ad81
child 23276 add6f5c93bc6
permissions -rw-r--r--
8024854: PPC64: Basic changes and files to build the class library on AIX Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan, art Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com
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
22597
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20453
diff changeset
    40
#ifdef AIX
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20453
diff changeset
    41
#include "porting_aix.h" /* For the 'dladdr' function. */
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20453
diff changeset
    42
#endif
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20453
diff changeset
    43
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define VERBOSE_AWT_DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
static void *awtHandle = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
16862
247af361e9ca 8008509: 6588413 changed JNIEXPORT visibility for GCC on HSX, jdk's jni_md.h needs similar change
martin
parents: 12050
diff changeset
    50
typedef jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
/* Initialize the Java VM instance variable when the library is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
   first loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
JavaVM *jvm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
JNIEXPORT jboolean JNICALL AWTIsHeadless() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static JNIEnv *env = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    static jboolean isHeadless;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    jmethodID headlessFn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    jclass graphicsEnvClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    if (env == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        graphicsEnvClass = (*env)->FindClass(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                                             "java/awt/GraphicsEnvironment");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        if (graphicsEnvClass == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        headlessFn = (*env)->GetStaticMethodID(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                                               graphicsEnvClass, "isHeadless", "()Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        if (headlessFn == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        isHeadless = (*env)->CallStaticBooleanMethod(env, graphicsEnvClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                                     headlessFn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    return isHeadless;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    80
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    81
 * Pathnames to the various awt toolkits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    82
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    83
12050
28109b684ac0 7152186: java.awt.HeadlessException when running AWT apps [macosx]
michaelm
parents: 12047
diff changeset
    84
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    85
#ifdef MACOSX
12050
28109b684ac0 7152186: java.awt.HeadlessException when running AWT apps [macosx]
michaelm
parents: 12047
diff changeset
    86
  #define LWAWT_PATH "/libawt_lwawt.dylib"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    87
  #define DEFAULT_PATH LWAWT_PATH
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    88
#else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    89
  #define XAWT_PATH "/libawt_xawt.so"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    90
  #define DEFAULT_PATH XAWT_PATH
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    91
  #define HEADLESS_PATH "/libawt_headless.so"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    92
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
    93
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
jint
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
AWT_OnLoad(JavaVM *vm, void *reserved)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    Dl_info dlinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    char buf[MAXPATHLEN];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    int32_t len;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   100
    char *p, *tk;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    JNI_OnLoad_type *JNI_OnLoad_ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    struct utsname name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(vm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    void *v;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   105
    jstring fmanager = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   106
    jstring fmProp = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    if (awtHandle != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        /* Avoid several loading attempts */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return JNI_VERSION_1_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    jvm = vm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /* Get address of this library and the directory containing it. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    dladdr((void *)JNI_OnLoad, &dlinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    realpath((char *)dlinfo.dli_fname, buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    len = strlen(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    p = strrchr(buf, '/');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * 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
   123
     * 1. Loading appropriate awt library, i.e. libawt_xawt or libawt_headless
20453
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   124
     * 2. Set the "sun.font.fontmanager" system property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   127
    fmProp = (*env)->NewStringUTF(env, "sun.font.fontmanager");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   128
#ifdef MACOSX
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   129
        fmanager = (*env)->NewStringUTF(env, "sun.font.CFontManager");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   130
        tk = LWAWT_PATH;
20453
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   131
#else
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   132
        fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   133
        tk = XAWT_PATH;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   134
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   135
    if (fmanager && fmProp) {
20453
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   136
        JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "setProperty",
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   137
                                   "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   138
                                   fmProp, fmanager);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
20453
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   141
#ifndef MACOSX
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    if (AWTIsHeadless()) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   143
        tk = HEADLESS_PATH;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
20453
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   145
#endif
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   146
e480eb64d2c2 7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure
anthony
parents: 16862
diff changeset
   147
    /* Calculate library name to load */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   148
    strncpy(p, tk, MAXPATHLEN-len-1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   150
    if (fmProp) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   151
        (*env)->DeleteLocalRef(env, fmProp);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   152
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   153
    if (fmanager) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   154
        (*env)->DeleteLocalRef(env, fmanager);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11665
diff changeset
   155
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                               "(Ljava/lang/String;)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                               JNU_NewStringPlatform(env, buf));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    return JNI_VERSION_1_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
JNI_OnLoad(JavaVM *vm, void *reserved)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    return AWT_OnLoad(vm, reserved);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * This entry point must remain in libawt.so as part of a contract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 * 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
   175
 * Reflect this call over to the correct libawt_<toolkit>.so.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                     jobject frame, jstring jcommand)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /* type of the old backdoor function */
16862
247af361e9ca 8008509: 6588413 changed JNIEXPORT visibility for GCC on HSX, jdk's jni_md.h needs similar change
martin
parents: 12050
diff changeset
   182
    typedef void JNICALL
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        XsessionWMcommand_type(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                               jobject frame, jstring jcommand);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    static XsessionWMcommand_type *XsessionWMcommand = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    if (XsessionWMcommand == NULL && awtHandle == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    XsessionWMcommand = (XsessionWMcommand_type *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        dlsym(awtHandle, "Java_sun_awt_motif_XsessionWMcommand");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    if (XsessionWMcommand == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    (*XsessionWMcommand)(env, this, frame, jcommand);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 * This entry point must remain in libawt.so as part of a contract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 * 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
   205
 * Reflect this call over to the correct libawt_<toolkit>.so.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
{
16862
247af361e9ca 8008509: 6588413 changed JNIEXPORT visibility for GCC on HSX, jdk's jni_md.h needs similar change
martin
parents: 12050
diff changeset
   210
    typedef void JNICALL
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        XsessionWMcommand_New_type(JNIEnv *env, jobjectArray jargv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    static XsessionWMcommand_New_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_New_type *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        dlsym(awtHandle, "Java_sun_awt_motif_XsessionWMcommand_New");
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, jargv);
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
#define REFLECT_VOID_FUNCTION(name, arglist, paramlist)                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
typedef name##_type arglist;                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
void name arglist                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
{                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    static name##_type *name##_ptr = NULL;                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    if (name##_ptr == NULL && awtHandle == NULL) {                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return;                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    name##_ptr = (name##_type *)                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        dlsym(awtHandle, #name);                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    if (name##_ptr == NULL) {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return;                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    (*name##_ptr)paramlist;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
#define REFLECT_FUNCTION(return_type, name, arglist, paramlist)         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
typedef return_type name##_type arglist;                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
return_type name arglist                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
{                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    static name##_type *name##_ptr = NULL;                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    if (name##_ptr == NULL && awtHandle == NULL) {                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        return NULL;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    name##_ptr = (name##_type *)                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        dlsym(awtHandle, #name);                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    if (name##_ptr == NULL) {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return NULL;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    return (*name##_ptr)paramlist;                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
 * 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
   264
 * Reflect this call over to the correct libawt_<toolkit>.so.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
REFLECT_VOID_FUNCTION(getAwtLockFunctions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                      (void (**AwtLock)(JNIEnv *), void (**AwtUnlock)(JNIEnv *),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                       void (**AwtNoFlushUnlock)(JNIEnv *), void *reserved),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                      (AwtLock, AwtUnlock, AwtNoFlushUnlock, reserved))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
REFLECT_VOID_FUNCTION(getAwtData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                      (int32_t *awt_depth, Colormap *awt_cmap, Visual **awt_visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                       int32_t *awt_num_colors, void *pReserved),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                      (awt_depth, awt_cmap, awt_visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                       awt_num_colors, pReserved))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
REFLECT_FUNCTION(Display *, getAwtDisplay, (void), ())