src/java.base/share/classes/java/lang/reflect/Method.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54952 a978d86ac389
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
   111         }
   111         }
   112         return genericInfo; //return cached repository
   112         return genericInfo; //return cached repository
   113     }
   113     }
   114 
   114 
   115     /**
   115     /**
   116      * Package-private constructor used by ReflectAccess to enable
   116      * Package-private constructor
   117      * instantiation of these objects in Java code from the java.lang
       
   118      * package via sun.reflect.LangReflectAccess.
       
   119      */
   117      */
   120     Method(Class<?> declaringClass,
   118     Method(Class<?> declaringClass,
   121            String name,
   119            String name,
   122            Class<?>[] parameterTypes,
   120            Class<?>[] parameterTypes,
   123            Class<?> returnType,
   121            Class<?> returnType,
   267      * Returns a {@code Type} object that represents the formal return
   265      * Returns a {@code Type} object that represents the formal return
   268      * type of the method represented by this {@code Method} object.
   266      * type of the method represented by this {@code Method} object.
   269      *
   267      *
   270      * <p>If the return type is a parameterized type,
   268      * <p>If the return type is a parameterized type,
   271      * the {@code Type} object returned must accurately reflect
   269      * the {@code Type} object returned must accurately reflect
   272      * the actual type parameters used in the source code.
   270      * the actual type arguments used in the source code.
   273      *
   271      *
   274      * <p>If the return type is a type variable or a parameterized type, it
   272      * <p>If the return type is a type variable or a parameterized type, it
   275      * is created. Otherwise, it is resolved.
   273      * is created. Otherwise, it is resolved.
   276      *
   274      *
   277      * @return  a {@code Type} object that represents the formal return
   275      * @return  a {@code Type} object that represents the formal return
   420         sb.append(getName());
   418         sb.append(getName());
   421     }
   419     }
   422 
   420 
   423     @Override
   421     @Override
   424     String toShortString() {
   422     String toShortString() {
   425         StringBuilder sb = new StringBuilder("method ");
   423         return "method " + getDeclaringClass().getTypeName() +
   426         sb.append(getDeclaringClass().getTypeName()).append('.');
   424                 '.' + toShortSignature();
   427         sb.append(getName());
   425     }
   428         sb.append('(');
   426 
   429         StringJoiner sj = new StringJoiner(",");
   427     String toShortSignature() {
       
   428         StringJoiner sj = new StringJoiner(",", getName() + "(", ")");
   430         for (Class<?> parameterType : getParameterTypes()) {
   429         for (Class<?> parameterType : getParameterTypes()) {
   431             sj.add(parameterType.getTypeName());
   430             sj.add(parameterType.getTypeName());
   432         }
   431         }
   433         sb.append(sj);
   432         return sj.toString();
   434         sb.append(')');
       
   435         return sb.toString();
       
   436     }
   433     }
   437 
   434 
   438     /**
   435     /**
   439      * Returns a string describing this {@code Method}, including type
   436      * Returns a string describing this {@code Method}, including type
   440      * parameters.  The string is formatted as the method access
   437      * parameters.  The string is formatted as the method access
   525      * @param args the arguments used for the method call
   522      * @param args the arguments used for the method call
   526      * @return the result of dispatching the method represented by
   523      * @return the result of dispatching the method represented by
   527      * this object on {@code obj} with parameters
   524      * this object on {@code obj} with parameters
   528      * {@code args}
   525      * {@code args}
   529      *
   526      *
   530      * @exception IllegalAccessException    if this {@code Method} object
   527      * @throws    IllegalAccessException    if this {@code Method} object
   531      *              is enforcing Java language access control and the underlying
   528      *              is enforcing Java language access control and the underlying
   532      *              method is inaccessible.
   529      *              method is inaccessible.
   533      * @exception IllegalArgumentException  if the method is an
   530      * @throws    IllegalArgumentException  if the method is an
   534      *              instance method and the specified object argument
   531      *              instance method and the specified object argument
   535      *              is not an instance of the class or interface
   532      *              is not an instance of the class or interface
   536      *              declaring the underlying method (or of a subclass
   533      *              declaring the underlying method (or of a subclass
   537      *              or implementor thereof); if the number of actual
   534      *              or implementor thereof); if the number of actual
   538      *              and formal parameters differ; if an unwrapping
   535      *              and formal parameters differ; if an unwrapping
   539      *              conversion for primitive arguments fails; or if,
   536      *              conversion for primitive arguments fails; or if,
   540      *              after possible unwrapping, a parameter value
   537      *              after possible unwrapping, a parameter value
   541      *              cannot be converted to the corresponding formal
   538      *              cannot be converted to the corresponding formal
   542      *              parameter type by a method invocation conversion.
   539      *              parameter type by a method invocation conversion.
   543      * @exception InvocationTargetException if the underlying method
   540      * @throws    InvocationTargetException if the underlying method
   544      *              throws an exception.
   541      *              throws an exception.
   545      * @exception NullPointerException      if the specified object is null
   542      * @throws    NullPointerException      if the specified object is null
   546      *              and the method is an instance method.
   543      *              and the method is an instance method.
   547      * @exception ExceptionInInitializerError if the initialization
   544      * @throws    ExceptionInInitializerError if the initialization
   548      * provoked by this method fails.
   545      * provoked by this method fails.
   549      */
   546      */
   550     @CallerSensitive
   547     @CallerSensitive
   551     @ForceInline // to ensure Reflection.getCallerClass optimization
   548     @ForceInline // to ensure Reflection.getCallerClass optimization
   552     @HotSpotIntrinsicCandidate
   549     @HotSpotIntrinsicCandidate