You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CtConstructor.html 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <!DOCTYPE HTML>
  2. <!-- NewPage -->
  3. <html lang="en">
  4. <head>
  5. <!-- Generated by javadoc (11) on Sat May 08 11:16:00 JST 2021 -->
  6. <title>CtConstructor (Javassist API)</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  8. <meta name="dc.created" content="2021-05-08">
  9. <link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
  10. <link rel="stylesheet" type="text/css" href="../jquery/jquery-ui.css" title="Style">
  11. <script type="text/javascript" src="../script.js"></script>
  12. <script type="text/javascript" src="../jquery/jszip/dist/jszip.min.js"></script>
  13. <script type="text/javascript" src="../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
  14. <!--[if IE]>
  15. <script type="text/javascript" src="../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
  16. <![endif]-->
  17. <script type="text/javascript" src="../jquery/jquery-3.3.1.js"></script>
  18. <script type="text/javascript" src="../jquery/jquery-migrate-3.0.1.js"></script>
  19. <script type="text/javascript" src="../jquery/jquery-ui.js"></script>
  20. </head>
  21. <body>
  22. <script type="text/javascript"><!--
  23. try {
  24. if (location.href.indexOf('is-external=true') == -1) {
  25. parent.document.title="CtConstructor (Javassist API)";
  26. }
  27. }
  28. catch(err) {
  29. }
  30. //-->
  31. var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10};
  32. var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
  33. var altColor = "altColor";
  34. var rowColor = "rowColor";
  35. var tableTab = "tableTab";
  36. var activeTableTab = "activeTableTab";
  37. var pathtoroot = "../";
  38. var useModuleDirectories = true;
  39. loadScripts(document, 'script');</script>
  40. <noscript>
  41. <div>JavaScript is disabled on your browser.</div>
  42. </noscript>
  43. <header role="banner">
  44. <nav role="navigation">
  45. <div class="fixedNav">
  46. <!-- ========= START OF TOP NAVBAR ======= -->
  47. <div class="topNav"><a id="navbar.top">
  48. <!-- -->
  49. </a>
  50. <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
  51. <a id="navbar.top.firstrow">
  52. <!-- -->
  53. </a>
  54. <ul class="navList" title="Navigation">
  55. <li><a href="../index.html">Overview</a></li>
  56. <li><a href="package-summary.html">Package</a></li>
  57. <li class="navBarCell1Rev">Class</li>
  58. <li><a href="class-use/CtConstructor.html">Use</a></li>
  59. <li><a href="package-tree.html">Tree</a></li>
  60. <li><a href="../deprecated-list.html">Deprecated</a></li>
  61. <li><a href="../index-all.html">Index</a></li>
  62. </ul>
  63. </div>
  64. <div class="subNav">
  65. <ul class="navList" id="allclasses_navbar_top">
  66. <li><a href="../allclasses.html">All&nbsp;Classes</a></li>
  67. </ul>
  68. <ul class="navListSearch">
  69. <li><label for="search">SEARCH:</label>
  70. <input type="text" id="search" value="search" disabled="disabled">
  71. <input type="reset" id="reset" value="reset" disabled="disabled">
  72. </li>
  73. </ul>
  74. <div>
  75. <script type="text/javascript"><!--
  76. allClassesLink = document.getElementById("allclasses_navbar_top");
  77. if(window==top) {
  78. allClassesLink.style.display = "block";
  79. }
  80. else {
  81. allClassesLink.style.display = "none";
  82. }
  83. //-->
  84. </script>
  85. <noscript>
  86. <div>JavaScript is disabled on your browser.</div>
  87. </noscript>
  88. </div>
  89. <div>
  90. <ul class="subNavList">
  91. <li>Summary:&nbsp;</li>
  92. <li>Nested&nbsp;|&nbsp;</li>
  93. <li>Field&nbsp;|&nbsp;</li>
  94. <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
  95. <li><a href="#method.summary">Method</a></li>
  96. </ul>
  97. <ul class="subNavList">
  98. <li>Detail:&nbsp;</li>
  99. <li>Field&nbsp;|&nbsp;</li>
  100. <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
  101. <li><a href="#method.detail">Method</a></li>
  102. </ul>
  103. </div>
  104. <a id="skip.navbar.top">
  105. <!-- -->
  106. </a></div>
  107. <!-- ========= END OF TOP NAVBAR ========= -->
  108. </div>
  109. <div class="navPadding">&nbsp;</div>
  110. <script type="text/javascript"><!--
  111. $('.navPadding').css('padding-top', $('.fixedNav').css("height"));
  112. //-->
  113. </script>
  114. </nav>
  115. </header>
  116. <!-- ======== START OF CLASS DATA ======== -->
  117. <main role="main">
  118. <div class="header">
  119. <div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">javassist</a></div>
  120. <h2 title="Class CtConstructor" class="title">Class CtConstructor</h2>
  121. </div>
  122. <div class="contentContainer">
  123. <ul class="inheritance">
  124. <li>java.lang.Object</li>
  125. <li>
  126. <ul class="inheritance">
  127. <li><a href="CtMember.html" title="class in javassist">javassist.CtMember</a></li>
  128. <li>
  129. <ul class="inheritance">
  130. <li><a href="CtBehavior.html" title="class in javassist">javassist.CtBehavior</a></li>
  131. <li>
  132. <ul class="inheritance">
  133. <li>javassist.CtConstructor</li>
  134. </ul>
  135. </li>
  136. </ul>
  137. </li>
  138. </ul>
  139. </li>
  140. </ul>
  141. <div class="description">
  142. <ul class="blockList">
  143. <li class="blockList">
  144. <hr>
  145. <pre>public final class <span class="typeNameLabel">CtConstructor</span>
  146. extends <a href="CtBehavior.html" title="class in javassist">CtBehavior</a></pre>
  147. <div class="block">An instance of CtConstructor represents a constructor.
  148. It may represent a static constructor
  149. (class initializer). To distinguish a constructor and a class
  150. initializer, call <code>isClassInitializer()</code>.
  151. <p>See the super class <code>CtBehavior</code> as well since
  152. a number of useful methods are in <code>CtBehavior</code>.</div>
  153. <dl>
  154. <dt><span class="seeLabel">See Also:</span></dt>
  155. <dd><a href="CtClass.html#getDeclaredConstructors()"><code>CtClass.getDeclaredConstructors()</code></a>,
  156. <a href="CtClass.html#getClassInitializer()"><code>CtClass.getClassInitializer()</code></a>,
  157. <a href="CtNewConstructor.html" title="class in javassist"><code>CtNewConstructor</code></a></dd>
  158. </dl>
  159. </li>
  160. </ul>
  161. </div>
  162. <div class="summary">
  163. <ul class="blockList">
  164. <li class="blockList">
  165. <!-- ======== CONSTRUCTOR SUMMARY ======== -->
  166. <section role="region">
  167. <ul class="blockList">
  168. <li class="blockList"><a id="constructor.summary">
  169. <!-- -->
  170. </a>
  171. <h3>Constructor Summary</h3>
  172. <table class="memberSummary">
  173. <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
  174. <tr>
  175. <th class="colFirst" scope="col">Constructor</th>
  176. <th class="colLast" scope="col">Description</th>
  177. </tr>
  178. <tr class="altColor">
  179. <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(javassist.CtClass%5B%5D,javassist.CtClass)">CtConstructor</a></span>&#8203;(<a href="CtClass.html" title="class in javassist">CtClass</a>[]&nbsp;parameters,
  180. <a href="CtClass.html" title="class in javassist">CtClass</a>&nbsp;declaring)</code></th>
  181. <td class="colLast">
  182. <div class="block">Creates a constructor with no constructor body.</div>
  183. </td>
  184. </tr>
  185. <tr class="rowColor">
  186. <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(javassist.CtConstructor,javassist.CtClass,javassist.ClassMap)">CtConstructor</a></span>&#8203;(<a href="CtConstructor.html" title="class in javassist">CtConstructor</a>&nbsp;src,
  187. <a href="CtClass.html" title="class in javassist">CtClass</a>&nbsp;declaring,
  188. <a href="ClassMap.html" title="class in javassist">ClassMap</a>&nbsp;map)</code></th>
  189. <td class="colLast">
  190. <div class="block">Creates a copy of a <code>CtConstructor</code> object.</div>
  191. </td>
  192. </tr>
  193. </table>
  194. </li>
  195. </ul>
  196. </section>
  197. <!-- ========== METHOD SUMMARY =========== -->
  198. <section role="region">
  199. <ul class="blockList">
  200. <li class="blockList"><a id="method.summary">
  201. <!-- -->
  202. </a>
  203. <h3>Method Summary</h3>
  204. <table class="memberSummary">
  205. <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
  206. <tr>
  207. <th class="colFirst" scope="col">Modifier and Type</th>
  208. <th class="colSecond" scope="col">Method</th>
  209. <th class="colLast" scope="col">Description</th>
  210. </tr>
  211. <tr id="i0" class="altColor">
  212. <td class="colFirst"><code>boolean</code></td>
  213. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#callsSuper()">callsSuper</a></span>()</code></th>
  214. <td class="colLast">
  215. <div class="block">Returns true if this constructor calls a constructor
  216. of the super class.</div>
  217. </td>
  218. </tr>
  219. <tr id="i1" class="rowColor">
  220. <td class="colFirst"><code>java.lang.String</code></td>
  221. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getLongName()">getLongName</a></span>()</code></th>
  222. <td class="colLast">
  223. <div class="block">Returns the constructor name followed by parameter types
  224. such as <code>javassist.CtConstructor(CtClass[],CtClass)</code>.</div>
  225. </td>
  226. </tr>
  227. <tr id="i2" class="altColor">
  228. <td class="colFirst"><code>java.lang.String</code></td>
  229. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getName()">getName</a></span>()</code></th>
  230. <td class="colLast">
  231. <div class="block">Obtains the name of this constructor.</div>
  232. </td>
  233. </tr>
  234. <tr id="i3" class="rowColor">
  235. <td class="colFirst"><code>void</code></td>
  236. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#insertBeforeBody(java.lang.String)">insertBeforeBody</a></span>&#8203;(java.lang.String&nbsp;src)</code></th>
  237. <td class="colLast">
  238. <div class="block">Inserts bytecode just after another constructor in the super class
  239. or this class is called.</div>
  240. </td>
  241. </tr>
  242. <tr id="i4" class="altColor">
  243. <td class="colFirst"><code>boolean</code></td>
  244. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isClassInitializer()">isClassInitializer</a></span>()</code></th>
  245. <td class="colLast">
  246. <div class="block">Returns true if this object represents a static initializer.</div>
  247. </td>
  248. </tr>
  249. <tr id="i5" class="rowColor">
  250. <td class="colFirst"><code>boolean</code></td>
  251. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isConstructor()">isConstructor</a></span>()</code></th>
  252. <td class="colLast">
  253. <div class="block">Returns true if this object represents a constructor.</div>
  254. </td>
  255. </tr>
  256. <tr id="i6" class="altColor">
  257. <td class="colFirst"><code>boolean</code></td>
  258. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#isEmpty()">isEmpty</a></span>()</code></th>
  259. <td class="colLast">
  260. <div class="block">Returns true if the constructor (or static initializer)
  261. is the default one.</div>
  262. </td>
  263. </tr>
  264. <tr id="i7" class="rowColor">
  265. <td class="colFirst"><code>void</code></td>
  266. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setBody(java.lang.String)">setBody</a></span>&#8203;(java.lang.String&nbsp;src)</code></th>
  267. <td class="colLast">
  268. <div class="block">Sets a constructor body.</div>
  269. </td>
  270. </tr>
  271. <tr id="i8" class="altColor">
  272. <td class="colFirst"><code>void</code></td>
  273. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#setBody(javassist.CtConstructor,javassist.ClassMap)">setBody</a></span>&#8203;(<a href="CtConstructor.html" title="class in javassist">CtConstructor</a>&nbsp;src,
  274. <a href="ClassMap.html" title="class in javassist">ClassMap</a>&nbsp;map)</code></th>
  275. <td class="colLast">
  276. <div class="block">Copies a constructor body from another constructor.</div>
  277. </td>
  278. </tr>
  279. <tr id="i9" class="rowColor">
  280. <td class="colFirst"><code><a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
  281. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toMethod(java.lang.String,javassist.CtClass)">toMethod</a></span>&#8203;(java.lang.String&nbsp;name,
  282. <a href="CtClass.html" title="class in javassist">CtClass</a>&nbsp;declaring)</code></th>
  283. <td class="colLast">
  284. <div class="block">Makes a copy of this constructor and converts it into a method.</div>
  285. </td>
  286. </tr>
  287. <tr id="i10" class="altColor">
  288. <td class="colFirst"><code><a href="CtMethod.html" title="class in javassist">CtMethod</a></code></td>
  289. <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#toMethod(java.lang.String,javassist.CtClass,javassist.ClassMap)">toMethod</a></span>&#8203;(java.lang.String&nbsp;name,
  290. <a href="CtClass.html" title="class in javassist">CtClass</a>&nbsp;declaring,
  291. <a href="ClassMap.html" title="class in javassist">ClassMap</a>&nbsp;map)</code></th>
  292. <td class="colLast">
  293. <div class="block">Makes a copy of this constructor and converts it into a method.</div>
  294. </td>
  295. </tr>
  296. </table>
  297. <ul class="blockList">
  298. <li class="blockList"><a id="methods.inherited.from.class.javassist.CtBehavior">
  299. <!-- -->
  300. </a>
  301. <h3>Methods inherited from class&nbsp;javassist.<a href="CtBehavior.html" title="class in javassist">CtBehavior</a></h3>
  302. <code><a href="CtBehavior.html#addCatch(java.lang.String,javassist.CtClass)">addCatch</a>, <a href="CtBehavior.html#addCatch(java.lang.String,javassist.CtClass,java.lang.String)">addCatch</a>, <a href="CtBehavior.html#addLocalVariable(java.lang.String,javassist.CtClass)">addLocalVariable</a>, <a href="CtBehavior.html#addParameter(javassist.CtClass)">addParameter</a>, <a href="CtBehavior.html#getAnnotation(java.lang.Class)">getAnnotation</a>, <a href="CtBehavior.html#getAnnotations()">getAnnotations</a>, <a href="CtBehavior.html#getAttribute(java.lang.String)">getAttribute</a>, <a href="CtBehavior.html#getAvailableAnnotations()">getAvailableAnnotations</a>, <a href="CtBehavior.html#getAvailableParameterAnnotations()">getAvailableParameterAnnotations</a>, <a href="CtBehavior.html#getExceptionTypes()">getExceptionTypes</a>, <a href="CtBehavior.html#getGenericSignature()">getGenericSignature</a>, <a href="CtBehavior.html#getMethodInfo()">getMethodInfo</a>, <a href="CtBehavior.html#getMethodInfo2()">getMethodInfo2</a>, <a href="CtBehavior.html#getModifiers()">getModifiers</a>, <a href="CtBehavior.html#getParameterAnnotations()">getParameterAnnotations</a>, <a href="CtBehavior.html#getParameterTypes()">getParameterTypes</a>, <a href="CtBehavior.html#getSignature()">getSignature</a>, <a href="CtBehavior.html#hasAnnotation(java.lang.String)">hasAnnotation</a>, <a href="CtBehavior.html#insertAfter(java.lang.String)">insertAfter</a>, <a href="CtBehavior.html#insertAfter(java.lang.String,boolean)">insertAfter</a>, <a href="CtBehavior.html#insertAfter(java.lang.String,boolean,boolean)">insertAfter</a>, <a href="CtBehavior.html#insertAt(int,boolean,java.lang.String)">insertAt</a>, <a href="CtBehavior.html#insertAt(int,java.lang.String)">insertAt</a>, <a href="CtBehavior.html#insertBefore(java.lang.String)">insertBefore</a>, <a href="CtBehavior.html#insertParameter(javassist.CtClass)">insertParameter</a>, <a href="CtBehavior.html#instrument(javassist.CodeConverter)">instrument</a>, <a href="CtBehavior.html#instrument(javassist.expr.ExprEditor)">instrument</a>, <a href="CtBehavior.html#setAttribute(java.lang.String,byte%5B%5D)">setAttribute</a>, <a href="CtBehavior.html#setBody(java.lang.String,java.lang.String,java.lang.String)">setBody</a>, <a href="CtBehavior.html#setExceptionTypes(javassist.CtClass%5B%5D)">setExceptionTypes</a>, <a href="CtBehavior.html#setGenericSignature(java.lang.String)">setGenericSignature</a>, <a href="CtBehavior.html#setModifiers(int)">setModifiers</a>, <a href="CtBehavior.html#useCflow(java.lang.String)">useCflow</a></code></li>
  303. </ul>
  304. <ul class="blockList">
  305. <li class="blockList"><a id="methods.inherited.from.class.javassist.CtMember">
  306. <!-- -->
  307. </a>
  308. <h3>Methods inherited from class&nbsp;javassist.<a href="CtMember.html" title="class in javassist">CtMember</a></h3>
  309. <code><a href="CtMember.html#getDeclaringClass()">getDeclaringClass</a>, <a href="CtMember.html#hasAnnotation(java.lang.Class)">hasAnnotation</a>, <a href="CtMember.html#toString()">toString</a>, <a href="CtMember.html#visibleFrom(javassist.CtClass)">visibleFrom</a></code></li>
  310. </ul>
  311. <ul class="blockList">
  312. <li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
  313. <!-- -->
  314. </a>
  315. <h3>Methods inherited from class&nbsp;java.lang.Object</h3>
  316. <code>equals, getClass, hashCode, notify, notifyAll, wait, wait, wait</code></li>
  317. </ul>
  318. </li>
  319. </ul>
  320. </section>
  321. </li>
  322. </ul>
  323. </div>
  324. <div class="details">
  325. <ul class="blockList">
  326. <li class="blockList">
  327. <!-- ========= CONSTRUCTOR DETAIL ======== -->
  328. <section role="region">
  329. <ul class="blockList">
  330. <li class="blockList"><a id="constructor.detail">
  331. <!-- -->
  332. </a>
  333. <h3>Constructor Detail</h3>
  334. <a id="&lt;init&gt;(javassist.CtClass[],javassist.CtClass)">
  335. <!-- -->
  336. </a>
  337. <ul class="blockList">
  338. <li class="blockList">
  339. <h4>CtConstructor</h4>
  340. <pre>public&nbsp;CtConstructor&#8203;(<a href="CtClass.html" title="class in javassist">CtClass</a>[]&nbsp;parameters,
  341. <a href="CtClass.html" title="class in javassist">CtClass</a>&nbsp;declaring)</pre>
  342. <div class="block">Creates a constructor with no constructor body.
  343. The created constructor
  344. must be added to a class with <code>CtClass.addConstructor()</code>.
  345. <p>The created constructor does not include a constructor body,
  346. which must be specified with <code>setBody()</code>.</div>
  347. <dl>
  348. <dt><span class="paramLabel">Parameters:</span></dt>
  349. <dd><code>declaring</code> - the class to which the created method is added.</dd>
  350. <dd><code>parameters</code> - a list of the parameter types</dd>
  351. <dt><span class="seeLabel">See Also:</span></dt>
  352. <dd><a href="CtClass.html#addConstructor(javassist.CtConstructor)"><code>CtClass.addConstructor(CtConstructor)</code></a>,
  353. <a href="#setBody(java.lang.String)"><code>setBody(String)</code></a>,
  354. <a href="#setBody(javassist.CtConstructor,javassist.ClassMap)"><code>setBody(CtConstructor,ClassMap)</code></a></dd>
  355. </dl>
  356. </li>
  357. </ul>
  358. <a id="&lt;init&gt;(javassist.CtConstructor,javassist.CtClass,javassist.ClassMap)">
  359. <!-- -->
  360. </a>
  361. <ul class="blockListLast">
  362. <li class="blockList">
  363. <h4>CtConstructor</h4>
  364. <pre>public&nbsp;CtConstructor&#8203;(<a href="CtConstructor.html" title="class in javassist">CtConstructor</a>&nbsp;src,
  365. <a href="CtClass.html" title="class in javassist">CtClass</a>&nbsp;declaring,
  366. <a href="ClassMap.html" title="class in javassist">ClassMap</a>&nbsp;map)
  367. throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
  368. <div class="block">Creates a copy of a <code>CtConstructor</code> object.
  369. The created constructor must be
  370. added to a class with <code>CtClass.addConstructor()</code>.
  371. <p>All occurrences of class names in the created constructor
  372. are replaced with names specified by
  373. <code>map</code> if <code>map</code> is not <code>null</code>.
  374. <p>By default, all the occurrences of the names of the class
  375. declaring <code>src</code> and the superclass are replaced
  376. with the name of the class and the superclass that
  377. the created constructor is added to.
  378. This is done whichever <code>map</code> is null or not.
  379. To prevent this replacement, call <code>ClassMap.fix()</code>
  380. or <code>put()</code> to explicitly specify replacement.
  381. <p><b>Note:</b> if the <code>.class</code> notation (for example,
  382. <code>String.class</code>) is included in an expression, the
  383. Javac compiler may produce a helper method.
  384. Since this constructor never
  385. copies this helper method, the programmers have the responsiblity of
  386. copying it. Otherwise, use <code>Class.forName()</code> in the
  387. expression.</div>
  388. <dl>
  389. <dt><span class="paramLabel">Parameters:</span></dt>
  390. <dd><code>src</code> - the source method.</dd>
  391. <dd><code>declaring</code> - the class to which the created method is added.</dd>
  392. <dd><code>map</code> - the hashtable associating original class names
  393. with substituted names.
  394. It can be <code>null</code>.</dd>
  395. <dt><span class="throwsLabel">Throws:</span></dt>
  396. <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
  397. <dt><span class="seeLabel">See Also:</span></dt>
  398. <dd><a href="CtClass.html#addConstructor(javassist.CtConstructor)"><code>CtClass.addConstructor(CtConstructor)</code></a>,
  399. <a href="ClassMap.html#fix(java.lang.String)"><code>ClassMap.fix(String)</code></a></dd>
  400. </dl>
  401. </li>
  402. </ul>
  403. </li>
  404. </ul>
  405. </section>
  406. <!-- ============ METHOD DETAIL ========== -->
  407. <section role="region">
  408. <ul class="blockList">
  409. <li class="blockList"><a id="method.detail">
  410. <!-- -->
  411. </a>
  412. <h3>Method Detail</h3>
  413. <a id="isConstructor()">
  414. <!-- -->
  415. </a>
  416. <ul class="blockList">
  417. <li class="blockList">
  418. <h4>isConstructor</h4>
  419. <pre class="methodSignature">public&nbsp;boolean&nbsp;isConstructor()</pre>
  420. <div class="block">Returns true if this object represents a constructor.</div>
  421. </li>
  422. </ul>
  423. <a id="isClassInitializer()">
  424. <!-- -->
  425. </a>
  426. <ul class="blockList">
  427. <li class="blockList">
  428. <h4>isClassInitializer</h4>
  429. <pre class="methodSignature">public&nbsp;boolean&nbsp;isClassInitializer()</pre>
  430. <div class="block">Returns true if this object represents a static initializer.</div>
  431. </li>
  432. </ul>
  433. <a id="getLongName()">
  434. <!-- -->
  435. </a>
  436. <ul class="blockList">
  437. <li class="blockList">
  438. <h4>getLongName</h4>
  439. <pre class="methodSignature">public&nbsp;java.lang.String&nbsp;getLongName()</pre>
  440. <div class="block">Returns the constructor name followed by parameter types
  441. such as <code>javassist.CtConstructor(CtClass[],CtClass)</code>.</div>
  442. <dl>
  443. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  444. <dd><code><a href="CtBehavior.html#getLongName()">getLongName</a></code>&nbsp;in class&nbsp;<code><a href="CtBehavior.html" title="class in javassist">CtBehavior</a></code></dd>
  445. <dt><span class="simpleTagLabel">Since:</span></dt>
  446. <dd>3.5</dd>
  447. </dl>
  448. </li>
  449. </ul>
  450. <a id="getName()">
  451. <!-- -->
  452. </a>
  453. <ul class="blockList">
  454. <li class="blockList">
  455. <h4>getName</h4>
  456. <pre class="methodSignature">public&nbsp;java.lang.String&nbsp;getName()</pre>
  457. <div class="block">Obtains the name of this constructor.
  458. It is the same as the simple name of the class declaring this
  459. constructor. If this object represents a class initializer,
  460. then this method returns <code>"&lt;clinit&gt;"</code>.</div>
  461. <dl>
  462. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  463. <dd><code><a href="CtMember.html#getName()">getName</a></code>&nbsp;in class&nbsp;<code><a href="CtMember.html" title="class in javassist">CtMember</a></code></dd>
  464. <dt><span class="seeLabel">See Also:</span></dt>
  465. <dd><a href="#getName()"><code>getName()</code></a></dd>
  466. </dl>
  467. </li>
  468. </ul>
  469. <a id="isEmpty()">
  470. <!-- -->
  471. </a>
  472. <ul class="blockList">
  473. <li class="blockList">
  474. <h4>isEmpty</h4>
  475. <pre class="methodSignature">public&nbsp;boolean&nbsp;isEmpty()</pre>
  476. <div class="block">Returns true if the constructor (or static initializer)
  477. is the default one. This method returns true if the constructor
  478. takes some arguments but it does not perform anything except
  479. calling <code>super()</code> (the no-argument constructor of
  480. the super class).</div>
  481. <dl>
  482. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  483. <dd><code><a href="CtBehavior.html#isEmpty()">isEmpty</a></code>&nbsp;in class&nbsp;<code><a href="CtBehavior.html" title="class in javassist">CtBehavior</a></code></dd>
  484. </dl>
  485. </li>
  486. </ul>
  487. <a id="callsSuper()">
  488. <!-- -->
  489. </a>
  490. <ul class="blockList">
  491. <li class="blockList">
  492. <h4>callsSuper</h4>
  493. <pre class="methodSignature">public&nbsp;boolean&nbsp;callsSuper()
  494. throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
  495. <div class="block">Returns true if this constructor calls a constructor
  496. of the super class. This method returns false if it
  497. calls another constructor of this class by <code>this()</code>.</div>
  498. <dl>
  499. <dt><span class="throwsLabel">Throws:</span></dt>
  500. <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
  501. </dl>
  502. </li>
  503. </ul>
  504. <a id="setBody(java.lang.String)">
  505. <!-- -->
  506. </a>
  507. <ul class="blockList">
  508. <li class="blockList">
  509. <h4>setBody</h4>
  510. <pre class="methodSignature">public&nbsp;void&nbsp;setBody&#8203;(java.lang.String&nbsp;src)
  511. throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
  512. <div class="block">Sets a constructor body.</div>
  513. <dl>
  514. <dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
  515. <dd><code><a href="CtBehavior.html#setBody(java.lang.String)">setBody</a></code>&nbsp;in class&nbsp;<code><a href="CtBehavior.html" title="class in javassist">CtBehavior</a></code></dd>
  516. <dt><span class="paramLabel">Parameters:</span></dt>
  517. <dd><code>src</code> - the source code representing the constructor body.
  518. It must be a single statement or block.
  519. If it is <code>null</code>, the substituted
  520. constructor body does nothing except calling
  521. <code>super()</code>.</dd>
  522. <dt><span class="throwsLabel">Throws:</span></dt>
  523. <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
  524. </dl>
  525. </li>
  526. </ul>
  527. <a id="setBody(javassist.CtConstructor,javassist.ClassMap)">
  528. <!-- -->
  529. </a>
  530. <ul class="blockList">
  531. <li class="blockList">
  532. <h4>setBody</h4>
  533. <pre class="methodSignature">public&nbsp;void&nbsp;setBody&#8203;(<a href="CtConstructor.html" title="class in javassist">CtConstructor</a>&nbsp;src,
  534. <a href="ClassMap.html" title="class in javassist">ClassMap</a>&nbsp;map)
  535. throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
  536. <div class="block">Copies a constructor body from another constructor.
  537. <p>All occurrences of the class names in the copied body
  538. are replaced with the names specified by
  539. <code>map</code> if <code>map</code> is not <code>null</code>.</div>
  540. <dl>
  541. <dt><span class="paramLabel">Parameters:</span></dt>
  542. <dd><code>src</code> - the method that the body is copied from.</dd>
  543. <dd><code>map</code> - the hashtable associating original class names
  544. with substituted names.
  545. It can be <code>null</code>.</dd>
  546. <dt><span class="throwsLabel">Throws:</span></dt>
  547. <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
  548. </dl>
  549. </li>
  550. </ul>
  551. <a id="insertBeforeBody(java.lang.String)">
  552. <!-- -->
  553. </a>
  554. <ul class="blockList">
  555. <li class="blockList">
  556. <h4>insertBeforeBody</h4>
  557. <pre class="methodSignature">public&nbsp;void&nbsp;insertBeforeBody&#8203;(java.lang.String&nbsp;src)
  558. throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
  559. <div class="block">Inserts bytecode just after another constructor in the super class
  560. or this class is called.
  561. It does not work if this object represents a class initializer.</div>
  562. <dl>
  563. <dt><span class="paramLabel">Parameters:</span></dt>
  564. <dd><code>src</code> - the source code representing the inserted bytecode.
  565. It must be a single statement or block.</dd>
  566. <dt><span class="throwsLabel">Throws:</span></dt>
  567. <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
  568. </dl>
  569. </li>
  570. </ul>
  571. <a id="toMethod(java.lang.String,javassist.CtClass)">
  572. <!-- -->
  573. </a>
  574. <ul class="blockList">
  575. <li class="blockList">
  576. <h4>toMethod</h4>
  577. <pre class="methodSignature">public&nbsp;<a href="CtMethod.html" title="class in javassist">CtMethod</a>&nbsp;toMethod&#8203;(java.lang.String&nbsp;name,
  578. <a href="CtClass.html" title="class in javassist">CtClass</a>&nbsp;declaring)
  579. throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
  580. <div class="block">Makes a copy of this constructor and converts it into a method.
  581. The signature of the mehtod is the same as the that of this constructor.
  582. The return type is <code>void</code>. The resulting method must be
  583. appended to the class specified by <code>declaring</code>.
  584. If this constructor is a static initializer, the resulting method takes
  585. no parameter.
  586. <p>An occurrence of another constructor call <code>this()</code>
  587. or a super constructor call <code>super()</code> is
  588. eliminated from the resulting method.
  589. <p>The immediate super class of the class declaring this constructor
  590. must be also a super class of the class declaring the resulting method.
  591. If the constructor accesses a field, the class declaring the resulting method
  592. must also declare a field with the same name and type.</div>
  593. <dl>
  594. <dt><span class="paramLabel">Parameters:</span></dt>
  595. <dd><code>name</code> - the name of the resulting method.</dd>
  596. <dd><code>declaring</code> - the class declaring the resulting method.</dd>
  597. <dt><span class="throwsLabel">Throws:</span></dt>
  598. <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
  599. </dl>
  600. </li>
  601. </ul>
  602. <a id="toMethod(java.lang.String,javassist.CtClass,javassist.ClassMap)">
  603. <!-- -->
  604. </a>
  605. <ul class="blockListLast">
  606. <li class="blockList">
  607. <h4>toMethod</h4>
  608. <pre class="methodSignature">public&nbsp;<a href="CtMethod.html" title="class in javassist">CtMethod</a>&nbsp;toMethod&#8203;(java.lang.String&nbsp;name,
  609. <a href="CtClass.html" title="class in javassist">CtClass</a>&nbsp;declaring,
  610. <a href="ClassMap.html" title="class in javassist">ClassMap</a>&nbsp;map)
  611. throws <a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></pre>
  612. <div class="block">Makes a copy of this constructor and converts it into a method.
  613. The signature of the method is the same as the that of this constructor.
  614. The return type is <code>void</code>. The resulting method must be
  615. appended to the class specified by <code>declaring</code>.
  616. If this constructor is a static initializer, the resulting method takes
  617. no parameter.
  618. <p>An occurrence of another constructor call <code>this()</code>
  619. or a super constructor call <code>super()</code> is
  620. eliminated from the resulting method.
  621. <p>The immediate super class of the class declaring this constructor
  622. must be also a super class of the class declaring the resulting method
  623. (this is obviously true if the second parameter <code>declaring</code> is
  624. the same as the class declaring this constructor).
  625. If the constructor accesses a field, the class declaring the resulting method
  626. must also declare a field with the same name and type.</div>
  627. <dl>
  628. <dt><span class="paramLabel">Parameters:</span></dt>
  629. <dd><code>name</code> - the name of the resulting method.</dd>
  630. <dd><code>declaring</code> - the class declaring the resulting method.
  631. It is normally the same as the class declaring this
  632. constructor.</dd>
  633. <dd><code>map</code> - the hash table associating original class names
  634. with substituted names. The original class names will be
  635. replaced while making a copy.
  636. <code>map</code> can be <code>null</code>.</dd>
  637. <dt><span class="throwsLabel">Throws:</span></dt>
  638. <dd><code><a href="CannotCompileException.html" title="class in javassist">CannotCompileException</a></code></dd>
  639. </dl>
  640. </li>
  641. </ul>
  642. </li>
  643. </ul>
  644. </section>
  645. </li>
  646. </ul>
  647. </div>
  648. </div>
  649. </main>
  650. <!-- ========= END OF CLASS DATA ========= -->
  651. <footer role="contentinfo">
  652. <nav role="navigation">
  653. <!-- ======= START OF BOTTOM NAVBAR ====== -->
  654. <div class="bottomNav"><a id="navbar.bottom">
  655. <!-- -->
  656. </a>
  657. <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
  658. <a id="navbar.bottom.firstrow">
  659. <!-- -->
  660. </a>
  661. <ul class="navList" title="Navigation">
  662. <li><a href="../index.html">Overview</a></li>
  663. <li><a href="package-summary.html">Package</a></li>
  664. <li class="navBarCell1Rev">Class</li>
  665. <li><a href="class-use/CtConstructor.html">Use</a></li>
  666. <li><a href="package-tree.html">Tree</a></li>
  667. <li><a href="../deprecated-list.html">Deprecated</a></li>
  668. <li><a href="../index-all.html">Index</a></li>
  669. </ul>
  670. </div>
  671. <div class="subNav">
  672. <ul class="navList" id="allclasses_navbar_bottom">
  673. <li><a href="../allclasses.html">All&nbsp;Classes</a></li>
  674. </ul>
  675. <div>
  676. <script type="text/javascript"><!--
  677. allClassesLink = document.getElementById("allclasses_navbar_bottom");
  678. if(window==top) {
  679. allClassesLink.style.display = "block";
  680. }
  681. else {
  682. allClassesLink.style.display = "none";
  683. }
  684. //-->
  685. </script>
  686. <noscript>
  687. <div>JavaScript is disabled on your browser.</div>
  688. </noscript>
  689. </div>
  690. <div>
  691. <ul class="subNavList">
  692. <li>Summary:&nbsp;</li>
  693. <li>Nested&nbsp;|&nbsp;</li>
  694. <li>Field&nbsp;|&nbsp;</li>
  695. <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
  696. <li><a href="#method.summary">Method</a></li>
  697. </ul>
  698. <ul class="subNavList">
  699. <li>Detail:&nbsp;</li>
  700. <li>Field&nbsp;|&nbsp;</li>
  701. <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
  702. <li><a href="#method.detail">Method</a></li>
  703. </ul>
  704. </div>
  705. <a id="skip.navbar.bottom">
  706. <!-- -->
  707. </a></div>
  708. <!-- ======== END OF BOTTOM NAVBAR ======= -->
  709. </nav>
  710. <p class="legalCopy"><small><i>Javassist, a Java-bytecode translator toolkit.<br>
  711. Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.</i></small></p>
  712. </footer>
  713. </body>
  714. </html>