diff --git a/contrib/platform/src/com/sun/jna/platform/DesktopWindow.java b/contrib/platform/src/com/sun/jna/platform/DesktopWindow.java
index 65867b12ce..988ef45790 100644
--- a/contrib/platform/src/com/sun/jna/platform/DesktopWindow.java
+++ b/contrib/platform/src/com/sun/jna/platform/DesktopWindow.java
@@ -22,55 +22,55 @@
* @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de
*/
public class DesktopWindow {
- private HWND hwnd;
- private String title;
- private String filePath;
- private Rectangle locAndSize;
+ private HWND hwnd;
+ private String title;
+ private String filePath;
+ private Rectangle locAndSize;
- /**
- * @param hwnd
- * The associated window handle for this window.
- * @param title
- * The title text of the window.
- * @param filePath
- * The full file path to the main process that created the
- * window.
- * @param locAndSize
- * The window's location on screen and its dimensions.
- */
- public DesktopWindow(final HWND hwnd, final String title,
- final String filePath, final Rectangle locAndSize) {
- this.hwnd = hwnd;
- this.title = title;
- this.filePath = filePath;
- this.locAndSize = locAndSize;
- }
+ /**
+ * @param hwnd
+ * The associated window handle for this window.
+ * @param title
+ * The title text of the window.
+ * @param filePath
+ * The full file path to the main process that created the
+ * window.
+ * @param locAndSize
+ * The window's location on screen and its dimensions.
+ */
+ public DesktopWindow(final HWND hwnd, final String title,
+ final String filePath, final Rectangle locAndSize) {
+ this.hwnd = hwnd;
+ this.title = title;
+ this.filePath = filePath;
+ this.locAndSize = locAndSize;
+ }
- /**
- * @return The associated window handle for this window.
- */
- public HWND getHWND() {
- return hwnd;
- }
+ /**
+ * @return The associated window handle for this window.
+ */
+ public HWND getHWND() {
+ return hwnd;
+ }
- /**
- * @return The title text of the window.
- */
- public String getTitle() {
- return title;
- }
+ /**
+ * @return The title text of the window.
+ */
+ public String getTitle() {
+ return title;
+ }
- /**
- * @return The full file path to the main process that created the window.
- */
- public String getFilePath() {
- return filePath;
- }
+ /**
+ * @return The full file path to the main process that created the window.
+ */
+ public String getFilePath() {
+ return filePath;
+ }
- /**
- * @return The window's location on screen and its dimensions.
- */
- public Rectangle getLocAndSize() {
- return locAndSize;
- }
+ /**
+ * @return The window's location on screen and its dimensions.
+ */
+ public Rectangle getLocAndSize() {
+ return locAndSize;
+ }
}
diff --git a/contrib/platform/src/com/sun/jna/platform/WindowUtils.java b/contrib/platform/src/com/sun/jna/platform/WindowUtils.java
index 0dee8ad896..c537b799cc 100644
--- a/contrib/platform/src/com/sun/jna/platform/WindowUtils.java
+++ b/contrib/platform/src/com/sun/jna/platform/WindowUtils.java
@@ -572,114 +572,107 @@ protected void setForceHeavyweightPopups(Window w, boolean force) {
}
}
- /**
- * Obtains the set icon for the window associated with the specified
- * window handle.
- *
- * @param hwnd
- * The concerning window handle.
- * @return Either the window's icon or {@code null} if an error
- * occurred.
- *
- * @throws UnsupportedOperationException
- * Thrown if this method wasn't yet implemented for the
- * current platform.
- */
- protected BufferedImage getWindowIcon(final HWND hwnd) {
- throw new UnsupportedOperationException(
- "This platform is not supported, yet.");
- }
-
- /**
- * Detects the size of an icon.
- *
- * @param hIcon
- * The icon handle type.
- * @return Either the requested icon's dimension or an {@link Dimension}
- * instance of {@code (0, 0)}.
- *
- * @throws UnsupportedOperationException
- * Thrown if this method wasn't yet implemented for the
- * current platform.
- */
- protected Dimension getIconSize(final HICON hIcon) {
- throw new UnsupportedOperationException(
- "This platform is not supported, yet.");
- }
-
- /**
- * Requests a list of all currently available Desktop windows.
- *
- * @param onlyVisibleWindows
- * Specifies whether only currently visible windows will be
- * considered ({@code true}). That are windows which are not
- * minimized. The {@code WS_VISIBLE} flag will be checked
- * (see: User32.IsWindowVisible(HWND)).
- *
- * @return A list with all windows and some detailed information.
- *
- * @throws UnsupportedOperationException
- * Thrown if this method wasn't yet implemented for the
- * current platform.
- */
- protected List getAllWindows(
- final boolean onlyVisibleWindows) {
- throw new UnsupportedOperationException(
- "This platform is not supported, yet.");
- }
-
- /**
- * Tries to obtain the Window's title which belongs to the specified
- * window handle.
- *
- * @param hwnd
- * The concerning window handle.
- * @return Either the title or an empty string of no title was found or
- * an error occurred.
- *
- * @throws UnsupportedOperationException
- * Thrown if this method wasn't yet implemented for the
- */
- protected String getWindowTitle(final HWND hwnd) {
- throw new UnsupportedOperationException(
- "This platform is not supported, yet.");
- }
-
- /**
- * Detects the full file path of the process associated with the specified
- * window handle.
- *
- * @param hwnd
- * The concerning window handle for which the PE file path is
- * required.
- * @return The full file path of the PE file that is associated with the
- * specified window handle.
- *
- * @throws UnsupportedOperationException
- * Thrown if this method wasn't yet implemented for the
- */
- protected String getProcessFilePath(final HWND hwnd){
- throw new UnsupportedOperationException(
- "This platform is not supported, yet.");
- }
-
- /**
- * Requests the location and size of the window associated with the
- * specified window handle.
- *
- * @param hwnd
- * The concerning window handle.
- * @return The location and size of the window.
- *
- * @throws UnsupportedOperationException
- * Thrown if this method wasn't yet implemented for the
- */
- protected Rectangle getWindowLocationAndSize(final HWND hwnd) {
- throw new UnsupportedOperationException(
- "This platform is not supported, yet.");
- }
+ /**
+ * Obtains the set icon for the window associated with the specified
+ * window handle.
+ *
+ * @param hwnd
+ * The concerning window handle.
+ * @return Either the window's icon or {@code null} if an error
+ * occurred.
+ *
+ * @throws UnsupportedOperationException
+ * Thrown if this method wasn't yet implemented for the
+ * current platform.
+ */
+ protected BufferedImage getWindowIcon(final HWND hwnd) {
+ throw new UnsupportedOperationException("This platform is not supported, yet.");
+ }
+
+ /**
+ * Detects the size of an icon.
+ *
+ * @param hIcon
+ * The icon handle type.
+ * @return Either the requested icon's dimension or an {@link Dimension}
+ * instance of {@code (0, 0)}.
+ *
+ * @throws UnsupportedOperationException
+ * Thrown if this method wasn't yet implemented for the
+ * current platform.
+ */
+ protected Dimension getIconSize(final HICON hIcon) {
+ throw new UnsupportedOperationException("This platform is not supported, yet.");
+ }
+
+ /**
+ * Requests a list of all currently available Desktop windows.
+ *
+ * @param onlyVisibleWindows
+ * Specifies whether only currently visible windows will be
+ * considered ({@code true}). That are windows which are not
+ * minimized. The {@code WS_VISIBLE} flag will be checked
+ * (see: User32.IsWindowVisible(HWND)).
+ *
+ * @return A list with all windows and some detailed information.
+ *
+ * @throws UnsupportedOperationException
+ * Thrown if this method wasn't yet implemented for the
+ * current platform.
+ */
+ protected List getAllWindows(final boolean onlyVisibleWindows) {
+ throw new UnsupportedOperationException("This platform is not supported, yet.");
+ }
+
+ /**
+ * Tries to obtain the Window's title which belongs to the specified
+ * window handle.
+ *
+ * @param hwnd
+ * The concerning window handle.
+ * @return Either the title or an empty string of no title was found or
+ * an error occurred.
+ *
+ * @throws UnsupportedOperationException
+ * Thrown if this method wasn't yet implemented for the
+ */
+ protected String getWindowTitle(final HWND hwnd) {
+ throw new UnsupportedOperationException("This platform is not supported, yet.");
+ }
+
+ /**
+ * Detects the full file path of the process associated with the specified
+ * window handle.
+ *
+ * @param hwnd
+ * The concerning window handle for which the PE file path is
+ * required.
+ * @return The full file path of the PE file that is associated with the
+ * specified window handle.
+ *
+ * @throws UnsupportedOperationException
+ * Thrown if this method wasn't yet implemented for the
+ */
+ protected String getProcessFilePath(final HWND hwnd){
+ throw new UnsupportedOperationException("This platform is not supported, yet.");
+ }
+
+ /**
+ * Requests the location and size of the window associated with the
+ * specified window handle.
+ *
+ * @param hwnd
+ * The concerning window handle.
+ * @return The location and size of the window.
+ *
+ * @throws UnsupportedOperationException
+ * Thrown if this method wasn't yet implemented for the
+ */
+ protected Rectangle getWindowLocationAndSize(final HWND hwnd) {
+ throw new UnsupportedOperationException("This platform is not supported, yet.");
+ }
}
/** Canonical lazy loading of a singleton. */
private static class Holder {
diff --git a/contrib/platform/src/com/sun/jna/platform/mac/SystemB.java b/contrib/platform/src/com/sun/jna/platform/mac/SystemB.java
index 14f180c0d1..17cabfa62e 100644
--- a/contrib/platform/src/com/sun/jna/platform/mac/SystemB.java
+++ b/contrib/platform/src/com/sun/jna/platform/mac/SystemB.java
@@ -32,266 +32,276 @@
*/
public interface SystemB extends Library {
- public static SystemB INSTANCE = (SystemB) Native.loadLibrary("System",
- SystemB.class);
+ public static SystemB INSTANCE = (SystemB) Native.loadLibrary("System",
+ SystemB.class);
- // host_statistics()
- static int HOST_LOAD_INFO = 1;// System loading stats
- static int HOST_VM_INFO = 2; // Virtual memory stats
- static int HOST_CPU_LOAD_INFO = 3;// CPU load stats
+ // host_statistics()
+ static int HOST_LOAD_INFO = 1;// System loading stats
+ static int HOST_VM_INFO = 2; // Virtual memory stats
+ static int HOST_CPU_LOAD_INFO = 3;// CPU load stats
- // host_statistics64()
- static int HOST_VM_INFO64 = 4; // 64-bit virtual memory stats
+ // host_statistics64()
+ static int HOST_VM_INFO64 = 4; // 64-bit virtual memory stats
- // host_cpu_load_info()
- static int CPU_STATE_MAX = 4;
- static int CPU_STATE_USER = 0;
- static int CPU_STATE_SYSTEM = 1;
- static int CPU_STATE_IDLE = 2;
- static int CPU_STATE_NICE = 3;
+ // host_cpu_load_info()
+ static int CPU_STATE_MAX = 4;
+ static int CPU_STATE_USER = 0;
+ static int CPU_STATE_SYSTEM = 1;
+ static int CPU_STATE_IDLE = 2;
+ static int CPU_STATE_NICE = 3;
- // Data size
- static int UINT64_SIZE = Native.getNativeSize(long.class);
- static int INT_SIZE = Native.getNativeSize(int.class);
+ // Data size
+ static int UINT64_SIZE = Native.getNativeSize(long.class);
+ static int INT_SIZE = Native.getNativeSize(int.class);
- public static class HostCpuLoadInfo extends Structure {
- public int cpu_ticks[] = new int[CPU_STATE_MAX];
+ public static class HostCpuLoadInfo extends Structure {
+ public int cpu_ticks[] = new int[CPU_STATE_MAX];
- protected List getFieldOrder() {
- return Arrays.asList(new String[] { "cpu_ticks" });
- }
- }
+ protected List getFieldOrder() {
+ return Arrays.asList(new String[] { "cpu_ticks" });
+ }
+ }
- public static class HostLoadInfo extends Structure {
- public int[] avenrun = new int[3]; // scaled by LOAD_SCALE
- public int[] mach_factor = new int[3]; // scaled by LOAD_SCALE
+ public static class HostLoadInfo extends Structure {
+ public int[] avenrun = new int[3]; // scaled by LOAD_SCALE
+ public int[] mach_factor = new int[3]; // scaled by LOAD_SCALE
- protected List getFieldOrder() {
- return Arrays.asList(new String[] { "avenrun", "mach_factor" });
- }
- }
+ protected List getFieldOrder() {
+ return Arrays.asList(new String[] { "avenrun", "mach_factor" });
+ }
+ }
- public static class VMStatistics extends Structure {
- public int free_count; // # of pages free
- public int active_count; // # of pages active
- public int inactive_count; // # of pages inactive
- public int wire_count; // # of pages wired down
- public int zero_fill_count; // # of zero fill pages
- public int reactivations; // # of pages reactivated
- public int pageins; // # of pageins
- public int pageouts; // # of pageouts
- public int faults; // # of faults
- public int cow_faults; // # of copy-on-writes
- public int lookups; // object cache lookups
- public int hits; // object cache hits
- public int purgeable_count; // # of pages purgeable
- public int purges; // # of pages purged
- // # of pages speculative (included in free_count)
- public int speculative_count;
+ public static class VMStatistics extends Structure {
+ public int free_count; // # of pages free
+ public int active_count; // # of pages active
+ public int inactive_count; // # of pages inactive
+ public int wire_count; // # of pages wired down
+ public int zero_fill_count; // # of zero fill pages
+ public int reactivations; // # of pages reactivated
+ public int pageins; // # of pageins
+ public int pageouts; // # of pageouts
+ public int faults; // # of faults
+ public int cow_faults; // # of copy-on-writes
+ public int lookups; // object cache lookups
+ public int hits; // object cache hits
+ public int purgeable_count; // # of pages purgeable
+ public int purges; // # of pages purged
+ // # of pages speculative (included in free_count)
+ public int speculative_count;
- protected List getFieldOrder() {
- return Arrays.asList(new String[] { "free_count", "active_count",
- "inactive_count", "wire_count", "zero_fill_count",
- "reactivations", "pageins", "pageouts", "faults",
- "cow_faults", "lookups", "hits", "purgeable_count",
- "purges", "speculative_count" });
- }
- }
+ protected List getFieldOrder() {
+ return Arrays.asList(new String[] { "free_count", "active_count",
+ "inactive_count", "wire_count", "zero_fill_count",
+ "reactivations", "pageins", "pageouts", "faults",
+ "cow_faults", "lookups", "hits", "purgeable_count",
+ "purges", "speculative_count" });
+ }
+ }
- public static class VMStatistics64 extends VMStatistics {
- public long zero_fill_count; // # of zero fill pages
- public long reactivations; // # of pages reactivated
- public long pageins; // # of pageins
- public long pageouts; // # of pageouts
- public long faults; // # of faults
- public long cow_faults; // # of copy-on-writes
- public long lookups; // object cache lookups
- public long hits; // object cache hits
- public long purges; // # of pages purged
- public long decompressions; // # of pages decompressed
- public long compressions; // # of pages compressed
- // # of pages swapped in (via compression segments)
- public long swapins;
- // # of pages swapped out (via compression segments)
- public long swapouts;
- // # of pages used by the compressed pager to hold all the
- // compressed data
- public int compressor_page_count;
- public int throttled_count; // # of pages throttled
- // # of pages that are file-backed (non-swap)
- public int external_page_count;
- public int internal_page_count; // # of pages that are anonymous
- // # of pages (uncompressed) held within the compressor.
- public long total_uncompressed_pages_in_compressor;
+ public static class VMStatistics64 extends Structure {
+ public int free_count; // # of pages free
+ public int active_count; // # of pages active
+ public int inactive_count; // # of pages inactive
+ public int wire_count; // # of pages wired down
+ public long zero_fill_count; // # of zero fill pages
+ public long reactivations; // # of pages reactivated
+ public long pageins; // # of pageins
+ public long pageouts; // # of pageouts
+ public long faults; // # of faults
+ public long cow_faults; // # of copy-on-writes
+ public long lookups; // object cache lookups
+ public long hits; // object cache hits
+ public long purges; // # of pages purged
+ public int purgeable_count;
+ public int speculative_count;
+ public long decompressions; // # of pages decompressed
+ public long compressions; // # of pages compressed
+ // # of pages swapped in (via compression segments)
+ public long swapins;
+ // # of pages swapped out (via compression segments)
+ public long swapouts;
+ // # of pages used by the compressed pager to hold all the
+ // compressed data
+ public int compressor_page_count;
+ public int throttled_count; // # of pages throttled
+ // # of pages that are file-backed (non-swap)
+ public int external_page_count;
+ public int internal_page_count; // # of pages that are anonymous
+ // # of pages (uncompressed) held within the compressor.
+ public long total_uncompressed_pages_in_compressor;
- @Override
- protected List getFieldOrder() {
- return Arrays.asList(new String[] { "free_count", "active_count",
- "inactive_count", "wire_count", "zero_fill_count",
- "reactivations", "pageins", "pageouts", "faults",
- "cow_faults", "lookups", "hits", "purges",
- "purgeable_count", "speculative_count", "decompressions",
- "compressions", "swapins", "swapouts",
- "compressor_page_count", "throttled_count",
- "external_page_count", "internal_page_count",
- "total_uncompressed_pages_in_compressor" });
- }
- }
+ @Override
+ protected List getFieldOrder() {
+ return Arrays.asList(new String[] { "free_count", "active_count",
+ "inactive_count", "wire_count",
+ "zero_fill_count", "reactivations",
+ "pageins", "pageouts",
+ "faults", "cow_faults",
+ "lookups", "hits",
+ "purges",
+ "purgeable_count", "speculative_count",
+ "decompressions", "compressions",
+ "swapins", "swapouts",
+ "compressor_page_count", "throttled_count",
+ "external_page_count", "internal_page_count",
+ "total_uncompressed_pages_in_compressor" });
+ }
+ }
- /**
- * The mach_host_self system call returns the calling thread's host name
- * port. It has an effect equivalent to receiving a send right for the host
- * port.
- *
- * @return the host's name port
- */
- int mach_host_self();
+ /**
+ * The mach_host_self system call returns the calling thread's host name
+ * port. It has an effect equivalent to receiving a send right for the host
+ * port.
+ *
+ * @return the host's name port
+ */
+ int mach_host_self();
- /**
- * The host_page_size function returns the page size for the given host.
- *
- * @param machPort
- * The name (or control) port for the host for which the page
- * size is desired.
- * @param pPageSize
- * The host's page size (in bytes), set on success.
- * @return 0 on success; sets errno on failure
- */
- int host_page_size(int machPort, LongByReference pPageSize);
+ /**
+ * The host_page_size function returns the page size for the given host.
+ *
+ * @param machPort
+ * The name (or control) port for the host for which the page
+ * size is desired.
+ * @param pPageSize
+ * The host's page size (in bytes), set on success.
+ * @return 0 on success; sets errno on failure
+ */
+ int host_page_size(int machPort, LongByReference pPageSize);
- /**
- * The host_statistics function returns scheduling and virtual memory
- * statistics concerning the host as specified by hostStat.
- *
- * @param machPort
- * The control port for the host for which information is to be
- * obtained.
- * @param hostStat
- * The type of statistics desired (HOST_LOAD_INFO, HOST_VM_INFO,
- * or HOST_CPU_LOAD_INFO)
- * @param stats
- * Statistics about the specified host.
- * @param count
- * On input, the maximum size of the buffer; on output, the size
- * returned (in natural-sized units).
- * @return 0 on success; sets errno on failure
- */
- int host_statistics(int machPort, int hostStat, Structure stats,
+ /**
+ * The host_statistics function returns scheduling and virtual memory
+ * statistics concerning the host as specified by hostStat.
+ *
+ * @param machPort
+ * The control port for the host for which information is to be
+ * obtained.
+ * @param hostStat
+ * The type of statistics desired (HOST_LOAD_INFO, HOST_VM_INFO,
+ * or HOST_CPU_LOAD_INFO)
+ * @param stats
+ * Statistics about the specified host.
+ * @param count
+ * On input, the maximum size of the buffer; on output, the size
+ * returned (in natural-sized units).
+ * @return 0 on success; sets errno on failure
+ */
+ int host_statistics(int machPort, int hostStat, Structure stats,
IntByReference count);
- /**
- * The host_statistics64 function returns 64-bit virtual memory statistics
- * concerning the host as specified by hostStat.
- *
- * @param machPort
- * The control port for the host for which information is to be
- * obtained.
- * @param hostStat
- * The type of statistics desired (HOST_VM_INFO64)
- * @param stats
- * Statistics about the specified host.
- * @param count
- * On input, the maximum size of the buffer; on output, the size
- * returned (in natural-sized units).
- * @return 0 on success; sets errno on failure
- */
- int host_statistics64(int machPort, int hostStat, Structure stats,
- IntByReference count);
+ /**
+ * The host_statistics64 function returns 64-bit virtual memory statistics
+ * concerning the host as specified by hostStat.
+ *
+ * @param machPort
+ * The control port for the host for which information is to be
+ * obtained.
+ * @param hostStat
+ * The type of statistics desired (HOST_VM_INFO64)
+ * @param stats
+ * Statistics about the specified host.
+ * @param count
+ * On input, the maximum size of the buffer; on output, the size
+ * returned (in natural-sized units).
+ * @return 0 on success; sets errno on failure
+ */
+ int host_statistics64(int machPort, int hostStat, Structure stats,
+ IntByReference count);
- /**
- * The sysctl() function retrieves system information and allows processes
- * with appropriate privileges to set system information. The information
- * available from sysctl() consists of integers, strings, and tables.
- *
- * The state is described using a "Management Information Base" (MIB) style
- * name, listed in name, which is a namelen length array of integers.
- *
- * The information is copied into the buffer specified by oldp. The size of
- * the buffer is given by the location specified by oldlenp before the call,
- * and that location gives the amount of data copied after a successful call
- * and after a call that returns with the error code ENOMEM. If the amount
- * of data available is greater than the size of the buffer supplied, the
- * call supplies as much data as fits in the buffer provided and returns
- * with the error code ENOMEM. If the old value is not desired, oldp and
- * oldlenp should be set to NULL.
- *
- * The size of the available data can be determined by calling sysctl() with
- * the NULL argument for oldp. The size of the available data will be
- * returned in the location pointed to by oldlenp. For some operations, the
- * amount of space may change often. For these operations, the system
- * attempts to round up so that the returned size is large enough for a call
- * to return the data shortly thereafter.
- *
- * To set a new value, newp is set to point to a buffer of length newlen
- * from which the requested value is to be taken. If a new value is not to
- * be set, newp should be set to NULL and newlen set to 0.
- *
- * @param name
- * MIB array of integers
- * @param namelen
- * length of the MIB array
- * @param oldp
- * Information retrieved
- * @param oldlenp
- * Size of information retrieved
- * @param newp
- * Information to be written
- * @param newlen
- * Size of information to be written
- * @return 0 on success; sets errno on failure
- */
- int sysctl(int[] name, int namelen, Pointer oldp, IntByReference oldlenp,
- Pointer newp, int newlen);
+ /**
+ * The sysctl() function retrieves system information and allows processes
+ * with appropriate privileges to set system information. The information
+ * available from sysctl() consists of integers, strings, and tables.
+ *
+ * The state is described using a "Management Information Base" (MIB) style
+ * name, listed in name, which is a namelen length array of integers.
+ *
+ * The information is copied into the buffer specified by oldp. The size of
+ * the buffer is given by the location specified by oldlenp before the call,
+ * and that location gives the amount of data copied after a successful call
+ * and after a call that returns with the error code ENOMEM. If the amount
+ * of data available is greater than the size of the buffer supplied, the
+ * call supplies as much data as fits in the buffer provided and returns
+ * with the error code ENOMEM. If the old value is not desired, oldp and
+ * oldlenp should be set to NULL.
+ *
+ * The size of the available data can be determined by calling sysctl() with
+ * the NULL argument for oldp. The size of the available data will be
+ * returned in the location pointed to by oldlenp. For some operations, the
+ * amount of space may change often. For these operations, the system
+ * attempts to round up so that the returned size is large enough for a call
+ * to return the data shortly thereafter.
+ *
+ * To set a new value, newp is set to point to a buffer of length newlen
+ * from which the requested value is to be taken. If a new value is not to
+ * be set, newp should be set to NULL and newlen set to 0.
+ *
+ * @param name
+ * MIB array of integers
+ * @param namelen
+ * length of the MIB array
+ * @param oldp
+ * Information retrieved
+ * @param oldlenp
+ * Size of information retrieved
+ * @param newp
+ * Information to be written
+ * @param newlen
+ * Size of information to be written
+ * @return 0 on success; sets errno on failure
+ */
+ int sysctl(int[] name, int namelen, Pointer oldp, IntByReference oldlenp,
+ Pointer newp, int newlen);
- /**
- * The sysctlbyname() function accepts an ASCII representation of the name
- * and internally looks up the integer name vector. Apart from that, it
- * behaves the same as the standard sysctl() function.
- *
- * @param name
- * ASCII representation of the MIB name
- * @param oldp
- * Information retrieved
- * @param oldlenp
- * Size of information retrieved
- * @param newp
- * Information to be written
- * @param newlen
- * Size of information to be written
- * @return 0 on success; sets errno on failure
- */
- int sysctlbyname(String name, Pointer oldp, IntByReference oldlenp,
- Pointer newp, int newlen);
+ /**
+ * The sysctlbyname() function accepts an ASCII representation of the name
+ * and internally looks up the integer name vector. Apart from that, it
+ * behaves the same as the standard sysctl() function.
+ *
+ * @param name
+ * ASCII representation of the MIB name
+ * @param oldp
+ * Information retrieved
+ * @param oldlenp
+ * Size of information retrieved
+ * @param newp
+ * Information to be written
+ * @param newlen
+ * Size of information to be written
+ * @return 0 on success; sets errno on failure
+ */
+ int sysctlbyname(String name, Pointer oldp, IntByReference oldlenp,
+ Pointer newp, int newlen);
- /**
- * The sysctlnametomib() function accepts an ASCII representation of the
- * name, looks up the integer name vector, and returns the numeric
- * representation in the mib array pointed to by mibp. The number of
- * elements in the mib array is given by the location specified by sizep
- * before the call, and that location gives the number of entries copied
- * after a successful call. The resulting mib and size may be used in
- * subsequent sysctl() calls to get the data associated with the requested
- * ASCII name. This interface is intended for use by applications that want
- * to repeatedly request the same variable (the sysctl() function runs in
- * about a third the time as the same request made via the sysctlbyname()
- * function).
- *
- * The number of elements in the mib array can be determined by calling
- * sysctlnametomib() with the NULL argument for mibp.
- *
- * The sysctlnametomib() function is also useful for fetching mib prefixes.
- * If size on input is greater than the number of elements written, the
- * array still contains the additional elements which may be written
- * programmatically.
- *
- * @param name
- * ASCII representation of the name
- * @param mibp
- * Integer array containing the corresponding name vector.
- * @param size
- * On input, number of elements in the returned array; on output,
- * the number of entries copied.
- * @return 0 on success; sets errno on failure
- */
- int sysctlnametomib(String name, Pointer mibp, IntByReference size);
+ /**
+ * The sysctlnametomib() function accepts an ASCII representation of the
+ * name, looks up the integer name vector, and returns the numeric
+ * representation in the mib array pointed to by mibp. The number of
+ * elements in the mib array is given by the location specified by sizep
+ * before the call, and that location gives the number of entries copied
+ * after a successful call. The resulting mib and size may be used in
+ * subsequent sysctl() calls to get the data associated with the requested
+ * ASCII name. This interface is intended for use by applications that want
+ * to repeatedly request the same variable (the sysctl() function runs in
+ * about a third the time as the same request made via the sysctlbyname()
+ * function).
+ *
+ * The number of elements in the mib array can be determined by calling
+ * sysctlnametomib() with the NULL argument for mibp.
+ *
+ * The sysctlnametomib() function is also useful for fetching mib prefixes.
+ * If size on input is greater than the number of elements written, the
+ * array still contains the additional elements which may be written
+ * programmatically.
+ *
+ * @param name
+ * ASCII representation of the name
+ * @param mibp
+ * Integer array containing the corresponding name vector.
+ * @param size
+ * On input, number of elements in the returned array; on output,
+ * the number of entries copied.
+ * @return 0 on success; sets errno on failure
+ */
+ int sysctlnametomib(String name, Pointer mibp, IntByReference size);
}
diff --git a/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java b/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java
index aa5a40fc3f..5911806c98 100644
--- a/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java
+++ b/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java
@@ -12,8 +12,6 @@
*/
package com.sun.jna.platform;
-import static org.junit.Assert.assertNotEquals;
-
import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -116,43 +114,43 @@ protected void tearDown() {
private static final int W = 100;
private static final int H = 100;
- /**
- * Verfies that the specified pixel within the image has the expected color component values.
- *
- * @param img The image to be checked.
- * @param x The X coordinate of the pixel to be checked.
- * @param y The Y coordinate of the pixel to be checked.
- * @param expectedRed The expected value of the red color component.
- * @param expectedGreen The expected value of the green color component.
- * @param expectedBlue The expected value of the blue color component.
- */
- private static void assertPixelColor(final BufferedImage img, final int x, final int y, final int expectedRed, final int expectedGreen, final int expectedBlue){
- int rgb = img.getRGB(x, y);
- int r = (rgb >> 16) & 0xFF;
- int g = (rgb >> 8) & 0xFF;
- int b = (rgb & 0xFF);
-
- assertEquals(expectedRed, r);
- assertEquals(expectedGreen, g);
- assertEquals(expectedBlue, b);
- }
+ /**
+ * Verfies that the specified pixel within the image has the expected color component values.
+ *
+ * @param img The image to be checked.
+ * @param x The X coordinate of the pixel to be checked.
+ * @param y The Y coordinate of the pixel to be checked.
+ * @param expectedRed The expected value of the red color component.
+ * @param expectedGreen The expected value of the green color component.
+ * @param expectedBlue The expected value of the blue color component.
+ */
+ public static void assertPixelColor(final BufferedImage img, final int x, final int y, final int expectedRed, final int expectedGreen, final int expectedBlue){
+ int rgb = img.getRGB(x, y);
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = (rgb & 0xFF);
- /**
- * Extracts the values of the color components at the specified pixel.
- *
- * @param img The concerning image.
- * @param x The X coordinate of the concerning pixel.
- * @param y The Y coordinate of the concerning pixel.
- * @return An array with three elements that represents the color components of the pixel: Red, green, blue.
- */
- private static int[] getPixelColor(final BufferedImage img, final int x, final int y){
- int rgb = img.getRGB(x, y);
- int r = (rgb >> 16) & 0xFF;
- int g = (rgb >> 8) & 0xFF;
- int b = (rgb & 0xFF);
-
- return new int[]{r,g,b};
- }
+ assertEquals(expectedRed, r);
+ assertEquals(expectedGreen, g);
+ assertEquals(expectedBlue, b);
+ }
+
+ /**
+ * Extracts the values of the color components at the specified pixel.
+ *
+ * @param img The concerning image.
+ * @param x The X coordinate of the concerning pixel.
+ * @param y The Y coordinate of the concerning pixel.
+ * @return An array with three elements that represents the color components of the pixel: Red, green, blue.
+ */
+ public static int[] getPixelColor(final BufferedImage img, final int x, final int y){
+ int rgb = img.getRGB(x, y);
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = (rgb & 0xFF);
+
+ return new int[]{r,g,b};
+ }
public void xtestReveal() throws Exception {
final int SIZE = 200;
@@ -470,159 +468,6 @@ public void run() {
}
}
- public void testGetAllWindows() {
- final List allWindows = WindowUtils.getAllWindows(false);
- final List allVisibleWindows = WindowUtils
- .getAllWindows(true);
-
- assertTrue(allWindows.size() > 0);
- assertTrue(allVisibleWindows.size() > 0);
- assertTrue(allWindows.size() > allVisibleWindows.size());
-
- DesktopWindow explorerProc = null;
- for (final DesktopWindow dw : allWindows) {
- if (dw.getFilePath().toLowerCase().endsWith("explorer.exe")) {
- explorerProc = dw;
- break;
- }
- }
-
- assertNotNull(explorerProc);
-
- explorerProc = null;
- for (final DesktopWindow dw : allVisibleWindows) {
- if (dw.getFilePath().toLowerCase().endsWith("explorer.exe")) {
- explorerProc = dw;
- break;
- }
- }
-
- assertNotNull(explorerProc);
- }
-
- public void testGetWindowIcon() throws Exception {
- final JFrame w = new JFrame();
- try {
- final BufferedImage expectedIcon = ImageIO
- .read(new FileInputStream(new File(getClass().getResource(
- "/res/test_icon.png").getPath())));
- w.setIconImage(expectedIcon);
- w.setVisible(true);
- HWND hwnd = new HWND();
- hwnd.setPointer(Native.getComponentPointer(w));
-
- final BufferedImage obtainedIcon = WindowUtils.getWindowIcon(hwnd);
-
- assertTrue(obtainedIcon.getWidth() > 0);
- assertTrue(obtainedIcon.getHeight() > 0);
-
- int[] expectedColors = getPixelColor(expectedIcon, 10, 10);
- assertPixelColor(obtainedIcon, 10, 10, expectedColors[0],
- expectedColors[1], expectedColors[2]);
-
- expectedColors = getPixelColor(expectedIcon,
- expectedIcon.getWidth() - 10, 10);
- assertPixelColor(obtainedIcon, obtainedIcon.getWidth() - 10, 10,
- expectedColors[0], expectedColors[1], expectedColors[2]);
-
- expectedColors = getPixelColor(expectedIcon,
- expectedIcon.getWidth() - 10, expectedIcon.getHeight() - 10);
- assertPixelColor(obtainedIcon, obtainedIcon.getWidth() - 10,
- obtainedIcon.getHeight() - 10, expectedColors[0],
- expectedColors[1], expectedColors[2]);
-
- expectedColors = getPixelColor(expectedIcon, 10,
- expectedIcon.getHeight() - 10);
- assertPixelColor(obtainedIcon, 10, obtainedIcon.getHeight() - 10,
- expectedColors[0], expectedColors[1], expectedColors[2]);
- } finally {
- w.dispose();
- }
- }
-
- public void testGetWindowLocationAndSize() {
- final JFrame w = new JFrame();
- try {
- w.setLocation(23, 23);
- w.setPreferredSize(new Dimension(100, 100));
- w.pack();
- w.setVisible(true);
-
- HWND hwnd = new HWND();
- hwnd.setPointer(Native.getComponentPointer(w));
- final Rectangle locAndSize = WindowUtils
- .getWindowLocationAndSize(hwnd);
-
- assertEquals(w.getLocation().x, locAndSize.x);
- assertEquals(w.getLocation().y, locAndSize.y);
- assertEquals(w.getSize().width, locAndSize.width);
- assertEquals(w.getSize().height, locAndSize.height);
- } finally {
- w.dispose();
- }
- }
-
- public void testGetWindowTitle() {
- final JFrame w = new JFrame("A super unique title by PAX! "
- + System.currentTimeMillis());
- try {
- w.setVisible(true);
-
- HWND hwnd = new HWND();
- hwnd.setPointer(Native.getComponentPointer(w));
-
- assertEquals(w.getTitle(), WindowUtils.getWindowTitle(hwnd));
- } finally {
- w.dispose();
- }
- }
-
- public void testGetIconSize() throws Exception {
- final JFrame w = new JFrame();
- try {
- final BufferedImage expectedIcon = ImageIO
- .read(new FileInputStream(new File(getClass().getResource(
- "/res/test_icon.png").getPath())));
- w.setIconImage(expectedIcon);
- w.setVisible(true);
- HWND hwnd = new HWND();
- hwnd.setPointer(Native.getComponentPointer(w));
-
- final DWORDByReference hIconNumber = new DWORDByReference();
- long result = User32.INSTANCE.SendMessageTimeout(hwnd,
- WinUser.WM_GETICON, WinUser.ICON_BIG, 0,
- WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber);
-
- assertNotEquals(0, result);
-
- final HICON hIcon = new HICON(new Pointer(hIconNumber.getValue()
- .longValue()));
- assertTrue(WindowUtils.getIconSize(hIcon).width >= 32);
- assertTrue(WindowUtils.getIconSize(hIcon).height >= 32);
- assertEquals(WindowUtils.getIconSize(hIcon).width,
- WindowUtils.getIconSize(hIcon).height);
- } finally {
- w.dispose();
- }
- }
-
- public void testGetProcessFilePath() {
- final JFrame w = new JFrame();
- try {
- w.setVisible(true);
-
- final String searchSubStr = "\\bin\\java";
- final HWND hwnd = new HWND(Native.getComponentPointer(w));
-
- assertTrue("Path didn't contain '" + searchSubStr + "': "
- + WindowUtils.getProcessFilePath(hwnd),
- WindowUtils.getProcessFilePath(hwnd).toLowerCase()
- .contains(searchSubStr));
- } finally {
- w.dispose();
- }
- }
-
public static void main(String[] args) {
junit.textui.TestRunner.run(WindowUtilsTest.class);
}
diff --git a/contrib/platform/test/com/sun/jna/platform/mac/SystemBTest.java b/contrib/platform/test/com/sun/jna/platform/mac/SystemBTest.java
index 3cb39cb210..d3ca829cfa 100644
--- a/contrib/platform/test/com/sun/jna/platform/mac/SystemBTest.java
+++ b/contrib/platform/test/com/sun/jna/platform/mac/SystemBTest.java
@@ -17,10 +17,10 @@
package com.sun.jna.platform.mac;
import junit.framework.TestCase;
-import oshi.software.os.mac.local.SystemB.HostCpuLoadInfo;
-import oshi.software.os.mac.local.SystemB.HostLoadInfo;
-import oshi.software.os.mac.local.SystemB.VMStatistics;
-import oshi.software.os.mac.local.SystemB.VMStatistics64;
+import com.sun.jna.platform.mac.SystemB.HostCpuLoadInfo;
+import com.sun.jna.platform.mac.SystemB.HostLoadInfo;
+import com.sun.jna.platform.mac.SystemB.VMStatistics;
+import com.sun.jna.platform.mac.SystemB.VMStatistics64;
import com.sun.jna.Memory;
import com.sun.jna.Platform;
diff --git a/contrib/platform/test/com/sun/jna/platform/win32/WindowUtilsTest.java b/contrib/platform/test/com/sun/jna/platform/win32/WindowUtilsTest.java
new file mode 100644
index 0000000000..a82c81d425
--- /dev/null
+++ b/contrib/platform/test/com/sun/jna/platform/win32/WindowUtilsTest.java
@@ -0,0 +1,199 @@
+package com.sun.jna.platform.win32;
+
+import static org.junit.Assert.assertNotEquals;
+import static com.sun.jna.platform.WindowUtilsTest.assertPixelColor;
+import static com.sun.jna.platform.WindowUtilsTest.getPixelColor;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+import javax.swing.JFrame;
+import java.awt.image.BufferedImage;
+import java.awt.Rectangle;
+import java.awt.Dimension;
+
+import junit.framework.TestCase;
+
+import com.sun.jna.Native;
+import com.sun.jna.Platform;
+import com.sun.jna.Pointer;
+
+import com.sun.jna.platform.WindowUtils;
+import com.sun.jna.platform.DesktopWindow;
+import com.sun.jna.platform.win32.User32;
+import com.sun.jna.platform.win32.WinDef.DWORDByReference;
+import com.sun.jna.platform.win32.WinDef.HICON;
+import com.sun.jna.platform.win32.WinDef.HWND;
+import com.sun.jna.platform.win32.WinUser;
+
+public class WindowUtilsTest extends TestCase {
+
+ public void testGetAllWindows() {
+
+ final List allWindows = WindowUtils.getAllWindows(false);
+ final List allVisibleWindows = WindowUtils
+ .getAllWindows(true);
+
+ assertTrue(allWindows.size() > 0);
+ assertTrue(allVisibleWindows.size() > 0);
+ assertTrue(allWindows.size() > allVisibleWindows.size());
+
+ DesktopWindow explorerProc = null;
+ for (final DesktopWindow dw : allWindows) {
+ if (dw.getFilePath().toLowerCase().endsWith("explorer.exe")) {
+ explorerProc = dw;
+ break;
+ }
+ }
+
+ assertNotNull(explorerProc);
+
+ explorerProc = null;
+ for (final DesktopWindow dw : allVisibleWindows) {
+ if (dw.getFilePath().toLowerCase().endsWith("explorer.exe")) {
+ explorerProc = dw;
+ break;
+ }
+ }
+
+ assertNotNull(explorerProc);
+ }
+
+ public void testGetWindowIcon() throws Exception {
+
+ final JFrame w = new JFrame();
+ try {
+ final BufferedImage expectedIcon = ImageIO
+ .read(new FileInputStream(new File(getClass().getResource(
+ "/res/test_icon.png").getPath())));
+ w.setIconImage(expectedIcon);
+ w.setVisible(true);
+ HWND hwnd = new HWND();
+ hwnd.setPointer(Native.getComponentPointer(w));
+
+ final BufferedImage obtainedIcon = WindowUtils.getWindowIcon(hwnd);
+
+ assertTrue(obtainedIcon.getWidth() > 0);
+ assertTrue(obtainedIcon.getHeight() > 0);
+
+ int[] expectedColors = getPixelColor(expectedIcon, 10, 10);
+ assertPixelColor(obtainedIcon, 10, 10, expectedColors[0],
+ expectedColors[1], expectedColors[2]);
+
+ expectedColors = getPixelColor(expectedIcon,
+ expectedIcon.getWidth() - 10, 10);
+ assertPixelColor(obtainedIcon, obtainedIcon.getWidth() - 10, 10,
+ expectedColors[0], expectedColors[1], expectedColors[2]);
+
+ expectedColors = getPixelColor(expectedIcon,
+ expectedIcon.getWidth() - 10, expectedIcon.getHeight() - 10);
+ assertPixelColor(obtainedIcon, obtainedIcon.getWidth() - 10,
+ obtainedIcon.getHeight() - 10, expectedColors[0],
+ expectedColors[1], expectedColors[2]);
+
+ expectedColors = getPixelColor(expectedIcon, 10,
+ expectedIcon.getHeight() - 10);
+ assertPixelColor(obtainedIcon, 10, obtainedIcon.getHeight() - 10,
+ expectedColors[0], expectedColors[1], expectedColors[2]);
+ } finally {
+ w.dispose();
+ }
+ }
+
+ public void testGetWindowLocationAndSize() {
+
+ final JFrame w = new JFrame();
+ try {
+ w.setLocation(23, 23);
+ w.setPreferredSize(new Dimension(100, 100));
+ w.pack();
+ w.setVisible(true);
+
+ HWND hwnd = new HWND();
+ hwnd.setPointer(Native.getComponentPointer(w));
+ final Rectangle locAndSize = WindowUtils
+ .getWindowLocationAndSize(hwnd);
+
+ assertEquals(w.getLocation().x, locAndSize.x);
+ assertEquals(w.getLocation().y, locAndSize.y);
+ assertEquals(w.getSize().width, locAndSize.width);
+ assertEquals(w.getSize().height, locAndSize.height);
+ } finally {
+ w.dispose();
+ }
+ }
+
+ public void testGetWindowTitle() {
+
+ final JFrame w = new JFrame("A super unique title by PAX! "
+ + System.currentTimeMillis());
+ try {
+ w.setVisible(true);
+
+ HWND hwnd = new HWND();
+ hwnd.setPointer(Native.getComponentPointer(w));
+
+ assertEquals(w.getTitle(), WindowUtils.getWindowTitle(hwnd));
+ } finally {
+ w.dispose();
+ }
+ }
+
+ public void testGetIconSize() throws Exception {
+
+ final JFrame w = new JFrame();
+ try {
+ final BufferedImage expectedIcon = ImageIO
+ .read(new FileInputStream(new File(getClass().getResource("/res/test_icon.png").getPath())));
+ w.setIconImage(expectedIcon);
+ w.setVisible(true);
+ HWND hwnd = new HWND();
+ hwnd.setPointer(Native.getComponentPointer(w));
+
+ final DWORDByReference hIconNumber = new DWORDByReference();
+ long result = User32.INSTANCE.SendMessageTimeout(hwnd,
+ WinUser.WM_GETICON, WinUser.ICON_BIG, 0,
+ WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber);
+
+ assertNotEquals(0, result);
+
+ final HICON hIcon = new HICON(new Pointer(hIconNumber.getValue()
+ .longValue()));
+ assertTrue(WindowUtils.getIconSize(hIcon).width >= 32);
+ assertTrue(WindowUtils.getIconSize(hIcon).height >= 32);
+ assertEquals(WindowUtils.getIconSize(hIcon).width,
+ WindowUtils.getIconSize(hIcon).height);
+ } finally {
+ w.dispose();
+ }
+ }
+
+ public void testGetProcessFilePath() {
+ if (!Platform.isWindows()) {
+ return;
+ }
+
+ final JFrame w = new JFrame();
+ try {
+ w.setVisible(true);
+
+ final String searchSubStr = "\\bin\\java";
+ final HWND hwnd = new HWND(Native.getComponentPointer(w));
+
+ assertTrue("Path didn't contain '" + searchSubStr + "': "
+ + WindowUtils.getProcessFilePath(hwnd),
+ WindowUtils.getProcessFilePath(hwnd).toLowerCase()
+ .contains(searchSubStr));
+ } finally {
+ w.dispose();
+ }
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(WindowUtilsTest.class);
+ }
+}
+
+
diff --git a/src/com/sun/jna/Structure.java b/src/com/sun/jna/Structure.java
index 42af90effb..0192331667 100644
--- a/src/com/sun/jna/Structure.java
+++ b/src/com/sun/jna/Structure.java
@@ -912,9 +912,11 @@ protected List getFields(boolean force) {
if (fieldOrder.size() != flist.size() && flist.size() > 1) {
if (force) {
throw new Error("Structure.getFieldOrder() on " + getClass()
- + " does not provide enough names ("
+ + " does not provide enough names [" + fieldOrder.size()
+ + "] ("
+ sort(fieldOrder)
- + ") to match declared fields ("
+ + ") to match declared fields [" + flist.size()
+ + "] ("
+ sort(names)
+ ")");
}