jdk/src/share/classes/java/lang/reflect/Method.java
author robm
Wed, 23 Jan 2013 17:54:34 +0000
changeset 15294 df55735ea03c
parent 14910 337380568515
child 15510 898d924a7efd
permissions -rw-r--r--
8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection Reviewed-by: darcy, forax, psandoz, dholmes, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
15294
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
     2
 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3959
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3959
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3959
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3959
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3959
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang.reflect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import sun.reflect.MethodAccessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import sun.reflect.Reflection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.reflect.generics.repository.MethodRepository;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.reflect.generics.factory.CoreReflectionFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.reflect.generics.factory.GenericsFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.reflect.generics.scope.MethodScope;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.reflect.annotation.AnnotationType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.reflect.annotation.AnnotationParser;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.lang.annotation.Annotation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.lang.annotation.AnnotationFormatError;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.nio.ByteBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * A {@code Method} provides information about, and access to, a single method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * on a class or interface.  The reflected method may be a class method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * or an instance method (including an abstract method).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>A {@code Method} permits widening conversions to occur when matching the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * actual parameters to invoke with the underlying method's formal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * parameters, but it throws an {@code IllegalArgumentException} if a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * narrowing conversion would occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @see Member
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @see java.lang.Class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @see java.lang.Class#getMethods()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @see java.lang.Class#getMethod(String, Class[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see java.lang.Class#getDeclaredMethods()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @see java.lang.Class#getDeclaredMethod(String, Class[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @author Kenneth Russell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @author Nakul Saraiya
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
    60
