Page 1 of 1

Transient reference to a byte array

Posted: Wed Jul 05, 2017 12:38 pm
by kosullivan
Hi folks,

I'm trying to write a data parsing class in Javacard and I want to store a transient pointer to the data buffer inside the class instance, so I don't have to keep passing the array, offset and length every call.

An example of how it would be used is:

Code: Select all

DataParser parser = new DataParser(); // Created in the Applet constructor

parser.setData(buffer, offset, length);
byte a = parser.readNextByte();
short b = parser.readNextShort();
short c = parser.readNextShort();

Is there any way in Javacard for a class to store a reference to a byte array without it being persistent?
Thanks,
kos

Re: Transient reference to a byte array

Posted: Wed Jul 05, 2017 10:19 pm
by UNKNwYSHSA
You can store the reference to a array created by JC API: JCSystem.makeTransientObjectArray(...).
Hope that is what you need.

Re: Transient reference to a byte array

Posted: Thu Aug 17, 2017 11:52 am
by kosullivan
Hi, apologies for not replying to this for so long. This is exactly what I was after, thanks :)