[code-reflection] RFR: Break infinite recursion in ReflectMethods::typeToTypeElement

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Jan 16 11:40:05 UTC 2026


On Thu, 15 Jan 2026 19:25:34 GMT, Adam Sotona <asotona at openjdk.org> wrote:

> Following piece of code to crash our compilation with `StackOverflowError`:
> 
>  @Reflect
>  <E extends Enum<E>> void crash(Enum<E> e) {}
> 
> 
> This PR breaks the infinite recursion in `ReflectMethods::typeToTypeElement`.

Note: we currently only use `TypeVariable::bound` in two cases:
* to compute the type-variable erasure (see above)
* to determine type-variable equality

We do *not* use the bound to e.g. resolve `TypeVariable` to a j.l.r.Type.

If we plan to "relax" type-variable bounds, I think we should also tweak equality not to rely on the bound information. E.g. treat bound as a best effort information -- equality should always be computed using the type variable owner + type variable name (as that pair is "unique" enough).

-------------

PR Comment: https://git.openjdk.org/babylon/pull/849#issuecomment-3759642163


More information about the babylon-dev mailing list