< prev index next >

src/java.management/share/classes/sun/management/MappedMXBeanType.java

Print this page
rev 10947 : 8055723: Replace concat String to append in StringBuilder parameters


 272     static class ArrayMXBeanType extends MappedMXBeanType {
 273         final Class<?> arrayClass;
 274         protected MappedMXBeanType componentType;
 275         protected MappedMXBeanType baseElementType;
 276 
 277         ArrayMXBeanType(Class<?> c) throws OpenDataException {
 278             this.arrayClass = c;
 279             this.componentType = getMappedType(c.getComponentType());
 280 
 281             StringBuilder className = new StringBuilder();
 282             Class<?> et = c;
 283             int dim;
 284             for (dim = 0; et.isArray(); dim++) {
 285                 className.append('[');
 286                 et = et.getComponentType();
 287             }
 288             baseElementType = getMappedType(et);
 289             if (et.isPrimitive()) {
 290                 className = new StringBuilder(c.getName());
 291             } else {
 292                 className.append("L" + baseElementType.getTypeName() + ";");
 293             }
 294             try {
 295                 mappedTypeClass = Class.forName(className.toString());
 296             } catch (ClassNotFoundException e) {
 297                 final OpenDataException ode =
 298                     new OpenDataException("Cannot obtain array class");
 299                 ode.initCause(e);
 300                 throw ode;
 301             }
 302 
 303             openType = new ArrayType<>(dim, baseElementType.getOpenType());
 304         }
 305 
 306         protected ArrayMXBeanType() {
 307             arrayClass = null;
 308         };
 309 
 310         Type getJavaType() {
 311             return arrayClass;
 312         }


 368     }
 369 
 370     static class GenericArrayMXBeanType extends ArrayMXBeanType {
 371         final GenericArrayType gtype;
 372         GenericArrayMXBeanType(GenericArrayType gat) throws OpenDataException {
 373             this.gtype = gat;
 374             this.componentType = getMappedType(gat.getGenericComponentType());
 375 
 376             StringBuilder className = new StringBuilder();
 377             Type elementType = gat;
 378             int dim;
 379             for (dim = 0; elementType instanceof GenericArrayType; dim++) {
 380                 className.append('[');
 381                 GenericArrayType et = (GenericArrayType) elementType;
 382                 elementType = et.getGenericComponentType();
 383             }
 384             baseElementType = getMappedType(elementType);
 385             if (elementType instanceof Class && ((Class) elementType).isPrimitive()) {
 386                 className = new StringBuilder(gat.toString());
 387             } else {
 388                 className.append("L" + baseElementType.getTypeName() + ";");
 389             }
 390             try {
 391                 mappedTypeClass = Class.forName(className.toString());
 392             } catch (ClassNotFoundException e) {
 393                 final OpenDataException ode =
 394                     new OpenDataException("Cannot obtain array class");
 395                 ode.initCause(e);
 396                 throw ode;
 397             }
 398 
 399             openType = new ArrayType<>(dim, baseElementType.getOpenType());
 400         }
 401 
 402         Type getJavaType() {
 403             return gtype;
 404         }
 405 
 406         String getName() {
 407             return gtype.toString();
 408         }




 272     static class ArrayMXBeanType extends MappedMXBeanType {
 273         final Class<?> arrayClass;
 274         protected MappedMXBeanType componentType;
 275         protected MappedMXBeanType baseElementType;
 276 
 277         ArrayMXBeanType(Class<?> c) throws OpenDataException {
 278             this.arrayClass = c;
 279             this.componentType = getMappedType(c.getComponentType());
 280 
 281             StringBuilder className = new StringBuilder();
 282             Class<?> et = c;
 283             int dim;
 284             for (dim = 0; et.isArray(); dim++) {
 285                 className.append('[');
 286                 et = et.getComponentType();
 287             }
 288             baseElementType = getMappedType(et);
 289             if (et.isPrimitive()) {
 290                 className = new StringBuilder(c.getName());
 291             } else {
 292                 className.append('L').append(baseElementType.getTypeName()).append(';');
 293             }
 294             try {
 295                 mappedTypeClass = Class.forName(className.toString());
 296             } catch (ClassNotFoundException e) {
 297                 final OpenDataException ode =
 298                     new OpenDataException("Cannot obtain array class");
 299                 ode.initCause(e);
 300                 throw ode;
 301             }
 302 
 303             openType = new ArrayType<>(dim, baseElementType.getOpenType());
 304         }
 305 
 306         protected ArrayMXBeanType() {
 307             arrayClass = null;
 308         };
 309 
 310         Type getJavaType() {
 311             return arrayClass;
 312         }


 368     }
 369 
 370     static class GenericArrayMXBeanType extends ArrayMXBeanType {
 371         final GenericArrayType gtype;
 372         GenericArrayMXBeanType(GenericArrayType gat) throws OpenDataException {
 373             this.gtype = gat;
 374             this.componentType = getMappedType(gat.getGenericComponentType());
 375 
 376             StringBuilder className = new StringBuilder();
 377             Type elementType = gat;
 378             int dim;
 379             for (dim = 0; elementType instanceof GenericArrayType; dim++) {
 380                 className.append('[');
 381                 GenericArrayType et = (GenericArrayType) elementType;
 382                 elementType = et.getGenericComponentType();
 383             }
 384             baseElementType = getMappedType(elementType);
 385             if (elementType instanceof Class && ((Class) elementType).isPrimitive()) {
 386                 className = new StringBuilder(gat.toString());
 387             } else {
 388                 className.append('L').append(baseElementType.getTypeName()).append(';');
 389             }
 390             try {
 391                 mappedTypeClass = Class.forName(className.toString());
 392             } catch (ClassNotFoundException e) {
 393                 final OpenDataException ode =
 394                     new OpenDataException("Cannot obtain array class");
 395                 ode.initCause(e);
 396                 throw ode;
 397             }
 398 
 399             openType = new ArrayType<>(dim, baseElementType.getOpenType());
 400         }
 401 
 402         Type getJavaType() {
 403             return gtype;
 404         }
 405 
 406         String getName() {
 407             return gtype.toString();
 408         }


< prev index next >