<h2>Changes</h2>
+<p>-version 3.8.1
+<ul>
+ <li>CtClass.rebuildClassFile() has been added.
+</ul>
+
<p>-version 3.8.0 on June 13, 2008
<ul>
<li>javassist.bytecode.analysis was implemented.
<delete file="${dist-version}.zip"/>
<zip zipfile="${dist-version}.zip">
<zipfileset dir="${basedir}" prefix="${dist-version}">
- <include name="**"/>
- <exclude name=".*"/>
- <exclude name=".*/**"/>
- <exclude name="build/**"/>
- <exclude name="local/**"/>
- <exclude name="eclipse-output/**"/>
- <exclude name="${dist-version}.zip"/>
- <exclude name="${target-src.jar}"/>
+ <include name="html/**"/>
+ <include name="sample/**"/>
+ <include name="src/**"/>
+ <include name="tutorial/**"/>
+ <include name="*.html"/>
+ <include name="*.xml"/>
+ <include name="${target.jar}"/>
</zipfileset>
</zip>
</target>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>3</version>
- </parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss</groupId>
+ <groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<packaging>jar</packaging>
<description>Javassist (JAVA programming ASSISTant) makes Java bytecode manipulation
</dependencies>
</profile>
</profiles>
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Inc. Repository</name>
- <layout>default</layout>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
methodInfo.setAccessFlags(methodInfo.getAccessFlags()
& ~AccessFlag.ABSTRACT);
methodInfo.rebuildStackMapIf6(cc.getClassPool(), cc.getClassFile2());
+ declaringClass.rebuildClassFile();
}
catch (CompileError e) {
throw new CannotCompileException(e);
destInfo.setAccessFlags(destInfo.getAccessFlags()
& ~AccessFlag.ABSTRACT);
+ destClass.rebuildClassFile();
}
/**
public boolean stopPruning(boolean stop) { return true; }
/**
- * Discards unnecessary attributes, in particuar,
+ * Discards unnecessary attributes, in particular,
* <code>CodeAttribute</code>s (method bodies) of the class,
* to minimize the memory footprint.
* After calling this method, the class is read only.
*/
void incGetCounter() {}
+ /**
+ * If this method is called, the class file will be
+ * rebuilt when it is finally generated by
+ * <code>toBytecode()</code> and <code>writeFile()</code>.
+ * For a performance reason, the symbol table of the
+ * class file may contain unused entries, for example,
+ * after a method or a filed is deleted.
+ * This method
+ * removes those unused entries. This removal will
+ * minimize the size of the class file.
+ *
+ * @since 3.8.1
+ */
+ public void rebuildClassFile() {}
+
/**
* Converts this class to a class file.
* Once this method is called, further modifications are not
boolean wasChanged;
private boolean wasFrozen;
boolean wasPruned;
- boolean memberRemoved;
+ boolean gcConstPool; // if true, the constant pool entries will be garbage collected.
ClassFile classfile;
byte[] rawClassfile; // backup storage
CtClassType(String name, ClassPool cp) {
super(name);
classPool = cp;
- wasChanged = wasFrozen = wasPruned = memberRemoved = false;
+ wasChanged = wasFrozen = wasPruned = gcConstPool = false;
classfile = null;
rawClassfile = null;
memberCache = null;
ClassFile cf = getClassFile2();
if (cf.getFields().remove(fi)) {
getMembers().remove(f);
- memberRemoved = true;
+ gcConstPool = true;
}
else
throw new NotFoundException(f.toString());
ClassFile cf = getClassFile2();
if (cf.getMethods().remove(mi)) {
getMembers().remove(m);
- memberRemoved = true;
+ gcConstPool = true;
}
else
throw new NotFoundException(m.toString());
ClassFile cf = getClassFile2();
if (cf.getMethods().remove(mi)) {
getMembers().remove(m);
- memberRemoved = true;
+ gcConstPool = true;
}
else
throw new NotFoundException(m.toString());
getClassFile2().prune();
}
+ public void rebuildClassFile() { gcConstPool = true; }
+
public void toBytecode(DataOutputStream out)
throws CannotCompileException, IOException
{
if (isModified()) {
checkPruned("toBytecode");
ClassFile cf = getClassFile2();
- if (memberRemoved) {
+ if (gcConstPool) {
cf.compact();
- memberRemoved = false;
+ gcConstPool = false;
}
modifyClassConstructor(cf);