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

VerifyDialog

public class VerifyDialog extends JDialog
A class for simple graphical class file verification. Use the _main(String []) method with fully qualified class names as arguments to use it as a stand-alone application. Use the VerifyDialog(String) constructor to use this class in your application. [This class was created using VisualAge for Java, but it does not work under VAJ itself (Version 3.02 JDK 1.2)]
version
$Id: VerifyDialog.java,v 1.1.1.1 2001/10/29 20:00:33 jvanzyl Exp $
author
Enver Haase
see
#main(String[])
see
#VerifyDialog(String)

Fields Summary
private JPanel
ivjJDialogContentPane
Machine-generated.
private JPanel
ivjPass1Panel
Machine-generated.
private JPanel
ivjPass2Panel
Machine-generated.
private JPanel
ivjPass3Panel
Machine-generated.
private JButton
ivjPass1Button
Machine-generated.
private JButton
ivjPass2Button
Machine-generated.
private JButton
ivjPass3Button
Machine-generated.
IvjEventHandler
ivjEventHandler
Machine-generated.
private String
class_name
The class to verify. Default set to 'java.lang.Object' in case this class is instantiated via one of the many machine-generated constructors.
private static int
classes_to_verify
This field is here to count the number of open VerifyDialog instances so the JVM can be exited afer every Dialog had been closed.
private JButton
ivjFlushButton
Machine-generated.
Constructors Summary
public VerifyDialog()
Machine-generated.

  
  
	super();
	initialize();
public VerifyDialog(String fully_qualified_class_name)
Use this constructor if you want a possibility to verify other class files than java.lang.Object.

