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

Remi Forax forax at univ-mlv.fr
Fri Jan 9 07:55:18 UTC 2015


On 01/08/2015 01:32 PM, Ali Ebrahimi wrote:
> I mean we can do better job than today by some hints and already 
> unused info by VM.
> One first step: disallowing raw types by java9/10.

you can not do that easily because the actual JLS introduces raw type 
even if the user code
doesn't explicitly write one.

List<String> list = ...
list.getClass() is inferred as Class<? extends List> :(

> And some form of http://www.google.com/patents/US7810077

while the idea of trying to infer the type argument from the bytecode is 
interesting,
I've trouble to see how runtime information can be used for finding type 
arguments
given that if you have found more than one runtime class for a type argument
it can be either an error or the type argument is a wildcard.

regards,
Rémi

>
> On Thu, Jan 8, 2015 at 3:49 PM, Remi Forax <forax at univ-mlv.fr 
> <mailto:forax at univ-mlv.fr>> wrote:
>
>     Do you really want to enhance a simple VM checkcast to check
>     subtyping relationship between wildcards at runtime ?
>
>     Rémi
>
>
>     On 01/08/2015 09:54 AM, Ali Ebrahimi wrote:
>
>         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