FileDocCategorySizeDatePackage
TransitiveHull.javaAPI DocJava SE 5 API5329Fri Aug 26 14:55:24 BST 2005com.sun.org.apache.bcel.internal.verifier

TransitiveHull

public class TransitiveHull extends Object implements VerifierFactoryObserver
This class has a _main method implementing a demonstration program of how to use the VerifierFactoryObserver. It transitively verifies all class files encountered; this may take up a lot of time and, more notably, memory.
version
$Id: TransitiveHull.java,v 1.1.1.1 2001/10/29 20:00:31 jvanzyl Exp $
author
Enver Haase

Fields Summary
private int
indent
Used for indentation.
Constructors Summary
private TransitiveHull()
Not publicly instantiable.


	    
	 
	
Methods Summary
public static void_main(java.lang.String[] args)
This method implements a demonstration program of how to use the VerifierFactoryObserver. It transitively verifies all class files encountered; this may take up a lot of time and, more notably, memory.

		if (args.length != 1){
			System.out.println("Need exactly one argument: The root class to verify.");
			System.exit(1);
		}

		int dotclasspos = args[0].lastIndexOf(".class");
		if (dotclasspos != -1) args[0] = args[0].substring(0,dotclasspos);
		args[0] = args[0].replace('/", '.");
	
		TransitiveHull th = new TransitiveHull();
		VerifierFactory.attach(th);
		VerifierFactory.getVerifier(args[0]); // the observer is called back and does the actual trick.
		VerifierFactory.detach(th);
	
public voidupdate(java.lang.String classname)


		System.gc(); // avoid swapping if possible.

		for (int i=0; i<indent; i++){
			System.out.print(" ");
		}
		System.out.println(classname);
		indent += 1;

		Verifier v = VerifierFactory.getVerifier(classname);
	
		VerificationResult vr;
		vr = v.doPass1();
		if (vr != VerificationResult.VR_OK) //System.exit(1);
			System.out.println("Pass 1:\n"+vr);

		vr = v.doPass2();
      if (vr != VerificationResult.VR_OK) //System.exit(1);
			System.out.println("Pass 2:\n"+vr);

		if (vr == VerificationResult.VR_OK){
			JavaClass jc = Repository.lookupClass(v.getClassName());
			for (int i=0; i<jc.getMethods().length; i++){
				vr = v.doPass3a(i);
				if (vr != VerificationResult.VR_OK) //System.exit(1);
					System.out.println(v.getClassName()+", Pass 3a, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);

				vr = v.doPass3b(i);
				if (vr != VerificationResult.VR_OK) //System.exit(1);
					System.out.println(v.getClassName()+", Pass 3b, method "+i+" ['"+jc.getMethods()[i]+"']:\n"+vr);
			}
		}

		indent -= 1;