Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize classpath pre-processing in java_stub_template.txt #19481

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,29 +306,32 @@ function create_and_run_classpath_jar() {

OLDIFS="$IFS"
IFS="${CLASSPATH_SEPARATOR}" # Use a custom separator for the loop.
current_dir=$(pwd)
for path in ${CLASSPATH}; do
# Loop through the characters of the path and convert characters that are
# not alphanumeric nor -_.~/ to their 2-digit hexadecimal representation
local i c buff
local converted_path=""

for ((i=0; i<${#path}; i++)); do
c=${path:$i:1}
case ${c} in
[-_.~/a-zA-Z0-9] ) buff=${c} ;;
* ) printf -v buff '%%%02x' "'$c'"
esac
converted_path+="${buff}"
done
path=${converted_path}
if [[ ! $path =~ ^[-_.~/a-zA-Z0-9]*$ ]]; then
local i c buff
local converted_path=""

for ((i=0; i<${#path}; i++)); do
c=${path:$i:1}
case ${c} in
[-_.~/a-zA-Z0-9] ) buff=${c} ;;
* ) printf -v buff '%%%02x' "'$c'"
esac
converted_path+="${buff}"
done
path=${converted_path}
fi

if is_windows; then
path="file:/${path}" # e.g. "file:/C:/temp/foo.jar"
else
# If not absolute, qualify the path
case "${path}" in
/*) ;; # Already an absolute path
*) path="$(pwd)/${path}";; # Now qualified
*) path="${current_dir}/${path}";; # Now qualified
esac
path="file:${path}" # e.g. "file:/usr/local/foo.jar"
fi
Expand Down
Loading