2 Replies Latest reply: Mar 5, 2014 9:37 PM by golfman RSS

    Installing an applet without any member variable usage

    derHarri

      Hello,

       

      i do make my first steps with JavaCard.

      I wrote a very simple Applet containing only 3 methods: install, process and my constructor.

      I convert it into a cap file using converter (JCDK2.2.2)

      Then install it with gpshell 1.4.4

       

      The source on the left side works fine.

      The right fails on calling "load -file playground.cap" in gpshell.

      Error: load() returns 0x80206A80 (6A80: Wrong data / Incorrect values in command data.)

       

      The only difference is the comment in the first line of the constructor. (Setting a value of a member variable)

       

      WorkingError

      package org.emetis.javacard.tests.playground;

      import javacard.framework.APDU;

      import javacard.framework.Applet;

       

      public class PlayGroundJC extends Applet {

        private byte dog;

       

        protected PlayGroundJC() {

      dog=0;

        register();

        }

        public static void install(byte[] bArray, short bOffset, byte bLength) {

        new PlayGroundJC();      

        }

        public void process(APDU apdu) {}

      }

      package org.emetis.javacard.tests.playground;

      import javacard.framework.APDU;

      import javacard.framework.Applet;

       

      public class PlayGroundJC extends Applet {

        private byte dog;

       

        protected PlayGroundJC() {

      // dog=0;

        register();

        }

        public static void install(byte[] bArray, short bOffset, byte bLength) {

        new PlayGroundJC();      

        }

        public void process(APDU apdu) {}

      }

       

      I am really confused.

      Any idea for this strange behavior ?

       

      Kind regards

      Harri E.

        • 1. Re: Installing an applet without any member variable usage
          Sebastien_Lorquet

          Hello

           

          I agree, that looks strange.

           

          Idea 0: Each time you tested this, did you remove the previous package before loading the new one? No card can contain the same package (AID) twice. This is obvious, but still worth mentionning.

           

          Idea 1: Try to call register() in the install() method, after returning from the constructor. No, that's not the same. install is a class method, while the constructor is an instance method.

           

          Idea 2:

          CAP files are zip/jar files.

          Each one will contain a manifest, and a set of ".cap" files (header.cap, directory.cap) in a subdirectory.

           

          Can you list the cap components in each case? and what about the manifest?

           

          BR

          Sebastien

          • 2. Re: Installing an applet without any member variable usage
            golfman

            show your command it's return 6A80 here. maybe project environment is set different. for example package AID is same as some packages loaded / installed inside before. this error is nothing to do with this code.

             

            chen song