Why JVM can not type infer type params but javac can do?

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Thu Jan 8 08:54:33 UTC 2015


Hi, maybe this is stupid question, but want to ask and what is requirements
for this?

Array instantiation sample:
public <any T> T[] newArray(int){
        return new T[0];
}

even for non-any T:
public <T> T[] newArray(int){
        return new T[0];
}

With thousands number of optimization and inlining mechanics equipped in
jvm, What is the reasoning behind not allowing to jvm to be aware of
generics info emitted in classfilles?

Why jvm should not able do following inlining?

String[] strs =  newArray(int) => String[] strs = new String[0];
I mean even in jitted code.

I think some time ago I read some papers in similar area.
-- 

Best Regards,
Ali Ebrahimi


More information about the valhalla-dev mailing list