You can do it by treating everything as a ByteBuffer, but then you pay some conversion costs(Int -&gt; Float is esp painful).<p>It&#x27;s fundamentally a data structure + execution flow problem so it&#x27;s not something that a VM&#x2F;compiler can help with. The fact that everything in Java is a ref(to be fixed some point in distant future) just means that every object fetch is a cache miss(really bad).