You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/08/26 00:36:05 UTC

svn commit: r1697778 - /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java

Author: sebb
Date: Tue Aug 25 22:36:05 2015
New Revision: 1697778

URL: http://svn.apache.org/r1697778
Log:
Make it easier to test

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java?rev=1697778&r1=1697777&r2=1697778&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/util/BCELifier.java Tue Aug 25 22:36:05 2015
@@ -17,6 +17,7 @@
  */
 package org.apache.commons.bcel6.util;
 
+import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.util.Locale;
@@ -275,12 +276,23 @@ public class BCELifier extends org.apach
     /** Default main method
      */
     public static void main( String[] argv ) throws Exception {
+        if (argv.length != 1) {
+            System.out.println("Usage: BCELifier classname");
+            System.out.println("\tThe class must exist on the classpath");
+            return;
+        }
+        JavaClass java_class = getJavaClass(argv[0]);
+        BCELifier bcelifier = new BCELifier(java_class, System.out);
+        bcelifier.start();
+    }
+
+
+    // Needs to be accessible from unit test code
+    static JavaClass getJavaClass(String name) throws ClassNotFoundException, IOException {
         JavaClass java_class;
-        String name = argv[0];
         if ((java_class = Repository.lookupClass(name)) == null) {
             java_class = new ClassParser(name).parse(); // May throw IOException
         }
-        BCELifier bcelifier = new BCELifier(java_class, System.out);
-        bcelifier.start();
+        return java_class;
     }
 }