Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

can annotations add code?

Thread view: 
Timasmith - 29 Nov 2006 19:09 GMT
Hi,

One thing that would be wonderful is if I could add an annotation say

@logthis
public void doSomething() {
  int i=0;
  i=10;
}

which inserted code into the beginning and end of the method such as

public void doSomething() {
  startLogging("doSomething");
  int i=0;
  i=10;
  stopLoggin("doSomething":);
}

Do annotations come close to providing that?

thanks
andrewmcdonagh - 29 Nov 2006 19:31 GMT
> Hi,
>
[quoted text clipped - 16 lines]
>
> thanks

No
Wesley Hall - 29 Nov 2006 19:46 GMT
> Hi,
>
[quoted text clipped - 16 lines]
>
> Do annotations come close to providing that?

No, but AOP does.
Daniel Dyer - 29 Nov 2006 19:49 GMT
> Hi,
>
[quoted text clipped - 16 lines]
>
> Do annotations come close to providing that?

You might want to look into Aspect Oriented Programming (AOP).

Dan.

Signature

Daniel Dyer
http://www.uncommons.org

hiwa - 29 Nov 2006 23:27 GMT
> Do annotations come close to providing that?
Yes. You must be an apt expert to do that.
Thomas Hawtin - 30 Nov 2006 00:02 GMT
>> Do annotations come close to providing that?
> Yes. You must be an apt expert to do that.

APT can be used to generate new code. It does not alter existing code.

I'm sure there are plenty of AOP-style tools that will help, either
modifying the byte code of the .class files, modifying classes in a
custom class loader or using instrumentation APIs on loading the code.

Tom Hawtin
Timasmith - 30 Nov 2006 03:30 GMT
> >> Do annotations come close to providing that?
> > Yes. You must be an apt expert to do that.
[quoted text clipped - 6 lines]
>
> Tom Hawtin

Ok, I guess ideally the annotation would drive the AOP- tool, I'll look
into that.
hiwa - 30 Nov 2006 05:50 GMT
> > >> Do annotations come close to providing that?
> > > Yes. You must be an apt expert to do that.
[quoted text clipped - 9 lines]
> Ok, I guess ideally the annotation would drive the AOP- tool, I'll look
> into that.
Some 'experts' on Java annotation are talking about ....
http://forum.java.sun.com/thread.jspa?threadID=739960&start=0&tstart=20
http://forum.java.sun.com/thread.jspa?threadID=735736&messageID=4227834#4227834
Robert Klemme - 30 Nov 2006 13:47 GMT
> Hi,
>
[quoted text clipped - 16 lines]
>
> Do annotations come close to providing that?

Others have answered that already.  However, if you just want to trace
execution then there are plenty tools out there.  These work either on
VM level or inside (limpy log or so).

    robert


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.