title: Writing fields to bytecode not working
body: <p>I am working on writing a class in bytecode but i am confused on how to add fields to the class.  I have tried adding a field like this</p>
  
  <pre><code>dout.writeShort(1);
  dout.writeShort(Modifier.PUBLIC);
  dout.writeShort(stringConstant("hdhd"));
  dout.writeShort(stringConstant(classCode(int.class)));
  </code></pre>
  
  <p>but when i try to load the resulting class i get a </p>
  
  <p>Exception in thread "main" java.lang.ClassFormatError: Illegal field modifiers in class test: 0x1
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
      at BytecodeTest$InterfaceClassLoader.buildInterface(BytecodeTest.java:139)
      at BytecodeTest.main(BytecodeTest.java:25)</p>
  
  <p>I should also mention that the class i am trying to build is an interface.</p>
  
  <p>I dont see what is invalid about the public modifier.</p>
  
  <p>Here is my classCode method</p>
  
  <pre><code>private static String classCode(Class&lt;?&gt; c) 
  {
      if (c == void.class)
          return "V";
      Class&lt;?&gt; arrayClass = Array.newInstance(c, 0).getClass();
      return arrayClass.getName().substring(1).replace('.', '/');
  }
  </code></pre>
  
  <hr>
  
  <p>My problem was that interfaces require final fields and i didn't make the field final.</p>