Java/Kotlin SDK 10.0.0 migration guide

The v10.0.0 release of Java and Kotlin SDKs builds on the unified codebase. Both SDKs share one implementation. You get feature parity and synchronized releases. You can use both SDKs in one app and receive features and fixes together.

Unified codebase release

Read the Java/Kotlin SDK v9.0.0 migration guide for details on moving to v9.0.0.

We kept the API surface close to v9.x.x. To upgrade to Java or Kotlin v10.0.0, make a few focused updates to how your app uses PubNub.

First, review the changes that need your attention.

Most notable changes include:

  • Java SDK only: Some package names changed from com.pubnub.api.* to com.pubnub.api.java.*. This lets you use Kotlin and Java SDKs in one app. Use the migration script to update imports.

    PNConfiguration class in Java

    From v10.0.0 of the Java SDK, the correct import for PNConfiguration is com.pubnub.api.java.v2.PNConfiguration.

  • Improved null safety. PatchValue<T> for optional fields shows whether a value is unset or null. For example, PatchValue.of(value) sets a value. PatchValue.unset() clears it.

  • Removed mutable PNConfiguration classes. They were deprecated in earlier releases.

This guide summarizes differences and the steps to migrate to Java/Kotlin SDK v10.0.0.

Differences between 9.x.x and 10.0.0

For API details, see the Java and Kotlin SDK documentation.

See the major differences between the versions:

Feature/Method/FieldJava/Kotlin SDK 9.x.xJava/Kotlin SDK 10.x.x
PNChannelMetadata optional field types
String or Any
PatchValue<String> or PatchValue<Any>
PNUUIDMetadata optional field types
String or Any
PatchValue<String> or PatchValue<Any>
PNChannelMembership custom and status field types
Map<String, Any?> or String?
PatchValue<Map<String, Any?>?>? or PatchValue<String?>?
PNMember custom and status field types
Map<String, Any?> or String?
PatchValue<Map<String, Any?>?>? or PatchValue<String?>?
PNSetMembershipEvent custom and status field types
Map<String, Any?> or String?
PatchValue<Map<String, Any?>?>? or PatchValue<String?>?
Mutable PNConfiguration
com.pubnub.api.PNConfiguration
com.pubnub.api.v2.PNConfiguration.builder(...)
Some Java package names
com.pubnub.api.*
com.pubnub.api.java.*

Mutable PNConfiguration

Mutable PNConfiguration classes deprecated in previous releases are removed. Use builders.

To change values at runtime, use value overrides.

Java SDK package names

We provide a migration script. It scans .java and .kt files in a chosen directory. It updates package names for classes moved to com.pubnub.api.java.* in PubNub Java SDK v10.0.0.

Package names

Not all classes moved. Use the migration script to change package names safely.

When you run the script, it creates a {filename}.bck backup for each changed file. You can disable this behavior.

Backup

Backups are best effort. Ensure you keep your data safe during migration.

Download the script

Download the script from GitHub.

Run the script

To run the script:

  1. Extract the downloaded .zip to a directory, for example update_script.

  2. Go to updated_script/bin/migration_utils and run migration_utils:

    migration_utils --dry-run --no-backups {path/to/your/Java/project}

    The script accepts:

    * required
    ParameterDescription
    --dry-run
    Runs without changing files. Prints the files that would change.
    --no-backups
    Disables creating .bck backups for changed files.
    -h, --help
    Shows help and exits.
    {path/to/your/Java/project} *
    Path to your Java project.

Example

If your Java project is at ~/projects/my_java_pubnub_project, run:

migration_utils ~/projects/my_java_pubnub_project

Migration steps

To migrate from Java/Kotlin SDK 9.x.x to 10.0.0, upgrade your SDK, review the differences above, and update your code.

Last updated on