emul/src/main/java/java/lang/reflect/Method.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 07 Jan 2013 18:27:01 +0100
changeset 413 c91483c86597
parent 392 44a5802816be
child 416 b2464b3fd015
permissions -rw-r--r--
@Compare method can throw exceptions
     1 /*
     2  * Copyright (c) 1996, 2006, 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
    23  * questions.
    24  */
    25 
    26 package java.lang.reflect;
    27 
    28 import java.lang.annotation.Annotation;
    29 import org.apidesign.bck2brwsr.core.JavaScriptBody;
    30 import org.apidesign.bck2brwsr.emul.AnnotationImpl;
    31 import org.apidesign.bck2brwsr.emul.MethodImpl;
    32 
    33 /**
    34  * A {@code Method} provides information about, and access to, a single method
    35  * on a class or interface.  The reflected method may be a class method
    36  * or an instance method (including an abstract method).
    37  *
    38  * <p>A {@code Method} permits widening conversions to occur when matching the
    39  * actual parameters to invoke with the underlying method's formal
    40  * parameters, but it throws an {@code IllegalArgumentException} if a
    41  * narrowing conversion would occur.
    42  *
    43  * @see Member
    44  * @see java.lang.Class
    45  * @see java.lang.Class#getMethods()
    46  * @see java.lang.Class#getMethod(String, Class[])
    47  * @see java.lang.Class#getDeclaredMethods()
    48  * @see java.lang.Class#getDeclaredMethod(String, Class[])
    49  *
    50  * @author Kenneth Russell
    51  * @author Nakul Saraiya
    52  */
    53 public final
    54     class Method extends AccessibleObject implements GenericDeclaration,
    55                                                      Member {
    56     private final Class<?> clazz;
    57     private final String name;
    58     private final Object data;
    59     private final String sig;
    60 
    61    // Generics infrastructure
    62 
    63     private String getGenericSignature() {return null;}
    64 
    65     /**
    66      * Package-private constructor used by ReflectAccess to enable
    67      * instantiation of these objects in Java code from the java.lang
    68      * package via sun.reflect.LangReflectAccess.
    69      */
    70     Method(Class<?> declaringClass, String name, Object data, String sig)
    71     {
    72         this.clazz = declaringClass;
    73         this.name = name;
    74         this.data = data;
    75         this.sig = sig;
    76     }
    77 
    78     /**
    79      * Package-private routine (exposed to java.lang.Class via
    80      * ReflectAccess) which returns a copy of this Method. The copy's
    81      * "root" field points to this Method.
    82      */
    83     Method copy() {
    84         return this;
    85     }
    86 
    87     /**
    88      * Returns the {@code Class} object representing the class or interface
    89      * that declares the method represented by this {@code Method} object.
    90      */
    91     public Class<?> getDeclaringClass() {
    92         return clazz;
    93     }
    94 
    95     /**
    96      * Returns the name of the method represented by this {@code Method}
    97      * object, as a {@code String}.
    98      */
    99     public String getName() {
   100         return name;
   101     }
   102 
   103     /**
   104      * Returns the Java language modifiers for the method represented
   105      * by this {@code Method} object, as an integer. The {@code Modifier} class should
   106      * be used to decode the modifiers.
   107      *
   108      * @see Modifier
   109      */
   110     public int getModifiers() {
   111         return getAccess(data);
   112     }
   113     
   114     @JavaScriptBody(args = "self", body = "return self.access;")
   115     private static native int getAccess(Object self);
   116     
   117     /**
   118      * Returns an array of {@code TypeVariable} objects that represent the
   119      * type variables declared by the generic declaration represented by this
   120      * {@code GenericDeclaration} object, in declaration order.  Returns an
   121      * array of length 0 if the underlying generic declaration declares no type
   122      * variables.
   123      *
   124      * @return an array of {@code TypeVariable} objects that represent
   125      *     the type variables declared by this generic declaration
   126      * @throws GenericSignatureFormatError if the generic
   127      *     signature of this generic declaration does not conform to
   128      *     the format specified in
   129      *     <cite>The Java&trade; Virtual Machine Specification</cite>
   130      * @since 1.5
   131      */
   132     public TypeVariable<Method>[] getTypeParameters() {
   133         throw new UnsupportedOperationException();
   134     }
   135 
   136     /**
   137      * Returns a {@code Class} object that represents the formal return type
   138      * of the method represented by this {@code Method} object.
   139      *
   140      * @return the return type for the method this object represents
   141      */
   142     public Class<?> getReturnType() {
   143         switch (sig.charAt(0)) {
   144             case 'I': return Integer.TYPE;
   145             case 'J': return Long.TYPE;
   146             case 'D': return Double.TYPE;
   147             case 'F': return Float.TYPE;
   148             case 'B': return Byte.TYPE;
   149             case 'Z': return Boolean.TYPE;
   150             case 'S': return Short.TYPE;
   151 //            case 'V': return Void.TYPE;
   152             case 'L': try {
   153                 int up = sig.indexOf("_2");
   154                 String type = sig.substring(1, up);
   155                 return Class.forName(type);
   156             } catch (ClassNotFoundException ex) {
   157                 // should not happen
   158             }
   159         }
   160         throw new UnsupportedOperationException(sig);
   161     }
   162 
   163     /**
   164      * Returns a {@code Type} object that represents the formal return
   165      * type of the method represented by this {@code Method} object.
   166      *
   167      * <p>If the return type is a parameterized type,
   168      * the {@code Type} object returned must accurately reflect
   169      * the actual type parameters used in the source code.
   170      *
   171      * <p>If the return type is a type variable or a parameterized type, it
   172      * is created. Otherwise, it is resolved.
   173      *
   174      * @return  a {@code Type} object that represents the formal return
   175      *     type of the underlying  method
   176      * @throws GenericSignatureFormatError
   177      *     if the generic method signature does not conform to the format
   178      *     specified in
   179      *     <cite>The Java&trade; Virtual Machine Specification</cite>
   180      * @throws TypeNotPresentException if the underlying method's
   181      *     return type refers to a non-existent type declaration
   182      * @throws MalformedParameterizedTypeException if the
   183      *     underlying method's return typed refers to a parameterized
   184      *     type that cannot be instantiated for any reason
   185      * @since 1.5
   186      */
   187     public Type getGenericReturnType() {
   188         throw new UnsupportedOperationException();
   189     }
   190 
   191 
   192     /**
   193      * Returns an array of {@code Class} objects that represent the formal
   194      * parameter types, in declaration order, of the method
   195      * represented by this {@code Method} object.  Returns an array of length
   196      * 0 if the underlying method takes no parameters.
   197      *
   198      * @return the parameter types for the method this object
   199      * represents
   200      */
   201     public Class<?>[] getParameterTypes() {
   202         throw new UnsupportedOperationException();
   203         //return (Class<?>[]) parameterTypes.clone();
   204     }
   205 
   206     /**
   207      * Returns an array of {@code Type} objects that represent the formal
   208      * parameter types, in declaration order, of the method represented by
   209      * this {@code Method} object. Returns an array of length 0 if the
   210      * underlying method takes no parameters.
   211      *
   212      * <p>If a formal parameter type is a parameterized type,
   213      * the {@code Type} object returned for it must accurately reflect
   214      * the actual type parameters used in the source code.
   215      *
   216      * <p>If a formal parameter type is a type variable or a parameterized
   217      * type, it is created. Otherwise, it is resolved.
   218      *
   219      * @return an array of Types that represent the formal
   220      *     parameter types of the underlying method, in declaration order
   221      * @throws GenericSignatureFormatError
   222      *     if the generic method signature does not conform to the format
   223      *     specified in
   224      *     <cite>The Java&trade; Virtual Machine Specification</cite>
   225      * @throws TypeNotPresentException if any of the parameter
   226      *     types of the underlying method refers to a non-existent type
   227      *     declaration
   228      * @throws MalformedParameterizedTypeException if any of
   229      *     the underlying method's parameter types refer to a parameterized
   230      *     type that cannot be instantiated for any reason
   231      * @since 1.5
   232      */
   233     public Type[] getGenericParameterTypes() {
   234         throw new UnsupportedOperationException();
   235     }
   236 
   237 
   238     /**
   239      * Returns an array of {@code Class} objects that represent
   240      * the types of the exceptions declared to be thrown
   241      * by the underlying method
   242      * represented by this {@code Method} object.  Returns an array of length
   243      * 0 if the method declares no exceptions in its {@code throws} clause.
   244      *
   245      * @return the exception types declared as being thrown by the
   246      * method this object represents
   247      */
   248     public Class<?>[] getExceptionTypes() {
   249         throw new UnsupportedOperationException();
   250         //return (Class<?>[]) exceptionTypes.clone();
   251     }
   252 
   253     /**
   254      * Returns an array of {@code Type} objects that represent the
   255      * exceptions declared to be thrown by this {@code Method} object.
   256      * Returns an array of length 0 if the underlying method declares
   257      * no exceptions in its {@code throws} clause.
   258      *
   259      * <p>If an exception type is a type variable or a parameterized
   260      * type, it is created. Otherwise, it is resolved.
   261      *
   262      * @return an array of Types that represent the exception types
   263      *     thrown by the underlying method
   264      * @throws GenericSignatureFormatError
   265      *     if the generic method signature does not conform to the format
   266      *     specified in
   267      *     <cite>The Java&trade; Virtual Machine Specification</cite>
   268      * @throws TypeNotPresentException if the underlying method's
   269      *     {@code throws} clause refers to a non-existent type declaration
   270      * @throws MalformedParameterizedTypeException if
   271      *     the underlying method's {@code throws} clause refers to a
   272      *     parameterized type that cannot be instantiated for any reason
   273      * @since 1.5
   274      */
   275       public Type[] getGenericExceptionTypes() {
   276         throw new UnsupportedOperationException();
   277       }
   278 
   279     /**
   280      * Compares this {@code Method} against the specified object.  Returns
   281      * true if the objects are the same.  Two {@code Methods} are the same if
   282      * they were declared by the same class and have the same name
   283      * and formal parameter types and return type.
   284      */
   285     public boolean equals(Object obj) {
   286         if (obj != null && obj instanceof Method) {
   287             Method other = (Method)obj;
   288             return data == other.data;
   289         }
   290         return false;
   291     }
   292 
   293     /**
   294      * Returns a hashcode for this {@code Method}.  The hashcode is computed
   295      * as the exclusive-or of the hashcodes for the underlying
   296      * method's declaring class name and the method's name.
   297      */
   298     public int hashCode() {
   299         return getDeclaringClass().getName().hashCode() ^ getName().hashCode();
   300     }
   301 
   302     /**
   303      * Returns a string describing this {@code Method}.  The string is
   304      * formatted as the method access modifiers, if any, followed by
   305      * the method return type, followed by a space, followed by the
   306      * class declaring the method, followed by a period, followed by
   307      * the method name, followed by a parenthesized, comma-separated
   308      * list of the method's formal parameter types. If the method
   309      * throws checked exceptions, the parameter list is followed by a
   310      * space, followed by the word throws followed by a
   311      * comma-separated list of the thrown exception types.
   312      * For example:
   313      * <pre>
   314      *    public boolean java.lang.Object.equals(java.lang.Object)
   315      * </pre>
   316      *
   317      * <p>The access modifiers are placed in canonical order as
   318      * specified by "The Java Language Specification".  This is
   319      * {@code public}, {@code protected} or {@code private} first,
   320      * and then other modifiers in the following order:
   321      * {@code abstract}, {@code static}, {@code final},
   322      * {@code synchronized}, {@code native}, {@code strictfp}.
   323      */
   324     public String toString() {
   325         try {
   326             StringBuilder sb = new StringBuilder();
   327             int mod = getModifiers() & Modifier.methodModifiers();
   328             if (mod != 0) {
   329                 sb.append(Modifier.toString(mod)).append(' ');
   330             }
   331             sb.append(Field.getTypeName(getReturnType())).append(' ');
   332             sb.append(Field.getTypeName(getDeclaringClass())).append('.');
   333             sb.append(getName()).append('(');
   334             /*
   335             Class<?>[] params = parameterTypes; // avoid clone
   336             for (int j = 0; j < params.length; j++) {
   337                 sb.append(Field.getTypeName(params[j]));
   338                 if (j < (params.length - 1))
   339                     sb.append(',');
   340             }
   341             sb.append(')');
   342             Class<?>[] exceptions = exceptionTypes; // avoid clone
   343             if (exceptions.length > 0) {
   344                 sb.append(" throws ");
   345                 for (int k = 0; k < exceptions.length; k++) {
   346                     sb.append(exceptions[k].getName());
   347                     if (k < (exceptions.length - 1))
   348                         sb.append(',');
   349                 }
   350             }
   351             */
   352             return sb.toString();
   353         } catch (Exception e) {
   354             return "<" + e + ">";
   355         }
   356     }
   357 
   358     /**
   359      * Returns a string describing this {@code Method}, including
   360      * type parameters.  The string is formatted as the method access
   361      * modifiers, if any, followed by an angle-bracketed
   362      * comma-separated list of the method's type parameters, if any,
   363      * followed by the method's generic return type, followed by a
   364      * space, followed by the class declaring the method, followed by
   365      * a period, followed by the method name, followed by a
   366      * parenthesized, comma-separated list of the method's generic
   367      * formal parameter types.
   368      *
   369      * If this method was declared to take a variable number of
   370      * arguments, instead of denoting the last parameter as
   371      * "<tt><i>Type</i>[]</tt>", it is denoted as
   372      * "<tt><i>Type</i>...</tt>".
   373      *
   374      * A space is used to separate access modifiers from one another
   375      * and from the type parameters or return type.  If there are no
   376      * type parameters, the type parameter list is elided; if the type
   377      * parameter list is present, a space separates the list from the
   378      * class name.  If the method is declared to throw exceptions, the
   379      * parameter list is followed by a space, followed by the word
   380      * throws followed by a comma-separated list of the generic thrown
   381      * exception types.  If there are no type parameters, the type
   382      * parameter list is elided.
   383      *
   384      * <p>The access modifiers are placed in canonical order as
   385      * specified by "The Java Language Specification".  This is
   386      * {@code public}, {@code protected} or {@code private} first,
   387      * and then other modifiers in the following order:
   388      * {@code abstract}, {@code static}, {@code final},
   389      * {@code synchronized}, {@code native}, {@code strictfp}.
   390      *
   391      * @return a string describing this {@code Method},
   392      * include type parameters
   393      *
   394      * @since 1.5
   395      */
   396     public String toGenericString() {
   397         try {
   398             StringBuilder sb = new StringBuilder();
   399             int mod = getModifiers() & Modifier.methodModifiers();
   400             if (mod != 0) {
   401                 sb.append(Modifier.toString(mod)).append(' ');
   402             }
   403             TypeVariable<?>[] typeparms = getTypeParameters();
   404             if (typeparms.length > 0) {
   405                 boolean first = true;
   406                 sb.append('<');
   407                 for(TypeVariable<?> typeparm: typeparms) {
   408                     if (!first)
   409                         sb.append(',');
   410                     // Class objects can't occur here; no need to test
   411                     // and call Class.getName().
   412                     sb.append(typeparm.toString());
   413                     first = false;
   414                 }
   415                 sb.append("> ");
   416             }
   417 
   418             Type genRetType = getGenericReturnType();
   419             sb.append( ((genRetType instanceof Class<?>)?
   420                         Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
   421                     .append(' ');
   422 
   423             sb.append(Field.getTypeName(getDeclaringClass())).append('.');
   424             sb.append(getName()).append('(');
   425             Type[] params = getGenericParameterTypes();
   426             for (int j = 0; j < params.length; j++) {
   427                 String param = (params[j] instanceof Class)?
   428                     Field.getTypeName((Class)params[j]):
   429                     (params[j].toString());
   430                 if (isVarArgs() && (j == params.length - 1)) // replace T[] with T...
   431                     param = param.replaceFirst("\\[\\]$", "...");
   432                 sb.append(param);
   433                 if (j < (params.length - 1))
   434                     sb.append(',');
   435             }
   436             sb.append(')');
   437             Type[] exceptions = getGenericExceptionTypes();
   438             if (exceptions.length > 0) {
   439                 sb.append(" throws ");
   440                 for (int k = 0; k < exceptions.length; k++) {
   441                     sb.append((exceptions[k] instanceof Class)?
   442                               ((Class)exceptions[k]).getName():
   443                               exceptions[k].toString());
   444                     if (k < (exceptions.length - 1))
   445                         sb.append(',');
   446                 }
   447             }
   448             return sb.toString();
   449         } catch (Exception e) {
   450             return "<" + e + ">";
   451         }
   452     }
   453 
   454     /**
   455      * Invokes the underlying method represented by this {@code Method}
   456      * object, on the specified object with the specified parameters.
   457      * Individual parameters are automatically unwrapped to match
   458      * primitive formal parameters, and both primitive and reference
   459      * parameters are subject to method invocation conversions as
   460      * necessary.
   461      *
   462      * <p>If the underlying method is static, then the specified {@code obj}
   463      * argument is ignored. It may be null.
   464      *
   465      * <p>If the number of formal parameters required by the underlying method is
   466      * 0, the supplied {@code args} array may be of length 0 or null.
   467      *
   468      * <p>If the underlying method is an instance method, it is invoked
   469      * using dynamic method lookup as documented in The Java Language
   470      * Specification, Second Edition, section 15.12.4.4; in particular,
   471      * overriding based on the runtime type of the target object will occur.
   472      *
   473      * <p>If the underlying method is static, the class that declared
   474      * the method is initialized if it has not already been initialized.
   475      *
   476      * <p>If the method completes normally, the value it returns is
   477      * returned to the caller of invoke; if the value has a primitive
   478      * type, it is first appropriately wrapped in an object. However,
   479      * if the value has the type of an array of a primitive type, the
   480      * elements of the array are <i>not</i> wrapped in objects; in
   481      * other words, an array of primitive type is returned.  If the
   482      * underlying method return type is void, the invocation returns
   483      * null.
   484      *
   485      * @param obj  the object the underlying method is invoked from
   486      * @param args the arguments used for the method call
   487      * @return the result of dispatching the method represented by
   488      * this object on {@code obj} with parameters
   489      * {@code args}
   490      *
   491      * @exception IllegalAccessException    if this {@code Method} object
   492      *              is enforcing Java language access control and the underlying
   493      *              method is inaccessible.
   494      * @exception IllegalArgumentException  if the method is an
   495      *              instance method and the specified object argument
   496      *              is not an instance of the class or interface
   497      *              declaring the underlying method (or of a subclass
   498      *              or implementor thereof); if the number of actual
   499      *              and formal parameters differ; if an unwrapping
   500      *              conversion for primitive arguments fails; or if,
   501      *              after possible unwrapping, a parameter value
   502      *              cannot be converted to the corresponding formal
   503      *              parameter type by a method invocation conversion.
   504      * @exception InvocationTargetException if the underlying method
   505      *              throws an exception.
   506      * @exception NullPointerException      if the specified object is null
   507      *              and the method is an instance method.
   508      * @exception ExceptionInInitializerError if the initialization
   509      * provoked by this method fails.
   510      */
   511     public Object invoke(Object obj, Object... args)
   512         throws IllegalAccessException, IllegalArgumentException,
   513            InvocationTargetException
   514     {
   515         if ((getModifiers() & Modifier.STATIC) == 0 && obj == null) {
   516             throw new NullPointerException();
   517         }
   518         Object res = invoke0(this, obj, args);
   519         if (getReturnType().isPrimitive()) {
   520             res = fromPrimitive(getReturnType(), res);
   521         }
   522         return res;
   523     }
   524     
   525     @JavaScriptBody(args = { "method", "self", "args" }, body =
   526           "if (args.length > 0) throw 'unsupported now';"
   527         + "return method.fld_data(self);"
   528     )
   529     private static native Object invoke0(Method m, Object self, Object[] args);
   530 
   531     private static Object fromPrimitive(Class<?> type, Object o) {
   532         if (type == Integer.TYPE) {
   533             return fromRaw(Integer.class, "valueOf__Ljava_lang_Integer_2I", o);
   534         }
   535         if (type == Long.TYPE) {
   536             return fromRaw(Long.class, "valueOf__Ljava_lang_Long_2J", o);
   537         }
   538         if (type == Double.TYPE) {
   539             return fromRaw(Double.class, "valueOf__Ljava_lang_Double_2D", o);
   540         }
   541         if (type == Float.TYPE) {
   542             return fromRaw(Float.class, "valueOf__Ljava_lang_Float_2F", o);
   543         }
   544         if (type == Byte.TYPE) {
   545             return fromRaw(Byte.class, "valueOf__Ljava_lang_Byte_2B", o);
   546         }
   547         if (type == Boolean.TYPE) {
   548             return fromRaw(Boolean.class, "valueOf__Ljava_lang_Boolean_2Z", o);
   549         }
   550         if (type == Short.TYPE) {
   551             return fromRaw(Short.class, "valueOf__Ljava_lang_Short_2S", o);
   552         }
   553         if (type.getName().equals("void")) {
   554             return null;
   555         }
   556         throw new IllegalStateException("Can't convert " + o);
   557     }
   558     
   559     @JavaScriptBody(args = { "cls", "m", "o" }, 
   560         body = "return cls.cnstr(false)[m](o);"
   561     )
   562     private static native Integer fromRaw(Class<?> cls, String m, Object o);
   563     
   564     /**
   565      * Returns {@code true} if this method is a bridge
   566      * method; returns {@code false} otherwise.
   567      *
   568      * @return true if and only if this method is a bridge
   569      * method as defined by the Java Language Specification.
   570      * @since 1.5
   571      */
   572     public boolean isBridge() {
   573         return (getModifiers() & Modifier.BRIDGE) != 0;
   574     }
   575 
   576     /**
   577      * Returns {@code true} if this method was declared to take
   578      * a variable number of arguments; returns {@code false}
   579      * otherwise.
   580      *
   581      * @return {@code true} if an only if this method was declared to
   582      * take a variable number of arguments.
   583      * @since 1.5
   584      */
   585     public boolean isVarArgs() {
   586         return (getModifiers() & Modifier.VARARGS) != 0;
   587     }
   588 
   589     /**
   590      * Returns {@code true} if this method is a synthetic
   591      * method; returns {@code false} otherwise.
   592      *
   593      * @return true if and only if this method is a synthetic
   594      * method as defined by the Java Language Specification.
   595      * @since 1.5
   596      */
   597     public boolean isSynthetic() {
   598         return Modifier.isSynthetic(getModifiers());
   599     }
   600 
   601     @JavaScriptBody(args = { "self", "ac" }, 
   602         body = 
   603           "if (self.fld_data.anno) {"
   604         + "  return self.fld_data.anno['L' + ac.jvmName + ';'];"
   605         + "} else return null;"
   606     )
   607     private Object getAnnotationData(Class<?> annotationClass) {
   608         throw new UnsupportedOperationException();
   609     }
   610     
   611     /**
   612      * @throws NullPointerException {@inheritDoc}
   613      * @since 1.5
   614      */
   615     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
   616         Object data = getAnnotationData(annotationClass);
   617         return data == null ? null : AnnotationImpl.create(annotationClass, data);
   618     }
   619 
   620     /**
   621      * @since 1.5
   622      */
   623     public Annotation[] getDeclaredAnnotations()  {
   624         throw new UnsupportedOperationException();
   625     }
   626 
   627     /**
   628      * Returns the default value for the annotation member represented by
   629      * this {@code Method} instance.  If the member is of a primitive type,
   630      * an instance of the corresponding wrapper type is returned. Returns
   631      * null if no default is associated with the member, or if the method
   632      * instance does not represent a declared member of an annotation type.
   633      *
   634      * @return the default value for the annotation member represented
   635      *     by this {@code Method} instance.
   636      * @throws TypeNotPresentException if the annotation is of type
   637      *     {@link Class} and no definition can be found for the
   638      *     default class value.
   639      * @since  1.5
   640      */
   641     public Object getDefaultValue() {
   642         throw new UnsupportedOperationException();
   643     }
   644 
   645     /**
   646      * Returns an array of arrays that represent the annotations on the formal
   647      * parameters, in declaration order, of the method represented by
   648      * this {@code Method} object. (Returns an array of length zero if the
   649      * underlying method is parameterless.  If the method has one or more
   650      * parameters, a nested array of length zero is returned for each parameter
   651      * with no annotations.) The annotation objects contained in the returned
   652      * arrays are serializable.  The caller of this method is free to modify
   653      * the returned arrays; it will have no effect on the arrays returned to
   654      * other callers.
   655      *
   656      * @return an array of arrays that represent the annotations on the formal
   657      *    parameters, in declaration order, of the method represented by this
   658      *    Method object
   659      * @since 1.5
   660      */
   661     public Annotation[][] getParameterAnnotations() {
   662         throw new UnsupportedOperationException();
   663     }
   664 
   665     static {
   666         MethodImpl.INSTANCE = new MethodImpl() {
   667             protected Method create(Class<?> declaringClass, String name, Object data, String sig) {
   668                 return new Method(declaringClass, name, data, sig);
   669             }
   670         };
   671     }
   672 }