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

ajbrowser.xml 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <chapter id="ajbrowser" xreflabel="AspectJ Browser">
  2. <title>AspectJ Browser</title>
  3. <sect1 id="ajbrowser-intro">
  4. <title>Introduction</title>
  5. <para>
  6. AJBrowser presents a GUI for compiling programs with ajc
  7. and navigating crosscutting structure.
  8. </para>
  9. <para>
  10. The AspectJ Browser can edit program source files,
  11. compile using the AspectJ compiler <literal>ajc</literal>
  12. run a program,
  13. and graphically navigate the program's
  14. crosscutting structure.
  15. For more information on <literal>ajc</literal>,
  16. see <xref linkend="ajc-ref"/>.
  17. </para>
  18. <para>
  19. Launch the browser from the command line either
  20. by typing "ajbrowser" to invoke the script in
  21. <literal>{aspectj}/bin</literal>
  22. (if AspectJ is installed correctly)
  23. or by using the
  24. <literal>aspectjtools.jar</literal> directly,
  25. and specifying no arguments or some number of
  26. build configuration files
  27. (suffix <literal>.lst</literal>):
  28. <programlisting>
  29. java -jar aspectj1.1/lib/aspectjtools.jar aspectj1.1/doc/examples/spacewar/debug.lst
  30. </programlisting>
  31. </para>
  32. </sect1>
  33. <sect1 id="ajbrowser-building">
  34. <title>Building Programs</title>
  35. <sect2 id="build-configurations" xreflabel="build-configurations">
  36. <title>Build Configurations</title>
  37. <para>A build configuration is a set of files to compile for a
  38. program (and optionally some additional compile arguments).
  39. Because <literal>ajc</literal> requires all sources to be specified
  40. (at least using the <literal>-sourceroots</literal> option),
  41. most users create <literal>.lst</literal> files that list
  42. the files to compile (one argument per line, globbing
  43. permitted - for more details, see <xref linkend="ajc-ref"/>).
  44. </para>
  45. <para>
  46. To work with a particular program, select the
  47. corresponding ".lst" build configuration file
  48. from the GUI using the File menu, "open" item,
  49. or by using the
  50. "Open Build Configuration" button
  51. (<inlinemediaobject>
  52. <imageobject>
  53. <imagedata fileref="openConfig.gif"/>
  54. </imageobject>
  55. </inlinemediaobject>).
  56. You can populate the build list from the command line
  57. by passing any number of ".lst" paths.
  58. (However, if you pass in any non-".lst" arguments,
  59. it will run the command-line compiler directly.)
  60. </para>
  61. <para>
  62. To switch between build configurations,
  63. select, add, or remove them
  64. using the corresponding toolbar buttons.
  65. </para>
  66. <para>Global build options are stored in an
  67. <literal>.ajbrowser</literal> file in your HOME directory.
  68. Edit these from the GUI by clicking the "Options" button
  69. or selecting the Tools menu item "Options...".
  70. This is how to set classpath, aspectpath, etc.
  71. </para>
  72. <para>The following sections walk through a build.
  73. </para>
  74. </sect2>
  75. <sect2 id="compiling-a-program-build-configuration" xreflabel="compiling-a-program-build-configuration">
  76. <title>Compiling a Program Build Configuration</title>
  77. <para>
  78. To compile click the "Build" button
  79. (<inlinemediaobject>
  80. <imageobject>
  81. <imagedata fileref="build.gif"/>
  82. </imageobject>
  83. </inlinemediaobject>), or
  84. or use the tools menu.
  85. </para>
  86. <!--
  87. <para>To build using AspectJ 1.1's incremental mode,
  88. click the <literal>incremental compile</literal> checkbox in
  89. the <literal>AspectJ Build Options</literal> tab
  90. of the <literal>Options</literal> dialog.
  91. Once in incremental mode, you can force a full rebuild
  92. by holding the shift key down when selecting the
  93. build menu item or button.
  94. </para>
  95. -->
  96. <para>
  97. You may select
  98. from different build configurations in the GUI
  99. (see label 1 in the graphic below).
  100. (If you get classpath or other errors, set up the
  101. global build options as described above.)
  102. </para>
  103. <para>
  104. <inlinemediaobject>
  105. <imageobject>
  106. <imagedata fileref="ajbrowser-building.gif"/>
  107. </imageobject>
  108. </inlinemediaobject>
  109. </para>
  110. </sect2>
  111. </sect1>
  112. <sect1 id="ajbrowser-navigating">
  113. <title>Navigating Program Structure</title>
  114. <para>
  115. Select nodes in the program structure by clicking them (see label 2).
  116. If one node is related to one or more other nodes by an association the
  117. name of the association will appear below that node and will be
  118. displayed in italics. Links to other structure nodes appear in blue
  119. below the association. If there is no corresponding source for the
  120. link it will appear light-blue.
  121. </para>
  122. <para>
  123. <inlinemediaobject>
  124. <imageobject>
  125. <imagedata fileref="ajbrowser-building.gif"/>
  126. </imageobject>
  127. </inlinemediaobject>
  128. </para>
  129. <sect2 id="example" xreflabel="example">
  130. <title>Example: Exploring the "Spacewar" sample code </title>
  131. <para>
  132. <itemizedlist>
  133. <listitem> <para>Launch <literal>ajbrowser</literal></para>
  134. </listitem>
  135. <listitem> <para>Choose "File -&gt; Open" or click the "Open Build
  136. Configuration" button
  137. (<inlinemediaobject>
  138. <imageobject>
  139. <imagedata fileref="openConfig.gif"/>
  140. </imageobject>
  141. </inlinemediaobject>) and select the configuration file for debugging
  142. the spacewar example, in
  143. <literal>examples/spacewar/debug.lst</literal>.</para>
  144. </listitem>
  145. <listitem> <para>Click the "Build" button (<inlinemediaobject>
  146. <imageobject>
  147. <imagedata fileref="build.gif"/>
  148. </imageobject>
  149. </inlinemediaobject>) to
  150. compile. The left pane should fill with a spacewar declaration
  151. tree. If there is a compiler error, the clickable error message
  152. shows up as in label 4.
  153. </para>
  154. <para>Note: If you did not set up your classpath, the
  155. compile will fail with a message that you need to install
  156. aspectjrt.jar on your compile classpath. To do that, select "Tools
  157. -&gt; Options" or click the "Options" button
  158. (<inlinemediaobject>
  159. <imageobject>
  160. <imagedata fileref="browseroptions.gif"/>
  161. </imageobject>
  162. </inlinemediaobject>). Click the <literal>Build Options</literal> tab
  163. to view the Build Paths pane. Edit the classpath entry to use your
  164. install location. For example, if you ran from the base Aspectj
  165. directory, the classpath need only include
  166. <literal>lib/aspectjrt.jar</literal> (though the browser may populate
  167. the classpath with the bootclasspath and classpath initially.)
  168. Be sure to use the
  169. <literal>lib/aspectjrt.jar</literal> that came with the browser.
  170. </para>
  171. <para>
  172. <inlinemediaobject>
  173. <imageobject>
  174. <imagedata fileref="ajbrowser-options.gif"/>
  175. </imageobject>
  176. </inlinemediaobject>
  177. </para>
  178. </listitem>
  179. <listitem> <para>Different structure views: The structure tree at the
  180. left can display different orderings and granularity for structure:
  181. <itemizedlist>
  182. <listitem><para>The package hierarchy view shows the traditional hierarchy
  183. of package, class, and members.</para></listitem>
  184. <listitem><para>The inheritance view shows the hierarchy from topmost
  185. parent classes through subclasses to members.</para></listitem>
  186. <listitem><para>The crosscutting view shows the aspect members
  187. and the code they affect.</para></listitem>
  188. <listitem><para>Additional buttons in the pane can be used to change the
  189. granularity and filter out items.</para>
  190. </listitem>
  191. </itemizedlist>
  192. </para>
  193. <para>Whenever you select an item in the tree view, the
  194. source pane scrolls to that item. If you select a leaf item
  195. representing another program element, then the tree
  196. selection will go to the corresponding node. (See below for
  197. how to use two panes to maintain your place.)
  198. </para>
  199. </listitem>
  200. <listitem>
  201. <para>When working with aspects, it helps to be able to navigate
  202. between different program elements:
  203. </para>
  204. <itemizedlist>
  205. <listitem><para>When looking at a method, find the advice that
  206. affects it. </para></listitem>
  207. <listitem><para>When looking at a pointcut, find the advice that
  208. uses it. </para></listitem>
  209. <listitem><para>When looking at advice, find what it advises -
  210. e.g., method calls or executions, initializers, etc.
  211. </para></listitem>
  212. <listitem><para>When looking at a type, find any aspects that
  213. declare members or supertypes of the type, or
  214. vice-versa.
  215. </para></listitem>
  216. </itemizedlist>
  217. <para>You can view the advice on a particular method using the
  218. default, hierarchical view. Navigate to the tree item for
  219. <literal>spacewar.Registry.register(SpaceObject)</literal>
  220. in the <literal>debug.lst</literal> config file. Now, in
  221. the lower, file view, you can see and navigate to the advice
  222. using the subtree whose parent is the <literal>method
  223. affected by</literal> relation.
  224. </para>
  225. <para>You can also use crosscutting view to see the
  226. advice using a pointcut or the methods affected by advice.
  227. For example, to see what advice uses a particular pointcut,
  228. navigate to the tree item for the pointcut
  229. <literal>spacewar.Debug.allConstructorsCut()</literal> in
  230. the <literal>debug.lst</literal> config file. You can see
  231. and navigate to the advice that uses the pointcut using the
  232. <literal>pointcut used by</literal> relation.
  233. </para>
  234. <para>As an example of seeing the methods affected by advice,
  235. while still in the same view, select the first
  236. <literal>before</literal> advice in
  237. <literal>spacewar.Debug</literal>. It has relation
  238. sub-trees for both <literal>uses pointcut</literal> and
  239. <literal>affects constructions</literal>. The
  240. <literal>affects</literal> relations will list different
  241. kinds of join points - constructor or method calls, etc.
  242. </para>
  243. <para>Note that the AspectJ browser can only display
  244. static structure (whether hierarchical or crosscutting).
  245. That means that dynamicly-determined pointcuts (like
  246. <literal>cflow(pointcut)</literal>)
  247. will not be shown as picking out static points in
  248. source code. Displayable pointcuts roughly correspond
  249. to those that can be used in a
  250. <literal>declare error</literal> statement.
  251. </para>
  252. </listitem>
  253. </itemizedlist>
  254. </para>
  255. </sect2>
  256. </sect1>
  257. <sect1 id="ajbrowser-running">
  258. <title>Running Programs</title>
  259. <para>
  260. The browser supports a limited form of running compiled programs.
  261. To run programs that have been built, click the run button
  262. or select one of the run menu items in the project menu.
  263. You can run in the same VM or spawn a new process;
  264. the latter is generally better for GUI programs.
  265. </para>
  266. <para>Both require that any classpath you set be specified
  267. using platform-specific paths and path separators (the
  268. compiler might be more tolerant).
  269. Output and error streams will be
  270. merged into the streams of the browser (using separate
  271. threads, so it may take a few seconds for the pipe
  272. threads to gain control.) Errors should
  273. be detected and displayed in a dialog.
  274. </para>
  275. <para>
  276. The GUI does not support killing a running program,
  277. so if your program might hang,
  278. be sure to save your files since you may need to
  279. kill the browser itself to kill its child processes.
  280. </para>
  281. </sect1>
  282. <sect1 id="ajbrowser-problems">
  283. <title>Isolating problems running the AspectJ browser</title>
  284. <para>
  285. If you have problems with the browser not solved by the documentation,
  286. please try to see if you have the same problems when running ajc
  287. directly on the command line.
  288. </para>
  289. <itemizedlist>
  290. <listitem><para>
  291. If the problem occurs on the command line also, then the problem
  292. is not in the browser.
  293. (It may be in the compiler; please send bug reports.)
  294. </para></listitem>
  295. <listitem><para>
  296. If the problem does not occur on the command line, then it may
  297. lie in the parameters you are supplying in the build options.
  298. </para></listitem>
  299. <listitem><para>
  300. If the build options look correct and the problem only occurs
  301. when building from the browser, then please submit a bug report.
  302. </para></listitem>
  303. </itemizedlist>
  304. <sect2 id="ajbrowser-knownProblems">
  305. <title>Known issues with the AspectJ browser</title>
  306. <para>
  307. For the most up-to-date information on known problems,
  308. see the
  309. <ulink url="http://bugs.eclipse.org/bugs">bug database</ulink>
  310. for unresolved
  311. <ulink url="http://bugs.eclipse.org/bugs/buglist.cgi?&amp;product=AspectJ&amp;component=Compiler&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED">
  312. compiler bugs
  313. </ulink> or
  314. <ulink url="http://bugs.eclipse.org/bugs/buglist.cgi?&amp;product=AspectJ&amp;component=IDE&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED">
  315. IDE bugs
  316. </ulink>.
  317. </para>
  318. <para>
  319. <itemizedlist>
  320. <listitem><para>
  321. Memory and forking: Users email most about the browser task running
  322. out of memory.
  323. This is not a problem with the browser; some compiles take a lot of
  324. memory, often more than similar compiles using javac.
  325. The browser does not support forking, so the only solution is to
  326. edit the java command line or script that launches the browser
  327. to add memory.
  328. </para></listitem>
  329. <listitem><para>
  330. Editing build configuration files: this is not currently supported.
  331. </para></listitem>
  332. <listitem><para>
  333. The structure model is incomplete after incremental compiles.
  334. To get a complete structure model requires a full build.
  335. </para></listitem>
  336. <listitem><para>
  337. If you change the output directory, you must do a
  338. full build.
  339. </para></listitem>
  340. </itemizedlist>
  341. </para>
  342. </sect2>
  343. <sect2 id="ajbrowser-limitations">
  344. <title>Limitations</title>
  345. <para>
  346. <itemizedlist>
  347. <listitem><para>
  348. The AJBrowser expects the package and directory structure to match. If they do not
  349. it will be unable to browse to the corresponding file.
  350. </para></listitem>
  351. <listitem><para>
  352. The "Run" feature launches applications in the same VM. As a result, if a Swing application
  353. is disposed the AJBrowser will be disposed as well.
  354. </para></listitem>
  355. </itemizedlist>
  356. </para>
  357. </sect2>
  358. <sect2 id="ajbrowser-feedback">
  359. <title>AspectJ Browser questions and bugs</title>
  360. <para>
  361. You can send email to
  362. <ulink url="mailto:aspectj-users@dev.eclipse.org">
  363. aspectj-users@dev.eclipse.org</ulink>.
  364. (Do join the list to participate!)
  365. We also welcome any bug reports, patches, and feature requests;
  366. you can submit them to the bug database at
  367. <ulink url="http://bugs.eclipse.org/bugs">
  368. http://bugs.eclipse.org/bugs</ulink>
  369. using the AspectJ product and IDE component.
  370. </para>
  371. </sect2>
  372. </sect1>
  373. </chapter>
  374. <!-- Local variables: -->
  375. <!-- fill-column: 79 -->
  376. <!-- sgml-local-ecat-files: devguide.ced -->
  377. <!-- sgml-parent-document:("devguide.sgml" "book" "refentry") -->
  378. <!-- End: -->