jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java
changeset 45332 9c9e51c44638
parent 44369 b5c4e28a7521
child 45434 4582657c7260
equal deleted inserted replaced
45331:f829a12aff54 45332:9c9e51c44638
     1 /*
     1 /*
     2  * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   586     public Annotation[][] getParameterAnnotations() {
   586     public Annotation[][] getParameterAnnotations() {
   587         return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
   587         return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
   588     }
   588     }
   589 
   589 
   590     @Override
   590     @Override
   591     void handleParameterNumberMismatch(int resultLength, int numParameters) {
   591     boolean handleParameterNumberMismatch(int resultLength, int numParameters) {
   592         Class<?> declaringClass = getDeclaringClass();
   592         Class<?> declaringClass = getDeclaringClass();
   593         if (declaringClass.isEnum() ||
   593         if (declaringClass.isEnum() ||
   594             declaringClass.isAnonymousClass() ||
   594             declaringClass.isAnonymousClass() ||
   595             declaringClass.isLocalClass() )
   595             declaringClass.isLocalClass() )
   596             return ; // Can't do reliable parameter counting
   596             return false; // Can't do reliable parameter counting
   597         else {
   597         else {
   598             if (!declaringClass.isMemberClass() || // top-level
   598             if (declaringClass.isMemberClass() &&
   599                 // Check for the enclosing instance parameter for
   599                 ((declaringClass.getModifiers() & Modifier.STATIC) == 0)  &&
   600                 // non-static member classes
   600                 resultLength + 1 == numParameters) {
   601                 (declaringClass.isMemberClass() &&
   601                 return true;
   602                  ((declaringClass.getModifiers() & Modifier.STATIC) == 0)  &&
   602             } else {
   603                  resultLength + 1 != numParameters) ) {
       
   604                 throw new AnnotationFormatError(
   603                 throw new AnnotationFormatError(
   605                           "Parameter annotations don't match number of parameters");
   604                           "Parameter annotations don't match number of parameters");
   606             }
   605             }
   607         }
   606         }
   608     }
   607     }