private void finishMethod() {
    if (currMethod!=null) { // finish the previous method
      int codeEnd=tsize;
      writeShort(0); // no exception table       // TODO: add exceptions
      writeShort(0); // no attributes

      int currPos=tsize;
      
      // Code attribute length
      tsize=startCodeAttr+2;
      writeInt(currPos-startCodeAttr-6);

      tsize=startCodeAttr+6;
      writeShort(mW);

      tsize=startCode-2;
      writeShort(codeEnd-startCode);
      
      tsize=currPos;

      currMethod=null;
    };
  };