< prev index next >

src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java

Print this page
rev 47761 : 8186209: Tool support for ConstantDynamic
8186046: Minimal ConstantDynamic support
Reviewed-by: acorn
Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
* * *
Minor Hotspot code cleanup changes resulting from condy review
Summary: Addressed missing DynamicInError condition, removed unused TraceDynamicConstants
Reviewed-by: acorn, psandoz
rev 47762 : 8187742: Minimal set of bootstrap methods for constant dynamic
Contributed-by: brian.goetz@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
Reviewed-by: forax


 293 
 294     // this implements the upcall from the JVM, MethodHandleNatives.linkDynamicConstant:
 295     static Object linkDynamicConstant(Object callerObj,
 296                                       int indexInCP,
 297                                       Object bootstrapMethodObj,
 298                                       Object nameObj, Object typeObj,
 299                                       Object staticArguments) {
 300         MethodHandle bootstrapMethod = (MethodHandle)bootstrapMethodObj;
 301         Class<?> caller = (Class<?>)callerObj;
 302         String name = nameObj.toString().intern();
 303         Class<?> type = (Class<?>)typeObj;
 304         if (!TRACE_METHOD_LINKAGE)
 305             return linkDynamicConstantImpl(caller, bootstrapMethod, name, type, staticArguments);
 306         return linkDynamicConstantTracing(caller, bootstrapMethod, name, type, staticArguments);
 307     }
 308 
 309     static Object linkDynamicConstantImpl(Class<?> caller,
 310                                           MethodHandle bootstrapMethod,
 311                                           String name, Class<?> type,
 312                                           Object staticArguments) {
 313         return DynamicConstant.makeConstant(bootstrapMethod, name, type, staticArguments, caller);
 314     }
 315 
 316     private static String staticArglistForTrace(Object staticArguments) {
 317         if (staticArguments instanceof Object[])
 318             return "BSA="+java.util.Arrays.asList((Object[]) staticArguments);
 319         if (staticArguments instanceof int[])
 320             return "BSA@"+java.util.Arrays.toString((int[]) staticArguments);
 321         if (staticArguments == null)
 322             return "BSA0=null";
 323         return "BSA1="+staticArguments;
 324     }
 325 
 326     // Tracing logic:
 327     static Object linkDynamicConstantTracing(Class<?> caller,
 328                                              MethodHandle bootstrapMethod,
 329                                              String name, Class<?> type,
 330                                              Object staticArguments) {
 331         Object bsmReference = bootstrapMethod.internalMemberName();
 332         if (bsmReference == null)  bsmReference = bootstrapMethod;
 333         String staticArglist = staticArglistForTrace(staticArguments);




 293 
 294     // this implements the upcall from the JVM, MethodHandleNatives.linkDynamicConstant:
 295     static Object linkDynamicConstant(Object callerObj,
 296                                       int indexInCP,
 297                                       Object bootstrapMethodObj,
 298                                       Object nameObj, Object typeObj,
 299                                       Object staticArguments) {
 300         MethodHandle bootstrapMethod = (MethodHandle)bootstrapMethodObj;
 301         Class<?> caller = (Class<?>)callerObj;
 302         String name = nameObj.toString().intern();
 303         Class<?> type = (Class<?>)typeObj;
 304         if (!TRACE_METHOD_LINKAGE)
 305             return linkDynamicConstantImpl(caller, bootstrapMethod, name, type, staticArguments);
 306         return linkDynamicConstantTracing(caller, bootstrapMethod, name, type, staticArguments);
 307     }
 308 
 309     static Object linkDynamicConstantImpl(Class<?> caller,
 310                                           MethodHandle bootstrapMethod,
 311                                           String name, Class<?> type,
 312                                           Object staticArguments) {
 313         return ConstantBootstraps.makeConstant(bootstrapMethod, name, type, staticArguments, caller);
 314     }
 315 
 316     private static String staticArglistForTrace(Object staticArguments) {
 317         if (staticArguments instanceof Object[])
 318             return "BSA="+java.util.Arrays.asList((Object[]) staticArguments);
 319         if (staticArguments instanceof int[])
 320             return "BSA@"+java.util.Arrays.toString((int[]) staticArguments);
 321         if (staticArguments == null)
 322             return "BSA0=null";
 323         return "BSA1="+staticArguments;
 324     }
 325 
 326     // Tracing logic:
 327     static Object linkDynamicConstantTracing(Class<?> caller,
 328                                              MethodHandle bootstrapMethod,
 329                                              String name, Class<?> type,
 330                                              Object staticArguments) {
 331         Object bsmReference = bootstrapMethod.internalMemberName();
 332         if (bsmReference == null)  bsmReference = bootstrapMethod;
 333         String staticArglist = staticArglistForTrace(staticArguments);


< prev index next >