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.adoc 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. [[ajbrowser]]
  2. == AspectJ Browser
  3. [[ajbrowser-intro]]
  4. === Introduction
  5. AJBrowser presents a GUI for compiling programs with ajc and navigating
  6. crosscutting structure.
  7. The AspectJ Browser can edit program source files, compile using the
  8. AspectJ compiler `ajc` run a program, and graphically navigate the
  9. program's crosscutting structure. For more information on `ajc`, see
  10. xref:ajc.adoc[`ajc`, the AspectJ compiler/weaver].
  11. Launch the browser from the command line either by typing "ajbrowser" to
  12. invoke the script in `{aspectj}/bin` (if AspectJ is installed correctly)
  13. or by using the `aspectjtools.jar` directly, and specifying no arguments
  14. or some number of build configuration files (suffix `.lst`):
  15. [source, text]
  16. ....
  17. java -jar aspectj1.1/lib/aspectjtools.jar aspectj1.1/doc/examples/spacewar/debug.lst
  18. ....
  19. [[ajbrowser-building]]
  20. === Building Programs
  21. ==== Build Configurations
  22. A build configuration is a set of files to compile for a program (and
  23. optionally some additional compile arguments). Because `ajc` requires
  24. all sources to be specified (at least using the `-sourceroots` option),
  25. most users create `.lst` files that list the files to compile (one
  26. argument per line, globbing permitted - for more details, see
  27. xref:ajc.adoc[`ajc`, the AspectJ compiler/weaver]).
  28. To work with a particular program, select the corresponding ".lst" build
  29. configuration file from the GUI using the File menu, "open" item, or by
  30. using the "Open Build Configuration" button
  31. (image:openConfig.gif[image]). You can populate the build list from the
  32. command line by passing any number of ".lst" paths. (However, if you
  33. pass in any non-".lst" arguments, it will run the command-line compiler
  34. directly.)
  35. To switch between build configurations, select, add, or remove them
  36. using the corresponding toolbar buttons.
  37. Global build options are stored in an `.ajbrowser` file in your HOME
  38. directory. Edit these from the GUI by clicking the "Options" button or
  39. selecting the Tools menu item "Options...". This is how to set
  40. classpath, aspectpath, etc.
  41. The following sections walk through a build.
  42. ==== Compiling a Program Build Configuration
  43. To compile click the "Build" button (image:build.gif[image]), or or use
  44. the tools menu.
  45. You may select from different build configurations in the GUI (see label
  46. 1 in the graphic below). (If you get classpath or other errors, set up
  47. the global build options as described above.)
  48. image:ajbrowser-building.gif[image]
  49. [[ajbrowser-navigating]]
  50. === Navigating Program Structure
  51. Select nodes in the program structure by clicking them (see label 2). If
  52. one node is related to one or more other nodes by an association the
  53. name of the association will appear below that node and will be
  54. displayed in italics. Links to other structure nodes appear in blue
  55. below the association. If there is no corresponding source for the link
  56. it will appear light-blue.
  57. image:ajbrowser-building.gif[image]
  58. [[example]]
  59. ==== Example: Exploring the "Spacewar" sample code
  60. * Launch `ajbrowser`
  61. * Choose "File -> Open" or click the "Open Build Configuration" button
  62. (image:openConfig.gif[image]) and select the configuration file for
  63. debugging the spacewar example, in `examples/spacewar/debug.lst`.
  64. * Click the "Build" button (image:build.gif[image]) to compile. The left
  65. pane should fill with a spacewar declaration tree. If there is a
  66. compiler error, the clickable error message shows up as in label 4.
  67. +
  68. Note: If you did not set up your classpath, the compile will fail with a
  69. message that you need to install aspectjrt.jar on your compile
  70. classpath. To do that, select "Tools -> Options" or click the "Options"
  71. button (image:browseroptions.gif[image]). Click the `Build Options` tab
  72. to view the Build Paths pane. Edit the classpath entry to use your
  73. install location. For example, if you ran from the base Aspectj
  74. directory, the classpath need only include `lib/aspectjrt.jar` (though
  75. the browser may populate the classpath with the bootclasspath and
  76. classpath initially.) Be sure to use the `lib/aspectjrt.jar` that came
  77. with the browser.
  78. +
  79. image:ajbrowser-options.gif[image]
  80. * Different structure views: The structure tree at the left can display
  81. different orderings and granularity for structure:
  82. ** The package hierarchy view shows the traditional hierarchy of
  83. package, class, and members.
  84. ** The inheritance view shows the hierarchy from topmost parent classes
  85. through subclasses to members.
  86. ** The crosscutting view shows the aspect members and the code they
  87. affect.
  88. ** Additional buttons in the pane can be used to change the granularity
  89. and filter out items.
  90. +
  91. Whenever you select an item in the tree view, the source pane scrolls to
  92. that item. If you select a leaf item representing another program
  93. element, then the tree selection will go to the corresponding node. (See
  94. below for how to use two panes to maintain your place.)
  95. * When working with aspects, it helps to be able to navigate between
  96. different program elements:
  97. ** When looking at a method, find the advice that affects it.
  98. ** When looking at a pointcut, find the advice that uses it.
  99. ** When looking at advice, find what it advises - e.g., method calls or
  100. executions, initializers, etc.
  101. ** When looking at a type, find any aspects that declare members or
  102. supertypes of the type, or vice-versa.
  103. +
  104. You can view the advice on a particular method using the default,
  105. hierarchical view. Navigate to the tree item for
  106. `spacewar.Registry.register(SpaceObject)` in the `debug.lst` config
  107. file. Now, in the lower, file view, you can see and navigate to the
  108. advice using the subtree whose parent is the `method
  109. affected by` relation.
  110. +
  111. You can also use crosscutting view to see the advice using a pointcut or
  112. the methods affected by advice. For example, to see what advice uses a
  113. particular pointcut, navigate to the tree item for the pointcut
  114. `spacewar.Debug.allConstructorsCut()` in the `debug.lst` config file.
  115. You can see and navigate to the advice that uses the pointcut using the
  116. `pointcut used by` relation.
  117. +
  118. As an example of seeing the methods affected by advice, while still in
  119. the same view, select the first `before` advice in `spacewar.Debug`. It
  120. has relation sub-trees for both `uses pointcut` and
  121. `affects constructions`. The `affects` relations will list different
  122. kinds of join points - constructor or method calls, etc.
  123. +
  124. Note that the AspectJ browser can only display static structure (whether
  125. hierarchical or crosscutting). That means that dynamicly-determined
  126. pointcuts (like `cflow(pointcut)`) will not be shown as picking out
  127. static points in source code. Displayable pointcuts roughly correspond
  128. to those that can be used in a `declare error` statement.
  129. [[ajbrowser-running]]
  130. === Running Programs
  131. The browser supports a limited form of running compiled programs. To run
  132. programs that have been built, click the run button or select one of the
  133. run menu items in the project menu. You can run in the same VM or spawn
  134. a new process; the latter is generally better for GUI programs.
  135. Both require that any classpath you set be specified using
  136. platform-specific paths and path separators (the compiler might be more
  137. tolerant). Output and error streams will be merged into the streams of
  138. the browser (using separate threads, so it may take a few seconds for
  139. the pipe threads to gain control.) Errors should be detected and
  140. displayed in a dialog.
  141. The GUI does not support killing a running program, so if your program
  142. might hang, be sure to save your files since you may need to kill the
  143. browser itself to kill its child processes.
  144. [[ajbrowser-problems]]
  145. === Isolating problems running the AspectJ browser
  146. If you have problems with the browser not solved by the documentation,
  147. please try to see if you have the same problems when running ajc
  148. directly on the command line.
  149. * If the problem occurs on the command line also, then the problem is
  150. not in the browser. (It may be in the compiler; please send bug
  151. reports.)
  152. * If the problem does not occur on the command line, then it may lie in
  153. the parameters you are supplying in the build options.
  154. * If the build options look correct and the problem only occurs when
  155. building from the browser, then please submit a bug report.
  156. [[ajbrowser-knownProblems]]
  157. ==== Known issues with the AspectJ browser
  158. For the most up-to-date information on known problems, see the
  159. https://bugs.eclipse.org/bugs[bug database] for unresolved
  160. https://bugs.eclipse.org/bugs/buglist.cgi?&product=AspectJ&component=Compiler&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED[compiler
  161. bugs] or
  162. https://bugs.eclipse.org/bugs/buglist.cgi?&product=AspectJ&component=IDE&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED[IDE
  163. bugs] .
  164. * Memory and forking: Users email most about the browser task running
  165. out of memory. This is not a problem with the browser; some compiles
  166. take a lot of memory, often more than similar compiles using javac. The
  167. browser does not support forking, so the only solution is to edit the
  168. java command line or script that launches the browser to add memory.
  169. * Editing build configuration files: this is not currently supported.
  170. * The structure model is incomplete after incremental compiles. To get a
  171. complete structure model requires a full build.
  172. * If you change the output directory, you must do a full build.
  173. [[ajbrowser-limitations]]
  174. ==== Limitations
  175. * The AJBrowser expects the package and directory structure to match. If
  176. they do not it will be unable to browse to the corresponding file.
  177. * The "Run" feature launches applications in the same VM. As a result,
  178. if a Swing application is disposed the AJBrowser will be disposed as
  179. well.
  180. [[ajbrowser-feedback]]
  181. ==== AspectJ Browser questions and bugs
  182. You can send email to aspectj-users@dev.eclipse.org. (Do join the list
  183. to participate!) We also welcome any bug reports, patches, and feature
  184. requests; you can submit them to the bug database at
  185. https://bugs.eclipse.org/bugs using the AspectJ product and IDE
  186. component.