Results 1 to 4 of 4

Thread: load-time weaving on classes

  1. #1
    Join Date
    Feb 2009
    Posts
    7

    Default load-time weaving on classes

    Hi,
    is there anything special I need to do to be able to use load-time weaving on classes that don't implement any interface? I was experimenting with it and ran into
    Code:
    java.lang.VerifyError: (class: be/test/App$$EnhancerByCGLIB$$4ce32774, method: getNumber signature: ()I) Inconsistent stack height 2 != 1
    As soon as I had my App class implement AppInterface this error was fixed. From what I understood from the reference manual, standard java Proxy's are used for interfaces, instead of cglib. So is this an issue in cglib or do I have to do something special to weave aspects into a class?

  2. #2
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    It is a well-known bug (or rather intentional limitation) in AspectJ that preclude it from proper handling of CGLIB-generated proxies. The team from AspectJ explains it as such (it is not exact quotation) "CGLIB performs formally legal but very unusual stack handling, to which AspectJ is unprepared".

    See https://bugs.eclipse.org/bugs/show_bug.cgi?id=160146 for detailed discussion.

    Workaround is to exclude CGLIB-generated proxies from weaving (by setting exclude inside aop.xml), look at above mentioned link.

    Regards,

    Oleksandr

    Quote Originally Posted by petervds View Post
    Hi,
    is there anything special I need to do to be able to use load-time weaving on classes that don't implement any interface? I was experimenting with it and ran into
    Code:
    java.lang.VerifyError: (class: be/test/App$$EnhancerByCGLIB$$4ce32774, method: getNumber signature: ()I) Inconsistent stack height 2 != 1
    As soon as I had my App class implement AppInterface this error was fixed. From what I understood from the reference manual, standard java Proxy's are used for interfaces, instead of cglib. So is this an issue in cglib or do I have to do something special to weave aspects into a class?

  3. #3
    Join Date
    Feb 2009
    Posts
    7

    Default

    Thanks al0,

    it's a shame though... On my previous project I had to work with an application from a third party vendor that had a dao layer that swallowed all exceptions from jdbc and just threw some vague exception saying "A database exception occurred, probably due to RI.", no mather what had gone wrong, be it a table that didn't exist, or an invalid column or invalid type... The application didn't use Spring, so I wanted to try and build some kind of 'toolkit' that allowed me to get this kind of information by weaving in some aspect... For JDBC it's fine since it's based on interfaces, but if I encounter a similar problem in some location that cannot be accessed through interfaces, I'll have to come up with something else...

    Regards,
    Peter

  4. #4
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Ok, it is not so bad - first of all there is workaround, just exclude non-appropriate classes from weaving (see link from my previous post, there are some details).

    And, secondly, AspectJ guys after all have prioritized the issue and planned some fix for it in 1.6.4 (which is not so far away).

    Regards,
    Oleksandr
    Quote Originally Posted by petervds View Post
    Thanks al0,

    it's a shame though... On my previous project I had to work with an application from a third party vendor that had a dao layer that swallowed all exceptions from jdbc and just threw some vague exception saying "A database exception occurred, probably due to RI.", no mather what had gone wrong, be it a table that didn't exist, or an invalid column or invalid type... The application didn't use Spring, so I wanted to try and build some kind of 'toolkit' that allowed me to get this kind of information by weaving in some aspect... For JDBC it's fine since it's based on interfaces, but if I encounter a similar problem in some location that cannot be accessed through interfaces, I'll have to come up with something else...

    Regards,
    Peter

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •