< prev index next >

src/jdk.attach/share/classes/com/sun/tools/attach/spi/AttachProvider.java

Print this page
rev 11875 : 8079360: AttachProviderImpl could not be instantiated
Reviewed-by:


 224      *
 225      *   <li>The JAR file contains a provider configuration named
 226      *   {@code com.sun.tools.attach.spi.AttachProvider} in the resource directory
 227      *   {@code META-INF/services}.</li>
 228      *
 229      *   <li>The provider configuration file lists the full-qualified class
 230      *   name of the AttachProvider implementation.</li>
 231      * </ul>
 232      *
 233      * <p> The format of the provider configuration file is one fully-qualified
 234      * class name per line. Space and tab characters surrounding each class name,
 235      * as well as blank lines are ignored. The comment character is
 236      *  {@code '#'} ({@code 0x23}), and on each line all characters following
 237      * the first comment character are ignored. The file must be encoded in
 238      * UTF-8.
 239      *
 240      * <p> AttachProvider implementations are loaded and instantiated
 241      * (using the zero-arg constructor) at the first invocation of this method.
 242      * The list returned by the first invocation of this method is the list
 243      * of providers. Subsequent invocations of this method return a list of the same
 244      * providers. The list is unmodifable.
 245      *
 246      * @return  A list of the installed attach providers.
 247      */
 248     public static List<AttachProvider> providers() {
 249         synchronized (lock) {
 250             if (providers == null) {
 251                 providers = new ArrayList<AttachProvider>();
 252 
 253                 ServiceLoader<AttachProvider> providerLoader =
 254                     ServiceLoader.load(AttachProvider.class,
 255                                        AttachProvider.class.getClassLoader());
 256 
 257                 Iterator<AttachProvider> i = providerLoader.iterator();
 258 
 259                 while (i.hasNext()) {
 260                     try {
 261                         providers.add(i.next());
 262                     } catch (Throwable t) {
 263                         if (t instanceof ThreadDeath) {
 264                             ThreadDeath td = (ThreadDeath)t;
 265                             throw td;
 266                         }
 267                         // Ignore errors and exceptions
 268                         System.err.println(t);
 269                     }
 270                 }
 271             }
 272             return Collections.unmodifiableList(providers);
 273         }
 274     }
 275 }


 224      *
 225      *   <li>The JAR file contains a provider configuration named
 226      *   {@code com.sun.tools.attach.spi.AttachProvider} in the resource directory
 227      *   {@code META-INF/services}.</li>
 228      *
 229      *   <li>The provider configuration file lists the full-qualified class
 230      *   name of the AttachProvider implementation.</li>
 231      * </ul>
 232      *
 233      * <p> The format of the provider configuration file is one fully-qualified
 234      * class name per line. Space and tab characters surrounding each class name,
 235      * as well as blank lines are ignored. The comment character is
 236      *  {@code '#'} ({@code 0x23}), and on each line all characters following
 237      * the first comment character are ignored. The file must be encoded in
 238      * UTF-8.
 239      *
 240      * <p> AttachProvider implementations are loaded and instantiated
 241      * (using the zero-arg constructor) at the first invocation of this method.
 242      * The list returned by the first invocation of this method is the list
 243      * of providers. Subsequent invocations of this method return a list of the same
 244      * providers. The list is unmodifiable.
 245      *
 246      * @return  A list of the installed attach providers.
 247      */
 248     public static List<AttachProvider> providers() {
 249         synchronized (lock) {
 250             if (providers == null) {
 251                 providers = new ArrayList<AttachProvider>();
 252 
 253                 ServiceLoader<AttachProvider> providerLoader =
 254                     ServiceLoader.load(AttachProvider.class,
 255                                        AttachProvider.class.getClassLoader());
 256 
 257                 Iterator<AttachProvider> i = providerLoader.iterator();
 258 
 259                 while (i.hasNext()) {
 260                     try {
 261                         providers.add(i.next());
 262                     } catch (Throwable t) {
 263                         if (t instanceof ThreadDeath) {
 264                             ThreadDeath td = (ThreadDeath)t;
 265                             throw td;
 266                         }
 267                         // Log errors and exceptions since we cannot return them
 268                         t.printStackTrace();
 269                     }
 270                 }
 271             }
 272             return Collections.unmodifiableList(providers);
 273         }
 274     }
 275 }
< prev index next >