aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/Class.java
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2007-02-01 20:34:08 +0000
committerTom Tromey <tromey@gcc.gnu.org>2007-02-01 20:34:08 +0000
commit0a32f469ac256a842ac1f721c37dab7ad2cf5e21 (patch)
tree045d28c226132bbb212ffd4956739e8e6fde799b /libjava/java/lang/Class.java
parent62e5bf5d4203458b41813a79213b3f513a4ca98c (diff)
downloadgcc-0a32f469ac256a842ac1f721c37dab7ad2cf5e21.zip
gcc-0a32f469ac256a842ac1f721c37dab7ad2cf5e21.tar.gz
gcc-0a32f469ac256a842ac1f721c37dab7ad2cf5e21.tar.bz2
Calendar.java: Implement Comparable<Calendar>.
* java/util/Calendar.java: Implement Comparable<Calendar>. Update comments. (clear): Call complete. (setTimeZone): Call computeTime, computeFields. (compareTo): New method. * java/nio/charset/Charset.java: Implement Comparable<Charset>. (availableCharsets): Genericized. (aliases): Likewise. (compareTo): Changed argument type. * java/lang/ClassLoader.java (loadClass): Genericized. (findClass): Likewise. (defineClass): Likewise. (resolveClass): Likewise. (findSystemClass): Likewise. (setSigners): Likewise. (findLoadedClass): Likewise. (getResources): Likewise. (findResources): Likewise. (getSystemResources): Likewise. (checkInitialized): New method. * java/lang/Class.java (getCanonicalName): New method. From-SVN: r121471
Diffstat (limited to 'libjava/java/lang/Class.java')
-rw-r--r--libjava/java/lang/Class.java55
1 files changed, 54 insertions, 1 deletions
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java
index a071ee3..b0151db 100644
--- a/libjava/java/lang/Class.java
+++ b/libjava/java/lang/Class.java
@@ -1,5 +1,5 @@
/* Class.java -- Representation of a Java class.
- Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation
This file is part of GNU Classpath.
@@ -1291,6 +1291,59 @@ public final class Class<T>
}
/**
+ * <p>
+ * Returns the canonical name of this class, as defined by section
+ * 6.7 of the Java language specification. Each package, top-level class,
+ * top-level interface and primitive type has a canonical name. A member
+ * class has a canonical name, if its parent class has one. Likewise,
+ * an array type has a canonical name, if its component type does.
+ * Local or anonymous classes do not have canonical names.
+ * </p>
+ * <p>
+ * The canonical name for top-level classes, top-level interfaces and
+ * primitive types is always the same as the fully-qualified name.
+ * For array types, the canonical name is the canonical name of its
+ * component type with `[]' appended.
+ * </p>
+ * <p>
+ * The canonical name of a member class always refers to the place where
+ * the class was defined, and is composed of the canonical name of the
+ * defining class and the simple name of the member class, joined by `.'.
+ * For example, if a <code>Person</code> class has an inner class,
+ * <code>M</code>, then both its fully-qualified name and canonical name
+ * is <code>Person.M</code>. A subclass, <code>Staff</code>, of
+ * <code>Person</code> refers to the same inner class by the fully-qualified
+ * name of <code>Staff.M</code>, but its canonical name is still
+ * <code>Person.M</code>.
+ * </p>
+ * <p>
+ * Where no canonical name is present, <code>null</code> is returned.
+ * </p>
+ *
+ * @return the canonical name of the class, or <code>null</code> if the
+ * class doesn't have a canonical name.
+ * @since 1.5
+ */
+ public String getCanonicalName()
+ {
+ if (isArray())
+ {
+ String componentName = getComponentType().getCanonicalName();
+ if (componentName != null)
+ return componentName + "[]";
+ }
+ if (isMemberClass())
+ {
+ String memberName = getDeclaringClass().getCanonicalName();
+ if (memberName != null)
+ return memberName + "." + getSimpleName();
+ }
+ if (isLocalClass() || isAnonymousClass())
+ return null;
+ return getName();
+ }
+
+ /**
* Returns all annotations directly defined by this class. If there are
* no annotations associated with this class, then a zero-length array
* will be returned. The returned array may be modified by the client