Java Code Examples for sun.invoke.util.BytecodeDescriptor#parseMethod()

The following examples show how to use sun.invoke.util.BytecodeDescriptor#parseMethod() . 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: 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 2
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 3
Source File: MethodType.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 4
Source File: MethodType.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 5
Source File: MethodType.java    From jdk-1.7-annotated with Apache License 2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benfit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(String descriptor, ClassLoader loader)
    throws IllegalArgumentException, TypeNotPresentException
{
    if (!descriptor.startsWith("(") ||  // also generates NPE if needed
        descriptor.indexOf(')') < 0 ||
        descriptor.indexOf('.') >= 0)
        throw new IllegalArgumentException("not a method descriptor: "+descriptor);
    List<Class<?>> types = BytecodeDescriptor.parseMethod(descriptor, loader);
    Class<?> rtype = types.remove(types.size() - 1);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 6
Source File: MethodType.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 7
Source File: MethodType.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 8
Source File: MethodType.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(String descriptor, ClassLoader loader)
    throws IllegalArgumentException, TypeNotPresentException
{
    if (!descriptor.startsWith("(") ||  // also generates NPE if needed
        descriptor.indexOf(')') < 0 ||
        descriptor.indexOf('.') >= 0)
        throw new IllegalArgumentException("not a method descriptor: "+descriptor);
    List<Class<?>> types = BytecodeDescriptor.parseMethod(descriptor, loader);
    Class<?> rtype = types.remove(types.size() - 1);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 9
Source File: MethodType.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(String descriptor, ClassLoader loader)
    throws IllegalArgumentException, TypeNotPresentException
{
    if (!descriptor.startsWith("(") ||  // also generates NPE if needed
        descriptor.indexOf(')') < 0 ||
        descriptor.indexOf('.') >= 0)
        throw new IllegalArgumentException("not a method descriptor: "+descriptor);
    List<Class<?>> types = BytecodeDescriptor.parseMethod(descriptor, loader);
    Class<?> rtype = types.remove(types.size() - 1);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 10
Source File: MethodType.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 11
Source File: MethodType.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 12
Source File: MethodType.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 13
Source File: MethodType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 14
Source File: MethodType.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 15
Source File: MethodType.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 16
Source File: MethodType.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 17
Source File: MethodType.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 18
Source File: MethodType.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}
 
Example 19
Source File: MethodType.java    From AndroidComponentPlugin with Apache License 2.0 3 votes vote down vote up
/**
 * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
 * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
 * Any class or interface name embedded in the descriptor string
 * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
 * on the given loader (or if it is null, on the system class loader).
 * <p>
 * Note that it is possible to encounter method types which cannot be
 * constructed by this method, because their component types are
 * not all reachable from a common class loader.
 * <p>
 * This method is included for the benefit of applications that must
 * generate bytecodes that process method handles and {@code invokedynamic}.
 * @param descriptor a bytecode-level type descriptor string "(T...)T"
 * @param loader the class loader in which to look up the types
 * @return a method type matching the bytecode-level type descriptor
 * @throws NullPointerException if the string is null
 * @throws IllegalArgumentException if the string is not well-formed
 * @throws TypeNotPresentException if a named type cannot be found
 */
public static MethodType fromMethodDescriptorString(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);
    checkSlotCount(types.size());
    Class<?>[] ptypes = listToArray(types);
    return makeImpl(rtype, ptypes, true);
}