A Parametric VM [1] is part of Java's project Valhalla. However, it is currently some releases away.
[1] https://cr.openjdk.java.net/~jrose/values/parametric-vm.pdf
[1] https://cr.openjdk.java.net/~jrose/values/parametric-vm.pdf
And the VM can specialize on any values, not just types.