1910 * @param type the type of the method, with the receiver argument omitted, and a void return type
1911 * @return the desired method handle
1912 * @throws NoSuchMethodException if the constructor does not exist
1913 * @throws IllegalAccessException if access checking fails
1914 * or if the method's variable arity modifier bit
1915 * is set and {@code asVarargsCollector} fails
1916 * @exception SecurityException if a security manager is present and it
1917 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
1918 * @throws NullPointerException if any argument is null
1919 */
1920 public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException {
1921 if (refc.isArray()) {
1922 throw new NoSuchMethodException("no constructor for array class: " + refc.getName());
1923 }
1924 String name = "<init>";
1925 MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type);
1926 return getDirectConstructor(refc, ctor);
1927 }
1928
1929 /**
1930 * Looks up a class by name from the lookup context defined by this {@code Lookup} object. The static
1931 * initializer of the class is not run.
1932 * <p>
1933 * The lookup context here is determined by the {@linkplain #lookupClass() lookup class}, its class
1934 * loader, and the {@linkplain #lookupModes() lookup modes}. In particular, the method first attempts to
1935 * load the requested class, and then determines whether the class is accessible to this lookup object.
1936 *
1937 * @param targetName the fully qualified name of the class to be looked up.
1938 * @return the requested class.
1939 * @exception SecurityException if a security manager is present and it
1940 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
1941 * @throws LinkageError if the linkage fails
1942 * @throws ClassNotFoundException if the class cannot be loaded by the lookup class' loader.
1943 * @throws IllegalAccessException if the class is not accessible, using the allowed access
1944 * modes.
1945 * @exception SecurityException if a security manager is present and it
1946 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
1947 * @since 9
1948 */
1949 public Class<?> findClass(String targetName) throws ClassNotFoundException, IllegalAccessException {
1950 Class<?> targetClass = Class.forName(targetName, false, lookupClass.getClassLoader());
1951 return accessClass(targetClass);
1952 }
1953
1954 /**
1955 * Determines if a class can be accessed from the lookup context defined by
|
1910 * @param type the type of the method, with the receiver argument omitted, and a void return type
1911 * @return the desired method handle
1912 * @throws NoSuchMethodException if the constructor does not exist
1913 * @throws IllegalAccessException if access checking fails
1914 * or if the method's variable arity modifier bit
1915 * is set and {@code asVarargsCollector} fails
1916 * @exception SecurityException if a security manager is present and it
1917 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
1918 * @throws NullPointerException if any argument is null
1919 */
1920 public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException {
1921 if (refc.isArray()) {
1922 throw new NoSuchMethodException("no constructor for array class: " + refc.getName());
1923 }
1924 String name = "<init>";
1925 MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type);
1926 return getDirectConstructor(refc, ctor);
1927 }
1928
1929 /**
1930 * Looks up a class by name from the lookup context defined by this {@code Lookup} object.
1931 * This method attempts to locate, load, and link the class. The static
1932 * initializer of the class is not run.
1933 * <p>
1934 * The lookup context here is determined by the {@linkplain #lookupClass() lookup class}, its class
1935 * loader, and the {@linkplain #lookupModes() lookup modes}. In particular, the method first attempts to
1936 * load the requested class, and then determines whether the class is accessible to this lookup object.
1937 * <p>
1938 * Note that this method throws errors related to loading and linking as
1939 * specified in Sections 12.2 and 12.3 of <em>The Java Language
1940 * Specification</em>.
1941 *
1942 * @param targetName the fully qualified name of the class to be looked up.
1943 * @return the requested class.
1944 * @exception SecurityException if a security manager is present and it
1945 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
1946 * @throws LinkageError if the linkage fails
1947 * @throws ClassNotFoundException if the class cannot be loaded by the lookup class' loader.
1948 * @throws IllegalAccessException if the class is not accessible, using the allowed access
1949 * modes.
1950 * @exception SecurityException if a security manager is present and it
1951 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
1952 * @since 9
1953 */
1954 public Class<?> findClass(String targetName) throws ClassNotFoundException, IllegalAccessException {
1955 Class<?> targetClass = Class.forName(targetName, false, lookupClass.getClassLoader());
1956 return accessClass(targetClass);
1957 }
1958
1959 /**
1960 * Determines if a class can be accessed from the lookup context defined by
|