title: Opcode for identifying switch case in javassist
body: <p>How to find the op-code for identifying  switch case in a java class using javassist or asm.</p>
  
  <p>I used the Below Snippet</p>
  
  <pre><code>List methods = lClassFile.getMethods();
          for (Object m : methods) {
              MethodInfo lMethodInfo = (MethodInfo) m;
              System.out.println("method name: " + lMethodInfo.getName());
              CodeAttribute ca = lMethodInfo.getCodeAttribute();
              for (CodeIterator ci = ca.iterator(); ci.hasNext();) {
                  int index = ci.next();
                  int op = ci.byteAt(index);
  
                  if (op == Opcode.TABLESWITCH) {
                      int a1 = ci.s16bitAt(index + 1);
                      String fieldrefType = " " + lClassFile.getConstPool().getFieldrefType(a1);
                      String fieldName = " " + lClassFile.getConstPool().getFieldrefName(a1);
                      String fieldrefClassName = " " + lClassFile.getConstPool().getFieldrefClassName(a1);
                      System.out.println("1 -&gt; FieldrefType = " + fieldrefType + "    field name: " + fieldName + "          FieldrefClassName name: " + fieldrefClassName);
                  }
                  if (op == Opcode.LOOKUPSWITCH) {
                      int a1 = ci.s16bitAt(index + 1);
                      String fieldrefType = " " + lClassFile.getConstPool().getFieldrefType(a1);
                      String fieldName = " " + lClassFile.getConstPool().getFieldrefName(a1);
                      String fieldrefClassName = " " + lClassFile.getConstPool().getFieldrefClassName(a1);
                      System.out.println("2 -&gt; FieldrefType = " + fieldrefType + "    field name: " + fieldName + "          FieldrefClassName name: " + fieldrefClassName);
                  }
              }
          }
  </code></pre>
  
  <p>I got Output as:</p>
  
  <pre><code>method name: &lt;init&gt;
  method name: execute
  2 -&gt; FieldrefType =  null    field name:  null          FieldrefClassName name:  null
  1 -&gt; FieldrefType =  null    field name:  null          FieldrefClassName name:  null
  method name: validate
  2 -&gt; FieldrefType =  null    field name:  null          FieldrefClassName name:  null
  2 -&gt; FieldrefType =  null    field name:  null          FieldrefClassName name:  null
  method name: postExecute
  2 -&gt; FieldrefType =  null    field name:  null          FieldrefClassName name:  null
  2 -&gt; FieldrefType =  null    field name:  null          FieldrefClassName name:  null
  </code></pre>
  
  <p>Cant able to get the switch cases values.
  Help me please....</p>