diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2004-05-18 08:43:47 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2004-05-18 08:43:47 +0000 |
commit | 37712645ade4a363aa5f02752c46a9f6fd3b9dc3 (patch) | |
tree | 7eee37b8227f7ba029bae0db0ffcc982192d0b8c /src/main/javassist/CtNewMethod.java | |
parent | e4990e08b3f35cf6e8b6f8ea1bb30bad2fcae6af (diff) | |
download | javassist-37712645ade4a363aa5f02752c46a9f6fd3b9dc3.tar.gz javassist-37712645ade4a363aa5f02752c46a9f6fd3b9dc3.zip |
minor and final changes for 3.0 beta
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@106 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/CtNewMethod.java')
-rw-r--r-- | src/main/javassist/CtNewMethod.java | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/main/javassist/CtNewMethod.java b/src/main/javassist/CtNewMethod.java index 2f8624d4..eb65b73e 100644 --- a/src/main/javassist/CtNewMethod.java +++ b/src/main/javassist/CtNewMethod.java @@ -82,7 +82,8 @@ public class CtNewMethod { } /** - * Creates a public method. + * Creates a public (non-static) method. The created method cannot + * be changed to a static method later. * * @param returnType the type of the returned value. * @param mname the method name. @@ -94,14 +95,42 @@ public class CtNewMethod { * does nothing except returning zero or null. * @param declaring the class to which the created method is added. */ - public static CtMethod make(CtClass returnType, String mname, - CtClass[] parameters, CtClass[] exceptions, + public static CtMethod make(CtClass returnType, + String mname, CtClass[] parameters, + CtClass[] exceptions, + String body, CtClass declaring) + throws CannotCompileException + { + return make(Modifier.PUBLIC, returnType, mname, parameters, exceptions, + body, declaring); + } + + /** + * Creates a method. + * + * @param modifiers access modifiers. + * @param returnType the type of the returned value. + * @param mname the method name. + * @param parameters a list of the parameter types. + * @param exceptions a list of the exception types. + * @param body the source text of the method body. + * It must be a block surrounded by <code>{}</code>. + * If it is <code>null</code>, the created method + * does nothing except returning zero or null. + * @param declaring the class to which the created method is added. + * + * @see Modifier + */ + public static CtMethod make(int modifiers, CtClass returnType, + String mname, CtClass[] parameters, + CtClass[] exceptions, String body, CtClass declaring) throws CannotCompileException { try { CtMethod cm = new CtMethod(returnType, mname, parameters, declaring); + cm.setModifiers(modifiers); cm.setExceptionTypes(exceptions); cm.setBody(body); return cm; |