[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


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);
        }
    }

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

Commit messages:
 - Fix array view tests and force factory creation of ranges

Changes: https://git.openjdk.org/babylon/pull/672/files
  Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=672&range=00
  Stats: 98 lines in 19 files changed: 1 ins; 0 del; 97 mod
  Patch: https://git.openjdk.org/babylon/pull/672.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/672/head:pull/672

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


More information about the babylon-dev mailing list