Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 58498 invoked from network); 14 Nov 2006 12:31:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Nov 2006 12:31:35 -0000 Received: (qmail 2402 invoked by uid 500); 14 Nov 2006 12:31:42 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 2367 invoked by uid 500); 14 Nov 2006 12:31:42 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 2358 invoked by uid 99); 14 Nov 2006 12:31:42 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Nov 2006 04:31:42 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of alexei.zakharov@gmail.com designates 66.249.92.171 as permitted sender) Received: from [66.249.92.171] (HELO ug-out-1314.google.com) (66.249.92.171) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Nov 2006 04:31:29 -0800 Received: by ug-out-1314.google.com with SMTP id y2so1605787uge for ; Tue, 14 Nov 2006 04:31:08 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=bcw7p6j5Yh8MN3x+yqlhGuURhyWtJ0hqjvzuPUBo12f6AZ6XQ1YokBIS64VWC+byAV9ZkhqtV1ps0nyc/FAOMtRbqcGdA7d8QxGxHuqZ8yFyF2jRRFuSS+3Zv45B1RUPzYQ+JMs6MlBJqm7b4+qyidCDB7csNNvEeR5kzc7sWZU= Received: by 10.78.26.9 with SMTP id 9mr905649huz.1163507467747; Tue, 14 Nov 2006 04:31:07 -0800 (PST) Received: by 10.78.183.12 with HTTP; Tue, 14 Nov 2006 04:31:07 -0800 (PST) Message-ID: <2c9597b90611140431n39d95d37l7ff116bc6b70ae0b@mail.gmail.com> Date: Tue, 14 Nov 2006 15:31:07 +0300 From: "Alexei Zakharov" To: harmony-dev@incubator.apache.org Subject: Re: [classlib] Using Aspects for Tracing In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org Sian, Cool! Thanks for this. Can AspectJ be used for something more sophisticated than just tracing? For application-level logging for example? Thanks, 2006/11/14, Sian January : > Hello, > > Following a recent discussion on this list I have been looking into how > aspects could be used for tracing in the Harmony class library code. I have > been using AspectJ and have written a really simple tracing aspect for the > math module, adapted the build.xml script and written some instructions on > how to apply it. At the moment the aspect just does entry and exit tracing > and prints to System.out, but this is because it's a first draft - it is > possible to do more targeted tracing and to use frameworks such as > java.util.logging with aspects. > > Steps to follow: > > > 1. Download AspectJ from > http://www.eclipse.org/aspectj/downloads.php > > 2. Copy aspectjrt.jar to /depends/jars/aspectj/ > > 3. Copy aspectjtools.jar and aspectjrt.jar to ANT_HOME/lib and if using > Eclipse add both of these to your ant runtime configuration (Window > > Preferences > Ant > Runtime > Add...) > > 4. Edit build file to use iajc* instead of javac and include aspect class > files (or apply the buildxmlpatch.txt to build.xml in the math module) > > 5. Write a tracing aspect (or copy the one attached to > modules\math\src\main\java\org\apache\harmony\tracing) > > 6. Re-build the module > > 7. Make sure to add aspectjrt.jar to the runtime classpath of whatever > program you are running. > > > * - iajc isn't incremental like javac in ant, it will always do a total > rebuild. Also if you switch from using iajc back to javac you will need to > do a clean before you do a rebuild. > Please also note that it's not possible to use this kind of tracing for any > classes that are depended on by the AspectJ runtime or there will be errors > initializing the classes because of circular dependencies. However I think > most modules apart from luni should be safe. Also it's important to not > trace methods that are called (directly or indirectly) by your tracing > methods otherwise you will end up in an endless loop. > > If anyone thinks this information might be useful to have available > somewhere I would be happy to expand it a bit for a web page or a Wiki page. > > Regards, > > Sian -- Alexei Zakharov, Intel Enterprise Solutions Software Division