aboutsummaryrefslogtreecommitdiffstats
path: root/docs/dist/doc/README-193.html
blob: f9cc4d0cf474f75a228177bde8452f176881825d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html> <head>
<title>AspectJ 1.9.3 Readme</title>
<style type="text/css">
<!--
  P   { margin-left:  20px; }
  PRE { margin-left:  20px; }
  LI  { margin-left:  20px; }
  H4  { margin-left:  20px; }
  H3  { margin-left:  10px; }
-->
</style>
</head>

<body>
<div align="right"><small>
&copy; Copyright 2018 Contributors.
All rights reserved.
</small></div>
<p>The full list of resolved issues in 1.9.3 is available 
<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>

<p>AspectJ 1.9.3 supports Java12. Java12 introduces the new switch expression syntax, but you must activate support for that via 
an <tt>--enable-preview</tt> flag when using the compiler and attempting to run the resultant classes:

Here is <tt>Switch3.java</tt>:
<pre><code>
=========8<=========
public class Switch3 {
	public static void main(String[] argv) {
		System.out.println(one(Color.R));
		System.out.println(one(Color.G));
		System.out.println(one(Color.B));
		System.out.println(one(Color.Y));
	}

	public static int one(Color color) {
		int result = switch(color) {
		 case R -> foo(0);
		 case G -> foo(1);
		 case B -> foo(2);
		 default -> foo(3);
		};
		return result;
	}
	
	public static final int foo(int i) {
		return i+1;
	}
}

enum Color {
	R, G, B, Y;
}

aspect X {
	int around(): call(* foo(..)) {
		return proceed()*3;
	}
}
=========8<=========
</code></pre>

Compile it with:
<pre><code>
$ ajc --enable-preview -showWeaveInfo -12 Switch3.java

Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:12) advised by around advice from 'X' (Switch3.java:30)

Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:13) advised by around advice from 'X' (Switch3.java:30)

Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:14) advised by around advice from 'X' (Switch3.java:30)

Join point 'method-call(int Switch3.foo(int))' in Type 'Switch3' (Switch3.java:15) advised by around advice from 'X' (Switch3.java:30)

</code></pre>

Now run it:
<pre><code>
$ java --enable-preview Switch3
3
6
9
12
</code></pre>



<p>Available: 1.9.3.RC1 available 7-Mar-2019</p>

<br><br>


<!-- ============================== -->  
</body>
</html>