Changes contributed by Manfred under https://github.com/eclipse/org.aspectj/pull/5/commits
*/
public class AsmElementFormatter {
+ private final static String ASPECTJ_ANNOTATION_PACKAGE = "org.aspectj.lang.annotation";
+ private final static char PACKAGE_INITIAL_CHAR = ASPECTJ_ANNOTATION_PACKAGE.charAt(0);
+
public void genLabelAndKind(MethodDeclaration methodDeclaration, IProgramElement node) {
if (methodDeclaration instanceof AdviceDeclaration) {
// Note: AV: implicit single advice type support here (should be enforced somewhere as well (APT etc))
Annotation annotation = methodDeclaration.annotations[i];
String annotationSig = new String(annotation.type.getTypeBindingPublic(methodDeclaration.scope).signature());
- if (annotationSig.charAt(1) == 'o') {
+ if (annotationSig.charAt(1) == PACKAGE_INITIAL_CHAR) {
if ("Lorg/aspectj/lang/annotation/Pointcut;".equals(annotationSig)) {
node.setKind(IProgramElement.Kind.POINTCUT);
node.setAnnotationStyleDeclaration(true); // pointcuts don't seem to get handled quite right...
// TODO: fix this way of determing ajc-added arguments, make subtype of Argument with extra info
private boolean acceptArgument(String name, String type) {
- if (name.charAt(0) != 'a' && type.charAt(0) != 'o') {
+ if (name.charAt(0) != 'a' && type.charAt(0) != PACKAGE_INITIAL_CHAR) {
return true;
}
return !name.startsWith("ajc$this_") && !type.equals("org.aspectj.lang.JoinPoint.StaticPart")
private final static String THROWING = "throwing";
private final static String RETURNING = "returning";
private final static String STRING_DESC = "Ljava/lang/String;";
+ private final static String ASPECTJ_ANNOTATION_PACKAGE = "org.aspectj.lang.annotation";
+ private final static char PACKAGE_INITIAL_CHAR = ASPECTJ_ANNOTATION_PACKAGE.charAt(0);
/**
* A struct that allows to add extra arguments without always breaking the API
*/
public static List<AjAttribute> readAj5ClassAttributes(AsmManager model, JavaClass javaClass, ReferenceType type,
ISourceContext context, IMessageHandler msgHandler, boolean isCodeStyleAspect) {
- boolean ignoreThisClass = javaClass.getClassName().charAt(0) == 'o'
- && javaClass.getClassName().startsWith("org.aspectj.lang.annotation");
+ boolean ignoreThisClass = javaClass.getClassName().charAt(0) == PACKAGE_INITIAL_CHAR
+ && javaClass.getClassName().startsWith(ASPECTJ_ANNOTATION_PACKAGE);
if (ignoreThisClass) {
return NO_ATTRIBUTES;
}
Constant constant = cpool[i];
if (constant != null && constant.getTag() == Constants.CONSTANT_Utf8) {
String constantValue = ((ConstantUtf8) constant).getValue();
- if (constantValue.length() > 28 && constantValue.charAt(1) == 'o') {
+ if (constantValue.length() > 28 && constantValue.charAt(1) == PACKAGE_INITIAL_CHAR) {
if (constantValue.startsWith("Lorg/aspectj/lang/annotation")) {
containsAnnotationClassReference = true;
if ("Lorg/aspectj/lang/annotation/DeclareAnnotation;".equals(constantValue)) {
//public final
class BcelMethod extends ResolvedMemberImpl {
+ private final static String ASPECTJ_ANNOTATION_PACKAGE = "org.aspectj.lang.annotation";
+ private final static char PACKAGE_INITIAL_CHAR = ASPECTJ_ANNOTATION_PACKAGE.charAt(0);
+
private Method method;
// these fields are not set for many BcelMethods...
for (int i = 0; i < axs.length; i++) {
AnnotationAJ annotationX = axs[i];
String typename = annotationX.getTypeName();
- if (typename.charAt(0) == 'o') {
+ if (typename.charAt(0) == PACKAGE_INITIAL_CHAR) {
if (typename.equals("org.aspectj.lang.annotation.Pointcut")
|| typename.equals("org.aspectj.lang.annotation.Before")
|| typename.equals("org.aspectj.lang.annotation.Around")
closureInstantiation.append(fact.createConstant(Integer.valueOf(bitflags)));
closureInstantiation.append(Utility.createInvoke(getFactory(), getWorld(),
new MemberImpl(Member.METHOD, UnresolvedType.forName("org.aspectj.runtime.internal.AroundClosure"),
- Modifier.PUBLIC, "linkClosureAndJoinPoint", "(I)Lorg/aspectj/lang/ProceedingJoinPoint;")));
+ Modifier.PUBLIC, "linkClosureAndJoinPoint", String.format("%s%s", "(I)", "Lorg/aspectj/lang/ProceedingJoinPoint;"))));
}
InstructionList advice = new InstructionList();
public class Utility {
+ private final static char PACKAGE_INITIAL_CHAR = AjAttribute.AttributePrefix.charAt(0);
+
public static List<AjAttribute> readAjAttributes(String classname, Attribute[] as, ISourceContext context, World w,
AjAttribute.WeaverVersionInfo version, ConstantPoolReader dataDecompressor) {
List<AjAttribute> attributes = new ArrayList<AjAttribute>();
if (a instanceof Unknown) {
Unknown u = (Unknown) a;
String name = u.getName();
- if (name.charAt(0) == 'o') { // 'o'rg.aspectj
+ if (name.charAt(0) == PACKAGE_INITIAL_CHAR) { // 'o'rg.aspectj
if (name.startsWith(AjAttribute.AttributePrefix)) {
if (name.endsWith(WeaverVersionInfo.AttributeName)) {
version = (AjAttribute.WeaverVersionInfo) AjAttribute.read(version, name, u.getBytes(), context, w,
public static final String SHOW_WEAVE_INFO_PROPERTY = "org.aspectj.weaver.showWeaveInfo";
public static final String TRACE_MESSAGES_PROPERTY = "org.aspectj.tracing.messages";
+ private final static String ASPECTJ_BASE_PACKAGE = "org.aspectj.";
+ private final static String PACKAGE_INITIAL_CHARS = ASPECTJ_BASE_PACKAGE.charAt(0) + "sj";
+
private boolean enabled = false;
protected boolean verbose = getVerbose();
protected BcelWorld bcelWorld;
}
private boolean shouldWeaveName(String name) {
- if ("osj".indexOf(name.charAt(0)) != -1) {
+ if (PACKAGE_INITIAL_CHARS.indexOf(name.charAt(0)) != -1) {
if ((weavingSpecialTypes & INITIALIZED) == 0) {
weavingSpecialTypes |= INITIALIZED;
// initialize it
}
}
}
- if (name.startsWith("org.aspectj.")) {
+ if (name.startsWith(ASPECTJ_BASE_PACKAGE)) {
return false;
}
if (name.startsWith("sun.reflect.")) {// JDK reflect