jdk/src/java.base/windows/native/libjli/java_md.c
author henryjen
Thu, 07 Jul 2016 21:15:24 -0700
changeset 39640 6f1a839ff43d
parent 34960 75262319b048
child 39761 4e61ba4a71b4
permissions -rw-r--r--
8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is" Reviewed-by: ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29742
b73f38796859 8074840: Resolve disabled warnings for libjli and libjli_static
mikael
parents: 28984
diff changeset
     2
 * Copyright (c) 1997, 2015, 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: 5381
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: 5381
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: 5381
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5381
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5381
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 <windows.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <io.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <process.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include <stdio.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <stdarg.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <sys/types.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <sys/stat.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <wtypes.h>
39
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
    36
#include <commctrl.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "java.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define JVM_DLL "jvm.dll"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#define JAVA_DLL "java.dll"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Prototypes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                           char *jvmpath, jint jvmpathsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
static jboolean GetJREPath(char *path, jint pathsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    51
/* We supports warmup for UI stack that is performed in parallel
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    52
 * to VM initialization.
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    53
 * This helps to improve startup of UI application as warmup phase
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    54
 * might be long due to initialization of OS or hardware resources.
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    55
 * It is not CPU bound and therefore it does not interfere with VM init.
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    56
 * Obviously such warmup only has sense for UI apps and therefore it needs
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    57
 * to be explicitly requested by passing -Dsun.awt.warmup=true property
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    58
 * (this is always the case for plugin/javaws).
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    59
 *
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    60
 * Implementation launches new thread after VM starts and use it to perform
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    61
 * warmup code (platform dependent).
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    62
 * This thread is later reused as AWT toolkit thread as graphics toolkit
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    63
 * often assume that they are used from the same thread they were launched on.
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    64
 *
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    65
 * At the moment we only support warmup for D3D. It only possible on windows
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    66
 * and only if other flags do not prohibit this (e.g. OpenGL support requested).
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    67
 */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    68
#undef ENABLE_AWT_PRELOAD
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    69
#ifndef JAVA_ARGS /* turn off AWT preloading for javac, jar, etc */
7256
adb296cc2eae 6999872: java.awt.Window instantiation leads to JVM CRASH on Windows, JDK7b118+ fastdebug
amenkov
parents: 7048
diff changeset
    70
    /* CR6999872: fastdebug crashes if awt library is loaded before JVM is
adb296cc2eae 6999872: java.awt.Window instantiation leads to JVM CRASH on Windows, JDK7b118+ fastdebug
amenkov
parents: 7048
diff changeset
    71
     * initialized*/
adb296cc2eae 6999872: java.awt.Window instantiation leads to JVM CRASH on Windows, JDK7b118+ fastdebug
amenkov
parents: 7048
diff changeset
    72
    #if !defined(DEBUG)
adb296cc2eae 6999872: java.awt.Window instantiation leads to JVM CRASH on Windows, JDK7b118+ fastdebug
amenkov
parents: 7048
diff changeset
    73
        #define ENABLE_AWT_PRELOAD
adb296cc2eae 6999872: java.awt.Window instantiation leads to JVM CRASH on Windows, JDK7b118+ fastdebug
amenkov
parents: 7048
diff changeset
    74
    #endif
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    75
#endif
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    76
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    77
#ifdef ENABLE_AWT_PRELOAD
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    78
/* "AWT was preloaded" flag;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    79
 * turned on by AWTPreload().
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    80
 */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    81
int awtPreloaded = 0;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    82
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    83
/* Calls a function with the name specified
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    84
 * the function must be int(*fn)(void).
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    85
 */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    86
int AWTPreload(const char *funcName);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    87
/* stops AWT preloading */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    88
void AWTPreloadStop();
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    89
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    90
/* D3D preloading */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    91
/* -1: not initialized; 0: OFF, 1: ON */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    92
int awtPreloadD3D = -1;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    93
/* command line parameter to swith D3D preloading on */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    94
#define PARAM_PRELOAD_D3D "-Dsun.awt.warmup"
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    95
/* D3D/OpenGL management parameters */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    96
#define PARAM_NODDRAW "-Dsun.java2d.noddraw"
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    97
#define PARAM_D3D "-Dsun.java2d.d3d"
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    98
#define PARAM_OPENGL "-Dsun.java2d.opengl"
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
    99
/* funtion in awt.dll (src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp) */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   100
#define D3D_PRELOAD_FUNC "preloadD3D"
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   101
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   102
/* Extracts value of a parameter with the specified name
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   103
 * from command line argument (returns pointer in the argument).
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   104
 * Returns NULL if the argument does not contains the parameter.
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   105
 * e.g.:
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   106
 * GetParamValue("theParam", "theParam=value") returns pointer to "value".
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   107
 */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   108
const char * GetParamValue(const char *paramName, const char *arg) {
29742
b73f38796859 8074840: Resolve disabled warnings for libjli and libjli_static
mikael
parents: 28984
diff changeset
   109
    size_t nameLen = JLI_StrLen(paramName);
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   110
    if (JLI_StrNCmp(paramName, arg, nameLen) == 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   111
        /* arg[nameLen] is valid (may contain final NULL) */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   112
        if (arg[nameLen] == '=') {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   113
            return arg + nameLen + 1;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   114
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   115
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   116
    return NULL;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   117
}
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   118
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   119
/* Checks if commandline argument contains property specified
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   120
 * and analyze it as boolean property (true/false).
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   121
 * Returns -1 if the argument does not contain the parameter;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   122
 * Returns 1 if the argument contains the parameter and its value is "true";
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   123
 * Returns 0 if the argument contains the parameter and its value is "false".
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   124
 */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   125
int GetBoolParamValue(const char *paramName, const char *arg) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   126
    const char * paramValue = GetParamValue(paramName, arg);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   127
    if (paramValue != NULL) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   128
        if (JLI_StrCaseCmp(paramValue, "true") == 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   129
            return 1;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   130
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   131
        if (JLI_StrCaseCmp(paramValue, "false") == 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   132
            return 0;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   133
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   134
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   135
    return -1;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   136
}
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   137
#endif /* ENABLE_AWT_PRELOAD */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   138
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   139
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
static jboolean _isjavaw = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
IsJavaw()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    return _isjavaw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 * Returns the arch path, to get the current arch use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * macro GetArch, nbits here is ignored for now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
const char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
GetArchPath(int nbits)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
#ifdef _M_AMD64
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    return "amd64";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
#elif defined(_M_IA64)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    return "ia64";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    return "i386";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
void
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   169
CreateExecutionEnvironment(int *pargc, char ***pargv,
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   170
                           char *jrepath, jint so_jrepath,
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   171
                           char *jvmpath, jint so_jvmpath,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   172
                           char *jvmcfg,  jint so_jvmcfg) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    char * jvmtype;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    int running = CURRENT_DATA_MODEL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    int wanted = running;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   179
    char** argv = *pargv;
22066
f2133b498789 8029388: java.exe consumes argument intended for launched java class
ksrini
parents: 16091
diff changeset
   180
    for (i = 1; i < *pargc ; i++) {
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   181
        if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            wanted = 64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   185
        if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            wanted = 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
22066
f2133b498789 8029388: java.exe consumes argument intended for launched java class
ksrini
parents: 16091
diff changeset
   189
f2133b498789 8029388: java.exe consumes argument intended for launched java class
ksrini
parents: 16091
diff changeset
   190
        if (IsJavaArgs() && argv[i][0] != '-')
f2133b498789 8029388: java.exe consumes argument intended for launched java class
ksrini
parents: 16091
diff changeset
   191
            continue;
f2133b498789 8029388: java.exe consumes argument intended for launched java class
ksrini
parents: 16091
diff changeset
   192
        if (argv[i][0] != '-')
f2133b498789 8029388: java.exe consumes argument intended for launched java class
ksrini
parents: 16091
diff changeset
   193
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    if (running != wanted) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   196
        JLI_ReportErrorMessage(JRE_ERROR2, wanted);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /* Find out where the JRE is that we will be using. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    if (!GetJREPath(jrepath, so_jrepath)) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   202
        JLI_ReportErrorMessage(JRE_ERROR1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        exit(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   206
    JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%s%sjvm.cfg",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   207
        jrepath, FILESEP, FILESEP, (char*)GetArch(), FILESEP);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   208
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /* Find the specified JVM type */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   210
    if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   211
        JLI_ReportErrorMessage(CFG_ERROR7);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   214
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   215
    jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   216
    if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   217
        JLI_ReportErrorMessage(CFG_ERROR9);
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   218
        exit(4);
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   219
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    jvmpath[0] = '\0';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   223
        JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        exit(4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /* If we got here, jvmpath has been correctly initialized. */
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   227
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   228
    /* Check if we need preload AWT */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   229
#ifdef ENABLE_AWT_PRELOAD
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   230
    argv = *pargv;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   231
    for (i = 0; i < *pargc ; i++) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   232
        /* Tests the "turn on" parameter only if not set yet. */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   233
        if (awtPreloadD3D < 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   234
            if (GetBoolParamValue(PARAM_PRELOAD_D3D, argv[i]) == 1) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   235
                awtPreloadD3D = 1;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   236
            }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   237
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   238
        /* Test parameters which can disable preloading if not already disabled. */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   239
        if (awtPreloadD3D != 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   240
            if (GetBoolParamValue(PARAM_NODDRAW, argv[i]) == 1
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   241
                || GetBoolParamValue(PARAM_D3D, argv[i]) == 0
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   242
                || GetBoolParamValue(PARAM_OPENGL, argv[i]) == 1)
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   243
            {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   244
                awtPreloadD3D = 0;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   245
                /* no need to test the rest of the parameters */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   246
                break;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   247
            }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   248
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   249
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   250
#endif /* ENABLE_AWT_PRELOAD */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   253
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   254
static jboolean
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   255
LoadMSVCRT()
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   256
{
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   257
    // Only do this once
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   258
    static int loaded = 0;
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   259
    char crtpath[MAXPATHLEN];
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   260
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   261
    if (!loaded) {
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   262
        /*
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   263
         * The Microsoft C Runtime Library needs to be loaded first.  A copy is
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   264
         * assumed to be present in the "JRE path" directory.  If it is not found
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   265
         * there (or "JRE path" fails to resolve), skip the explicit load and let
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   266
         * nature take its course, which is likely to be a failure to execute.
28984
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   267
         * The makefiles will provide the correct lib contained in quotes in the
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   268
         * macro MSVCR_DLL_NAME.
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   269
         */
28984
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   270
#ifdef MSVCR_DLL_NAME
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   271
        if (GetJREPath(crtpath, MAXPATHLEN)) {
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   272
            if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") +
28984
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   273
                    JLI_StrLen(MSVCR_DLL_NAME) >= MAXPATHLEN) {
6535
77ffd0e75bfb 6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents: 6522
diff changeset
   274
                JLI_ReportErrorMessage(JRE_ERROR11);
77ffd0e75bfb 6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents: 6522
diff changeset
   275
                return JNI_FALSE;
77ffd0e75bfb 6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents: 6522
diff changeset
   276
            }
28984
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   277
            (void)JLI_StrCat(crtpath, "\\bin\\" MSVCR_DLL_NAME);   /* Add crt dll */
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   278
            JLI_TraceLauncher("CRT path is %s\n", crtpath);
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   279
            if (_access(crtpath, 0) == 0) {
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   280
                if (LoadLibrary(crtpath) == 0) {
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   281
                    JLI_ReportErrorMessage(DLL_ERROR4, crtpath);
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   282
                    return JNI_FALSE;
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   283
                }
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   284
            }
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   285
        }
28984
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   286
#endif /* MSVCR_DLL_NAME */
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   287
#ifdef MSVCP_DLL_NAME
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   288
        if (GetJREPath(crtpath, MAXPATHLEN)) {
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   289
            if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") +
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   290
                    JLI_StrLen(MSVCP_DLL_NAME) >= MAXPATHLEN) {
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   291
                JLI_ReportErrorMessage(JRE_ERROR11);
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   292
                return JNI_FALSE;
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   293
            }
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   294
            (void)JLI_StrCat(crtpath, "\\bin\\" MSVCP_DLL_NAME);   /* Add prt dll */
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   295
            JLI_TraceLauncher("PRT path is %s\n", crtpath);
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   296
            if (_access(crtpath, 0) == 0) {
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   297
                if (LoadLibrary(crtpath) == 0) {
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   298
                    JLI_ReportErrorMessage(DLL_ERROR4, crtpath);
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   299
                    return JNI_FALSE;
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   300
                }
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   301
            }
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   302
        }
12031ba2dc38 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27938
diff changeset
   303
#endif /* MSVCP_DLL_NAME */
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   304
        loaded = 1;
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   305
    }
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   306
    return JNI_TRUE;
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   307
}
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   308
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   309
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
 * Find path to JRE based on .exe's location or registry settings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
GetJREPath(char *path, jint pathsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    char javadll[MAXPATHLEN];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    struct stat s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    if (GetApplicationHome(path, pathsize)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        /* Is JRE co-located with the application? */
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   321
        JLI_Snprintf(javadll, sizeof(javadll), "%s\\bin\\" JAVA_DLL, path);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        if (stat(javadll, &s) == 0) {
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   323
            JLI_TraceLauncher("JRE path is %s\n", path);
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   324
            return JNI_TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        }
31690
3944eaf3322c 8073773: Presume path preparedness
ksrini
parents: 30914
diff changeset
   326
        /* ensure storage for path + \jre + NULL */
3944eaf3322c 8073773: Presume path preparedness
ksrini
parents: 30914
diff changeset
   327
        if ((JLI_StrLen(path) + 4 + 1) > (size_t) pathsize) {
3944eaf3322c 8073773: Presume path preparedness
ksrini
parents: 30914
diff changeset
   328
            JLI_TraceLauncher("Insufficient space to store JRE path\n");
3944eaf3322c 8073773: Presume path preparedness
ksrini
parents: 30914
diff changeset
   329
            return JNI_FALSE;
3944eaf3322c 8073773: Presume path preparedness
ksrini
parents: 30914
diff changeset
   330
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        /* Does this app ship a private JRE in <apphome>\jre directory? */
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   332
        JLI_Snprintf(javadll, sizeof (javadll), "%s\\jre\\bin\\" JAVA_DLL, path);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        if (stat(javadll, &s) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            JLI_StrCat(path, "\\jre");
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   335
            JLI_TraceLauncher("JRE path is %s\n", path);
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   336
            return JNI_TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
34960
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   340
    /* Try getting path to JRE from path to JLI.DLL */
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   341
    if (GetApplicationHomeFromDll(path, pathsize)) {
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   342
        JLI_Snprintf(javadll, sizeof(javadll), "%s\\bin\\" JAVA_DLL, path);
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   343
        if (stat(javadll, &s) == 0) {
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   344
            JLI_TraceLauncher("JRE path is %s\n", path);
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   345
            return JNI_TRUE;
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   346
        }
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   347
    }
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   348
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   349
    JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
 * Given a JRE location and a JVM type, construct what the name the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
 * JVM shared library will be.  Return true, if such a library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
 * exists, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
GetJVMPath(const char *jrepath, const char *jvmtype,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
           char *jvmpath, jint jvmpathsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    struct stat s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    if (JLI_StrChr(jvmtype, '/') || JLI_StrChr(jvmtype, '\\')) {
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   365
        JLI_Snprintf(jvmpath, jvmpathsize, "%s\\" JVM_DLL, jvmtype);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    } else {
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   367
        JLI_Snprintf(jvmpath, jvmpathsize, "%s\\bin\\%s\\" JVM_DLL,
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   368
                     jrepath, jvmtype);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    if (stat(jvmpath, &s) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
 * Load a jvm from "jvmpath" and initialize the invocation functions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    HINSTANCE handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    JLI_TraceLauncher("JVM path is %s\n", jvmpath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * The Microsoft C Runtime Library needs to be loaded first.  A copy is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * assumed to be present in the "JRE path" directory.  If it is not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * there (or "JRE path" fails to resolve), skip the explicit load and let
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * nature take its course, which is likely to be a failure to execute.
1776
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 1331
diff changeset
   392
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     */
3111
fefdeafb7ab9 6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents: 1776
diff changeset
   394
    LoadMSVCRT();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /* Load the Java VM DLL */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    if ((handle = LoadLibrary(jvmpath)) == 0) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   398
        JLI_ReportErrorMessage(DLL_ERROR4, (char *)jvmpath);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    /* Now get the function addresses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    ifn->CreateJavaVM =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        (void *)GetProcAddress(handle, "JNI_CreateJavaVM");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    ifn->GetDefaultJavaVMInitArgs =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        (void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   408
        JLI_ReportErrorMessage(JNI_ERROR1, (char *)jvmpath);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
/*
34960
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   416
 * Removes the trailing file name and one sub-folder from a path.
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   417
 * If buf is "c:\foo\bin\javac", then put "c:\foo" into buf.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
jboolean
34960
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   420
TruncatePath(char *buf)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    char *cp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    *JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    if ((cp = JLI_StrRChr(buf, '\\')) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        /* This happens if the application is in a drive root, and
34960
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   426
        * there is no bin directory. */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        buf[0] = '\0';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    *cp = '\0';  /* remove the bin\ part */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
/*
34960
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   435
 * Retrieves the path to the JRE home by locating the executable file
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   436
 * of the current process and then truncating the path to the executable
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   437
 */
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   438
jboolean
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   439
GetApplicationHome(char *buf, jint bufsize)
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   440
{
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   441
    GetModuleFileName(NULL, buf, bufsize);
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   442
    return TruncatePath(buf);
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   443
}
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   444
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   445
/*
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   446
 * Retrieves the path to the JRE home by locating JLI.DLL and
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   447
 * then truncating the path to JLI.DLL
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   448
 */
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   449
jboolean
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   450
GetApplicationHomeFromDll(char *buf, jint bufsize)
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   451
{
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   452
    HMODULE hModule;
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   453
    DWORD dwFlags =
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   454
        GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   455
        GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   456
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   457
    if (GetModuleHandleEx(dwFlags, (LPCSTR)&GetJREPath, &hModule) == 0) {
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   458
        return JNI_FALSE;
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   459
    };
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   460
    GetModuleFileName(hModule, buf, bufsize);
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   461
    return TruncatePath(buf);
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   462
}
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   463
75262319b048 8145409: Better detect JRE that JLI will be using
dcherepanov
parents: 31690
diff changeset
   464
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
 * Support for doing cheap, accurate interval timing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
static jboolean counterAvailable = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
static jboolean counterInitialized = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
static LARGE_INTEGER counterFrequency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
jlong CounterGet()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    LARGE_INTEGER count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    if (!counterInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        counterAvailable = QueryPerformanceFrequency(&counterFrequency);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        counterInitialized = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    if (!counterAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    QueryPerformanceCounter(&count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    return (jlong)(count.QuadPart);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
jlong Counter2Micros(jlong counts)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    if (!counterAvailable || !counterInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    return (counts * 1000 * 1000)/counterFrequency.QuadPart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
}
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   493
/*
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   494
 * windows snprintf does not guarantee a null terminator in the buffer,
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   495
 * if the computed size is equal to or greater than the buffer size,
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   496
 * as well as error conditions. This function guarantees a null terminator
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   497
 * under all these conditions. An unreasonable buffer or size will return
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   498
 * an error value. Under all other conditions this function will return the
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   499
 * size of the bytes actually written minus the null terminator, similar
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   500
 * to ansi snprintf api. Thus when calling this function the caller must
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   501
 * ensure storage for the null terminator.
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   502
 */
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   503
int
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   504
JLI_Snprintf(char* buffer, size_t size, const char* format, ...) {
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   505
    int rc;
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   506
    va_list vl;
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   507
    if (size == 0 || buffer == NULL)
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   508
        return -1;
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   509
    buffer[0] = '\0';
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   510
    va_start(vl, format);
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   511
    rc = vsnprintf(buffer, size, format, vl);
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   512
    va_end(vl);
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   513
    /* force a null terminator, if something is amiss */
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   514
    if (rc < 0) {
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   515
        /* apply ansi semantics */
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   516
        buffer[size - 1] = '\0';
29742
b73f38796859 8074840: Resolve disabled warnings for libjli and libjli_static
mikael
parents: 28984
diff changeset
   517
        return (int)size;
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   518
    } else if (rc == size) {
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   519
        /* force a null terminator */
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   520
        buffer[size - 1] = '\0';
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
   521
    }
16077
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   522
    return rc;
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   523
}
92008ab562e0 7200499: Better data validation for options
ksrini
parents: 13411
diff changeset
   524
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
void
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   526
JLI_ReportErrorMessage(const char* fmt, ...) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    va_list vl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    va_start(vl,fmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    if (IsJavaw()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        char *message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        /* get the length of the string we need */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        int n = _vscprintf(fmt, vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        message = (char *)JLI_MemAlloc(n + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        _vsnprintf(message, n, fmt, vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        message[n]='\0';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        MessageBox(NULL, message, "Java Virtual Machine Launcher",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        JLI_MemFree(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        vfprintf(stderr, fmt, vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        fprintf(stderr, "\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    va_end(vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
/*
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   550
 * Just like JLI_ReportErrorMessage, except that it concatenates the system
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
 * error message if any, its upto the calling routine to correctly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
 * format the separation of the messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
void
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   555
JLI_ReportErrorMessageSys(const char *fmt, ...)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    va_list vl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    int save_errno = errno;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    DWORD       errval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    jboolean freeit = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    char  *errtext = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    va_start(vl, fmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    if ((errval = GetLastError()) != 0) {               /* Platform SDK / DOS Error */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        int n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_ALLOCATE_BUFFER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            NULL, errval, 0, (LPTSTR)&errtext, 0, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        if (errtext == NULL || n == 0) {                /* Paranoia check */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            errtext = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            n = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            freeit = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            if (n > 2) {                                /* Drop final CR, LF */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                if (errtext[n - 1] == '\n') n--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                if (errtext[n - 1] == '\r') n--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                errtext[n] = '\0';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    } else {   /* C runtime error that has no corresponding DOS error code */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        errtext = strerror(save_errno);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    if (IsJavaw()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        char *message;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        int mlen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        /* get the length of the string we need */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        int len = mlen =  _vscprintf(fmt, vl) + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        if (freeit) {
7028
adadd244f506 6989469: (launcher) compiler warnings in jli native code
ksrini
parents: 6535
diff changeset
   591
           mlen += (int)JLI_StrLen(errtext);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        message = (char *)JLI_MemAlloc(mlen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        _vsnprintf(message, len, fmt, vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        message[len]='\0';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        if (freeit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
           JLI_StrCat(message, errtext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        MessageBox(NULL, message, "Java Virtual Machine Launcher",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        JLI_MemFree(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        vfprintf(stderr, fmt, vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        if (freeit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
           fprintf(stderr, "%s", errtext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    if (freeit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        (void)LocalFree((HLOCAL)errtext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    va_end(vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 715
diff changeset
   618
void  JLI_ReportExceptionDescription(JNIEnv * env) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    if (IsJavaw()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
       /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        * This code should be replaced by code which opens a window with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        * the exception detail message, for now atleast put a dialog up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        MessageBox(NULL, "A Java Exception has occurred.", "Java Virtual Machine Launcher",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
               (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        (*env)->ExceptionDescribe(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
ServerClassMachine() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    return (GetErgoPolicy() == ALWAYS_SERVER_CLASS) ? JNI_TRUE : JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
 * Wrapper for platform dependent unsetenv function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
UnsetEnv(char *name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    int ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    char *buf = JLI_MemAlloc(JLI_StrLen(name) + 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    buf = JLI_StrCat(JLI_StrCpy(buf, name), "=");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    ret = _putenv(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    JLI_MemFree(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    return (ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
/* --- Splash Screen shared library support --- */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
static const char* SPLASHSCREEN_SO = "\\bin\\splashscreen.dll";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
static HMODULE hSplashLib = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
void* SplashProcAddress(const char* name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    char libraryPath[MAXPATHLEN]; /* some extra space for JLI_StrCat'ing SPLASHSCREEN_SO */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    if (!GetJREPath(libraryPath, MAXPATHLEN)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    if (JLI_StrLen(libraryPath)+JLI_StrLen(SPLASHSCREEN_SO) >= MAXPATHLEN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    JLI_StrCat(libraryPath, SPLASHSCREEN_SO);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    if (!hSplashLib) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        hSplashLib = LoadLibrary(libraryPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    if (hSplashLib) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        return GetProcAddress(hSplashLib, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
void SplashFreeLibrary() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    if (hSplashLib) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        FreeLibrary(hSplashLib);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        hSplashLib = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
 * Block current thread and continue execution in a new thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    int rslt = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    unsigned thread_id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
#ifndef STACK_SIZE_PARAM_IS_A_RESERVATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
#define STACK_SIZE_PARAM_IS_A_RESERVATION  (0x10000)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * STACK_SIZE_PARAM_IS_A_RESERVATION is what we want, but it's not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * supported on older version of Windows. Try first with the flag; and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * if that fails try again without the flag. See MSDN document or HotSpot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * source (os_win32.cpp) for details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    HANDLE thread_handle =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
      (HANDLE)_beginthreadex(NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                             (unsigned)stack_size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                             continuation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                             args,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                             STACK_SIZE_PARAM_IS_A_RESERVATION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                             &thread_id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    if (thread_handle == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
      thread_handle =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
      (HANDLE)_beginthreadex(NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                             (unsigned)stack_size,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                             continuation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                             args,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                             0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                             &thread_id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    }
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   718
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   719
    /* AWT preloading (AFTER main thread start) */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   720
#ifdef ENABLE_AWT_PRELOAD
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   721
    /* D3D preloading */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   722
    if (awtPreloadD3D != 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   723
        char *envValue;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   724
        /* D3D routines checks env.var J2D_D3D if no appropriate
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   725
         * command line params was specified
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   726
         */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   727
        envValue = getenv("J2D_D3D");
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   728
        if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   729
            awtPreloadD3D = 0;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   730
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   731
        /* Test that AWT preloading isn't disabled by J2D_D3D_PRELOAD env.var */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   732
        envValue = getenv("J2D_D3D_PRELOAD");
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   733
        if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   734
            awtPreloadD3D = 0;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   735
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   736
        if (awtPreloadD3D < 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   737
            /* If awtPreloadD3D is still undefined (-1), test
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   738
             * if it is turned on by J2D_D3D_PRELOAD env.var.
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   739
             * By default it's turned OFF.
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   740
             */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   741
            awtPreloadD3D = 0;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   742
            if (envValue != NULL && JLI_StrCaseCmp(envValue, "true") == 0) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   743
                awtPreloadD3D = 1;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   744
            }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   745
         }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   746
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   747
    if (awtPreloadD3D) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   748
        AWTPreload(D3D_PRELOAD_FUNC);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   749
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   750
#endif /* ENABLE_AWT_PRELOAD */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   751
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    if (thread_handle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
      WaitForSingleObject(thread_handle, INFINITE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
      GetExitCodeThread(thread_handle, &rslt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
      CloseHandle(thread_handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
      rslt = continuation(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    }
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   759
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   760
#ifdef ENABLE_AWT_PRELOAD
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   761
    if (awtPreloaded) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   762
        AWTPreloadStop();
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   763
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   764
#endif /* ENABLE_AWT_PRELOAD */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   765
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    return rslt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   769
/* Unix only, empty on windows. */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
void SetJavaLauncherPlatformProps() {}
39
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   771
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   772
/*
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   773
 * The implementation for finding classes from the bootstrap
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   774
 * class loader, refer to java.h
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   775
 */
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   776
static FindClassFromBootLoader_t *findBootClass = NULL;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   777
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   778
jclass FindBootStrapClass(JNIEnv *env, const char *classname)
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   779
{
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   780
   HMODULE hJvm;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   781
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   782
   if (findBootClass == NULL) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   783
       hJvm = GetModuleHandle(JVM_DLL);
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   784
       if (hJvm == NULL) return NULL;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   785
       /* need to use the demangled entry point */
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   786
       findBootClass = (FindClassFromBootLoader_t *)GetProcAddress(hJvm,
3834
16342ebd576d 6864028: Update the java launcher to use the new entry point JVM_FindClassFromBootLoader
mchung
parents: 3111
diff changeset
   787
            "JVM_FindClassFromBootLoader");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   788
       if (findBootClass == NULL) {
3834
16342ebd576d 6864028: Update the java launcher to use the new entry point JVM_FindClassFromBootLoader
mchung
parents: 3111
diff changeset
   789
          JLI_ReportErrorMessage(DLL_ERROR4, "JVM_FindClassFromBootLoader");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   790
          return NULL;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   791
       }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   792
   }
3834
16342ebd576d 6864028: Update the java launcher to use the new entry point JVM_FindClassFromBootLoader
mchung
parents: 3111
diff changeset
   793
   return findBootClass(env, classname);
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   794
}
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   795
39
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   796
void
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   797
InitLauncher(boolean javaw)
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   798
{
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   799
    INITCOMMONCONTROLSEX icx;
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   800
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   801
    /*
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   802
     * Required for javaw mode MessageBox output as well as for
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   803
     * HotSpot -XX:+ShowMessageBoxOnError in java mode, an empty
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   804
     * flag field is sufficient to perform the basic UI initialization.
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   805
     */
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   806
    memset(&icx, 0, sizeof(INITCOMMONCONTROLSEX));
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   807
    icx.dwSize = sizeof(INITCOMMONCONTROLSEX);
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   808
    InitCommonControlsEx(&icx);
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   809
    _isjavaw = javaw;
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   810
    JLI_SetTraceLauncher();
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   811
}
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   812
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   813
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   814
/* ============================== */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   815
/* AWT preloading */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   816
#ifdef ENABLE_AWT_PRELOAD
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   817
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   818
typedef int FnPreloadStart(void);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   819
typedef void FnPreloadStop(void);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   820
static FnPreloadStop *fnPreloadStop = NULL;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   821
static HMODULE hPreloadAwt = NULL;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   822
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   823
/*
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   824
 * Starts AWT preloading
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   825
 */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   826
int AWTPreload(const char *funcName)
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   827
{
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   828
    int result = -1;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   829
    /* load AWT library once (if several preload function should be called) */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   830
    if (hPreloadAwt == NULL) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   831
        /* awt.dll is not loaded yet */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   832
        char libraryPath[MAXPATHLEN];
29742
b73f38796859 8074840: Resolve disabled warnings for libjli and libjli_static
mikael
parents: 28984
diff changeset
   833
        size_t jrePathLen = 0;
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   834
        HMODULE hJava = NULL;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   835
        HMODULE hVerify = NULL;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   836
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   837
        while (1) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   838
            /* awt.dll depends on jvm.dll & java.dll;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   839
             * jvm.dll is already loaded, so we need only java.dll;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   840
             * java.dll depends on MSVCRT lib & verify.dll.
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   841
             */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   842
            if (!GetJREPath(libraryPath, MAXPATHLEN)) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   843
                break;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   844
            }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   845
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   846
            /* save path length */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   847
            jrePathLen = JLI_StrLen(libraryPath);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   848
25538
421c18d84c71 8037046: Validate libraries to be loaded
kizune
parents: 22279
diff changeset
   849
            if (jrePathLen + JLI_StrLen("\\bin\\verify.dll") >= MAXPATHLEN) {
421c18d84c71 8037046: Validate libraries to be loaded
kizune
parents: 22279
diff changeset
   850
              /* jre path is too long, the library path will not fit there;
421c18d84c71 8037046: Validate libraries to be loaded
kizune
parents: 22279
diff changeset
   851
               * report and abort preloading
421c18d84c71 8037046: Validate libraries to be loaded
kizune
parents: 22279
diff changeset
   852
               */
421c18d84c71 8037046: Validate libraries to be loaded
kizune
parents: 22279
diff changeset
   853
              JLI_ReportErrorMessage(JRE_ERROR11);
421c18d84c71 8037046: Validate libraries to be loaded
kizune
parents: 22279
diff changeset
   854
              break;
421c18d84c71 8037046: Validate libraries to be loaded
kizune
parents: 22279
diff changeset
   855
            }
421c18d84c71 8037046: Validate libraries to be loaded
kizune
parents: 22279
diff changeset
   856
7004
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   857
            /* load msvcrt 1st */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   858
            LoadMSVCRT();
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   859
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   860
            /* load verify.dll */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   861
            JLI_StrCat(libraryPath, "\\bin\\verify.dll");
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   862
            hVerify = LoadLibrary(libraryPath);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   863
            if (hVerify == NULL) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   864
                break;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   865
            }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   866
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   867
            /* restore jrePath */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   868
            libraryPath[jrePathLen] = 0;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   869
            /* load java.dll */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   870
            JLI_StrCat(libraryPath, "\\bin\\" JAVA_DLL);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   871
            hJava = LoadLibrary(libraryPath);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   872
            if (hJava == NULL) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   873
                break;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   874
            }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   875
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   876
            /* restore jrePath */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   877
            libraryPath[jrePathLen] = 0;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   878
            /* load awt.dll */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   879
            JLI_StrCat(libraryPath, "\\bin\\awt.dll");
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   880
            hPreloadAwt = LoadLibrary(libraryPath);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   881
            if (hPreloadAwt == NULL) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   882
                break;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   883
            }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   884
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   885
            /* get "preloadStop" func ptr */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   886
            fnPreloadStop = (FnPreloadStop *)GetProcAddress(hPreloadAwt, "preloadStop");
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   887
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   888
            break;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   889
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   890
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   891
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   892
    if (hPreloadAwt != NULL) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   893
        FnPreloadStart *fnInit = (FnPreloadStart *)GetProcAddress(hPreloadAwt, funcName);
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   894
        if (fnInit != NULL) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   895
            /* don't forget to stop preloading */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   896
            awtPreloaded = 1;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   897
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   898
            result = fnInit();
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   899
        }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   900
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   901
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   902
    return result;
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   903
}
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   904
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   905
/*
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   906
 * Terminates AWT preloading
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   907
 */
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   908
void AWTPreloadStop() {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   909
    if (fnPreloadStop != NULL) {
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   910
        fnPreloadStop();
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   911
    }
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   912
}
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   913
3f92ea1ffcac 6867515: Reduce impact of D3D initializion on startup time
amenkov
parents: 6535
diff changeset
   914
#endif /* ENABLE_AWT_PRELOAD */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   915
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   916
int
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   917
JVMInit(InvocationFunctions* ifn, jlong threadStackSize,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   918
        int argc, char **argv,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   919
        int mode, char *what, int ret)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   920
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   921
    ShowSplashScreen();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   922
    return ContinueInNewThread(ifn, threadStackSize, argc, argv, mode, what, ret);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   923
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   924
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   925
void
30467
075f4f160f19 8076264: [macosx] Launching app on MacOSX requires enclosing class
serb
parents: 29742
diff changeset
   926
PostJVMInit(JNIEnv *env, jclass mainClass, JavaVM *vm)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   927
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   928
    // stubbed out for windows and *nixes.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   929
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   930
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   931
void
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   932
RegisterThread()
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   933
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   934
    // stubbed out for windows and *nixes.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   935
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   936
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   937
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   938
 * on windows, we return a false to indicate this option is not applicable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   939
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   940
jboolean
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   941
ProcessPlatformOption(const char *arg)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   942
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   943
    return JNI_FALSE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9842
diff changeset
   944
}
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   945
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   946
/*
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   947
 * At this point we have the arguments to the application, and we need to
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   948
 * check with original stdargs in order to compare which of these truly
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   949
 * needs expansion. cmdtoargs will specify this if it finds a bare
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   950
 * (unquoted) argument containing a glob character(s) ie. * or ?
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   951
 */
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   952
jobjectArray
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   953
CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   954
{
29742
b73f38796859 8074840: Resolve disabled warnings for libjli and libjli_static
mikael
parents: 28984
diff changeset
   955
    int i, j, idx;
b73f38796859 8074840: Resolve disabled warnings for libjli and libjli_static
mikael
parents: 28984
diff changeset
   956
    size_t tlen;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   957
    jobjectArray outArray, inArray;
39640
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   958
    char *arg, **nargv;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   959
    jboolean needs_expansion = JNI_FALSE;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   960
    jmethodID mid;
39640
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   961
    int stdargc;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   962
    StdArg *stdargs;
39640
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   963
    int *appArgIdx;
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   964
    int isTool;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   965
    jclass cls = GetLauncherHelperClass(env);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   966
    NULL_CHECK0(cls);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   967
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   968
    if (argc == 0) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   969
        return NewPlatformStringArray(env, strv, argc);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   970
    }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   971
    // the holy grail we need to compare with.
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   972
    stdargs = JLI_GetStdArgs();
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   973
    stdargc = JLI_GetStdArgc();
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   974
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   975
    // sanity check, this should never happen
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   976
    if (argc > stdargc) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   977
        JLI_TraceLauncher("Warning: app args is larger than the original, %d %d\n", argc, stdargc);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   978
        JLI_TraceLauncher("passing arguments as-is.\n");
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   979
        return NewPlatformStringArray(env, strv, argc);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   980
    }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   981
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
   982
    // sanity check, match the args we have, to the holy grail
39640
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   983
    idx = JLI_GetAppArgIndex();
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   984
    isTool = (idx == 0);
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   985
    if (isTool) { idx++; } // skip tool name
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   986
    JLI_TraceLauncher("AppArgIndex: %d points to %s\n", idx, stdargs[idx].arg);
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   987
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   988
    appArgIdx = calloc(argc, sizeof(int));
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   989
    for (i = idx, j = 0; i < stdargc; i++) {
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   990
        if (isTool) { // filter -J used by tools to pass JVM options
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   991
            arg = stdargs[i].arg;
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   992
            if (arg[0] == '-' && arg[1] == 'J') {
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   993
                continue;
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   994
            }
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   995
        }
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   996
        appArgIdx[j++] = i;
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   997
    }
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   998
    // sanity check, ensure same number of arguments for application
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
   999
    if (j != argc) {
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1000
        JLI_TraceLauncher("Warning: app args count doesn't match, %d %d\n", j, argc);
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1001
        JLI_TraceLauncher("passing arguments as-is.\n");
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1002
        JLI_MemFree(appArgIdx);
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1003
        return NewPlatformStringArray(env, strv, argc);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1004
    }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1005
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1006
    // make a copy of the args which will be expanded in java if required.
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1007
    nargv = (char **)JLI_MemAlloc(argc * sizeof(char*));
39640
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1008
    for (i = 0; i < argc; i++) {
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1009
        j = appArgIdx[i];
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1010
        jboolean arg_expand = (JLI_StrCmp(stdargs[j].arg, strv[i]) == 0)
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1011
                                ? stdargs[j].has_wildcard
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1012
                                : JNI_FALSE;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1013
        if (needs_expansion == JNI_FALSE)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1014
            needs_expansion = arg_expand;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1015
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1016
        // indicator char + String + NULL terminator, the java method will strip
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1017
        // out the first character, the indicator character, so no matter what
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1018
        // we add the indicator
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1019
        tlen = 1 + JLI_StrLen(strv[i]) + 1;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1020
        nargv[i] = (char *) JLI_MemAlloc(tlen);
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
  1021
        if (JLI_Snprintf(nargv[i], tlen, "%c%s", arg_expand ? 'T' : 'F',
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
  1022
                         strv[i]) < 0) {
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
  1023
            return NULL;
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 16077
diff changeset
  1024
        }
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1025
        JLI_TraceLauncher("%s\n", nargv[i]);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1026
    }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1027
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1028
    if (!needs_expansion) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1029
        // clean up any allocated memory and return back the old arguments
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1030
        for (i = 0 ; i < argc ; i++) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1031
            JLI_MemFree(nargv[i]);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1032
        }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1033
        JLI_MemFree(nargv);
39640
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1034
        JLI_MemFree(appArgIdx);
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1035
        return NewPlatformStringArray(env, strv, argc);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1036
    }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1037
    NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1038
                                                "expandArgs",
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1039
                                                "([Ljava/lang/String;)[Ljava/lang/String;"));
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1040
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1041
    // expand the arguments that require expansion, the java method will strip
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1042
    // out the indicator character.
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 22066
diff changeset
  1043
    NULL_CHECK0(inArray = NewPlatformStringArray(env, nargv, argc));
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1044
    outArray = (*env)->CallStaticObjectMethod(env, cls, mid, inArray);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1045
    for (i = 0; i < argc; i++) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1046
        JLI_MemFree(nargv[i]);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1047
    }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1048
    JLI_MemFree(nargv);
39640
6f1a839ff43d 8132379: -J options can cause crash or "Warning: app args parsing error passing arguments as-is"
henryjen
parents: 34960
diff changeset
  1049
    JLI_MemFree(appArgIdx);
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1050
    return outArray;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12047
diff changeset
  1051
}