Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/StringRepresentation.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/StringRepresentation.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/StringRepresentation.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/statics/StringRepresentation.java Tue Jun 21 20:50:19 2016 @@ -123,7 +123,7 @@ public class StringRepresentation extend ret = obj.toString(); } - catch (RuntimeException e) { + catch (final RuntimeException e) { // including ClassFormatException, trying to convert the "signature" of a ReturnaddressType LocalVariable // (shouldn't occur, but people do crazy things) String s = obj.getClass().getName();
Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ControlFlowGraph.java Tue Jun 21 20:50:19 2016 @@ -122,7 +122,7 @@ public class ControlFlowGraph{ Frame org; - InstructionContext jsr = lastExecutionJSR(); + final InstructionContext jsr = lastExecutionJSR(); org = outFrames.get(jsr); @@ -137,7 +137,7 @@ public class ControlFlowGraph{ public Frame getInFrame() { Frame org; - InstructionContext jsr = lastExecutionJSR(); + final InstructionContext jsr = lastExecutionJSR(); org = inFrames.get(jsr); @@ -194,7 +194,7 @@ public class ControlFlowGraph{ // Now we're sure the inFrame has changed! // new inFrame is already merged in, see above. - Frame workingFrame = inF.getClone(); + final Frame workingFrame = inF.getClone(); try{ // This verifies the InstructionConstraint for the current @@ -203,7 +203,7 @@ public class ControlFlowGraph{ icv.setFrame(workingFrame); getInstruction().accept(icv); } - catch(StructuralCodeConstraintException ce) { + catch(final StructuralCodeConstraintException ce) { ce.extendMessage("","\nInstructionHandle: "+getInstruction()+"\n"); ce.extendMessage("","\nExecution Frame:\n"+workingFrame); extendMessageWithFlow(ce); @@ -230,7 +230,7 @@ public class ControlFlowGraph{ //TODO: Put information in the brackets, e.g. // Is this an ExceptionHandler? Is this a RET? Is this the start of // a subroutine? - String ret = getInstruction().toString(false)+"\t[InstructionContext]"; + final String ret = getInstruction().toString(false)+"\t[InstructionContext]"; return ret; } @@ -240,13 +240,13 @@ public class ControlFlowGraph{ */ private boolean mergeInFrames(final Frame inFrame) { // TODO: Can be performance-improved. - Frame inF = inFrames.get(lastExecutionJSR()); - OperandStack oldstack = inF.getStack().getClone(); - LocalVariables oldlocals = inF.getLocals().getClone(); + final Frame inF = inFrames.get(lastExecutionJSR()); + final OperandStack oldstack = inF.getStack().getClone(); + final LocalVariables oldlocals = inF.getLocals().getClone(); try { inF.getStack().merge(inFrame.getStack()); inF.getLocals().merge(inFrame.getLocals()); - } catch (StructuralCodeConstraintException sce) { + } catch (final StructuralCodeConstraintException sce) { extendMessageWithFlow(sce); throw sce; } @@ -273,7 +273,7 @@ public class ControlFlowGraph{ * violation that triggered the throwing of the "e" object. */ private void extendMessageWithFlow(final StructuralCodeConstraintException e) { - String s = "Execution flow:\n"; + final String s = "Execution flow:\n"; e.extendMessage("", s+getExecutionChain()); } @@ -294,12 +294,12 @@ public class ControlFlowGraph{ */ private InstructionContextImpl lastExecutionJSR() { - int size = executionPredecessors.size(); + final int size = executionPredecessors.size(); int retcount = 0; for (int i=size-1; i>=0; i--) { - InstructionContextImpl current = (InstructionContextImpl) (executionPredecessors.get(i)); - Instruction currentlast = current.getInstruction().getInstruction(); + final InstructionContextImpl current = (InstructionContextImpl) (executionPredecessors.get(i)); + final Instruction currentlast = current.getInstruction().getInstruction(); if (currentlast instanceof RET) { retcount++; } @@ -330,10 +330,10 @@ public class ControlFlowGraph{ final InstructionHandle[] empty = new InstructionHandle[0]; final InstructionHandle[] single = new InstructionHandle[1]; - Instruction inst = getInstruction().getInstruction(); + final Instruction inst = getInstruction().getInstruction(); if (inst instanceof RET) { - Subroutine s = subroutines.subroutineOf(getInstruction()); + final Subroutine s = subroutines.subroutineOf(getInstruction()); if (s==null) { //return empty; // RET in dead code. "empty" would be the correct answer, but we know something about the surrounding project... throw new AssertionViolatedException("Asking for successors of a RET in dead code?!"); @@ -343,8 +343,8 @@ public class ControlFlowGraph{ // will want it. Thanks Johannes Wust. //throw new AssertionViolatedException("DID YOU REALLY WANT TO ASK FOR RET'S SUCCS?"); - InstructionHandle[] jsrs = s.getEnteringJsrInstructions(); - InstructionHandle[] ret = new InstructionHandle[jsrs.length]; + final InstructionHandle[] jsrs = s.getEnteringJsrInstructions(); + final InstructionHandle[] ret = new InstructionHandle[jsrs.length]; for (int i=0; i<jsrs.length; i++) { ret[i] = jsrs[i].getNext(); } @@ -377,8 +377,8 @@ public class ControlFlowGraph{ if (inst instanceof Select) { // BCEL's getTargets() returns only the non-default targets, // thanks to Eli Tilevich for reporting. - InstructionHandle[] matchTargets = ((Select) inst).getTargets(); - InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1]; + final InstructionHandle[] matchTargets = ((Select) inst).getTargets(); + final InstructionHandle[] ret = new InstructionHandle[matchTargets.length+1]; ret[0] = ((Select) inst).getTarget(); System.arraycopy(matchTargets, 0, ret, 1, matchTargets.length); return ret; @@ -426,8 +426,8 @@ public class ControlFlowGraph{ subroutines = new Subroutines(method_gen, enableJustIceCheck); exceptionhandlers = new ExceptionHandlers(method_gen); - InstructionHandle[] instructionhandles = method_gen.getInstructionList().getInstructionHandles(); - for (InstructionHandle instructionhandle : instructionhandles) { + final InstructionHandle[] instructionhandles = method_gen.getInstructionList().getInstructionHandles(); + for (final InstructionHandle instructionhandle : instructionhandles) { instructionContexts.put(instructionhandle, new InstructionContextImpl(instructionhandle)); } @@ -438,7 +438,7 @@ public class ControlFlowGraph{ * Returns the InstructionContext of a given instruction. */ public InstructionContext contextOf(final InstructionHandle inst) { - InstructionContext ic = instructionContexts.get(inst); + final InstructionContext ic = instructionContexts.get(inst); if (ic == null) { throw new AssertionViolatedException("InstructionContext requested for an InstructionHandle that's not known!"); } @@ -450,7 +450,7 @@ public class ControlFlowGraph{ * in a naturally ordered manner. */ public InstructionContext[] contextsOf(final InstructionHandle[] insts) { - InstructionContext[] ret = new InstructionContext[insts.length]; + final InstructionContext[] ret = new InstructionContext[insts.length]; for (int i=0; i<insts.length; i++) { ret[i] = contextOf(insts[i]); } @@ -463,7 +463,7 @@ public class ControlFlowGraph{ * <B>(NOT ORDERED!)</B>. */ public InstructionContext[] getInstructionContexts() { - InstructionContext[] ret = new InstructionContext[instructionContexts.values().size()]; + final InstructionContext[] ret = new InstructionContext[instructionContexts.values().size()]; return instructionContexts.values().toArray(ret); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExceptionHandlers.java Tue Jun 21 20:50:19 2016 @@ -44,9 +44,9 @@ public class ExceptionHandlers{ */ public ExceptionHandlers(final MethodGen mg) { exceptionhandlers = new HashMap<>(); - CodeExceptionGen[] cegs = mg.getExceptionHandlers(); - for (CodeExceptionGen ceg : cegs) { - ExceptionHandler eh = new ExceptionHandler(ceg.getCatchType(), ceg.getHandlerPC()); + final CodeExceptionGen[] cegs = mg.getExceptionHandlers(); + for (final CodeExceptionGen ceg : cegs) { + final ExceptionHandler eh = new ExceptionHandler(ceg.getCatchType(), ceg.getHandlerPC()); for (InstructionHandle ih=ceg.getStartPC(); ih != ceg.getEndPC().getNext(); ih=ih.getNext()) { Set<ExceptionHandler> hs; hs = exceptionhandlers.get(ih); @@ -64,7 +64,7 @@ public class ExceptionHandlers{ * handlers that protect the instruction ih. */ public ExceptionHandler[] getExceptionHandlers(final InstructionHandle ih) { - Set<ExceptionHandler> hsSet = exceptionhandlers.get(ih); + final Set<ExceptionHandler> hsSet = exceptionhandlers.get(ih); if (hsSet == null) { return new ExceptionHandler[0]; } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/ExecutionVisitor.java Tue Jun 21 20:50:19 2016 @@ -125,12 +125,12 @@ public class ExecutionVisitor extends Em public void visitAALOAD(final AALOAD o) { stack().pop(); // pop the index int //System.out.print(stack().peek()); - Type t = stack().pop(); // Pop Array type + final Type t = stack().pop(); // Pop Array type if (t == Type.NULL) { stack().push(Type.NULL); } // Do nothing stackwise --- a NullPointerException is thrown at Run-Time else{ - ArrayType at = (ArrayType) t; + final ArrayType at = (ArrayType) t; stack().push(at.getElementType()); } } @@ -179,7 +179,7 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitATHROW(final ATHROW o) { - Type t = stack().pop(); + final Type t = stack().pop(); stack().clear(); if (t.equals(Type.NULL)) { stack().push(Type.getType("Ljava/lang/NullPointerException;")); @@ -347,15 +347,15 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitDUP(final DUP o) { - Type t = stack().pop(); + final Type t = stack().pop(); stack().push(t); stack().push(t); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitDUP_X1(final DUP_X1 o) { - Type w1 = stack().pop(); - Type w2 = stack().pop(); + final Type w1 = stack().pop(); + final Type w2 = stack().pop(); stack().push(w1); stack().push(w2); stack().push(w1); @@ -363,15 +363,15 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitDUP_X2(final DUP_X2 o) { - Type w1 = stack().pop(); - Type w2 = stack().pop(); + final Type w1 = stack().pop(); + final Type w2 = stack().pop(); if (w2.getSize() == 2) { stack().push(w1); stack().push(w2); stack().push(w1); } else{ - Type w3 = stack().pop(); + final Type w3 = stack().pop(); stack().push(w1); stack().push(w3); stack().push(w2); @@ -381,13 +381,13 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitDUP2(final DUP2 o) { - Type t = stack().pop(); + final Type t = stack().pop(); if (t.getSize() == 2) { stack().push(t); stack().push(t); } else{ // t.getSize() is 1 - Type u = stack().pop(); + final Type u = stack().pop(); stack().push(u); stack().push(t); stack().push(u); @@ -397,16 +397,16 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitDUP2_X1(final DUP2_X1 o) { - Type t = stack().pop(); + final Type t = stack().pop(); if (t.getSize() == 2) { - Type u = stack().pop(); + final Type u = stack().pop(); stack().push(t); stack().push(u); stack().push(t); } else{ //t.getSize() is1 - Type u = stack().pop(); - Type v = stack().pop(); + final Type u = stack().pop(); + final Type v = stack().pop(); stack().push(u); stack().push(t); stack().push(v); @@ -417,15 +417,15 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitDUP2_X2(final DUP2_X2 o) { - Type t = stack().pop(); + final Type t = stack().pop(); if (t.getSize() == 2) { - Type u = stack().pop(); + final Type u = stack().pop(); if (u.getSize() == 2) { stack().push(t); stack().push(u); stack().push(t); }else{ - Type v = stack().pop(); + final Type v = stack().pop(); stack().push(t); stack().push(v); stack().push(u); @@ -433,8 +433,8 @@ public class ExecutionVisitor extends Em } } else{ //t.getSize() is 1 - Type u = stack().pop(); - Type v = stack().pop(); + final Type u = stack().pop(); + final Type v = stack().pop(); if (v.getSize() == 2) { stack().push(u); stack().push(t); @@ -442,7 +442,7 @@ public class ExecutionVisitor extends Em stack().push(u); stack().push(t); }else{ - Type w = stack().pop(); + final Type w = stack().pop(); stack().push(u); stack().push(t); stack().push(w); @@ -837,7 +837,7 @@ public class ExecutionVisitor extends Em @Override public void visitINVOKESPECIAL(final INVOKESPECIAL o) { if (o.getMethodName(cpg).equals(Const.CONSTRUCTOR_NAME)) { - UninitializedObjectType t = (UninitializedObjectType) stack().peek(o.getArgumentTypes(cpg).length); + final UninitializedObjectType t = (UninitializedObjectType) stack().peek(o.getArgumentTypes(cpg).length); if (t == Frame.getThis()) { Frame.setThis(null); } @@ -1040,7 +1040,7 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitLDC(final LDC o) { - Constant c = cpg.getConstant(o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); if (c instanceof ConstantInteger) { stack().push(Type.INT); } @@ -1056,7 +1056,7 @@ public class ExecutionVisitor extends Em } /** Symbolically executes the corresponding Java Virtual Machine instruction. */ public void visitLDC_W(final LDC_W o) { - Constant c = cpg.getConstant(o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); if (c instanceof ConstantInteger) { stack().push(Type.INT); } @@ -1073,7 +1073,7 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitLDC2_W(final LDC2_W o) { - Constant c = cpg.getConstant(o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); if (c instanceof ConstantLong) { stack().push(Type.LONG); } @@ -1212,7 +1212,7 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitPOP2(final POP2 o) { - Type t = stack().pop(); + final Type t = stack().pop(); if (t.getSize() == 1) { stack().pop(); } @@ -1261,8 +1261,8 @@ public class ExecutionVisitor extends Em /** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitSWAP(final SWAP o) { - Type t = stack().pop(); - Type u = stack().pop(); + final Type t = stack().pop(); + final Type u = stack().pop(); stack().push(t); stack().push(u); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Frame.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Frame.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Frame.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Frame.java Tue Jun 21 20:50:19 2016 @@ -70,7 +70,7 @@ public class Frame{ */ @Override protected Object clone() { - Frame f = new Frame(locals.getClone(), stack.getClone()); + final Frame f = new Frame(locals.getClone(), stack.getClone()); return f; } @@ -108,7 +108,7 @@ public class Frame{ if (!(o instanceof Frame)) { return false; // implies "null" is non-equal. } - Frame f = (Frame) o; + final Frame f = (Frame) o; return this.stack.equals(f.stack) && this.locals.equals(f.locals); } 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=1749603&r1=1749602&r2=1749603&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:50:19 2016 @@ -108,7 +108,7 @@ public class InstConstraintVisitor exten * @throws StructuralCodeConstraintException always. */ private void constraintViolated(final Instruction violator, final String description) { - String fq_classname = violator.getClass().getName(); + final String fq_classname = violator.getClass().getName(); throw new StructuralCodeConstraintException( "Instruction "+ fq_classname.substring(fq_classname.lastIndexOf('.')+1) +" constraint violated: " + description); } @@ -204,13 +204,13 @@ public class InstConstraintVisitor exten * @see #visitStackInstruction(StackInstruction o) */ private void _visitStackAccessor(final Instruction o) { - int consume = o.consumeStack(cpg); // Stack values are always consumed first; then produced. + final int consume = o.consumeStack(cpg); // Stack values are always consumed first; then produced. 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. + final int produce = o.produceStack(cpg) - o.consumeStack(cpg); // Stack values are always consumed first; then produced. 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()); @@ -229,10 +229,10 @@ public class InstConstraintVisitor exten */ @Override public void visitLoadClass(final LoadClass o) { - ObjectType t = o.getLoadClassType(cpg); + final ObjectType t = o.getLoadClassType(cpg); if (t != null) {// null means "no class is loaded" - Verifier v = VerifierFactory.getVerifier(t.getClassName()); - VerificationResult vr = v.doPass2(); + 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+"'."); @@ -267,7 +267,7 @@ public class InstConstraintVisitor exten */ @Override public void visitCPInstruction(final CPInstruction o) { - int idx = o.getIndex(); + final int idx = o.getIndex(); if ((idx < 0) || (idx >= cpg.getSize())) { throw new AssertionViolatedException( "Huh?! Constant pool index of instruction '"+o+"' illegal? Pass 3a should have checked this!"); @@ -283,17 +283,17 @@ public class InstConstraintVisitor exten // implements LoadClass. // visitCPInstruction(o) has been called before. // A FieldInstruction may be: GETFIELD, GETSTATIC, PUTFIELD, PUTSTATIC - Constant c = cpg.getConstant(o.getIndex()); + 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). - Type t = o.getType(cpg); + final Type t = o.getType(cpg); if (t instanceof ObjectType) { - String name = ((ObjectType)t).getClassName(); - Verifier v = VerifierFactory.getVerifier( name ); - VerificationResult vr = v.doPass2(); + 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+"'."); } @@ -393,7 +393,7 @@ public class InstConstraintVisitor exten } } else{ // we deal with ASTORE - Type stacktop = stack().peek(); + final Type stacktop = stack().peek(); 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."); @@ -461,8 +461,8 @@ public class InstConstraintVisitor exten */ @Override public void visitAALOAD(final AALOAD o) { - Type arrayref = stack().peek(1); - Type index = stack().peek(0); + final Type arrayref = stack().peek(1); + final Type index = stack().peek(0); indexOfInt(o, index); if (arrayrefOfArrayType(o, arrayref)) { @@ -480,9 +480,9 @@ public class InstConstraintVisitor exten */ @Override public void visitAASTORE(final AASTORE o) { - Type arrayref = stack().peek(2); - Type index = stack().peek(1); - Type value = stack().peek(0); + final Type arrayref = stack().peek(2); + final Type index = stack().peek(1); + final Type value = stack().peek(0); indexOfInt(o, index); if (!(value instanceof ReferenceType)) { @@ -539,7 +539,7 @@ public class InstConstraintVisitor exten 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()); + final ReferenceType objectref = (ReferenceType) (stack().peek()); referenceTypeIsInitialized(o, objectref); // The check below should already done via visitReturnInstruction(ReturnInstruction), see there. @@ -556,7 +556,7 @@ public class InstConstraintVisitor exten */ @Override public void visitARRAYLENGTH(final ARRAYLENGTH o) { - Type arrayref = stack().peek(0); + final Type arrayref = stack().peek(0); arrayrefOfArrayType(o, arrayref); } @@ -590,13 +590,13 @@ public class InstConstraintVisitor exten return; } - ObjectType exc = (ObjectType) (stack().peek()); - ObjectType throwable = (ObjectType) (Type.getType("Ljava/lang/Throwable;")); + final ObjectType exc = (ObjectType) (stack().peek()); + final ObjectType throwable = (ObjectType) (Type.getType("Ljava/lang/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()+"'."); } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } @@ -607,8 +607,8 @@ public class InstConstraintVisitor exten */ @Override public void visitBALOAD(final BALOAD o) { - Type arrayref = stack().peek(1); - Type index = stack().peek(0); + final Type arrayref = stack().peek(1); + final Type index = stack().peek(0); indexOfInt(o, index); if (arrayrefOfArrayType(o, arrayref)) { if (! ( (((ArrayType) arrayref).getElementType().equals(Type.BOOLEAN)) || @@ -625,9 +625,9 @@ public class InstConstraintVisitor exten */ @Override public void visitBASTORE(final BASTORE o) { - Type arrayref = stack().peek(2); - Type index = stack().peek(1); - Type value = stack().peek(0); + final Type arrayref = stack().peek(2); + final Type index = stack().peek(1); + final Type value = stack().peek(0); indexOfInt(o, index); valueOfInt(o, value); @@ -663,8 +663,8 @@ public class InstConstraintVisitor exten */ @Override public void visitCALOAD(final CALOAD o) { - Type arrayref = stack().peek(1); - Type index = stack().peek(0); + final Type arrayref = stack().peek(1); + final Type index = stack().peek(0); indexOfInt(o, index); arrayrefOfArrayType(o, arrayref); @@ -675,9 +675,9 @@ public class InstConstraintVisitor exten */ @Override public void visitCASTORE(final CASTORE o) { - Type arrayref = stack().peek(2); - Type index = stack().peek(1); - Type value = stack().peek(0); + final Type arrayref = stack().peek(2); + final Type index = stack().peek(1); + final Type value = stack().peek(0); indexOfInt(o, index); valueOfInt(o, value); @@ -695,7 +695,7 @@ public class InstConstraintVisitor exten @Override public void visitCHECKCAST(final CHECKCAST o) { // The objectref must be of type reference. - Type objectref = stack().peek(0); + final Type objectref = stack().peek(0); if (!(objectref instanceof ReferenceType)) { constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+"."); } @@ -705,7 +705,7 @@ public class InstConstraintVisitor exten // The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the // 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()); + final Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)) { constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'."); } @@ -766,7 +766,7 @@ public class InstConstraintVisitor exten 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(); + final Type t = ((ArrayType) (stack().peek(1))).getBasicType(); if (t != Type.DOUBLE) { constraintViolated(o, "Stack next-to-top must be of type double[] but is '"+stack().peek(1)+"'."); } @@ -787,7 +787,7 @@ public class InstConstraintVisitor exten 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(); + final Type t = ((ArrayType) (stack().peek(2))).getBasicType(); if (t != Type.DOUBLE) { constraintViolated(o, "Stack next-to-next-to-top must be of type double[] but is '"+stack().peek(2)+"'."); } @@ -1097,7 +1097,7 @@ public class InstConstraintVisitor exten 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(); + final Type t = ((ArrayType) (stack().peek(1))).getBasicType(); if (t != Type.FLOAT) { constraintViolated(o, "Stack next-to-top must be of type float[] but is '"+stack().peek(1)+"'."); } @@ -1118,7 +1118,7 @@ public class InstConstraintVisitor exten 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(); + final Type t = ((ArrayType) (stack().peek(2))).getBasicType(); if (t != Type.FLOAT) { constraintViolated(o, "Stack next-to-next-to-top must be of type float[] but is '"+stack().peek(2)+"'."); } @@ -1251,7 +1251,7 @@ public class InstConstraintVisitor exten } private ObjectType getObjectType(final FieldInstruction o) { - ReferenceType rt = o.getReferenceType(cpg); + final ReferenceType rt = o.getReferenceType(cpg); if(rt instanceof ObjectType) { return (ObjectType)rt; } @@ -1265,20 +1265,20 @@ public class InstConstraintVisitor exten @Override public void visitGETFIELD(final GETFIELD o) { try { - Type objectref = stack().peek(); + final Type objectref = stack().peek(); 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+"'."); } - String field_name = o.getFieldName(cpg); + final String field_name = o.getFieldName(cpg); - JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); + final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); Field[] fields = jc.getFields(); Field f = null; - for (Field field : fields) { + for (final Field field : fields) { if (field.getName().equals(field_name)) { - Type f_type = Type.getType(field.getSignature()); - Type o_type = o.getType(cpg); + final Type f_type = Type.getType(field.getSignature()); + final Type o_type = o.getType(cpg); /* TODO: Check if assignment compatibility is sufficient. * What does Sun do? */ @@ -1290,14 +1290,14 @@ public class InstConstraintVisitor exten } if (f == null) { - JavaClass[] superclasses = jc.getSuperClasses(); + final JavaClass[] superclasses = jc.getSuperClasses(); outer: - for (JavaClass superclass : superclasses) { + for (final JavaClass superclass : superclasses) { fields = superclass.getFields(); - for (Field field : fields) { + for (final Field field : fields) { if (field.getName().equals(field_name)) { - Type f_type = Type.getType(field.getSignature()); - Type o_type = o.getType(cpg); + final Type f_type = Type.getType(field.getSignature()); + final Type o_type = o.getType(cpg); if (f_type.equals(o_type)) { f = field; if ((f.getAccessFlags() & (Const.ACC_PUBLIC | Const.ACC_PROTECTED)) == 0) { @@ -1314,19 +1314,19 @@ public class InstConstraintVisitor exten } if (f.isProtected()) { - ObjectType classtype = getObjectType(o); - ObjectType curr = ObjectType.getInstance(mg.getClassName()); + final ObjectType classtype = getObjectType(o); + final ObjectType curr = ObjectType.getInstance(mg.getClassName()); if ( classtype.equals(curr) || curr.subclassOf(classtype) ) { - Type t = stack().peek(); + final Type t = stack().peek(); if (t == Type.NULL) { return; } 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; + final ObjectType objreftype = (ObjectType) t; if (! ( objreftype.equals(curr) || objreftype.subclassOf(curr) ) ) { //TODO: One day move to Staerk-et-al's "Set of object types" instead of "wider" object types @@ -1345,7 +1345,7 @@ public class InstConstraintVisitor exten constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be."); } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } @@ -1460,7 +1460,7 @@ public class InstConstraintVisitor exten 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(); + final Type t = ((ArrayType) (stack().peek(1))).getBasicType(); if (t != Type.INT) { constraintViolated(o, "Stack next-to-top must be of type int[] but is '"+stack().peek(1)+"'."); } @@ -1494,7 +1494,7 @@ public class InstConstraintVisitor exten 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(); + final Type t = ((ArrayType) (stack().peek(2))).getBasicType(); if (t != Type.INT) { constraintViolated(o, "Stack next-to-next-to-top must be of type int[] but is '"+stack().peek(2)+"'."); } @@ -1781,7 +1781,7 @@ public class InstConstraintVisitor exten @Override public void visitINSTANCEOF(final INSTANCEOF o) { // The objectref must be of type reference. - Type objectref = stack().peek(0); + final Type objectref = stack().peek(0); if (!(objectref instanceof ReferenceType)) { constraintViolated(o, "The 'objectref' is not of a ReferenceType but of type "+objectref+"."); } @@ -1791,7 +1791,7 @@ public class InstConstraintVisitor exten // The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the // 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()); + final Constant c = cpg.getConstant(o.getIndex()); if (! (c instanceof ConstantClass)) { constraintViolated(o, "The Constant at 'index' is not a ConstantClass, but '"+c+"'."); } @@ -1813,7 +1813,7 @@ public class InstConstraintVisitor exten public void visitINVOKEINTERFACE(final INVOKEINTERFACE o) { // Method is not native, otherwise pass 3 would not happen. - int count = o.getCount(); + final int count = o.getCount(); if (count == 0) { constraintViolated(o, "The 'count' argument must not be 0."); } @@ -1823,22 +1823,22 @@ public class InstConstraintVisitor exten // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). - Type t = o.getType(cpg); + final Type t = o.getType(cpg); if (t instanceof ObjectType) { - String name = ((ObjectType)t).getClassName(); - Verifier v = VerifierFactory.getVerifier( name ); - VerificationResult vr = v.doPass2(); + 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+"'."); } } - Type[] argtypes = o.getArgumentTypes(cpg); - int nargs = argtypes.length; + final Type[] argtypes = o.getArgumentTypes(cpg); + final int nargs = argtypes.length; for (int i=nargs-1; i>=0; i--) { - Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 + final Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 Type fromDesc = argtypes[i]; if (fromDesc == Type.BOOLEAN || fromDesc == Type.BYTE || @@ -1848,7 +1848,7 @@ public class InstConstraintVisitor exten } if (! fromStack.equals(fromDesc)) { if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType) { - ReferenceType rFromStack = (ReferenceType) fromStack; + final 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. @@ -1915,22 +1915,22 @@ public class InstConstraintVisitor exten // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). - Type t = o.getType(cpg); + final Type t = o.getType(cpg); if (t instanceof ObjectType) { - String name = ((ObjectType)t).getClassName(); - Verifier v = VerifierFactory.getVerifier( name ); - VerificationResult vr = v.doPass2(); + 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+"'."); } } - Type[] argtypes = o.getArgumentTypes(cpg); - int nargs = argtypes.length; + final Type[] argtypes = o.getArgumentTypes(cpg); + final int nargs = argtypes.length; for (int i=nargs-1; i>=0; i--) { - Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 + final Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 Type fromDesc = argtypes[i]; if (fromDesc == Type.BOOLEAN || fromDesc == Type.BYTE || @@ -1940,8 +1940,8 @@ public class InstConstraintVisitor exten } if (! fromStack.equals(fromDesc)) { if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType) { - ReferenceType rFromStack = (ReferenceType) fromStack; - ReferenceType rFromDesc = (ReferenceType) fromDesc; + final ReferenceType rFromStack = (ReferenceType) fromStack; + final ReferenceType rFromDesc = (ReferenceType) fromDesc; // TODO: This can only be checked using Staerk-et-al's "set of object types", not // using a "wider cast object type". if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ) { @@ -1986,12 +1986,12 @@ public class InstConstraintVisitor exten } - String theClass = o.getClassName(cpg); + final String theClass = o.getClassName(cpg); if ( ! Repository.instanceOf(objref_classname, theClass) ) { constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected."); } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } @@ -2005,21 +2005,21 @@ public class InstConstraintVisitor exten try { // Method is not native, otherwise pass 3 would not happen. - Type t = o.getType(cpg); + final Type t = o.getType(cpg); if (t instanceof ObjectType) { - String name = ((ObjectType)t).getClassName(); - Verifier v = VerifierFactory.getVerifier( name ); - VerificationResult vr = v.doPass2(); + 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+"'."); } } - Type[] argtypes = o.getArgumentTypes(cpg); - int nargs = argtypes.length; + final Type[] argtypes = o.getArgumentTypes(cpg); + final int nargs = argtypes.length; for (int i=nargs-1; i>=0; i--) { - Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 + final Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 Type fromDesc = argtypes[i]; if (fromDesc == Type.BOOLEAN || fromDesc == Type.BYTE || @@ -2029,8 +2029,8 @@ public class InstConstraintVisitor exten } if (! fromStack.equals(fromDesc)) { if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType) { - ReferenceType rFromStack = (ReferenceType) fromStack; - ReferenceType rFromDesc = (ReferenceType) fromDesc; + final ReferenceType rFromStack = (ReferenceType) fromStack; + final ReferenceType rFromDesc = (ReferenceType) fromDesc; // TODO: This check can possibly only be done using Staerk-et-al's "set of object types" // instead of a "wider cast object type" created during verification. if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ) { @@ -2044,7 +2044,7 @@ public class InstConstraintVisitor exten } } } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } @@ -2058,22 +2058,22 @@ public class InstConstraintVisitor exten try { // the o.getClassType(cpg) type has passed pass 2; see visitLoadClass(o). - Type t = o.getType(cpg); + final Type t = o.getType(cpg); if (t instanceof ObjectType) { - String name = ((ObjectType)t).getClassName(); - Verifier v = VerifierFactory.getVerifier( name ); - VerificationResult vr = v.doPass2(); + 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+"'."); } } - Type[] argtypes = o.getArgumentTypes(cpg); - int nargs = argtypes.length; + final Type[] argtypes = o.getArgumentTypes(cpg); + final int nargs = argtypes.length; for (int i=nargs-1; i>=0; i--) { - Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 + final Type fromStack = stack().peek( (nargs-1) - i ); // 0 to nargs-1 Type fromDesc = argtypes[i]; if (fromDesc == Type.BOOLEAN || fromDesc == Type.BYTE || @@ -2083,8 +2083,8 @@ public class InstConstraintVisitor exten } if (! fromStack.equals(fromDesc)) { if (fromStack instanceof ReferenceType && fromDesc instanceof ReferenceType) { - ReferenceType rFromStack = (ReferenceType) fromStack; - ReferenceType rFromDesc = (ReferenceType) fromDesc; + final ReferenceType rFromStack = (ReferenceType) fromStack; + final ReferenceType rFromDesc = (ReferenceType) fromDesc; // TODO: This can possibly only be checked when using Staerk-et-al's "set of object types" instead // of a single "wider cast object type" created during verification. if ( ! rFromStack.isAssignmentCompatibleWith(rFromDesc) ) { @@ -2116,14 +2116,14 @@ public class InstConstraintVisitor exten } } - String objref_classname = ((ObjectType) objref).getClassName(); + final String objref_classname = ((ObjectType) objref).getClassName(); - String theClass = o.getClassName(cpg); + final String theClass = o.getClassName(cpg); if ( ! Repository.instanceOf(objref_classname, theClass) ) { constraintViolated(o, "The 'objref' item '"+objref+"' does not implement '"+theClass+"' as expected."); } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } @@ -2311,7 +2311,7 @@ public class InstConstraintVisitor exten if (! (stack().peek(1) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-top must be of type long[] but is '"+stack().peek(1)+"'."); } - Type t = ((ArrayType) (stack().peek(1))).getBasicType(); + final Type t = ((ArrayType) (stack().peek(1))).getBasicType(); if (t != Type.LONG) { constraintViolated(o, "Stack next-to-top must be of type long[] but is '"+stack().peek(1)+"'."); } @@ -2345,7 +2345,7 @@ public class InstConstraintVisitor exten if (! (stack().peek(2) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-next-to-top must be of type long[] but is '"+stack().peek(2)+"'."); } - Type t = ((ArrayType) (stack().peek(2))).getBasicType(); + final Type t = ((ArrayType) (stack().peek(2))).getBasicType(); if (t != Type.LONG) { constraintViolated(o, "Stack next-to-next-to-top must be of type long[] but is '"+stack().peek(2)+"'."); } @@ -2379,7 +2379,7 @@ public class InstConstraintVisitor exten public void visitLDC(final LDC o) { // visitCPInstruction is called first. - Constant c = cpg.getConstant(o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); if (! ( ( c instanceof ConstantInteger) || ( c instanceof ConstantFloat ) || ( c instanceof ConstantString ) || @@ -2396,7 +2396,7 @@ public class InstConstraintVisitor exten public void visitLDC_W(final LDC_W o) { // visitCPInstruction is called first. - Constant c = cpg.getConstant(o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); if (! ( ( c instanceof ConstantInteger) || ( c instanceof ConstantFloat ) || ( c instanceof ConstantString ) || @@ -2414,7 +2414,7 @@ public class InstConstraintVisitor exten public void visitLDC2_W(final LDC2_W o) { // visitCPInstruction is called first. - Constant c = cpg.getConstant(o.getIndex()); + final Constant c = cpg.getConstant(o.getIndex()); if (! ( ( c instanceof ConstantLong) || ( c instanceof ConstantDouble ) ) ) { constraintViolated(o, @@ -2617,7 +2617,7 @@ public class InstConstraintVisitor exten */ @Override public void visitMULTIANEWARRAY(final MULTIANEWARRAY o) { - int dimensions = o.getDimensions(); + final int dimensions = o.getDimensions(); // Dimensions argument is okay: see Pass 3a. for (int i=0; i<dimensions; i++) { if (stack().peek(i) != Type.INT) { @@ -2636,21 +2636,21 @@ public class InstConstraintVisitor exten //visitCPInstruction(CPInstruction) has been called before. //visitLoadClass(LoadClass) has been called before. - Type t = o.getType(cpg); + final Type t = o.getType(cpg); if (! (t instanceof ReferenceType)) { throw new AssertionViolatedException("NEW.getType() returning a non-reference type?!"); } if (! (t instanceof ObjectType)) { constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '"+t+"'."); } - ObjectType obj = (ObjectType) t; + final ObjectType obj = (ObjectType) t; //e.g.: Don't instantiate interfaces try { if (! obj.referencesClassExact()) { constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '"+obj+"'."); } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { constraintViolated(o, "Expecting a class type (ObjectType) to work on. Found: '"+obj+"'." + " which threw " + e); } } @@ -2702,21 +2702,21 @@ public class InstConstraintVisitor exten public void visitPUTFIELD(final PUTFIELD o) { try { - Type objectref = stack().peek(1); + final Type objectref = stack().peek(1); if (! ( (objectref instanceof ObjectType) || (objectref == Type.NULL) ) ) { constraintViolated(o, "Stack next-to-top should be an object reference that's not an array reference, but is '"+objectref+"'."); } - String field_name = o.getFieldName(cpg); + final String field_name = o.getFieldName(cpg); - JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); - Field[] fields = jc.getFields(); + final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); + final Field[] fields = jc.getFields(); Field f = null; - for (Field field : fields) { + for (final Field field : fields) { if (field.getName().equals(field_name)) { - Type f_type = Type.getType(field.getSignature()); - Type o_type = o.getType(cpg); + final Type f_type = Type.getType(field.getSignature()); + final Type o_type = o.getType(cpg); /* TODO: Check if assignment compatibility is sufficient. * What does Sun do? */ @@ -2730,8 +2730,8 @@ public class InstConstraintVisitor exten throw new AssertionViolatedException("Field '" + field_name + "' not found in " + jc.getClassName()); } - Type value = stack().peek(); - Type t = Type.getType(f.getSignature()); + final Type value = stack().peek(); + final Type t = Type.getType(f.getSignature()); Type shouldbe = t; if (shouldbe == Type.BOOLEAN || shouldbe == Type.BYTE || @@ -2762,19 +2762,19 @@ public class InstConstraintVisitor exten } if (f.isProtected()) { - ObjectType classtype = getObjectType(o); - ObjectType curr = ObjectType.getInstance(mg.getClassName()); + final ObjectType classtype = getObjectType(o); + final ObjectType curr = ObjectType.getInstance(mg.getClassName()); if ( classtype.equals(curr) || curr.subclassOf(classtype) ) { - Type tp = stack().peek(1); + final Type tp = stack().peek(1); if (tp == Type.NULL) { return; } if (! (tp instanceof ObjectType) ) { constraintViolated(o, "The 'objectref' must refer to an object that's not an array. Found instead: '"+tp+"'."); } - ObjectType objreftype = (ObjectType) tp; + final ObjectType objreftype = (ObjectType) tp; if (! ( objreftype.equals(curr) || objreftype.subclassOf(curr) ) ) { constraintViolated(o, @@ -2790,7 +2790,7 @@ public class InstConstraintVisitor exten constraintViolated(o, "Referenced field '"+f+"' is static which it shouldn't be."); } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } @@ -2802,14 +2802,14 @@ public class InstConstraintVisitor exten @Override public void visitPUTSTATIC(final PUTSTATIC o) { try { - String field_name = o.getFieldName(cpg); - JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); - Field[] fields = jc.getFields(); + final String field_name = o.getFieldName(cpg); + final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName()); + final Field[] fields = jc.getFields(); Field f = null; - for (Field field : fields) { + for (final Field field : fields) { if (field.getName().equals(field_name)) { - Type f_type = Type.getType(field.getSignature()); - Type o_type = o.getType(cpg); + final Type f_type = Type.getType(field.getSignature()); + final Type o_type = o.getType(cpg); /* TODO: Check if assignment compatibility is sufficient. * What does Sun do? */ @@ -2822,8 +2822,8 @@ public class InstConstraintVisitor exten if (f == null) { throw new AssertionViolatedException("Field '" + field_name + "' not found in " + jc.getClassName()); } - Type value = stack().peek(); - Type t = Type.getType(f.getSignature()); + final Type value = stack().peek(); + final Type t = Type.getType(f.getSignature()); Type shouldbe = t; if (shouldbe == Type.BOOLEAN || shouldbe == Type.BYTE || @@ -2855,7 +2855,7 @@ public class InstConstraintVisitor exten // TODO: Interface fields may be assigned to only once. (Hard to implement in // JustIce's execution model). This may only happen in <clinit>, see Pass 3a. - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } @@ -2900,7 +2900,7 @@ public class InstConstraintVisitor exten if (! (stack().peek(1) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-top must be of type short[] but is '"+stack().peek(1)+"'."); } - Type t = ((ArrayType) (stack().peek(1))).getBasicType(); + final Type t = ((ArrayType) (stack().peek(1))).getBasicType(); if (t != Type.SHORT) { constraintViolated(o, "Stack next-to-top must be of type short[] but is '"+stack().peek(1)+"'."); } @@ -2921,7 +2921,7 @@ public class InstConstraintVisitor exten if (! (stack().peek(2) instanceof ArrayType)) { constraintViolated(o, "Stack next-to-next-to-top must be of type short[] but is '"+stack().peek(2)+"'."); } - Type t = ((ArrayType) (stack().peek(2))).getBasicType(); + final Type t = ((ArrayType) (stack().peek(2))).getBasicType(); if (t != Type.SHORT) { constraintViolated(o, "Stack next-to-next-to-top must be of type short[] but is '"+stack().peek(2)+"'."); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/LocalVariables.java Tue Jun 21 20:50:19 2016 @@ -50,7 +50,7 @@ public class LocalVariables implements C */ @Override public Object clone() { - LocalVariables lvs = new LocalVariables(locals.length); + final LocalVariables lvs = new LocalVariables(locals.length); for (int i=0; i<locals.length; i++) { lvs.locals[i] = this.locals[i]; } @@ -103,7 +103,7 @@ public class LocalVariables implements C if (!(o instanceof LocalVariables)) { return false; } - LocalVariables lv = (LocalVariables) o; + final LocalVariables lv = (LocalVariables) o; if (this.locals.length != lv.locals.length) { return false; } @@ -159,7 +159,7 @@ public class LocalVariables implements C } if ((locals[i] instanceof ReferenceType) && (lv.locals[i] instanceof ReferenceType)) { if (! locals[i].equals(lv.locals[i])) { // needed in case of two UninitializedObjectType instances - Type sup = ((ReferenceType) locals[i]).getFirstCommonSuperclass((ReferenceType) (lv.locals[i])); + final Type sup = ((ReferenceType) locals[i]).getFirstCommonSuperclass((ReferenceType) (lv.locals[i])); if (sup != null) { locals[i] = sup; @@ -183,7 +183,7 @@ public class LocalVariables implements C locals[i] = Type.UNKNOWN; } } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } @@ -194,7 +194,7 @@ public class LocalVariables implements C */ @Override public String toString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); for (int i=0; i<locals.length; i++) { sb.append(Integer.toString(i)); sb.append(": "); Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/OperandStack.java Tue Jun 21 20:50:19 2016 @@ -63,7 +63,7 @@ public class OperandStack implements Clo */ @Override public Object clone() { - OperandStack newstack = new OperandStack(this.maxStack); + final OperandStack newstack = new OperandStack(this.maxStack); @SuppressWarnings("unchecked") // OK because this.stack is the same type final ArrayList<Type> clone = (ArrayList<Type>) this.stack.clone(); newstack.stack = clone; @@ -92,7 +92,7 @@ public class OperandStack implements Clo if (!(o instanceof OperandStack)) { return false; } - OperandStack s = (OperandStack) o; + final OperandStack s = (OperandStack) o; return this.stack.equals(s.stack); } @@ -138,7 +138,7 @@ public class OperandStack implements Clo * Returns the element on top of the stack. The element is popped off the stack. */ public Type pop() { - Type e = stack.remove(size()-1); + final Type e = stack.remove(size()-1); return e; } @@ -197,7 +197,7 @@ public class OperandStack implements Clo */ @Override public String toString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Slots used: "); sb.append(slotsUsed()); sb.append(" MaxStack: "); @@ -253,7 +253,7 @@ public class OperandStack implements Clo } } } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } Modified: commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java?rev=1749603&r1=1749602&r2=1749603&view=diff ============================================================================== --- commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java (original) +++ commons/proper/bcel/trunk/src/main/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java Tue Jun 21 20:50:19 2016 @@ -129,7 +129,7 @@ public final class Pass3bVerifier extend private void circulationPump(final MethodGen m,final ControlFlowGraph cfg, final InstructionContext start, final Frame vanillaFrame, final InstConstraintVisitor icv, final ExecutionVisitor ev) { final Random random = new Random(); - InstructionContextQueue icq = new InstructionContextQueue(); + final InstructionContextQueue icq = new InstructionContextQueue(); start.execute(vanillaFrame, new ArrayList<InstructionContext>(), icv, ev); // new ArrayList() <=> no Instruction was executed before @@ -141,7 +141,7 @@ public final class Pass3bVerifier extend InstructionContext u; ArrayList<InstructionContext> ec; if (!DEBUG) { - int r = random.nextInt(icq.size()); + final int r = random.nextInt(icq.size()); u = icq.getIC(r); ec = icq.getEC(r); icq.remove(r); @@ -153,8 +153,10 @@ public final class Pass3bVerifier extend } @SuppressWarnings("unchecked") // ec is of type ArrayList<InstructionContext> + final ArrayList<InstructionContext> oldchain = (ArrayList<InstructionContext>) (ec.clone()); @SuppressWarnings("unchecked") // ec is of type ArrayList<InstructionContext> + final ArrayList<InstructionContext> newchain = (ArrayList<InstructionContext>) (ec.clone()); newchain.add(u); @@ -162,9 +164,9 @@ public final class Pass3bVerifier extend //System.err.println(u); // We can only follow _one_ successor, the one after the // JSR that was recently executed. - RET ret = (RET) (u.getInstruction().getInstruction()); - ReturnaddressType t = (ReturnaddressType) u.getOutFrame(oldchain).getLocals().get(ret.getIndex()); - InstructionContext theSuccessor = cfg.contextOf(t.getTarget()); + final RET ret = (RET) (u.getInstruction().getInstruction()); + final ReturnaddressType t = (ReturnaddressType) u.getOutFrame(oldchain).getLocals().get(ret.getIndex()); + final InstructionContext theSuccessor = cfg.contextOf(t.getTarget()); // Sanity check InstructionContext lastJSR = null; @@ -188,7 +190,7 @@ public final class Pass3bVerifier extend if (lastJSR == null) { throw new AssertionViolatedException("RET without a JSR before in ExecutionChain?! EC: '"+oldchain+"'."); } - JsrInstruction jsr = (JsrInstruction) (lastJSR.getInstruction().getInstruction()); + final JsrInstruction jsr = (JsrInstruction) (lastJSR.getInstruction().getInstruction()); if ( theSuccessor != (cfg.contextOf(jsr.physicalSuccessor())) ) { throw new AssertionViolatedException("RET '"+u.getInstruction()+"' info inconsistent: jump back to '"+ theSuccessor+"' or '"+cfg.contextOf(jsr.physicalSuccessor())+"'?"); @@ -196,6 +198,7 @@ public final class Pass3bVerifier extend if (theSuccessor.execute(u.getOutFrame(oldchain), newchain, icv, ev)) { @SuppressWarnings("unchecked") // newchain is already of type ArrayList<InstructionContext> + final ArrayList<InstructionContext> newchainClone = (ArrayList<InstructionContext>) newchain.clone(); icq.add(theSuccessor, newchainClone); } @@ -203,10 +206,11 @@ public final class Pass3bVerifier extend else{// "not a ret" // Normal successors. Add them to the queue of successors. - InstructionContext[] succs = u.getSuccessors(); - for (InstructionContext v : succs) { + final InstructionContext[] succs = u.getSuccessors(); + for (final InstructionContext v : succs) { if (v.execute(u.getOutFrame(oldchain), newchain, icv, ev)) { @SuppressWarnings("unchecked") // newchain is already of type ArrayList<InstructionContext> + final ArrayList<InstructionContext> newchainClone = (ArrayList<InstructionContext>) newchain.clone(); icq.add(v, newchainClone); } @@ -215,9 +219,9 @@ public final class Pass3bVerifier extend // Exception Handlers. Add them to the queue of successors. // [subroutines are never protected; mandated by JustIce] - ExceptionHandler[] exc_hds = u.getExceptionHandlers(); - for (ExceptionHandler exc_hd : exc_hds) { - InstructionContext v = cfg.contextOf(exc_hd.getHandlerStart()); + final ExceptionHandler[] exc_hds = u.getExceptionHandlers(); + for (final ExceptionHandler exc_hd : exc_hds) { + final InstructionContext v = cfg.contextOf(exc_hd.getHandlerStart()); // TODO: the "oldchain" and "newchain" is used to determine the subroutine // we're in (by searching for the last JSR) by the InstructionContext // implementation. Therefore, we should not use this chain mechanism @@ -243,18 +247,18 @@ public final class Pass3bVerifier extend InstructionHandle ih = start.getInstruction(); do{ if ((ih.getInstruction() instanceof ReturnInstruction) && (!(cfg.isDead(ih)))) { - InstructionContext ic = cfg.contextOf(ih); + final InstructionContext ic = cfg.contextOf(ih); // TODO: This is buggy, we check only the top-level return instructions this way. // Maybe some maniac returns from a method when in a subroutine? - Frame f = ic.getOutFrame(new ArrayList<InstructionContext>()); - LocalVariables lvs = f.getLocals(); + final Frame f = ic.getOutFrame(new ArrayList<InstructionContext>()); + final LocalVariables lvs = f.getLocals(); for (int i=0; i<lvs.maxLocals(); i++) { if (lvs.get(i) instanceof UninitializedObjectType) { this.addMessage("Warning: ReturnInstruction '"+ic+ "' may leave method with an uninitialized object in the local variables array '"+lvs+"'."); } } - OperandStack os = f.getStack(); + final OperandStack os = f.getStack(); for (int i=0; i<os.size(); i++) { if (os.peek(i) instanceof UninitializedObjectType) { this.addMessage("Warning: ReturnInstruction '"+ic+ @@ -263,7 +267,7 @@ public final class Pass3bVerifier extend } //see JVM $4.8.2 Type returnedType = null; - OperandStack inStack = ic.getInFrame().getStack(); + final OperandStack inStack = ic.getInFrame().getStack(); if (inStack.size() >= 1) { returnedType = inStack.peek(); } else { @@ -276,7 +280,7 @@ public final class Pass3bVerifier extend if (!((ReferenceType) returnedType).isCastableTo(m.getReturnType())) { invalidReturnTypeError(returnedType, m); } - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // Don't know what do do now, so raise RuntimeException throw new RuntimeException(e); } @@ -320,34 +324,34 @@ public final class Pass3bVerifier extend JavaClass jc; try { jc = Repository.lookupClass(myOwner.getClassName()); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { // FIXME: maybe not the best way to handle this throw new AssertionViolatedException("Missing class: " + e, e); } - ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool()); + final ConstantPoolGen constantPoolGen = new ConstantPoolGen(jc.getConstantPool()); // Init Visitors - InstConstraintVisitor icv = new InstConstraintVisitor(); + final InstConstraintVisitor icv = new InstConstraintVisitor(); icv.setConstantPoolGen(constantPoolGen); - ExecutionVisitor ev = new ExecutionVisitor(); + final ExecutionVisitor ev = new ExecutionVisitor(); ev.setConstantPoolGen(constantPoolGen); - Method[] methods = jc.getMethods(); // Method no "method_no" exists, we ran Pass3a before on it! + final Method[] methods = jc.getMethods(); // Method no "method_no" exists, we ran Pass3a before on it! try{ - MethodGen mg = new MethodGen(methods[method_no], myOwner.getClassName(), constantPoolGen); + final MethodGen mg = new MethodGen(methods[method_no], myOwner.getClassName(), constantPoolGen); icv.setMethodGen(mg); ////////////// DFA BEGINS HERE //////////////// if (! (mg.isAbstract() || mg.isNative()) ) { // IF mg HAS CODE (See pass 2) - ControlFlowGraph cfg = new ControlFlowGraph(mg); + final ControlFlowGraph cfg = new ControlFlowGraph(mg); // Build the initial frame situation for this method. - Frame f = new Frame(mg.getMaxLocals(),mg.getMaxStack()); + final Frame f = new Frame(mg.getMaxLocals(),mg.getMaxStack()); if ( !mg.isStatic() ) { if (mg.getName().equals(Const.CONSTRUCTOR_NAME)) { Frame.setThis(new UninitializedObjectType(ObjectType.getInstance(jc.getClassName()))); @@ -358,7 +362,7 @@ public final class Pass3bVerifier extend f.getLocals().set(0, ObjectType.getInstance(jc.getClassName())); } } - Type[] argtypes = mg.getArgumentTypes(); + final Type[] argtypes = mg.getArgumentTypes(); int twoslotoffset = 0; for (int j=0; j<argtypes.length; j++) { if (argtypes[j] == Type.SHORT || argtypes[j] == Type.BYTE || @@ -374,15 +378,15 @@ public final class Pass3bVerifier extend circulationPump(mg,cfg, cfg.contextOf(mg.getInstructionList().getStart()), f, icv, ev); } } - catch (VerifierConstraintViolatedException ce) { + catch (final VerifierConstraintViolatedException ce) { ce.extendMessage("Constraint violated in method '"+methods[method_no]+"':\n",""); return new VerificationResult(VerificationResult.VERIFIED_REJECTED, ce.getMessage()); } - catch (RuntimeException re) { + catch (final RuntimeException re) { // These are internal errors - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); re.printStackTrace(pw); throw new AssertionViolatedException("Some RuntimeException occured while verify()ing class '"+jc.getClassName()+