[jboss-cvs] javassist/tutorial ...
Shigeru Chiba
chiba at is.titech.ac.jp
Fri Jun 8 09:32:10 EDT 2007
User: chiba
Date: 07/06/08 09:32:10
Modified: tutorial tutorial.html
Log:
made automatic pruning off by default because I found that pruning does not really save memory (only 20%). I changed Javassist to compress a class file on memory after toBytecode().
Revision Changes Path
1.32 +33 -25 javassist/tutorial/tutorial.html
(In the diff below, changes in quantity of whitespace are not shown.)
Index: tutorial.html
===================================================================
RCS file: /cvsroot/jboss/javassist/tutorial/tutorial.html,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- tutorial.html 24 May 2007 07:46:56 -0000 1.31
+++ tutorial.html 8 Jun 2007 13:32:10 -0000 1.32
@@ -140,19 +140,37 @@
to modify a class file that has been already loaded since the JVM does
not allow reloading a class.
-<p>When Javassist freezes a <code>CtClass</code> object, it also
-prunes the data structure contained in that object. To reduce memory
-consumption, Javassist discards unnecessary attributes
+<p>A frozen <code>CtClass</code> can be defrost so that
+modifications of the class definition will be permitted. For example,
+
+<ul><pre>
+CtClasss cc = ...;
+ :
+cc.writeFile();
+cc.defrost();
+cc.setSuperclass(...); // OK since the class is not frozen.
+</pre></ul>
+
+<p>After <code>defrost()</code> is called, the <code>CtClass</code>
+object can be modified again.
+
+<p>If <code>ClassPool.doPruning</code> is set to <code>true</code>,
+then Javassist prunes the data structure contained
+in a <code>CtClass</code> object
+when Javassist freezes that object.
+To reduce memory
+consumption, pruning discards unnecessary attributes
(<code>attribute_info</code> structures) in that object.
For example, <code>Code_attribute</code> structures (method bodies)
are discarded.
Thus, after a
<code>CtClass</code> object is pruned, the bytecode of a method is not
-accessible although method names, signatures, and annotations
-are still accessible.
+accessible except method names, signatures, and annotations.
+The pruned <code>CtClass</code> object cannot be defrost again.
+The default value of <code>ClassPool.doPruning</code> is <code>false</code>.
-<p>To disallow pruning a <code>CtClass</code>, <code>stopPruning()</code>
-must be called in advance:
+<p>To disallow pruning a particular <code>CtClass</code>,
+<code>stopPruning()</code> must be called on that object in advance:
<ul><pre>
CtClasss cc = ...;
@@ -162,29 +180,19 @@
// cc is not pruned.
</pre></ul>
-<p>If a <code>CtClass</code> is not pruned, it can be defrost so that
-modifications of the class definition can be permitted. For example,
-
-<ul><pre>
-CtClasss cc = ...;
-cc.stopPruning(true);
- :
-cc.writeFile();
-cc.defrost();
-cc.setSuperclass(...); // OK since the class is not frozen.
-</pre></ul>
-
-<p>To disallow pruning for all the <code>CtClass</code>es, set
-<code>ClassPool.doPruning</code> to <code>false</code>.
+<p>The <code>CtClass</code> object <code>cc</code> is not pruned.
+Thus it can be defrost after <code>writeFile()</code> is called.
<ul><b>Note:</b>
-While debugging, you might want to temporarily stop pruning and write a modified
-class file to a disk drive. <code>debugWriteFile()</code> is a convenient method
-for that purpose. It stops pruning, write a class file, defrost it, and turn
-pruning on again (if it was initially on).
+While debugging, you might want to temporarily stop pruning and freezing
+and write a modified class file to a disk drive.
+<code>debugWriteFile()</code> is a convenient method
+for that purpose. It stops pruning, writes a class file, defrosts it,
+and turns pruning on again (if it was initially on).
</ul>
+
<h4>Class search path</h4>
<p>The default <code>ClassPool</code> returned
More information about the jboss-cvs-commits
mailing list