jakarta-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1136407 - in /jakarta/bcel/trunk/src/examples: HelloWorldBuilder.java JasminVisitor.java Package.java Peephole.java ProxyCreator.java TransitiveHull.java helloify.java listclass.java maxstack.java patchclass.java
Date Thu, 16 Jun 2011 12:42:39 GMT
Author: sebb
Date: Thu Jun 16 12:42:39 2011
New Revision: 1136407

URL: http://svn.apache.org/viewvc?rev=1136407&view=rev
Log:
Tab police

Modified:
    jakarta/bcel/trunk/src/examples/HelloWorldBuilder.java
    jakarta/bcel/trunk/src/examples/JasminVisitor.java
    jakarta/bcel/trunk/src/examples/Package.java
    jakarta/bcel/trunk/src/examples/Peephole.java
    jakarta/bcel/trunk/src/examples/ProxyCreator.java
    jakarta/bcel/trunk/src/examples/TransitiveHull.java
    jakarta/bcel/trunk/src/examples/helloify.java
    jakarta/bcel/trunk/src/examples/listclass.java
    jakarta/bcel/trunk/src/examples/maxstack.java
    jakarta/bcel/trunk/src/examples/patchclass.java

Modified: jakarta/bcel/trunk/src/examples/HelloWorldBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/HelloWorldBuilder.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/HelloWorldBuilder.java (original)
+++ jakarta/bcel/trunk/src/examples/HelloWorldBuilder.java Thu Jun 16 12:42:39 2011
@@ -47,7 +47,7 @@ import org.apache.bcel.generic.Type;
  *       name = in.readLine();
  *     } catch(IOException e) { 
  *       System.out.println(e);
- *	 return; 
+ *     return; 
  *     }
  * 
  *     System.out.println("Hello, " + name);
@@ -61,20 +61,20 @@ import org.apache.bcel.generic.Type;
 public class HelloWorldBuilder {
   public static void main(String[] argv) {
     ClassGen        cg = new ClassGen("HelloWorld", "java.lang.Object",
-				      "<generated>", Constants.ACC_PUBLIC |
-				      Constants.ACC_SUPER,
-				      null);
+                      "<generated>", Constants.ACC_PUBLIC |
+                      Constants.ACC_SUPER,
+                      null);
     ConstantPoolGen cp = cg.getConstantPool(); // cg creates constant pool
     InstructionList il = new InstructionList();
     MethodGen       mg = new MethodGen(Constants.ACC_STATIC |
-				       Constants.ACC_PUBLIC,// access flags
-				       Type.VOID,              // return type
-				       new Type[] {            // argument types
-					 new ArrayType(Type.STRING, 1) 
-				       },
-				       new String[] { "argv" }, // arg names
-				       "main", "HelloWorld",    // method, class
-				       il, cp);
+                       Constants.ACC_PUBLIC,// access flags
+                       Type.VOID,              // return type
+                       new Type[] {            // argument types
+                     new ArrayType(Type.STRING, 1) 
+                       },
+                       new String[] { "argv" }, // arg names
+                       "main", "HelloWorld",    // method, class
+                       il, cp);
     InstructionFactory factory = new InstructionFactory(cg);
 
     ObjectType i_stream = new ObjectType("java.io.InputStream");
@@ -87,22 +87,22 @@ public class HelloWorldBuilder {
     il.append(factory.createNew("java.io.InputStreamReader"));
     il.append(InstructionConstants.DUP);
     il.append(factory.createFieldAccess("java.lang.System", "in", i_stream,
-					Constants.GETSTATIC));
+                    Constants.GETSTATIC));
 
     /* Call constructors, i.e. BufferedReader(InputStreamReader())
      */
     il.append(factory.createInvoke("java.io.InputStreamReader", "<init>",
-				   Type.VOID, new Type[] { i_stream },
-				   Constants.INVOKESPECIAL));
+                   Type.VOID, new Type[] { i_stream },
+                   Constants.INVOKESPECIAL));
     il.append(factory.createInvoke("java.io.BufferedReader", "<init>", Type.VOID,
-				   new Type[] { new ObjectType("java.io.Reader") },
-				   Constants.INVOKESPECIAL));
+                   new Type[] { new ObjectType("java.io.Reader") },
+                   Constants.INVOKESPECIAL));
 
     /* Create local variable `in'
      */
     LocalVariableGen lg = mg.addLocalVariable("in",
-					      new ObjectType("java.io.BufferedReader"),
-					      null, null);
+                          new ObjectType("java.io.BufferedReader"),
+                          null, null);
     int in = lg.getIndex();
     lg.setStart(il.append(new ASTORE(in))); // `i' valid from here
 
