Commit b31306f8 authored by Henry Jian's avatar Henry Jian Committed by Commit Bot

[Android] Remove report_java_assert support

Support for report_java_assert is no longer needed.
This CL removes it.
In addition, this CL removes BuildHooks.java as
report_java_assert is the only thing BuildHooks.java
is used for.


Bug: 1024346
Change-Id: I0235718b771d717f258575ab005acdb261612c99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2123316
Commit-Queue: Henry Jian <hzjian@google.com>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarSam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755062}
parent c4efac55
......@@ -5,29 +5,6 @@
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
java_library("build_hooks_java") {
jacoco_never_instrument = true
sources = [ "java/org/chromium/build/BuildHooks.java" ]
# Make all targets pull in the try-with-resources support files.
# If an apk ends up not using any such statements, ProGuard will remove
# them.
deps = [ "//third_party/bazel/desugar:desugar_runtime_java" ]
srcjar_deps = [ ":base_build_hooks_config" ]
no_build_hooks = true
supports_android = true
}
java_cpp_template("base_build_hooks_config") {
sources = [ "java/templates/BuildHooksConfig.template" ]
package_path = "org/chromium/build"
defines = []
if (report_java_assert) {
defines += [ "_REPORT_JAVA_ASSERT" ]
}
}
build_hooks_android_impl = "java/org/chromium/build/BuildHooksAndroidImpl.java"
android_library("build_hooks_android_java") {
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.build;
/**
* All Java targets that support android have dependence on this class.
*/
public abstract class BuildHooks {
/**
* Defines an interface for reporting assertion error.
*/
@FunctionalInterface
public interface ReportAssertionCallback {
void run(AssertionError arg);
}
private static ReportAssertionCallback sReportAssertionCallback;
/**
* This method is used to handle assert failures when asserts are enabled by
* //build/android/bytecode:java_bytecode_rewriter. For non-release builds, this is always
* enabled and assert failures will result in an assertion error being thrown. For release
* builds, this is only enabled when report_java_assert = true. Assert failures will result in
* an error report being uploaded to the crash servers only if the callback is set (so that this
* can be a no-op for WebView in Monochrome). This also means that asserts hit before the
* callback is set will be no-op's as well.
*/
public static void assertFailureHandler(AssertionError assertionError) {
if (BuildHooksConfig.REPORT_JAVA_ASSERT) {
if (sReportAssertionCallback != null) {
sReportAssertionCallback.run(assertionError);
}
} else {
throw assertionError;
}
}
/**
* Set the callback function that handles assert failure.
* This should be called from attachBaseContext.
*/
public static void setReportAssertionCallback(ReportAssertionCallback callback) {
if (!BuildHooksConfig.REPORT_JAVA_ASSERT) {
throw new AssertionError();
}
sReportAssertionCallback = callback;
}
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.build;
/**
* BuildHooks configuration. Generated on a per-target basis.
*/
public class BuildHooksConfig {
#if defined(_REPORT_JAVA_ASSERT)
public static final boolean REPORT_JAVA_ASSERT = true;
#else
public static final boolean REPORT_JAVA_ASSERT = false;
#endif
}
......@@ -168,10 +168,6 @@ if (is_android || is_chromeos) {
# off will enable proguard.
is_java_debug = is_debug
# Report Java assert failure on Android. Turning it on will report Java
# assert failure without crash.
report_java_assert = false
# Mark APKs as android:debuggable="true".
debuggable_apks = !is_official_build
......
......@@ -1077,7 +1077,7 @@ if (enable_java_templates) {
inputs += [ _proguard_jar_path ]
}
_enable_assert = is_java_debug || dcheck_always_on || report_java_assert
_enable_assert = is_java_debug || dcheck_always_on
if (_enable_assert) {
# The default for generating dex file format is
# --force-disable-assertions.
......@@ -1474,7 +1474,7 @@ if (enable_java_templates) {
rebase_path(_r8_path, root_build_dir),
]
_enable_assert = is_java_debug || dcheck_always_on || report_java_assert
_enable_assert = is_java_debug || dcheck_always_on
if (_enable_assert) {
# The default for generating dex file format is
# --force-disable-assertions.
......@@ -1533,7 +1533,6 @@ if (enable_java_templates) {
# build_config:
# input_jar_path:
# output_jar_path:
# enable_build_hooks:
# enable_build_hooks_android:
# supports_android:
# jacoco_instrument: Use Jacoco-instrumented classes to generate Java
......@@ -3213,21 +3212,12 @@ if (enable_java_templates) {
}
}
_enable_build_hooks =
_supports_android &&
(!defined(invoker.no_build_hooks) || !invoker.no_build_hooks)
if (_enable_build_hooks) {
_java_full_deps += [ "//build/android/buildhooks:build_hooks_java" ]
_java_header_deps +=
[ "//build/android/buildhooks:build_hooks_java__header" ]
}
# Some testonly targets use their own resources and the code being
# tested will use custom resources so there's no need to enable this
# for testonly targets.
_enable_build_hooks_android =
_enable_build_hooks && _requires_android &&
(!defined(invoker.testonly) || !invoker.testonly)
(!defined(invoker.no_build_hooks) || !invoker.no_build_hooks) &&
_requires_android && (!defined(invoker.testonly) || !invoker.testonly)
if (_enable_build_hooks_android) {
_java_full_deps +=
[ "//build/android/buildhooks:build_hooks_android_java" ]
......@@ -3235,6 +3225,14 @@ if (enable_java_templates) {
[ "//build/android/buildhooks:build_hooks_android_java__header" ]
}
if (_supports_android &&
(!defined(invoker.no_build_hooks) || !invoker.no_build_hooks)) {
# Android targets that are desugared rely on the desugar runtime library.
_java_full_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
_java_header_deps +=
[ "//third_party/bazel/desugar:desugar_runtime_java__header" ]
}
# Don't enable coverage or lint unless the target has some non-generated
# files.
if (defined(invoker.chromium_code)) {
......
......@@ -1918,8 +1918,6 @@ if (enable_java_templates) {
sources = [ "//base/android/java/templates/BuildConfig.template" ]
defines = []
# TODO(agrieve): These two are not target-specific and should be moved
# to BuildHooks.java.
# Set these even when !use_final_fields so that they have correct default
# values withnin junit_binary().
if (is_java_debug || dcheck_always_on) {
......
......@@ -28,9 +28,7 @@ import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.base.memory.MemoryPressureMonitor;
import org.chromium.base.multidex.ChromiumMultiDexInstaller;
import org.chromium.base.task.AsyncTask;
import org.chromium.build.BuildHooks;
import org.chromium.build.BuildHooksAndroid;
import org.chromium.build.BuildHooksConfig;
import org.chromium.chrome.browser.background_task_scheduler.ChromeBackgroundTaskFactory;
import org.chromium.chrome.browser.crash.ApplicationStatusTracker;
import org.chromium.chrome.browser.crash.FirebaseConfig;
......@@ -144,10 +142,6 @@ public class ChromeApplication extends Application {
// Incremental install disables process isolation, so things in this block will actually
// be run for incremental apks, but not normal apks.
PureJavaExceptionHandler.installHandler();
if (BuildHooksConfig.REPORT_JAVA_ASSERT) {
BuildHooks.setReportAssertionCallback(
PureJavaExceptionReporter::reportJavaException);
}
}
AsyncTask.takeOverAndroidThreadPool();
......
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