File: 12-add-j2objc-annotations.patch

package info (click to toggle)
guava-libraries 31.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 40,360 kB
  • sloc: java: 367,214; xml: 2,492; sh: 34; makefile: 9; javascript: 9
file content (246 lines) | stat: -rw-r--r-- 9,183 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
Description: Add the j2objc annotations (not yet packaged in Debian)
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: not-needed
--- /dev/null
+++ b/guava/src/com/google/j2objc/annotations/J2ObjCIncompatible.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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;
+
+/**
+ * Marks a declaration to be stripped by the J2ObjC translator prior to
+ * compilation. It is the developer's responsibility to ensure that any code
+ * depending on an element marked with {@literal @}J2ObjCIncompatible is also
+ * marked with {@literal @}J2ObjCIncompatible.
+ *
+ * @author Keith Stanger
+ */
+@Documented
+@Target({
+    ElementType.ANNOTATION_TYPE,
+    ElementType.CONSTRUCTOR,
+    ElementType.FIELD,
+    ElementType.METHOD,
+    ElementType.TYPE
+})
+@Retention(RetentionPolicy.SOURCE)
+public @interface J2ObjCIncompatible {}
--- /dev/null
+++ b/guava/src/com/google/j2objc/annotations/ReflectionSupport.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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 the level of reflection support for a particular
+ * class.
+ *
+ * @author Keith Stanger
+ */
+@Documented
+@Target({ ElementType.TYPE, ElementType.PACKAGE })
+@Retention(RetentionPolicy.SOURCE)
+public @interface ReflectionSupport {
+
+  /**
+   * Enumerates the available levels of reflection support.
+   */
+  enum Level {
+    /*
+     * No metadata is emitted, so reflection support is limited to the
+     * information that can be obtained from the Objective-C runtime.
+     */
+    NATIVE_ONLY,
+    /*
+     * Additional metadata is emitted, allowing for full reflection support.
+     */
+    FULL
+  }
+
+  Level value();
+}
--- /dev/null
+++ b/guava/src/com/google/j2objc/annotations/RetainedWith.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.j2objc.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * PLEASE READ THIS DOCUMENTATION BEFORE USING THIS ANNOTATION!
+ *
+ * <p>Note the criteria listed below which cannot be enforced by static analysis
+ * in j2objc. Prefer using {@link Weak} over @RetainedWith if possible.
+ *
+ * <p>Indicates that the annotated field (child) forms a direct reference cycle
+ * with the referring object (parent). Adding this annotation informs J2ObjC of
+ * the reference cycle between the pair of objects allowing both objects to be
+ * deallocated once there are no external references to either object.
+ *
+ * <p>{@literal @}RetainedWith can be applied when a parent object pairs itself
+ * with a child object and cannot fully manage the child's lifecycle, usually
+ * because the child is returned to the caller. It can also be applied when the
+ * child has the same class as the parent, for example on an inverse field of an
+ * invertible collection type.
+ *
+ * <p>{@literal @}RetainedWith can only be applied where there is a two-object
+ * pair with a cycle created by one reference from each object. Note: the two
+ * references can be from the same declared field. When the references are from
+ * different fields only one field should be given a @RetainedWith annotation,
+ * and the {@literal @}RetainedWith field should point from parent to child.
+ *
+ * <p>When applied carefully in the right circumstance this annotation is very
+ * useful in preventing leaks from certain Java collection types without needing
+ * to alter their behavior.
+ *
+ * <p>The following criteria must be adhered to otherwise behavior will be
+ * undefined:
+ * <ul>
+ * <li> The child object must not reassign any references back to the parent
+ *   object. Preferably references from child to parent are declared final.
+ * <li> The child object must not contain any {@link Weak} references back to the
+ *   parent object.
+ * <li> The child object must not be available to other threads at the time of
+ *   assignment. (Normally, the cycle is created upon construction of the child)
+ * </ul>
+ *
+ * @author Keith Stanger
+ */
+@Target({ ElementType.FIELD })
+@Retention(RetentionPolicy.SOURCE)
+public @interface RetainedWith {
+}
--- /dev/null
+++ b/guava/src/com/google/j2objc/annotations/Weak.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.j2objc.annotations;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+
+/**
+ * Annotation that indicates a variable has a weak relationship to its owner. The variable will be
+ * declared with the __unsafe_unretained annotation.
+ *
+ * @author Tom Ball
+ */
+@Target({FIELD, LOCAL_VARIABLE, PARAMETER})
+@Retention(SOURCE)
+public @interface Weak {
+}
--- /dev/null
+++ b/guava/src/com/google/j2objc/annotations/WeakOuter.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.j2objc.annotations;
+
+import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.TYPE_USE;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that indicates an inner class has a weak relationship to its owning class.
+ *
+ * <p>Lambdas can be given a weak outer reference by declaring a local variable with this annotation
+ * and assigning the lambda expression directly to the local variable. WeakOuter is only allowed on
+ * local variables, not fields, to encourage the annotation to be used where the lambda is declared.
+ *
+ * @author Tom Ball
+ */
+@Target({TYPE, TYPE_USE, LOCAL_VARIABLE})
+@Retention(SOURCE)
+public @interface WeakOuter {}