Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jre_emul/Classes/FastPointerLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
#ifndef FastPointerLookup_H_
#define FastPointerLookup_H_

#import <Foundation/Foundation.h>
#import <pthread.h>
#import <stdbool.h>

NS_ASSUME_NONNULL_BEGIN

struct FastPointerLookupStore;

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

NS_ASSUME_NONNULL_END
#endif // FastPointerLookup_H_
2 changes: 2 additions & 0 deletions jre_emul/Classes/IOSArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* An abstract class that represents a Java array. Like a Java array,
* an IOSArray is fixed-size but its elements are mutable.
*/
NS_ASSUME_NONNULL_BEGIN
@interface IOSArray<__covariant ObjectType> : NSMutableArray<ObjectType> {
@public
/**
Expand Down Expand Up @@ -59,6 +60,7 @@
- (void *)buffer;

@end
NS_ASSUME_NONNULL_END

CF_EXTERN_C_BEGIN
void IOSArray_throwOutOfBoundsWithMsg(jint size, jint index);
Expand Down
4 changes: 2 additions & 2 deletions jre_emul/Classes/IOSArrayClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

@interface IOSArrayClass : IOSClass {
// An IOSClass is used instead of a Class so a IOSPrimitiveClass can be used.
IOSClass *componentType_;
IOSClass *_Nonnull componentType_;
}

- (instancetype)initWithComponentType:(IOSClass *)type;
- (instancetype)initWithComponentType:(nonnull IOSClass *)type;

@end

Expand Down
22 changes: 12 additions & 10 deletions jre_emul/Classes/IOSClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* instances: those representing real classes and interfaces, those
* representing primitive types, and those representing array classes.
*/
NS_ASSUME_NONNULL_BEGIN
@interface IOSClass : NSObject <JavaLangReflectAnnotatedElement,
JavaLangReflectGenericDeclaration, JavaIoSerializable,
JavaLangReflectType, NSCopying> {
Expand Down Expand Up @@ -99,17 +100,17 @@

// Class.getMethod(String, Class...)
- (JavaLangReflectMethod *)getMethod:(NSString *)name
parameterTypes:(IOSObjectArray *)types;
parameterTypes:(nullable IOSObjectArray *)types;

// Class.getDeclaredMethod(String, Class...)
- (JavaLangReflectMethod *)getDeclaredMethod:(NSString *)name
parameterTypes:(IOSObjectArray *)types;
parameterTypes:(nullable IOSObjectArray *)types;

// Class.getDeclaredConstructor(Class...)
- (JavaLangReflectConstructor *)getDeclaredConstructor:(IOSObjectArray *)types;
- (JavaLangReflectConstructor *)getDeclaredConstructor:(nullable IOSObjectArray *)types;

// Class.getConstructor(Class)
- (JavaLangReflectConstructor *)getConstructor:(IOSObjectArray *)types;
- (JavaLangReflectConstructor *)getConstructor:(nullable IOSObjectArray *)types;

// Class.getConstructors()
- (IOSObjectArray *)getConstructors;
Expand All @@ -130,10 +131,10 @@
+ (IOSClass *)forName:(NSString *)className;
+ (IOSClass *)forName:(NSString *)className
initialize:(jboolean)load
classLoader:(JavaLangClassLoader *)loader;
classLoader:(nullable JavaLangClassLoader *)loader;

// Class.cast(Object)
- (id)cast:(id)throwable;
- (id)cast:(nullable id)throwable;

// Class.getEnclosingClass()
- (IOSClass *)getEnclosingClass;
Expand All @@ -154,9 +155,8 @@
- (IOSObjectArray *)getGenericInterfaces;
- (IOSObjectArray *)getTypeParameters;

- (id<JavaLangAnnotationAnnotation>)
getAnnotationWithIOSClass:(IOSClass *)annotationClass;
- (jboolean)isAnnotationPresentWithIOSClass:(IOSClass *)annotationType;
- (id<JavaLangAnnotationAnnotation>)getAnnotationWithIOSClass:(nullable IOSClass *)annotationClass;
- (jboolean)isAnnotationPresentWithIOSClass:(nullable IOSClass *)annotationType;
- (IOSObjectArray *)getAnnotations;
- (IOSObjectArray *)getDeclaredAnnotations;
- (id<JavaLangAnnotationAnnotation>)
Expand Down Expand Up @@ -219,7 +219,7 @@ CF_EXTERN_C_BEGIN
IOSClass *IOSClass_forName_(NSString *className);
// Class.forName(String, boolean, ClassLoader)
IOSClass *IOSClass_forName_initialize_classLoader_(
NSString *className, jboolean load, JavaLangClassLoader *loader);
NSString *className, jboolean load, JavaLangClassLoader * _Nullable loader);

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

J2OBJC_TYPE_LITERAL_HEADER(IOSClass)

NS_ASSUME_NONNULL_END

#endif // _IOSClass_H_
8 changes: 4 additions & 4 deletions jre_emul/Classes/IOSConcreteClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
#import "IOSMetadata.h"

@interface IOSConcreteClass : IOSClass {
Class class_;
Class _Nonnull class_;
}

- (instancetype)initWithClass:(Class)cls
metadata:(const J2ObjcClassInfo *)metadata;
- (instancetype)initWithClass:(Class)cls;
- (instancetype)initWithClass:(Class _Nonnull)cls
metadata:(const J2ObjcClassInfo * _Nonnull)metadata;
- (instancetype)initWithClass:(Class _Nonnull)cls;

@end

Expand Down
9 changes: 5 additions & 4 deletions jre_emul/Classes/IOSPrimitiveArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

// ********** IOSBooleanArray **********

NS_ASSUME_NONNULL_BEGIN

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

// Create an array from an NSData object.
+ (instancetype)arrayWithNSData:(NSData *)data;
+ (instancetype)arrayWithNSData:(nullable NSData *)data;

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

NS_ASSUME_NONNULL_END

#undef PRIMITIVE_ARRAY_INTERFACE
#undef PRIMITIVE_ARRAY_C_INTERFACE
#pragma clang diagnostic pop // ignored "-Wzero-length-array"

#pragma clang diagnostic pop
#endif // IOSPrimitiveArray_H
8 changes: 4 additions & 4 deletions jre_emul/Classes/IOSPrimitiveClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
// be used with Java reflection routines. This class is minimal because Java
// primitive types have/need little runtime support, other than their name.
@interface IOSPrimitiveClass : IOSClass {
NSString *name_;
NSString *type_;
NSString * _Nonnull name_;
NSString * _Nonnull type_;
}

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

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

@end

Expand Down
2 changes: 1 addition & 1 deletion jre_emul/Classes/IOSProtocolClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@interface IOSProtocolClass : IOSClass

- (instancetype)initWithProtocol:(Protocol *)protocol;
- (instancetype)initWithProtocol:(Protocol * _Nonnull)protocol;

@end

Expand Down
5 changes: 5 additions & 0 deletions jre_emul/Classes/J2ObjC_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#ifndef _J2OBJC_HEADER_H_
#define _J2OBJC_HEADER_H_

#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wnullability-completeness"

#import "IOSObjectArray.h"
#import "J2ObjC_common.h"
#import "JavaObject.h"
Expand Down Expand Up @@ -340,4 +343,6 @@ CF_EXTERN_C_END
// can measure how much of the app's size is due to transpiled Java code.
#define J2OBJC_TEXT_SEGMENT __attribute__((section("__TEXT,__j2objc_text")))

#pragma clang diagnostic pop

#endif // _J2OBJC_HEADER_H_
4 changes: 2 additions & 2 deletions jre_emul/Classes/JavaObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
@protocol JavaObject <NSObject>

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

// Returns the IOSClass of the receiver.
- (IOSClass *)java_getClass;
- (IOSClass * _Nonnull)java_getClass;

// Wakes up a waiting thread (if any).
- (void)java_notify;
Expand Down
5 changes: 5 additions & 0 deletions jre_emul/Classes/JreEmulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#define _JreEmulation_H_

#ifdef __OBJC__
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wnullability-completeness"

#import "J2ObjC_common.h"
#import "JavaObject.h"
#import "IOSClass.h"
Expand All @@ -28,6 +31,8 @@
#import "NSNumber+JavaNumber.h"
#import "NSObject+JavaObject.h"
#import "NSString+JavaString.h"

#pragma clang diagnostic pop
#endif // __OBJC__

#endif // _JreEmulation_H_
2 changes: 2 additions & 0 deletions jre_emul/Classes/NSDataInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
// a given NSData instance. The NSData instance is copied at
// initialization, so further modifications (if it happened to
// be mutable) will not be visible.
NS_ASSUME_NONNULL_BEGIN
@interface NSDataInputStream : JavaIoInputStream

- (instancetype)initWithData:(NSData *)data;
+ (NSDataInputStream *)streamWithData:(NSData *)data;

@end
NS_ASSUME_NONNULL_END

#endif // _NSDataInputStream_H_
2 changes: 2 additions & 0 deletions jre_emul/Classes/NSDataOutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

// A concrete subclass of java.io.InputStream that writes into
// a backing NSData instance, retrievable at any point.
NS_ASSUME_NONNULL_BEGIN
@interface NSDataOutputStream : JavaIoOutputStream

+ (NSDataOutputStream *)stream;
Expand All @@ -23,5 +24,6 @@
- (NSData *)data;

@end
NS_ASSUME_NONNULL_END

#endif // _NSDataOutputStream_H_
2 changes: 2 additions & 0 deletions jre_emul/Classes/NSDictionaryMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// The entrySet, keySet and valueSet methods return sets not backed
// by the Map, so modifications to the map won't be reflected in the
// sets and vice-versa.
NS_ASSUME_NONNULL_BEGIN
@interface NSDictionaryMap : JavaUtilAbstractMap < JavaUtilMap > {
@private
// The backing native map.
Expand All @@ -36,5 +37,6 @@
- (void)forEachWithJavaUtilFunctionBiConsumer:(id<JavaUtilFunctionBiConsumer>)action;

@end
NS_ASSUME_NONNULL_END

#endif // _NSDictionaryMap_H_
2 changes: 1 addition & 1 deletion jre_emul/Classes/NSNumber+JavaNumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

@end

__attribute__((always_inline)) inline void NSNumber_init(NSObject *self) {
__attribute__((always_inline)) inline void NSNumber_init(NSObject * _Nonnull self) {
#pragma unused(self)
}

Expand Down
11 changes: 7 additions & 4 deletions jre_emul/Classes/NSObject+JavaObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
@class IOSClass;

// A category that adds Java Object-compatible methods to NSObject.
NS_ASSUME_NONNULL_BEGIN
@interface NSObject (JavaObject) <JavaObject>

// JavaObject doesn't implement Comparable, but the Comparable contract wants
Expand All @@ -50,14 +51,16 @@
- (void)_java_lang_ref_original_release;

@end
NS_ASSUME_NONNULL_END

__attribute__((always_inline)) inline void NSObject_init(NSObject *self) {
#pragma unused(self)
__attribute__((always_inline)) inline void NSObject_init(NSObject* _Nonnull self) {
#pragma unused(self)
}
__attribute__((always_inline)) NS_RETURNS_RETAINED inline NSObject *new_NSObject_init(void) {
__attribute__((always_inline)) NS_RETURNS_RETAINED inline NSObject* _Nonnull new_NSObject_init(
void) {
return [NSObject alloc];
}
__attribute__((always_inline)) inline NSObject *create_NSObject_init(void) {
__attribute__((always_inline)) inline NSObject* _Nonnull create_NSObject_init(void) {
return AUTORELEASE([NSObject alloc]);
}

Expand Down
7 changes: 4 additions & 3 deletions jre_emul/Classes/NSString+JavaString.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#if __has_feature(nullability)
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wnullability"
#pragma GCC diagnostic ignored "-Wnullability-completeness"
#endif

Expand All @@ -43,10 +42,11 @@
// A category that adds java.lang.String-like methods to NSString. The method
// list is not exhaustive, since methods that can be directly substituted are
// inlined.
NS_ASSUME_NONNULL_BEGIN
@interface NSString (JavaString) <JavaIoSerializable, JavaLangComparable, JavaLangCharSequence>

// String.valueOf(Object)
+ (nonnull NSString *)java_valueOf:(id<NSObject>)obj;
+ (nonnull NSString *)java_valueOf:(nullable id<NSObject>)obj;

// String.valueOf(boolean)
+ (nonnull NSString *)java_valueOfBool:(jboolean)value;
Expand Down Expand Up @@ -222,7 +222,7 @@
// String.format(String, ...), String.format(Locale, String, ...)
+ (nonnull NSString *)java_formatWithNSString:(NSString *)format
withNSObjectArray:(IOSObjectArray *)args;
+ (nonnull NSString *)java_formatWithJavaUtilLocale:(JavaUtilLocale *)locale
+ (nonnull NSString *)java_formatWithJavaUtilLocale:(nullable JavaUtilLocale *)locale
withNSString:(NSString *)format
withNSObjectArray:(IOSObjectArray *)args;

Expand Down Expand Up @@ -305,6 +305,7 @@
- (jboolean)java_isBlank;

@end
NS_ASSUME_NONNULL_END

// String.format(Locale, String, Object...)
FOUNDATION_EXPORT NSString *NSString_java_formatWithJavaUtilLocale_withNSString_withNSObjectArray_(
Expand Down
3 changes: 3 additions & 0 deletions jre_emul/Classes/java/lang/AbstractStringBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ typedef struct JreStringBuilder {
jint count_;
} JreStringBuilder;

NS_ASSUME_NONNULL_BEGIN
@interface JavaLangAbstractStringBuilder : NSObject < JavaLangAppendable, JavaLangCharSequence > {
@package
JreStringBuilder delegate_;
Expand Down Expand Up @@ -141,4 +142,6 @@ NSString *JreStringBuilder_toStringAndDealloc(JreStringBuilder *sb);

CF_EXTERN_C_END

NS_ASSUME_NONNULL_END

#endif // _JavaLangAbstractStringBuilder_H_