@@ -117,14 +117,14 @@ public class HelloWorldBuilder {
      */
     InstructionHandle try_start =
       il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
-					  Constants.GETSTATIC));
+                      Constants.GETSTATIC));
 
     il.append(new PUSH(cp, "Please enter your name> "));
     il.append(factory.createInvoke("java.io.PrintStream", "print", Type.VOID, 
-				   new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL));
+                   new Type[] { Type.STRING }, Constants.INVOKEVIRTUAL));
     il.append(new ALOAD(in));
     il.append(factory.createInvoke("java.io.BufferedReader", "readLine",
-				   Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
+                   Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
     il.append(new ASTORE(name));
 
     /* Upon normal execution we jump behind exception handler, 
@@ -138,22 +138,22 @@ public class HelloWorldBuilder {
      */
     InstructionHandle handler =
       il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
-					  Constants.GETSTATIC));
+                      Constants.GETSTATIC));
     // Little trick in order not to save exception object temporarily
     il.append(InstructionConstants.SWAP);
 
     il.append(factory.createInvoke("java.io.PrintStream", "println", Type.VOID, 
-	   new Type[] { Type.OBJECT }, Constants.INVOKEVIRTUAL));
+       new Type[] { Type.OBJECT }, Constants.INVOKEVIRTUAL));
     il.append(InstructionConstants.RETURN);
     mg.addExceptionHandler(try_start, try_end, handler,
-			   new ObjectType("java.io.IOException"));
+               new ObjectType("java.io.IOException"));
 
     /* Normal code continues, now we can set the branch target of the GOTO
      * that jumps over the handler code.
      */
     InstructionHandle ih =
       il.append(factory.createFieldAccess("java.lang.System", "out", p_stream,
-					  Constants.GETSTATIC));
+                      Constants.GETSTATIC));
     g.setTarget(ih);
 
     /* String concatenation compiles to StringBuffer operations.
@@ -162,22 +162,22 @@ public class HelloWorldBuilder {
     il.append(InstructionConstants.DUP);
     il.append(new PUSH(cp, "Hello, "));
     il.append(factory.createInvoke("java.lang.StringBuffer", "<init>",
-				   Type.VOID, new Type[] { Type.STRING },
-				   Constants.INVOKESPECIAL));
+                   Type.VOID, new Type[] { Type.STRING },
+                   Constants.INVOKESPECIAL));
     il.append(new ALOAD(name));
     
     /* Concatenate strings using a StringBuffer and print them.
      */
     il.append(factory.createInvoke("java.lang.StringBuffer", "append",
-				   Type.STRINGBUFFER, new Type[] { Type.STRING },
-				   Constants.INVOKEVIRTUAL));
+                   Type.STRINGBUFFER, new Type[] { Type.STRING },
+                   Constants.INVOKEVIRTUAL));
     il.append(factory.createInvoke("java.lang.StringBuffer", "toString",
-				   Type.STRING, Type.NO_ARGS,
-				   Constants.INVOKEVIRTUAL));
+                   Type.STRING, Type.NO_ARGS,
+                   Constants.INVOKEVIRTUAL));
     
     il.append(factory.createInvoke("java.io.PrintStream", "println",
-				   Type.VOID, new Type[] { Type.STRING },
-				   Constants.INVOKEVIRTUAL));
+                   Type.VOID, new Type[] { Type.STRING },
+                   Constants.INVOKEVIRTUAL));
 
     il.append(InstructionConstants.RETURN);
 

Modified: jakarta/bcel/trunk/src/examples/JasminVisitor.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/JasminVisitor.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/JasminVisitor.java (original)
+++ jakarta/bcel/trunk/src/examples/JasminVisitor.java Thu Jun 16 12:42:39 2011
@@ -84,8 +84,8 @@ public class JasminVisitor extends org.a
 
     out.println(".source " + clazz.getSourceFileName());
     out.println("." + Utility.classOrInterface(clazz.getAccessFlags()) + " " +
-		Utility.accessToString(clazz.getAccessFlags(), true) +
-		" " + clazz.getClassName().replace('.', '/'));
+        Utility.accessToString(clazz.getAccessFlags(), true) +
+        " " + clazz.getClassName().replace('.', '/'));
     out.println(".super " + clazz.getSuperclassName().replace('.', '/'));
 
     String[] interfaces = clazz.getInterfaceNames();
@@ -99,7 +99,7 @@ public class JasminVisitor extends org.a
 
   public void visitField(Field field) {
     out.print(".field " + Utility.accessToString(field.getAccessFlags()) +
-		" \"" +field.getName() + "\"" + field.getSignature());
+        " \"" +field.getName() + "\"" + field.getSignature());
     if(field.getAttributes().length == 0) {
         out.print("\n");
     }
@@ -136,7 +136,7 @@ public class JasminVisitor extends org.a
     this._method = method; // Remember for use in subsequent visitXXX calls
 
     out.println("\n.method " + Utility.accessToString(_method.getAccessFlags()) +
-		" " + _method.getName() + _method.getSignature());
+        " " + _method.getName() + _method.getSignature());
 
     Attribute[] attributes = _method.getAttributes();
     if((attributes == null) || (attributes.length == 0)) {
@@ -172,18 +172,18 @@ public class JasminVisitor extends org.a
 
     for(int i=0; i < ihs.length; i++) {
       if(ihs[i] instanceof BranchHandle) {
-	BranchInstruction bi = (BranchInstruction)ihs[i].getInstruction();
-	
-	if(bi instanceof Select) { // Special cases LOOKUPSWITCH and TABLESWITCH
-	  InstructionHandle[] targets = ((Select)bi).getTargets();
-	  
-	  for(int j=0; j < targets.length; j++) {
+    BranchInstruction bi = (BranchInstruction)ihs[i].getInstruction();
+    
+    if(bi instanceof Select) { // Special cases LOOKUPSWITCH and TABLESWITCH
+      InstructionHandle[] targets = ((Select)bi).getTargets();
+      
+      for(int j=0; j < targets.length; j++) {
         put(targets[j], "Label" + label_counter++ + ":");
     }
-	}
+    }
 
-	InstructionHandle ih = bi.getTarget();
-	put(ih, "Label" + label_counter++ + ":");
+    InstructionHandle ih = bi.getTarget();
+    put(ih, "Label" + label_counter++ + ":");
       }
     }
 
@@ -192,7 +192,7 @@ public class JasminVisitor extends org.a
       InstructionHandle ih = lvs[i].getStart();
       put(ih, "Label" + label_counter++ + ":");
       ih = lvs[i].getEnd();
-      put(ih, "Label" + label_counter++ + ":");	
+      put(ih, "Label" + label_counter++ + ":");    
     }
     
     CodeExceptionGen[] ehs = mg.getExceptionHandlers();
@@ -200,11 +200,11 @@ public class JasminVisitor extends org.a
       CodeExceptionGen  c  = ehs[i];
       InstructionHandle ih = c.getStartPC();
 
-      put(ih, "Label" + label_counter++ + ":");	
+      put(ih, "Label" + label_counter++ + ":");    
       ih = c.getEndPC();
-      put(ih, "Label" + label_counter++ + ":");	
+      put(ih, "Label" + label_counter++ + ":");    
       ih = c.getHandlerPC();
-      put(ih, "Label" + label_counter++ + ":");	
+      put(ih, "Label" + label_counter++ + ":");    
     }
 
     LineNumberGen[] lns = mg.getLineNumbers();
