RFR: 8359335: Template-Framework Library: Primitive Types subtyping

Emanuel Peter epeter at openjdk.org
Fri Jan 23 10:43:43 UTC 2026


On Wed, 21 Jan 2026 15:56:36 GMT, Manuel Hässig <mhaessig at openjdk.org> wrote:

> This PR implements the subtype relation for primitive types in the Template Framework Library according to JLS §4.10.1. Further, this PR extends the primitive type example to test the addition.
> 
> Testing:
>  - [x] Github Actions
>  - [x] tier1, tier2

Ok, so this is what I remember from our conversation yesterday:
- I think the subtyping is a valuable contribution, to be able to more accurately model things.
- But I now think that it is not great to allow sampling Expressions for subtypes, at least not in all cases:
  - It means that we can do an implicit cast.
  - That leads to issues with context sensitive operators like `%` as you have discovered. That operator is a bit strange, because the supertype (float) cannot throw an exception, but the subtype (int) can.
  - Implicit casts also means the fuzzer has no control over the probabilities of these casts. And we may want to (at some point) figure out a way to control probability of operations. For example, we may want to lower or increase the probability of casts, because we think that more interesting things happen with/without casts.
- There may also be cases in the future where we do actively want to allow sampling Expressions for subtypes. For example, we may soon want to model Objects (and Valhalla value classes), and then we might want to use opreations to model things like method calls, where both the `this` and the arguments can be subtypes.
- So I suspect that we will have to eventually support both kinds of operations: those that only work on exact types and those that allow subtypes.

TLDR: for now, it would be nice to restrict `Expression` nesting to exact type matches, rather than `isSubtypeOf`, but we may allow both cases in the future.

What do you think?

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

PR Comment: https://git.openjdk.org/jdk/pull/29349#issuecomment-3789608450


More information about the hotspot-compiler-dev mailing list