author | acorn |
Tue, 03 Dec 2013 11:13:14 -0800 | |
changeset 21913 | 0e2fd7282ac6 |
parent 16091 | 4eb1062acb5b |
child 22066 | f2133b498789 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include <windows.h> |
|
27 |
#include <io.h> |
|
28 |
#include <process.h> |
|
29 |
#include <stdlib.h> |
|
30 |
#include <stdio.h> |
|
31 |
#include <stdarg.h> |
|
32 |
#include <string.h> |
|
33 |
#include <sys/types.h> |
|
34 |
#include <sys/stat.h> |
|
35 |
#include <wtypes.h> |
|
39
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
36 |
#include <commctrl.h> |
2 | 37 |
|
38 |
#include <jni.h> |
|
39 |
#include "java.h" |
|
40 |
#include "version_comp.h" |
|
41 |
||
42 |
#define JVM_DLL "jvm.dll" |
|
43 |
#define JAVA_DLL "java.dll" |
|
44 |
||
45 |
/* |
|
46 |
* Prototypes. |
|
47 |
*/ |
|
48 |
static jboolean GetPublicJREHome(char *path, jint pathsize); |
|
49 |
static jboolean GetJVMPath(const char *jrepath, const char *jvmtype, |
|
50 |
char *jvmpath, jint jvmpathsize); |
|
51 |
static jboolean GetJREPath(char *path, jint pathsize); |
|
52 |
||
7004
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
53 |
/* 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
|
54 |
* to VM initialization. |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
55 |
* 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
|
56 |
* 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
|
57 |
* 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
|
58 |
* 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
|
59 |
* 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
|
60 |
* (this is always the case for plugin/javaws). |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
61 |
* |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
62 |
* 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
|
63 |
* warmup code (platform dependent). |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
64 |
* 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
|
65 |
* 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
|
66 |
* |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
67 |
* 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
|
68 |
* 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
|
69 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
70 |
#undef ENABLE_AWT_PRELOAD |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
71 |
#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
|
72 |
/* 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
|
73 |
* initialized*/ |
adb296cc2eae
6999872: java.awt.Window instantiation leads to JVM CRASH on Windows, JDK7b118+ fastdebug
amenkov
parents:
7048
diff
changeset
|
74 |
#if !defined(DEBUG) |
adb296cc2eae
6999872: java.awt.Window instantiation leads to JVM CRASH on Windows, JDK7b118+ fastdebug
amenkov
parents:
7048
diff
changeset
|
75 |
#define ENABLE_AWT_PRELOAD |
adb296cc2eae
6999872: java.awt.Window instantiation leads to JVM CRASH on Windows, JDK7b118+ fastdebug
amenkov
parents:
7048
diff
changeset
|
76 |
#endif |
7004
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
77 |
#endif |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
78 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
79 |
#ifdef ENABLE_AWT_PRELOAD |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
80 |
/* "AWT was preloaded" flag; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
81 |
* turned on by AWTPreload(). |
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 |
int awtPreloaded = 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
84 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
85 |
/* Calls a function with the name specified |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
86 |
* the function must be int(*fn)(void). |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
87 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
88 |
int AWTPreload(const char *funcName); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
89 |
/* stops AWT preloading */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
90 |
void AWTPreloadStop(); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
91 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
92 |
/* D3D preloading */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
93 |
/* -1: not initialized; 0: OFF, 1: ON */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
94 |
int awtPreloadD3D = -1; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
95 |
/* command line parameter to swith D3D preloading on */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
96 |
#define PARAM_PRELOAD_D3D "-Dsun.awt.warmup" |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
97 |
/* D3D/OpenGL management parameters */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
98 |
#define PARAM_NODDRAW "-Dsun.java2d.noddraw" |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
99 |
#define PARAM_D3D "-Dsun.java2d.d3d" |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
100 |
#define PARAM_OPENGL "-Dsun.java2d.opengl" |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
101 |
/* 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
|
102 |
#define D3D_PRELOAD_FUNC "preloadD3D" |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
103 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
104 |
/* Extracts value of a parameter with the specified name |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
105 |
* from command line argument (returns pointer in the argument). |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
106 |
* 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
|
107 |
* e.g.: |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
108 |
* GetParamValue("theParam", "theParam=value") returns pointer to "value". |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
109 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
110 |
const char * GetParamValue(const char *paramName, const char *arg) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
111 |
int nameLen = JLI_StrLen(paramName); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
112 |
if (JLI_StrNCmp(paramName, arg, nameLen) == 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
113 |
/* arg[nameLen] is valid (may contain final NULL) */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
114 |
if (arg[nameLen] == '=') { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
115 |
return arg + nameLen + 1; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
116 |
} |
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 |
return NULL; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
119 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
120 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
121 |
/* Checks if commandline argument contains property specified |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
122 |
* and analyze it as boolean property (true/false). |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
123 |
* 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
|
124 |
* 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
|
125 |
* 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
|
126 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
127 |
int GetBoolParamValue(const char *paramName, const char *arg) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
128 |
const char * paramValue = GetParamValue(paramName, arg); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
129 |
if (paramValue != NULL) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
130 |
if (JLI_StrCaseCmp(paramValue, "true") == 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
131 |
return 1; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
132 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
133 |
if (JLI_StrCaseCmp(paramValue, "false") == 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
134 |
return 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
135 |
} |
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 |
return -1; |
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 |
#endif /* ENABLE_AWT_PRELOAD */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
140 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
141 |
|
2 | 142 |
static jboolean _isjavaw = JNI_FALSE; |
143 |
||
144 |
||
145 |
jboolean |
|
146 |
IsJavaw() |
|
147 |
{ |
|
148 |
return _isjavaw; |
|
149 |
} |
|
150 |
||
151 |
/* |
|
152 |
* Returns the arch path, to get the current arch use the |
|
153 |
* macro GetArch, nbits here is ignored for now. |
|
154 |
*/ |
|
155 |
const char * |
|
156 |
GetArchPath(int nbits) |
|
157 |
{ |
|
158 |
#ifdef _M_AMD64 |
|
159 |
return "amd64"; |
|
160 |
#elif defined(_M_IA64) |
|
161 |
return "ia64"; |
|
162 |
#else |
|
163 |
return "i386"; |
|
164 |
#endif |
|
165 |
} |
|
166 |
||
167 |
/* |
|
168 |
* |
|
169 |
*/ |
|
170 |
void |
|
6005 | 171 |
CreateExecutionEnvironment(int *pargc, char ***pargv, |
172 |
char *jrepath, jint so_jrepath, |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
173 |
char *jvmpath, jint so_jvmpath, |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
174 |
char *jvmcfg, jint so_jvmcfg) { |
2 | 175 |
char * jvmtype; |
176 |
int i = 0; |
|
177 |
int running = CURRENT_DATA_MODEL; |
|
178 |
||
179 |
int wanted = running; |
|
180 |
||
6005 | 181 |
char** argv = *pargv; |
182 |
for (i = 0; i < *pargc ; i++) { |
|
183 |
if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) { |
|
2 | 184 |
wanted = 64; |
185 |
continue; |
|
186 |
} |
|
6005 | 187 |
if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) { |
2 | 188 |
wanted = 32; |
189 |
continue; |
|
190 |
} |
|
191 |
} |
|
192 |
if (running != wanted) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
193 |
JLI_ReportErrorMessage(JRE_ERROR2, wanted); |
2 | 194 |
exit(1); |
195 |
} |
|
196 |
||
197 |
/* Find out where the JRE is that we will be using. */ |
|
198 |
if (!GetJREPath(jrepath, so_jrepath)) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
199 |
JLI_ReportErrorMessage(JRE_ERROR1); |
2 | 200 |
exit(2); |
201 |
} |
|
202 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
203 |
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
|
204 |
jrepath, FILESEP, FILESEP, (char*)GetArch(), FILESEP); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
205 |
|
2 | 206 |
/* Find the specified JVM type */ |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
207 |
if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) { |
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
208 |
JLI_ReportErrorMessage(CFG_ERROR7); |
2 | 209 |
exit(1); |
210 |
} |
|
6005 | 211 |
|
212 |
jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE); |
|
213 |
if (JLI_StrCmp(jvmtype, "ERROR") == 0) { |
|
214 |
JLI_ReportErrorMessage(CFG_ERROR9); |
|
215 |
exit(4); |
|
216 |
} |
|
2 | 217 |
|
218 |
jvmpath[0] = '\0'; |
|
219 |
if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
220 |
JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); |
2 | 221 |
exit(4); |
222 |
} |
|
223 |
/* 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
|
224 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
225 |
/* Check if we need preload AWT */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
226 |
#ifdef ENABLE_AWT_PRELOAD |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
227 |
argv = *pargv; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
228 |
for (i = 0; i < *pargc ; i++) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
229 |
/* 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
|
230 |
if (awtPreloadD3D < 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
231 |
if (GetBoolParamValue(PARAM_PRELOAD_D3D, argv[i]) == 1) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
232 |
awtPreloadD3D = 1; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
233 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
234 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
235 |
/* 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
|
236 |
if (awtPreloadD3D != 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
237 |
if (GetBoolParamValue(PARAM_NODDRAW, argv[i]) == 1 |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
238 |
|| GetBoolParamValue(PARAM_D3D, argv[i]) == 0 |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
239 |
|| GetBoolParamValue(PARAM_OPENGL, argv[i]) == 1) |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
240 |
{ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
241 |
awtPreloadD3D = 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
242 |
/* no need to test the rest of the parameters */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
243 |
break; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
244 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
245 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
246 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
247 |
#endif /* ENABLE_AWT_PRELOAD */ |
2 | 248 |
} |
249 |
||
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
250 |
|
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
251 |
static jboolean |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
252 |
LoadMSVCRT() |
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 |
// Only do this once |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
255 |
static int loaded = 0; |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
256 |
char crtpath[MAXPATHLEN]; |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
257 |
|
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
258 |
if (!loaded) { |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
259 |
/* |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
260 |
* 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
|
261 |
* 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
|
262 |
* 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
|
263 |
* nature take its course, which is likely to be a failure to execute. |
5381
d6d64a42ff51
6931180: Migration to recent versions of MS Platform SDK
prr
parents:
3834
diff
changeset
|
264 |
* This is clearly completely specific to the exact compiler version |
d6d64a42ff51
6931180: Migration to recent versions of MS Platform SDK
prr
parents:
3834
diff
changeset
|
265 |
* which isn't very nice, but its hardly the only place. |
d6d64a42ff51
6931180: Migration to recent versions of MS Platform SDK
prr
parents:
3834
diff
changeset
|
266 |
* No attempt to look for compiler versions in between 2003 and 2010 |
d6d64a42ff51
6931180: Migration to recent versions of MS Platform SDK
prr
parents:
3834
diff
changeset
|
267 |
* as we aren't supporting building with those. |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
268 |
*/ |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
269 |
#ifdef _MSC_VER |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
270 |
#if _MSC_VER < 1400 |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
271 |
#define CRT_DLL "msvcr71.dll" |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
272 |
#endif |
5381
d6d64a42ff51
6931180: Migration to recent versions of MS Platform SDK
prr
parents:
3834
diff
changeset
|
273 |
#if _MSC_VER >= 1600 |
d6d64a42ff51
6931180: Migration to recent versions of MS Platform SDK
prr
parents:
3834
diff
changeset
|
274 |
#define CRT_DLL "msvcr100.dll" |
d6d64a42ff51
6931180: Migration to recent versions of MS Platform SDK
prr
parents:
3834
diff
changeset
|
275 |
#endif |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
276 |
#ifdef CRT_DLL |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
277 |
if (GetJREPath(crtpath, MAXPATHLEN)) { |
16077 | 278 |
if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + |
279 |
JLI_StrLen(CRT_DLL) >= MAXPATHLEN) { |
|
6535
77ffd0e75bfb
6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents:
6522
diff
changeset
|
280 |
JLI_ReportErrorMessage(JRE_ERROR11); |
77ffd0e75bfb
6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents:
6522
diff
changeset
|
281 |
return JNI_FALSE; |
77ffd0e75bfb
6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents:
6522
diff
changeset
|
282 |
} |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
283 |
(void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL); /* Add crt dll */ |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
284 |
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
|
285 |
if (_access(crtpath, 0) == 0) { |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
286 |
if (LoadLibrary(crtpath) == 0) { |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
287 |
JLI_ReportErrorMessage(DLL_ERROR4, crtpath); |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
288 |
return JNI_FALSE; |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
289 |
} |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
290 |
} |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
291 |
} |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
292 |
#endif /* CRT_DLL */ |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
293 |
#endif /* _MSC_VER */ |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
294 |
loaded = 1; |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
295 |
} |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
296 |
return JNI_TRUE; |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
297 |
} |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
298 |
|
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
299 |
|
2 | 300 |
/* |
301 |
* Find path to JRE based on .exe's location or registry settings. |
|
302 |
*/ |
|
303 |
jboolean |
|
304 |
GetJREPath(char *path, jint pathsize) |
|
305 |
{ |
|
306 |
char javadll[MAXPATHLEN]; |
|
307 |
struct stat s; |
|
308 |
||
309 |
if (GetApplicationHome(path, pathsize)) { |
|
310 |
/* Is JRE co-located with the application? */ |
|
6005 | 311 |
JLI_Snprintf(javadll, sizeof(javadll), "%s\\bin\\" JAVA_DLL, path); |
2 | 312 |
if (stat(javadll, &s) == 0) { |
6005 | 313 |
JLI_TraceLauncher("JRE path is %s\n", path); |
314 |
return JNI_TRUE; |
|
2 | 315 |
} |
316 |
||
317 |
/* Does this app ship a private JRE in <apphome>\jre directory? */ |
|
6005 | 318 |
JLI_Snprintf(javadll, sizeof (javadll), "%s\\jre\\bin\\" JAVA_DLL, path); |
2 | 319 |
if (stat(javadll, &s) == 0) { |
320 |
JLI_StrCat(path, "\\jre"); |
|
6005 | 321 |
JLI_TraceLauncher("JRE path is %s\n", path); |
322 |
return JNI_TRUE; |
|
2 | 323 |
} |
324 |
} |
|
325 |
||
326 |
/* Look for a public JRE on this machine. */ |
|
327 |
if (GetPublicJREHome(path, pathsize)) { |
|
6005 | 328 |
JLI_TraceLauncher("JRE path is %s\n", path); |
329 |
return JNI_TRUE; |
|
2 | 330 |
} |
331 |
||
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
332 |
JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); |
2 | 333 |
return JNI_FALSE; |
334 |
||
335 |
} |
|
336 |
||
337 |
/* |
|
338 |
* Given a JRE location and a JVM type, construct what the name the |
|
339 |
* JVM shared library will be. Return true, if such a library |
|
340 |
* exists, false otherwise. |
|
341 |
*/ |
|
342 |
static jboolean |
|
343 |
GetJVMPath(const char *jrepath, const char *jvmtype, |
|
344 |
char *jvmpath, jint jvmpathsize) |
|
345 |
{ |
|
346 |
struct stat s; |
|
347 |
if (JLI_StrChr(jvmtype, '/') || JLI_StrChr(jvmtype, '\\')) { |
|
6005 | 348 |
JLI_Snprintf(jvmpath, jvmpathsize, "%s\\" JVM_DLL, jvmtype); |
2 | 349 |
} else { |
16077 | 350 |
JLI_Snprintf(jvmpath, jvmpathsize, "%s\\bin\\%s\\" JVM_DLL, |
351 |
jrepath, jvmtype); |
|
2 | 352 |
} |
353 |
if (stat(jvmpath, &s) == 0) { |
|
354 |
return JNI_TRUE; |
|
355 |
} else { |
|
356 |
return JNI_FALSE; |
|
357 |
} |
|
358 |
} |
|
359 |
||
360 |
/* |
|
361 |
* Load a jvm from "jvmpath" and initialize the invocation functions. |
|
362 |
*/ |
|
363 |
jboolean |
|
364 |
LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) |
|
365 |
{ |
|
366 |
HINSTANCE handle; |
|
367 |
||
368 |
JLI_TraceLauncher("JVM path is %s\n", jvmpath); |
|
369 |
||
370 |
/* |
|
371 |
* The Microsoft C Runtime Library needs to be loaded first. A copy is |
|
372 |
* assumed to be present in the "JRE path" directory. If it is not found |
|
373 |
* there (or "JRE path" fails to resolve), skip the explicit load and let |
|
374 |
* 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
|
375 |
* |
2 | 376 |
*/ |
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
377 |
LoadMSVCRT(); |
2 | 378 |
|
379 |
/* Load the Java VM DLL */ |
|
380 |
if ((handle = LoadLibrary(jvmpath)) == 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
381 |
JLI_ReportErrorMessage(DLL_ERROR4, (char *)jvmpath); |
2 | 382 |
return JNI_FALSE; |
383 |
} |
|
384 |
||
385 |
/* Now get the function addresses */ |
|
386 |
ifn->CreateJavaVM = |
|
387 |
(void *)GetProcAddress(handle, "JNI_CreateJavaVM"); |
|
388 |
ifn->GetDefaultJavaVMInitArgs = |
|
389 |
(void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs"); |
|
390 |
if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
391 |
JLI_ReportErrorMessage(JNI_ERROR1, (char *)jvmpath); |
2 | 392 |
return JNI_FALSE; |
393 |
} |
|
394 |
||
395 |
return JNI_TRUE; |
|
396 |
} |
|
397 |
||
398 |
/* |
|
399 |
* If app is "c:\foo\bin\javac", then put "c:\foo" into buf. |
|
400 |
*/ |
|
401 |
jboolean |
|
402 |
GetApplicationHome(char *buf, jint bufsize) |
|
403 |
{ |
|
404 |
char *cp; |
|
405 |
GetModuleFileName(0, buf, bufsize); |
|
406 |
*JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */ |
|
407 |
if ((cp = JLI_StrRChr(buf, '\\')) == 0) { |
|
408 |
/* This happens if the application is in a drive root, and |
|
409 |
* there is no bin directory. */ |
|
410 |
buf[0] = '\0'; |
|
411 |
return JNI_FALSE; |
|
412 |
} |
|
413 |
*cp = '\0'; /* remove the bin\ part */ |
|
414 |
return JNI_TRUE; |
|
415 |
} |
|
416 |
||
417 |
/* |
|
418 |
* Helpers to look in the registry for a public JRE. |
|
419 |
*/ |
|
420 |
/* Same for 1.5.0, 1.5.1, 1.5.2 etc. */ |
|
421 |
#define JRE_KEY "Software\\JavaSoft\\Java Runtime Environment" |
|
422 |
||
423 |
static jboolean |
|
424 |
GetStringFromRegistry(HKEY key, const char *name, char *buf, jint bufsize) |
|
425 |
{ |
|
426 |
DWORD type, size; |
|
427 |
||
428 |
if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0 |
|
429 |
&& type == REG_SZ |
|
430 |
&& (size < (unsigned int)bufsize)) { |
|
431 |
if (RegQueryValueEx(key, name, 0, 0, buf, &size) == 0) { |
|
432 |
return JNI_TRUE; |
|
433 |
} |
|
434 |
} |
|
435 |
return JNI_FALSE; |
|
436 |
} |
|
437 |
||
438 |
static jboolean |
|
439 |
GetPublicJREHome(char *buf, jint bufsize) |
|
440 |
{ |
|
441 |
HKEY key, subkey; |
|
442 |
char version[MAXPATHLEN]; |
|
443 |
||
444 |
/* |
|
445 |
* Note: There is a very similar implementation of the following |
|
446 |
* registry reading code in the Windows java control panel (javacp.cpl). |
|
447 |
* If there are bugs here, a similar bug probably exists there. Hence, |
|
448 |
* changes here require inspection there. |
|
449 |
*/ |
|
450 |
||
451 |
/* Find the current version of the JRE */ |
|
452 |
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) != 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
453 |
JLI_ReportErrorMessage(REG_ERROR1, JRE_KEY); |
2 | 454 |
return JNI_FALSE; |
455 |
} |
|
456 |
||
457 |
if (!GetStringFromRegistry(key, "CurrentVersion", |
|
458 |
version, sizeof(version))) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
459 |
JLI_ReportErrorMessage(REG_ERROR2, JRE_KEY); |
2 | 460 |
RegCloseKey(key); |
461 |
return JNI_FALSE; |
|
462 |
} |
|
463 |
||
464 |
if (JLI_StrCmp(version, GetDotVersion()) != 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
465 |
JLI_ReportErrorMessage(REG_ERROR3, JRE_KEY, version, GetDotVersion() |
2 | 466 |
); |
467 |
RegCloseKey(key); |
|
468 |
return JNI_FALSE; |
|
469 |
} |
|
470 |
||
471 |
/* Find directory where the current version is installed. */ |
|
472 |
if (RegOpenKeyEx(key, version, 0, KEY_READ, &subkey) != 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
473 |
JLI_ReportErrorMessage(REG_ERROR1, JRE_KEY, version); |
2 | 474 |
RegCloseKey(key); |
475 |
return JNI_FALSE; |
|
476 |
} |
|
477 |
||
478 |
if (!GetStringFromRegistry(subkey, "JavaHome", buf, bufsize)) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
479 |
JLI_ReportErrorMessage(REG_ERROR4, JRE_KEY, version); |
2 | 480 |
RegCloseKey(key); |
481 |
RegCloseKey(subkey); |
|
482 |
return JNI_FALSE; |
|
483 |
} |
|
484 |
||
485 |
if (JLI_IsTraceLauncher()) { |
|
486 |
char micro[MAXPATHLEN]; |
|
487 |
if (!GetStringFromRegistry(subkey, "MicroVersion", micro, |
|
488 |
sizeof(micro))) { |
|
489 |
printf("Warning: Can't read MicroVersion\n"); |
|
490 |
micro[0] = '\0'; |
|
491 |
} |
|
492 |
printf("Version major.minor.micro = %s.%s\n", version, micro); |
|
493 |
} |
|
494 |
||
495 |
RegCloseKey(key); |
|
496 |
RegCloseKey(subkey); |
|
497 |
return JNI_TRUE; |
|
498 |
} |
|
499 |
||
500 |
/* |
|
501 |
* Support for doing cheap, accurate interval timing. |
|
502 |
*/ |
|
503 |
static jboolean counterAvailable = JNI_FALSE; |
|
504 |
static jboolean counterInitialized = JNI_FALSE; |
|
505 |
static LARGE_INTEGER counterFrequency; |
|
506 |
||
507 |
jlong CounterGet() |
|
508 |
{ |
|
509 |
LARGE_INTEGER count; |
|
510 |
||
511 |
if (!counterInitialized) { |
|
512 |
counterAvailable = QueryPerformanceFrequency(&counterFrequency); |
|
513 |
counterInitialized = JNI_TRUE; |
|
514 |
} |
|
515 |
if (!counterAvailable) { |
|
516 |
return 0; |
|
517 |
} |
|
518 |
QueryPerformanceCounter(&count); |
|
519 |
return (jlong)(count.QuadPart); |
|
520 |
} |
|
521 |
||
522 |
jlong Counter2Micros(jlong counts) |
|
523 |
{ |
|
524 |
if (!counterAvailable || !counterInitialized) { |
|
525 |
return 0; |
|
526 |
} |
|
527 |
return (counts * 1000 * 1000)/counterFrequency.QuadPart; |
|
528 |
} |
|
16077 | 529 |
/* |
530 |
* windows snprintf does not guarantee a null terminator in the buffer, |
|
531 |
* 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
|
532 |
* 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
|
533 |
* 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
|
534 |
* 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
|
535 |
* 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
|
536 |
* 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
|
537 |
* ensure storage for the null terminator. |
16077 | 538 |
*/ |
16091
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
539 |
int |
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
540 |
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
|
541 |
int rc; |
16077 | 542 |
va_list vl; |
16091
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
543 |
if (size == 0 || buffer == NULL) |
16077 | 544 |
return -1; |
16091
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
545 |
buffer[0] = '\0'; |
16077 | 546 |
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
|
547 |
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
|
548 |
va_end(vl); |
16077 | 549 |
/* 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
|
550 |
if (rc < 0) { |
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
551 |
/* apply ansi semantics */ |
16077 | 552 |
buffer[size - 1] = '\0'; |
16091
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
553 |
return size; |
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
554 |
} else if (rc == size) { |
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
555 |
/* force a null terminator */ |
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
556 |
buffer[size - 1] = '\0'; |
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
557 |
} |
16077 | 558 |
return rc; |
559 |
} |
|
560 |
||
2 | 561 |
void |
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
562 |
JLI_ReportErrorMessage(const char* fmt, ...) { |
2 | 563 |
va_list vl; |
564 |
va_start(vl,fmt); |
|
565 |
||
566 |
if (IsJavaw()) { |
|
567 |
char *message; |
|
568 |
||
569 |
/* get the length of the string we need */ |
|
570 |
int n = _vscprintf(fmt, vl); |
|
571 |
||
572 |
message = (char *)JLI_MemAlloc(n + 1); |
|
573 |
_vsnprintf(message, n, fmt, vl); |
|
574 |
message[n]='\0'; |
|
575 |
MessageBox(NULL, message, "Java Virtual Machine Launcher", |
|
576 |
(MB_OK|MB_ICONSTOP|MB_APPLMODAL)); |
|
577 |
JLI_MemFree(message); |
|
578 |
} else { |
|
579 |
vfprintf(stderr, fmt, vl); |
|
580 |
fprintf(stderr, "\n"); |
|
581 |
} |
|
582 |
va_end(vl); |
|
583 |
} |
|
584 |
||
585 |
/* |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
586 |
* Just like JLI_ReportErrorMessage, except that it concatenates the system |
2 | 587 |
* error message if any, its upto the calling routine to correctly |
588 |
* format the separation of the messages. |
|
589 |
*/ |
|
590 |
void |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
591 |
JLI_ReportErrorMessageSys(const char *fmt, ...) |
2 | 592 |
{ |
593 |
va_list vl; |
|
594 |
||
595 |
int save_errno = errno; |
|
596 |
DWORD errval; |
|
597 |
jboolean freeit = JNI_FALSE; |
|
598 |
char *errtext = NULL; |
|
599 |
||
600 |
va_start(vl, fmt); |
|
601 |
||
602 |
if ((errval = GetLastError()) != 0) { /* Platform SDK / DOS Error */ |
|
603 |
int n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM| |
|
604 |
FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_ALLOCATE_BUFFER, |
|
605 |
NULL, errval, 0, (LPTSTR)&errtext, 0, NULL); |
|
606 |
if (errtext == NULL || n == 0) { /* Paranoia check */ |
|
607 |
errtext = ""; |
|
608 |
n = 0; |
|
609 |
} else { |
|
610 |
freeit = JNI_TRUE; |
|
611 |
if (n > 2) { /* Drop final CR, LF */ |
|
612 |
if (errtext[n - 1] == '\n') n--; |
|
613 |
if (errtext[n - 1] == '\r') n--; |
|
614 |
errtext[n] = '\0'; |
|
615 |
} |
|
616 |
} |
|
617 |
} else { /* C runtime error that has no corresponding DOS error code */ |
|
618 |
errtext = strerror(save_errno); |
|
619 |
} |
|
620 |
||
621 |
if (IsJavaw()) { |
|
622 |
char *message; |
|
623 |
int mlen; |
|
624 |
/* get the length of the string we need */ |
|
625 |
int len = mlen = _vscprintf(fmt, vl) + 1; |
|
626 |
if (freeit) { |
|
7028
adadd244f506
6989469: (launcher) compiler warnings in jli native code
ksrini
parents:
6535
diff
changeset
|
627 |
mlen += (int)JLI_StrLen(errtext); |
2 | 628 |
} |
629 |
||
630 |
message = (char *)JLI_MemAlloc(mlen); |
|
631 |
_vsnprintf(message, len, fmt, vl); |
|
632 |
message[len]='\0'; |
|
633 |
||
634 |
if (freeit) { |
|
635 |
JLI_StrCat(message, errtext); |
|
636 |
} |
|
637 |
||
638 |
MessageBox(NULL, message, "Java Virtual Machine Launcher", |
|
639 |
(MB_OK|MB_ICONSTOP|MB_APPLMODAL)); |
|
640 |
||
641 |
JLI_MemFree(message); |
|
642 |
} else { |
|
643 |
vfprintf(stderr, fmt, vl); |
|
644 |
if (freeit) { |
|
645 |
fprintf(stderr, "%s", errtext); |
|
646 |
} |
|
647 |
} |
|
648 |
if (freeit) { |
|
649 |
(void)LocalFree((HLOCAL)errtext); |
|
650 |
} |
|
651 |
va_end(vl); |
|
652 |
} |
|
653 |
||
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
654 |
void JLI_ReportExceptionDescription(JNIEnv * env) { |
2 | 655 |
if (IsJavaw()) { |
656 |
/* |
|
657 |
* This code should be replaced by code which opens a window with |
|
658 |
* the exception detail message, for now atleast put a dialog up. |
|
659 |
*/ |
|
660 |
MessageBox(NULL, "A Java Exception has occurred.", "Java Virtual Machine Launcher", |
|
661 |
(MB_OK|MB_ICONSTOP|MB_APPLMODAL)); |
|
662 |
} else { |
|
663 |
(*env)->ExceptionDescribe(env); |
|
664 |
} |
|
665 |
} |
|
666 |
||
667 |
jboolean |
|
668 |
ServerClassMachine() { |
|
669 |
return (GetErgoPolicy() == ALWAYS_SERVER_CLASS) ? JNI_TRUE : JNI_FALSE; |
|
670 |
} |
|
671 |
||
672 |
/* |
|
673 |
* Determine if there is an acceptable JRE in the registry directory top_key. |
|
674 |
* Upon locating the "best" one, return a fully qualified path to it. |
|
675 |
* "Best" is defined as the most advanced JRE meeting the constraints |
|
676 |
* contained in the manifest_info. If no JRE in this directory meets the |
|
677 |
* constraints, return NULL. |
|
678 |
* |
|
679 |
* It doesn't matter if we get an error reading the registry, or we just |
|
680 |
* don't find anything interesting in the directory. We just return NULL |
|
681 |
* in either case. |
|
682 |
*/ |
|
683 |
static char * |
|
684 |
ProcessDir(manifest_info* info, HKEY top_key) { |
|
685 |
DWORD index = 0; |
|
686 |
HKEY ver_key; |
|
687 |
char name[MAXNAMELEN]; |
|
688 |
int len; |
|
689 |
char *best = NULL; |
|
690 |
||
691 |
/* |
|
692 |
* Enumerate "<top_key>/SOFTWARE/JavaSoft/Java Runtime Environment" |
|
693 |
* searching for the best available version. |
|
694 |
*/ |
|
695 |
while (RegEnumKey(top_key, index, name, MAXNAMELEN) == ERROR_SUCCESS) { |
|
696 |
index++; |
|
697 |
if (JLI_AcceptableRelease(name, info->jre_version)) |
|
698 |
if ((best == NULL) || (JLI_ExactVersionId(name, best) > 0)) { |
|
699 |
if (best != NULL) |
|
700 |
JLI_MemFree(best); |
|
701 |
best = JLI_StringDup(name); |
|
702 |
} |
|
703 |
} |
|
704 |
||
705 |
/* |
|
706 |
* Extract "JavaHome" from the "best" registry directory and return |
|
707 |
* that path. If no appropriate version was located, or there is an |
|
708 |
* error in extracting the "JavaHome" string, return null. |
|
709 |
*/ |
|
710 |
if (best == NULL) |
|
711 |
return (NULL); |
|
712 |
else { |
|
713 |
if (RegOpenKeyEx(top_key, best, 0, KEY_READ, &ver_key) |
|
714 |
!= ERROR_SUCCESS) { |
|
715 |
JLI_MemFree(best); |
|
716 |
if (ver_key != NULL) |
|
717 |
RegCloseKey(ver_key); |
|
718 |
return (NULL); |
|
719 |
} |
|
720 |
JLI_MemFree(best); |
|
721 |
len = MAXNAMELEN; |
|
722 |
if (RegQueryValueEx(ver_key, "JavaHome", NULL, NULL, (LPBYTE)name, &len) |
|
723 |
!= ERROR_SUCCESS) { |
|
724 |
if (ver_key != NULL) |
|
725 |
RegCloseKey(ver_key); |
|
726 |
return (NULL); |
|
727 |
} |
|
728 |
if (ver_key != NULL) |
|
729 |
RegCloseKey(ver_key); |
|
730 |
return (JLI_StringDup(name)); |
|
731 |
} |
|
732 |
} |
|
733 |
||
734 |
/* |
|
735 |
* This is the global entry point. It examines the host for the optimal |
|
736 |
* JRE to be used by scanning a set of registry entries. This set of entries |
|
737 |
* is hardwired on Windows as "Software\JavaSoft\Java Runtime Environment" |
|
738 |
* under the set of roots "{ HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }". |
|
739 |
* |
|
740 |
* This routine simply opens each of these registry directories before passing |
|
741 |
* control onto ProcessDir(). |
|
742 |
*/ |
|
743 |
char * |
|
744 |
LocateJRE(manifest_info* info) { |
|
745 |
HKEY key = NULL; |
|
746 |
char *path; |
|
747 |
int key_index; |
|
748 |
HKEY root_keys[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }; |
|
749 |
||
750 |
for (key_index = 0; key_index <= 1; key_index++) { |
|
751 |
if (RegOpenKeyEx(root_keys[key_index], JRE_KEY, 0, KEY_READ, &key) |
|
752 |
== ERROR_SUCCESS) |
|
753 |
if ((path = ProcessDir(info, key)) != NULL) { |
|
754 |
if (key != NULL) |
|
755 |
RegCloseKey(key); |
|
756 |
return (path); |
|
757 |
} |
|
758 |
if (key != NULL) |
|
759 |
RegCloseKey(key); |
|
760 |
} |
|
761 |
return NULL; |
|
762 |
} |
|
763 |
||
764 |
/* |
|
765 |
* Local helper routine to isolate a single token (option or argument) |
|
766 |
* from the command line. |
|
767 |
* |
|
768 |
* This routine accepts a pointer to a character pointer. The first |
|
769 |
* token (as defined by MSDN command-line argument syntax) is isolated |
|
770 |
* from that string. |
|
771 |
* |
|
772 |
* Upon return, the input character pointer pointed to by the parameter s |
|
773 |
* is updated to point to the remainding, unscanned, portion of the string, |
|
774 |
* or to a null character if the entire string has been consummed. |
|
775 |
* |
|
776 |
* This function returns a pointer to a null-terminated string which |
|
777 |
* contains the isolated first token, or to the null character if no |
|
778 |
* token could be isolated. |
|
779 |
* |
|
780 |
* Note the side effect of modifying the input string s by the insertion |
|
781 |
* of a null character, making it two strings. |
|
782 |
* |
|
783 |
* See "Parsing C Command-Line Arguments" in the MSDN Library for the |
|
784 |
* parsing rule details. The rule summary from that specification is: |
|
785 |
* |
|
786 |
* * Arguments are delimited by white space, which is either a space or a tab. |
|
787 |
* |
|
788 |
* * A string surrounded by double quotation marks is interpreted as a single |
|
789 |
* argument, regardless of white space contained within. A quoted string can |
|
790 |
* be embedded in an argument. Note that the caret (^) is not recognized as |
|
791 |
* an escape character or delimiter. |
|
792 |
* |
|
793 |
* * A double quotation mark preceded by a backslash, \", is interpreted as a |
|
794 |
* literal double quotation mark ("). |
|
795 |
* |
|
796 |
* * Backslashes are interpreted literally, unless they immediately precede a |
|
797 |
* double quotation mark. |
|
798 |
* |
|
799 |
* * If an even number of backslashes is followed by a double quotation mark, |
|
800 |
* then one backslash (\) is placed in the argv array for every pair of |
|
801 |
* backslashes (\\), and the double quotation mark (") is interpreted as a |
|
802 |
* string delimiter. |
|
803 |
* |
|
804 |
* * If an odd number of backslashes is followed by a double quotation mark, |
|
805 |
* then one backslash (\) is placed in the argv array for every pair of |
|
806 |
* backslashes (\\) and the double quotation mark is interpreted as an |
|
807 |
* escape sequence by the remaining backslash, causing a literal double |
|
808 |
* quotation mark (") to be placed in argv. |
|
809 |
*/ |
|
810 |
static char* |
|
811 |
nextarg(char** s) { |
|
812 |
char *p = *s; |
|
813 |
char *head; |
|
814 |
int slashes = 0; |
|
815 |
int inquote = 0; |
|
816 |
||
817 |
/* |
|
818 |
* Strip leading whitespace, which MSDN defines as only space or tab. |
|
819 |
* (Hence, no locale specific "isspace" here.) |
|
820 |
*/ |
|
821 |
while (*p != (char)0 && (*p == ' ' || *p == '\t')) |
|
822 |
p++; |
|
823 |
head = p; /* Save the start of the token to return */ |
|
824 |
||
825 |
/* |
|
826 |
* Isolate a token from the command line. |
|
827 |
*/ |
|
828 |
while (*p != (char)0 && (inquote || !(*p == ' ' || *p == '\t'))) { |
|
829 |
if (*p == '\\' && *(p+1) == '"' && slashes % 2 == 0) |
|
830 |
p++; |
|
831 |
else if (*p == '"') |
|
832 |
inquote = !inquote; |
|
833 |
slashes = (*p++ == '\\') ? slashes + 1 : 0; |
|
834 |
} |
|
835 |
||
836 |
/* |
|
837 |
* If the token isolated isn't already terminated in a "char zero", |
|
838 |
* then replace the whitespace character with one and move to the |
|
839 |
* next character. |
|
840 |
*/ |
|
841 |
if (*p != (char)0) |
|
842 |
*p++ = (char)0; |
|
843 |
||
844 |
/* |
|
845 |
* Update the parameter to point to the head of the remaining string |
|
846 |
* reflecting the command line and return a pointer to the leading |
|
847 |
* token which was isolated from the command line. |
|
848 |
*/ |
|
849 |
*s = p; |
|
850 |
return (head); |
|
851 |
} |
|
852 |
||
853 |
/* |
|
854 |
* Local helper routine to return a string equivalent to the input string |
|
855 |
* s, but with quotes removed so the result is a string as would be found |
|
856 |
* in argv[]. The returned string should be freed by a call to JLI_MemFree(). |
|
857 |
* |
|
858 |
* The rules for quoting (and escaped quotes) are: |
|
859 |
* |
|
860 |
* 1 A double quotation mark preceded by a backslash, \", is interpreted as a |
|
861 |
* literal double quotation mark ("). |
|
862 |
* |
|
863 |
* 2 Backslashes are interpreted literally, unless they immediately precede a |
|
864 |
* double quotation mark. |
|
865 |
* |
|
866 |
* 3 If an even number of backslashes is followed by a double quotation mark, |
|
867 |
* then one backslash (\) is placed in the argv array for every pair of |
|
868 |
* backslashes (\\), and the double quotation mark (") is interpreted as a |
|
869 |
* string delimiter. |
|
870 |
* |
|
871 |
* 4 If an odd number of backslashes is followed by a double quotation mark, |
|
872 |
* then one backslash (\) is placed in the argv array for every pair of |
|
873 |
* backslashes (\\) and the double quotation mark is interpreted as an |
|
874 |
* escape sequence by the remaining backslash, causing a literal double |
|
875 |
* quotation mark (") to be placed in argv. |
|
876 |
*/ |
|
877 |
static char* |
|
878 |
unquote(const char *s) { |
|
879 |
const char *p = s; /* Pointer to the tail of the original string */ |
|
880 |
char *un = (char*)JLI_MemAlloc(JLI_StrLen(s) + 1); /* Ptr to unquoted string */ |
|
881 |
char *pun = un; /* Pointer to the tail of the unquoted string */ |
|
882 |
||
883 |
while (*p != '\0') { |
|
884 |
if (*p == '"') { |
|
885 |
p++; |
|
886 |
} else if (*p == '\\') { |
|
887 |
const char *q = p + JLI_StrSpn(p,"\\"); |
|
888 |
if (*q == '"') |
|
889 |
do { |
|
890 |
*pun++ = '\\'; |
|
891 |
p += 2; |
|
892 |
} while (*p == '\\' && p < q); |
|
893 |
else |
|
894 |
while (p < q) |
|
895 |
*pun++ = *p++; |
|
896 |
} else { |
|
897 |
*pun++ = *p++; |
|
898 |
} |
|
899 |
} |
|
900 |
*pun = '\0'; |
|
901 |
return un; |
|
902 |
} |
|
903 |
||
904 |
/* |
|
905 |
* Given a path to a jre to execute, this routine checks if this process |
|
906 |
* is indeed that jre. If not, it exec's that jre. |
|
907 |
* |
|
908 |
* We want to actually check the paths rather than just the version string |
|
909 |
* built into the executable, so that given version specification will yield |
|
910 |
* the exact same Java environment, regardless of the version of the arbitrary |
|
911 |
* launcher we start with. |
|
912 |
*/ |
|
913 |
void |
|
914 |
ExecJRE(char *jre, char **argv) { |
|
16077 | 915 |
jint len; |
2 | 916 |
char path[MAXPATHLEN + 1]; |
917 |
||
918 |
const char *progname = GetProgramName(); |
|
919 |
||
920 |
/* |
|
921 |
* Resolve the real path to the currently running launcher. |
|
922 |
*/ |
|
923 |
len = GetModuleFileName(NULL, path, MAXPATHLEN + 1); |
|
924 |
if (len == 0 || len > MAXPATHLEN) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
925 |
JLI_ReportErrorMessageSys(JRE_ERROR9, progname); |
2 | 926 |
exit(1); |
927 |
} |
|
928 |
||
929 |
JLI_TraceLauncher("ExecJRE: old: %s\n", path); |
|
930 |
JLI_TraceLauncher("ExecJRE: new: %s\n", jre); |
|
931 |
||
932 |
/* |
|
933 |
* If the path to the selected JRE directory is a match to the initial |
|
934 |
* portion of the path to the currently executing JRE, we have a winner! |
|
935 |
* If so, just return. |
|
936 |
*/ |
|
937 |
if (JLI_StrNCaseCmp(jre, path, JLI_StrLen(jre)) == 0) |
|
938 |
return; /* I am the droid you were looking for */ |
|
939 |
||
940 |
/* |
|
941 |
* If this isn't the selected version, exec the selected version. |
|
942 |
*/ |
|
6535
77ffd0e75bfb
6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents:
6522
diff
changeset
|
943 |
JLI_Snprintf(path, sizeof(path), "%s\\bin\\%s.exe", jre, progname); |
2 | 944 |
|
945 |
/* |
|
946 |
* Although Windows has an execv() entrypoint, it doesn't actually |
|
947 |
* overlay a process: it can only create a new process and terminate |
|
948 |
* the old process. Therefore, any processes waiting on the initial |
|
949 |
* process wake up and they shouldn't. Hence, a chain of pseudo-zombie |
|
950 |
* processes must be retained to maintain the proper wait semantics. |
|
951 |
* Fortunately the image size of the launcher isn't too large at this |
|
952 |
* time. |
|
953 |
* |
|
954 |
* If it weren't for this semantic flaw, the code below would be ... |
|
955 |
* |
|
956 |
* execv(path, argv); |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
957 |
* JLI_ReportErrorMessage("Error: Exec of %s failed\n", path); |
2 | 958 |
* exit(1); |
959 |
* |
|
960 |
* The incorrect exec semantics could be addressed by: |
|
961 |
* |
|
962 |
* exit((int)spawnv(_P_WAIT, path, argv)); |
|
963 |
* |
|
964 |
* Unfortunately, a bug in Windows spawn/exec impementation prevents |
|
965 |
* this from completely working. All the Windows POSIX process creation |
|
966 |
* interfaces are implemented as wrappers around the native Windows |
|
967 |
* function CreateProcess(). CreateProcess() takes a single string |
|
968 |
* to specify command line options and arguments, so the POSIX routine |
|
969 |
* wrappers build a single string from the argv[] array and in the |
|
970 |
* process, any quoting information is lost. |
|
971 |
* |
|
972 |
* The solution to this to get the original command line, to process it |
|
973 |
* to remove the new multiple JRE options (if any) as was done for argv |
|
974 |
* in the common SelectVersion() routine and finally to pass it directly |
|
975 |
* to the native CreateProcess() Windows process control interface. |
|
976 |
*/ |
|
977 |
{ |
|
978 |
char *cmdline; |
|
979 |
char *p; |
|
980 |
char *np; |
|
981 |
char *ocl; |
|
982 |
char *ccl; |
|
983 |
char *unquoted; |
|
984 |
DWORD exitCode; |
|
985 |
STARTUPINFO si; |
|
986 |
PROCESS_INFORMATION pi; |
|
987 |
||
988 |
/* |
|
989 |
* The following code block gets and processes the original command |
|
990 |
* line, replacing the argv[0] equivalent in the command line with |
|
991 |
* the path to the new executable and removing the appropriate |
|
992 |
* Multiple JRE support options. Note that similar logic exists |
|
993 |
* in the platform independent SelectVersion routine, but is |
|
994 |
* replicated here due to the syntax of CreateProcess(). |
|
995 |
* |
|
996 |
* The magic "+ 4" characters added to the command line length are |
|
997 |
* 2 possible quotes around the path (argv[0]), a space after the |
|
998 |
* path and a terminating null character. |
|
999 |
*/ |
|
1000 |
ocl = GetCommandLine(); |
|
1001 |
np = ccl = JLI_StringDup(ocl); |
|
1002 |
p = nextarg(&np); /* Discard argv[0] */ |
|
1003 |
cmdline = (char *)JLI_MemAlloc(JLI_StrLen(path) + JLI_StrLen(np) + 4); |
|
1004 |
if (JLI_StrChr(path, (int)' ') == NULL && JLI_StrChr(path, (int)'\t') == NULL) |
|
1005 |
cmdline = JLI_StrCpy(cmdline, path); |
|
1006 |
else |
|
1007 |
cmdline = JLI_StrCat(JLI_StrCat(JLI_StrCpy(cmdline, "\""), path), "\""); |
|
1008 |
||
1009 |
while (*np != (char)0) { /* While more command-line */ |
|
1010 |
p = nextarg(&np); |
|
1011 |
if (*p != (char)0) { /* If a token was isolated */ |
|
1012 |
unquoted = unquote(p); |
|
1013 |
if (*unquoted == '-') { /* Looks like an option */ |
|
1014 |
if (JLI_StrCmp(unquoted, "-classpath") == 0 || |
|
1015 |
JLI_StrCmp(unquoted, "-cp") == 0) { /* Unique cp syntax */ |
|
1016 |
cmdline = JLI_StrCat(JLI_StrCat(cmdline, " "), p); |
|
1017 |
p = nextarg(&np); |
|
1018 |
if (*p != (char)0) /* If a token was isolated */ |
|
1019 |
cmdline = JLI_StrCat(JLI_StrCat(cmdline, " "), p); |
|
1020 |
} else if (JLI_StrNCmp(unquoted, "-version:", 9) != 0 && |
|
1021 |
JLI_StrCmp(unquoted, "-jre-restrict-search") != 0 && |
|
1022 |
JLI_StrCmp(unquoted, "-no-jre-restrict-search") != 0) { |
|
1023 |
cmdline = JLI_StrCat(JLI_StrCat(cmdline, " "), p); |
|
1024 |
} |
|
1025 |
} else { /* End of options */ |
|
1026 |
cmdline = JLI_StrCat(JLI_StrCat(cmdline, " "), p); |
|
1027 |
cmdline = JLI_StrCat(JLI_StrCat(cmdline, " "), np); |
|
1028 |
JLI_MemFree((void *)unquoted); |
|
1029 |
break; |
|
1030 |
} |
|
1031 |
JLI_MemFree((void *)unquoted); |
|
1032 |
} |
|
1033 |
} |
|
1034 |
JLI_MemFree((void *)ccl); |
|
1035 |
||
1036 |
if (JLI_IsTraceLauncher()) { |
|
1037 |
np = ccl = JLI_StringDup(cmdline); |
|
1038 |
p = nextarg(&np); |
|
1039 |
printf("ReExec Command: %s (%s)\n", path, p); |
|
1040 |
printf("ReExec Args: %s\n", np); |
|
1041 |
JLI_MemFree((void *)ccl); |
|
1042 |
} |
|
1043 |
(void)fflush(stdout); |
|
1044 |
(void)fflush(stderr); |
|
1045 |
||
1046 |
/* |
|
1047 |
* The following code is modeled after a model presented in the |
|
1048 |
* Microsoft Technical Article "Moving Unix Applications to |
|
1049 |
* Windows NT" (March 6, 1994) and "Creating Processes" on MSDN |
|
1050 |
* (Februrary 2005). It approximates UNIX spawn semantics with |
|
1051 |
* the parent waiting for termination of the child. |
|
1052 |
*/ |
|
1053 |
memset(&si, 0, sizeof(si)); |
|
1054 |
si.cb =sizeof(STARTUPINFO); |
|
1055 |
memset(&pi, 0, sizeof(pi)); |
|
1056 |
||
1057 |
if (!CreateProcess((LPCTSTR)path, /* executable name */ |
|
1058 |
(LPTSTR)cmdline, /* command line */ |
|
1059 |
(LPSECURITY_ATTRIBUTES)NULL, /* process security attr. */ |
|
1060 |
(LPSECURITY_ATTRIBUTES)NULL, /* thread security attr. */ |
|
1061 |
(BOOL)TRUE, /* inherits system handles */ |
|
1062 |
(DWORD)0, /* creation flags */ |
|
1063 |
(LPVOID)NULL, /* environment block */ |
|
1064 |
(LPCTSTR)NULL, /* current directory */ |
|
1065 |
(LPSTARTUPINFO)&si, /* (in) startup information */ |
|
1066 |
(LPPROCESS_INFORMATION)&pi)) { /* (out) process information */ |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
1067 |
JLI_ReportErrorMessageSys(SYS_ERROR1, path); |
2 | 1068 |
exit(1); |
1069 |
} |
|
1070 |
||
1071 |
if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_FAILED) { |
|
1072 |
if (GetExitCodeProcess(pi.hProcess, &exitCode) == FALSE) |
|
1073 |
exitCode = 1; |
|
1074 |
} else { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
715
diff
changeset
|
1075 |
JLI_ReportErrorMessage(SYS_ERROR2); |
2 | 1076 |
exitCode = 1; |
1077 |
} |
|
1078 |
||
1079 |
CloseHandle(pi.hThread); |
|
1080 |
CloseHandle(pi.hProcess); |
|
1081 |
||
1082 |
exit(exitCode); |
|
1083 |
} |
|
1084 |
} |
|
1085 |
||
1086 |
/* |
|
1087 |
* Wrapper for platform dependent unsetenv function. |
|
1088 |
*/ |
|
1089 |
int |
|
1090 |
UnsetEnv(char *name) |
|
1091 |
{ |
|
1092 |
int ret; |
|
1093 |
char *buf = JLI_MemAlloc(JLI_StrLen(name) + 2); |
|
1094 |
buf = JLI_StrCat(JLI_StrCpy(buf, name), "="); |
|
1095 |
ret = _putenv(buf); |
|
1096 |
JLI_MemFree(buf); |
|
1097 |
return (ret); |
|
1098 |
} |
|
1099 |
||
1100 |
/* --- Splash Screen shared library support --- */ |
|
1101 |
||
1102 |
static const char* SPLASHSCREEN_SO = "\\bin\\splashscreen.dll"; |
|
1103 |
||
1104 |
static HMODULE hSplashLib = NULL; |
|
1105 |
||
1106 |
void* SplashProcAddress(const char* name) { |
|
1107 |
char libraryPath[MAXPATHLEN]; /* some extra space for JLI_StrCat'ing SPLASHSCREEN_SO */ |
|
1108 |
||
1109 |
if (!GetJREPath(libraryPath, MAXPATHLEN)) { |
|
1110 |
return NULL; |
|
1111 |
} |
|
1112 |
if (JLI_StrLen(libraryPath)+JLI_StrLen(SPLASHSCREEN_SO) >= MAXPATHLEN) { |
|
1113 |
return NULL; |
|
1114 |
} |
|
1115 |
JLI_StrCat(libraryPath, SPLASHSCREEN_SO); |
|
1116 |
||
1117 |
if (!hSplashLib) { |
|
1118 |
hSplashLib = LoadLibrary(libraryPath); |
|
1119 |
} |
|
1120 |
if (hSplashLib) { |
|
1121 |
return GetProcAddress(hSplashLib, name); |
|
1122 |
} else { |
|
1123 |
return NULL; |
|
1124 |
} |
|
1125 |
} |
|
1126 |
||
1127 |
void SplashFreeLibrary() { |
|
1128 |
if (hSplashLib) { |
|
1129 |
FreeLibrary(hSplashLib); |
|
1130 |
hSplashLib = NULL; |
|
1131 |
} |
|
1132 |
} |
|
1133 |
||
1134 |
const char * |
|
1135 |
jlong_format_specifier() { |
|
1136 |
return "%I64d"; |
|
1137 |
} |
|
1138 |
||
1139 |
/* |
|
1140 |
* Block current thread and continue execution in a new thread |
|
1141 |
*/ |
|
1142 |
int |
|
1143 |
ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) { |
|
1144 |
int rslt = 0; |
|
1145 |
unsigned thread_id; |
|
1146 |
||
1147 |
#ifndef STACK_SIZE_PARAM_IS_A_RESERVATION |
|
1148 |
#define STACK_SIZE_PARAM_IS_A_RESERVATION (0x10000) |
|
1149 |
#endif |
|
1150 |
||
1151 |
/* |
|
1152 |
* STACK_SIZE_PARAM_IS_A_RESERVATION is what we want, but it's not |
|
1153 |
* supported on older version of Windows. Try first with the flag; and |
|
1154 |
* if that fails try again without the flag. See MSDN document or HotSpot |
|
1155 |
* source (os_win32.cpp) for details. |
|
1156 |
*/ |
|
1157 |
HANDLE thread_handle = |
|
1158 |
(HANDLE)_beginthreadex(NULL, |
|
1159 |
(unsigned)stack_size, |
|
1160 |
continuation, |
|
1161 |
args, |
|
1162 |
STACK_SIZE_PARAM_IS_A_RESERVATION, |
|
1163 |
&thread_id); |
|
1164 |
if (thread_handle == NULL) { |
|
1165 |
thread_handle = |
|
1166 |
(HANDLE)_beginthreadex(NULL, |
|
1167 |
(unsigned)stack_size, |
|
1168 |
continuation, |
|
1169 |
args, |
|
1170 |
0, |
|
1171 |
&thread_id); |
|
1172 |
} |
|
7004
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1173 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1174 |
/* AWT preloading (AFTER main thread start) */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1175 |
#ifdef ENABLE_AWT_PRELOAD |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1176 |
/* D3D preloading */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1177 |
if (awtPreloadD3D != 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1178 |
char *envValue; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1179 |
/* 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
|
1180 |
* command line params was specified |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1181 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1182 |
envValue = getenv("J2D_D3D"); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1183 |
if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1184 |
awtPreloadD3D = 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1185 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1186 |
/* 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
|
1187 |
envValue = getenv("J2D_D3D_PRELOAD"); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1188 |
if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1189 |
awtPreloadD3D = 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1190 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1191 |
if (awtPreloadD3D < 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1192 |
/* If awtPreloadD3D is still undefined (-1), test |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1193 |
* 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
|
1194 |
* By default it's turned OFF. |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1195 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1196 |
awtPreloadD3D = 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1197 |
if (envValue != NULL && JLI_StrCaseCmp(envValue, "true") == 0) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1198 |
awtPreloadD3D = 1; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1199 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1200 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1201 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1202 |
if (awtPreloadD3D) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1203 |
AWTPreload(D3D_PRELOAD_FUNC); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1204 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1205 |
#endif /* ENABLE_AWT_PRELOAD */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1206 |
|
2 | 1207 |
if (thread_handle) { |
1208 |
WaitForSingleObject(thread_handle, INFINITE); |
|
1209 |
GetExitCodeThread(thread_handle, &rslt); |
|
1210 |
CloseHandle(thread_handle); |
|
1211 |
} else { |
|
1212 |
rslt = continuation(args); |
|
1213 |
} |
|
7004
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1214 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1215 |
#ifdef ENABLE_AWT_PRELOAD |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1216 |
if (awtPreloaded) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1217 |
AWTPreloadStop(); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1218 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1219 |
#endif /* ENABLE_AWT_PRELOAD */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1220 |
|
2 | 1221 |
return rslt; |
1222 |
} |
|
1223 |
||
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1224 |
/* Unix only, empty on windows. */ |
2 | 1225 |
void SetJavaLauncherPlatformProps() {} |
39
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1226 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1227 |
/* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1228 |
* The implementation for finding classes from the bootstrap |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1229 |
* class loader, refer to java.h |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1230 |
*/ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1231 |
static FindClassFromBootLoader_t *findBootClass = NULL; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1232 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1233 |
jclass FindBootStrapClass(JNIEnv *env, const char *classname) |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1234 |
{ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1235 |
HMODULE hJvm; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1236 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1237 |
if (findBootClass == NULL) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1238 |
hJvm = GetModuleHandle(JVM_DLL); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1239 |
if (hJvm == NULL) return NULL; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1240 |
/* need to use the demangled entry point */ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1241 |
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
|
1242 |
"JVM_FindClassFromBootLoader"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1243 |
if (findBootClass == NULL) { |
3834
16342ebd576d
6864028: Update the java launcher to use the new entry point JVM_FindClassFromBootLoader
mchung
parents:
3111
diff
changeset
|
1244 |
JLI_ReportErrorMessage(DLL_ERROR4, "JVM_FindClassFromBootLoader"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1245 |
return NULL; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1246 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1247 |
} |
3834
16342ebd576d
6864028: Update the java launcher to use the new entry point JVM_FindClassFromBootLoader
mchung
parents:
3111
diff
changeset
|
1248 |
return findBootClass(env, classname); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1249 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1250 |
|
39
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1251 |
void |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1252 |
InitLauncher(boolean javaw) |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1253 |
{ |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1254 |
INITCOMMONCONTROLSEX icx; |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1255 |
|
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1256 |
/* |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1257 |
* Required for javaw mode MessageBox output as well as for |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1258 |
* HotSpot -XX:+ShowMessageBoxOnError in java mode, an empty |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1259 |
* flag field is sufficient to perform the basic UI initialization. |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1260 |
*/ |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1261 |
memset(&icx, 0, sizeof(INITCOMMONCONTROLSEX)); |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1262 |
icx.dwSize = sizeof(INITCOMMONCONTROLSEX); |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1263 |
InitCommonControlsEx(&icx); |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1264 |
_isjavaw = javaw; |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1265 |
JLI_SetTraceLauncher(); |
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
1266 |
} |
7004
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1267 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1268 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1269 |
/* ============================== */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1270 |
/* AWT preloading */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1271 |
#ifdef ENABLE_AWT_PRELOAD |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1272 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1273 |
typedef int FnPreloadStart(void); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1274 |
typedef void FnPreloadStop(void); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1275 |
static FnPreloadStop *fnPreloadStop = NULL; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1276 |
static HMODULE hPreloadAwt = NULL; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1277 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1278 |
/* |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1279 |
* Starts AWT preloading |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1280 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1281 |
int AWTPreload(const char *funcName) |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1282 |
{ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1283 |
int result = -1; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1284 |
/* 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
|
1285 |
if (hPreloadAwt == NULL) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1286 |
/* awt.dll is not loaded yet */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1287 |
char libraryPath[MAXPATHLEN]; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1288 |
int jrePathLen = 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1289 |
HMODULE hJava = NULL; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1290 |
HMODULE hVerify = NULL; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1291 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1292 |
while (1) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1293 |
/* awt.dll depends on jvm.dll & java.dll; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1294 |
* 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
|
1295 |
* java.dll depends on MSVCRT lib & verify.dll. |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1296 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1297 |
if (!GetJREPath(libraryPath, MAXPATHLEN)) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1298 |
break; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1299 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1300 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1301 |
/* save path length */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1302 |
jrePathLen = JLI_StrLen(libraryPath); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1303 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1304 |
/* load msvcrt 1st */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1305 |
LoadMSVCRT(); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1306 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1307 |
/* load verify.dll */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1308 |
JLI_StrCat(libraryPath, "\\bin\\verify.dll"); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1309 |
hVerify = LoadLibrary(libraryPath); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1310 |
if (hVerify == NULL) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1311 |
break; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1312 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1313 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1314 |
/* restore jrePath */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1315 |
libraryPath[jrePathLen] = 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1316 |
/* load java.dll */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1317 |
JLI_StrCat(libraryPath, "\\bin\\" JAVA_DLL); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1318 |
hJava = LoadLibrary(libraryPath); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1319 |
if (hJava == NULL) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1320 |
break; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1321 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1322 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1323 |
/* restore jrePath */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1324 |
libraryPath[jrePathLen] = 0; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1325 |
/* load awt.dll */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1326 |
JLI_StrCat(libraryPath, "\\bin\\awt.dll"); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1327 |
hPreloadAwt = LoadLibrary(libraryPath); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1328 |
if (hPreloadAwt == NULL) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1329 |
break; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1330 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1331 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1332 |
/* get "preloadStop" func ptr */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1333 |
fnPreloadStop = (FnPreloadStop *)GetProcAddress(hPreloadAwt, "preloadStop"); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1334 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1335 |
break; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1336 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1337 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1338 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1339 |
if (hPreloadAwt != NULL) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1340 |
FnPreloadStart *fnInit = (FnPreloadStart *)GetProcAddress(hPreloadAwt, funcName); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1341 |
if (fnInit != NULL) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1342 |
/* don't forget to stop preloading */ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1343 |
awtPreloaded = 1; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1344 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1345 |
result = fnInit(); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1346 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1347 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1348 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1349 |
return result; |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1350 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1351 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1352 |
/* |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1353 |
* Terminates AWT preloading |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1354 |
*/ |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1355 |
void AWTPreloadStop() { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1356 |
if (fnPreloadStop != NULL) { |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1357 |
fnPreloadStop(); |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1358 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1359 |
} |
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1360 |
|
3f92ea1ffcac
6867515: Reduce impact of D3D initializion on startup time
amenkov
parents:
6535
diff
changeset
|
1361 |
#endif /* ENABLE_AWT_PRELOAD */ |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1362 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1363 |
int |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1364 |
JVMInit(InvocationFunctions* ifn, jlong threadStackSize, |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1365 |
int argc, char **argv, |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1366 |
int mode, char *what, int ret) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1367 |
{ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1368 |
ShowSplashScreen(); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1369 |
return ContinueInNewThread(ifn, threadStackSize, argc, argv, mode, what, ret); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1370 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1371 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1372 |
void |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1373 |
PostJVMInit(JNIEnv *env, jstring mainClass, JavaVM *vm) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1374 |
{ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1375 |
// stubbed out for windows and *nixes. |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1376 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1377 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1378 |
void |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1379 |
RegisterThread() |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1380 |
{ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1381 |
// stubbed out for windows and *nixes. |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1382 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1383 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1384 |
/* |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1385 |
* 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
|
1386 |
*/ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1387 |
jboolean |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1388 |
ProcessPlatformOption(const char *arg) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1389 |
{ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1390 |
return JNI_FALSE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9842
diff
changeset
|
1391 |
} |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1392 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1393 |
/* |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1394 |
* 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
|
1395 |
* 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
|
1396 |
* needs expansion. cmdtoargs will specify this if it finds a bare |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1397 |
* (unquoted) argument containing a glob character(s) ie. * or ? |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1398 |
*/ |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1399 |
jobjectArray |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1400 |
CreateApplicationArgs(JNIEnv *env, char **strv, int argc) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1401 |
{ |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1402 |
int i, j, idx, tlen; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1403 |
jobjectArray outArray, inArray; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1404 |
char *ostart, *astart, **nargv; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1405 |
jboolean needs_expansion = JNI_FALSE; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1406 |
jmethodID mid; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1407 |
int stdargc; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1408 |
StdArg *stdargs; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1409 |
jclass cls = GetLauncherHelperClass(env); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1410 |
NULL_CHECK0(cls); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1411 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1412 |
if (argc == 0) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1413 |
return NewPlatformStringArray(env, strv, argc); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1414 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1415 |
// the holy grail we need to compare with. |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1416 |
stdargs = JLI_GetStdArgs(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1417 |
stdargc = JLI_GetStdArgc(); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1418 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1419 |
// sanity check, this should never happen |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1420 |
if (argc > stdargc) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1421 |
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
|
1422 |
JLI_TraceLauncher("passing arguments as-is.\n"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1423 |
return NewPlatformStringArray(env, strv, argc); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1424 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1425 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1426 |
// sanity check, match the args we have, to the holy grail |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1427 |
idx = stdargc - argc; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1428 |
ostart = stdargs[idx].arg; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1429 |
astart = strv[0]; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1430 |
// sanity check, ensure that the first argument of the arrays are the same |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1431 |
if (JLI_StrCmp(ostart, astart) != 0) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1432 |
// some thing is amiss the args don't match |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1433 |
JLI_TraceLauncher("Warning: app args parsing error\n"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1434 |
JLI_TraceLauncher("passing arguments as-is\n"); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1435 |
return NewPlatformStringArray(env, strv, argc); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1436 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1437 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1438 |
// 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
|
1439 |
nargv = (char **)JLI_MemAlloc(argc * sizeof(char*)); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1440 |
for (i = 0, j = idx; i < argc; i++, j++) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1441 |
jboolean arg_expand = (JLI_StrCmp(stdargs[j].arg, strv[i]) == 0) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1442 |
? stdargs[j].has_wildcard |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1443 |
: JNI_FALSE; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1444 |
if (needs_expansion == JNI_FALSE) |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1445 |
needs_expansion = arg_expand; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1446 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1447 |
// indicator char + String + NULL terminator, the java method will strip |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1448 |
// out the first character, the indicator character, so no matter what |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1449 |
// we add the indicator |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1450 |
tlen = 1 + JLI_StrLen(strv[i]) + 1; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1451 |
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
|
1452 |
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
|
1453 |
strv[i]) < 0) { |
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
1454 |
return NULL; |
4eb1062acb5b
8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents:
16077
diff
changeset
|
1455 |
} |
13411
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1456 |
JLI_TraceLauncher("%s\n", nargv[i]); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1457 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1458 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1459 |
if (!needs_expansion) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1460 |
// clean up any allocated memory and return back the old arguments |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1461 |
for (i = 0 ; i < argc ; i++) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1462 |
JLI_MemFree(nargv[i]); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1463 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1464 |
JLI_MemFree(nargv); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1465 |
return NewPlatformStringArray(env, strv, argc); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1466 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1467 |
NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1468 |
"expandArgs", |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1469 |
"([Ljava/lang/String;)[Ljava/lang/String;")); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1470 |
|
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1471 |
// expand the arguments that require expansion, the java method will strip |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1472 |
// out the indicator character. |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1473 |
inArray = NewPlatformStringArray(env, nargv, argc); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1474 |
outArray = (*env)->CallStaticObjectMethod(env, cls, mid, inArray); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1475 |
for (i = 0; i < argc; i++) { |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1476 |
JLI_MemFree(nargv[i]); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1477 |
} |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1478 |
JLI_MemFree(nargv); |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1479 |
return outArray; |
224a28370893
7146424: Wildcard expansion for single entry classpath
ksrini
parents:
12047
diff
changeset
|
1480 |
} |