< prev index next >

src/java.base/share/classes/java/lang/reflect/Constructor.java

Print this page




 279     public int hashCode() {
 280         return getDeclaringClass().getName().hashCode();
 281     }
 282 
 283     /**
 284      * Returns a string describing this {@code Constructor}.  The string is
 285      * formatted as the constructor access modifiers, if any,
 286      * followed by the fully-qualified name of the declaring class,
 287      * followed by a parenthesized, comma-separated list of the
 288      * constructor's formal parameter types.  For example:
 289      * <pre>
 290      *    public java.util.Hashtable(int,float)
 291      * </pre>
 292      *
 293      * <p>The only possible modifiers for constructors are the access
 294      * modifiers {@code public}, {@code protected} or
 295      * {@code private}.  Only one of these may appear, or none if the
 296      * constructor has default (package) access.
 297      *
 298      * @return a string describing this {@code Constructor}
 299      * @jls 8.8.3. Constructor Modifiers

 300      */
 301     public String toString() {
 302         return sharedToString(Modifier.constructorModifiers(),
 303                               false,
 304                               parameterTypes,
 305                               exceptionTypes);
 306     }
 307 
 308     @Override
 309     void specificToStringHeader(StringBuilder sb) {
 310         sb.append(getDeclaringClass().getTypeName());
 311     }
 312 
 313     /**
 314      * Returns a string describing this {@code Constructor},
 315      * including type parameters.  The string is formatted as the
 316      * constructor access modifiers, if any, followed by an
 317      * angle-bracketed comma separated list of the constructor's type
 318      * parameters, if any, followed by the fully-qualified name of the
 319      * declaring class, followed by a parenthesized, comma-separated


 325      * "<tt><i>Type</i>...</tt>".
 326      *
 327      * A space is used to separate access modifiers from one another
 328      * and from the type parameters or return type.  If there are no
 329      * type parameters, the type parameter list is elided; if the type
 330      * parameter list is present, a space separates the list from the
 331      * class name.  If the constructor is declared to throw
 332      * exceptions, the parameter list is followed by a space, followed
 333      * by the word "{@code throws}" followed by a
 334      * comma-separated list of the thrown exception types.
 335      *
 336      * <p>The only possible modifiers for constructors are the access
 337      * modifiers {@code public}, {@code protected} or
 338      * {@code private}.  Only one of these may appear, or none if the
 339      * constructor has default (package) access.
 340      *
 341      * @return a string describing this {@code Constructor},
 342      * include type parameters
 343      *
 344      * @since 1.5
 345      * @jls 8.8.3. Constructor Modifiers

 346      */
 347     @Override
 348     public String toGenericString() {
 349         return sharedToGenericString(Modifier.constructorModifiers(), false);
 350     }
 351 
 352     @Override
 353     void specificToGenericStringHeader(StringBuilder sb) {
 354         specificToStringHeader(sb);
 355     }
 356 
 357     /**
 358      * Uses the constructor represented by this {@code Constructor} object to
 359      * create and initialize a new instance of the constructor's
 360      * declaring class, with the specified initialization parameters.
 361      * Individual parameters are automatically unwrapped to match
 362      * primitive formal parameters, and both primitive and reference
 363      * parameters are subject to method invocation conversions as necessary.
 364      *
 365      * <p>If the number of formal parameters required by the underlying constructor




 279     public int hashCode() {
 280         return getDeclaringClass().getName().hashCode();
 281     }
 282 
 283     /**
 284      * Returns a string describing this {@code Constructor}.  The string is
 285      * formatted as the constructor access modifiers, if any,
 286      * followed by the fully-qualified name of the declaring class,
 287      * followed by a parenthesized, comma-separated list of the
 288      * constructor's formal parameter types.  For example:
 289      * <pre>
 290      *    public java.util.Hashtable(int,float)
 291      * </pre>
 292      *
 293      * <p>The only possible modifiers for constructors are the access
 294      * modifiers {@code public}, {@code protected} or
 295      * {@code private}.  Only one of these may appear, or none if the
 296      * constructor has default (package) access.
 297      *
 298      * @return a string describing this {@code Constructor}
 299      * @jls 8.8.3 Constructor Modifiers
 300      * @jls 8.9.2 Enum Body Declarations 
 301      */
 302     public String toString() {
 303         return sharedToString(Modifier.constructorModifiers(),
 304                               false,
 305                               parameterTypes,
 306                               exceptionTypes);
 307     }
 308 
 309     @Override
 310     void specificToStringHeader(StringBuilder sb) {
 311         sb.append(getDeclaringClass().getTypeName());
 312     }
 313 
 314     /**
 315      * Returns a string describing this {@code Constructor},
 316      * including type parameters.  The string is formatted as the
 317      * constructor access modifiers, if any, followed by an
 318      * angle-bracketed comma separated list of the constructor's type
 319      * parameters, if any, followed by the fully-qualified name of the
 320      * declaring class, followed by a parenthesized, comma-separated


 326      * "<tt><i>Type</i>...</tt>".
 327      *
 328      * A space is used to separate access modifiers from one another
 329      * and from the type parameters or return type.  If there are no
 330      * type parameters, the type parameter list is elided; if the type
 331      * parameter list is present, a space separates the list from the
 332      * class name.  If the constructor is declared to throw
 333      * exceptions, the parameter list is followed by a space, followed
 334      * by the word "{@code throws}" followed by a
 335      * comma-separated list of the thrown exception types.
 336      *
 337      * <p>The only possible modifiers for constructors are the access
 338      * modifiers {@code public}, {@code protected} or
 339      * {@code private}.  Only one of these may appear, or none if the
 340      * constructor has default (package) access.
 341      *
 342      * @return a string describing this {@code Constructor},
 343      * include type parameters
 344      *
 345      * @since 1.5
 346      * @jls 8.8.3 Constructor Modifiers
 347      * @jls 8.9.2 Enum Body Declarations 
 348      */
 349     @Override
 350     public String toGenericString() {
 351         return sharedToGenericString(Modifier.constructorModifiers(), false);
 352     }
 353 
 354     @Override
 355     void specificToGenericStringHeader(StringBuilder sb) {
 356         specificToStringHeader(sb);
 357     }
 358 
 359     /**
 360      * Uses the constructor represented by this {@code Constructor} object to
 361      * create and initialize a new instance of the constructor's
 362      * declaring class, with the specified initialization parameters.
 363      * Individual parameters are automatically unwrapped to match
 364      * primitive formal parameters, and both primitive and reference
 365      * parameters are subject to method invocation conversions as necessary.
 366      *
 367      * <p>If the number of formal parameters required by the underlying constructor


< prev index next >