35 import sun.invoke.util.Wrapper; |
35 import sun.invoke.util.Wrapper; |
36 import sun.reflect.CallerSensitive; |
36 import sun.reflect.CallerSensitive; |
37 import sun.reflect.Reflection; |
37 import sun.reflect.Reflection; |
38 import sun.reflect.misc.ReflectUtil; |
38 import sun.reflect.misc.ReflectUtil; |
39 import sun.security.util.SecurityConstants; |
39 import sun.security.util.SecurityConstants; |
|
40 import java.lang.invoke.LambdaForm.BasicType; |
|
41 import static java.lang.invoke.LambdaForm.BasicType.*; |
40 import static java.lang.invoke.MethodHandleStatics.*; |
42 import static java.lang.invoke.MethodHandleStatics.*; |
41 import static java.lang.invoke.MethodHandleNatives.Constants.*; |
43 import static java.lang.invoke.MethodHandleNatives.Constants.*; |
42 import java.util.concurrent.ConcurrentHashMap; |
44 import java.util.concurrent.ConcurrentHashMap; |
43 import sun.security.util.SecurityConstants; |
|
44 |
45 |
45 /** |
46 /** |
46 * This class consists exclusively of static methods that operate on or return |
47 * This class consists exclusively of static methods that operate on or return |
47 * method handles. They fall into several categories: |
48 * method handles. They fall into several categories: |
48 * <ul> |
49 * <ul> |
2187 MethodHandle result = target; |
2188 MethodHandle result = target; |
2188 for (int i = 0; i < insCount; i++) { |
2189 for (int i = 0; i < insCount; i++) { |
2189 Object value = values[i]; |
2190 Object value = values[i]; |
2190 Class<?> ptype = oldType.parameterType(pos+i); |
2191 Class<?> ptype = oldType.parameterType(pos+i); |
2191 if (ptype.isPrimitive()) { |
2192 if (ptype.isPrimitive()) { |
2192 char btype = 'I'; |
2193 BasicType btype = I_TYPE; |
2193 Wrapper w = Wrapper.forPrimitiveType(ptype); |
2194 Wrapper w = Wrapper.forPrimitiveType(ptype); |
2194 switch (w) { |
2195 switch (w) { |
2195 case LONG: btype = 'J'; break; |
2196 case LONG: btype = J_TYPE; break; |
2196 case FLOAT: btype = 'F'; break; |
2197 case FLOAT: btype = F_TYPE; break; |
2197 case DOUBLE: btype = 'D'; break; |
2198 case DOUBLE: btype = D_TYPE; break; |
2198 } |
2199 } |
2199 // perform unboxing and/or primitive conversion |
2200 // perform unboxing and/or primitive conversion |
2200 value = w.convert(value, ptype); |
2201 value = w.convert(value, ptype); |
2201 result = result.bindArgument(pos, btype, value); |
2202 result = result.bindArgument(pos, btype, value); |
2202 continue; |
2203 continue; |
2203 } |
2204 } |
2204 value = ptype.cast(value); // throw CCE if needed |
2205 value = ptype.cast(value); // throw CCE if needed |
2205 if (pos == 0) { |
2206 if (pos == 0) { |
2206 result = result.bindReceiver(value); |
2207 result = result.bindReceiver(value); |
2207 } else { |
2208 } else { |
2208 result = result.bindArgument(pos, 'L', value); |
2209 result = result.bindArgument(pos, L_TYPE, value); |
2209 } |
2210 } |
2210 } |
2211 } |
2211 return result; |
2212 return result; |
2212 } |
2213 } |
2213 |
2214 |