1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
|
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (11) on Thu Nov 01 00:14:40 JST 2018 -->
<title>CtNewMethod (Javassist API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="dc.created" content="2018-11-01">
<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>
|