6979327: method handle invocation should use casts instead of type parameters to specify return type

Infer return type for polymorphic signature calls according to updated JSR 292 draft

Reviewed-by: jjg
This commit is contained in:
John Rose 2010-09-07 17:32:27 +01:00 committed by Maurizio Cimadamore
parent 73825fc885
commit cd74d63c12
26 changed files with 516 additions and 380 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,11 @@
/*
* @test
* @bug 6754038
* @bug 6754038 6979327
* @summary Generate call sites for method handle
* @author jrose
*
* @compile -source 7 -target 7 InvokeMH.java
* @compile -source 7 -target 7 -XDallowTransitionalJSR292=no InvokeMH.java
*/
/*
@ -57,20 +57,17 @@ public class InvokeMH {
Object k = "kosmos";
mh_SiO.invokeExact((String)k, 789);
o = mh_SiO.invokeExact((String)null, 000);
o = mh_SiO.<Object>invokeExact("arda", -123);
o = (Object) mh_SiO.invokeExact("arda", -123);
// sig = ()String
s = mh_vS.<String>invokeExact();
s = (String) mh_vS.invokeExact();
// sig = ()int
i = mh_vi.<int>invokeExact();
o = mh_vi.<int>invokeExact();
//s = mh_vi.<int>invokeExact(); //BAD
mh_vi.<int>invokeExact();
i = (int) mh_vi.invokeExact();
o = (int) mh_vi.invokeExact();
// sig = ()void
//o = mh_vv.<void>invokeExact(); //BAD
mh_vv.<void>invokeExact();
mh_vv.invokeExact();
}
void testGen(MethodHandle mh_SiO,
@ -80,24 +77,23 @@ public class InvokeMH {
Object o; String s; int i; // for return type testing
// next five must have sig = (*,*)*
mh_SiO.invokeGeneric((Object)"world", (Object)123);
mh_SiO.<void>invokeGeneric((Object)"mundus", (Object)456);
o = mh_SiO.invokeGeneric((Object)"world", (Object)123);
mh_SiO.invokeGeneric((Object)"mundus", (Object)456);
Object k = "kosmos";
mh_SiO.invokeGeneric(k, 789);
o = mh_SiO.invokeGeneric(k, 789);
o = mh_SiO.invokeGeneric(null, 000);
o = mh_SiO.<Object>invokeGeneric("arda", -123);
o = mh_SiO.invokeGeneric("arda", -123);
// sig = ()String
o = mh_vS.invokeGeneric();
// sig = ()int
i = mh_vi.<int>invokeGeneric();
o = mh_vi.invokeGeneric();
//s = mh_vi.<int>invokeGeneric(); //BAD
mh_vi.<void>invokeGeneric();
i = (int) mh_vi.invokeGeneric();
o = (int) mh_vi.invokeGeneric();
mh_vi.invokeGeneric();
// sig = ()void
//o = mh_vv.<void>invokeGeneric(); //BAD
mh_vv.invokeGeneric();
o = mh_vv.invokeGeneric();
}
}