public class ByteArrayClassPath extends java.lang.Object implements ClassPath
ByteArrayClassPath
contains bytes that is served as
a class file to a ClassPool
. It is useful to convert
a byte array to a CtClass
object.
For example, if you want to convert a byte array b
into a CtClass
object representing the class with a name
classname
, then do as following:
ClassPool cp = ClassPool.getDefault(); cp.insertClassPath(new ByteArrayClassPath(classname, b)); CtClass cc = cp.get(classname);
The ClassPool
object cp
uses the created
ByteArrayClassPath
object as the source of the class file.
A ByteArrayClassPath
must be instantiated for every
class. It contains only a single class file.
Constructor and Description |
---|
ByteArrayClassPath(java.lang.String name,
byte[] classfile) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this class path.
|
java.net.URL |
find(java.lang.String classname)
Obtains the URL.
|
java.io.InputStream |
openClassfile(java.lang.String classname)
Opens the class file.
|
java.lang.String |
toString() |
public ByteArrayClassPath(java.lang.String name, byte[] classfile)
public java.lang.String toString()
toString
in class java.lang.Object
public java.io.InputStream openClassfile(java.lang.String classname)
openClassfile
in interface ClassPath
classname
- a fully-qualified class nameTranslator
Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.