jdk/src/java.base/share/native/launcher/main.c
author ksrini
Fri, 09 Jun 2017 09:54:59 -0700
changeset 45463 d9325138bac6
parent 43691 f3c0d65c7b17
permissions -rw-r--r--
8180334: Unable to build jaotc launcher on windows Reviewed-by: erikj, ihse, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
45463
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
     2
 * Copyright (c) 1995, 2017, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * This file contains the main entry point into the launcher code
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * this is the only file which will be repeatedly compiled by other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * tools. The rest of the files will be linked in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "defines.h"
32267
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
    34
#include "jli_util.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
1776
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    36
#ifdef _MSC_VER
5381
d6d64a42ff51 6931180: Migration to recent versions of MS Platform SDK
prr
parents: 1776
diff changeset
    37
#if _MSC_VER > 1400 && _MSC_VER < 1600
1776
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    38
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    39
/*
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    40
 * When building for Microsoft Windows, main has a dependency on msvcr??.dll.
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    41
 *
5381
d6d64a42ff51 6931180: Migration to recent versions of MS Platform SDK
prr
parents: 1776
diff changeset
    42
 * When using Visual Studio 2005 or 2008, that must be recorded in
1776
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    43
 * the [java,javaw].exe.manifest file.
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    44
 *
5381
d6d64a42ff51 6931180: Migration to recent versions of MS Platform SDK
prr
parents: 1776
diff changeset
    45
 * As of VS2010 (ver=1600), the runtimes again no longer need manifests.
d6d64a42ff51 6931180: Migration to recent versions of MS Platform SDK
prr
parents: 1776
diff changeset
    46
 *
1776
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    47
 * Reference:
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    48
 *     C:/Program Files/Microsoft SDKs/Windows/v6.1/include/crtdefs.h
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    49
 */
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    50
#include <crtassem.h>
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    51
#ifdef _M_IX86
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    52
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    53
#pragma comment(linker,"/manifestdependency:\"type='win32' "            \
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    54
        "name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT' "              \
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    55
        "version='" _CRT_ASSEMBLY_VERSION "' "                          \
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    56
        "processorArchitecture='x86' "                                  \
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    57
        "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    58
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    59
#endif /* _M_IX86 */
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    60
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    61
//This may not be necessary yet for the Windows 64-bit build, but it
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    62
//will be when that build environment is updated.  Need to test to see
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    63
//if it is harmless:
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    64
#ifdef _M_AMD64
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    65
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    66
#pragma comment(linker,"/manifestdependency:\"type='win32' "            \
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    67
        "name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT' "              \
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    68
        "version='" _CRT_ASSEMBLY_VERSION "' "                          \
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    69
        "processorArchitecture='amd64' "                                \
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    70
        "publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    71
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    72
#endif  /* _M_AMD64 */
5381
d6d64a42ff51 6931180: Migration to recent versions of MS Platform SDK
prr
parents: 1776
diff changeset
    73
#endif  /* _MSC_VER > 1400 && _MSC_VER < 1600 */
1776
33e9405ab91b 6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents: 715
diff changeset
    74
#endif  /* _MSC_VER */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * Entry point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#ifdef JAVAW
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
char **__initenv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
int WINAPI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
{
41814
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 36511
diff changeset
    86
    int margc;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    char** margv;
45463
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
    88
    int jargc;
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
    89
    char** jargv;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    const jboolean const_javaw = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    __initenv = _environ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#else /* JAVAW */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
int
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
    96
main(int argc, char **argv)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
{
41814
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 36511
diff changeset
    98
    int margc;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    char** margv;
45463
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   100
    int jargc;
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   101
    char** jargv;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    const jboolean const_javaw = JNI_FALSE;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   103
#endif /* JAVAW */
45463
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   104
    {
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   105
        int i, main_jargc, extra_jargc;
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   106
        JLI_List list;
32267
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   107
45463
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   108
        main_jargc = (sizeof(const_jargs) / sizeof(char *)) > 1
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   109
            ? sizeof(const_jargs) / sizeof(char *)
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   110
            : 0; // ignore the null terminator index
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   111
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   112
        extra_jargc = (sizeof(const_extra_jargs) / sizeof(char *)) > 1
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   113
            ? sizeof(const_extra_jargs) / sizeof(char *)
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   114
            : 0; // ignore the null terminator index
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   115
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   116
        if (main_jargc > 0 && extra_jargc > 0) { // combine extra java args
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   117
            jargc = main_jargc + extra_jargc;
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   118
            list = JLI_List_new(jargc + 1);
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   119
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   120
            for (i = 0 ; i < extra_jargc; i++) {
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   121
                JLI_List_add(list, JLI_StringDup(const_extra_jargs[i]));
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   122
            }
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   123
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   124
            for (i = 0 ; i < main_jargc ; i++) {
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   125
                JLI_List_add(list, JLI_StringDup(const_jargs[i]));
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   126
            }
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   127
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   128
            // terminate the list
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   129
            JLI_List_add(list, NULL);
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   130
            jargv = list->elements;
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   131
         } else if (extra_jargc > 0) { // should never happen
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   132
            fprintf(stderr, "EXTRA_JAVA_ARGS defined without JAVA_ARGS");
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   133
            abort();
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   134
         } else { // no extra args, business as usual
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   135
            jargc = main_jargc;
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   136
            jargv = (char **) const_jargs;
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   137
         }
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   138
    }
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   139
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   140
    JLI_InitArgProcessing(jargc > 0, const_disable_argfile);
32267
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   141
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   142
#ifdef _WIN32
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   143
    {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   144
        int i = 0;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   145
        if (getenv(JLDEBUG_ENV_ENTRY) != NULL) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   146
            printf("Windows original main args:\n");
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   147
            for (i = 0 ; i < __argc ; i++) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   148
                printf("wwwd_args[%d] = %s\n", i, __argv[i]);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   149
            }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   150
        }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   151
    }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   152
    JLI_CmdToArgs(GetCommandLine());
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   153
    margc = JLI_GetStdArgc();
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   154
    // add one more to mark the end
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   155
    margv = (char **)JLI_MemAlloc((margc + 1) * (sizeof(char *)));
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   156
    {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   157
        int i = 0;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   158
        StdArg *stdargs = JLI_GetStdArgs();
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   159
        for (i = 0 ; i < margc ; i++) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   160
            margv[i] = stdargs[i].arg;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   161
        }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   162
        margv[i] = NULL;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   163
    }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   164
