blob: 1f23b140c4ba18679bb770ce3293301f48cda95d [file] [log] [blame]
Colin Crossfb6d7812019-01-09 22:17:55 -08001// Copyright 2019 Google Inc. All rights reserved.
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
15package java
16
17import (
Colin Crossfb6d7812019-01-09 22:17:55 -080018 "path/filepath"
19 "reflect"
20 "strings"
21 "testing"
22
23 "github.com/google/blueprint/proptools"
Colin Cross60405e52019-04-18 12:31:22 -070024
25 "android/soong/android"
26 "android/soong/java/config"
Colin Crossfb6d7812019-01-09 22:17:55 -080027)
28
Colin Crossfb6d7812019-01-09 22:17:55 -080029func TestClasspath(t *testing.T) {
Colin Cross3047fa22019-04-18 10:56:44 -070030 var classpathTestcases = []struct {
Colin Cross617b1452019-10-25 15:22:50 -070031 name string
32 unbundled bool
33 pdk bool
34 moduleType string
35 host android.OsClass
36 properties string
37
38 // for java 8
39 bootclasspath []string
40 java8classpath []string
41
42 // for java 9
43 system string
44 java9classpath []string
45
46 forces8 bool // if set, javac will always be called with java 8 arguments
47
48 aidl string
Colin Cross3047fa22019-04-18 10:56:44 -070049 }{
50 {
Colin Cross617b1452019-10-25 15:22:50 -070051 name: "default",
Pete Gillin0638dfc2020-07-01 10:48:14 +010052 bootclasspath: config.LegacyCorePlatformBootclasspathLibraries,
53 system: config.LegacyCorePlatformSystemModules,
54 java8classpath: config.FrameworkLibraries,
55 java9classpath: config.FrameworkLibraries,
Colin Cross617b1452019-10-25 15:22:50 -070056 aidl: "-Iframework/aidl",
Colin Cross3047fa22019-04-18 10:56:44 -070057 },
58 {
Colin Cross617b1452019-10-25 15:22:50 -070059 name: `sdk_version:"core_platform"`,
60 properties: `sdk_version:"core_platform"`,
Pete Gillin0638dfc2020-07-01 10:48:14 +010061 bootclasspath: config.LegacyCorePlatformBootclasspathLibraries,
62 system: config.LegacyCorePlatformSystemModules,
Colin Cross617b1452019-10-25 15:22:50 -070063 java8classpath: []string{},
64 aidl: "",
Paul Duffin50c217c2019-06-12 13:25:22 +010065 },
66 {
Colin Cross617b1452019-10-25 15:22:50 -070067 name: "blank sdk version",
68 properties: `sdk_version: "",`,
Pete Gillin0638dfc2020-07-01 10:48:14 +010069 bootclasspath: config.LegacyCorePlatformBootclasspathLibraries,
70 system: config.LegacyCorePlatformSystemModules,
71 java8classpath: config.FrameworkLibraries,
72 java9classpath: config.FrameworkLibraries,
Colin Cross617b1452019-10-25 15:22:50 -070073 aidl: "-Iframework/aidl",
Colin Cross3047fa22019-04-18 10:56:44 -070074 },
75 {
76
Colin Cross74362a42019-10-28 08:05:02 -070077 name: "sdk v29",
78 properties: `sdk_version: "29",`,
Colin Cross617b1452019-10-25 15:22:50 -070079 bootclasspath: []string{`""`},
80 forces8: true,
Colin Cross74362a42019-10-28 08:05:02 -070081 java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
82 aidl: "-pprebuilts/sdk/29/public/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -070083 },
84 {
85
Colin Cross17dec172020-05-14 18:05:32 -070086 name: "sdk v30",
87 properties: `sdk_version: "30",`,
88 bootclasspath: []string{`""`},
89 system: "sdk_public_30_system_modules",
90 java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
91 java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
92 aidl: "-pprebuilts/sdk/30/public/framework.aidl",
93 },
94 {
95
Colin Cross6cef4812019-10-17 14:23:50 -070096 name: "current",
97 properties: `sdk_version: "current",`,
98 bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"},
99 system: "core-current-stubs-system-modules",
100 java9classpath: []string{"android_stubs_current"},
101 aidl: "-p" + buildDir + "/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700102 },
103 {
104
Colin Cross6cef4812019-10-17 14:23:50 -0700105 name: "system_current",
106 properties: `sdk_version: "system_current",`,
107 bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"},
108 system: "core-current-stubs-system-modules",
109 java9classpath: []string{"android_system_stubs_current"},
110 aidl: "-p" + buildDir + "/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700111 },
112 {
113
Colin Cross74362a42019-10-28 08:05:02 -0700114 name: "system_29",
115 properties: `sdk_version: "system_29",`,
Colin Cross617b1452019-10-25 15:22:50 -0700116 bootclasspath: []string{`""`},
117 forces8: true,
Colin Cross74362a42019-10-28 08:05:02 -0700118 java8classpath: []string{"prebuilts/sdk/29/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
119 aidl: "-pprebuilts/sdk/29/public/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700120 },
121 {
122
Colin Cross17dec172020-05-14 18:05:32 -0700123 name: "system_30",
124 properties: `sdk_version: "system_30",`,
125 bootclasspath: []string{`""`},
126 system: "sdk_public_30_system_modules",
127 java8classpath: []string{"prebuilts/sdk/30/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
128 java9classpath: []string{"prebuilts/sdk/30/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
129 aidl: "-pprebuilts/sdk/30/public/framework.aidl",
130 },
131 {
132
Colin Cross6cef4812019-10-17 14:23:50 -0700133 name: "test_current",
134 properties: `sdk_version: "test_current",`,
135 bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"},
136 system: "core-current-stubs-system-modules",
137 java9classpath: []string{"android_test_stubs_current"},
138 aidl: "-p" + buildDir + "/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700139 },
140 {
141
Pete Gillin880f9642020-07-01 13:17:16 +0100142 name: "core_current",
143 properties: `sdk_version: "core_current",`,
144 bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"},
145 system: "core-current-stubs-system-modules",
Colin Cross3047fa22019-04-18 10:56:44 -0700146 },
147 {
148
Colin Cross617b1452019-10-25 15:22:50 -0700149 name: "nostdlib",
150 properties: `sdk_version: "none", system_modules: "none"`,
151 system: "none",
152 bootclasspath: []string{`""`},
153 java8classpath: []string{},
Paul Duffin52d398a2019-06-11 12:31:14 +0100154 },
155 {
156
Colin Cross617b1452019-10-25 15:22:50 -0700157 name: "nostdlib system_modules",
Pete Gillin1f41dbf2020-06-02 15:59:45 +0100158 properties: `sdk_version: "none", system_modules: "legacy-core-platform-api-stubs-system-modules"`,
159 system: "legacy-core-platform-api-stubs-system-modules",
160 bootclasspath: []string{"legacy-core-platform-api-stubs-system-modules-lib"},
Colin Cross617b1452019-10-25 15:22:50 -0700161 java8classpath: []string{},
Paul Duffin52d398a2019-06-11 12:31:14 +0100162 },
163 {
164
Colin Cross617b1452019-10-25 15:22:50 -0700165 name: "host default",
166 moduleType: "java_library_host",
167 properties: ``,
168 host: android.Host,
169 bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
170 java8classpath: []string{},
Colin Cross3047fa22019-04-18 10:56:44 -0700171 },
172 {
Colin Cross3047fa22019-04-18 10:56:44 -0700173
Colin Cross617b1452019-10-25 15:22:50 -0700174 name: "host supported default",
175 host: android.Host,
176 properties: `host_supported: true,`,
177 java8classpath: []string{},
178 bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
Colin Cross3047fa22019-04-18 10:56:44 -0700179 },
180 {
Colin Cross617b1452019-10-25 15:22:50 -0700181 name: "host supported nostdlib",
182 host: android.Host,
183 properties: `host_supported: true, sdk_version: "none", system_modules: "none"`,
184 java8classpath: []string{},
Paul Duffin52d398a2019-06-11 12:31:14 +0100185 },
186 {
Colin Cross3047fa22019-04-18 10:56:44 -0700187
Colin Cross74362a42019-10-28 08:05:02 -0700188 name: "unbundled sdk v29",
Colin Cross617b1452019-10-25 15:22:50 -0700189 unbundled: true,
Colin Cross74362a42019-10-28 08:05:02 -0700190 properties: `sdk_version: "29",`,
Colin Cross617b1452019-10-25 15:22:50 -0700191 bootclasspath: []string{`""`},
192 forces8: true,
Colin Cross74362a42019-10-28 08:05:02 -0700193 java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
194 aidl: "-pprebuilts/sdk/29/public/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700195 },
196 {
197
Colin Cross17dec172020-05-14 18:05:32 -0700198 name: "unbundled sdk v30",
199 unbundled: true,
200 properties: `sdk_version: "30",`,
201 bootclasspath: []string{`""`},
202 system: "sdk_public_30_system_modules",
203 java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
204 java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
205 aidl: "-pprebuilts/sdk/30/public/framework.aidl",
206 },
207 {
208
Colin Cross617b1452019-10-25 15:22:50 -0700209 name: "unbundled current",
210 unbundled: true,
211 properties: `sdk_version: "current",`,
212 bootclasspath: []string{`""`},
Colin Cross17dec172020-05-14 18:05:32 -0700213 system: "sdk_public_current_system_modules",
Colin Cross617b1452019-10-25 15:22:50 -0700214 java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
Colin Cross17dec172020-05-14 18:05:32 -0700215 java9classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
Colin Cross617b1452019-10-25 15:22:50 -0700216 aidl: "-pprebuilts/sdk/current/public/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700217 },
218
219 {
Colin Cross617b1452019-10-25 15:22:50 -0700220 name: "pdk default",
221 pdk: true,
222 bootclasspath: []string{`""`},
Colin Cross17dec172020-05-14 18:05:32 -0700223 system: "sdk_public_30_system_modules",
224 java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
225 java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
226 aidl: "-pprebuilts/sdk/30/public/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700227 },
228 {
Colin Cross617b1452019-10-25 15:22:50 -0700229 name: "pdk current",
230 pdk: true,
231 properties: `sdk_version: "current",`,
232 bootclasspath: []string{`""`},
Colin Cross17dec172020-05-14 18:05:32 -0700233 system: "sdk_public_30_system_modules",
234 java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
235 java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
236 aidl: "-pprebuilts/sdk/30/public/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700237 },
238 {
Colin Cross74362a42019-10-28 08:05:02 -0700239 name: "pdk 29",
Colin Cross617b1452019-10-25 15:22:50 -0700240 pdk: true,
Colin Cross74362a42019-10-28 08:05:02 -0700241 properties: `sdk_version: "29",`,
Colin Cross617b1452019-10-25 15:22:50 -0700242 bootclasspath: []string{`""`},
Colin Cross17dec172020-05-14 18:05:32 -0700243 system: "sdk_public_30_system_modules",
244 java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
245 java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
246 aidl: "-pprebuilts/sdk/30/public/framework.aidl",
Colin Cross3047fa22019-04-18 10:56:44 -0700247 },
Jiyong Park50146e92020-01-30 18:00:15 +0900248 {
Jiyong Park50146e92020-01-30 18:00:15 +0900249 name: "module_current",
250 properties: `sdk_version: "module_current",`,
251 bootclasspath: []string{"android_module_lib_stubs_current", "core-lambda-stubs"},
252 system: "core-current-stubs-system-modules",
253 java9classpath: []string{"android_module_lib_stubs_current"},
Anton Hansson3f07ab22020-04-09 13:29:59 +0100254 aidl: "-p" + buildDir + "/framework_non_updatable.aidl",
Jiyong Park50146e92020-01-30 18:00:15 +0900255 },
Jiyong Parkaae9bd12020-02-12 04:36:43 +0900256 {
257 name: "system_server_current",
258 properties: `sdk_version: "system_server_current",`,
Anton Hanssonba6ab2e2020-03-19 15:23:38 +0000259 bootclasspath: []string{"android_system_server_stubs_current", "core-lambda-stubs"},
Jiyong Parkaae9bd12020-02-12 04:36:43 +0900260 system: "core-current-stubs-system-modules",
Anton Hanssonba6ab2e2020-03-19 15:23:38 +0000261 java9classpath: []string{"android_system_server_stubs_current"},
Jiyong Parkaae9bd12020-02-12 04:36:43 +0900262 aidl: "-p" + buildDir + "/framework.aidl",
263 },
Colin Cross3047fa22019-04-18 10:56:44 -0700264 }
265
Colin Crossfb6d7812019-01-09 22:17:55 -0800266 for _, testcase := range classpathTestcases {
267 t.Run(testcase.name, func(t *testing.T) {
268 moduleType := "java_library"
269 if testcase.moduleType != "" {
270 moduleType = testcase.moduleType
271 }
272
Pete Gillinbdf5d712019-10-21 14:29:58 +0100273 props := `
Colin Crossfb6d7812019-01-09 22:17:55 -0800274 name: "foo",
275 srcs: ["a.java"],
Colin Cross3047fa22019-04-18 10:56:44 -0700276 target: {
277 android: {
278 srcs: ["bar-doc/IFoo.aidl"],
279 },
280 },
Pete Gillinbdf5d712019-10-21 14:29:58 +0100281 `
282 bp := moduleType + " {" + props + testcase.properties + `
283 }`
284 bpJava8 := moduleType + " {" + props + `java_version: "1.8",
Colin Crossfb6d7812019-01-09 22:17:55 -0800285 ` + testcase.properties + `
286 }`
287
288 variant := "android_common"
289 if testcase.host == android.Host {
290 variant = android.BuildOs.String() + "_common"
291 }
292
293 convertModulesToPaths := func(cp []string) []string {
294 ret := make([]string, len(cp))
295 for i, e := range cp {
296 ret[i] = moduleToPath(e)
297 }
298 return ret
299 }
300
301 bootclasspath := convertModulesToPaths(testcase.bootclasspath)
Colin Cross617b1452019-10-25 15:22:50 -0700302 java8classpath := convertModulesToPaths(testcase.java8classpath)
303 java9classpath := convertModulesToPaths(testcase.java9classpath)
Colin Crossfb6d7812019-01-09 22:17:55 -0800304
Pete Gillinbdf5d712019-10-21 14:29:58 +0100305 bc := ""
306 var bcDeps []string
307 if len(bootclasspath) > 0 {
308 bc = "-bootclasspath " + strings.Join(bootclasspath, ":")
309 if bootclasspath[0] != `""` {
310 bcDeps = bootclasspath
311 }
Colin Crossfb6d7812019-01-09 22:17:55 -0800312 }
313
Colin Cross617b1452019-10-25 15:22:50 -0700314 j8c := ""
315 if len(java8classpath) > 0 {
316 j8c = "-classpath " + strings.Join(java8classpath, ":")
317 }
318
319 j9c := ""
320 if len(java9classpath) > 0 {
321 j9c = "-classpath " + strings.Join(java9classpath, ":")
Colin Crossfb6d7812019-01-09 22:17:55 -0800322 }
Pete Gillinbdf5d712019-10-21 14:29:58 +0100323
Colin Crossfb6d7812019-01-09 22:17:55 -0800324 system := ""
Pete Gillinbdf5d712019-10-21 14:29:58 +0100325 var systemDeps []string
Colin Crossfb6d7812019-01-09 22:17:55 -0800326 if testcase.system == "none" {
327 system = "--system=none"
328 } else if testcase.system != "" {
Colin Cross17dec172020-05-14 18:05:32 -0700329 dir := ""
330 if strings.HasPrefix(testcase.system, "sdk_public_") {
331 dir = "prebuilts/sdk"
332 }
333 system = "--system=" + filepath.Join(buildDir, ".intermediates", dir, testcase.system, "android_common", "system")
Pete Gillinbdf5d712019-10-21 14:29:58 +0100334 // The module-relative parts of these paths are hardcoded in system_modules.go:
335 systemDeps = []string{
Colin Cross17dec172020-05-14 18:05:32 -0700336 filepath.Join(buildDir, ".intermediates", dir, testcase.system, "android_common", "system", "lib", "modules"),
337 filepath.Join(buildDir, ".intermediates", dir, testcase.system, "android_common", "system", "lib", "jrt-fs.jar"),
338 filepath.Join(buildDir, ".intermediates", dir, testcase.system, "android_common", "system", "release"),
Pete Gillinbdf5d712019-10-21 14:29:58 +0100339 }
Colin Crossfb6d7812019-01-09 22:17:55 -0800340 }
341
Pete Gillinbdf5d712019-10-21 14:29:58 +0100342 checkClasspath := func(t *testing.T, ctx *android.TestContext, isJava8 bool) {
Colin Crossc0806172019-06-14 18:51:47 -0700343 foo := ctx.ModuleForTests("foo", variant)
344 javac := foo.Rule("javac")
Pete Gillinbdf5d712019-10-21 14:29:58 +0100345 var deps []string
Colin Crossc0806172019-06-14 18:51:47 -0700346
347 aidl := foo.MaybeRule("aidl")
Pete Gillinbdf5d712019-10-21 14:29:58 +0100348 if aidl.Rule != nil {
349 deps = append(deps, aidl.Output.String())
350 }
Colin Crossfb6d7812019-01-09 22:17:55 -0800351
352 got := javac.Args["bootClasspath"]
Pete Gillinbdf5d712019-10-21 14:29:58 +0100353 expected := ""
Colin Cross617b1452019-10-25 15:22:50 -0700354 if isJava8 || testcase.forces8 {
Pete Gillinbdf5d712019-10-21 14:29:58 +0100355 expected = bc
356 deps = append(deps, bcDeps...)
357 } else {
358 expected = system
359 deps = append(deps, systemDeps...)
360 }
361 if got != expected {
362 t.Errorf("bootclasspath expected %q != got %q", expected, got)
Colin Crossfb6d7812019-01-09 22:17:55 -0800363 }
364
Colin Cross617b1452019-10-25 15:22:50 -0700365 if isJava8 || testcase.forces8 {
366 expected = j8c
367 deps = append(deps, java8classpath...)
368 } else {
369 expected = j9c
370 deps = append(deps, java9classpath...)
Colin Crossfb6d7812019-01-09 22:17:55 -0800371 }
Colin Cross617b1452019-10-25 15:22:50 -0700372 got = javac.Args["classpath"]
373 if got != expected {
374 t.Errorf("classpath expected %q != got %q", expected, got)
375 }
Colin Crossfb6d7812019-01-09 22:17:55 -0800376
377 if !reflect.DeepEqual(javac.Implicits.Strings(), deps) {
378 t.Errorf("implicits expected %q != got %q", deps, javac.Implicits.Strings())
379 }
Colin Cross3047fa22019-04-18 10:56:44 -0700380 }
381
Pete Gillin1b3370f2019-10-01 13:57:31 +0100382 // Test with legacy javac -source 1.8 -target 1.8
Pete Gillin0c2143e2019-05-02 15:32:11 +0100383 t.Run("Java language level 8", func(t *testing.T) {
Colin Cross98be1bb2019-12-13 20:41:13 -0800384 config := testConfig(nil, bpJava8, nil)
Colin Cross3047fa22019-04-18 10:56:44 -0700385 if testcase.unbundled {
386 config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
387 }
388 if testcase.pdk {
389 config.TestProductVariables.Pdk = proptools.BoolPtr(true)
390 }
Colin Cross98be1bb2019-12-13 20:41:13 -0800391 ctx := testContext()
Colin Cross3047fa22019-04-18 10:56:44 -0700392 run(t, ctx, config)
393
Pete Gillinbdf5d712019-10-21 14:29:58 +0100394 checkClasspath(t, ctx, true /* isJava8 */)
Colin Cross3047fa22019-04-18 10:56:44 -0700395
396 if testcase.host != android.Host {
397 aidl := ctx.ModuleForTests("foo", variant).Rule("aidl")
398
Colin Crossc0806172019-06-14 18:51:47 -0700399 if g, w := aidl.RuleParams.Command, testcase.aidl+" -I."; !strings.Contains(g, w) {
400 t.Errorf("want aidl command to contain %q, got %q", w, g)
Colin Cross3047fa22019-04-18 10:56:44 -0700401 }
402 }
Colin Crossfb6d7812019-01-09 22:17:55 -0800403 })
404
Pete Gillin1b3370f2019-10-01 13:57:31 +0100405 // Test with default javac -source 9 -target 9
Pete Gillin0c2143e2019-05-02 15:32:11 +0100406 t.Run("Java language level 9", func(t *testing.T) {
Colin Cross98be1bb2019-12-13 20:41:13 -0800407 config := testConfig(nil, bp, nil)
Colin Crossfb6d7812019-01-09 22:17:55 -0800408 if testcase.unbundled {
409 config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
410 }
Colin Cross98fd5742019-01-09 23:04:25 -0800411 if testcase.pdk {
412 config.TestProductVariables.Pdk = proptools.BoolPtr(true)
413 }
Colin Cross98be1bb2019-12-13 20:41:13 -0800414 ctx := testContext()
Colin Crossfb6d7812019-01-09 22:17:55 -0800415 run(t, ctx, config)
416
Pete Gillinbdf5d712019-10-21 14:29:58 +0100417 checkClasspath(t, ctx, false /* isJava8 */)
418
419 if testcase.host != android.Host {
420 aidl := ctx.ModuleForTests("foo", variant).Rule("aidl")
421
422 if g, w := aidl.RuleParams.Command, testcase.aidl+" -I."; !strings.Contains(g, w) {
423 t.Errorf("want aidl command to contain %q, got %q", w, g)
424 }
Colin Crossfb6d7812019-01-09 22:17:55 -0800425 }
426 })
Colin Crossff0daf42019-04-02 16:10:56 -0700427
Pete Gillinbdf5d712019-10-21 14:29:58 +0100428 // Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 8 -target 8
429 t.Run("REL + Java language level 8", func(t *testing.T) {
Colin Cross98be1bb2019-12-13 20:41:13 -0800430 config := testConfig(nil, bpJava8, nil)
Colin Crossff0daf42019-04-02 16:10:56 -0700431 config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL")
432 config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true)
433
434 if testcase.unbundled {
435 config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
436 }
437 if testcase.pdk {
438 config.TestProductVariables.Pdk = proptools.BoolPtr(true)
439 }
Colin Cross98be1bb2019-12-13 20:41:13 -0800440 ctx := testContext()
Colin Crossff0daf42019-04-02 16:10:56 -0700441 run(t, ctx, config)
442
Pete Gillinbdf5d712019-10-21 14:29:58 +0100443 checkClasspath(t, ctx, true /* isJava8 */)
Colin Crossff0daf42019-04-02 16:10:56 -0700444 })
Pete Gillinbdf5d712019-10-21 14:29:58 +0100445
Colin Cross6cef4812019-10-17 14:23:50 -0700446 // Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9
447 t.Run("REL + Java language level 9", func(t *testing.T) {
Colin Cross98be1bb2019-12-13 20:41:13 -0800448 config := testConfig(nil, bp, nil)
Colin Cross6cef4812019-10-17 14:23:50 -0700449 config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL")
450 config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true)
451
452 if testcase.unbundled {
453 config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
454 }
455 if testcase.pdk {
456 config.TestProductVariables.Pdk = proptools.BoolPtr(true)
457 }
Colin Cross98be1bb2019-12-13 20:41:13 -0800458 ctx := testContext()
Colin Cross6cef4812019-10-17 14:23:50 -0700459 run(t, ctx, config)
460
461 checkClasspath(t, ctx, false /* isJava8 */)
462 })
Colin Crossfb6d7812019-01-09 22:17:55 -0800463 })
464 }
Colin Crossfb6d7812019-01-09 22:17:55 -0800465}