Package javassist

Class ClassClassPath

  • All Implemented Interfaces:

    public class ClassClassPath
    extends java.lang.Object
    implements ClassPath
    A search-path for obtaining a class file by getResourceAsStream() in java.lang.Class.

    Try adding a ClassClassPath when a program is running with a user-defined class loader and any class files are not found with the default ClassPool. For example,

     ClassPool cp = ClassPool.getDefault();
     cp.insertClassPath(new ClassClassPath(this.getClass()));
    This code snippet permanently adds a ClassClassPath to the default ClassPool. Note that the default ClassPool is a singleton. The added ClassClassPath uses a class object representing the class including the code snippet above.

    Class files in a named module are private to that module. This method cannot obtain class files in named modules.

    See Also:
    ClassPool.insertClassPath(ClassPath), ClassPool.appendClassPath(ClassPath), LoaderClassPath
    • Constructor Summary

      Constructor Description
      ClassClassPath​(java.lang.Class<?> c)
      Creates a search path.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description find​(java.lang.String classname)
      Obtains the URL of the specified class file. openClassfile​(java.lang.String classname)
      Obtains a class file by getResourceAsStream().
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ClassClassPath

        public ClassClassPath​(java.lang.Class<?> c)
        Creates a search path.
        c - the Class object used to obtain a class file. getResourceAsStream() is called on this object.
    • Method Detail

      • openClassfile

        public openClassfile​(java.lang.String classname)
                                          throws NotFoundException
        Obtains a class file by getResourceAsStream().
        Specified by:
        openClassfile in interface ClassPath
        classname - a fully-qualified class name
        the input stream for reading a class file
        See Also:
      • find

        public find​(java.lang.String classname)
        Obtains the URL of the specified class file.
        Specified by:
        find in interface ClassPath
        classname - a fully-qualified class name.
        null if the class file could not be found.
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object