Byte-buddy: generate classes with cyclic types

前端 未结 2 493
日久生厌
日久生厌 2021-01-17 21:16

I\'m trying to generate classes with a cyclic class dependency, similar to this question: Byte Buddy - Handling cyclic references in generated classes

As a minimal e

2条回答
  •  死守一世寂寞
    2021-01-17 22:02

    This is a bug in Byte Buddy; the resolver for type annotations needs to know the depth of any type description and therefore resolves the type path of any type description. For latent types, this depth is always 0 but the default implementation applies a more complex solution.

    This will be fixed in the next release. In the meantime, subclass the latent type description and override the method to return 0.

    I decided not to change the TypeDescription.Latent type but rather make the InstrumentedType.Default implementation more accessible. Use the latter type which allows you to define features of the cyclic type which will be visible to any user. This way, you can for example specify existing fields and methods if you want to define Implementations that validate against this feature.

提交回复
热议问题