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
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"../../lib/docbook/docbook-dtd/docbookx.dtd">
<?xml-stylesheet type="text/css"
href="../../style.css"?>
<!-- `copy-to-register' (C-x r s) then `insert-register' (C-x r i).
<qandaentry>
<question id="q:XX" xreflabel="Q:XX">
<para></para>
</question>
<answer>
<para></para>
</answer>
</qandaentry>
-->
<article class="faq">
<title>Frequently Asked Questions about AspectJ</title>
<para>Copyright (c) 1997-2001 Xerox Corporation,
2002 Palo Alto Research Center, Incorporated. All rights reserved.
</para>
<!-- todo Update me! -->
<para>Last updated December 31, 2002.
</para>
<para>
For a list of recently-updated FAQ entries, see <xref linkend="q:faqchanges"/>
AspectJ 1.1 is currently in development, and
some answers may change after it is released;
for more information, see the README
included with the AspectJ 1.1 distribution.
</para>
<qandaset defaultlabel="number">
<qandadiv id="overview" xreflabel="Overview">
<title>Overview</title>
<qandaentry>
<question id="q:whatisaj" xreflabel="Q:What is AspectJ?">
<para>What is AspectJ?</para>
</question>
<answer>
<para>
AspectJ(tm) is a simple and practical extension to the
Java(tm) programming
language that adds to Java aspect-oriented programming (AOP)
capabilities. AOP allows developers to reap the benefits of
modularity for concerns that cut across the natural units of
modularity. In object-oriented programs like Java, the natural unit
of modularity is the class. In AspectJ, aspects modularize concerns that
affect more than one class.
</para>
<para> AspectJ includes a compiler (<literal>ajc</literal>), a
debugger (<literal>ajdb</literal>), a documentation generator
(<literal>ajdoc</literal>), a program structure browser
(<literal>ajbrowser</literal>), and integration
with Eclipse, Sun-ONE/Netbeans, GNU Emacs/XEmacs, JBuilder, and Ant.
</para>
<para>You compile your program using the AspectJ compiler (perhaps using
the supported development environments) and then run it, supplying
a small (< 100K) runtime library.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:benefits"
xreflabel="Q:What are the benefits of using AspectJ?">
<para>What are the benefits of using AspectJ?</para>
</question>
<answer>
<para>AspectJ can be used to improve the modularity of software
systems.
</para>
<para> Using ordinary Java, it can be difficult to modularize design
concerns such as
</para>
<itemizedlist>
<listitem><para>system-wide error-handling</para></listitem>
<listitem><para>contract enforcement</para></listitem>
<listitem><para>distribution concerns</para></listitem>
<listitem><para>feature variations</para></listitem>
<listitem><para>context-sensitive behavior</para></listitem>
<listitem><para>persistence</para></listitem>
<listitem><para>testing</para></listitem>
</itemizedlist>
<para>The code for these concerns tends to be spread out across the
system. Because these concerns won't stay inside of any one module
boundary, we say that they <emphasis>crosscut</emphasis> the
system's modularity.
</para>
<para>AspectJ adds constructs to Java that enable the modular
implementation of crosscutting concerns. This ability is
particularly valuable because crosscutting concerns tend to be both
complex and poorly localized, making them hard to deal with.
</para>
<!--
<para>Initial studies have shown code size reductions of up to 40%
and programmer productivity gains of 20%-40%. These studies were in
an earlier version of the language and only for small sample sizes.
So while the results are encouraging, they aren't conclusive. We
intend to run a new set of studies once the current phase of
language development stabilizes.</para>
-->
</answer>
</qandaentry>
<qandaentry>
<question id="q:compability"
xreflabel="Q:Can AspectJ work with any Java program?">
<para>Can AspectJ work with any Java program?</para>
</question>
<answer>
<para>AspectJ has been designed as a <emphasis>compatible</emphasis>
extension to Java. By compatible, we mean
</para>
<informaltable frame="none">
<tgroup cols="2">
<tbody>
<row>
<entry align="right">
<emphasis>upward compatible</emphasis>
</entry>
<entry>All legal Java programs are legal AspectJ
programs.
</entry>
</row>
<row>
<entry align="right">
<emphasis>platform
compatible
</emphasis>
</entry>
<entry>All legal AspectJ programs run on standard Java
virtual machines.
</entry>
</row>
<row>
<entry align="right">
<emphasis>tool
compatible
</emphasis>
</entry>
<entry>Existing tools can be extended to work with
AspectJ.
</entry>
</row>
<row>
<entry align="right">
<emphasis>programmer compatible</emphasis>
</entry>
<entry>Programming in AspectJ feels natural to Java
programmers.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>The AspectJ tools run on any Java 2 Platform compatible
platform. The AspectJ compiler produces classes that run
on any Java 1.1 (or later) compatible platform.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:license" xreflabel="Q:How is AspectJ licensed?">
<para>How is AspectJ licensed?</para>
</question>
<answer>
<para>The AspectJ tools are open-source software available under the
<ulink url="http://aspectj.org/MPL">Mozilla Public License 1.1</ulink>.
The documentation is available under a separate
<ulink url="http://aspectj.org/servlets/AJSite?channel=download&subChannel=docTerms">
license
</ulink> that precludes for-profit or commercial
redistribution. Generally, we permit some usage for
internal presentations; please contact us at
<ulink url="mailto:support@aspectj.org?subject=Presentation%20materials">support@aspectj.org</ulink>
for permission.
</para>
<para>Most users only want to use AspectJ to build programs they distribute.
There are no restrictions here. When you distribute your program, be sure to
include all the runtime classes from the aspectjrt.jar for that version of AspectJ.
When distributing only the runtime classes, you need not provide any notice that
the program was compiled with AspectJ or includes binaries from the AspectJ project,
except as necessary to preserve the warranty disclaimers in our license.
Although the license does not require it, please email
<ulink url="mailto:support@aspectj.org">support@aspectj.org</ulink>
if you are shipping applications built with AspectJ; knowing that is
critical for ongoing support from our sponsors.
</para>
<para>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:project" xreflabel="Q:What is the AspectJ Project?">
<para>What is the AspectJ Project?</para>
</question>
<answer>
<para>AspectJ is based on over ten years of research at
<ulink url="http://www.parc.xerox.com">
Xerox Palo Alto Research Center
</ulink>
as funded by Xerox, a U.S. Government grant (NISTATP), and a
DARPA contract.
</para>
<para>It has evolved through open-source releases to a strong
user community.
The AspectJ team works closely with the community
to ensure AspectJ continues to evolve as an effective
aspect-oriented programming language and tool set.
</para>
<para>The latest release is 1.0.6 <!-- XXX todo Update me! -->
which can be downloaded from the AspectJ
<ulink url="http://aspectj.org/dl">download</ulink> page.
Further development is focused on supporting applications,
improving performance of the 1.0 compiler,
enhancing integration with IDEs,
and building the next generations of the language.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="quickstart" xreflabel="Quick Start">
<title>Quick Start</title>
<qandaentry>
<question id="q:requirements"
xreflabel="Q:What Java versions does AspectJ require and support?">
<para>
What Java versions does AspectJ require and support?
</para>
</question>
<answer>
<para>
The AspectJ compiler produces programs for any released version of the
Java platform (jdk1.1 and later). When running, your program classes must
be able to reach classes in the
small (< 100K) runtime library (aspectjrt.jar) from the distribution.
The tools themselves require Java 2 (jdk 1.2) or later to run,
but the compiler can be set up to target any 1.1-compliant
version of the Java platform.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:install"
xreflabel="Q:How do I download and install AspectJ?">
<para>How do I download and install AspectJ?</para>
</question>
<answer>
<para>Go to AspectJ's
<ulink url="http://aspectj.org/dl">download web
page
</ulink> and choose which components you want download.
The <literal>jar</literal> files are installed by executing
</para>
<programlisting>
java -jar <emphasis>jar file name</emphasis>
</programlisting>
<para>Do <emphasis role="bold">not</emphasis> try to extract the
<literal>jar</literal> file contents and then attempt to execute
<literal>java org.aspectj.Main</literal>. (A
<classname>NoClassDefFoundError</classname> exception will be
thrown.) The AspectJ distribution is not designed to be installed
this way. Use the <literal>java -jar</literal> form shown above.
</para>
<para>The compressed <literal>tar</literal> files (suffix:
<literal>.tgz</literal>) are extracted by decompressing them with
<literal>tar</literal> or with <literal>WinZip</literal>.
</para>
<para>To uninstall, remove the files the installer wrote in your
file system. In most cases, you can delete the top-level install
directory (and all contained files), after you remove any
new or updated files you want to keep. On Windows, no
registry settings were added or changed, so nothing needs to be
undone. You may install over prior versions, but if the files are
locked the installer will warn you but still complete; in this case,
remove the locked files and reinstall.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:startUsingAJ"
xreflabel="Q: How should I start using AspectJ?">
<para>How should I start using AspectJ?</para>
</question>
<answer>
<para>Many users adopt AspectJ incrementally, first using it
to understand and validate their systems (relying on it only in
development) and then using it to implement crosscutting concerns
in production systems. AspectJ has been designed to make each
step discrete and beneficial.
</para>
<para>
In order of increasing reliance, you may use AspectJ:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis role="bold"> In the development
process
</emphasis> Use AspectJ to trace or log
interesting information. You can do this by adding
simple AspectJ code that performs logging or tracing.
This kind of addition may be removed ("unplugged") for
the final build since it does not implement a design
requirement; the functionality of the system is unaffected by
the aspect.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">As an ancillary part of your
system
</emphasis> Use AspectJ to more completely and
accurately test the system.
Add sophisticated code that can check contracts,
provide debugging support, or implement test strategies.
Like pure development aspects, this code may also be
unplugged from production builds. However, the same code
can often be helpful in diagnosing failures in deployed
production systems, so you may design the functionality
to be deployed but disabled, and enable it when debugging.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold">As an essential part of your
system
</emphasis> Use AspectJ to modularize
crosscutting concerns in your system by design.
This uses AspectJ to implement logic integral to a system
and is delivered in production builds.
</para>
</listitem>
</itemizedlist>
<para>This adoption sequence works well in practice and has been
followed by many projects.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:integrateWithDevTools"
xreflabel="Q: How well does AspectJ integrate with existing Java development tools?">
<para>How does AspectJ integrate with existing Java development
tools?
</para>
</question>
<answer>
<para>AspectJ products are designed to make it easy to integrate
AspectJ into an existing development process.
Each release includes
Ant taskdefs for building programs,
the AspectJ Development Environment (AJDE) for writing
aspects inside popular IDE's, and
command-line tools for compiling, documenting, and debugging.
</para>
<!-- ok to order for style, not priority? -->
<para>AspectJ provides replacements for standard Java tools:
<itemizedlist>
<listitem>
<para><literal>ajc</literal>, the AspectJ compiler,
runs on any Java 2 compatible platform, and produces classes
that run on any Java 1.1 (or later) compatible platform.
</para>
</listitem>
<listitem>
<para><literal>ajdoc</literal> works like
Sun's <literal>javadoc</literal> API documentation generator
to produce HTML describing the semantics of Java and
AspectJ source files, including entries and cross-references
for the crosscutting structure.
</para>
</listitem>
<listitem>
<para><literal>ajdb</literal> is an aspect-aware debugger
akin to Java's <literal>jdb</literal>.
</para>
</listitem>
</itemizedlist>
</para>
<para>The AspectJ Development Environment (AJDE)
enables programmers to view and navigate the crosscutting structures
in their programs, integrated with existing support in
popular Java IDE's for viewing and navigating object-oriented
structures. For many programmers this provides a deeper understanding
of how aspects work to modularize their concerns and permits them
to incrementally extend their development practices without
having to abandon their existing tools.
</para>
<para>
AJDE integrates with the following tools:
</para>
<itemizedlist>
<listitem>
<para>Borland's JBuilder (versions 4 and 5)</para>
</listitem>
<listitem>
<para>Sun Microsystems' Forte for Java (versions 2 and 3),
and Netbeans 3.2
</para>
</listitem>
<listitem>
<para>Eclipse (version 2.0)</para>
</listitem>
<listitem>
<para>GNU Emacs (version 20.3) and XEmacs (version 21.1 on Unix
and 21.4 on Windows)
</para>
</listitem>
</itemizedlist>
<para>
The common functionality of AJDE is also available in
the stand-alone source code browser <literal>ajbrowser</literal>,
included in the tools distribution.
</para>
<para>AspectJ also supports building with Ant by providing
taskdef interfaces to the ajc and ajdoc tools.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="typicalprograms" xreflabel="Typical AspectJ programs">
<title>Typical AspectJ programs</title>
<qandaentry>
<question id="q:aspectsoptional"
xreflabel="Q:Are aspects always optional or non-functional parts of a program?">
<para>Are aspects always optional or non-functional parts of
a program?
</para>
</question>
<answer>
<para>No. Although AspectJ can be used in a way that allows AspectJ
code to be removed for the final build, aspect-oriented code is not
<emphasis>always</emphasis> optional or non-functional. Consider
what AOP really does: it makes the modules in a program correspond
to modules in the design. In any given design, some modules are
optional, and some are not.
</para>
<para>The examples directory included in the AspectJ distribution
contains some examples of the use aspects that are not optional.
Without aspects,
</para>
<informaltable frame="none">
<tgroup cols="2">
<tbody>
<row>
<entry align="right">
<emphasis role="strong">bean</emphasis>
</entry>
<entry>Point objects would not be JavaBeans.</entry>
</row>
<row>
<entry align="right">
<emphasis role="strong">introduction</emphasis>
</entry>
<entry>Point objects would not be cloneable, comparable or
serializable.
</entry>
</row>
<row>
<entry align="right">
<emphasis role="strong">spacewar</emphasis>
</entry>
<entry>Nothing would be displayed.</entry>
</row>
<row>
<entry align="right">
<emphasis role="strong">telecom</emphasis>
</entry>
<entry>No calls would be billed.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</answer>
</qandaentry>
<qandaentry>
<question id="q:developmentAndProductionAspects"
xreflabel="Q:What is the difference between development and production aspects?">
<para>
What is the difference between development and production aspects?
</para>
</question>
<answer>
<para>
Production aspects are delivered with the finished product,
while development aspects are used during the development process.
Often production aspects are also used during development.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:devAspects"
xreflabel="Q:What are some common development aspects?">
<para>
What are some common development aspects?
</para>
</question>
<answer>
<para>Aspects for logging, tracing, debugging, profiling
or performance monitoring, or testing.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:prodAspects"
xreflabel="Q:What are some common production aspects?">
<para>
What are some common production aspects?
</para>
</question>
<answer>
<para>
Aspects for performance monitoring and diagnostic systems,
display updating or notifications generally, security,
context passing, and error handling.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="concepts" xreflabel="Basic AOP and AspectJ Concepts">
<title>Basic AOP and AspectJ Concepts</title>
<qandaentry>
<question id="q:crosscutting"
xreflabel="Q:What are scattering, tangling, and crosscutting?">
<para>What are scattering, tangling, and crosscutting?</para>
</question>
<answer>
<para>
"Scattering" is when similar code is distributed throughout many
program modules. This differs from a component being used by
many other components since
it involves the risk of misuse at each point and of inconsistencies
across all points. Changes to the implementation may require
finding and editing all affected code.
</para>
<para>"Tangling" is when two or more concerns are implemented in
the same body of code or component, making it more difficult to understand.
Changes to one implementation may cause unintended changes
to other tangled concerns.
</para>
<para>"Crosscutting" is how to characterize a concern than spans
multiple units of OO modularity - classes and objects. Crosscutting
concerns resist modularization using normal OO constructs, but
aspect-oriented programs can modularize crosscutting concerns.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:joinpoints"
xreflabel="Q: What are join points?">
<para>What are join points?</para>
</question>
<answer>
<para>Join points are well-defined points in the execution of a
program. Not every execution point is a join point: only those
points that can be used in a disciplined and principled manner are.
So, in AspectJ, the execution of a method call is a join point, but
"the execution of the expression at line 37 in file Foo.java" is
not.
</para>
<para>The rationale for restricting join points is similar to the
rationale for restricting access to memory (pointers) or
restricting control flow expressions (<literal>goto</literal>) in
Java: programs are easier to understand, maintain and extend
without the full power of the feature.
</para>
<para>AspectJ join points include reading or writing a field; calling
or executing an exception handler, method or constructor.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:pointcut"
xreflabel="Q; What is a pointcut?">
<para>
What is a pointcut?
</para>
</question>
<answer>
<para>A pointcut picks out
<link linkend="q:joinpoints">
join points
</link>. These join points are described by the pointcut
declaration. Pointcuts can be defined in classes or in aspects,
and can be named or be anonymous.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:advice"
xreflabel="Q:What is advice?">
<para>What is advice?</para>
</question>
<answer>
<para>Advice is code that executes at each
<link linkend="q:joinpoints">join point</link> picked out by a
<link linkend="q:pointcut">pointcut</link>. There are three
kinds of advice: before advice, around advice and after advice. As
their names suggest, before advice runs before the join point
executes; around advice executes before and after the join point;
and after advice executes after the join point. The power of
advice comes from the advice being able to access values in the
execution context of a pointcut.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:declarations"
xreflabel="Q:What are inter-type declarations?">
<para>What are inter-type declarations?</para>
</question>
<answer>
<para>AspectJ enables you to declare members and supertypes of another class
in an aspect, subject to Java's type-safety and access rules. These are
visible to other classes only if you declare them as accessible.
You can also declare compile-time errors and warnings based on pointcuts.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:whatisanaspect"
xreflabel="Q:What is an aspect?">
<para>What is an aspect?</para>
</question>
<answer>
<para>Aspects are a new class-like language element that has been
added to Java by AspectJ. Aspects are how developers encapsulate
concerns that cut across classes, the natural unit of modularity in
Java.
</para>
<para>Aspects are similar to classes because...
<itemizedlist>
<listitem><para>aspects have type</para></listitem>
<listitem>
<para>
aspects can extend classes and other aspects
</para>
</listitem>
<listitem>
<para>
aspects can be abstract or concrete
</para>
</listitem>
<listitem>
<para>
non-abstract aspects can be instantiated
</para>
</listitem>
<listitem>
<para>aspects can have static and non-static state and
behavior
</para>
</listitem>
<listitem>
<para>aspects can have fields, methods, and types
as members
</para>
</listitem>
<listitem>
<para>the members of non-privileged aspects follow the
same accessibility rules as those of classes
</para>
</listitem>
</itemizedlist>
</para>
<para>Aspects are different than classes because...
<itemizedlist>
<listitem>
<para>aspects can additionally include as members pointcuts,
advice, and inter-type declarations;
</para>
</listitem>
<listitem>
<para>aspects can be qualified by specifying the
context in which the non-static state is available
</para>
</listitem>
<listitem>
<para>aspects can't be used interchangeably with
classes
</para>
</listitem>
<listitem>
<para>aspects don't have constructors or finalizers,
and they cannot be created with the new operator;
they are automatically available as needed.
</para>
</listitem>
<listitem>
<para>privileged aspects can access private members of
other types
</para>
</listitem>
</itemizedlist>
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="whyaop" xreflabel="Why AOP?">
<title>Why AOP?</title>
<qandaentry>
<question id="q:ccfromflaws"
xreflabel="Q:Are crosscutting concerns induced by flaws?">
<para>Are crosscutting concerns induced by flaws in parts of the
system design, programming language, operating system, etc. Or is
there something more fundamental going on?
</para>
</question>
<answer>
<para>AOP's fundamental assumption is that in any sufficiently
complex system, there will inherently be some crosscutting
concerns.
</para>
<para>So, while there are some cases where you could re-factor a
system to make a concern no longer be crosscutting, the AOP idea
is that there are many cases where that is not possible, or where
doing so would damage the code in other ways.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:definingaspectspercc"
xreflabel="Q:Does it really make sense to define aspects in terms of crosscutting?">
<para>Does it really make sense to define aspects in terms of
crosscutting?
</para>
</question>
<answer>
<para>Yes.</para>
<para>The short summary is that it is right to define AOP in terms of
crosscutting, because well-written AOP programs have clear
crosscutting structure. It would be a mistake to define AOP in
terms of "cleaning up tangling and scattering", because that isn't
particular to AOP, and past programming language innovations also
do that, as will future developments.
</para>
<para>Slides for a long talk on this topic are at
<ulink url="http://www.cs.ubc.ca/~gregor/vinst-2-17-01.zip">
http://www.cs.ubc.ca/~gregor/vinst-2-17-01.zip
</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:domainspecific"
xreflabel="Q:Is AOP restricted to domain-specific applications?">
<para>Is AOP restricted to domain-specific
applications?
</para>
</question>
<answer>
<para>No. Some implementations of AOP are domain-specific, but
AspectJ was specifically designed to be general-purpose.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:whyaopifinterceptors"
xreflabel="Q:Why do I need AOP if I can use interceptors?">
<para>Why do I need AOP if I can use interceptors
(or JVMPI or ref
lection)?
</para>
</question>
<answer>
<para>There are many mechanisms people use now to implement
some crosscutting concerns. But they don't have a way to express
the actual structure of the program so you (and your tools)
can reason about it. Using a language enables you to express the
crosscutting in first-class constructs. You can not only avoid the
maintenance problems and structural requirements of some other
mechanisms, but also combine forms of crosscutting so that all
the mechanisms for a particular concern are one piece of code.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="related" xreflabel="Related Technology">
<title>Related Technology</title>
<qandaentry>
<question id="q:comparetonewforms"
xreflabel="Q:How does AspectJ compare to other new forms of programming?">
<para>
How does AspectJ compare to other new forms of programming?
</para>
</question>
<answer>
<para>There are many recent proposals for programming languages that
provide control over crosscutting concerns. Aspect-oriented
programming is an overall framework into which many of these
approaches fit. AspectJ is one particular instance of AOP,
distinguished by the fact that it was designed from the ground up
to be compatible with Java.
</para>
<para>See the
<ulink url="http://aspectj.org/relatedSites">Related
Sites
</ulink> page of the AspectJ web site for more
information.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:compartoreflection"
xreflabel="Q:How do you compare the features of AspectJ with reflective systems?">
<para>How do you compare the features of AspectJ with
reflective systems?
</para>
</question>
<answer>
<para>Reflective and aspect-oriented languages have an important
similarity: both provide programming support for dealing with
crosscutting concerns. In this sense reflective systems proved
that independent programming of crosscutting concerns is
possible.
</para>
<para>But the control that reflection provides tends to be low-level
and extremely powerful. In contrast, AspectJ provides more
carefully controlled power, drawing on the rules learned from
object-oriented development to encourage a clean and understandable
program structure.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:comparetomixin"
xreflabel="Q:How do AspectJ features compare with those of mixin-based inheritance?">
<para>How do AspectJ features compare with those of mixin-based
inheritance?
</para>
</question>
<answer>
<para>Some features of AspectJ, such as introduction, are related to
<emphasis>mixin-based inheritance</emphasis>. But, in order to
support crosscutting, a core goal for AspectJ, AspectJ goes beyond
mixin-based inheritance.
</para>
<para>Firstly, an aspect imposes behavior on a class, rather than a
class requesting behavior from an aspect. An aspect can modify a
class without needing to edit that class. This property is
sometimes called <emphasis>reverse inheritance</emphasis>.
</para>
<para>Secondly, a single aspect can affect multiple classes in
different ways. A single paint aspect can add different paint
methods to all the classes that know how to paint, unlike mixin
classes.
</para>
<para>
So mixin-based inheritance doesn't have the reverse inheritance
property, and mixins affect every class that mixes them in the same.
If I want to do something like SubjectObserverProtocol, I need two
mixins, SubjectPartofSubjectObserverProtocol and ObserverPartof...
In AspectJ, both halves of the protocol can be captured in a single
aspect.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:aopandxp"
xreflabel="Q:What is the relationship between AOP and
XP (extreme programming AKA agile methods)?">
<para>What is the relationship between AOP and
XP (extreme programming AKA agile methods)?
</para>
</question>
<answer>
<para>From a question on the user list:
<programlisting>
> Anyone know the connections between AOP and Extreme Programming?
> I am really confused. It seems AOP is a programming paradigm, which
> is the next level of abstraction of OOP. Extreme Programming, however,
> this is a lightweight software development process. One of the common
> motivations of AOP and XP is designed to adopt to the requirement
> changes, so that it can save the cost of software development.
</programlisting>
</para>
<para>
This is Raymond Lee's answer:
</para>
<para>
You're not really that confused. AOP and XP are orthogonal concepts,
although AOP can be used to help accomplish XP goals.
One of the goals of XP is to respond to changing requirements.
Another is to reduce the overall cost of development. These are
not necessarily the same thing.
</para>
<para>
One of the principles of XP that contribute to meeting those goals
is to maintain clean, simple designs. One of the criteria for clean,
simple designs is to factor out duplication from the code. Benefits
of removing duplication include the code being easier to understand,
better modularity of the design, lower costs of code changes, less
chance of conflicting changes when practicing collective code
ownership, etc.
</para>
<para>
Different types of duplication lend themselves to being addressed by
different design paradigms and language features. Duplicate snippets
of code can be factored out into methods. Duplicate methods can be
factored out to common classes, or pushed up to base classes.
Duplicate patterns of methods and their use can be factored out to
mechanisms of classes and methods (i.e. instantiations of design
patterns).
</para>
<para>
AOP addresses a type of duplication that is very difficult to handle
in the other common paradigms, namely cross-cutting concerns. By
factoring out duplicate cross-cutting code into aspects, the target
code becomes simpler and cleaner, and the cross-cutting code becomes
more centralized and modular.
</para>
<para>
So, AOP as a paradigm, and the associated tools, gives an XPer, or
anyone wanting to remove duplication from the code base, a powerful
way to remove a form of duplication not easily addressed until now.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:aspectjandcsharp"
xreflabel="Q:Will you support C#?">
<para>Will you support C#?</para>
</question>
<answer>
<para>Not at this time. Although the resemblances between C# and Java
means it would probably be a fairly straightforward matter to take
the AspectJ language design and produce AspectC#, our current focus
is only on supporting effective uses of AspectJ.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="adoption" xreflabel="Deciding to adopt AspectJ">
<title>Deciding to adopt AspectJ</title>
<qandaentry>
<question id="q:productplans"
xreflabel="Q:Is it safe to use AspectJ in my product plans??">
<para>
Is it safe to use AspectJ in my product plans?
</para>
</question>
<answer>
<para>You may use AspectJ in your product or project with little
risk. Several factors play a role in reducing the risk of adopting
this new technology:
<itemizedlist>
<listitem>
<para>AspectJ is an <emphasis>addition</emphasis> to
Java, and can be incrementally introduced into a project
in a way that limits risk.
See <xref linkend="q:startUsingAJ"/> for
some suggestions on how to do this.
</para>
</listitem>
<listitem>
<para>The AspectJ compiler accepts standard Java as
input and produces standard Java bytecode as output. An
optional mode produces standard Java source code which may
then be compiled with any compliant Java compiler, e.g. Sun's
<literal>javac</literal> compiler
or IBM's <literal>jikes</literal> compiler.
</para>
</listitem>
<listitem>
<para>AspectJ is available under the
<ulink url="http://aspectj.org/MPL">Mozilla Public License</ulink>,
a non-proprietary, open source license. This ensures that
AspectJ will continue to evolve and be available, regardless
of the fate of any particular organization involved with
AspectJ.
</para>
</listitem>
<listitem>
<para>Removing AspectJ from your program is not
difficult, although you will lose the flexibility and
economy that AspectJ provided.
</para>
</listitem>
</itemizedlist>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:effectonsize"
xreflabel="Q:What is the effect of using AspectJ on the source code size of programs?">
<para>What is the effect of using AspectJ on the source code
size of programs?
</para>
</question>
<answer>
<para>Using aspects reduces, as a side effect, the number of source
lines in a program. However, the major benefit of using aspects
comes from <emphasis>improving</emphasis> the modularity of a
program, not because the program is smaller. Aspects gather into a
module concerns that would otherwise be scattered across or
duplicated in multiple classes.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:effectonperformance"
xreflabel="Q:Does AspectJ add any performance overhead?">
<para>
Does AspectJ add any performance overhead?
</para>
</question>
<answer>
<para>The issue of performance overhead is an important one. It is
also quite subtle, since knowing what to measure is at least as
important as knowing how to measure it, and neither is always
apparent.
</para>
<para>There is currently no benchmark suite for AOP languages in
general nor for AspectJ in particular. It is probably too early to
develop such a suite because AspectJ needs more maturation of the
language and the coding styles first. Coding styles really drive
the development of the benchmark suites since they suggest what is
important to measure.
</para>
<para>In the absence of a benchmark suite, AspectJ probably has an
acceptable performance for everything except non-static advice.
Introductions and static advice should have extremely small
performance overheads compared to the same functionality
implemented by hand.
</para>
<para>The <literal>ajc</literal> compiler will use static typing information
to only insert those checks that are absolutely necessary. Unless you use
'thisJoinPoint' or 'if', then the only dynamic checks that will be
inserted by ajc will be 'instanceof' checks which are generally quite fast.
These checks will only be inserted when they can not be inferred from
the static type information.
</para>
<para>If you'd like to measure the performance be sure to write code
fragments in AspectJ and compare them to the performance of the
corresponding code written without AspectJ. For example, don't
compare a method with before/after advice that grabs a lock to just
the method. That would be comparing apples and oranges. Also be
sure to watch out for JIT effects that come from empty method
bodies and the like. Our experience is that they can be quite
misleading in understanding what you've measured.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:modularityviolations"
xreflabel="Q:I've heard that AspectJ leads to modularity violations. Does it?">
<para>
I've heard that AspectJ leads to modularity violations. Does it?
</para>
</question>
<answer>
<para>
Well I haven't yet seen a language in which you can't write bad code!
</para>
<para>
But seriously, most AspectJ users find that just like when they learned
OO, it takes a while to really get the hang of it. They tend to start
in the usual way, by copying canonical examples and experimenting with
variations on them.
</para>
<para>
But users also find that rather than being dangerous, AspectJ helps them
write code that is more clear and has better encapsulation -- once they
understand the kind of modularity AspectJ supports. There are several
good papers that talk about this (see below), but here's a basic point
to keep in mind: when properly used, AspectJ makes it possible program
in a modular way, something that would otherwise be spread throughout
the code. Consider the following code, adapted from the AspectJ tutorial:
</para>
<programlisting>
aspect PublicErrorLogging {
Log log = new Log();
pointcut publicInterface(Object o):
call(public * com.xerox.*.*(..)) && target(o);
after(Object o) throwing (Error e): publicInterface(o) {
log.write(o, e);
}
}
</programlisting>
<para>
The effect of this code is to ensure that whenever any public method of
an interface or class in the <literal>com.xerox</literal> package
throws an error, that error is logged before being thrown to its caller.
</para>
<para>
Of course in the alternative implementation a large number of methods
have a try/catch around their body.
</para>
<para>
The AspectJ implementation of this crosscutting concern is clearly
modular, whereas the other implementation is not. As a result, if you
want to change it, its easier in the AspectJ implementation. For
example, if you also want to pass the name of the method, or its
arguments to <literal>log.write</literal>, you only have to edit
one place in the AspectJ code.
</para>
<para>
This is just a short example, but I hope it shows how what happens
with AOP and AspectJ is that the usual benefits of modularity are
achieved for crosscutting concerns, and that leads to better code,
not more dangerous code.
</para>
<para>
One paper someone else just reminded me of that talks some more
about this is:
<ulink url="http://www.cs.ubc.ca/~kdvolder/Workshops/OOPSLA2001/submissions/12-nordberg.pdf">
http://www.cs.ubc.ca/~kdvolder/Workshops/OOPSLA2001/submissions/12-nordberg.pdf
</ulink>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:encapsulation"
xreflabel="Q:Why does AspectJ permit aspects to access and add members of another type?">
<para>
Why does AspectJ permit aspects to access and add members of another type?
Isn't that violating OO encapsulation?
</para>
</question>
<answer>
<para>In the spirit of Smalltalk, we have decided to give more power
to the language in order to let the user community experiment and
discover what is right. To date this has proven to be a successful
strategy because it has permitted the construction of many useful
aspects that crosscut the internal state of an object, and as such
need access the its private members. However, we are not
discounting that some sort of restrictions are useful, rather, we
are seeking input from the community in order to decide on what
these restrictions should be.
</para>
<para>
In that light, our position on encapsulation is :
</para>
<itemizedlist>
<listitem><para>we respect Java's visibility rules</para></listitem>
<listitem><para>we also provide open-classes, a mature OO technology</para></listitem>
<listitem><para>we provide "privileged" access if you really need it.</para></listitem>
</itemizedlist>
<para>
Introducing parents or members to classes is a well-studied OO technique
known as open classes.
</para>
<para>
Open classes have been used in many languages prior to AspectJ,
including CLOS, Python, Smalltalk, Objective-C, and others.
Building from Java, introduction in AspectJ provides better
name hygiene and access control than prior languages.
Introduced code obeys all of Java's normal accessibility rules
for its lexical location in the aspect that it is introduced from.
Such code can not even see, much less access, private members of
the class it is introduced into. Further, introductions can be
declared private to the aspect, so they are not visible to
other clients of the class.
</para>
<para>
Privileged aspects do permit access to private members of another
class. They are a response to the very few cases where developers
genuinely need such access (typically for testing purposes where it
access is necessary), but it would be more risky to open access by
putting the aspect in the same package, adding test code, or changing
access in the target class. We recommend using privileged aspects
only as necessary, and believe that marking them "privileged" makes
any potential misuse apparent.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:aspectjandj2ee"
xreflabel="Q:Can I use AspectJ with J2EE?">
<para>Can I use AspectJ with J2EE?</para>
</question>
<answer>
<para>
Consider the component types in J2EE:
</para>
<itemizedlist>
<listitem>
<para>
Servlet: AspectJ works well within servlets
</para>
</listitem>
<listitem>
<para>
JSP: It is possible to use AspectJ to affect code in JSPs by precompiling
them into Java sources and compiling these with ajc. This can be used, e.g., to
customize displays by turning on and off custom JSP taglibs. The mapping from a
given jsp source to java package and class name is not standardized, which means
doing this imposes dependencies on specific container versions.
</para>
</listitem>
<listitem>
<para>
EJB: AspectJ supports a wide variety of aspects for EJBs. It can be used for
logging, tracing, debugging, error handling by layers, correlated method-level
interception (e.g., chargebacks), metering, fine-grained transactions, etc.
Indeed, it can be used to enforce adherence to coding restrictions within an
EJB (e.g., not using java.io, creating a class loader, or listening on
sockets) using <literal>declare error</literal>.
</para>
</listitem>
</itemizedlist>
<para>
The basic limitations are that there is no built-in support for writing J2EE
analogs for AspectJ extensions to Java, like distributed aspects, distributed
cflow, or managing state between invocations. These don't prevent one from using
AspectJ to do useful intra-container implementation, nor need they prevent one
from building distributed support, state management, and inter-component
implementations that leverage AspectJ. It just takes some work. In more detail:
</para>
<para>
All AspectJ implementations may define "code the implementation controls".
The AspectJ 1.0 implementation defines this as the files passed to the compiler
(AspectJ 1.1 will also support bytecode weaving).
</para>
<para>
Some advice on EJB operations will generate methods that confuse ejb compilers.
To avoid this problem, you can use the -XaddSafePrefix flag when compiling with ajc.
</para>
<para>
EJB components may be invoked remotely, and containers may passivate and
pool EJB's. Servlets have similar limitations, and in both cases the
lifespan of the defining class loader is implementation-dependent
(though it must span the operation of a particular request).
</para>
<para>
Being limited by lifecycle and namespace, the AspectJ 1.0 implementation
supports aspects that operate through non-remote invocations during the lifetime
of the namespace for a particular
deployment unit compiled in its entirety by the ajc compiler.
This means AspectJ supports common aspects only within a single local runtime
namespace (usually implemented as a class loader hierarchy).
</para>
<para>
Further, AspectJ recognizes language-level join points (object initialization,
method calls, etc.), not their EJB analogs (ejb find or create methods...).
These lead to the following consequences:
</para>
<itemizedlist>
<listitem>
<para>
Issingleton aspects (the default) are limited to the lifetime of
the defining class loader, which in some implementations may not span
multiple invocations of the same application or EJB component.
</para>
</listitem>
<listitem>
<para>
EJB lifecycles are different from object lifecycles, so perthis
and pertarget aspects will make little sense. They do not work
in the current implementation, which uses synchronized methods
to ensure a correct association in threaded environments
(EJB's may not have synchronized methods).
</para>
</listitem>
<listitem>
<para>
Percflow or percflowbelow aspects are restricted to a chain of
non-remote invocations. While EJB 2.0 permits declaring an interface
local, this information is not available to the AspectJ compiler today.
For same reasons as stated above fore perthis, these will not work even
in the EJB container.
</para>
</listitem>
<listitem>
<para>
Evaluation of cflow or cflowbelow pointcuts will be valid only
with respect to a chain of non-remote invocations.
</para>
</listitem>
</itemizedlist>
<para>
In addition, any AspectJ code should respect EJB operations:
</para>
<itemizedlist>
<listitem>
<para>
The EJB container accesses EJB component fields directly, i.e.,
in code outside the control of the compiler. There is no join point for
these accesses, and hence no way to write a pointcut to advise that access.
</para>
</listitem>
<listitem>
<para>
The EJB container may pool EJB components, so any initialization
join points may run once per component constructed, not once per
component initialized for purposes of a client call.
</para>
</listitem>
<listitem>
<para>
The EJB container is permitted to change class loaders, even
between invocations of a particular EJB component (by passivating and
activating with a new class loader). In this case, instances of singleton
aspects will not operate over multiple invocations of the component, or that
static initialization join point recur for a given class as it is re-loaded.
This behavior depends on the container implementation.
</para>
</listitem>
</itemizedlist>
</answer>
</qandaentry>
<qandaentry>
<question id="q:aspectjandgj"
xreflabel="Q:Can I use AspectJ with Generic Java?">
<para>Can I use AspectJ with Generic Java?</para>
</question>
<answer>
<para>At this time, unfortunately not. The two compilers are just not
at all compatible. In an ideal world, there would be a wonderful
Open Source extensible compiler framework for Java that both GJ and
AspectJ would be built on top of, and they would seamlessly
interoperate along with all other extensions to Java that you might
be interested in, but that's not the case (yet?).
</para>
<para>However, on 09 October 2000, the Java Community Process
approved a proposal to add generic types to Java that is largely
based on GJ (JSR 14). A draft specification was submitted for
public review, which closed on 01 August 2001, and a
<ulink url="http://plan9.bell-labs.com/who/wadler/pizza/gj/">
prototype implementation
</ulink> has been released.
</para>
<para>We are committed to moving very rapidly to add support for
generic types in AspectJ when generic types become part of the Java
language specification. Everyone on the AspectJ team is looking
forward to this, because we too would really like to be able to
write code that includes both aspects and generic types.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:aopinjava"
xreflabel="Q: Are you working to put AOP into Java?">
<para> Are you working to put AOP into Java?
It seems that every AOP toolset currently uses proprietary mechanisms
to describe point-cuts, etc.
</para>
</question>
<answer>
<para>
We are working on standardization, but it's
a question of timing/ripeness (imagine going from thousands of users
to millions). (See <xref linkend="q:standardization"/>.) We believe
AspectJ addresses this question in the best way possible now:
<itemizedlist>
<listitem>
<para>
It's open-source. Rather than being proprietary or controlled by a
vendor, it's available for anybody to use and build upon, forever.
</para>
</listitem>
<listitem>
<para>
AspectJ is not a set of mechanisms, it's a language. It is currently
implemented using certain techniques, but there's nothing that prevents
it from being implemented with other techniques. That means users can
adopt the language with confidence that implementations will get better.
</para>
</listitem>
<listitem>
<para>
There is no engineering need to change Java. The AspectJ language uses
the join point model already in Java, so there is no need to extend the
programming model. Our implementation produces valid Java bytecode, which
runs in any compliant J2SE VM and supports standard debuggers for those VM's
that support JSR-45 (debugging support for multi-language/multi-file sources).
This is a huge benefit to Sun since Sun must be extremely cautious
about extensions to the language or VM; before adopting AOP, Sun should
demand the kind of actual-proof that AspectJ implementations offer.
</para>
</listitem>
<listitem>
<para>
On the issue of "proprietary mechanisms to describe pointcuts, etc.": Any AOP
has to have some language to describe pointcuts and the like ("pointcuts"
of course being the AspectJ term). Users would like to have one language
(to avoid having to learn or transform between many languages) and the
choice of multiple implementations (tailored for a configuration, subject
to competitive pressure, etc.). That's what AspectJ offers.
</para>
</listitem>
<listitem>
<para>
That said, we believe the AspectJ extensions to Java could form the basis
for bringing AOP to Java; when that happens, there will be engineering
opportunities to make the implementation and tool support better.
</para>
</listitem>
</itemizedlist>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:support"
xreflabel="Q: What kind of support is available?">
<para>What kind of support is available?</para>
</question>
<answer>
<para>
The AspectJ users mailing list provides an
informal network of AspectJ experts. To subscribe,
visit the <ulink url="http://aspectj.org/servlets/AJSite?channel=userCommunity&subChannel=mailingLists">Mailing Lists</ulink>
page of the AspectJ web site.
</para>
<para>If you have a problem that is not a bug, you may email
the AspectJ team at
<ulink url="mailto:support@aspectj.org">support@aspectj.org</ulink>.
You may view and submit bug reports and feature requests at
<ulink url="http://aspectj.org/bugs">http://aspectj.org/bugs</ulink>.
</para>
<para>Members of the AspectJ team are available to work with users in
more depth on both program design and implementation issues.
The team also presents educational courses and speakers for
interested groups and offers commercial support
and consulting for businesses.
Please contact the
<ulink url="mailto:support@aspectj.org">AspectJ team</ulink>.
with your request.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="compiler" xreflabel="Using the AspectJ compiler">
<title>Using the AspectJ compiler</title>
<qandaentry>
<question id="q:requiredsources"
xreflabel="Q:What files do I need to include when compiling AspectJ programs?">
<para>
What files do I need to include when compiling AspectJ programs?
</para>
</question>
<answer>
<para>You need to specify to the compiler the source files that
contain your aspects and the source files that contain the
types affected by your aspects.
See <xref linkend="q:knowWhenAspectsAffectClasses"/>.
The AspectJ compiler will not search the source path for types
that may be affected (unlike Javac and Jikes), and it only uses
aspects in source form.
</para>
<para>In some cases you should compile your entire system all at once.
If this is too slow, then you can try to make reasonable divisions
between sets of source files whose aspects do not interact to
achieve a shorter compile cycle (particularly for development
aspects). However, if you get any problems
or if you wish to run tests or do a release, you should recompile
the entire system.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:listingsources"
xreflabel="Q:Is there any other way to provide the file names to ajc?">
<para>I have to list many files in the command line to
compile with <literal>ajc</literal>. Is there any other way to
provide the file names to <literal>ajc</literal>?
</para>
</question>
<answer>
<para>
Yes, use the argfile option to ajc. List source
files in a line-delimited text file and direct ajc to that
file using <literal>-argfile</literal> or <literal>@</literal>:
</para>
<programlisting>ajc @sources.lst
ajc -argfile sources.lst
</programlisting>
<para>
For more information, see the <literal>ajc</literal> tool
section of the
<ulink url="devguide/index.html">
Development Environment Guide
</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:compilerVM"
xreflabel="Q: What Java virtual machine (JVM) do I use to run the
AspectJ compiler? ">
<para>What Java virtual machine (JVM) do I use to run the
AspectJ compiler?
</para>
</question>
<answer>
<para>Use the latest, greatest, fastest JVM you can get your hands on
for your platform. The compiler's performance is dependent on the
performance of the JVM it is running on, so the faster a JVM you
can find to run it on, the shorter your compile times will be. At a
minimum you need to use a Java 2 or later JVM to run the compiler.
We realize that this constraint can be a problem for users who
don't currently have a Java 2 JVM available. We're sorry for the
inconvenience, but we had to make the hard decision that the
advantages of being able to rely on Java 2 were worth the cost of
losing a number of developers who are working on platforms without
Java 2 support. Here is a list of starting places where you might
find support for your system.
<itemizedlist>
<listitem>
<para>
<ulink url="http://java.sun.com/j2se/">Java 2
Platform, Standard Edition
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink
url="http://www.ibm.com/java/jdk/download/">
developerWorks : J
ava technology : Tools and products - Developer kits
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink
url="http://oss.software.ibm.com/developerworks/projects/jikes/?dwzone=opensource">
developerWorks : Open Source - Jikes Project
</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink url="http://java.sun.com/cgi-bin/java-ports.cgi">Java
Platform Ports
</ulink>
</para>
</listitem>
</itemizedlist>
</para>
<para>The requirement of Java 2 support is only for
<emphasis>running</emphasis> the AspectJ compiler. The AspectJ
compiler can be used to build programs that will run on Java 1.1
(or probably even on Java 1.0) systems. This means that it can
build programs that will run on Macintosh, FreeBSD, and applets
that will run in Internet Explorer and Netscape Navigator that are
still not yet Java 2 compliant.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:compilingForDifferentVMs"
xreflabel="Q: How to use ajc to compile for a different VM?">
<para>How can I use <literal>ajc</literal> to compile
programs for a JVM that is different from the one used to run it?
</para>
</question>
<answer>
<para>
<literal>ajc</literal> can be used to develop programs that are
targeted at the Java 1.1 platform, even though the
<literal>ajc</literal> compiler won't run on that platform. Here's
an example of using <literal>ajc</literal> in this sort of
cross-compilation mode (assuming a Windows platform with all the
default installation directories):
</para>
<programlisting>
ajc -target 1.1 -bootclasspath c:\jdk1.1.7\lib\classes.zip \
-classpath c:\aspectj1.0\lib\aspectjrt.jar -extdirs "" \
-argfile jdk11system.lst
</programlisting>
<para>This same technique can be used if you want to run
<literal>ajc</literal> on a JDK 1.3 JVM (highly recommended) but
need to generate code for JDK 1.2. That would look something
like:
</para>
<programlisting>
ajc -bootclasspath c:\jdk1.2\jre\lib\rt.jar \
-classpath c:\aspectj1.0\lib\aspectjrt.jar \
-extdirs c:\jdk1.2\jre\lib\ext
-argfile jdk12system.lst
</programlisting>
</answer>
</qandaentry>
<qandaentry>
<question id="q:assert"
xreflabel="Q:Does the ajc compiler support the assert keyword in Java 1.4?">
<para>Does the <literal>ajc</literal> compiler support
the <literal>assert</literal> keyword in Java 1.4?
</para>
</question>
<answer>
<para>Yes. As with <literal>Javac</literal>,
use the <literal>-source 1.4</literal> option as described
in the <literal>ajc</literal> tool section
of the
<ulink url="devguide/index.html">
Development Environment Guide
</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:msjvm"
xreflabel="Q:Are there any issues using AspectJ with the Microsoft JVM?">
<para>Are there any issues using AspectJ with the Microsoft
JVM?
</para>
</question>
<answer>
<para>Since AspectJ requires Java 2 or later, it will not run on the
Microsoft JVM, which does not support Java 2.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:javacbytecode"
xreflabel="Q:Does ajc rely on javac for generating bytecode?">
<para>Does <literal>ajc</literal> rely
on <literal>javac</literal> for generating Java bytecode
(<literal>.class</literal>) files?
</para>
</question>
<answer>
<para> No. Some previous versions of AspectJ had this requirement,
and <literal>javac</literal> can still be used as
<literal>ajc</literal> back end by using the
<literal>-usejavac</literal> flag. You can also run <literal>ajc</literal>
in preprocessor mode to generate Java source
(<literal>.java</literal>) files to be compiled using
<literal>javac</literal> or another java compiler.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:parsergenerators"
xreflabel="Q:I noticed the AspectJ compiler doesn't use a parser generator. Why is that?">
<para>
I noticed the AspectJ compiler doesn't use a parser generator. Why is that?
</para>
</question>
<answer>
<para>
The PARSER for ajc is written by hand. This choice was made with full
awareness of the generator tools out there. (Jim had for example used
the excellent javacc tool for building the parser for JPython (now Jython)).
One of the reasons that AspectJ uses a hand-written parser is that using
javacc taught Jim about the LL-k design for parsers (pioneered by antlr).
As opposed to the state-machine parsers produced by yacc, these parsers are
very readable and writable by humans.
</para>
<para>
Antlr and javacc did not really suit the project:
</para>
<itemizedlist>
<listitem>
<para>
Antlr's support for unicode in the lexer is still immature and this makes
using it with Java challenging. This was an even bigger issue 3 years ago
when we started on the Java implementation of ajc.
</para>
</listitem>
<listitem>
<para>
While javacc is freely available, it is not Open Source. Depending on a
closed-source tool to build an Open Source compiler would reduce some
of the transparency and control of open-source.
</para>
</listitem>
</itemizedlist>
<para>
There were also several things that were easier to implement with
a hand-written parser than with any of the exiting tools.
</para>
<itemizedlist>
<listitem>
<para>
Semi-keywords -- it's important to us that
"every legal Java program is also a legal AspectJ program."
This wouldn't be true if we made 'before' and 'call' full keywords in
AspectJ. It is easier to support these sorts of semi-keywords with a
hand-written parser. (Note: ajc-1.0.x handles 'aspect' and 'pointcut'
slightly specially which can break a few unusual pure Java programs.
This is a compiler limitation that will be fixed in a future release.)
</para>
</listitem>
<listitem>
<para>
Deprecated syntax warnings -- the syntax of AspectJ
changed many times from version 0.2 to the 1.0 release. It was easier
to provide helpful warning messages for these changes with our
hand-written parser.
</para>
</listitem>
<listitem>
<para>
Grammar modularity -- We like being able to have
AspectJParser extend JavaParser.
</para>
</listitem>
<listitem>
<para>
Part of the grammar for AspectJ is extremely hard for existing tools to
capture. This is the type pattern syntax, i.e. "com.xerox..*.*(..)".
The sort of case that gives standard parser generators fits is something
like "*1.f(..)" which no one would ever write, but which must be
supported for a consistent language.
</para>
</listitem>
</itemizedlist>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="devtools" xreflabel="Integrating AspectJ into your development environment">
<title>Integrating AspectJ into your development environment</title>
<qandaentry>
<question id="q:knowWhenAspectsAffectClasses"
xreflabel="Q: How do I know which aspects affect a class when looking at that class's source code?">
<para>How do I know which aspects affect a class when looking
at that class's source code?
</para>
</question>
<answer>
<para>When you are working with the IDE support, you can get an
understanding of which aspects affect any class.
This enables AspectJ programmers to get the benefits of
modularizing crosscutting concerns while still having immediate
access to what aspects affect a class.
</para>
<para>For example, the
<ulink url="devguide/index.html">
Development Environment Guide
</ulink> section
on <literal>ajbrowser</literal> shows that you can list or navigate
between method and advice affecting that method and between a type
and declarations in an aspect on that type. (The IDE support may
have more features than <literal>ajbrowser</literal>, depending
on the IDE.)
</para>
<para>
When you are looking at documentation,
<literal>ajdoc</literal> will provide links from aspects and
advice to the affected code, but it provides less information
than the IDE support because it only parses declarations.
</para>
<para>
When you are running your program,
you can trace advice as it executes. This
enables you to identify advice on join points picked out
dynamically, which cannot be reflected precisely by IDE support.
</para>
<para>See <xref linkend="q:integrateWithDevTools"/> for more
information on which Java development environments are
supported.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:idesupport"
xreflabel="Q:What kind of IDE support is available for developing AspectJ programs?">
<para>What kind of IDE support is available for developing
AspectJ programs?
</para>
</question>
<answer>
<para>See <xref linkend="q:integrateWithDevTools"/></para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:hybridbuilds"
xreflabel="Q:Setting up hybrid builds">
<para>I want the aspects for development builds but
remove them for production builds. How can I set up the build
system so they are unpluggable? And so I use <literal>javac</literal>
in my production build?
</para>
</question>
<answer>
<para>
If you are using development-time-only aspects - aspects that only
exist when you are developing the code, not when you ship it -
you can use implement a hybrid build process by listing
the production source files into a javac-compliant argfile,
and the development source files in another ajc argfiles:
</para>
<programlisting>
-- file "production.lst":
One.java
two/Three.java
...
-- file "tracing.lst":
trace/Library.java
Trace.java
-- file "development.lst":
@production.lst
@tracing.lst
</programlisting>
<para>
Then your development build can use <literal>ajc</literal>:
</para>
<programlisting>
ajc @development.lst
</programlisting>
<para>
And your development build can use
<literal>ajc</literal> or <literal>javac</literal>
or <literal>jikes</literal>:
</para>
<programlisting>
jikes @production.lst
</programlisting>
</answer>
</qandaentry>
<qandaentry>
<question id="q:idesupportplans"
xreflabel="Q:What plans are there to support my IDE?">
<para>What plans are there to support my IDE?</para>
</question>
<answer>
<para>
The AspectJ team directly provides components for JBuilder, Forte,
and Emacs. We also support the open-source AspectJ plugin project
at <ulink url="http://eclipse.org/ajdt">http://eclipse.org/ajdt</ulink>
which uses the AJDE API support for IDE's. We
are interested in supporting other developers as they use AJDE
to provide components for the following IDE's (roughly in
order of interest and viability).
<itemizedlist>
<title></title>
<listitem>
<para>IDEA/IntelliJ has an enthusiastic community and
the developers are working on an extensibility API
- <ulink url="http://intellij.com">http://intellij.com</ulink>
</para>
</listitem>
<listitem>
<para>jEdit comes from a very active open-source community.</para>
</listitem>
<listitem>
<para>
Oracle JDeveloper has an Extension SDK unfamiliar to us.
</para>
</listitem>
<listitem>
<para>Together extensibility API is too limited</para>
</listitem>
<listitem>
<para>
VisualCafe may have a difficult extensibility API
</para>
</listitem>
<listitem>
<para>
IBM's VisualAge for Java is to be replaced with Eclipse
</para>
</listitem>
<listitem>
<para>Some have suggested Codeguide from Omnicore
<ulink url="http://www.omnicore.com">http://www.omnicore.com/</ulink>
</para>
</listitem>
<listitem><para>Visual SlickEdit ??</para></listitem>
<listitem><para>Kawa has been discontinued</para></listitem>
<listitem> <para>VIM has been suggested.</para></listitem>
</itemizedlist>
</para>
<para>
If you would like to build support for an IDE, contact us so we can help.
To contribute or propose new IDE's, please
<ulink url="mailto:support@aspectj.org?subject=IDE%20Support:%20">mail us</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:portingajde"
xreflabel="Q:Can I port AJDE support to my development environment?">
<para>Can I port AJDE support to my development environment?</para>
</question>
<answer>
<para>Yes. The core AJDE API is extensible and the source code is
available for download. Start by studying the sources
for the existing IDE support.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="notes" xreflabel="Programming notes and tips">
<title>Programming notes and tips</title>
<qandaentry>
<question id="q:methodsignatures"
xreflabel="Q:Is it possible to change methods by introducing keywords, adding parameters, or changing the throws clause?">
<para>Is it possible to change methods by introducing keywords (like
<literal>synchronized</literal>), adding parameters,
or changing the "throws" clause?
</para>
</question>
<answer>
<para>AspectJ does not enable you to change the signature of a method,
but you can (by express declaration) work around some
limits imposed by the signature. You can convert a checked exception to
unchecked using <literal>declare soft</literal>, privileged aspects
have access to private methods, and you can use a percflow aspect to
ferry additional state to a callee without changing intervening
signatures. For more details, see
<ulink url="progguide/index.html">The AspectJ Programming Guide</ulink>.
In the case of <literal>synchronized</literal>,
we have what we consider a better solution that uses
around advice instead of introduction. This solution is described
in
<ulink url="http://aspectj.org/pipermail/users/2000/000534.html">
this thread
</ulink> on the AspectJ users list, with some
<ulink url="http://aspectj.org/pipermail/users/2000/000536.html">
additional comments
</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:seeingjoinpoints"
xreflabel="Q:I don't understand what join points exist. How can I see them?">
<para>
I don't understand what join points exist. How can I see them?
</para>
</question>
<answer>
<para>
Try using an aspect posted to the user's list called
<ulink url="http://aspectj.org/pipermail/users/2002/001883.html">
TraceJoinPoints.java
</ulink>.
For example, you can start logging at a particular method call and
see what join points occur after the call and before it returns.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:comparecallandexecution"
xreflabel="Q:What is the difference between call and execution join points?">
<para>
What is the difference between call and execution join points?
</para>
</question>
<answer>
<para>
Briefly, there are two interesting times when a constructor or method is
run. Those times are when it is called, and when it actually
executes.
</para>
<para>
The main difference is that a call join point happens outside of
the object (for non-static methods) or class (for static methods
and constructors), and that an execution join point happens inside
the object or class. This means that the <literal>within</literal>
and <literal>withincode</literal> pointcuts pick them out
differently: A call join point is picked out within the caller,
while an execution join point is picked
out where it is actually defined.
</para>
<para>
A call join point is the ``outermost'' join point for a particular
call. Once a call join point proceeds, then a number of different
things happen. For non-static methods, for example, method
dispatch happens, which will cause one method execution join point
-- perhaps more, if there are super calls. For constructors, the
super constructor is called, and fields are initialized, and then
various constructor execution join points will occur.
</para>
<para>
A call join point matches only the ``external'' calls of a method
or constructor, based on a signature, and it does not pick out
calls made with <literal>super</literal>, or
<literal>this</literal> constructor calls.
</para>
<para>Here's more detail:
</para>
<para>Consider method execution in Java as (1) the initial call from
this object to some method on the target object with a
particular signature; and (2) the execution of the actual code
in the particular method dispatched in the target object.
The call join point starts with the initial call and ends
when control returns to the call (by return or perhaps
thrown exception). The execution join point starts with
the method body and ends when the body completes (again
by return or throwing an exception), so the execution join
point always happens within the bounds of the corresponding
call join point. You can see this if you use the
join-point tracing aspect in
<ulink url="http://aspectj.org/pipermail/users/2002/001883.html">
TraceJoinPoints.java
</ulink>.
as described above.
</para>
<para>As you would expect, the context differs
in advice on pointcuts picking out execution and call join
points; for call, <literal>this</literal> refers to the caller, whereas
for execution <literal>this</literal> refers to the called
(executing) object.
</para>
<para>
There are some subtle interactions with other AspectJ semantics.
First, the meaning of the signature in the
<literal>execution()</literal> and <literal>call()</literal>
pointcut designators (PCD's) differ: the call type depends upon
the type of the reference making the call, while the execution
type depends on the enclosing class.
Second, you may choose one over another if you cannot bring all
your sources within the code the compiler controls
(described in the <ulink url="progguide/apb.html">appendix</ulink>
to the <literal>Programming Guide</literal>).
For example, to trace calls into a
method from classes which are outside the code the compiler controls
at compile time, then using <literal>execution()</literal> will work
while using <literal>call()</literal>may not. Finally, since
<literal>super</literal> invocations are not considered method calls,
to trace <literal>super.foo()</literal> would require using
<literal>execution</literal>.
</para>
<para>
In most cases you should use the <literal>call()</literal>
pointcut designator unless you have a good reason to use
<literal>execution()</literal>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:comparecflowandcflowbelow"
xreflabel="Q:What is the difference between cflow and cflowbelow?">
<para>
What is the difference between cflow and cflowbelow?
</para>
</question>
<answer>
<para>
Both pick out all the join points in the control flow of
the specified join points.
They differ only in that the <literal>cflowbelow()</literal>
pointcut designator does not pick out the join points
specified, while <literal>cflow()</literal> does.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:recursiveentrypoints"
xreflabel="Q:How do I say that I want the topmost entrypoint in a recursive call?">
<para>How do I say that I want the topmost entrypoint in a
recursive call? How about the most-recent prior entrypoint?
</para>
</question>
<answer>
<para>This is best seen by way of example.
Given a recursive call to <literal>int factorial(int)</literal>
you can print the arguments for
(a) the current and most-recent recursive call
or (b) the current and original recursive call:
</para>
<programlisting>
aspect LogFactorial {
pointcut f(int i) : call(int factorial(int)) && args(i);
// most-recent
before(int i, final int j) : f(i) && cflowbelow(f(j)) {
System.err.println(i + "-" + j);
}
// original
before(int i, final int j) : f(i)
&& cflowbelow(cflow(f(j)) && !cflowbelow(f(int))) {
System.err.println(i + "@" + j);
}
}
</programlisting>
</answer>
</qandaentry>
<qandaentry>
<question id="q:initializationjoinpoints"
xreflabel="Q:What is the difference between constructor call, constructor execution, initialization, and static initialization join points?">
<para>What is the difference between constructor call,
constructor execution, initialization, and static
initialization join points?
</para>
</question>
<answer>
<para>Static initialization pertains to initialization of
a class or interface type. Constructor call and execution
are akin to method call, and initialization generalizes this and
picks out the first constructor called.
</para>
<para>Their relations are best
demonstrated by tracing the join points. Below is the class
Test which implements an interface and extends a class
along with a trace of the join points below and including
the constructor call obtained using
<literal>TraceJointPoints.java</literal> (linked above).
</para>
<programlisting>
<![CDATA[
public class Init {
public static void main (String[] args) {
new Test();
end();
}
static void end() {}
}
class Super {}
interface I {}
class Test extends Super implements I {
Test() {}
}
<constructor-call sig="Test()" >
<staticinitialization sig="Super._init_" />
<staticinitialization sig="Test._init_" />
<initialization sig="Super()" >
<instanceinitializer-execution sig="Super._init_" />
<constructor-execution sig="Super()" />
</initialization>
<initialization sig="I()" >
<instanceinitializer-execution sig="I._init_" />
<constructor-execution sig="I()" />
</initialization>
<initialization sig="Test()" >
<instanceinitializer-execution sig="Test._init_" />
<constructor-execution sig="Test()" />
</initialization>
</constructor-call>
]]>
</programlisting>
<para>
Ordinarily, using a <literal>call</literal> pointcut designator
is best because the call join point surrounds the others, but in
the case of constructors there is no target object for
the call (because it has not been constructed yet), so you
might prefer to use the <literal>initialization</literal>
pointcut designator.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:adviseconstructors"
xreflabel="Q:How do I work with an object right when it is created?">
<para>How do I work with an object right when it is created?
</para>
</question>
<answer>
<para>
You can advise some form of constructor join point.
Constructors are tricky in Java, and that's exposed in AspectJ.
Here are some rules of thumb:
<itemizedlist>
<listitem>
<para>If you want the join point on the "outside" of object creation,
use after returning from call to the constructor:
</para>
<programlisting>
after() returning (Foo newlyCreatedObject): call(Foo.new(..)) { ... }
</programlisting>
<para>
You might be tempted to use "this" or "target" to expose the new object, but remember
that if you're on the "outside" of object creation, the object itself might not be
created yet... it only exists "on the way out", when you return the object.
</para>
</listitem>
<listitem>
<para>If you want the join point inside a particular constructor, use:
</para>
<programlisting>
after(Foo newlyCreatedObject) returning: this(newlyCreatedObject) && execution(Foo.new(..)) { ... }
</programlisting>
<para>
Remember, though, that if you use "before" advice here, the body of the constructor
will not have run, and so the object may be somewhat uninitialized.
</para>
</listitem>
<listitem>
<para>
In the rare case that there are all sorts of constructors for the object that call
each other with <literal>this(...)</literal> and you want exactly one join point
for each initialization of <literal>Foo</literal>, regardless of the path of
constructors it takes, then use:
</para>
<programlisting>
after(Foo f) returning: this(f) && initialization(Foo.new(..)) { ... }
</programlisting>
</listitem>
</itemizedlist>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:andingpointcuts"
xreflabel="Q:I want advice to run at two pointcuts, but it doesn't run at all.">
<para>
I want advice to run at two pointcuts, but it doesn't run at all. What gives?
</para>
</question>
<answer>
<para>
This reflects both a conceptual error and a programming mistake.
Most likely you want to do something like "run the advice for all
public and private calls," and the code looks something like this:
</para>
<programlisting>
within(com.xerox.printing..*) && call(public * *(..)) && call(private * *(..))
</programlisting>
<para>
A pointcut picks out join points; it is evaluated at each join point.
The expression above would never pick out any call join point,
because no method signature has both public and private access.
In a pointcut, <literal>pc1() && pc2()</literal> means both
must be true at a given join point for advice to run at that join point.
The correct pointcut would use <literal>||</literal> as follows:
</para>
<programlisting>
within(com.xerox.printing..*) && (call(public * *(..)) || call(private * *(..)))
</programlisting>
<para>
Then the advice will run at the join point.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:staticfieldreferences"
xreflabel="Q:How do I refer to a static field when my advice crosscuts multiple classes?">
<para>
How do I refer to a static field when my advice crosscuts multiple classes?
</para>
</question>
<answer>
<para>There is no way in advice to refer to the type of the
code executing in a static context except by specification.
This makes it impossible to refer to static members using
runtime information.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:interfacesastypepatterns"
xreflabel="Q:How can I reuse a type pattern?">
<para>I would like to reuse a type pattern, e.g., to
write advice that is limited to a certain set of classes.
Do I have to retype it each time?
</para>
</question>
<answer>
<para>No. You can declare that all the types implement
an interface you define, and then use the interface type in
your program. For example:
</para>
<programlisting>
/**
* Example of using an interface to represent a type pattern.
* sub-aspects use declare parents to add to traced types, e.g.,
* declare parents: com.mycompany.whatever..* implements Marked;
*/
abstract aspect MarkerExample {
/** marker interface for types that we want to trace */
interface Marked {}
/** calls to an instance of Marked not from an instance of Marked */
pointcut dynamicCallsIn(): call(* *(..)) && target(Marked) && !this(Marked);
/** calls to methods defined by a subtype of Marked
* that don't come from the body of a subtype of Marked
*/
pointcut staticCallsIn(): call(* Marked+.*(..)) && !within(Marked+);
/** print dynamic calls */
before(): dynamicCallsIn() { System.out.println("before " + thisJoinPoint); }
}
aspect MyMarker extends MarkerExample {
declare parents: com.mycompany.whatever..* implements Marked;
}
</programlisting>
</answer>
</qandaentry>
<qandaentry>
<question id="q:exampleprograms"
xreflabel="Q:Where do I find example programs?">
<para>Where do I find example programs?</para>
</question>
<answer>
<para>Some examples are distributed in the documentation release,
and you can find other code in the discussions on the users list.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:aspectlibraries"
xreflabel="Q:Are aspect libraries available?">
<para>Are aspect libraries available?</para>
</question>
<answer>
<para>Some libraries are distributed in the release under the
examples folder in the distribution. If you develop a library and
want to make it available to other users, make sure to
<ulink
url="http://aspectj.org/servlets/AJSite?channel=supportAndBugs&subChannel=askAQuestion">
contact us
</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:serialversionuid"
xreflabel="Q:How does ajc interact with the serialVersionUID?">
<para>How does <literal>ajc</literal> interact with the
<literal>serialVersionUID</literal>?
</para>
</question>
<answer>
<para>The current version of <literal>ajc</literal> can change the
<varname>serialVersionUID</varname> of generated
<filename>.class</filename> files as a result of weaving in advice.
This is an important fact that developers using both aspects and
serialization should be aware of. It is likely that a future
version of the compiler will be better behaved regarding the
<varname>serialVersionUID</varname>.
</para>
<para>However, changes to the <literal>serialVersionUID</literal>
attribute are typically only important when using serialization for
the long-term persistence of objects. Using standard Java
serialization for long-term persistence has a number of drawbacks
and many developers already use alternative solutions. For one
possibly standard solution, see
<ulink url="http://jcp.org/jsr/detail/057.jsp">
Lon
g-Term Persistence for JavaBeans Specification
</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:applets"
xreflabel="Q:How can I use AspectJ with applets?">
<para>How can I use AspectJ with applets?</para>
</question>
<answer>
<para>
Just include the aspectjrt.jar as a required archive.
For example, here is the HTML code for an HTML editor
applet that contains some debugging aspects:
</para>
<programlisting>
<![CDATA[
<APPLET
CODE='com.company.swing.applets.EditorApplet'
WIDTH='700'
HEIGHT='525'>
<PARAM NAME="CODE" VALUE="com.company.swing.applets.EditorApplet" >
<PARAM NAME="ARCHIVE"
VALUE ="../company-applets.jar,../aspectjrt.jar,../xmlrpc-applet.jar" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
<PARAM NAME="scriptable" VALUE="false">
</APPLET>
]]>
</programlisting>
<para>
The above markup has worked reliably with the Java Plugin
(included in the JRE 1.4.x) in IE 6, Mozilla 1.1 (Win32),
and Mozilla 1.0.1 (Red Hat Linux 8.0).
The following link describes how to configure Mozilla/Netscape
6.x/7.x to use the Java Plugin from a JRE/SDK installation:
<ulink url="http://java.sun.com/j2se/1.4.1/manual_install_linux.html">
http://java.sun.com/j2se/1.4.1/manual_install_linux.html</ulink>.
(Thanks to Chris Bartling for this answer.)
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:typeoblivious"
xreflabel="Q:How can I specify types for advice that captures primitives, void, etc.?">
<para>How can I specify types for advice that captures primitives, void, etc.?</para>
</question>
<answer>
<para>
In some cases, AspectJ allows conversion from values of primitive types to Object,
so that highly polymorphic advice may be written. This works if an advice parameter
or the return type for around is typed to Object. So:
</para>
<programlisting>
class Test {
static int i;
public static void main(String[] args) {
i = 37;
}
}
aspect TraceSet {
before(Object val): set(* Test.*) && args(val) {
System.err.println(val);
System.err.println(val.class);
}
}
</programlisting>
<para>
will print out
</para>
<programlisting>
37
java.lang.Integer
</programlisting>
<para>
For more information, see the Programming Guide
<ulink url="http://aspectj.org/doc/dist/progguide/apbs02.html">
semantics section "Context Exposure"
</ulink>.
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="problems" xreflabel="Common Problems">
<title>Common Problems</title>
<qandaentry>
<question id="q:infiniterecursion"
xreflabel="Q:When I run, I get a StackOverflowError or no output.">
<para>When I run, I get a <literal>StackOverflowError</literal>
(or a long stack trace or no output whatsoever)
</para>
</question>
<answer>
<para>Most likely this is a case of infinite recursion,
where advice is advising itself. It presents as a
<literal>StackOverflowError</literal>
or silence as the VM exhausts itself in the recursion.
</para>
<para>Of course, infinite recursion is possible in Java:</para>
<programlisting>
public class Main {
public static void main(String[] args) {
try {
main(args);
} finally {
main(args);
}
}
}
</programlisting>
<para>If you compile and run this program, and it will fail silently, trying
to process the finally clause even after throwing the StackOverflowError.
</para>
<para>Here's a similar AspectJ program where the recursion is
not so obvious:
</para>
<programlisting>
aspect A {
after(): call(* *(..)) { System.out.println("after " + thisJoinPoint); }
}
</programlisting>
<para>This re-invokes itself because it advises any call.
It invokes itself even after an exception is thrown, since
<literal>after</literal> advice, like a finally clause, runs even
after exceptions are thrown. You can fix this by following two practices:
</para>
<para>
(1) Use <literal>after returning</literal> to advise normal completions
or <literal>after throwing</literal> to advise abrupt completions.
If you use <literal>after</literal> or <literal>after throwing</literal>,
write the advice with the same care you would a finally clause,
understanding that it may run after some failure.
</para>
<para>(2) Avoid writing advice that advises itself. One simple way to
do so is to exclude the code within the current aspect:
</para>
<programlisting>
aspect A {
after() returning: !within(A) && call(* *(..)) {
System.out.println("after " + thisJoinPoint);
}
}
</programlisting>
<para>A better way is often to re-write the pointcut.
If the advice is advising itself accidentally, that's a sign that
the pointcut is not saying what you mean.
</para>
<programlisting>
aspect A {
pointcut withinTargetClasses() : within(A+) || within(B+);
after() returning: withinTargetClasses() && call(* *(..)) {
System.out.println("after " + thisJoinPoint);
}
}
</programlisting>
</answer>
</qandaentry>
<qandaentry>
<question id="q:typelessdeclarations"
xreflabel="Q:I've declared a field on every class in my package; how do I use it in advice?">
<para>I've declared a field on every class in
my package; how do I use it in advice?
</para>
<programlisting>
aspect A {
boolean com.xerox..*.dirtyFlag;
after (Object target) returning
: target(target) && call(* com.xerox..*.set*(..)) {
target.dirtyFlag = true; // compile fails here
}
}
</programlisting>
</question>
<answer>
<para>You need a type to refer to any member, field or method.
It's generally better to introduce onto an interface and
declare classes to implement the interface, which permits you
to use the interface type in advice formals.
</para>
<programlisting>
aspect A {
interface TrackingSets {}
boolean TrackingSets.dirtyFlag;
declare parents : com.xerox..* implements TrackingSets;
after (TrackingSets target) returning
: target(target) && call(* com.xerox..*.set*(..)) {
target.dirtyFlag = true;
}
}
</programlisting>
</answer>
</qandaentry>
<qandaentry>
<question id="q:ajcoom"
xreflabel="Q:The AspectJ compiler aborts with an OutOfMemoryError when compiling many classes. How can I fix this?">
<para>The AspectJ compiler aborts with an OutOfMemoryError when
compiling many classes. How can I fix this?
</para>
</question>
<answer>
<para>The command <literal>ajc</literal> is actually a script that
launches a Java virtual machine with the correct classpath. You
should make a copy of this script, rename it, and then edit it.
Change the -Xmx option, size of memory allocation pool (heap). You
might try <literal>-Xmx128M</literal> or even
<literal>-Xmx256M</literal>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:ajcrecompile"
xreflabel="Q:ajc recompiles all files every time. How can I make it recompile only the files that have changed?">
<para>
<literal>ajc</literal> recompiles all files every time.
How can I make it recompile only the files that have changed?
</para>
</question>
<answer>
<para>
<literal>ajc</literal> 1.0 does not currently support incremental
compilation, but we are working on this for the 1.1 release.
</para>
<para>As a limited workaround, many build systems enable you to avoid
doing a compile if no sources have changed. (See, e.g., Ant's
"uptodate" task.)
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:ajcjvm"
xreflabel="Q:ajc is using the wrong JVM. How do I fix it?">
<para>
<literal>ajc</literal> is using the wrong JVM. How do I
fix it?
</para>
</question>
<answer>
<para>The easiest way to fix this is to re-install
<literal>ajc</literal> (using the same <literal>.class</literal> or
<literal>.exe</literal> file that you originally downloaded) and
this time make sure to tell it to use the desired JDK (typically
the JDK versions 1.2 or 1.3 from Sun).
</para>
<para>If you are familiar with DOS batch files or shell programming,
you could also fix this by simply editing the
<literal>bin\ajc.bat</literal> or <literal>bin/ajc</literal>
script.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:idebalkingataspects"
xreflabel="Q:My IDE is trying to parse AspectJ files which makes my project unusable. What can I do?">
<para>My IDE is trying to parse AspectJ files which makes my project unusable.
What can I do?
</para>
</question>
<answer>
<para>
When working with an unsupported IDE that objects to the syntax of
AspectJ source files (and, e.g., automatically gathers them
in a source tree as Java files based on the .java extension),
you can use the .aj extension for your AspectJ files.
The ajc compiler accepts both .java and .aj files, and you can
set up your build scripts to include the correct list of
source files. (You will have to find another editor for
editing AspectJ files; you can use the ajbrowser to view
edit your AspectJ files and navigate the crosscutting structure.)
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:idememory"
xreflabel="Q:I used to be able to compile my program, but now I run out of memory.">
<para>I used to be able to compile my program in my IDE, but when I
use AJDE, I run out of memory (or it goes really slow).
</para>
</question>
<answer>
<para>
The ajc compiler does more analysis than (e.g.,) javac,
and AJDE may in some IDE's hold a copy of the structure tree until the
next tree is available from the compile process. Both mean that you may
need extra memory to compile the same program. However, increasing
available memory to the point that you are swapping to disk can
slow the process considerably.
</para>
<para>
If you are having problems and would like to find the optimal memory
allocation, iteratively decrease the amount of memory available until
AJDE or ajc signals out-of-memory errors, and then increase that
amount by 5-10%.
</para>
<para>
To increase memory for the ajc compiler, see <xref linkend="q:ajcoom"/>.
For your IDE, do something similar or follow the provider's instructions.
For example, to increase memory in JBuilder, edit the
<literal>jbuilderX/bin/jbuilder.config</literal>
file to have an entry like:
<programlisting>
vmparam -Xmx384m
</programlisting>
</para>
<para>
If it turns out that your project is too big to use with AJDE, your IDE
may nonetheless support external commands or Ant build processes, which
run outside the IDE memory space. For an Ant taskdef, see
<ulink url="http://aspectj.org/dl"/>. For a JBuilder Ant plugin, some
people have directed us to <ulink url="http://antrunner.sourceforge.net"/>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:stacktraces"
xreflabel="Q:My stack traces don't make sense. What gives?">
<para>
My stack traces don't make sense. What gives?
</para>
</question>
<answer>
<para>Unless you are using the <literal>ajdb</literal> debugger,
stack traces may
have synthetic methods in the stack, and the line numbers may
not track your source code. The
<ulink url="devguide/index.html">Development Environment Guide</ulink>.
discusses how to interpret stack at the end of the section
on the <literal>ajc</literal> compiler.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:advicenotrunning"
xreflabel="Q:My advice is not running (or running twice), and I don't know why.">
<para>
My advice is not running (or running twice), and I don't know why.
</para>
</question>
<answer>
<para>When advice is not running, it is probably a problem in the
pointcut. Sometimes users specify pointcuts that do not mean what they intend -
most often when they misspell a type name. Run the compiler in
<literal>-Xlint</literal> mode, which will flag some likely mistakes,
like the type name. If that does not work, use
<ulink url="http://aspectj.org/pipermail/users/2002/001883.html">
TraceJoinPoints.java
</ulink> to see if your join points are executing at all.
</para>
<para>When advice is running more than it should, it may be that your
pointcut picks out more join points than you intend.
If you are using IDE support, you should be able to trace back from
the pointcut or advice to the join points which can be statically
determined to be affected. To identify advised dynamic join points,
you can try using
<ulink url="http://aspectj.org/pipermail/users/2002/001883.html">
TraceJoinPoints.java
</ulink>, but often it is easier to update the advice to
print the source location of the join point.
This will show if the advice applies to code that you did
not consider.
</para>
<para>If you've done this and convinced yourself it's not working,
it may be a bug. See <xref linkend="q:bugreports"/>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:packagedeclares"
xreflabel="Q:I declared a member on a class with package access, but other classes in the package cannot see it.">
<para>
I declared a member on a class with package access, but other classes in the package cannot see it.
</para>
</question>
<answer>
<para>When declaring parents on other types from an aspect, package access only
applies to code the implementation controls. For AspectJ 1.0, that is the set of files
passed to the compiler. That means other classes not compiled with the aspect will not
be able to access the aspect-declared members even if they are in the same package.
The only way for classes outside the control of the implementation to access aspect-declared
members is to declare them public.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:cantfindjavac"
xreflabel="Q:ajc complains that it can't find javac. What's wrong?">
<para>
<literal>ajc</literal> complains that it can't find
<literal>javac</literal>. What's wrong?
</para>
</question>
<answer>
<para>
<literal>ajc</literal> does not try to locate
<literal>javac</literal> in your path: it uses the
<literal>javac</literal> classes directly. In JDK 1.2 and 1.3 these
classes are found in <literal>tools.jar</literal> (in the
<literal>lib</literal> directory of the JDK distribution), which
must be on your classpath to make
<literal>ajc</literal> work with <literal>javac</literal>.
Inspect the java command that launches ajc to make sure that
<literal>tools.jar</literal> is on the classpath for ajc;
the -classpath option only applies to the sources compiled.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:ajdocneeds13"
xreflabel="Q:I'm running under 1.4, but ajdoc asks for 1.3 (or throws IllegalAccessError for HtmlWriter.configuration)">
<para>
I'm running under 1.4, but <literal>ajdoc</literal> asks for 1.3
(or throws IllegalAccessError for HtmlWriter.configuration)
</para>
</question>
<answer>
<para>
The current implementation of <literal>ajdoc</literal> uses
specific javadoc classes in the J2SE 1.3 tools.jar.
We are working on addressing this limitation, but in the interim
it is best to run ajdoc under 1.3.
</para>
<para>
When running from the command-line scripts, edit the scripts directly
to put the 1.3 tools.jar first on the classpath. (The installer does
not know about this limitation of ajdoc.)
</para>
<para>
When running from Ant, users often have tools.jar in ${ant.classpath}
(to make javac, et al work). That makes it impossible to run the ajdoc
taskdef (which does not currently support forking), so you'll need to
run a separate ant process, either from the command-line or via Ant's
exec task (the Ant task will propagate the classpath).
If the wrong tools.jar is not on the ant classpath, then it should work
to put the 1.3 tools.jar in the taskdef classpath.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:compileunits"
xreflabel="Q:I set up different files to my compiles to change what the aspects see, but now I don't understand how the aspects are working?">
<para>I set up different files to my compiles to change what
the aspects see, but now I don't
understand how the aspects are working.
</para>
</question>
<answer>
<para>It is a bad practice to use the compilation unit
to control crosscutting. Aspects and pointcuts especially
should be written to specify crosscutting precisely.
Aspects will behave the same when you add files if
you initially included all files affected by your aspects.
If you use the compilation unit, then your code will behave
differently in AspectJ implementations that do not limit
themselves to specified files.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:readingpreprocessedcode"
xreflabel="Q:I'm reading the code generated by ajc in -preprocess mode, and it seems like it would not work.">
<para>I'm reading the code generated by <literal>ajc</literal>
in <literal>-preprocess</literal> mode, and it seems like it would not
work (or "like it works this way").
</para>
</question>
<answer>
<para>The generated code can be difficult for a human to read and
understand. The compiler uses implementation techniques which might
not be apparent. To determine if the code is behaving correctly, you
should write and run a program that attempts to provoke the error you
suspect. Similarly, you should not rely on invariants you infer from
the generated code (especially naming conventions for generated members).
Please rely only on the semantics stated in the appendix of the
AspectJ <ulink url="progguide/index.html">Programming Guide</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:injection"
xreflabel="Q:I've heard AspectJ can generate or inject code into my code. Is this true?">
<para>I've heard AspectJ can generate or inject code into my code.
Is this true?
</para>
</question>
<answer>
<para>
This is a misconception spawned from the early implementation.
</para>
<para>
AspectJ does not "inject" or "generate" code. In AspectJ the
pointcut constructs allow the programmer to identify join points,
and the advice constructs define additional code to run at those
join points.
</para>
<para>
So the semantic model of advice is like the semantic model of a
method -- it says "when any of these things happen, do this".
</para>
<para>
People who worked with earlier versions of AspectJ, in which ajc
was very explicitly a pre-processor, sometimes thought of AspectJ
as injecting code. But that was an artifact of the implementation,
not the underlying language semantics.
</para>
<para>
This distinction is important for two reasons. One is that thinking
about it this way will make more sense at the implementation continues
to evolve towards load-time or runtime weaving. The other is that
it makes it much easier to understand the semantics of advice on
cflow pointcuts.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:currentbugs"
xreflabel="Q:What are the bugs now most affecting users?">
<para>What are the bugs now most affecting users?</para>
</question>
<answer>
<itemizedlist>
<listitem>
<para>
<ulink url="http://aspectj.org/bugs/ajdoc?id=813">813</ulink>
- Ajdoc requires J2SE 1.3 tools.jar, not that of 1.2 or 1.4.
</para>
</listitem>
</itemizedlist>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="help" xreflabel="Getting Help">
<title>Getting Help</title>
<qandaentry>
<question id="q:moreaboutaj"
xreflabel="Q:How do I find out more about AspectJ?">
<para>
How do I find out more about AspectJ?
</para>
</question>
<answer>
<para>Visit the AspectJ project web site:
<ulink url="http://aspectj.org">http://aspectj.org</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:bugreports"
xreflabel="Q:How do I submit a bug report?">
<para>How do I submit a bug report?</para>
</question>
<answer>
<para>You can submit a bug using the web interface
<ulink url="http://aspectj.org/bugs">http://aspectj.org/bugs</ulink>
(preferred), or you may send email to
<ulink url="mailto:jitterbug@aspectj.org">jitterbug@aspectj.org</ulink> directly.
See also
If it seems to be a bug in the compiler,
please include in the body of the email source code to reproduce the problem.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:comments"
xreflabel="Q:How do I submit comments and feature requests?">
<para>
How do I submit comments and feature requests?
</para>
</question>
<answer>
<para>You can email comments to all users at
<ulink url="mailto:users@aspectj.org">users@aspectj.org</ulink>,
email the AspectJ team at
<ulink url="mailto:support@aspectj.org">support@aspectj.org</ulink>.
You can view and submit bug reports and feature requests at
<ulink url="http://aspectj.org/bugs">http://aspectj.org/bugs</ulink>.
If you think you might simply be making a mistake, you might
email some source code to
<ulink url="mailto:users@aspectj.org">users@aspectj.org</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:talktousers"
xreflabel="Q:How do I communicate with other AspectJ users?">
<para>
How do I communicate with other AspectJ users?
</para>
</question>
<answer>
<para>You can reach other AspectJ users by using the
aspectj-users mailing list. To subscribe to the list or view the
list archives go to the user community page:
<ulink url="http://aspectj.org/lists">
http://aspectj.org/lists
</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:searchingsite"
xreflabel="Q:How can I search the email archives or the web site?">
<para>
How can I search the email archives or the web site?
</para>
</question>
<answer>
<para>
There is a search entry box on the left navigation bar of the web site,
but it is generally more effective to do a google search of the form,
<ulink url="http://www.google.com/search?q=site%3Aaspectj.org+%22abstract pointcuts%22">
http://www.google.com/search?q=site%3Aaspectj.org+%22abstract pointcuts%22
</ulink>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:writingbugsandemails"
xreflabel="Q:How should I write email queries?">
<para>
How should I write email queries?
</para>
</question>
<answer>
<orderedlist>
<listitem>
<para>
Here's the big picture of what I'm trying to do...
</para>
</listitem>
<listitem>
<para>
Here's what I think it takes, in AspectJ terms
(concepts, syntax, and semantics) from the
<ulink url="progguide/index.html">Programming Guide</ulink>...
</para>
</listitem>
<listitem>
<para>
Here's the AspectJ code I'm using, the output it
produces when run, and what I expect...
</para>
</listitem>
</orderedlist>
<para>
The big picture helps others redirect you to other approaches.
Using AspectJ terms helps others correct mistakes in thinking
about the problem (the most common being to confuse join points
and pointcuts).
The code is key to clarifying your question and getting a good
response. On the mail list, someone can reply by fixing your
code. In bugs, the developers can reproduce the problem immediately
and start analyzing the fix.
</para>
<para>
For the mail lists, we try to follow the conventions for open-source
discussions that help avoid "the tragedy of the commons."
For example conventions, see
<ulink url="http://jakarta.apache.org/site/mail.html">
http://jakarta.apache.org/site/mail.html
</ulink> and
<ulink url="http://www.tuxedo.org/%7Eesr/faqs/smart-questions.html">
http://www.tuxedo.org/%7Eesr/faqs/smart-questions.html
</ulink>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:idebugs"
xreflabel="Q:How do I write bugs for the IDE support?">
<para>
How do I write bugs for IDE support?
</para>
</question>
<answer>
<para>
Bugs appearing in the IDE's may apply to the affected IDE
or to the compiler. Compiler stack traces in IDE message windows
are prefixed "Internal Compiler Error" and should be written up
as compiler bugs. If you are unsure, try redoing the compile
from the command line.
</para>
<para>
Bug reports for the Eclipse support go to the Eclipse
<ulink url="http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AJDT">
bugzilla
</ulink> database.
Bug reports on other IDE support should have version
information for both Java and the IDE, and
(most importantly) clear steps for reproducing the bug.
You may submit the bugs via the web form
(<ulink url="http://aspectj.org/bugs">http://aspectj.org/bugs</ulink>)
or via email
(<ulink url="mailto:jitterbug@aspectj.org">jitterbug@aspectj.org</ulink>).
</para>
<para>
One of the benefits of open-source is that you can
find and fix the bug for yourself; when you submit
the fix back to us, we can validate the fix for you
and incorporate it into the next release. Email
<ulink url="mailto:support@aspectj.org">support@aspectj.org</ulink>
for instructions on submitting a patch.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:ajcbugs"
xreflabel="Q:How do I write bugs for the AspectJ compiler?">
<para>
How do I write bugs for the AspectJ compiler?
</para>
</question>
<answer>
<para>
The best compiler bug report is a reproducible test case,
standalone code that demonstrates the problem.
Sometimes with aspects, a test case requires several
files, if not some way to capture the behavior.
Here's how we recommend submitting test cases:
<orderedlist>
<listitem>
<para>
Write the test case so that when the compiler bug
is fixed, the test completes normally without output
(e.g., expected compiler errors are issued,
or classes produced run correctly). This usually
means writing one or more source files.
</para>
</listitem>
<listitem>
<para>
In the bug report, briefly summarize the bug.
If it is not obvious, be sure to specify
the expected output/behavior (e.g., compiler error on line 32)
and, if the compile should complete, the main class to run.
</para>
</listitem>
<listitem>
<para>
At the end of the report, append each source file,
separated with a line and the file name.
(Include all sources, and do not send attachments.)
</para>
</listitem>
<listitem>
<para>
Submit the bugs via the web form
(<ulink url="http://aspectj.org/bugs">http://aspectj.org/bugs</ulink>)
or via email
(<ulink url="mailto:jitterbug@aspectj.org">jitterbug@aspectj.org</ulink>).
</para>
</listitem>
</orderedlist>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:teachingmaterials"
xreflabel="Q:Can you recommend reading or teaching material for AspectJ?">
<para>
Can you recommend reading or teaching material for AspectJ?
</para>
</question>
<answer>
<para>The documentation available on this site is a primary source of
material on AspectJ:
<informaltable frame="none">
<tgroup cols="2">
<tbody>
<row>
<entry valign="top">
<ulink url="http://aspectj.org/doc/papersAndSlides">
Selected AspectJ Papers and Presentations
</ulink>
</entry>
<entry>Papers presented at various conferences; tutorial
slide presentations.
</entry>
</row>
<row>
<entry valign="top">
<ulink url="http://aspectj.org/documentation/papersAndSlides/ECOOP1997-AOP.pdf">
Aspect-Oriented Programming
</ulink>
</entry>
<entry valign="top">
The seminal AOP/AspectJ paper
</entry>
</row>
<row>
<entry valign="top">
<ulink url="progguide/index.html">
The AspectJ Programming Guide
</ulink>
</entry>
<entry valign="top">A practical guide for programmers.
Includes a number of examples, some quite
sophisticated.
</entry>
</row>
<row>
<entry>
<ulink url="tutorial.pdf">The AspectJ Tutorial</ulink>
</entry>
<entry>Slides from a day-long tutorial presentation on
AspectJ.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:consulting"
xreflabel="Q:Where can our group get consulting and support?">
<para>
Where can our group get consulting and support?
</para>
</question>
<answer>
<para>Beyond what's available on the aspectj.org web site,
the AspectJ team does a limited amount of consulting
and support for qualified groups. For more information,
see <xref linkend="q:support"/>.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:faqchanges"
xreflabel="Q:What has changed since the last FAQ version?">
<para>
What has changed since the last FAQ version?
</para>
</question>
<answer>
<para>
Entries changed since the earlier November 26 version:
<itemizedlist>
<listitem><para><xref linkend="q:adviseconstructors"/></para></listitem>
</itemizedlist>
</para>
</answer>
</qandaentry>
</qandadiv>
<qandadiv id="project" xreflabel="About the AspectJ Project">
<title>About the AspectJ Project</title>
<qandaentry>
<question id="q:opensource"
xreflabel="Q:What does the fact that AspectJ is an Open Source Project mean to me?">
<para>What does the fact that AspectJ is an Open Source
Project mean to me?
</para>
</question>
<answer>
<para>Open source protects your interest in a correct, long-lived,
up-to-date, and widely-accepted implementation of AspectJ.
<itemizedlist>
<listitem>
<para>With the source code, you control your own destiny
in perpetuity. You can continue to use the implementation
and update it as necessary to fix bugs and add things you need.
</para>
</listitem>
<listitem>
<para>Because the code is available to all, anyone can find
and fix bugs. There is no need to hope for it to be fixed
in the next product release. Those who encounter the bugs
are motivated to fix them, and there are more eyeballs on
the code than in closed-source, so the quality tends to be high.
This can be particularly true for the AspectJ community,
which tends to be highly skilled.
</para>
</listitem>
<listitem>
<para>The same is true of new features or behavior, so the
implementation should be up-to-date. This is important as
the field of AOP develops, to capture the latest solutions.
</para>
</listitem>
<listitem>
<para>For a programming language which forms the basis of
an entire solution stack, open source facilitates the kind
of adoption -- tool integrations and significant projects --
that develop and prove the technology for wider adoption. This
limits delays caused by waiting for the completion of standards
process or promulgation by industry leaders, and also provides
the proofs necessary for such adoption.
</para>
</listitem>
</itemizedlist>
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:standardization"
xreflabel="Q:What are your plans to make AspectJ a general feature of Java supported by Sun and the other key-players in the Java Industry?">
<para>What are your plans to make AspectJ a general feature
of Java supported by Sun and the other key players in the Java
Industry?
</para>
</question>
<answer>
<para>Although we are committed to making AspectJ available to a wide
range of users, it is too early to decide on a strategy. Some
options include continuing AspectJ as a stand-alone product,
integrating it into IDEs, or possibly incorporating it into
standard Java with Sun's blessing.
</para>
<para>We currently focus on developing for the 1.1 implementation
which improves AspectJ in key areas: rapid
incremental compilation, bytecode weaving, and IDE integration.
</para>
<para>Through all of this our goal is to make AspectJ integrate as
seamlessly as possible with the Java programming language. The
AspectJ language design is becoming more integrated, the compiler
is becoming faster and more integrated, the IDE extensions are
becoming more integrated. All of this is designed to help users
really use AspectJ and give us feedback on it.
</para>
<para>As the system is improved and we work more closely
with users, we will be in good position to explore the best path
for AspectJ in the long term.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:bytecodeweaving"
xreflabel="Q:When will AspectJ work from class files? When will it work at class-loading time?">
<para>When will AspectJ work from class files?
When will it work at class-loading time?
</para>
</question>
<answer>
<para>Bytecode weaving is scheduled for AspectJ 1.1. We believe it
will work as described in an email to the users list by Jim Hugugin:
</para>
<para>
The AspectJ language was designed to support weaving at many different times:
compile, load, or even run-time in the JVM. Weaving into bytecodes at both
compile and load-time will definitely be provided in a future release. This
will allow weaving at compile-time into libraries for which source code is
not available. It will also support aspect-aware class loaders that can
perform weaving at load time on arbitrary classes. One advantage of a
language like AspectJ, rather than an explicit meta-tool like jiapi, is
that it separates the specification of a crosscutting concern from any
particular implementation strategy for weaving.
</para>
<para>
...AspectJ provides a language that can cleanly
capture crosscutting concerns while preserving the static type checking,
modularity, and composability of Java.
</para>
<para>If you have an application for using aspects and bytecode,
please let the AspectJ team know of your requirements.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:differences"
xreflabel="Q:What are the differences between the current and previously released versions of AspectJ?">
<para>What are the differences between the current and
previously released versions of AspectJ?
</para>
</question>
<answer>
<para>The AspectJ team aims to keep the implementation up-to-date
and bug-free, but to limit language changes to those that
are carefully considered, compelling, and backwards-compatible,
and to deliver those language changes only in significant releases (1.0, 1.1).
</para>
<table>
<title></title>
<tgroup cols="2">
<tbody>
<row>
<entry align="left">Version</entry>
<entry align="left">Description</entry>
</row>
<row>
<entry>AspectJ 1.0</entry>
<entry>Many language changes, fixes, cleanup and
clarifications, some significant.
</entry>
</row>
<row>
<entry>AspectJ 0.8</entry>
<entry>More cleanup of the syntax and semantics.</entry>
</row>
<row>
<entry>AspectJ 0.7</entry>
<entry>Clean up of the semantics, 0.7 beta 4 is the first
open source release.
</entry>
</row>
<row>
<entry>AspectJ 0.6</entry>
<entry>Advice and crosscuts get explicit type signatures
which describe the values that are available to advice at a
crosscut.
</entry>
</row>
<row>
<entry>AspectJ 0.5</entry>
<entry>Improved tool support: better Emacs environment
support and <literal>ajdoc</literal> to parallel
<literal>javadoc</literal>. around advice is added, and the
<literal>aspect</literal> keyword is removed and replaced
by the Java keyword class.
</entry>
</row>
<row>
<entry>AspectJ 0.4</entry>
<entry>Clear separation of crosscuts and crosscut actions
makes it possible to define extensible library
aspects.
</entry>
</row>
<row>
<entry>AspectJ 0.3</entry>
<entry>First all Java implementation, also includes many
small language improvements.
</entry>
</row>
<row>
<entry>AspectJ 0.2</entry>
<entry>General-purpose support for crosscutting. Users could
program any kind of aspects, not just coordination. This
release dropped COOL.
</entry>
</row>
<row>
<entry>AspectJ 0.1</entry>
<entry>A single domain-specific aspect language, called COOL,
for programming coordination in multi-threaded
programs.
</entry>
</row>
</tbody>
</tgroup>
</table>
<para> More detailed comments are available in the
<literal>doc/changes.html</literal> file in the
distribution.
</para>
</answer>
</qandaentry>
<qandaentry>
<question id="q:schedule"
xreflabel="Q:What is the AspectJ development schedule?">
<para>
What is the AspectJ development schedule?
</para>
</question>
<answer>
<table>
<title>The AspectJ Development Schedule</title>
<tgroup cols="2">
<tbody>
<row>
<entry align="left">Version</entry>
<entry align="left">Description</entry>
</row>
<row>
<entry valign="top" align="center">1.0</entry>
<entry>Final syntax and semantic changes. Standalone structure
browser. Complete documentation.
</entry>
</row>
<row>
<entry valign="top" align="center">1.1</entry>
<entry>Faster incremental compilation, bytecode weaving,
and a small number of language changes.</entry>
</row>
<row>
<entry valign="top" align="center">2.0</entry>
<entry>New, dynamic crosscuts (bytecode-only)</entry>
</row>
</tbody>
</tgroup>
</table>
</answer>
</qandaentry>
</qandadiv>
</qandaset>
<para>AspectJ is a registered trademark of Palo Alto Research Center, Incorporated (PARC).
Java and all Java-based marks are trademarks or registered trademarks of
Sun Microsystems, Inc. in the United States and other countries. All other
trademarks are the property of their respective owners.
</para>
</article>
<!--
Local variables:
compile-command: "java com.icl.saxon.StyleSheet -o faq.html faq.xml /usr/local/docbook/docbook-xsl-1.44/html/docbook.xsl"
fill-column: 79
sgml-local-ecat-files: faq.ced
End:
-->
|