Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7A803200B17 for ; Tue, 21 Jun 2016 22:43:59 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 79041160A68; Tue, 21 Jun 2016 20:43:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2ACA4160A07 for ; Tue, 21 Jun 2016 22:43:57 +0200 (CEST) Received: (qmail 63269 invoked by uid 500); 21 Jun 2016 20:43:56 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 63260 invoked by uid 99); 21 Jun 2016 20:43:56 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jun 2016 20:43:56 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id AEE371805DB for ; Tue, 21 Jun 2016 20:43:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.426 X-Spam-Level: X-Spam-Status: No, score=-0.426 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id phap5nVwa9pO for ; Tue, 21 Jun 2016 20:43:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id C6B8D5F3F2 for ; Tue, 21 Jun 2016 20:43:42 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6DDB7E109E for ; Tue, 21 Jun 2016 20:43:41 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 6F8BD3A1AAE for ; Tue, 21 Jun 2016 20:43:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1749600 [5/6] - in /commons/proper/bcel/trunk/src: main/java/org/apache/bcel/generic/ main/java/org/apache/bcel/util/ main/java/org/apache/bcel/verifier/exc/ main/java/org/apache/bcel/verifier/statics/ main/java/org/apache/bcel/verifier/st... Date: Tue, 21 Jun 2016 20:43:39 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160621204340.6F8BD3A1AAE@svn01-us-west.apache.org> archived-at: Tue, 21 Jun 2016 20:43:59 -0000 Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java?rev=1749600&r1=1749599&r2=1749600&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java Tue Jun 21 20:43:38 2016 @@ -58,7 +58,7 @@ public class InstConstraintVisitor exten /** * The constructor. Constructs a new instance of this class. */ - public InstConstraintVisitor(){} + public InstConstraintVisitor() {} /** * The Execution Frame we're working on. @@ -88,7 +88,7 @@ public class InstConstraintVisitor exten * * @see #setFrame(Frame f) */ - private OperandStack stack(){ + private OperandStack stack() { return frame.getStack(); } @@ -97,7 +97,7 @@ public class InstConstraintVisitor exten * * @see #setFrame(Frame f) */ - private LocalVariables locals(){ + private LocalVariables locals() { return frame.getLocals(); } @@ -107,7 +107,7 @@ public class InstConstraintVisitor exten * StructuralCodeConstraintException. * @throws StructuralCodeConstraintException always. */ - private void constraintViolated(final Instruction violator, final String description){ + private void constraintViolated(final Instruction violator, final String description) { String fq_classname = violator.getClass().getName(); throw new StructuralCodeConstraintException( "Instruction "+ fq_classname.substring(fq_classname.lastIndexOf('.')+1) +" constraint violated: " + description); @@ -122,7 +122,7 @@ public class InstConstraintVisitor exten * @see #setConstantPoolGen(ConstantPoolGen cpg) * @see #setMethodGen(MethodGen mg) */ - public void setFrame(final Frame f){ // TODO could be package-protected? + public void setFrame(final Frame f) { // TODO could be package-protected? this.frame = f; //if (singleInstance.mg == null || singleInstance.cpg == null) // throw new AssertionViolatedException("Forgot to set important values first."); @@ -132,7 +132,7 @@ public class InstConstraintVisitor exten * Sets the ConstantPoolGen instance needed for constraint * checking prior to execution. */ - public void setConstantPoolGen(final ConstantPoolGen cpg){ // TODO could be package-protected? + public void setConstantPoolGen(final ConstantPoolGen cpg) { // TODO could be package-protected? this.cpg = cpg; } @@ -140,7 +140,7 @@ public class InstConstraintVisitor exten * Sets the MethodGen instance needed for constraint * checking prior to execution. */ - public void setMethodGen(final MethodGen mg){ + public void setMethodGen(final MethodGen mg) { this.mg = mg; } @@ -148,7 +148,7 @@ public class InstConstraintVisitor exten * Assures index is of type INT. * @throws StructuralCodeConstraintException if the above constraint is not satisfied. */ - private void indexOfInt(final Instruction o, final Type index){ + private void indexOfInt(final Instruction o, final Type index) { if (! index.equals(Type.INT)) { constraintViolated(o, "The 'index' is not of type int but of type "+index+"."); } @@ -160,14 +160,14 @@ public class InstConstraintVisitor exten * there are no uninitialized array types. * @throws StructuralCodeConstraintException if the above constraint is not satisfied. */ - private void referenceTypeIsInitialized(final Instruction o, final ReferenceType r){ - if (r instanceof UninitializedObjectType){ + private void referenceTypeIsInitialized(final Instruction o, final ReferenceType r) { + if (r instanceof UninitializedObjectType) { constraintViolated(o, "Working on an uninitialized object '"+r+"'."); } } /** Assures value is of type INT. */ - private void valueOfInt(final Instruction o, final Type value){ + private void valueOfInt(final Instruction o, final Type value) { if (! value.equals(Type.INT)) { constraintViolated(o, "The 'value' is not of type int but of type "+value+"."); } @@ -178,7 +178,7 @@ public class InstConstraintVisitor exten * returns true if and only if arrayref is non-NULL. * @throws StructuralCodeConstraintException if the above constraint is violated. */ - private boolean arrayrefOfArrayType(final Instruction o, final Type arrayref){ + private boolean arrayrefOfArrayType(final Instruction o, final 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+"."); } @@ -203,15 +203,15 @@ public class InstConstraintVisitor exten * @see #visitStackProducer(StackProducer o) * @see #visitStackInstruction(StackInstruction o) */ - private void _visitStackAccessor(final Instruction o){ + private void _visitStackAccessor(final Instruction o) { int consume = o.consumeStack(cpg); // Stack values are always consumed first; then produced. - if (consume > stack().slotsUsed()){ + if (consume > stack().slotsUsed()) { constraintViolated(o, "Cannot consume "+consume+" stack slots: only "+stack().slotsUsed()+" slot(s) left on stack!\nStack:\n"+stack()); } int produce = o.produceStack(cpg) - o.consumeStack(cpg); // Stack values are always consumed first; then produced. - if ( produce + stack().slotsUsed() > stack().maxStack() ){ + if ( produce + stack().slotsUsed() > stack().maxStack() ) { constraintViolated(o, "Cannot produce "+produce+" stack slots: only "+(stack().maxStack()-stack().slotsUsed())+ " free stack slot(s) left.\nStack:\n"+stack()); } @@ -228,12 +228,12 @@ public class InstConstraintVisitor exten * The referenced class is loaded and pass2-verified. */ @Override - public void visitLoadClass(final LoadClass o){ + public void visitLoadClass(final LoadClass o) { ObjectType t = o.getLoadClassType(cpg); - if (t != null){// null means "no class is loaded" + 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){ + if (vr.getStatus() != VerificationResult.VERIFIED_OK) { constraintViolated((Instruction) o, "Class '"+o.getLoadClassType(cpg).getClassName()+ "' is referenced, but cannot be loaded and resolved: '"+vr+"'."); } @@ -244,7 +244,7 @@ public class InstConstraintVisitor exten * Ensures the general preconditions of a StackConsumer instance. */ @Override - public void visitStackConsumer(final StackConsumer o){ + public void visitStackConsumer(final StackConsumer o) { _visitStackAccessor((Instruction) o); } @@ -252,7 +252,7 @@ public class InstConstraintVisitor exten * Ensures the general preconditions of a StackProducer instance. */ @Override - public void visitStackProducer(final StackProducer o){ + public void visitStackProducer(final StackProducer o) { _visitStackAccessor((Instruction) o); } @@ -266,9 +266,9 @@ public class InstConstraintVisitor exten * Ensures the general preconditions of a CPInstruction instance. */ @Override - public void visitCPInstruction(final CPInstruction o){ + public void visitCPInstruction(final CPInstruction o) { int idx = o.getIndex(); - if ((idx < 0) || (idx >= cpg.getSize())){ + if ((idx < 0) || (idx >= cpg.getSize())) { throw new AssertionViolatedException( "Huh?! Constant pool index of instruction '"+o+"' illegal? Pass 3a should have checked this!"); } @@ -278,23 +278,23 @@ public class InstConstraintVisitor exten * Ensures the general preconditions of a FieldInstruction instance. */ @Override - public void visitFieldInstruction(final FieldInstruction o){ + 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 Constant c = cpg.getConstant(o.getIndex()); - if (!(c instanceof ConstantFieldref)){ + 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){ + if (t instanceof ObjectType) { String name = ((ObjectType)t).getClassName(); Verifier v = VerifierFactory.getVerifier( name ); VerificationResult vr = v.doPass2(); - if (vr.getStatus() != VerificationResult.VERIFIED_OK){ + if (vr.getStatus() != VerificationResult.VERIFIED_OK) { constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); } } @@ -304,7 +304,7 @@ public class InstConstraintVisitor exten * Ensures the general preconditions of an InvokeInstruction instance. */ @Override - public void visitInvokeInstruction(final InvokeInstruction o){ + public void visitInvokeInstruction(final InvokeInstruction o) { // visitLoadClass(o) has been called before: Every FieldOrMethod // implements LoadClass. // visitCPInstruction(o) has been called before. @@ -315,7 +315,7 @@ public class InstConstraintVisitor exten * Ensures the general preconditions of a StackInstruction instance. */ @Override - public void visitStackInstruction(final StackInstruction o){ + public void visitStackInstruction(final StackInstruction o) { _visitStackAccessor(o); } @@ -324,8 +324,8 @@ public class InstConstraintVisitor exten * That is, the index of the local variable must be valid. */ @Override - public void visitLocalVariableInstruction(final LocalVariableInstruction o){ - if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ){ + public void visitLocalVariableInstruction(final LocalVariableInstruction o) { + if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ) { constraintViolated(o, "The 'index' is not a valid index into the local variable array."); } } @@ -334,19 +334,19 @@ public class InstConstraintVisitor exten * Assures the generic preconditions of a LoadInstruction instance. */ @Override - public void visitLoadInstruction(final LoadInstruction o){ + public void visitLoadInstruction(final LoadInstruction o) { //visitLocalVariableInstruction(o) is called before, because it is more generic. // LOAD instructions must not read Type.UNKNOWN - if (locals().get(o.getIndex()) == Type.UNKNOWN){ + if (locals().get(o.getIndex()) == Type.UNKNOWN) { constraintViolated(o, "Read-Access on local variable "+o.getIndex()+" with unknown content."); } // LOAD instructions, two-slot-values at index N must have Type.UNKNOWN // as a symbol for the higher halve at index N+1 // [suppose some instruction put an int at N+1--- our double at N is defective] - if (o.getType(cpg).getSize() == 2){ - if (locals().get(o.getIndex()+1) != Type.UNKNOWN){ + if (o.getType(cpg).getSize() == 2) { + if (locals().get(o.getIndex()+1) != Type.UNKNOWN) { constraintViolated(o, "Reading a two-locals value from local variables "+o.getIndex()+ " and "+(o.getIndex()+1)+" where the latter one is destroyed."); @@ -354,14 +354,14 @@ public class InstConstraintVisitor exten } // LOAD instructions must read the correct type. - if (!(o instanceof ALOAD)){ - if (locals().get(o.getIndex()) != o.getType(cpg) ){ + if (!(o instanceof ALOAD)) { + if (locals().get(o.getIndex()) != o.getType(cpg) ) { constraintViolated(o,"Local Variable type and LOADing Instruction type mismatch: Local Variable: '"+ locals().get(o.getIndex())+"'; Instruction type: '"+o.getType(cpg)+"'."); } } else{ // we deal with an ALOAD - if (!(locals().get(o.getIndex()) instanceof ReferenceType)){ + if (!(locals().get(o.getIndex()) instanceof ReferenceType)) { constraintViolated(o, "Local Variable type and LOADing Instruction type mismatch: Local Variable: '"+ locals().get(o.getIndex())+"'; Instruction expects a ReferenceType."); } @@ -370,7 +370,7 @@ public class InstConstraintVisitor exten } // LOAD instructions must have enough free stack slots. - if ((stack().maxStack() - stack().slotsUsed()) < o.getType(cpg).getSize()){ + if ((stack().maxStack() - stack().slotsUsed()) < o.getType(cpg).getSize()) { constraintViolated(o, "Not enough free stack slots to load a '"+o.getType(cpg)+"' onto the OperandStack."); } } @@ -379,26 +379,26 @@ public class InstConstraintVisitor exten * Assures the generic preconditions of a StoreInstruction instance. */ @Override - public void visitStoreInstruction(final StoreInstruction o){ + public void visitStoreInstruction(final StoreInstruction o) { //visitLocalVariableInstruction(o) is called before, because it is more generic. - if (stack().isEmpty()){ // Don't bother about 1 or 2 stack slots used. This check is implicitly done below while type checking. + if (stack().isEmpty()) { // Don't bother about 1 or 2 stack slots used. This check is implicitly done below while type checking. constraintViolated(o, "Cannot STORE: Stack to read from is empty."); } - if ( !(o instanceof ASTORE) ){ - if (! (stack().peek() == o.getType(cpg)) ){// the other xSTORE types are singletons in BCEL. + if ( !(o instanceof ASTORE) ) { + if (! (stack().peek() == o.getType(cpg)) ) {// the other xSTORE types are singletons in BCEL. constraintViolated(o, "Stack top type and STOREing Instruction type mismatch: Stack top: '"+stack().peek()+ "'; Instruction type: '"+o.getType(cpg)+"'."); } } else{ // we deal with ASTORE Type stacktop = stack().peek(); - if ( (!(stacktop instanceof ReferenceType)) && (!(stacktop instanceof ReturnaddressType)) ){ + if ( (!(stacktop instanceof ReferenceType)) && (!(stacktop instanceof ReturnaddressType)) ) { constraintViolated(o, "Stack top type and STOREing Instruction type mismatch: Stack top: '"+stack().peek()+ "'; Instruction expects a ReferenceType or a ReturnadressType."); } - //if (stacktop instanceof ReferenceType){ + //if (stacktop instanceof ReferenceType) { // referenceTypeIsInitialized(o, (ReferenceType) stacktop); //} } @@ -408,44 +408,44 @@ public class InstConstraintVisitor exten * Assures the generic preconditions of a ReturnInstruction instance. */ @Override - public void visitReturnInstruction(final ReturnInstruction o){ + public void visitReturnInstruction(final ReturnInstruction o) { Type method_type = mg.getType(); if (method_type == Type.BOOLEAN || method_type == Type.BYTE || method_type == Type.SHORT || - method_type == Type.CHAR){ + method_type == Type.CHAR) { method_type = Type.INT; } - if (o instanceof RETURN){ - if (method_type != Type.VOID){ + if (o instanceof RETURN) { + if (method_type != Type.VOID) { constraintViolated(o, "RETURN instruction in non-void method."); } else{ return; } } - if (o instanceof ARETURN){ - if (method_type == Type.VOID){ + if (o instanceof ARETURN) { + if (method_type == Type.VOID) { constraintViolated(o, "ARETURN instruction in void method."); } - if (stack().peek() == Type.NULL){ + if (stack().peek() == Type.NULL) { return; } - if (! (stack().peek() instanceof ReferenceType)){ + if (! (stack().peek() instanceof ReferenceType)) { constraintViolated(o, "Reference type expected on top of stack, but is: '"+stack().peek()+"'."); } referenceTypeIsInitialized(o, (ReferenceType) (stack().peek())); //ReferenceType objectref = (ReferenceType) (stack().peek()); // TODO: This can only be checked if using Staerk-et-al's "set of object types" instead of a // "wider cast object type" created during verification. - //if (! (objectref.isAssignmentCompatibleWith(mg.getType())) ){ + //if (! (objectref.isAssignmentCompatibleWith(mg.getType())) ) { // constraintViolated(o, "Type on stack top which should be returned is a '"+stack().peek()+ // "' which is not assignment compatible with the return type of this method, '"+mg.getType()+"'."); //} } else{ - if (! ( method_type.equals( stack().peek() ))){ + if (! ( method_type.equals( stack().peek() ))) { constraintViolated(o, "Current method has return type of '"+mg.getType()+"' expecting a '"+method_type+ "' on top of the stack. But stack top is a '"+stack().peek()+"'."); } @@ -460,13 +460,13 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitAALOAD(final AALOAD o){ + public void visitAALOAD(final AALOAD o) { Type arrayref = stack().peek(1); Type index = stack().peek(0); indexOfInt(o, index); - if (arrayrefOfArrayType(o, arrayref)){ - if (! (((ArrayType) arrayref).getElementType() instanceof ReferenceType)){ + if (arrayrefOfArrayType(o, arrayref)) { + if (! (((ArrayType) arrayref).getElementType() instanceof ReferenceType)) { constraintViolated(o, "The 'arrayref' does not refer to an array with elements of a ReferenceType but to an array of "+ ((ArrayType) arrayref).getElementType()+"."); @@ -479,21 +479,21 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitAASTORE(final AASTORE o){ + public void visitAASTORE(final AASTORE o) { Type arrayref = stack().peek(2); Type index = stack().peek(1); Type value = stack().peek(0); indexOfInt(o, index); - if (!(value instanceof ReferenceType)){ + if (!(value instanceof ReferenceType)) { constraintViolated(o, "The 'value' is not of a ReferenceType but of type "+value+"."); }else{ //referenceTypeIsInitialized(o, (ReferenceType) value); } // Don't bother further with "referenceTypeIsInitialized()", there are no arrays // of an uninitialized object type. - if (arrayrefOfArrayType(o, arrayref)){ - if (! (((ArrayType) arrayref).getElementType() instanceof ReferenceType)){ + if (arrayrefOfArrayType(o, arrayref)) { + if (! (((ArrayType) arrayref).getElementType() instanceof ReferenceType)) { constraintViolated(o, "The 'arrayref' does not refer to an array with elements of a ReferenceType but to an array of "+ ((ArrayType) arrayref).getElementType()+"."); } @@ -505,7 +505,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitACONST_NULL(final ACONST_NULL o){ + public void visitACONST_NULL(final ACONST_NULL o) { // Nothing needs to be done here. } @@ -513,7 +513,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitALOAD(final ALOAD o){ + public void visitALOAD(final ALOAD o) { //visitLoadInstruction(LoadInstruction) is called before. // Nothing else needs to be done here. @@ -523,7 +523,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitANEWARRAY(final ANEWARRAY o){ + public void visitANEWARRAY(final 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()+"'."); // The runtime constant pool item at that index must be a symbolic reference to a class, @@ -535,8 +535,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitARETURN(final ARETURN o){ - if (! (stack().peek() instanceof ReferenceType) ){ + public void visitARETURN(final ARETURN o) { + if (! (stack().peek() instanceof ReferenceType) ) { constraintViolated(o, "The 'objectref' at the stack top is not of a ReferenceType but of type '"+stack().peek()+"'."); } ReferenceType objectref = (ReferenceType) (stack().peek()); @@ -545,7 +545,7 @@ public class InstConstraintVisitor exten // The check below should already done via visitReturnInstruction(ReturnInstruction), see there. // It cannot be done using Staerk-et-al's "set of object types" instead of a // "wider cast object type", anyway. - //if (! objectref.isAssignmentCompatibleWith(mg.getReturnType() )){ + //if (! objectref.isAssignmentCompatibleWith(mg.getReturnType() )) { // constraintViolated(o, "The 'objectref' type "+objectref+ // " at the stack top is not assignment compatible with the return type '"+mg.getReturnType()+"' of the method."); //} @@ -555,7 +555,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitARRAYLENGTH(final ARRAYLENGTH o){ + public void visitARRAYLENGTH(final ARRAYLENGTH o) { Type arrayref = stack().peek(0); arrayrefOfArrayType(o, arrayref); } @@ -564,11 +564,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitASTORE(final ASTORE o){ - if (! ( (stack().peek() instanceof ReferenceType) || (stack().peek() instanceof ReturnaddressType) ) ){ + public void visitASTORE(final ASTORE o) { + if (! ( (stack().peek() instanceof ReferenceType) || (stack().peek() instanceof ReturnaddressType) ) ) { constraintViolated(o, "The 'objectref' is not of a ReferenceType or of ReturnaddressType but of "+stack().peek()+"."); } - //if (stack().peek() instanceof ReferenceType){ + //if (stack().peek() instanceof ReferenceType) { // referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) ); //} } @@ -577,11 +577,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitATHROW(final ATHROW o){ + public void visitATHROW(final ATHROW o) { try { // It's stated that 'objectref' must be of a ReferenceType --- but since Throwable is // not derived from an ArrayType, it follows that 'objectref' must be of an ObjectType or Type.NULL. - if (! ((stack().peek() instanceof ObjectType) || (stack().peek().equals(Type.NULL))) ){ + if (! ((stack().peek() instanceof ObjectType) || (stack().peek().equals(Type.NULL))) ) { constraintViolated(o, "The 'objectref' is not of an (initialized) ObjectType but of type "+stack().peek()+"."); } @@ -592,7 +592,7 @@ public class InstConstraintVisitor exten ObjectType exc = (ObjectType) (stack().peek()); ObjectType throwable = (ObjectType) (Type.getType("Ljava/lang/Throwable;")); - if ( (! (exc.subclassOf(throwable)) ) && (! (exc.equals(throwable))) ){ + if ( (! (exc.subclassOf(throwable)) ) && (! (exc.equals(throwable))) ) { constraintViolated(o, "The 'objectref' is not of class Throwable or of a subclass of Throwable, but of '"+stack().peek()+"'."); } @@ -606,13 +606,13 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitBALOAD(final BALOAD o){ + public void visitBALOAD(final BALOAD o) { Type arrayref = stack().peek(1); Type index = stack().peek(0); indexOfInt(o, index); - if (arrayrefOfArrayType(o, arrayref)){ + if (arrayrefOfArrayType(o, arrayref)) { if (! ( (((ArrayType) arrayref).getElementType().equals(Type.BOOLEAN)) || - (((ArrayType) arrayref).getElementType().equals(Type.BYTE)) ) ){ + (((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()+"'."); @@ -624,14 +624,14 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitBASTORE(final BASTORE o){ + public void visitBASTORE(final BASTORE o) { Type arrayref = stack().peek(2); Type index = stack().peek(1); Type value = stack().peek(0); indexOfInt(o, index); valueOfInt(o, value); - if (arrayrefOfArrayType(o, arrayref)){ + if (arrayrefOfArrayType(o, arrayref)) { if (! ( (((ArrayType) arrayref).getElementType().equals(Type.BOOLEAN)) || (((ArrayType) arrayref).getElementType().equals(Type.BYTE)) ) ) { constraintViolated(o, @@ -645,7 +645,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitBIPUSH(final BIPUSH o){ + public void visitBIPUSH(final BIPUSH o) { // Nothing to do... } @@ -653,7 +653,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitBREAKPOINT(final BREAKPOINT o){ + public void visitBREAKPOINT(final BREAKPOINT o) { throw new AssertionViolatedException( "In this JustIce verification pass there should not occur an illegal instruction such as BREAKPOINT."); } @@ -662,7 +662,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitCALOAD(final CALOAD o){ + public void visitCALOAD(final CALOAD o) { Type arrayref = stack().peek(1); Type index = stack().peek(0); @@ -674,15 +674,15 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitCASTORE(final CASTORE o){ + public void visitCASTORE(final CASTORE o) { Type arrayref = stack().peek(2); Type index = stack().peek(1); Type value = stack().peek(0); indexOfInt(o, index); valueOfInt(o, value); - if (arrayrefOfArrayType(o, arrayref)){ - if (! ((ArrayType) arrayref).getElementType().equals(Type.CHAR) ){ + if (arrayrefOfArrayType(o, arrayref)) { + if (! ((ArrayType) arrayref).getElementType().equals(Type.CHAR) ) { constraintViolated(o, "The 'arrayref' does not refer to an array with elements of type char but to an array of type "+ ((ArrayType) arrayref).getElementType()+"."); } @@ -693,10 +693,10 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitCHECKCAST(final CHECKCAST o){ + public void visitCHECKCAST(final CHECKCAST o) { // The objectref must be of type reference. Type objectref = stack().peek(0); - if (!(objectref instanceof ReferenceType)){ + if (!(objectref instanceof ReferenceType)) { constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+"."); } //else{ @@ -706,7 +706,7 @@ public class InstConstraintVisitor exten // current class (�3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant // pool item at the index must be a symbolic reference to a class, array, or interface type. Constant c = cpg.getConstant(o.getIndex()); - if (! (c instanceof ConstantClass)){ + if (! (c instanceof ConstantClass)) { constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'."); } } @@ -715,8 +715,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitD2F(final D2F o){ - if (stack().peek() != Type.DOUBLE){ + public void visitD2F(final D2F o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } } @@ -725,8 +725,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitD2I(final D2I o){ - if (stack().peek() != Type.DOUBLE){ + public void visitD2I(final D2I o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } } @@ -735,8 +735,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitD2L(final D2L o){ - if (stack().peek() != Type.DOUBLE){ + public void visitD2L(final D2L o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } } @@ -745,11 +745,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDADD(final DADD o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDADD(final DADD o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.DOUBLE){ + if (stack().peek(1) != Type.DOUBLE) { constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } @@ -758,16 +758,16 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDALOAD(final DALOAD o){ + public void visitDALOAD(final DALOAD o) { indexOfInt(o, stack().peek()); - if (stack().peek(1) == Type.NULL){ + if (stack().peek(1) == Type.NULL) { return; } - if (! (stack().peek(1) instanceof ArrayType)){ + if (! (stack().peek(1) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-top must be of type double[] but is '"+stack().peek(1)+"'."); } Type t = ((ArrayType) (stack().peek(1))).getBasicType(); - if (t != Type.DOUBLE){ + if (t != Type.DOUBLE) { constraintViolated(o, "Stack next-to-top must be of type double[] but is '"+stack().peek(1)+"'."); } } @@ -776,19 +776,19 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDASTORE(final DASTORE o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDASTORE(final DASTORE o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } indexOfInt(o, stack().peek(1)); - if (stack().peek(2) == Type.NULL){ + if (stack().peek(2) == Type.NULL) { return; } - if (! (stack().peek(2) instanceof ArrayType)){ + if (! (stack().peek(2) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-next-to-top must be of type double[] but is '"+stack().peek(2)+"'."); } Type t = ((ArrayType) (stack().peek(2))).getBasicType(); - if (t != Type.DOUBLE){ + if (t != Type.DOUBLE) { constraintViolated(o, "Stack next-to-next-to-top must be of type double[] but is '"+stack().peek(2)+"'."); } } @@ -797,11 +797,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDCMPG(final DCMPG o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDCMPG(final DCMPG o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.DOUBLE){ + if (stack().peek(1) != Type.DOUBLE) { constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } @@ -810,11 +810,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDCMPL(final DCMPL o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDCMPL(final DCMPL o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.DOUBLE){ + if (stack().peek(1) != Type.DOUBLE) { constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } @@ -823,7 +823,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDCONST(final DCONST o){ + public void visitDCONST(final DCONST o) { // There's nothing to be done here. } @@ -831,11 +831,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDDIV(final DDIV o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDDIV(final DDIV o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.DOUBLE){ + if (stack().peek(1) != Type.DOUBLE) { constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } @@ -844,7 +844,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDLOAD(final DLOAD o){ + public void visitDLOAD(final DLOAD o) { //visitLoadInstruction(LoadInstruction) is called before. // Nothing else needs to be done here. @@ -854,11 +854,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDMUL(final DMUL o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDMUL(final DMUL o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.DOUBLE){ + if (stack().peek(1) != Type.DOUBLE) { constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } @@ -867,8 +867,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDNEG(final DNEG o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDNEG(final DNEG o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } } @@ -877,11 +877,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDREM(final DREM o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDREM(final DREM o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.DOUBLE){ + if (stack().peek(1) != Type.DOUBLE) { constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } @@ -890,8 +890,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDRETURN(final DRETURN o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDRETURN(final DRETURN o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } } @@ -900,7 +900,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDSTORE(final DSTORE o){ + public void visitDSTORE(final DSTORE o) { //visitStoreInstruction(StoreInstruction) is called before. // Nothing else needs to be done here. @@ -910,11 +910,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDSUB(final DSUB o){ - if (stack().peek() != Type.DOUBLE){ + public void visitDSUB(final DSUB o) { + if (stack().peek() != Type.DOUBLE) { constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.DOUBLE){ + if (stack().peek(1) != Type.DOUBLE) { constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'."); } } @@ -923,8 +923,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDUP(final DUP o){ - if (stack().peek().getSize() != 1){ + public void visitDUP(final DUP o) { + if (stack().peek().getSize() != 1) { constraintViolated(o, "Won't DUP type on stack top '"+stack().peek()+ "' because it must occupy exactly one slot, not '"+stack().peek().getSize()+"'."); } @@ -934,12 +934,12 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDUP_X1(final DUP_X1 o){ - if (stack().peek().getSize() != 1){ + public void visitDUP_X1(final DUP_X1 o) { + if (stack().peek().getSize() != 1) { constraintViolated(o, "Type on stack top '"+stack().peek()+"' should occupy exactly one slot, not '"+stack().peek().getSize()+"'."); } - if (stack().peek(1).getSize() != 1){ + if (stack().peek(1).getSize() != 1) { constraintViolated(o, "Type on stack next-to-top '"+stack().peek(1)+ "' should occupy exactly one slot, not '"+stack().peek(1).getSize()+"'."); @@ -950,16 +950,16 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDUP_X2(final DUP_X2 o){ - if (stack().peek().getSize() != 1){ + public void visitDUP_X2(final DUP_X2 o) { + if (stack().peek().getSize() != 1) { constraintViolated(o, "Stack top type must be of size 1, but is '"+stack().peek()+"' of size '"+stack().peek().getSize()+"'."); } - if (stack().peek(1).getSize() == 2){ + if (stack().peek(1).getSize() == 2) { return; // Form 2, okay. } //stack().peek(1).getSize == 1. - if (stack().peek(2).getSize() != 1){ + if (stack().peek(2).getSize() != 1) { constraintViolated(o, "If stack top's size is 1 and stack next-to-top's size is 1,"+ " stack next-to-next-to-top's size must also be 1, but is: '"+ @@ -971,12 +971,12 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDUP2(final DUP2 o){ - if (stack().peek().getSize() == 2){ + public void visitDUP2(final DUP2 o) { + if (stack().peek().getSize() == 2) { return; // Form 2, okay. } //stack().peek().getSize() == 1. - if (stack().peek(1).getSize() != 1){ + if (stack().peek(1).getSize() != 1) { constraintViolated(o, "If stack top's size is 1, then stack next-to-top's size must also be 1. But it is '"+stack().peek(1)+ "' of size '"+stack().peek(1).getSize()+"'."); @@ -987,9 +987,9 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDUP2_X1(final DUP2_X1 o){ - if (stack().peek().getSize() == 2){ - if (stack().peek(1).getSize() != 1){ + public void visitDUP2_X1(final DUP2_X1 o) { + if (stack().peek().getSize() == 2) { + if (stack().peek(1).getSize() != 1) { constraintViolated(o, "If stack top's size is 2, then stack next-to-top's size must be 1. But it is '"+ stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'."); } @@ -998,11 +998,11 @@ public class InstConstraintVisitor exten } } else{ // stack top is of size 1 - if ( stack().peek(1).getSize() != 1 ){ + if ( stack().peek(1).getSize() != 1 ) { constraintViolated(o, "If stack top's size is 1, then stack next-to-top's size must also be 1. But it is '"+ stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'."); } - if ( stack().peek(2).getSize() != 1 ){ + if ( stack().peek(2).getSize() != 1 ) { constraintViolated(o, "If stack top's size is 1, then stack next-to-next-to-top's size must also be 1. But it is '"+ stack().peek(2)+"' of size '"+stack().peek(2).getSize()+"'."); } @@ -1013,14 +1013,14 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitDUP2_X2(final DUP2_X2 o){ + public void visitDUP2_X2(final DUP2_X2 o) { - if (stack().peek(0).getSize() == 2){ - if (stack().peek(1).getSize() == 2){ + if (stack().peek(0).getSize() == 2) { + if (stack().peek(1).getSize() == 2) { return; // Form 4 } // stack top size is 2, next-to-top's size is 1 - if ( stack().peek(2).getSize() != 1 ){ + if ( stack().peek(2).getSize() != 1 ) { constraintViolated(o, "If stack top's size is 2 and stack-next-to-top's size is 1,"+ " then stack next-to-next-to-top's size must also be 1. But it is '"+stack().peek(2)+ "' of size '"+stack().peek(2).getSize()+"'."); @@ -1030,11 +1030,11 @@ public class InstConstraintVisitor exten } } else{// stack top is of size 1 - if (stack().peek(1).getSize() == 1){ - if ( stack().peek(2).getSize() == 2 ){ + if (stack().peek(1).getSize() == 1) { + if ( stack().peek(2).getSize() == 2 ) { return; // Form 3 } - if ( stack().peek(3).getSize() == 1){ + if ( stack().peek(3).getSize() == 1) { return; // Form 1 } } @@ -1046,8 +1046,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitF2D(final F2D o){ - if (stack().peek() != Type.FLOAT){ + public void visitF2D(final F2D o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } } @@ -1056,8 +1056,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitF2I(final F2I o){ - if (stack().peek() != Type.FLOAT){ + public void visitF2I(final F2I o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } } @@ -1066,8 +1066,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitF2L(final F2L o){ - if (stack().peek() != Type.FLOAT){ + public void visitF2L(final F2L o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } } @@ -1076,11 +1076,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFADD(final FADD o){ - if (stack().peek() != Type.FLOAT){ + public void visitFADD(final FADD o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.FLOAT){ + if (stack().peek(1) != Type.FLOAT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } } @@ -1089,16 +1089,16 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFALOAD(final FALOAD o){ + public void visitFALOAD(final FALOAD o) { indexOfInt(o, stack().peek()); - if (stack().peek(1) == Type.NULL){ + if (stack().peek(1) == Type.NULL) { return; } - if (! (stack().peek(1) instanceof ArrayType)){ + if (! (stack().peek(1) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-top must be of type float[] but is '"+stack().peek(1)+"'."); } Type t = ((ArrayType) (stack().peek(1))).getBasicType(); - if (t != Type.FLOAT){ + if (t != Type.FLOAT) { constraintViolated(o, "Stack next-to-top must be of type float[] but is '"+stack().peek(1)+"'."); } } @@ -1107,19 +1107,19 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFASTORE(final FASTORE o){ - if (stack().peek() != Type.FLOAT){ + public void visitFASTORE(final FASTORE o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } indexOfInt(o, stack().peek(1)); - if (stack().peek(2) == Type.NULL){ + if (stack().peek(2) == Type.NULL) { return; } - if (! (stack().peek(2) instanceof ArrayType)){ + if (! (stack().peek(2) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-next-to-top must be of type float[] but is '"+stack().peek(2)+"'."); } Type t = ((ArrayType) (stack().peek(2))).getBasicType(); - if (t != Type.FLOAT){ + if (t != Type.FLOAT) { constraintViolated(o, "Stack next-to-next-to-top must be of type float[] but is '"+stack().peek(2)+"'."); } } @@ -1128,11 +1128,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFCMPG(final FCMPG o){ - if (stack().peek() != Type.FLOAT){ + public void visitFCMPG(final FCMPG o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.FLOAT){ + if (stack().peek(1) != Type.FLOAT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } } @@ -1141,11 +1141,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFCMPL(final FCMPL o){ - if (stack().peek() != Type.FLOAT){ + public void visitFCMPL(final FCMPL o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.FLOAT){ + if (stack().peek(1) != Type.FLOAT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } } @@ -1154,7 +1154,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFCONST(final FCONST o){ + public void visitFCONST(final FCONST o) { // nothing to do here. } @@ -1162,11 +1162,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFDIV(final FDIV o){ - if (stack().peek() != Type.FLOAT){ + public void visitFDIV(final FDIV o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.FLOAT){ + if (stack().peek(1) != Type.FLOAT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } } @@ -1175,7 +1175,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFLOAD(final FLOAD o){ + public void visitFLOAD(final FLOAD o) { //visitLoadInstruction(LoadInstruction) is called before. // Nothing else needs to be done here. @@ -1185,11 +1185,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFMUL(final FMUL o){ - if (stack().peek() != Type.FLOAT){ + public void visitFMUL(final FMUL o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.FLOAT){ + if (stack().peek(1) != Type.FLOAT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } } @@ -1198,8 +1198,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFNEG(final FNEG o){ - if (stack().peek() != Type.FLOAT){ + public void visitFNEG(final FNEG o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } } @@ -1208,11 +1208,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFREM(final FREM o){ - if (stack().peek() != Type.FLOAT){ + public void visitFREM(final FREM o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.FLOAT){ + if (stack().peek(1) != Type.FLOAT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } } @@ -1221,8 +1221,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFRETURN(final FRETURN o){ - if (stack().peek() != Type.FLOAT){ + public void visitFRETURN(final FRETURN o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } } @@ -1231,7 +1231,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFSTORE(final FSTORE o){ + public void visitFSTORE(final FSTORE o) { //visitStoreInstruction(StoreInstruction) is called before. // Nothing else needs to be done here. @@ -1241,11 +1241,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitFSUB(final FSUB o){ - if (stack().peek() != Type.FLOAT){ + public void visitFSUB(final FSUB o) { + if (stack().peek() != Type.FLOAT) { constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.FLOAT){ + if (stack().peek(1) != Type.FLOAT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'."); } } @@ -1263,10 +1263,10 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitGETFIELD(final GETFIELD o){ + public void visitGETFIELD(final GETFIELD o) { try { Type objectref = stack().peek(); - if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ){ + if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ) { constraintViolated(o, "Stack top should be an object reference that's not an array reference, but is '"+objectref+"'."); } @@ -1276,20 +1276,20 @@ public class InstConstraintVisitor exten Field[] fields = jc.getFields(); Field f = null; for (Field field : fields) { - if (field.getName().equals(field_name)){ + if (field.getName().equals(field_name)) { Type f_type = Type.getType(field.getSignature()); Type o_type = o.getType(cpg); /* TODO: Check if assignment compatibility is sufficient. * What does Sun do? */ - if (f_type.equals(o_type)){ + if (f_type.equals(o_type)) { f = field; break; } } } - if (f == null){ + if (f == null) { JavaClass[] superclasses = jc.getSuperClasses(); outer: for (JavaClass superclass : superclasses) { @@ -1313,22 +1313,22 @@ public class InstConstraintVisitor exten } } - if (f.isProtected()){ + if (f.isProtected()) { ObjectType classtype = getObjectType(o); ObjectType curr = ObjectType.getInstance(mg.getClassName()); if ( classtype.equals(curr) || - curr.subclassOf(classtype) ){ + curr.subclassOf(classtype) ) { Type t = stack().peek(); - if (t == Type.NULL){ + if (t == Type.NULL) { return; } - if (! (t instanceof ObjectType) ){ + if (! (t instanceof ObjectType) ) { constraintViolated(o, "The 'objectref' must refer to an object that's not an array. Found instead: '"+t+"'."); } ObjectType objreftype = (ObjectType) t; if (! ( objreftype.equals(curr) || - objreftype.subclassOf(curr) ) ){ + objreftype.subclassOf(curr) ) ) { //TODO: One day move to Staerk-et-al's "Set of object types" instead of "wider" object types // created during the verification. // "Wider" object types don't allow us to check for things like that below. @@ -1341,7 +1341,7 @@ public class InstConstraintVisitor exten } // TODO: Could go into Pass 3a. - if (f.isStatic()){ + if (f.isStatic()) { constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be."); } @@ -1355,7 +1355,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitGETSTATIC(final GETSTATIC o){ + public void visitGETSTATIC(final GETSTATIC o) { // Field must be static: see Pass 3a. } @@ -1363,7 +1363,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitGOTO(final GOTO o){ + public void visitGOTO(final GOTO o) { // nothing to do here. } @@ -1371,7 +1371,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitGOTO_W(final GOTO_W o){ + public void visitGOTO_W(final GOTO_W o) { // nothing to do here. } @@ -1379,8 +1379,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitI2B(final I2B o){ - if (stack().peek() != Type.INT){ + public void visitI2B(final I2B o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1389,8 +1389,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitI2C(final I2C o){ - if (stack().peek() != Type.INT){ + public void visitI2C(final I2C o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1399,8 +1399,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitI2D(final I2D o){ - if (stack().peek() != Type.INT){ + public void visitI2D(final I2D o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1409,8 +1409,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitI2F(final I2F o){ - if (stack().peek() != Type.INT){ + public void visitI2F(final I2F o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1419,8 +1419,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitI2L(final I2L o){ - if (stack().peek() != Type.INT){ + public void visitI2L(final I2L o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1429,8 +1429,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitI2S(final I2S o){ - if (stack().peek() != Type.INT){ + public void visitI2S(final I2S o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1439,11 +1439,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIADD(final IADD o){ - if (stack().peek() != Type.INT){ + public void visitIADD(final IADD o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1452,16 +1452,16 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIALOAD(final IALOAD o){ + public void visitIALOAD(final IALOAD o) { indexOfInt(o, stack().peek()); - if (stack().peek(1) == Type.NULL){ + if (stack().peek(1) == Type.NULL) { return; } - if (! (stack().peek(1) instanceof ArrayType)){ + if (! (stack().peek(1) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-top must be of type int[] but is '"+stack().peek(1)+"'."); } Type t = ((ArrayType) (stack().peek(1))).getBasicType(); - if (t != Type.INT){ + if (t != Type.INT) { constraintViolated(o, "Stack next-to-top must be of type int[] but is '"+stack().peek(1)+"'."); } } @@ -1470,11 +1470,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIAND(final IAND o){ - if (stack().peek() != Type.INT){ + public void visitIAND(final IAND o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1483,19 +1483,19 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIASTORE(final IASTORE o){ - if (stack().peek() != Type.INT){ + public void visitIASTORE(final IASTORE o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } indexOfInt(o, stack().peek(1)); - if (stack().peek(2) == Type.NULL){ + if (stack().peek(2) == Type.NULL) { return; } - if (! (stack().peek(2) instanceof ArrayType)){ + if (! (stack().peek(2) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-next-to-top must be of type int[] but is '"+stack().peek(2)+"'."); } Type t = ((ArrayType) (stack().peek(2))).getBasicType(); - if (t != Type.INT){ + if (t != Type.INT) { constraintViolated(o, "Stack next-to-next-to-top must be of type int[] but is '"+stack().peek(2)+"'."); } } @@ -1504,7 +1504,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitICONST(final ICONST o){ + public void visitICONST(final ICONST o) { //nothing to do here. } @@ -1512,11 +1512,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIDIV(final IDIV o){ - if (stack().peek() != Type.INT){ + public void visitIDIV(final IDIV o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1525,13 +1525,13 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIF_ACMPEQ(final IF_ACMPEQ o){ - if (!(stack().peek() instanceof ReferenceType)){ + public void visitIF_ACMPEQ(final IF_ACMPEQ o) { + if (!(stack().peek() instanceof ReferenceType)) { constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'."); } //referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) ); - if (!(stack().peek(1) instanceof ReferenceType)){ + if (!(stack().peek(1) instanceof ReferenceType)) { constraintViolated(o, "The value at the stack next-to-top is not of a ReferenceType, but of type '"+stack().peek(1)+"'."); } //referenceTypeIsInitialized(o, (ReferenceType) (stack().peek(1)) ); @@ -1542,12 +1542,12 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIF_ACMPNE(final IF_ACMPNE o){ - if (!(stack().peek() instanceof ReferenceType)){ + public void visitIF_ACMPNE(final IF_ACMPNE o) { + if (!(stack().peek() instanceof ReferenceType)) { constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'."); //referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) ); } - if (!(stack().peek(1) instanceof ReferenceType)){ + if (!(stack().peek(1) instanceof ReferenceType)) { constraintViolated(o, "The value at the stack next-to-top is not of a ReferenceType, but of type '"+stack().peek(1)+"'."); //referenceTypeIsInitialized(o, (ReferenceType) (stack().peek(1)) ); } @@ -1557,11 +1557,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIF_ICMPEQ(final IF_ICMPEQ o){ - if (stack().peek() != Type.INT){ + public void visitIF_ICMPEQ(final IF_ICMPEQ o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1570,11 +1570,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIF_ICMPGE(final IF_ICMPGE o){ - if (stack().peek() != Type.INT){ + public void visitIF_ICMPGE(final IF_ICMPGE o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1583,11 +1583,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIF_ICMPGT(final IF_ICMPGT o){ - if (stack().peek() != Type.INT){ + public void visitIF_ICMPGT(final IF_ICMPGT o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1596,11 +1596,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIF_ICMPLE(final IF_ICMPLE o){ - if (stack().peek() != Type.INT){ + public void visitIF_ICMPLE(final IF_ICMPLE o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1609,11 +1609,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIF_ICMPLT(final IF_ICMPLT o){ - if (stack().peek() != Type.INT){ + public void visitIF_ICMPLT(final IF_ICMPLT o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1622,11 +1622,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIF_ICMPNE(final IF_ICMPNE o){ - if (stack().peek() != Type.INT){ + public void visitIF_ICMPNE(final IF_ICMPNE o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1635,8 +1635,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIFEQ(final IFEQ o){ - if (stack().peek() != Type.INT){ + public void visitIFEQ(final IFEQ o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1645,8 +1645,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIFGE(final IFGE o){ - if (stack().peek() != Type.INT){ + public void visitIFGE(final IFGE o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1655,8 +1655,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIFGT(final IFGT o){ - if (stack().peek() != Type.INT){ + public void visitIFGT(final IFGT o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1665,8 +1665,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIFLE(final IFLE o){ - if (stack().peek() != Type.INT){ + public void visitIFLE(final IFLE o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1675,8 +1675,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIFLT(final IFLT o){ - if (stack().peek() != Type.INT){ + public void visitIFLT(final IFLT o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1685,8 +1685,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIFNE(final IFNE o){ - if (stack().peek() != Type.INT){ + public void visitIFNE(final IFNE o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1695,8 +1695,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIFNONNULL(final IFNONNULL o){ - if (!(stack().peek() instanceof ReferenceType)){ + public void visitIFNONNULL(final IFNONNULL o) { + if (!(stack().peek() instanceof ReferenceType)) { constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'."); } referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) ); @@ -1706,8 +1706,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIFNULL(final IFNULL o){ - if (!(stack().peek() instanceof ReferenceType)){ + public void visitIFNULL(final IFNULL o) { + if (!(stack().peek() instanceof ReferenceType)) { constraintViolated(o, "The value at the stack top is not of a ReferenceType, but of type '"+stack().peek()+"'."); } referenceTypeIsInitialized(o, (ReferenceType) (stack().peek()) ); @@ -1717,9 +1717,9 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIINC(final IINC o){ + public void visitIINC(final IINC o) { // Mhhh. In BCEL, at this time "IINC" is not a LocalVariableInstruction. - if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ){ + if (locals().maxLocals() <= (o.getType(cpg).getSize()==1? o.getIndex() : o.getIndex()+1) ) { constraintViolated(o, "The 'index' is not a valid index into the local variable array."); } @@ -1730,7 +1730,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitILOAD(final ILOAD o){ + public void visitILOAD(final ILOAD o) { // All done by visitLocalVariableInstruction(), visitLoadInstruction() } @@ -1738,7 +1738,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIMPDEP1(final IMPDEP1 o){ + public void visitIMPDEP1(final IMPDEP1 o) { throw new AssertionViolatedException( "In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP1."); } @@ -1747,7 +1747,7 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIMPDEP2(final IMPDEP2 o){ + public void visitIMPDEP2(final IMPDEP2 o) { throw new AssertionViolatedException( "In this JustIce verification pass there should not occur an illegal instruction such as IMPDEP2."); } @@ -1756,11 +1756,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitIMUL(final IMUL o){ - if (stack().peek() != Type.INT){ + public void visitIMUL(final IMUL o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } - if (stack().peek(1) != Type.INT){ + if (stack().peek(1) != Type.INT) { constraintViolated(o, "The value at the stack next-to-top is not of type 'int', but of type '"+stack().peek(1)+"'."); } } @@ -1769,8 +1769,8 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitINEG(final INEG o){ - if (stack().peek() != Type.INT){ + public void visitINEG(final INEG o) { + if (stack().peek() != Type.INT) { constraintViolated(o, "The value at the stack top is not of type 'int', but of type '"+stack().peek()+"'."); } } @@ -1779,10 +1779,10 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitINSTANCEOF(final INSTANCEOF o){ + public void visitINSTANCEOF(final INSTANCEOF o) { // The objectref must be of type reference. Type objectref = stack().peek(0); - if (!(objectref instanceof ReferenceType)){ + if (!(objectref instanceof ReferenceType)) { constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+"."); } //else{ @@ -1792,7 +1792,7 @@ public class InstConstraintVisitor exten // current class (�3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant // pool item at the index must be a symbolic reference to a class, array, or interface type. Constant c = cpg.getConstant(o.getIndex()); - if (! (c instanceof ConstantClass)){ + if (! (c instanceof ConstantClass)) { constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'."); } } @@ -1802,7 +1802,7 @@ public class InstConstraintVisitor exten * @since 6.0 */ @Override - public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC o){ + public void visitINVOKEDYNAMIC(final INVOKEDYNAMIC o) { throw new RuntimeException("INVOKEDYNAMIC instruction is not supported at this time"); } @@ -1810,11 +1810,11 @@ public class InstConstraintVisitor exten * Ensures the specific preconditions of the said instruction. */ @Override - public void visitINVOKEINTERFACE(final INVOKEINTERFACE o){ + public void visitINVOKEINTERFACE(final INVOKEINTERFACE o) { // Method is not native, otherwise pass 3 would not happen. int count = o.getCount(); - if (count == 0){ + if (count == 0) { constraintViolated(o, "The 'count' argument must not be 0."); } // It is a ConstantInterfaceMethodref, Pass 3a made it sure. @@ -1824,11 +1824,11 @@ public class InstConstraintVisitor exten // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). Type t = o.getType(cpg); - if (t instanceof ObjectType){ + if (t instanceof ObjectType) { String name = ((ObjectType)t).getClassName(); Verifier v = VerifierFactory.getVerifier( name ); VerificationResult vr = v.doPass2(); - if (vr.getStatus() != VerificationResult.VERIFIED_OK){ + if (vr.getStatus() != VerificationResult.VERIFIED_OK) { constraintViolated(o, "Class '"+name+"' is referenced, but cannot be loaded and resolved: '"+vr+"'."); } } @@ -1837,22 +1837,22 @@ public class InstConstraintVisitor exten Type[] argtypes = o.getArgumentTypes(cpg); int nargs = argtypes.length; - for (int i=nargs-1; i>=0; i--){ + for (int i=nargs-1; i>=0; i--) { Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 Type fromDesc = argtypes[i]; if (fromDesc == Type.BOOLEAN || fromDesc == Type.BYTE || fromDesc == Type.CHAR || - fromDesc == Type.SHORT){ + fromDesc == Type.SHORT) { fromDesc = Type.INT; } - if (! fromStack.equals(fromDesc)){ - if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType){ + if (! fromStack.equals(fromDesc)) { + if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType) { ReferenceType rFromStack = (ReferenceType) fromStack; //ReferenceType rFromDesc = (ReferenceType) fromDesc; // TODO: This can only be checked when using Staerk-et-al's "set of object types" // instead of a "wider cast object type" created during verification. - //if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ){ + //if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ) { // constraintViolated(o, "Expecting a '"+fromDesc+"' but found a '"+fromStack+ // "' on the stack (which is not assignment compatible)."); //} @@ -1865,15 +1865,15 @@ public class InstConstraintVisitor exten } Type objref = stack().peek(nargs); - if (objref == Type.NULL){ + if (objref == Type.NULL) { return; } - if (! (objref instanceof ReferenceType) ){ + if (! (objref instanceof ReferenceType) ) { constraintViolated(o, "Expecting a reference type as 'objectref' on the stack, not a '"+objref+"'."); } referenceTypeIsInitialized(o, (ReferenceType) objref); - if (!(objref instanceof ObjectType)){ - if (!(objref instanceof ArrayType)){ // could be a ReturnaddressType + if (!(objref instanceof ObjectType)) { + if (!(objref instanceof ArrayType)) { // could be a ReturnaddressType constraintViolated(o, "Expecting an ObjectType as 'objectref' on the stack, not a '"+objref+"'."); } else{ @@ -1885,15 +1885,15 @@ public class InstConstraintVisitor exten // String theInterface = o.getClassName(cpg); // TODO: This can only be checked if we're using Staerk-et-al's "set of object types" // instead of "wider cast object types" generated during verification. - //if ( ! Repository.implementationOf(objref_classname, theInterface) ){ + //if ( ! Repository.implementationOf(objref_classname, theInterface) ) { // constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theInterface+"' as expected."); //} int counted_count = 1; // 1 for the objectref - for (int i=0; i