Package javassist
Class ByteArrayClassPath
- java.lang.Object
-
- javassist.ByteArrayClassPath
-
- All Implemented Interfaces:
ClassPath
public class ByteArrayClassPath extends Object implements ClassPath
AByteArrayClassPathcontains bytes that is served as a class file to aClassPool. It is useful to convert a byte array to aCtClassobject.For example, if you want to convert a byte array
binto aCtClassobject representing the class with a nameclassname, then do as following:ClassPool cp = ClassPool.getDefault(); cp.insertClassPath(new ByteArrayClassPath(classname, b)); CtClass cc = cp.get(classname);
The
ClassPoolobjectcpuses the createdByteArrayClassPathobject as the source of the class file.A
ByteArrayClassPathmust be instantiated for every class. It contains only a single class file.
-
-
Constructor Summary
Constructors Constructor Description ByteArrayClassPath(String name, byte[] classfile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URLfind(String classname)Obtains the URL.InputStreamopenClassfile(String classname)Opens the class file.StringtoString()
-
-
-
Constructor Detail
-
ByteArrayClassPath
public ByteArrayClassPath(String name, byte[] classfile)
-
-
Method Detail
-
openClassfile
public InputStream openClassfile(String classname)
Opens the class file.- Specified by:
openClassfilein interfaceClassPath- Parameters:
classname- a fully-qualified class name- Returns:
- the input stream for reading a class file
- See Also:
Translator
-
-