Re: [abc-users] ABC Error during compile - Please HELP!

From: Eric Bodden <eric.bodden@mail.mcgill.ca>
Date: Fri Jun 22 2007 - 18:58:24 BST

You do not weave in to SavingsAccount. You should read the command
line options, specifically the option -inpath.

http://abc.comlab.ox.ac.uk/dists/1.0.2/files/doc/usage.pdf

Eric

On 22/06/07, Fayezin <nitrousfiz@googlemail.com> wrote:
> Hello,
>
> I am trying to compile a few aspectj files. I get the following errors -
>
> 1. MinimumBalanceRuleAspect.java:23: Host of an intertype declaration must
> be a weavable class
> 2. Benchmark.java:28: Could not find field or local variable "inFile"
> 3. cc.java:55: Could not find field or local variable "counter".
> 4. MSTPrim.java:49: Ambiguous reference to pred - multiple fields in
> GPL.Vertex
>
> I get more similar errors with other files. I have given each only different
> errors above.
>
> Does it have anything to do with loadtime or compile time weaving?
> Can anyone please help me to understand why there errors have occurred?
>
> The aspectj files are given below. The command I am using to run the file is
> -
> C:\Programs\abc\abc.bat -cp
> ".;D:\Subjects\aosdsubjects;C:\Programs\abc\lib\abc-complete.jar;C:\jdk1.5.0_07\jre\lib\jce.jar;C:\jdk1.5.0_07\jre\lib\jsse.jar;C:\jdk1.5.0_07\jre\lib\rt.jar;C:\Masters_Project\source\lib\junit.jar"
> -d D:\Subjects\aosdsubjects\abc_output GPL\MSTPrim.java
>
>
> Waiting for your help.
>
> Thanks,
>
> Fayezin
>
>
> ================================================
> MinimumBalanceRuleAspect.java
> ================================================
>
>
> //Listing 12.11 An aspect that implements the rule for enforcing a minimum
> balance
>
> package account;
>
>
> public aspect MinimumBalanceRuleAspect
> /*extends AbstractDebitRulesAspect*/ {
>
> /*
> public float SavingsAccount.getAvailableBalance() {
> return getBalance();
> }
> */
>
> public pointcut debitExecution(SavingsAccount account,
> float withdrawalAmount)
> : execution(void SavingsAccount.debit(float)
> throws InsufficientBalanceException)
> && this(account) && args(withdrawalAmount);
>
> private static final float MINIMUM_BALANCE_REQD = 25;
>
> public float SavingsAccount.getAvailableBalance() {
> return getBalance() - MINIMUM_BALANCE_REQD;
> }
>
> pointcut savingsDebitExecution(SavingsAccount account,
> float withdrawalAmount)
> : debitExecution(account, withdrawalAmount)
> && this(SavingsAccount);
>
> before(SavingsAccount account, float withdrawalAmount)
> throws InsufficientBalanceException
> : savingsDebitExecution(account, withdrawalAmount) {
> if (account.getAvailableBalance() < withdrawalAmount) {
> throw new InsufficientBalanceException(
> "Minimum balance condition not met");
> }
> }
> }
>
>
>
>
> ================================================
> Benchmark.java
> ================================================
>
>
> // Benchmark.java aspect
> // GPL using AspectJ
> // Roberto E. Lopez-Herrejon
> // Product-Line Architecture Research Lab
> // Department of Computer Sciences
> // University of Texas at Austin
> // Last update: May 3, 2002
>
> package GPL;
>
> import java.util.LinkedList;
> import java.io.*;
>
> public aspect Benchmark
> {
> //
> ****************************************************************
> // **** Graph
> public Reader Graph.inFile; // File handler for reading
> public static int Graph.ch; // Character to read/write
>
> // timings
> static long Graph.last=0;
> static long Graph.current=0;
> static long Graph.accum=0;
>
> public void GPL.Graph.runBenchmark (String FileName) throws IOException
> {
> try {
> inFile = new FileReader(FileName);
> } catch (IOException e) {
> System.out.println("Your file " + FileName + " cannot be read");
> }
> }
>
> public void Graph.stopBenchmark() throws IOException {
> inFile.close();
> }
>
> public int Graph.readNumber() throws IOException {
> int index =0;
> char[] word = new char[80];
> int ch=0;
>
> ch = inFile.read();
> while(ch==32) ch = inFile.read(); // skips extra whitespaces
>
> while(ch!=-1 && ch!=32 && ch!=10) // while it is not EOF, WS, NL
> {
> word[index++] = (char)ch;
> ch = inFile.read();
> }
> word[index]=0;
>
> String theString = new String(word);
>
> theString = new String(theString.substring(0,index));
> return Integer.parseInt(theString,10);
> }
>
> public static void Graph.startProfile() {
> accum = 0;
> current = System.currentTimeMillis();
> last = current;
> }
>
> public static void Graph.stopProfile() {
> current = System.currentTimeMillis ();
> accum = accum + (current - last);
> }
>
> public static void Graph.resumeProfile() {
> current = System.currentTimeMillis();
> last = current;
> }
>
> public static void Graph.endProfile () {
> current = System.currentTimeMillis();
> accum = accum + (current-last);
> System.out.println("Time elapsed: " + accum + " milliseconds");
> }
>
> }
>
>
> ================================================
> cc.java
> ================================================
>
>
> // CC.java ConnectedComponents aspect
> // GPL using AspectJ
> // Roberto E. Lopez-Herrejon
> // Product-Line Architecture Research Lab
> // Department of Computer Sciences
> // University of Texas at Austin
> // Last update: May 3, 2002
>
> package GPL;
>
> import java.util.LinkedList;
>
> public aspect CC
> {
> //
> *****************************************************************
> // **** Graph class
> // Executes Strongly Connected Components
> // A point cut to calls to Graph run
> // Gets the pointcuts of the target that call run
> pointcut graph_run(Graph g, Vertex v): target(g) && args(v) &&
> call(void Graph.run(Vertex));
>
> // An after advice to run Vertex Numbering
> after(Graph g, Vertex v): graph_run(g,v) {
> MyLog.println("Running Connected Components ");
> g.ConnectedComponents();
> }
>
> // Runs the connected components
> public void Graph.ConnectedComponents() {
> GraphSearch( new RegionWorkSpace());
> }
>
> //
> *****************************************************************
> // **** Vertex class
> public int Vertex.componentNumber;
>
> // A point cut to calls to Vertex.display, originally overriden
> // Gets the pointcuts of the targets that call display of a Vertex
> pointcut vertex_display(Vertex v): target(v) &&
> call(void Vertex.display());
>
> // A before advice to display the vertex number
> before(Vertex v): vertex_display(v) {
> MyLog.print(" comp# "+ v.componentNumber + " ");
> }
>
> //
> *****************************************************************
> // **** RegionWorkspace class extends the WorkSpace class
> declare parents: RegionWorkSpace extends WorkSpace;
>
> public int RegionWorkSpace.counter;
>
> public RegionWorkSpace.new() {
> counter = 0;
> }
>
> public void RegionWorkSpace.init_vertex(Vertex v ) {
> v.componentNumber = -1;
> }
>
> public void RegionWorkSpace.postVisitAction(Vertex v ) {
> v.componentNumber = counter;
> }
>
> public void RegionWorkSpace.nextRegionAction(Vertex v )
> {
> counter ++;
> }
>
> } // Connected Components aspect
>
>
>
>
>
> ================================================
> MSTPrim.java
> ================================================
>
>
> // MSTPrim.java aspect
> // GPL using AspectJ
> // Roberto E. Lopez-Herrejon
> // Product-Line Architecture Research Lab
> // Department of Computer Sciences
> // University of Texas at Austin
> // Last update: May 3, 2002
>
> package GPL;
>
> import java.util.LinkedList;
> import java.lang.Integer;
> import java.util.Collections;
> import java.util.Comparator;
>
> public aspect MSTPrim
> {
>
> //
> ******************************************************************
> // **** Graph class
> // Executes Strongly Connected Components
> // A point cut to calls to Graph run
> // Gets the pointcuts of the target that call run
> pointcut graph_run(Graph g, Vertex v): target(g) && args(v) &&
> call(void Graph.run(Vertex));
>
> // An after advice to run Vertex Numbering
> after(Graph g, Vertex v): graph_run(g,v) {
> System.out.println("Running MST Prim ");
> Graph gaux = g.Prim(v);
> g.stopProfile();
> if (MyLog.dumpgraph) gaux.display();
> g.resumeProfile();
> }
>
> // Computes the strongly connected components
> public Graph Graph.Prim(Vertex r) {
> Vertex root;
>
> root = r;
> int numvertices = vertices.size();
> int i;
> Vertex x;
>
> // 2. and 3. Initializes the vertices
> for (i=0; i < numvertices; i++)
> {
> x = (Vertex)vertices.get(i);
> x.pred = null;
> x.key = Integer.MAX_VALUE;
> }
>
> // 4. and 5.
> root.key = 0;
> root.pred = null;
>
> // 2. S <- empty set
>
> // 1. Queue <- V[G], copy the vertex in the graph in the priority queue
> LinkedList Queue = new LinkedList();
>
> for(i=0; i < numvertices; i++)
> {
> x = (Vertex)vertices.get(i);
> if (x.key != 0) // this means, if this is not the root
> Queue.add(x);
> }
>
> // Inserts the root at the head of the queue
> Queue.addFirst(root);
>
> // 6. while Q!=0
> Vertex ucurrent;
> int j,k,l;
> int pos;
> LinkedList Uneighbors;
> Vertex u,v;
> Edge en;
> Neighbor vn;
>
> int wuv;
> boolean isNeighborInQueue = false;
>
> // Queue is a list ordered by key values.
> // At the beginning all key values are INFINITUM except
> // for the root whose value is 0.
> while (Queue.size()!=0)
> {
> // 7. u <- Extract-Min(Q);
> // Since this is an ordered queue the first element is the min
> u = (Vertex)Queue.removeFirst();
>
> // 8. for each vertex v adjacent to u
> Uneighbors = u.neighbors;
>
> for(k=0; k < Uneighbors.size(); k++)
> {
> vn = (Neighbor)Uneighbors.get(k);
> v = vn.end;
> en = vn.edge;
>
> // Check to see if the neighbor is in the queue
> isNeighborInQueue = false;
>
> // if the Neighor is in the queue
> int indexNeighbor = Queue.indexOf(v);
> if (indexNeighbor>=0) isNeighborInQueue=true;
>
> wuv = en.weight;
>
> // 9. Relax (u,v w)
> if (isNeighborInQueue && (wuv < v.key))
> {
> v.key = wuv;
> v.pred = u.name;
> Uneighbors.set(k,vn); // adjust values in the neighbors
>
> // update the values of v in the queue
> // Remove v from the Queue so that we can reinsert it
> // in a new place according to its new value to keep
> // the Linked List ordered
> Object residue = Queue.remove(indexNeighbor);
>
> // Get the new position for v
> int position = Collections.binarySearch(Queue,v,
> new Comparator()
> {
> public int compare (Object o1, Object o2)
> {
> Vertex v1 = (Vertex)o1;
> Vertex v2 = (Vertex)o2;
>
> if (v1.key < v2.key)
> return -1;
> if ( v1.key == v2.key)
> return 0;
> return 1;
> }
> });
>
> // Adds v in its new position in Queue
> if (position < 0) // means it is not there
> { Queue.add(-(position+1),v); }
> else // means it is there
> { Queue.add(position,v); }
>
> } // if 8-9.
> } // for all neighbors
> } // of while
>
> // Creates the new Graph that contains the SSSP
> String theName;
> Graph newGraph = new Graph();
>
> // Creates and adds the vertices with the same name
> for (i=0; i<numvertices; i++)
> {
> theName = ((Vertex)vertices.get(i)).name;
> newGraph.addVertex(new Vertex(theName));
> }
>
> // Creates the edges from the NewGraph
> Vertex theVertex, thePred;
> Vertex theNewVertex, theNewPred;
> Edge e;
>
> // For each vertex in vertices list we find its predecessor
> // make an edge for the new graph from predecessor->vertex
> for(i=0; i<numvertices; i++)
> {
> // theVertex and its Predecessor
> theVertex = (Vertex)vertices.get(i);
> thePred = findsVertex(theVertex.pred);
>
> // if theVertex is the source then continue we dont need
> // to create a new edge at all
> if (thePred==null) continue;
>
> // Find the references in the new Graph
> theNewVertex = newGraph.findsVertex(theVertex.name);
> theNewPred = newGraph.findsVertex(thePred.name);
>
> // Creates the new edge from predecessor -> vertex in the newGraph
> // and ajusts the adorns based on the old edge
> Edge theNewEdge = new Edge(theNewPred, theNewVertex);
> e = findsEdge(thePred,theVertex);
> theNewEdge.adjustAdorns(e);
>
> // Adds the new edge to the newGraph
> newGraph.addEdge(theNewEdge);
> }
> return newGraph;
>
> } // end of Prim
>
> //
> ***************************************************************
> // **** Vertex class
> public String Vertex.pred; // the predecessor vertex if any
> public int Vertex.key; // weight so far from s to it
>
> // A point cut to calls to Vertex.display
> // Gets the pointcuts of the targets that call display of a Vertex
> pointcut vertex_display(Vertex v): target(v) &&
> call(void Vertex.display());
>
> // A before advice to display the vertex number
> before(Vertex v): vertex_display(v) {
> MyLog.print(" Pred " + v.pred + " Key " + v.key + " ");
> }
>
> } // end of MSTPrim
>

-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
Received on Fri Jun 22 18:58:30 2007

This archive was generated by hypermail 2.1.8 : Sat Jun 23 2007 - 00:50:11 BST