summaryrefslogtreecommitdiff
path: root/cmds/app_process/app_main.cpp
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2016-09-29 15:19:58 -0700
committerIgor Murashkin <iam@google.com>2016-10-03 11:08:42 -0700
commit4f66cb3f534eafff335ec803caff0572d08e8aa5 (patch)
tree6e884d6466b0a4a56e1f2640a0eb61293bc7e98e /cmds/app_process/app_main.cpp
parent5706a8f5353218a60d3cf104a03e79fae301c27d (diff)
app_process: Forward -cp/-classpath to ART.
* No new functionality was added, this was already possible via -Djava.class.path=classpath * However, this makes it a bit more compatible with other tools that use -cp to invoke the main class. * Also update the benchmarks README for correct up-to-date vogar instructions. Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/ParcelBenchmark.java Bug: 31807538 Change-Id: Idb04600fed3dd955437ccac832617dcfd1b52b63
Diffstat (limited to 'cmds/app_process/app_main.cpp')
-rw-r--r--cmds/app_process/app_main.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 18ad43eac37e..d5580acce4f8 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -188,6 +188,16 @@ int main(int argc, char* const argv[])
LOG_ALWAYS_FATAL("PR_SET_NO_NEW_PRIVS failed: %s", strerror(errno));
}
+ if (!LOG_NDEBUG) {
+ String8 argv_String;
+ for (int i = 0; i < argc; ++i) {
+ argv_String.append("\"");
+ argv_String.append(argv[i]);
+ argv_String.append("\" ");
+ }
+ ALOGV("app_process main with argv: %s", argv_String.string());
+ }
+
AppRuntime runtime(argv[0], computeArgBlockSize(argc, argv));
// Process command line arguments
// ignore argv[0]
@@ -216,9 +226,31 @@ int main(int argc, char* const argv[])
//
// Note that we must copy argument string values since we will rewrite the
// entire argument block when we apply the nice name to argv0.
+ //
+ // As an exception to the above rule, anything in "spaced commands"
+ // goes to the vm even though it has a space in it.
+ const char* spaced_commands[] = { "-cp", "-classpath" };
+ // Allow "spaced commands" to be succeeded by exactly 1 argument (regardless of -s).
+ bool known_command = false;
int i;
for (i = 0; i < argc; i++) {
+ if (known_command == true) {
+ runtime.addOption(strdup(argv[i]));
+ ALOGV("app_process main add known option '%s'", argv[i]);
+ known_command = false;
+ continue;
+ }
+
+ for (int j = 0;
+ j < static_cast<int>(sizeof(spaced_commands) / sizeof(spaced_commands[0]));
+ ++j) {
+ if (strcmp(argv[i], spaced_commands[j]) == 0) {
+ known_command = true;
+ ALOGV("app_process main found known command '%s'", argv[i]);
+ }
+ }
+
if (argv[i][0] != '-') {
break;
}
@@ -226,7 +258,9 @@ int main(int argc, char* const argv[])
++i; // Skip --.
break;
}
+
runtime.addOption(strdup(argv[i]));
+ ALOGV("app_process main add option '%s'", argv[i]);
}
// Parse runtime arguments. Stop at first unrecognized option.
@@ -266,6 +300,18 @@ int main(int argc, char* const argv[])
// copies of them before we overwrite them with the process name.
args.add(application ? String8("application") : String8("tool"));
runtime.setClassNameAndArgs(className, argc - i, argv + i);
+
+ if (!LOG_NDEBUG) {
+ String8 restOfArgs;
+ char* const* argv_new = argv + i;
+ int argc_new = argc - i;
+ for (int k = 0; k < argc_new; ++k) {
+ restOfArgs.append("\"");
+ restOfArgs.append(argv_new[k]);
+ restOfArgs.append("\" ");
+ }
+ ALOGV("Class name = %s, args = %s", className.string(), restOfArgs.string());
+ }
} else {
// We're in zygote mode.
maybeCreateDalvikCache();