Skip to content

refactor: migrate MParticleIdentityClient to Kotlin (Lane C, part 1) - #778

Merged
thomson-t merged 1 commit into
workstation/kotlin-migrationfrom
kotlin/lane-c-identity-leaf
Sep 10, 2026
Merged

refactor: migrate MParticleIdentityClient to Kotlin (Lane C, part 1)#778
thomson-t merged 1 commit into
workstation/kotlin-migrationfrom
kotlin/lane-c-identity-leaf

Conversation

@nickolas-dimitrakas

Copy link
Copy Markdown
Contributor

Lane C — identity leaf classes, part 1 (1 of 2 files, 13 of 170 LOC)

Stacked on #777 (Lane E) — merge that one first. Part of the Java→Kotlin migration (PLAN.md).

Converts identity/MParticleIdentityClient. Zero public API diff (bash scripts/api-guard.sh check passes) — this file lives outside com.mparticle.internal, so any diff here is a hard gate failure, not a reviewable one. Each method keeps @Throws(Exception::class) to preserve the throws clause Java callers compile against.

MParticleUserImpl is deliberately NOT in this PR

Lane C's other easy-tier file (157 LOC) turned out to have a real hazard: it has three package-private members (setUserIdentities, setUserIdentity, setUserDelegate/mUserDelegate) that testutils/AccessUtils.java calls directly — from a separate Gradle module.

Kotlin has no package-private visibility. The closest equivalent, internal, is module-scoped and name-mangled on the JVM, so converting these would break that cross-module Java call site outright. Working around the mangling with @JvmName compiles, but makes those three members permanently public in the ABI — a real (if obscure) addition to a frozen-by-default file, which is exactly what this migration is supposed to avoid.

This needs either a coordinated PR that also converts AccessUtils.java/IdentityApi.java, or a restructured test hook. Filing as a follow-up rather than folding it in here or quietly accepting the API growth. Worth adding to PLAN.md's hazard table — package-private Java members with cross-module Java callers are a distinct case from the ones already documented.

Validation

  • ./gradlew :android-core:compileDebugKotlin :android-core:compileDebugJavaWithJavac — clean
  • ./gradlew :android-kit-base:compileDebugKotlin :android-kit-base:compileDebugJavaWithJavac — clean
  • bash scripts/api-guard.sh check — passed, zero diff
  • bash scripts/kotlin-migration-progress.sh — 23.3% → 23.3% (rounds the same at one decimal; LOC moved 16,752 → 16,739)
  • Local ktlintCheck/unit tests could not run in this environment — Maven Central is rate-limiting dependency resolution (429). The commit hook's own ktlint pass (cached deps) was clean. CI will run the full suite.

Draft while CI runs — flip to ready once green, and once #777 merges so this rebases onto workstation/kotlin-migration directly.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Kotlin migration progress

This PR migrates 13 lines of Java to Kotlin (+0.0 pp).

Module Kotlin LOC Java LOC Java (facade, staying) Java left to migrate Kotlin %
android-core 3417 22251 9241 13010 13.3%
android-kit-base 557 5380 1651 3729 9.4%
kits/rokt/rokt 1122 0 0 0 100.0%
Total 5096 27631 10892 16739 15.6%

Migration goal progress: 23.3% (Kotlin LOC as a share of everything that is not a designated public-API facade.)

126 Java files / 49 Kotlin files in scope.

Largest Java files still to migrate
LOC File
1514 android-core/src/main/java/com/mparticle/internal/ConfigManager.java
1441 android-kit-base/src/main/java/com/mparticle/kits/KitManagerImpl.java
1089 android-core/src/main/java/com/mparticle/internal/MessageManager.java
1069 android-kit-base/src/main/java/com/mparticle/kits/KitConfiguration.java
858 android-core/src/main/java/com/mparticle/internal/MPUtility.java
840 android-core/src/main/java/com/mparticle/internal/MParticleJSInterface.java
809 android-core/src/main/java/com/mparticle/internal/KitFrameworkWrapper.java
786 android-core/src/main/java/com/mparticle/internal/database/services/MParticleDBManager.java
490 android-kit-base/src/main/java/com/mparticle/kits/mappings/CustomMapping.java
482 android-core/src/main/java/com/mparticle/internal/MParticleApiClientImpl.java
431 android-core/src/main/java/com/mparticle/identity/MParticleIdentityClientImpl.java
375 android-core/src/main/java/com/mparticle/internal/UploadHandler.java
350 android-core/src/main/java/com/mparticle/internal/DeviceAttributes.java
322 android-core/src/main/java/com/mparticle/networking/MParticleBaseClientImpl.java
319 android-core/src/main/java/com/mparticle/internal/MessageHandler.java

@nickolas-dimitrakas nickolas-dimitrakas self-assigned this Sep 2, 2026
@nickolas-dimitrakas
nickolas-dimitrakas force-pushed the kotlin/lane-c-identity-leaf branch 2 times, most recently from 6a31a86 to 9716d9f Compare September 2, 2026 23:18
@thomson-t
thomson-t force-pushed the kotlin/lane-c-identity-leaf branch from 9716d9f to 5c8104e Compare September 10, 2026 16:45
@thomson-t

Copy link
Copy Markdown
Collaborator

