From 521e889058e460e274386e771c6e0fdb8d0c26d9 Mon Sep 17 00:00:00 2001 From: Wei Jun Kong Date: Wed, 20 May 2026 09:05:03 -0700 Subject: [PATCH] BEGIN_PUBLIC Support Header KLibs via New Annotation with CLASS Retention END_PUBLIC Migrate the J2ObjC compatibility plugin to use a new annotation @ObjectiveCTypeName with CLASS retention for types. This ensures that the annotations are preserved in the metadata of Header KLibs, fixing issues where downstream targets fail to resolve short Objective-C names. PiperOrigin-RevId: 918482191 --- .../annotations/ObjectiveCTypeName.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 annotations/src/main/java/com/google/j2objc/annotations/ObjectiveCTypeName.java diff --git a/annotations/src/main/java/com/google/j2objc/annotations/ObjectiveCTypeName.java b/annotations/src/main/java/com/google/j2objc/annotations/ObjectiveCTypeName.java new file mode 100644 index 0000000000..a9b1a1b813 --- /dev/null +++ b/annotations/src/main/java/com/google/j2objc/annotations/ObjectiveCTypeName.java @@ -0,0 +1,21 @@ +package com.google.j2objc.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** Annotation that specifies what the Objective-C class or protocol should be when translated. */ +@Documented +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.CLASS) +public @interface ObjectiveCTypeName { + + /** + * The Objective-C name to use for this type. + * + * @return the Objective-C name. + */ + String value(); +}