Skip to content

Commit bf099f2

Browse files
committed
Use os.arch and move variantSize check into static final variable
Signed-off-by: Dan Heidinga <[email protected]>
1 parent f7344f4 commit bf099f2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

runtime/src/main/java/com4j/Variant.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,20 @@ public int comEnumValue() {
364364
* definition. See https://docs.microsoft.com/en-gb/windows/desktop/api/oaidl/ns-oaidl-tagvariant
365365
*/
366366
private static int variantSize() {
367-
String model = System.getProperty("sun.arch.data.model");
368-
if (model.equals("64")) {
367+
/* Typical os.arch values: `x86_64`, `amd64` */
368+
String model = System.getProperty("os.arch");
369+
if (model.indexOf("64") != -1) {
369370
return 24;
370371
}
371372
return 16;
372373
}
373374

375+
private static final int variantSize = variantSize();
376+
374377
/**
375378
* Creates an empty {@link Variant}.
376379
*/
377380
public Variant() {
378-
final int variantSize = variantSize();
379381
image = ByteBuffer.allocateDirect(variantSize);
380382
image.order(ByteOrder.LITTLE_ENDIAN);
381383
// The initial content of a buffer is, in general, undefined. See the documentation of java.nio.Buffer.

0 commit comments

Comments
 (0)