diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-08-18 15:22:38 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-08-18 15:22:38 +0000 |
commit | 2d60b1690e44dd33553e28618c7c0b25e4b34d9f (patch) | |
tree | b9a6b9c069e8ed045258c00d25708156401a838c /src/main/javassist/ClassPool.java | |
parent | ff329de74b48a2a8431024ae1097abbdac60aa8f (diff) | |
download | javassist-2d60b1690e44dd33553e28618c7c0b25e4b34d9f.tar.gz javassist-2d60b1690e44dd33553e28618c7c0b25e4b34d9f.zip |
modified the compiler to support "import".
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@195 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/ClassPool.java')
-rw-r--r-- | src/main/javassist/ClassPool.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java index 452f2e6f..e8b288e5 100644 --- a/src/main/javassist/ClassPool.java +++ b/src/main/javassist/ClassPool.java @@ -22,6 +22,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.util.Hashtable; +import java.util.Iterator; +import java.util.ArrayList; import javassist.bytecode.Descriptor; /** @@ -111,6 +113,8 @@ public class ClassPool { private static final int INIT_HASH_SIZE = 191; + private ArrayList importedPackages; + /** * Creates a root class pool. No parent class pool is specified. */ @@ -136,6 +140,7 @@ public class ClassPool { } this.cflow = null; + clearImportedPackages(); } /** @@ -214,6 +219,46 @@ public class ClassPool { } /** + * Record a package name so that the Javassist compiler searches + * the package to resolve a class name. + * Don't record the <code>java.lang</code> package, which has + * been implicitly recorded by default. + * + * <p>Note that <code>get()</code> in <code>ClassPool</code> does + * not search the recorded package. Only the compiler searches it. + * + * @param packageName the package name. + * It must not include the last '.' (dot). + * For example, "java.util" is valid but "java.util." is wrong. + * @since 3.1 + */ + public void importPackage(String packageName) { + importedPackages.add(packageName); + } + + /** + * Clear all the package names recorded by <code>importPackage()</code>. + * The <code>java.lang</code> package is not removed. + * + * @see #importPackage(String) + * @since 3.1 + */ + public void clearImportedPackages() { + importedPackages = new ArrayList(); + importedPackages.add("java.lang"); + } + + /** + * Returns all the package names recorded by <code>importPackage()</code>. + * + * @see #importPackage(String) + * @since 3.1 + */ + public Iterator getImportedPackages() { + return importedPackages.iterator(); + } + + /** * Records a name that never exists. * For example, a package name can be recorded by this method. * This would improve execution performance |