325 |
* @param klass the class whose simple name should be returned. |
* @param klass the class whose simple name should be returned. |
326 |
* @return the simple name for this class. |
* @return the simple name for this class. |
327 |
*/ |
*/ |
328 |
static String getSimpleName(Class<?> klass) |
static String getSimpleName(Class klass) |
329 |
{ |
{ |
330 |
if (isArray(klass)) |
if (isArray(klass)) |
331 |
{ |
{ |
387 |
* @return the annotations directly defined by the specified class. |
* @return the annotations directly defined by the specified class. |
388 |
* @since 1.5 |
* @since 1.5 |
389 |
*/ |
*/ |
390 |
static native Annotation[] getDeclaredAnnotations(Class<?> klass); |
static native Annotation[] getDeclaredAnnotations(Class klass); |
391 |
|
|
392 |
/** |
/** |
393 |
* <p> |
* <p> |
424 |
* class doesn't have a canonical name. |
* class doesn't have a canonical name. |
425 |
* @since 1.5 |
* @since 1.5 |
426 |
*/ |
*/ |
427 |
static String getCanonicalName(Class<?> klass) |
static String getCanonicalName(Class klass) |
428 |
{ |
{ |
429 |
if (isArray(klass)) |
if (isArray(klass)) |
430 |
{ |
{ |
452 |
* a top-level class. |
* a top-level class. |
453 |
* @since 1.5 |
* @since 1.5 |
454 |
*/ |
*/ |
455 |
static native Class<?> getEnclosingClass(Class<?> klass); |
static native Class getEnclosingClass(Class klass); |
456 |
|
|
457 |
/** |
/** |
458 |
* Returns the constructor which immediately encloses the specified class. |
* Returns the constructor which immediately encloses the specified class. |
466 |
* is returned. |
* is returned. |
467 |
* @since 1.5 |
* @since 1.5 |
468 |
*/ |
*/ |
469 |
static native Constructor<?> getEnclosingConstructor(Class<?> klass); |
static native Constructor getEnclosingConstructor(Class klass); |
470 |
|
|
471 |
/** |
/** |
472 |
* Returns the method which immediately encloses the specified class. If |
* Returns the method which immediately encloses the specified class. If |
480 |
* is returned. |
* is returned. |
481 |
* @since 1.5 |
* @since 1.5 |
482 |
*/ |
*/ |
483 |
static native Method getEnclosingMethod(Class<?> klass); |
static native Method getEnclosingMethod(Class klass); |
484 |
|
|
485 |
/** |
/** |
486 |
* <p> |
* Returns the class signature as specified in Class File Format |
487 |
* Returns an array of <code>Type</code> objects which represent the |
* chapter in the VM specification, or null if the class is not |
488 |
* interfaces directly implemented by the specified class or extended by the |
* generic. |
|
* specified interface. |
|
|
* </p> |
|
|
* <p> |
|
|
* If one of the superinterfaces is a parameterized type, then the |
|
|
* object returned for this interface reflects the actual type |
|
|
* parameters used in the source code. Type parameters are created |
|
|
* using the semantics specified by the <code>ParameterizedType</code> |
|
|
* interface, and only if an instance has not already been created. |
|
|
* </p> |
|
|
* <p> |
|
|
* The order of the interfaces in the array matches the order in which |
|
|
* the interfaces are declared. For classes which represent an array, |
|
|
* an array of two interfaces, <code>Cloneable</code> and |
|
|
* <code>Serializable</code>, is always returned, with the objects in |
|
|
* that order. A class representing a primitive type or void always |
|
|
* returns an array of zero size. |
|
|
* </p> |
|
489 |
* |
* |
490 |
* @param klass the class whose generic interfaces should be retrieved. |
* @param klass the klass to test. |
491 |
* @return an array of interfaces implemented or extended by the specified |
* @return a ClassSignature string. |
|
* class. |
|
|
* @throws GenericSignatureFormatError if the generic signature of one |
|
|
* of the interfaces does not comply with that specified by the Java |
|
|
* Virtual Machine specification, 3rd edition. |
|
|
* @throws TypeNotPresentException if any of the superinterfaces refers |
|
|
* to a non-existant type. |
|
|
* @throws MalformedParameterizedTypeException if any of the interfaces |
|
|
* refer to a parameterized type that can not be instantiated for |
|
|
* some reason. |
|
|
* @since 1.5 |
|
|
* @see java.lang.reflect.ParameterizedType |
|
|
*/ |
|
|
static native Type[] getGenericInterfaces(Class<?> klass); |
|
|
|
|
|
/** |
|
|
* <p> |
|
|
* Returns a <code>Type</code> object representing the direct superclass, |
|
|
* whether class, interface, primitive type or void, of the specified class. |
|
|
* If the class is an array class, then a class instance representing |
|
|
* the <code>Object</code> class is returned. If the class is primitive, |
|
|
* an interface, or a representation of either the <code>Object</code> |
|
|
* class or void, then <code>null</code> is returned. |
|
|
* </p> |
|
|
* <p> |
|
|
* If the superclass is a parameterized type, then the |
|
|
* object returned for this interface reflects the actual type |
|
|
* parameters used in the source code. Type parameters are created |
|
|
* using the semantics specified by the <code>ParameterizedType</code> |
|
|
* interface, and only if an instance has not already been created. |
|
|
* </p> |
|
|
* |
|
|
* @param klass the class whose generic superclass should be obtained. |
|
|
* @return the superclass of the specified class. |
|
|
* @throws GenericSignatureFormatError if the generic signature of the |
|
|
* class does not comply with that specified by the Java |
|
|
* Virtual Machine specification, 3rd edition. |
|
|
* @throws TypeNotPresentException if the superclass refers |
|
|
* to a non-existant type. |
|
|
* @throws MalformedParameterizedTypeException if the superclass |
|
|
* refers to a parameterized type that can not be instantiated for |
|
|
* some reason. |
|
|
* @since 1.5 |
|
|
* @see java.lang.reflect.ParameterizedType |
|
|
*/ |
|
|
static native Type getGenericSuperclass(Class<?> klass); |
|
|
|
|
|
/** |
|
|
* Returns an array of <code>TypeVariable</code> objects that represents |
|
|
* the type variables declared by the specified class, in declaration order. |
|
|
* An array of size zero is returned if the specified class has no type |
|
|
* variables. |
|
|
* |
|
|
* @param klass the class whose type variables should be returned. |
|
|
* @return the type variables associated with this class. |
|
|
* @throws GenericSignatureFormatError if the generic signature does |
|
|
* not conform to the format specified in the Virtual Machine |
|
|
* specification, version 3. |
|
492 |
* @since 1.5 |
* @since 1.5 |
493 |
*/ |
*/ |
494 |
static native <T> TypeVariable<Class<T>>[] getTypeParameters(Class<T> klass); |
static native String getClassSignature(Class klass); |
495 |
|
|
496 |
/** |
/** |
497 |
* Returns true if the specified class represents an anonymous class. |
* Returns true if the specified class represents an anonymous class. |
500 |
* @return true if the specified class represents an anonymous class. |
* @return true if the specified class represents an anonymous class. |
501 |
* @since 1.5 |
* @since 1.5 |
502 |
*/ |
*/ |
503 |
static native boolean isAnonymousClass(Class<?> klass); |
static native boolean isAnonymousClass(Class klass); |
504 |
|
|
505 |
/** |
/** |
506 |
* Returns true if the specified class represents an local class. |
* Returns true if the specified class represents an local class. |
509 |
* @return true if the specified class represents an local class. |
* @return true if the specified class represents an local class. |
510 |
* @since 1.5 |
* @since 1.5 |
511 |
*/ |
*/ |
512 |
static native boolean isLocalClass(Class<?> klass); |
static native boolean isLocalClass(Class klass); |
513 |
|
|
514 |
/** |
/** |
515 |
* Returns true if the specified class represents an member class. |
* Returns true if the specified class represents an member class. |
518 |
* @return true if the specified class represents an member class. |
* @return true if the specified class represents an member class. |
519 |
* @since 1.5 |
* @since 1.5 |
520 |
*/ |
*/ |
521 |
static native boolean isMemberClass(Class<?> klass); |
static native boolean isMemberClass(Class klass); |
522 |
|
|
523 |
} // class VMClass |
} // class VMClass |