Run test build: Refactor javac_wrapper.sh usage.
It turns out the tests don't need to replace javac behaviour,
they just want to perform custom action after the compilation.
Let the python script do the javac compilation as usual
(which automatically adds RBE support for those tests),
add call javac_post.sh after the compilation instead.
Test: Build artifacts are identical as before.
Change-Id: I9093968ba678706815bc7c2eef6380d454975f9b
diff --git a/test/003-omnibus-opcodes/javac_wrapper.sh b/test/003-omnibus-opcodes/javac_post.sh
similarity index 97%
rename from test/003-omnibus-opcodes/javac_wrapper.sh
rename to test/003-omnibus-opcodes/javac_post.sh
index 62e94f8..6065423 100755
--- a/test/003-omnibus-opcodes/javac_wrapper.sh
+++ b/test/003-omnibus-opcodes/javac_post.sh
@@ -16,5 +16,4 @@
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/javac_wrapper.sh b/test/004-ReferenceMap/javac_post.sh
similarity index 100%
rename from test/004-ReferenceMap/javac_wrapper.sh
rename to test/004-ReferenceMap/javac_post.sh
diff --git a/test/004-StackWalk/javac_wrapper.sh b/test/004-StackWalk/javac_post.sh
similarity index 100%
rename from test/004-StackWalk/javac_wrapper.sh
rename to test/004-StackWalk/javac_post.sh
diff --git a/test/005-annotations/javac_wrapper.sh b/test/005-annotations/javac_post.sh
similarity index 98%
rename from test/005-annotations/javac_wrapper.sh
rename to test/005-annotations/javac_post.sh
index 69e6161..abec8b0 100755
--- a/test/005-annotations/javac_wrapper.sh
+++ b/test/005-annotations/javac_post.sh
@@ -16,8 +16,6 @@
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'
diff --git a/test/091-override-package-private-method/javac_wrapper.sh b/test/091-override-package-private-method/javac_post.sh
similarity index 98%
rename from test/091-override-package-private-method/javac_wrapper.sh
rename to test/091-override-package-private-method/javac_post.sh
index 0e2b2e1..d2dd7e6 100755
--- a/test/091-override-package-private-method/javac_wrapper.sh
+++ b/test/091-override-package-private-method/javac_post.sh
@@ -15,6 +15,6 @@
# 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/javac_wrapper.sh b/test/111-unresolvable-exception/javac_post.sh
similarity index 97%
rename from test/111-unresolvable-exception/javac_wrapper.sh
rename to test/111-unresolvable-exception/javac_post.sh
index 9e4d2a2..355f792 100755
--- a/test/111-unresolvable-exception/javac_wrapper.sh
+++ b/test/111-unresolvable-exception/javac_post.sh
@@ -16,7 +16,5 @@
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/javac_wrapper.sh b/test/124-missing-classes/javac_post.sh
similarity index 89%
rename from test/124-missing-classes/javac_wrapper.sh
rename to test/124-missing-classes/javac_post.sh
index c6c234d..39e26bb 100755
--- a/test/124-missing-classes/javac_wrapper.sh
+++ b/test/124-missing-classes/javac_post.sh
@@ -16,8 +16,5 @@
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.
+# Some classes are available at compile time but not at run time.
rm 'classes/MissingClass.class' 'classes/Main$MissingInnerClass.class'
diff --git a/test/126-miranda-multidex/generate-sources b/test/126-miranda-multidex/generate-sources
index b35d5ef..f42ba10 100755
--- a/test/126-miranda-multidex/generate-sources
+++ b/test/126-miranda-multidex/generate-sources
@@ -19,3 +19,4 @@
# Signal to default-build that this is a multidex test.
mkdir src-multidex
+touch src-multidex/Empty.java
diff --git a/test/003-omnibus-opcodes/javac_wrapper.sh b/test/126-miranda-multidex/javac_post.sh
similarity index 88%
copy from test/003-omnibus-opcodes/javac_wrapper.sh
copy to test/126-miranda-multidex/javac_post.sh
index 62e94f8..79a9cef 100755
--- a/test/003-omnibus-opcodes/javac_wrapper.sh
+++ b/test/126-miranda-multidex/javac_post.sh
@@ -16,5 +16,6 @@
set -e # Stop on error - the caller script may not have this set.
-$JAVAC "$@"
-rm -f classes/UnresClass.class
+if [[ "$1" == "classes2" ]]; then
+ mv classes/MirandaInterface.class classes2
+fi
diff --git a/test/126-miranda-multidex/javac_wrapper.sh b/test/126-miranda-multidex/javac_wrapper.sh
deleted file mode 100755
index 71cafa1..0000000
--- a/test/126-miranda-multidex/javac_wrapper.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/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/javac_wrapper.sh b/test/127-checker-secondarydex/javac_post.sh
similarity index 97%
rename from test/127-checker-secondarydex/javac_wrapper.sh
rename to test/127-checker-secondarydex/javac_post.sh
index 7fe6a55..e9d5d18 100755
--- a/test/127-checker-secondarydex/javac_wrapper.sh
+++ b/test/127-checker-secondarydex/javac_post.sh
@@ -16,7 +16,5 @@
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/javac_wrapper.sh b/test/138-duplicate-classes-check2/javac_post.sh
similarity index 97%
rename from test/138-duplicate-classes-check2/javac_wrapper.sh
rename to test/138-duplicate-classes-check2/javac_post.sh
index 68c352f..ce8b82f 100755
--- a/test/138-duplicate-classes-check2/javac_wrapper.sh
+++ b/test/138-duplicate-classes-check2/javac_post.sh
@@ -16,7 +16,5 @@
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/829-unresolved-enclosing/javac_wrapper.sh b/test/829-unresolved-enclosing/javac_post.sh
similarity index 97%
rename from test/829-unresolved-enclosing/javac_wrapper.sh
rename to test/829-unresolved-enclosing/javac_post.sh
index e3dc1e3..93875d4 100755
--- a/test/829-unresolved-enclosing/javac_wrapper.sh
+++ b/test/829-unresolved-enclosing/javac_post.sh
@@ -16,7 +16,5 @@
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.py b/test/952-invoke-custom/build.py
index c640b9e..166d3a8 100644
--- a/test/952-invoke-custom/build.py
+++ b/test/952-invoke-custom/build.py
@@ -16,4 +16,6 @@
def build(ctx):
ctx.bash("./generate-sources")
- ctx.default_build(use_desugar=False, api_level=28)
+ ctx.default_build(use_desugar=False,
+ api_level=28,
+ javac_classpath=[ctx.test_dir / "transformer.jar"])
diff --git a/test/952-invoke-custom/javac_wrapper.sh b/test/952-invoke-custom/javac_post.sh
similarity index 77%
rename from test/952-invoke-custom/javac_wrapper.sh
rename to test/952-invoke-custom/javac_post.sh
index c8e0716..be5d8cf 100755
--- a/test/952-invoke-custom/javac_wrapper.sh
+++ b/test/952-invoke-custom/javac_post.sh
@@ -18,25 +18,6 @@
export ASM_JAR="${ANDROID_BUILD_TOP}/prebuilts/misc/common/asm/asm-9.2.jar"
-# 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
diff --git a/test/979-const-method-handle/generate-sources b/test/979-const-method-handle/generate-sources
index d102d73..0cd94d1 100755
--- a/test/979-const-method-handle/generate-sources
+++ b/test/979-const-method-handle/generate-sources
@@ -24,3 +24,6 @@
${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
+
+# Add annotation src files to our compiler inputs.
+cp -r util-src/annotations src/
diff --git a/test/979-const-method-handle/javac_wrapper.sh b/test/979-const-method-handle/javac_post.sh
similarity index 90%
rename from test/979-const-method-handle/javac_wrapper.sh
rename to test/979-const-method-handle/javac_post.sh
index 5ed8481..1be31d5 100755
--- a/test/979-const-method-handle/javac_wrapper.sh
+++ b/test/979-const-method-handle/javac_post.sh
@@ -18,12 +18,6 @@
export ASM_JAR="${ANDROID_BUILD_TOP}/prebuilts/misc/common/asm/asm-9.2.jar"
-# 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
diff --git a/test/run_test_build.py b/test/run_test_build.py
index 13458dd..6c3a212 100755
--- a/test/run_test_build.py
+++ b/test/run_test_build.py
@@ -48,6 +48,11 @@
lock_file = None # Keep alive as long as this process is alive.
+RBE_D8_DISABLED_FOR = {
+ "089-many-methods", # D8 compilation intentionally fails.
+ "952-invoke-custom", # b/228312861: RBE uses wrong inputs.
+ "979-const-method-handle", # b/228312861: RBE uses wrong inputs.
+}
class BuildTestContext:
def __init__(self, args, android_build_top, test_dir):
@@ -80,7 +85,8 @@
if "RBE_server_address" in os.environ and USE_RBE > (hash(self.test_name) % 100):
self.rbe_exec_root = os.environ.get("RBE_exec_root")
self.rbe_rewrapper = self.android_build_top / "prebuilts/remoteexecution-client/live/rewrapper"
- self.d8 = functools.partial(self.rbe_d8, args.d8.absolute())
+ if self.test_name not in RBE_D8_DISABLED_FOR:
+ self.d8 = functools.partial(self.rbe_d8, args.d8.absolute())
self.javac = functools.partial(self.rbe_javac, self.javac_path)
self.smali = functools.partial(self.rbe_smali, args.smali.absolute())
@@ -106,7 +112,7 @@
env=self.bash_env,
check=True)
- def run(self, executable: pathlib.Path, args: List[str]):
+ def run(self, executable: pathlib.Path, args: List[Union[pathlib.Path, str]]):
assert isinstance(executable, pathlib.Path), executable
cmd: List[Union[pathlib.Path, str]] = []
if executable.suffix == ".sh":
@@ -191,11 +197,13 @@
zip_align_bytes=None,
api_level:Union[int, str]=26, # Can also be named alias (string).
javac_args=[],
+ javac_classpath: List[Path]=[],
d8_flags=[],
smali_args=[],
use_smali=True,
use_jasmin=True,
):
+ javac_classpath = javac_classpath.copy() # Do not modify default value.
# Wrap "pathlib.Path" with our own version that ensures all paths are absolute.
# Plain filenames are assumed to be relative to self.test_dir and made absolute.
@@ -222,11 +230,6 @@
api_level = API_LEVEL[api_level]
assert isinstance(api_level, int), api_level
- # If wrapper script exists, use it instead of the default javac.
- javac_wrapper = Path("javac_wrapper.sh")
- if javac_wrapper.exists():
- self.javac = functools.partial(self.run, javac_wrapper)
-
def zip(zip_target: Path, *files: Path):
zip_args = ["-o", zip_target, "-C", zip_target.parent]
if zip_compression_method == "store":
@@ -258,9 +261,6 @@
["--output", dst_dex] + sorted(src_dir.glob("**/*.smali")))
return dst_dex
-
- java_classpath: List[Path] = []
-
def make_java(dst_dir: Path, *src_dirs: Path) -> Optional[Path]:
if not any(src_dir.exists() for src_dir in src_dirs):
return None # No sources to compile.
@@ -269,11 +269,14 @@
args += ["-implicit:none", "-encoding", "utf8", "-d", dst_dir]
if not self.jvm:
args += ["-bootclasspath", self.bootclasspath]
- if java_classpath:
- args += ["-classpath", java_classpath]
+ if javac_classpath:
+ args += ["-classpath", javac_classpath]
for src_dir in src_dirs:
args += sorted(src_dir.glob("**/*.java"))
self.javac(args)
+ javac_post = Path("javac_post.sh")
+ if javac_post.exists():
+ self.run(javac_post, [dst_dir])
return dst_dir
@@ -332,10 +335,10 @@
return
if make_jasmin(Path("jasmin_classes"), Path("jasmin")):
- java_classpath.append(Path("jasmin_classes"))
+ javac_classpath.append(Path("jasmin_classes"))
if make_jasmin(Path("jasmin_classes2"), Path("jasmin-multidex")):
- java_classpath.append(Path("jasmin_classes2"))
+ javac_classpath.append(Path("jasmin_classes2"))
# To allow circular references, compile src/, src-multidex/, src-aotex/,
# src-bcpex/, src-ex/ together and pass the output as class path argument.
@@ -347,7 +350,7 @@
if (Path("src").exists() and
any(Path(p).exists() for p in extra_srcs + replacement_srcs)):
make_java(Path("classes-tmp-all"), Path("src"), *map(Path, extra_srcs))
- java_classpath.append(Path("classes-tmp-all"))
+ javac_classpath.append(Path("classes-tmp-all"))
if make_java(Path("classes-aotex"), Path("src-aotex")) and need_dex:
make_dex(Path("classes-aotex"))