You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by tc...@apache.org on 2006/03/15 12:33:43 UTC
svn commit: r386056 [28/28] - in /jakarta/bcel/trunk: examples/
examples/Mini/ src/java/org/apache/bcel/
src/java/org/apache/bcel/classfile/ src/java/org/apache/bcel/generic/
src/java/org/apache/bcel/util/ src/java/org/apache/bcel/verifier/
src/java/or...
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/VerifyDialog.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/VerifyDialog.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/VerifyDialog.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/VerifyDialog.java Wed Mar 15 03:31:56 2006
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- */
+ */
package org.apache.bcel.verifier;
-
import java.awt.Color;
import org.apache.bcel.Repository;
import org.apache.bcel.classfile.JavaClass;
@@ -36,493 +35,519 @@
* @see #VerifyDialog(String)
*/
public class VerifyDialog extends javax.swing.JDialog {
- /** Machine-generated. */
- private javax.swing.JPanel ivjJDialogContentPane = null;
- /** Machine-generated. */
- private javax.swing.JPanel ivjPass1Panel = null;
- /** Machine-generated. */
- private javax.swing.JPanel ivjPass2Panel = null;
- /** Machine-generated. */
- private javax.swing.JPanel ivjPass3Panel = null;
- /** Machine-generated. */
- private javax.swing.JButton ivjPass1Button = null;
- /** Machine-generated. */
- private javax.swing.JButton ivjPass2Button = null;
- /** Machine-generated. */
- private javax.swing.JButton ivjPass3Button = null;
- /** Machine-generated. */
- IvjEventHandler ivjEventHandler = new IvjEventHandler();
-
- /**
- * 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 String class_name = "java.lang.Object";
-
- /**
- * 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 static int classes_to_verify;
-
-/** Machine-generated. */
-class IvjEventHandler implements java.awt.event.ActionListener {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- if (e.getSource() == VerifyDialog.this.getPass1Button())
- connEtoC1(e);
- if (e.getSource() == VerifyDialog.this.getPass2Button())
- connEtoC2(e);
- if (e.getSource() == VerifyDialog.this.getPass3Button())
- connEtoC3(e);
- if (e.getSource() == VerifyDialog.this.getFlushButton())
- connEtoC4(e);
- };
- };
- /** Machine-generated. */
- private javax.swing.JButton ivjFlushButton = null;
-/** Machine-generated. */
-public VerifyDialog() {
- super();
- initialize();
-}
-
-/** Machine-generated. */
-public VerifyDialog(java.awt.Dialog owner) {
- super(owner);
-}
-
-/** Machine-generated. */
-public VerifyDialog(java.awt.Dialog owner, String title) {
- super(owner, title);
-}
-
-/** Machine-generated. */
-public VerifyDialog(java.awt.Dialog owner, String title, boolean modal) {
- super(owner, title, modal);
-}
-
-/** Machine-generated. */
-public VerifyDialog(java.awt.Dialog owner, boolean modal) {
- super(owner, modal);
-}
-
-/** Machine-generated. */
-public VerifyDialog(java.awt.Frame owner) {
- super(owner);
-}
-
-/** Machine-generated. */
-public VerifyDialog(java.awt.Frame owner, String title) {
- super(owner, title);
-}
-
-/** Machine-generated. */
-public VerifyDialog(java.awt.Frame owner, String title, boolean modal) {
- super(owner, title, modal);
-}
-
-/** Machine-generated. */
-public VerifyDialog(java.awt.Frame owner, boolean modal) {
- super(owner, modal);
-}
-/**
- * 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
- */
-public VerifyDialog(String fully_qualified_class_name) {
- 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();
-}
-
-
-/** Machine-generated. */
-private void connEtoC1(java.awt.event.ActionEvent arg1) {
- 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);
- }
-}
-
-/** Machine-generated. */
-private void connEtoC2(java.awt.event.ActionEvent arg1) {
- 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);
- }
-}
-
-/** Machine-generated. */
-private void connEtoC3(java.awt.event.ActionEvent arg1) {
- 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);
- }
-}
-
-/** Machine-generated. */
-private void connEtoC4(java.awt.event.ActionEvent arg1) {
- 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);
- }
-}
-
-/** Machine-generated. */
-public void flushButton_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
- 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();
-}
-
-/** Machine-generated. */
-private javax.swing.JButton getFlushButton() {
- 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;
-}
-
-/** Machine-generated. */
-private javax.swing.JPanel getJDialogContentPane() {
- 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;
-}
-
-/** Machine-generated. */
-private javax.swing.JButton getPass1Button() {
- 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;
-}
-
-/** Machine-generated. */
-private javax.swing.JPanel getPass1Panel() {
- 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;
-}
-
-/** Machine-generated. */
-private javax.swing.JButton getPass2Button() {
- 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;
-}
-
-/** Machine-generated. */
-private javax.swing.JPanel getPass2Panel() {
- 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;
-}
-
-/** Machine-generated. */
-private javax.swing.JButton getPass3Button() {
- 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;
-}
-
-/** Machine-generated. */
-private javax.swing.JPanel getPass3Panel() {
- 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;
-}
-
-/** Machine-generated. */
-private void handleException(java.lang.Throwable exception) {
-
- /* Uncomment the following lines to print uncaught exceptions to stdout */
- System.out.println("--------- UNCAUGHT EXCEPTION ---------");
- exception.printStackTrace(System.out);
-}
-
-
-/** Machine-generated. */
-private void initConnections() throws java.lang.Exception {
- // user code begin {1}
- // user code end
- getPass1Button().addActionListener(ivjEventHandler);
- getPass2Button().addActionListener(ivjEventHandler);
- getPass3Button().addActionListener(ivjEventHandler);
- getFlushButton().addActionListener(ivjEventHandler);
-}
-
-/** Machine-generated. */
-private void initialize() {
- 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
-}
-/**
- * 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.
- */
-public static void main(java.lang.String[] args) {
- 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);
- }
-
- }
-}
-
-/** Machine-generated. */
-public void pass1Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
- 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();
- }
-}
-
-/** Machine-generated. */
-public void pass2Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
- 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();
- }
-}
-
-/** Machine-generated. */
-public void pass4Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
-
- 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 = null;
- try {
- 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;
- }
- }
- } catch (ClassNotFoundException ex) {
- // FIXME: report the error
- ex.printStackTrace();
- }
- }
- else{
- color = Color.yellow;
- }
-
- getPass3Panel().setBackground(color);
- getPass3Panel().repaint();
-}
+ /** Machine-generated. */
+ private javax.swing.JPanel ivjJDialogContentPane = null;
+ /** Machine-generated. */
+ private javax.swing.JPanel ivjPass1Panel = null;
+ /** Machine-generated. */
+ private javax.swing.JPanel ivjPass2Panel = null;
+ /** Machine-generated. */
+ private javax.swing.JPanel ivjPass3Panel = null;
+ /** Machine-generated. */
+ private javax.swing.JButton ivjPass1Button = null;
+ /** Machine-generated. */
+ private javax.swing.JButton ivjPass2Button = null;
+ /** Machine-generated. */
+ private javax.swing.JButton ivjPass3Button = null;
+ /** Machine-generated. */
+ IvjEventHandler ivjEventHandler = new IvjEventHandler();
+ /**
+ * 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 String class_name = "java.lang.Object";
+ /**
+ * 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 static int classes_to_verify;
+
+ /** Machine-generated. */
+ class IvjEventHandler implements java.awt.event.ActionListener {
+
+ public void actionPerformed( java.awt.event.ActionEvent e ) {
+ if (e.getSource() == VerifyDialog.this.getPass1Button()) {
+ connEtoC1(e);
+ }
+ if (e.getSource() == VerifyDialog.this.getPass2Button()) {
+ connEtoC2(e);
+ }
+ if (e.getSource() == VerifyDialog.this.getPass3Button()) {
+ connEtoC3(e);
+ }
+ if (e.getSource() == VerifyDialog.this.getFlushButton()) {
+ connEtoC4(e);
+ }
+ };
+ };
+
+ /** Machine-generated. */
+ private javax.swing.JButton ivjFlushButton = null;
+
+
+ /** Machine-generated. */
+ public VerifyDialog() {
+ super();
+ initialize();
+ }
+
+
+ /** Machine-generated. */
+ public VerifyDialog(java.awt.Dialog owner) {
+ super(owner);
+ }
+
+
+ /** Machine-generated. */
+ public VerifyDialog(java.awt.Dialog owner, String title) {
+ super(owner, title);
+ }
+
+
+ /** Machine-generated. */
+ public VerifyDialog(java.awt.Dialog owner, String title, boolean modal) {
+ super(owner, title, modal);
+ }
+
+
+ /** Machine-generated. */
+ public VerifyDialog(java.awt.Dialog owner, boolean modal) {
+ super(owner, modal);
+ }
+
+
+ /** Machine-generated. */
+ public VerifyDialog(java.awt.Frame owner) {
+ super(owner);
+ }
+
+
+ /** Machine-generated. */
+ public VerifyDialog(java.awt.Frame owner, String title) {
+ super(owner, title);
+ }
+
+
+ /** Machine-generated. */
+ public VerifyDialog(java.awt.Frame owner, String title, boolean modal) {
+ super(owner, title, modal);
+ }
+
+
+ /** Machine-generated. */
+ public VerifyDialog(java.awt.Frame owner, boolean modal) {
+ super(owner, modal);
+ }
+
+
+ /**
+ * 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
+ */
+ public VerifyDialog(String fully_qualified_class_name) {
+ 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();
+ }
+
+
+ /** Machine-generated. */
+ private void connEtoC1( java.awt.event.ActionEvent arg1 ) {
+ 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);
+ }
+ }
+
+
+ /** Machine-generated. */
+ private void connEtoC2( java.awt.event.ActionEvent arg1 ) {
+ 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);
+ }
+ }
+
+
+ /** Machine-generated. */
+ private void connEtoC3( java.awt.event.ActionEvent arg1 ) {
+ 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);
+ }
+ }
+
+
+ /** Machine-generated. */
+ private void connEtoC4( java.awt.event.ActionEvent arg1 ) {
+ 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);
+ }
+ }
+
+
+ /** Machine-generated. */
+ public void flushButton_ActionPerformed( java.awt.event.ActionEvent actionEvent ) {
+ 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();
+ }
+
+
+ /** Machine-generated. */
+ private javax.swing.JButton getFlushButton() {
+ 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;
+ }
+
+
+ /** Machine-generated. */
+ private javax.swing.JPanel getJDialogContentPane() {
+ 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;
+ }
+
+
+ /** Machine-generated. */
+ private javax.swing.JButton getPass1Button() {
+ 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;
+ }
+
+
+ /** Machine-generated. */
+ private javax.swing.JPanel getPass1Panel() {
+ 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;
+ }
+
+
+ /** Machine-generated. */
+ private javax.swing.JButton getPass2Button() {
+ 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;
+ }
+
+
+ /** Machine-generated. */
+ private javax.swing.JPanel getPass2Panel() {
+ 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;
+ }
+
+
+ /** Machine-generated. */
+ private javax.swing.JButton getPass3Button() {
+ 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;
+ }
+
+
+ /** Machine-generated. */
+ private javax.swing.JPanel getPass3Panel() {
+ 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;
+ }
+
+
+ /** Machine-generated. */
+ private void handleException( java.lang.Throwable exception ) {
+ /* Uncomment the following lines to print uncaught exceptions to stdout */
+ System.out.println("--------- UNCAUGHT EXCEPTION ---------");
+ exception.printStackTrace(System.out);
+ }
+
+
+ /** Machine-generated. */
+ private void initConnections() throws java.lang.Exception {
+ // user code begin {1}
+ // user code end
+ getPass1Button().addActionListener(ivjEventHandler);
+ getPass2Button().addActionListener(ivjEventHandler);
+ getPass3Button().addActionListener(ivjEventHandler);
+ getFlushButton().addActionListener(ivjEventHandler);
+ }
+
+
+ /** Machine-generated. */
+ private void initialize() {
+ 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
+ }
+
+
+ /**
+ * 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.
+ */
+ public static void main( java.lang.String[] args ) {
+ 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);
+ }
+ }
+ }
+
+
+ /** Machine-generated. */
+ public void pass1Button_ActionPerformed( java.awt.event.ActionEvent actionEvent ) {
+ 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();
+ }
+ }
+
+
+ /** Machine-generated. */
+ public void pass2Button_ActionPerformed( java.awt.event.ActionEvent actionEvent ) {
+ 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();
+ }
+ }
+
+
+ /** Machine-generated. */
+ public void pass4Button_ActionPerformed( java.awt.event.ActionEvent actionEvent ) {
+ 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 = null;
+ try {
+ 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;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ // FIXME: report the error
+ ex.printStackTrace();
+ }
+ } else {
+ color = Color.yellow;
+ }
+ getPass3Panel().setBackground(color);
+ getPass3Panel().repaint();
+ }
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/exc/AssertionViolatedException.java Wed Mar 15 03:31:56 2006
@@ -45,9 +45,15 @@
method, the error message of this object can no longer be null.
*/
public void extendMessage(String pre, String post){
- if (pre == null) pre="";
- if (detailMessage == null) detailMessage="";
- if (post == null) post="";
+ if (pre == null) {
+ pre="";
+ }
+ if (detailMessage == null) {
+ detailMessage="";
+ }
+ if (post == null) {
+ post="";
+ }
detailMessage = pre+detailMessage+post;
}
/**
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/exc/VerifierConstraintViolatedException.java Wed Mar 15 03:31:56 2006
@@ -55,9 +55,15 @@
method, the error message of this object can no longer be null.
*/
public void extendMessage(String pre, String post){
- if (pre == null) pre="";
- if (detailMessage == null) detailMessage="";
- if (post == null) post="";
+ if (pre == null) {
+ pre="";
+ }
+ if (detailMessage == null) {
+ detailMessage="";
+ }
+ if (post == null) {
+ post="";
+ }
detailMessage = pre+detailMessage+post;
}
/**
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/IntList.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/IntList.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/IntList.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/IntList.java Wed Mar 15 03:31:56 2006
@@ -42,7 +42,9 @@
Integer[] ints = new Integer[theList.size()];
theList.toArray(ints);
for (int j=0; j<ints.length; j++){
- if (i == ints[j].intValue()) return true;
+ if (i == ints[j].intValue()) {
+ return true;
+ }
}
return false;
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/LocalVariablesInfo.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/LocalVariablesInfo.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/LocalVariablesInfo.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/LocalVariablesInfo.java Wed Mar 15 03:31:56 2006
@@ -64,7 +64,11 @@
}
localVariableInfos[slot].add(name, startpc, length, t);
- if (t == Type.LONG) localVariableInfos[slot+1].add(name, startpc, length, LONG_Upper.theInstance());
- if (t == Type.DOUBLE) localVariableInfos[slot+1].add(name, startpc, length, DOUBLE_Upper.theInstance());
+ if (t == Type.LONG) {
+ localVariableInfos[slot+1].add(name, startpc, length, LONG_Upper.theInstance());
+ }
+ if (t == Type.DOUBLE) {
+ localVariableInfos[slot+1].add(name, startpc, length, DOUBLE_Upper.theInstance());
+ }
}
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/Pass2Verifier.java Wed Mar 15 03:31:56 2006
@@ -114,7 +114,9 @@
* You should not add own information. Leave that to JustIce.
*/
public LocalVariablesInfo getLocalVariablesInfo(int method_nr){
- if (this.verify() != VerificationResult.VR_OK) return null; // It's cached, don't worry.
+ if (this.verify() != VerificationResult.VR_OK) {
+ return null; // It's cached, don't worry.
+ }
if (method_nr < 0 || method_nr >= localVariablesInfos.length){
throw new AssertionViolatedException("Method number out of range.");
}
@@ -163,9 +165,9 @@
vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage());
}
return vr;
- }
- else
- return VerificationResult.VR_NOTYET;
+ } else {
+ return VerificationResult.VR_NOTYET;
+ }
} catch (ClassNotFoundException e) {
// FIXME: this might not be the best way to handle missing classes.
@@ -386,13 +388,17 @@
}
if (atts[i] instanceof SourceFile){
- if (foundSourceFile == false) foundSourceFile = true;
- else throw new ClassConstraintException("A ClassFile structure (like '"+tostring(obj)+"') may have no more than one SourceFile attribute."); //vmspec2 4.7.7
+ if (foundSourceFile == false) {
+ foundSourceFile = true;
+ } else {
+ throw new ClassConstraintException("A ClassFile structure (like '"+tostring(obj)+"') may have no more than one SourceFile attribute."); //vmspec2 4.7.7
+ }
}
if (atts[i] instanceof InnerClasses){
- if (foundInnerClasses == false) foundInnerClasses = true;
- else{
+ if (foundInnerClasses == false) {
+ foundInnerClasses = true;
+ } else{
if (hasInnerClass){
throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). More than one InnerClasses attribute was found.");
}
@@ -493,9 +499,15 @@
if (jc.isClass()){
int maxone=0;
- if (obj.isPrivate()) maxone++;
- if (obj.isProtected()) maxone++;
- if (obj.isPublic()) maxone++;
+ if (obj.isPrivate()) {
+ maxone++;
+ }
+ if (obj.isProtected()) {
+ maxone++;
+ }
+ if (obj.isPublic()) {
+ maxone++;
+ }
if (maxone > 1){
throw new ClassConstraintException("Field '"+tostring(obj)+"' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
}
@@ -590,7 +602,9 @@
// Check if referenced objects exist.
Type act = t;
- if (act instanceof ArrayType) act = ((ArrayType) act).getBasicType();
+ if (act instanceof ArrayType) {
+ act = ((ArrayType) act).getBasicType();
+ }
if (act instanceof ObjectType){
Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
VerificationResult vr = v.doPass1();
@@ -601,7 +615,9 @@
for (int i=0; i<ts.length; i++){
act = ts[i];
- if (act instanceof ArrayType) act = ((ArrayType) act).getBasicType();
+ if (act instanceof ArrayType) {
+ act = ((ArrayType) act).getBasicType();
+ }
if (act instanceof ObjectType){
Verifier v = VerifierFactory.getVerifier( ((ObjectType) act).getClassName() );
VerificationResult vr = v.doPass1();
@@ -618,20 +634,38 @@
if (jc.isClass()){
int maxone=0;
- if (obj.isPrivate()) maxone++;
- if (obj.isProtected()) maxone++;
- if (obj.isPublic()) maxone++;
+ if (obj.isPrivate()) {
+ maxone++;
+ }
+ if (obj.isProtected()) {
+ maxone++;
+ }
+ if (obj.isPublic()) {
+ maxone++;
+ }
if (maxone > 1){
throw new ClassConstraintException("Method '"+tostring(obj)+"' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
}
if (obj.isAbstract()){
- if (obj.isFinal()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_FINAL modifier set.");
- if (obj.isNative()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_NATIVE modifier set.");
- if (obj.isPrivate()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_PRIVATE modifier set.");
- if (obj.isStatic()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STATIC modifier set.");
- if (obj.isStrictfp()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STRICT modifier set.");
- if (obj.isSynchronized()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_SYNCHRONIZED modifier set.");
+ if (obj.isFinal()) {
+ throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_FINAL modifier set.");
+ }
+ if (obj.isNative()) {
+ throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_NATIVE modifier set.");
+ }
+ if (obj.isPrivate()) {
+ throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_PRIVATE modifier set.");
+ }
+ if (obj.isStatic()) {
+ throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STATIC modifier set.");
+ }
+ if (obj.isStrictfp()) {
+ throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STRICT modifier set.");
+ }
+ if (obj.isSynchronized()) {
+ throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_SYNCHRONIZED modifier set.");
+ }
}
}
else{ // isInterface!
@@ -703,7 +737,9 @@
if ((atts[i] instanceof Code) && (obj.isNative() || obj.isAbstract())){
throw new ClassConstraintException("Native or abstract methods like '"+tostring(obj)+"' must not have a Code attribute like '"+tostring(atts[i])+"'."); //vmspec2 page120, 4.7.3
}
- if (atts[i] instanceof Code) num_code_atts++;
+ if (atts[i] instanceof Code) {
+ num_code_atts++;
+ }
}
if ( !obj.isNative() && !obj.isAbstract() && num_code_atts != 1){
throw new ClassConstraintException("Non-native, non-abstract methods like '"+tostring(obj)+"' must have exactly one Code attribute (found: "+num_code_atts+").");
@@ -880,7 +916,9 @@
JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName());
JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName());
while (e != o){
- if (e == t) break; // It's a subclass of Throwable, OKAY, leave.
+ if (e == t) {
+ break; // It's a subclass of Throwable, OKAY, leave.
+ }
v = VerifierFactory.getVerifier(e.getSuperclassName());
vr = v.doPass1();
@@ -891,7 +929,9 @@
e = Repository.lookupClass(e.getSuperclassName());
}
}
- if (e != t) throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+ if (e != t) {
+ throw new ClassConstraintException("Code attribute '"+tostring(obj)+"' (method '"+m+"') has an exception_table entry '"+tostring(exc_table[i])+"' that references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+ }
}
}
}
@@ -1019,7 +1059,9 @@
JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName());
JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName());
while (e != o){
- if (e == t) break; // It's a subclass of Throwable, OKAY, leave.
+ if (e == t) {
+ break; // It's a subclass of Throwable, OKAY, leave.
+ }
v = VerifierFactory.getVerifier(e.getSuperclassName());
vr = v.doPass1();
@@ -1030,7 +1072,9 @@
e = Repository.lookupClass(e.getSuperclassName());
}
}
- if (e != t) throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+ if (e != t) {
+ throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"' references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+ }
}
}
@@ -1258,7 +1302,9 @@
* for the class/interface initialization method may be allowed.
*/
private static boolean validMethodName(String name, boolean allowStaticInit){
- if (validJavaLangMethodName(name)) return true;
+ if (validJavaLangMethodName(name)) {
+ return true;
+ }
if (allowStaticInit){
return (name.equals(CONSTRUCTOR_NAME) || name.equals(STATIC_INITIALIZER_NAME));
@@ -1284,10 +1330,14 @@
* Conforming to: The Java Virtual Machine Specification, Second Edition, §2.7, §2.7.1, §2.2.
*/
private static boolean validJavaLangMethodName(String name){
- if (!Character.isJavaIdentifierStart(name.charAt(0))) return false;
+ if (!Character.isJavaIdentifierStart(name.charAt(0))) {
+ return false;
+ }
for (int i=1; i<name.length(); i++){
- if (!Character.isJavaIdentifierPart(name.charAt(i))) return false;
+ if (!Character.isJavaIdentifierPart(name.charAt(i))) {
+ return false;
+ }
}
return true;
}
@@ -1299,7 +1349,9 @@
*/
private static boolean validInterfaceMethodName(String name){
// I guess we should assume special names forbidden here.
- if (name.startsWith("<")) return false;
+ if (name.startsWith("<")) {
+ return false;
+ }
return validJavaLangMethodName(name);
}
@@ -1308,13 +1360,19 @@
* represents a valid Java identifier (so-called simple name).
*/
private static boolean validJavaIdentifier(String name){
- if (name.length() == 0) return false; // must not be empty, reported by <fr...@easynet.fr>, thanks!
+ if (name.length() == 0) {
+ return false; // must not be empty, reported by <fr...@easynet.fr>, thanks!
+ }
// vmspec2 2.7, vmspec2 2.2
- if (!Character.isJavaIdentifierStart(name.charAt(0))) return false;
+ if (!Character.isJavaIdentifierStart(name.charAt(0))) {
+ return false;
+ }
for (int i=1; i<name.length(); i++){
- if (!Character.isJavaIdentifierPart(name.charAt(i))) return false;
+ if (!Character.isJavaIdentifierPart(name.charAt(i))) {
+ return false;
+ }
}
return true;
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java Wed Mar 15 03:31:56 2006
@@ -361,8 +361,9 @@
if (! ((last instanceof ReturnInstruction) ||
(last instanceof RET) ||
(last instanceof GotoInstruction) ||
- (last instanceof ATHROW) )) // JSR / JSR_W would possibly RETurn and then fall off the code!
- throw new StaticCodeInstructionConstraintException("Execution must not fall off the bottom of the code array. This constraint is enforced statically as some existing verifiers do - so it may be a false alarm if the last instruction is not reachable.");
+ (last instanceof ATHROW) )) {
+ throw new StaticCodeInstructionConstraintException("Execution must not fall off the bottom of the code array. This constraint is enforced statically as some existing verifiers do - so it may be a false alarm if the last instruction is not reachable.");
+ }
}
/**
@@ -421,7 +422,9 @@
/** A small utility method returning if a given int i is in the given int[] ints. */
private static boolean contains(int[] ints, int i){
for (int j=0; j<ints.length; j++){
- if (ints[j]==i) return true;
+ if (ints[j]==i) {
+ return true;
+ }
}
return false;
}
@@ -572,15 +575,17 @@
Type o_type = o.getType(cpg);
if (f_type.equals(o_type)){
f = fields[i];
- if ((f.getAccessFlags() & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == 0)
- f = null;
+ if ((f.getAccessFlags() & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == 0) {
+ f = null;
+ }
break outer;
}
}
}
}
- if (f == null)
- constraintViolated(o, "Referenced field '"+field_name+"' does not exist in class '"+jc.getClassName()+"'.");
+ if (f == null) {
+ constraintViolated(o, "Referenced field '"+field_name+"' does not exist in class '"+jc.getClassName()+"'.");
+ }
}
else{
/* TODO: Check if assignment compatibility is sufficient.
@@ -1109,7 +1114,9 @@
break;
}
}
- if (meth != null) break;
+ if (meth != null) {
+ break;
+ }
}
if (meth == null){
constraintViolated(o, "ACC_SUPER special lookup procedure not successful: method '"+o.getMethodName(cpg)+"' with proper signature not declared in superclass hierarchy.");
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/StringRepresentation.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/StringRepresentation.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/StringRepresentation.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/statics/StringRepresentation.java Wed Mar 15 03:31:56 2006
@@ -92,7 +92,9 @@
// However, in terms of performance this would be a better idea.
// If some new "Node" is defined in BCEL (such as some concrete "Attribute"), we
// want to know that this class has also to be adapted.
- if (tostring == null) throw new AssertionViolatedException("Please adapt '" + getClass() + "' to deal with objects of class '" + n.getClass() + "'.");
+ if (tostring == null) {
+ throw new AssertionViolatedException("Please adapt '" + getClass() + "' to deal with objects of class '" + n.getClass() + "'.");
+ }
return tostring;
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java Wed Mar 15 03:31:56 2006
@@ -82,7 +82,9 @@
* Creation of one per InstructionHandle suffices. Don't create more.
*/
public InstructionContextImpl(InstructionHandle inst){
- if (inst == null) throw new AssertionViolatedException("Cannot instantiate InstructionContextImpl from NULL.");
+ if (inst == null) {
+ throw new AssertionViolatedException("Cannot instantiate InstructionContextImpl from NULL.");
+ }
instruction = inst;
inFrames = new java.util.HashMap();
@@ -292,10 +294,14 @@
for (int i=size-1; i>=0; i--){
InstructionContextImpl current = (InstructionContextImpl) (executionPredecessors.get(i));
Instruction currentlast = current.getInstruction().getInstruction();
- if (currentlast instanceof RET) retcount++;
+ if (currentlast instanceof RET) {
+ retcount++;
+ }
if (currentlast instanceof JsrInstruction){
retcount--;
- if (retcount == -1) return current;
+ if (retcount == -1) {
+ return current;
+ }
}
}
return null;
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java Wed Mar 15 03:31:56 2006
@@ -63,8 +63,9 @@
*/
public ExceptionHandler[] getExceptionHandlers(InstructionHandle ih){
Set hs = (Set) exceptionhandlers.get(ih);
- if (hs == null) return new ExceptionHandler[0];
- else{
+ if (hs == null) {
+ return new ExceptionHandler[0];
+ } else{
ExceptionHandler[] ret = new ExceptionHandler[hs.size()];
return (ExceptionHandler[]) (hs.toArray(ret));
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java Wed Mar 15 03:31:56 2006
@@ -167,10 +167,11 @@
public void visitATHROW(ATHROW o){
Type t = stack().pop();
stack().clear();
- if (t.equals(Type.NULL))
- stack().push(Type.getType("Ljava/lang/NullPointerException;"));
- else
- stack().push(t);
+ if (t.equals(Type.NULL)) {
+ stack().push(Type.getType("Ljava/lang/NullPointerException;"));
+ } else {
+ stack().push(t);
+ }
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
@@ -505,8 +506,9 @@
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
+ t.equals(Type.SHORT) ) {
+ t = Type.INT;
+ }
stack().push(t);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
@@ -515,8 +517,9 @@
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
+ t.equals(Type.SHORT) ) {
+ t = Type.INT;
+ }
stack().push(t);
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */
@@ -702,8 +705,9 @@
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
+ t.equals(Type.SHORT) ) {
+ t = Type.INT;
+ }
stack().push(t);
}
}
@@ -730,8 +734,9 @@
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
+ t.equals(Type.SHORT) ) {
+ t = Type.INT;
+ }
stack().push(t);
}
}
@@ -749,8 +754,9 @@
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
+ t.equals(Type.SHORT) ) {
+ t = Type.INT;
+ }
stack().push(t);
}
}
@@ -769,8 +775,9 @@
if ( t.equals(Type.BOOLEAN) ||
t.equals(Type.CHAR) ||
t.equals(Type.BYTE) ||
- t.equals(Type.SHORT) )
- t = Type.INT;
+ t.equals(Type.SHORT) ) {
+ t = Type.INT;
+ }
stack().push(t);
}
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/Frame.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/Frame.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/Frame.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/Frame.java Wed Mar 15 03:31:56 2006
@@ -99,7 +99,9 @@
*
*/
public boolean equals(Object o){
- if (!(o instanceof Frame)) return false; // implies "null" is non-equal.
+ if (!(o instanceof Frame)) {
+ return false; // implies "null" is non-equal.
+ }
Frame f = (Frame) o;
return this.stack.equals(f.stack) && this.locals.equals(f.locals);
}
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java Wed Mar 15 03:31:56 2006
@@ -146,8 +146,9 @@
* @throws org.apache.bcel.verifier.exc.StructuralCodeConstraintException if the above constraint is not satisfied.
*/
private void indexOfInt(Instruction o, Type index){
- if (! index.equals(Type.INT))
- constraintViolated(o, "The 'index' is not of type int but of type "+index+".");
+ if (! index.equals(Type.INT)) {
+ constraintViolated(o, "The 'index' is not of type int but of type "+index+".");
+ }
}
/**
@@ -164,8 +165,9 @@
/** Assures value is of type INT. */
private void valueOfInt(Instruction o, Type value){
- if (! value.equals(Type.INT))
- constraintViolated(o, "The 'value' is not of type int but of type "+value+".");
+ if (! value.equals(Type.INT)) {
+ constraintViolated(o, "The 'value' is not of type int but of type "+value+".");
+ }
}
/**
@@ -174,8 +176,9 @@
* @throws org.apache.bcel.verifier.exc.StructuralCodeConstraintException if the above constraint is violated.
*/
private boolean arrayrefOfArrayType(Instruction o, Type arrayref){
- if (! ((arrayref instanceof ArrayType) || arrayref.equals(Type.NULL)) )
- constraintViolated(o, "The 'arrayref' does not refer to an array but is of type "+arrayref+".");
+ if (! ((arrayref instanceof ArrayType) || arrayref.equals(Type.NULL)) ) {
+ constraintViolated(o, "The 'arrayref' does not refer to an array but is of type "+arrayref+".");
+ }
return (arrayref instanceof ArrayType);
}
@@ -492,10 +495,11 @@
* Ensures the specific preconditions of the said instruction.
*/
public void visitANEWARRAY(ANEWARRAY o){
- if (!stack().peek().equals(Type.INT))
- constraintViolated(o, "The 'count' at the stack top is not of type '"+Type.INT+"' but of type '"+stack().peek()+"'.");
+ if (!stack().peek().equals(Type.INT)) {
+ constraintViolated(o, "The 'count' at the stack top is not of type '"+Type.INT+"' but of type '"+stack().peek()+"'.");
// The runtime constant pool item at that index must be a symbolic reference to a class,
// array, or interface type. See Pass 3a.
+ }
}
/**
@@ -548,7 +552,9 @@
}
// NULL is a subclass of every class, so to speak.
- if (stack().peek().equals(Type.NULL)) return;
+ if (stack().peek().equals(Type.NULL)) {
+ return;
+ }
ObjectType exc = (ObjectType) (stack().peek());
ObjectType throwable = (ObjectType) (Type.getType("Ljava/lang/Throwable;"));
@@ -588,8 +594,9 @@
valueOfInt(o, value);
if (arrayrefOfArrayType(o, arrayref)){
if (! ( (((ArrayType) arrayref).getElementType().equals(Type.BOOLEAN)) ||
- (((ArrayType) arrayref).getElementType().equals(Type.BYTE)) ) )
- constraintViolated(o, "The 'arrayref' does not refer to an array with elements of a Type.BYTE or Type.BOOLEAN but to an array of '"+((ArrayType) arrayref).getElementType()+"'.");
+ (((ArrayType) arrayref).getElementType().equals(Type.BYTE)) ) ) {
+ constraintViolated(o, "The 'arrayref' does not refer to an array with elements of a Type.BYTE or Type.BOOLEAN but to an array of '"+((ArrayType) arrayref).getElementType()+"'.");
+ }
}
}
@@ -1185,15 +1192,17 @@
Type o_type = o.getType(cpg);
if (f_type.equals(o_type)){
f = fields[i];
- if ((f.getAccessFlags() & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == 0)
- f = null;
+ if ((f.getAccessFlags() & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == 0) {
+ f = null;
+ }
break outer;
}
}
}
}
- if (f == null)
- throw new AssertionViolatedException("Field '"+field_name+"' not found?!?");
+ if (f == null) {
+ throw new AssertionViolatedException("Field '"+field_name+"' not found?!?");
+ }
}
if (f.isProtected()){
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/LocalVariables.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/LocalVariables.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/LocalVariables.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/LocalVariables.java Wed Mar 15 03:31:56 2006
@@ -97,9 +97,13 @@
* Fulfills the general contract of Object.equals().
*/
public boolean equals(Object o){
- if (!(o instanceof LocalVariables)) return false;
+ if (!(o instanceof LocalVariables)) {
+ return false;
+ }
LocalVariables lv = (LocalVariables) o;
- if (this.locals.length != lv.locals.length) return false;
+ if (this.locals.length != lv.locals.length) {
+ return false;
+ }
for (int i=0; i<this.locals.length; i++){
if (!this.locals[i].equals(lv.locals[i])){
//System.out.println(this.locals[i]+" is not "+lv.locals[i]);
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/OperandStack.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/OperandStack.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/OperandStack.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/OperandStack.java Wed Mar 15 03:31:56 2006
@@ -83,7 +83,9 @@
* objects on the stacks.
*/
public boolean equals(Object o){
- if (!(o instanceof OperandStack)) return false;
+ if (!(o instanceof OperandStack)) {
+ return false;
+ }
OperandStack s = (OperandStack) o;
return this.stack.equals(s.stack);
}
@@ -148,7 +150,9 @@
* Pushes a Type object onto the stack.
*/
public void push(Type type){
- if (type == null) throw new AssertionViolatedException("Cannot push NULL onto OperandStack.");
+ if (type == null) {
+ throw new AssertionViolatedException("Cannot push NULL onto OperandStack.");
+ }
if (type == Type.BOOLEAN || type == Type.CHAR || type == Type.BYTE || type == Type.SHORT){
throw new AssertionViolatedException("The OperandStack does not know about '"+type+"'; use Type.INT instead.");
}
@@ -207,8 +211,9 @@
*/
public void merge(OperandStack s){
try {
- if ( (slotsUsed() != s.slotsUsed()) || (size() != s.size()) )
- throw new StructuralCodeConstraintException("Cannot merge stacks of different size:\nOperandStack A:\n"+this+"\nOperandStack B:\n"+s);
+ if ( (slotsUsed() != s.slotsUsed()) || (size() != s.size()) ) {
+ throw new StructuralCodeConstraintException("Cannot merge stacks of different size:\nOperandStack A:\n"+this+"\nOperandStack B:\n"+s);
+ }
for (int i=0; i<size(); i++){
// If the object _was_ initialized and we're supposed to merge
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/Subroutines.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/Subroutines.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/Subroutines.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/Subroutines.java Wed Mar 15 03:31:56 2006
@@ -278,7 +278,9 @@
// the constant pool.
if (ih.getInstruction() instanceof LocalVariableInstruction){
int s = ((LocalVariableInstruction) ih.getInstruction()).getType(null).getSize();
- if (s==2) acc.add(new Integer(idx+1));
+ if (s==2) {
+ acc.add(new Integer(idx+1));
+ }
}
}
catch(RuntimeException re){
@@ -557,7 +559,9 @@
Iterator i = subroutines.values().iterator();
while (i.hasNext()){
Subroutine s = (Subroutine) i.next();
- if (s.contains(any)) return s;
+ if (s.contains(any)) {
+ return s;
+ }
}
System.err.println("DEBUG: Please verify '"+any+"' lies in dead code.");
return null;
Modified: jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java
URL: http://svn.apache.org/viewcvs/jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java?rev=386056&r1=386055&r2=386056&view=diff
==============================================================================
--- jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java (original)
+++ jakarta/bcel/trunk/src/java/org/apache/bcel/verifier/structurals/UninitializedObjectType.java Wed Mar 15 03:31:56 2006
@@ -59,7 +59,9 @@
*
*/
public boolean equals(Object o){
- if (! (o instanceof UninitializedObjectType)) return false;
+ if (! (o instanceof UninitializedObjectType)) {
+ return false;
+ }
return initialized.equals(((UninitializedObjectType)o).initialized);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org