diff options
author | chibash <chiba@javassist.org> | 2015-02-04 01:20:21 +0900 |
---|---|---|
committer | chibash <chiba@javassist.org> | 2015-02-04 01:20:21 +0900 |
commit | c43f4a7cde41d04095feb027f33f3ab4da7248bd (patch) | |
tree | bada37243778b56128ca3b505685e8d49224d5a3 /src/main/javassist/ClassPool.java | |
parent | e59339343a538699b632bd9fa0cf4f251ab6f3ee (diff) | |
download | javassist-c43f4a7cde41d04095feb027f33f3ab4da7248bd.tar.gz javassist-c43f4a7cde41d04095feb027f33f3ab4da7248bd.zip |
updated javadoc comments. makeClass(ClassFile cf) was added to ClassPool.
Diffstat (limited to 'src/main/javassist/ClassPool.java')
-rw-r--r-- | src/main/javassist/ClassPool.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java index a1e46e2e..c90c2c74 100644 --- a/src/main/javassist/ClassPool.java +++ b/src/main/javassist/ClassPool.java @@ -31,6 +31,8 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.ArrayList; import java.util.Enumeration; + +import javassist.bytecode.ClassFile; import javassist.bytecode.Descriptor; /** @@ -736,6 +738,54 @@ public class ClassPool { /** * Creates a new class (or interface) from the given class file. + * If there already exists a class with the same name, the new class + * overwrites that previous class. + * + * <p>This method is used for creating a <code>CtClass</code> object + * directly from a class file. The qualified class name is obtained + * from the class file; you do not have to explicitly give the name. + * + * @param classfile class file. + * @throws RuntimeException if there is a frozen class with the + * the same name. + * @since 3.20 + */ + public CtClass makeClass(ClassFile classfile) + throws RuntimeException + { + return makeClass(classfile, true); + } + + /** + * Creates a new class (or interface) from the given class file. + * If there already exists a class with the same name, the new class + * overwrites that previous class. + * + * <p>This method is used for creating a <code>CtClass</code> object + * directly from a class file. The qualified class name is obtained + * from the class file; you do not have to explicitly give the name. + * + * @param classfile class file. + * @param ifNotFrozen throws a RuntimeException if this parameter is true + * and there is a frozen class with the same name. + * @since 3.20 + */ + public CtClass makeClass(ClassFile classfile, boolean ifNotFrozen) + throws RuntimeException + { + compress(); + CtClass clazz = new CtClassType(classfile, this); + clazz.checkModify(); + String classname = clazz.getName(); + if (ifNotFrozen) + checkNotFrozen(classname); + + cacheCtClass(classname, clazz, true); + return clazz; + } + + /** + * Creates a new class (or interface) from the given class file. * If there already exists a class with the same name, this method * returns the existing class; a new class is never created from * the given class file. |