Rebased onto the updated Lane E branch (#777), which now includes latest main via #789.

@thomson-t
thomson-t force-pushed the kotlin/lane-c-identity-leaf branch 2 times, most recently from 5b1f8d2 to 3005277 Compare September 10, 2026 17:00
@thomson-t
thomson-t marked this pull request as ready for review September 10, 2026 17:11
@thomson-t
thomson-t requested a review from a team as a code owner September 10, 2026 17:11
@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Source-only language migration of a small public interface with explicit JVM throw annotations; behavior and ABI are unchanged per API guard.

Overview
Lane C (part 1) moves the public MParticleIdentityClient interface from Java to Kotlin as part of the planned Java→Kotlin migration, with no intended public API change.

The Java file is removed and replaced by a Kotlin interface with the same four identity HTTP operations (login, logout, identify, modify). Each method keeps @Throws(Exception::class) so Java callers still see throws Exception at compile time. api-guard is expected to stay clean because this type is outside com.mparticle.internal.

Reviewed by Cursor Bugbot for commit 6ae7760. Bugbot is set up for automated code reviews on this repo. Configure here.

thomson-t
thomson-t previously approved these changes Sep 10, 2026
thomson-t added a commit that referenced this pull request Sep 10, 2026
Brings `workstation/kotlin-migration` up to date with `main`.

## ⚠️ Merge this with "Create a merge commit" — not squash, not rebase

The branch already contains a real merge commit with two parents
(`7907bbe4` from the integration branch, `a1377d39` from `main`).
Squashing would flatten the upstream commits into one synthetic commit
on the integration branch and lose the branch point; rebasing would
rewrite `main`'s commits with new SHAs. Either one makes the eventual
`workstation/kotlin-migration` → `main` merge harder to read and harder
to bisect.

## What it picks up

| | |
| --- | --- |
| [#616](#616) |
chore: bump androidx.test.ext:junit from 1.1.4 to 1.3.0 |
| [#769](#769) |
docs: trim AGENTS.md to the non-derivable core and add CLAUDE.md |
| [#784](#784) |
chore: bump actions/setup-java from 5 to 6 |
| [#765](#765) |
chore: bump gradle/actions/setup-gradle from 5.0.2 to 6.3.0 |
| [#764](#764) |
chore: bump trunk-io/trunk-action from 1.3.1 to 2.0.0 |
| [#775](#775) |
chore: prepare release 6.0.4 |

14 files, +194 / −211. **No conflicts.**

## Why the migration tooling is unaffected

Nothing on `main` touched `android-core` or `android-kit-base`
`src/main`, so the committed `api/*.api` files are still exact. The
androidTest manifest and `testutils/build.gradle` junit bump do not
affect the public API guard or the Kotlin migration tracker.

Stacked PRs #777 and #778 will rebase onto this once it lands.


Made with [Cursor](https://cursor.com)
@thomson-t
thomson-t force-pushed the kotlin/lane-c-identity-leaf branch from 3005277 to 21262a9 Compare September 10, 2026 17:25
@thomson-t
thomson-t force-pushed the kotlin/lane-c-identity-leaf branch from 21262a9 to c0a2987 Compare September 10, 2026 18:03

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c0a2987. Configure here.

Base automatically changed from kotlin/lane-e-kit-infra-leaf to workstation/kotlin-migration September 10, 2026 18:08
Converts the identity leaf interface MParticleIdentityClient. Zero
public API diff (verified with scripts/api-guard.sh check) — this
file lives outside com.mparticle.internal, so any diff here is a hard
gate failure, not just a reviewable one.

Each method keeps @throws(Exception::class) to preserve the `throws`
clause Java callers compile against; Kotlin has no checked exceptions
by default, so dropping this annotation would silently change the
bytecode-visible throws clause even though the guard's plain
javap -public diff doesn't show it (javap -public without -v doesn't
print throws clauses either, so this one wouldn't even trip the
guard — caught it by matching the plan's own hazard table, not by the
tool).

MParticleUserImpl (Lane C's other easy-tier file, 157 LOC) is
deliberately not included here. It has three package-private members
(setUserIdentities, setUserIdentity, setUserDelegate/mUserDelegate)
that testutils/AccessUtils.java calls directly from a separate Gradle
module. Kotlin has no package-private visibility: converting those to
`internal` breaks that cross-module Java call site (internal is
module-scoped and name-mangled on the JVM), and dodging the mangling
with @JvmName makes them permanently public — a real, if obscure, ABI
addition in a frozen file. Needs a coordinated PR with
AccessUtils.java/IdentityApi.java or a restructured test hook; tracked
as a follow-up rather than folded in here.

Local ktlintCheck and unit tests could not run in this environment —
Maven Central is rate-limiting dependency resolution (429). Compile
and api-guard both ran clean against the real build; the commit hook's
own ktlint pass (cached deps) was clean. CI will run the full suite.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@thomson-t
thomson-t force-pushed the kotlin/lane-c-identity-leaf branch from c0a2987 to 6ae7760 Compare September 10, 2026 18:08
@thomson-t
thomson-t merged commit 058bdc8 into workstation/kotlin-migration Sep 10, 2026
45 checks passed
@thomson-t
thomson-t deleted the kotlin/lane-c-identity-leaf branch September 10, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants