11@ echo off
2+ setlocal enableextensions
23
34rem %~dp0 is expanded pathname of the current script under NT
45set DEFAULT_BTRACE_HOME = %~dp0 ..
56
67if " %BTRACE_HOME% " == " " set BTRACE_HOME = %DEFAULT_BTRACE_HOME%
78set DEFAULT_BTRACE_HOME =
89
9- if not exist " %BTRACE_HOME% \libs \btrace-agent.jar" goto noBTraceHome
10+ set " CLIENT_JAR = %BTRACE_HOME% \libs\btrace.jar"
11+ if not exist " %CLIENT_JAR% " goto noBTraceHome
1012
11- set OPTIONS =
13+ set " OPTIONS = "
1214
1315if " %1 " == " " (
1416 call :usage
1517 goto end
1618)
1719if " %JAVA_HOME% " == " " goto noJavaHome
1820
21+ set " JAVA_ARGS = -XX:+IgnoreUnrecognizedVMOptions"
22+
1923if exist " %JAVA_HOME% /jmods/" (
20- set JAVA_ARGS = " %JAVA_ARGS% -XX:+AllowRedefinitionToAddDeleteMethods"
21- set JAVA_ARGS = " %JAVA_ARGS% --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED"
24+ set " JAVA_ARGS = %JAVA_ARGS% -XX:+AllowRedefinitionToAddDeleteMethods"
25+ set " JAVA_ARGS = %JAVA_ARGS% --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED"
2226)
2327
2428if " %1 " == " --version" (
25- set CLIENT_JAR = %BTRACE_HOME% \libs\btrace.jar
26- if not exist " %CLIENT_JAR% " goto noBTraceHome
27- %JAVA_HOME% \bin\java " %JAVA_ARGS% " -cp %CLIENT_JAR% org.openjdk.btrace.boot.Loader --version
29+ " %JAVA_HOME% \bin\java" %JAVA_ARGS% -cp " %CLIENT_JAR% " io.btrace.boot.Loader --version
2830 goto end
2931)
3032
31- set inloop = 1
3233:loop
3334 IF " %1 " == " -v" (
34- set OPTIONS = " debug=true,%OPTIONS"
35+ set " OPTIONS = debug=true,%OPTIONS% "
3536 goto next
3637 )
3738 IF " %1 " == " -u" (
38- set OPTIONS = " unsafe=true,%OPTIONS"
39+ set " OPTIONS = unsafe=true,%OPTIONS% "
3940 goto next
4041 )
4142 if " %1 " == " -p" (
42- set OPTIONS = " port=%2 ,%OPTIONS"
43+ set " OPTIONS = port=%2 ,%OPTIONS% "
4344 shift
4445 goto next
4546 )
4647 if " %1 " == " -d" (
47- set OPTIONS = " dumpClasses=true,dumpDir=%2 ,%OPTIONS"
48- shift
48+ set " OPTIONS = dumpClasses=true,dumpDir=%2 ,%OPTIONS% "
49+ shift
4950 goto next
5051 )
5152 if " %1 " == " -o" (
52- set OPTIONS = " scriptOutputFile=%2 ,%OPTIONS"
53+ set " OPTIONS = scriptOutputFile=%2 ,%OPTIONS% "
5354 shift
5455 goto next
5556 )
5657 if " %1 " == " -pd" (
57- set OPTIONS = " probeDescPath=%2 ,%OPTIONS"
58+ set " OPTIONS = probeDescPath=%2 ,%OPTIONS% "
5859 shift
5960 goto next
6061 )
6162 if " %1 " == " -bcp" (
62- OPTIONS=" bootClassPath=%2 ,%OPTIONS"
63+ set " OPTIONS = bootClassPath=%2 ,%OPTIONS% "
6364 shift
6465 goto next
6566 )
6667 if " %1 " == " -scp" (
67- set OPTIONS = " systemClassPath=%2 ,%OPTIONS"
68+ set " OPTIONS = systemClassPath=%2 ,%OPTIONS% "
6869 shift
6970 goto next
7071 )
7172 if " %1 " == " --noserver" (
72- set OPTIONS = " noServer=true,%OPTIONS"
73+ set " OPTIONS = noServer=true,%OPTIONS% "
7374 goto next
7475 )
7576 if " %1 " == " --stdout" (
76- set OPTIONS = " stdout=true,%OPTIONS"
77+ set " OPTIONS = stdout=true,%OPTIONS% "
7778 goto next
7879 )
7980 if " %1 " == " -statsd" (
80- set OPTIONS = " statsd=%2 ,%OPTIONS"
81+ set " OPTIONS = statsd=%2 ,%OPTIONS% "
82+ shift
8183 goto next
8284 )
83- call :usage
84- goto end
85-
86- set inloop = 0
85+ if " %1 " == " -h" (
86+ call :usage
87+ goto end
88+ )
89+ goto launch
8790
8891 :next
89- if %inloop== 1 (
90- shift
91- goto loop
92- )
92+ shift
93+ goto loop
9394
94- %JAVA_HOME% \bin\java -Xshare:off " %JAVA_ARGS% " " -javaagent:%BTRACE_HOME% /libs/btrace-agent.jar=%OPTIONS,script=% ~1" %2 %3 %4 %5 %6 %7 %8 %9
95- goto end
95+ :launch
96+ " %JAVA_HOME% \bin\java" -Xshare:off %JAVA_ARGS% " -javaagent:%CLIENT_JAR% =%OPTIONS% ,script=%~1 " %2 %3 %4 %5 %6 %7 %8 %9
97+ goto end
9698
9799:noJavaHome
98100 echo Please set JAVA_HOME before running this script
@@ -118,3 +120,4 @@ goto end
118120 echo -h This message
119121
120122:end
123+ endlocal
0 commit comments