Constructor.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:VarJ 作者:
/**
    * Returns an array of arrays that represent the annotations on the formal
    * parameters, in declaration order, of the method represented by
    * this <tt>Constructor</tt> object. (Returns an array of length zero if the
    * underlying method is parameterless.  If the method has one or more
    * parameters, a nested array of length zero is returned for each parameter
    * with no annotations.) The annotation objects contained in the returned
    * arrays are serializable.  The caller of this method is free to modify
    * the returned arrays; it will have no effect on the arrays returned to
    * other callers.
    *
    * @return an array of arrays that represent the annotations on the formal
    *    parameters, in declaration order, of the method represented by this
    *    Constructor object
    * @since 1.5
    */
   public Annotation[][] getParameterAnnotations() {
       int numParameters = parameterTypes.length;
       if (parameterAnnotations == null)
           return new Annotation[numParameters][0];

       Annotation[][] result = AnnotationParser.parseParameterAnnotations(
           parameterAnnotations,
           sun.misc.SharedSecrets.getJavaLangAccess().
               getConstantPool(getDeclaringClass()),
           getDeclaringClass());
       if (result.length != numParameters) {
    Class<?> declaringClass = getDeclaringClass();
    if (declaringClass.isEnum() || 
    declaringClass.isAnonymousClass() || 
    declaringClass.isLocalClass() )
    ; // Can't do reliable parameter counting
    else { 
    if (!declaringClass.isMemberClass() || // top-level 
        // Check for the enclosing instance parameter for
        // non-static member classes
        (declaringClass.isMemberClass() && 
         ((declaringClass.getModifiers() & Modifier.STATIC) == 0)  && 
         result.length + 1 != numParameters) ) {
        throw new AnnotationFormatError(
              "Parameter annotations don't match number of parameters");
    }
    }
}
       return result;
   }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号