Example #1
0
 /// <summary>
 /// Imports a BiGramCollection from disk
 /// </summary>
 /// <param name="filename">Input file</param>
 /// <returns>BiGram collection</returns>
 public static BiGramCollection Import(string filename)
 {
     TextReader file = new StreamReader(filename);
     BiGramCollection bigrams = new BiGramCollection();
     int lineNumber = 0;
     string line;
     while ((line = file.ReadLine()) != null)
     {
         lineNumber++;
         if (String.IsNullOrWhiteSpace(line))
             continue;
         string caller, callee;
         try
         {
             string[] split = line.Split('\t');
             caller = split[0];
             callee = split[1];
         }
         catch (IndexOutOfRangeException e)
         {
             throw new DevelopmentKitException("Error in bigram file format on line " + lineNumber, e);
         }
         bigrams.Add(new BiGram(caller, callee));
     }
     return bigrams;
 }
Example #2
0
        /// <summary>
        /// Imports a BiGramCollection from disk
        /// </summary>
        /// <param name="filename">Input file</param>
        /// <returns>BiGram collection</returns>
        public static BiGramCollection Import(string filename)
        {
            TextReader       file    = new StreamReader(filename);
            BiGramCollection bigrams = new BiGramCollection();
            int    lineNumber        = 0;
            string line;

            while ((line = file.ReadLine()) != null)
            {
                lineNumber++;
                if (String.IsNullOrWhiteSpace(line))
                {
                    continue;
                }
                string caller, callee;
                try
                {
                    string[] split = line.Split('\t');
                    caller = split[0];
                    callee = split[1];
                }
                catch (IndexOutOfRangeException e)
                {
                    throw new DevelopmentKitException("Error in bigram file format on line " + lineNumber, e);
                }
                bigrams.Add(new BiGram(caller, callee));
            }
            return(bigrams);
        }
