diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2007-05-24 10:54:41 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2007-05-24 10:54:41 +0000 |
commit | 9f548a4c38fe9bb54d33b06e5b89e6b556a7c4bd (patch) | |
tree | cd766796757652c582871e9cdee294b580f2767e | |
parent | fef3cedb4bd296532f9941b2847c9559d29eef4d (diff) | |
download | javassist-9f548a4c38fe9bb54d33b06e5b89e6b556a7c4bd.tar.gz javassist-9f548a4c38fe9bb54d33b06e5b89e6b556a7c4bd.zip |
a minor API extension.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@373 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r-- | src/main/javassist/ClassPool.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java index 2581ae85..51220a3e 100644 --- a/src/main/javassist/ClassPool.java +++ b/src/main/javassist/ClassPool.java @@ -586,11 +586,33 @@ public class ClassPool { public CtClass makeClass(InputStream classfile) throws IOException, 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. + * @see javassist.ByteArrayClassPath + */ + public CtClass makeClass(InputStream classfile, boolean ifNotFrozen) + throws IOException, RuntimeException + { classfile = new BufferedInputStream(classfile); CtClass clazz = new CtClassType(classfile, this); clazz.checkModify(); String classname = clazz.getName(); - checkNotFrozen(classname); + if (ifNotFrozen) + checkNotFrozen(classname); + cacheCtClass(classname, clazz, true); return clazz; } |