src/solaris/native/sun/awt/awt_LoadLibrary.c

Print this page




  93         return JNI_VERSION_1_2;
  94     }
  95 
  96     jvm = vm;
  97 
  98     /* Get address of this library and the directory containing it. */
  99     dladdr((void *)JNI_OnLoad, &dlinfo);
 100     realpath((char *)dlinfo.dli_fname, buf);
 101     len = strlen(buf);
 102     p = strrchr(buf, '/');
 103 
 104     /*
 105      * 1. Set the "sun.font.fontmanager" system property,
 106      * 2. Choose the library image name.
 107      */
 108 
 109     fmProp = (*env)->NewStringUTF(env, "sun.font.fontmanager");
 110     /* Check if toolkit is specified in env variable */
 111 #ifdef MACOSX
 112     envvar = getenv("AWT_TOOLKIT");
 113     if (envvar && strstr(envvar, "XToolkit")) {
 114 #endif
 115         fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
 116         tk = "/xawt/libmawt";
 117 #ifdef MACOSX
 118     } else {
 119         fmanager = (*env)->NewStringUTF(env, "sun.font.CFontManager");
 120         tk = "/lwawt/liblwawt";
 121     }
 122 #endif
 123     if (fmanager && fmProp) {
 124         JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "setProperty",
 125                                    "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
 126                                    fmProp, fmanager);
 127     }
 128 
 129     /* Calculate library name to load */
 130 #ifndef MACOSX
 131     if (AWTIsHeadless()) {
 132         strcpy(p, "/headless/libmawt");
 133     } else if (tk) {
 134 #endif
 135         strcpy(p, tk);
 136 #ifndef MACOSX
 137     }
 138 #endif
 139 
 140 #ifdef MACOSX
 141     strcat(p, ".dylib");
 142 #else
 143     strcat(p, ".so");
 144 #endif
 145 
 146     if (tk) {
 147         JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load",
 148                                    "(Ljava/lang/String;)V",
 149                                    JNU_NewStringPlatform(env, buf));
 150             awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
 151     }
 152 
 153     return JNI_VERSION_1_2;
 154 }
 155 
 156 JNIEXPORT jint JNICALL
 157 JNI_OnLoad(JavaVM *vm, void *reserved)
 158 {




  93         return JNI_VERSION_1_2;
  94     }
  95 
  96     jvm = vm;
  97 
  98     /* Get address of this library and the directory containing it. */
  99     dladdr((void *)JNI_OnLoad, &dlinfo);
 100     realpath((char *)dlinfo.dli_fname, buf);
 101     len = strlen(buf);
 102     p = strrchr(buf, '/');
 103 
 104     /*
 105      * 1. Set the "sun.font.fontmanager" system property,
 106      * 2. Choose the library image name.
 107      */
 108 
 109     fmProp = (*env)->NewStringUTF(env, "sun.font.fontmanager");
 110     /* Check if toolkit is specified in env variable */
 111 #ifdef MACOSX
 112     envvar = getenv("AWT_TOOLKIT");
 113     if ((envvar && strstr(envvar, "XToolkit")) || AWTIsHeadless()) {
 114 #endif
 115         fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
 116         tk = "/xawt/libmawt";
 117 #ifdef MACOSX
 118     } else {
 119         fmanager = (*env)->NewStringUTF(env, "sun.font.CFontManager");
 120         tk = "/lwawt/liblwawt";
 121     }
 122 #endif
 123     if (fmanager && fmProp) {
 124         JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "setProperty",
 125                                    "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
 126                                    fmProp, fmanager);
 127     }
 128 
 129     /* Calculate library name to load */

 130     if (AWTIsHeadless()) {
 131         strcpy(p, "/headless/libmawt");
 132     } else if (tk) {

 133         strcpy(p, tk);

 134     }

 135 
 136 #ifdef MACOSX
 137     strcat(p, ".dylib");
 138 #else
 139     strcat(p, ".so");
 140 #endif
 141 
 142     if (tk) {
 143         JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load",
 144                                    "(Ljava/lang/String;)V",
 145                                    JNU_NewStringPlatform(env, buf));
 146             awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
 147     }
 148 
 149     return JNI_VERSION_1_2;
 150 }
 151 
 152 JNIEXPORT jint JNICALL
 153 JNI_OnLoad(JavaVM *vm, void *reserved)
 154 {