Use jars containg sources for java generators

srcFileLists was an ill-fated attempt to deal with generators that
produce a set of java sources that is not known ahead of time.
For example, the list of files produced by protoc depends on the
package statement in the .proto file.  srcFileLists put the list
of generated files into a file, which was then passed to javac
using the @file syntax.  This worked, but it was too easy to cause
missing dependencies, and will not work well in a future distributed
build environment.

Switch to putting generated sources into a jar, and then pass them
jar to javac using -sourcepath.

Test: m checkbuild
Change-Id: Iaab7a588a6c1239f7bf46e4f1b102b3ef517619b
diff --git a/java/java.go b/java/java.go
index 6485f06..770c9c1 100644
--- a/java/java.go
+++ b/java/java.go
@@ -169,9 +169,9 @@
 
 	logtagsSrcs android.Paths
 
-	// filelists of extra source files that should be included in the javac command line,
+	// jars containing source files that should be included in the javac command line,
 	// for example R.java generated by aapt for android apps
-	ExtraSrcLists android.Paths
+	ExtraSrcJars android.Paths
 
 	// installed file for binary dependency
 	installFile android.Path
@@ -370,7 +370,7 @@
 	staticJars         android.Paths
 	staticJarResources android.Paths
 	aidlIncludeDirs    android.Paths
-	srcFileLists       android.Paths
+	srcJars            android.Paths
 	systemModules      android.Path
 	aidlPreprocess     android.OptionalPath
 }
@@ -422,7 +422,7 @@
 			if ctx.ModuleName() == "framework" {
 				// framework.jar has a one-off dependency on the R.java and Manifest.java files
 				// generated by framework-res.apk
-				deps.srcFileLists = append(deps.srcFileLists, module.(*AndroidApp).aaptJavaFileList)
+				// TODO(ccross): aapt java files should go in a src jar
 			}
 		default:
 			panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
@@ -483,13 +483,12 @@
 		flags = protoFlags(ctx, &j.protoProperties, flags)
 	}
 
-	var srcFileLists android.Paths
+	var srcJars classpath
+	srcFiles, srcJars = j.genSources(ctx, srcFiles, flags)
 
-	srcFiles, srcFileLists = j.genSources(ctx, srcFiles, flags)
+	srcJars = append(srcJars, deps.srcJars...)
 
-	srcFileLists = append(srcFileLists, deps.srcFileLists...)
-
-	srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
+	srcJars = append(srcJars, j.ExtraSrcJars...)
 
 	var jars android.Paths
 
@@ -502,13 +501,13 @@
 			// TODO(ccross): Once we always compile with javac9 we may be able to conditionally
 			//    enable error-prone without affecting the output class files.
 			errorprone := android.PathForModuleOut(ctx, "classes-errorprone.list")
-			RunErrorProne(ctx, errorprone, srcFiles, srcFileLists, flags)
+			RunErrorProne(ctx, errorprone, srcFiles, srcJars, flags)
 			extraJarDeps = append(extraJarDeps, errorprone)
 		}
 
 		// Compile java sources into .class files
 		classes := android.PathForModuleOut(ctx, "classes-compiled.jar")
-		TransformJavaToClasses(ctx, classes, srcFiles, srcFileLists, flags, extraJarDeps)
+		TransformJavaToClasses(ctx, classes, srcFiles, srcJars, flags, extraJarDeps)
 		if ctx.Failed() {
 			return
 		}