@@ -218,9 +218,9 @@ public class JasminVisitor extends org.a
     for(int i=0; i < lvs.length; i++) {
       LocalVariableGen l = lvs[i];
       out.println(".var " + l.getIndex() + " is " + l.getName() + " " +
-		  l.getType().getSignature() + 
-		  " from " + get(l.getStart()) + 
-		  " to " + get(l.getEnd()));
+          l.getType().getSignature() + 
+          " from " + get(l.getStart()) + 
+          " to " + get(l.getEnd()));
     }
 
     out.print("\n");
@@ -235,34 +235,34 @@ public class JasminVisitor extends org.a
     }
 
       if(inst instanceof BranchInstruction) {
-	if(inst instanceof Select) { // Special cases LOOKUPSWITCH and TABLESWITCH
-	  Select              s       = (Select)inst;
-	  int[]               matchs  = s.getMatchs();
-	  InstructionHandle[] targets = s.getTargets();
-	  
-	  if(s instanceof TABLESWITCH) {
-	    out.println("\ttableswitch " + matchs[0] + " " +
-			matchs[matchs.length - 1]);
-	    
-	    for(int j=0; j < targets.length; j++) {
+    if(inst instanceof Select) { // Special cases LOOKUPSWITCH and TABLESWITCH
+      Select              s       = (Select)inst;
+      int[]               matchs  = s.getMatchs();
+      InstructionHandle[] targets = s.getTargets();
+      
+      if(s instanceof TABLESWITCH) {
+        out.println("\ttableswitch " + matchs[0] + " " +
+            matchs[matchs.length - 1]);
+        
+        for(int j=0; j < targets.length; j++) {
             out.println("\t\t" + get(targets[j]));
         }
 
-	  } else { // LOOKUPSWITCH
-	    out.println("\tlookupswitch ");
+      } else { // LOOKUPSWITCH
+        out.println("\tlookupswitch ");
 
-	    for(int j=0; j < targets.length; j++) {
+        for(int j=0; j < targets.length; j++) {
             out.println("\t\t" + matchs[j] + " : " + get(targets[j]));
         }
-	  }
+      }
 
-	  out.println("\t\tdefault: " + get(s.getTarget())); // Applies for both
-	} else {
-	  BranchInstruction bi  = (BranchInstruction)inst;
-	  ih  = bi.getTarget();
-	  str = get(ih);
-	  out.println("\t" + Constants.OPCODE_NAMES[bi.getOpcode()] + " " + str);
-	}
+      out.println("\t\tdefault: " + get(s.getTarget())); // Applies for both
+    } else {
+      BranchInstruction bi  = (BranchInstruction)inst;
+      ih  = bi.getTarget();
+      str = get(ih);
+      out.println("\t" + Constants.OPCODE_NAMES[bi.getOpcode()] + " " + str);
+    }
       } else {
         out.println("\t" + inst.toString(cp.getConstantPool()));
     }
@@ -274,11 +274,11 @@ public class JasminVisitor extends org.a
       CodeExceptionGen c = ehs[i];
       ObjectType caught = c.getCatchType();
       String class_name = (caught == null)?  // catch any exception, used when compiling
finally
-	"all" : caught.getClassName().replace('.', '/');
+    "all" : caught.getClassName().replace('.', '/');
 
       out.println(".catch " + class_name + " from " +
-		  get(c.getStartPC()) + " to " + get(c.getEndPC()) +
-		  " using " + get(c.getHandlerPC()));
+          get(c.getStartPC()) + " to " + get(c.getEndPC()) +
+          " using " + get(c.getHandlerPC()));
     }
 
     printEndMethod(code);
@@ -301,7 +301,7 @@ public class JasminVisitor extends org.a
 
       map.put(ih, str + "\n" + line); // append
     }
-  }	
+  }    
 
   public static void main(String[] argv) { 
     JavaClass   java_class;
@@ -310,27 +310,27 @@ public class JasminVisitor extends org.a
       if(argv.length == 0) {
         System.err.println("disassemble: No input files specified");
     } else {
-	for(int i=0; i < argv.length; i++) {
-	  if((java_class = Repository.lookupClass(argv[i])) == null) {
+    for(int i=0; i < argv.length; i++) {
+      if((java_class = Repository.lookupClass(argv[i])) == null) {
         java_class = new ClassParser(argv[i]).parse();
     }
 
           String class_name = java_class.getClassName();
           int    index      = class_name.lastIndexOf('.');
-	  String path       = class_name.substring(0, index + 1).replace('.', File.separatorChar);
-	  class_name = class_name.substring(index + 1);
+      String path       = class_name.substring(0, index + 1).replace('.', File.separatorChar);
+      class_name = class_name.substring(index + 1);
+
+      if(!path.equals("")) {
+        File f = new File(path);
+        f.mkdirs();
+      }
 
-	  if(!path.equals("")) {
-	    File f = new File(path);
-	    f.mkdirs();
-	  }
-
-	  String name = path + class_name + ".j";
-	  FileOutputStream out = new FileOutputStream(name);
-	  new JasminVisitor(java_class, out).disassemble();
-	  System.out.println("File dumped to: " + name);
-	}
-      }	  
+      String name = path + class_name + ".j";
+      FileOutputStream out = new FileOutputStream(name);
+      new JasminVisitor(java_class, out).disassemble();
+      System.out.println("File dumped to: " + name);
+    }
+      }
     } catch(Exception e) {
       e.printStackTrace();
     }

