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.

README-193.html 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  2. <html> <head>
  3. <title>AspectJ 1.9.3 Readme</title>
  4. <style type="text/css">
  5. <!--
  6. P { margin-left: 20px; }
  7. PRE { margin-left: 20px; }
  8. LI { margin-left: 20px; }
  9. H4 { margin-left: 20px; }
  10. H3 { margin-left: 10px; }
  11. -->
  12. </style>
  13. </head>
  14. <body>
  15. <div align="right"><small>
  16. &copy; Copyright 2018 Contributors.
  17. All rights reserved.
  18. </small></div>
  19. <p>The full list of resolved issues in 1.9.3 is available
  20. <a href="https://bugs.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&f0=OP&f1=OP&f3=CP&f4=CP&j1=OR&list_id=16866879&product=AspectJ&query_format=advanced&target_milestone=1.9.3">here</a></h2>.</p>
  21. <p>AspectJ 1.9.3 supports Java12. Java12 introduces the new switch expression syntax, but you must activate support for that via
  22. an <tt>--enable-preview</tt> flag when using the compiler and attempting to run the resultant classes:
  23. Here is <tt>Switch3.java</tt>:
  24. <pre><code>
  25. =========8<=========
  26. public class Switch3 {
  27. public static void main(String[] argv) {
  28. System.out.println(one(Color.R));
  29. System.out.println(one(Color.G));
  30. System.out.println(one(Color.B));
  31. System.out.println(one(Color.Y));
  32. }
  33. public static int one(Color color) {
  34. int result = switch(color) {
  35. case R -> foo(0);
  36. case G -> foo(1);
  37. case B -> foo(2);
  38. default -> foo(3);
  39. };
  40. return result;
  41. }
  42. public static final int foo(int i) {
  43. return i+1;
  44. }
  45. }
  46. enum Color {
  47. R, G, B, Y;
  48. }
  49. aspect X {
  50. int around(): call(* foo(..)) {
  51. return proceed()*3;
  52. }
  53. }
  54. =========8<=========
  55. </code></pre>
  56. Compile it with:
  57. <pre><code>
  58. $ ajc --enable-preview -showWeaveInfo -12 Switch3.java
  59. Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:12) advised by around advice from 'X' (Switch3.java:30)
  60. Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:13) advised by around advice from 'X' (Switch3.java:30)
  61. Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:14) advised by around advice from 'X' (Switch3.java:30)
  62. Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:15) advised by around advice from 'X' (Switch3.java:30)
  63. </code></pre>
  64. Now run it:
  65. <pre><code>
  66. $ java --enable-preview Switch3
  67. 3
  68. 6
  69. 9
  70. 12
  71. </code></pre>
  72. <p>Available: 1.9.3.RC1 available 7-Mar-2019</p>
  73. <br><br>
  74. <!-- ============================== -->
  75. </body>
  76. </html>