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.xml 7.2KB

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