本文整理了Java中java.lang.invoke.MethodHandle.toString()
方法的一些代码示例,展示了MethodHandle.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MethodHandle.toString()
方法的具体详情如下:
包路径:java.lang.invoke.MethodHandle
类名称:MethodHandle
方法名:toString
[英]Returns a string representation of the method handle, starting with the string "MethodHandle" and ending with the string representation of the method handle's type. In other words, this method returns a string equal to the value of:
"MethodHandle" + type().toString()
(Note: Future releases of this API may add further information to the string representation. Therefore, the present syntax should not be parsed by applications.)
[中]返回方法句柄的字符串表示形式,以字符串“MethodHandle”开头,以方法句柄类型的字符串表示形式结尾。换句话说,此方法返回一个等于以下值的字符串:
"MethodHandle" + type().toString()
(*注意:*此API的未来版本可能会向字符串表示添加更多信息。因此,应用程序不应解析当前语法。)
代码示例来源:origin: org.jgrapes/org.jgrapes.core
/**
* Returns a string representation of the method.
*
* @return the string
*/
protected String methodToString() {
return method.toString();
}
代码示例来源:origin: anba/es6draft
private static MethodHandle getComputedValueMethodHandle(Lookup lookup, Method method)
throws IllegalAccessException {
// check: (ExecutionContext) -> Object
MethodHandle handle = lookup.unreflect(method);
MethodType type = handle.type();
if (type.parameterCount() != 1 || !ExecutionContext.class.equals(type.parameterType(0))) {
throw new IllegalArgumentException(handle.toString());
}
if (!Object.class.equals(type.returnType())) {
throw new IllegalArgumentException(handle.toString());
}
return handle;
}
内容来源于网络,如有侵权,请联系作者删除!