This discussion is archived
4 Replies Latest reply: Feb 22, 2013 5:43 AM by Murray9654 RSS

small doubt on AOP?

Murray9654 Newbie
Currently Being Moderated
In Aspect oriented programming when we declare join point as method the implementations like "aspectj" injects some code into methods in the class file. how is that possible? how can we insert the code into the methods of generated class files?
  • 1. Re: small doubt on AOP?
    jtahlborn Expert
    Currently Being Moderated
    you can do it at compile time by adding lines to the source file before compiling. you can do it statically, post-compilation by adding new byte code to the .class file. lastly, you can do it on-the-fly at runtime in a custom ClassLoader by reading the original class file byte codes, adding any additional byte code, then passing it along to the part of the jvm where byte codes are turned into actual Classes.
  • 2. Re: small doubt on AOP?
    Murray9654 Newbie
    Currently Being Moderated
    you can do it at compile time by adding lines to the source file before compiling.
    I know the process of doing this. so I have no doubts in this.
    you can do it statically, post-compilation by adding new byte code to the .class file.
    How to do this. what is the process. any api for this?
    lastly, you can do it on-the-fly at runtime in a custom ClassLoader by reading the original class file byte codes, adding any additional byte code, then passing it along to the part of the jvm where byte codes are turned into actual Classes.
    how to do this? what is the process? may be in simple steps.
  • 3. Re: small doubt on AOP?
    jtahlborn Expert
    Currently Being Moderated
    there are a variety of libraries/utilities for messing with java byte code. all are findable from google.
  • 4. Re: small doubt on AOP?
    Murray9654 Newbie
    Currently Being Moderated
    Thank you.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points