title: Javacard Shareable Interface: lookupAID returns AID but getAppletShareableInterface returns null
body: <p>edit 2: Found the mistake. I tried to initialize the Shareable object in the constructor. At that time the client's register method is not yet called, so the JCRE doesn't have its AID. While my server's getShareableInterfaceObject(AID clientaid, byte parameter) method doesn't require the client's AID to be != null the JCRE probably does, since it calls this method for my client. I now initialize my Shareable object when I process my first APDU and it now works.</p>
  
  <p>And btw, thank you owlstead for helping with formatting of my post. Definitely made it easier to read!</p>
  
  <hr>
  
  <p>I'm new to Java Card development and I can't get my <code>Shareable</code> interface to work.</p>
  
  <p>I have an interface class declaring a function my client applet wants to use. My server applet implements this class. My client applet looks up the AID and tries to acquire the interface by calling <code>getAppletShareableInterface()</code>. But this always returns <code>null</code>.</p>
  
  <p>My server applet's <code>getShareableInterface()</code> consists of just <code>return this;</code>, so I guess the fault lies elsewhere. But I have no idea where.</p>
  
  <p>I'm using the JCWDE and stepping through the code I see that my server applet calls register so the client applet should be able to find it. Can anyone give me some pointers what could be going wrong?</p>
  
  <p>edit:</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface IF extends Shareable {
      public void method();
  }
  
  public class Server extends Applet implements IF {
      public getShareableInterfaceObject {
          return this;
      }
  }
  
  public class Client extends Applet {
  
      private Client() {
          AID ServerAID = JCSystem.lookupAID(byteArrayAID, (short)0, (byte)byteArrayAID.length);
          interface = (IF)JCSystem.getAppletShareableInterfaceObject(ServerAID, (byte)0x00);
      }
  
      public void process(APDU apdu) {
          interface.method();
      }
  }
  </code></pre>
  
  <p>lookupAID returns the correct AID, but getAppletShareableInterfaceObject returns null as if the server applet didn't exist.</p>