]> source.dussan.org Git - aspectj.git/commitdiff
persistence
authoraclement <aclement>
Tue, 25 Aug 2009 17:00:52 +0000 (17:00 +0000)
committeraclement <aclement>
Tue, 25 Aug 2009 17:00:52 +0000 (17:00 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/Advice.java
org.aspectj.matcher/src/org/aspectj/weaver/Checker.java
org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembers.java
org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembersSet.java
org.aspectj.matcher/src/org/aspectj/weaver/ISourceContext.java
org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java [new file with mode: 0644]
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
org.aspectj.matcher/src/org/aspectj/weaver/ShadowMunger.java
org.aspectj.matcher/src/org/aspectj/weaver/SourceContextImpl.java

index 08426a197cc1c7a129158286b3eab70669f037d3..be57b8421de2934fa75407c37eb0b9a3f7d78d53 100644 (file)
@@ -24,20 +24,16 @@ import org.aspectj.weaver.patterns.TypePattern;
 
 public abstract class Advice extends ShadowMunger {
 
-       protected AjAttribute.AdviceAttribute attribute; // the pointcut field is
-       // ignored
-
-       protected AdviceKind kind; // alias of attribute.getKind()
+       protected AjAttribute.AdviceAttribute attribute;
+       protected transient AdviceKind kind; // alias for attribute.getKind()
        protected Member signature;
-       protected boolean hasMatchedAtLeastOnce = false;
 
        // not necessarily declaring aspect, this is a semantics change from 1.0
        protected ResolvedType concreteAspect; // null until after concretize
 
-       protected List innerCflowEntries = Collections.EMPTY_LIST; // just for
-       // cflow*Entry
-       // kinds
-       protected int nFreeVars; // just for cflow*Entry kinds
+       // Just for Cflow*entry kinds
+       protected List innerCflowEntries = Collections.EMPTY_LIST;
+       protected int nFreeVars;
 
        protected TypePattern exceptionType; // just for Softener kind
 
@@ -45,6 +41,8 @@ public abstract class Advice extends ShadowMunger {
        // signature types
        protected UnresolvedType[] bindingParameterTypes;
 
+       protected boolean hasMatchedAtLeastOnce = false;
+
        protected List/* Lint.Kind */suppressedLintKinds = null; // based on
        // annotations on
        // this advice
@@ -97,9 +95,9 @@ public abstract class Advice extends ShadowMunger {
        }
 
        public Advice(AjAttribute.AdviceAttribute attribute, Pointcut pointcut, Member signature) {
-               super(pointcut, attribute.getStart(), attribute.getEnd(), attribute.getSourceContext());
+               super(pointcut, attribute.getStart(), attribute.getEnd(), attribute.getSourceContext(), ShadowMungerAdvice);
                this.attribute = attribute;
-               kind = attribute.getKind(); // alias
+               this.kind = attribute.getKind(); // alias
                this.signature = signature;
                if (signature != null) {
                        bindingParameterTypes = signature.getParameterTypes();
@@ -140,14 +138,16 @@ public abstract class Advice extends ShadowMunger {
                                return matches;
                        } else if (hasExtraParameter() && kind == AdviceKind.AfterThrowing) { // pr119749
                                ResolvedType exceptionType = getExtraParameterType().resolve(world);
-                               if (!exceptionType.isCheckedException())
+                               if (!exceptionType.isCheckedException()) {
                                        return true;
+                               }
                                UnresolvedType[] shadowThrows = shadow.getSignature().getExceptions(world);
                                boolean matches = false;
                                for (int i = 0; i < shadowThrows.length && !matches; i++) {
                                        ResolvedType type = shadowThrows[i].resolve(world);
-                                       if (exceptionType.isAssignableFrom(type))
+                                       if (exceptionType.isAssignableFrom(type)) {
                                                matches = true;
+                                       }
                                }
                                return matches;
                        } else if (kind == AdviceKind.PerTargetEntry) {
@@ -271,8 +271,9 @@ public abstract class Advice extends ShadowMunger {
        public static int countOnes(int bits) {
                int ret = 0;
                while (bits != 0) {
-                       if ((bits & 1) != 0)
+                       if ((bits & 1) != 0) {
                                ret += 1;
+                       }
                        bits = bits >> 1;
                }
                return ret;
@@ -285,8 +286,9 @@ public abstract class Advice extends ShadowMunger {
        public String[] getBaseParameterNames(World world) {
                String[] allNames = getSignature().getParameterNames(world);
                int extras = getExtraParameterCount();
-               if (extras == 0)
+               if (extras == 0) {
                        return allNames;
+               }
                String[] result = new String[getBaseParameterCount()];
                for (int i = 0; i < result.length; i++) {
                        result[i] = allNames[i];
@@ -429,8 +431,9 @@ public abstract class Advice extends ShadowMunger {
 
        // XXX this perhaps ought to take account of the other fields in advice ...
        public boolean equals(Object other) {
-               if (!(other instanceof Advice))
+               if (!(other instanceof Advice)) {
                        return false;
+               }
                Advice o = (Advice) other;
                return o.kind.equals(kind) && ((o.pointcut == null) ? (pointcut == null) : o.pointcut.equals(pointcut))
                                && ((o.signature == null) ? (signature == null) : o.signature.equals(signature));
@@ -464,9 +467,9 @@ public abstract class Advice extends ShadowMunger {
        public static final int ThisEnclosingJoinPointStaticPart = 0x08;
        public static final int ParameterMask = 0x0f;
        // For an if pointcut, this indicates it is hard wired to access a constant of either true or false
-       public static final int ConstantReference = 0x10; 
+       public static final int ConstantReference = 0x10;
        // When the above flag is set, this indicates whether it is true or false
-       public static final int ConstantValue = 0x20; 
+       public static final int ConstantValue = 0x20;
        public static final int CanInline = 0x40;
 
        // for testing only
index a2d8dc26213df517392d95c7897838d39b42aab7..b3732495d116d517910f276c97a9afe5faae6c3b 100644 (file)
@@ -27,33 +27,29 @@ import org.aspectj.weaver.patterns.Pointcut;
  */
 public class Checker extends ShadowMunger {
 
-       private final String message;
-       private final boolean isError; // if not error then it is a warning
+       private boolean isError; // if not error then it is a warning
+       private String message;
        private volatile int hashCode = -1;
 
+       private Checker() {
+       }
+
        /**
-        * Create a Checker for a deow.
+        * Create a Checker for a declare error or declare warning.
         * 
-        * @param deow the declare error or warning for which to create the checker munger
+        * @param deow the declare error or declare warning for which to create the checker munger
         */
        public Checker(DeclareErrorOrWarning deow) {
-               super(deow.getPointcut(), deow.getStart(), deow.getEnd(), deow.getSourceContext());
+               super(deow.getPointcut(), deow.getStart(), deow.getEnd(), deow.getSourceContext(), ShadowMungerDeow);
                this.message = deow.getMessage();
                this.isError = deow.isError();
        }
 
        /**
-        * Only used when filling in a parameterized Checker.
-        * 
-        * @param pc the pointcut
-        * @param start the start
-        * @param end the end
-        * @param context the source context
-        * @param message the message string
-        * @param isError whether it is an error or just a warning
+        * Only used when filling in a parameterized Checker
         */
-       private Checker(Pointcut pc, int start, int end, ISourceContext context, String message, boolean isError) {
-               super(pc, start, end, context);
+       private Checker(Pointcut pointcut, int start, int end, ISourceContext context, String message, boolean isError) {
+               super(pointcut, start, end, context, ShadowMungerDeow);
                this.message = message;
                this.isError = isError;
        }
@@ -62,22 +58,20 @@ public class Checker extends ShadowMunger {
                return isError;
        }
 
-       /**
-        * Not supported for a Checker
-        */
+       public String getMessage() {
+               return this.message;
+       }
+
        public void specializeOn(Shadow shadow) {
-               throw new RuntimeException("illegal state");
+               throw new IllegalStateException("Cannot call specializeOn(...) for a Checker");
        }
 
-       /**
-        * Not supported for a Checker
-        */
        public boolean implementOn(Shadow shadow) {
-               throw new RuntimeException("illegal state");
+               throw new IllegalStateException("Cannot call implementOn(...) for a Checker");
        }
 
        /**
-        * Determine if the Checker matches at a shadow. If it does then we can immediately report the message. There (currently) can
+        * Determine if the Checker matches at a shadow. If it does then we can immediately report the message. Currently, there can
         * never be a non-statically determinable match.
         * 
         * @param shadow the shadow which to match against
@@ -90,17 +84,11 @@ public class Checker extends ShadowMunger {
                return false;
        }
 
-       // FIXME what the hell?
+       // implementation for PartialOrder.PartialComparable
        public int compareTo(Object other) {
                return 0;
        }
 
-       // FIXME Alex: ATAJ is that ok in all cases ?
-       /**
-        * Default to true
-        * 
-        * @return
-        */
        public boolean mustCheckExceptions() {
                return true;
        }
@@ -109,7 +97,7 @@ public class Checker extends ShadowMunger {
                return Collections.EMPTY_LIST;
        }
 
-       // FIXME this perhaps ought to take account of the other fields in advice ...
+       // FIXME this perhaps ought to take account of the other fields in advice (use super.equals?)
        public boolean equals(Object other) {
                if (!(other instanceof Checker)) {
                        return false;
@@ -128,6 +116,9 @@ public class Checker extends ShadowMunger {
                return hashCode;
        }
 
+       /**
+        * Parameterize the Checker by parameterizing the pointcut
+        */
        public ShadowMunger parameterizeWith(ResolvedType declaringType, Map typeVariableMap) {
                Checker ret = new Checker(this.pointcut.parameterizeWith(typeVariableMap, declaringType.getWorld()), this.start, this.end,
                                this.sourceContext, this.message, this.isError);
@@ -135,8 +126,7 @@ public class Checker extends ShadowMunger {
        }
 
        /**
-        * Concretize this Checker by concretizing the pointcut.
-        * 
+        * Concretize this Checker by concretizing the pointcut
         */
        public ShadowMunger concretize(ResolvedType theAspect, World world, PerClause clause) {
                this.pointcut = this.pointcut.concretize(theAspect, getDeclaringType(), 0, this);
@@ -144,8 +134,16 @@ public class Checker extends ShadowMunger {
                return this;
        }
 
-       public String getMessage() {
-               return this.message;
-       }
-
+       // public void write(DataOutputStream stream) throws IOException {
+       // super.write(stream);
+       // stream.writeBoolean(isError);
+       // stream.writeUTF(message);
+       // }
+       //
+       // public static Checker read(DataInputStream stream, World world) throws IOException {
+       // Checker checker = new Checker();
+       // checker.isError = stream.readBoolean();
+       // checker.message = stream.readUTF();
+       // return checker;
+       // }
 }
index f8a5e81cc6ec4423cf7cf7aef07fd226055bcc49..96f39c70994c8e9dd0a0983c8a0d0181bcfbcaee 100644 (file)
@@ -88,8 +88,9 @@ public class CrosscuttingMembers {
        }
 
        private void addShadowMunger(ShadowMunger m) {
-               if (inAspect.isAbstract())
-                       return; // we don't do mungers for abstract aspects
+               if (inAspect.isAbstract()) {
+                       return; // mungers for abstract aspects are not added
+               }
                addConcreteShadowMunger(m.concretize(inAspect, world, perClause));
        }
 
index e5a44bc1b5f873824636079e9f70f7008bd4df3c..5371e0bc2cc67553d1c058e09b7c7b1635b1bf22 100644 (file)
@@ -1,5 +1,5 @@
 /* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2002-2009 Contributors
  * All rights reserved. 
  * This program and the accompanying materials are made available 
  * under the terms of the Eclipse Public License v1.0 
@@ -12,6 +12,8 @@
 
 package org.aspectj.weaver;
 
+import java.io.DataOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -29,28 +31,31 @@ import org.aspectj.weaver.tools.TraceFactory;
  * This holds on to all CrosscuttingMembers for a world. It handles management of change.
  * 
  * @author Jim Hugunin
+ * @author Andy Clement
  */
 public class CrosscuttingMembersSet {
+
+       private static Trace trace = TraceFactory.getTraceFactory().getTrace(CrosscuttingMembersSet.class);
+
+       private transient World world;
+
        // FIXME AV - ? we may need a sequencedHashMap there to ensure source based precedence for @AJ advice
        private final Map /* ResolvedType (the aspect) > CrosscuttingMembers */members = new HashMap();
 
-       private World world;
-       private List shadowMungers = null;
+       // List of things to be verified once the type system is 'complete'
+       private transient List /* IVerificationRequired */verificationList = null;
+
+       private List /* ShadowMunger */shadowMungers = null;
        private List typeMungers = null;
        private List lateTypeMungers = null;
        private List declareSofts = null;
        private List declareParents = null;
        private List declareAnnotationOnTypes = null;
        private List declareAnnotationOnFields = null;
-       private List declareAnnotationOnMethods = null; // includes ctors
+       private List declareAnnotationOnMethods = null; // includes constructors
        private List declareDominates = null;
        private boolean changedSinceLastReset = false;
 
-       private List /* IVerificationRequired */verificationList = null; // List of things to be verified once the type system is
-       // 'complete'
-
-       private static Trace trace = TraceFactory.getTraceFactory().getTrace(CrosscuttingMembersSet.class);
-
        public CrosscuttingMembersSet(World world) {
                this.world = world;
        }
@@ -267,8 +272,9 @@ public class CrosscuttingMembersSet {
                        ResolvedType element = (ResolvedType) iter.next();
                        for (Iterator i = ((CrosscuttingMembers) members.get(element)).getDeclareParents().iterator(); i.hasNext();) {
                                DeclareParents dp = (DeclareParents) i.next();
-                               if (dp.equals(p))
+                               if (dp.equals(p)) {
                                        return element;
+                               }
                        }
                }
                return null;
@@ -288,8 +294,9 @@ public class CrosscuttingMembersSet {
         * we go along - for example some recursive type variable references (pr133307)
         */
        public void recordNecessaryCheck(IVerificationRequired verification) {
-               if (verificationList == null)
+               if (verificationList == null) {
                        verificationList = new ArrayList();
+               }
                verificationList.add(verification);
        }
 
@@ -297,8 +304,9 @@ public class CrosscuttingMembersSet {
         * Called when type bindings are complete - calls all registered verification objects in turn.
         */
        public void verify() {
-               if (verificationList == null)
+               if (verificationList == null) {
                        return;
+               }
                for (Iterator iter = verificationList.iterator(); iter.hasNext();) {
                        IVerificationRequired element = (IVerificationRequired) iter.next();
                        element.verify();
@@ -306,4 +314,25 @@ public class CrosscuttingMembersSet {
                verificationList = null;
        }
 
+       public int serializationVersion = 1;
+
+       public void write(DataOutputStream stream) throws IOException {
+               // stream.writeInt(serializationVersion);
+               stream.writeInt(shadowMungers.size());
+               for (Iterator iterator = shadowMungers.iterator(); iterator.hasNext();) {
+                       ShadowMunger shadowMunger = (ShadowMunger) iterator.next();
+                       shadowMunger.write(stream);
+               }
+               // // private List /* ShadowMunger */shadowMungers = null;
+               // // private List typeMungers = null;
+               // // private List lateTypeMungers = null;
+               // // private List declareSofts = null;
+               // // private List declareParents = null;
+               // // private List declareAnnotationOnTypes = null;
+               // // private List declareAnnotationOnFields = null;
+               // // private List declareAnnotationOnMethods = null; // includes constructors
+               // // private List declareDominates = null;
+               // // private boolean changedSinceLastReset = false;
+               //
+       }
 }
index dfaab8da23cede76a7f6e62b3a6ee52b896f5b8b..0f2f0aba1af8846fc18cbc8024083e0e64b413b0 100644 (file)
  *     PARC     initial implementation 
  * ******************************************************************/
 
-
 package org.aspectj.weaver;
 
 import org.aspectj.bridge.ISourceLocation;
 
 public interface ISourceContext {
        public ISourceLocation makeSourceLocation(IHasPosition position);
+
        public ISourceLocation makeSourceLocation(int line, int offset);
+
        public int getOffset();
+
        public void tidy();
 }
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java b/org.aspectj.matcher/src/org/aspectj/weaver/PersistenceSupport.java
new file mode 100644 (file)
index 0000000..8536adc
--- /dev/null
@@ -0,0 +1,32 @@
+/* *******************************************************************
+ * Copyright (c) 2009 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://www.eclipse.org/legal/epl-v10.html 
+ *  
+ * ******************************************************************/
+ package org.aspectj.weaver;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/**
+ * @author Andy Clement
+ */
+public class PersistenceSupport {
+
+       public static void write(DataOutputStream stream, ISourceContext sourceContext) throws IOException {
+               throw new IllegalStateException();
+       }
+
+       public static void write(DataOutputStream stream, Serializable serializableObject) throws IOException {
+               ObjectOutputStream oos = new ObjectOutputStream(stream);
+               oos.writeObject(serializableObject);
+               oos.flush();
+       }
+
+}
index ab7f75f91130218e400fc9b626e695d2d5741e49..f1f67795556c0452e4cd85650010df0a082b11f4 100644 (file)
@@ -597,8 +597,9 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
        }
 
        public final Collection collectDeclares(boolean includeAdviceLike) {
-               if (!this.isAspect())
+               if (!this.isAspect()) {
                        return Collections.EMPTY_LIST;
+               }
 
                ArrayList ret = new ArrayList();
                // if (this.isAbstract()) {
index 39cac57c3a8ca162ab2b75acd5e5941b77bead57..a55c84fd00d11defec3e606139749ba9f3f5157b 100644 (file)
@@ -12,7 +12,9 @@
 
 package org.aspectj.weaver;
 
+import java.io.DataOutputStream;
 import java.io.File;
+import java.io.IOException;
 import java.util.Collection;
 import java.util.Map;
 
@@ -33,36 +35,39 @@ import org.aspectj.weaver.patterns.TypePattern;
  */
 public abstract class ShadowMunger implements PartialOrder.PartialComparable, IHasPosition {
 
-       protected Pointcut pointcut;
+       public static final ShadowMunger[] NONE = new ShadowMunger[0];
+
+       private static int VERSION_1 = 1; // ShadowMunger version for serialization
+
+       protected static final int ShadowMungerAdvice = 1;
+       protected static final int ShadowMungerDeow = 2;
+
+       public String handle = null;
+
+       private int shadowMungerKind;
 
-       // these three fields hold the source location of this munger
        protected int start, end;
        protected ISourceContext sourceContext;
        private ISourceLocation sourceLocation;
        private ISourceLocation binarySourceLocation;
        private File binaryFile;
-       public String handle = null;
-       private ResolvedType declaringType; // the type that declared this munger.
+       private ResolvedType declaringType;
+       private boolean isBinary;
+       private boolean checkedIsBinary;
+
+       protected Pointcut pointcut;
 
-       public ShadowMunger(Pointcut pointcut, int start, int end, ISourceContext sourceContext) {
+       protected ShadowMunger() {
+       }
+
+       public ShadowMunger(Pointcut pointcut, int start, int end, ISourceContext sourceContext, int shadowMungerKind) {
+               this.shadowMungerKind = shadowMungerKind;
                this.pointcut = pointcut;
                this.start = start;
                this.end = end;
                this.sourceContext = sourceContext;
        }
 
-       public abstract ShadowMunger concretize(ResolvedType fromType, World world, PerClause clause);
-
-       public abstract void specializeOn(Shadow shadow);
-
-       /**
-        * Implement this munger at the specified shadow, returning a boolean to indicate success.
-        * 
-        * @param shadow the shadow where this munger should be applied
-        * @return true if the munger was successful
-        */
-       public abstract boolean implementOn(Shadow shadow);
-
        /**
         * All overriding methods should call super
         */
@@ -79,8 +84,6 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
                return pointcut.match(shadow).maybeTrue();
        }
 
-       public abstract ShadowMunger parameterizeWith(ResolvedType declaringType, Map typeVariableMap);
-
        public int fallbackCompareTo(Object other) {
                return toString().compareTo(toString());
        }
@@ -108,10 +111,6 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
                return sourceLocation;
        }
 
-       // ---- fields
-
-       public static final ShadowMunger[] NONE = new ShadowMunger[0];
-
        public Pointcut getPointcut() {
                return pointcut;
        }
@@ -134,27 +133,15 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
                return declaringType;
        }
 
-       /**
-        * @return a Collection of ResolvedType for all checked exceptions that might be thrown by this munger
-        */
-       public abstract Collection getThrownExceptions();
-
-       /**
-        * Does the munger has to check that its exception are accepted by the shadow ? ATAJ: It s not the case for @AJ around advice
-        * f.e. that can throw Throwable, even if the advised method does not throw any exceptions.
-        * 
-        * @return true if munger has to check that its exceptions can be throwned based on the shadow
-        */
-       public abstract boolean mustCheckExceptions();
-
        /**
         * Returns the binarySourceLocation for the given sourcelocation. This isn't cached because it's used when faulting in the
         * binary nodes and is called with ISourceLocations for all advice, pointcuts and deows contained within the
         * resolvedDeclaringAspect.
         */
        public ISourceLocation getBinarySourceLocation(ISourceLocation sl) {
-               if (sl == null)
+               if (sl == null) {
                        return null;
+               }
                String sourceFileName = null;
                if (getDeclaringType() instanceof ReferenceType) {
                        String s = ((ReferenceType) getDeclaringType()).getDelegate().getSourcefilename();
@@ -178,7 +165,7 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
        private File getBinaryFile() {
                if (binaryFile == null) {
                        String s = getDeclaringType().getBinaryPath();
-                       if (s.indexOf("!")==-1) {
+                       if (s.indexOf("!") == -1) {
                                File f = getDeclaringType().getSourceLocation().getSourceFile();
                                // Replace the source file suffix with .class
                                int i = f.getPath().lastIndexOf('.');
@@ -211,7 +198,60 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
                return isBinary;
        }
 
-       private boolean isBinary;
-       private boolean checkedIsBinary;
+       public abstract ShadowMunger concretize(ResolvedType fromType, World world, PerClause clause);
+
+       public abstract void specializeOn(Shadow shadow);
+
+       /**
+        * Implement this munger at the specified shadow, returning a boolean to indicate success.
+        * 
+        * @param shadow the shadow where this munger should be applied
+        * @return true if the implement was successful
+        */
+       public abstract boolean implementOn(Shadow shadow);
+
+       public abstract ShadowMunger parameterizeWith(ResolvedType declaringType, Map typeVariableMap);
+
+       /**
+        * @return a Collection of ResolvedTypes for all checked exceptions that might be thrown by this munger
+        */
+       public abstract Collection getThrownExceptions();
+
+       /**
+        * Does the munger have to check that its exception are accepted by the shadow ? It is not the case for annotation style around
+        * advice, for example: that can throw Throwable, even if the advised method does not throw any exceptions.
+        * 
+        * @return true if munger has to check that its exceptions can be thrown based on the shadow
+        */
+       public abstract boolean mustCheckExceptions();
 
+       public void write(DataOutputStream stream) throws IOException {
+               stream.writeInt(VERSION_1);
+               stream.writeInt(shadowMungerKind); // determines real subclass
+               stream.writeInt(start);
+               stream.writeInt(end);
+               PersistenceSupport.write(stream, sourceContext);
+               PersistenceSupport.write(stream, sourceLocation);
+               PersistenceSupport.write(stream, binarySourceLocation);
+               PersistenceSupport.write(stream, binaryFile);
+               declaringType.write(stream);
+               stream.writeBoolean(isBinary);
+               stream.writeBoolean(checkedIsBinary);
+               pointcut.write(stream);
+       }
+       //
+       // public static ShadowMunger read(VersionedDataInputStream stream, World world) throws IOException {
+       // stream.readInt();
+       // int kind = stream.readInt();
+       // ShadowMunger newShadowMunger = null;
+       // switch (kind) {
+       // case ShadowMungerAdvice:
+       // // world.getWeavingSupport().createAdviceMunger(attribute, pointcut, signature)
+       // case ShadowMungerDeow:
+       // newShadowMunger = Checker.read(stream, world);
+       // default:
+       // throw new IllegalStateException("Unexpected type of shadow munger found on deserialization: " + kind);
+       // }
+       // newShadowMunger.binaryFile = null;
+       // }
 }
index 76f0dbd62f93737b0a8c70cc5eb464932932e9bd..2ae91c649046bb45f694d15eca40a1dbc57955e2 100644 (file)
@@ -10,7 +10,6 @@
  *     PARC     initial implementation 
  * ******************************************************************/
 
-
 package org.aspectj.weaver;
 
 import java.io.File;
@@ -20,90 +19,80 @@ import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.bridge.SourceLocation;
 
 public class SourceContextImpl implements ISourceContext {
-       
-//     private AbstractReferenceTypeDelegate delegate;
+
        private int[] lineBreaks;
-       String sfname;
-       
+       String sourceFilename;
+
        public SourceContextImpl(AbstractReferenceTypeDelegate delegate) {
-//             this.delegate = delegate;
-               sfname = delegate.getSourcefilename();
+               sourceFilename = delegate.getSourcefilename();
        }
-       
-       public void configureFromAttribute(String name,int []linebreaks) { 
-//             this.delegate.setSourcefilename(name);
-               sfname = name;
+
+       public void configureFromAttribute(String name, int[] linebreaks) {
+               this.sourceFilename = name;
                this.lineBreaks = linebreaks;
        }
-       
+
        public void setSourceFileName(String name) {
-               sfname = name;
+               sourceFilename = name;
        }
-       
+
        private File getSourceFile() {
-               return new File(sfname);
-//             return new File(delegate.getSourcefilename());
+               return new File(sourceFilename);
        }
-       
-       public void tidy() {}
-       
-       public int getOffset() { return 0; }
-               
-               /*
-               // AMC - a temporary "fudge" to give as much information as possible about the identity of the
-               // source file this source location points to.
-               String internalClassName = getEnclosingClass().getInternalClassName();
-               String fileName = getEnclosingClass().getFileName();
-               String extension = fileName.substring( fileName.lastIndexOf("."), fileName.length());
-               String filePrefix = fileName.substring( 0, fileName.lastIndexOf("."));
-               // internal class name is e.g. figures/Point, we don't know whether the file was
-               // .aj or .java so we put it together with the file extension of the enclosing class
-               // BUT... sometimes internalClassName is a different class (an aspect), so we only use it if it 
-               // matches the file name.
-               String mostAccurateFileNameGuess;
-               if ( internalClassName.endsWith(filePrefix)) {
-                       mostAccurateFileNameGuess = internalClassName + extension;
-               } else {
-                       mostAccurateFileNameGuess = fileName;
-               }
-               return new SourceLocation(new File(mostAccurateFileNameGuess), getSourceLine());
-               */
 
+       public void tidy() {
+       }
 
+       public int getOffset() {
+               return 0;
+       }
 
        public ISourceLocation makeSourceLocation(IHasPosition position) {
                if (lineBreaks != null) {
                        int line = Arrays.binarySearch(lineBreaks, position.getStart());
-                       if (line < 0) line = -line;
-                       return new SourceLocation(getSourceFile(), line); //??? have more info
+                       if (line < 0) {
+                               line = -line;
+                       }
+                       return new SourceLocation(getSourceFile(), line); // ??? have more info
                } else {
                        return new SourceLocation(getSourceFile(), 0);
                }
        }
-       
+
        public ISourceLocation makeSourceLocation(int line, int offset) {
-        if (line < 0) line = 0;
+               if (line < 0) {
+                       line = 0;
+               }
                SourceLocation sl = new SourceLocation(getSourceFile(), line);
-        if (offset > 0) {
-            sl.setOffset(offset);
-        } else {
-            if (lineBreaks != null) {
-                int likelyOffset = 0;
-                if (line > 0 && line < lineBreaks.length) {
-                    //1st char of given line is next char after previous end of line
-                    likelyOffset = lineBreaks[line-1] + 1;
-                }
-                sl.setOffset(likelyOffset);
-            }
-        }
-        return sl;
+               if (offset > 0) {
+                       sl.setOffset(offset);
+               } else {
+                       if (lineBreaks != null) {
+                               int likelyOffset = 0;
+                               if (line > 0 && line < lineBreaks.length) {
+                                       // 1st char of given line is next char after previous end of line
+                                       likelyOffset = lineBreaks[line - 1] + 1;
+                               }
+                               sl.setOffset(likelyOffset);
+                       }
+               }
+               return sl;
        }
 
-
        public final static ISourceContext UNKNOWN_SOURCE_CONTEXT = new ISourceContext() {
-               public ISourceLocation makeSourceLocation(IHasPosition position) {return null;}
-               public ISourceLocation makeSourceLocation(int line, int offset) {return null;}
-               public int getOffset() {return 0;}
-               public void tidy() {}
+               public ISourceLocation makeSourceLocation(IHasPosition position) {
+                       return null;
+               }
+
+               public ISourceLocation makeSourceLocation(int line, int offset) {
+                       return null;
+               }
+
+               public int getOffset() {
+                       return 0;
+               }
+
+               public void tidy() {
+               }
        };
 }