< prev index next >

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

Print this page




 221                     sb.append(' ');
 222                 }
 223 
 224                 if (isAnnotation()) {
 225                     sb.append('@');
 226                 }
 227                 if (isInterface()) { // Note: all annotation types are interfaces
 228                     sb.append("interface");
 229                 } else {
 230                     if (isEnum())
 231                         sb.append("enum");
 232                     else
 233                         sb.append("class");
 234                 }
 235                 sb.append(' ');
 236                 sb.append(getName());
 237             }
 238 
 239             TypeVariable<?>[] typeparms = component.getTypeParameters();
 240             if (typeparms.length > 0) {
 241                 boolean first = true;
 242                 sb.append('<');
 243                 for(TypeVariable<?> typeparm: typeparms) {
 244                     if (!first)
 245                         sb.append(',');
 246                     sb.append(typeparm.getTypeName());
 247                     first = false;
 248                 }
 249                 sb.append('>');
 250             }
 251 
 252             for (int i = 0; i < arrayDepth; i++)
 253                 sb.append("[]");
 254 
 255             return sb.toString();
 256         }
 257     }
 258 
 259     /**
 260      * Returns the {@code Class} object associated with the class or
 261      * interface with the given string name.  Invoking this method is
 262      * equivalent to:
 263      *
 264      * <blockquote>
 265      *  {@code Class.forName(className, true, currentLoader)}
 266      * </blockquote>
 267      *
 268      * where {@code currentLoader} denotes the defining class loader of
 269      * the current class.




 221                     sb.append(' ');
 222                 }
 223 
 224                 if (isAnnotation()) {
 225                     sb.append('@');
 226                 }
 227                 if (isInterface()) { // Note: all annotation types are interfaces
 228                     sb.append("interface");
 229                 } else {
 230                     if (isEnum())
 231                         sb.append("enum");
 232                     else
 233                         sb.append("class");
 234                 }
 235                 sb.append(' ');
 236                 sb.append(getName());
 237             }
 238 
 239             TypeVariable<?>[] typeparms = component.getTypeParameters();
 240             if (typeparms.length > 0) {
 241                 StringJoiner sj = new StringJoiner(",", "<", ">");

 242                 for(TypeVariable<?> typeparm: typeparms) {
 243                     sj.add(typeparm.getTypeName());



 244                 }
 245                 sb.append(sj.toString());
 246             }
 247 
 248             for (int i = 0; i < arrayDepth; i++)
 249                 sb.append("[]");
 250 
 251             return sb.toString();
 252         }
 253     }
 254 
 255     /**
 256      * Returns the {@code Class} object associated with the class or
 257      * interface with the given string name.  Invoking this method is
 258      * equivalent to:
 259      *
 260      * <blockquote>
 261      *  {@code Class.forName(className, true, currentLoader)}
 262      * </blockquote>
 263      *
 264      * where {@code currentLoader} denotes the defining class loader of
 265      * the current class.


< prev index next >