Moshi: data classes with over 32 properties need multiple masks

Created on 30 Oct 2019  路  4Comments  路  Source: square/moshi

1.3.60-eap-76 with version 1.9.0 of codegen I started getting java.lang.IllegalArgumentException: Wrong number of arguments for data classes that have more than 32 properties.

the decompiled byte code for the synthetic default constructor expects an additional mask for each 32 count boundary crossed.

this issue is a follow up to https://github.com/square/moshi/issues/960

bug

All 4 comments

data

Only data classes? Or any constructor?

Put together a demo here: https://gist.github.com/ZacSweers/2f22227d3971a1bc64f9e2e6ffa4eee5

Applies to more than just data classes.

Thinking out loud of how to do this...

We currently keep a mask int and count.

  • Create n number of masks as local vars lazily. Track in list in code gen for end args
  • Track current mask var name
  • Keep a pointer to the current mask index, we keep incrementing that as we're traversing args
  • After 32, we would reset the counter to 0, add a new mask local var and set that to the current name.

Then factor that into the final "args" count. This should be pretty easy once #976 is in.

PR opened here: #978

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefanmedack picture stefanmedack  路  4Comments

Speedrockracer picture Speedrockracer  路  4Comments

cdongieux picture cdongieux  路  4Comments

ayedo picture ayedo  路  4Comments

VictorAlbertos picture VictorAlbertos  路  5Comments