Split java 8 and 9 classpaths in TestClasspath

In preparation for adding the system modules jars to the classpath
for java 9, split the expected java 8 and java 9 classpaths into
separate fields.  Also replace the system: "bootclasspath" special
case with a bool that specifies that the module will always be
built using a java 8 style command line.

Test: TestClasspath
Change-Id: I661ec50d77a039c435c03bc8e6443cc5a57c206e
This commit is contained in:
Colin Cross 2019-10-25 15:22:50 -07:00
parent 5bce0931c1
commit 617b1451b4
1 changed files with 133 additions and 114 deletions

View File

@ -34,16 +34,25 @@ func TestClasspath(t *testing.T) {
moduleType string
host android.OsClass
properties string
// for java 8
bootclasspath []string
java8classpath []string
// for java 9
system string
classpath []string
java9classpath []string
forces8 bool // if set, javac will always be called with java 8 arguments
aidl string
}{
{
name: "default",
bootclasspath: config.DefaultBootclasspathLibraries,
system: config.DefaultSystemModules,
classpath: config.DefaultLibraries,
java8classpath: config.DefaultLibraries,
java9classpath: config.DefaultLibraries,
aidl: "-Iframework/aidl",
},
{
@ -51,7 +60,7 @@ func TestClasspath(t *testing.T) {
properties: `sdk_version:"core_platform"`,
bootclasspath: config.DefaultBootclasspathLibraries,
system: config.DefaultSystemModules,
classpath: []string{},
java8classpath: []string{},
aidl: "",
},
{
@ -59,7 +68,8 @@ func TestClasspath(t *testing.T) {
properties: `sdk_version: "",`,
bootclasspath: config.DefaultBootclasspathLibraries,
system: config.DefaultSystemModules,
classpath: config.DefaultLibraries,
java8classpath: config.DefaultLibraries,
java9classpath: config.DefaultLibraries,
aidl: "-Iframework/aidl",
},
{
@ -67,8 +77,8 @@ func TestClasspath(t *testing.T) {
name: "sdk v25",
properties: `sdk_version: "25",`,
bootclasspath: []string{`""`},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
forces8: true,
java8classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
},
{
@ -76,7 +86,7 @@ func TestClasspath(t *testing.T) {
name: "current",
properties: `sdk_version: "current",`,
bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
forces8: true,
aidl: "-p" + buildDir + "/framework.aidl",
},
{
@ -84,7 +94,7 @@ func TestClasspath(t *testing.T) {
name: "system_current",
properties: `sdk_version: "system_current",`,
bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
forces8: true,
aidl: "-p" + buildDir + "/framework.aidl",
},
{
@ -92,8 +102,8 @@ func TestClasspath(t *testing.T) {
name: "system_25",
properties: `sdk_version: "system_25",`,
bootclasspath: []string{`""`},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/25/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
forces8: true,
java8classpath: []string{"prebuilts/sdk/25/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
},
{
@ -101,7 +111,7 @@ func TestClasspath(t *testing.T) {
name: "test_current",
properties: `sdk_version: "test_current",`,
bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
forces8: true,
aidl: "-p" + buildDir + "/framework.aidl",
},
{
@ -109,7 +119,7 @@ func TestClasspath(t *testing.T) {
name: "core_current",
properties: `sdk_version: "core_current",`,
bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
forces8: true,
},
{
@ -117,7 +127,7 @@ func TestClasspath(t *testing.T) {
properties: `sdk_version: "none", system_modules: "none"`,
system: "none",
bootclasspath: []string{`""`},
classpath: []string{},
java8classpath: []string{},
},
{
@ -125,7 +135,7 @@ func TestClasspath(t *testing.T) {
properties: `sdk_version: "none", system_modules: "core-platform-api-stubs-system-modules"`,
system: "core-platform-api-stubs-system-modules",
bootclasspath: []string{"core-platform-api-stubs-system-modules-lib"},
classpath: []string{},
java8classpath: []string{},
},
{
@ -134,21 +144,21 @@ func TestClasspath(t *testing.T) {
properties: ``,
host: android.Host,
bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
classpath: []string{},
java8classpath: []string{},
},
{
name: "host supported default",
host: android.Host,
properties: `host_supported: true,`,
classpath: []string{},
java8classpath: []string{},
bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
},
{
name: "host supported nostdlib",
host: android.Host,
properties: `host_supported: true, sdk_version: "none", system_modules: "none"`,
classpath: []string{},
java8classpath: []string{},
},
{
@ -156,8 +166,8 @@ func TestClasspath(t *testing.T) {
unbundled: true,
properties: `sdk_version: "25",`,
bootclasspath: []string{`""`},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
forces8: true,
java8classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
},
{
@ -166,8 +176,8 @@ func TestClasspath(t *testing.T) {
unbundled: true,
properties: `sdk_version: "current",`,
bootclasspath: []string{`""`},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
forces8: true,
java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
},
@ -175,8 +185,8 @@ func TestClasspath(t *testing.T) {
name: "pdk default",
pdk: true,
bootclasspath: []string{`""`},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
forces8: true,
java8classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
},
{
@ -184,8 +194,8 @@ func TestClasspath(t *testing.T) {
pdk: true,
properties: `sdk_version: "current",`,
bootclasspath: []string{`""`},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
forces8: true,
java8classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
},
{
@ -193,8 +203,8 @@ func TestClasspath(t *testing.T) {
pdk: true,
properties: `sdk_version: "25",`,
bootclasspath: []string{`""`},
system: "bootclasspath", // special value to tell 1.9 test to expect bootclasspath
classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
forces8: true,
java8classpath: []string{"prebuilts/sdk/25/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/25/public/framework.aidl",
},
}
@ -235,7 +245,8 @@ func TestClasspath(t *testing.T) {
}
bootclasspath := convertModulesToPaths(testcase.bootclasspath)
classpath := convertModulesToPaths(testcase.classpath)
java8classpath := convertModulesToPaths(testcase.java8classpath)
java9classpath := convertModulesToPaths(testcase.java9classpath)
bc := ""
var bcDeps []string
@ -246,18 +257,20 @@ func TestClasspath(t *testing.T) {
}
}
c := ""
if len(classpath) > 0 {
c = "-classpath " + strings.Join(classpath, ":")
j8c := ""
if len(java8classpath) > 0 {
j8c = "-classpath " + strings.Join(java8classpath, ":")
}
j9c := ""
if len(java9classpath) > 0 {
j9c = "-classpath " + strings.Join(java9classpath, ":")
}
system := ""
var systemDeps []string
if testcase.system == "none" {
system = "--system=none"
} else if testcase.system == "bootclasspath" {
system = bc
systemDeps = bcDeps
} else if testcase.system != "" {
system = "--system=" + filepath.Join(buildDir, ".intermediates", testcase.system, "android_common", "system")
// The module-relative parts of these paths are hardcoded in system_modules.go:
@ -280,7 +293,7 @@ func TestClasspath(t *testing.T) {
got := javac.Args["bootClasspath"]
expected := ""
if isJava8 {
if isJava8 || testcase.forces8 {
expected = bc
deps = append(deps, bcDeps...)
} else {
@ -291,11 +304,17 @@ func TestClasspath(t *testing.T) {
t.Errorf("bootclasspath expected %q != got %q", expected, got)
}
got = javac.Args["classpath"]
if got != c {
t.Errorf("classpath expected %q != got %q", c, got)
if isJava8 || testcase.forces8 {
expected = j8c
deps = append(deps, java8classpath...)
} else {
expected = j9c
deps = append(deps, java9classpath...)
}
got = javac.Args["classpath"]
if got != expected {
t.Errorf("classpath expected %q != got %q", expected, got)
}
deps = append(deps, classpath...)
if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings())