[patch] StackMap attribute info in Class2HTML output

"Ed Price" <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <000001c3f972$2bd938f0$6600a8c0@xpc>
greetings. 

I would like to contribute the following patch.
It nicely formats StackMap attribute info in Class2HTML output.
This is useful for J2ME development.
Any feedback is welcome.
Thanks!

-Ed

--- jakarta-bcel/src/java/org/apache/bcel/util/AttributeHTML.java.~1.3.~
2003-05-23 03:55:32.000000000 -0400
+++ jakarta-bcel/src/java/org/apache/bcel/util/AttributeHTML.java
2004-02-22 13:02:11.000000000 -0500
@@ -245,6 +245,51 @@
       file.print("</UL>\n");
       break;
 
+    case ATTR_STACK_MAP:
+      StackMapEntry[] entries = ((StackMap)attribute).getStackMap();
+      // assert (entries != null);
+
+      // List StackMap entries
+      file.print("<OL>");
+
+      for(int i=0; i < entries.length; i++) {
+        StackMapEntry entry = entries[i];
+        // assert (entry != null);
+
+        int offset = entry.getByteCodeOffset();
+        StackMapType[] localTypes = entry.getTypesOfLocals();
+        StackMapType[] stackTypes = entry.getTypesOfStackItems ();
+        // assert (localTypes != null);
+        // assert (stackTypes != null);
+
+        file.println("<LI>" + 
+                     "offset: " + codeLink(offset, method_number) + "<BR>"
+
+                     "locals: " + localTypes.length);
+
+        if (localTypes.length > 0) {
+            file.print("<UL>");
+            for(int j=0; j < localTypes.length; j++) {
+                file.println("<LI>" + localTypes[j] + "</LI>");
+            }
+            file.println("</UL>");
+        }
+
+        file.println("stack items: " + stackTypes.length);
+
+        if (stackTypes.length > 0) {
+            file.print("<UL>");
+            for (int j=0; j < stackTypes.length; j++) {
+                file.println("<LI>" + stackTypes[j] + "</LI>");
+            }
+            file.println("</UL>");
+        }
+
+        file.println("</LI>");
+      }
+      file.println("</OL>");
+
+      break;
+
     default: // Such as Unknown attribute or Deprecated
       file.print("<P>" + attribute.toString());
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.