1253 ProcessBuilder.class, methodType(void.class, String[].class)); 1254 ProcessBuilder pb = (ProcessBuilder) 1255 MH_newProcessBuilder.invoke("x", "y", "z"); 1256 assertEquals("[x, y, z]", pb.command().toString()); 1257 * }</pre></blockquote> 1258 * @param refc the class or interface from which the method is accessed 1259 * @param type the type of the method, with the receiver argument omitted, and a void return type 1260 * @return the desired method handle 1261 * @throws NoSuchMethodException if the constructor does not exist 1262 * @throws IllegalAccessException if access checking fails 1263 * or if the method's variable arity modifier bit 1264 * is set and {@code asVarargsCollector} fails 1265 * @exception SecurityException if a security manager is present and it 1266 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a> 1267 * @throws NullPointerException if any argument is null 1268 */ 1269 public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException { 1270 if (refc.isArray()) { 1271 throw new NoSuchMethodException("no constructor for array class: " + refc.getName()); 1272 } 1273 String name = "<init>"; 1274 MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type); 1275 return getDirectConstructor(refc, ctor); 1276 } 1277 1278 /** 1279 * Looks up a class by name from the lookup context defined by this {@code Lookup} object. The static 1280 * initializer of the class is not run. 1281 * <p> 1282 * The lookup context here is determined by the {@linkplain #lookupClass() lookup class}, its class 1283 * loader, and the {@linkplain #lookupModes() lookup modes}. In particular, the method first attempts to 1284 * load the requested class, and then determines whether the class is accessible to this lookup object. 1285 * 1286 * @param targetName the fully qualified name of the class to be looked up. 1287 * @return the requested class. 1288 * @exception SecurityException if a security manager is present and it 1289 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a> 1290 * @throws LinkageError if the linkage fails 1291 * @throws ClassNotFoundException if the class cannot be loaded by the lookup class' loader. 1292 * @throws IllegalAccessException if the class is not accessible, using the allowed access | 1253 ProcessBuilder.class, methodType(void.class, String[].class)); 1254 ProcessBuilder pb = (ProcessBuilder) 1255 MH_newProcessBuilder.invoke("x", "y", "z"); 1256 assertEquals("[x, y, z]", pb.command().toString()); 1257 * }</pre></blockquote> 1258 * @param refc the class or interface from which the method is accessed 1259 * @param type the type of the method, with the receiver argument omitted, and a void return type 1260 * @return the desired method handle 1261 * @throws NoSuchMethodException if the constructor does not exist 1262 * @throws IllegalAccessException if access checking fails 1263 * or if the method's variable arity modifier bit 1264 * is set and {@code asVarargsCollector} fails 1265 * @exception SecurityException if a security manager is present and it 1266 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a> 1267 * @throws NullPointerException if any argument is null 1268 */ 1269 public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException { 1270 if (refc.isArray()) { 1271 throw new NoSuchMethodException("no constructor for array class: " + refc.getName()); 1272 } 1273 if (type.returnType() != void.class) { 1274 throw new NoSuchMethodException("Constructors must have void return type: " + refc.getName()); 1275 } 1276 String name = "<init>"; 1277 MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type); 1278 return getDirectConstructor(refc, ctor); 1279 } 1280 1281 /** 1282 * Looks up a class by name from the lookup context defined by this {@code Lookup} object. The static 1283 * initializer of the class is not run. 1284 * <p> 1285 * The lookup context here is determined by the {@linkplain #lookupClass() lookup class}, its class 1286 * loader, and the {@linkplain #lookupModes() lookup modes}. In particular, the method first attempts to 1287 * load the requested class, and then determines whether the class is accessible to this lookup object. 1288 * 1289 * @param targetName the fully qualified name of the class to be looked up. 1290 * @return the requested class. 1291 * @exception SecurityException if a security manager is present and it 1292 * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a> 1293 * @throws LinkageError if the linkage fails 1294 * @throws ClassNotFoundException if the class cannot be loaded by the lookup class' loader. 1295 * @throws IllegalAccessException if the class is not accessible, using the allowed access |