< prev index next >

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

Print this page




3486         if (loader == null)
3487             return desiredAssertionStatus0(this);
3488 
3489         // If the classloader has been initialized with the assertion
3490         // directives, ask it. Otherwise, ask the VM.
3491         synchronized(loader.assertionLock) {
3492             if (loader.classAssertionStatus != null) {
3493                 return loader.desiredAssertionStatus(getName());
3494             }
3495         }
3496         return desiredAssertionStatus0(this);
3497     }
3498 
3499     // Retrieves the desired assertion status of this class from the VM
3500     private static native boolean desiredAssertionStatus0(Class<?> clazz);
3501 
3502     /**
3503      * Returns true if and only if this class was declared as an enum in the
3504      * source code.
3505      *
3506      * Note that if an enum constant is declared with a class body,


3507      * the class of that enum constant object is an anonymous class
3508      * and <em>not</em> the class of the declaring enum type. The
3509      * {@link Enum#getDeclaringClass} method of an enum constant can
3510      * be used to get the class of the enum type declaring the
3511      * constant.
3512      *
3513      * @return true if and only if this class was declared as an enum in the
3514      *     source code
3515      * @since 1.5
3516      * @jls 8.9.1 Enum Constants
3517      */
3518     public boolean isEnum() {
3519         // An enum must both directly extend java.lang.Enum and have
3520         // the ENUM bit set; classes for specialized enum constants
3521         // don't do the former.
3522         return (this.getModifiers() & ENUM) != 0 &&
3523         this.getSuperclass() == java.lang.Enum.class;
3524     }
3525 
3526     // Fetches the factory for reflective objects




3486         if (loader == null)
3487             return desiredAssertionStatus0(this);
3488 
3489         // If the classloader has been initialized with the assertion
3490         // directives, ask it. Otherwise, ask the VM.
3491         synchronized(loader.assertionLock) {
3492             if (loader.classAssertionStatus != null) {
3493                 return loader.desiredAssertionStatus(getName());
3494             }
3495         }
3496         return desiredAssertionStatus0(this);
3497     }
3498 
3499     // Retrieves the desired assertion status of this class from the VM
3500     private static native boolean desiredAssertionStatus0(Class<?> clazz);
3501 
3502     /**
3503      * Returns true if and only if this class was declared as an enum in the
3504      * source code.
3505      *
3506      * Note that {@link java.lang.Enum} is not itself an enum type.
3507      *
3508      * Also note that if an enum constant is declared with a class body,
3509      * the class of that enum constant object is an anonymous class
3510      * and <em>not</em> the class of the declaring enum type. The
3511      * {@link Enum#getDeclaringClass} method of an enum constant can
3512      * be used to get the class of the enum type declaring the
3513      * constant.
3514      *
3515      * @return true if and only if this class was declared as an enum in the
3516      *     source code
3517      * @since 1.5
3518      * @jls 8.9.1 Enum Constants
3519      */
3520     public boolean isEnum() {
3521         // An enum must both directly extend java.lang.Enum and have
3522         // the ENUM bit set; classes for specialized enum constants
3523         // don't do the former.
3524         return (this.getModifiers() & ENUM) != 0 &&
3525         this.getSuperclass() == java.lang.Enum.class;
3526     }
3527 
3528     // Fetches the factory for reflective objects


< prev index next >