sun.invoke.util.BytecodeDescriptor Java Examples

The following examples show how to use sun.invoke.util.BytecodeDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MemberName.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/** 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());
}
 
Example #2
Source File: MemberName.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** 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());
}
 
Example #3
Source File: MemberName.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** 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());
}
 
Example #4
Source File: MemberName.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** 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());
}
 
Example #5
Source File: MethodType.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source File: MemberName.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/** 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());
}
 
Example #7
Source File: MemberName.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** 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());
}
 
Example #8
Source File: MemberName.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
/** 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());
}
 
Example #9
Source File: MemberName.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** 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());
}
 
Example #10
Source File: MethodType.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #11
Source File: MemberName.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/** 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());
}
 
Example #12
Source File: MemberName.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** 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());
}
 
Example #13
Source File: MemberName.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** 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());
}
 
Example #14
Source File: MemberName.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** 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());
}
 
Example #15
Source File: MethodType.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
static String toFieldDescriptorString(Class<?> cls) {
    return BytecodeDescriptor.unparse(cls);
}
 
Example #16
Source File: MethodType.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
static String toFieldDescriptorString(Class<?> cls) {
    return BytecodeDescriptor.unparse(cls);
}
 
Example #17
Source File: MethodType.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static String toFieldDescriptorString(Class<?> cls) {
    return BytecodeDescriptor.unparse(cls);
}
 
Example #18
Source File: MemberName.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #19
Source File: MemberName.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #20
Source File: MemberName.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #21
Source File: MemberName.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #22
Source File: MethodType.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
static String toFieldDescriptorString(Class<?> cls) {
    return BytecodeDescriptor.unparse(cls);
}
 
Example #23
Source File: MemberName.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #24
Source File: MemberName.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #25
Source File: MemberName.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #26
Source File: MethodType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
static String toFieldDescriptorString(Class<?> cls) {
    return BytecodeDescriptor.unparse(cls);
}
 
Example #27
Source File: MemberName.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #28
Source File: MethodType.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static String toFieldDescriptorString(Class<?> cls) {
    return BytecodeDescriptor.unparse(cls);
}
 
Example #29
Source File: MemberName.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example #30
Source File: MemberName.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}