aboutsummaryrefslogtreecommitdiffstats
path: root/tutorial
diff options
context:
space:
mode:
Diffstat (limited to 'tutorial')
-rw-r--r--tutorial/tutorial.html19
-rw-r--r--tutorial/tutorial3.html8
2 files changed, 21 insertions, 6 deletions
diff --git a/tutorial/tutorial.html b/tutorial/tutorial.html
index 0598f60b..52a68e1c 100644
--- a/tutorial/tutorial.html
+++ b/tutorial/tutorial.html
@@ -400,6 +400,15 @@ program by a user-defined class loader. The latter one, as well as
the program of the user-defined class loader, should be loaded by the
system class loader.
+<ul>
+<b>Note:</b> The JVM does not allow dynamically reloading a class.
+Once a class loader loads a class, it cannot reload a modified
+version of that class during runtime. Thus, you cannot alter
+the definition of a class after the JVM loads it.
+However, the JPDA (Java Platform Debugger Architecture) provides
+limited ability for reloading a class. See "HotSwap" of JPDA for details.
+</ul>
+
<p><br>
<h3>4.1 Class loading in Java</h3>
@@ -589,15 +598,15 @@ The event-listener class must implement the following interface:
<ul><pre>public interface Translator {
public void start(ClassPool pool)
throws NotFoundException, CannotCompileException;
- public void onWrite(ClassPool pool, String classname)
+ public void onLoad(ClassPool pool, String classname)
throws NotFoundException, CannotCompileException;
}</pre></ul>
<p>The method <code>start()</code> is called when this event listener
is added to a <code>javassist.Loader</code> object by
<code>addTranslator()</code> in <code>javassist.Loader</code>. The
-method <code>onWrite()</code> is called before
-<code>javassist.Loader</code> loads a class. <code>onWrite()</code>
+method <code>onLoad()</code> is called before
+<code>javassist.Loader</code> loads a class. <code>onLoad()</code>
can modify the definition of the loaded class.
<p>For example, the following event listener changes all classes
@@ -606,7 +615,7 @@ to public classes just before they are loaded.
<ul><pre>public class MyTranslator implements Translator {
void start(ClassPool pool)
throws NotFoundException, CannotCompileException {}
- void onWrite(ClassPool pool, String classname)
+ void onLoad(ClassPool pool, String classname)
throws NotFoundException, CannotCompileException
{
CtClass cc = pool.get(classname);
@@ -614,7 +623,7 @@ to public classes just before they are loaded.
}
}</pre></ul>
-<p>Note that <code>onWrite()</code> does not have to call
+<p>Note that <code>onLoad()</code> does not have to call
<code>toBytecode()</code> or <code>writeFile()</code> since
<code>javassist.Loader</code> calls these methods to obtain a class
file.
diff --git a/tutorial/tutorial3.html b/tutorial/tutorial3.html
index 4b732978..c965a64c 100644
--- a/tutorial/tutorial3.html
+++ b/tutorial/tutorial3.html
@@ -84,10 +84,16 @@ In other words, a <code>FieldInfo</code> (or <code>MethodInfo</code> etc.) objec
must not be shared among different <code>ClassFile</code> objects.
<p>
-To remove a field or a method, you must first obtain a <code>java.util.List</code>
+To remove a field or a method,
+you must first obtain a <code>java.util.List</code>
object containing all the fields of the class. <code>getFields()</code>
and <code>getMethods()</code> return the lists. A field or a method can
be removed by calling <code>remove()</code> on the <code>List</code> object.
+An attribute can be removed in a similar way.
+Call <code>getAttributes()</code> in <code>FieldInfo</code> or
+<code>MethodInfo</code> to obtain the list of attributes,
+and remove one from the list.
+
<p><br>