[code-reflection] Integrated: Fix array view tests and force factory creation of ranges

Gary Frost gfrost at openjdk.org
Sun Nov 9 12:26:04 UTC 2025


On Sun, 9 Nov 2025 12:19:11 GMT, Gary Frost <gfrost at openjdk.org> wrote:

> We missed use of new ranges in recent array view tests merge.
> 
> I also refactored all uses of new ranges to use factory methods
> 
> So 
> 
> Global1D.of(1) 
> 
> Instead of 
> 
> new Global1D(1)
> 
> 
> I assumed I could override the default public record constructor with a private one, and only expose the public factory. But this is not allowed with records  (why?)
> 
> Instead (put your hack sensitive sunglasses on!)   I added a fake boolean field to these records to catch all allocations with new ..  Clumsey but effective
> 
> Hence this temporary nonsense using forceUseOfOf until we cach our mental muscle memory for using new
> 
> 
>    record Global1D(int x, boolean forceUseOfOf) implements _1DX, Global{
>         public static Global1D of(int x) {
>             return new Global1D(x, true);
>         }
>     }

This pull request has now been integrated.

Changeset: 9983b707
Author:    Gary Frost <gfrost at openjdk.org>
URL:       https://git.openjdk.org/babylon/commit/9983b707837e6243b6300709bbbcda93cc3fe20a
Stats:     98 lines in 19 files changed: 1 ins; 0 del; 97 mod

Fix array view tests and force factory creation of ranges

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

PR: https://git.openjdk.org/babylon/pull/672


More information about the babylon-dev mailing list