8180334: Unable to build jaotc launcher on windows
Reviewed-by: erikj, ihse, mchung
--- a/jdk/make/launcher/Launcher-jdk.aot.gmk Fri Jun 09 16:26:32 2017 +0100
+++ b/jdk/make/launcher/Launcher-jdk.aot.gmk Fri Jun 09 09:54:59 2017 -0700
@@ -30,7 +30,7 @@
$(eval $(call SetupBuildLauncher, jaotc, \
MAIN_CLASS := jdk.tools.jaotc.Main, \
- JAVA_ARGS := -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI \
+ EXTRA_JAVA_ARGS := -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
@@ -38,12 +38,13 @@
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
- --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ , \
+ JAVA_ARGS := --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.sparc=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
- --add-exports=jdk.internal.vm.ci/jdk.vm.ci.sparc=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.sparc=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
-XX:+UseAOT \
-Djvmci.UseProfilingInformation=false \
-Dgraal.UseExceptionProbability=false \
--- a/jdk/make/launcher/LauncherCommon.gmk Fri Jun 09 16:26:32 2017 +0100
+++ b/jdk/make/launcher/LauncherCommon.gmk Fri Jun 09 09:54:59 2017 -0700
@@ -66,7 +66,10 @@
# MAIN_MODULE The module of the main class to launch if different from the
# current module
# MAIN_CLASS The Java main class to launch
-# JAVA_ARGS Processed into a -DJAVA_ARGS C flag
+# JAVA_ARGS Processed into a -DJAVA_ARGS and added to CFLAGS
+# EXTRA_JAVA_ARGS Processed into a -DEXTRA_JAVA_ARGS and is prepended
+# before JAVA_ARGS to CFLAGS, primarily to allow long string literal
+# compile time defines exceeding Visual Studio 2013 limitations.
# CFLAGS Additional CFLAGS
# CFLAGS_windows Additional CFLAGS_windows
# LIBS_unix Additional LIBS_unix
@@ -104,6 +107,11 @@
endif
ifneq ($$($1_JAVA_ARGS), )
+ ifneq ($$($1_EXTRA_JAVA_ARGS), )
+ $1_EXTRA_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
+ $$(addprefix -J, $$($1_EXTRA_JAVA_ARGS)), "$$a"$(COMMA) )) }'
+ $1_CFLAGS += -DEXTRA_JAVA_ARGS=$$($1_EXTRA_JAVA_ARGS_STR)
+ endif
$1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
$$(addprefix -J, $$($1_JAVA_ARGS)) -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS), "$$a"$(COMMA) )) }'
$1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR)
--- a/jdk/src/java.base/share/native/launcher/defines.h Fri Jun 09 16:26:32 2017 +0100
+++ b/jdk/src/java.base/share/native/launcher/defines.h Fri Jun 09 09:54:59 2017 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,17 +44,24 @@
#define DOT_VERSION "0.0"
#ifdef JAVA_ARGS
-#define HAS_JAVA_ARGS JNI_TRUE
#ifdef PROGNAME
static const char* const_progname = PROGNAME;
#else
static char* const_progname = NULL;
#endif
static const char* const_jargs[] = JAVA_ARGS;
+#ifdef EXTRA_JAVA_ARGS
+static const char* const_extra_jargs[] = EXTRA_JAVA_ARGS;
+#else
+static const char** const_extra_jargs = NULL;
+#endif
#else /* !JAVA_ARGS */
-#define HAS_JAVA_ARGS JNI_FALSE
+#ifdef EXTRA_JAVA_ARGS
+#error "EXTRA_JAVA_ARGS defined without JAVA_ARGS"
+#endif
static const char* const_progname = "java";
static const char** const_jargs = NULL;
+static const char** const_extra_jargs = NULL;
static const char* const_appclasspath[] = { NULL };
#endif /* JAVA_ARGS */
--- a/jdk/src/java.base/share/native/launcher/main.c Fri Jun 09 16:26:32 2017 +0100
+++ b/jdk/src/java.base/share/native/launcher/main.c Fri Jun 09 09:54:59 2017 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -85,6 +85,8 @@
{
int margc;
char** margv;
+ int jargc;
+ char** jargv;
const jboolean const_javaw = JNI_TRUE;
__initenv = _environ;
@@ -95,10 +97,47 @@
{
int margc;
char** margv;
+ int jargc;
+ char** jargv;
const jboolean const_javaw = JNI_FALSE;
#endif /* JAVAW */
+ {
+ int i, main_jargc, extra_jargc;
+ JLI_List list;
- JLI_InitArgProcessing(!HAS_JAVA_ARGS, const_disable_argfile);
+ main_jargc = (sizeof(const_jargs) / sizeof(char *)) > 1
+ ? sizeof(const_jargs) / sizeof(char *)
+ : 0; // ignore the null terminator index
+
+ extra_jargc = (sizeof(const_extra_jargs) / sizeof(char *)) > 1
+ ? sizeof(const_extra_jargs) / sizeof(char *)
+ : 0; // ignore the null terminator index
+
+ if (main_jargc > 0 && extra_jargc > 0) { // combine extra java args
+ jargc = main_jargc + extra_jargc;
+ list = JLI_List_new(jargc + 1);
+
+ for (i = 0 ; i < extra_jargc; i++) {
+ JLI_List_add(list, JLI_StringDup(const_extra_jargs[i]));
+ }
+
+ for (i = 0 ; i < main_jargc ; i++) {
+ JLI_List_add(list, JLI_StringDup(const_jargs[i]));
+ }
+
+ // terminate the list
+ JLI_List_add(list, NULL);
+ jargv = list->elements;
+ } else if (extra_jargc > 0) { // should never happen
+ fprintf(stderr, "EXTRA_JAVA_ARGS defined without JAVA_ARGS");
+ abort();
+ } else { // no extra args, business as usual
+ jargc = main_jargc;
+ jargv = (char **) const_jargs;
+ }
+ }
+
+ JLI_InitArgProcessing(jargc > 0, const_disable_argfile);
#ifdef _WIN32
{
@@ -164,12 +203,12 @@
}
#endif /* WIN32 */
return JLI_Launch(margc, margv,
- sizeof(const_jargs) / sizeof(char *), const_jargs,
+ jargc, (const char**) jargv,
0, NULL,
VERSION_STRING,
DOT_VERSION,
(const_progname != NULL) ? const_progname : *margv,
(const_launcher != NULL) ? const_launcher : *margv,
- HAS_JAVA_ARGS,
+ jargc > 0,
const_cpwildcard, const_javaw, 0);
}
--- a/jdk/src/java.base/share/native/libjli/args.c Fri Jun 09 16:26:32 2017 +0100
+++ b/jdk/src/java.base/share/native/libjli/args.c Fri Jun 09 09:54:59 2017 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -78,7 +78,7 @@
static jboolean stopExpansion = JNI_FALSE;
static jboolean relaunch = JNI_FALSE;
-void JLI_InitArgProcessing(jboolean isJava, jboolean disableArgFile) {
+void JLI_InitArgProcessing(jboolean hasJavaArgs, jboolean disableArgFile) {
// No expansion for relaunch
if (argsCount != 1) {
relaunch = JNI_TRUE;
@@ -91,7 +91,7 @@
expectingNoDashArg = JNI_FALSE;
// for tools, this value remains 0 all the time.
- firstAppArgIndex = isJava ? NOT_FOUND : 0;
+ firstAppArgIndex = hasJavaArgs ? 0: NOT_FOUND;
}
int JLI_GetAppArgIndex() {
--- a/jdk/src/java.base/share/native/libjli/java.c Fri Jun 09 16:26:32 2017 +0100
+++ b/jdk/src/java.base/share/native/libjli/java.c Fri Jun 09 09:54:59 2017 -0700
@@ -246,6 +246,10 @@
DumpState();
if (JLI_IsTraceLauncher()) {
int i;
+ printf("Java args:\n");
+ for (i = 0; i < jargc ; i++) {
+ printf("jargv[%d] = %s\n", i, jargv[i]);
+ }
printf("Command line args:\n");
for (i = 0; i < argc ; i++) {
printf("argv[%d] = %s\n", i, argv[i]);
--- a/jdk/src/java.base/share/native/libjli/jli_util.h Fri Jun 09 16:26:32 2017 +0100
+++ b/jdk/src/java.base/share/native/libjli/jli_util.h Fri Jun 09 09:54:59 2017 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -133,7 +133,7 @@
char *JLI_List_join(JLI_List l, char sep);
JLI_List JLI_List_split(const char *str, char sep);
-void JLI_InitArgProcessing(jboolean isJava, jboolean disableArgFile);
+void JLI_InitArgProcessing(jboolean hasJavaArgs, jboolean disableArgFile);
JLI_List JLI_PreprocessArg(const char *arg);
jboolean JLI_AddArgsFromEnvVar(JLI_List args, const char *var_name);