@@ -10,6 +10,8 @@ export const OVERRIDES_DIR = path.join(APP_ROOT, 'overrides');
1010const OVERRIDE_RUBYGEMS_PATH = path . join ( OVERRIDES_DIR , 'gems' ) ;
1111const OVERRIDE_PYTHONPATH = path . join ( OVERRIDES_DIR , 'pythonpath' ) ;
1212
13+ export const OVERRIDE_JAVA_AGENT = path . join ( OVERRIDES_DIR , 'java-agent.jar' ) ;
14+
1315const OVERRIDE_JS_SCRIPT = path . join ( OVERRIDES_DIR , 'js' , 'prepend-node.js' ) ;
1416const NODE_OPTION = `--require ${
1517 // Avoid quoting except when necessary, because node 8 doesn't support quotes here
@@ -27,6 +29,10 @@ export function getTerminalEnvVars(
2729) : { [ key : string ] : string } {
2830 const proxyUrl = `http://127.0.0.1:${ proxyPort } ` ;
2931
32+ const javaAgentOption = `-javaagent:${
33+ OVERRIDE_JAVA_AGENT
34+ } =127.0.0.1|${ proxyPort } |${ httpsConfig . certPath } `;
35+
3036 return {
3137 'http_proxy' : proxyUrl ,
3238 'HTTP_PROXY' : proxyUrl ,
@@ -84,6 +90,13 @@ export function getTerminalEnvVars(
8490 // subprocesses. Otherwise e.g. --max-http-header-size breaks old Node/Electron.
8591 'NODE_OPTIONS' : currentEnv === 'runtime-inherit'
8692 ? `$NODE_OPTIONS ${ NODE_OPTION } `
87- : NODE_OPTION
93+ : NODE_OPTION ,
94+
95+ // Attach our Java agent to all launched Java processes:
96+ 'JAVA_TOOL_OPTIONS' : currentEnv === 'runtime-inherit'
97+ ? `$JAVA_TOOL_OPTIONS ${ javaAgentOption } `
98+ : currentEnv . JAVA_TOOL_OPTIONS
99+ ? `${ currentEnv . JAVA_TOOL_OPTIONS } ${ javaAgentOption } `
100+ : javaAgentOption
88101 } ;
89102}
0 commit comments