J2ObjC 3.1 is an interim release that updates the j2objc-annotations Maven artifact, as well as includes all source changes since 3.0. We'll be releasing more frequently as we start moving the build to use Bazel instead of Make.
What's Changed
Replaces use of mac_absolute_time() with clock_gettime_nsec_np(CLOCK_MONOTONIC) in java.lang.System.nanoTime() implementation. The returned value is no longer relatable to other system times, instead only useful for measuring elapsed time (as the method's javadoc describes). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2307
Add SwiftName to avoid build failures in the public. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2310
Fixes cycle_finder's public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2311
Fixes for Swift Name annotation by @copybara-service[bot] in https://github.com/google/j2objc/pull/2312
Support disabling no-wrapper-method flag for j2objc_library. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2313
Add error prone jar to fix build issue in the public. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2317
Make call to system fstatat() direct to better support tools verifying privacy manifest compliance. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2316
Rename JUnitTestRunner.main to JUnitTestRunner.run. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2320
Adds translator flag to generate j2objc-generated code in separate text (code) segment, so engineers can determine how much native to transpiled code is in their app. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2322
Fixes public builds of j2objc/cycle_finder and j2objc/tree_shaker. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2326
Sets jmod path and fixes duplicate mkdir error in public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2327
Fix //googlemac/iPhone/Applecrisp/Shared/DocosLib/Test:TranspiledTests when strip-reflection is on. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2328
Issue #2323: rewrite super constructor invocations for java.lang.Number subclasses. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2331
Fixes patch file application in public junit build. The issue is that MacOS has CRLF line endings, while Linux and our repo has LF. So MacOS created CRLF endings when diff -ru was run, the repo changed them to LF, and then the patch would fail. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2335
Issue #2330: removed JSON headers from JRE framework. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2336
Add --no-doc-comments option to skip doc-comment translation. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2338
Hides logged stack trace from expected result, as all the stack trace did was make a successful test execution look like a failure. The stack trace is logged from the Java protobuf runtime, which we can't change. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2339
Updates IntelliJ projects to use latest Java library dependencies from j2objc/java_deps. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2343
Supports linking the core jre_emul subset library without the -ObjC flag, by making static references to classes that are dynamically loaded. The static references ensure that the classes continue to be linked into the app. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2342
Automated g4 rollback of changelist 638722935. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2346
Automated g4 rollback of changelist 638827797. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2347
Implement prototype of J2ObjC "adapter" method annotation. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2321
Add few annotations to classes.mk for public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2349
Improve experimental -Xnull-marked: by @copybara-service[bot] in https://github.com/google/j2objc/pull/2348
Fix -Wshorten-64-to-32 error in JreCollectionAdapters.m by @copybara-service[bot] in https://github.com/google/j2objc/pull/2351
Disable adapter method tests temporarily to fix external build break. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2353
Update J2ObjC Protocol Buffer builder method arguments to default to nonnull. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2352
Rollback J2ObjC Protocol Buffer builder method argument nullability changes which caused project build failures. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2355
Migrate usages of org.jspecify.nullness to org.jspecify.annotations. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2356
Update JSpecify to version 0.3.0 in public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2358
Updates IntelliJ projects to jspecify-3.0. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2357
Update J2ObjC Protocol Buffer builder method arguments to default to nonnull. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2359
Adds flag to generate separate header files for inner types. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2344
Add j2objc support to transformer. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2361
Avoid clang -Wdocumentation warning when doc-comment starts with <PRE> tag. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2362
Adds compatibilitytest for ProtocolStringList. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2366
Hook up codegen tests for j2objc. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2364
Enable editions support in j2objc plugin. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2365
Fix open source test failures related to adapter methods prototype. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2369
Fix new errors and warnings in protobuf compiler build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2367
Updates protobuf-java jars to v4.27.2 for public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2370
Add a minimal protoc implementation based on the existing J2ObjC protoc that's used only for generating the class map file, to be used by the eventual J2ObjC proto implementation that will transpile Java proto lite instead of using the custom J2ObjC protoc. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2368
Use more accurate license information for j2objc/protobuf by @copybara-service[bot] in https://github.com/google/j2objc/pull/2373
Add a minimal protoc implementation based on the existing J2ObjC protoc that's used only for generating the class map file, to be used by the eventual J2ObjC proto implementation that will transpile Java proto lite instead of using the custom J2ObjC protoc. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2374
Remove jre_concurrent_dynamic. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2377
Fixes deps in core_plus_channels open-source test. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2380
Update TreeConverter to work with new constants added to Tree.Kind and ElementKind enums between supported JDK versions. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2382
Updates java.util.stream package to latest Android release. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2383
Update public build to JSpecify-1.0.0. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2384
Issue #2332: fix bridging header for HelloSwift example. This demonstrates the correct way to include j2objc-generated headers into a Swift application. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2385
Disable generic method signatures for the Google Protobuf package (type declaration generics were already disabled, but not method signatures). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2386
Don't generate hasser methods for fields without presence by @copybara-service[bot] in https://github.com/google/j2objc/pull/2389
Add test support for Java 17, fixed default in setup(). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2390
Adds RecordDeclaration AST type to translator. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2391
Add --suppress-header-clang-tidy-warnings j2objc translation flag to suppress one clang tidy warnings. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2392
Add C++11-added and C++20-added keywords to reserved_names.txt. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2395
Disable iOS fstatat() reference due to privacy manifest scanning issue. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2397
Adds reflection support for Java records. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2399
Fixed execution running on Java 16 and higher, added test that record equals() methods compare using string or object equals (instead of ==). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2401
Internal change by @copybara-service[bot] in https://github.com/google/j2objc/pull/2404
Ignore method without return value for property annotation. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2406
Add suppressions for existing usages of the Security Manager API, which will be disabled in Java 24. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2407
Updates IntelliJ project to Java 22. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2408
Adds instanceof pattern support (no guards yet). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2409
Remove a reference to the Security Manager API by @copybara-service[bot] in https://github.com/google/j2objc/pull/2411
Adds java.time.InstantSource (Java 17) to j2objc JRE. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2413
Added support for guards in Java 17 instanceof enhancement. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2414
Make code forward-compatible with returning string_view in protobuf descriptor API. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2416
Add Duration.isPositive() to GWT and j2objc emulation. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2417
Adds SwitchExpression, SwitchExpressionCase and YieldStatement AST nodes, to support Java 22 switch expression syntax. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2418
Prepare code for breaking change in Protobuf C++ API. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2419
Converts javac AST nodes related to switch expressions to translator's AST. Adds onJava21OrAbove() test support method. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2421
Add support for switch expression patterns and guards, fixed yield AST conversion. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2422
Supports switch expression null cases, qualified enum names, rules in cases. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2423
Supports switch expressions by AST translators. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2424
Simplified tests that require a minimum Java version. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2425
Remove ContactsJava-j2objc reference due to j2objc legacy rule deprecation. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2426
Generates ObjC for new switch statement syntax; converts return of switch expression into by @copybara-service[bot] in https://github.com/google/j2objc/pull/2428
Get rid of memory leak in j2objc protos. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2430
Remove unused macro definitions from FieldTypes.h. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2429
Get rid of memory leaks in CGPMapField by @copybara-service[bot] in https://github.com/google/j2objc/pull/2431
Clean up a pile of warnings about conversions of int to short and jchar to byte (and I believe technically more correct?) by @copybara-service[bot] in https://github.com/google/j2objc/pull/2434
intX => intX_t, uintX => uintX_t for Objective-C sources, to fix old type name deprecations. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2432
Removes JRE calls to System.getSecurityManager() and code blocks that depend on a non-null being returned, since on j2objc and Android that method always returns null. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2433
Updates floating point cast functions to better reflect JLS 5.3.1. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2436
Update EnumRewriter to use correct nullability when null-marked: by @copybara-service[bot] in https://github.com/google/j2objc/pull/2435
Synced java.util.stream.Collectors to latest Android version, adding new teeing() method. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2438
Annotates IOSObjectArray for nullability. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2439
Fixed generation of switch expression cases with multiple expressions. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2440
Pilot cl for adding property support to j2objc protos (and improving swift/kt interop). To avoid getters being dropped in Swift, uppercase get methods are used (and synthesized in the runtime accordingly). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2441
Generate mutable properties for proto message builders. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2443
Fixed enum constant cases in switch expressions, tested empty switch cases. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2442
Fixed public j2objc protobuf build by replacing a C++20 function call with an equivalent statement. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2445
Move j2objc protobuf field property generation behind an explicit internal proto option. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2447
Add TextFormat stub to j2objc by @copybara-service[bot] in https://github.com/google/j2objc/pull/2444
Generate properties for enum values and a "number" property. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2446
Alias j2objc classes to the k/n proto objective c class name prefix (KNP) if property support is enabled. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2450
Add @NonNull annotation in JSONArray.toString() and don't return null in the same way as it's done in JSONObject.toString(). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2449
Fixes enum const expression in switch statements, conversion of yield AST nodes. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2451
Adds __builtin_unreachable() function call after switch expressions that by @copybara-service[bot] in https://github.com/google/j2objc/pull/2452
Rewrote references to Java 21 API to fix public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2453
For assignments of switch expressions, convert to switch and assign yield by @copybara-service[bot] in https://github.com/google/j2objc/pull/2454
Split local variable declaration initialized with a switch expression in two by @copybara-service[bot] in https://github.com/google/j2objc/pull/2455
Add test for unreachable directive to all blocks, not just method bodies. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2457
Add a function declaration in emitted j2objc proto code to improve Kotlin interop. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2456
Handle multiple expressions in switch expression cases, fixup string cases in switch expressions. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2460
Issue #2459: adds Abseil nullguard library dependency to j2objc's protobuf compiler plugin, needed for latest Abseil version. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2462
Supported null switch expression cases, added necessary break statements by @copybara-service[bot] in https://github.com/google/j2objc/pull/2463
Support repeatedFieldCount property for j2objc protos if property generation is enabled by @copybara-service[bot] in https://github.com/google/j2objc/pull/2464
Support getFieldNameIndex methods for repeated fields (matching the correspodning k/n method and getFieldNameWithInt here) in j2objc protos, gated by the "generate properties" j2objc protobuf option. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2466
Add kotlin/native-compatible map support, gated by the generate properties option. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2468
Turn the "companion" property added for k/n-compatibility into an actual property, as the swift compiler seems to complain otherwise if it's used as a property. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2473
For k/n compatibility properties, add trailing underscore if the name is a reserved word. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2474
Support Kotlin Native-compatible OneOf access in J2objc proto, gated by the properties option. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2469
Add support for k/n-compatible addAll, gated by the "generate_properties" option. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2475
Fix concurrent access to an object field inside ReentrantLock. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2476
Fix a data race found by tsan in Thread.java, interrupted should be accessed behind a lock. This also has the nice side effect of making the wasInterrupted changes in NSObject+JavaObject atomic. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2477
Adds android.icu.text.ListFormatter (Android SDK 26) to j2objc JRE. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2478
Updates j2objc's JRE to support Java 11+ String methods: by @copybara-service[bot] in https://github.com/google/j2objc/pull/2479
Added swift names to the J2ObjC protobuf repeated field index based getter, gated by the properties option. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2480
Align the j2objc properties option for swift with k/n protos, i.e by @copybara-service[bot] in https://github.com/google/j2objc/pull/2482
BEGIN_PUBLIC by @copybara-service[bot] in https://github.com/google/j2objc/pull/2481
Translator generates Objective-C "bool" instead of jboolean for Java boolean types. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2484
Rolled back changes to JNI headers and impl. The "j" primitive types are originally from the JNI spec. Objective-C code making JNI function calls needs to use the JNI types. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2488
For Java primitive types (except int), translator generates Objective-C native types instead of "j" types. Replaced all "jboolean" references in third_party/java_src/j2objc/** with "bool". by @copybara-service[bot] in https://github.com/google/j2objc/pull/2487
Translator now generates Objective-C "int32_t" instead of "jint", updated JRE public headers except the JNI-specific ones. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2489
Fix generated get_ENUM_CONSTANT() when mangled. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2491
Detect include cycles when segmented headers are disabled. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2492
Added JNI methods to support per-thread exception handling in native code: ExceptionCheck(), ExceptionOccurred(), ExceptionDescribe(), and FatalError(msg). Updated Throw() and ThrowNew() to save the exception, instead of immediately throwing it. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2494
Refactor Protobuf Message.toString() call to TextFormat.printer().printToString() by @copybara-service[bot] in https://github.com/google/j2objc/pull/2496
Adds support for com.google.j2kt.annotations.Throws, as an alias for j2objc translation of: by @copybara-service[bot] in https://github.com/google/j2objc/pull/2495
Updated text formatting tests to pass with latest iOS I18N updates, mostly to timezone names. Commented out test log noise from stack traces printed from tests. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2497
BEGIN_PUBLIC by @copybara-service[bot] in https://github.com/google/j2objc/pull/2498
Disable tests in SimpleDateFormatTest that fail due to ICU data differences between iOS and Android. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2499
Issue #2501: fixes reference cycles in java.io.InputStreamReader. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2502
Fix gnu-folding-constant warning. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2505
Convert enum constants to lowerCamelCase in their Objective-C properties. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2500
Bazel build support for its Java targets: annotations jar, translator, and jre_emul's jre_emul.jar. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2504
Fix the j2objc public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2507
Fix unboxing method lookup when the boxed type returns a different primitive than the boxed type. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2509
BEGIN_PUBLIC by @copybara-service[bot] in https://github.com/google/j2objc/pull/2506
Issue 2387: fixed JSON header inclusion in public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2511
Extend the list of ObjC reserved words. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2512
Fixed volatile assign/swap calls to properly retain and release objects to be thread-safe. Fixed clang-tidy warnings about parameter names being different between the header and implementation functions. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2513
BEGIN_PUBLIC by @copybara-service[bot] in https://github.com/google/j2objc/pull/2515
Issue #2514: fixes invalid reflection calls in java.io.File.toPath(). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2517
Issue #2514: added varargs type to method lookup using reflection. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2518
Add SwitchCaseRewriter, which handles Java 21 switch patterns and guards. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2519
BEGIN_PUBLIC by @copybara-service[bot] in https://github.com/google/j2objc/pull/2520
Use $key_storage_type$ for the "swift name" put method (gated by the corresponding message flag) instead of $key_nonnull_type$, which only exist for values (which can be messages). by @copybara-service[bot] in https://github.com/google/j2objc/pull/2521
Fix j2objc test suite with changes to ICU 70 and above: by @copybara-service[bot] in https://github.com/google/j2objc/pull/2523
Synced test lists in both builds, commented out printlns to reduce log noise, removed obsolete build paths. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2525
Reproduce J2ObjC crash when creating WeakReference with String, both constant and non-constant. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2527
Creates jre_emul ios_framework. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2528
Fix memory leak in TreeMap descending views by applying @RetainedWith annotation by @copybara-service[bot] in https://github.com/google/j2objc/pull/2530
BEGIN_PUBLIC by @copybara-service[bot] in https://github.com/google/j2objc/pull/2531
Use "_" as prefix on internal setter/getter methods added for properties, making their "internal" state more obvious (compared to using uppercase). This should prevent them from showing up as suggestions in xcode. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2524
Removes JRE subset library size test targets from public build. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2532
Update j2objc-annotations to use Sonatype Central Publishing. by @copybara-service[bot] in https://github.com/google/j2objc/pull/2533
Full Changelog: https://github.com/google/j2objc/compare/3.0.0...3.1