Bug 174385 - Compiler crashes on use of static final string as pointcut expression
Summary: Compiler crashes on use of static final string as pointcut expression
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: 1.6.1   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-15 17:38 EST by Ramnivas Laddad CLA
Modified: 2008-06-10 16:21 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 Ramnivas Laddad CLA 2007-02-15 17:38:36 EST
One user on the Spring forum posted an aspect that used a 'static final' string as pointcut expression. The compiler crashes for such an aspect. I think either accepting it (since such a string is a compile-time constant) or issuing a proper error message will be appropriate resolution.

package bug;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class StaticFinalStringInPointcutAspect {
	static final String pcExpression = "within(*)";
	
	@Pointcut(pcExpression)
	public void pointcutThatUsesStaticFinalStringAsExpression() {}
}

java.lang.ClassCastException
at org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceType.getPointcutStringFromAnnotationStylePointcut(EclipseSourceType.java:169)
at org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceType.makeResolvedPointcutDefinition(EclipseSourceType.java:266)
at org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceType.fillDeclaredMembers(EclipseSourceType.java:232)
at org.aspectj.ajdt.internal.compiler.looku ... rg.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference cannot be cast to org.aspectj.org.eclipse.jdt.internal.compiler.ast.StringLiteral
Comment 1 Andrew Clement CLA 2007-10-26 06:31:54 EDT
i think this could work...
Comment 2 Andrew Clement CLA 2008-06-08 13:41:51 EDT
raising p so I will look at this soon.
Comment 3 Andrew Clement CLA 2008-06-10 16:21:25 EDT
fixed.

Had to allow for something other than fixed constants for the values.
Changes were in:
EclipseSourceType.getPointcutStringFromAnnotationStylePointcut()
ValidateAtAspectJAnnotationsVisitor.getStringLiteralFor()