Bug 174385

Summary: Compiler crashes on use of static final string as pointcut expression
Product: [Tools] AspectJ Reporter: Ramnivas Laddad <ramnivas>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: aclement
Version: DEVELOPMENT   
Target Milestone: 1.6.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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()