MCPcopy Create free account
hub / github.com/apache/impala / JavaAddJammAgent

Function JavaAddJammAgent

be/src/common/init.cc:350–376  ·  view source on GitHub ↗

Append the javaagent arg to JAVA_TOOL_OPTIONS to load jamm.

Source from the content-addressed store, hash-verified

348
349// Append the javaagent arg to JAVA_TOOL_OPTIONS to load jamm.
350static Status JavaAddJammAgent() {
351 stringstream val_out;
352 char* current_val_c = getenv("JAVA_TOOL_OPTIONS");
353 if (current_val_c != NULL) {
354 val_out << current_val_c << " ";
355 }
356
357 istringstream classpath {getenv("CLASSPATH")};
358 string jamm_path, test_path;
359 while (getline(classpath, test_path, ':')) {
360 Status status = FileSystemUtil::FindFileInPath(test_path, "jamm-.*.jar", &jamm_path);
361 // Error during FindFileInPath is not fatal if jamm path is found in another path.
362 if (!status.ok()) {
363 LOG(ERROR) << "Error when processing class path: " << status.msg().msg();
364 }
365 if (!jamm_path.empty()) break;
366 }
367 if (jamm_path.empty()) {
368 return Status("Could not find jamm-*.jar in Java CLASSPATH");
369 }
370 val_out << "-javaagent:" << jamm_path;
371
372 if (setenv("JAVA_TOOL_OPTIONS", val_out.str().c_str(), 1) < 0) {
373 return Status(Substitute("Could not update JAVA_TOOL_OPTIONS: $0", GetStrErrMsg()));
374 }
375 return Status::OK();
376}
377
378// Append add-opens args to JAVA_TOOL_OPTIONS for ehcache and jamm.
379static Status JavaAddOpens(bool useSizeOf) {

Callers 1

InitializeJavaWeigherFunction · 0.85

Calls 7

SubstituteFunction · 0.85
GetStrErrMsgFunction · 0.85
OKFunction · 0.85
StatusClass · 0.70
okMethod · 0.45
emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected