Class ZClassContext

java.lang.Object
dxt.scanpath.v2.bc.ZClassContext

public class ZClassContext extends Object
Provides access to class metadata discovered from configured classpath locations.

A context maintains the configured BinSource instances, an index of their BinFile entries, and the ZClass instances created from those entries. Call prepareIndex() after adding class paths and before querying class names or metadata.

Author:
indroneel
  • Constructor Details

    • ZClassContext

      public ZClassContext()
      Creates an empty class context with no configured class-path locations.
  • Method Details

    • appendClassPath

      public void appendClassPath(String path)
      Adds a class-path location to this context.

      Paths ending in .zip or .jar are treated as archive files. Other paths are treated as directories. The location is not indexed until prepareIndex() is called. Invalid or unreadable locations are ignored after a warning is logged.

      Parameters:
      path - the path to a class-file directory, ZIP archive, or JAR archive
    • prepareIndex

      public void prepareIndex()
      Rebuilds the class-file index from all classpath locations currently configured. Rebuilding also discards all previously created ZClass instances.
    • close

      public void close()
      Clears the indexed class files and cached class metadata.

      Configured classpath locations remain available and can be indexed again by calling prepareIndex().

    • listClassNames

      public List<String> listClassNames()
      Lists the fully qualified names of the class files in the current index.
      Returns:
      an immutable snapshot of the indexed class names
    • getZClass

      public ZClass getZClass(String clsName)
      Retrieves metadata for a class by fully qualified name.

      If the class is present in the current index, its bytecode is parsed and the resulting metadata is cached. If it is not indexed, a placeholder ZClass is created and cached.

      Parameters:
      clsName - the fully qualified class name
      Returns:
      the cached or newly created class metadata