title: Changing the interface without recompiling the implementing class
body: <p>I have the following classes</p>
  
  <pre><code>public abstract interface X 
  {
      public abstract void f() throws java.io.IOException;
  }
  
  
  public class Y implements X 
  {
      public void f() throws java.io.IOException 
      {
          throw new java.ioIOException("Hello");
      }
  
      public static void main(String [] args)
      {
          X x = new Y();
          try
          {
              x.f();
          }
          catch (IOException e)
          {
              System.out.println("Caught");
          }
      }
  
  }
  </code></pre>
  
  <p>Now I compile both and get <code>X.class</code> and <code>Y.class</code>.</p>
  
  <p>Now I change X to remove the throws</p>
  
  <pre><code>public abstract interface X 
  {
      public abstract void f();
  }
  </code></pre>
  
  <p>Obviously if I recompile both X &amp; Y, Y's compilation will fail</p>
  
  <pre><code>Y.java:4: f() in Y cannot implement f() in X; overridden method does not throw j
  ava.io.IOException
  </code></pre>
  
  <p>However, what I if only recompile X.java &amp; keep my Y.class which was compiled with the older X.java.</p>
  
  <p>What happens in such a case - is it well defined? </p>
  
  <p>Or does it fall under the category of undefined - i.e. anything can happen? </p>
  
  <p>Are there any guarantees at all - i.e. if I am running it always under Java 1.6.32 under Windows, can I rely on nothing bad happening?</p>
  
  <p>Update: Updated it because some answers said I would get a <code>IncompatibleClassChangeError</code> at runtime. But I don't.</p>
  
  <p>Steps</p>
  
  <p>1) Compile both X.java and Y.java as given above. Run Y.</p>
  
  <p>Output: Caught</p>
  
  <p>2) Change X.java to comment out the throws. Recompile X.java. <strong>Do not</strong> recompile Y.java.</p>
  
  <p>Run Y</p>
  
  <p>Output: Caught</p>
  
  <p>I am running java on Windows 7</p>
  
  <p>Compiler</p>
  
  <pre><code>javac 1.6.0_35
  </code></pre>
  
  <p>Runtime</p>
  
  <pre><code>java version "1.6.0_35"
  Java(TM) SE Runtime Environment (build 1.6.0_35-b10)
  Java HotSpot(TM) Client VM (build 20.10-b01, mixed mode, sharing)
  </code></pre>