6
6
import java .nio .CharBuffer ;
7
7
import java .io .UnsupportedEncodingException ;
8
8
import com .sun .jna .ptr .IntByReference ;
9
+ import com .sun .jna .ptr .LongByReference ;
10
+ import java .math .BigInteger ;
9
11
import java .util .ArrayList ;
10
12
import java .util .List ;
11
13
@@ -24,6 +26,10 @@ public class LexFloatClient {
24
26
*/
25
27
public static final int LF_FAIL = 1 ;
26
28
29
+ private static long toUnsignedLong (long value ) {
30
+ return BigInteger .valueOf (value ).and (BigInteger .valueOf (0xFFFFFFFFFFFFFFFFL )).longValue ();
31
+ }
32
+
27
33
/**
28
34
* Sets the product id of your application
29
35
*
@@ -257,19 +263,19 @@ public static String GetHostLicenseMetadata(String key) throws LexFloatClientExc
257
263
*/
258
264
public static HostLicenseMeterAttribute GetHostLicenseMeterAttribute (String name ) throws LexFloatClientException , UnsupportedEncodingException {
259
265
int status ;
260
- IntByReference allowedUses = new IntByReference (0 );
261
- IntByReference totalUses = new IntByReference (0 );
262
- IntByReference grossUses = new IntByReference (0 );
266
+ LongByReference allowedUses = new LongByReference (0 );
267
+ LongByReference totalUses = new LongByReference (0 );
268
+ LongByReference grossUses = new LongByReference (0 );
263
269
264
270
if (Platform .isWindows ()) {
265
271
status = LexFloatClientNative .GetHostLicenseMeterAttribute (new WString (name ), allowedUses , totalUses , grossUses );
266
272
if (LF_OK == status ) {
267
- return new HostLicenseMeterAttribute (name , allowedUses .getValue (), totalUses .getValue (), grossUses .getValue ());
273
+ return new HostLicenseMeterAttribute (name , allowedUses .getValue (), toUnsignedLong ( totalUses .getValue ()), toUnsignedLong ( grossUses .getValue () ));
268
274
}
269
275
} else {
270
276
status = LexFloatClientNative .GetHostLicenseMeterAttribute (name , allowedUses , totalUses , grossUses );
271
277
if (LF_OK == status ) {
272
- return new HostLicenseMeterAttribute (name , allowedUses .getValue (), totalUses .getValue (), grossUses .getValue ());
278
+ return new HostLicenseMeterAttribute (name , allowedUses .getValue (), toUnsignedLong ( totalUses .getValue ()), toUnsignedLong ( grossUses .getValue () ));
273
279
}
274
280
}
275
281
throw new LexFloatClientException (status );
0 commit comments