1// Copyright (C) 2007 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//
16// Definitions for building the Android core library and associated tests.
17//
18
19// The Android core library provides low-level APIs for use by the rest of the
20// Android software stack. It is made up of various parts, some of which can be
21// found in libcore/ and other parts that can be found in various external/
22// directories.
23//
24// libcore has some sub-directories that follow a common structure:
25// e.g. dalvik, dom, harmony-tests, json, jsr166-tests, luni, libart, ojluni,
26// support, xml, xmlpull.
27//
28// The structure of these is generally:
29//
30//   src/
31//       main/               # To be shipped on every device.
32//            java/          # Java source for library code.
33//            native/        # C/C++ source for library code.
34//            resources/     # Support files.
35//       test/               # Built only on demand, for testing.
36//            java/          # Java source for tests.
37//            native/        # C/C++ source for tests (rare).
38//            resources/     # Support files.
39//
40// All subdirectories are optional.
41
42build = [
43    "openjdk_java_files.bp",
44    "non_openjdk_java_files.bp",
45]
46
47// The Java files and their associated resources.
48filegroup {
49    name: "core-luni-resources",
50    visibility: [
51        "//libcore:__subpackages__",
52    ],
53    path: "luni/src/main/java/",
54    srcs: [
55        "luni/src/main/java/java/util/logging/logging.properties",
56        "luni/src/main/java/java/security/security.properties",
57    ],
58}
59
60filegroup {
61    name: "core-ojluni-resources",
62    visibility: [
63        "//libcore:__subpackages__",
64    ],
65    path: "ojluni/src/main/resources/",
66    srcs: [
67        "ojluni/src/main/resources/**/*",
68    ],
69}
70
71core_resources = [
72    ":core-luni-resources",
73    ":core-ojluni-resources",
74]
75
76// The source files that go into core-oj.
77filegroup {
78    name: "core_oj_java_files",
79    visibility: [
80        "//libcore:__subpackages__",
81    ],
82    srcs: [":openjdk_java_files"],
83}
84
85// http://b/129765390, http://b/188966706
86// Rewrite links to "platform" or "technotes" folders which are siblings
87// (and thus outside of) {@docRoot}.
88//
89// We have to escape \ as \\ and $ as $$ here because they get resolved by
90// different layers of the build tooling. The arguments are wrapped in '' so
91// that the shell doesn't add yet another level of escaping.
92rewrite_openjdk_doc_links = "sed 's" +
93    "!\\({@docRoot}/\\.\\.\\/\\|[./]\\+\\)\\(\\(platform\\|technotes\\).\\+\\)\">" +
94    "!https://docs.oracle.com/javase/8/docs/\\2\">!' " +
95    "$(in) > $(out)"
96
97// OpenJDK source is not annotated with @hide so we need this separate
98// filegroup for just the parts that contribute to the API.
99gensrcs {
100    name: "core_oj_api_files",
101    cmd: rewrite_openjdk_doc_links,
102    srcs: [":openjdk_javadoc_files"],
103    output_extension: "java",
104}
105
106// The source files that go into core-libart.l
107filegroup {
108    name: "core_libart_java_files",
109    visibility: [
110        "//libcore:__subpackages__",
111    ],
112    srcs: [
113        ":non_openjdk_java_files",
114    ],
115}
116
117// Some parts of libart are not annotated with @hide so we need this separate
118// filegroup for just the parts that contribute to the API.
119filegroup {
120    name: "core_libart_api_files",
121    srcs: [
122        ":non_openjdk_javadoc_files",
123    ],
124}
125
126// The set of files for the ART module that contribute to one or more API
127// surfaces. This includes files that are in the public API as well as those
128// that are not but which have been marked up with @hide plus one or more of
129// the API defining annotations.
130//
131// Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are
132// annotated by applying annotations to the .annotated.java stubs files in
133// ojluni/annotated/mmodules and rather than in the original source. See the comments
134// in openjdk_java_files.bp for more details.
135filegroup {
136    name: "art_module_api_files",
137    visibility: [
138        "//libcore:__subpackages__",
139    ],
140    srcs: [
141        ":apache-xml_api_files",
142        ":bouncycastle_java_files",
143        ":core_oj_api_files",
144        ":core_libart_api_files",
145        ":okhttp_api_files",
146        ":openjdk_mmodule_extra_files",
147    ],
148}
149
150java_defaults {
151    name: "libcore_java_defaults",
152    javacflags: [
153        //"-Xlint:all",
154        //"-Xlint:-serial,-deprecation,-unchecked",
155    ],
156    dxflags: ["--core-library"],
157    errorprone: {
158        javacflags: [
159            "-Xep:MissingOverride:OFF", // Ignore missing @Override.
160            "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
161            "-Xep:UnicodeInCode:WARN", // XML parser uses line feeds in whitespace
162        ],
163    },
164    min_sdk_version: "31",
165}
166
167//
168// Build for the target (device).
169//
170
171// A target used to bootstrap compilation for the core library.
172//
173// See core-all-system-modules for more details.
174java_library {
175    name: "core-all",
176    defaults: ["libcore_java_defaults"],
177
178    srcs: [
179        // Use the source code for the I18N module intra core API as using the
180        // compiled version does not work due to limitations in either soong or the javac
181        // toolchain. See http://b/142056316 for more details.
182        ":i18n.module.intra.core.api{.public.stubs.source}",
183        ":core_oj_java_files",
184        ":core_libart_java_files",
185        // framework-api-annotations contain API annotations, e.g. @SystemApi.
186        ":framework-api-annotations",
187        ":openjdk_lambda_stub_files",
188        ":openjdk_generated_annotation_stub_files",
189        ":app-compat-annotations-source",
190
191        // Use the okhttp source too to allow libcore code to reference it
192        // directly.
193        ":okhttp_impl_files",
194    ],
195
196    sdk_version: "none",
197    system_modules: "none",
198    patch_module: "java.base",
199    openjdk9: {
200        srcs: ["luni/src/module/java/module-info.java"],
201    },
202
203    java_resources: core_resources,
204
205    installable: false,
206
207    plugins: [
208        "compat-changeid-annotation-processor",
209        "unsupportedappusage-annotation-processor",
210    ],
211    libs: [
212        "conscrypt.module.intra.core.api",
213    ],
214}
215
216platform_compat_config {
217    name: "libcore-platform-compat-config",
218    src: ":core-all",
219    visibility: [
220        "//art/build/apex",
221        "//art/build/sdk",
222    ],
223}
224
225// A system modules definition for use by core library targets only. It only
226// contains the core-all jar, which contains the classes that end up in core-oj,
227// core-libart as well as the lambda stubs needed to compile Java lambda code.
228// It does not contain other parts of core library like conscrypt, bouncycastle,
229// etc. This system_modules definition is used to bootstrap compilation for
230// other parts of the core library like core-oj, core-libart, conscrypt,
231// bouncycastle, etc. It is also used to compile Libcore tests, as well as ART
232// Java tests (run-tests).
233java_system_modules {
234    name: "core-all-system-modules",
235
236    // Visibility is deliberately restricted to a small set of build modules that
237    // the core library team control.
238    visibility: [
239        "//art/test:__subpackages__",
240        "//external/apache-harmony:__subpackages__",
241        "//external/apache-xml",
242        "//external/okhttp",
243        "//libcore:__subpackages__",
244    ],
245
246    libs: ["core-all"],
247}
248
249// Contains the parts of core library associated with OpenJDK.
250java_library {
251    name: "core-oj",
252    visibility: [
253        "//art/build/apex",
254        "//art/build/sdk",
255        "//external/wycheproof",
256        "//libcore/benchmarks",
257        "//packages/modules/ArtPrebuilt",
258    ],
259    apex_available: [
260        "com.android.art",
261        "com.android.art.debug",
262    ],
263    defaults: ["libcore_java_defaults"],
264    installable: true,
265    hostdex: true,
266
267    srcs: [":core_oj_java_files"],
268    java_resources: core_resources,
269
270    sdk_version: "none",
271    system_modules: "core-all-system-modules",
272    patch_module: "java.base",
273
274    jacoco: {
275        exclude_filter: [
276            "java.lang.Class",
277            "java.lang.Long",
278            "java.lang.Number",
279            "java.lang.Object",
280            "java.lang.String",
281            "java.lang.invoke.MethodHandle",
282            "java.lang.invoke.VarHandle",
283            "java.lang.ref.Reference",
284            "java.lang.reflect.Proxy",
285            "java.util.AbstractMap",
286            "java.util.HashMap",
287            "java.util.HashMap$Node",
288            "java.util.Map",
289        ],
290    },
291
292    notice: "ojluni/NOTICE",
293
294    hiddenapi_additional_annotations: [
295        "core-oj-hiddenapi-annotations",
296    ],
297}
298
299// Contains parts of core library not associated with OpenJDK. Contains not
300// just java.*, javax.* code but also android.system.* and various internal
301// libcore.* packages.
302java_library {
303    name: "core-libart",
304    visibility: [
305        "//art/build/apex",
306        "//art/build/sdk",
307        "//external/wycheproof",
308        "//libcore/benchmarks",
309        "//packages/modules/ArtPrebuilt",
310    ],
311    apex_available: [
312        "com.android.art",
313        "com.android.art.debug",
314    ],
315    defaults: ["libcore_java_defaults"],
316    installable: true,
317    hostdex: true,
318
319    srcs: [":core_libart_java_files"],
320
321    sdk_version: "none",
322    system_modules: "core-all-system-modules",
323    patch_module: "java.base",
324
325    jacoco: {
326        exclude_filter: [
327            "java.lang.DexCache",
328            "dalvik.system.ClassExt",
329        ],
330    },
331
332    target: {
333        hostdex: {
334            required: [
335                // Files used to simulate the /system, runtime APEX and tzdata
336                // APEX dir structure on host.
337                "icu_tzdata.dat_host_tzdata_apex",
338                "tzdata_host",
339                "tzdata_host_tzdata_apex",
340                "tzlookup.xml_host_tzdata_apex",
341                "tz_version_host",
342                "tz_version_host_tzdata_apex",
343            ],
344        },
345        darwin: {
346            enabled: false,
347        },
348    },
349}
350
351// Java library for use on host, e.g. by robolectric or layoutlib.
352java_library {
353    name: "core-libart-for-host",
354    visibility: [
355        "//art/build/sdk",
356        "//external/robolectric-shadows",
357        "//frameworks/layoutlib",
358    ],
359    static_libs: [
360        "core-libart",
361    ],
362    sdk_version: "none",
363    system_modules: "none",
364}
365
366// Provided solely to contribute information about which hidden parts of the
367// core-oj API are used by apps.
368//
369// Usually, e.g. for core-libart, the UnsupportedAppUsage annotations are
370// added to the source that is compiled directly into the bootjar and the build
371// system extracts the information about UnsupportedAppUsage directly from
372// there.
373//
374// This approach of having separate annotated source and a separate build
375// target was taken for ojluni to avoid having to maintain local patches in the
376// ojluni source for UnsupportedAppUsage annotations as that would make it more
377// difficult to pull down changes from upstream.
378//
379java_library {
380    name: "core-oj-hiddenapi-annotations",
381    // Do not allow this to be accessed from outside this directory.
382    visibility: ["//visibility:private"],
383    defaults: ["libcore_java_defaults"],
384    compile_dex: true,
385
386    srcs: [":openjdk_hiddenapi_javadoc_files"],
387
388    sdk_version: "none",
389    system_modules: "core-all-system-modules",
390    patch_module: "java.base",
391    plugins: ["unsupportedappusage-annotation-processor"],
392}
393
394java_defaults {
395    name: "core_lambda_stubs_defaults",
396    defaults: ["libcore_java_defaults"],
397    hostdex: true,
398
399    sdk_version: "none",
400    system_modules: "core-all-system-modules",
401    patch_module: "java.base",
402
403    notice: "ojluni/NOTICE",
404
405    installable: false,
406    include_srcs: true,
407}
408
409// Creates a jar that exists to satisfy javac when compiling source code that
410// contains lambdas. This contains all classes / methods required by javac
411// when generating invoke-dynamic lambda implementation code, even those that
412// are also in the public SDK API from API level 26 onwards.
413java_library {
414    name: "core-lambda-stubs",
415    visibility: ["//visibility:public"],
416    defaults: ["core_lambda_stubs_defaults"],
417    srcs: [
418        ":openjdk_lambda_stub_files",
419        ":openjdk_lambda_duplicate_stub_files",
420    ],
421    // This jar is packaged as part of the SDK, use -target 8 so that it works
422    // with old JDKs.
423    java_version: "1.8",
424}
425
426// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files
427// because those classes are also part of the core library public SDK API
428// (since API level 26).
429java_library {
430    name: "core-lambda-stubs-for-system-modules",
431    visibility: [
432        "//art/build/sdk",
433        "//build/soong/java/core-libraries",
434    ],
435    defaults: ["core_lambda_stubs_defaults"],
436    srcs: [
437        ":openjdk_lambda_stub_files",
438    ],
439    include_srcs: true,
440}
441
442// Creates a jar that exists to satisfy javac when compiling source code that
443// contains @Generated annotations, which are produced by some code generation
444// tools (notably dagger) but aren't part of the Android API.
445// See http://b/123891440.
446java_library {
447    name: "core-generated-annotation-stubs",
448    visibility: [
449        "//art/build/sdk",
450        "//build/soong/java/core-libraries",
451    ],
452    defaults: ["libcore_java_defaults"],
453    srcs: [
454        ":openjdk_generated_annotation_stub_files",
455    ],
456    hostdex: true,
457    sdk_version: "none",
458    system_modules: "core-all-system-modules",
459    patch_module: "java.base",
460    notice: "ojluni/NOTICE",
461    installable: false,
462    include_srcs: true,
463}
464
465// Builds libcore test rules
466java_library_static {
467    name: "core-test-rules",
468    visibility: [
469        "//art/build/sdk",
470        "//cts/tests/tests/util",
471        "//external/conscrypt",
472        "//external/conscrypt/apex/tests",
473        "//frameworks/base/location/tests/locationtests",
474        "//frameworks/base/core/tests/coretests",
475        "//frameworks/base/wifi/tests",
476        "//libcore/luni/src/test/java9compatibility",
477        "//packages/modules/Wifi/framework/tests",
478    ],
479    hostdex: true,
480    srcs: [
481        "dalvik/test-rules/src/main/**/*.java",
482        "test-rules/src/main/**/*.java",
483    ],
484    static_libs: ["junit"],
485
486    sdk_version: "none",
487    system_modules: "core-all-system-modules",
488}
489
490// Builds platform_compat test rules
491java_library_static {
492    name: "core-compat-test-rules",
493    visibility: [
494        "//art/build/sdk",
495        "//frameworks/base/tests/PlatformCompatGating/test-rules",
496    ],
497    srcs: [
498        "luni/src/main/java/android/compat/**/*.java",
499        "test-rules/src/platform_compat/**/*.java",
500        "luni/src/main/java/libcore/api/CorePlatformApi.java",
501        "luni/src/main/java/libcore/api/IntraCoreApi.java",
502    ],
503    static_libs: [
504        "junit",
505        "guava",
506    ],
507    sdk_version: "none",
508    system_modules: "core-all-system-modules",
509    // This builds classes that are in the java.base Java module:
510    patch_module: "java.base",
511    hostdex: true,
512}
513
514// Builds the core-tests-support library used by various tests.
515java_library_static {
516    name: "core-tests-support",
517    visibility: [
518        "//art/build/sdk",
519        "//cts/apps/CtsVerifier",
520        "//cts/tests/tests/keystore",
521        "//cts/tests/tests/net",
522        "//cts/tests/tests/net/api23Test",
523        "//external/apache-harmony",
524        "//frameworks/base/core/tests/coretests",
525        "//libcore/benchmarks",
526        "//packages/apps/KeyChain/tests",
527        "//system/timezone/distro/core",
528        "//packages/modules/Connectivity/tests:__subpackages__",
529    ],
530    hostdex: true,
531    srcs: ["support/src/test/java/**/*.java"],
532
533    sdk_version: "core_platform",
534    libs: ["junit"],
535    static_libs: [
536        "bouncycastle-unbundled",
537        "bouncycastle-bcpkix-unbundled",
538        "bouncycastle-ocsp-unbundled",
539    ],
540}
541
542// Builds the jsr166-tests library.
543java_test {
544    name: "jsr166-tests",
545    visibility: [
546        "//art/build/sdk",
547        "//cts/tests/libcore/jsr166",
548    ],
549    srcs: ["jsr166-tests/src/test/java/**/*.java"],
550    sdk_version: "none",
551    system_modules: "core-all-system-modules",
552    libs: [
553        "junit",
554    ],
555    errorprone: {
556        javacflags: [
557            "-Xep:DoNotCall:OFF",
558        ],
559    },
560}
561
562// A filegroup that provides access to a source file for a toolchain test that
563// checks Java 9 language features are handled properly by JarJar.
564filegroup {
565    name: "core-java-9-language-features-source",
566    srcs: ["luni/src/main/java/libcore/internal/Java9LanguageFeatures.java"],
567    visibility: ["//libcore/luni/src/test/java9language"],
568}
569
570// A filegroup that provides access to a source file for a toolchain test that
571// checks Java 11 language features are handled properly by JarJar.
572filegroup {
573    name: "core-java-11-language-features-source",
574    srcs: ["luni/src/main/java/libcore/internal/Java11LanguageFeatures.java"],
575    visibility: ["//libcore/luni/src/test/java11language"],
576}
577
578genrule {
579    name: "core-tests-smali-dex",
580    srcs: ["luni/src/test/java/**/*.smali"],
581    cmd: "$(location smali) ass --api 28 -o $(out) $(in)",
582    out: ["core-tests-smali.dex"],
583    tools: ["smali"],
584}
585
586filegroup {
587    name: "core-ojtests-javax-resources",
588    // Set path to keep the resources and .class files in the same directory in the jar file.
589    path: "ojluni/src",
590    srcs: ["ojluni/src/test/javax/**/*"],
591    exclude_srcs: ["ojluni/src/test/javax/**/*.java"],
592}
593
594// Builds the core-tests library.
595java_test {
596    name: "core-tests",
597    visibility: [
598        "//art/build/sdk",
599        "//cts/tests/libcore/luni",
600    ],
601    defaults: ["libcore_java_defaults"],
602    hostdex: true,
603    srcs: [
604        "dalvik/src/test/java/**/*.java",
605        "dalvik/test-rules/src/test/java/**/*.java",
606        "dom/src/test/java/**/*.java",
607        "harmony-tests/src/test/java/**/*.java",
608        "json/src/test/java/**/*.java",
609        "luni/src/test/java/**/*.java",
610        "test-rules/src/test/java/**/*.java",
611        "xml/src/test/java/**/*.java",
612    ],
613    exclude_srcs: [
614        "harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/*.java",
615        "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
616        "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
617        "luni/src/test/java/libcore/javax/crypto/**/*.java",
618        "luni/src/test/java/libcore/javax/net/ssl/**/*.java",
619        "luni/src/test/java/org/apache/harmony/crypto/**/*.java",
620    ],
621
622    java_resource_dirs: [
623        "*/src/test/java",
624        "*/src/test/resources",
625    ],
626    exclude_java_resource_dirs: [
627        "ojluni/src/test/java",
628        "ojluni/src/test/javax",
629        "ojluni/src/test/resources",
630    ],
631
632    java_resources: [
633        ":annotations-test",
634        ":filesystemstest",
635        ":parameter-metadata-test",
636        ":core-tests-smali-dex",
637    ],
638
639    sdk_version: "none",
640    system_modules: "core-all-system-modules",
641    libs: [
642        "okhttp",
643        "bouncycastle",
644    ],
645
646    static_libs: [
647        "core-compat-test-rules",
648        "core-java-9-compatibility-tests",
649        "core-java-9-language-tests",
650        "core-java-11-language-tests",
651        "core-test-rules",
652        "core-tests-support",
653        "junit-params",
654        "libcore-crypto-tests",
655        "mockftpserver",
656        "mockito-target",
657        "mockwebserver",
658        "nist-pkix-tests",
659        "slf4j-jdk14",
660        "sqlite-jdbc",
661        "truth-prebuilt-jar",
662    ],
663
664    errorprone: {
665        javacflags: [
666            "-Xep:TryFailThrowable:ERROR",
667            "-Xep:ComparisonOutOfRange:ERROR",
668            "-Xep:DoNotCall:OFF",
669        ],
670    },
671
672    test_config: "AndroidTest-core-tests.xml",
673}
674
675java_test {
676    name: "libcore-crypto-tests",
677
678    visibility: [
679        "//art/build/sdk",
680        "//external/conscrypt/apex/tests",
681    ],
682    srcs: [
683        "harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/*.java",
684        "luni/src/test/java/libcore/javax/crypto/**/*.java",
685        "luni/src/test/java/libcore/javax/net/ssl/**/*.java",
686        "luni/src/test/java/libcore/libcore/util/SerializationTester.java",
687        "luni/src/test/java/libcore/sun/security/**/*.java",
688        "luni/src/test/java/org/apache/harmony/crypto/**/*.java",
689    ],
690
691    java_resource_dirs: [
692        "luni/src/test/java",
693        "luni/src/test/resources",
694        "support/src/test/java",
695    ],
696
697    sdk_version: "none",
698    system_modules: "core-all-system-modules",
699
700    static_libs: [
701        "core-test-rules",
702        "core-tests-support",
703        "junit-params",
704        "mockito-target",
705    ],
706}
707
708// Builds the core-ojtests library that contains test code from OpenJDK.
709java_test {
710    name: "core-ojtests",
711    defaults: ["libcore_java_defaults"],
712    hostdex: true,
713
714    srcs: [
715        "ojluni/src/test/java/**/*.java",
716        "ojluni/src/test/javax/**/*.java",
717        "ojluni/src/test/sun/**/*.java",
718    ],
719    java_resource_dirs: [
720        "ojluni/src/test/java",
721        "ojluni/src/test/resources",
722    ],
723
724    java_resources: [
725        ":core-ojtests-javax-resources",
726    ],
727
728    sdk_version: "none",
729    system_modules: "core-all-system-modules",
730    libs: [
731        "okhttp",
732        "bouncycastle",
733    ],
734
735    static_libs: [
736        "junit",
737        "testng",
738    ],
739
740    // ojluni/src/test/java/util/stream/{bootlib,boottest}
741    // contains tests that are in packages from java.base;
742    // By default, OpenJDK 9's javac will only compile such
743    // code if it's declared to also be in java.base at
744    // compile time.
745    //
746    // For now, we use patch_module to put all sources
747    // and dependencies from this make target into java.base;
748    // other source directories in this make target are in
749    // packages not from java.base; if this becomes a problem
750    // in future, this could be addressed eg. by splitting
751    // boot{lib,test} out into a separate make target,
752    // deleting those tests or moving them to a different
753    // package.
754    patch_module: "java.base",
755
756    errorprone: {
757        javacflags: [
758            "-Xep:AlwaysThrows:OFF",
759            "-Xep:DoNotCall:OFF",
760        ],
761    },
762}
763
764// Builds the core-ojtests-public library. Excludes any private API tests.
765// Like core-ojtests but smaller.
766java_test {
767    name: "core-ojtests-public",
768    visibility: [
769        "//art/build/sdk",
770        "//cts/tests/libcore/ojluni",
771    ],
772    defaults: ["libcore_java_defaults"],
773    srcs: [
774        "ojluni/src/test/java/**/*.java",
775        "ojluni/src/test/javax/**/*.java",
776        "ojluni/src/test/sun/**/*.java",
777    ],
778    // Filter out the following:
779    // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
780    //     and won't actually run, and
781    // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
782    //     excluding them means we don't need patch_module: "java.base"
783    exclude_srcs: [
784        "**/DeserializeMethodTest.java",
785        "**/SerializedLambdaTest.java",
786        "ojluni/src/test/java/util/stream/boot*/**/*",
787    ],
788    java_resource_dirs: [
789        "ojluni/src/test/java",
790        "ojluni/src/test/resources",
791        // Include source code as part of JAR
792        "ojluni/src/test/dist",
793    ],
794
795    java_resources: [
796        ":core-ojtests-javax-resources",
797    ],
798
799    sdk_version: "none",
800    system_modules: "core-all-system-modules",
801    libs: [
802        "bouncycastle",
803        "junit",
804        "okhttp",
805        "testng",
806    ],
807
808    errorprone: {
809        javacflags: [
810            "-Xep:AlwaysThrows:OFF",
811            "-Xep:DoNotCall:OFF",
812        ],
813    },
814}
815
816// Exports annotated stubs source files in ojluni/annotations/sdk to make them
817// available to metalava. Used for nullability annotations in OpenJDK source.
818droiddoc_exported_dir {
819    name: "ojluni-annotated-sdk-stubs",
820    visibility: [
821        "//libcore:__subpackages__",
822    ],
823    path: "ojluni/annotations/sdk",
824}
825
826droiddoc_exported_dir {
827    name: "ojluni-annotated-nullability-stubs",
828    path: "ojluni/annotations/sdk/nullability",
829}
830
831// Exports annotated stubs source files in ojluni/annotations/mmodules to make
832// them available to metalava. Used for core platform API and intra-core API
833// annotations in OpenJDK source.
834droiddoc_exported_dir {
835    name: "ojluni-annotated-mmodule-stubs",
836    visibility: [
837        "//libcore/mmodules/intracoreapi",
838    ],
839    path: "ojluni/annotations/mmodule",
840}
841
842// A file containing the list of tags that are "known" to us from the OpenJdk
843// source code and so should not cause an error or warning.
844filegroup {
845    name: "known-oj-tags",
846    visibility: [
847        "//frameworks/base",
848    ],
849    srcs: [
850        "known_oj_tags.txt",
851    ],
852}
853
854// A special set of stubs containing the minimal set of self consistent
855// classes for which a system module can be created. Every system module must
856// contain the java.lang classes so the set was constructed by starting with
857// the java.lang classes and then adding their transitive dependencies without
858// splitting packages. So, if one class from a package is used then all classes
859// in that package were added to the set.
860//
861// Needed for java-current-stubs-system-modules.
862droidstubs {
863    name: "java-current-stubs-source",
864    srcs: [
865        ":core_oj_api_files",
866        ":core_libart_api_files",
867    ],
868    installable: false,
869    sdk_version: "none",
870    system_modules: "none",
871
872    args: "--stub-packages java.*:javax.*:org.w3c.dom.*:org.xml.sax.*",
873}
874
875java_library {
876    name: "java.current.stubs",
877    srcs: [":java-current-stubs-source"],
878    errorprone: {
879        javacflags: [
880            "-Xep:MissingOverride:OFF",
881        ],
882    },
883    patch_module: "java.base",
884    sdk_version: "none",
885    system_modules: "none",
886}
887
888// A special set of system modules needed to build art.module.public.api
889// that contain nullability annotations when targeting java language level 1.9
890// and above.
891java_system_modules {
892    name: "java-current-stubs-system-modules",
893    libs: [
894        // Minimal set of classes required for a system module.
895        "java.current.stubs",
896
897        // The nullability annotations used by the generated stubs.
898        "stub-annotations",
899    ],
900}
901
902java_library {
903    name: "framework-api-annotations-lib",
904    srcs: [":framework-api-annotations"],
905    sdk_version: "none",
906    patch_module: "java.base",
907    system_modules: "core-all-system-modules",
908    installable: false,
909    visibility: [
910        "//visibility:private",
911    ],
912}
913
914// Define the public SDK API provided by the ART module.
915java_sdk_library {
916    name: "art.module.public.api",
917    visibility: [
918        "//art/build/sdk",
919        "//build/soong/java/core-libraries",
920        "//frameworks/base",
921        "//frameworks/base/api",
922    ],
923    srcs: [
924        ":core_oj_api_files",
925        ":core_libart_api_files",
926
927        // Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are
928        // annotated by applying annotations to the .annotated.java stubs files in
929        // ojluni/annotated/mmodules and rather than in the original source. See the comments
930        // in openjdk_java_files.bp for more details.
931        ":openjdk_mmodule_extra_files",
932        ":okhttp_api_files",
933
934    ],
935    libs: [
936        // Put framework-api-annotations into libs to avoid exposing the definition of framework's
937        // annotations from libcore (wrong place) instead of framework (correct place).
938        "framework-api-annotations-lib",
939        // Provide access to I18N constants that are used to initialize
940        // constants in the public API. i.e. to allow the value of the
941        // java.text.CollectionElementIterator.NULLORDER to be initialized from
942        // android.icu.text.CollationElementIterator.NULLORDER.
943        "i18n.module.intra.core.api.stubs",
944    ],
945    stub_only_static_libs: ["notices-for-stubs-jar"],
946
947    // Make dex jars for the stubs available for use by hiddenapi processing.
948    compile_dex: true,
949
950    public: {
951        enabled: true,
952    },
953    system: {
954        enabled: true,
955    },
956    module_lib: {
957        enabled: true,
958    },
959
960    api_only: true,
961    droiddoc_options: [
962        "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.* ",
963        "--hide-annotation libcore.api.Hide",
964    ],
965
966    merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
967    // Emit nullability annotations from the source to the stub files.
968    annotations_enabled: true,
969
970    merge_annotations_dirs: [
971        "metalava-manual",
972        "ojluni-annotated-sdk-stubs",
973    ],
974
975    doctag_files: [
976        ":known-oj-tags",
977    ],
978
979    errorprone: {
980        javacflags: [
981            "-Xep:MissingOverride:OFF",
982        ],
983    },
984    patch_module: "java.base",
985    sdk_version: "none",
986    system_modules: "java-current-stubs-system-modules",
987    // The base name for the artifacts that are automatically published to the
988    // dist and which end up in one of the sub-directories of prebuilts/sdk.
989    // As long as this matches the name of the artifacts in prebuilts/sdk then
990    // the API will be checked for compatibility against the latest released
991    // version of the API.
992    dist_stem: "art",
993    dist_group: "android",
994}
995
996// Used when compiling higher-level code against art.module.public.api.stubs.
997//
998// This is only intended for use within core libraries and must not be used
999// from outside.
1000java_system_modules {
1001    name: "art-module-public-api-stubs-system-modules",
1002    visibility: [
1003        "//art/build/sdk",
1004        "//external/conscrypt",
1005        "//external/icu/android_icu4j",
1006        "//external/wycheproof",
1007    ],
1008    libs: [
1009        "art.module.public.api.stubs",
1010        // This one is not on device but it's needed when javac compiles code
1011        // containing lambdas.
1012        "core-lambda-stubs-for-system-modules",
1013        // This one is not on device but it's needed when javac compiles code
1014        // containing @Generated annotations produced by some code generation
1015        // tools.
1016        // See http://b/123891440.
1017        "core-generated-annotation-stubs",
1018
1019        // Ensure that core libraries that depend on the public API can access
1020        // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
1021        // annotations.
1022        "art.module.api.annotations.for.system.modules",
1023
1024        // Make nullability annotations available when compiling public stubs.
1025        // They are provided as a separate library because while the
1026        // annotations are not themselves part of the public API provided by
1027        // this module they are used in the stubs.
1028        "stub-annotations",
1029    ],
1030}
1031
1032// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
1033//
1034// This is only intended for use within core libraries and must not be used
1035// from outside.
1036java_system_modules {
1037    name: "art-module-lib-api-stubs-system-modules",
1038    visibility: [
1039        "//art/build/sdk",
1040        "//external/conscrypt",
1041        "//external/icu/android_icu4j",
1042    ],
1043    libs: [
1044        "art.module.public.api.stubs.module_lib",
1045    ],
1046}
1047
1048// Target for validating nullability annotations for correctness and
1049// completeness. To check that there are no nullability errors:
1050//   m art-module-public-api-stubs-nullability-validation
1051// To check that there are only the expected nullability warnings:
1052//   m art-module-public-api-stubs-nullability-validation-check-nullability-warnings
1053// (If that check fails, it will provide instructions on how to proceed,
1054// including the command to run to update the expected warnings file.)
1055droidstubs {
1056    name: "art-module-public-api-stubs-nullability-validation",
1057    srcs: [":art_module_api_files"],
1058    installable: false,
1059    sdk_version: "none",
1060    system_modules: "none",
1061    annotations_enabled: true,
1062    args: "--hide-annotation libcore.api.Hide " +
1063        "--validate-nullability-from-merged-stubs ",
1064    merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
1065    merge_annotations_dirs: [
1066        // N.B. Stubs in this filegroup will be validated:
1067        "ojluni-annotated-nullability-stubs",
1068    ],
1069    // The list of classes which have nullability annotations included in the source.
1070    // (This is in addition to those which have annotations in the merged stubs.)
1071    validate_nullability_from_list: "nullability_annotated_classes.txt",
1072    // The expected set of warnings about missing annotations:
1073    check_nullability_warnings: "nullability_warnings.txt",
1074}
1075
1076// A special set of system modules for building the following library for use
1077// in the art-module-public-api-system-modules.
1078java_system_modules {
1079    name: "api-annotations-system-modules",
1080    libs: [
1081        "art.module.public.api.stubs",
1082    ],
1083}
1084
1085// A library that contains annotations that define API surfaces (core
1086// platform, intra core and the hidden API) along with some supporting
1087// constants. The annotations are source only and do not introduce any runtime
1088// dependencies. Specially built for use in system modules definitions to
1089// avoid introducing compile time cycles.
1090java_library {
1091    name: "art.module.api.annotations.for.system.modules",
1092    visibility: [
1093        "//art/libartservice",
1094    ],
1095    srcs: [
1096        ":api_surface_annotation_files",
1097    ],
1098
1099    installable: false,
1100    sdk_version: "none",
1101    system_modules: "api-annotations-system-modules",
1102    patch_module: "java.base",
1103}
1104
1105// Create a library containing the api surface annotations, built against
1106// core_current for use by the annotation processor in frameworks/base.
1107java_library {
1108    name: "art.module.api.annotations",
1109    visibility: [
1110        "//art/build/sdk",
1111        "//external/icu/android_icu4j",
1112        "//frameworks/base",
1113    ],
1114    host_supported: true,
1115    srcs: [
1116        ":api_surface_annotation_files",
1117    ],
1118    sdk_version: "core_current",
1119}
1120