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