< prev index next >

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

Print this page
rev 52749 : Bootstrap method consolidation
* clean up and simplify JDK support code for BSM invocation
* simplify JVM bootstrap handshake: use BootstrapCallInfo only
* remove unused JVM paths and data fields
* move bootstrap argument processing from MethodHandleNatives to ConstantPool
* remove ConstantGroup; merge argument access into BootstrapCallInfo
* adjust BSM argument access: remove copyArguments, add argumentRef API
* add metadata-free BSM modes, including symbolic arguments from CP

*** 195,205 **** MethodType newType = newTarget.type(); // null check! if (!newType.equals(oldType)) throw wrongTargetType(newTarget, oldType); } ! private static WrongMethodTypeException wrongTargetType(MethodHandle target, MethodType type) { return new WrongMethodTypeException(String.valueOf(target)+" should be of type "+type); } /** * Produces a method handle equivalent to an invokedynamic instruction --- 195,205 ---- MethodType newType = newTarget.type(); // null check! if (!newType.equals(oldType)) throw wrongTargetType(newTarget, oldType); } ! static WrongMethodTypeException wrongTargetType(Object target, MethodType type) { return new WrongMethodTypeException(String.valueOf(target)+" should be of type "+type); } /** * Produces a method handle equivalent to an invokedynamic instruction
*** 291,340 **** } /*package-private*/ void setTargetVolatile(MethodHandle newTarget) { MethodHandleNatives.setCallSiteTargetVolatile(this, newTarget); } - - // this implements the upcall from the JVM, MethodHandleNatives.linkCallSite: - static CallSite makeSite(MethodHandle bootstrapMethod, - // Callee information: - String name, MethodType type, - // Extra arguments for BSM, if any: - Object info, - // Caller information: - Class<?> callerClass) { - CallSite site; - try { - Object binding = BootstrapMethodInvoker.invoke( - CallSite.class, bootstrapMethod, name, type, info, callerClass); - if (binding instanceof CallSite) { - site = (CallSite) binding; - } else { - // See the "Linking Exceptions" section for the invokedynamic - // instruction in JVMS 6.5. - // Throws a runtime exception defining the cause that is then - // in the "catch (Throwable ex)" a few lines below wrapped in - // BootstrapMethodError - throw new ClassCastException("CallSite bootstrap method failed to produce an instance of CallSite"); - } - if (!site.getTarget().type().equals(type)) { - // See the "Linking Exceptions" section for the invokedynamic - // instruction in JVMS 6.5. - // Throws a runtime exception defining the cause that is then - // in the "catch (Throwable ex)" a few lines below wrapped in - // BootstrapMethodError - throw wrongTargetType(site.getTarget(), type); - } - } catch (Error e) { - // Pass through an Error, including BootstrapMethodError, any other - // form of linkage error, such as IllegalAccessError if the bootstrap - // method is inaccessible, or say ThreadDeath/OutOfMemoryError - // See the "Linking Exceptions" section for the invokedynamic - // instruction in JVMS 6.5. - throw e; - } catch (Throwable ex) { - // Wrap anything else in BootstrapMethodError - throw new BootstrapMethodError("CallSite bootstrap method initialization exception", ex); - } - return site; - } } --- 291,296 ----
< prev index next >