Project valhalla - 2019
(cr.openjdk.java.net)
改得超多的,之前的什麼 any T 都不見了
In Valhalla, we convert from inline to reference types via an inline widening conversion. This is similar to boxing, but it has a significant difference: the result of the conversion is not an identity object (as a box would be), but a reference to an inline object.
Boxing
的話是直接開一個肥 Object, Reference projection
的話只是一個 reference 指向 inline object,所以整個輕量化。
看到後面,最大缺點是 Optional
要寫成
Optional.inline<User> userOpt = Optional.of( findUserById(12))
這種奇怪的型式才能得到最佳化,然後像是 Map API 也變難懂:
public V.ref get(K key);
看到 return V.ref
一定很傻眼