JakeWharton / JakeWharton/diffuse

Add flag to ignore kotlin-internal methods in methods diff

Open
#315 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
2.2k
Forks
118
Avg merge
2h 18m
Merged PRs (30d)
19

Description

While using diffuse to investigate a refactor, I am seeing output like this:
```
jarpath: ../../out-old/dist/top-of-tree-m2repository-all-0.zip.unzipped/m2repository/androidx/compose/ui/ui-tooling-data-android/1.8.0-alpha05/ui-tooling-data-android-1.8.0-alpha05.aar.unzipped/classes.jar
../../prebuilts/build-tools/diffuse/diffuse-0.3.0/bin/diffuse diff --jar ../../out-old/dist/top-of-tree-m2repository-all-0.zip.unzipped/m2repository/androidx/compose/ui/ui-tooling-data-android/1.8.0-alpha05/ui-tooling-data-android-1.8.0-alpha05.aar.unzipped/classes.jar ../../out-new/dist/top-of-tree-m2repository-all-0.zip.unzipped/m2repository/androidx/compose/ui/ui-tooling-data-android/1.8.0-alpha05/ui-tooling-data-android-1.8.0-alpha05.aar.unzipped/classes.jar
OLD: classes.jar
NEW: classes.jar

JAR │ old │ new │ diff
───────┼──────────┼──────────┼────────
class │ 79.5 KiB │ 79.4 KiB │ -144 B
other │ 86 B │ 86 B │ 0 B
───────┼──────────┼──────────┼────────
total │ 79.6 KiB │ 79.5 KiB │ -144 B

CLASSES │ old │ new │ diff
─────────┼─────┼─────┼───────────
classes │ 17 │ 17 │ 0 (+0 -0)
methods │ 266 │ 266 │ 0 (+1 -1)
fields │ 68 │ 68 │ 0 (+0 -0)

=================
==== JAR ====
=================

size │ diff │ path
──────────┼────────┼───────────────────────────────────────────────────────────────────
│ -72 B │ - META-INF/ui-tooling-data_release.kotlin_module
72 B │ +72 B │ + META-INF/ui-tooling-data.kotlin_module
2.7 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/CallGroup.class
10.7 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/CompositionCallStack.class
1.4 KiB │ -16 B │ ∆ androidx/compose/ui/tooling/data/ContextCache.class
1.3 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/EmptyGroup.class
4.6 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/Group.class
2.9 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/JoinedKey.class
2.5 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/NodeGroup.class
1.2 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/Parameter.class
4.9 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/ParameterInformation.class
590 B │ -8 B │ ∆ androidx/compose/ui/tooling/data/ParseError.class
31.8 KiB │ -16 B │ ∆ androidx/compose/ui/tooling/data/SlotTreeKt.class
1.5 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/SourceContext.class
5 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/SourceInformationContext.class
3.9 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/SourceLocation.class
1.3 KiB │ -8 B │ ∆ androidx/compose/ui/tooling/data/SourceLocationInfo.class
796 B │ -8 B │ ∆ androidx/compose/ui/tooling/data/UiToolingDataApi.class
──────────┼────────┼───────────────────────────────────────────────────────────────────
77.2 KiB │ -144 B │ (total)

=====================
==== CLASSES ====
=====================

METHODS:

old │ new │ diff
─────┼─────┼───────────
266 │ 266 │ 0 (+1 -1)

+ androidx.compose.ui.tooling.data.ContextCache getContexts$ui_tooling_data() → Map

- androidx.compose.ui.tooling.data.ContextCache getContexts$ui_tooling_data_release() → Map
```
Basically, an AGP upgrade is causing the module name of this jar to change from `ui_tooling_data_release` to `ui_tooling_data`. The changed method is a kotlin-internal method that is name mangled with that module name, the renamed `kotlin_module` file is named by the module name, and the lost bytes are due to the shorter module name in the class file header, AIUI.

While this is in a large part an edge case, at minimum it would be nice to have a flag to exclude internal members from a jar diff. Changes to internal members should never be relevant, though excluding `@PublishedApi` from that exclusion would probably be appropriate (`@PublishedApi` aren't name-mangled like that, so they did not appear in this diff).

(It might also be nice to have a configuration flag for only printing the CLASSES or METHODS section, but that's easily doable in post-processing, which could get this down to an actionable warning output.)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the `diffuse diff --jar` command and trace the code producing the CLASSES and METHODS sections, including where command-line flags are defined. Done means a flag can exclude Kotlin-internal methods from a JAR diff while retaining the reported method differences by default; the issue names no specific files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.