Open mikehearn opened 1 month ago
The whole generics optimization code is very complex and used to be quite buggy. We managed to fix almost all edge cases but apparently there are more. I'm afraid I won't be able to fix this without a minimal reproducer.
I'd recommend that you simply keep generics optimization turned off. Serialization should be faster but your serialized size will increase a bit.
Unfortunately I'm not entirely sure how to make a minimal reproducer for this, so figured I'd drop a bug in case anyone who knows the code spots the issue.
When serializing a sufficiently crazy object graph (Micronaut compile time reflection metadata), some kind of limit gets hit in the optimized generics code and there's an
ArrayIndexOutOfBoundsException
. I tried to understand the code that's failing but it's a bit arcane:Turning off optimized generics is a functioning workaround. The failure happens here:
From a bit of debugging, the issue is that
sizeNeeded
seems to be calculated wrong. There are two iterations of the outer for loop, but after the first the array is full andargumentsSize
points off the end. My guess is that the test suite doesn't exercise the case where the arguments array gets so full it needs to be expanded, because normal object graphs never encounter it. But I'm not sure. The for loops are structured in a rather confusing way.