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.

ltwdump.adoc 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. [[ltwdump]]
  2. = Dumping classes during load-time weaving
  3. [[ltwdump-introduction]]
  4. == Introduction
  5. Very rarely problems may be encountered with classes that have been
  6. load-time woven. Symptoms will include incorrect program function or a
  7. Java exception such as `java.lang.VerifyError`. In these situations it's
  8. most helpful to include the offending class in the bug report. When
  9. using load-time weaving the woven classes are in memory only so to save
  10. them to disk configure `META-INF/aop.xml` to dump the classes (by
  11. default to an `_ajdump` subdirectory of the current working directory).
  12. Also if the input class file is not available (e.g. it is a generated
  13. proxy or has already been instrumented by another agent) you can
  14. configure the weaver to dump the input classes as well.
  15. [[ltw-examples]]
  16. === Configuring bytecode dumping in load-time weaving
  17. For details of how to configure byte-code dumping, see the AspectJ
  18. Development Environment Guide section on
  19. xref:../devguide/ltw.adoc#configuring-load-time-weaving-with-aopxml-files[Configuring
  20. Load-time Weaving]. Following is a simple example.
  21. [[ltwdump-examples]]
  22. === LTW Dump Examples
  23. The following `META-INF/aop.xml` will weave classes in the `com.foo`
  24. package (and subpackages) but not CGLIB generated classes in the
  25. `com.foo.bar` package (and subpackages). It will also ensure all woven
  26. byte-code is dumped both before and after weaving.
  27. [source, xml]
  28. ....
  29. <aspectj>
  30. <aspects>
  31. <aspect name="ataspectj.EmptyAspect"/>
  32. </aspects>
  33. <weaver options="-verbose -debug">
  34. <dump within="com.foo.bar..*" beforeandafter="true"/>
  35. <include within="com.foo..*"/>
  36. <exclude within="com.foo.bar..*CGLIB*"/>
  37. </weaver>
  38. </aspectj>
  39. ....
  40. You should see messages similar to this:
  41. [source, text]
  42. ....
  43. [WeavingURLClassLoader] info AspectJ Weaver Version 1.5.3 built on Thursday Oct 26, 2006 at 17:22:31 GMT
  44. [WeavingURLClassLoader] info register classloader org.aspectj.weaver.loadtime.WeavingURLClassLoader
  45. [WeavingURLClassLoader] info using configuration /C:/tempMETA-INF/aop.xml
  46. [WeavingURLClassLoader] info register aspect ataspectj.EmptyAspect
  47. [WeavingURLClassLoader] debug not weaving 'com.foo.bar.Test$$EnhancerByCGLIB$$12345'
  48. [WeavingURLClassLoader] debug weaving 'com.foo.bar.Test'
  49. ....
  50. On disk you would find the following files:
  51. [source, text]
  52. ....
  53. _ajdump/_before/com/foo/bar/Test.class
  54. _ajdump/com/foo/bar/Test.class
  55. ....