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