/usr/share/doc/aspectj-doc/README-182.html is in aspectj-doc 1.8.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html> <head>
<title>AspectJ 1.8.2 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>
© Copyright 2014 Contributors.
All rights reserved.
</small></div>
<h1>AspectJ 1.8.2 Readme</h1>
<p>The full list of resolved issues in 1.8.2 is available
<a href="https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced;bug_status=RESOLVED;bug_status=VERIFIED;bug_status=CLOSED;product=AspectJ;target_milestone=1.8.2;">here</a></h2>.</p>
<ul>
<li>1.8.2 available 14-Aug-2014
</ul>
<h2>Notable changes</h2>
<p>Although only a few bugs have been fixed here, they are quite important ones:</p>
<h3>Update to more recent Eclipse Compiler</h3>
<p>AspectJ is now based on a more up to date Eclipse compiler level (git hash 2b07958) so includes all the latest fixes</p>
<h3>Correct handling of RuntimeInvisibleTypeAnnotations (type annotations without runtime visibility)</h3>
<p>For anyone weaving code containing these kind of type annotations, this is an important fix. Although AspectJ does not currently
support pointcuts matching on these kinds of annotation it was crashing when they were encountered. That is now fixed.</p>
<h3>Annotation processing</h3>
<p>A very long standing issue, the AspectJ compiler now supports annotation processors thanks to some work by Sergey Stupin.</p>
<p>Here is a short example, a very basic annotation and application:</p>
<h4>Marker.java</h4>
<code><pre>
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Marker { }
</pre></code>
<h4>Code.java</h4>
<code><pre>
public class Code {
public static void main(String []argv) {
new Code().moo();
new Code().boo();
new Code().too();
new Code().woo();
}
public void moo() {}
@Marker
public void boo() {}
@Marker
public void too() {}
public void woo() {}
}
</pre></code>
<p>And now a basic annotation processor. This processor will find methods in the source marked with the annotation <tt>Marker</tt> and for
each one generate an aspect tailored to advising that method (this *is* a contrived demo!)</p>
<h4>DemoProcessor.java</h4>
<code><pre>
import java.io.*;
import javax.tools.*;
import java.util.*;
import javax.annotation.processing.*;
import javax.lang.model.*;
import javax.lang.model.element.*;
@SupportedAnnotationTypes(value= {"*"})
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class DemoProcessor extends AbstractProcessor {
private Filer filer;
@Override
public void init(ProcessingEnvironment env) {
filer = env.getFiler();
}
@Override
public boolean process(Set elements, RoundEnvironment env) {
// Discover anything marked with @Marker
for (Element element: env.getElementsAnnotatedWith(Marker.class)) {
if (element.getKind() == ElementKind.METHOD) {
// For any methods we find, create an aspect:
String methodName = element.getSimpleName().toString();
String aspectText =
"public aspect Advise_"+methodName+" {\n"+
" before(): execution(* "+methodName+"(..)) {\n"+
" System.out.println(\""+methodName+" running\");\n"+
" }\n"+
"}\n";
try {
JavaFileObject file = filer.createSourceFile("Advise_"+methodName, element);
file.openWriter().append(aspectText).close();
System.out.println("Generated aspect to advise "+element.getSimpleName());
} catch (IOException ioe) {
// already creates message can appear if processor runs more than once
if (!ioe.getMessage().contains("already created")) {
ioe.printStackTrace();
}
}
}
}
return true;
}
}
</pre></code>
<p>With those sources, we compile the processor:</p>
<code><pre>ajc -1.6 DemoProcessor.java Marker.java</pre></code>
<p>Now compile the code with the processor specified:</p>
<code><pre>ajc -1.6 -processor DemoProcessor -showWeaveInfo Code.java Marker.java</pre></code>
<code><pre>
Generated aspect to advise too
Generated aspect to advise boo
Join point 'method-execution(void Code.boo())' in Type 'Code' (Code.java:14) advised by before advice from 'Advise_boo' (Advise_boo.java:2)
Join point 'method-execution(void Code.too())' in Type 'Code' (Code.java:17) advised by before advice from 'Advise_too' (Advise_too.java:2)
</pre></code>
<p>Notice the processor generates the aspects and then they are woven into the code being compiled immediately.</p>
<p>Finally we can run it:</p>
<code><pre>java Code
boo running
too running
</pre></code>
<p><b>Note:</b> There is still work to be done to get annotation processors behaving under AJDT.
<!-- ============================== -->
</body>
</html>
|