Why can’t I just call ‘throw’ to return the status word?

Julien SIMON

In standard Java, you’d do something like throw new MyException(). The problem is that Java Card doesn’t support garbage collection. Hence, it’s highly undesirable to create many short-lived objects, whose memory will NOT be reclaimed. Here, “many” really means one for each APDU!

Instead, you must call ISOException.throwIt(). This class extends the Exception class and implements the well-known Singleton pattern, so there’s only one instance of the ISOException class, which is reused. This way, applets can throw and catch exceptions, but still conserve memory.

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact