Move javac_wrapper.sh scripts into own files.
I have originally created those snippets as minimal
change from the previous bash-functions.
On second thought, rather than generate those files,
it is cleaner to just create those files in source.
The build script will use "javac_wrapper.sh" if it exists.
Test: check that generated run-test data is unchanged
Change-Id: Ibd0d92cf399c3026be127ac42b513382c04142f7
diff --git a/test/003-omnibus-opcodes/build b/test/003-omnibus-opcodes/build
index 3fbb5b0..a14ddc9 100644
--- a/test/003-omnibus-opcodes/build
+++ b/test/003-omnibus-opcodes/build
@@ -17,18 +17,4 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- $ORIGINAL_JAVAC "$@"
- rm -f classes/UnresClass.class
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
./default-build "$@"
diff --git a/test/003-omnibus-opcodes/javac_wrapper.sh b/test/003-omnibus-opcodes/javac_wrapper.sh
new file mode 100755
index 0000000..62e94f8
--- /dev/null
+++ b/test/003-omnibus-opcodes/javac_wrapper.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+$JAVAC "$@"
+rm -f classes/UnresClass.class
diff --git a/test/004-ReferenceMap/build b/test/004-ReferenceMap/build
index df02ab0..6203c97 100644
--- a/test/004-ReferenceMap/build
+++ b/test/004-ReferenceMap/build
@@ -17,20 +17,6 @@
# Stop if something fails.
set -e
-# This test depends on the exact format of the DEX file. Since dx is deprecated,
-# the classes.dex file is packaged as a test input. It was created with:
-#
-# $ javac -g -Xlint:-options -source 1.7 -target 1.7 -d classes src/Main.java
-# $ dx --debug --dex --output=classes.dex classes
-
-# Wrapper function for javac which for this test does nothing as the
-# test uses a pre-built DEX file.
-cat >javac_wrapper.sh <<"EOF"
- # Nothing to compile, using dx generated classes.dex.
- return 0
-EOF
-export JAVAC=./javac_wrapper.sh
-
# Do not invoke D8 for this test.
export D8=':'
diff --git a/test/004-ReferenceMap/javac_wrapper.sh b/test/004-ReferenceMap/javac_wrapper.sh
new file mode 100755
index 0000000..bb5b349
--- /dev/null
+++ b/test/004-ReferenceMap/javac_wrapper.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This test depends on the exact format of the DEX file. Since dx is deprecated,
+# the classes.dex file is packaged as a test input. It was created with:
+#
+# $ javac -g -Xlint:-options -source 1.7 -target 1.7 -d classes src/Main.java
+# $ dx --debug --dex --output=classes.dex classes
+
+# Nothing to compile, using dx generated classes.dex.
+return 0
diff --git a/test/004-StackWalk/build b/test/004-StackWalk/build
index 3d049c8..6203c97 100644
--- a/test/004-StackWalk/build
+++ b/test/004-StackWalk/build
@@ -17,17 +17,6 @@
# Stop if something fails.
set -e
-# This test depends on the exact format of the DEX file. Since dx is deprecated,
-# the classes.dex file is packaged as a test input. See src/Main.java file
-# to check how it was created.
-
-# Wrapper function for javac which for this test does nothing as the
-# test uses a pre-built DEX file.
-cat >javac_wrapper.sh <<"EOF"
- return 0
-EOF
-export JAVAC=./javac_wrapper.sh
-
# Do not invoke D8 for this test.
export D8=':'
diff --git a/test/004-StackWalk/javac_wrapper.sh b/test/004-StackWalk/javac_wrapper.sh
new file mode 100755
index 0000000..603ce39
--- /dev/null
+++ b/test/004-StackWalk/javac_wrapper.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This test depends on the exact format of the DEX file. Since dx is deprecated,
+# the classes.dex file is packaged as a test input. See src/Main.java file
+# to check how it was created.
+return 0
diff --git a/test/005-annotations/build b/test/005-annotations/build
index e7a713d..bdc1950 100644
--- a/test/005-annotations/build
+++ b/test/005-annotations/build
@@ -17,28 +17,6 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- $ORIGINAL_JAVAC "$@"
-
- # Classes available at compile time, but not at runtime.
- rm -f classes/android/test/anno/MissingAnnotation.class
- rm -f 'classes/android/test/anno/ClassWithInnerAnnotationClass$MissingInnerAnnotationClass.class'
-
- # overwrite RenamedEnum in classes
- if [ -f classes2/android/test/anno/RenamedEnumClass.java ] ; then
- mv classes2/android/test/anno/RenamedEnumClass.java classes/android/test/anno/RenamedEnumClass.java
- fi
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
# Build intermediate object to preserve class-retention annotations.
export D8_FLAGS=--intermediate
./default-build "$@"
diff --git a/test/005-annotations/javac_wrapper.sh b/test/005-annotations/javac_wrapper.sh
new file mode 100755
index 0000000..69e6161
--- /dev/null
+++ b/test/005-annotations/javac_wrapper.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+$JAVAC "$@"
+
+# Classes available at compile time, but not at runtime.
+rm -f classes/android/test/anno/MissingAnnotation.class
+rm -f 'classes/android/test/anno/ClassWithInnerAnnotationClass$MissingInnerAnnotationClass.class'
+
+# overwrite RenamedEnum in classes
+if [ -f classes2/android/test/anno/RenamedEnumClass.java ] ; then
+ mv classes2/android/test/anno/RenamedEnumClass.java classes/android/test/anno/RenamedEnumClass.java
+fi
diff --git a/test/091-override-package-private-method/build b/test/091-override-package-private-method/build
index 34bde6f..6b298f7 100755
--- a/test/091-override-package-private-method/build
+++ b/test/091-override-package-private-method/build
@@ -17,18 +17,4 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
- $ORIGINAL_JAVAC "$@"
- mkdir -p classes-ex
- mv classes/OverridePackagePrivateMethodSuper.class classes-ex
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
./default-build "$@"
diff --git a/test/091-override-package-private-method/javac_wrapper.sh b/test/091-override-package-private-method/javac_wrapper.sh
new file mode 100755
index 0000000..0e2b2e1
--- /dev/null
+++ b/test/091-override-package-private-method/javac_wrapper.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+$JAVAC "$@"
+mkdir -p classes-ex
+mv classes/OverridePackagePrivateMethodSuper.class classes-ex
diff --git a/test/111-unresolvable-exception/build b/test/111-unresolvable-exception/build
index 2d744e6..f378df1 100644
--- a/test/111-unresolvable-exception/build
+++ b/test/111-unresolvable-exception/build
@@ -17,20 +17,4 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- $ORIGINAL_JAVAC "$@"
-
- # Remove class available at compile time but not at run time.
- rm classes/TestException.class
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
./default-build "$@"
diff --git a/test/111-unresolvable-exception/javac_wrapper.sh b/test/111-unresolvable-exception/javac_wrapper.sh
new file mode 100755
index 0000000..9e4d2a2
--- /dev/null
+++ b/test/111-unresolvable-exception/javac_wrapper.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+$JAVAC "$@"
+
+# Remove class available at compile time but not at run time.
+rm classes/TestException.class
diff --git a/test/124-missing-classes/build b/test/124-missing-classes/build
index c72d820..a40cbc9 100644
--- a/test/124-missing-classes/build
+++ b/test/124-missing-classes/build
@@ -17,22 +17,4 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- # Some classes are available at compile time...
- $ORIGINAL_JAVAC "$@"
-
- # ...but not at run time.
- rm 'classes/MissingClass.class' 'classes/Main$MissingInnerClass.class'
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
./default-build "$@"
diff --git a/test/124-missing-classes/javac_wrapper.sh b/test/124-missing-classes/javac_wrapper.sh
new file mode 100755
index 0000000..c6c234d
--- /dev/null
+++ b/test/124-missing-classes/javac_wrapper.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+# Some classes are available at compile time...
+$JAVAC "$@"
+
+# ...but not at run time.
+rm 'classes/MissingClass.class' 'classes/Main$MissingInnerClass.class'
diff --git a/test/126-miranda-multidex/build b/test/126-miranda-multidex/build
index f71e70f..c827e55 100644
--- a/test/126-miranda-multidex/build
+++ b/test/126-miranda-multidex/build
@@ -17,28 +17,6 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- if [[ "$*" != *"classes2"* ]]; then
- # First invocation: compile src/ files.
- $ORIGINAL_JAVAC "$@"
- else
- # Second invocation: move MirandaInterface.class for placement in
- # a secondary dex file. There are no other source files for the
- # secondary DEX so no compilation required.
- mv classes/MirandaInterface.class classes2
- fi
- exit $?
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
# Signal to default-build that this is a multidex test.
mkdir src-multidex
./default-build "$@"
diff --git a/test/126-miranda-multidex/javac_wrapper.sh b/test/126-miranda-multidex/javac_wrapper.sh
new file mode 100755
index 0000000..71cafa1
--- /dev/null
+++ b/test/126-miranda-multidex/javac_wrapper.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+if [[ "$*" != *"classes2"* ]]; then
+ # First invocation: compile src/ files.
+ $JAVAC "$@"
+else
+ # Second invocation: move MirandaInterface.class for placement in
+ # a secondary dex file. There are no other source files for the
+ # secondary DEX so no compilation required.
+ mv classes/MirandaInterface.class classes2
+fi
+exit $?
diff --git a/test/127-checker-secondarydex/build b/test/127-checker-secondarydex/build
index da632ce..f378df1 100755
--- a/test/127-checker-secondarydex/build
+++ b/test/127-checker-secondarydex/build
@@ -17,20 +17,4 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- $ORIGINAL_JAVAC "$@"
-
- mkdir classes-ex
- mv classes/Super.class classes-ex
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
./default-build "$@"
diff --git a/test/127-checker-secondarydex/javac_wrapper.sh b/test/127-checker-secondarydex/javac_wrapper.sh
new file mode 100755
index 0000000..7fe6a55
--- /dev/null
+++ b/test/127-checker-secondarydex/javac_wrapper.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+$JAVAC "$@"
+
+mkdir classes-ex
+mv classes/Super.class classes-ex
diff --git a/test/138-duplicate-classes-check2/build b/test/138-duplicate-classes-check2/build
index e32e3a6..6b298f7 100755
--- a/test/138-duplicate-classes-check2/build
+++ b/test/138-duplicate-classes-check2/build
@@ -17,20 +17,4 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- $ORIGINAL_JAVAC "$@"
-
- # Remove one A.class from classes-ex
- rm -f classes-ex/A.class
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
./default-build "$@"
diff --git a/test/138-duplicate-classes-check2/javac_wrapper.sh b/test/138-duplicate-classes-check2/javac_wrapper.sh
new file mode 100755
index 0000000..68c352f
--- /dev/null
+++ b/test/138-duplicate-classes-check2/javac_wrapper.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+$JAVAC "$@"
+
+# Remove one A.class from classes-ex
+rm -f classes-ex/A.class
diff --git a/test/1948-obsolete-const-method-handle/util-src/build-classes b/test/1948-obsolete-const-method-handle/util-src/build-classes
index 19fdc01..eae5b47 100755
--- a/test/1948-obsolete-const-method-handle/util-src/build-classes
+++ b/test/1948-obsolete-const-method-handle/util-src/build-classes
@@ -33,7 +33,7 @@
fi
# Build the initial class files.
-(cd "${SRC_PATH}" && ${JAVAC} -source 8 -target 8 -cp "${ASM_CLASSPATH}" -d "${BUILD_PATH}" Main.java art/*.java art/constmethodhandle/*.java) || fail "javac error"
+(cd "${SRC_PATH}" && ${JAVAC} ${JAVAC_ARGS} -source 8 -target 8 -cp "${ASM_CLASSPATH}" -d "${BUILD_PATH}" Main.java art/*.java art/constmethodhandle/*.java) || fail "javac error"
# Modify the class files using ASM
(cd "${SCRIPT_PATH}" && ${JAVA} -cp "${ASM_CLASSPATH}:${BUILD_PATH}" art.constmethodhandle.TestGenerator "${BUILD_PATH}" "$D8") || fail "generator failure"
# Remove the modification classes. We don't need nor want them for the actual test.
diff --git a/test/829-unresolved-enclosing/build b/test/829-unresolved-enclosing/build
index 2c4f471..f378df1 100644
--- a/test/829-unresolved-enclosing/build
+++ b/test/829-unresolved-enclosing/build
@@ -17,20 +17,4 @@
# Stop if something fails.
set -e
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# additional setup steps for the test.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- $ORIGINAL_JAVAC "$@"
-
- # Remove class available at compile time but not at run time.
- rm classes/MissingSuperClass.class
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
./default-build "$@"
diff --git a/test/829-unresolved-enclosing/javac_wrapper.sh b/test/829-unresolved-enclosing/javac_wrapper.sh
new file mode 100755
index 0000000..e3dc1e3
--- /dev/null
+++ b/test/829-unresolved-enclosing/javac_wrapper.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+$JAVAC "$@"
+
+# Remove class available at compile time but not at run time.
+rm classes/MissingSuperClass.class
diff --git a/test/952-invoke-custom/build b/test/952-invoke-custom/build
index 7ba1f5c..e835517 100755
--- a/test/952-invoke-custom/build
+++ b/test/952-invoke-custom/build
@@ -19,50 +19,9 @@
export ASM_JAR="${ANDROID_BUILD_TOP}/prebuilts/misc/common/asm/asm-9.2.jar"
-export ORIGINAL_JAVAC="$JAVAC"
-
-# Wrapper function for javac which invokes the compiler and applies
-# transforms to class files after compilation.
-cat >javac_wrapper.sh <<"EOF"
- set -e # Stop on error - the caller script may not have this set.
-
- # Update arguments to add transformer and ASM to the compiler classpath.
- classpath="./transformer.jar:$ASM_JAR"
- args=(-cp $classpath)
- while [ $# -ne 0 ] ; do
- case $1 in
- -cp|-classpath|--class-path)
- shift
- shift
- ;;
- *)
- args+=("$1")
- shift
- ;;
- esac
- done
-
- # Compile.
- $ORIGINAL_JAVAC "${args[@]}"
-
- # Move original classes to intermediate location.
- mv classes intermediate-classes
- mkdir classes
-
- # Transform intermediate classes.
- transformer_args="-cp ${ASM_JAR}:transformer.jar transformer.IndyTransformer"
- for class in intermediate-classes/*.class ; do
- transformed_class=classes/$(basename ${class})
- ${JAVA:-java} ${transformer_args} $PWD/${class} ${transformed_class}
- done
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
# Build the transformer to apply to compiled classes.
mkdir classes
-${ORIGINAL_JAVAC:-javac} ${JAVAC_ARGS} -cp "${ASM_JAR}" -d classes $(find util-src -name '*.java')
+${JAVAC:-javac} ${JAVAC_ARGS} -cp "${ASM_JAR}" -d classes $(find util-src -name '*.java')
${SOONG_ZIP} --jar -o transformer.jar -C classes -D classes
rm -rf classes
diff --git a/test/952-invoke-custom/javac_wrapper.sh b/test/952-invoke-custom/javac_wrapper.sh
new file mode 100755
index 0000000..8659030
--- /dev/null
+++ b/test/952-invoke-custom/javac_wrapper.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e # Stop on error - the caller script may not have this set.
+
+# Update arguments to add transformer and ASM to the compiler classpath.
+classpath="./transformer.jar:$ASM_JAR"
+args=(-cp $classpath)
+while [ $# -ne 0 ] ; do
+ case $1 in
+ -cp|-classpath|--class-path)
+ shift
+ shift
+ ;;
+ *)
+ args+=("$1")
+ shift
+ ;;
+ esac
+done
+
+# Compile.
+$JAVAC "${args[@]}"
+
+# Move original classes to intermediate location.
+mv classes intermediate-classes
+mkdir classes
+
+# Transform intermediate classes.
+transformer_args="-cp ${ASM_JAR}:transformer.jar transformer.IndyTransformer"
+for class in intermediate-classes/*.class ; do
+ transformed_class=classes/$(basename ${class})
+ ${JAVA:-java} ${transformer_args} $PWD/${class} ${transformed_class}
+done
diff --git a/test/968-default-partial-compile-gen/build b/test/968-default-partial-compile-gen/build
index 5a62aa4..04532b0 100755
--- a/test/968-default-partial-compile-gen/build
+++ b/test/968-default-partial-compile-gen/build
@@ -21,7 +21,7 @@
# Build the Java files if we are running a --jvm test
mkdir -p classes
mkdir -p src
- echo "${JAVAC} \$@" >> ./javac_exec.sh
+ echo "${JAVAC} ${JAVAC_ARGS} \$@" >> ./javac_exec.sh
# This will use java_exec.sh to execute the javac compiler. It will place the
# compiled class files in ./classes and the expected values in expected-stdout.txt
#
diff --git a/test/971-iface-super/build b/test/971-iface-super/build
index 5a62aa4..04532b0 100755
--- a/test/971-iface-super/build
+++ b/test/971-iface-super/build
@@ -21,7 +21,7 @@
# Build the Java files if we are running a --jvm test
mkdir -p classes
mkdir -p src
- echo "${JAVAC} \$@" >> ./javac_exec.sh
+ echo "${JAVAC} ${JAVAC_ARGS} \$@" >> ./javac_exec.sh
# This will use java_exec.sh to execute the javac compiler. It will place the
# compiled class files in ./classes and the expected values in expected-stdout.txt
#
diff --git a/test/979-const-method-handle/build b/test/979-const-method-handle/build
index 8ba2875..fa6a0ea 100755
--- a/test/979-const-method-handle/build
+++ b/test/979-const-method-handle/build
@@ -19,35 +19,9 @@
export ASM_JAR="${ANDROID_BUILD_TOP}/prebuilts/misc/common/asm/asm-9.2.jar"
-export ORIGINAL_JAVAC="$JAVAC"
-
-cat >javac_wrapper.sh <<"EOF"
- set -e
-
- # Add annotation src files to our compiler inputs.
- asrcs=util-src/annotations/*.java
-
- # Compile.
- $ORIGINAL_JAVAC "$@" $asrcs
-
- # Move original classes to intermediate location.
- mv classes intermediate-classes
- mkdir classes
-
- # Transform intermediate classes.
- transformer_args="-cp ${ASM_JAR}:$PWD/transformer.jar transformer.ConstantTransformer"
- for class in intermediate-classes/*.class ; do
- transformed_class=classes/$(basename ${class})
- ${JAVA:-java} ${transformer_args} ${class} ${transformed_class}
- done
-EOF
-export JAVAC=./javac_wrapper.sh
-
-######################################################################
-
# Build the transformer to apply to compiled classes.
mkdir classes
-${ORIGINAL_JAVAC:-javac} ${JAVAC_ARGS} -cp "${ASM_JAR}" -d classes $(find util-src -name '*.java')
+${JAVAC:-javac} ${JAVAC_ARGS} -cp "${ASM_JAR}" -d classes $(find util-src -name '*.java')
${SOONG_ZIP} --jar -o transformer.jar -C classes -D classes
rm -rf classes
diff --git a/test/979-const-method-handle/javac_wrapper.sh b/test/979-const-method-handle/javac_wrapper.sh
new file mode 100755
index 0000000..77b6bc3
--- /dev/null
+++ b/test/979-const-method-handle/javac_wrapper.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+# Add annotation src files to our compiler inputs.
+asrcs=util-src/annotations/*.java
+
+# Compile.
+$JAVAC "$@" $asrcs
+
+# Move original classes to intermediate location.
+mv classes intermediate-classes
+mkdir classes
+
+# Transform intermediate classes.
+transformer_args="-cp ${ASM_JAR}:$PWD/transformer.jar transformer.ConstantTransformer"
+for class in intermediate-classes/*.class ; do
+ transformed_class=classes/$(basename ${class})
+ ${JAVA:-java} ${transformer_args} ${class} ${transformed_class}
+done
diff --git a/test/etc/default-build b/test/etc/default-build
index c2c0b6a..26820f2 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -158,6 +158,9 @@
d8 = functools.partial(run, os.environ["D8"])
hiddenapi = functools.partial(run, os.environ["HIDDENAPI"])
+# If wrapper script exists, use it instead of the default javac.
+if os.path.exists("javac_wrapper.sh"):
+ javac = functools.partial(run, "javac_wrapper.sh")
def find(root, name):
return sorted(glob.glob(path.join(root, "**", name), recursive=True))
diff --git a/test/run-test-build.py b/test/run-test-build.py
index 03ac18f..f8eb283 100755
--- a/test/run-test-build.py
+++ b/test/run-test-build.py
@@ -66,7 +66,8 @@
"SOONG_ZIP": join(build_top, "prebuilts/build-tools/linux-x86/bin/soong_zip"),
"ZIPALIGN": join(build_top, "prebuilts/build-tools/linux-x86/bin/zipalign"),
"JAVA": join(java_home, "bin/java"),
- "JAVAC": join(java_home, "bin/javac") + " -g -Xlint:-options -source 1.8 -target 1.8",
+ "JAVAC": join(java_home, "bin/javac"),
+ "JAVAC_ARGS": "-g -Xlint:-options -source 1.8 -target 1.8",
"D8": join(tools_dir, "d8"),
"HIDDENAPI": join(tools_dir, "hiddenapi"),
"JASMIN": join(tools_dir, "jasmin"),