Bug 267498 - org.aspectj.matcher.jar causes "Attempted to create Java 1.5 reflection based delegate but org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate was not found on classpath"
Summary: org.aspectj.matcher.jar causes "Attempted to create Java 1.5 reflection based...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.3   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-07 09:28 EST by Bruno De Fraine CLA
Modified: 2010-03-15 17:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno De Fraine CLA 2009-03-07 09:28:48 EST
When I configure my project with the new org.aspectj.matcher.jar which is distributed with AspectJ 1.6.3, I get the following exception when trying to parse a pointcut expression:

Caused by: java.lang.IllegalStateException: Attempted to create Java 1.5 reflection based delegate but org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate was not found on classpath
	at org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateFactory.create15Delegate(ReflectionBasedReferenceTypeDelegateFactory.java:70)
	at org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateFactory.createDelegate(ReflectionBasedReferenceTypeDelegateFactory.java:40)
	at org.aspectj.weaver.reflect.ReflectionWorld.resolveDelegate(ReflectionWorld.java:113)
	at org.aspectj.weaver.World.resolveToReferenceType(World.java:383)
	at org.aspectj.weaver.World.resolve(World.java:277)
	at org.aspectj.weaver.World.resolve(World.java:191)
	at org.aspectj.weaver.World.resolve(World.java:346)
	at org.aspectj.weaver.tools.PointcutParser.buildResolutionScope(PointcutParser.java:380)
	at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:313)
	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:295)
	at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:279)
	at ecosys.aj.AJHostedPointcut.<init>(AJHostedPointcut.java:18)

The type Java15ReflectionBasedReferenceTypeDelegate is indeed not included in this JAR. When I use the aspectjweaver.jar instead, it works.
Comment 1 Andrew Clement CLA 2009-03-07 12:14:48 EST
Can i ask how you were using the matcher?
Comment 2 Andrew Clement CLA 2009-03-12 14:03:34 EDT
Putting notes from the email exchange in here otherwise they will be lost.

Bruno wants to use a reflection world - whereas the initial reason for extracting the matcher was with SpringAOP and an alternative world implementation.  Due to the module structure the weaver5 code (where the reflection world extensions for 1.5 support lives) is not included in the matcher jar file.  To do it properly I would need to split weaver5 into weaver5 and matcher5 (much like I split weaver to be matcher and weaver).  This isn't trivial.

There is a way to force the world to behave as a 1.4 world but the reflection support will not expose anything related to annotations or generics.  It is done by creating a ReflectionWorld and forcing the use of only 1.4 delegates:

new ReflectionWorld(boolean forceUseOf14Delegates, ClassLoader aClassLoader);

However, from Brunos basic scenario:

import org.aspectj.weaver.tools.PointcutParser;

public class Main {
       public static void main(String[] args) {
               PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolution();
               parser.parsePointcutExpression("execution(* *(..))");
       }
}

There is no way to pass the world we want to use to that pointcut parser.  However, there is no documentation on correct use of the extracted matcher, there are only testcases, like this one:
http://dev.eclipse.org/viewcvs/index.cgi/org.aspectj/modules/org.aspectj.matcher/testsrc/org/aspectj/matcher/tools/CommonPointcutExpressionTests.java?revision=1.3&root=Tools_Project&view=markup

which show the way to get a parser using a world is via:
pointcutParser = StandardPointcutParser.getPointcutParserSupportingAllPrimitives(world);

I remarked to Bruno:

Andy said:
>>    [...] I will say the API around StandardPointcutExpression.matchesXXX are 
>> messy, and that is partly because they are only just starting to be
>> abstracted away from a version that just supported matching a reflection 
>> based representation of the join points.
>
> Bruno said:
> 
> The method I am proposing is precisely one way in which you could add an 
> interface that is less messy, by unifying the different XXX's as 
> org.aspectj.lang.JoinPoint. Although this may cause a dependency to
> aspectjrt.jar, and I could understand you don't want that.

I would rather not have a dependency on aspectjrt.jar and am actively trying to avoid it.  Due to other pressures that API will only change when necessary, I don't imagine I will have any time to fix it up for the next few months.  If you want to work on sorting it out and give me a patch, that would be great.  Otherwise we'll just have to cope with the current state it is in.

Your findings are very interesting as you are the first person to attempt to try it out - I think it proves that it is a long way from being finished.
Comment 3 Andrew Clement CLA 2010-03-15 17:37:04 EDT
recommendation is to use the aspectjweaver.jar to solve this problem, instead of org.aspectj.matcher.jar (and so pickup the dependency).  Further matcher improvements are not imminent.  The original driving requirements from the IDE are now not so urgent.

However, since I wrote my previous comment AspectJ has now become a Java 5 project so it should be possible for org.aspectj.matcher.jar to easily include the missing type with a tweak to the build process (but that is something I don't want to tackle right now).