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.
javassist.ClassPath , ClassPool#insertClassPath(ClassPath), ClassPool#appendClassPath(ClassPath), ClassPool#makeClass(InputStream)
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| protected byte[] | |
| protected String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public URL | find(String
a fully-qualified class name. classname)Implements javassist. Obtains the URL. |
| public InputStream | openClassfile(String
a fully-qualified class name classname)Implements javassist. Opens the class file. |
| public String |
| classfile | back to summary |
|---|---|
| protected byte[] classfile | |
| classname | back to summary |
|---|---|
| protected String classname | |
| ByteArrayClassPath | back to summary |
|---|---|
| public ByteArrayClassPath(String name, byte[] classfile) | |
| find | back to summary |
|---|---|
| public URL find(String classname) Implements javassist. Obtains the URL.
| |
| openClassfile | back to summary |
|---|---|
| public InputStream openClassfile(String classname) Implements javassist. Opens the class file.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | connect()
Implements abstract java. Opens a communications link to the resource referenced by this URL, if such a connection has not already been established. |
| public int | getContentLength()
Overrides java. Returns the value of the |
| public InputStream | getInputStream()
Overrides java. Returns an input stream that reads from this open connection. |
| BytecodeURLConnection | back to summary |
|---|---|
| protected BytecodeURLConnection(URL url) | |
| connect | back to summary |
|---|---|
| public void connect() throws IOException Implements abstract java. Doc from java. Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
If the URLConnection objects go through two phases: first they are created, then they are connected. After being created, and before being connected, various options can be specified (e.g., doInput and UseCaches). After connecting, it is an error to try to set them. Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary.
| |
| getContentLength | back to summary |
|---|---|
| public int getContentLength() Overrides java. Doc from java. Returns the value of the Note
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws IOException Overrides java. Doc from java. Returns an input stream that reads from this open connection. A SocketTimeoutException can be thrown when reading from the returned input stream if the read timeout expires before data is available for read.
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| protected URLConnection | openConnection(final URL
the URL that this connects to. u)Implements abstract java. Opens a connection to the object referenced by the
|
| BytecodeURLStreamHandler | back to summary |
|---|---|
| private BytecodeURLStreamHandler() | |
| openConnection | back to summary |
|---|---|
| protected URLConnection openConnection(final URL u) Implements abstract java. Doc from java. Opens a connection to the object referenced by the
If for the handler's protocol (such as HTTP or JAR), there exists a public, specialized URLConnection subclass belonging to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net, the connection returned will be of that subclass. For example, for HTTP an HttpURLConnection will be returned, and for JAR a JarURLConnection will be returned.
| |