< prev index next >

src/java.base/share/classes/java/lang/Class.java

Print this page




3404     }
3405 
3406     private native Field[]       getDeclaredFields0(boolean publicOnly);
3407     private native Method[]      getDeclaredMethods0(boolean publicOnly);
3408     private native Constructor<T>[] getDeclaredConstructors0(boolean publicOnly);
3409     private native Class<?>[]   getDeclaredClasses0();
3410 
3411     /**
3412      * Helper method to get the method name from arguments.
3413      */
3414     private String methodToString(String name, Class<?>[] argTypes) {
3415         return getName() + '.' + name +
3416                 ((argTypes == null || argTypes.length == 0) ?
3417                 "()" :
3418                 Arrays.stream(argTypes)
3419                         .map(c -> c == null ? "null" : c.getName())
3420                         .collect(Collectors.joining(",", "(", ")")));
3421     }
3422 
3423     /** use serialVersionUID from JDK 1.1 for interoperability */

3424     private static final long serialVersionUID = 3206093459760846163L;
3425 
3426 
3427     /**
3428      * Class Class is special cased within the Serialization Stream Protocol.
3429      *
3430      * A Class instance is written initially into an ObjectOutputStream in the
3431      * following format:
3432      * <pre>
3433      *      {@code TC_CLASS} ClassDescriptor
3434      *      A ClassDescriptor is a special cased serialization of
3435      *      a {@code java.io.ObjectStreamClass} instance.
3436      * </pre>
3437      * A new handle is generated for the initial time the class descriptor
3438      * is written into the stream. Future references to the class descriptor
3439      * are written as references to the initial class descriptor instance.
3440      *
3441      * @see java.io.ObjectStreamClass
3442      */

3443     private static final ObjectStreamField[] serialPersistentFields =
3444         new ObjectStreamField[0];
3445 
3446 
3447     /**
3448      * Returns the assertion status that would be assigned to this
3449      * class if it were to be initialized at the time this method is invoked.
3450      * If this class has had its assertion status set, the most recent
3451      * setting will be returned; otherwise, if any package default assertion
3452      * status pertains to this class, the most recent setting for the most
3453      * specific pertinent package default assertion status is returned;
3454      * otherwise, if this class is not a system class (i.e., it has a
3455      * class loader) its class loader's default assertion status is returned;
3456      * otherwise, the system class default assertion status is returned.
3457      * <p>
3458      * Few programmers will have any need for this method; it is provided
3459      * for the benefit of the JRE itself.  (It allows a class to determine at
3460      * the time that it is initialized whether assertions should be enabled.)
3461      * Note that this method is not guaranteed to return the actual
3462      * assertion status that was (or will be) associated with the specified




3404     }
3405 
3406     private native Field[]       getDeclaredFields0(boolean publicOnly);
3407     private native Method[]      getDeclaredMethods0(boolean publicOnly);
3408     private native Constructor<T>[] getDeclaredConstructors0(boolean publicOnly);
3409     private native Class<?>[]   getDeclaredClasses0();
3410 
3411     /**
3412      * Helper method to get the method name from arguments.
3413      */
3414     private String methodToString(String name, Class<?>[] argTypes) {
3415         return getName() + '.' + name +
3416                 ((argTypes == null || argTypes.length == 0) ?
3417                 "()" :
3418                 Arrays.stream(argTypes)
3419                         .map(c -> c == null ? "null" : c.getName())
3420                         .collect(Collectors.joining(",", "(", ")")));
3421     }
3422 
3423     /** use serialVersionUID from JDK 1.1 for interoperability */
3424     @java.io.Serial
3425     private static final long serialVersionUID = 3206093459760846163L;
3426 
3427 
3428     /**
3429      * Class Class is special cased within the Serialization Stream Protocol.
3430      *
3431      * A Class instance is written initially into an ObjectOutputStream in the
3432      * following format:
3433      * <pre>
3434      *      {@code TC_CLASS} ClassDescriptor
3435      *      A ClassDescriptor is a special cased serialization of
3436      *      a {@code java.io.ObjectStreamClass} instance.
3437      * </pre>
3438      * A new handle is generated for the initial time the class descriptor
3439      * is written into the stream. Future references to the class descriptor
3440      * are written as references to the initial class descriptor instance.
3441      *
3442      * @see java.io.ObjectStreamClass
3443      */
3444     @java.io.Serial
3445     private static final ObjectStreamField[] serialPersistentFields =
3446         new ObjectStreamField[0];
3447 
3448 
3449     /**
3450      * Returns the assertion status that would be assigned to this
3451      * class if it were to be initialized at the time this method is invoked.
3452      * If this class has had its assertion status set, the most recent
3453      * setting will be returned; otherwise, if any package default assertion
3454      * status pertains to this class, the most recent setting for the most
3455      * specific pertinent package default assertion status is returned;
3456      * otherwise, if this class is not a system class (i.e., it has a
3457      * class loader) its class loader's default assertion status is returned;
3458      * otherwise, the system class default assertion status is returned.
3459      * <p>
3460      * Few programmers will have any need for this method; it is provided
3461      * for the benefit of the JRE itself.  (It allows a class to determine at
3462      * the time that it is initialized whether assertions should be enabled.)
3463      * Note that this method is not guaranteed to return the actual
3464      * assertion status that was (or will be) associated with the specified


< prev index next >