本文整理汇总了Java中sun.invoke.util.BytecodeDescriptor.unparse方法的典型用法代码示例。如果您正苦于以下问题:Java BytecodeDescriptor.unparse方法的具体用法?Java BytecodeDescriptor.unparse怎么用?Java BytecodeDescriptor.unparse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.invoke.util.BytecodeDescriptor
的用法示例。
在下文中一共展示了BytecodeDescriptor.unparse方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSignature
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
/** Utility method to produce the signature of this member,
* used within the class file format to describe its type.
*/
public String getSignature() {
if (type == null) {
expandFromVM();
if (type == null) {
return null;
}
}
if (isInvocable())
return BytecodeDescriptor.unparse(getMethodType());
else
return BytecodeDescriptor.unparse(getFieldType());
}
示例2: getSignature
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
/** Utility method to produce the signature of this member,
* used within the class file format to describe its type.
*/
public String getSignature() {
if (type == null) {
expandFromVM();
if (type == null) return null;
}
if (type instanceof String)
return (String) type;
if (isInvocable())
return BytecodeDescriptor.unparse(getMethodType());
else
return BytecodeDescriptor.unparse(getFieldType());
}
示例3: toFieldDescriptorString
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
static String toFieldDescriptorString(Class<?> cls) {
return BytecodeDescriptor.unparse(cls);
}
示例4: getMembers
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
List<MemberName> getMembers(Class<?> defc,
String matchName, Object matchType,
int matchFlags, Class<?> lookupClass) {
matchFlags &= ALLOWED_FLAGS;
String matchSig = null;
if (matchType != null) {
matchSig = BytecodeDescriptor.unparse(matchType);
if (matchSig.startsWith("("))
matchFlags &= ~(ALL_KINDS & ~IS_INVOCABLE);
else
matchFlags &= ~(ALL_KINDS & ~IS_FIELD);
}
final int BUF_MAX = 0x2000;
int len1 = matchName == null ? 10 : matchType == null ? 4 : 1;
MemberName[] buf = newMemberBuffer(len1);
int totalCount = 0;
ArrayList<MemberName[]> bufs = null;
int bufCount = 0;
for (;;) {
bufCount = MethodHandleNatives.getMembers(defc,
matchName, matchSig, matchFlags,
lookupClass,
totalCount, buf);
if (bufCount <= buf.length) {
if (bufCount < 0) bufCount = 0;
totalCount += bufCount;
break;
}
// JVM returned to us with an intentional overflow!
totalCount += buf.length;
int excess = bufCount - buf.length;
if (bufs == null) bufs = new ArrayList<>(1);
bufs.add(buf);
int len2 = buf.length;
len2 = Math.max(len2, excess);
len2 = Math.max(len2, totalCount / 4);
buf = newMemberBuffer(Math.min(BUF_MAX, len2));
}
ArrayList<MemberName> result = new ArrayList<>(totalCount);
if (bufs != null) {
for (MemberName[] buf0 : bufs) {
Collections.addAll(result, buf0);
}
}
result.addAll(Arrays.asList(buf).subList(0, bufCount));
// Signature matching is not the same as type matching, since
// one signature might correspond to several types.
// So if matchType is a Class or MethodType, refilter the results.
if (matchType != null && matchType != matchSig) {
for (Iterator<MemberName> it = result.iterator(); it.hasNext();) {
MemberName m = it.next();
if (!matchType.equals(m.getType()))
it.remove();
}
}
return result;
}
示例5: getMembers
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
List<MemberName> getMembers(Class<?> defc,
String matchName, Object matchType,
int matchFlags, Class<?> lookupClass) {
matchFlags &= ALLOWED_FLAGS;
String matchSig = null;
if (matchType != null) {
matchSig = BytecodeDescriptor.unparse(matchType);
if (matchSig.startsWith("("))
matchFlags &= ~(ALL_KINDS & ~IS_INVOCABLE);
else
matchFlags &= ~(ALL_KINDS & ~IS_FIELD);
}
final int BUF_MAX = 0x2000;
int len1 = matchName == null ? 10 : matchType == null ? 4 : 1;
MemberName[] buf = newMemberBuffer(len1);
int totalCount = 0;
ArrayList<MemberName[]> bufs = null;
int bufCount = 0;
for (;;) {
bufCount = MethodHandleNatives.getMembers(defc,
matchName, matchSig, matchFlags,
lookupClass,
totalCount, buf);
if (bufCount <= buf.length) {
if (bufCount < 0) bufCount = 0;
totalCount += bufCount;
break;
}
// JVM returned to us with an intentional overflow!
totalCount += buf.length;
int excess = bufCount - buf.length;
if (bufs == null) bufs = new ArrayList<>(1);
bufs.add(buf);
int len2 = buf.length;
len2 = Math.max(len2, excess);
len2 = Math.max(len2, totalCount / 4);
buf = newMemberBuffer(Math.min(BUF_MAX, len2));
}
ArrayList<MemberName> result = new ArrayList<>(totalCount);
if (bufs != null) {
for (MemberName[] buf0 : bufs) {
Collections.addAll(result, buf0);
}
}
for (int i = 0; i < bufCount; i++) {
result.add(buf[i]);
}
// Signature matching is not the same as type matching, since
// one signature might correspond to several types.
// So if matchType is a Class or MethodType, refilter the results.
if (matchType != null && matchType != matchSig) {
for (Iterator<MemberName> it = result.iterator(); it.hasNext();) {
MemberName m = it.next();
if (!matchType.equals(m.getType()))
it.remove();
}
}
return result;
}
示例6: getMembers
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
List<MemberName> getMembers(Class<?> defc,
String matchName, Object matchType,
int matchFlags, Class<?> lookupClass) {
matchFlags &= ALLOWED_FLAGS;
String matchSig = null;
if (matchType != null) {
matchSig = BytecodeDescriptor.unparse(matchType);
if (matchSig.startsWith("("))
matchFlags &= ~(ALL_KINDS & ~IS_INVOCABLE);
else
matchFlags &= ~(ALL_KINDS & ~IS_FIELD);
}
final int BUF_MAX = 0x2000;
int len1 = matchName == null ? 10 : matchType == null ? 4 : 1;
MemberName[] buf = newMemberBuffer(len1);
int totalCount = 0;
ArrayList<MemberName[]> bufs = null;
int bufCount = 0;
for (;;) {
bufCount = MethodHandleNatives.getMembers(defc,
matchName, matchSig, matchFlags,
lookupClass,
totalCount, buf);
if (bufCount <= buf.length) {
if (bufCount < 0) bufCount = 0;
totalCount += bufCount;
break;
}
// JVM returned to us with an intentional overflow!
totalCount += buf.length;
int excess = bufCount - buf.length;
if (bufs == null) bufs = new ArrayList<MemberName[]>(1);
bufs.add(buf);
int len2 = buf.length;
len2 = Math.max(len2, excess);
len2 = Math.max(len2, totalCount / 4);
buf = newMemberBuffer(Math.min(BUF_MAX, len2));
}
ArrayList<MemberName> result = new ArrayList<MemberName>(totalCount);
if (bufs != null) {
for (MemberName[] buf0 : bufs) {
Collections.addAll(result, buf0);
}
}
result.addAll(Arrays.asList(buf).subList(0, bufCount));
// Signature matching is not the same as type matching, since
// one signature might correspond to several types.
// So if matchType is a Class or MethodType, refilter the results.
if (matchType != null && matchType != matchSig) {
for (Iterator<MemberName> it = result.iterator(); it.hasNext();) {
MemberName m = it.next();
if (!matchType.equals(m.getType()))
it.remove();
}
}
return result;
}
示例7: toMethodDescriptorString
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
/**
* Produces a bytecode descriptor representation of the method type.
* <p>
* Note that this is not a strict inverse of {@link #fromMethodDescriptorString fromMethodDescriptorString}.
* Two distinct classes which share a common name but have different class loaders
* will appear identical when viewed within descriptor strings.
* <p>
* This method is included for the benefit of applications that must
* generate bytecodes that process method handles and {@code invokedynamic}.
* {@link #fromMethodDescriptorString(java.lang.String, java.lang.ClassLoader) fromMethodDescriptorString},
* because the latter requires a suitable class loader argument.
* @return the bytecode type descriptor representation
*/
public String toMethodDescriptorString() {
String desc = methodDescriptor;
if (desc == null) {
desc = BytecodeDescriptor.unparse(this);
methodDescriptor = desc;
}
return desc;
}
示例8: InnerClassLambdaMetafactory
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
/**
* General meta-factory constructor, supporting both standard cases and
* allowing for uncommon options such as serialization or bridging.
*
* @param caller Stacked automatically by VM; represents a lookup context
* with the accessibility privileges of the caller.
* @param invokedType Stacked automatically by VM; the signature of the
* invoked method, which includes the expected static
* type of the returned lambda object, and the static
* types of the captured arguments for the lambda. In
* the event that the implementation method is an
* instance method, the first argument in the invocation
* signature will correspond to the receiver.
* @param samMethodName Name of the method in the functional interface to
* which the lambda or method reference is being
* converted, represented as a String.
* @param samMethodType Type of the method in the functional interface to
* which the lambda or method reference is being
* converted, represented as a MethodType.
* @param implMethod The implementation method which should be called (with
* suitable adaptation of argument types, return types,
* and adjustment for captured arguments) when methods of
* the resulting functional interface instance are invoked.
* @param instantiatedMethodType The signature of the primary functional
* interface method after type variables are
* substituted with their instantiation from
* the capture site
* @param isSerializable Should the lambda be made serializable? If set,
* either the target type or one of the additional SAM
* types must extend {@code Serializable}.
* @param markerInterfaces Additional interfaces which the lambda object
* should implement.
* @param additionalBridges Method types for additional signatures to be
* bridged to the implementation method
* @throws LambdaConversionException If any of the meta-factory protocol
* invariants are violated
*/
public InnerClassLambdaMetafactory(MethodHandles.Lookup caller,
MethodType invokedType,
String samMethodName,
MethodType samMethodType,
MethodHandle implMethod,
MethodType instantiatedMethodType,
boolean isSerializable,
Class<?>[] markerInterfaces,
MethodType[] additionalBridges)
throws LambdaConversionException {
super(caller, invokedType, samMethodName, samMethodType,
implMethod, instantiatedMethodType,
isSerializable, markerInterfaces, additionalBridges);
implMethodClassName = implDefiningClass.getName().replace('.', '/');
implMethodName = implInfo.getName();
implMethodDesc = implMethodType.toMethodDescriptorString();
implMethodReturnClass = (implKind == MethodHandleInfo.REF_newInvokeSpecial)
? implDefiningClass
: implMethodType.returnType();
constructorType = invokedType.changeReturnType(Void.TYPE);
lambdaClassName = targetClass.getName().replace('.', '/') + "$$Lambda$" + counter.incrementAndGet();
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
int parameterCount = invokedType.parameterCount();
if (parameterCount > 0) {
argNames = new String[parameterCount];
argDescs = new String[parameterCount];
for (int i = 0; i < parameterCount; i++) {
argNames[i] = "arg$" + (i + 1);
argDescs[i] = BytecodeDescriptor.unparse(invokedType.parameterType(i));
}
} else {
argNames = argDescs = EMPTY_STRING_ARRAY;
}
}
示例9: InnerClassLambdaMetafactory
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
/**
* General meta-factory constructor, supporting both standard cases and
* allowing for uncommon options such as serialization or bridging.
*
* @param caller Stacked automatically by VM; represents a lookup context
* with the accessibility privileges of the caller.
* @param invokedType Stacked automatically by VM; the signature of the
* invoked method, which includes the expected static
* type of the returned lambda object, and the static
* types of the captured arguments for the lambda. In
* the event that the implementation method is an
* instance method, the first argument in the invocation
* signature will correspond to the receiver.
* @param samMethodName Name of the method in the functional interface to
* which the lambda or method reference is being
* converted, represented as a String.
* @param samMethodType Type of the method in the functional interface to
* which the lambda or method reference is being
* converted, represented as a MethodType.
* @param implMethod The implementation method which should be called (with
* suitable adaptation of argument types, return types,
* and adjustment for captured arguments) when methods of
* the resulting functional interface instance are invoked.
* @param instantiatedMethodType The signature of the primary functional
* interface method after type variables are
* substituted with their instantiation from
* the capture site
* @param isSerializable Should the lambda be made serializable? If set,
* either the target type or one of the additional SAM
* types must extend {@code Serializable}.
* @param markerInterfaces Additional interfaces which the lambda object
* should implement.
* @param additionalBridges Method types for additional signatures to be
* bridged to the implementation method
* @throws LambdaConversionException If any of the meta-factory protocol
* invariants are violated
*/
public InnerClassLambdaMetafactory(MethodHandles.Lookup caller,
MethodType invokedType,
String samMethodName,
MethodType samMethodType,
MethodHandle implMethod,
MethodType instantiatedMethodType,
boolean isSerializable,
Class<?>[] markerInterfaces,
MethodType[] additionalBridges)
throws LambdaConversionException {
super(caller, invokedType, samMethodName, samMethodType,
implMethod, instantiatedMethodType,
isSerializable, markerInterfaces, additionalBridges);
implMethodClassName = implClass.getName().replace('.', '/');
implMethodName = implInfo.getName();
implMethodDesc = implInfo.getMethodType().toMethodDescriptorString();
constructorType = invokedType.changeReturnType(Void.TYPE);
lambdaClassName = targetClass.getName().replace('.', '/') + "$$Lambda$" + counter.incrementAndGet();
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
int parameterCount = invokedType.parameterCount();
if (parameterCount > 0) {
argNames = new String[parameterCount];
argDescs = new String[parameterCount];
for (int i = 0; i < parameterCount; i++) {
argNames[i] = "arg$" + (i + 1);
argDescs[i] = BytecodeDescriptor.unparse(invokedType.parameterType(i));
}
} else {
argNames = argDescs = EMPTY_STRING_ARRAY;
}
}
示例10: toMethodDescriptorString
import sun.invoke.util.BytecodeDescriptor; //导入方法依赖的package包/类
/**
* Produces a bytecode descriptor representation of the method type.
* <p>
* Note that this is not a strict inverse of {@link #fromMethodDescriptorString fromMethodDescriptorString}.
* Two distinct classes which share a common name but have different class loaders
* will appear identical when viewed within descriptor strings.
* <p>
* This method is included for the benfit of applications that must
* generate bytecodes that process method handles and {@code invokedynamic}.
* {@link #fromMethodDescriptorString(java.lang.String, java.lang.ClassLoader) fromMethodDescriptorString},
* because the latter requires a suitable class loader argument.
* @return the bytecode type descriptor representation
*/
public String toMethodDescriptorString() {
return BytecodeDescriptor.unparse(this);
}