#else /* *NIXES */
32267
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   165
    {
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   166
        // accommodate the NULL at the end
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   167
        JLI_List args = JLI_List_new(argc + 1);
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   168
        int i = 0;
43325
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   169
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   170
        // Add first arg, which is the app name
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   171
        JLI_List_add(args, JLI_StringDup(argv[0]));
43691
f3c0d65c7b17 8173712: Rename JAVA_OPTIONS environment variable to JDK_JAVA_OPTIONS
mchung
parents: 43325
diff changeset
   172
        // Append JDK_JAVA_OPTIONS
f3c0d65c7b17 8173712: Rename JAVA_OPTIONS environment variable to JDK_JAVA_OPTIONS
mchung
parents: 43325
diff changeset
   173
        if (JLI_AddArgsFromEnvVar(args, JDK_JAVA_OPTIONS)) {
43325
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   174
            // JLI_SetTraceLauncher is not called yet
43691
f3c0d65c7b17 8173712: Rename JAVA_OPTIONS environment variable to JDK_JAVA_OPTIONS
mchung
parents: 43325
diff changeset
   175
            // Show _JAVA_OPTIONS content along with JDK_JAVA_OPTIONS to aid diagnosis
43325
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   176
            if (getenv(JLDEBUG_ENV_ENTRY)) {
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   177
                char *tmp = getenv("_JAVA_OPTIONS");
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   178
                if (NULL != tmp) {
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   179
                    JLI_ReportMessage(ARG_INFO_ENVVAR, "_JAVA_OPTIONS", tmp);
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   180
                }
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   181
            }
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   182
        }
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   183
        // Iterate the rest of command line
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 41966
diff changeset
   184
        for (i = 1; i < argc; i++) {
32267
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   185
            JLI_List argsInFile = JLI_PreprocessArg(argv[i]);
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   186
            if (NULL == argsInFile) {
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   187
                JLI_List_add(args, JLI_StringDup(argv[i]));
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   188
            } else {
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   189
                int cnt, idx;
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   190
                cnt = argsInFile->size;
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   191
                for (idx = 0; idx < cnt; idx++) {
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   192
                    JLI_List_add(args, argsInFile->elements[idx]);
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   193
                }
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   194
                // Shallow free, we reuse the string to avoid copy
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   195
                JLI_MemFree(argsInFile->elements);
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   196
                JLI_MemFree(argsInFile);
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   197
            }
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   198
        }
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   199
        margc = args->size;
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   200
        // add the NULL pointer at argv[argc]
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   201
        JLI_List_add(args, NULL);
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   202
        margv = args->elements;
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 30822
diff changeset
   203
    }
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 7668
diff changeset
   204
#endif /* WIN32 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    return JLI_Launch(margc, margv,
45463
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   206
                   jargc, (const char**) jargv,
41814
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 36511
diff changeset
   207
                   0, NULL,
33984
2333676816eb 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 30822
diff changeset
   208
                   VERSION_STRING,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                   DOT_VERSION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                   (const_progname != NULL) ? const_progname : *margv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                   (const_launcher != NULL) ? const_launcher : *margv,
45463
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 43691
diff changeset
   212
                   jargc > 0,
41966
bac52fa6e617 8169001: Remove launcher's built-in ergonomics
ksrini
parents: 41814
diff changeset
   213
                   const_cpwildcard, const_javaw, 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
}