Add j.a.p.Generated to ART's Public API surface

Certain code generation tools like Dagger emit this annotation. Add this
to Public API surface to enable apps to use these annotation processors.

Another option was to add this to the new "Toolchain" API surface
instead. e.g. LambdaMetaFactory (LMF) was added to Toolchain API surface
and not Public API in aosp/2369873. One difference is that unlike LMF,
j.a.p.Generated is part of JLS and is backed by an implementation.

Bug: 261244752
Bug: 283243108
Test: TH

Change-Id: I29122adc5ee9d7cafd5403ac5421a7b0d9737dd1
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 91e72d0..749ba59 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -185,7 +185,6 @@
         // framework-api-annotations contain API annotations, e.g. @SystemApi.
         ":framework-api-annotations",
         ":openjdk_lambda_stub_files",
-        ":openjdk_generated_annotation_stub_files",
         ":app-compat-annotations-source",
 
         // Use the okhttp source too to allow libcore code to reference it
@@ -440,10 +439,11 @@
     include_srcs: true,
 }
 
-// Creates a jar that exists to satisfy javac when compiling source code that
-// contains @Generated annotations, which are produced by some code generation
-// tools (notably dagger) but aren't part of the Android API.
-// See http://b/123891440.
+// This is an empty jar that exists for backwards compatibility with T (and below).
+// Historically, it existed to satisfy javac when compiling source code that
+// contains @Generated annotations.
+// This is no longer necessary since @Generated was added to ART's Public API
+// surface in U.
 java_library {
     name: "core-generated-annotation-stubs",
     visibility: [
@@ -452,7 +452,6 @@
     ],
     defaults: ["libcore_java_defaults"],
     srcs: [
-        ":openjdk_generated_annotation_stub_files",
     ],
     hostdex: true,
     sdk_version: "none",
@@ -935,7 +934,6 @@
         // in openjdk_java_files.bp for more details.
         ":openjdk_mmodule_extra_files",
         ":okhttp_api_files",
-
     ],
     libs: [
         // Put framework-api-annotations into libs to avoid exposing the definition of framework's
@@ -1015,11 +1013,6 @@
         // This one is not on device but it's needed when javac compiles code
         // containing lambdas.
         "core-lambda-stubs-for-system-modules",
-        // This one is not on device but it's needed when javac compiles code
-        // containing @Generated annotations produced by some code generation
-        // tools.
-        // See http://b/123891440.
-        "core-generated-annotation-stubs",
 
         // Ensure that core libraries that depend on the public API can access
         // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
diff --git a/api/current.txt b/api/current.txt
index fb751ea..20f1448 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -17782,6 +17782,16 @@
 
 }
 
+package javax.annotation.processing {
+
+  @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @java.lang.annotation.Target({java.lang.annotation.ElementType.PACKAGE, java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.CONSTRUCTOR, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.LOCAL_VARIABLE, java.lang.annotation.ElementType.PARAMETER}) public @interface Generated {
+    method public abstract String comments() default "";
+    method public abstract String date() default "";
+    method public abstract String[] value();
+  }
+
+}
+
 package javax.crypto {
 
   public class AEADBadTagException extends javax.crypto.BadPaddingException {
diff --git a/mmodules/intracoreapi/Android.bp b/mmodules/intracoreapi/Android.bp
index 34c6f1c..f2ebef2 100644
--- a/mmodules/intracoreapi/Android.bp
+++ b/mmodules/intracoreapi/Android.bp
@@ -96,7 +96,6 @@
     name: "art-module-intra-core-api-stubs-system-modules-lib",
     srcs: [
         ":openjdk_lambda_stub_files",
-        ":openjdk_generated_annotation_stub_files",
     ],
     libs: [
         "art.module.intra.core.api",
diff --git a/ojluni/src/generated-annotation/java/javax/annotation/processing/Generated.java b/ojluni/src/main/java/javax/annotation/processing/Generated.java
similarity index 100%
rename from ojluni/src/generated-annotation/java/javax/annotation/processing/Generated.java
rename to ojluni/src/main/java/javax/annotation/processing/Generated.java
diff --git a/openjdk_java_files.bp b/openjdk_java_files.bp
index 3f1005e..73d01b0 100644
--- a/openjdk_java_files.bp
+++ b/openjdk_java_files.bp
@@ -1235,6 +1235,7 @@
         "ojluni/src/main/java/java/util/zip/ZipOutputStream.java",
         "ojluni/src/main/java/java/util/zip/ZipUtils.java",
         "ojluni/src/main/java/java/util/zip/ZStreamRef.java",
+        "ojluni/src/main/java/javax/annotation/processing/Generated.java",
         "ojluni/src/main/java/javax/crypto/AEADBadTagException.java",
         "ojluni/src/main/java/javax/crypto/BadPaddingException.java",
         "ojluni/src/main/java/javax/crypto/CipherInputStream.java",
@@ -1404,21 +1405,6 @@
     ],
 }
 
-// Stubs needed to satisfy javac when compiling source code that contains
-// @Generated annotations, which are produced by some code generation tools.
-// TODO: Remove this source file, this target, and all its dependencies, if
-// the code generation tools (notably dagger) can be fixed.
-// See http://b/123891440.
-filegroup {
-    name: "openjdk_generated_annotation_stub_files",
-    visibility: [
-        "//libcore:__subpackages__",
-    ],
-    srcs: [
-        "ojluni/src/generated-annotation/java/javax/annotation/processing/Generated.java",
-    ],
-}
-
 // Classes which are exposed in the intra-core or core-platform APIs but not in
 // the public APIs. Unless they are annotated, these classes and all their
 // members will be exposed in all such APIs. To avoid patching the main ojluni
@@ -1863,7 +1849,6 @@
         ":openjdk_mmodule_extra_files",
         ":openjdk_internal_files",
         ":openjdk_lambda_stub_files",
-        ":openjdk_generated_annotation_stub_files",
     ],
 }