Class ClassFileLocator.ForUrl

java.lang.Object
net.bytebuddy.dynamic.ClassFileLocator.ForUrl
All Implemented Interfaces:
Closeable, AutoCloseable, ClassFileLocator
Enclosing interface:
ClassFileLocator

@Enhance public static class ClassFileLocator.ForUrl extends Object implements ClassFileLocator
A class file locator that reads class files from one or several URLs. The reading is accomplished via using an URLClassLoader. Doing so, boot loader resources might be located additionally to those found via the specified URLs.
  • Field Details

    • classLoader

      private final ClassLoader classLoader
      The class loader that delegates to the URLs.
  • Constructor Details

    • ForUrl

      public ForUrl(URL... url)
      Creates a new class file locator for the given URLs.
      Parameters:
      url - The URLs to search for class files.
    • ForUrl

      public ForUrl(Collection<? extends URL> urls)
      Creates a new class file locator for the given URLs.
      Parameters:
      urls - The URLs to search for class files.
  • Method Details

    • doPrivileged

      @Enhance private static <T> T doPrivileged(PrivilegedAction<T> action)
      A proxy for java.security.AccessController#doPrivileged that is activated if available.
      Type Parameters:
      T - The type of the action's resolved value.
      Parameters:
      action - The action to execute from a privileged context.
      Returns:
      The action's resolved value.
    • locate

      public ClassFileLocator.Resolution locate(String name) throws IOException
      Locates the class file for a given type and returns the binary data of the class file.
      Specified by:
      locate in interface ClassFileLocator
      Parameters:
      name - The name of the type to locate a class file representation for.
      Returns:
      Any binary representation of the type which might be illegal.
      Throws:
      IOException - If reading a class file causes an error.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException