jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java
author chegar
Mon, 28 Sep 2015 13:39:27 +0100
changeset 32834 e1dca5fe4de3
parent 32033 bf24e33c7919
child 36511 9d0388c6b336
permissions -rw-r--r--
8137056: Move SharedSecrets and interface friends out of sun.misc Reviewed-by: alanb, mchung, psandoz, rriggs
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
32834
e1dca5fe4de3 8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents: 32033
diff changeset
    28
import jdk.internal.misc.SharedSecrets;
16906
44dfee24cb71 8010117: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
mchung
parents: 16743
diff changeset
    29
import sun.reflect.CallerSensitive;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.reflect.ConstructorAccessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import sun.reflect.Reflection;
21361
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
    32
import sun.reflect.annotation.TypeAnnotation;
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
    33
import sun.reflect.annotation.TypeAnnotationParser;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.reflect.generics.repository.ConstructorRepository;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.reflect.generics.factory.CoreReflectionFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.reflect.generics.factory.GenericsFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.reflect.generics.scope.ConstructorScope;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.lang.annotation.Annotation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.lang.annotation.AnnotationFormatError;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * {@code Constructor} provides information about, and access to, a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * constructor for a class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>{@code Constructor} permits widening conversions to occur when matching the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * actual parameters to newInstance() with the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * constructor's formal parameters, but throws an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * {@code IllegalArgumentException} if a narrowing conversion would occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @param <T> the class in which the constructor is declared
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @see Member
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @see java.lang.Class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see java.lang.Class#getConstructors()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @see java.lang.Class#getConstructor(Class[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @see java.lang.Class#getDeclaredConstructors()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @author      Kenneth Russell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @author      Nakul Saraiya
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
    61
