1 package com.sun.org.apache.bcel.internal.verifier; 2 3 56 57 import com.sun.org.apache.bcel.internal.verifier.*; 58 import com.sun.org.apache.bcel.internal.classfile.*; 59 import com.sun.org.apache.bcel.internal.*; 60 61 70 public class TransitiveHull implements VerifierFactoryObserver{ 71 72 73 private int indent = 0; 74 75 76 private TransitiveHull(){ 77 } 78 79 80 public void update(String classname){ 81 82 System.gc(); 84 for (int i=0; i<indent; i++){ 85 System.out.print(" "); 86 } 87 System.out.println(classname); 88 indent += 1; 89 90 Verifier v = VerifierFactory.getVerifier(classname); 91 92 VerificationResult vr; 93 vr = v.doPass1(); 94 if (vr != VerificationResult.VR_OK) System.out.println("Pass 1:\n"+vr); 96 97 vr = v.doPass2(); 98 if (vr != VerificationResult.VR_OK) System.out.println("Pass 2:\n"+vr); 100 101 if (vr == VerificationResult.VR_OK){ 102 JavaClass jc = Repository.lookupClass(v.getClassName()); 103 for (int i=0; i<jc.getMethods().length; i++){ 104 vr = v.doPass3a(i); 105 if (vr != VerificationResult.VR_OK) System.out.println(v.getClassName()+", Pass 3a, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr); 107 108 vr = v.doPass3b(i); 109 if (vr != VerificationResult.VR_OK) System.out.println(v.getClassName()+", Pass 3b, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr); 111 } 112 } 113 114 indent -= 1; 115 } 116 117 123 public static void _main(String [] args){ 124 if (args.length != 1){ 125 System.out.println("Need exactly one argument: The root class to verify."); 126 System.exit(1); 127 } 128 129 int dotclasspos = args[0].lastIndexOf(".class"); 130 if (dotclasspos != -1) args[0] = args[0].substring(0,dotclasspos); 131 args[0] = args[0].replace('/', '.'); 132 133 TransitiveHull th = new TransitiveHull(); 134 VerifierFactory.attach(th); 135 VerifierFactory.getVerifier(args[0]); VerifierFactory.detach(th); 137 } 138 } 139 | Popular Tags |