• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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 (
18	"path/filepath"
19	"strings"
20	"testing"
21
22	"github.com/google/blueprint/proptools"
23
24	"android/soong/android"
25	"android/soong/java/config"
26)
27
28type classpathTestCase struct {
29	name       string
30	unbundled  bool
31	moduleType string
32	host       android.OsClass
33	properties string
34
35	// for java 8
36	bootclasspath  []string
37	java8classpath []string
38
39	// for java 9
40	system         string
41	java9classpath []string
42
43	forces8 bool // if set, javac will always be called with java 8 arguments
44
45	aidl string
46
47	// Indicates how this test case is affected by the setting of Always_use_prebuilt_sdks.
48	//
49	// If this is nil then the test case is unaffected by the setting of Always_use_prebuilt_sdks.
50	// Otherwise, the test case can only be used when
51	// Always_use_prebuilt_sdks=*forAlwaysUsePrebuiltSdks.
52	forAlwaysUsePrebuiltSdks *bool
53}
54
55func TestClasspath(t *testing.T) {
56	const frameworkAidl = "-I" + defaultJavaDir + "/framework/aidl"
57	var classpathTestcases = []classpathTestCase{
58		{
59			name:           "default",
60			bootclasspath:  config.StableCorePlatformBootclasspathLibraries,
61			system:         config.StableCorePlatformSystemModules,
62			java8classpath: config.FrameworkLibraries,
63			java9classpath: config.FrameworkLibraries,
64			aidl:           frameworkAidl,
65		},
66		{
67			name:           `sdk_version:"core_platform"`,
68			properties:     `sdk_version:"core_platform"`,
69			bootclasspath:  config.StableCorePlatformBootclasspathLibraries,
70			system:         config.StableCorePlatformSystemModules,
71			java8classpath: []string{},
72			aidl:           "",
73		},
74		{
75			name:           "blank sdk version",
76			properties:     `sdk_version: "",`,
77			bootclasspath:  config.StableCorePlatformBootclasspathLibraries,
78			system:         config.StableCorePlatformSystemModules,
79			java8classpath: config.FrameworkLibraries,
80			java9classpath: config.FrameworkLibraries,
81			aidl:           frameworkAidl,
82		},
83		{
84
85			name:           "sdk v29",
86			properties:     `sdk_version: "29",`,
87			bootclasspath:  []string{`""`},
88			forces8:        true,
89			java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
90			aidl:           "-pprebuilts/sdk/29/public/framework.aidl",
91		},
92		{
93
94			name:           "sdk v30",
95			properties:     `sdk_version: "30",`,
96			bootclasspath:  []string{`""`},
97			system:         "sdk_public_30_system_modules",
98			java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
99			java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
100			aidl:           "-pprebuilts/sdk/30/public/framework.aidl",
101		},
102		{
103			// Test case only applies when Always_use_prebuilt_sdks=false (the default).
104			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
105
106			name:           "current",
107			properties:     `sdk_version: "current",`,
108			bootclasspath:  []string{"android_stubs_current", "core-lambda-stubs"},
109			system:         "core-public-stubs-system-modules",
110			java9classpath: []string{"android_stubs_current"},
111			aidl:           "-pout/soong/framework.aidl",
112		},
113		{
114			// Test case only applies when Always_use_prebuilt_sdks=true.
115			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
116
117			name:           "current",
118			properties:     `sdk_version: "current",`,
119			bootclasspath:  []string{`""`},
120			system:         "sdk_public_current_system_modules",
121			java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
122			java9classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
123			aidl:           "-pprebuilts/sdk/current/public/framework.aidl",
124		},
125		{
126			// Test case only applies when Always_use_prebuilt_sdks=false (the default).
127			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
128
129			name:           "system_current",
130			properties:     `sdk_version: "system_current",`,
131			bootclasspath:  []string{"android_system_stubs_current", "core-lambda-stubs"},
132			system:         "core-public-stubs-system-modules",
133			java9classpath: []string{"android_system_stubs_current"},
134			aidl:           "-pout/soong/framework.aidl",
135		},
136		{
137			// Test case only applies when Always_use_prebuilt_sdks=true.
138			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
139
140			name:           "system_current",
141			properties:     `sdk_version: "system_current",`,
142			bootclasspath:  []string{`""`},
143			system:         "sdk_public_current_system_modules",
144			java8classpath: []string{"prebuilts/sdk/current/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
145			java9classpath: []string{"prebuilts/sdk/current/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
146			aidl:           "-pprebuilts/sdk/current/public/framework.aidl",
147		},
148		{
149			name:           "system_29",
150			properties:     `sdk_version: "system_29",`,
151			bootclasspath:  []string{`""`},
152			forces8:        true,
153			java8classpath: []string{"prebuilts/sdk/29/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
154			aidl:           "-pprebuilts/sdk/29/public/framework.aidl",
155		},
156		{
157			name:           "system_30",
158			properties:     `sdk_version: "system_30",`,
159			bootclasspath:  []string{`""`},
160			system:         "sdk_public_30_system_modules",
161			java8classpath: []string{"prebuilts/sdk/30/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
162			java9classpath: []string{"prebuilts/sdk/30/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
163			aidl:           "-pprebuilts/sdk/30/public/framework.aidl",
164		},
165		{
166			// Test case only applies when Always_use_prebuilt_sdks=false (the default).
167			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
168
169			name:           "test_current",
170			properties:     `sdk_version: "test_current",`,
171			bootclasspath:  []string{"android_test_stubs_current", "core-lambda-stubs"},
172			system:         "core-public-stubs-system-modules",
173			java9classpath: []string{"android_test_stubs_current"},
174			aidl:           "-pout/soong/framework.aidl",
175		},
176		{
177			// Test case only applies when Always_use_prebuilt_sdks=true.
178			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
179
180			name:           "test_current",
181			properties:     `sdk_version: "test_current",`,
182			bootclasspath:  []string{`""`},
183			system:         "sdk_public_current_system_modules",
184			java8classpath: []string{"prebuilts/sdk/current/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
185			java9classpath: []string{"prebuilts/sdk/current/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
186			aidl:           "-pprebuilts/sdk/current/public/framework.aidl",
187		},
188		{
189			name:           "test_30",
190			properties:     `sdk_version: "test_30",`,
191			bootclasspath:  []string{`""`},
192			system:         "sdk_public_30_system_modules",
193			java8classpath: []string{"prebuilts/sdk/30/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
194			java9classpath: []string{"prebuilts/sdk/30/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
195			aidl:           "-pprebuilts/sdk/30/public/framework.aidl",
196		},
197		{
198			// Test case only applies when Always_use_prebuilt_sdks=false (the default).
199			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
200
201			name:          "core_current",
202			properties:    `sdk_version: "core_current",`,
203			bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"},
204			system:        "core-public-stubs-system-modules",
205		},
206		{
207			// Test case only applies when Always_use_prebuilt_sdks=true.
208			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
209
210			name:           "core_current",
211			properties:     `sdk_version: "core_current",`,
212			bootclasspath:  []string{`""`},
213			system:         "sdk_public_current_system_modules",
214			java8classpath: []string{"prebuilts/sdk/current/core/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
215			java9classpath: []string{"prebuilts/sdk/current/core/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
216			aidl:           "-pprebuilts/sdk/current/public/framework.aidl",
217		},
218		{
219
220			name:           "nostdlib",
221			properties:     `sdk_version: "none", system_modules: "none"`,
222			system:         "none",
223			bootclasspath:  []string{`""`},
224			java8classpath: []string{},
225		},
226		{
227
228			name:           "nostdlib system_modules",
229			properties:     `sdk_version: "none", system_modules: "stable-core-platform-api-stubs-system-modules"`,
230			system:         "stable-core-platform-api-stubs-system-modules",
231			bootclasspath:  []string{"stable-core-platform-api-stubs-system-modules-lib"},
232			java8classpath: []string{},
233		},
234		{
235
236			name:           "host default",
237			moduleType:     "java_library_host",
238			properties:     ``,
239			host:           android.Host,
240			bootclasspath:  []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
241			java8classpath: []string{},
242		},
243		{
244
245			name:           "host supported default",
246			host:           android.Host,
247			properties:     `host_supported: true,`,
248			java8classpath: []string{},
249			bootclasspath:  []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"},
250		},
251		{
252			name:           "host supported nostdlib",
253			host:           android.Host,
254			properties:     `host_supported: true, sdk_version: "none", system_modules: "none"`,
255			java8classpath: []string{},
256		},
257		{
258
259			name:           "unbundled sdk v29",
260			unbundled:      true,
261			properties:     `sdk_version: "29",`,
262			bootclasspath:  []string{`""`},
263			forces8:        true,
264			java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
265			aidl:           "-pprebuilts/sdk/29/public/framework.aidl",
266		},
267		{
268
269			name:           "unbundled sdk v30",
270			unbundled:      true,
271			properties:     `sdk_version: "30",`,
272			bootclasspath:  []string{`""`},
273			system:         "sdk_public_30_system_modules",
274			java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
275			java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
276			aidl:           "-pprebuilts/sdk/30/public/framework.aidl",
277		},
278		{
279
280			name:           "unbundled current",
281			unbundled:      true,
282			properties:     `sdk_version: "current",`,
283			bootclasspath:  []string{`""`},
284			system:         "sdk_public_current_system_modules",
285			java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
286			java9classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
287			aidl:           "-pprebuilts/sdk/current/public/framework.aidl",
288		},
289		{
290			// Test case only applies when Always_use_prebuilt_sdks=false (the default).
291			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
292
293			name:           "module_current",
294			properties:     `sdk_version: "module_current",`,
295			bootclasspath:  []string{"android_module_lib_stubs_current", "core-lambda-stubs"},
296			system:         "core-module-lib-stubs-system-modules",
297			java9classpath: []string{"android_module_lib_stubs_current"},
298			aidl:           "-pout/soong/framework_non_updatable.aidl",
299		},
300		{
301			// Test case only applies when Always_use_prebuilt_sdks=true.
302			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
303
304			name:           "module_current",
305			properties:     `sdk_version: "module_current",`,
306			bootclasspath:  []string{`""`},
307			system:         "sdk_module-lib_current_system_modules",
308			java8classpath: []string{"prebuilts/sdk/current/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
309			java9classpath: []string{"prebuilts/sdk/current/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
310			aidl:           "-pprebuilts/sdk/current/public/framework.aidl",
311		},
312		{
313			name:           "module_30",
314			properties:     `sdk_version: "module_30",`,
315			bootclasspath:  []string{`""`},
316			system:         "sdk_public_30_system_modules",
317			java8classpath: []string{"prebuilts/sdk/30/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
318			java9classpath: []string{"prebuilts/sdk/30/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
319			aidl:           "-pprebuilts/sdk/30/public/framework.aidl",
320		},
321		{
322			name:           "module_31",
323			properties:     `sdk_version: "module_31",`,
324			bootclasspath:  []string{`""`},
325			system:         "sdk_public_31_system_modules",
326			java8classpath: []string{"prebuilts/sdk/31/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
327			java9classpath: []string{"prebuilts/sdk/31/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
328			aidl:           "-pprebuilts/sdk/31/public/framework.aidl",
329		},
330		{
331			name:           "module_32",
332			properties:     `sdk_version: "module_32",`,
333			bootclasspath:  []string{`""`},
334			system:         "sdk_module-lib_32_system_modules",
335			java8classpath: []string{"prebuilts/sdk/32/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
336			java9classpath: []string{"prebuilts/sdk/32/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
337			aidl:           "-pprebuilts/sdk/32/public/framework.aidl",
338		},
339		{
340			// Test case only applies when Always_use_prebuilt_sdks=false (the default).
341			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false),
342
343			name:           "system_server_current",
344			properties:     `sdk_version: "system_server_current",`,
345			bootclasspath:  []string{"android_system_server_stubs_current", "core-lambda-stubs"},
346			system:         "core-module-lib-stubs-system-modules",
347			java9classpath: []string{"android_system_server_stubs_current"},
348			aidl:           "-pout/soong/framework.aidl",
349		},
350		{
351			// Test case only applies when Always_use_prebuilt_sdks=true.
352			forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true),
353
354			name:           "system_server_current",
355			properties:     `sdk_version: "system_server_current",`,
356			bootclasspath:  []string{`""`},
357			system:         "sdk_module-lib_current_system_modules",
358			java8classpath: []string{"prebuilts/sdk/current/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
359			java9classpath: []string{"prebuilts/sdk/current/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
360			aidl:           "-pprebuilts/sdk/current/public/framework.aidl",
361		},
362		{
363			name:           "system_server_30",
364			properties:     `sdk_version: "system_server_30",`,
365			bootclasspath:  []string{`""`},
366			system:         "sdk_public_30_system_modules",
367			java8classpath: []string{"prebuilts/sdk/30/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
368			java9classpath: []string{"prebuilts/sdk/30/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
369			aidl:           "-pprebuilts/sdk/30/public/framework.aidl",
370		},
371		{
372			name:           "system_server_31",
373			properties:     `sdk_version: "system_server_31",`,
374			bootclasspath:  []string{`""`},
375			system:         "sdk_public_31_system_modules",
376			java8classpath: []string{"prebuilts/sdk/31/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
377			java9classpath: []string{"prebuilts/sdk/31/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
378			aidl:           "-pprebuilts/sdk/31/public/framework.aidl",
379		},
380		{
381			name:           "system_server_32",
382			properties:     `sdk_version: "system_server_32",`,
383			bootclasspath:  []string{`""`},
384			system:         "sdk_module-lib_32_system_modules",
385			java8classpath: []string{"prebuilts/sdk/32/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
386			java9classpath: []string{"prebuilts/sdk/32/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
387			aidl:           "-pprebuilts/sdk/32/public/framework.aidl",
388		},
389	}
390
391	t.Run("basic", func(t *testing.T) {
392		testClasspathTestCases(t, classpathTestcases, false)
393	})
394
395	t.Run("Always_use_prebuilt_sdks=true", func(t *testing.T) {
396		testClasspathTestCases(t, classpathTestcases, true)
397	})
398}
399
400func testClasspathTestCases(t *testing.T, classpathTestcases []classpathTestCase, alwaysUsePrebuiltSdks bool) {
401	for _, testcase := range classpathTestcases {
402		if testcase.forAlwaysUsePrebuiltSdks != nil && *testcase.forAlwaysUsePrebuiltSdks != alwaysUsePrebuiltSdks {
403			continue
404		}
405
406		t.Run(testcase.name, func(t *testing.T) {
407			moduleType := "java_library"
408			if testcase.moduleType != "" {
409				moduleType = testcase.moduleType
410			}
411
412			props := `
413				name: "foo",
414				srcs: ["a.java"],
415				target: {
416					android: {
417						srcs: ["bar-doc/IFoo.aidl"],
418					},
419				},
420				`
421			bp := moduleType + " {" + props + testcase.properties + `
422			}`
423			bpJava8 := moduleType + " {" + props + `java_version: "1.8",
424				` + testcase.properties + `
425			}`
426
427			variant := func(result *android.TestResult) string {
428				if testcase.host == android.Host {
429					return result.Config.BuildOS.String() + "_common"
430				}
431				return "android_common"
432			}
433
434			convertModulesToPaths := func(cp []string) []string {
435				ret := make([]string, len(cp))
436				for i, e := range cp {
437					ret[i] = defaultModuleToPath(e)
438				}
439				return ret
440			}
441
442			bootclasspath := convertModulesToPaths(testcase.bootclasspath)
443			java8classpath := convertModulesToPaths(testcase.java8classpath)
444			java9classpath := convertModulesToPaths(testcase.java9classpath)
445
446			bc := ""
447			var bcDeps []string
448			if len(bootclasspath) > 0 {
449				bc = "-bootclasspath " + strings.Join(bootclasspath, ":")
450				if bootclasspath[0] != `""` {
451					bcDeps = bootclasspath
452				}
453			}
454
455			j8c := ""
456			if len(java8classpath) > 0 {
457				j8c = "-classpath " + strings.Join(java8classpath, ":")
458			}
459
460			j9c := ""
461			if len(java9classpath) > 0 {
462				j9c = "-classpath " + strings.Join(java9classpath, ":")
463			}
464
465			system := ""
466			var systemDeps []string
467			if testcase.system == "none" {
468				system = "--system=none"
469			} else if testcase.system != "" {
470				dir := ""
471				// If the system modules name starts with sdk_ then it is a prebuilt module and so comes
472				// from the prebuilt directory.
473				if strings.HasPrefix(testcase.system, "sdk_") {
474					dir = "prebuilts/sdk"
475				} else {
476					dir = defaultJavaDir
477				}
478				system = "--system=" + filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system")
479				// The module-relative parts of these paths are hardcoded in system_modules.go:
480				systemDeps = []string{
481					filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "lib", "modules"),
482					filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "lib", "jrt-fs.jar"),
483					filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "release"),
484				}
485			}
486
487			checkClasspath := func(t *testing.T, result *android.TestResult, isJava8 bool) {
488				foo := result.ModuleForTests("foo", variant(result))
489				javac := foo.Rule("javac")
490				var deps []string
491
492				aidl := foo.MaybeRule("aidl")
493				if aidl.Rule != nil {
494					deps = append(deps, android.PathRelativeToTop(aidl.Output))
495				}
496
497				got := javac.Args["bootClasspath"]
498				expected := ""
499				if isJava8 || testcase.forces8 {
500					expected = bc
501					deps = append(deps, bcDeps...)
502				} else {
503					expected = system
504					deps = append(deps, systemDeps...)
505				}
506				if got != expected {
507					t.Errorf("bootclasspath expected %q != got %q", expected, got)
508				}
509
510				if isJava8 || testcase.forces8 {
511					expected = j8c
512					deps = append(deps, java8classpath...)
513				} else {
514					expected = j9c
515					deps = append(deps, java9classpath...)
516				}
517				got = javac.Args["classpath"]
518				if got != expected {
519					t.Errorf("classpath expected %q != got %q", expected, got)
520				}
521
522				android.AssertPathsRelativeToTopEquals(t, "implicits", deps, javac.Implicits)
523			}
524
525			preparer := android.NullFixturePreparer
526			if alwaysUsePrebuiltSdks {
527				preparer = android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
528					variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
529				})
530			}
531
532			fixtureFactory := android.GroupFixturePreparers(
533				prepareForJavaTest,
534				FixtureWithPrebuiltApis(map[string][]string{
535					"29":      {},
536					"30":      {},
537					"31":      {},
538					"32":      {},
539					"current": {},
540				}),
541				android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
542					if testcase.unbundled {
543						variables.Unbundled_build = proptools.BoolPtr(true)
544						variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
545					}
546				}),
547				android.FixtureModifyEnv(func(env map[string]string) {
548					if env["ANDROID_JAVA8_HOME"] == "" {
549						env["ANDROID_JAVA8_HOME"] = "jdk8"
550					}
551				}),
552				preparer,
553			)
554
555			// Test with legacy javac -source 1.8 -target 1.8
556			t.Run("Java language level 8", func(t *testing.T) {
557				result := fixtureFactory.RunTestWithBp(t, bpJava8)
558
559				checkClasspath(t, result, true /* isJava8 */)
560
561				if testcase.host != android.Host {
562					aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl")
563
564					android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.")
565				}
566			})
567
568			// Test with default javac -source 9 -target 9
569			t.Run("Java language level 9", func(t *testing.T) {
570				result := fixtureFactory.RunTestWithBp(t, bp)
571
572				checkClasspath(t, result, false /* isJava8 */)
573
574				if testcase.host != android.Host {
575					aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl")
576
577					android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.")
578				}
579			})
580
581			prepareWithPlatformVersionRel := android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
582				variables.Platform_sdk_codename = proptools.StringPtr("REL")
583				variables.Platform_sdk_final = proptools.BoolPtr(true)
584			})
585
586			// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 8 -target 8
587			t.Run("REL + Java language level 8", func(t *testing.T) {
588				result := android.GroupFixturePreparers(
589					fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bpJava8)
590
591				checkClasspath(t, result, true /* isJava8 */)
592			})
593
594			// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9
595			t.Run("REL + Java language level 9", func(t *testing.T) {
596				result := android.GroupFixturePreparers(
597					fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bp)
598
599				checkClasspath(t, result, false /* isJava8 */)
600			})
601		})
602	}
603}
604