2 Replies Latest reply on Mar 2, 2012 12:39 AM by safarmer

    static final problem.

      I am having one large java card application. Because of its size I splited it in three packages. One applet package and two library packages.
      In one class that is part of one library package I am having several constants which are byte arrays. When I put the identifier static final, I was able to build the project but when I was running the applet, I was getting the exception 0x6F00 when I access that field in a static way. What can be the reason for that? When I modify these fields in a way that I remove the static final identifier and when I accessed that field in a instance manner, everything was ok.
        • 1. Re: static final problem.
          Can you share the code how you define them and how you are accessing them ?
          • 2. Re: static final problem.

            VCheck the JCVM spec for limitations on library packages. Since static fields (objects) are created in the context of the applet that first uses the class other applets in different packages would get a security exception when using these fields as they are in a different context. One solution is to initialise the constants in the applet and pass a reference to the class in the library package. This is not as clean but it works. Just be sure to clear the references when you uninstall the applet to allow the JCRE to remove your applet instances.