Example #3
0
        /// <summary>
        /// Generates a BiGramCollection from a file
        /// </summary>
        /// <param name="filename">Input file</param>
        /// <returns>BiGram collection</returns>
        public static BiGramCollection GenerateBiGrams(string filename)
        {
            TextReader       brTrace = new StreamReader(filename);
            BiGramCollection bigrams = new BiGramCollection();

            int lineNumber = 0;
            Dictionary <string, string> idToClass  = new Dictionary <string, string>();
            Dictionary <string, string> idToMethod = new Dictionary <string, string>();
            // Stack<methodID>
            Dictionary <string, Stack <string> > threadToMethodsStackTranslator = new Dictionary <string, Stack <string> >();
            string currentLine;

            while ((currentLine = brTrace.ReadLine()) != null)
            {
                lineNumber++;
                string[] traceLineSplit;
                // classDef
                if (currentLine.StartsWith("<classDef "))
                {
                    traceLineSplit = currentLine.Split(' ');
                    if (traceLineSplit[1].StartsWith("name=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[2].StartsWith("sourceName=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[3].StartsWith("classId=") == false)
                    {
                        throw new Exception();
                    }
                    string name    = ExtractValueFromQuotes(traceLineSplit[1]);
                    string classID = ExtractValueFromQuotes(traceLineSplit[3]);
                    //System.out.println(classID+"\t"+name);
                    idToClass.Add(classID, name);
                    continue;
                }
                // methodDef
                if (currentLine.StartsWith("<methodDef "))
                {
                    traceLineSplit = currentLine.Split(' ');
                    if (traceLineSplit[1].StartsWith("name=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[2].StartsWith("signature=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[3].StartsWith("startLineNumber=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[4].StartsWith("endLineNumber=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[5].StartsWith("methodId=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[6].StartsWith("classIdRef=") == false)
                    {
                        throw new Exception();
                    }
                    string name      = ExtractValueFromQuotes(traceLineSplit[1]);
                    string signature = ExtractValueFromQuotes(traceLineSplit[2]);
                    string methodID  = ExtractValueFromQuotes(traceLineSplit[5]);
                    string classID   = ExtractValueFromQuotes(traceLineSplit[6]);
                    //System.out.println("#"+name+"\t"+signature+"\t"+methodID+"\t"+classID);
                    //leave all the names in; the methods that are not in the corpus will be eliminated because they will not have an ID
                    if (name.Equals("-init-"))
                    {
                        string fullClassName = idToClass[classID];
                        //System.out.println("\tfullClassName="+fullClassName);
                        string className = fullClassName.Substring(fullClassName.LastIndexOf("/") + 1);
                        // remove "outer" classes from inner classes
                        if (className.IndexOf("$") > 0)
                        {
                            //System.out.println(currentLine);
                            className = className.Substring(className.LastIndexOf("$") + 1);
                        }
                        name = className;
                        //System.out.println("\tclassName="+className);
                        //System.out.println("\tname="+name);
                    }
                    if (name.EndsWith("$"))
                    {
                        name = name.Substring(0, name.LastIndexOf("$"));
                    }
                    string fullMethodName = idToClass[classID] + "#" + name;
                    fullMethodName = fullMethodName.Replace('/', '.');
                    fullMethodName = fullMethodName.Replace('#', '.');
                    fullMethodName = fullMethodName.Replace('$', '.');
                    //System.out.println("MethodName="+fullMethodName);
                    idToMethod.Add(methodID, fullMethodName);
                    continue;
                }
                // methodEntry
                if (currentLine.StartsWith("<methodEntry "))
                {
                    traceLineSplit = currentLine.Split(' ');
                    if (traceLineSplit[1].StartsWith("threadIdRef=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[2].StartsWith("time=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[3].StartsWith("methodIdRef=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[4].StartsWith("classIdRef=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[5].StartsWith("ticket=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[6].StartsWith("stackDepth=") == false)
                    {
                        throw new Exception();
                    }
                    string threadID      = ExtractValueFromQuotes(traceLineSplit[1]);
                    string methodIDTrace = ExtractValueFromQuotes(traceLineSplit[3]);
                    //Stack<PairMethodIDTraceMethodIDCorpus> currentThreadMethodsStack=threadToMethodsStackTranslator.get(threadID);
                    if (!threadToMethodsStackTranslator.ContainsKey(threadID))
                    {
                        threadToMethodsStackTranslator.Add(threadID, new Stack <string>());
                    }

                    //string fullMethodName = idToMethod[methodIDTrace];
                    //string IDCorpusForFullMethodName = inputOutput.getPositionOfMethodMappingInCorpus(fullMethodName);

                    //PairMethodIDTraceMethodIDCorpus parentMethod=null;
                    string parentMethodID = null;
                    try
                    {
                        parentMethodID = threadToMethodsStackTranslator[threadID].Peek();
                    }
                    catch (InvalidOperationException)
                    {
                        // stack is empty
                        // do nothing, we will be adding childMethodID
                    }

                    //PairMethodIDTraceMethodIDCorpus childMethod=new PairMethodIDTraceMethodIDCorpus(methodIDTrace,fullMethodName,IDCorpusForFullMethodName);
                    //string childMethod = fullMethodName;
                    string childMethodID = methodIDTrace;
                    threadToMethodsStackTranslator[threadID].Push(childMethodID);

                    if (threadToMethodsStackTranslator[threadID].Count == 1)
                    {
                        //if its only 1 element, it couldn't have been called by anything
                        continue;
                    }

                    //if (parentMethod.methodIDCorpus.equals("-1")||childMethod.methodIDCorpus.equals("-1"))
                    if (String.IsNullOrWhiteSpace(parentMethodID) || String.IsNullOrWhiteSpace(childMethodID))
                    {
                        continue;
                    }

                    if (idToMethod[parentMethodID].EndsWith(".class") ||
                        idToMethod[parentMethodID].EndsWith(".-clinit-") ||
                        idToMethod[parentMethodID].EndsWith(".1") ||
                        idToMethod[parentMethodID].Contains(".1.")
                        )
                    {
                        continue;
                    }

                    if (idToMethod[childMethodID].EndsWith(".class") ||
                        idToMethod[childMethodID].EndsWith(".-clinit-") ||
                        idToMethod[childMethodID].EndsWith(".1") ||
                        idToMethod[childMethodID].Contains(".1.")
                        )
                    {
                        continue;
                    }

                    //do not add "recursive calls". This is due to the fact that these are calls between overwritten methods
                    if (parentMethodID.Equals(childMethodID) || idToMethod[parentMethodID].Equals(idToMethod[childMethodID]))
                    {
                        continue;
                    }

                    bigrams.Add(new BiGram(idToMethod[parentMethodID], idToMethod[childMethodID]));
                    continue;
                }
                // methodExit
                if (currentLine.StartsWith("<methodExit "))
                {
                    traceLineSplit = currentLine.Split(' ');
                    if (traceLineSplit[1].StartsWith("threadIdRef=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[2].StartsWith("methodIdRef=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[3].StartsWith("classIdRef=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[4].StartsWith("ticket=") == false)
                    {
                        throw new Exception();
                    }
                    if (traceLineSplit[5].StartsWith("time=") == false)
                    {
                        throw new Exception();
                    }

                    string threadID      = ExtractValueFromQuotes(traceLineSplit[1]);
                    string methodIDTrace = ExtractValueFromQuotes(traceLineSplit[2]);

                    //Stack<PairMethodIDTraceMethodIDCorpus> currentThreadMethodsStack=threadToMethodsStackTranslator.get(threadID);
                    string topOfStack = threadToMethodsStackTranslator[threadID].Peek();
                    if (topOfStack.Equals(methodIDTrace) == false)
                    {
                        throw new Exception(currentLine + "\r\n" + threadToMethodsStackTranslator[threadID]);
                    }
                    threadToMethodsStackTranslator[threadID].Pop();

                    continue;
                }
            }
            brTrace.Close();
            return(bigrams);
        }
Example #4
0
        /// <summary>
        /// Generates a BiGramCollection from a file,
        /// ignoring methods that do not appear in the given set
        /// </summary>
        /// <param name="filename">Input file</param>
        /// <param name="includeOnly">Set of methods to include</param>
        /// <returns>BiGram collection</returns>
        public static BiGramCollection GenerateBiGrams(string filename, ISet <string> includeOnly)
        {
            TextReader       traceFile = new StreamReader(filename);
            BiGramCollection bigrams   = new BiGramCollection();
            Dictionary <string, List <string> > threadToMethodsStackTranslator = new Dictionary <string, List <string> >();
            int    lineNumber = 0;
            string line;

            while ((line = traceFile.ReadLine()) != null)
            {
                lineNumber++;

                if (line.Equals("-- VM Started --"))
                {
                    continue;
                }
                if (line.Equals("m-- VM Started --"))
                {
                    continue;
                }
                if (line.Equals("-- The application exited --"))
                {
                    continue;
                }
                if (line.Length == 1)
                {
                    continue;
                }

                string[] traceLineSplit = line.Split('\t');

                if (traceLineSplit.Length >= 3)
                {
                    throw new DevelopmentKitException("Error at line " + lineNumber + ": " + line);
                }

                if (traceLineSplit[1][0] == '=')
                {
                    // do nothing. This is a report line like ===== main =====
                    continue;
                }

                String threadName = traceLineSplit[0].Substring(0, traceLineSplit[0].IndexOf(':'));
//					if (threadName.equals("org.eclipse.jdt.internal.ui.text.JavaReconciler"))
//					{
//						continue;
//					}

                if (!threadToMethodsStackTranslator.ContainsKey(threadName))
                {
                    threadToMethodsStackTranslator.Add(threadName, new List <string>());
                }

                int numberOfPipes = 0;
                // count number of pipes "|"
                for (int i = 0; i < traceLineSplit[0].Length; i++)
                {
                    if (traceLineSplit[0][i] == '|')
                    {
                        numberOfPipes++;
                    }
                }

                string[] buf        = traceLineSplit[1].Split(new string[] { "  --  " }, StringSplitOptions.None);
                string   methodName = buf[0];
                string   methodPath = buf[1];

                //leave method names like method14, but eliminate everything after a dollar (e.g., method$1)
                int indexOfDollar = methodName.IndexOf('$');
                if (indexOfDollar >= 0)
                {
//						System.out.print(methodName+"->");
                    methodName = methodName.Substring(0, indexOfDollar);
//						System.out.println(methodName);
                }

                indexOfDollar = methodPath.IndexOf('$');
                if (indexOfDollar >= 0)
                {
//						System.out.print(methodPath+"->");
                    methodPath = methodPath.Replace('$', '.');
//						methodPath=methodPath.substring(0,indexOfDollar);
//						System.out.println(methodPath);
                }

                if (methodName.Equals("<init>"))
                {
//						System.out.print("<init>"+"->");
                    methodName = methodPath.Substring(methodPath.LastIndexOf(".") + 1);
//						System.out.println(methodName);
                }

                if (methodName.Equals("<clinit>"))
                {
//						System.out.print("<cinit>"+"->");
                    methodName = methodPath.Substring(methodPath.LastIndexOf(".") + 1);
//						System.out.println(methodName);
                }

                if (numberOfPipes == 0)
                {
                    threadToMethodsStackTranslator[threadName].Clear();
                    string fullMethodName = methodPath + "." + methodName;
                    //string IDFullMethodName = inputOutput.getPositionOfMethodMappingInCorpus(fullMethodName);

                    threadToMethodsStackTranslator[threadName].Insert(numberOfPipes, fullMethodName);
                    //if its 0, it couldn't have been called by anything
                    continue;
                }

                while (threadToMethodsStackTranslator[threadName].Count > numberOfPipes)
                {
                    threadToMethodsStackTranslator[threadName].RemoveAt(numberOfPipes);
                }

//					if (threadName.equals("org.eclipse.jdt.internal.ui.text.JavaReconciler"))
//					{
//						//code to deal with the Reconciler thread which sometimes has methods that start with 20-30 pipes and the size of the stack traces is less than that
//						//solution: add an unknownMethod
//
//						if (currentThreadMethodsStack.size()<numberOfPipes)
//						{
//							int numberOfUnknownMethodsToAdd=numberOfPipes-currentThreadMethodsStack.size();
//							for (int i=0;i<numberOfUnknownMethodsToAdd;i++)
//								currentThreadMethodsStack.add("orgeclipsejdtinternaluitextjavareconciler#unknownMethod");
//						}
//					}

                if (threadToMethodsStackTranslator[threadName].Count < numberOfPipes)
                {
//					numberOfInconsistencies++;
//						System.out.println(currentLine);
                    continue;
                }
                string fullMethodName2 = methodPath + "." + methodName;
                //String IDFullMethodName=inputOutput.getPositionOfMethodMappingInCorpus(fullMethodName);
                threadToMethodsStackTranslator[threadName].Insert(numberOfPipes, fullMethodName2);

                string parentMethod = threadToMethodsStackTranslator[threadName][numberOfPipes - 1];
                string childMethod  = threadToMethodsStackTranslator[threadName][numberOfPipes];
                //if (parentMethod.id.equals("-1")||childMethod.id.equals("-1"))
                //	continue;

                if (includeOnly != null)
                {
                    if (!includeOnly.Contains(parentMethod))
                    {
                        //Console.WriteLine(String.Format("includeOnly.Contains({0}): {1}", parentMethod, includeOnly.Contains(parentMethod)));
                        //Console.WriteLine("Ignoring parent: " + parentMethod);
                        continue;
                    }
                    if (!includeOnly.Contains(childMethod))
                    {
                        //Console.WriteLine("Ignoring child: " + childMethod);
                        continue;
                    }
                }

                bigrams.Add(new BiGram(parentMethod, childMethod));
            }

            traceFile.Close();
            return(bigrams);
        }
Example #5
0
        /// <summary>
        /// Generates a BiGramCollection from a file,
        /// ignoring methods that do not appear in the given set
        /// </summary>
        /// <param name="filename">Input file</param>
        /// <param name="includeOnly">Set of methods to include</param>
        /// <returns>BiGram collection</returns>
        public static BiGramCollection GenerateBiGrams(string filename, ISet<string> includeOnly)
        {
            TextReader traceFile = new StreamReader(filename);
            BiGramCollection bigrams = new BiGramCollection();
            Dictionary<string, List<string>> threadToMethodsStackTranslator = new Dictionary<string, List<string>>();
            int lineNumber = 0;
            string line;
            while ((line = traceFile.ReadLine()) != null)
            {
                lineNumber++;

                if (line.Equals("-- VM Started --"))
                    continue;
                if (line.Equals("m-- VM Started --"))
                    continue;
                if (line.Equals("-- The application exited --"))
                    continue;
                if (line.Length == 1)
                    continue;

                string[] traceLineSplit = line.Split('\t');

                if (traceLineSplit.Length >= 3)
                {
                    throw new DevelopmentKitException("Error at line " + lineNumber + ": " + line);
                }

                if (traceLineSplit[1][0] == '=')
                {
                    // do nothing. This is a report line like ===== main =====
                    continue;
                }

                String threadName = traceLineSplit[0].Substring(0, traceLineSplit[0].IndexOf(':'));
            //					if (threadName.equals("org.eclipse.jdt.internal.ui.text.JavaReconciler"))
            //					{
            //						continue;
            //					}

                if (!threadToMethodsStackTranslator.ContainsKey(threadName))
                {
                    threadToMethodsStackTranslator.Add(threadName, new List<string>());
                }

                int numberOfPipes = 0;
                // count number of pipes "|"
                for (int i = 0; i < traceLineSplit[0].Length; i++)
                {
                    if (traceLineSplit[0][i] == '|')
                    {
                        numberOfPipes++;
                    }
                }

                string[] buf = traceLineSplit[1].Split(new string[] {"  --  "}, StringSplitOptions.None);
                string methodName = buf[0];
                string methodPath = buf[1];

                //leave method names like method14, but eliminate everything after a dollar (e.g., method$1)
                int indexOfDollar = methodName.IndexOf('$');
                if (indexOfDollar >= 0)
                {
            //						System.out.print(methodName+"->");
                    methodName = methodName.Substring(0, indexOfDollar);
            //						System.out.println(methodName);
                }

                indexOfDollar = methodPath.IndexOf('$');
                if (indexOfDollar >= 0)
                {
            //						System.out.print(methodPath+"->");
                    methodPath = methodPath.Replace('$','.');
            //						methodPath=methodPath.substring(0,indexOfDollar);
            //						System.out.println(methodPath);
                }

                if (methodName.Equals("<init>"))
                {
            //						System.out.print("<init>"+"->");
                    methodName=methodPath.Substring(methodPath.LastIndexOf(".") + 1);
            //						System.out.println(methodName);
                }

                if (methodName.Equals("<clinit>"))
                {
            //						System.out.print("<cinit>"+"->");
                    methodName=methodPath.Substring(methodPath.LastIndexOf(".") + 1);
            //						System.out.println(methodName);
                }

                if (numberOfPipes == 0)
                {
                    threadToMethodsStackTranslator[threadName].Clear();
                    string fullMethodName = methodPath + "." + methodName;
                    //string IDFullMethodName = inputOutput.getPositionOfMethodMappingInCorpus(fullMethodName);

                    threadToMethodsStackTranslator[threadName].Insert(numberOfPipes, fullMethodName);
                    //if its 0, it couldn't have been called by anything
                    continue;
                }

                while (threadToMethodsStackTranslator[threadName].Count > numberOfPipes)
                {
                    threadToMethodsStackTranslator[threadName].RemoveAt(numberOfPipes);
                }

            //					if (threadName.equals("org.eclipse.jdt.internal.ui.text.JavaReconciler"))
            //					{
            //						//code to deal with the Reconciler thread which sometimes has methods that start with 20-30 pipes and the size of the stack traces is less than that
            //						//solution: add an unknownMethod
            //
            //						if (currentThreadMethodsStack.size()<numberOfPipes)
            //						{
            //							int numberOfUnknownMethodsToAdd=numberOfPipes-currentThreadMethodsStack.size();
            //							for (int i=0;i<numberOfUnknownMethodsToAdd;i++)
            //								currentThreadMethodsStack.add("orgeclipsejdtinternaluitextjavareconciler#unknownMethod");
            //						}
            //					}

                if (threadToMethodsStackTranslator[threadName].Count < numberOfPipes)
                {
            //					numberOfInconsistencies++;
            //						System.out.println(currentLine);
                    continue;
                }
                string fullMethodName2 = methodPath + "." + methodName;
                //String IDFullMethodName=inputOutput.getPositionOfMethodMappingInCorpus(fullMethodName);
                threadToMethodsStackTranslator[threadName].Insert(numberOfPipes, fullMethodName2);

                string parentMethod = threadToMethodsStackTranslator[threadName][numberOfPipes - 1];
                string childMethod = threadToMethodsStackTranslator[threadName][numberOfPipes];
                //if (parentMethod.id.equals("-1")||childMethod.id.equals("-1"))
                //	continue;

                if (includeOnly != null)
                {
                    if (!includeOnly.Contains(parentMethod))
                    {
                        //Console.WriteLine(String.Format("includeOnly.Contains({0}): {1}", parentMethod, includeOnly.Contains(parentMethod)));
                        //Console.WriteLine("Ignoring parent: " + parentMethod);
                        continue;
                    }
                    if (!includeOnly.Contains(childMethod))
                    {
                        //Console.WriteLine("Ignoring child: " + childMethod);
                        continue;
                    }
                }

                bigrams.Add(new BiGram(parentMethod, childMethod));
            }

            traceFile.Close();
            return bigrams;
        }
Example #6
0
        /// <summary>
        /// Generates a BiGramCollection from a file
        /// </summary>
        /// <param name="filename">Input file</param>
        /// <returns>BiGram collection</returns>
        public static BiGramCollection GenerateBiGrams(string filename)
        {
            TextReader brTrace = new StreamReader(filename);
            BiGramCollection bigrams = new BiGramCollection();

            int lineNumber = 0;
            Dictionary<string, string> idToClass = new Dictionary<string,string>();
            Dictionary<string, string> idToMethod = new Dictionary<string,string>();
            // Stack<methodID>
            Dictionary<string, Stack<string>> threadToMethodsStackTranslator = new Dictionary<string, Stack<string>>();
            string currentLine;

            while ((currentLine = brTrace.ReadLine()) != null)
            {
                lineNumber++;
                string[] traceLineSplit;
                // classDef
                if (currentLine.StartsWith("<classDef "))
                {
                    traceLineSplit = currentLine.Split(' ');
                    if (traceLineSplit[1].StartsWith("name=") == false)
                        throw new Exception();
                    if (traceLineSplit[2].StartsWith("sourceName=") == false)
                        throw new Exception();
                    if (traceLineSplit[3].StartsWith("classId=") == false)
                        throw new Exception();
                    string name = ExtractValueFromQuotes(traceLineSplit[1]);
                    string classID = ExtractValueFromQuotes(traceLineSplit[3]);
                    //System.out.println(classID+"\t"+name);
                    idToClass.Add(classID, name);
                    continue;
                }
                // methodDef
                if (currentLine.StartsWith("<methodDef "))
                {
                    traceLineSplit = currentLine.Split(' ');
                    if (traceLineSplit[1].StartsWith("name=") == false)
                        throw new Exception();
                    if (traceLineSplit[2].StartsWith("signature=") == false)
                        throw new Exception();
                    if (traceLineSplit[3].StartsWith("startLineNumber=") == false)
                        throw new Exception();
                    if (traceLineSplit[4].StartsWith("endLineNumber=") == false)
                        throw new Exception();
                    if (traceLineSplit[5].StartsWith("methodId=") == false)
                        throw new Exception();
                    if (traceLineSplit[6].StartsWith("classIdRef=") == false)
                        throw new Exception();
                    string name = ExtractValueFromQuotes(traceLineSplit[1]);
                    string signature = ExtractValueFromQuotes(traceLineSplit[2]);
                    string methodID = ExtractValueFromQuotes(traceLineSplit[5]);
                    string classID = ExtractValueFromQuotes(traceLineSplit[6]);
                    //System.out.println("#"+name+"\t"+signature+"\t"+methodID+"\t"+classID);
                    //leave all the names in; the methods that are not in the corpus will be eliminated because they will not have an ID
                    if (name.Equals("-init-"))
                    {
                        string fullClassName = idToClass[classID];
                        //System.out.println("\tfullClassName="+fullClassName);
                        string className = fullClassName.Substring(fullClassName.LastIndexOf("/") + 1);
                        // remove "outer" classes from inner classes
                        if (className.IndexOf("$") > 0)
                        {
                            //System.out.println(currentLine);
                            className = className.Substring(className.LastIndexOf("$") + 1);
                        }
                        name = className;
                        //System.out.println("\tclassName="+className);
                        //System.out.println("\tname="+name);
                    }
                    if (name.EndsWith("$"))
                    {
                        name = name.Substring(0, name.LastIndexOf("$"));
                    }
                    string fullMethodName = idToClass[classID] + "#" + name;
                    fullMethodName = fullMethodName.Replace('/', '.');
                    fullMethodName = fullMethodName.Replace('#','.');
                    fullMethodName = fullMethodName.Replace('$','.');
                    //System.out.println("MethodName="+fullMethodName);
                    idToMethod.Add(methodID, fullMethodName);
                    continue;
                }
                // methodEntry
                if (currentLine.StartsWith("<methodEntry "))
                {
                    traceLineSplit = currentLine.Split(' ');
                    if (traceLineSplit[1].StartsWith("threadIdRef=") == false)
                        throw new Exception();
                    if (traceLineSplit[2].StartsWith("time=") == false)
                        throw new Exception();
                    if (traceLineSplit[3].StartsWith("methodIdRef=") == false)
                        throw new Exception();
                    if (traceLineSplit[4].StartsWith("classIdRef=") == false)
                        throw new Exception();
                    if (traceLineSplit[5].StartsWith("ticket=") == false)
                        throw new Exception();
                    if (traceLineSplit[6].StartsWith("stackDepth=") == false)
                        throw new Exception();
                    string threadID = ExtractValueFromQuotes(traceLineSplit[1]);
                    string methodIDTrace = ExtractValueFromQuotes(traceLineSplit[3]);
                    //Stack<PairMethodIDTraceMethodIDCorpus> currentThreadMethodsStack=threadToMethodsStackTranslator.get(threadID);
                    if (!threadToMethodsStackTranslator.ContainsKey(threadID))
                    {
                        threadToMethodsStackTranslator.Add(threadID, new Stack<string>());
                    }

                    //string fullMethodName = idToMethod[methodIDTrace];
                    //string IDCorpusForFullMethodName = inputOutput.getPositionOfMethodMappingInCorpus(fullMethodName);

                    //PairMethodIDTraceMethodIDCorpus parentMethod=null;
                    string parentMethodID = null;
                    try
                    {
                        parentMethodID = threadToMethodsStackTranslator[threadID].Peek();
                    }
                    catch (InvalidOperationException)
                    {
                        // stack is empty
                        // do nothing, we will be adding childMethodID
                    }

                    //PairMethodIDTraceMethodIDCorpus childMethod=new PairMethodIDTraceMethodIDCorpus(methodIDTrace,fullMethodName,IDCorpusForFullMethodName);
                    //string childMethod = fullMethodName;
                    string childMethodID = methodIDTrace;
                    threadToMethodsStackTranslator[threadID].Push(childMethodID);

                    if (threadToMethodsStackTranslator[threadID].Count == 1)
                    {
                        //if its only 1 element, it couldn't have been called by anything
                        continue;
                    }

                    //if (parentMethod.methodIDCorpus.equals("-1")||childMethod.methodIDCorpus.equals("-1"))
                    if (String.IsNullOrWhiteSpace(parentMethodID) || String.IsNullOrWhiteSpace(childMethodID))
                        continue;

                    if (idToMethod[parentMethodID].EndsWith(".class")
                        || idToMethod[parentMethodID].EndsWith(".-clinit-")
                        || idToMethod[parentMethodID].EndsWith(".1")
                        || idToMethod[parentMethodID].Contains(".1.")
                    )
                        continue;

                    if (idToMethod[childMethodID].EndsWith(".class")
                        || idToMethod[childMethodID].EndsWith(".-clinit-")
                        || idToMethod[childMethodID].EndsWith(".1")
                        || idToMethod[childMethodID].Contains(".1.")
                    )
                        continue;

                    //do not add "recursive calls". This is due to the fact that these are calls between overwritten methods
                    if (parentMethodID.Equals(childMethodID) || idToMethod[parentMethodID].Equals(idToMethod[childMethodID]))
                        continue;

                    bigrams.Add(new BiGram(idToMethod[parentMethodID], idToMethod[childMethodID]));
                    continue;
                }
                // methodExit
                if (currentLine.StartsWith("<methodExit "))
                {
                    traceLineSplit = currentLine.Split(' ');
                    if (traceLineSplit[1].StartsWith("threadIdRef=") == false)
                        throw new Exception();
                    if (traceLineSplit[2].StartsWith("methodIdRef=") == false)
                        throw new Exception();
                    if (traceLineSplit[3].StartsWith("classIdRef=") == false)
                        throw new Exception();
                    if (traceLineSplit[4].StartsWith("ticket=") == false)
                        throw new Exception();
                    if (traceLineSplit[5].StartsWith("time=") == false)
                        throw new Exception();

                    string threadID = ExtractValueFromQuotes(traceLineSplit[1]);
                    string methodIDTrace = ExtractValueFromQuotes(traceLineSplit[2]);

                    //Stack<PairMethodIDTraceMethodIDCorpus> currentThreadMethodsStack=threadToMethodsStackTranslator.get(threadID);
                    string topOfStack = threadToMethodsStackTranslator[threadID].Peek();
                    if (topOfStack.Equals(methodIDTrace) == false)
                        throw new Exception(currentLine + "\r\n" + threadToMethodsStackTranslator[threadID]);
                    threadToMethodsStackTranslator[threadID].Pop();

                    continue;
                }
            }
            brTrace.Close();
            return bigrams;
        }