Skip to content

Commit

Permalink
Fix -c option to work on JDK 11 and above (where java.class.path no l…
Browse files Browse the repository at this point in the history
…onger includes agent jars)
  • Loading branch information
giltene committed Oct 6, 2018
1 parent 9656b7d commit d0aa858
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/org/jhiccup/HiccupMeter.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.HdrHistogram.*;

import java.io.*;
import java.security.CodeSource;
import java.util.*;
import java.text.SimpleDateFormat;
import java.lang.management.*;
Expand Down Expand Up @@ -299,13 +300,17 @@ public HiccupMeterConfiguration(final String[] args, String defaultLogFileName)
File controlFilePath = new File(parentFileNamePart, childFileNamePart + ".c");
controlProcessLogFileName = controlFilePath.getPath();

// Compute path to agent's JAR file
CodeSource agentCodeSource = HiccupMeter.class.getProtectionDomain().getCodeSource();
String agentPath = new File(agentCodeSource.getLocation().toURI()).getPath();

// Derive controlProcessCommand from our java home, class name, and parsed
// options:
controlProcessCommand =
System.getProperty("java.home") +
File.separator + "bin" + File.separator + "java" +
(controlProcessJvmArgsExplicitlySpecified ? " " + controlProcessJvmArgs : "") +
" -cp " + System.getProperty("java.class.path") +
" -cp " + agentPath +
" -Dorg.jhiccup.avoidRecursion=true" +
" " + HiccupMeter.class.getCanonicalName() +
" -l " + controlProcessLogFileName +
Expand Down

0 comments on commit d0aa858

Please sign in to comment.