aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/javassist/ClassPoolBench.java
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2011-08-31 10:29:34 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2011-08-31 10:29:34 +0000
commitd72870bfb6b09927e10944bdd129ce18dfcf7366 (patch)
tree27f56e4d1523a8cecc8976df60155e6b8429e504 /src/test/javassist/ClassPoolBench.java
parent76a1cba9c433e8242bb6648e72b3ed43c7a4995a (diff)
downloadjavassist-d72870bfb6b09927e10944bdd129ce18dfcf7366.tar.gz
javassist-d72870bfb6b09927e10944bdd129ce18dfcf7366.zip
JvstTest test case.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@589 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/test/javassist/ClassPoolBench.java')
-rw-r--r--src/test/javassist/ClassPoolBench.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/javassist/ClassPoolBench.java b/src/test/javassist/ClassPoolBench.java
new file mode 100644
index 00000000..d3cb6b2d
--- /dev/null
+++ b/src/test/javassist/ClassPoolBench.java
@@ -0,0 +1,57 @@
+package javassist;
+
+import java.util.Enumeration;
+import java.util.zip.*;
+
+public class ClassPoolBench {
+ static ClassPool cp;
+ static boolean mod = false, detach = false, readonly = false;
+
+ public static void accessClass(String name) throws Exception {
+ CtClass cc = cp.get(name);
+ System.out.println(cc.getName());
+ cc.getSuperclass();
+ if (mod)
+ cc.getClassFile();
+
+ if (detach)
+ cc.stopPruning(true);
+
+ if (!readonly)
+ cc.toBytecode();
+
+ if (detach)
+ cc.detach();
+ }
+
+ public static void accessAll(String filename) throws Exception {
+ ZipFile zip = new ZipFile(filename);
+ Enumeration files = zip.entries();
+ while (files.hasMoreElements()) {
+ ZipEntry z = (ZipEntry)files.nextElement();
+ String name = z.getName();
+ if (name.endsWith(".class")) {
+ name = name.substring(0, name.length() - 6)
+ .replace('/', '.');
+ accessClass(name);
+ }
+ }
+
+ zip.close();
+ }
+
+ public static void main(String[] args) throws Exception {
+ cp = ClassPool.getDefault();
+ cp.appendClassPath(args[0]);
+ if (args[1].equals("true"))
+ mod = true;
+ else if (args[1].equals("detach"))
+ mod = detach = true;
+ else if (args[1].equals("read"))
+ readonly = true;
+
+ System.err.println("mod: " + mod + " detach: " + detach
+ + " readonly: " + readonly);
+ accessAll(args[0]);
+ }
+}