commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1695794 - in /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6: generic/ verifier/statics/
Date Thu, 13 Aug 2015 22:28:03 GMT
Author: ggregory
Date: Thu Aug 13 22:28:03 2015
New Revision: 1695794

URL: http://svn.apache.org/r1695794
Log:
Statement unnecessarily nested within else clause.

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Instruction.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionFactory.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionHandle.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionList.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LineNumberGen.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ObjectType.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/SimpleElementValueGen.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/verifier/statics/Pass2Verifier.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/FieldGen.java
Thu Aug 13 22:28:03 2015
@@ -300,9 +300,8 @@ public class FieldGen extends FieldGenOr
     public String getInitValue() {
         if (value != null) {
             return value.toString();
-        } else {
-            return null;
         }
+        return null;
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Instruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Instruction.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Instruction.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Instruction.java
Thu Aug 13 22:28:03 2015
@@ -80,9 +80,8 @@ public abstract class Instruction implem
     public String toString( boolean verbose ) {
         if (verbose) {
             return getName() + "[" + opcode + "](" + length + ")";
-        } else {
-            return getName();
         }
+        return getName();
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionFactory.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionFactory.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionFactory.java
Thu Aug 13 22:28:03 2015
@@ -590,9 +590,8 @@ public class InstructionFactory implemen
         } else if ((src_type instanceof ReferenceType) && (dest_type instanceof ReferenceType))
{
             if (dest_type instanceof ArrayType) {
                 return new CHECKCAST(cp.addArrayClass((ArrayType) dest_type));
-            } else {
-                return new CHECKCAST(cp.addClass(((ObjectType) dest_type).getClassName()));
             }
+            return new CHECKCAST(cp.addClass(((ObjectType) dest_type).getClassName()));
         } else {
             throw new RuntimeException("Can not cast " + src_type + " to " + dest_type);
         }
@@ -622,18 +621,16 @@ public class InstructionFactory implemen
     public CHECKCAST createCheckCast( ReferenceType t ) {
         if (t instanceof ArrayType) {
             return new CHECKCAST(cp.addArrayClass((ArrayType) t));
-        } else {
-            return new CHECKCAST(cp.addClass((ObjectType) t));
         }
+        return new CHECKCAST(cp.addClass((ObjectType) t));
     }
 
 
     public INSTANCEOF createInstanceOf( ReferenceType t ) {
         if (t instanceof ArrayType) {
             return new INSTANCEOF(cp.addArrayClass((ArrayType) t));
-        } else {
-            return new INSTANCEOF(cp.addClass((ObjectType) t));
         }
+        return new INSTANCEOF(cp.addClass((ObjectType) t));
     }
 
 
@@ -659,15 +656,14 @@ public class InstructionFactory implemen
             } else {
                 return new NEWARRAY(t.getType());
             }
+        }
+        ArrayType at;
+        if (t instanceof ArrayType) {
+            at = (ArrayType) t;
         } else {
-            ArrayType at;
-            if (t instanceof ArrayType) {
-                at = (ArrayType) t;
-            } else {
-                at = new ArrayType(t, dim);
-            }
-            return new MULTIANEWARRAY(cp.addArrayClass(at), dim);
+            at = new ArrayType(t, dim);
         }
+        return new MULTIANEWARRAY(cp.addArrayClass(at), dim);
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionHandle.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionHandle.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionHandle.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionHandle.java
Thu Aug 13 22:28:03 2015
@@ -109,12 +109,11 @@ public class InstructionHandle implement
     static InstructionHandle getInstructionHandle( Instruction i ) {
         if (ih_list == null) {
             return new InstructionHandle(i);
-        } else {
-            InstructionHandle ih = ih_list;
-            ih_list = ih.next;
-            ih.setInstruction(i);
-            return ih;
         }
+        InstructionHandle ih = ih_list;
+        ih_list = ih.next;
+        ih.setInstruction(i);
+        return ih;
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionList.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionList.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionList.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/InstructionList.java
Thu Aug 13 22:28:03 2015
@@ -289,9 +289,8 @@ public class InstructionList implements
             length = il.length;
             il.clear();
             return start;
-        } else {
-            return append(end, il); // was end.instruction
         }
+        return append(end, il); // was end.instruction
     }
 
 
@@ -456,9 +455,8 @@ public class InstructionList implements
         if (isEmpty()) {
             append(il); // Code is identical for this case
             return start;
-        } else {
-            return insert(start, il);
         }
+        return insert(start, il);
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LineNumberGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LineNumberGen.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LineNumberGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LineNumberGen.java
Thu Aug 13 22:28:03 2015
@@ -62,9 +62,8 @@ public class LineNumberGen implements In
     public void updateTarget( InstructionHandle old_ih, InstructionHandle new_ih ) {
         if (old_ih != ih) {
             throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}");
-        } else {
-            setInstruction(new_ih);
         }
