2019-01-10 07:17:55 +01:00
|
|
|
// Copyright 2019 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// 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 java
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/google/blueprint/proptools"
|
2019-04-18 21:31:22 +02:00
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/java/config"
|
2019-01-10 07:17:55 +01:00
|
|
|
)
|
|
|
|
|
2021-10-28 19:05:53 +02:00
|
|
|
type classpathTestCase struct {
|
|
|
|
name string
|
|
|
|
unbundled bool
|
|
|
|
moduleType string
|
|
|
|
host android.OsClass
|
|
|
|
properties string
|
|
|
|
|
|
|
|
// for java 8
|
|
|
|
bootclasspath []string
|
|
|
|
java8classpath []string
|
2019-10-26 00:22:50 +02:00
|
|
|
|
2021-10-28 19:05:53 +02:00
|
|
|
// for java 9
|
|
|
|
system string
|
|
|
|
java9classpath []string
|
2019-10-26 00:22:50 +02:00
|
|
|
|
2021-10-28 19:05:53 +02:00
|
|
|
forces8 bool // if set, javac will always be called with java 8 arguments
|
2019-10-26 00:22:50 +02:00
|
|
|
|
2021-10-28 19:05:53 +02:00
|
|
|
aidl string
|
2021-10-28 19:16:14 +02:00
|
|
|
|
|
|
|
// Indicates how this test case is affected by the setting of Always_use_prebuilt_sdks.
|
|
|
|
//
|
|
|
|
// If this is nil then the test case is unaffected by the setting of Always_use_prebuilt_sdks.
|
|
|
|
// Otherwise, the test case can only be used when
|
|
|
|
// Always_use_prebuilt_sdks=*forAlwaysUsePrebuiltSdks.
|
|
|
|
forAlwaysUsePrebuiltSdks *bool
|
2021-10-28 19:05:53 +02:00
|
|
|
}
|
2019-10-26 00:22:50 +02:00
|
|
|
|
2021-10-28 19:05:53 +02:00
|
|
|
func TestClasspath(t *testing.T) {
|
|
|
|
const frameworkAidl = "-I" + defaultJavaDir + "/framework/aidl"
|
|
|
|
var classpathTestcases = []classpathTestCase{
|
2019-04-18 19:56:44 +02:00
|
|
|
{
|
2019-10-26 00:22:50 +02:00
|
|
|
name: "default",
|
2020-07-09 19:03:41 +02:00
|
|
|
bootclasspath: config.StableCorePlatformBootclasspathLibraries,
|
|
|
|
system: config.StableCorePlatformSystemModules,
|
2020-07-01 11:48:14 +02:00
|
|
|
java8classpath: config.FrameworkLibraries,
|
|
|
|
java9classpath: config.FrameworkLibraries,
|
2021-03-13 10:55:25 +01:00
|
|
|
aidl: frameworkAidl,
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
2019-06-12 14:25:22 +02:00
|
|
|
{
|
2019-10-26 00:22:50 +02:00
|
|
|
name: `sdk_version:"core_platform"`,
|
|
|
|
properties: `sdk_version:"core_platform"`,
|
2020-07-09 19:03:41 +02:00
|
|
|
bootclasspath: config.StableCorePlatformBootclasspathLibraries,
|
|
|
|
system: config.StableCorePlatformSystemModules,
|
2019-10-26 00:22:50 +02:00
|
|
|
java8classpath: []string{},
|
|
|
|
aidl: "",
|
2019-06-12 14:25:22 +02:00
|
|
|
},
|
2019-04-18 19:56:44 +02:00
|
|
|
{
|
2019-10-26 00:22:50 +02:00
|
|
|
name: "blank sdk version",
|
|
|
|
properties: `sdk_version: "",`,
|
2020-07-09 19:03:41 +02:00
|
|
|
bootclasspath: config.StableCorePlatformBootclasspathLibraries,
|
|
|
|
system: config.StableCorePlatformSystemModules,
|
2020-07-01 11:48:14 +02:00
|
|
|
java8classpath: config.FrameworkLibraries,
|
|
|
|
java9classpath: config.FrameworkLibraries,
|
2021-03-13 10:55:25 +01:00
|
|
|
aidl: frameworkAidl,
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
|
2019-10-28 16:05:02 +01:00
|
|
|
name: "sdk v29",
|
|
|
|
properties: `sdk_version: "29",`,
|
2019-10-26 00:22:50 +02:00
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
forces8: true,
|
2019-10-28 16:05:02 +01:00
|
|
|
java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
2020-05-15 03:05:32 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
name: "sdk v30",
|
|
|
|
properties: `sdk_version: "30",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_30_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
|
|
|
|
},
|
2019-04-18 19:56:44 +02:00
|
|
|
{
|
2021-10-28 19:16:14 +02:00
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=false (the default).
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
|
2019-04-18 19:56:44 +02:00
|
|
|
|
2019-10-17 23:23:50 +02:00
|
|
|
name: "current",
|
|
|
|
properties: `sdk_version: "current",`,
|
|
|
|
bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
|
2021-11-03 17:53:31 +01:00
|
|
|
system: "core-public-stubs-system-modules",
|
2019-10-17 23:23:50 +02:00
|
|
|
java9classpath: []string{"android_stubs_current"},
|
2021-03-22 18:31:52 +01:00
|
|
|
aidl: "-pout/soong/framework.aidl",
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
|
|
|
{
|
2021-10-28 19:16:14 +02:00
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=true.
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
|
|
|
|
|
|
|
|
name: "current",
|
|
|
|
properties: `sdk_version: "current",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_current_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=false (the default).
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
|
2019-04-18 19:56:44 +02:00
|
|
|
|
2019-10-17 23:23:50 +02:00
|
|
|
name: "system_current",
|
|
|
|
properties: `sdk_version: "system_current",`,
|
|
|
|
bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
|
2021-11-03 17:53:31 +01:00
|
|
|
system: "core-public-stubs-system-modules",
|
2019-10-17 23:23:50 +02:00
|
|
|
java9classpath: []string{"android_system_stubs_current"},
|
2021-03-22 18:31:52 +01:00
|
|
|
aidl: "-pout/soong/framework.aidl",
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
|
|
|
{
|
2021-10-28 19:16:14 +02:00
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=true.
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
|
2019-04-18 19:56:44 +02:00
|
|
|
|
2021-10-28 19:16:14 +02:00
|
|
|
name: "system_current",
|
|
|
|
properties: `sdk_version: "system_current",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_current_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/current/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/current/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
|
|
|
},
|
|
|
|
{
|
2019-10-28 16:05:02 +01:00
|
|
|
name: "system_29",
|
|
|
|
properties: `sdk_version: "system_29",`,
|
2019-10-26 00:22:50 +02:00
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
forces8: true,
|
2019-10-28 16:05:02 +01:00
|
|
|
java8classpath: []string{"prebuilts/sdk/29/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
2020-05-15 03:05:32 +02:00
|
|
|
{
|
|
|
|
name: "system_30",
|
|
|
|
properties: `sdk_version: "system_30",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_30_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/30/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/30/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
|
|
|
|
},
|
2019-04-18 19:56:44 +02:00
|
|
|
{
|
2021-10-28 19:16:14 +02:00
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=false (the default).
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
|
|
|
|
|
2019-10-17 23:23:50 +02:00
|
|
|
name: "test_current",
|
|
|
|
properties: `sdk_version: "test_current",`,
|
|
|
|
bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
|
2021-11-03 17:53:31 +01:00
|
|
|
system: "core-public-stubs-system-modules",
|
2019-10-17 23:23:50 +02:00
|
|
|
java9classpath: []string{"android_test_stubs_current"},
|
2021-03-22 18:31:52 +01:00
|
|
|
aidl: "-pout/soong/framework.aidl",
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
2021-10-28 19:16:14 +02:00
|
|
|
{
|
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=true.
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
|
|
|
|
|
|
|
|
name: "test_current",
|
|
|
|
properties: `sdk_version: "test_current",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_current_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/current/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/current/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
|
|
|
},
|
2021-10-28 18:42:16 +02:00
|
|
|
{
|
|
|
|
name: "test_30",
|
|
|
|
properties: `sdk_version: "test_30",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_30_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/30/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/30/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
|
|
|
|
},
|
2019-04-18 19:56:44 +02:00
|
|
|
{
|
2021-10-28 19:16:14 +02:00
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=false (the default).
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
|
2019-04-18 19:56:44 +02:00
|
|
|
|
2020-07-01 14:17:16 +02:00
|
|
|
name: "core_current",
|
|
|
|
properties: `sdk_version: "core_current",`,
|
|
|
|
bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"},
|
2021-11-03 17:53:31 +01:00
|
|
|
system: "core-public-stubs-system-modules",
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
2021-10-28 19:16:14 +02:00
|
|
|
{
|
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=true.
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
|
|
|
|
|
|
|
|
name: "core_current",
|
|
|
|
properties: `sdk_version: "core_current",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_current_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/current/core/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/current/core/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
|
|
|
},
|
2019-04-18 19:56:44 +02:00
|
|
|
{
|
|
|
|
|
2019-10-26 00:22:50 +02:00
|
|
|
name: "nostdlib",
|
|
|
|
properties: `sdk_version: "none", system_modules: "none"`,
|
|
|
|
system: "none",
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
java8classpath: []string{},
|
2019-06-11 13:31:14 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
|
2019-10-26 00:22:50 +02:00
|
|
|
name: "nostdlib system_modules",
|
2020-07-09 19:03:41 +02:00
|
|
|
properties: `sdk_version: "none", system_modules: "stable-core-platform-api-stubs-system-modules"`,
|
|
|
|
system: "stable-core-platform-api-stubs-system-modules",
|
|
|
|
bootclasspath: []string{"stable-core-platform-api-stubs-system-modules-lib"},
|
2019-10-26 00:22:50 +02:00
|
|
|
java8classpath: []string{},
|
2019-06-11 13:31:14 +02:00
|
|
|
},
|
2019-04-18 19:56:44 +02:00
|
|
|
{
|
|
|
|
|
2019-10-26 00:22:50 +02:00
|
|
|
name: "host default",
|
|
|
|
moduleType: "java_library_host",
|
|
|
|
properties: ``,
|
|
|
|
host: android.Host,
|
|
|
|
bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
|
|
|
|
java8classpath: []string{},
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
|
2019-10-26 00:22:50 +02:00
|
|
|
name: "host supported default",
|
|
|
|
host: android.Host,
|
|
|
|
properties: `host_supported: true,`,
|
|
|
|
java8classpath: []string{},
|
|
|
|
bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
|
|
|
{
|
2019-10-26 00:22:50 +02:00
|
|
|
name: "host supported nostdlib",
|
|
|
|
host: android.Host,
|
|
|
|
properties: `host_supported: true, sdk_version: "none", system_modules: "none"`,
|
|
|
|
java8classpath: []string{},
|
2019-06-11 13:31:14 +02:00
|
|
|
},
|
|
|
|
{
|
2019-04-18 19:56:44 +02:00
|
|
|
|
2019-10-28 16:05:02 +01:00
|
|
|
name: "unbundled sdk v29",
|
2019-10-26 00:22:50 +02:00
|
|
|
unbundled: true,
|
2019-10-28 16:05:02 +01:00
|
|
|
properties: `sdk_version: "29",`,
|
2019-10-26 00:22:50 +02:00
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
forces8: true,
|
2019-10-28 16:05:02 +01:00
|
|
|
java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/29/public/framework.aidl",
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
2020-05-15 03:05:32 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
name: "unbundled sdk v30",
|
|
|
|
unbundled: true,
|
|
|
|
properties: `sdk_version: "30",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_30_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
|
|
|
|
},
|
2019-04-18 19:56:44 +02:00
|
|
|
{
|
|
|
|
|
2019-10-26 00:22:50 +02:00
|
|
|
name: "unbundled current",
|
|
|
|
unbundled: true,
|
|
|
|
properties: `sdk_version: "current",`,
|
|
|
|
bootclasspath: []string{`""`},
|
2020-05-15 03:05:32 +02:00
|
|
|
system: "sdk_public_current_system_modules",
|
2019-10-26 00:22:50 +02:00
|
|
|
java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
2020-05-15 03:05:32 +02:00
|
|
|
java9classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
2019-10-26 00:22:50 +02:00
|
|
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
2019-04-18 19:56:44 +02:00
|
|
|
},
|
2020-01-30 10:00:15 +01:00
|
|
|
{
|
2021-10-28 19:16:14 +02:00
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=false (the default).
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
|
|
|
|
|
2020-01-30 10:00:15 +01:00
|
|
|
name: "module_current",
|
|
|
|
properties: `sdk_version: "module_current",`,
|
|
|
|
bootclasspath: []string{"android_module_lib_stubs_current", "core-lambda-stubs"},
|
2021-06-29 23:05:58 +02:00
|
|
|
system: "core-module-lib-stubs-system-modules",
|
2020-01-30 10:00:15 +01:00
|
|
|
java9classpath: []string{"android_module_lib_stubs_current"},
|
2021-03-22 18:31:52 +01:00
|
|
|
aidl: "-pout/soong/framework_non_updatable.aidl",
|
2020-01-30 10:00:15 +01:00
|
|
|
},
|
2021-10-28 19:16:14 +02:00
|
|
|
{
|
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=true.
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
|
|
|
|
|
|
|
|
name: "module_current",
|
|
|
|
properties: `sdk_version: "module_current",`,
|
|
|
|
bootclasspath: []string{`""`},
|
2021-10-29 14:50:24 +02:00
|
|
|
system: "sdk_module-lib_current_system_modules",
|
2021-10-28 19:16:14 +02:00
|
|
|
java8classpath: []string{"prebuilts/sdk/current/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/current/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
|
|
|
},
|
2021-10-28 18:42:16 +02:00
|
|
|
{
|
|
|
|
name: "module_30",
|
|
|
|
properties: `sdk_version: "module_30",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_30_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/30/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/30/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "module_31",
|
|
|
|
properties: `sdk_version: "module_31",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_31_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/31/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/31/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/31/public/framework.aidl",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "module_32",
|
|
|
|
properties: `sdk_version: "module_32",`,
|
|
|
|
bootclasspath: []string{`""`},
|
2021-10-29 14:50:24 +02:00
|
|
|
system: "sdk_module-lib_32_system_modules",
|
2021-10-28 18:42:16 +02:00
|
|
|
java8classpath: []string{"prebuilts/sdk/32/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/32/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/32/public/framework.aidl",
|
|
|
|
},
|
2020-02-11 20:36:43 +01:00
|
|
|
{
|
2021-10-28 19:16:14 +02:00
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=false (the default).
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
|
|
|
|
|
2020-02-11 20:36:43 +01:00
|
|
|
name: "system_server_current",
|
|
|
|
properties: `sdk_version: "system_server_current",`,
|
2020-03-19 16:23:38 +01:00
|
|
|
bootclasspath: []string{"android_system_server_stubs_current", "core-lambda-stubs"},
|
2021-06-29 23:05:58 +02:00
|
|
|
system: "core-module-lib-stubs-system-modules",
|
2020-03-19 16:23:38 +01:00
|
|
|
java9classpath: []string{"android_system_server_stubs_current"},
|
2021-03-22 18:31:52 +01:00
|
|
|
aidl: "-pout/soong/framework.aidl",
|
2020-02-11 20:36:43 +01:00
|
|
|
},
|
2021-10-28 19:16:14 +02:00
|
|
|
{
|
|
|
|
// Test case only applies when Always_use_prebuilt_sdks=true.
|
|
|
|
forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
|
|
|
|
|
|
|
|
name: "system_server_current",
|
|
|
|
properties: `sdk_version: "system_server_current",`,
|
|
|
|
bootclasspath: []string{`""`},
|
2021-10-29 14:50:24 +02:00
|
|
|
system: "sdk_module-lib_current_system_modules",
|
2021-10-28 19:16:14 +02:00
|
|
|
java8classpath: []string{"prebuilts/sdk/current/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/current/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
|
|
|
|
},
|
2021-10-28 18:42:16 +02:00
|
|
|
{
|
|
|
|
name: "system_server_30",
|
|
|
|
properties: `sdk_version: "system_server_30",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_30_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/30/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/30/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "system_server_31",
|
|
|
|
properties: `sdk_version: "system_server_31",`,
|
|
|
|
bootclasspath: []string{`""`},
|
|
|
|
system: "sdk_public_31_system_modules",
|
|
|
|
java8classpath: []string{"prebuilts/sdk/31/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/31/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/31/public/framework.aidl",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "system_server_32",
|
|
|
|
properties: `sdk_version: "system_server_32",`,
|
|
|
|
bootclasspath: []string{`""`},
|
2021-10-29 14:50:24 +02:00
|
|
|
system: "sdk_module-lib_32_system_modules",
|
2021-10-28 18:42:16 +02:00
|
|
|
java8classpath: []string{"prebuilts/sdk/32/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
java9classpath: []string{"prebuilts/sdk/32/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
|
|
|
|
aidl: "-pprebuilts/sdk/32/public/framework.aidl",
|
|
|
|
},
|
2019-04-18 19:56:44 +02:00
|
|
|
}
|
|
|
|
|
2021-10-28 19:16:14 +02:00
|
|
|
t.Run("basic", func(t *testing.T) {
|
|
|
|
testClasspathTestCases(t, classpathTestcases, false)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Always_use_prebuilt_sdks=true", func(t *testing.T) {
|
|
|
|
testClasspathTestCases(t, classpathTestcases, true)
|
|
|
|
})
|
2021-10-28 19:05:53 +02:00
|
|
|
}
|
|
|
|
|
2021-10-28 19:16:14 +02:00
|
|
|
func testClasspathTestCases(t *testing.T, classpathTestcases []classpathTestCase, alwaysUsePrebuiltSdks bool) {
|
2019-01-10 07:17:55 +01:00
|
|
|
for _, testcase := range classpathTestcases {
|
2021-10-28 19:16:14 +02:00
|
|
|
if testcase.forAlwaysUsePrebuiltSdks != nil && *testcase.forAlwaysUsePrebuiltSdks != alwaysUsePrebuiltSdks {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2019-01-10 07:17:55 +01:00
|
|
|
t.Run(testcase.name, func(t *testing.T) {
|
|
|
|
moduleType := "java_library"
|
|
|
|
if testcase.moduleType != "" {
|
|
|
|
moduleType = testcase.moduleType
|
|
|
|
}
|
|
|
|
|
2019-10-21 15:29:58 +02:00
|
|
|
props := `
|
2019-01-10 07:17:55 +01:00
|
|
|
name: "foo",
|
|
|
|
srcs: ["a.java"],
|
2019-04-18 19:56:44 +02:00
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
srcs: ["bar-doc/IFoo.aidl"],
|
|
|
|
},
|
|
|
|
},
|
2019-10-21 15:29:58 +02:00
|
|
|
`
|
|
|
|
bp := moduleType + " {" + props + testcase.properties + `
|
|
|
|
}`
|
|
|
|
bpJava8 := moduleType + " {" + props + `java_version: "1.8",
|
2019-01-10 07:17:55 +01:00
|
|
|
` + testcase.properties + `
|
|
|
|
}`
|
|
|
|
|
2021-07-20 18:47:41 +02:00
|
|
|
variant := func(result *android.TestResult) string {
|
|
|
|
if testcase.host == android.Host {
|
|
|
|
return result.Config.BuildOS.String() + "_common"
|
|
|
|
}
|
|
|
|
return "android_common"
|
2019-01-10 07:17:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
convertModulesToPaths := func(cp []string) []string {
|
|
|
|
ret := make([]string, len(cp))
|
|
|
|
for i, e := range cp {
|
2021-03-13 10:55:25 +01:00
|
|
|
ret[i] = defaultModuleToPath(e)
|
2019-01-10 07:17:55 +01:00
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
bootclasspath := convertModulesToPaths(testcase.bootclasspath)
|
2019-10-26 00:22:50 +02:00
|
|
|
java8classpath := convertModulesToPaths(testcase.java8classpath)
|
|
|
|
java9classpath := convertModulesToPaths(testcase.java9classpath)
|
2019-01-10 07:17:55 +01:00
|
|
|
|
2019-10-21 15:29:58 +02:00
|
|
|
bc := ""
|
|
|
|
var bcDeps []string
|
|
|
|
if len(bootclasspath) > 0 {
|
|
|
|
bc = "-bootclasspath " + strings.Join(bootclasspath, ":")
|
|
|
|
if bootclasspath[0] != `""` {
|
|
|
|
bcDeps = bootclasspath
|
|
|
|
}
|
2019-01-10 07:17:55 +01:00
|
|
|
}
|
|
|
|
|
2019-10-26 00:22:50 +02:00
|
|
|
j8c := ""
|
|
|
|
if len(java8classpath) > 0 {
|
|
|
|
j8c = "-classpath " + strings.Join(java8classpath, ":")
|
|
|
|
}
|
|
|
|
|
|
|
|
j9c := ""
|
|
|
|
if len(java9classpath) > 0 {
|
|
|
|
j9c = "-classpath " + strings.Join(java9classpath, ":")
|
2019-01-10 07:17:55 +01:00
|
|
|
}
|
2019-10-21 15:29:58 +02:00
|
|
|
|
2019-01-10 07:17:55 +01:00
|
|
|
system := ""
|
2019-10-21 15:29:58 +02:00
|
|
|
var systemDeps []string
|
2019-01-10 07:17:55 +01:00
|
|
|
if testcase.system == "none" {
|
|
|
|
system = "--system=none"
|
|
|
|
} else if testcase.system != "" {
|
2020-05-15 03:05:32 +02:00
|
|
|
dir := ""
|
2021-10-28 18:42:16 +02:00
|
|
|
// If the system modules name starts with sdk_ then it is a prebuilt module and so comes
|
|
|
|
// from the prebuilt directory.
|
|
|
|
if strings.HasPrefix(testcase.system, "sdk_") {
|
2020-05-15 03:05:32 +02:00
|
|
|
dir = "prebuilts/sdk"
|
2021-03-13 10:55:25 +01:00
|
|
|
} else {
|
|
|
|
dir = defaultJavaDir
|
2020-05-15 03:05:32 +02:00
|
|
|
}
|
2021-03-22 18:31:52 +01:00
|
|
|
system = "--system=" + filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system")
|
2019-10-21 15:29:58 +02:00
|
|
|
// The module-relative parts of these paths are hardcoded in system_modules.go:
|
|
|
|
systemDeps = []string{
|
2021-03-22 18:31:52 +01:00
|
|
|
filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "lib", "modules"),
|
|
|
|
filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "lib", "jrt-fs.jar"),
|
|
|
|
filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "release"),
|
2019-10-21 15:29:58 +02:00
|
|
|
}
|
2019-01-10 07:17:55 +01:00
|
|
|
}
|
|
|
|
|
2021-03-13 10:55:25 +01:00
|
|
|
checkClasspath := func(t *testing.T, result *android.TestResult, isJava8 bool) {
|
2021-07-20 18:47:41 +02:00
|
|
|
foo := result.ModuleForTests("foo", variant(result))
|
2021-03-29 01:42:57 +02:00
|
|
|
javac := foo.Rule("javac")
|
2019-10-21 15:29:58 +02:00
|
|
|
var deps []string
|
2019-06-15 03:51:47 +02:00
|
|
|
|
2021-03-29 01:42:57 +02:00
|
|
|
aidl := foo.MaybeRule("aidl")
|
2019-10-21 15:29:58 +02:00
|
|
|
if aidl.Rule != nil {
|
2021-03-22 18:31:52 +01:00
|
|
|
deps = append(deps, android.PathRelativeToTop(aidl.Output))
|
2019-10-21 15:29:58 +02:00
|
|
|
}
|
2019-01-10 07:17:55 +01:00
|
|
|
|
|
|
|
got := javac.Args["bootClasspath"]
|
2019-10-21 15:29:58 +02:00
|
|
|
expected := ""
|
2019-10-26 00:22:50 +02:00
|
|
|
if isJava8 || testcase.forces8 {
|
2019-10-21 15:29:58 +02:00
|
|
|
expected = bc
|
|
|
|
deps = append(deps, bcDeps...)
|
|
|
|
} else {
|
|
|
|
expected = system
|
|
|
|
deps = append(deps, systemDeps...)
|
|
|
|
}
|
|
|
|
if got != expected {
|
|
|
|
t.Errorf("bootclasspath expected %q != got %q", expected, got)
|
2019-01-10 07:17:55 +01:00
|
|
|
}
|
|
|
|
|
2019-10-26 00:22:50 +02:00
|
|
|
if isJava8 || testcase.forces8 {
|
|
|
|
expected = j8c
|
|
|
|
deps = append(deps, java8classpath...)
|
|
|
|
} else {
|
|
|
|
expected = j9c
|
|
|
|
deps = append(deps, java9classpath...)
|
|
|
|
}
|
2019-01-10 07:17:55 +01:00
|
|
|
got = javac.Args["classpath"]
|
2019-10-26 00:22:50 +02:00
|
|
|
if got != expected {
|
|
|
|
t.Errorf("classpath expected %q != got %q", expected, got)
|
2019-01-10 07:17:55 +01:00
|
|
|
}
|
|
|
|
|
2021-03-22 18:31:52 +01:00
|
|
|
android.AssertPathsRelativeToTopEquals(t, "implicits", deps, javac.Implicits)
|
2019-04-18 19:56:44 +02:00
|
|
|
}
|
|
|
|
|
2021-10-28 19:16:14 +02:00
|
|
|
preparer := android.NullFixturePreparer
|
|
|
|
if alwaysUsePrebuiltSdks {
|
|
|
|
preparer = android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-03-22 16:36:52 +01:00
|
|
|
fixtureFactory := android.GroupFixturePreparers(
|
|
|
|
prepareForJavaTest,
|
2021-03-13 11:18:26 +01:00
|
|
|
FixtureWithPrebuiltApis(map[string][]string{
|
|
|
|
"29": {},
|
|
|
|
"30": {},
|
2021-10-28 18:42:16 +02:00
|
|
|
"31": {},
|
|
|
|
"32": {},
|
2021-03-13 11:18:26 +01:00
|
|
|
"current": {},
|
|
|
|
}),
|
2021-03-13 10:55:25 +01:00
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
if testcase.unbundled {
|
|
|
|
variables.Unbundled_build = proptools.BoolPtr(true)
|
|
|
|
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
android.FixtureModifyEnv(func(env map[string]string) {
|
|
|
|
if env["ANDROID_JAVA8_HOME"] == "" {
|
|
|
|
env["ANDROID_JAVA8_HOME"] = "jdk8"
|
|
|
|
}
|
|
|
|
}),
|
2021-10-28 19:16:14 +02:00
|
|
|
preparer,
|
2021-03-13 10:55:25 +01:00
|
|
|
)
|
|
|
|
|
2019-10-01 14:57:31 +02:00
|
|
|
// Test with legacy javac -source 1.8 -target 1.8
|
2019-05-02 16:32:11 +02:00
|
|
|
t.Run("Java language level 8", func(t *testing.T) {
|
2021-03-13 10:55:25 +01:00
|
|
|
result := fixtureFactory.RunTestWithBp(t, bpJava8)
|
2019-04-18 19:56:44 +02:00
|
|
|
|
2021-03-13 10:55:25 +01:00
|
|
|
checkClasspath(t, result, true /* isJava8 */)
|
2019-04-18 19:56:44 +02:00
|
|
|
|
|
|
|
if testcase.host != android.Host {
|
2021-07-20 18:47:41 +02:00
|
|
|
aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl")
|
2019-04-18 19:56:44 +02:00
|
|
|
|
2021-03-13 10:55:25 +01:00
|
|
|
android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.")
|
2019-04-18 19:56:44 +02:00
|
|
|
}
|
2019-01-10 07:17:55 +01:00
|
|
|
})
|
|
|
|
|
2019-10-01 14:57:31 +02:00
|
|
|
// Test with default javac -source 9 -target 9
|
2019-05-02 16:32:11 +02:00
|
|
|
t.Run("Java language level 9", func(t *testing.T) {
|
2021-03-13 10:55:25 +01:00
|
|
|
result := fixtureFactory.RunTestWithBp(t, bp)
|
2019-01-10 07:17:55 +01:00
|
|
|
|
2021-03-13 10:55:25 +01:00
|
|
|
checkClasspath(t, result, false /* isJava8 */)
|
2019-10-21 15:29:58 +02:00
|
|
|
|
|
|
|
if testcase.host != android.Host {
|
2021-07-20 18:47:41 +02:00
|
|
|
aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl")
|
2019-10-21 15:29:58 +02:00
|
|
|
|
2021-03-13 10:55:25 +01:00
|
|
|
android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.")
|
2019-01-10 07:17:55 +01:00
|
|
|
}
|
|
|
|
})
|
2019-04-03 01:10:56 +02:00
|
|
|
|
2021-03-13 10:55:25 +01:00
|
|
|
prepareWithPlatformVersionRel := android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
variables.Platform_sdk_codename = proptools.StringPtr("REL")
|
|
|
|
variables.Platform_sdk_final = proptools.BoolPtr(true)
|
|
|
|
})
|
|
|
|
|
2019-10-21 15:29:58 +02:00
|
|
|
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 8 -target 8
|
|
|
|
t.Run("REL + Java language level 8", func(t *testing.T) {
|
2021-03-29 03:16:14 +02:00
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bpJava8)
|
2019-04-03 01:10:56 +02:00
|
|
|
|
2021-03-13 10:55:25 +01:00
|
|
|
checkClasspath(t, result, true /* isJava8 */)
|
2019-04-03 01:10:56 +02:00
|
|
|
})
|
2019-10-21 15:29:58 +02:00
|
|
|
|
2019-10-17 23:23:50 +02:00
|
|
|
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9
|
|
|
|
t.Run("REL + Java language level 9", func(t *testing.T) {
|
2021-03-29 03:16:14 +02:00
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bp)
|
2019-10-17 23:23:50 +02:00
|
|
|
|
2021-03-13 10:55:25 +01:00
|
|
|
checkClasspath(t, result, false /* isJava8 */)
|
2019-10-17 23:23:50 +02:00
|
|
|
})
|
2019-01-10 07:17:55 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|