Community
Participate
Working Groups
Hi guys! I've downloaded DEVELOPMENT-20051029200407. There is some issue that I think is still open. Take a look at the example: Java Code: ---------- public class Test1 { Set<Integer> intsSet; public Set<Integer> foo() { return intsSet; } } public class Test2 { Set<Double> dSet; public Set<Double> foo() { return dSet; } } Aspect: ------- public privileged aspect TestAspect { pointcut gettingMemberCollection(Test t) : target(t) && get(!public Set<Number+> com.*.*) && !within(TestAspect); Set around(Test t) : gettingMemberCollection(t) { Set s = proceed(t); return s; } } As you can see, I would like to replace access to member Set of something which derives from Number. But the problem is that around advice is stricted to return exact type of the member, and I'm getting the same error as earlier. incompatible return type applying to field-get(java.util.Set com.mprv.secsph.Test.intsSet) incompatible return type applying to field-get(java.util.Set com.mprv.secsph.Test.dSet) In the M2 I just declared the advice this way and it worked fine. May be now, you should allow to declare the advice this way: Set<? extends Number> around(Test t) : gettingMemberCollection(t) { Set s = proceed(t); return s; } Thanks! Misha.
interesting. it is a slight variation from the previous problem posted. marking RC1.
Fix checked in. We will allow the case where you use 'Set' as the around() advice return value but you will get an unchecked conversion warning, if you want to hide the conversion warning, use -Xlint to suppress it or this annotation on the advice @org.aspectj.lang.annotation.SuppressAjWarnings("uncheckedAdviceConversion") Waiting on build before closing.
Thanks A LOT! I'll get the build as soon as it's ready.
fix available from download page. thanks for the clear bug report and test case.
Hi! Another issue ... :) Here is the example: Java Code: ---------- public class Test<T> { Set<T> set; public <T> T[] toArray(T[] a) { return set.toArray(a); } } public class TTT { public void foo() { Test<Integer> mt = new Test<Integer>(); Integer[] arr = mt.toArray(new Integer[]{}); } } Aspect: ------- public privileged aspect TestAspect { pointcut TestToArray(Test mt) : target(mt) && !within(TestAspect); Object[] around(Test mt, Object[] objs) : TestToArray(mt) && args(objs) && execution(Object[] com.Test.toArray(Object[])) { objs = proceed(mt, objs); return objs; } } Errors: ------- TestAspect.aj:19::381 incompatible return type applying to method-execution (java.lang.Object[] com.mprv.secsph.Test.toArray(java.lang.Object[])) Test.java:19:0::0 incompatible return type applying to method-execution (java.lang.Object[] com.mprv.secsph.Test.toArray(java.lang.Object[])) As you see, I'm trying to apply around advice to generic version of "toArray" method. I think it's impossible for now to do so ... P.S. THANKS A LOT for your fast responses and almost immediate bug fixes!!!
sigh...
eventually we'll get to a point where you try something and it works :) I'll look at this bug tomorrow morning.
Don't misunderstand me, I've tried a lot of things in AspectJ that already work :) - we have developed for a 6 months with M2 version and it was great. Just a new generics stuff is still causing problems, but this is what Milestones are made for :) I think you are doing a great job! Thanks!
Fix for latest case committed. I'm going to experiment a little bit with it though - I suspect if the bounds of the type variable aren't Object then we'll blow up...
Ok, tried my case and *it worked* (shock horror). So i'll close this bug again when the build comes through :) thanks for the simple testcase each time.
*boing* it bounces closed again - build is available with latest fix in.
Hi, It seems that those "field-get problems" were not fixed in aspectjweaver.jar. When I compile my code I only get warnings for "unchecked conversion" (like expected). But when I've tried to enable load time weaving, I've got the same errors like in my first post here. Thanks!
As it fails LTW, it probably fails binary weaving - I'll try it out.
seems to work for me either binary weaving or LTW - so I need more information, I must be doing something different to you. I'm using the program almost as described in the original post on this bug report - except my Test1 and Test2 are subclasses of a simple Test type (required by the pointcut definition...) Or are you referring to the program in comment #5? And when you say 'enabled load time weaving' - how are you doing that? command line? in AJDT? I'm confused because exactly the same logic is used to weave in either case - so I can't currently see how it can work in one case and not another, hmmm.
Hi, I'm referring to the FIRST post - not comment #5. I'm enabling LTW by passing: -javaagent:/my_path/aspectjweaver.jar to JVM. I have the development build from November 3. When I look at the content of the aspectjweaver.jar I can see that most of the classes are created at Nov 3, but some of them are from Oct 17. May be aspectjweaver.jar is not up-to-date? Thanks!
October 10, not 17
Some of the jar contents come from other jars - if those weren't rebuilt then they'll still have the old dates in aspectjweaver.jar (e.g. org/aspectj/apache/bcel/*). I don't think thats a problem here as the fix was in org/aspectj/weaver/Advice which doesn't come from a jar. two things: 1. Can you try on a more up to date dev build? 3rd Nov is a bit old... although I don't know that this will help considering the fix was committed on the 1st Nov. 2. Can I ask how you are building the parts of the application prior to load time weaving?
Created attachment 30140 [details] Test case
Hi Andy, I've attached the IntelliJ Idea's project. Unfortunately bugzilla didn't allow me to attach more than 10MB, so you will have to put aspectj libs in the project's lib directory. Run it. You will receive the errors. For build information, you can look at the build.xml If you have questions, I'm here :)
Guys? What about this bug?
You havent been forgotten - I've just a mountain of bugs to get through and they are all serious. Did you try a more recent dev build, per my comment #17. If you could unpick your build.xml to explain how the parts of the application build prior to load time weaving, that will help me too. I don't use intellij so haven't looked at the appended tar.gz yet.
I'm trying to recreate this problem. I've installed an up to date AspectJ in c:\aspectj1.5.0-dev Then I type 'ant build' then 'ant build-aspects' (the latter of which gives me warnings I can ignore about advice not matching) I then try and run it from the resultant classes folder: java -javaagent:c:\aspectj1.5.0-dev\lib\aspectjweaver.jar com.mprv.secsph.Test and it just blows up with a BCException. what am i doing wrong such that I don't see the failure you see? this is what I get: warning Register definition failed -- (BCException) malformed org.aspectj.weaver.PointcutDeclaration attribute java.io.EOFExceptio n malformed org.aspectj.weaver.PointcutDeclaration attribute java.io.EOFException org.aspectj.weaver.BCException: malformed org.aspectj.weaver.PointcutDeclaration attribute java.io.EOFException at org.aspectj.weaver.AjAttribute.read(AjAttribute.java:123) at org.aspectj.weaver.bcel.BcelAttributes.readAjAttributes(BcelAttributes.java:59) at org.aspectj.weaver.bcel.BcelObjectType.unpackAspectAttributes(BcelObjectType.java:270) at org.aspectj.weaver.bcel.BcelObjectType.<init>(BcelObjectType.java:131) at org.aspectj.weaver.bcel.BcelWorld.makeBcelObjectType(BcelWorld.java:255) at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:250) at org.aspectj.weaver.World.resolveToReferenceType(World.java:296)
Hi, Sorry for the late response. Tonns of work ... :) Are you still getting this exception? I'm going to try the latest build now with this testcase.
Hi, I've runned the testcase with the latest (today's Nov 23 build) build and it worked! I've rechecked it with Nov 3 build, and it didn't work! Did you do something? :-) Anyway, thanks a lot!
Thanks for trying it out. I haven't knowingly done anything to affect this test but we have fixed quite a few bugs in the last few days all over the place. So shall I close it again for now? :) Feel free to reopen if you encounter this problem again.
Hi Andy, Thanks for the help! I think now this bug can be closed :-) But there is another issue. Take a look at this post (and topic) - you will know what I'm talking about. http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01869.html My problem is that I'm working with Hibernate (3.0.5, cglib 2.1) and LTW seems to cause exceptions in generated code. Is this issue will be solved in 1.5, or should I leave LTW for a while? Thanks! Misha.
Closing as fixed. On the other comments... I remember that long debate about attributes and annotations. We have no plans to move to annotations for everything during 1.5.0 - we're going to look at it again for 1.5.1. Out of interest, how does it manifest as failing for you? The problem we were getting at in the annotation/attribute discussion was that ASM discards attributes it doesn't understand - so it discards the attributes AspectJ adds that tells the weaver what to do. We are thinking about what the right solution is .... maybe a plugin for ASM that would allow us to define whats allowed through ... maybe we move to annotations, but that isn't a small piece of work we can fit into 1.5.0 now.