public void tableSwitch(final int[] keys,final TableSwitchGenerator generator,final boolean useTable){
  for (int i=1; i < keys.length; ++i) {
    if (keys[i] < keys[i - 1]) {
      throw new IllegalArgumentException("keys must be sorted ascending");
    }
  }
  Label def=newLabel();
  Label end=newLabel();
  if (keys.length > 0) {
    int len=keys.length;
    int min=keys[0];
    int max=keys[len - 1];
    int range=max - min + 1;
    if (useTable) {
      Label[] labels=new Label[range];
      Arrays.fill(labels,def);
      for (int i=0; i < len; ++i) {
        labels[keys[i] - min]=newLabel();
      }
      mv.visitTableSwitchInsn(min,max,def,labels);
      for (int i=0; i < range; ++i) {
        Label label=labels[i];
        if (label != def) {
          mark(label);
          generator.generateCase(i + min,end);
        }
      }
    }
 else {
      Label[] labels=new Label[len];
      for (int i=0; i < len; ++i) {
        labels[i]=newLabel();
      }
      mv.visitLookupSwitchInsn(def,keys,labels);
      for (int i=0; i < len; ++i) {
        mark(labels[i]);
        generator.generateCase(keys[i],end);
      }
    }
  }
  mark(def);
  generator.generateDefault();
  mark(end);
}

public void tableSwitch ( final int [ ] keys , final TableSwitchGenerator generator , final boolean useTable ) { for ( int i = 1 ; i < keys . length ; ++ i ) { if ( keys [ i ] < keys [ i - 1 ] ) { throw new IllegalArgumentException ( "keys must be sorted ascending" ) ; } } Label def = newLabel ( ) ; Label end = newLabel ( ) ; if ( keys . length > 0 ) { int len = keys . length ; int min = keys [ 0 ] ; int max = keys [ len - 1 ] ; int range = max - min + 1 ; if ( useTable ) { Label [ ] labels = new Label [ range ] ; Arrays . fill ( labels , def ) ; for ( int i = 0 ; i < len ; ++ i ) { labels [ keys [ i ] - min ] = newLabel ( ) ; } mv . visitTableSwitchInsn ( min , max , def , labels ) ; for ( int i = 0 ; i < range ; ++ i ) { Label label = labels [ i ] ; if ( label != def ) { mark ( label ) ; generator . generateCase ( i + min , end ) ; } } } else { Label [ ] labels = new Label [ len ] ; for ( int i = 0 ; i < len ; ++ i ) { labels [ i ] = newLabel ( ) ; } mv . visitLookupSwitchInsn ( def , keys , labels ) ; for ( int i = 0 ; i < len ; ++ i ) { mark ( labels [ i ] ) ; generator . generateCase ( keys [ i ] , end ) ; } } } mark ( def ) ; generator . generateDefault ( ) ; mark ( end ) ; }
generates the instructions for a switch statement .