public final class Constructor<T> extends Executable {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private Class<T>            clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private int                 slot;
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
    64
    private Class<?>[]          parameterTypes;
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
    65
    private Class<?>[]          exceptionTypes;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private int                 modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    // Generics and annotations support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private transient String    signature;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // generic info repository; lazily initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private transient ConstructorRepository genericInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private byte[]              annotations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private byte[]              parameterAnnotations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    // Generics infrastructure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    // Accessor for factory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private GenericsFactory getFactory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        // create scope and factory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        return CoreReflectionFactory.make(this, ConstructorScope.make(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    // Accessor for generic info repository
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
    82
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
    83
    ConstructorRepository getGenericInfo() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        // lazily initialize repository if necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        if (genericInfo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            // create and cache generic info repository
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            genericInfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                ConstructorRepository.make(getSignature(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                           getFactory());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return genericInfo; //return cached repository
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private volatile ConstructorAccessor constructorAccessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    // For sharing of ConstructorAccessors. This branching structure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    // is currently only two levels deep (i.e., one root Constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    // and potentially many Constructor objects pointing to it.)
26455
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
    98
    //
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
    99
    // If this branching structure would ever contain cycles, deadlocks can
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   100
    // occur in annotation code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private Constructor<T>      root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
26455
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   104
     * Used by Excecutable for annotation sharing.
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   105
     */
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   106
    @Override
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   107
    Executable getRoot() {
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   108
        return root;
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   109
    }
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   110
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   111
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Package-private constructor used by ReflectAccess to enable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * instantiation of these objects in Java code from the java.lang
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * package via sun.reflect.LangReflectAccess.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    Constructor(Class<T> declaringClass,
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   117
                Class<?>[] parameterTypes,
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   118
                Class<?>[] checkedExceptions,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                int modifiers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                int slot,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                String signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                byte[] annotations,
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   123
                byte[] parameterAnnotations) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        this.clazz = declaringClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        this.parameterTypes = parameterTypes;
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
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Package-private routine (exposed to java.lang.Class via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * ReflectAccess) which returns a copy of this Constructor. The copy's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * "root" field points to this Constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    Constructor<T> copy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // This routine enables sharing of ConstructorAccessor objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        // among Constructor objects which refer to the same underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        // method in the VM. (All of this contortion is only necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        // because of the "accessibility" bit in AccessibleObject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        // which implicitly requires that new java.lang.reflect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        // objects be fabricated for each reflective call on Class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        // objects.)
26455
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   147
        if (this.root != null)
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   148
            throw new IllegalArgumentException("Can not copy a non-root Constructor");
195a6f3e0cd0 8054987: (reflect) Add sharing of annotations between instances of Executable
jfranck
parents: 25991
diff changeset
   149
7803
56bc97d69d93 6880112: Project Coin: Port JDK core library code to use diamond operator
smarks
parents: 6534
diff changeset
   150
        Constructor<T> res = new Constructor<>(clazz,
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   151
                                               parameterTypes,
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   152
                                               exceptionTypes, modifiers, slot,
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   153
                                               signature,
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   154
                                               annotations,
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   155
                                               parameterAnnotations);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        res.root = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        // Might as well eagerly propagate this if already present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        res.constructorAccessor = constructorAccessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   162
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   163
    boolean hasGenericInformation() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   164
        return (getSignature() != null);
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   165
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   166
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   167
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   168
    byte[] getAnnotationBytes() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   169
        return annotations;
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   170
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   171
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   173
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   175
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public Class<T> getDeclaringClass() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        return clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Returns the name of this constructor, as a string.  This is
6534
ad71f5af4022 6294399: (reflect) Constructor.getName() returns fully qualified name of declaring class
darcy
parents: 5506
diff changeset
   182
     * the binary name of the constructor's declaring class.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   184
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return getDeclaringClass().getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   190
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   192
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public int getModifiers() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   198
     * {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   199
     * @throws GenericSignatureFormatError {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   202
    @Override
13795
73850c397272 7193406: Clean-up JDK Build Warnings in java.util, java.io
dxu
parents: 10342
diff changeset
   203
    @SuppressWarnings({"rawtypes", "unchecked"})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public TypeVariable<Constructor<T>>[] getTypeParameters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
      if (getSignature() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return (TypeVariable<Constructor<T>>[])getGenericInfo().getTypeParameters();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
      } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
          return (TypeVariable<Constructor<T>>[])new TypeVariable[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   213
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   215
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public Class<?>[] getParameterTypes() {
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 10127
diff changeset
   217
        return parameterTypes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   220
    /**
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   221
     * {@inheritDoc}
22083
1ac4a52255f4 8030785: Missing "since 1.8" javadoc for java.lang.reflect.Method:getParameterCount
darcy
parents: 21361
diff changeset
   222
     * @since 1.8
15294
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   223
     */
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   224
    public int getParameterCount() { return parameterTypes.length; }
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   225
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   226
    /**
df55735ea03c 8004729: Add java.lang.reflect.Parameter and related changes for parameter reflection
robm
parents: 14910
diff changeset
   227
     * {@inheritDoc}
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   228
     * @throws GenericSignatureFormatError {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   229
     * @throws TypeNotPresentException {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   230
     * @throws MalformedParameterizedTypeException {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   231
     * @since 1.5
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   232
     */
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   233
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   234
    public Type[] getGenericParameterTypes() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   235
        return super.getGenericParameterTypes();
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   236
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   239
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   241
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public Class<?>[] getExceptionTypes() {
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 10127
diff changeset
   243
        return exceptionTypes.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   248
     * {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   249
     * @throws GenericSignatureFormatError {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   250
     * @throws TypeNotPresentException {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   251
     * @throws MalformedParameterizedTypeException {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   254
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   255
    public Type[] getGenericExceptionTypes() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   256
        return super.getGenericExceptionTypes();
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   257
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Compares this {@code Constructor} against the specified object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * Returns true if the objects are the same.  Two {@code Constructor} objects are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * the same if they were declared by the same class and have the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * same formal parameter types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        if (obj != null && obj instanceof Constructor) {
3959
05a07c0a273b 5062288: (reflect) Core reflection uses raw types when it could be using wildcards
darcy
parents: 3941
diff changeset
   267
            Constructor<?> other = (Constructor<?>)obj;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            if (getDeclaringClass() == other.getDeclaringClass()) {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   269
                return equalParamTypes(parameterTypes, other.parameterTypes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * Returns a hashcode for this {@code Constructor}. The hashcode is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * the same as the hashcode for the underlying constructor's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * declaring class name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        return getDeclaringClass().getName().hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * Returns a string describing this {@code Constructor}.  The string is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * formatted as the constructor access modifiers, if any,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * followed by the fully-qualified name of the declaring class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * followed by a parenthesized, comma-separated list of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * constructor's formal parameter types.  For example:
32033
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 29125
diff changeset
   290
     * <pre>{@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *    public java.util.Hashtable(int,float)
32033
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 29125
diff changeset
   292
     * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * <p>The only possible modifiers for constructors are the access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * modifiers {@code public}, {@code protected} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * {@code private}.  Only one of these may appear, or none if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * constructor has default (package) access.
16729
3b26e313ad81 8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents: 16058
diff changeset
   298
     *
3b26e313ad81 8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents: 16058
diff changeset
   299
     * @return a string describing this {@code Constructor}
29125
83b9bf8a6c2a 8073952: Spec of j.l.r.Method.toString/toGenericString need to be clarified
darcy
parents: 26455
diff changeset
   300
     * @jls 8.8.3 Constructor Modifiers
83b9bf8a6c2a 8073952: Spec of j.l.r.Method.toString/toGenericString need to be clarified
darcy
parents: 26455
diff changeset
   301
     * @jls 8.9.2 Enum Body Declarations
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    public String toString() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   304
        return sharedToString(Modifier.constructorModifiers(),
16729
3b26e313ad81 8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents: 16058
diff changeset
   305
                              false,
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   306
                              parameterTypes,
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   307
                              exceptionTypes);
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   308
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   309
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   310
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   311
    void specificToStringHeader(StringBuilder sb) {
16743
b0b34102bb4c 6298888: Add toGenericString to j.l.Class and getTypeName to j.l.reflect.Type
darcy
parents: 16729
diff changeset
   312
        sb.append(getDeclaringClass().getTypeName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Returns a string describing this {@code Constructor},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * including type parameters.  The string is formatted as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * constructor access modifiers, if any, followed by an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * angle-bracketed comma separated list of the constructor's type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * parameters, if any, followed by the fully-qualified name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * declaring class, followed by a parenthesized, comma-separated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * list of the constructor's generic formal parameter types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * If this constructor was declared to take a variable number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * arguments, instead of denoting the last parameter as
32033
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 29125
diff changeset
   326
     * "<code><i>Type</i>[]</code>", it is denoted as
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 29125
diff changeset
   327
     * "<code><i>Type</i>...</code>".
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * A space is used to separate access modifiers from one another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * and from the type parameters or return type.  If there are no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * type parameters, the type parameter list is elided; if the type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * parameter list is present, a space separates the list from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * class name.  If the constructor is declared to throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * exceptions, the parameter list is followed by a space, followed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * by the word "{@code throws}" followed by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * comma-separated list of the thrown exception types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * <p>The only possible modifiers for constructors are the access
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * modifiers {@code public}, {@code protected} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * {@code private}.  Only one of these may appear, or none if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * constructor has default (package) access.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @return a string describing this {@code Constructor},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * include type parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @since 1.5
29125
83b9bf8a6c2a 8073952: Spec of j.l.r.Method.toString/toGenericString need to be clarified
darcy
parents: 26455
diff changeset
   347
     * @jls 8.8.3 Constructor Modifiers
83b9bf8a6c2a 8073952: Spec of j.l.r.Method.toString/toGenericString need to be clarified
darcy
parents: 26455
diff changeset
   348
     * @jls 8.9.2 Enum Body Declarations
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   350
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    public String toGenericString() {
16729
3b26e313ad81 8004979: java.lang.reflect.Modifier.toString should include "default"
darcy
parents: 16058
diff changeset
   352
        return sharedToGenericString(Modifier.constructorModifiers(), false);
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   353
    }
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   354
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   355
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   356
    void specificToGenericStringHeader(StringBuilder sb) {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   357
        specificToStringHeader(sb);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * Uses the constructor represented by this {@code Constructor} object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * create and initialize a new instance of the constructor's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * declaring class, with the specified initialization parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Individual parameters are automatically unwrapped to match
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * primitive formal parameters, and both primitive and reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * parameters are subject to method invocation conversions as necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * <p>If the number of formal parameters required by the underlying constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * is 0, the supplied {@code initargs} array may be of length 0 or null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * <p>If the constructor's declaring class is an inner class in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * non-static context, the first argument to the constructor needs
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
   373
     * to be the enclosing instance; see section 15.9.3 of
121fb370f179 7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents: 9029
diff changeset
   374
     * <cite>The Java&trade; Language Specification</cite>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * <p>If the required access and argument checks succeed and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * instantiation will proceed, the constructor's declaring class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * is initialized if it has not already been initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * <p>If the constructor completes normally, returns the newly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * created and initialized instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * @param initargs array of objects to be passed as arguments to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * the constructor call; values of primitive types are wrapped in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * a wrapper object of the appropriate type (e.g. a {@code float}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * in a {@link java.lang.Float Float})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * @return a new object created by calling the constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * this object represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @exception IllegalAccessException    if this {@code Constructor} object
9022
b2e8758b10fd 6543593: (reflect) Clarify private final field mutability
darcy
parents: 7816
diff changeset
   392
     *              is enforcing Java language access control and the underlying
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *              constructor is inaccessible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @exception IllegalArgumentException  if the number of actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *              and formal parameters differ; if an unwrapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *              conversion for primitive arguments fails; or if,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *              after possible unwrapping, a parameter value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *              cannot be converted to the corresponding formal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *              parameter type by a method invocation conversion; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     *              this constructor pertains to an enum type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @exception InstantiationException    if the class that declares the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     *              underlying constructor represents an abstract class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @exception InvocationTargetException if the underlying constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *              throws an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @exception ExceptionInInitializerError if the initialization provoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     *              by this method fails.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     */
16906
44dfee24cb71 8010117: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
mchung
parents: 16743
diff changeset
   408
    @CallerSensitive
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    public T newInstance(Object ... initargs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        throws InstantiationException, IllegalAccessException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
               IllegalArgumentException, InvocationTargetException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        if (!override) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
16906
44dfee24cb71 8010117: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
mchung
parents: 16743
diff changeset
   415
                Class<?> caller = Reflection.getCallerClass();
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   416
                checkAccess(caller, clazz, null, modifiers);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        if ((clazz.getModifiers() & Modifier.ENUM) != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            throw new IllegalArgumentException("Cannot reflectively create enum objects");
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   421
        ConstructorAccessor ca = constructorAccessor;   // read volatile
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   422
        if (ca == null) {
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   423
            ca = acquireConstructorAccessor();
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   424
        }
10342
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 10127
diff changeset
   425
        @SuppressWarnings("unchecked")
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 10127
diff changeset
   426
        T inst = (T) ca.newInstance(initargs);
ca0984bc9d32 7077389: Reflection classes do not build with javac -Xlint:all -Werror
jjg
parents: 10127
diff changeset
   427
        return inst;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   431
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   434
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    public boolean isVarArgs() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   436
        return super.isVarArgs();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   440
     * {@inheritDoc}
14910
337380568515 8005097: Tie isSynthetic javadoc to the JLS
darcy
parents: 14905
diff changeset
   441
     * @jls 13.1 The Form of a Binary
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   444
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    public boolean isSynthetic() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   446
        return super.isSynthetic();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    // NOTE that there is no synchronization used here. It is correct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    // (though not efficient) to generate more than one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    // ConstructorAccessor for a given Constructor. However, avoiding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    // synchronization will probably make the implementation more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    // scalable.
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   454
    private ConstructorAccessor acquireConstructorAccessor() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        // First check to see if one has been created yet, and take it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        // if so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        ConstructorAccessor tmp = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        if (root != null) tmp = root.getConstructorAccessor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        if (tmp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            constructorAccessor = tmp;
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   461
        } else {
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   462
            // 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
   463
            tmp = reflectionFactory.newConstructorAccessor(this);
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   464
            setConstructorAccessor(tmp);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        }
9029
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   466
e92fcf58f684 6565585: Remove critical section in Method.invoke, Constructor.newInstance, Field.getFieldAccessor improving performance
mduigou
parents: 9022
diff changeset
   467
        return tmp;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    // Returns ConstructorAccessor for this Constructor object, not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    // looking up the chain to the root
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    ConstructorAccessor getConstructorAccessor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        return constructorAccessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    // Sets the ConstructorAccessor for this Constructor object and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    // (recursively) its root
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    void setConstructorAccessor(ConstructorAccessor accessor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        constructorAccessor = accessor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        // Propagate up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        if (root != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            root.setConstructorAccessor(accessor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    int getSlot() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        return slot;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   490
    String getSignature() {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   491
        return signature;
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   492
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    byte[] getRawAnnotations() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        return annotations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    byte[] getRawParameterAnnotations() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        return parameterAnnotations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   502
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   504
     * {@inheritDoc}
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   505
     * @throws NullPointerException  {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   509
        return super.getAnnotation(annotationClass);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   513
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    public Annotation[] getDeclaredAnnotations()  {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   517
        return super.getDeclaredAnnotations();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /**
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   521
     * {@inheritDoc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     */
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   524
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    public Annotation[][] getParameterAnnotations() {
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   526
        return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   527
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
10127
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   529
    @Override
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   530
    void handleParameterNumberMismatch(int resultLength, int numParameters) {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   531
        Class<?> declaringClass = getDeclaringClass();
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   532
        if (declaringClass.isEnum() ||
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   533
            declaringClass.isAnonymousClass() ||
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   534
            declaringClass.isLocalClass() )
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   535
            return ; // Can't do reliable parameter counting
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   536
        else {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   537
            if (!declaringClass.isMemberClass() || // top-level
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   538
                // Check for the enclosing instance parameter for
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   539
                // non-static member classes
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   540
                (declaringClass.isMemberClass() &&
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   541
                 ((declaringClass.getModifiers() & Modifier.STATIC) == 0)  &&
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   542
                 resultLength + 1 != numParameters) ) {
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   543
                throw new AnnotationFormatError(
c85d1ec57ee7 7007535: (reflect) Please generalize Constructor and Method
darcy
parents: 9266
diff changeset
   544
                          "Parameter annotations don't match number of parameters");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    }
15510
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 15294
diff changeset
   548
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 15294
diff changeset
   549
    /**
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 15294
diff changeset
   550
     * {@inheritDoc}
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 15294
diff changeset
   551
     * @since 1.8
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 15294
diff changeset
   552
     */
16058
5b8d8cec6280 8007808: Missing method: Executable.getAnnotatedReturnType()
jfranck
parents: 15510
diff changeset
   553
    @Override
15510
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 15294
diff changeset
   554
    public AnnotatedType getAnnotatedReturnType() {
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 15294
diff changeset
   555
        return getAnnotatedReturnType0(getDeclaringClass());
898d924a7efd 8004698: Implement Core Reflection for Type Annotations
jfranck
parents: 15294
diff changeset
   556
    }
21361
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   557
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   558
    /**
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   559
     * {@inheritDoc}
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   560
     * @since 1.8
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   561
     */
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   562
    @Override
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   563
    public AnnotatedType getAnnotatedReceiverType() {
25982
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   564
        Class<?> thisDeclClass = getDeclaringClass();
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   565
        Class<?> enclosingClass = thisDeclClass.getEnclosingClass();
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   566
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   567
        if (enclosingClass == null) {
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   568
            // A Constructor for a top-level class
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   569
            return null;
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   570
        }
21361
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   571
25982
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   572
        Class<?> outerDeclaringClass = thisDeclClass.getDeclaringClass();
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   573
        if (outerDeclaringClass == null) {
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   574
            // A constructor for a local or anonymous class
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   575
            return null;
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   576
        }
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   577
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   578
        // Either static nested or inner class
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   579
        if (Modifier.isStatic(thisDeclClass.getModifiers())) {
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   580
            // static nested
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   581
            return null;
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   582
        }
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   583
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   584
        // A Constructor for an inner class
21361
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   585
        return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
32834
e1dca5fe4de3 8137056: Move SharedSecrets and interface friends out of sun.misc
chegar
parents: 32033
diff changeset
   586
                SharedSecrets.getJavaLangAccess().
25982
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   587
                    getConstantPool(thisDeclClass),
21361
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   588
                this,
25982
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   589
                thisDeclClass,
724303cf59ba 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
jfranck
parents: 22083
diff changeset
   590
                enclosingClass,
21361
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   591
                TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
6e4ef4e0097f 8023651: j.l.r.Constructor.getAnnotatedReceiverType() and j.l.r.Constructor.getAnnotatedReturnType() for inner classes return incorrect result
jfranck
parents: 20482
diff changeset
   592
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
}