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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. <inlinemediaobject>
  103. <imageobject>
  104. <imagedata fileref="ajbrowser-building.gif"/>
  105. </imageobject>
  106. </inlinemediaobject>
  107. </para>
  108. </sect2>
  109. </sect1>
  110. <sect1 id="ajbrowser-navigating">
  111. <title>Navigating Program Structure</title>
  112. <para>
  113. Select nodes in the program structure by clicking them (see label 2).
  114. If one node is related to one or more other nodes by an association the
  115. name of the association will appear below that node and will be
  116. displayed in italics. Links to other structure nodes appear in blue
  117. below the association. If there is no corresponding source for the
  118. link it will appear light-blue.
  119. <inlinemediaobject>
  120. <imageobject>
  121. <imagedata fileref="ajbrowser-building.gif"/>
  122. </imageobject>
  123. </inlinemediaobject>
  124. </para>
  125. <sect2 id="example" xreflabel="example">
  126. <title>Example: Exploring the "Spacewar" sample code </title>
  127. <para>
  128. <itemizedlist>
  129. <listitem> <para>Launch <literal>ajbrowser</literal></para>
  130. </listitem>
  131. <listitem> <para>Choose "File -&gt; Open" or click the "Open Build
  132. Configuration" button
  133. (<inlinemediaobject>
  134. <imageobject>
  135. <imagedata fileref="openConfig.gif"/>
  136. </imageobject>
  137. </inlinemediaobject>) and select the configuration file for debugging
  138. the spacewar example, in
  139. <literal>examples/spacewar/debug.lst</literal>.</para>
  140. </listitem>
  141. <listitem> <para>Click the "Build" button (<inlinemediaobject>
  142. <imageobject>
  143. <imagedata fileref="build.gif"/>
  144. </imageobject>
  145. </inlinemediaobject>) to
  146. compile. The left pane should fill with a spacewar declaration
  147. tree. If there is a compiler error, the clickable error message
  148. shows up as in label 4.
  149. </para>
  150. <para>Note: If you did not set up your classpath, the
  151. compile will fail with a message that you need to install
  152. aspectjrt.jar on your compile classpath. To do that, select "Tools
  153. -&gt; Options" or click the "Options" button
  154. (<inlinemediaobject>
  155. <imageobject>
  156. <imagedata fileref="browseroptions.gif"/>
  157. </imageobject>
  158. </inlinemediaobject>). Click the <literal>Build Options</literal> tab
  159. to view the Build Paths pane. Edit the classpath entry to use your
  160. install location. For example, if you ran from the base Aspectj
  161. directory, the classpath need only include
  162. <literal>lib/aspectjrt.jar</literal> (though the browser may populate
  163. the classpath with the bootclasspath and classpath initially.)
  164. Be sure to use the
  165. <literal>lib/aspectjrt.jar</literal> that came with the browser.
  166. </para>
  167. <para>
  168. <inlinemediaobject>
  169. <imageobject>
  170. <imagedata fileref="ajbrowser-options.gif"/>
  171. </imageobject>
  172. </inlinemediaobject>>
  173. </para>
  174. </listitem>
  175. <listitem> <para>Different structure views: The structure tree at the
  176. left can display different orderings and granularity for structure:
  177. <itemizedlist>
  178. <listitem><para>The package hierarchy view shows the traditional hierarchy
  179. of package, class, and members.</para></listitem>
  180. <listitem><para>The inheritance view shows the hierarchy from topmost
  181. parent classes through subclasses to members.</para></listitem>
  182. <listitem><para>The crosscutting view shows the aspect members
  183. and the code they affect.</para></listitem>
  184. <listitem><para>Additional buttons in the pane can be used to change the
  185. granularity and filter out items.</para>
  186. </listitem>
  187. </itemizedlist>
  188. </para>
  189. <para>Whenever you select an item in the tree view, the
  190. source pane scrolls to that item. If you select a leaf item
  191. representing another program element, then the tree
  192. selection will go to the corresponding node. (See below for
  193. how to use two panes to maintain your place.)
  194. </para>
  195. </listitem>
  196. <listitem>
  197. <para>When working with aspects, it helps to be able to navigate
  198. between different program elements:
  199. </para>
  200. <itemizedlist>
  201. <listitem><para>When looking at a method, find the advice that
  202. affects it. </para></listitem>
  203. <listitem><para>When looking at a pointcut, find the advice that
  204. uses it. </para></listitem>
  205. <listitem><para>When looking at advice, find what it advises -
  206. e.g., method calls or executions, initializers, etc.
  207. </para></listitem>
  208. <listitem><para>When looking at a type, find any aspects that
  209. declare members or supertypes of the type, or
  210. vice-versa.
  211. </para></listitem>
  212. </itemizedlist>
  213. <para>You can view the advice on a particular method using the
  214. default, hierarchical view. Navigate to the tree item for
  215. <literal>spacewar.Registry.register(SpaceObject)</literal>
  216. in the <literal>debug.lst</literal> config file. Now, in
  217. the lower, file view, you can see and navigate to the advice
  218. using the subtree whose parent is the <literal>method
  219. affected by</literal> relation.
  220. </para>
  221. <para>You can also use crosscutting view to see the
  222. advice using a pointcut or the methods affected by advice.
  223. For example, to see what advice uses a particular pointcut,
  224. navigate to the tree item for the pointcut
  225. <literal>spacewar.Debug.allConstructorsCut()</literal> in
  226. the <literal>debug.lst</literal> config file. You can see
  227. and navigate to the advice that uses the pointcut using the
  228. <literal>pointcut used by</literal> relation.
  229. </para>
  230. <para>As an example of seeing the methods affected by advice,
  231. while still in the same view, select the first
  232. <literal>before</literal> advice in
  233. <literal>spacewar.Debug</literal>. It has relation
  234. sub-trees for both <literal>uses pointcut</literal> and
  235. <literal>affects constructions</literal>. The
  236. <literal>affects</literal> relations will list different
  237. kinds of join points - constructor or method calls, etc.
  238. </para>
  239. <para>Note that the AspectJ browser can only display
  240. static structure (whether hierarchical or crosscutting).
  241. That means that dynamicly-determined pointcuts (like
  242. <literal>cflow(pointcut)</literal>)
  243. will not be shown as picking out static points in
  244. source code. Displayable pointcuts roughly correspond
  245. to those that can be used in a
  246. <literal>declare error</literal> statement.
  247. </para>
  248. </listitem>
  249. </itemizedlist>
  250. </para>
  251. </sect2>
  252. </sect1>
  253. <sect1 id="ajbrowser-running">
  254. <title>Running Programs</title>
  255. <para>
  256. The browser supports a limited form of running compiled programs.
  257. To run programs that have been built, click the run button
  258. or select one of the run menu items in the project menu.
  259. You can run in the same VM or spawn a new process;
  260. the latter is generally better for GUI programs.
  261. </para>
  262. <para>Both require that any classpath you set be specified
  263. using platform-specific paths and path separators (the
  264. compiler might be more tolerant).
  265. Output and error streams will be
  266. merged into the streams of the browser (using separate
  267. threads, so it may take a few seconds for the pipe
  268. threads to gain control.) Errors should
  269. be detected and displayed in a dialog.
  270. </para>
  271. <para>
  272. The GUI does not support killing a running program,
  273. so if your program might hang,
  274. be sure to save your files since you may need to
  275. kill the browser itself to kill its child processes.
  276. </para>
  277. </sect1>
  278. <sect1 id="ajbrowser-problems">
  279. <title>Isolating problems running the AspectJ browser</title>
  280. <para>
  281. If you have problems with the browser not solved by the documentation,
  282. please try to see if you have the same problems when running ajc
  283. directly on the command line.
  284. </para>
  285. <itemizedlist>
  286. <listitem><para>
  287. If the problem occurs on the command line also, then the problem
  288. is not in the browser.
  289. (It may be in the compiler; please send bug reports.)
  290. </para></listitem>
  291. <listitem><para>
  292. If the problem does not occur on the command line, then it may
  293. lie in the parameters you are supplying in the build options.
  294. </para></listitem>
  295. <listitem><para>
  296. If the build options look correct and the problem only occurs
  297. when building from the browser, then please submit a bug report.
  298. </para></listitem>
  299. </itemizedlist>
  300. <sect2 id="ajbrowser-knownProblems">
  301. <title>Known issues with the AspectJ browser</title>
  302. <para>
  303. For the most up-to-date information on known problems,
  304. see the
  305. <ulink url="http://bugs.eclipse.org/bugs">bug database</ulink>
  306. for unresolved
  307. <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">
  308. compiler bugs
  309. </ulink> or
  310. <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">
  311. IDE bugs
  312. </ulink>.
  313. </para>
  314. <para>
  315. <itemizedlist>
  316. <listitem><para>
  317. Memory and forking: Users email most about the browser task running
  318. out of memory.
  319. This is not a problem with the browser; some compiles take a lot of
  320. memory, often more than similar compiles using javac.
  321. The browser does not support forking, so the only solution is to
  322. edit the java command line or script that launches the browser
  323. to add memory.
  324. </para></listitem>
  325. <listitem><para>
  326. Editing build configuration files: this is not currently supported.
  327. </para></listitem>
  328. <listitem><para>
  329. The structure model is incomplete after incremental compiles.
  330. To get a complete structure model requires a full build.
  331. </para></listitem>
  332. <listitem><para>
  333. If you change the output directory, you must do a
  334. full build.
  335. </para></listitem>
  336. </itemizedlist>
  337. </para>
  338. </sect2>
  339. <sect2 id="ajbrowser-limitations">
  340. <title>Limitations</title>
  341. <para>
  342. <itemizedlist>
  343. <listitem><para>
  344. The AJBrowser expects the package and directory structure to match. If they do not
  345. it will be unable to browse to the corresponding file.
  346. </para></listitem>
  347. <listitem><para>
  348. The "Run" feature launches applications in the same VM. As a result, if a Swing application
  349. is disposed the AJBrowser will be disposed as well.
  350. </para></listitem>
  351. </itemizedlist>
  352. </para>
  353. </sect2>
  354. <sect2 id="ajbrowser-feedback">
  355. <title>AspectJ Browser questions and bugs</title>
  356. <para>
  357. You can send email to
  358. <ulink url="mailto:aspectj-users@dev.eclipse.org">
  359. aspectj-users@dev.eclipse.org</ulink>.
  360. (Do join the list to participate!)
  361. We also welcome any bug reports, patches, and feature requests;
  362. you can submit them to the bug database at
  363. <ulink url="http://bugs.eclipse.org/bugs">
  364. http://bugs.eclipse.org/bugs</ulink>
  365. using the AspectJ product and IDE component.
  366. </para>
  367. </sect2>
  368. </sect1>
  369. </chapter>
  370. <!-- Local variables: -->
  371. <!-- fill-column: 79 -->
  372. <!-- sgml-local-ecat-files: devguide.ced -->
  373. <!-- sgml-parent-document:("devguide.sgml" "book" "refentry") -->
  374. <!-- End: -->