Commit 532a8982 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Use checked-in JDK11 for most build scripts

Rather than whatever version of java is available in PATH.

For desugar and errorprone, some java warnings started to show
up from this:
"WARNING: An illegal reflective access operation has occurred"

I've just silenced them with a stderr filter, and figure they
will go away next time we roll these deps.

I've checked the effect on d8 & r8 for this:
 * On my local machine, they run much faster.
 * On the trybot, they ran a bit slower.

Bug: 693079
Change-Id: I4001bbcb5bdcc2a9afa062c35633dc397b0ef9cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857702
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706483}
parent 99677a6a
......@@ -13,6 +13,8 @@ import os
import subprocess
import sys
from util import build_utils
# Assume this is stored under build/android/gyp/
BUNDLETOOL_DIR = os.path.abspath(os.path.join(
__file__, '..', '..', '..', '..', 'third_party', 'android_build_tools',
......@@ -24,7 +26,7 @@ BUNDLETOOL_JAR_PATH = os.path.join(
BUNDLETOOL_DIR, 'bundletool-all-%s.jar' % BUNDLETOOL_VERSION)
def RunBundleTool(args):
args = ['java', '-jar', BUNDLETOOL_JAR_PATH] + args
args = [build_utils.JAVA_PATH, '-jar', BUNDLETOOL_JAR_PATH] + args
logging.debug(' '.join(args))
subprocess.check_call(args)
......
......@@ -411,12 +411,17 @@ def main(args):
with open(tmp_bundle_config, 'w') as f:
f.write(bundle_config)
cmd_args = ['java', '-jar', bundletool.BUNDLETOOL_JAR_PATH, 'build-bundle']
cmd_args += ['--modules=%s' % ','.join(module_zips)]
cmd_args += ['--output=%s' % tmp_unsigned_bundle]
cmd_args += ['--config=%s' % tmp_bundle_config]
build_utils.CheckOutput(cmd_args, print_stdout=True, print_stderr=True)
cmd_args = [
build_utils.JAVA_PATH, '-jar', bundletool.BUNDLETOOL_JAR_PATH,
'build-bundle', '--modules=' + ','.join(module_zips),
'--output=' + tmp_unsigned_bundle, '--config=' + tmp_bundle_config
]
build_utils.CheckOutput(
cmd_args,
print_stdout=True,
print_stderr=True,
stderr_filter=build_utils.FilterReflectiveAccessJavaWarnings)
if options.keystore_path:
# NOTE: As stated by the public documentation, apksigner cannot be used
......
......@@ -31,7 +31,7 @@ def main():
options.classpath = build_utils.ParseGnList(options.classpath)
cmd = [
'java',
build_utils.JAVA_PATH,
'-jar',
options.desugar_jar,
'--input',
......@@ -46,7 +46,10 @@ def main():
cmd += ['--bootclasspath_entry', path]
for path in options.classpath:
cmd += ['--classpath_entry', path]
build_utils.CheckOutput(cmd, print_stdout=False)
build_utils.CheckOutput(
cmd,
print_stdout=False,
stderr_filter=build_utils.FilterReflectiveAccessJavaWarnings)
if options.depfile:
build_utils.WriteDepfile(
......
......@@ -404,7 +404,10 @@ def main(args):
final_dex_inputs = list(options.class_inputs)
final_dex_inputs += options.dex_inputs
dex_cmd = ['java', '-jar', options.r8_jar_path, 'd8', '--no-desugaring']
dex_cmd = [
build_utils.JAVA_PATH, '-jar', options.r8_jar_path, 'd8',
'--no-desugaring'
]
if options.release:
dex_cmd += ['--release']
if options.min_api:
......
......@@ -49,7 +49,7 @@ def _ParseOptions(args):
def _RunDexsplitter(options, output_dir):
cmd = [
'java',
build_utils.JAVA_PATH,
'-jar',
options.r8_path,
'dexsplitter',
......
......@@ -215,7 +215,9 @@ def _RunInstrumentCommand(parser):
source_files.extend(build_utils.ReadSourcesList(args.java_sources_file))
with build_utils.TempDir() as temp_dir:
instrument_cmd = ['java', '-jar', args.jacococli_jar, 'instrument']
instrument_cmd = [
build_utils.JAVA_PATH, '-jar', args.jacococli_jar, 'instrument'
]
if not args.files_to_instrument:
_InstrumentWholeJar(instrument_cmd, args.input_path, args.output_path,
......
......@@ -55,7 +55,7 @@ def _ParseArgs():
def main():
args = _ParseArgs()
proguard_cmd = [
'java',
build_utils.JAVA_PATH,
'-jar',
args.r8_path,
'--classfile',
......@@ -105,7 +105,7 @@ def main():
# Step 2: Expand inclusion list to all classes referenced by the .class
# files of kept classes (non-recursive).
main_dex_list_cmd = [
'java',
build_utils.JAVA_PATH,
'-cp',
args.dx_path,
'com.android.multidex.MainDexListBuilder',
......
......@@ -92,7 +92,7 @@ def main(argv):
with build_utils.AtomicOutput(args.output) as output:
cmd = [
'java',
build_utils.JAVA_PATH,
'-cp',
classpath,
_MANIFEST_MERGER_MAIN_CLASS,
......
......@@ -176,7 +176,7 @@ def _OptimizeWithR8(options,
os.mkdir(tmp_output)
cmd = [
'java',
build_utils.JAVA_PATH,
'-jar',
options.r8_path,
'--no-desugaring',
......@@ -246,7 +246,7 @@ def _OptimizeWithProguard(options,
if options.proguard_path.endswith('.jar'):
cmd = [
'java', '-jar', options.proguard_path, '-include',
build_utils.JAVA_PATH, '-jar', options.proguard_path, '-include',
combined_proguard_configs_path
]
else:
......
......@@ -33,6 +33,8 @@ import gn_helpers
DIR_SOURCE_ROOT = os.environ.get('CHECKOUT_SOURCE_ROOT',
os.path.abspath(os.path.join(os.path.dirname(__file__),
os.pardir, os.pardir, os.pardir, os.pardir)))
JAVA_PATH = os.path.join(DIR_SOURCE_ROOT, 'third_party', 'jdk', 'current',
'bin', 'java')
try:
string_types = basestring
......@@ -206,6 +208,26 @@ def FilterLines(output, filter_string):
line for line in output.splitlines() if not re_filter.search(line))
def FilterReflectiveAccessJavaWarnings(output):
"""Filters out warnings about illegal reflective access operation.
These warnings were introduced in Java 9, and generally mean that dependencies
need to be updated.
"""
# WARNING: An illegal reflective access operation has occurred
# WARNING: Illegal reflective access by ...
# WARNING: Please consider reporting this to the maintainers of ...
# WARNING: Use --illegal-access=warn to enable warnings of further ...
# WARNING: All illegal access operations will be denied in a future release
return FilterLines(
output, r'WARNING: ('
'An illegal reflective|'
'Illegal reflective access|'
'Please consider reporting this to|'
'Use --illegal-access=warn|'
'All illegal access operations)')
# This can be used in most cases like subprocess.check_output(). The output,
# particularly when the command fails, better highlights the command's failure.
# If the command fails, raises a build_utils.CalledProcessError.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment