Skip to content

Commit

Permalink
fix bash -jvm-debug to work on Java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
qwe2 committed Nov 27, 2024
1 parent a3dc087 commit 561f638
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ addResidual () {
residual_args+=( "$1" )
}
addDebugger () {
addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:$1"
local major_version=$(get_java_major_version)
local address="*:$1"
if [ $major_version -le 8 ]; then
address="$1"
fi
addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$address"
}

require_arg () {
Expand Down Expand Up @@ -311,6 +316,21 @@ java_version_check() {
fi
}

get_java_major_version() {
readonly java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}')
if [[ "$java_version" == "" ]]; then
echoerr "Could not determine Java version. Assuming 8."
echo 8
else
local major=$(echo "$java_version" | cut -d'.' -f1)
if [[ "$major" -eq "1" ]]; then
local major=$(echo "$java_version" | cut -d'.' -f2)
fi
echo $major
fi
}


### ------------------------------- ###
### Start of customized settings ###
### ------------------------------- ###
Expand Down

0 comments on commit 561f638

Please sign in to comment.