public static ResolvedMember perSingletonAspectOfMethod(UnresolvedType declaringType) {
- return new ResolvedMemberImpl(Member.METHOD,
- declaringType, PUBLIC_STATIC, "aspectOf",
- "()" + declaringType.getSignature());
+ return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, "aspectOf", "()" + declaringType.getSignature());
}
public static ResolvedMember perSingletonHasAspectMethod(UnresolvedType declaringType) {
+++ /dev/null
-/* *******************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import org.aspectj.util.FuzzyBoolean;
-
-
-/**
- * Records stats about the weaver. Information like 'how many types are dismissed during fast match' that
- * may be useful for trying to tune pointcuts. Not publicised.
- */
-public class WeaverMetrics {
-
- // Level 1 of matching is at the type level, which types can be dismissed?
- public static int fastMatchOnTypeAttempted = 0;
- public static int fastMatchOnTypeTrue = 0;
- public static int fastMatchOnTypeFalse = 0;
-
- // Level 2 of matching is fast matching on the shadows in the remaining types
- public static int fastMatchOnShadowsAttempted = 0;
- public static int fastMatchOnShadowsTrue = 0;
- public static int fastMatchOnShadowsFalse = 0;
-
- // Level 3 of matching is slow matching on the shadows (more shadows than were fast matched on!)
- public static int matchTrue = 0;
- public static int matchAttempted = 0;
-
-
-
- public static void reset() {
-
- fastMatchOnShadowsAttempted = 0;
- fastMatchOnShadowsTrue = 0;
- fastMatchOnShadowsFalse = 0;
-
- fastMatchOnTypeAttempted = 0;
- fastMatchOnTypeTrue = 0;
- fastMatchOnTypeFalse = 0;
-
- matchTrue = 0;
- matchAttempted = 0;
- }
-
-
- public static void dumpInfo() {
- System.err.println("Match summary:");
- int fastMatchOnTypeMaybe = (fastMatchOnTypeAttempted-fastMatchOnTypeTrue-fastMatchOnTypeFalse);
- System.err.print("At the type level, we attempted #"+fastMatchOnTypeAttempted+" fast matches:");
- System.err.println(" YES/NO/MAYBE = "+fastMatchOnTypeTrue+"/"+fastMatchOnTypeFalse+"/"+fastMatchOnTypeMaybe);
- int fastMatchMaybe = (fastMatchOnShadowsAttempted-fastMatchOnShadowsFalse-fastMatchOnShadowsTrue);
- System.err.print("Within those #"+(fastMatchOnTypeTrue+fastMatchOnTypeMaybe)+" possible types, ");
- System.err.print("we fast matched on #"+fastMatchOnShadowsAttempted+" shadows:");
- System.err.println(" YES/NO/MAYBE = "+fastMatchOnShadowsTrue+"/"+fastMatchOnShadowsFalse+"/"+fastMatchMaybe);
- System.err.println("Shadow (non-fast) matches attempted #"+matchAttempted+" of which "+matchTrue+" successful");
- }
-
-
- public static void recordFastMatchTypeResult(FuzzyBoolean fb) {
- fastMatchOnTypeAttempted++;
- if (fb.alwaysTrue()) fastMatchOnTypeTrue++;
- if (fb.alwaysFalse()) fastMatchOnTypeFalse++;
- }
-
- public static void recordFastMatchResult(FuzzyBoolean fb) {
- fastMatchOnShadowsAttempted++;
- if (fb.alwaysTrue()) fastMatchOnShadowsTrue++;
- if (fb.alwaysFalse()) fastMatchOnShadowsFalse++;
- }
-
- public static void recordMatchResult(boolean b) {
- matchAttempted++;
- if (b) matchTrue++;
- }
-
-}
import org.aspectj.weaver.ShadowMunger;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.WeaverMessages;
-import org.aspectj.weaver.WeaverMetrics;
import org.aspectj.weaver.WeaverStateInfo;
import org.aspectj.weaver.World;
import org.aspectj.weaver.patterns.DeclareAnnotation;
ShadowMunger munger = (ShadowMunger)i.next();
ContextToken mungerMatchToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.MATCHING_POINTCUT, munger.getPointcut());
if (munger.match(shadow, world)) {
- WeaverMetrics.recordMatchResult(true);// Could pass: munger
shadow.addMunger(munger);
isMatched = true;
if (shadow.getKind() == Shadow.StaticInitialization) {
clazz.warnOnAddedStaticInitializer(shadow,munger.getSourceLocation());
}
- } else {
- WeaverMetrics.recordMatchResult(false); // Could pass: munger
- }
+ }
CompilationAndWeavingContext.leavingPhase(mungerMatchToken);
}
import org.aspectj.weaver.ShadowMunger;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.WeaverMessages;
-import org.aspectj.weaver.WeaverMetrics;
import org.aspectj.weaver.WeaverStateInfo;
import org.aspectj.weaver.World;
import org.aspectj.weaver.patterns.AndPointcut;
public BcelWeaver(BcelWorld world) {
super();
if (trace.isTraceEnabled()) trace.enter("<init>",this,world);
- WeaverMetrics.reset();
this.world = world;
this.xcutSet = world.getCrosscuttingMembersSet();
if (trace.isTraceEnabled()) trace.exit("<init>");
//clazz is null if the classfile was unchanged by weaving...
if (clazz != null) {
UnwovenClassFile[] newClasses = getClassFilesFor(clazz);
+ // OPTIMIZE can we avoid using the string name at all in UnwovenClassFile instances?
+ // Copy the char[] across as it means the WeaverAdapter.removeFromMap() can be fast!
+ if (newClasses[0].getClassName().equals(classFile.getClassName())) {
+ newClasses[0].setClassNameAsChars(classFile.getClassNameAsChars());
+ }
for (int i = 0; i < newClasses.length; i++) {
requestor.acceptResult(newClasses[i]);
}
while (iter.hasNext()) {
ShadowMunger munger = (ShadowMunger)iter.next();
FuzzyBoolean fb = munger.getPointcut().fastMatch(info);
- WeaverMetrics.recordFastMatchTypeResult(fb); // Could pass: munger.getPointcut().toString(),info
if (fb.maybeTrue()) {
result.add(munger);
}
public class UnwovenClassFile {
protected String filename;
+ protected char[] charfilename;
protected byte[] bytes;
// protected JavaClass javaClass = null;
//protected byte[] writtenBytes = null;
return true;
}
+ public char[] getClassNameAsChars() {
+ if (charfilename==null) {
+ charfilename = getClassName().replace('.', '/').toCharArray();
+ }
+ return charfilename;
+ }
public String getClassName() {
- if (className == null) className = getJavaClass().getClassName();
+ if (className == null) className = getJavaClass().getClassName(); // OPTIMIZE quicker way to determine name??? surely?
return className;
}
}
// record
+ // OPTIMIZE why is the 'short name' used here (the bit after the dollar) - seems we mess about a lot trimming it off only to put it back on!
public static class ChildClass {
public final String name;
public final byte[] bytes;
return "(ChildClass " + name + ")";
}
}
+
+ public void setClassNameAsChars(char[] classNameAsChars) {
+ this.charfilename = classNameAsChars;
+ }
}
+++ /dev/null
-/* *******************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver.ltw;
-
-import org.aspectj.weaver.IWeaver;
-
-/**
- * @author adrian
- *
- */
-public class LTWeaver implements IWeaver {
-
-}
package org.aspectj.weaver.tools;
-/** This class implements a boolean that includes a "maybe"
+/**
+ * This class implements a boolean that includes a "maybe"
*/
public class FuzzyBoolean {
+++ /dev/null
-<html>
-<body>
-Provides a set of interfaces for third-parties wishing to integrate
-AspectJ weaving capabilities into their environments.
-</body>
-</html>