Page 1 of 1

Static class variables in javacard applet

Posted: Tue Jan 26, 2016 11:14 pm
by Elisadl
Hi folks!
I have some doubts about static class variables in javacard applet.

Q1: Why should I never use static class variables in java card applets or to use it very carefully ?
Q2: Why does the Static variables are stored in heap and what are the issues in using them?

Hope someone clarify my doubts. Thanks!

Re: Static class variables in javacard applet

Posted: Thu Jan 28, 2016 10:21 pm
by UNKNwYSHSA
A1:
1 The applet instance which create one static object can't be deleted (You should set the static object to null before delete the applet instance);
2 You should make sure the static object is null or not before use it.
A2:
1 The static object is allocated by the new statement, so it is located in heap. The data memory space can be located in heap or COR/COD;
2 You can use it when applet instances use one common object.

Re: Static class variables in javacard applet

Posted: Fri May 18, 2018 4:27 am
by WhiteRabbit
The static class variables are very useful for sharing data to across the object instance. Even to share the data among applets or packages.