From 285e443aa24cde2324380ebeac83c97efc456f94 Mon Sep 17 00:00:00 2001
Message-Id:
<285e443aa24cde2324380ebeac83c97efc456f94.1350037981.git.cbley(a)av-test.de>
In-Reply-To: <cover.1350037981.git.cbley(a)av-test.de>
References:
<2DA6F4A3691599408358374D182280F9141CF6(a)xmb-rcd-x04.cisco.com> <cover.1350037981.git.cbley(a)av-test.de>
From: cbley(a)av-test.de (Claudio Bley)
Date: Thu, 11 Oct 2012 14:58:57 +0200
Subject: [PATCH 15/15] Explicitely define the order of a struct's fields.
To: libvir-list(a)redhat.com
Organization: AV-Test GmbH, Germany
The latest JNA version requires us to define the order of the fields
in a struct explicitely because the JVM does not guarantee the order
of the fields returned by Class.getFields().
---
src/main/java/org/libvirt/jna/virConnectAuth.java | 10 ++++++++++
.../java/org/libvirt/jna/virConnectCredential.java | 12 ++++++++++++
.../java/org/libvirt/jna/virDomainBlockInfo.java | 8 ++++++++
.../java/org/libvirt/jna/virDomainBlockStats.java | 11 +++++++++++
src/main/java/org/libvirt/jna/virDomainInfo.java | 11 +++++++++++
.../org/libvirt/jna/virDomainInterfaceStats.java | 13 +++++++++++++
.../java/org/libvirt/jna/virDomainJobInfo.java | 18 ++++++++++++++++++
.../java/org/libvirt/jna/virDomainMemoryStats.java | 7 +++++++
src/main/java/org/libvirt/jna/virError.java | 19 +++++++++++++++++++
src/main/java/org/libvirt/jna/virNodeInfo.java | 15 +++++++++++++++
.../java/org/libvirt/jna/virSchedParameter.java | 9 +++++++++
.../java/org/libvirt/jna/virStoragePoolInfo.java | 10 ++++++++++
.../java/org/libvirt/jna/virStorageVolInfo.java | 8 ++++++++
src/main/java/org/libvirt/jna/virVcpuInfo.java | 9 +++++++++
14 files changed, 160 insertions(+)
diff --git a/src/main/java/org/libvirt/jna/virConnectAuth.java
b/src/main/java/org/libvirt/jna/virConnectAuth.java
index 74dd65c..f805b89 100644
--- a/src/main/java/org/libvirt/jna/virConnectAuth.java
+++ b/src/main/java/org/libvirt/jna/virConnectAuth.java
@@ -3,6 +3,9 @@ package org.libvirt.jna;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virConnectAuth structure
*/
@@ -11,4 +14,11 @@ public class virConnectAuth extends Structure {
public int ncredtype;
public Libvirt.VirConnectAuthCallback cb;
public Pointer cbdata;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("credtype",
+ "ncredtype",
+ "cb",
+ "cbdata");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virConnectCredential.java
b/src/main/java/org/libvirt/jna/virConnectCredential.java
index ba47482..7a750d1 100644
--- a/src/main/java/org/libvirt/jna/virConnectCredential.java
+++ b/src/main/java/org/libvirt/jna/virConnectCredential.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virConnectCredential structure
*/
@@ -13,4 +16,13 @@ public class virConnectCredential extends Structure implements
Structure.ByRefer
// public Pointer result;
public String result;
public int resultlen;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("type",
+ "prompt",
+ "challenge",
+ "defresult",
+ "result",
+ "resultlen");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
b/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
index 234a381..fdf8bb1 100644
--- a/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainBlockInfo.java
@@ -2,9 +2,17 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
public class virDomainBlockInfo extends Structure {
public long capacity;
public long allocation;
public long physical;
+ protected List getFieldOrder() {
+ return Arrays.asList("capacity",
+ "allocation",
+ "physical");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainBlockStats.java
b/src/main/java/org/libvirt/jna/virDomainBlockStats.java
index f29dba0..c7f0d8c 100644
--- a/src/main/java/org/libvirt/jna/virDomainBlockStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainBlockStats.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virDomainBlockStats structure
*/
@@ -16,4 +19,12 @@ public class virDomainBlockStats extends Structure {
// is correct
public long errs; // this is a long long in the code, so a long mapping is
// correct
+
+ protected List getFieldOrder() {
+ return Arrays.asList("rd_req",
+ "rd_bytes",
+ "wr_req",
+ "wr_bytes",
+ "errs");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainInfo.java
b/src/main/java/org/libvirt/jna/virDomainInfo.java
index a93c0a5..8525f37 100644
--- a/src/main/java/org/libvirt/jna/virDomainInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainInfo.java
@@ -3,6 +3,9 @@ package org.libvirt.jna;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virDomainInfo structure
*/
@@ -12,4 +15,12 @@ public class virDomainInfo extends Structure {
public NativeLong memory;
public short nrVirtCpu;
public long cpuTime;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("state",
+ "maxMem",
+ "memory",
+ "nrVirtCpu",
+ "cpuTime");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
b/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
index 1cb0e66..39ceb52 100644
--- a/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainInterfaceStats.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virDomainInterfaceStats structure
*/
@@ -23,4 +26,14 @@ public class virDomainInterfaceStats extends Structure {
public long tx_drop; // this is a long long in the code, so a long mapping
// is correct
+ protected List getFieldOrder() {
+ return Arrays.asList("rx_bytes",
+ "rx_packets",
+ "rx_errs",
+ "rx_drop",
+ "tx_bytes",
+ "tx_packets",
+ "tx_errs",
+ "tx_drop");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainJobInfo.java
b/src/main/java/org/libvirt/jna/virDomainJobInfo.java
index 98b4f59..f8b63e0 100644
--- a/src/main/java/org/libvirt/jna/virDomainJobInfo.java
+++ b/src/main/java/org/libvirt/jna/virDomainJobInfo.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
public class virDomainJobInfo extends Structure {
public int type;
public long timeElapsed;
@@ -15,4 +18,19 @@ public class virDomainJobInfo extends Structure {
public long fileTotal;
public long fileProcessed;
public long fileRemaining;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("type",
+ "timeElapsed",
+ "timeRemaining",
+ "dataTotal",
+ "dataProcessed",
+ "dataRemaining",
+ "memTotal",
+ "memProcessed",
+ "memRemaining",
+ "fileTotal",
+ "fileProcessed",
+ "fileRemaining");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
b/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
index 7a9f5d2..1d4e075 100644
--- a/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
+++ b/src/main/java/org/libvirt/jna/virDomainMemoryStats.java
@@ -2,7 +2,14 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
public class virDomainMemoryStats extends Structure {
public int tag ;
public long val ;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("tag", "val");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virError.java
b/src/main/java/org/libvirt/jna/virError.java
index e2580dd..b3fad6d 100644
--- a/src/main/java/org/libvirt/jna/virError.java
+++ b/src/main/java/org/libvirt/jna/virError.java
@@ -3,6 +3,9 @@ package org.libvirt.jna;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virError structure
*/
@@ -19,4 +22,20 @@ public class virError extends Structure {
public int int1;
public int int2;
public NetworkPointer net;
+
+ protected List getFieldOrder() {
+ return Arrays.asList(
+ "code",
+ "domain",
+ "message",
+ "level",
+ "conn",
+ "dom",
+ "str1",
+ "str2",
+ "str3",
+ "int1",
+ "int2",
+ "net");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virNodeInfo.java
b/src/main/java/org/libvirt/jna/virNodeInfo.java
index 532aad9..6f0d002 100644
--- a/src/main/java/org/libvirt/jna/virNodeInfo.java
+++ b/src/main/java/org/libvirt/jna/virNodeInfo.java
@@ -3,6 +3,9 @@ package org.libvirt.jna;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virNodeInfo structure
*/
@@ -21,4 +24,16 @@ public class virNodeInfo extends Structure {
public int sockets;
public int cores;
public int threads;
+
+ protected List getFieldOrder() {
+ return Arrays.asList(
+ "model",
+ "memory",
+ "cpus",
+ "mhz",
+ "nodes",
+ "sockets",
+ "cores",
+ "threads");
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/libvirt/jna/virSchedParameter.java
b/src/main/java/org/libvirt/jna/virSchedParameter.java
index 0013fff..e213f04 100644
--- a/src/main/java/org/libvirt/jna/virSchedParameter.java
+++ b/src/main/java/org/libvirt/jna/virSchedParameter.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virSchedParameter structure
*/
@@ -9,4 +12,10 @@ public class virSchedParameter extends Structure {
public byte field[] = new byte[Libvirt.VIR_DOMAIN_SCHED_FIELD_LENGTH];
public int type;
public virSchedParameterValue value;
+
+ protected List getFieldOrder() {
+ return Arrays.asList("field",
+ "type",
+ "value");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
b/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
index 5a98e08..860b78e 100644
--- a/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
+++ b/src/main/java/org/libvirt/jna/virStoragePoolInfo.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virStoragePoolInfo structure
*/
@@ -13,4 +16,11 @@ public class virStoragePoolInfo extends Structure {
// mapping is correct
public long available; // this is a long long in the code, so a long mapping
// is correct
+
+ protected List getFieldOrder() {
+ return Arrays.asList("state",
+ "capacity",
+ "allocation",
+ "available");
+ }
}
diff --git a/src/main/java/org/libvirt/jna/virStorageVolInfo.java
b/src/main/java/org/libvirt/jna/virStorageVolInfo.java
index db8a5bd..d07b22e 100644
--- a/src/main/java/org/libvirt/jna/virStorageVolInfo.java
+++ b/src/main/java/org/libvirt/jna/virStorageVolInfo.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virStorageVolInfo structure
*/
@@ -12,4 +15,9 @@ public class virStorageVolInfo extends Structure {
public long allocation; // this is a long long in the code, so a long
// mapping is correct
+ protected List getFieldOrder() {
+ return Arrays.asList("type",
+ "capacity",
+ "allocation");
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/libvirt/jna/virVcpuInfo.java
b/src/main/java/org/libvirt/jna/virVcpuInfo.java
index 16f237d..7bf3448 100644
--- a/src/main/java/org/libvirt/jna/virVcpuInfo.java
+++ b/src/main/java/org/libvirt/jna/virVcpuInfo.java
@@ -2,6 +2,9 @@ package org.libvirt.jna;
import com.sun.jna.Structure;
+import java.util.List;
+import java.util.Arrays;
+
/**
* JNA mapping for the virVcpuInfo structure
*/
@@ -12,4 +15,10 @@ public class virVcpuInfo extends Structure {
// is correct
public int cpu;
+ protected List getFieldOrder() {
+ return Arrays.asList("number",
+ "state",
+ "cpuTime",
+ "cpu");
+ }
}
--
AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>
Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern