diff options
| -rwxr-xr-x | tools/hoststubgen/hoststubgen/test-tiny-framework/diff-and-update-golden.sh | 2 | ||||
| -rwxr-xr-x | tools/hoststubgen/scripts/dump-jar | 32 |
2 files changed, 13 insertions, 21 deletions
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/diff-and-update-golden.sh b/tools/hoststubgen/hoststubgen/test-tiny-framework/diff-and-update-golden.sh index 00cbfe38e815..3726ca972564 100755 --- a/tools/hoststubgen/hoststubgen/test-tiny-framework/diff-and-update-golden.sh +++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/diff-and-update-golden.sh @@ -63,7 +63,7 @@ shift $(($OPTIND - 1)) # Build the dump files, which are the input of this test. -run m tiny-framework-dump-test +run m dump-jar tiny-framework-dump-test # Get the path to the generate text files. (not the golden files.) diff --git a/tools/hoststubgen/scripts/dump-jar b/tools/hoststubgen/scripts/dump-jar index fe546fe9cc92..87652451359d 100755 --- a/tools/hoststubgen/scripts/dump-jar +++ b/tools/hoststubgen/scripts/dump-jar @@ -26,12 +26,12 @@ help() { Dump a *.class file - dump-jar [-v] [-s] [-o OUTPUT-FILENAME] JAR-FILE[: filename regex] [...] + dump-jar [-v] [-s] [-o OUTPUT-FILENAME] JAR-FILE[: class internal name regex] [...] Dump a jar file. If a filename contains a ':', then the following part - will be used to filter files in the jar file. + will be used to filter files in the jar file that matches against class internal names. For example, "file.jar:/MyClass$" will only dump "MyClass" in file.jar. @@ -78,16 +78,6 @@ if (( $simple )) ; then JAVAP_OPTS="-p -c -v" fi - -# Normalize a java class name. -# Convert '.' to '/' -# Remove the *.class suffix. -normalize() { - local name="$1" - name="${name%.class}" # Remove the .class suffix. - echo "$name" | tr '.' '/' -} - # Convert the output for `-s` as needed. filter_output() { if (( $simple )) ; then @@ -124,6 +114,12 @@ write_to_out() { fi } +# Read jar file names and remove the .class suffix. +# Also remove non-class files. +to_internal_names() { + sed -ne 's/\.class$//p' +} + for file in "${@}"; do # *.class? @@ -136,7 +132,7 @@ for file in "${@}"; do # Take the regex. Remove everything up to : in $file regex="" if [[ "$file" =~ : ]] ; then - regex="$(normalize "${file##*:}")" + regex="${file##*:}" fi # Remove everything after ':', inclusively, in $file. @@ -151,13 +147,9 @@ for file in "${@}"; do echo fi - jar tf "$file" | grep '\.class$' | sort | while read -r class ; do - if normalize "$class" | grep -q -- "$regex" ; then - echo "## Class: $class" - javap $dump_code_opt $JAVAP_OPTS -cp $file ${class%.class} - else - (( $verbose )) && echo "## Skipping class: $class" - fi + jar tf "$file" | sort | to_internal_names | grep -- "$regex" | while read -r class ; do + echo "## Class: $class.class" + javap $dump_code_opt $JAVAP_OPTS -cp "$file" "${class}" done else |