Skip to content

Commit 79f5a08

Browse files
tomballcopybara-github
authored andcommitted
Updated nullability annotations in jre_emul's native headers.
PiperOrigin-RevId: 733856216
1 parent 5b7212e commit 79f5a08

17 files changed

+61
-40
lines changed

jre_emul/Classes/FastPointerLookup.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
#ifndef FastPointerLookup_H_
1414
#define FastPointerLookup_H_
1515

16+
#import <Foundation/Foundation.h>
1617
#import <pthread.h>
1718
#import <stdbool.h>
1819

20+
NS_ASSUME_NONNULL_BEGIN
21+
1922
struct FastPointerLookupStore;
2023

2124
typedef struct FastPointerLookup_t {
@@ -44,4 +47,5 @@ void *FastPointerLookup(FastPointerLookup_t *lookup, void *key);
4447
// new mapping was added, false if the key is already mapped.
4548
bool FastPointerLookupAddMapping(FastPointerLookup_t *lookup, void *key, void *value);
4649

50+
NS_ASSUME_NONNULL_END
4751
#endif // FastPointerLookup_H_

jre_emul/Classes/IOSArray.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* An abstract class that represents a Java array. Like a Java array,
3030
* an IOSArray is fixed-size but its elements are mutable.
3131
*/
32+
NS_ASSUME_NONNULL_BEGIN
3233
@interface IOSArray<__covariant ObjectType> : NSMutableArray<ObjectType> {
3334
@public
3435
/**
@@ -59,6 +60,7 @@
5960
- (void *)buffer;
6061

6162
@end
63+
NS_ASSUME_NONNULL_END
6264

6365
CF_EXTERN_C_BEGIN
6466
void IOSArray_throwOutOfBoundsWithMsg(jint size, jint index);

jre_emul/Classes/IOSArrayClass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
@interface IOSArrayClass : IOSClass {
2828
// An IOSClass is used instead of a Class so a IOSPrimitiveClass can be used.
29-
IOSClass *componentType_;
29+
IOSClass *_Nonnull componentType_;
3030
}
3131

32-
- (instancetype)initWithComponentType:(IOSClass *)type;
32+
- (instancetype)initWithComponentType:(nonnull IOSClass *)type;
3333

3434
@end
3535

jre_emul/Classes/IOSClass.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* instances: those representing real classes and interfaces, those
4646
* representing primitive types, and those representing array classes.
4747
*/
48+
NS_ASSUME_NONNULL_BEGIN
4849
@interface IOSClass : NSObject <JavaLangReflectAnnotatedElement,
4950
JavaLangReflectGenericDeclaration, JavaIoSerializable,
5051
JavaLangReflectType, NSCopying> {
@@ -99,17 +100,17 @@
99100

100101
// Class.getMethod(String, Class...)
101102
- (JavaLangReflectMethod *)getMethod:(NSString *)name
102-
parameterTypes:(IOSObjectArray *)types;
103+
parameterTypes:(nullable IOSObjectArray *)types;
103104

104105
// Class.getDeclaredMethod(String, Class...)
105106
- (JavaLangReflectMethod *)getDeclaredMethod:(NSString *)name
106-
parameterTypes:(IOSObjectArray *)types;
107+
parameterTypes:(nullable IOSObjectArray *)types;
107108

108109
// Class.getDeclaredConstructor(Class...)
109-
- (JavaLangReflectConstructor *)getDeclaredConstructor:(IOSObjectArray *)types;
110+
- (JavaLangReflectConstructor *)getDeclaredConstructor:(nullable IOSObjectArray *)types;
110111

111112
// Class.getConstructor(Class)
112-
- (JavaLangReflectConstructor *)getConstructor:(IOSObjectArray *)types;
113+
- (JavaLangReflectConstructor *)getConstructor:(nullable IOSObjectArray *)types;
113114

114115
// Class.getConstructors()
115116
- (IOSObjectArray *)getConstructors;
@@ -130,10 +131,10 @@
130131
+ (IOSClass *)forName:(NSString *)className;
131132
+ (IOSClass *)forName:(NSString *)className
132133
initialize:(jboolean)load
133-
classLoader:(JavaLangClassLoader *)loader;
134+
classLoader:(nullable JavaLangClassLoader *)loader;
134135

135136
// Class.cast(Object)
136-
- (id)cast:(id)throwable;
137+
- (id)cast:(nullable id)throwable;
137138

138139
// Class.getEnclosingClass()
139140
- (IOSClass *)getEnclosingClass;
@@ -154,9 +155,8 @@
154155
- (IOSObjectArray *)getGenericInterfaces;
155156
- (IOSObjectArray *)getTypeParameters;
156157

157-
- (id<JavaLangAnnotationAnnotation>)
158-
getAnnotationWithIOSClass:(IOSClass *)annotationClass;
159-
- (jboolean)isAnnotationPresentWithIOSClass:(IOSClass *)annotationType;
158+
- (id<JavaLangAnnotationAnnotation>)getAnnotationWithIOSClass:(nullable IOSClass *)annotationClass;
159+
- (jboolean)isAnnotationPresentWithIOSClass:(nullable IOSClass *)annotationType;
160160
- (IOSObjectArray *)getAnnotations;
161161
- (IOSObjectArray *)getDeclaredAnnotations;
162162
- (id<JavaLangAnnotationAnnotation>)
@@ -219,7 +219,7 @@ CF_EXTERN_C_BEGIN
219219
IOSClass *IOSClass_forName_(NSString *className);
220220
// Class.forName(String, boolean, ClassLoader)
221221
IOSClass *IOSClass_forName_initialize_classLoader_(
222-
NSString *className, jboolean load, JavaLangClassLoader *loader);
222+
NSString *className, jboolean load, JavaLangClassLoader * _Nullable loader);
223223

224224
// Lookup a IOSClass from its associated ObjC class, protocol or component type.
225225
IOSClass *IOSClass_fromClass(Class cls);
@@ -252,4 +252,6 @@ J2OBJC_STATIC_INIT(IOSClass)
252252

253253
J2OBJC_TYPE_LITERAL_HEADER(IOSClass)
254254

255+
NS_ASSUME_NONNULL_END
256+
255257
#endif // _IOSClass_H_

jre_emul/Classes/IOSConcreteClass.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
#import "IOSMetadata.h"
2525

2626
@interface IOSConcreteClass : IOSClass {
27-
Class class_;
27+
Class _Nonnull class_;
2828
}
2929

30-
- (instancetype)initWithClass:(Class)cls
31-
metadata:(const J2ObjcClassInfo *)metadata;
32-
- (instancetype)initWithClass:(Class)cls;
30+
- (instancetype)initWithClass:(Class _Nonnull)cls
31+
metadata:(const J2ObjcClassInfo * _Nonnull)metadata;
32+
- (instancetype)initWithClass:(Class _Nonnull)cls;
3333

3434
@end
3535

jre_emul/Classes/IOSPrimitiveArray.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
// ********** IOSBooleanArray **********
4949

50+
NS_ASSUME_NONNULL_BEGIN
51+
5052
/**
5153
* An Objective-C representation of a Java boolean array. Like a Java array,
5254
* an IOSBooleanArray is fixed-size but its elements are mutable.
@@ -292,7 +294,7 @@ __attribute__((always_inline)) inline jchar *IOSCharArray_GetRef(
292294
- (void)getBytes:(jbyte *)buffer length:(NSUInteger)length;
293295

294296
// Create an array from an NSData object.
295-
+ (instancetype)arrayWithNSData:(NSData *)data;
297+
+ (instancetype)arrayWithNSData:(nullable NSData *)data;
296298

297299
// Copies the array contents into a specified buffer, up to the specified
298300
// length. An IndexOutOfBoundsException is thrown if the specified length
@@ -774,9 +776,8 @@ __attribute__((always_inline)) inline jdouble *IOSDoubleArray_GetRef(
774776
return &array->buffer_[index];
775777
}
776778

779+
NS_ASSUME_NONNULL_END
777780

778-
#undef PRIMITIVE_ARRAY_INTERFACE
779-
#undef PRIMITIVE_ARRAY_C_INTERFACE
781+
#pragma clang diagnostic pop // ignored "-Wzero-length-array"
780782

781-
#pragma clang diagnostic pop
782783
#endif // IOSPrimitiveArray_H

jre_emul/Classes/IOSPrimitiveClass.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
// be used with Java reflection routines. This class is minimal because Java
2929
// primitive types have/need little runtime support, other than their name.
3030
@interface IOSPrimitiveClass : IOSClass {
31-
NSString *name_;
32-
NSString *type_;
31+
NSString * _Nonnull name_;
32+
NSString * _Nonnull type_;
3333
}
3434

35-
- (instancetype)initWithName:(NSString *)name type:(NSString *)type;
35+
- (instancetype)initWithName:(NSString * _Nonnull)name type:(NSString * _Nonnull)type;
3636

3737
// For a primitive type, return its associated wrapper class.
38-
- (IOSClass *)wrapperClass;
38+
- (IOSClass * _Nonnull)wrapperClass;
3939

4040
@end
4141

jre_emul/Classes/IOSProtocolClass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
@interface IOSProtocolClass : IOSClass
2626

27-
- (instancetype)initWithProtocol:(Protocol *)protocol;
27+
- (instancetype)initWithProtocol:(Protocol * _Nonnull)protocol;
2828

2929
@end
3030

jre_emul/Classes/J2ObjC_common.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ J2OBJC_VOLATILE_ACCESS_DEFN(Double, jdouble)
260260
* @define J2OBJC_TYPE_LITERAL_HEADER
261261
* @param TYPE The name of the type to declare the accessor for.
262262
*/
263-
#define J2OBJC_TYPE_LITERAL_HEADER(TYPE) \
264-
FOUNDATION_EXPORT IOSClass *TYPE##_class_(void);
263+
#define J2OBJC_TYPE_LITERAL_HEADER(TYPE) FOUNDATION_EXPORT IOSClass *_Nonnull TYPE##_class_(void);
265264

266265
/*!
267266
* Defines the type literal accessor for a class or enum type. This macro should
@@ -271,8 +270,8 @@ J2OBJC_VOLATILE_ACCESS_DEFN(Double, jdouble)
271270
* @param TYPE The name of the type to define the accessor for.
272271
*/
273272
#define J2OBJC_CLASS_TYPE_LITERAL_SOURCE(TYPE) \
274-
IOSClass *TYPE##_class_(void) { \
275-
static IOSClass *cls; \
273+
IOSClass * _Nonnull TYPE##_class_(void) { \
274+
static IOSClass * _Nonnull cls; \
276275
static dispatch_once_t token; \
277276
TYPE##_initialize(); \
278277
dispatch_once(&token, ^{ \
@@ -289,7 +288,7 @@ J2OBJC_VOLATILE_ACCESS_DEFN(Double, jdouble)
289288
* @param TYPE The name of the type to define the accessor for.
290289
*/
291290
#define J2OBJC_INTERFACE_TYPE_LITERAL_SOURCE(TYPE) \
292-
IOSClass *TYPE##_class_(void) { \
291+
IOSClass * _Nonnull TYPE##_class_(void) { \
293292
static IOSClass *cls; \
294293
static dispatch_once_t token; \
295294
TYPE##_initialize(); \

jre_emul/Classes/JavaObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
@protocol JavaObject <NSObject>
3131

3232
// Returns a copy of the object, if it implements java.lang.Cloneable.
33-
- (id)java_clone;
33+
- (id _Nonnull)java_clone;
3434

3535
// Returns the IOSClass of the receiver.
36-
- (IOSClass *)java_getClass;
36+
- (IOSClass * _Nonnull)java_getClass;
3737

3838
// Wakes up a waiting thread (if any).
3939
- (void)java_notify;

0 commit comments

Comments
 (0)