src/share/classes/javax/imageio/metadata/IIOMetadata.java

Print this page
rev 9344 : 8034998: Fix raw and unchecked lint warnings in javax.imageio
Reviewed-by: darcy, prr


 378         if (standardFormatSupported
 379             && formatName.equals
 380                 (IIOMetadataFormatImpl.standardMetadataFormatName)) {
 381             return IIOMetadataFormatImpl.getStandardFormatInstance();
 382         }
 383         String formatClassName = null;
 384         if (formatName.equals(nativeMetadataFormatName)) {
 385             formatClassName = nativeMetadataFormatClassName;
 386         } else if (extraMetadataFormatNames != null) {
 387             for (int i = 0; i < extraMetadataFormatNames.length; i++) {
 388                 if (formatName.equals(extraMetadataFormatNames[i])) {
 389                     formatClassName = extraMetadataFormatClassNames[i];
 390                     break;  // out of for
 391                 }
 392             }
 393         }
 394         if (formatClassName == null) {
 395             throw new IllegalArgumentException("Unsupported format name");
 396         }
 397         try {
 398             Class cls = null;
 399             final Object o = this;
 400 
 401             // firstly we try to use classloader used for loading
 402             // the IIOMetadata implemantation for this plugin.
 403             ClassLoader loader = (ClassLoader)
 404                 java.security.AccessController.doPrivileged(
 405                     new java.security.PrivilegedAction() {
 406                             public Object run() {
 407                                 return o.getClass().getClassLoader();
 408                             }
 409                         });
 410 
 411             try {
 412                 cls = Class.forName(formatClassName, true,
 413                                     loader);
 414             } catch (ClassNotFoundException e) {
 415                 // we failed to load IIOMetadataFormat class by
 416                 // using IIOMetadata classloader.Next try is to
 417                 // use thread context classloader.
 418                 loader = (ClassLoader)
 419                     java.security.AccessController.doPrivileged(
 420                         new java.security.PrivilegedAction() {
 421                                 public Object run() {
 422                                     return Thread.currentThread().getContextClassLoader();
 423                                 }
 424                         });
 425                 try {
 426                     cls = Class.forName(formatClassName, true,
 427                                         loader);
 428                 } catch (ClassNotFoundException e1) {
 429                     // finally we try to use system classloader in case
 430                     // if we failed to load IIOMetadataFormat implementation
 431                     // class above.
 432                     cls = Class.forName(formatClassName, true,
 433                                         ClassLoader.getSystemClassLoader());
 434                 }
 435             }
 436 
 437             Method meth = cls.getMethod("getInstance");
 438             return (IIOMetadataFormat) meth.invoke(null);
 439         } catch (Exception e) {
 440             RuntimeException ex =
 441                 new IllegalStateException ("Can't obtain format");




 378         if (standardFormatSupported
 379             && formatName.equals
 380                 (IIOMetadataFormatImpl.standardMetadataFormatName)) {
 381             return IIOMetadataFormatImpl.getStandardFormatInstance();
 382         }
 383         String formatClassName = null;
 384         if (formatName.equals(nativeMetadataFormatName)) {
 385             formatClassName = nativeMetadataFormatClassName;
 386         } else if (extraMetadataFormatNames != null) {
 387             for (int i = 0; i < extraMetadataFormatNames.length; i++) {
 388                 if (formatName.equals(extraMetadataFormatNames[i])) {
 389                     formatClassName = extraMetadataFormatClassNames[i];
 390                     break;  // out of for
 391                 }
 392             }
 393         }
 394         if (formatClassName == null) {
 395             throw new IllegalArgumentException("Unsupported format name");
 396         }
 397         try {
 398             Class<?> cls = null;
 399             final Object o = this;
 400 
 401             // firstly we try to use classloader used for loading
 402             // the IIOMetadata implemantation for this plugin.
 403             ClassLoader loader =
 404                 java.security.AccessController.doPrivileged(
 405                     new java.security.PrivilegedAction<ClassLoader>() {
 406                             public ClassLoader run() {
 407                                 return o.getClass().getClassLoader();
 408                             }
 409                         });
 410 
 411             try {
 412                 cls = Class.forName(formatClassName, true,
 413                                     loader);
 414             } catch (ClassNotFoundException e) {
 415                 // we failed to load IIOMetadataFormat class by
 416                 // using IIOMetadata classloader.Next try is to
 417                 // use thread context classloader.
 418                 loader =
 419                     java.security.AccessController.doPrivileged(
 420                         new java.security.PrivilegedAction<ClassLoader>() {
 421                                 public ClassLoader run() {
 422                                     return Thread.currentThread().getContextClassLoader();
 423                                 }
 424                         });
 425                 try {
 426                     cls = Class.forName(formatClassName, true,
 427                                         loader);
 428                 } catch (ClassNotFoundException e1) {
 429                     // finally we try to use system classloader in case
 430                     // if we failed to load IIOMetadataFormat implementation
 431                     // class above.
 432                     cls = Class.forName(formatClassName, true,
 433                                         ClassLoader.getSystemClassLoader());
 434                 }
 435             }
 436 
 437             Method meth = cls.getMethod("getInstance");
 438             return (IIOMetadataFormat) meth.invoke(null);
 439         } catch (Exception e) {
 440             RuntimeException ex =
 441                 new IllegalStateException ("Can't obtain format");