1 /*
2 * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
488 sb.append(getDeclaringClass().getTypeName()).append('.');
489 sb.append(getName());
490 }
491
492 /**
493 * Invokes the underlying method represented by this {@code Method}
494 * object, on the specified object with the specified parameters.
495 * Individual parameters are automatically unwrapped to match
496 * primitive formal parameters, and both primitive and reference
497 * parameters are subject to method invocation conversions as
498 * necessary.
499 *
500 * <p>If the underlying method is static, then the specified {@code obj}
501 * argument is ignored. It may be null.
502 *
503 * <p>If the number of formal parameters required by the underlying method is
504 * 0, the supplied {@code args} array may be of length 0 or null.
505 *
506 * <p>If the underlying method is an instance method, it is invoked
507 * using dynamic method lookup as documented in The Java Language
508 * Specification, Second Edition, section 15.12.4.4; in particular,
509 * overriding based on the runtime type of the target object will occur.
510 *
511 * <p>If the underlying method is static, the class that declared
512 * the method is initialized if it has not already been initialized.
513 *
514 * <p>If the method completes normally, the value it returns is
515 * returned to the caller of invoke; if the value has a primitive
516 * type, it is first appropriately wrapped in an object. However,
517 * if the value has the type of an array of a primitive type, the
518 * elements of the array are <i>not</i> wrapped in objects; in
519 * other words, an array of primitive type is returned. If the
520 * underlying method return type is void, the invocation returns
521 * null.
522 *
523 * @param obj the object the underlying method is invoked from
524 * @param args the arguments used for the method call
525 * @return the result of dispatching the method represented by
526 * this object on {@code obj} with parameters
527 * {@code args}
528 *
529 * @exception IllegalAccessException if this {@code Method} object
|
1 /*
2 * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
488 sb.append(getDeclaringClass().getTypeName()).append('.');
489 sb.append(getName());
490 }
491
492 /**
493 * Invokes the underlying method represented by this {@code Method}
494 * object, on the specified object with the specified parameters.
495 * Individual parameters are automatically unwrapped to match
496 * primitive formal parameters, and both primitive and reference
497 * parameters are subject to method invocation conversions as
498 * necessary.
499 *
500 * <p>If the underlying method is static, then the specified {@code obj}
501 * argument is ignored. It may be null.
502 *
503 * <p>If the number of formal parameters required by the underlying method is
504 * 0, the supplied {@code args} array may be of length 0 or null.
505 *
506 * <p>If the underlying method is an instance method, it is invoked
507 * using dynamic method lookup as documented in The Java Language
508 * Specification, section 15.12.4.4; in particular,
509 * overriding based on the runtime type of the target object may occur.
510 *
511 * <p>If the underlying method is static, the class that declared
512 * the method is initialized if it has not already been initialized.
513 *
514 * <p>If the method completes normally, the value it returns is
515 * returned to the caller of invoke; if the value has a primitive
516 * type, it is first appropriately wrapped in an object. However,
517 * if the value has the type of an array of a primitive type, the
518 * elements of the array are <i>not</i> wrapped in objects; in
519 * other words, an array of primitive type is returned. If the
520 * underlying method return type is void, the invocation returns
521 * null.
522 *
523 * @param obj the object the underlying method is invoked from
524 * @param args the arguments used for the method call
525 * @return the result of dispatching the method represented by
526 * this object on {@code obj} with parameters
527 * {@code args}
528 *
529 * @exception IllegalAccessException if this {@code Method} object
|