title: Using reflection to change static final File.separatorChar for unit testing?
body: <p>Specifically, I'm trying to create a unit test for a method which requires uses <code>File.separatorChar</code> to build paths on windows and unix. The code must run on both platforms, and yet I get errors with JUnit when I attempt to change this static final field.</p>
  
  <p>Anyone have any idea what's going on?</p>
  
  <pre><code>Field field = java.io.File.class.getDeclaredField( "separatorChar" );
  field.setAccessible(true);
  field.setChar(java.io.File.class,'/');
  </code></pre>
  
  <p>When I do this, I get</p>
  
  <pre><code>IllegalAccessException: Can not set static final char field java.io.File.separatorChar to java.lang.Character
  </code></pre>
  
  <p>Thoughts?</p>