Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to ignore kotlin-internal methods in methods diff #315

Open
owengray-google opened this issue Oct 25, 2024 · 0 comments
Open

Add flag to ignore kotlin-internal methods in methods diff #315

owengray-google opened this issue Oct 25, 2024 · 0 comments

Comments

@owengray-google
Copy link

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.)

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

No branches or pull requests

1 participant