blob: 382d878423d21ed3f4da6e8ceadb23cf0c6df6ab (
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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
<chapter id="trace" xreflabel="Trace">
<title>Tracing</title>
<sect1 id="trace-introduction">
<title>Introduction</title>
<para> The usual approach to opening a report on Bugzilla is to describe the symptoms of the
problem and attach a simple testcase. This allows the AspectJ team to try and reproduce the problem in
an attempt to fix it as well as improve the test suite. Unfortunately it may not be possible
to produce such a testcase either because your program is too large or is commercially sensitive. Alternatively
the problem may relate to your specific environment where AspectJ is being used and will not be
reproducible by the AspectJ team. In each of these situations you may be asked to produce a
trace of the compiler when the problem occurs instead. This can then be attached to the bug report. </para>
<sect2 id="configuration" xreflabel="configuration">
<title>Configuration</title>
<para> When available (Java 5 or later) AspectJ will use the
<literal>java.util.logging</literal>
<ulink url="http://java.sun.com/j2se/1.5.0/docs/guide/logging/index.html">infrastructure</ulink>
that is configured using a logging.properties file. By default only error
and fatal events will be logged but less severe warnings as well as fine grained
method entry and exit events can be obtained using the appropriate configuration. All
regular compiler messages can also be logged through the infrastructure by setting the
<literal>org.aspectj.weaving.messages</literal> System property. </para>
<para> If you are using a JDK 1.4 or earlier AspectJ will use a simple built-in trace
infrastructure that logs to stderr. This is enabled by setting the
<literal>org.aspectj.weaving.tracing.enabled</literal> System property. You may also override
the default behaviour or provide your own trace implementation using the
<literal>org.aspectj.weaving.tracing.factory</literal> System property. </para>
<para> The table below lists the System properties that can be used to configure tracing. </para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Property</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<literal>org.aspectj.tracing.debug</literal>
</entry>
<entry>
Enable simple debugging of the trace infrastructure itself.
<para> Default: <literal>false</literal>. </para>
</entry>
</row>
<row>
<entry>
<literal>org.aspectj.tracing.enabled</literal>
</entry>
<entry>
Enable the built-in AspectJ trace infrastructure.
<para> Default: <literal>false</literal>. </para>
</entry>
</row>
<row>
<entry>
<literal>org.aspectj.tracing.factory</literal>
</entry>
<entry>
Select trace infrastructure. Specify the fully qualified class name
of the <literal>org.aspectj.weaver.tools.TraceFactory</literal>
interface to use a custom infrastructure. Specify a value of
<literal>default</literal> to force AspectJ to use it's
built-in infrastructure.
</entry>
</row>
<row>
<entry>
<literal>org.aspectj.tracing.messages</literal>
</entry>
<entry>
Enable tracing of compiler messages. The kind of messages logged
is determined by the selected trace infrastructure not the message
configuration.
<para> Default: <literal>false</literal>. </para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
<sect2 id="examples" xreflabel="examples">
<title>Examples</title>
<para> Using <literal>-Dorg.aspectj.tracing.factory=default</literal>
to force AspectJ to use its internal infrastructure,
<literal>-Dorg.aspectj.tracing.enabled=true</literal> to turn it on and
<literal>-Dorg.aspectj.tracing.messages=true</literal> to include messages
running a simple HelloWorld with LTW will generate tracing to stderr. Below
is an extract from that trace with method arguments removed.
You will notice the millisecond time stamp,
thread id and indication of entry/exit/event or message type for each line
of trace.
</para>
<programlisting><![CDATA[
15:44:18.630 main > org.aspectj.weaver.loadtime.Aj.<init>
15:44:18.660 main < org.aspectj.weaver.loadtime.Aj.<init>
15:44:18.660 main > org.aspectj.weaver.loadtime.Aj.preProcess
15:44:18.660 main - org.aspectj.weaver.loadtime.Aj.preProcess
15:44:18.730 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.<init>
15:44:18.730 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.<init>
15:44:18.730 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize
15:44:18.821 main I [AppClassLoader@92e78c] info AspectJ Weaver Version DEVELOPMENT ...
15:44:18.821 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
15:44:18.821 main I [AppClassLoader@92e78c] info register classloader ...
15:44:18.821 main - org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
15:44:18.841 main - org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
15:44:18.841 main I [AppClassLoader@92e78c] info using configuration ...
15:44:18.891 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
15:44:19.021 main > org.aspectj.weaver.World$TypeMap.<init>
15:44:19.021 main < org.aspectj.weaver.World$TypeMap.<init>
15:44:19.021 main > org.aspectj.weaver.CrosscuttingMembersSet.<init>
15:44:19.021 main < org.aspectj.weaver.CrosscuttingMembersSet.<init>
15:44:19.021 main > org.aspectj.weaver.Lint.<init>
15:44:19.021 main < org.aspectj.weaver.Lint.<init>
15:44:19.021 main > org.aspectj.weaver.World.<init>
15:44:19.111 main < org.aspectj.weaver.World.<init>
15:44:19.201 main > org.aspectj.weaver.bcel.BcelWeaver.<init>
15:44:19.201 main < org.aspectj.weaver.bcel.BcelWeaver.<init>
15:44:19.201 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions
15:44:19.211 main > org.aspectj.weaver.bcel.BcelWeaver.setReweavableMode
15:44:19.351 main < org.aspectj.weaver.bcel.BcelWeaver.setReweavableMode
15:44:19.351 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects
15:44:19.351 main I [AppClassLoader@92e78c] info register aspect Aspect
15:44:19.351 main > org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect
15:44:19.501 main - org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass
15:44:19.632 main > org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect
15:44:19.792 main < org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect
15:44:19.792 main < org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect
15:44:19.792 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects
15:44:19.792 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions
15:44:19.792 main > org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave
15:44:19.822 main < org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave
15:44:19.822 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConcete...
15:44:19.822 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConcete...
15:44:19.822 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize
15:44:19.822 main > org.aspectj.weaver.tools.WeavingAdaptor.weaveClass
...
]]></programlisting>
<para> Alternatively when running under Java 5 the <literal>logging.properties</literal>
file below could be used to configure Java Logging. The resulting
file, just containing trace for the
<literal>org.aspectj.weaver.loadtime</literal> package, will be
written to <literal>java0.log</literal> in your <literal>user.home</literal> directory.
</para>
<programlisting><![CDATA[
handlers= java.util.logging.FileHandler
.level= INFO
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level = FINER
org.aspectj.weaver.loadtime.level = FINER
]]></programlisting>
<para>
By setting the System property <literal>-Dorg.aspectj.tracing.debug=true</literal>
you should see a message confirming which trace infrastructure is being used.
</para>
<programlisting><![CDATA[
TraceFactory.instance=org.aspectj.weaver.tools.Jdk14TraceFactory@12dacd1
]]></programlisting>
</sect2>
</sect1>
</chapter>
|