title: Java enum and additional class files
body: <p>I've noticed <code>enums</code> introduce many additional class files (Class$1) after compilation bloating the total size. It seems to be attached to every class that even uses an enum, and these are often duplicated.</p>
  
  <p>Why does this occur and is there a way to prevent this without removing the enum.</p>
  
  <p>(Reason for question is space is at a premium for me)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>On investigating the issue further, Sun's <strong>Javac 1.6 creates an additional synthetic class each time you use a switch on an Enum</strong>. It uses some kind of SwitchMap. <a href="http://jakeherringbone.com/2009/04/switchmap/" rel="noreferrer">This</a> site has some more information, and <a href="https://stackoverflow.com/questions/1163076/how-is-values-implemented-for-java-6-enums/1163121#1163121">here</a> tells you how to analyse what Javac is doing.</p>
  
  <p>An additional physical file seems a high price to pay each time you use a switch on an enum!</p>
  
  <p>Interestingly, Eclipe's compiler does not produce these additional files. I wonder if the only solution is to switch compilers?</p>