aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2019-06-25 15:40:29 +0100
committerPaul Duffin <paulduffin@google.com>2019-07-02 14:26:07 +0100
commitc241d6a26776614449440f7be1851709387deaab (patch)
tree024eb49dd0eb36511ec188f1a07b9b62c6458baf
parentad7ae581f05bc3320db06e478c8f548220f76810 (diff)
downloadlibcore-c241d6a26776614449440f7be1851709387deaab.tar.gz
Set default visibility to private
Takes advantage of a new mechanism for specifying the default visibility of all modules in a package to restrict the visibility of libcore modules as much as possible: package {default_visibility: ["//visibility:private"]} Bug: 133290645 Bug: 134379140 Test: m droid Change-Id: I2ba1a6131993d218fd65cd4a8f0ad29a7a83df14
-rw-r--r--Android.bp21
-rw-r--r--JavaLibrary.bp67
-rw-r--r--NativeCode.bp15
-rw-r--r--expectations/Android.bp20
-rw-r--r--luni/src/main/native/Android.bp20
-rw-r--r--luni/src/test/filesystems/Android.bp3
-rw-r--r--luni/src/test/java9language/Android.bp2
-rw-r--r--luni/src/test/parameter_metadata/Android.bp3
-rw-r--r--mmodules/core_platform_api/Android.bp7
-rw-r--r--mmodules/intracoreapi/Android.bp6
-rw-r--r--non_openjdk_java_files.bp3
-rw-r--r--ojluni/src/main/native/Android.bp17
-rw-r--r--openjdk_java_files.bp3
13 files changed, 181 insertions, 6 deletions
diff --git a/Android.bp b/Android.bp
index e57045fc5b4..268ea18ae02 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,3 +1,21 @@
+// Copyright (C) 2017 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.
+
+package {
+ default_visibility: ["//visibility:private"],
+}
+
build = [
"JavaLibrary.bp",
"NativeCode.bp",
@@ -5,6 +23,9 @@ build = [
genrule {
name: "notices-for-framework-stubs",
+ visibility: [
+ "//development/build",
+ ],
tool_files: [
"NOTICE",
"ojluni/NOTICE",
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index b229c2fcfd6..f446439ebf7 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -53,6 +53,9 @@ core_resource_dirs = [
// The source files that go into core-oj.
filegroup {
name: "core_oj_java_files",
+ visibility: [
+ "//libcore:__subpackages__",
+ ],
srcs: [":openjdk_java_files"],
}
@@ -66,6 +69,9 @@ filegroup {
// The source files that go into core-libart.
filegroup {
name: "core_libart_java_files",
+ visibility: [
+ "//libcore:__subpackages__",
+ ],
srcs: [
":non_openjdk_java_files",
":android_icu4j_src_files",
@@ -87,6 +93,9 @@ filegroup {
// files for inclusion in the public SDK docs.
filegroup {
name: "core_public_api_files",
+ visibility: [
+ "//frameworks/base",
+ ],
srcs: [
":core_oj_api_files",
":core_libart_api_files",
@@ -104,6 +113,9 @@ filegroup {
// in openjdk_java_files.bp for more details.
filegroup {
name: "core_api_files",
+ visibility: [
+ "//libcore:__subpackages__",
+ ],
srcs: [
":apache-xml_api_files",
":bouncycastle_java_files",
@@ -144,9 +156,7 @@ core_all_visibility = [
"//external/conscrypt",
"//external/icu/android_icu4j",
"//external/okhttp",
- "//libcore/benchmarks",
- "//libcore/luni/src/test/java9language",
- "//libcore/mmodules/intracoreapi",
+ "//libcore:__subpackages__",
]
// A target used to bootstrap compilation for the core library.
@@ -383,6 +393,7 @@ java_defaults {
// are also in the public SDK API from API level 26 onwards.
java_library {
name: "core-lambda-stubs",
+ visibility: ["//visibility:public"],
defaults: ["core_lambda_stubs_defaults"],
srcs: [
":openjdk_lambda_stub_files",
@@ -395,6 +406,9 @@ java_library {
// (since API level 26).
java_library {
name: "core-lambda-stubs-for-system-modules",
+ visibility: [
+ "//libcore/mmodules/core_platform_api",
+ ],
defaults: ["core_lambda_stubs_defaults"],
srcs: [
":openjdk_lambda_stub_files",
@@ -407,6 +421,9 @@ java_library {
// See http://b/123891440.
java_library {
name: "core-generated-annotation-stubs",
+ visibility: [
+ "//libcore/mmodules/core_platform_api",
+ ],
defaults: ["libcore_java_defaults"],
srcs: [
":openjdk_generated_annotation_stub_files",
@@ -436,6 +453,7 @@ java_library {
// Java lambdas.
java_system_modules {
name: "core-system-modules",
+ visibility: ["//visibility:public"],
libs: [
"core-oj",
"core-libart",
@@ -452,6 +470,9 @@ java_system_modules {
// Builds libcore test rules
java_library_static {
name: "core-test-rules",
+ visibility: [
+ "//frameworks/base/location/tests/locationtests",
+ ],
hostdex: true,
srcs: [
"dalvik/test-rules/src/main/**/*.java",
@@ -467,6 +488,17 @@ java_library_static {
// Builds the core-tests-support library used by various tests.
java_library_static {
name: "core-tests-support",
+ visibility: [
+ "//cts/apps/CtsVerifier",
+ "//cts/tests/tests/keystore",
+ "//cts/tests/tests/net",
+ "//cts/tests/tests/net/api23Test",
+ "//external/apache-harmony",
+ "//frameworks/base/core/tests/coretests",
+ "//libcore/benchmarks",
+ "//packages/apps/KeyChain/tests",
+ "//system/timezone/distro/core",
+ ],
hostdex: true,
srcs: ["support/src/test/java/**/*.java"],
@@ -482,6 +514,9 @@ java_library_static {
// Builds the jsr166-tests library.
java_test {
name: "jsr166-tests",
+ visibility: [
+ "//cts/tests/libcore/jsr166",
+ ],
srcs: ["jsr166-tests/src/test/java/**/*.java"],
sdk_version: "none",
libs: [
@@ -502,6 +537,9 @@ filegroup {
// Builds the core-tests library.
java_test {
name: "core-tests",
+ visibility: [
+ "//cts/tests/libcore/luni",
+ ],
defaults: ["libcore_java_defaults"],
hostdex: true,
srcs: [
@@ -613,6 +651,9 @@ java_test {
// Like core-ojtests but smaller.
java_test {
name: "core-ojtests-public",
+ visibility: [
+ "//cts/tests/libcore/ojluni",
+ ],
defaults: ["libcore_java_defaults"],
srcs: [
"ojluni/src/test/java/**/*.java",
@@ -648,6 +689,9 @@ java_test {
// available to metalava. Used for nullability annotations in OpenJDK source.
droiddoc_exported_dir {
name: "ojluni-annotated-sdk-stubs",
+ visibility: [
+ "//frameworks/base",
+ ],
path: "ojluni/annotations/sdk",
}
@@ -657,10 +701,14 @@ droiddoc_exported_dir {
}
// Exports annotated stubs source files in ojluni/annotations/mmodules to make
-// them available to metalava. Used for core platform API and intra-code API
+// them available to metalava. Used for core platform API and intra-core API
// annotations in OpenJDK source.
droiddoc_exported_dir {
name: "ojluni-annotated-mmodule-stubs",
+ visibility: [
+ "//libcore/mmodules/core_platform_api",
+ "//libcore/mmodules/intracoreapi",
+ ],
path: "ojluni/annotations/mmodule",
}
@@ -668,6 +716,9 @@ droiddoc_exported_dir {
// source code and so should not cause an error or warning.
filegroup {
name: "known-oj-tags",
+ visibility: [
+ "//frameworks/base",
+ ],
srcs: [
"known_oj_tags.txt",
],
@@ -694,6 +745,7 @@ droidstubs {
// Don't use this directly, use "sdk_version: core_current".
java_library {
name: "core.current.stubs",
+ visibility: ["//visibility:public"],
srcs: [":core-current-stubs-gen"],
errorprone: {
javacflags: [
@@ -717,6 +769,7 @@ java_library {
// Used when compiling higher-level code against core.current.stubs.
java_system_modules {
name: "core-current-stubs-system-modules",
+ visibility: ["//visibility:public"],
libs: [
"core.current.stubs",
// This one is not on device but it's needed when javac compiles code
@@ -763,12 +816,18 @@ droidstubs {
// time zone data.
java_library_host {
name: "timezone-host",
+ visibility: [
+ "//system/timezone/distro/core",
+ ],
srcs: [":timezone_host_files"],
}
// The source files that contain the UnsupportedAppUsage annotation and its dependencies.
filegroup {
name: "unsupportedappusage_annotation_files",
+ visibility: [
+ "//frameworks/base",
+ ],
srcs: [
"dalvik/src/main/java/dalvik/annotation/compat/UnsupportedAppUsage.java",
"dalvik/src/main/java/dalvik/system/VersionCodes.java",
diff --git a/NativeCode.bp b/NativeCode.bp
index e40b9bc80b5..e268a87aae4 100644
--- a/NativeCode.bp
+++ b/NativeCode.bp
@@ -47,6 +47,9 @@ cc_defaults {
cc_library_shared {
name: "libjavacore",
+ visibility: [
+ "//art/build/apex",
+ ],
defaults: [
"core_native_default_flags",
"core_native_default_libs",
@@ -83,6 +86,9 @@ cc_library_shared {
cc_library_shared {
name: "libandroidio",
+ visibility: [
+ "//art/build/apex",
+ ],
defaults: [
"core_native_default_flags",
],
@@ -155,6 +161,9 @@ cc_defaults {
cc_library_shared {
name: "libopenjdk",
+ visibility: [
+ "//art/build/apex",
+ ],
defaults: ["libopenjdk_native_defaults"],
shared_libs: [
"libopenjdkjvm",
@@ -164,6 +173,9 @@ cc_library_shared {
// Debug version of libopenjdk. Depends on libopenjdkjvmd.
cc_library_shared {
name: "libopenjdkd",
+ visibility: [
+ "//art/build/apex",
+ ],
defaults: ["libopenjdk_native_defaults"],
shared_libs: [
"libopenjdkjvmd",
@@ -173,6 +185,9 @@ cc_library_shared {
// Test JNI library.
cc_library_shared {
name: "libjavacoretests",
+ visibility: [
+ "//cts/tests/libcore/luni",
+ ],
defaults: ["core_native_default_flags"],
host_supported: true,
diff --git a/expectations/Android.bp b/expectations/Android.bp
index bf4a993c80c..c2667d39806 100644
--- a/expectations/Android.bp
+++ b/expectations/Android.bp
@@ -1,9 +1,29 @@
+// Copyright (C) 2019 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.
+
+expectations_visibility = [
+ "//cts/tests/libcore:__subpackages__",
+]
+
filegroup {
name: "libcore-expectations-knownfailures",
+ visibility: expectations_visibility,
srcs: ["knownfailures.txt"],
}
filegroup {
name: "libcore-expectations-virtualdeviceknownfailures",
+ visibility: expectations_visibility,
srcs: ["virtualdeviceknownfailures.txt"],
}
diff --git a/luni/src/main/native/Android.bp b/luni/src/main/native/Android.bp
index 8621752f412..85c6430a06d 100644
--- a/luni/src/main/native/Android.bp
+++ b/luni/src/main/native/Android.bp
@@ -1,5 +1,22 @@
+// Copyright (C) 2017 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.
+
filegroup {
name: "luni_native_srcs",
+ visibility: [
+ "//libcore",
+ ],
srcs: [
"ExecStrings.cpp",
"IcuUtilities.cpp",
@@ -31,6 +48,9 @@ filegroup {
filegroup {
name: "libandroidio_srcs",
+ visibility: [
+ "//libcore",
+ ],
srcs: [
"AsynchronousCloseMonitor.cpp",
],
diff --git a/luni/src/test/filesystems/Android.bp b/luni/src/test/filesystems/Android.bp
index 8acf4283d3c..83cb936af57 100644
--- a/luni/src/test/filesystems/Android.bp
+++ b/luni/src/test/filesystems/Android.bp
@@ -18,6 +18,9 @@
// class loader by libcore.java.nio.file.FileSystemsTest.
java_library {
name: "filesystemstest",
+ visibility: [
+ "//libcore",
+ ],
compile_dex: true,
srcs: ["src/**/*.java"],
java_resource_dirs: ["resources"],
diff --git a/luni/src/test/java9language/Android.bp b/luni/src/test/java9language/Android.bp
index c19090e4b87..28f0ce5e83e 100644
--- a/luni/src/test/java9language/Android.bp
+++ b/luni/src/test/java9language/Android.bp
@@ -17,7 +17,6 @@
// Use jarjar to repackage Java9LanguageFeatures, to be used in tests below.
java_library {
name: "core-java-9-language-features-repackaged-for-test",
- defaults: ["libcore_java_defaults"],
hostdex: true,
srcs: [":core-java-9-language-features-source"],
@@ -61,7 +60,6 @@ genrule {
java_library {
name: "core-java-9-language-tests",
- defaults: ["libcore_java_defaults"],
hostdex: true,
srcs: [
"java/**/*.java",
diff --git a/luni/src/test/parameter_metadata/Android.bp b/luni/src/test/parameter_metadata/Android.bp
index 5e00fa2ebbc..0eec841d8e0 100644
--- a/luni/src/test/parameter_metadata/Android.bp
+++ b/luni/src/test/parameter_metadata/Android.bp
@@ -21,6 +21,9 @@
// class loader by libcore.java.lang.reflect.ParameterTest.
java_library {
name: "parameter-metadata-test",
+ visibility: [
+ "//libcore",
+ ],
compile_dex: true,
srcs: ["src/**/*.java"],
sdk_version: "core_platform",
diff --git a/mmodules/core_platform_api/Android.bp b/mmodules/core_platform_api/Android.bp
index ff0e372f05b..de165d5c558 100644
--- a/mmodules/core_platform_api/Android.bp
+++ b/mmodules/core_platform_api/Android.bp
@@ -45,6 +45,11 @@ droidstubs {
},
}
+// Ideally this should be a restricted whitelist but there are hundreds of modules that depend on
+// this.
+// TODO(http://b/134561230) - limit the number of dependents on this.
+core_platform_visibility = ["//visibility:public"]
+
// A library containing the {public SDK + core platform} API stubs for the core jars.
//
// Although this stubs library is primarily used by the Java compiler / build to indicate
@@ -53,6 +58,7 @@ droidstubs {
// accessibility. b/119068555
java_library {
name: "core.platform.api.stubs",
+ visibility: core_platform_visibility,
srcs: [":core-platform-api-stubs"],
hostdex: true,
compile_dex: true,
@@ -65,6 +71,7 @@ java_library {
// Used when compiling higher-level code against core.platform.api.stubs.
java_system_modules {
name: "core-platform-api-stubs-system-modules",
+ visibility: core_platform_visibility,
libs: [
"core.platform.api.stubs",
// This one is not on device but it's needed when javac compiles code
diff --git a/mmodules/intracoreapi/Android.bp b/mmodules/intracoreapi/Android.bp
index 816e7024416..fab9d83b1d2 100644
--- a/mmodules/intracoreapi/Android.bp
+++ b/mmodules/intracoreapi/Android.bp
@@ -49,6 +49,9 @@ droidstubs {
// core jars.
java_library {
name: "core.intra.stubs",
+ visibility: [
+ "//external/conscrypt",
+ ],
srcs: [":core-intra-stubs"],
sdk_version: "none",
@@ -62,6 +65,9 @@ java_library {
// Used when compiling against core.intra.stubs.
java_system_modules {
name: "core-intra-stubs-system-modules",
+ visibility: [
+ "//external/conscrypt",
+ ],
libs: ["core.intra.stubs"],
}
diff --git a/non_openjdk_java_files.bp b/non_openjdk_java_files.bp
index caf3c996d8e..2cbb9465289 100644
--- a/non_openjdk_java_files.bp
+++ b/non_openjdk_java_files.bp
@@ -298,6 +298,9 @@ filegroup {
filegroup {
name: "non_openjdk_java_files",
+ visibility: [
+ "//frameworks/base",
+ ],
srcs: [
"luni/src/main/java/java/net/AddressCache.java",
"luni/src/main/java/libcore/icu/CollationKeyICU.java",
diff --git a/ojluni/src/main/native/Android.bp b/ojluni/src/main/native/Android.bp
index 38a2a23d330..7aa8dda13e1 100644
--- a/ojluni/src/main/native/Android.bp
+++ b/ojluni/src/main/native/Android.bp
@@ -1,5 +1,22 @@
+// Copyright (C) 2017 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.
+
filegroup {
name: "libopenjdk_native_srcs",
+ visibility: [
+ "//libcore",
+ ],
srcs: [
"ZipFile.c",
"Inflater.c",
diff --git a/openjdk_java_files.bp b/openjdk_java_files.bp
index 94805709c61..f79658ef8f6 100644
--- a/openjdk_java_files.bp
+++ b/openjdk_java_files.bp
@@ -1806,6 +1806,9 @@ filegroup {
// All classes, whether exposed in any API or not.
filegroup {
name: "openjdk_java_files",
+ visibility: [
+ "//frameworks/base",
+ ],
srcs: [
":openjdk_javadoc_files",
":openjdk_mmodule_extra_files",