+        setInstruction(new_ih);
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/LocalVariableInstruction.java
Thu Aug 13 22:28:03 2015
@@ -109,9 +109,8 @@ public abstract class LocalVariableInstr
         if (((opcode >= Constants.ILOAD_0) && (opcode <= Constants.ALOAD_3))
                 || ((opcode >= Constants.ISTORE_0) && (opcode <= Constants.ASTORE_3)))
{
             return super.toString(verbose);
-        } else {
-            return super.toString(verbose) + " " + n;
         }
+        return super.toString(verbose) + " " + n;
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/MethodGen.java
Thu Aug 13 22:28:03 2015
@@ -305,10 +305,9 @@ public class MethodGen extends FieldGenO
                 variable_vec.add(l);
             }
             return l;
-        } else {
-            throw new IllegalArgumentException("Can not use " + type
-                    + " as type for local variable");
         }
+        throw new IllegalArgumentException("Can not use " + type
+                + " as type for local variable");
     }
 
 

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ObjectType.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ObjectType.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ObjectType.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/ObjectType.java
Thu Aug 13 22:28:03 2015
@@ -119,9 +119,8 @@ public class ObjectType extends Referenc
         JavaClass jc = Repository.lookupClass(class_name);
         if (jc.isPublic()) {
             return true;
-        } else {
-            JavaClass acc = Repository.lookupClass(accessor.class_name);
-            return acc.getPackageName().equals(jc.getPackageName());
         }
+        JavaClass acc = Repository.lookupClass(accessor.class_name);
+        return acc.getPackageName().equals(jc.getPackageName());
     }
 }

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/SimpleElementValueGen.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/SimpleElementValueGen.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/SimpleElementValueGen.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/SimpleElementValueGen.java
Thu Aug 13 22:28:03 2015
@@ -234,9 +234,8 @@ public class SimpleElementValueGen exten
             ConstantInteger bo = (ConstantInteger) getConstantPoolgen().getConstant(idx);
             if (bo.getBytes() == 0) {
                 return "false";
-            } else {
-                return "true";
             }
+            return "true";
         case STRING:
             ConstantUtf8 cu8 = (ConstantUtf8) getConstantPoolgen().getConstant(idx);
             return cu8.getBytes();

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/verifier/statics/Pass2Verifier.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/verifier/statics/Pass2Verifier.java?rev=1695794&r1=1695793&r2=1695794&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/verifier/statics/Pass2Verifier.java
(original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/verifier/statics/Pass2Verifier.java
Thu Aug 13 22:28:03 2015
@@ -1067,29 +1067,25 @@ public final class Pass2Verifier extends
                 if (vr != VerificationResult.VR_OK){
                     throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"'
references '"+cname+"' as an Exception but it does not pass verification pass 1: "+vr);
                 }
-                else{
-                    // We cannot safely trust any other "instanceof" mechanism. We need to
transitively verify
-                    // the ancestor hierarchy.
-                    JavaClass e = Repository.lookupClass(cname);
-                    JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName());
-                    JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName());
-                    while (e != o){
-                        if (e == t) {
-                            break; // It's a subclass of Throwable, OKAY, leave.
-                        }
-
-                        v = VerifierFactory.getVerifier(e.getSuperclassName());
-                        vr = v.doPass1();
-                        if (vr != VerificationResult.VR_OK){
-                            throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"'
references '"+cname+"' as an Exception but '"+e.getSuperclassName()+"' in the ancestor hierachy
does not pass verification pass 1: "+vr);
-                        }
-                        else{
-                            e = Repository.lookupClass(e.getSuperclassName());
-                        }
+                // We cannot safely trust any other "instanceof" mechanism. We need to transitively
verify
+                // the ancestor hierarchy.
+                JavaClass e = Repository.lookupClass(cname);
+                JavaClass t = Repository.lookupClass(Type.THROWABLE.getClassName());
+                JavaClass o = Repository.lookupClass(Type.OBJECT.getClassName());
+                while (e != o){
+                    if (e == t) {
+                        break; // It's a subclass of Throwable, OKAY, leave.
                     }
-                    if (e != t) {
-                        throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"'
references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
+
+                    v = VerifierFactory.getVerifier(e.getSuperclassName());
+                    vr = v.doPass1();
+                    if (vr != VerificationResult.VR_OK){
+                        throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"'
references '"+cname+"' as an Exception but '"+e.getSuperclassName()+"' in the ancestor hierachy
does not pass verification pass 1: "+vr);
                     }
+                    e = Repository.lookupClass(e.getSuperclassName());
+                }
+                if (e != t) {
+                    throw new ClassConstraintException("Exceptions attribute '"+tostring(obj)+"'
references '"+cname+"' as an Exception but it is not a subclass of '"+t.getClassName()+"'.");
                 }
             }
 
@@ -1335,9 +1331,7 @@ public final class Pass2Verifier extends
         if (allowStaticInit){
             return (name.equals(Constants.CONSTRUCTOR_NAME) || name.equals(Constants.STATIC_INITIALIZER_NAME));
         }
-        else{
-            return name.equals(Constants.CONSTRUCTOR_NAME);
-        }
+        return name.equals(Constants.CONSTRUCTOR_NAME);
     }
 
     /**



Mime
View raw message