本文整理汇总了Java中sun.invoke.util.BytecodeDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java BytecodeDescriptor类的具体用法?Java BytecodeDescriptor怎么用?Java BytecodeDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BytecodeDescriptor类属于sun.invoke.util包,在下文中一共展示了BytecodeDescriptor类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: fromDescriptor
import sun.invoke.util.BytecodeDescriptor; //导入依赖的package包/类
/**
* Same as {@link #fromMethodDescriptorString(String, ClassLoader)}, but
* {@code null} ClassLoader means the bootstrap loader is used here.
* <p>
* IMPORTANT: This method is preferable for JDK internal use as it more
* correctly interprets {@code null} ClassLoader than
* {@link #fromMethodDescriptorString(String, ClassLoader)}.
* Use of this method also avoids early initialization issues when system
* ClassLoader is not initialized yet.
*/
static MethodType fromDescriptor(String descriptor, ClassLoader loader)
throws IllegalArgumentException, TypeNotPresentException
{
if (!descriptor.startsWith("(") || // also generates NPE if needed
descriptor.indexOf(')') < 0 ||
descriptor.indexOf('.') >= 0)
throw newIllegalArgumentException("not a method descriptor: "+descriptor);
List<Class<?>> types = BytecodeDescriptor.parseMethod(descriptor, loader);
Class<?> rtype = types.remove(types.size() - 1);
Class<?>[] ptypes = listToArray(types);
return makeImpl(rtype, ptypes, true);
}
示例3: 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());
}
示例4: toFieldDescriptorString
import sun.invoke.util.BytecodeDescriptor; //导入依赖的package包/类
static String toFieldDescriptorString(Class<?> cls) {
return BytecodeDescriptor.unparse(cls);
}
示例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);
}
}
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;
}
示例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<>(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;
}
示例7: 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;
}