You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/08/21 14:41:43 UTC

svn commit: r1696961 - /commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/StackMapEntry.java

Author: sebb
Date: Fri Aug 21 12:41:43 2015
New Revision: 1696961

URL: http://svn.apache.org/r1696961
Log:
Checkstyle, also ensure invalid numbers are reported

Modified:
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/StackMapEntry.java

Modified: commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/StackMapEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/StackMapEntry.java?rev=1696961&r1=1696960&r2=1696961&view=diff
==============================================================================
--- commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/StackMapEntry.java (original)
+++ commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/classfile/StackMapEntry.java Fri Aug 21 12:41:43 2015
@@ -231,7 +231,8 @@ public final class StackMapEntry impleme
     int getMapEntrySize() {
         if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) {
             return 1;
-        } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+        } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && 
+                   frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
             return 1 + (types_of_stack_items[0].hasIndex() ? 3 : 1);
         } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
             return 3 + (types_of_stack_items[0].hasIndex() ? 3 : 1);
@@ -242,16 +243,16 @@ public final class StackMapEntry impleme
         } else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) {
             int len = 3;
             for (int i = 0; i < types_of_locals.length; i++) {
-                len += (types_of_locals[i].hasIndex() ? 3 : 1);
+                len += types_of_locals[i].hasIndex() ? 3 : 1;
             }            
             return len;
         } else if (frame_type == Constants.FULL_FRAME) {        
             int len = 7;
             for (int i = 0; i < types_of_locals.length; i++) {
-                len += (types_of_locals[i].hasIndex() ? 3 : 1);
+                len += types_of_locals[i].hasIndex() ? 3 : 1;
             }
             for (int i = 0; i < types_of_stack_items.length; i++) {
-                len += (types_of_stack_items[i].hasIndex() ? 3 : 1);
+                len += types_of_stack_items[i].hasIndex() ? 3 : 1;
             }
             return len;
         } else {
@@ -263,13 +264,14 @@ public final class StackMapEntry impleme
     public void setFrameType( int f ) {
         if (f >= Constants.SAME_FRAME && f <= Constants.SAME_FRAME_MAX) {
             byte_code_offset = f - Constants.SAME_FRAME;
-        } else if (f >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && f <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
+        } else if (f >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && 
+                   f <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) {
             byte_code_offset = f - Constants.SAME_LOCALS_1_STACK_ITEM_FRAME;
-        } else if (f == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
-        } else if (f >= Constants.CHOP_FRAME && f <= Constants.CHOP_FRAME_MAX) {
-        } else if (f == Constants.SAME_FRAME_EXTENDED) {
-        } else if (f >= Constants.APPEND_FRAME && f <= Constants.APPEND_FRAME_MAX) {
-        } else if (f == Constants.FULL_FRAME) {        
+        } else if (f == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock
+        } else if (f >= Constants.CHOP_FRAME && f <= Constants.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock
+        } else if (f == Constants.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock
+        } else if (f >= Constants.APPEND_FRAME && f <= Constants.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock
+        } else if (f == Constants.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock
         } else {
             throw new RuntimeException("Invalid StackMap frame_type");
         }
@@ -284,7 +286,7 @@ public final class StackMapEntry impleme
 
     public void setByteCodeOffset( int new_offset ) {
         if (new_offset < 0 || new_offset > 32767) {
-            throw new RuntimeException("Invalid StackMap offset");
+            throw new RuntimeException("Invalid StackMap offset: " + new_offset);
         }
 
         if (frame_type >= Constants.SAME_FRAME &&
@@ -301,15 +303,15 @@ public final class StackMapEntry impleme
             } else {
                 frame_type = Constants.SAME_LOCALS_1_STACK_ITEM_FRAME + new_offset;
             }
-        } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) {
+        } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock
         } else if (frame_type >= Constants.CHOP_FRAME &&
-                   frame_type <= Constants.CHOP_FRAME_MAX) {
-        } else if (frame_type == Constants.SAME_FRAME_EXTENDED) {
+                   frame_type <= Constants.CHOP_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock
+        } else if (frame_type == Constants.SAME_FRAME_EXTENDED) { // CHECKSTYLE IGNORE EmptyBlock
         } else if (frame_type >= Constants.APPEND_FRAME &&
-                   frame_type <= Constants.APPEND_FRAME_MAX) {
-        } else if (frame_type == Constants.FULL_FRAME) {
+                   frame_type <= Constants.APPEND_FRAME_MAX) { // CHECKSTYLE IGNORE EmptyBlock
+        } else if (frame_type == Constants.FULL_FRAME) { // CHECKSTYLE IGNORE EmptyBlock
         } else {
-            throw new RuntimeException("Invalid StackMap frame_type");
+            throw new RuntimeException("Invalid StackMap frame_type: " + frame_type);
         }
         byte_code_offset = new_offset;
     }