diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-10-27 11:04:32 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-10-27 11:04:32 +0000 |
commit | 6aaacd96767eae3bf716a542ac67bcff7336380d (patch) | |
tree | 0d25da25d8702b5ddbe60aad26fa05a3c70e8d46 /src/main/javassist/CtMethod.java | |
parent | 0446eb7e747fd18bfed7eaf0ab0fe3a7c96aadc7 (diff) | |
download | javassist-6aaacd96767eae3bf716a542ac67bcff7336380d.tar.gz javassist-6aaacd96767eae3bf716a542ac67bcff7336380d.zip |
Implemented CtConstructor#toMethod().
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@212 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/CtMethod.java')
-rw-r--r-- | src/main/javassist/CtMethod.java | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/main/javassist/CtMethod.java b/src/main/javassist/CtMethod.java index 9c1532d0..043c8d3b 100644 --- a/src/main/javassist/CtMethod.java +++ b/src/main/javassist/CtMethod.java @@ -22,6 +22,7 @@ import javassist.bytecode.*; * * <p>See the super class <code>CtBehavior</code> since * a number of useful methods are in <code>CtBehavior</code>. + * A number of useful factory methods are in <code>CtNewMethod</code>. * * @see CtClass#getDeclaredMethods() * @see CtNewMethod @@ -106,30 +107,23 @@ public final class CtMethod extends CtBehavior { throws CannotCompileException { this(null, declaring); - MethodInfo srcInfo = src.methodInfo; - CtClass srcClass = src.getDeclaringClass(); - ConstPool cp = declaring.getClassFile2().getConstPool(); - if (map == null) - map = new ClassMap(); + copy(src, false, map); + } - map.put(srcClass.getName(), declaring.getName()); - try { - CtClass srcSuper = srcClass.getSuperclass(); - if (srcSuper != null) { - String srcSuperName = srcSuper.getName(); - if (!srcSuperName.equals(CtClass.javaLangObject)) - map.put(srcSuperName, - declaring.getSuperclass().getName()); - } - - methodInfo = new MethodInfo(cp, srcInfo.getName(), srcInfo, map); - } - catch (NotFoundException e) { - throw new CannotCompileException(e); - } - catch (BadBytecode e) { - throw new CannotCompileException(e); - } + /** + * Compiles the given source code and creates a method. + * This method simply delegates to <code>make()</code> in + * <code>CtNewMethod</code>. See it for more details. + * <code>CtNewMethod</code> has a number of useful factory methods. + * + * @param src the source text. + * @param declaring the class to which the created method is added. + * @see CtNewMethod.make(String, CtClass) + */ + public static CtMethod make(String src, CtClass declaring) + throws CannotCompileException + { + return CtNewMethod.make(src, declaring); } /** |