src/share/classes/java/lang/reflect/Method.java

Print this page


   1 /*
   2  * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   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


 148         Method res = new Method(clazz, name, parameterTypes, returnType,
 149                                 exceptionTypes, modifiers, slot, signature,
 150                                 annotations, parameterAnnotations, annotationDefault);
 151         res.root = this;
 152         // Might as well eagerly propagate this if already present
 153         res.methodAccessor = methodAccessor;
 154 
 155         res.typeAnnotations = typeAnnotations;
 156         return res;
 157     }
 158 
 159     @Override
 160     boolean hasGenericInformation() {
 161         return (getGenericSignature() != null);
 162     }
 163 
 164     @Override
 165     byte[] getAnnotationBytes() {
 166         return annotations;
 167     }




 168 
 169     /**
 170      * {@inheritDoc}
 171      */
 172     @Override
 173     public Class<?> getDeclaringClass() {
 174         return clazz;
 175     }
 176 
 177     /**
 178      * Returns the name of the method represented by this {@code Method}
 179      * object, as a {@code String}.
 180      */
 181     @Override
 182     public String getName() {
 183         return name;
 184     }
 185 
 186     /**
 187      * {@inheritDoc}


 602      * {@inheritDoc}
 603      * @since 1.5
 604      */
 605     public Annotation[] getDeclaredAnnotations()  {
 606         return super.getDeclaredAnnotations();
 607     }
 608 
 609     /**
 610      * {@inheritDoc}
 611      * @since 1.5
 612      */
 613     @Override
 614     public Annotation[][] getParameterAnnotations() {
 615         return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
 616     }
 617 
 618     @Override
 619     void handleParameterNumberMismatch(int resultLength, int numParameters) {
 620         throw new AnnotationFormatError("Parameter annotations don't match number of parameters");
 621     }




 622 }
   1 /*
   2  * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   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


 148         Method res = new Method(clazz, name, parameterTypes, returnType,
 149                                 exceptionTypes, modifiers, slot, signature,
 150                                 annotations, parameterAnnotations, annotationDefault);
 151         res.root = this;
 152         // Might as well eagerly propagate this if already present
 153         res.methodAccessor = methodAccessor;
 154 
 155         res.typeAnnotations = typeAnnotations;
 156         return res;
 157     }
 158 
 159     @Override
 160     boolean hasGenericInformation() {
 161         return (getGenericSignature() != null);
 162     }
 163 
 164     @Override
 165     byte[] getAnnotationBytes() {
 166         return annotations;
 167     }
 168     @Override
 169     byte[] getTypeAnnotationBytes() {
 170         return typeAnnotations;
 171     }
 172 
 173     /**
 174      * {@inheritDoc}
 175      */
 176     @Override
 177     public Class<?> getDeclaringClass() {
 178         return clazz;
 179     }
 180 
 181     /**
 182      * Returns the name of the method represented by this {@code Method}
 183      * object, as a {@code String}.
 184      */
 185     @Override
 186     public String getName() {
 187         return name;
 188     }
 189 
 190     /**
 191      * {@inheritDoc}


 606      * {@inheritDoc}
 607      * @since 1.5
 608      */
 609     public Annotation[] getDeclaredAnnotations()  {
 610         return super.getDeclaredAnnotations();
 611     }
 612 
 613     /**
 614      * {@inheritDoc}
 615      * @since 1.5
 616      */
 617     @Override
 618     public Annotation[][] getParameterAnnotations() {
 619         return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
 620     }
 621 
 622     @Override
 623     void handleParameterNumberMismatch(int resultLength, int numParameters) {
 624         throw new AnnotationFormatError("Parameter annotations don't match number of parameters");
 625     }
 626 
 627     public AnnotatedType getAnnotatedReturnType() {
 628         return getAnnotatedReturnType0(getGenericReturnType());
 629 }
 630 }