Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
I am learning GoF Java Design Patterns and I want to see some real life examples of them. Can you guys point to some good usage of these Design Patterns.(preferably in Java's core libraries). Thank you
I read about Java's type erasure on Sun's website (http://java.sun.com/docs/books/tutorial/java/generics/erasure.html). I have the following question : When does type erasure occur - at compile time / runtime:when the class is loaded / runtime:when the class is instantiated. A lot of sites (including the Sun tutorial mentioned above) say type erasure occurs at compile time. If the type infor...
If I have a class like this: public class Whatever { public void aMethod(int aParam); } is there any way to know that aMethod uses a parameter named aParam, that is of type int?
I'm working on a tiny web library and wonder wheter I should call the HTTP handler methods for GET, POST, PUT etc. reflectivly or not. Fixed Methods First the variant with an if else ... block calling methods given in the base class where they have a default implementation returning an error to the client. Since a request to an unsupported method needs a header with the allowed methods, I nee...
public class SuperClass { public void method1() { System.out.println("superclass method1"); this.method2(); } public void method2() { System.out.println("superclass method2"); } } public class SubClass extends SuperClass { @Override public void method1() { System.out.println("subclass method1"); super.method1(); ...
I need to get a list of all caller methods for a method of interest for me in Java. Is there a tool that can help me with this? Edit: I forgot to mention that I need to do this from a program. I'm usig Java Pathfinder and I want to run it an all the methods that call my method of interest.
I'm working on a school assignment about Java reflection. The details are below: Write a console program that asks the user for a class name, loads that class and creates an instance of it. We assume that the class has a constructor without any parameters. Then, the program prints out the names and values of the public variables of the created object, and also a list of the public m...
I am trying to measure the execution time for several methods. so I was thinking to make a method instead of duplicate same code many times. Here is my code: private void MeasureExecutionTime(Method m) { startTime = System.nanoTime(); try { m(); } finally { endTime = System.nanoTime(); } elapsedTime = endTime - startTime; System.out.println(...
Is it possible to obtain references to an object's methods? For example, I'd like to have a method that invokes other methods as callbacks. Something like: public class Whatever { public void myMethod(Method m,Object args[]) { } } Is this possible? EDIT: I meant an object's methods. I take it it's not possible?
I have a java.lang.reflect.Method object and I would like to know if it's return type is void. I've checked the Javadocs and there is a getReturnType() method that returns a Class object. The thing is that they don't say what would be the return type if the method is void. Thanks!
Possible Duplicate: Does Java guarantee that Object.getClass() == Object.getClass()? I know you're supposed to use equals() in general, but is there any way two Class<?> objects could be equal with equals() but not equal with ==? edit: I am specifically looking to find out whether two class objects exist such that Class<?> cl1 = ... Class<?> cl2 = ... cl1.equals(c...
Consider this code: public example(String s, int i, @Foo Bar bar) { /* ... */ } I want to check if the method has an annotation @Foo and get the argument or throw an exception if no @Foo annotation is found. My current approach is to first get the current method and then iterate through the parameter annotations: import java.lang.annotation.Annotation; import java.lang.reflect.Method; c...
I have this code: public static final <TypeVO extends BaseVo> List<SelectItem> populateSelectBoxForType( final Class<TypeVO> voClass, final String fieldName) { List<SelectItem> listSelectBox = null; final List<TypeVO> vosList = GenericEjbProxyFactory .getGenericTopValueObjectProxy(voClass) .getAllValueObj...
How to find out if a method is overridden by child classes? For example, public class Test { static public class B { public String m() {return "From B";}; } static public class B1 extends B { } static public class B2 extends B { public String m() {return "from B2";}; } /** * @param args * @throws FileNotFoundException */ public static void main(String[] args) { B b1 = n...
What is the difference between the invocation and execution of a method ? Are two the same thing ?
I just noticed there's a Method.getGenericReturnType() as well as Method.getReturnType() and similar pairs for exception types and parameter types. I thought generics in Java worked via type erasure. So how would these methods work at runtime? (and what would I use them for at runtime?)
I'm teaching an intro to programming course and we're using Java. I want to help the students learn how to translate a written class specification into a working program. I will provide the written specification. It specifies the name of the class and behavior in the form of method signatures. I want the students to translate that into a working Java class. I could provide them an interface an...
I have two classes. public class A { public Object method() {...} } public class B extends A { @Override public Object method() {...} } I have an instance of B. How do I call A.method() from b? Basically, the same effect as calling super.method() from B. B b = new B(); Class<?> superclass = b.getClass().getSuperclass(); Method method = superclass.getMethod("method", Arr...
I have a String array that contains names of method in the yyyyyy class In the xxxxxx class I'm making a yyyyyy instance (say obj). Now I can call obj.function_name(), except I want to read function_name from the String array in a loop. Is this possible?
I've come across some code that I can't share here but it declares a method WITHIN the paramter list of another method. I didnt even know that was possible. I dont really understand why its doing that. Can someone please explain to me some possible uses that you as a programmer would have for doing that? (Note: Since I can't show the code I dont expect an in-context explanation just generally) ...
The title says it all. If I didn't know that the sleep method on java.lang.Thread was static, how could I find out?
  /*
   * Copyright 1996-2006 Sun Microsystems, Inc.  All Rights Reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Sun designates this
   * particular file as subject to the "Classpath" exception as provided
   * by Sun in the LICENSE file that accompanied this code.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
  * have any questions.
  */
 
 package java.lang.reflect;
 
 import java.util.Map;

A Method provides information about, and access to, a single method on a class or interface. The reflected method may be a class method or an instance method (including an abstract method).

A Method permits widening conversions to occur when matching the actual parameters to invoke with the underlying method's formal parameters, but it throws an IllegalArgumentException if a narrowing conversion would occur.

 
 public final
     class Method extends AccessibleObject implements GenericDeclaration,
                                                      Member {
     private Class               clazz;
     private int                 slot;
     // This is guaranteed to be interned by the VM in the 1.4
     // reflection implementation
     private String              name;
     private Class               returnType;
     private Class[]             parameterTypes;
     private Class[]             exceptionTypes;
     private int                 modifiers;
     // Generics and annotations support
     private transient String              signature;
     // generic info repository; lazily initialized
     private transient MethodRepository genericInfo;
     private byte[]              annotations;
     private byte[]              parameterAnnotations;
     private byte[]              annotationDefault;
     private volatile MethodAccessor methodAccessor;
     // For sharing of MethodAccessors. This branching structure is
     // currently only two levels deep (i.e., one root Method and
     // potentially many Method objects pointing to it.)
     private Method              root;
 
     // More complicated security check cache needed here than for
     // Class.newInstance() and Constructor.newInstance()
     private Class securityCheckCache;
 
     // Modifiers that can be applied to a method in source code
     private static final int LANGUAGE_MODIFIERS =
         .         | .    | . |
         .       | .       | .   |
         .   | .;
 
    // Generics infrastructure
 
     private String getGenericSignature() {return ;}
    // Accessor for factory
    private GenericsFactory getFactory() {
        // create scope and factory
        return CoreReflectionFactory.make(this, MethodScope.make(this));
    }
    // Accessor for generic info repository
    private MethodRepository getGenericInfo() {
        // lazily initialize repository if necessary
        if ( == null) {
            // create and cache generic info repository
             = MethodRepository.make(getGenericSignature(),
                                                getFactory());
        }
        return //return cached repository
    }

    
Package-private constructor used by ReflectAccess to enable instantiation of these objects in Java code from the java.lang package via sun.reflect.LangReflectAccess.
    Method(Class declaringClass,
           String name,
           Class[] parameterTypes,
           Class returnType,
           Class[] checkedExceptions,
           int modifiers,
           int slot,
           String signature,
           byte[] annotations,
           byte[] parameterAnnotations,
           byte[] annotationDefault)
    {
        this. = declaringClass;
        this. = name;
        this. = parameterTypes;
        this. = returnType;
        this. = checkedExceptions;
        this. = modifiers;
        this. = slot;
        this. = signature;
        this. = annotations;
        this. = parameterAnnotations;
        this. = annotationDefault;
    }

    
Package-private routine (exposed to java.lang.Class via ReflectAccess) which returns a copy of this Method. The copy's "root" field points to this Method.
    Method copy() {
        // This routine enables sharing of MethodAccessor objects
        // among Method objects which refer to the same underlying
        // method in the VM. (All of this contortion is only necessary
        // because of the "accessibility" bit in AccessibleObject,
        // which implicitly requires that new java.lang.reflect
        // objects be fabricated for each reflective call on Class
        // objects.)
        Method res = new Method(,
                                ,
                                );
        res.root = this;
        // Might as well eagerly propagate this if already present
        res.methodAccessor = ;
        return res;
    }

    
Returns the Class object representing the class or interface that declares the method represented by this Method object.
    public Class<?> getDeclaringClass() {
        return ;
    }

    
Returns the name of the method represented by this Method object, as a String.
    public String getName() {
        return ;
    }

    
Returns the Java language modifiers for the method represented by this Method object, as an integer. The Modifier class should be used to decode the modifiers.

See also:
Modifier
    public int getModifiers() {
        return ;
    }

    
Returns an array of TypeVariable objects that represent the type variables declared by the generic declaration represented by this GenericDeclaration object, in declaration order. Returns an array of length 0 if the underlying generic declaration declares no type variables.

Returns:
an array of TypeVariable objects that represent the type variables declared by this generic declaration
Throws:
GenericSignatureFormatError if the generic signature of this generic declaration does not conform to the format specified in the Java Virtual Machine Specification, 3rd edition
Since:
1.5
    public TypeVariable<Method>[] getTypeParameters() {
        if (getGenericSignature() != null)
            return (TypeVariable<Method>[])getGenericInfo().getTypeParameters();
        else
            return (TypeVariable<Method>[])new TypeVariable[0];
    }

    
Returns a Class object that represents the formal return type of the method represented by this Method object.

Returns:
the return type for the method this object represents
    public Class<?> getReturnType() {
        return ;
    }

    
Returns a Type object that represents the formal return type of the method represented by this Method object.

If the return type is a parameterized type, the Type object returned must accurately reflect the actual type parameters used in the source code.

If the return type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.

Returns:
a Type object that represents the formal return type of the underlying method
Throws:
GenericSignatureFormatError if the generic method signature does not conform to the format specified in the Java Virtual Machine Specification, 3rd edition
java.lang.TypeNotPresentException if the underlying method's return type refers to a non-existent type declaration
MalformedParameterizedTypeException if the underlying method's return typed refers to a parameterized type that cannot be instantiated for any reason
Since:
1.5
    public Type getGenericReturnType() {
      if (getGenericSignature() != null) {
        return getGenericInfo().getReturnType();
      } else { return getReturnType();}
    }


    
Returns an array of Class objects that represent the formal parameter types, in declaration order, of the method represented by this Method object. Returns an array of length 0 if the underlying method takes no parameters.

Returns:
the parameter types for the method this object represents
    public Class<?>[] getParameterTypes() {
        return (Class<?>[]) .clone();
    }

    
Returns an array of Type objects that represent the formal parameter types, in declaration order, of the method represented by this Method object. Returns an array of length 0 if the underlying method takes no parameters.

If a formal parameter type is a parameterized type, the Type object returned for it must accurately reflect the actual type parameters used in the source code.

If a formal parameter type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.

Returns:
an array of Types that represent the formal parameter types of the underlying method, in declaration order
Throws:
GenericSignatureFormatError if the generic method signature does not conform to the format specified in the Java Virtual Machine Specification, 3rd edition
java.lang.TypeNotPresentException if any of the parameter types of the underlying method refers to a non-existent type declaration
MalformedParameterizedTypeException if any of the underlying method's parameter types refer to a parameterized type that cannot be instantiated for any reason
Since:
1.5
    public Type[] getGenericParameterTypes() {
        if (getGenericSignature() != null)
            return getGenericInfo().getParameterTypes();
        else
            return getParameterTypes();
    }


    
Returns an array of Class objects that represent the types of the exceptions declared to be thrown by the underlying method represented by this Method object. Returns an array of length 0 if the method declares no exceptions in its throws clause.

Returns:
the exception types declared as being thrown by the method this object represents
    public Class<?>[] getExceptionTypes() {
        return (Class<?>[]) .clone();
    }

    
Returns an array of Type objects that represent the exceptions declared to be thrown by this Method object. Returns an array of length 0 if the underlying method declares no exceptions in its throws clause.

If an exception type is a parameterized type, the Type object returned for it must accurately reflect the actual type parameters used in the source code.

If an exception type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.

Returns:
an array of Types that represent the exception types thrown by the underlying method
Throws:
GenericSignatureFormatError if the generic method signature does not conform to the format specified in the Java Virtual Machine Specification, 3rd edition
java.lang.TypeNotPresentException if the underlying method's throws clause refers to a non-existent type declaration
MalformedParameterizedTypeException if the underlying method's throws clause refers to a parameterized type that cannot be instantiated for any reason
Since:
1.5
      public Type[] getGenericExceptionTypes() {
          Type[] result;
          if (getGenericSignature() != null &&
              ((result = getGenericInfo().getExceptionTypes()).length > 0))
              return result;
          else
              return getExceptionTypes();
      }

    
Compares this Method against the specified object. Returns true if the objects are the same. Two Methods are the same if they were declared by the same class and have the same name and formal parameter types and return type.
    public boolean equals(Object obj) {
        if (obj != null && obj instanceof Method) {
            Method other = (Method)obj;
            if ((getDeclaringClass() == other.getDeclaringClass())
                && (getName() == other.getName())) {
                if (!.equals(other.getReturnType()))
                    return false;
                /* Avoid unnecessary cloning */
                Class[] params1 = ;
                Class[] params2 = other.parameterTypes;
                if (params1.length == params2.length) {
                    for (int i = 0; i < params1.lengthi++) {
                        if (params1[i] != params2[i])
                            return false;
                    }
                    return true;
                }
            }
        }
        return false;
    }

    
Returns a hashcode for this Method. The hashcode is computed as the exclusive-or of the hashcodes for the underlying method's declaring class name and the method's name.
    public int hashCode() {
        return getDeclaringClass().getName().hashCode() ^ getName().hashCode();
    }

    
Returns a string describing this Method. The string is formatted as the method access modifiers, if any, followed by the method return type, followed by a space, followed by the class declaring the method, followed by a period, followed by the method name, followed by a parenthesized, comma-separated list of the method's formal parameter types. If the method throws checked exceptions, the parameter list is followed by a space, followed by the word throws followed by a comma-separated list of the thrown exception types. For example:
    public boolean java.lang.Object.equals(java.lang.Object)
 

The access modifiers are placed in canonical order as specified by "The Java Language Specification". This is public, protected or private first, and then other modifiers in the following order: abstract, static, final, synchronized, native.

    public String toString() {
        try {
            StringBuffer sb = new StringBuffer();
            int mod = getModifiers() & ;
            if (mod != 0) {
                sb.append(Modifier.toString(mod) + " ");
            }
            sb.append(Field.getTypeName(getReturnType()) + " ");
            sb.append(Field.getTypeName(getDeclaringClass()) + ".");
            sb.append(getName() + "(");
            Class[] params = // avoid clone
            for (int j = 0; j < params.lengthj++) {
                sb.append(Field.getTypeName(params[j]));
                if (j < (params.length - 1))
                    sb.append(",");
            }
            sb.append(")");
            Class[] exceptions = // avoid clone
            if (exceptions.length > 0) {
                sb.append(" throws ");
                for (int k = 0; k < exceptions.lengthk++) {
                    sb.append(exceptions[k].getName());
                    if (k < (exceptions.length - 1))
                        sb.append(",");
                }
            }
            return sb.toString();
        } catch (Exception e) {
            return "<" + e + ">";
        }
    }

    
Returns a string describing this Method, including type parameters. The string is formatted as the method access modifiers, if any, followed by an angle-bracketed comma-separated list of the method's type parameters, if any, followed by the method's generic return type, followed by a space, followed by the class declaring the method, followed by a period, followed by the method name, followed by a parenthesized, comma-separated list of the method's generic formal parameter types. A space is used to separate access modifiers from one another and from the type parameters or return type. If there are no type parameters, the type parameter list is elided; if the type parameter list is present, a space separates the list from the class name. If the method is declared to throw exceptions, the parameter list is followed by a space, followed by the word throws followed by a comma-separated list of the generic thrown exception types. If there are no type parameters, the type parameter list is elided.

The access modifiers are placed in canonical order as specified by "The Java Language Specification". This is public, protected or private first, and then other modifiers in the following order: abstract, static, final, synchronized native.

Returns:
a string describing this Method, include type parameters
Since:
1.5
    public String toGenericString() {
        try {
            StringBuilder sb = new StringBuilder();
            int mod = getModifiers() & ;
            if (mod != 0) {
                sb.append(Modifier.toString(mod) + " ");
            }
            TypeVariable<?>[] typeparms = getTypeParameters();
            if (typeparms.length > 0) {
                boolean first = true;
                sb.append("<");
                for(TypeVariable<?> typeparmtypeparms) {
                    if (!first)
                        sb.append(",");
                    // Class objects can't occur here; no need to test
                    // and call Class.getName().
                    sb.append(typeparm.toString());
                    first = false;
                }
                sb.append("> ");
            }
            Type genRetType = getGenericReturnType();
            sb.append( ((genRetType instanceof Class<?>)?
                        Field.getTypeName((Class<?>)genRetType):genRetType.toString())  + " ");
            sb.append(Field.getTypeName(getDeclaringClass()) + ".");
            sb.append(getName() + "(");
            Type[] params = getGenericParameterTypes();
            for (int j = 0; j < params.lengthj++) {
                String param = (params[jinstanceof Class)?
                    Field.getTypeName((Class)params[j]):
                    (params[j].toString());
                sb.append(param);
                if (j < (params.length - 1))
                    sb.append(",");
            }
            sb.append(")");
            Type[] exceptions = getGenericExceptionTypes();
            if (exceptions.length > 0) {
                sb.append(" throws ");
                for (int k = 0; k < exceptions.lengthk++) {
                    sb.append((exceptions[kinstanceof Class)?
                              ((Class)exceptions[k]).getName():
                              exceptions[k].toString());
                    if (k < (exceptions.length - 1))
                        sb.append(",");
                }
            }
            return sb.toString();
        } catch (Exception e) {
            return "<" + e + ">";
        }
    }

    
Invokes the underlying method represented by this Method object, on the specified object with the specified parameters. Individual parameters are automatically unwrapped to match primitive formal parameters, and both primitive and reference parameters are subject to method invocation conversions as necessary.

If the underlying method is static, then the specified obj argument is ignored. It may be null.

If the number of formal parameters required by the underlying method is 0, the supplied args array may be of length 0 or null.

If the underlying method is an instance method, it is invoked using dynamic method lookup as documented in The Java Language Specification, Second Edition, section 15.12.4.4; in particular, overriding based on the runtime type of the target object will occur.

If the underlying method is static, the class that declared the method is initialized if it has not already been initialized.

If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is first appropriately wrapped in an object. However, if the value has the type of an array of a primitive type, the elements of the array are not wrapped in objects; in other words, an array of primitive type is returned. If the underlying method return type is void, the invocation returns null.

Parameters:
obj the object the underlying method is invoked from
args the arguments used for the method call
Returns:
the result of dispatching the method represented by this object on obj with parameters args
Throws:
java.lang.IllegalAccessException if this Method object enforces Java language access control and the underlying method is inaccessible.
java.lang.IllegalArgumentException if the method is an instance method and the specified object argument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion.
InvocationTargetException if the underlying method throws an exception.
java.lang.NullPointerException if the specified object is null and the method is an instance method.
java.lang.ExceptionInInitializerError if the initialization provoked by this method fails.
    public Object invoke(Object objObject... args)
           InvocationTargetException
    {
        if (!) {
            if (!Reflection.quickCheckMemberAccess()) {
                Class caller = Reflection.getCallerClass(1);
                Class targetClass = ((obj == null || !Modifier.isProtected())
                                     ? 
                                     : obj.getClass());
                boolean cached;
                synchronized (this) {
                    cached = ( == caller)
                            && ( == targetClass);
                }
                if (!cached) {
                    Reflection.ensureMemberAccess(callerobj);
                    synchronized (this) {
                         = caller;
                         = targetClass;
                    }
                }
            }
        }
        if ( == nullacquireMethodAccessor();
        return .invoke(objargs);
    }

    
Returns true if this method is a bridge method; returns false otherwise.

Returns:
true if and only if this method is a bridge method as defined by the Java Language Specification.
Since:
1.5
    public boolean isBridge() {
        return (getModifiers() & .) != 0;
    }

    
Returns true if this method was declared to take a variable number of arguments; returns false otherwise.

Returns:
true if an only if this method was declared to take a variable number of arguments.
Since:
1.5
    public boolean isVarArgs() {
        return (getModifiers() & .) != 0;
    }

    
Returns true if this method is a synthetic method; returns false otherwise.

Returns:
true if and only if this method is a synthetic method as defined by the Java Language Specification.
Since:
1.5
    public boolean isSynthetic() {
        return Modifier.isSynthetic(getModifiers());
    }
    // NOTE that there is no synchronization used here. It is correct
    // (though not efficient) to generate more than one MethodAccessor
    // for a given Method. However, avoiding synchronization will
    // probably make the implementation more scalable.
    private void acquireMethodAccessor() {
        // First check to see if one has been created yet, and take it
        // if so
        MethodAccessor tmp = null;
        if ( != nulltmp = .getMethodAccessor();
        if (tmp != null) {
             = tmp;
            return;
        }
        // Otherwise fabricate one and propagate it up to the root
        tmp = .newMethodAccessor(this);
        setMethodAccessor(tmp);
    }
    // Returns MethodAccessor for this Method object, not looking up
    // the chain to the root
        return ;
    }
    // Sets the MethodAccessor for this Method object and
    // (recursively) its root
    void setMethodAccessor(MethodAccessor accessor) {
         = accessor;
        // Propagate up
        if ( != null) {
            .setMethodAccessor(accessor);
        }
    }

    
    public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
        if (annotationClass == null)
            throw new NullPointerException();
        return (T) declaredAnnotations().get(annotationClass);
    }
    private static final Annotation[] EMPTY_ANNOTATION_ARRAY=new Annotation[0];

    

Since:
1.5
    public Annotation[] getDeclaredAnnotations()  {
    }
    private transient Map<ClassAnnotationdeclaredAnnotations;
    private synchronized  Map<ClassAnnotationdeclaredAnnotations() {
        if ( == null) {
             = AnnotationParser.parseAnnotations(
                , sun.misc.SharedSecrets.getJavaLangAccess().
                getConstantPool(getDeclaringClass()),
                getDeclaringClass());
        }
        return ;
    }

    
Returns the default value for the annotation member represented by this Method instance. If the member is of a primitive type, an instance of the corresponding wrapper type is returned. Returns null if no default is associated with the member, or if the method instance does not represent a declared member of an annotation type.

Returns:
the default value for the annotation member represented by this Method instance.
Throws:
java.lang.TypeNotPresentException if the annotation is of type java.lang.Class and no definition can be found for the default class value.
Since:
1.5
    public Object getDefaultValue() {
        if  ( == null)
            return null;
        Class memberType = AnnotationType.invocationHandlerReturnType(
            getReturnType());
        Object result = AnnotationParser.parseMemberValue(
            memberType, ByteBuffer.wrap(),
            sun.misc.SharedSecrets.getJavaLangAccess().
                getConstantPool(getDeclaringClass()),
            getDeclaringClass());
        if (result instanceof sun.reflect.annotation.ExceptionProxy)
            throw new AnnotationFormatError("Invalid default: " + this);
        return result;
    }

    
Returns an array of arrays that represent the annotations on the formal parameters, in declaration order, of the method represented by this Method object. (Returns an array of length zero if the underlying method is parameterless. If the method has one or more parameters, a nested array of length zero is returned for each parameter with no annotations.) The annotation objects contained in the returned arrays are serializable. The caller of this method is free to modify the returned arrays; it will have no effect on the arrays returned to other callers.

Returns:
an array of arrays that represent the annotations on the formal parameters, in declaration order, of the method represented by this Method object
Since:
1.5
    public Annotation[][] getParameterAnnotations() {
        int numParameters = .;
        if ( == null)
            return new Annotation[numParameters][0];
        Annotation[][] result = AnnotationParser.parseParameterAnnotations(
            ,
            sun.misc.SharedSecrets.getJavaLangAccess().
                getConstantPool(getDeclaringClass()),
            getDeclaringClass());
        if (result.length != numParameters)
            throw new java.lang.annotation.AnnotationFormatError(
                "Parameter annotations don't match number of parameters");
        return result;
    }
New to GrepCode? Check out our FAQ X