1925 MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type); |
1925 MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type); |
1926 return getDirectConstructor(refc, ctor); |
1926 return getDirectConstructor(refc, ctor); |
1927 } |
1927 } |
1928 |
1928 |
1929 /** |
1929 /** |
1930 * Looks up a class by name from the lookup context defined by this {@code Lookup} object. The static |
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, and then determines whether |
|
1932 * the class is accessible to this {@code Lookup} object. The static |
1931 * initializer of the class is not run. |
1933 * initializer of the class is not run. |
1932 * <p> |
1934 * <p> |
1933 * The lookup context here is determined by the {@linkplain #lookupClass() lookup class}, its class |
1935 * 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 |
1936 * loader, and the {@linkplain #lookupModes() lookup modes}. |
1935 * 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>. |
1936 * |
1941 * |
1937 * @param targetName the fully qualified name of the class to be looked up. |
1942 * @param targetName the fully qualified name of the class to be looked up. |
1938 * @return the requested class. |
1943 * @return the requested class. |
1939 * @exception SecurityException if a security manager is present and it |
1944 * @exception SecurityException if a security manager is present and it |
1940 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a> |
1945 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a> |
1942 * @throws ClassNotFoundException if the class cannot be loaded by the lookup class' loader. |
1947 * @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 |
1948 * @throws IllegalAccessException if the class is not accessible, using the allowed access |
1944 * modes. |
1949 * modes. |
1945 * @exception SecurityException if a security manager is present and it |
1950 * @exception SecurityException if a security manager is present and it |
1946 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a> |
1951 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a> |
|
1952 * |
|
1953 * @jls 12.2 Loading of Classes and Interfaces |
|
1954 * @jls 12.3 Linking of Classes and Interfaces |
1947 * @since 9 |
1955 * @since 9 |
1948 */ |
1956 */ |
1949 public Class<?> findClass(String targetName) throws ClassNotFoundException, IllegalAccessException { |
1957 public Class<?> findClass(String targetName) throws ClassNotFoundException, IllegalAccessException { |
1950 Class<?> targetClass = Class.forName(targetName, false, lookupClass.getClassLoader()); |
1958 Class<?> targetClass = Class.forName(targetName, false, lookupClass.getClassLoader()); |
1951 return accessClass(targetClass); |
1959 return accessClass(targetClass); |