aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/ConstPool.java
diff options
context:
space:
mode:
authorejort <ejort@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2005-04-08 17:19:58 +0000
committerejort <ejort@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2005-04-08 17:19:58 +0000
commite2f3a2907491a7c9e3fe450e94598cbb8dd49f1c (patch)
tree8986f387c092f97b167e94c7e7fada7400006e61 /src/main/javassist/bytecode/ConstPool.java
parent6ab159e1f5f9053f6a25b3c99ed1649c7af1a6dc (diff)
downloadjavassist-e2f3a2907491a7c9e3fe450e94598cbb8dd49f1c.tar.gz
javassist-e2f3a2907491a7c9e3fe450e94598cbb8dd49f1c.zip
Add the ability to retrieve and change the Major/Minor versions of the ClassFile
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@165 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode/ConstPool.java')
-rw-r--r--src/main/javassist/bytecode/ConstPool.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/main/javassist/bytecode/ConstPool.java b/src/main/javassist/bytecode/ConstPool.java
index ad5edc5b..1676c116 100644
--- a/src/main/javassist/bytecode/ConstPool.java
+++ b/src/main/javassist/bytecode/ConstPool.java
@@ -20,8 +20,10 @@ import java.io.DataOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.io.IOException;
-import java.util.Map;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import javassist.CtClass;
/**
@@ -838,6 +840,25 @@ public final class ConstPool {
}
/**
+ * Get all the class names
+ *
+ * @return a set of class names
+ */
+ public Set getClassNames()
+ {
+ HashSet result = new HashSet();
+ LongVector v = items;
+ int size = numOfItems;
+ for (int i = 1; i < size; ++i)
+ {
+ String className = ((ConstInfo) v.elementAt(i)).getClassName(this);
+ if (className != null)
+ result.add(className);
+ }
+ return result;
+ }
+
+ /**
* Replaces all occurrences of a class name.
*
* @param oldName the replaced name
@@ -961,6 +982,7 @@ public final class ConstPool {
abstract class ConstInfo {
public abstract int getTag();
+ public String getClassName(ConstPool cp) { return null; }
public void renameClass(ConstPool cp, String oldName, String newName) {}
public void renameClass(ConstPool cp, Map classnames) {}
public abstract int copy(ConstPool src, ConstPool dest, Map classnames);
@@ -1010,6 +1032,11 @@ class ClassInfo extends ConstInfo {
public int getTag() { return tag; }
+ public String getClassName(ConstPool cp)
+ {
+ return cp.getUtf8Info(name);
+ };
+
public void renameClass(ConstPool cp, String oldName, String newName) {
String nameStr = cp.getUtf8Info(name);
if (nameStr.equals(oldName))