Snippets

Michael Eichberg [OPAL - 0.8.15] Getting TACode for a huge number of projects stored in subfolders

Updated by Michael Eichberg

File GetTAC.scala Modified

  • Ignore whitespace
  • Hide word diff
         } catch {
             case t : Throwable => 
             Console.err.println("\n\n\nFAILED - FAILURE - ERROR - FAILED - FAILURE - ERROR")
-            val cf = p.classFile(m)
-            Console.err.println(m.toJava(cf,p.source(cf).toString))
+            val cf = m.classFile
+            Console.err.println(m.toJava(p.source(cf).toString))
             t.printStackTrace(Console.err)
             Console.err.println("\n\nFailed after "+counter.get+" successfull conversions.\n")
             throw t;
Updated by Michael Eichberg

File GetTAC Deleted

  • Ignore whitespace
  • Hide word diff
-import org.opalj.collection.immutable._; import org.opalj.br._ ; import org.opalj.br.analyses._; import org.opalj.br.instructions._; import org.opalj.collection.immutable.ConstArray.find; import org.opalj.util.PerformanceEvaluation.time
-import java.io.File
-val startTime = System.currentTimeMillis
-val counter = new java.util.concurrent.atomic.AtomicInteger(0)
-for {
-    f <- new File("/Users/eichberg/Desktop/QualitasCorpus-20130901r/Systems").listFiles
-    if f.isDirectory
-} {
-    println(f)
-    val p = Project(f)
-    val tacKey = p.get(org.opalj.tac.DefaultTACAIKey)
-    p.allMethodsWithBody.par.foreach{m => 
-        try {
-            // tacKey(m) // getting the 3-address code
-            org.opalj.ai.BaseAI(p.classFile(m),m,new org.opalj.ai.domain.l1.DefaultDomainWithCFGAndDefUse(p,p.classFile(m),m)) // performing AI
-            counter.incrementAndGet()
-        } catch {
-            case t : Throwable => 
-            Console.err.println("\n\n\nFAILED - FAILURE - ERROR - FAILED - FAILURE - ERROR")
-            val cf = p.classFile(m)
-            Console.err.println(m.toJava(cf,p.source(cf).toString))
-            t.printStackTrace(Console.err)
-            Console.err.println("\n\nFailed after "+counter.get+" successfull conversions.\n")
-            throw t;
-        }
-    }
-}
-val endTime = System.currentTimeMillis
-Console.err.println("\n\nSuccessfully converted "+counter.get+" methods.\n("+(endTime-startTime)/1000+"s)")

File GetTAC.scala Added

  • Ignore whitespace
  • Hide word diff
+import org.opalj.collection.immutable._; import org.opalj.br._ ; import org.opalj.br.analyses._; import org.opalj.br.instructions._; import org.opalj.collection.immutable.ConstArray.find; import org.opalj.util.PerformanceEvaluation.time
+import java.io.File
+val startTime = System.currentTimeMillis
+val counter = new java.util.concurrent.atomic.AtomicInteger(0)
+for {
+    f <- new File("/Users/eichberg/Desktop/QualitasCorpus-20130901r/Systems").listFiles
+    if f.isDirectory
+} {
+    println(f)
+    val p = Project(f)
+    val tacKey = p.get(org.opalj.tac.DefaultTACAIKey)
+    p.parForeachMethodWithBody(){mi => // the native parallelization offered by OPAL is more efficient than the generic one provided by the parallel collections api.
+        val m = mi.method
+        try {
+             tacKey(m) // getting the 3-address code
+            //org.opalj.ai.BaseAI(p.classFile(m),m,new org.opalj.ai.domain.l1.DefaultDomainWithCFGAndDefUse(p,p.classFile(m),m)) // performing AI
+            if(counter.incrementAndGet() %1000 == 0) print(s"\rtransformed ${counter.get} methods")
+            
+        } catch {
+            case t : Throwable => 
+            Console.err.println("\n\n\nFAILED - FAILURE - ERROR - FAILED - FAILURE - ERROR")
+            val cf = p.classFile(m)
+            Console.err.println(m.toJava(cf,p.source(cf).toString))
+            t.printStackTrace(Console.err)
+            Console.err.println("\n\nFailed after "+counter.get+" successfull conversions.\n")
+            throw t;
+        }
+    }
+}
+val endTime = System.currentTimeMillis
+Console.err.println("\n\nSuccessfully converted "+counter.get+" methods.\n("+(endTime-startTime)/1000+"s)")
+
+
Updated by Michael Eichberg

File GetTAC Modified

  • Ignore whitespace
  • Hide word diff
 import org.opalj.collection.immutable._; import org.opalj.br._ ; import org.opalj.br.analyses._; import org.opalj.br.instructions._; import org.opalj.collection.immutable.ConstArray.find; import org.opalj.util.PerformanceEvaluation.time
 import java.io.File
+val startTime = System.currentTimeMillis
 val counter = new java.util.concurrent.atomic.AtomicInteger(0)
 for {
     f <- new File("/Users/eichberg/Desktop/QualitasCorpus-20130901r/Systems").listFiles
     val tacKey = p.get(org.opalj.tac.DefaultTACAIKey)
     p.allMethodsWithBody.par.foreach{m => 
         try {
-            tacKey(m)
+            // tacKey(m) // getting the 3-address code
+            org.opalj.ai.BaseAI(p.classFile(m),m,new org.opalj.ai.domain.l1.DefaultDomainWithCFGAndDefUse(p,p.classFile(m),m)) // performing AI
             counter.incrementAndGet()
         } catch {
             case t : Throwable => 
         }
     }
 }
-Console.err.println("\n\nSuccessfully converted "+counter.get+" methods.\n")
+val endTime = System.currentTimeMillis
+Console.err.println("\n\nSuccessfully converted "+counter.get+" methods.\n("+(endTime-startTime)/1000+"s)")
Updated by Michael Eichberg

File GetTAC Modified

  • Ignore whitespace
  • Hide word diff
 import org.opalj.collection.immutable._; import org.opalj.br._ ; import org.opalj.br.analyses._; import org.opalj.br.instructions._; import org.opalj.collection.immutable.ConstArray.find; import org.opalj.util.PerformanceEvaluation.time
 import java.io.File
+val counter = new java.util.concurrent.atomic.AtomicInteger(0)
 for {
     f <- new File("/Users/eichberg/Desktop/QualitasCorpus-20130901r/Systems").listFiles
     if f.isDirectory
     p.allMethodsWithBody.par.foreach{m => 
         try {
             tacKey(m)
+            counter.incrementAndGet()
         } catch {
             case t : Throwable => 
             Console.err.println("\n\n\nFAILED - FAILURE - ERROR - FAILED - FAILURE - ERROR")
             val cf = p.classFile(m)
             Console.err.println(m.toJava(cf,p.source(cf).toString))
             t.printStackTrace(Console.err)
+            Console.err.println("\n\nFailed after "+counter.get+" successfull conversions.\n")
             throw t;
         }
     }
-}
+}
+Console.err.println("\n\nSuccessfully converted "+counter.get+" methods.\n")
Created by Michael Eichberg

File GetTAC Added

  • Ignore whitespace
  • Hide word diff
+import org.opalj.collection.immutable._; import org.opalj.br._ ; import org.opalj.br.analyses._; import org.opalj.br.instructions._; import org.opalj.collection.immutable.ConstArray.find; import org.opalj.util.PerformanceEvaluation.time
+import java.io.File
+for {
+    f <- new File("/Users/eichberg/Desktop/QualitasCorpus-20130901r/Systems").listFiles
+    if f.isDirectory
+} {
+    println(f)
+    val p = Project(f)
+    val tacKey = p.get(org.opalj.tac.DefaultTACAIKey)
+    p.allMethodsWithBody.par.foreach{m => 
+        try {
+            tacKey(m)
+        } catch {
+            case t : Throwable => 
+            Console.err.println("\n\n\nFAILED - FAILURE - ERROR - FAILED - FAILURE - ERROR")
+            val cf = p.classFile(m)
+            Console.err.println(m.toJava(cf,p.source(cf).toString))
+            t.printStackTrace(Console.err)
+            throw t;
+        }
+    }
+}
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.