8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.lang.reflect;
27
28 import sun.reflect.CallerSensitive;
29 import sun.reflect.ConstructorAccessor;
30 import sun.reflect.Reflection;
31 import sun.reflect.annotation.TypeAnnotation;
32 import sun.reflect.annotation.TypeAnnotationParser;
33 import sun.reflect.generics.repository.ConstructorRepository;
34 import sun.reflect.generics.factory.CoreReflectionFactory;
35 import sun.reflect.generics.factory.GenericsFactory;
36 import sun.reflect.generics.scope.ConstructorScope;
37 import java.lang.annotation.Annotation;
38 import java.lang.annotation.AnnotationFormatError;
39
40 /**
41 * {@code Constructor} provides information about, and access to, a single
42 * constructor for a class.
43 *
44 * <p>{@code Constructor} permits widening conversions to occur when matching the
45 * actual parameters to newInstance() with the underlying
46 * constructor's formal parameters, but throws an
47 * {@code IllegalArgumentException} if a narrowing conversion would occur.
565
566 if (enclosingClass == null) {
567 // A Constructor for a top-level class
568 return null;
569 }
570
571 Class<?> outerDeclaringClass = thisDeclClass.getDeclaringClass();
572 if (outerDeclaringClass == null) {
573 // A constructor for a local or anonymous class
574 return null;
575 }
576
577 // Either static nested or inner class
578 if (Modifier.isStatic(thisDeclClass.getModifiers())) {
579 // static nested
580 return null;
581 }
582
583 // A Constructor for an inner class
584 return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
585 sun.misc.SharedSecrets.getJavaLangAccess().
586 getConstantPool(thisDeclClass),
587 this,
588 thisDeclClass,
589 enclosingClass,
590 TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
591 }
592 }
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.lang.reflect;
27
28 import jdk.internal.misc.SharedSecrets;
29 import sun.reflect.CallerSensitive;
30 import sun.reflect.ConstructorAccessor;
31 import sun.reflect.Reflection;
32 import sun.reflect.annotation.TypeAnnotation;
33 import sun.reflect.annotation.TypeAnnotationParser;
34 import sun.reflect.generics.repository.ConstructorRepository;
35 import sun.reflect.generics.factory.CoreReflectionFactory;
36 import sun.reflect.generics.factory.GenericsFactory;
37 import sun.reflect.generics.scope.ConstructorScope;
38 import java.lang.annotation.Annotation;
39 import java.lang.annotation.AnnotationFormatError;
40
41 /**
42 * {@code Constructor} provides information about, and access to, a single
43 * constructor for a class.
44 *
45 * <p>{@code Constructor} permits widening conversions to occur when matching the
46 * actual parameters to newInstance() with the underlying
47 * constructor's formal parameters, but throws an
48 * {@code IllegalArgumentException} if a narrowing conversion would occur.
566
567 if (enclosingClass == null) {
568 // A Constructor for a top-level class
569 return null;
570 }
571
572 Class<?> outerDeclaringClass = thisDeclClass.getDeclaringClass();
573 if (outerDeclaringClass == null) {
574 // A constructor for a local or anonymous class
575 return null;
576 }
577
578 // Either static nested or inner class
579 if (Modifier.isStatic(thisDeclClass.getModifiers())) {
580 // static nested
581 return null;
582 }
583
584 // A Constructor for an inner class
585 return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
586 SharedSecrets.getJavaLangAccess().
587 getConstantPool(thisDeclClass),
588 this,
589 thisDeclClass,
590 enclosingClass,
591 TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
592 }
593 }
|