/** Machine-generated. */ public void pass2Button_ActionPerformed( final java.awt.event.ActionEvent actionEvent ) { pass1Button_ActionPerformed(actionEvent); final Verifier v = VerifierFactory.getVerifier(class_name); final 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 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(); } }
System.out.println("Pass 1:\n"+vr); vr = v.doPass2(); System.out.println("Pass 2:\n"+vr);
vr = v.doPass1(); System.out.println("Pass 1:\n" + vr); vr = v.doPass2(); System.out.println("Pass 2:\n" + vr); if (vr == VerificationResult.VR_OK) {
public void update(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; }
System.out.println("Pass 1:\n" + vr); vr = v.doPass2(); if (vr != VerificationResult.VR_OK) { System.out.println("Pass 2:\n" + vr);
/** Machine-generated. */ public void pass4Button_ActionPerformed( final java.awt.event.ActionEvent actionEvent ) { pass2Button_ActionPerformed(actionEvent); Color color = Color.green; final 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); final 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 (final ClassNotFoundException ex) { // FIXME: report the error ex.printStackTrace(); } } else { color = Color.yellow; } getPass3Panel().setBackground(color); getPass3Panel().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 = 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(); } }
/** * Assures the generic preconditions of a LoadClass instance. * The referenced class is loaded and pass2-verified. */ public void visitLoadClass(LoadClass o){ ObjectType t = o.getLoadClassType(cpg); if (t != null){// null means "no class is loaded" Verifier v = VerifierFactory.getVerifier(t.getClassName()); VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK){ constraintViolated((Instruction) o, "Class '"+o.getLoadClassType(cpg).getClassName()+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); } } }
/** * Assures the generic preconditions of a LoadClass instance. * The referenced class is loaded and pass2-verified. */ @Override public void visitLoadClass(final LoadClass o) { final ObjectType t = o.getLoadClassType(cpg); if (t != null) {// null means "no class is loaded" final Verifier v = VerifierFactory.getVerifier(t.getClassName()); final VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK) { constraintViolated((Instruction) o, "Class '"+o.getLoadClassType(cpg).getClassName()+ "' is referenced, but cannot be loaded and resolved: '"+vr+"'."); } } }
pass1TextPane.setBackground(Color.green); pass1TextPane.setText(vr.getMessage()); vr = v.doPass2(); if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED) { pass2TextPane.setText(vr.getMessage());
pass1TextPane.setText(vr.getMessage()); vr = v.doPass2(); if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){ pass2TextPane.setText(vr.getMessage());
String name = ((ObjectType)t).getClassName(); Verifier v = VerifierFactory.getVerifier( name ); VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK){ constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
public void testDefaultMethodValidation() { final String classname = Collection.class.getName(); final Verifier verifier = VerifierFactory.getVerifier(classname); VerificationResult result = verifier.doPass1(); assertEquals("Pass 1 verification of " + classname + " failed: " + result.getMessage(), VerificationResult.VERIFIED_OK, result.getStatus()); result = verifier.doPass2(); assertEquals("Pass 2 verification of " + classname + " failed: " + result.getMessage(), VerificationResult.VERIFIED_OK, result.getStatus()); } }
/** * Ensures the general preconditions of a FieldInstruction instance. */ @Override public void visitFieldInstruction(final FieldInstruction o) { // visitLoadClass(o) has been called before: Every FieldOrMethod // implements LoadClass. // visitCPInstruction(o) has been called before. // A FieldInstruction may be: GETFIELD, GETSTATIC, PUTFIELD, PUTSTATIC final Constant c = cpg.getConstant(o.getIndex()); if (!(c instanceof ConstantFieldref)) { constraintViolated(o, "Index '"+o.getIndex()+"' should refer to a CONSTANT_Fieldref_info structure, but refers to '"+c+"'."); } // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). final Type t = o.getType(cpg); if (t instanceof ObjectType) { final String name = ((ObjectType)t).getClassName(); final Verifier v = VerifierFactory.getVerifier( name ); final VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK) { constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); } } }
/** * Ensures the general preconditions of a FieldInstruction instance. */ public void visitFieldInstruction(FieldInstruction o){ // visitLoadClass(o) has been called before: Every FieldOrMethod // implements LoadClass. // visitCPInstruction(o) has been called before. // A FieldInstruction may be: GETFIELD, GETSTATIC, PUTFIELD, PUTSTATIC Constant c = cpg.getConstant(o.getIndex()); if (!(c instanceof ConstantFieldref)){ constraintViolated(o, "Index '"+o.getIndex()+"' should refer to a CONSTANT_Fieldref_info structure, but refers to '"+c+"'."); } // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). Type t = o.getType(cpg); if (t instanceof ObjectType){ String name = ((ObjectType)t).getClassName(); Verifier v = VerifierFactory.getVerifier( name ); VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK){ constraintViolated((Instruction) o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); } } }
VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK){ constraintViolated(o, "Return type class/interface could not be verified successfully: '"+vr.getMessage()+"'."); VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK){ constraintViolated(o, "Argument type class/interface could not be verified successfully: '"+vr.getMessage()+"'.");
final String name = ((ObjectType)t).getClassName(); final Verifier v = VerifierFactory.getVerifier( name ); final VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK) { constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");
result = verifier.doPass2(); if (result.getStatus() != VerificationResult.VERIFIED_OK) { return false;
final String name = ((ObjectType)t).getClassName(); final Verifier v = VerifierFactory.getVerifier( name ); final VerificationResult vr = v.doPass2(); if (vr.getStatus() != VerificationResult.VERIFIED_OK) { constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'.");