Modified: jakarta/bcel/trunk/src/examples/Package.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/Package.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/Package.java (original)
+++ jakarta/bcel/trunk/src/examples/Package.java Thu Jun 16 12:42:39 2011
@@ -123,21 +123,21 @@ public class Package {
     JavaClass clazz ;
     // sort the options
     for(int i = 0 ; i < args.length ; i++ ){
-      if( args[i].startsWith("-e")  )	{
-	showNotFound = true;
-	continue;
-      }
-      if( args[i].startsWith("-s")  )	{
-	printClasses = true ;
-	continue;
-      }
-      if( args[i].startsWith("-l")  )	{
-	log = true ;
-	continue;
+      if( args[i].startsWith("-e")  )    {
+    showNotFound = true;
+    continue;
+      }
+      if( args[i].startsWith("-s")  )    {
+    printClasses = true ;
+    continue;
+      }
+      if( args[i].startsWith("-l")  )    {
+    log = true ;
+    continue;
       }
       String clName = args[i];
       if(clName.endsWith(".class")) {
-	clName = clName.substring(0,clName.length()-6);
+    clName = clName.substring(0,clName.length()-6);
       }
       clName = clName.replace('.','/'); 
       clazz = new ClassParser(classPath.getInputStream(clName),clName).parse();
@@ -156,14 +156,14 @@ public class Package {
       String name = (String)dependents.firstKey();
       String from = (String) dependents.remove(name);
       if(allClasses.get(name) == null){
-	try{
-	  InputStream is = classPath.getInputStream(name);
-	  clazz = new ClassParser(is, name).parse();
-	  addDependents(clazz);
-	}catch( IOException e){
-	  //System.err.println("Error, class not found " + name );
-	  notFound.put(name,from);
-	}
+    try{
+      InputStream is = classPath.getInputStream(name);
+      clazz = new ClassParser(is, name).parse();
+      addDependents(clazz);
+    }catch( IOException e){
+      //System.err.println("Error, class not found " + name );
+      notFound.put(name,from);
+    }
       }
     }
     if(printClasses) { // if wanted show all classes
@@ -186,16 +186,16 @@ public class Package {
     }
     jarFile.close();
     System.err.println("The jar file contains " + allClasses.size() 
-		       +" classes and contains " +written+ " bytes");
+               +" classes and contains " +written+ " bytes");
     if( !notFound.isEmpty() ){
       System.err.println( notFound.size() +" classes could not be found");
       if(showNotFound){ // if wanted show the actual classes that we not found
-	while(!notFound.isEmpty()){
-	  String name = (String)notFound.firstKey();
-	  System.err.println( name+ " (" + notFound.remove(name)+")");
-	}
+    while(!notFound.isEmpty()){
+      String name = (String)notFound.firstKey();
+      System.err.println( name+ " (" + notFound.remove(name)+")");
+    }
       }else{
-	System.err.println("Use '-e' option to view classes that were not found");
+    System.err.println("Use '-e' option to view classes that were not found");
       }
     }
   }
@@ -225,9 +225,9 @@ public class Package {
       Constant cons =  pool.getConstant(i);
       //System.out.println("("+i+") " + cons );
       if( cons!=null && cons.getTag() == Constants.CONSTANT_Class ){
-	int idx = ((ConstantClass)pool.getConstant(i)).getNameIndex();
-	String clas = ((ConstantUtf8)pool.getConstant(idx)).getBytes();
-	addClassString(clas,name);
+    int idx = ((ConstantClass)pool.getConstant(i)).getNameIndex();
+    String clas = ((ConstantUtf8)pool.getConstant(idx)).getBytes();
+    addClassString(clas,name);
       }
     }
   }
@@ -243,19 +243,19 @@ public class Package {
     // must check if it's an arrary (start with "[")
     if(clas.startsWith("[")) {
       if(clas.length() == 2 ) {
-	// it's an array of built in type, ignore
-	return;
+    // it's an array of built in type, ignore
+    return;
       }
       if( 'L' == clas.charAt(1) ){
-	// it's an array of objects, the class name is between [L and ;
-	// like    [Ljava/lang/Object;
-	addClassString(clas.substring(2,clas.length()-1),from);
-	return;
+    // it's an array of objects, the class name is between [L and ;
+    // like    [Ljava/lang/Object;
+    addClassString(clas.substring(2,clas.length()-1),from);
+    return;
       }
       if( '[' == clas.charAt(1) ){
-	// it's an array of arrays, call recursive
-	addClassString(clas.substring(1),from);
-	return ;
+    // it's an array of arrays, call recursive
+    addClassString(clas.substring(1),from);
+    return ;
       }
       throw new IOException("Can't recognize class name =" + clas);
     }

Modified: jakarta/bcel/trunk/src/examples/Peephole.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/Peephole.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/Peephole.java (original)
+++ jakarta/bcel/trunk/src/examples/Peephole.java Thu Jun 16 12:42:39 2011
@@ -43,15 +43,15 @@ public class Peephole {
       ConstantPoolGen cp      = new ConstantPoolGen(clazz.getConstantPool());
 
       for(int i=0; i < methods.length; i++) {
-	if(!(methods[i].isAbstract() || methods[i].isNative())) {
-	  MethodGen mg       = new MethodGen(methods[i],
-					     clazz.getClassName(), cp);
-	  Method    stripped = removeNOPs(mg);
-	  
-	  if(stripped != null) {
+    if(!(methods[i].isAbstract() || methods[i].isNative())) {
+      MethodGen mg       = new MethodGen(methods[i],
+                         clazz.getClassName(), cp);
+      Method    stripped = removeNOPs(mg);
+      
+      if(stripped != null) {
         methods[i] = stripped; // Overwrite with stripped method
     }
-	}
+    }
       }
 
       /* Dump the class to <class name>_.class
@@ -85,16 +85,16 @@ public class Peephole {
        * (non-nop) instruction.
        */
       try {
-	il.delete(first, last);
+    il.delete(first, last);
       } catch(TargetLostException e2) {
-	InstructionHandle[] targets = e2.getTargets();
-	for(int i=0; i < targets.length; i++) {
-	  InstructionTargeter[] targeters = targets[i].getTargeters();
-	  
-	  for(int j=0; j < targeters.length; j++) {
+    InstructionHandle[] targets = e2.getTargets();
+    for(int i=0; i < targets.length; i++) {
+      InstructionTargeter[] targeters = targets[i].getTargeters();
+      
+      for(int j=0; j < targeters.length; j++) {
         targeters[j].updateTarget(targets[i], next);
     }
-	}
+    }
       }
     }
 
@@ -102,7 +102,7 @@ public class Peephole {
     
     if(count > 0) {
       System.out.println("Removed " + count + " NOP instructions from method " +
-			 mg.getName());
+             mg.getName());
       m = mg.getMethod();
     }
 

Modified: jakarta/bcel/trunk/src/examples/ProxyCreator.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/ProxyCreator.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/ProxyCreator.java (original)
+++ jakarta/bcel/trunk/src/examples/ProxyCreator.java Thu Jun 16 12:42:39 2011
@@ -75,7 +75,7 @@ public class ProxyCreator {
     if(loader.getClass().toString().equals("class org.apache.bcel.util.ClassLoader")) {
       // Real class name will be set by the class loader
       ClassGen cg = new ClassGen("foo", "java.lang.Object", "", Constants.ACC_PUBLIC,
-				 new String[] {"java.awt.event.ActionListener"});
+                 new String[] {"java.awt.event.ActionListener"});
      
       // That's important, otherwise newInstance() won't work
       cg.addEmptyConstructor(Constants.ACC_PUBLIC);
@@ -85,13 +85,13 @@ public class ProxyCreator {
       InstructionFactory factory = new InstructionFactory(cg);
 
       int out     = cp.addFieldref("java.lang.System", "out",
-				   "Ljava/io/PrintStream;");
+                   "Ljava/io/PrintStream;");
       int println = cp.addMethodref("java.io.PrintStream", "println",
-				  "(Ljava/lang/Object;)V");
+                  "(Ljava/lang/Object;)V");
       MethodGen mg = new MethodGen(Constants.ACC_PUBLIC, Type.VOID,
-				   new Type[] {
-				     new ObjectType("java.awt.event.ActionEvent")
-				   }, null, "actionPerformed", "foo", il, cp);
+                   new Type[] {
+                     new ObjectType("java.awt.event.ActionEvent")
+                   }, null, "actionPerformed", "foo", il, cp);
 
       // System.out.println("actionPerformed:" + event);
       il.append(new GETSTATIC(out));
@@ -99,7 +99,7 @@ public class ProxyCreator {
       il.append(InstructionConstants.DUP);
       il.append(new PUSH(cp, "actionPerformed:"));
       il.append(factory.createInvoke("java.lang.StringBuffer", "<init>", Type.VOID,
-				     new Type[] {Type.STRING}, Constants.INVOKESPECIAL));
+                     new Type[] {Type.STRING}, Constants.INVOKESPECIAL));
 
       il.append(new ALOAD(1));
       il.append(factory.createAppend(Type.OBJECT));

Modified: jakarta/bcel/trunk/src/examples/TransitiveHull.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/TransitiveHull.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/TransitiveHull.java (original)
+++ jakarta/bcel/trunk/src/examples/TransitiveHull.java Thu Jun 16 12:42:39 2011
@@ -51,144 +51,144 @@ import org.apache.bcel.util.ClassSet;
  * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
  */
 public class TransitiveHull extends org.apache.bcel.classfile.EmptyVisitor {
-	private ClassQueue						_queue;
-	private ClassSet							_set;
-	private ConstantPool					_cp;
-	private String[]							_ignored	= IGNORED;
-
-	public static final String[]	IGNORED		= { "java[.].*", "javax[.].*", "sun[.].*", "sunw[.].*",
-			"com[.]sun[.].*", "org[.]omg[.].*", "org[.]w3c[.].*", "org[.]xml[.].*", "net[.]jini[.].*"
};
-
-	public TransitiveHull(JavaClass clazz) {
-		_queue = new ClassQueue();
-		_queue.enqueue(clazz);
-		_set = new ClassSet();
-		_set.add(clazz);
-	}
-
-	public JavaClass[] getClasses() {
-		return _set.toArray();
-	}
-
-	public String[] getClassNames() {
-		return _set.getClassNames();
-	}
-
-	/**
-	 * Start traversal using DescendingVisitor pattern.
-	 */
-	public void start() {
-		while (!_queue.empty()) {
-			JavaClass clazz = _queue.dequeue();
-			_cp = clazz.getConstantPool();
-
-			new org.apache.bcel.classfile.DescendingVisitor(clazz, this).visit();
-		}
-	}
-
-	private void add(String class_name) {
-		class_name = class_name.replace('/', '.');
-
-		for (int i = 0; i < _ignored.length; i++) {
-			if (Pattern.matches(_ignored[i], class_name)) {
-				return;
-			}
-		}
-
-		try {
-			JavaClass clazz = Repository.lookupClass(class_name);
-
-			if (_set.add(clazz)) {
-				_queue.enqueue(clazz);
-			}
-		} catch (ClassNotFoundException e) {
-			throw new IllegalStateException("Missing class: " + e.toString());
-		}
-	}
-
-	public void visitConstantClass(ConstantClass cc) {
-		String class_name = (String) cc.getConstantValue(_cp);
-		add(class_name);
-	}
-
-	private void checkType(Type type) {
-		if (type instanceof ArrayType) {
-			type = ((ArrayType) type).getBasicType();
-		}
-
-		if (type instanceof ObjectType) {
-			add(((ObjectType) type).getClassName());
-		}
-	}
-
-	private void visitRef(ConstantCP ccp, boolean method) {
-		String class_name = ccp.getClass(_cp);
-		add(class_name);
-
-		ConstantNameAndType cnat = (ConstantNameAndType) _cp.getConstant(ccp.getNameAndTypeIndex(),
-				Constants.CONSTANT_NameAndType);
-
-		String signature = cnat.getSignature(_cp);
-
-		if (method) {
-			Type type = Type.getReturnType(signature);
-
-			checkType(type);
-
-			Type[] types = Type.getArgumentTypes(signature);
-
-			for (int i = 0; i < types.length; i++) {
-				checkType(types[i]);
-			}
-		} else {
-			checkType(Type.getType(signature));
-		}
-	}
-
-	public void visitConstantMethodref(ConstantMethodref cmr) {
-		visitRef(cmr, true);
-	}
-
-	public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref cimr) {
-		visitRef(cimr, true);
-	}
-
-	public void visitConstantFieldref(ConstantFieldref cfr) {
-		visitRef(cfr, false);
-	}
-
-	public String[] getIgnored() {
-		return _ignored;
-	}
-
-	/**
-	 * Set the value of _ignored.
-	 * 
-	 * @param v
-	 *          Value to assign to _ignored.
-	 */
-	public void setIgnored(String[] v) {
-		_ignored = v;
-	}
-
-	public static void main(String[] argv) {
-		JavaClass java_class;
-
-		try {
-			if (argv.length == 0) {
-				System.err.println("transitive: No input files specified");
-			} else {
-				if ((java_class = Repository.lookupClass(argv[0])) == null) {
-					java_class = new ClassParser(argv[0]).parse();
-				}
-
-				TransitiveHull hull = new TransitiveHull(java_class);
-
-				hull.start();
-				System.out.println(Arrays.asList(hull.getClassNames()));
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
+    private ClassQueue                        _queue;
+    private ClassSet                            _set;
+    private ConstantPool                    _cp;
+    private String[]                            _ignored    = IGNORED;
+
+    public static final String[]    IGNORED        = { "java[.].*", "javax[.].*", "sun[.].*",
"sunw[.].*",
+            "com[.]sun[.].*", "org[.]omg[.].*", "org[.]w3c[.].*", "org[.]xml[.].*", "net[.]jini[.].*"
};
+
+    public TransitiveHull(JavaClass clazz) {
+        _queue = new ClassQueue();
+        _queue.enqueue(clazz);
+        _set = new ClassSet();
+        _set.add(clazz);
+    }
+
+    public JavaClass[] getClasses() {
+        return _set.toArray();
+    }
+
+    public String[] getClassNames() {
+        return _set.getClassNames();
+    }
+
+    /**
+     * Start traversal using DescendingVisitor pattern.
+     */
+    public void start() {
+        while (!_queue.empty()) {
+            JavaClass clazz = _queue.dequeue();
+            _cp = clazz.getConstantPool();
+
+            new org.apache.bcel.classfile.DescendingVisitor(clazz, this).visit();
+        }
+    }
+
+    private void add(String class_name) {
+        class_name = class_name.replace('/', '.');
+
+        for (int i = 0; i < _ignored.length; i++) {
+            if (Pattern.matches(_ignored[i], class_name)) {
+                return;
+            }
+        }
+
+        try {
+            JavaClass clazz = Repository.lookupClass(class_name);
+
+            if (_set.add(clazz)) {
+                _queue.enqueue(clazz);
+            }
+        } catch (ClassNotFoundException e) {
+            throw new IllegalStateException("Missing class: " + e.toString());
+        }
+    }
+
+    public void visitConstantClass(ConstantClass cc) {
+        String class_name = (String) cc.getConstantValue(_cp);
+        add(class_name);
+    }
+
+    private void checkType(Type type) {
+        if (type instanceof ArrayType) {
+            type = ((ArrayType) type).getBasicType();
+        }
+
+        if (type instanceof ObjectType) {
+            add(((ObjectType) type).getClassName());
+        }
+    }
+
+    private void visitRef(ConstantCP ccp, boolean method) {
+        String class_name = ccp.getClass(_cp);
+        add(class_name);
+
+        ConstantNameAndType cnat = (ConstantNameAndType) _cp.getConstant(ccp.getNameAndTypeIndex(),
+                Constants.CONSTANT_NameAndType);
+
+        String signature = cnat.getSignature(_cp);
+
+        if (method) {
+            Type type = Type.getReturnType(signature);
+
+            checkType(type);
+
+            Type[] types = Type.getArgumentTypes(signature);
+
+            for (int i = 0; i < types.length; i++) {
+                checkType(types[i]);
+            }
+        } else {
+            checkType(Type.getType(signature));
+        }
+    }
+
+    public void visitConstantMethodref(ConstantMethodref cmr) {
+        visitRef(cmr, true);
+    }
+
+    public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref cimr) {
+        visitRef(cimr, true);
+    }
+
+    public void visitConstantFieldref(ConstantFieldref cfr) {
+        visitRef(cfr, false);
+    }
+
+    public String[] getIgnored() {
+        return _ignored;
+    }
+
+    /**
+     * Set the value of _ignored.
+     * 
+     * @param v
+     *          Value to assign to _ignored.
+     */
+    public void setIgnored(String[] v) {
+        _ignored = v;
+    }
+
+    public static void main(String[] argv) {
+        JavaClass java_class;
+
+        try {
+            if (argv.length == 0) {
+                System.err.println("transitive: No input files specified");
+            } else {
+                if ((java_class = Repository.lookupClass(argv[0])) == null) {
+                    java_class = new ClassParser(argv[0]).parse();
+                }
+
+                TransitiveHull hull = new TransitiveHull(java_class);
+
+                hull.start();
+                System.out.println(Arrays.asList(hull.getClassNames()));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 }

Modified: jakarta/bcel/trunk/src/examples/helloify.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/helloify.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/helloify.java (original)
+++ jakarta/bcel/trunk/src/examples/helloify.java Thu Jun 16 12:42:39 2011
@@ -49,32 +49,32 @@ public final class helloify implements C
   public static void main(String[] argv) { 
     try {
       for(int i=0; i < argv.length; i++) {
-	if(argv[i].endsWith(".class")) {
+    if(argv[i].endsWith(".class")) {
           JavaClass       java_class = new ClassParser(argv[i]).parse();
-	  ConstantPool    constants  = java_class.getConstantPool();
+      ConstantPool    constants  = java_class.getConstantPool();
           String          file_name  = argv[i].substring(0, argv[i].length() - 6) +
-	    "_hello.class";
-	  cp = new ConstantPoolGen(constants);
+        "_hello.class";
+      cp = new ConstantPoolGen(constants);
 
-	  helloifyClassName(java_class);
+      helloifyClassName(java_class);
 
-	  out     = cp.addFieldref("java.lang.System", "out",
-				   "Ljava/io/PrintStream;");
-	  println = cp.addMethodref("java.io.PrintStream", "println",
-				    "(Ljava/lang/String;)V");
-	  /* Patch all methods.
-	   */
+      out     = cp.addFieldref("java.lang.System", "out",
+                   "Ljava/io/PrintStream;");
+      println = cp.addMethodref("java.io.PrintStream", "println",
+                    "(Ljava/lang/String;)V");
+      /* Patch all methods.
+       */
           Method[] methods = java_class.getMethods();
 
-	  for(int j=0; j < methods.length; j++) {
+      for(int j=0; j < methods.length; j++) {
         methods[j] = helloifyMethod(methods[j]);
     }
 
-	  /* Finally dump it back to a file.
-	   */
-	  java_class.setConstantPool(cp.getFinalConstantPool());
-	  java_class.dump(file_name);
-	}
+      /* Finally dump it back to a file.
+       */
+      java_class.setConstantPool(cp.getFinalConstantPool());
+      java_class.dump(file_name);
+    }
       }
     } catch(Exception e) {
       e.printStackTrace();
@@ -107,8 +107,8 @@ public final class helloify implements C
     /* Create instruction list to be inserted at method start.
      */
     String mesg = "Hello from " + Utility.methodSignatureToString(m.getSignature(),
-								  name, 
-								  Utility.accessToString(flags));
+                                  name, 
+                                  Utility.accessToString(flags));
     InstructionList patch  = new InstructionList();
     patch.append(new GETSTATIC(out));
     patch.append(new PUSH(cp, mesg));
@@ -120,10 +120,10 @@ public final class helloify implements C
 
     if(name.equals("<init>")) { // First let the super or other constructor be called
       for(int j=1; j < ihs.length; j++) {
-	if(ihs[j].getInstruction() instanceof INVOKESPECIAL) {
-	  il.append(ihs[j], patch); // Should check: method name == "<init>"
-	  break;
-	}
+    if(ihs[j].getInstruction() instanceof INVOKESPECIAL) {
+      il.append(ihs[j], patch); // Should check: method name == "<init>"
+      break;
+    }
       }
     } else {
         il.insert(ihs[0], patch);

Modified: jakarta/bcel/trunk/src/examples/listclass.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/listclass.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/listclass.java (original)
+++ jakarta/bcel/trunk/src/examples/listclass.java Thu Jun 16 12:42:39 2011
@@ -107,8 +107,8 @@ public class listclass {
             exclude=true;
         } else if(argv[i].equals("-help")) {
           System.out.println( "Usage: java listclass [-constants] [-code] [-brief] " +
-			      "[-dependencies] [-nocontents] [-recurse] class... " +
-			      "[-exclude <list>]\n" +
+                  "[-dependencies] [-nocontents] [-recurse] class... " +
+                  "[-exclude <list>]\n" +
                               "-constants       Print constants table (constant pool)\n"
+
                               "-code            Dump byte code of methods\n" +
                               "-brief           Brief listing\n" +
@@ -116,9 +116,9 @@ public class listclass {
                               "-nocontents      Do not print field/method information\n"
+
                               "-recurse         Recurse into dependent classes\n" +
                               "-exclude <list>  Do not list classes beginning with
" +
-			      "strings in <list>" );
+                  "strings in <list>" );
           System.exit( 0 );
-	} else {
+    } else {
             System.err.println("Unknown switch " + argv[i] + " ignored.");
         }
       } else { // add file name to list
@@ -134,7 +134,7 @@ public class listclass {
         System.err.println("list: No input files specified");
     } else {
       listclass listClass = new listclass(code, constants, verbose, classdep,
-					  nocontents, recurse, exclude_name);
+                      nocontents, recurse, exclude_name);
 
       for(int i=0; i < file_name.size(); i++) {
         name = (String) file_name.elementAt(i);
@@ -145,7 +145,7 @@ public class listclass {
   }
 
   public listclass(boolean code, boolean constants, boolean verbose, boolean classdep,
-		   boolean nocontents, boolean recurse, Vector exclude_name)
+           boolean nocontents, boolean recurse, Vector exclude_name)
   {
     this.code = code;
     this.constants = constants;
@@ -176,7 +176,7 @@ public class listclass {
       if(name.endsWith(".class")) {
         java_class = new ClassParser(name).parse(); // May throw IOException
       } else {
-	java_class = Repository.lookupClass(name);
+    java_class = Repository.lookupClass(name);
       }
 
       if(nocontents) {
@@ -240,7 +240,7 @@ public class listclass {
           if(buf.charAt(n) == '/') {
             buf.setCharAt(n, '.');
         }
-	}
+    }
 
         tempArray[size++] = buf.toString();
       }

Modified: jakarta/bcel/trunk/src/examples/maxstack.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/maxstack.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/maxstack.java (original)
+++ jakarta/bcel/trunk/src/examples/maxstack.java Thu Jun 16 12:42:39 2011
@@ -33,48 +33,48 @@ public final class maxstack {
   public static void main(String[] argv) { 
     try {
       for(int i = 0; i < argv.length; i++) {
-	String    class_name = argv[i];
-	JavaClass java_class = Repository.lookupClass(class_name);
+    String    class_name = argv[i];
+    JavaClass java_class = Repository.lookupClass(class_name);
 
-	if(java_class == null) {
+    if(java_class == null) {
         java_class = new ClassParser(class_name).parse();
     }
 
-	ConstantPoolGen cp      = new ConstantPoolGen(java_class.getConstantPool());
-   	Method[]        methods = java_class.getMethods();
-	
-	for(int j = 0; j < methods.length; j++) {
-	  Method    m  = methods[j];
+    ConstantPoolGen cp      = new ConstantPoolGen(java_class.getConstantPool());
+       Method[]        methods = java_class.getMethods();
+    
+    for(int j = 0; j < methods.length; j++) {
+      Method    m  = methods[j];
 
-	  if(!(m.isAbstract() || m.isNative())) {
-	    MethodGen mg = new MethodGen(m, argv[i], cp);
+      if(!(m.isAbstract() || m.isNative())) {
+        MethodGen mg = new MethodGen(m, argv[i], cp);
 
-	    int compiled_stack  = mg.getMaxStack();
-	    int compiled_locals = mg.getMaxLocals();
-	    mg.setMaxStack(); // Recompute value
-	    mg.setMaxLocals();
-	    int computed_stack  = mg.getMaxStack();
-	    int computed_locals = mg.getMaxLocals();
+        int compiled_stack  = mg.getMaxStack();
+        int compiled_locals = mg.getMaxLocals();
+        mg.setMaxStack(); // Recompute value
+        mg.setMaxLocals();
+        int computed_stack  = mg.getMaxStack();
+        int computed_locals = mg.getMaxLocals();
 
-	    mg.getInstructionList().dispose(); // Reuse instruction handles
-	    
-	    System.out.println(m);
-	    
-	    if(computed_stack == compiled_stack) {
+        mg.getInstructionList().dispose(); // Reuse instruction handles
+        
+        System.out.println(m);
+        
+        if(computed_stack == compiled_stack) {
             System.out.println("Stack ok(" + computed_stack + ")");
         } else {
             System.out.println("\nCompiled stack size " + compiled_stack +
-            	       " computed size " + computed_stack);
+                       " computed size " + computed_stack);
         }
-	    
-	    if(computed_locals == compiled_locals) {
+        
+        if(computed_locals == compiled_locals) {
             System.out.println("Locals ok(" + computed_locals + ")");
         } else {
             System.out.println("\nCompiled locals " + compiled_locals +
-            		 " computed size " + computed_locals);
+                     " computed size " + computed_locals);
         }
-	  }
-	}
+      }
+    }
       }
     } catch(Exception e) {
       e.printStackTrace();

Modified: jakarta/bcel/trunk/src/examples/patchclass.java
URL: http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/examples/patchclass.java?rev=1136407&r1=1136406&r2=1136407&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/examples/patchclass.java (original)
+++ jakarta/bcel/trunk/src/examples/patchclass.java Thu Jun 16 12:42:39 2011
@@ -45,18 +45,18 @@ public class patchclass {
       for(int i=2; i < argv.length; i++) {
         file_name[files++] = argv[i];
     }
-	
+    
       for(int i=0; i < files; i++) {
-	parser     = new ClassParser(file_name[i]);
-	java_class = parser.parse();
-	
-	patchIt(argv[0], argv[1],
-		java_class.getConstantPool().getConstantPool());
+    parser     = new ClassParser(file_name[i]);
+    java_class = parser.parse();
+    
+    patchIt(argv[0], argv[1],
+        java_class.getConstantPool().getConstantPool());
 
-	// Dump the changed class to a new file
-	java_class.dump("_" + file_name[i]);
-	System.out.println("Results saved in: _" +  file_name[i]);
-      }	  
+    // Dump the changed class to a new file
+    java_class.dump("_" + file_name[i]);
+    System.out.println("Results saved in: _" +  file_name[i]);
+      }      
     } catch(Exception e) {
       System.err.println(e);
     }
@@ -66,7 +66,7 @@ public class patchclass {
    * "<em>replacement</em>" in all Utf8 constants
    */
   private static void patchIt(String old, String replacement,
-			      Constant[] constant_pool)
+                  Constant[] constant_pool)
   {
     ConstantUtf8 c;
     String       str;
@@ -77,32 +77,32 @@ public class patchclass {
      */
     for(short i=0; i < constant_pool.length; i++) {
       if(constant_pool[i] instanceof ConstantUtf8) { // Utf8 string found
-	try {
-	  c   = (ConstantUtf8)constant_pool[i]; // Get the string
-	  str = c.getBytes();
-	  
-	  if((index = str.indexOf(old)) != -1) { // `old' found in str
-	    buf       = new StringBuffer();      // target buffer
-	    old_index = 0;                       // String start offset
-	    
-	    // While we have something to replace
-	    while((index = str.indexOf(old, old_index)) != -1) {
-	      buf.append(str.substring(old_index, index)); // append prefix
-	      buf.append(replacement);               // append `replacement'
-	      
-	      old_index = index + old.length(); // Skip `old'.length chars
-	    }
+    try {
+      c   = (ConstantUtf8)constant_pool[i]; // Get the string
+      str = c.getBytes();
+      
+      if((index = str.indexOf(old)) != -1) { // `old' found in str
+        buf       = new StringBuffer();      // target buffer
+        old_index = 0;                       // String start offset
+        
+        // While we have something to replace
+        while((index = str.indexOf(old, old_index)) != -1) {
+          buf.append(str.substring(old_index, index)); // append prefix
+          buf.append(replacement);               // append `replacement'
+          
+          old_index = index + old.length(); // Skip `old'.length chars
+        }
 
-	    buf.append(str.substring(old_index)); // append rest of string
-	    str = buf.toString();
+        buf.append(str.substring(old_index)); // append rest of string
+        str = buf.toString();
 
-	    // Finally push the new string back to the constant pool
-	    c = new ConstantUtf8(str);
-	    constant_pool[i] = c;
-	  }
-	} catch(StringIndexOutOfBoundsException e) { // Should not occur
-	  System.err.println(e);
-	}
+        // Finally push the new string back to the constant pool
+        c = new ConstantUtf8(str);
+        constant_pool[i] = c;
+      }
+    } catch(StringIndexOutOfBoundsException e) { // Should not occur
+      System.err.println(e);
+    }
       }
     } 
   }  



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org


Mime
View raw message