From 6aaacd96767eae3bf716a542ac67bcff7336380d Mon Sep 17 00:00:00 2001 From: chiba Date: Thu, 27 Oct 2005 11:04:32 +0000 Subject: Implemented CtConstructor#toMethod(). git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@212 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- tutorial/tutorial.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tutorial') diff --git a/tutorial/tutorial.html b/tutorial/tutorial.html index 29c56a68..c2d54a87 100644 --- a/tutorial/tutorial.html +++ b/tutorial/tutorial.html @@ -63,6 +63,8 @@ In the case of the program shown above, the test.Rectangle is obtained from the ClassPool object and it is assigned to a variable cc. +The ClassPool object returned by getDfault() +searches the default system search path.

From the implementation viewpoint, ClassPool is a hash table of CtClass objects, which uses the class names as @@ -90,6 +92,17 @@ modified bytecode. To obtain the bytecode, call toBytecode(): byte[] b = cc.toBytecode(); +

You can directly load the CtClass as well: + +

+ +

toClass() requests the context class loader for the current +thread to load the class file represented by the CtClass. It +returns a java.lang.Class object representing the loaded class. +For more details, please see the following section. +

Defining a new class

@@ -483,7 +496,7 @@ the easiest way for modifying the classes is as follows: ClassPool.get(),
  • 2. Modify it, and
  • 3. Call writeFile() or toBytecode() - on that CtClass object. + on that CtClass object to obtain a modified class file.

    If whether a class is modified or not is determined at load time, @@ -496,7 +509,9 @@ by Javassist.


    +

    3.1 The toClass method in CtClass

    +

    The CtClass provides a convenience method toClass(), which requests the context class loader for -- cgit v1.2.3