public final class Method extends Executable {
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
    61
    private Class<?>            clazz;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private int                 slot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    // This is guaranteed to be interned by the VM in the 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // reflection implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private String              name;
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
    66
    private Class<?>            returnType;
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
    67
    private Class<?>[]          parameterTypes;
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
    68
    private Class<?>[]          exceptionTypes;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private int                 modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    // Generics and annotations support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private transient String              signature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // generic info repository; lazily initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private transient MethodRepository genericInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private byte[]              annotations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private byte[]              parameterAnnotations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private byte[]              annotationDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private volatile MethodAccessor methodAccessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    // For sharing of MethodAccessors. This branching structure is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    // currently only two levels deep (i.e., one root Method and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    // potentially many Method objects pointing to it.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    private Method              root;
14905
ca1bf7f03ffb 8004699: Add type annotation storage to Constructor, Field and Method
darcy
parents: 14904
diff changeset
    82
    // This is set by the vm at Method creation
ca1bf7f03ffb 8004699: Add type annotation storage to Constructor, Field and Method
darcy
parents: 14904
diff changeset
    83
    private byte[]              typeAnnotations;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
    85
    // Generics infrastructure
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private String getGenericSignature() {return signature;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    // Accessor for factory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private GenericsFactory getFactory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        // create scope and factory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return CoreReflectionFactory.make(this, MethodScope.make(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    // Accessor for generic info repository
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
    95
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
    96
    MethodRepository getGenericInfo() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        // lazily initialize repository if necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        if (genericInfo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            // create and cache generic info repository
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            genericInfo = MethodRepository.make(getGenericSignature(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                                                getFactory());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        return genericInfo; //return cached repository
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Package-private constructor used by ReflectAccess to enable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * instantiation of these objects in Java code from the java.lang
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * package via sun.reflect.LangReflectAccess.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   111
    Method(Class<?> declaringClass,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
           String name,
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   113
           Class<?>[] parameterTypes,
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   114
           Class<?> returnType,
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   115
           Class<?>[] checkedExceptions,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
           int modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
           int slot,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
           String signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
           byte[] annotations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
           byte[] parameterAnnotations,
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   121
           byte[] annotationDefault) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        this.clazz = declaringClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        this.parameterTypes = parameterTypes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        this.returnType = returnType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        this.exceptionTypes = checkedExceptions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        this.modifiers = modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        this.slot = slot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        this.signature = signature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        this.annotations = annotations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        this.parameterAnnotations = parameterAnnotations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        this.annotationDefault = annotationDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Package-private routine (exposed to java.lang.Class via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * ReflectAccess) which returns a copy of this Method. The copy's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * "root" field points to this Method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    Method copy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        // This routine enables sharing of MethodAccessor objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        // among Method objects which refer to the same underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        // method in the VM. (All of this contortion is only necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        // because of the "accessibility" bit in AccessibleObject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        // which implicitly requires that new java.lang.reflect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        // objects be fabricated for each reflective call on Class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        // objects.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        Method res = new Method(clazz, name, parameterTypes, returnType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                                exceptionTypes, modifiers, slot, signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                                annotations, parameterAnnotations, annotationDefault);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        res.root = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        // Might as well eagerly propagate this if already present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        res.methodAccessor = methodAccessor;
14905
ca1bf7f03ffb 8004699: Add type annotation storage to Constructor, Field and Method
darcy
parents: 14904
diff changeset
   154
ca1bf7f03ffb 8004699: Add type annotation storage to Constructor, Field and Method
darcy
parents: 14904
diff changeset
   155
        res.typeAnnotations = typeAnnotations;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   159
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   160
    boolean hasGenericInformation() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   161
        return (getGenericSignature() != null);
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   162
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   163
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   164
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   165
    byte[] getAnnotationBytes() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   166
        return annotations;
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   167
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   168
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   170
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   172
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public Class<?> getDeclaringClass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        return clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Returns the name of the method represented by this {@code Method}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * object, as a {@code String}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   181
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   187
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   189
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public int getModifiers() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        return modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   195
     * {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   196
     * @throws GenericSignatureFormatError {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   199
    @Override
13795
73850c397272 7193406: Clean-up JDK Build Warnings in java.util, java.io
dxu
parents: 10342
diff changeset
   200
    @SuppressWarnings({"rawtypes", "unchecked"})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public TypeVariable<Method>[] getTypeParameters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        if (getGenericSignature() != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            return (TypeVariable<Method>[])getGenericInfo().getTypeParameters();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return (TypeVariable<Method>[])new TypeVariable[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Returns a {@code Class} object that represents the formal return type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * of the method represented by this {@code Method} object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @return the return type for the method this object represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public Class<?> getReturnType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return returnType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Returns a {@code Type} object that represents the formal return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * type of the method represented by this {@code Method} object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * <p>If the return type is a parameterized type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * the {@code Type} object returned must accurately reflect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * the actual type parameters used in the source code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * <p>If the return type is a type variable or a parameterized type, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * is created. Otherwise, it is resolved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @return  a {@code Type} object that represents the formal return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *     type of the underlying  method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @throws GenericSignatureFormatError
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *     if the generic method signature does not conform to the format
9266
121fb370f179 7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents: 9029
diff changeset
   233
     *     specified in
121fb370f179 7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents: 9029
diff changeset
   234
     *     <cite>The Java&trade; Virtual Machine Specification</cite>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @throws TypeNotPresentException if the underlying method's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *     return type refers to a non-existent type declaration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @throws MalformedParameterizedTypeException if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *     underlying method's return typed refers to a parameterized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *     type that cannot be instantiated for any reason
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public Type getGenericReturnType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      if (getGenericSignature() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return getGenericInfo().getReturnType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
      } else { return getReturnType();}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   249
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   251
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public Class<?>[] getParameterTypes() {
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 10127
diff changeset
   253
        return parameterTypes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   257
     * {@inheritDoc}
15294
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   258
     */
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   259
    public int getParameterCount() { return parameterTypes.length; }
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   260
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   261
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   262
    /**
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   263
     * {@inheritDoc}
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   264
     * @throws GenericSignatureFormatError {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   265
     * @throws TypeNotPresentException {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   266
     * @throws MalformedParameterizedTypeException {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   269
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public Type[] getGenericParameterTypes() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   271
        return super.getGenericParameterTypes();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   275
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   277
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    public Class<?>[] getExceptionTypes() {
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 10127
diff changeset
   279
        return exceptionTypes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   283
     * {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   284
     * @throws GenericSignatureFormatError {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   285
     * @throws TypeNotPresentException {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   286
     * @throws MalformedParameterizedTypeException {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   289
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   290
    public Type[] getGenericExceptionTypes() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   291
        return super.getGenericExceptionTypes();
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   292
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * Compares this {@code Method} against the specified object.  Returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * true if the objects are the same.  Two {@code Methods} are the same if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * they were declared by the same class and have the same name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * and formal parameter types and return type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        if (obj != null && obj instanceof Method) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            Method other = (Method)obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            if ((getDeclaringClass() == other.getDeclaringClass())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                && (getName() == other.getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                if (!returnType.equals(other.getReturnType()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                    return false;
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   307
                return equalParamTypes(parameterTypes, other.parameterTypes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * Returns a hashcode for this {@code Method}.  The hashcode is computed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * as the exclusive-or of the hashcodes for the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * method's declaring class name and the method's name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        return getDeclaringClass().getName().hashCode() ^ getName().hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * Returns a string describing this {@code Method}.  The string is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * formatted as the method access modifiers, if any, followed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * the method return type, followed by a space, followed by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * class declaring the method, followed by a period, followed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * the method name, followed by a parenthesized, comma-separated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * list of the method's formal parameter types. If the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * throws checked exceptions, the parameter list is followed by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * space, followed by the word throws followed by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * comma-separated list of the thrown exception types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * For example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *    public boolean java.lang.Object.equals(java.lang.Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * <p>The access modifiers are placed in canonical order as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * specified by "The Java Language Specification".  This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * {@code public}, {@code protected} or {@code private} first,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * and then other modifiers in the following order:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * {@code abstract}, {@code static}, {@code final},
3712
8851d55adef0 6261502: (reflect) Add the functionality to screen out the "inappropriate" modifier bits
darcy
parents: 2174
diff changeset
   342
     * {@code synchronized}, {@code native}, {@code strictfp}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    public String toString() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   345
        return sharedToString(Modifier.methodModifiers(),
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   346
                              parameterTypes,
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   347
                              exceptionTypes);
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   348
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   349
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   350
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   351
    void specificToStringHeader(StringBuilder sb) {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   352
        sb.append(Field.getTypeName(getReturnType())).append(' ');
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   353
        sb.append(Field.getTypeName(getDeclaringClass())).append('.');
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   354
        sb.append(getName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Returns a string describing this {@code Method}, including
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * type parameters.  The string is formatted as the method access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * modifiers, if any, followed by an angle-bracketed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * comma-separated list of the method's type parameters, if any,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * followed by the method's generic return type, followed by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * space, followed by the class declaring the method, followed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * a period, followed by the method name, followed by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * parenthesized, comma-separated list of the method's generic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * formal parameter types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * If this method was declared to take a variable number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * arguments, instead of denoting the last parameter as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * "<tt><i>Type</i>[]</tt>", it is denoted as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * "<tt><i>Type</i>...</tt>".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * A space is used to separate access modifiers from one another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * and from the type parameters or return type.  If there are no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * type parameters, the type parameter list is elided; if the type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * parameter list is present, a space separates the list from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * class name.  If the method is declared to throw exceptions, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * parameter list is followed by a space, followed by the word
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * throws followed by a comma-separated list of the generic thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * exception types.  If there are no type parameters, the type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * parameter list is elided.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * <p>The access modifiers are placed in canonical order as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * specified by "The Java Language Specification".  This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * {@code public}, {@code protected} or {@code private} first,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * and then other modifiers in the following order:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * {@code abstract}, {@code static}, {@code final},
3712
8851d55adef0 6261502: (reflect) Add the functionality to screen out the "inappropriate" modifier bits
darcy
parents: 2174
diff changeset
   388
     * {@code synchronized}, {@code native}, {@code strictfp}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @return a string describing this {@code Method},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * include type parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   395
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    public String toGenericString() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   397
        return sharedToGenericString(Modifier.methodModifiers());
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   398
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   400
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   401
    void specificToGenericStringHeader(StringBuilder sb) {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   402
        Type genRetType = getGenericReturnType();
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   403
        sb.append( ((genRetType instanceof Class<?>)?
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   404
                    Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   405
            .append(' ');
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   406
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   407
        sb.append(Field.getTypeName(getDeclaringClass())).append('.');
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   408
        sb.append(getName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * Invokes the underlying method represented by this {@code Method}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * object, on the specified object with the specified parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * Individual parameters are automatically unwrapped to match
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * primitive formal parameters, and both primitive and reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * parameters are subject to method invocation conversions as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * <p>If the underlying method is static, then the specified {@code obj}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * argument is ignored. It may be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * <p>If the number of formal parameters required by the underlying method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * 0, the supplied {@code args} array may be of length 0 or null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * <p>If the underlying method is an instance method, it is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * using dynamic method lookup as documented in The Java Language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * Specification, Second Edition, section 15.12.4.4; in particular,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * overriding based on the runtime type of the target object will occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * <p>If the underlying method is static, the class that declared
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * the method is initialized if it has not already been initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * <p>If the method completes normally, the value it returns is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * returned to the caller of invoke; if the value has a primitive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * type, it is first appropriately wrapped in an object. However,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * if the value has the type of an array of a primitive type, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * elements of the array are <i>not</i> wrapped in objects; in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * other words, an array of primitive type is returned.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * underlying method return type is void, the invocation returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @param obj  the object the underlying method is invoked from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @param args the arguments used for the method call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @return the result of dispatching the method represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * this object on {@code obj} with parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * {@code args}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @exception IllegalAccessException    if this {@code Method} object
9022
b2e8758b10fd 6543593: (reflect) Clarify private final field mutability
darcy
parents: 5506
diff changeset
   449
     *              is enforcing Java language access control and the underlying
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *              method is inaccessible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @exception IllegalArgumentException  if the method is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *              instance method and the specified object argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *              is not an instance of the class or interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *              declaring the underlying method (or of a subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *              or implementor thereof); if the number of actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     *              and formal parameters differ; if an unwrapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *              conversion for primitive arguments fails; or if,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     *              after possible unwrapping, a parameter value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     *              cannot be converted to the corresponding formal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *              parameter type by a method invocation conversion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @exception InvocationTargetException if the underlying method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *              throws an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * @exception NullPointerException      if the specified object is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *              and the method is an instance method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @exception ExceptionInInitializerError if the initialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * provoked by this method fails.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    public Object invoke(Object obj, Object... args)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        throws IllegalAccessException, IllegalArgumentException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
           InvocationTargetException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        if (!override) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   474
                Class<?> caller = Reflection.getCallerClass(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   476
                checkAccess(caller, clazz, obj, modifiers);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        }
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   479
        MethodAccessor ma = methodAccessor;             // read volatile
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   480
        if (ma == null) {
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   481
            ma = acquireMethodAccessor();
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   482
        }
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   483
        return ma.invoke(obj, args);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * Returns {@code true} if this method is a bridge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * method; returns {@code false} otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @return true if and only if this method is a bridge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * method as defined by the Java Language Specification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    public boolean isBridge() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        return (getModifiers() & Modifier.BRIDGE) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   499
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   502
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    public boolean isVarArgs() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   504
        return super.isVarArgs();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   508
     * {@inheritDoc}
14910
337380568515 8005097: Tie isSynthetic javadoc to the JLS
darcy
parents: 14905
diff changeset
   509
     * @jls 13.1 The Form of a Binary
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   512
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    public boolean isSynthetic() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   514
        return super.isSynthetic();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
14904
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   517
    /**
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   518
     * Returns {@code true} if this method is a default
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   519
     * method; returns {@code false} otherwise.
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   520
     *
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   521
     * A default method is a non-abstract method, that is, a method
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   522
     * with a body, declared in an interface type.
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   523
     *
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   524
     * @return true if and only if this method is a default
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   525
     * method as defined by the Java Language Specification.
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   526
     * @since 1.8
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   527
     */
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   528
    public boolean isDefault() {
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   529
        return (getModifiers() & Modifier.ABSTRACT) == 0 &&
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   530
            getDeclaringClass().isInterface();
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   531
    }
6d9721836463 8005042: Add Method.isDefault to core reflection
darcy
parents: 14342
diff changeset
   532
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    // NOTE that there is no synchronization used here. It is correct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    // (though not efficient) to generate more than one MethodAccessor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    // for a given Method. However, avoiding synchronization will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    // probably make the implementation more scalable.
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   537
    private MethodAccessor acquireMethodAccessor() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        // First check to see if one has been created yet, and take it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        // if so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        MethodAccessor tmp = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        if (root != null) tmp = root.getMethodAccessor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        if (tmp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            methodAccessor = tmp;
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   544
        } else {
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   545
            // Otherwise fabricate one and propagate it up to the root
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   546
            tmp = reflectionFactory.newMethodAccessor(this);
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   547
            setMethodAccessor(tmp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        }
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   549
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   550
        return tmp;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    // Returns MethodAccessor for this Method object, not looking up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    // the chain to the root
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    MethodAccessor getMethodAccessor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        return methodAccessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    // Sets the MethodAccessor for this Method object and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    // (recursively) its root
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    void setMethodAccessor(MethodAccessor accessor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        methodAccessor = accessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        // Propagate up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        if (root != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            root.setMethodAccessor(accessor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * Returns the default value for the annotation member represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * this {@code Method} instance.  If the member is of a primitive type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * an instance of the corresponding wrapper type is returned. Returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * null if no default is associated with the member, or if the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * instance does not represent a declared member of an annotation type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @return the default value for the annotation member represented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     *     by this {@code Method} instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * @throws TypeNotPresentException if the annotation is of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     *     {@link Class} and no definition can be found for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     *     default class value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * @since  1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    public Object getDefaultValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        if  (annotationDefault == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            return null;
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   586
        Class<?> memberType = AnnotationType.invocationHandlerReturnType(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            getReturnType());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        Object result = AnnotationParser.parseMemberValue(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            memberType, ByteBuffer.wrap(annotationDefault),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            sun.misc.SharedSecrets.getJavaLangAccess().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                getConstantPool(getDeclaringClass()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            getDeclaringClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        if (result instanceof sun.reflect.annotation.ExceptionProxy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            throw new AnnotationFormatError("Invalid default: " + this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   599
     * {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   600
     * @throws NullPointerException  {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   601
     * @since 1.5
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   602
     */
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   603
    public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   604
        return super.getAnnotation(annotationClass);
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   605
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   606
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   607
    /**
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   608
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   611
    public Annotation[] getDeclaredAnnotations()  {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   612
        return super.getDeclaredAnnotations();
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   613
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   615
    /**
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   616
     * {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   617
     * @since 1.5
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   618
     */
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   619
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   620
    public Annotation[][] getParameterAnnotations() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   621
        return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   622
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   623
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   624
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   625
    void handleParameterNumberMismatch(int resultLength, int numParameters) {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   626
        throw new AnnotationFormatError("Parameter annotations don't match number of parameters");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
}