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.

compatibility.adoc 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. [[compatibility]]
  2. = AspectJ version compatibility
  3. [[versionCompatibility]]
  4. == Version Compatibility
  5. Systems, code, and build tools change over time, often not in step.
  6. Generally, later versions of the build tools understand earlier versions
  7. of the code, but systems should include versions of the runtime used to
  8. build the AspectJ program.
  9. [[javaCompatibility]]
  10. === Java compatibility
  11. AspectJ programs can run on any Java VM of the required version. The
  12. AspectJ tools produce Java bytecode .class files that run on Java
  13. compatible VM's. If a Java class is changed by an aspect, the resulting
  14. class is binary compatible (as defined in the Java Language
  15. Specification). Further, the AspectJ compiler and weaving do all the
  16. exception checking required of Java compilers by the Java
  17. specifications.
  18. Like other Java compilers, the AspectJ compiler can target particular
  19. Java versions. Obviously, code targeted at one version cannot be run in
  20. a VM of a lesser version. The `aspectjrt.jar` is designed to take
  21. advantage of features available in Java 2 or Java 5, but will run in a
  22. JDK 1.1.x environment, so you can use AspectJ to target older or
  23. restricted versions of Java. However, there may be restricted variants
  24. of JDK 1.1.x that do not have API's used by the AspectJ runtime. If you
  25. deploy to one of those, you can email aspectj-dev@eclipse.org or
  26. download the runtime code to modify it for your environment.
  27. Aside from the runtime, running the AspectJ tools themselves will
  28. require a more recent version of Java. You might use Java 5 to run the
  29. AspectJ compiler to produce code for Java 1.1.8.
  30. [[runtimeCompatibility]]
  31. === Runtime library compatibility
  32. When deploying AspectJ programs, include on the classpath the classes,
  33. aspects, and the AspectJ runtime library (`aspectjrt.jar`). Use the
  34. version of the runtime that came with the tools used to build the
  35. program. If the runtime is earlier than the build tools used, it's very
  36. likely to fail. If the runtime is later than the build tools used, it's
  37. possible (but not guaranteed) that it will work.
  38. Given that, three scenarios cause problems. First, you deploy new
  39. aspects into an an existing system that already has aspects that were
  40. built with a different version. Second, the runtime is already deployed
  41. in your system and cannot be changed (e.g., some application servers put
  42. `aspectjrt.jar` on the bootclasspath). Third, you (unintentionally)
  43. deploy two versions of the runtime, and the one loaded by a parent
  44. loader is used).
  45. In earlier versions of AspectJ, these problems present in obscure ways
  46. (e.g., unable to resolve a class). In later versions, a stack trace
  47. might even specify that the runtime version is out of sync with an
  48. aspect. To find out if the runtime you deployed is the one actually
  49. being used, log the defining class loader for the aspects and runtime.
  50. [[binaryCompatibility]]
  51. === Aspect binary compatibility
  52. Generally, binary aspects can be read by later versions of the weaver if
  53. the aspects were built by version 1.2.1 or later. (Some future weavers
  54. might have documented limitations in how far back they go.) If a
  55. post-1.2.1 weaver reads an aspect built by a later version, it will emit
  56. a message. If the weaver reads in a binary aspect and writes it out
  57. again, the result will be in the form produced by that weaver, not the
  58. original form of the aspect (just like other weaver output).
  59. With unreleased or development versions of the tools, there are no
  60. guarantees for binary compatibility, unless they are stated in the
  61. release notes. If you use aspects built with development versions of the
  62. weaver, be careful to rebuild and redeploy with the next released
  63. version.
  64. [[sourceCompatibility]]
  65. === Aspect source compatibility
  66. Generally, AspectJ source files can be read by later versions of the
  67. compiler. Language features do not change in dot releases (e.g., from
  68. 1.2.1 to 1.2.2). In some very rare cases, a language feature will no
  69. longer be supported or may change its meaning; these cases are
  70. documented in the release notes for that version. Some changes like this
  71. were necessary when moving to binary weaving in the 1.1 release, but at
  72. this time we don't anticipate more in the future. You might also find
  73. that the program behaves differently if you relied on behavior specific
  74. to that compiler/weaver, but which is not specified in the
  75. xref:../progguide/semantics.html[Semantics appendix to the Programming
  76. Guide].
  77. [[upgrading]]
  78. === Problems when upgrading to new AspectJ versions
  79. Let's say your program behaves differently after being built with a new
  80. version of the AspectJ tools. It could be a bug that was introduced by
  81. the tools, but often it results from relying on behavior that was not
  82. guaranteed by the compiler. For example, the order of advice across two
  83. aspects is not guaranteed unless there is a precedence relationship
  84. between the aspects. If the program implicitly relies on a certain order
  85. that obtains in one compiler, it can fail when built with a different
  86. compiler.
  87. Another trap is deploying into the same system, when the `aspectjrt.jar`
  88. has not been changed accordingly.
  89. Finally, when updating to a version that has new language features,
  90. there is a temptation to change both the code and the tools at the same
  91. time. It's best to validate the old code with the new tools before
  92. updating the code to use new features. That distinguishes problems of
  93. new engineering from those of new semantics.