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 -E 's" + 93 "!(\\{@docRoot\\}/\\.\\./|[./]+)((platform|technotes).+)\">" + 94 "!https://docs.oracle.com/javase/8/docs/\\2\">!' " + 95 "$(in) " + 96 "| sed -E 's" + // Android doesn't have java.base in the API docs 97 "!(\\{@docRoot\\}/)(java\\.base/)(.+)\">" + 98 "!\\1reference/\\3\">!' " + 99 "| sed -E 's" + 100 "!(\\{@docRoot\\}/\\.\\./)(specs/.+)\">" + 101 "!https://docs.oracle.com/en/java/javase/17/docs/\\2\">!' " + 102 " > $(out) " + 103 "&& ! grep '{@docRoot}/../' $(out)" // exit with 1 if "{@docRoot}/../" still exists. 104 105// OpenJDK source is not annotated with @hide so we need this separate 106// filegroup for just the parts that contribute to the API. 107gensrcs { 108 name: "core_oj_api_files", 109 cmd: rewrite_openjdk_doc_links, 110 srcs: [":openjdk_javadoc_files"], 111 output_extension: "java", 112} 113 114// The source files that go into core-libart.l 115filegroup { 116 name: "core_libart_java_files", 117 visibility: [ 118 "//libcore:__subpackages__", 119 ], 120 srcs: [ 121 ":non_openjdk_java_files", 122 ], 123} 124 125// Some parts of libart are not annotated with @hide so we need this separate 126// filegroup for just the parts that contribute to the API. 127filegroup { 128 name: "core_libart_api_files", 129 srcs: [ 130 ":non_openjdk_javadoc_files", 131 ], 132} 133 134// The set of files for the ART module that contribute to one or more API 135// surfaces. This includes files that are in the public API as well as those 136// that are not but which have been marked up with @hide plus one or more of 137// the API defining annotations. 138// 139// Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are 140// annotated by applying annotations to the .annotated.java stubs files in 141// ojluni/annotated/mmodules and rather than in the original source. See the comments 142// in openjdk_java_files.bp for more details. 143filegroup { 144 name: "art_module_api_files", 145 visibility: [ 146 "//libcore:__subpackages__", 147 ], 148 srcs: [ 149 ":apache-xml_api_files", 150 ":bouncycastle_java_files", 151 ":core_oj_api_files", 152 ":core_libart_api_files", 153 ":okhttp_api_files", 154 ":openjdk_mmodule_extra_files", 155 ], 156} 157 158java_defaults { 159 name: "libcore_java_defaults", 160 visibility: [ 161 "//libcore:__subpackages__", 162 ], 163 javacflags: [ 164 //"-Xlint:all", 165 //"-Xlint:-serial,-deprecation,-unchecked", 166 ], 167 dxflags: [ 168 "--android-platform-build", 169 "--core-library", 170 ], 171 errorprone: { 172 javacflags: [ 173 "-Xep:MissingOverride:OFF", // Ignore missing @Override. 174 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom 175 "-Xep:UnicodeInCode:WARN", // XML parser uses line feeds in whitespace 176 "-Xep:ReturnValueIgnored:WARN", 177 "-Xep:HashtableContains:WARN", 178 "-Xep:ComparableType:WARN", 179 "-Xep:IdentityBinaryExpression:WARN", 180 "-Xep:BoxedPrimitiveEquality:WARN", 181 "-Xep:EmptyTopLevelDeclaration:WARN", 182 "-Xep:GetClassOnClass:WARN", 183 "-Xep:NullableOnContainingClass:WARN", 184 "-Xep:GetClassOnAnnotation:WARN", 185 "-Xep:DoNotCall:WARN", 186 ], 187 }, 188 lint: { 189 warning_checks: [ 190 "SuspiciousIndentation", 191 "NewApi", 192 ], 193 }, 194 min_sdk_version: "31", 195} 196 197// 198// Build for the target (device). 199// 200 201// A target used to bootstrap compilation for the core library. 202// 203// See core-all-system-modules for more details. 204java_library { 205 name: "core-all", 206 defaults: ["libcore_java_defaults"], 207 208 srcs: [ 209 // Use the source code for the I18N module intra core API as using the 210 // compiled version does not work due to limitations in either soong or the javac 211 // toolchain. See http://b/142056316 for more details. 212 ":i18n.module.intra.core.api{.public.stubs.source}", 213 ":core_oj_java_files", 214 ":core_libart_java_files", 215 // framework-api-annotations contain API annotations, e.g. @SystemApi. 216 ":framework-api-annotations", 217 ":openjdk_lambda_stub_files", 218 ":app-compat-annotations-source", 219 220 // Use the okhttp source too to allow libcore code to reference it 221 // directly. 222 ":okhttp_impl_files", 223 ], 224 static_libs: [ 225 "art-aconfig-flags-java-lib-for-core-all-only", 226 "libcore-aconfig-flags-lib-for-core-all-only", 227 ], 228 229 sdk_version: "none", 230 system_modules: "none", 231 patch_module: "java.base", 232 openjdk9: { 233 srcs: ["luni/src/module/java/module-info.java"], 234 }, 235 236 java_resources: core_resources, 237 238 installable: false, 239 240 plugins: [ 241 "compat-changeid-annotation-processor", 242 "unsupportedappusage-annotation-processor", 243 ], 244 libs: [ 245 "conscrypt.module.intra.core.api.stubs", 246 ], 247 248 java_version: "21", 249} 250 251platform_compat_config { 252 name: "libcore-platform-compat-config", 253 src: ":core-all", 254 visibility: [ 255 "//art/build/apex", 256 "//art/build/sdk", 257 ], 258} 259 260// A system modules definition for use by core library targets only. It only 261// contains the core-all jar, which contains the classes that end up in core-oj, 262// core-libart as well as the lambda stubs needed to compile Java lambda code. 263// It does not contain other parts of core library like conscrypt, bouncycastle, 264// etc. This system_modules definition is used to bootstrap compilation for 265// other parts of the core library like core-oj, core-libart, conscrypt, 266// bouncycastle, etc. It is also used to compile Libcore tests, as well as ART 267// Java tests (run-tests). 268java_system_modules { 269 name: "core-all-system-modules", 270 271 // Visibility is deliberately restricted to a small set of build modules that 272 // the core library team control. 273 visibility: [ 274 "//art/build/flags", 275 "//art/test:__subpackages__", 276 "//build/make/tools/aconfig/aconfig_storage_file", 277 "//build/make/tools/aconfig/aconfig_storage_read_api", 278 "//build/make/tools/aconfig/fake_device_config", 279 "//external/apache-harmony:__subpackages__", 280 "//external/apache-xml", 281 "//external/icu", 282 "//external/conscrypt", 283 "//external/okhttp", 284 "//frameworks/libs/modules-utils/java", 285 "//libcore:__subpackages__", 286 "//tools/platform-compat/java/android/compat/annotation", 287 ], 288 289 libs: ["core-all"], 290} 291 292// Contains the parts of core library associated with OpenJDK. 293java_library { 294 name: "core-oj", 295 visibility: [ 296 "//art/build/apex", 297 "//art/build/sdk", 298 "//art/tools/ahat", 299 "//art/tools/fuzzer", 300 "//external/wycheproof", 301 "//libcore/benchmarks", 302 "//packages/modules/ArtPrebuilt", 303 ], 304 apex_available: [ 305 "com.android.art", 306 "com.android.art.debug", 307 ], 308 defaults: ["libcore_java_defaults"], 309 installable: true, 310 hostdex: true, 311 312 srcs: [":core_oj_java_files"], 313 java_resources: core_resources, 314 315 sdk_version: "none", 316 system_modules: "core-all-system-modules", 317 patch_module: "java.base", 318 319 jacoco: { 320 exclude_filter: [ 321 "java.lang.Class", 322 "java.lang.Long", 323 "java.lang.Number", 324 "java.lang.Object", 325 "java.lang.String", 326 "java.lang.invoke.MethodHandle", 327 "java.lang.invoke.VarHandle", 328 "java.lang.ref.Reference", 329 "java.lang.reflect.Proxy", 330 "java.util.AbstractMap", 331 "java.util.HashMap", 332 "java.util.HashMap$Node", 333 "java.util.Map", 334 ], 335 }, 336 337 hiddenapi_additional_annotations: [ 338 "core-oj-hiddenapi-annotations", 339 ], 340 341 errorprone: { 342 javacflags: [ 343 "-Xep:ReturnValueIgnored:WARN", 344 "-Xep:HashtableContains:WARN", 345 "-Xep:ComparableType:WARN", 346 "-Xep:IdentityBinaryExpression:WARN", 347 "-Xep:BoxedPrimitiveEquality:WARN", 348 "-Xep:EmptyTopLevelDeclaration:WARN", 349 "-Xep:GetClassOnClass:WARN", 350 ], 351 }, 352} 353 354// Contains parts of core library not associated with OpenJDK. Contains not 355// just java.*, javax.* code but also android.system.* and various internal 356// libcore.* packages. 357java_library { 358 name: "core-libart", 359 visibility: [ 360 "//art/build/apex", 361 "//art/build/sdk", 362 "//art/tools/ahat", 363 "//art/tools/fuzzer", 364 "//external/wycheproof", 365 "//libcore/benchmarks", 366 "//packages/modules/ArtPrebuilt", 367 ], 368 apex_available: [ 369 "com.android.art", 370 "com.android.art.debug", 371 ], 372 defaults: ["libcore_java_defaults"], 373 installable: true, 374 hostdex: true, 375 376 srcs: [":core_libart_java_files"], 377 static_libs: [ 378 "art-aconfig-flags-java-lib", 379 "libcore-aconfig-flags-lib", 380 ], 381 382 sdk_version: "none", 383 system_modules: "core-all-system-modules", 384 patch_module: "java.base", 385 386 jacoco: { 387 exclude_filter: [ 388 "java.lang.DexCache", 389 "dalvik.system.ClassExt", 390 ], 391 }, 392 393 target: { 394 hostdex: { 395 required: [ 396 // Files used to simulate the /system, runtime APEX and tzdata 397 // APEX dir structure on host. 398 "tzdata_icu_res_files_host_prebuilts", 399 "tzdata_host", 400 "tzdata_host_tzdata_apex", 401 "tzlookup.xml_host_tzdata_apex", 402 "tz_version_host", 403 "tz_version_host_tzdata_apex", 404 ], 405 }, 406 darwin: { 407 enabled: false, 408 }, 409 }, 410 411 errorprone: { 412 javacflags: [ 413 "-Xep:EmptyTopLevelDeclaration:WARN", 414 "-Xep:GetClassOnAnnotation:WARN", 415 "-Xep:NullableOnContainingClass:WARN", 416 ], 417 }, 418 419 java_version: "21", 420} 421 422// Java library for use on host, e.g. by robolectric or layoutlib. 423java_library { 424 name: "core-libart-for-host", 425 visibility: [ 426 "//art/build/sdk", 427 "//external/robolectric", 428 "//external/robolectric-shadows", 429 "//frameworks/base", 430 "//frameworks/layoutlib", 431 ], 432 static_libs: [ 433 "core-libart", 434 ], 435 sdk_version: "none", 436 system_modules: "none", 437} 438 439// Provided solely to contribute information about which hidden parts of the 440// core-oj API are used by apps. 441// 442// Usually, e.g. for core-libart, the UnsupportedAppUsage annotations are 443// added to the source that is compiled directly into the bootjar and the build 444// system extracts the information about UnsupportedAppUsage directly from 445// there. 446// 447// This approach of having separate annotated source and a separate build 448// target was taken for ojluni to avoid having to maintain local patches in the 449// ojluni source for UnsupportedAppUsage annotations as that would make it more 450// difficult to pull down changes from upstream. 451// 452java_library { 453 name: "core-oj-hiddenapi-annotations", 454 // Do not allow this to be accessed from outside this directory. 455 visibility: ["//libcore:__subpackages__"], 456 defaults: ["libcore_java_defaults"], 457 compile_dex: true, 458 459 srcs: [":openjdk_hiddenapi_javadoc_files"], 460 461 sdk_version: "none", 462 system_modules: "core-all-system-modules", 463 patch_module: "java.base", 464 plugins: ["unsupportedappusage-annotation-processor"], 465 466 errorprone: { 467 javacflags: [ 468 "-Xep:ComparableType:WARN", 469 ], 470 }, 471} 472 473java_defaults { 474 name: "core_lambda_stubs_defaults", 475 defaults: ["libcore_java_defaults"], 476 hostdex: true, 477 478 sdk_version: "none", 479 system_modules: "core-all-system-modules", 480 patch_module: "java.base", 481 482 installable: false, 483 include_srcs: true, 484} 485 486// Creates a jar that exists to satisfy javac when compiling source code that 487// contains lambdas. This contains all classes / methods required by javac 488// when generating invoke-dynamic lambda implementation code, even those that 489// are also in the public SDK API from API level 26 onwards. 490java_library { 491 name: "core-lambda-stubs", 492 visibility: [ 493 "//visibility:public", 494 ], 495 defaults: ["core_lambda_stubs_defaults"], 496 srcs: [ 497 ":openjdk_lambda_stub_files", 498 ":openjdk_lambda_duplicate_stub_files", 499 ], 500 // This jar is packaged as part of the SDK, use -target 8 so that it works 501 // with old JDKs. 502 java_version: "1.8", 503 is_stubs_module: true, 504} 505 506// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files 507// because those classes are also part of the core library public SDK API 508// (since API level 26). 509java_library { 510 name: "core-lambda-stubs-for-system-modules", 511 visibility: [ 512 "//art/build/sdk", 513 "//build/soong/java/core-libraries", 514 "//frameworks/base", 515 "//frameworks/base/api", 516 ], 517 defaults: ["core_lambda_stubs_defaults"], 518 srcs: [ 519 ":openjdk_lambda_stub_files", 520 ], 521 include_srcs: true, 522 // This jar is packaged as part of the SDK, use -target 8 so that it works 523 // with old JDKs. 524 java_version: "1.8", 525} 526 527// This is an empty jar that exists for backwards compatibility with T (and below). 528// Historically, it existed to satisfy javac when compiling source code that 529// contains @Generated annotations. 530// This is no longer necessary since @Generated was added to ART's Public API 531// surface in U. 532java_library { 533 name: "core-generated-annotation-stubs", 534 visibility: [ 535 "//art/build/sdk", 536 "//build/soong/java/core-libraries", 537 "//frameworks/base", 538 "//frameworks/base/api", 539 ], 540 defaults: ["libcore_java_defaults"], 541 srcs: [ 542 ], 543 hostdex: true, 544 sdk_version: "none", 545 system_modules: "core-all-system-modules", 546 patch_module: "java.base", 547 installable: false, 548 include_srcs: true, 549 // This jar is packaged as part of the SDK, use -target 8 so that it works 550 // with old JDKs. 551 java_version: "1.8", 552} 553 554// Builds libcore test rules 555java_library_static { 556 name: "core-test-rules", 557 visibility: [ 558 "//art/build/sdk", 559 "//cts/tests/core/runner-axt", 560 "//cts/tests/tests/util", 561 "//external/conscrypt", 562 "//external/conscrypt/apex/tests", 563 "//frameworks/base/location/tests/locationtests", 564 "//frameworks/base/core/tests/coretests", 565 "//frameworks/base/wifi/tests", 566 "//libcore/ojluni/src/test", 567 "//libcore/luni/src/test/java9compatibility", 568 "//packages/modules/Wifi/framework/tests", 569 ], 570 hostdex: true, 571 srcs: [ 572 "dalvik/test-rules/src/main/**/*.java", 573 "test-rules/src/main/**/*.java", 574 ], 575 static_libs: [ 576 "junit", 577 "platform-test-annotations", 578 ], 579 580 sdk_version: "none", 581 system_modules: "core-all-system-modules", 582} 583 584// Builds platform_compat test rules 585java_library_static { 586 name: "core-compat-test-rules", 587 visibility: [ 588 "//art/build/sdk", 589 "//libcore:__subpackages__", 590 "//frameworks/base/tests/PlatformCompatGating/test-rules", 591 "//libcore:__subpackages__", 592 ], 593 srcs: [ 594 "luni/src/main/java/android/compat/**/*.java", 595 "test-rules/src/platform_compat/**/*.java", 596 "luni/src/main/java/libcore/api/CorePlatformApi.java", 597 "luni/src/main/java/libcore/api/IntraCoreApi.java", 598 ], 599 static_libs: [ 600 "junit", 601 "guava", 602 ], 603 sdk_version: "none", 604 system_modules: "core-all-system-modules", 605 // This builds classes that are in the java.base Java module: 606 patch_module: "java.base", 607 hostdex: true, 608 609 errorprone: { 610 javacflags: [ 611 "-Xep:EmptyTopLevelDeclaration:WARN", 612 "-Xep:GetClassOnAnnotation:WARN", 613 ], 614 }, 615} 616 617// Builds the core-tests-support library used by various tests. 618java_library_static { 619 name: "core-tests-support", 620 visibility: [ 621 "//art/build/sdk", 622 "//cts/apps/CtsVerifier", 623 "//cts/tests/tests/keystore", 624 "//cts/tests/tests/net", 625 "//cts/hostsidetests/statsdatom/apps/statsdapp", 626 "//cts/tests/tests/net/api23Test", 627 "//external/apache-harmony", 628 "//frameworks/base/core/tests/coretests", 629 "//frameworks/base/apct-tests/perftests/core", 630 "//libcore/benchmarks", 631 "//packages/apps/KeyChain/tests", 632 "//system/timezone/distro/core", 633 "//packages/modules/Connectivity/tests:__subpackages__", 634 ], 635 hostdex: true, 636 srcs: ["support/src/test/java/**/*.java"], 637 638 sdk_version: "core_platform", 639 // Make sure that this will be added to the sdk snapshot for S. 640 min_sdk_version: "S", 641 libs: ["junit"], 642 static_libs: [ 643 "bouncycastle-unbundled", 644 "bouncycastle-bcpkix-unbundled", 645 "bouncycastle-ocsp-unbundled", 646 ], 647 errorprone: { 648 javacflags: [ 649 "-Xep:BoxedPrimitiveEquality:WARN", 650 ], 651 }, 652} 653 654// Used to generate the prebuilt file luni/src/test/resources/prebuilt-dex-from-java.dex. 655// The reason why we pre-build this dex file is to stabilize the test result from the 656// dexer / javac / other toolchains change. 657// Regenerate the prebuilt file with the following command: 658// m core-tests-prebuilt-dex-from-java && 659// unzip out/soong/.intermediates/libcore/core-tests-prebuilt-dex-from-java/android_common/dex/core-tests-prebuilt-dex-from-java.jar classes.dex \ 660// -d libcore/luni/src/test/resources/ && mv libcore/luni/src/test/resources/classes.dex libcore/luni/src/test/resources/prebuilt-dex-from-java.dex 661java_test { 662 name: "core-tests-prebuilt-dex-from-java", 663 srcs: ["luni/src/test/dex_src/**/*.java"], 664 compile_dex: true, 665 defaults: ["libcore_java_defaults"], 666 sdk_version: "none", 667 system_modules: "core-all-system-modules", 668 669 visibility: [ 670 "//libcore:__subpackages__", 671 ], 672} 673 674// Builds the jsr166-tests library. 675java_test { 676 name: "jsr166-tests", 677 visibility: [ 678 "//art/build/sdk", 679 "//cts/tests/libcore/jsr166", 680 ], 681 srcs: ["jsr166-tests/src/test/java/**/*.java"], 682 sdk_version: "none", 683 system_modules: "core-all-system-modules", 684 libs: [ 685 "junit", 686 ], 687 errorprone: { 688 javacflags: [ 689 "-Xep:DoNotCall:OFF", 690 "-Xep:ModifyingCollectionWithItself:WARN", 691 "-Xep:ReturnValueIgnored:WARN", 692 "-Xep:HashtableContains:WARN", 693 ], 694 }, 695} 696 697// A filegroup that provides access to a source file for a toolchain test that 698// checks Java 9 language features are handled properly by JarJar. 699filegroup { 700 name: "core-java-9-language-features-source", 701 srcs: ["luni/src/main/java/libcore/internal/Java9LanguageFeatures.java"], 702 visibility: ["//libcore/luni/src/test/java9language"], 703} 704 705// A filegroup that provides access to a source file for a toolchain test that 706// checks Java 11 language features are handled properly by JarJar. 707filegroup { 708 name: "core-java-11-language-features-source", 709 srcs: ["luni/src/main/java/libcore/internal/Java11LanguageFeatures.java"], 710 visibility: ["//libcore/luni/src/test/java11language"], 711} 712 713// A filegroup that provides access to a source file for a toolchain test that 714// checks Java 17 language features are handled properly by JarJar. 715filegroup { 716 name: "core-java-17-language-features-source", 717 srcs: ["luni/src/main/java/libcore/internal/Java17LanguageFeatures.java"], 718 visibility: ["//libcore/luni/src/test/java17language"], 719} 720 721// A filegroup that provides access to a source file for a toolchain test that 722// checks Java 21 language features are handled properly by JarJar. 723filegroup { 724 name: "core-java-21-language-features-source", 725 srcs: ["luni/src/main/java/libcore/internal/Java21LanguageFeatures.java"], 726 visibility: ["//libcore/luni/src/test/java21language"], 727} 728 729genrule { 730 name: "core-tests-smali-dex", 731 srcs: ["luni/src/test/java/**/*.smali"], 732 cmd: "$(location android-smali) ass --api 28 -o $(out) $(in)", 733 out: ["core-tests-smali.dex"], 734 tools: ["android-smali"], 735} 736 737filegroup { 738 name: "core-ojtests-javax-resources", 739 // Set path to keep the resources and .class files in the same directory in the jar file. 740 path: "ojluni/src", 741 srcs: ["ojluni/src/test/javax/**/*"], 742 exclude_srcs: ["ojluni/src/test/javax/**/*.java"], 743} 744 745filegroup { 746 name: "core-ojtests-java-resources", 747 // Set path to keep the resources and .class files in the same directory in the jar file. 748 path: "ojluni/src", 749 srcs: [ 750 "ojluni/src/test/java/util/regex/**/*", 751 "ojluni/src/test/java/util/Base64/**/*", 752 "ojluni/src/test/java/util/Scanner/**/*", 753 "ojluni/src/test/java/util/Properties/**/*", 754 ], 755 exclude_srcs: ["ojluni/src/test/java/**/*.java"], 756} 757 758// Builds the core-tests library. 759java_test { 760 name: "core-tests", 761 visibility: [ 762 "//art/build/sdk", 763 "//cts/tests/libcore/luni", 764 ], 765 defaults: ["libcore_java_defaults"], 766 hostdex: true, 767 srcs: [ 768 "dalvik/src/test/java/**/*.java", 769 "dalvik/test-rules/src/test/java/**/*.java", 770 "dom/src/test/java/**/*.java", 771 "harmony-tests/src/test/java/**/*.java", 772 "json/src/test/java/**/*.java", 773 "luni/src/test/java/**/*.java", 774 "test-rules/src/test/java/**/*.java", 775 "xml/src/test/java/**/*.java", 776 ], 777 exclude_srcs: [ 778 "harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/*.java", 779 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java", 780 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java", 781 "luni/src/test/java/libcore/javax/crypto/**/*.java", 782 "luni/src/test/java/libcore/javax/net/ssl/**/*.java", 783 "luni/src/test/java/org/apache/harmony/crypto/**/*.java", 784 ], 785 786 java_resource_dirs: [ 787 "*/src/test/java", 788 "*/src/test/resources", 789 ], 790 exclude_java_resource_dirs: [ 791 "ojluni/src/test/java", 792 "ojluni/src/test/javax", 793 "ojluni/src/test/resources", 794 ], 795 796 java_resources: [ 797 ":annotations-test", 798 ":filesystemstest", 799 ":parameter-metadata-test", 800 ":core-tests-smali-dex", 801 ], 802 803 sdk_version: "none", 804 system_modules: "core-all-system-modules", 805 libs: [ 806 "okhttp", 807 "bouncycastle", 808 ], 809 810 static_libs: [ 811 "apache-xml-tests", 812 "core-compat-test-rules", 813 "core-java-9-compatibility-tests", 814 "core-java-9-language-tests", 815 "core-java-11-language-tests", 816 "core-java-17-language-tests", 817 "core-java-21-language-tests", 818 "core-test-rules", 819 "core-tests-support", 820 "junit-params", 821 "libcore-crypto-tests", 822 "mockftpserver", 823 "mockito-target", 824 "mockwebserver", 825 "nist-pkix-tests", 826 "slf4j-jdk14", 827 "sqlite-jdbc", 828 ], 829 830 errorprone: { 831 javacflags: [ 832 "-Xep:TryFailThrowable:ERROR", 833 "-Xep:ComparisonOutOfRange:ERROR", 834 "-Xep:DoNotCall:OFF", 835 "-Xep:ArrayToString:WARN", 836 "-Xep:SelfEquals:WARN", 837 "-Xep:SelfComparison:WARN", 838 "-Xep:ReturnValueIgnored:WARN", 839 "-Xep:BoxedPrimitiveEquality:WARN", 840 "-Xep:SizeGreaterThanOrEqualsZero:WARN", 841 "-Xep:MisusedDayOfYear:WARN", 842 "-Xep:InvalidTimeZoneID:WARN", 843 "-Xep:CollectionToArraySafeParameter:WARN", 844 "-Xep:ModifyingCollectionWithItself:WARN", 845 "-Xep:ComparableType:WARN", 846 "-Xep:UnusedCollectionModifiedInPlace:WARN", 847 "-Xep:HashtableContains:WARN", 848 "-Xep:DoubleBraceInitialization:WARN", 849 "-Xep:RandomModInteger:WARN", 850 "-Xep:IdentityBinaryExpression:WARN", 851 "-Xep:UnnecessaryStringBuilder:OFF", // https://github.com/google/error-prone/issues/4195 852 // Some of the invalid regexes in the tests cause java to throw 853 // an exception that contains a null byte. The null byte is then 854 // printed by errorprone to the build log, causing some tools to 855 // think the build log is a binary file. Disable instead of demoting 856 // to a warning. 857 "-Xep:InvalidPatternSyntax:OFF", 858 ], 859 }, 860 861 test_config: "AndroidTest-core-tests.xml", 862} 863 864java_test { 865 name: "libcore-crypto-tests", 866 867 visibility: [ 868 "//art/build/sdk", 869 "//external/conscrypt/apex/tests", 870 ], 871 exclude_srcs: [ 872 "luni/src/test/java/libcore/javax/crypto/CipherTest.java", 873 ], 874 srcs: [ 875 "harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/*.java", 876 "luni/src/test/java/libcore/javax/crypto/**/*.java", 877 "luni/src/test/java/libcore/javax/net/ssl/**/*.java", 878 "luni/src/test/java/libcore/libcore/util/SerializationTester.java", 879 "luni/src/test/java/libcore/sun/security/**/*.java", 880 "luni/src/test/java/org/apache/harmony/crypto/**/*.java", 881 ], 882 883 java_resource_dirs: [ 884 "luni/src/test/java", 885 "luni/src/test/resources", 886 "support/src/test/java", 887 ], 888 889 sdk_version: "none", 890 system_modules: "core-all-system-modules", 891 892 static_libs: [ 893 "core-test-rules", 894 "core-tests-support", 895 "junit-params", 896 "mockito-target", 897 ], 898 899 errorprone: { 900 javacflags: [ 901 "-Xep:ArrayToString:WARN", 902 "-Xep:ReturnValueIgnored:WARN", 903 ], 904 }, 905} 906 907java_genrule { 908 name: "libcore-non-cts-tests-txt", 909 srcs: [ 910 ":apache-harmony-tests{.jar}", 911 ":conscrypt-tests{.jar}", 912 ":core-tests{.jar}", 913 ":core-ojtests{.jar}", 914 ], 915 tools: ["non-cts-json-generator"], 916 out: ["libcore-non-cts-tests.txt"], 917 cmd: "$(location non-cts-json-generator) $(in) > $(out)", 918} 919 920// Exports annotated stubs source files in ojluni/annotations/sdk to make them 921// available to metalava. Used for nullability annotations in OpenJDK source. 922droiddoc_exported_dir { 923 name: "ojluni-annotated-sdk-stubs", 924 visibility: [ 925 "//libcore:__subpackages__", 926 ], 927 path: "ojluni/annotations/sdk", 928} 929 930droiddoc_exported_dir { 931 name: "ojluni-annotated-nullability-stubs", 932 path: "ojluni/annotations/sdk/nullability", 933} 934 935// Exports annotated stubs source files in ojluni/annotations/mmodules to make 936// them available to metalava. Used for core platform API and intra-core API 937// annotations in OpenJDK source. 938droiddoc_exported_dir { 939 name: "ojluni-annotated-mmodule-stubs", 940 visibility: [ 941 "//libcore/mmodules/intracoreapi", 942 ], 943 path: "ojluni/annotations/mmodule", 944} 945 946droiddoc_exported_dir { 947 name: "ojluni-annotated-flagged-stubs", 948 path: "ojluni/annotations/flagged_api", 949 visibility: ["//visibility:private"], 950} 951 952droiddoc_exported_dir { 953 name: "toolchainapi-annotated-flagged-stubs", 954 path: "ojluni/annotations/flagged_toolchainapi", 955 visibility: ["//libcore/toolchainapi"], 956} 957 958// A file containing the list of tags that are "known" to us from the OpenJdk 959// source code and so should not cause an error or warning. 960filegroup { 961 name: "known-oj-tags", 962 visibility: [ 963 "//frameworks/base", 964 "//frameworks/base/api", 965 ], 966 srcs: [ 967 "known_oj_tags.txt", 968 ], 969} 970 971// A special set of stubs containing the minimal set of self consistent 972// classes for which a system module can be created. Every system module must 973// contain the java.lang classes so the set was constructed by starting with 974// the java.lang classes and then adding their transitive dependencies without 975// splitting packages. So, if one class from a package is used then all classes 976// in that package were added to the set. 977// 978// Needed for java-current-stubs-system-modules. 979droidstubs { 980 name: "java-current-stubs-source", 981 srcs: [ 982 ":core_oj_api_files", 983 ":core_libart_api_files", 984 ], 985 installable: false, 986 sdk_version: "none", 987 system_modules: "none", 988 989 args: "--stub-packages java.*:javax.*:org.w3c.dom.*:org.xml.sax.*", 990} 991 992// Generates stub files for the classes exposed in the public API, without 993// javadoc. This can be used as a starting point for adding a new file to 994// libcore/luni/annotations/flagged_api. 995droidstubs { 996 name: "libart-sdk-stubs-no-javadoc", 997 srcs: [ 998 ":core_libart_api_files", 999 // The definition of @SystemApi is needed to generate module-lib stubs. 1000 ":framework-api-annotations", 1001 ], 1002 installable: false, 1003 sdk_version: "none", 1004 system_modules: "none", 1005 api_levels_sdk_type: "module-lib", 1006 flags: [ 1007 "--exclude-documentation-from-stubs", 1008 "--show-for-stub-purposes-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.MODULE_LIBRARIES\\)", 1009 ], 1010} 1011 1012// Separate @FlaggedApi annotations for luni/ to avoid a circular dependency between 1013// libcore_aconfig_flags_lib and core-all 1014droiddoc_exported_dir { 1015 name: "luni-annotated-flagged-stubs", 1016 path: "luni/annotations/flagged_api", 1017 visibility: ["//visibility:private"], 1018} 1019 1020java_library { 1021 name: "java.current.stubs", 1022 srcs: [":java-current-stubs-source"], 1023 errorprone: { 1024 javacflags: [ 1025 "-Xep:MissingOverride:OFF", 1026 ], 1027 }, 1028 patch_module: "java.base", 1029 sdk_version: "none", 1030 system_modules: "none", 1031} 1032 1033// A special set of system modules needed to build art.module.public.api 1034java_system_modules { 1035 name: "java-current-stubs-system-modules", 1036 libs: [ 1037 // Minimal set of classes required for a system module. 1038 "java.current.stubs", 1039 ], 1040} 1041 1042java_library { 1043 name: "framework-api-annotations-lib", 1044 srcs: [":framework-api-annotations"], 1045 static_libs: ["aconfig-annotations-lib-sdk-none"], 1046 sdk_version: "none", 1047 patch_module: "java.base", 1048 system_modules: "core-all-system-modules", 1049 installable: false, 1050 visibility: [ 1051 "//art/build/flags", 1052 "//libcore:__subpackages__", 1053 ], 1054} 1055 1056aconfig_declarations { 1057 name: "libcore-aconfig-flags", 1058 package: "com.android.libcore", 1059 container: "com.android.art", 1060 exportable: true, 1061 srcs: ["libcore.aconfig"], 1062 visibility: [ 1063 "//libcore:__subpackages__", 1064 "//frameworks/base", 1065 ], 1066} 1067 1068java_system_modules { 1069 name: "libcore-bootstrap-core-current-from-text-system-modules", 1070 libs: ["core.current.stubs.from-text"], 1071 visibility: ["//visibility:private"], 1072} 1073 1074java_library { 1075 name: "libcore-bootstrap-lib-for-flags-lib", 1076 srcs: [ 1077 // Needs @UnsupportedAppUsage definition from this source 1078 ":app-compat-annotations-source", 1079 // Needs @AssumeFalseForR8 and AconfigFlagAccessor from this source 1080 ":framework-api-annotations", 1081 // Needs LambdaMetafactory due to lambda usage in the lib 1082 ":openjdk_lambda_stub_files", 1083 ], 1084 sdk_version: "none", 1085 patch_module: "java.base", 1086 system_modules: "libcore-bootstrap-core-current-from-text-system-modules", 1087 installable: false, 1088 visibility: [ 1089 "//visibility:private", 1090 ], 1091} 1092 1093// We need this system module because openjdk_lambda_stub_files and core.current.stubs.from-text 1094// need to be in the same module. Otherwise, javac isn't happy to use the LambdaMetaFactory if 1095// it's not in the system module. 1096java_system_modules { 1097 name: "libcore-bootstrap-lib-for-flags-lib-system-modules", 1098 libs: [ 1099 "core.current.stubs.from-text", 1100 "libcore-bootstrap-lib-for-flags-lib", 1101 ], 1102 visibility: ["//visibility:private"], 1103} 1104 1105java_aconfig_library { 1106 name: "libcore-aconfig-flags-lib-for-core-all-only", 1107 aconfig_declarations: "libcore-aconfig-flags", 1108 // This system module is specifically crafted to avoid a circular dependency on core-all. 1109 // Instead of dependency on core-all, this system module contains the stubs generated from 1110 // API files, e.g. libcore/api/current.txt. See "core.current.stubs.from-text" for more details. 1111 // An alternative is to generate the .java source files of this lib without running javac, 1112 // but it wasn't possible using java_aconfig_library when this comment is written. 1113 system_modules: "libcore-bootstrap-lib-for-flags-lib-system-modules", 1114 sdk_version: "none", 1115 patch_module: "java.base", 1116 installable: false, 1117 visibility: ["//visibility:private"], 1118} 1119 1120java_aconfig_library { 1121 name: "art-aconfig-flags-java-lib-for-core-all-only", 1122 aconfig_declarations: "art-aconfig-flags", 1123 system_modules: "libcore-bootstrap-lib-for-flags-lib-system-modules", 1124 sdk_version: "none", 1125 patch_module: "java.base", 1126 installable: false, 1127 visibility: ["//visibility:private"], 1128} 1129 1130java_aconfig_library { 1131 name: "libcore-aconfig-flags-lib", 1132 aconfig_declarations: "libcore-aconfig-flags", 1133 sdk_version: "none", 1134 patch_module: "java.base", 1135 system_modules: "core-all-system-modules", 1136 libs: ["framework-api-annotations-lib"], 1137 min_sdk_version: "31", // ART module is enabled on Android 12 or above. 1138 apex_available: [ 1139 "com.android.art", 1140 "com.android.art.debug", 1141 ], 1142 visibility: [ 1143 "//libcore:__subpackages__", 1144 ], 1145} 1146 1147// Define the public SDK API provided by the ART module. 1148java_sdk_library { 1149 name: "art.module.public.api", 1150 visibility: [ 1151 "//art/build/sdk", 1152 "//build/soong/java/core-libraries", 1153 "//frameworks/base", 1154 "//frameworks/base/api", 1155 1156 // DO NOT REMOVE: Legacy visibility, needed for snapshots that are 1157 // generated for the S build. 1158 "//libcore/mmodules/core_platform_api", 1159 ], 1160 srcs: [ 1161 ":core_oj_api_files", 1162 ":core_libart_api_files", 1163 1164 // Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are 1165 // annotated by applying annotations to the .annotated.java stubs files in 1166 // ojluni/annotated/mmodules and rather than in the original source. See the comments 1167 // in openjdk_java_files.bp for more details. 1168 ":openjdk_mmodule_extra_files", 1169 ":okhttp_api_files", 1170 ], 1171 api_srcs: [ 1172 ":openjdk_javadoc_only_files", 1173 ], 1174 libs: [ 1175 // Put framework-api-annotations into libs to avoid exposing the definition of framework's 1176 // annotations from libcore (wrong place) instead of framework (correct place). 1177 "framework-api-annotations-lib", 1178 // Provide access to I18N constants that are used to initialize 1179 // constants in the public API. i.e. to allow the value of the 1180 // java.text.CollectionElementIterator.NULLORDER to be initialized from 1181 // android.icu.text.CollationElementIterator.NULLORDER. 1182 "i18n.module.intra.core.api.stubs", 1183 "art-aconfig-flags-java-lib", 1184 "libcore-aconfig-flags-lib", 1185 ], 1186 stub_only_static_libs: ["notices-for-stubs-jar"], 1187 1188 // Make dex jars for the stubs available for use by hiddenapi processing. 1189 compile_dex: true, 1190 1191 public: { 1192 enabled: true, 1193 }, 1194 system: { 1195 enabled: true, 1196 }, 1197 module_lib: { 1198 enabled: true, 1199 }, 1200 1201 api_only: true, 1202 droiddoc_options: [ 1203 "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.* ", 1204 "--hide-annotation libcore.api.Hide", 1205 ], 1206 1207 merge_inclusion_annotations_dirs: [ 1208 "luni-annotated-flagged-stubs", 1209 "ojluni-annotated-flagged-stubs", 1210 "ojluni-annotated-mmodule-stubs", 1211 ], 1212 // Emit nullability annotations from the source to the stub files. 1213 annotations_enabled: true, 1214 1215 merge_annotations_dirs: [ 1216 "metalava-manual", 1217 "ojluni-annotated-sdk-stubs", 1218 ], 1219 1220 doctag_files: [ 1221 ":known-oj-tags", 1222 ], 1223 1224 errorprone: { 1225 javacflags: [ 1226 "-Xep:MissingOverride:OFF", 1227 ], 1228 }, 1229 patch_module: "java.base", 1230 sdk_version: "none", 1231 system_modules: "java-current-stubs-system-modules", 1232 // The base name for the artifacts that are automatically published to the 1233 // dist and which end up in one of the sub-directories of prebuilts/sdk. 1234 // As long as this matches the name of the artifacts in prebuilts/sdk then 1235 // the API will be checked for compatibility against the latest released 1236 // version of the API. 1237 dist_stem: "art", 1238 dist_group: "android", 1239 aconfig_declarations: [ 1240 "art-aconfig-flags", 1241 "libcore-aconfig-flags", 1242 ], 1243} 1244 1245// Target for validating nullability annotations for correctness and 1246// completeness. To check that there are no nullability errors: 1247// m art-module-public-api-stubs-nullability-validation 1248// To check that there are only the expected nullability warnings: 1249// m art-module-public-api-stubs-nullability-validation-check-nullability-warnings 1250// (If that check fails, it will provide instructions on how to proceed, 1251// including the command to run to update the expected warnings file.) 1252droidstubs { 1253 name: "art-module-public-api-stubs-nullability-validation", 1254 srcs: [":art_module_api_files"], 1255 installable: false, 1256 sdk_version: "none", 1257 system_modules: "none", 1258 annotations_enabled: true, 1259 args: "--hide-annotation libcore.api.Hide " + 1260 "--validate-nullability-from-merged-stubs ", 1261 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"], 1262 merge_annotations_dirs: [ 1263 // N.B. Stubs in this filegroup will be validated: 1264 "ojluni-annotated-nullability-stubs", 1265 ], 1266 // The list of classes which have nullability annotations included in the source. 1267 // (This is in addition to those which have annotations in the merged stubs.) 1268 validate_nullability_from_list: "nullability_annotated_classes.txt", 1269 // The expected set of warnings about missing annotations: 1270 check_nullability_warnings: "nullability_warnings.txt", 1271} 1272 1273// A special set of system modules for building the following library for use 1274// in the art-module-public-api-system-modules. 1275java_system_modules { 1276 name: "api-annotations-system-modules", 1277 libs: [ 1278 "art.module.public.api.stubs", 1279 ], 1280} 1281 1282// A library that contains annotations that define API surfaces (core 1283// platform, intra core and the hidden API) along with some supporting 1284// constants. The annotations are source only and do not introduce any runtime 1285// dependencies. Specially built for use in system modules definitions to 1286// avoid introducing compile time cycles. 1287java_library { 1288 name: "art.module.api.annotations.for.system.modules", 1289 visibility: [ 1290 "//build/soong/java/core-libraries", 1291 ], 1292 srcs: [ 1293 ":api_surface_annotation_files", 1294 ], 1295 1296 installable: false, 1297 sdk_version: "none", 1298 system_modules: "api-annotations-system-modules", 1299 patch_module: "java.base", 1300 // This jar is packaged as part of the SDK, use -target 8 so that it works 1301 // with old JDKs. 1302 java_version: "1.8", 1303} 1304 1305// Create a library containing the api surface annotations, built against 1306// core_current for use by the annotation processor in frameworks/base. 1307java_library { 1308 name: "art.module.api.annotations", 1309 visibility: [ 1310 "//art/build/sdk", 1311 "//external/icu/android_icu4j", 1312 "//frameworks/base", 1313 "//frameworks/base/api", 1314 ], 1315 host_supported: true, 1316 srcs: [ 1317 ":api_surface_annotation_files", 1318 ], 1319 sdk_version: "core_current", 1320 // Make sure that this will be added to the sdk snapshot for S. 1321 min_sdk_version: "S", 1322 // This jar is packaged as part of the ART module host exports, use -target 8 so that it works 1323 // with old JDKs. 1324 java_version: "1.8", 1325} 1326