123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816 |
- <!DOCTYPE HTML>
- <!-- NewPage -->
- <html lang="en">
- <head>
- <!-- Generated by javadoc (11) on Sat May 08 11:16:00 JST 2021 -->
- <title>CtNewMethod (Javassist API)</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="dc.created" content="2021-05-08">
- <link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
- <link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
- <script type="text/javascript" src="../script.js"></script>
- <script type="text/javascript" src="../jquery/jszip/dist/jszip.min.js"></script>
- <script type="text/javascript" src="../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
- <!--[if IE]>
- <script type="text/javascript" src="../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
- <![endif]-->
- <script type="text/javascript" src="../jquery/jquery-3.3.1.js"></script>
- <script type="text/javascript" src="../jquery/jquery-migrate-3.0.1.js"></script>
- <script type="text/javascript" src="../jquery/jquery-ui.js"></script>
- </head>
- <body>
- <script type="text/javascript"><!--
- try {
- if (location.href.indexOf('is-external=true') == -1) {
- parent.document.title="CtNewMethod (Javassist API)";
- }
- }
- catch(err) {
- }
- //-->
- var data = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9};
- var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
- var altColor = "altColor";
- var rowColor = "rowColor";
- var tableTab = "tableTab";
- var activeTableTab = "activeTableTab";
- var pathtoroot = "../";
- var useModuleDirectories = true;
- loadScripts(document, 'script');</script>
- <noscript>
- <div>JavaScript is disabled on your browser.</div>
- </noscript>
- <header role="banner">
- <nav role="navigation">
- <div class="fixedNav">
- <!-- ========= START OF TOP NAVBAR ======= -->
- <div class="topNav"><a id="navbar.top">
- <!-- -->
- </a>
- <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
- <a id="navbar.top.firstrow">
- <!-- -->
- </a>
- <ul class="navList" title="Navigation">
- <li><a href="../index.html">Overview</a></li>
- <li><a href="package-summary.html">Package</a></li>
- <li class="navBarCell1Rev">Class</li>
- <li><a href="class-use/CtNewMethod.html">Use</a></li>
- <li><a href="package-tree.html">Tree</a></li>
- <li><a href="../deprecated-list.html">Deprecated</a></li>
- <li><a href="../index-all.html">Index</a></li>
- </ul>
- </div>
- <div class="subNav">
- <ul class="navList" id="allclasses_navbar_top">
- <li><a href="../allclasses.html">All Classes</a></li>
- </ul>
- <ul class="navListSearch">
- <li><label for="search">SEARCH:</label>
- <input type="text" id="search" value="search" disabled="disabled">
- <input type="reset" id="reset" value="reset" disabled="disabled">
- </li>
- </ul>
- <div>
- <script type="text/javascript"><!--
- allClassesLink = document.getElementById("allclasses_navbar_top");
- if(window==top) {
- allClassesLink.style.display = "block";
- }
- else {
- allClassesLink.style.display = "none";
- }
- //-->
- </script>
- <noscript>
- <div>JavaScript is disabled on your browser.</div>
- </noscript>
- </div>
- <div>
- <ul class="subNavList">
- <li>Summary: </li>
- <li>Nested | </li>
- <li>Field | </li>
- <li><a href="#constructor.summary">Constr</a> | </li>
- <li><a href="#method.summary">Method</a></li>
- </ul>
- <ul class="subNavList">
- <li>Detail: </li>
- <li>Field | </li>
- <li><a href="#constructor.detail">Constr</a> | </li>
- <li><a href="#method.detail">Method</a></li>
- </ul>
- </div>
- <a id="skip.navbar.top">
- <!-- -->
- </a></div>
- <!-- ========= END OF TOP NAVBAR ========= -->
- </div>
- <div class="navPadding"> </div>
- <script type="text/javascript"><!--
- $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
- //-->
- </script>
- </nav>
- </header>
- <!-- ======== START OF CLASS DATA ======== -->
- <main role="main">
- <div class="header">
- <div class="subTitle"><span class="packageLabelInType">Package</span> <a href="package-summary.html">javassist</a></div>
- <h2 title="Class CtNewMethod" class="title">Class CtNewMethod</h2>
- </div>
- <div class="contentContainer">
- <ul class="inheritance">
- <li>java.lang.Object</li>
- <li>
- <ul class="inheritance">
- <li>javassist.CtNewMethod</li>
- </ul>
- </li>
- </ul>
- <div class="description">
- <ul class="blockList">
- <li class="blockList">
- <hr>
- <pre>public class <span class="typeNameLabel">CtNewMethod</span>
- extends java.lang.Object</pre>
- <div class="block">A collection of static methods for creating a <code>CtMethod</code>.
- An instance of this class does not make any sense.</div>
- <dl>
- <dt><span class="seeLabel">See Also:</span></dt>
- <dd><a href="CtClass.html#addMethod(javassist.CtMethod)"><code>CtClass.addMethod(CtMethod)</code></a></dd>
- </dl>
- </li>
- </ul>
- </div>
- <div class="summary">
- <ul class="blockList">
- <li class="blockList">
- <!-- ======== CONSTRUCTOR SUMMARY ======== -->
- <section role="region">
- <ul class="blockList">
- <li class="blockList"><a id="constructor.summary">
- <!-- -->
- </a>
- <h3>Constructor Summary</h3>
- <table class="memberSummary">
- <caption><span>Constructors</span><span class="tabEnd"> </span></caption>
- <tr>
- <th class="colFirst" scope="col">Constructor</th>
- <th class="colLast" scope="col">Description</th>
- </tr>
- <tr class="altColor">
- <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">CtNewMethod</a></span>()</code></th>
- <td class="colLast"> </td>
- </tr>
- </table>
- </li>
- </ul>
- </section>
- <!-- ========== METHOD SUMMARY =========== -->
- <section role="region">
- <ul class="blockList">
- <li class="blockList"><a id="method.summary">
- <!-- -->
- </a>
- <h3>Method Summary</h3>
- <table class="memberSummary">
- <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption>
- <tr>
- <th class="colFirst" scope="col">Modifier and Type</th>
- <th class="colSecond" scope="col">Method</th>
- <th class="colLast" scope="col">Description</th>
- </tr>
- <tr id="i0" class="altColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#abstractMethod(javassist.CtClass,java.lang.String,javassist.CtClass%5B%5D,javassist.CtClass%5B%5D,javassist.CtClass)">abstractMethod</a></span>​(<a href="CtClass.html" title="class in javassist">CtClass</a> returnType,
- java.lang.String mname,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] parameters,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] exceptions,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)</code></th>
- <td class="colLast">
- <div class="block">Creates a public abstract method.</div>
- </td>
- </tr>
- <tr id="i1" class="rowColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#copy(javassist.CtMethod,java.lang.String,javassist.CtClass,javassist.ClassMap)">copy</a></span>​(<a href="CtMethod.html" title="class in javassist">CtMethod</a> src,
- java.lang.String name,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring,
- <a href="ClassMap.html" title="class in javassist">ClassMap</a> map)</code></th>
- <td class="colLast">
- <div class="block">Creates a copy of a method with a new name.</div>
- </td>
- </tr>
- <tr id="i2" class="altColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#copy(javassist.CtMethod,javassist.CtClass,javassist.ClassMap)">copy</a></span>​(<a href="CtMethod.html" title="class in javassist">CtMethod</a> src,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring,
- <a href="ClassMap.html" title="class in javassist">ClassMap</a> map)</code></th>
- <td class="colLast">
- <div class="block">Creates a copy of a method.</div>
- </td>
- </tr>
- <tr id="i3" class="rowColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#delegator(javassist.CtMethod,javassist.CtClass)">delegator</a></span>​(<a href="CtMethod.html" title="class in javassist">CtMethod</a> delegate,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)</code></th>
- <td class="colLast">
- <div class="block">Creates a method forwarding to a delegate in
- a super class.</div>
- </td>
- </tr>
- <tr id="i4" class="altColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getter(java.lang.String,javassist.CtField)">getter</a></span>​(java.lang.String methodName,
- <a href="CtField.html" title="class in javassist">CtField</a> field)</code></th>
- <td class="colLast">
- <div class="block">Creates a public getter method.</div>
- </td>
- </tr>
- <tr id="i5" class="rowColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#make(int,javassist.CtClass,java.lang.String,javassist.CtClass%5B%5D,javassist.CtClass%5B%5D,java.lang.String,javassist.CtClass)">make</a></span>​(int modifiers,
- <a href="CtClass.html" title="class in javassist">CtClass</a> returnType,
- java.lang.String mname,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] parameters,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] exceptions,
- java.lang.String body,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)</code></th>
- <td class="colLast">
- <div class="block">Creates a method.</div>
- </td>
- </tr>
- <tr id="i6" class="altColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#make(java.lang.String,javassist.CtClass)">make</a></span>​(java.lang.String src,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)</code></th>
- <td class="colLast">
- <div class="block">Compiles the given source code and creates a method.</div>
- </td>
- </tr>
- <tr id="i7" class="rowColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#make(java.lang.String,javassist.CtClass,java.lang.String,java.lang.String)">make</a></span>​(java.lang.String src,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring,
- java.lang.String delegateObj,
- java.lang.String delegateMethod)</code></th>
- <td class="colLast">
- <div class="block">Compiles the given source code and creates a method.</div>
- </td>
- </tr>
- <tr id="i8" class="altColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#make(javassist.CtClass,java.lang.String,javassist.CtClass%5B%5D,javassist.CtClass%5B%5D,java.lang.String,javassist.CtClass)">make</a></span>​(<a href="CtClass.html" title="class in javassist">CtClass</a> returnType,
- java.lang.String mname,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] parameters,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] exceptions,
- java.lang.String body,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)</code></th>
- <td class="colLast">
- <div class="block">Creates a public (non-static) method.</div>
- </td>
- </tr>
- <tr id="i9" class="rowColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setter(java.lang.String,javassist.CtField)">setter</a></span>​(java.lang.String methodName,
- <a href="CtField.html" title="class in javassist">CtField</a> field)</code></th>
- <td class="colLast">
- <div class="block">Creates a public setter method.</div>
- </td>
- </tr>
- <tr id="i10" class="altColor">
- <td class="colFirst"><code>static <a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
- <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#wrapped(javassist.CtClass,java.lang.String,javassist.CtClass%5B%5D,javassist.CtClass%5B%5D,javassist.CtMethod,javassist.CtMethod.ConstParameter,javassist.CtClass)">wrapped</a></span>​(<a href="CtClass.html" title="class in javassist">CtClass</a> returnType,
- java.lang.String mname,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] parameterTypes,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] exceptionTypes,
- <a href="CtMethod.html" title="class in javassist">CtMethod</a> body,
- <a href="CtMethod.ConstParameter.html" title="class in javassist">CtMethod.ConstParameter</a> constParam,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)</code></th>
- <td class="colLast">
- <div class="block">Creates a wrapped method.</div>
- </td>
- </tr>
- </table>
- <ul class="blockList">
- <li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
- <!-- -->
- </a>
- <h3>Methods inherited from class java.lang.Object</h3>
- <code>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
- </ul>
- </li>
- </ul>
- </section>
- </li>
- </ul>
- </div>
- <div class="details">
- <ul class="blockList">
- <li class="blockList">
- <!-- ========= CONSTRUCTOR DETAIL ======== -->
- <section role="region">
- <ul class="blockList">
- <li class="blockList"><a id="constructor.detail">
- <!-- -->
- </a>
- <h3>Constructor Detail</h3>
- <a id="<init>()">
- <!-- -->
- </a>
- <ul class="blockListLast">
- <li class="blockList">
- <h4>CtNewMethod</h4>
- <pre>public CtNewMethod()</pre>
- </li>
- </ul>
- </li>
- </ul>
- </section>
- <!-- ============ METHOD DETAIL ========== -->
- <section role="region">
- <ul class="blockList">
- <li class="blockList"><a id="method.detail">
- <!-- -->
- </a>
- <h3>Method Detail</h3>
- <a id="make(java.lang.String,javassist.CtClass)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>make</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> make​(java.lang.String src,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Compiles the given source code and creates a method.
- The source code must include not only the method body
- but the whole declaration, for example,
-
- <pre>"public Object id(Object obj) { return obj; }"</pre></div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>src</code> - the source text.</dd>
- <dd><code>declaring</code> - the class to which the created method is added.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- </dl>
- </li>
- </ul>
- <a id="make(java.lang.String,javassist.CtClass,java.lang.String,java.lang.String)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>make</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> make​(java.lang.String src,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring,
- java.lang.String delegateObj,
- java.lang.String delegateMethod)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Compiles the given source code and creates a method.
- The source code must include not only the method body
- but the whole declaration, for example,
-
- <pre>"public Object id(Object obj) { return obj; }"</pre>
-
- <p>If the source code includes <code>$proceed()</code>, then
- it is compiled into a method call on the specified object.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>src</code> - the source text.</dd>
- <dd><code>declaring</code> - the class to which the created method is added.</dd>
- <dd><code>delegateObj</code> - the source text specifying the object
- that is called on by <code>$proceed()</code>.</dd>
- <dd><code>delegateMethod</code> - the name of the method
- that is called by <code>$proceed()</code>.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- </dl>
- </li>
- </ul>
- <a id="make(javassist.CtClass,java.lang.String,javassist.CtClass[],javassist.CtClass[],java.lang.String,javassist.CtClass)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>make</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> make​(<a href="CtClass.html" title="class in javassist">CtClass</a> returnType,
- java.lang.String mname,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] parameters,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] exceptions,
- java.lang.String body,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Creates a public (non-static) method. The created method cannot
- be changed to a static method later.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>returnType</code> - the type of the returned value.</dd>
- <dd><code>mname</code> - the method name.</dd>
- <dd><code>parameters</code> - a list of the parameter types.</dd>
- <dd><code>exceptions</code> - a list of the exception types.</dd>
- <dd><code>body</code> - 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.</dd>
- <dd><code>declaring</code> - the class to which the created method is added.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- <dt><span class="seeLabel">See Also:</span></dt>
- <dd><a href="#make(int,javassist.CtClass,java.lang.String,javassist.CtClass%5B%5D,javassist.CtClass%5B%5D,java.lang.String,javassist.CtClass)"><code>make(int, CtClass, String, CtClass[], CtClass[], String, CtClass)</code></a></dd>
- </dl>
- </li>
- </ul>
- <a id="make(int,javassist.CtClass,java.lang.String,javassist.CtClass[],javassist.CtClass[],java.lang.String,javassist.CtClass)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>make</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> make​(int modifiers,
- <a href="CtClass.html" title="class in javassist">CtClass</a> returnType,
- java.lang.String mname,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] parameters,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] exceptions,
- java.lang.String body,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Creates a method. <code>modifiers</code> can contain
- <code>Modifier.STATIC</code>.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>modifiers</code> - access modifiers.</dd>
- <dd><code>returnType</code> - the type of the returned value.</dd>
- <dd><code>mname</code> - the method name.</dd>
- <dd><code>parameters</code> - a list of the parameter types.</dd>
- <dd><code>exceptions</code> - a list of the exception types.</dd>
- <dd><code>body</code> - 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.</dd>
- <dd><code>declaring</code> - the class to which the created method is added.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- <dt><span class="seeLabel">See Also:</span></dt>
- <dd><a href="Modifier.html" title="class in javassist"><code>Modifier</code></a></dd>
- </dl>
- </li>
- </ul>
- <a id="copy(javassist.CtMethod,javassist.CtClass,javassist.ClassMap)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>copy</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> copy​(<a href="CtMethod.html" title="class in javassist">CtMethod</a> src,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring,
- <a href="ClassMap.html" title="class in javassist">ClassMap</a> map)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Creates a copy of a method. This method is provided for creating
- a new method based on an existing method.
- This is a convenience method for calling
- <a href="CtMethod.html#%3Cinit%3E(javassist.CtMethod,javassist.CtClass,javassist.ClassMap)"><code>this constructor</code></a>.
- See the description of the constructor for particular behavior of the copying.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>src</code> - the source method.</dd>
- <dd><code>declaring</code> - the class to which the created method is added.</dd>
- <dd><code>map</code> - the hash table associating original class names
- with substituted names.
- It can be <code>null</code>.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- <dt><span class="seeLabel">See Also:</span></dt>
- <dd><a href="CtMethod.html#%3Cinit%3E(javassist.CtMethod,javassist.CtClass,javassist.ClassMap)"><code>CtMethod(CtMethod,CtClass,ClassMap)</code></a></dd>
- </dl>
- </li>
- </ul>
- <a id="copy(javassist.CtMethod,java.lang.String,javassist.CtClass,javassist.ClassMap)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>copy</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> copy​(<a href="CtMethod.html" title="class in javassist">CtMethod</a> src,
- java.lang.String name,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring,
- <a href="ClassMap.html" title="class in javassist">ClassMap</a> map)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Creates a copy of a method with a new name.
- This method is provided for creating
- a new method based on an existing method.
- This is a convenience method for calling
- <a href="CtMethod.html#%3Cinit%3E(javassist.CtMethod,javassist.CtClass,javassist.ClassMap)"><code>this constructor</code></a>.
- See the description of the constructor for particular behavior of the copying.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>src</code> - the source method.</dd>
- <dd><code>name</code> - the name of the created method.</dd>
- <dd><code>declaring</code> - the class to which the created method is added.</dd>
- <dd><code>map</code> - the hash table associating original class names
- with substituted names.
- It can be <code>null</code>.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- <dt><span class="seeLabel">See Also:</span></dt>
- <dd><a href="CtMethod.html#%3Cinit%3E(javassist.CtMethod,javassist.CtClass,javassist.ClassMap)"><code>CtMethod(CtMethod,CtClass,ClassMap)</code></a></dd>
- </dl>
- </li>
- </ul>
- <a id="abstractMethod(javassist.CtClass,java.lang.String,javassist.CtClass[],javassist.CtClass[],javassist.CtClass)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>abstractMethod</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> abstractMethod​(<a href="CtClass.html" title="class in javassist">CtClass</a> returnType,
- java.lang.String mname,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] parameters,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] exceptions,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)
- throws <a href="NotFoundException.html" title="class in javassist">NotFoundException</a></pre>
- <div class="block">Creates a public abstract method.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>returnType</code> - the type of the returned value</dd>
- <dd><code>mname</code> - the method name</dd>
- <dd><code>parameters</code> - a list of the parameter types</dd>
- <dd><code>exceptions</code> - a list of the exception types</dd>
- <dd><code>declaring</code> - the class to which the created method is added.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="NotFoundException.html" title="class in javassist">NotFoundException</a></code></dd>
- <dt><span class="seeLabel">See Also:</span></dt>
- <dd><a href="CtMethod.html#%3Cinit%3E(javassist.CtClass,java.lang.String,javassist.CtClass%5B%5D,javassist.CtClass)"><code>CtMethod(CtClass,String,CtClass[],CtClass)</code></a></dd>
- </dl>
- </li>
- </ul>
- <a id="getter(java.lang.String,javassist.CtField)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>getter</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> getter​(java.lang.String methodName,
- <a href="CtField.html" title="class in javassist">CtField</a> field)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Creates a public getter method. The getter method returns the value
- of the specified field in the class to which this method is added.
- The created method is initially not static even if the field is
- static. Change the modifiers if the method should be static.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>methodName</code> - the name of the getter</dd>
- <dd><code>field</code> - the field accessed.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- </dl>
- </li>
- </ul>
- <a id="setter(java.lang.String,javassist.CtField)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>setter</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> setter​(java.lang.String methodName,
- <a href="CtField.html" title="class in javassist">CtField</a> field)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Creates a public setter method. The setter method assigns the
- value of the first parameter to the specified field
- in the class to which this method is added.
- The created method is not static even if the field is
- static. You may not change it to be static
- by <code>setModifiers()</code> in <code>CtBehavior</code>.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>methodName</code> - the name of the setter</dd>
- <dd><code>field</code> - the field accessed.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- </dl>
- </li>
- </ul>
- <a id="delegator(javassist.CtMethod,javassist.CtClass)">
- <!-- -->
- </a>
- <ul class="blockList">
- <li class="blockList">
- <h4>delegator</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> delegator​(<a href="CtMethod.html" title="class in javassist">CtMethod</a> delegate,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Creates a method forwarding to a delegate in
- a super class. The created method calls a method specified
- by <code>delegate</code> with all the parameters passed to the
- created method. If the delegate method returns a value,
- the created method returns that value to the caller.
- The delegate method must be declared in a super class.
-
- <p>The following method is an example of the created method.
-
- <pre>
- int f(int p, int q) {
- return super.f(p, q);
- }</pre>
-
- <p>The name of the created method can be changed by
- <code>setName()</code>.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>delegate</code> - the method that the created method forwards to.</dd>
- <dd><code>declaring</code> - the class to which the created method is
- added.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- </dl>
- </li>
- </ul>
- <a id="wrapped(javassist.CtClass,java.lang.String,javassist.CtClass[],javassist.CtClass[],javassist.CtMethod,javassist.CtMethod.ConstParameter,javassist.CtClass)">
- <!-- -->
- </a>
- <ul class="blockListLast">
- <li class="blockList">
- <h4>wrapped</h4>
- <pre class="methodSignature">public static <a href="CtMethod.html" title="class in javassist">CtMethod</a> wrapped​(<a href="CtClass.html" title="class in javassist">CtClass</a> returnType,
- java.lang.String mname,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] parameterTypes,
- <a href="CtClass.html" title="class in javassist">CtClass</a>[] exceptionTypes,
- <a href="CtMethod.html" title="class in javassist">CtMethod</a> body,
- <a href="CtMethod.ConstParameter.html" title="class in javassist">CtMethod.ConstParameter</a> constParam,
- <a href="CtClass.html" title="class in javassist">CtClass</a> declaring)
- throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
- <div class="block">Creates a wrapped method. The wrapped method receives parameters
- in the form of an array of <code>Object</code>.
-
- <p>The body of the created method is a copy of the body of the method
- specified by <code>body</code>. However, it is wrapped in
- parameter-conversion code.
-
- <p>The method specified by <code>body</code> must have this singature:
-
- <pre>Object method(Object[] params, <type> cvalue)</pre>
-
- <p>The type of the <code>cvalue</code> depends on
- <code>constParam</code>.
- If <code>constParam</code> is <code>null</code>, the signature
- must be:
-
- <pre>Object method(Object[] params)</pre>
-
- <p>The method body copied from <code>body</code> is wrapped in
- parameter-conversion code, which converts parameters specified by
- <code>parameterTypes</code> into an array of <code>Object</code>.
- The returned value is also converted from the <code>Object</code>
- type to the type specified by <code>returnType</code>. Thus,
- the resulting method body is as follows:
-
- <pre>
- Object[] params = new Object[] { p0, p1, ... };
- <<i>type</i>> cvalue = <<i>constant-value</i>>;
- <i>... copied method body ...</i>
- Object result = <<i>returned value</i>>
- return (<i><returnType></i>)result;
- </pre>
-
- <p>The variables <code>p0</code>, <code>p2</code>, ... represent
- formal parameters of the created method.
- The value of <code>cvalue</code> is specified by
- <code>constParam</code>.
-
- <p>If the type of a parameter or a returned value is a primitive
- type, then the value is converted into a wrapper object such as
- <code>java.lang.Integer</code>. If the type of the returned value
- is <code>void</code>, the returned value is discarded.
-
- <p><i>Example:</i>
-
- <pre>
- ClassPool pool = ... ;
- CtClass vec = pool.makeClass("intVector");
- vec.setSuperclass(pool.get("java.util.Vector"));
- CtMethod addMethod = pool.getMethod("Sample", "add0");
-
- CtClass[] argTypes = { CtClass.intType };
- CtMethod m = CtNewMethod.wrapped(CtClass.voidType, "add", argTypes,
- null, addMethod, null, vec);
- vec.addMethod(m);</pre>
-
- <p>where the class <code>Sample</code> is as follows:
-
- <pre>public class Sample extends java.util.Vector {
- public Object add0(Object[] args) {
- super.addElement(args[0]);
- return null;
- }
- }</pre>
-
- <p>This program produces a class <code>intVector</code>:
-
- <pre>public class intVector extends java.util.Vector {
- public void add(int p0) {
- Object[] args = new Object[] { p0 };
- // begin of the copied body
- super.addElement(args[0]);
- Object result = null;
- // end
- }
- }</pre>
-
- <p>Note that the type of the parameter to <code>add()</code> depends
- only on the value of <code>argTypes</code> passed to
- <code>CtNewMethod.wrapped()</code>. Thus, it is easy to
- modify this program to produce a
- <code>StringVector</code> class, which is a vector containing
- only <code>String</code> objects, and other vector classes.</div>
- <dl>
- <dt><span class="paramLabel">Parameters:</span></dt>
- <dd><code>returnType</code> - the type of the returned value.</dd>
- <dd><code>mname</code> - the method name.</dd>
- <dd><code>parameterTypes</code> - a list of the parameter types.</dd>
- <dd><code>exceptionTypes</code> - a list of the exception types.</dd>
- <dd><code>body</code> - the method body
- (must not be a static method).</dd>
- <dd><code>constParam</code> - the constant parameter
- (maybe <code>null</code>).</dd>
- <dd><code>declaring</code> - the class to which the created method is
- added.</dd>
- <dt><span class="throwsLabel">Throws:</span></dt>
- <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
- </dl>
- </li>
- </ul>
- </li>
- </ul>
- </section>
- </li>
- </ul>
- </div>
- </div>
- </main>
- <!-- ========= END OF CLASS DATA ========= -->
- <footer role="contentinfo">
- <nav role="navigation">
- <!-- ======= START OF BOTTOM NAVBAR ====== -->
- <div class="bottomNav"><a id="navbar.bottom">
- <!-- -->
- </a>
- <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
- <a id="navbar.bottom.firstrow">
- <!-- -->
- </a>
- <ul class="navList" title="Navigation">
- <li><a href="../index.html">Overview</a></li>
- <li><a href="package-summary.html">Package</a></li>
- <li class="navBarCell1Rev">Class</li>
- <li><a href="class-use/CtNewMethod.html">Use</a></li>
- <li><a href="package-tree.html">Tree</a></li>
- <li><a href="../deprecated-list.html">Deprecated</a></li>
- <li><a href="../index-all.html">Index</a></li>
- </ul>
- </div>
- <div class="subNav">
- <ul class="navList" id="allclasses_navbar_bottom">
- <li><a href="../allclasses.html">All Classes</a></li>
- </ul>
- <div>
- <script type="text/javascript"><!--
- allClassesLink = document.getElementById("allclasses_navbar_bottom");
- if(window==top) {
- allClassesLink.style.display = "block";
- }
- else {
- allClassesLink.style.display = "none";
- }
- //-->
- </script>
- <noscript>
- <div>JavaScript is disabled on your browser.</div>
- </noscript>
- </div>
- <div>
- <ul class="subNavList">
- <li>Summary: </li>
- <li>Nested | </li>
- <li>Field | </li>
- <li><a href="#constructor.summary">Constr</a> | </li>
- <li><a href="#method.summary">Method</a></li>
- </ul>
- <ul class="subNavList">
- <li>Detail: </li>
- <li>Field | </li>
- <li><a href="#constructor.detail">Constr</a> | </li>
- <li><a href="#method.detail">Method</a></li>
- </ul>
- </div>
- <a id="skip.navbar.bottom">
- <!-- -->
- </a></div>
- <!-- ======== END OF BOTTOM NAVBAR ======= -->
- </nav>
- <p class="legalCopy"><small><i>Javassist, a Java-bytecode translator toolkit.<br>
- Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.</i></small></p>
- </footer>
- </body>
- </html>
|