param
fully_qualified_class_name java.lang.String

	super();
	
	int dotclasspos = fully_qualified_class_name.lastIndexOf(".class");
	if (dotclasspos != -1) fully_qualified_class_name = fully_qualified_class_name.substring(0,dotclasspos);
	fully_qualified_class_name = fully_qualified_class_name.replace('/", '.");

	class_name = fully_qualified_class_name;
	initialize();
public VerifyDialog(Dialog owner)
Machine-generated.

	super(owner);
public VerifyDialog(Dialog owner, String title)
Machine-generated.

	super(owner, title);
public VerifyDialog(Dialog owner, String title, boolean modal)
Machine-generated.

	super(owner, title, modal);
public VerifyDialog(Dialog owner, boolean modal)
Machine-generated.

	super(owner, modal);
public VerifyDialog(Frame owner)
Machine-generated.

	super(owner);
public VerifyDialog(Frame owner, String title)
Machine-generated.

	super(owner, title);
public VerifyDialog(Frame owner, String title, boolean modal)
Machine-generated.

	super(owner, title, modal);
public VerifyDialog(Frame owner, boolean modal)
Machine-generated.

	super(owner, modal);
Methods Summary
public static void_main(java.lang.String[] args)
Verifies one or more class files. Verification results are presented graphically: Red means 'rejected', green means 'passed' while yellow means 'could not be verified yet'.

param
args java.lang.String[] fully qualified names of classes to verify.

	classes_to_verify = args.length;
	
	for (int i=0; i<args.length; i++){

		try {
			VerifyDialog aVerifyDialog;
			aVerifyDialog = new VerifyDialog(args[i]);
			aVerifyDialog.setModal(true);
			aVerifyDialog.addWindowListener(new java.awt.event.WindowAdapter() {
				public void windowClosing(java.awt.event.WindowEvent e) {
					classes_to_verify--;
					if (classes_to_verify == 0) System.exit(0);
				};
			});
			aVerifyDialog.setVisible(true);
		} catch (Throwable exception) {
			System.err.println("Exception occurred in main() of javax.swing.JDialog");
			exception.printStackTrace(System.out);
		}
	
	}
private voidconnEtoC1(java.awt.event.ActionEvent arg1)
Machine-generated.

	try {
		// user code begin {1}
		// user code end
		this.pass1Button_ActionPerformed(arg1);
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
private voidconnEtoC2(java.awt.event.ActionEvent arg1)
Machine-generated.

	try {
		// user code begin {1}
		// user code end
		this.pass2Button_ActionPerformed(arg1);
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
private voidconnEtoC3(java.awt.event.ActionEvent arg1)
Machine-generated.

	try {
		// user code begin {1}
		// user code end
		this.pass4Button_ActionPerformed(arg1);
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
private voidconnEtoC4(java.awt.event.ActionEvent arg1)
Machine-generated.

	try {
		// user code begin {1}
		// user code end
		this.flushButton_ActionPerformed(arg1);
		// user code begin {2}
		// user code end
	} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
	}
public voidflushButton_ActionPerformed(java.awt.event.ActionEvent actionEvent)
Machine-generated.

	VerifierFactory.getVerifier(class_name).flush();
	Repository.removeClass(class_name); // Make sure it will be reloaded.
	getPass1Panel().setBackground(Color.gray);
	getPass1Panel().repaint();
	getPass2Panel().setBackground(Color.gray);
	getPass2Panel().repaint();
	getPass3Panel().setBackground(Color.gray);
	getPass3Panel().repaint();
private javax.swing.JButtongetFlushButton()
Machine-generated.

	if (ivjFlushButton == null) {
		try {
			ivjFlushButton = new javax.swing.JButton();
			ivjFlushButton.setName("FlushButton");
			ivjFlushButton.setText("Flush: Forget old verification results");
			ivjFlushButton.setBackground(java.awt.SystemColor.controlHighlight);
			ivjFlushButton.setBounds(60, 215, 300, 30);
			ivjFlushButton.setForeground(java.awt.Color.red);
			ivjFlushButton.setActionCommand("FlushButton");
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjFlushButton;
private javax.swing.JPanelgetJDialogContentPane()
Machine-generated.

	if (ivjJDialogContentPane == null) {
		try {
			ivjJDialogContentPane = new javax.swing.JPanel();
			ivjJDialogContentPane.setName("JDialogContentPane");
			ivjJDialogContentPane.setLayout(null);
			getJDialogContentPane().add(getPass1Panel(), getPass1Panel().getName());
			getJDialogContentPane().add(getPass3Panel(), getPass3Panel().getName());
			getJDialogContentPane().add(getPass2Panel(), getPass2Panel().getName());
			getJDialogContentPane().add(getPass1Button(), getPass1Button().getName());
			getJDialogContentPane().add(getPass2Button(), getPass2Button().getName());
			getJDialogContentPane().add(getPass3Button(), getPass3Button().getName());
			getJDialogContentPane().add(getFlushButton(), getFlushButton().getName());
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjJDialogContentPane;
private javax.swing.JButtongetPass1Button()
Machine-generated.

	if (ivjPass1Button == null) {
		try {
			ivjPass1Button = new javax.swing.JButton();
			ivjPass1Button.setName("Pass1Button");
			ivjPass1Button.setText("Pass1: Verify binary layout of .class file");
			ivjPass1Button.setBackground(java.awt.SystemColor.controlHighlight);
			ivjPass1Button.setBounds(100, 40, 300, 30);
			ivjPass1Button.setActionCommand("Button1");
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjPass1Button;
private javax.swing.JPanelgetPass1Panel()
Machine-generated.

	if (ivjPass1Panel == null) {
		try {
			ivjPass1Panel = new javax.swing.JPanel();
			ivjPass1Panel.setName("Pass1Panel");
			ivjPass1Panel.setLayout(null);
			ivjPass1Panel.setBackground(java.awt.SystemColor.controlShadow);
			ivjPass1Panel.setBounds(30, 30, 50, 50);
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjPass1Panel;
private javax.swing.JButtongetPass2Button()
Machine-generated.

	if (ivjPass2Button == null) {
		try {
			ivjPass2Button = new javax.swing.JButton();
			ivjPass2Button.setName("Pass2Button");
			ivjPass2Button.setText("Pass 2: Verify static .class file constraints");
			ivjPass2Button.setBackground(java.awt.SystemColor.controlHighlight);
			ivjPass2Button.setBounds(100, 100, 300, 30);
			ivjPass2Button.setActionCommand("Button2");
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjPass2Button;
private javax.swing.JPanelgetPass2Panel()
Machine-generated.

	if (ivjPass2Panel == null) {
		try {
			ivjPass2Panel = new javax.swing.JPanel();
			ivjPass2Panel.setName("Pass2Panel");
			ivjPass2Panel.setLayout(null);
			ivjPass2Panel.setBackground(java.awt.SystemColor.controlShadow);
			ivjPass2Panel.setBounds(30, 90, 50, 50);
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjPass2Panel;
private javax.swing.JButtongetPass3Button()
Machine-generated.

	if (ivjPass3Button == null) {
		try {
			ivjPass3Button = new javax.swing.JButton();
			ivjPass3Button.setName("Pass3Button");
			ivjPass3Button.setText("Passes 3a+3b: Verify code arrays");
			ivjPass3Button.setBackground(java.awt.SystemColor.controlHighlight);
			ivjPass3Button.setBounds(100, 160, 300, 30);
			ivjPass3Button.setActionCommand("Button2");
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjPass3Button;
private javax.swing.JPanelgetPass3Panel()
Machine-generated.

	if (ivjPass3Panel == null) {
		try {
			ivjPass3Panel = new javax.swing.JPanel();
			ivjPass3Panel.setName("Pass3Panel");
			ivjPass3Panel.setLayout(null);
			ivjPass3Panel.setBackground(java.awt.SystemColor.controlShadow);
			ivjPass3Panel.setBounds(30, 150, 50, 50);
			// user code begin {1}
			// user code end
		} catch (java.lang.Throwable ivjExc) {
			// user code begin {2}
			// user code end
			handleException(ivjExc);
		}
	}
	return ivjPass3Panel;
private voidhandleException(java.lang.Throwable exception)
Machine-generated.


	/* Uncomment the following lines to print uncaught exceptions to stdout */
	 System.out.println("--------- UNCAUGHT EXCEPTION ---------");
	 exception.printStackTrace(System.out);
private voidinitConnections()
Machine-generated.

	// user code begin {1}
	// user code end
	getPass1Button().addActionListener(ivjEventHandler);
	getPass2Button().addActionListener(ivjEventHandler);
	getPass3Button().addActionListener(ivjEventHandler);
	getFlushButton().addActionListener(ivjEventHandler);
private voidinitialize()
Machine-generated.

	try {
		// user code begin {1}
		// user code end
		setName("VerifyDialog");
		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setSize(430, 280);
		setVisible(true);
		setModal(true);
		setResizable(false);
		setContentPane(getJDialogContentPane());
		initConnections();
	} catch (java.lang.Throwable ivjExc) {
		handleException(ivjExc);
	}
	// user code begin {2}
	setTitle("'"+class_name+"' verification - JustIce / BCEL");
	// user code end
public voidpass1Button_ActionPerformed(java.awt.event.ActionEvent actionEvent)
Machine-generated.

	Verifier v = VerifierFactory.getVerifier(class_name);
	VerificationResult vr = v.doPass1();
	if (vr.getStatus() == VerificationResult.VERIFIED_OK){
		getPass1Panel().setBackground(Color.green);
		getPass1Panel().repaint();
	}
	if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
		getPass1Panel().setBackground(Color.red);
		getPass1Panel().repaint();
	}
public voidpass2Button_ActionPerformed(java.awt.event.ActionEvent actionEvent)
Machine-generated.

	pass1Button_ActionPerformed(actionEvent);
	
	Verifier v = VerifierFactory.getVerifier(class_name);
	VerificationResult vr = v.doPass2();
	if (vr.getStatus() == VerificationResult.VERIFIED_OK){
		getPass2Panel().setBackground(Color.green);
		getPass2Panel().repaint();
	}
	if (vr.getStatus() == VerificationResult.VERIFIED_NOTYET){
		getPass2Panel().setBackground(Color.yellow);
		getPass2Panel().repaint();
	}
	if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){
		getPass2Panel().setBackground(Color.red);
		getPass2Panel().repaint();
	}
public voidpass4Button_ActionPerformed(java.awt.event.ActionEvent actionEvent)
Machine-generated.

	
	pass2Button_ActionPerformed(actionEvent);
	
	
	Color color = Color.green;

	Verifier v = VerifierFactory.getVerifier(class_name);
	VerificationResult vr = v.doPass2();
	if (vr.getStatus() == VerificationResult.VERIFIED_OK){
		JavaClass jc = Repository.lookupClass(class_name);
		int nr = jc.getMethods().length;
		for (int i=0; i<nr; i++) {
			vr = v.doPass3b(i);
			if (vr.getStatus() != VerificationResult.VERIFIED_OK){
				color = Color.red;
				break;
			}
		}
	}
	else{
		color = Color.yellow;
	}

	getPass3Panel().setBackground(color);
	getPass3Panel().repaint();