diff --git a/CHANGES.md b/CHANGES.md index f07408dd63..12f98c4cb0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,6 +30,7 @@ Features * [#563](https://github.com/java-native-access/jna/pull/563): Added `com.sun.jna.platform.win32.Wininet` with the following 4 methods: `FindFirstUrlCacheEntry`, `DeleteUrlCacheEntry`, `FindCloseUrlCache`, `FindNextUrlCacheEntry`, and the `INTERNET_CACHE_ENTRY_INFO` structure, and a helper in `com.sun.jna.platform.win32.WininetUtil` for parsing WinInet's cache - [@mlfreeman2](https://github.com/mlfreeman2). * [#567](https://github.com/java-native-access/jna/pull/567): Added `PrintWindow`, `IsWindowEnabled`, `IsWindow`, `FindWindowEx`, `GetAncestor`, `GetCursorPos`, `SetCursorPos`, `SetWinEventHook`, `UnhookWinEvent`, `CopyIcon`, and `GetClassLong` to `com.sun.jna.platform.win32.User32` and supporting constants to `com.sun.jna.platform.win32.WinUser` - [@mlfreeman2](https://github.com/mlfreeman2). * [#573](https://github.com/java-native-access/jna/pull/573): Added `EnumProcessModules`, `GetModuleInformation`, and `GetProcessImageFileName` to `com.sun.jna.platform.win32.Psapi` and added `ExtractIconEx` to `com.sun.jna.platform.win32.Shell32` - [@mlfreeman2](https://github.com/mlfreeman2). +* [#574](https://github.com/java-native-access/jna/pull/574): Using static final un-modifiable List of field names for structure(s) [@lgoldstein](https://github.com/lgoldstein) Bug Fixes --------- diff --git a/contrib/ntservice/src/jnacontrib/jna/Advapi32.java b/contrib/ntservice/src/jnacontrib/jna/Advapi32.java index d32ea95b2b..d3cacdf562 100644 --- a/contrib/ntservice/src/jnacontrib/jna/Advapi32.java +++ b/contrib/ntservice/src/jnacontrib/jna/Advapi32.java @@ -151,6 +151,9 @@ public int callback(int dwControl, int dwEventType, * SERVICE_STATUS,LPSERVICE_STATUS; */ public static class SERVICE_STATUS extends Structure { + public static final List FIELDS = createFieldsOrder( + "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint"); + public int dwServiceType; public int dwCurrentState; public int dwControlsAccepted; @@ -159,8 +162,9 @@ public static class SERVICE_STATUS extends Structure { public int dwCheckPoint; public int dwWaitHint; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -170,11 +174,13 @@ protected List getFieldOrder() { * LPSERVICE_TABLE_ENTRY; */ public static class SERVICE_TABLE_ENTRY extends Structure { + public static final List FIELDS = createFieldsOrder("lpServiceName", "lpServiceProc"); public String lpServiceName; public SERVICE_MAIN_FUNCTION lpServiceProc; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "lpServiceName", "lpServiceProc" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -186,10 +192,12 @@ public static abstract class ChangeServiceConfig2Info extends Structure { * SERVICE_DESCRIPTION,LPSERVICE_DESCRIPTION; */ public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info { + public static final List FIELDS = createFieldsOrder("lpDescription"); public String lpDescription; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "lpDescription" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/RasterRangesUtils.java b/contrib/platform/src/com/sun/jna/platform/RasterRangesUtils.java index a5f025f048..9eb5cef951 100644 --- a/contrib/platform/src/com/sun/jna/platform/RasterRangesUtils.java +++ b/contrib/platform/src/com/sun/jna/platform/RasterRangesUtils.java @@ -30,7 +30,7 @@ /** * Methods that are useful to decompose a raster into a set of rectangles. - * An occupied pixel has two possible meanings, depending on the raster : + * An occupied pixel has two possible meanings, depending on the raster : *
    *
  • if the raster has an alpha layer, occupied means with alpha not null
  • *
  • if the raster doesn't have any alpha layer, occupied means not completely black
  • @@ -45,6 +45,7 @@ public class RasterRangesUtils { }; private static final Comparator COMPARATOR = new Comparator() { + @Override public int compare(Object o1, Object o2) { return ((Rectangle)o1).x - ((Rectangle)o2).x; } @@ -117,7 +118,7 @@ public static boolean outputOccupiedRanges(Raster raster, RangesOutput out) { */ public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) { Set rects = new HashSet(); - Set prevLine = Collections.EMPTY_SET; + Set prevLine = Collections.emptySet(); int scanlineBytes = binaryBits.length / h; for (int row = 0; row < h; row++) { Set curLine = new TreeSet(COMPARATOR); @@ -190,7 +191,7 @@ public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int */ public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RangesOutput out) { Set rects = new HashSet(); - Set prevLine = Collections.EMPTY_SET; + Set prevLine = Collections.emptySet(); for (int row = 0; row < h; row++) { Set curLine = new TreeSet(COMPARATOR); int idxOffset = row * w; diff --git a/contrib/platform/src/com/sun/jna/platform/mac/Carbon.java b/contrib/platform/src/com/sun/jna/platform/mac/Carbon.java index ff28bca87e..ff0ce6dc0a 100644 --- a/contrib/platform/src/com/sun/jna/platform/mac/Carbon.java +++ b/contrib/platform/src/com/sun/jna/platform/mac/Carbon.java @@ -18,7 +18,6 @@ package com.sun.jna.platform.mac; import java.nio.IntBuffer; -import java.util.Arrays; import java.util.List; import com.sun.jna.Library; @@ -72,22 +71,28 @@ public interface Carbon extends Library { int UnregisterEventHotKey(Pointer inHotKey); public class EventTypeSpec extends Structure { + public static final List FIELDS = createFieldsOrder("eventClass", "eventKind"); + public int eventClass; public int eventKind; + @Override protected List getFieldOrder() { - return Arrays.asList("eventClass", "eventKind"); + return FIELDS; } } public static class EventHotKeyID extends Structure { + public static final List FIELDS = createFieldsOrder("signature", "id"); + public int signature; public int id; public static class ByValue extends EventHotKeyID implements Structure.ByValue { } + @Override protected List getFieldOrder() { - return Arrays.asList("signature", "id"); + return FIELDS; } } diff --git a/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java b/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java index c569713b39..2261560fd2 100644 --- a/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java +++ b/contrib/platform/src/com/sun/jna/platform/mac/MacFileUtils.java @@ -1,10 +1,10 @@ /* Copyright (c) 2007-2013 Timothy Wall, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -15,12 +15,10 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import com.sun.jna.Library; import com.sun.jna.Native; -import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.ptr.ByteByReference; @@ -28,6 +26,7 @@ public class MacFileUtils extends FileUtils { + @Override public boolean hasTrash() { return true; } public interface FileManager extends Library { @@ -44,12 +43,17 @@ public interface FileManager extends Library { int kFSPathMakeRefDoNotFollowLeafSymlink = 0x01; class FSRef extends Structure { + public static final List FIELDS = createFieldsOrder("hidden"); public byte[] hidden = new byte[80]; - protected List getFieldOrder() { return Arrays.asList(new String[] { "hidden" }); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } // Deprecated; use trashItemAtURL instead: - // https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/trashItemAtURL:resultingItemURL:error: + // https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/trashItemAtURL:resultingItemURL:error: int FSRefMakePath(FSRef fsref, byte[] path, int maxPathSize); int FSPathMakeRef(String source, int options, ByteByReference isDirectory); int FSPathMakeRefWithOptions(String source, int options, FSRef fsref, ByteByReference isDirectory); @@ -57,6 +61,7 @@ class FSRef extends Structure { int FSMoveObjectToTrashSync(FSRef source, FSRef target, int options); } + @Override public void moveToTrash(File[] files) throws IOException { File home = new File(System.getProperty("user.home")); File trash = new File(home, ".Trash"); @@ -67,7 +72,7 @@ public void moveToTrash(File[] files) throws IOException { for (int i=0;i < files.length;i++) { File src = files[i]; FileManager.FSRef fsref = new FileManager.FSRef(); - int status = FileManager.INSTANCE.FSPathMakeRefWithOptions(src.getAbsolutePath(), + int status = FileManager.INSTANCE.FSPathMakeRefWithOptions(src.getAbsolutePath(), FileManager.kFSPathMakeRefDoNotFollowLeafSymlink, fsref, null); if (status != 0) { 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 79a756fec3..a1d6b682bb 100644 --- a/contrib/platform/src/com/sun/jna/platform/mac/SystemB.java +++ b/contrib/platform/src/com/sun/jna/platform/mac/SystemB.java @@ -17,7 +17,6 @@ package com.sun.jna.platform.mac; -import java.util.Arrays; import java.util.List; import com.sun.jna.Library; @@ -59,25 +58,33 @@ public interface SystemB extends Library { int INT_SIZE = Native.getNativeSize(int.class); public static class HostCpuLoadInfo extends Structure { + public static final List FIELDS = createFieldsOrder("cpu_ticks"); public int cpu_ticks[] = new int[CPU_STATE_MAX]; @Override protected List getFieldOrder() { - return Arrays.asList("cpu_ticks"); + return FIELDS; } } public static class HostLoadInfo extends Structure { + public static final List FIELDS = createFieldsOrder("avenrun", "mach_factor"); public int[] avenrun = new int[3]; // scaled by LOAD_SCALE public int[] mach_factor = new int[3]; // scaled by LOAD_SCALE @Override protected List getFieldOrder() { - return Arrays.asList("avenrun", "mach_factor"); + return FIELDS; } } public static class VMStatistics extends Structure { + public static final List FIELDS = createFieldsOrder("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 int free_count; // # of pages free public int active_count; // # of pages active public int inactive_count; // # of pages inactive @@ -97,15 +104,25 @@ public static class VMStatistics extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList("free_count", "active_count", - "inactive_count", "wire_count", "zero_fill_count", - "reactivations", "pageins", "pageouts", "faults", - "cow_faults", "lookups", "hits", "purgeable_count", - "purges", "speculative_count"); + return FIELDS; } } public static class VMStatistics64 extends Structure { + public static final List FIELDS = createFieldsOrder("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"); + public int free_count; // # of pages free public int active_count; // # of pages active public int inactive_count; // # of pages inactive @@ -139,19 +156,7 @@ public static class VMStatistics64 extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList("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"); + return FIELDS; } } diff --git a/contrib/platform/src/com/sun/jna/platform/unix/Resource.java b/contrib/platform/src/com/sun/jna/platform/unix/Resource.java index 37673bc4a7..a52bb6a6ec 100644 --- a/contrib/platform/src/com/sun/jna/platform/unix/Resource.java +++ b/contrib/platform/src/com/sun/jna/platform/unix/Resource.java @@ -12,7 +12,6 @@ */ package com.sun.jna.platform.unix; -import java.util.Arrays; import java.util.List; import com.sun.jna.Structure; @@ -83,6 +82,8 @@ public interface Resource { int RLIMIT_NLIMITS = 16; public static class Rlimit extends Structure { + public static final List FIELDS = createFieldsOrder("rlim_cur", "rlim_max"); + /** The current (soft) limit. */ public long rlim_cur; @@ -91,7 +92,7 @@ public static class Rlimit extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "rlim_cur", "rlim_max" }); + return FIELDS; } } diff --git a/contrib/platform/src/com/sun/jna/platform/unix/X11.java b/contrib/platform/src/com/sun/jna/platform/unix/X11.java index b1596a9219..1b2e3cea1b 100644 --- a/contrib/platform/src/com/sun/jna/platform/unix/X11.java +++ b/contrib/platform/src/com/sun/jna/platform/unix/X11.java @@ -297,16 +297,20 @@ void XShapeCombineMask(Display display, Window window, int dest_kind, /** Definition (incomplete) of the Xrender library. */ interface Xrender extends Library { Xrender INSTANCE = Native.loadLibrary("Xrender", Xrender.class); + class XRenderDirectFormat extends Structure { + public static final List FIELDS = createFieldsOrder("red", "redMask", "green", "greenMask", "blue", "blueMask", "alpha", "alphaMask"); public short red, redMask; public short green, greenMask; public short blue, blueMask; public short alpha, alphaMask; + @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "red", "redMask", "green", "greenMask", "blue", "blueMask", "alpha", "alphaMask" }); + protected List getFieldOrder() { + return FIELDS; } } + class PictFormat extends XID { private static final long serialVersionUID = 1L; public static final PictFormat None = null; @@ -320,14 +324,16 @@ public Object fromNative(Object nativeValue, FromNativeContext context) { } } class XRenderPictFormat extends Structure { + public static final List FIELDS = createFieldsOrder("id", "type", "depth", "direct", "colormap"); public PictFormat id; public int type; public int depth; public XRenderDirectFormat direct; public Colormap colormap; + @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "id", "type", "depth", "direct", "colormap" }); + protected List getFieldOrder() { + return FIELDS; } } int PictTypeIndexed = 0x0; @@ -375,21 +381,25 @@ interface XTest extends Library { } class XInputClassInfoByReference extends Structure implements Structure.ByReference { + public static final List FIELDS = createFieldsOrder("input_class", "event_type_base"); public byte input_class; public byte event_type_base; + @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "input_class", "event_type_base" }); + protected List getFieldOrder() { + return FIELDS; } } class XDeviceByReference extends Structure implements Structure.ByReference { + public static final List FIELDS = createFieldsOrder("device_id", "num_classes", "classes"); public XID device_id; public int num_classes; public XInputClassInfoByReference classes; + @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "device_id", "num_classes", "classes" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -410,6 +420,9 @@ protected List getFieldOrder() { } XWMHints; */ class XWMHints extends Structure { + public static final List FIELDS = createFieldsOrder( + "flags", "input", "initial_state", "icon_pixmap", "icon_window", "icon_x", "icon_y", "icon_mask", "window_group"); + public NativeLong flags; public boolean input; public int initial_state; @@ -419,8 +432,8 @@ class XWMHints extends Structure { public Pixmap icon_mask; public XID window_group; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "flags", "input", "initial_state", "icon_pixmap", "icon_window", "icon_x", "icon_y", "icon_mask", "window_group" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -433,13 +446,15 @@ protected List getFieldOrder() { } XTextProperty; */ class XTextProperty extends Structure { + public static final List FIELDS = createFieldsOrder("value", "encoding", "format", "nitems"); public String value; public Atom encoding; public int format; public NativeLong nitems; + @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "value", "encoding", "format", "nitems" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -460,25 +475,41 @@ protected List getFieldOrder() { } XSizeHints; */ class XSizeHints extends Structure { + public static class Aspect extends Structure { + public static final List FIELDS = createFieldsOrder("x", "y"); + public int x; // numerator + public int y; // denominator + @Override + protected List getFieldOrder() { + return FIELDS; + } + } + + public static final List FIELDS = createFieldsOrder( + "flags", + "x", "y", + "width", "height", + "min_width", "min_height", + "max_width", "max_height", + "width_inc", "height_inc", + "min_aspect", "max_aspect", + "base_width", "base_height", + "win_gravity"); + public NativeLong flags; public int x, y; public int width, height; public int min_width, min_height; public int max_width, max_height; public int width_inc, height_inc; - public static class Aspect extends Structure { - public int x; // numerator - public int y; // denominator - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "x", "y" }); } - } + public Aspect min_aspect, max_aspect; public int base_width, base_height; public int win_gravity; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "flags", "x", "y", "width", "height", "min_width", "min_height", "max_width", "max_height", "width_inc", "height_inc", "min_aspect", "max_aspect", "base_width", "base_height", "win_gravity" }); } + protected List getFieldOrder() { + return FIELDS; + } } /* @@ -511,6 +542,18 @@ protected List getFieldOrder() { } XWindowAttributes; */ class XWindowAttributes extends Structure { + public static final List FIELDS = createFieldsOrder( + "x", "y", + "width", "height", + "border_width", + "depth", "visual", "root", "c_class", + "bit_gravity", "win_gravity", + "backing_store", "backing_planes", "backing_pixel", + "save_under", "colormap", + "map_installed", "map_state", + "all_event_masks", "your_event_mask", "do_not_propagate_mask", + "override_redirect", "screen"); + public int x, y; public int width, height; public int border_width; @@ -533,8 +576,8 @@ class XWindowAttributes extends Structure { public boolean override_redirect; public Screen screen; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "x", "y", "width", "height", "border_width", "depth", "visual", "root", "c_class", "bit_gravity", "win_gravity", "backing_store", "backing_planes", "backing_pixel", "save_under", "colormap", "map_installed", "map_state", "all_event_masks", "your_event_mask", "do_not_propagate_mask", "override_redirect", "screen" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -558,6 +601,15 @@ protected List getFieldOrder() { } XSetWindowAttributes; */ class XSetWindowAttributes extends Structure { + public static final List FIELDS = createFieldsOrder( + "background_pixmap", "background_pixel", + "border_pixmap", "border_pixel", + "bit_gravity", "win_gravity", + "backing_store", "backing_planes", "backing_pixel", + "save_under", + "event_mask", "do_not_propagate_mask", + "override_redirect", "colormap", "cursor"); + public Pixmap background_pixmap; public NativeLong background_pixel; public Pixmap border_pixmap; @@ -574,8 +626,8 @@ class XSetWindowAttributes extends Structure { public Colormap colormap; public Cursor cursor; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "background_pixmap", "background_pixel", "border_pixmap", "border_pixel", "bit_gravity", "win_gravity", "backing_store", "backing_planes", "backing_pixel", "save_under", "event_mask", "do_not_propagate_mask", "override_redirect", "colormap", "cursor" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -609,6 +661,9 @@ protected List getFieldOrder() { int VisualAllMask = 0x1FF; class XVisualInfo extends Structure { + public static final List FIELDS = createFieldsOrder( + "visual", "visualid", "screen", "depth", "c_class", "red_mask", "green_mask", "blue_mask", "colormap_size", "bits_per_rgb"); + public Visual visual; public VisualID visualid; public int screen; @@ -620,15 +675,16 @@ class XVisualInfo extends Structure { public int colormap_size; public int bits_per_rgb; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "visual", "visualid", "screen", "depth", "c_class", "red_mask", "green_mask", "blue_mask", "colormap_size", "bits_per_rgb" }); + protected List getFieldOrder() { + return FIELDS; } } class XPoint extends Structure { + public static final List FIELDS = createFieldsOrder("x", "y"); public short x, y; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "x", "y" }); + protected List getFieldOrder() { + return FIELDS; } public XPoint() { this((short)0, (short)0); } public XPoint(short x, short y) { @@ -637,11 +693,13 @@ public XPoint(short x, short y) { } } class XRectangle extends Structure { + public static final List FIELDS = createFieldsOrder("x", "y", "width", "height"); + public short x, y; public short width, height; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "x", "y", "width", "height" }); + protected List getFieldOrder() { + return FIELDS; } public XRectangle() { this((short)0, (short)0, (short)0, (short)0); } public XRectangle(short x, short y, short width, short height) { @@ -808,6 +866,18 @@ Pixmap XCreateBitmapFromData(Display display, Window window, Pointer data, Pixmap XCreatePixmap(Display display, Drawable drawable, int width, int height, int depth); int XFreePixmap(Display display, Pixmap pixmap); class XGCValues extends Structure { + public static final List FIELDS = createFieldsOrder( + "function", "plane_mask", + "foreground", "background", + "line_width", "line_style", + "cap_style", "join_style", + "fill_style", "fill_rule", + "arc_mode", "tile", "stipple", + "ts_x_origin", "ts_y_origin", + "font", "subwindow_mode", "graphics_exposures", + "clip_x_origin", "clip_y_origin", "clip_mask", + "dash_offset", "dashes"); + public int function; /* logical operation */ public NativeLong plane_mask;/* plane mask */ public NativeLong foreground;/* foreground pixel */ @@ -832,8 +902,8 @@ class XGCValues extends Structure { public int dash_offset; /* patterned/dashed line information */ public byte dashes; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "function", "plane_mask", "foreground", "background", "line_width", "line_style", "cap_style", "join_style", "fill_style", "fill_rule", "arc_mode", "tile", "stipple", "ts_x_origin", "ts_y_origin", "font", "subwindow_mode", "graphics_exposures", "clip_x_origin", "clip_y_origin", "clip_mask", "dash_offset", "dashes" }); + protected List getFieldOrder() { + return FIELDS; } } GC XCreateGC(Display display, Drawable drawable, NativeLong mask, XGCValues values); @@ -1455,14 +1525,15 @@ public static class XEvent extends Union { } public static class XAnyEvent extends Structure { + public static final List FIELDS = createFieldsOrder("type", "serial", "send_event", "display", "window"); public int type; public NativeLong serial; // # of last request processed by server public int send_event; // true if this came from a SendEvent request public Display display; // Display the event was read from public Window window; // window on which event was requested in event mask @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window" }); + protected List getFieldOrder() { + return FIELDS; } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java b/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java index 1d54b9747d..86eee774ea 100755 --- a/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java @@ -15,7 +15,6 @@ import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; import com.sun.jna.platform.win32.WinBase.STARTUPINFO; import com.sun.jna.platform.win32.WinBase.FE_EXPORT_FUNC; @@ -1575,11 +1574,6 @@ boolean LookupPrivilegeName(String lpSystemName, WinNT.LUID lpLuid, boolean GetFileSecurity(String lpFileName, int RequestedInformation, Pointer pointer, int nLength, IntByReference lpnLengthNeeded); - /** @deprecated Use the String version */ - @Deprecated - boolean GetFileSecurity(WString lpFileName, - int RequestedInformation, Pointer pointer, int nLength, - IntByReference lpnLengthNeeded); /** * The GetNamedSecurityInfo function retrieves a copy of the security @@ -1793,9 +1787,6 @@ boolean AccessCheck(Pointer pSecurityDescriptor, * information, call GetLastError. */ boolean EncryptFile(String lpFileName); - /** @deprecated Use the String version */ - @Deprecated - boolean EncryptFile(WString lpFileName); /** * Decrypts an encrypted file or directory. @@ -1809,9 +1800,6 @@ boolean AccessCheck(Pointer pSecurityDescriptor, * information, call GetLastError. */ boolean DecryptFile(String lpFileName, DWORD dwReserved); - /** @deprecated Use the String version */ - @Deprecated - boolean DecryptFile(WString lpFileName, DWORD dwReserved); /** * Retrieves the encryption status of the specified file. @@ -1826,9 +1814,6 @@ boolean AccessCheck(Pointer pSecurityDescriptor, * information, call GetLastError. */ boolean FileEncryptionStatus(String lpFileName, DWORDByReference lpStatus); - /** @deprecated Use the String version */ - @Deprecated - boolean FileEncryptionStatus(WString lpFileName, DWORDByReference lpStatus); /** * Disables or enables encryption of the specified directory and the files in @@ -1846,9 +1831,6 @@ boolean AccessCheck(Pointer pSecurityDescriptor, * information, call GetLastError. */ boolean EncryptionDisable(String DirPath, boolean Disable); - /** @deprecated Use the String version */ - @Deprecated - boolean EncryptionDisable(WString DirPath, boolean Disable); /** * Opens an encrypted file in order to backup (export) or restore (import) the @@ -1871,9 +1853,6 @@ boolean AccessCheck(Pointer pSecurityDescriptor, * text description of the error. */ int OpenEncryptedFileRaw(String lpFileName, ULONG ulFlags, PointerByReference pvContext); - /** @deprecated Use the String version */ - @Deprecated - int OpenEncryptedFileRaw(WString lpFileName, ULONG ulFlags, PointerByReference pvContext); /** * Backs up (export) encrypted files. This is one of a group of Encrypted File diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java b/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java index 871801746e..b7b1a0104e 100755 --- a/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java @@ -12,6 +12,30 @@ */ package com.sun.jna.platform.win32; +import static com.sun.jna.platform.win32.WinBase.CREATE_FOR_DIR; +import static com.sun.jna.platform.win32.WinBase.CREATE_FOR_IMPORT; +import static com.sun.jna.platform.win32.WinNT.DACL_SECURITY_INFORMATION; +import static com.sun.jna.platform.win32.WinNT.FILE_ALL_ACCESS; +import static com.sun.jna.platform.win32.WinNT.FILE_GENERIC_EXECUTE; +import static com.sun.jna.platform.win32.WinNT.FILE_GENERIC_READ; +import static com.sun.jna.platform.win32.WinNT.FILE_GENERIC_WRITE; +import static com.sun.jna.platform.win32.WinNT.GENERIC_EXECUTE; +import static com.sun.jna.platform.win32.WinNT.GENERIC_READ; +import static com.sun.jna.platform.win32.WinNT.GENERIC_WRITE; +import static com.sun.jna.platform.win32.WinNT.GROUP_SECURITY_INFORMATION; +import static com.sun.jna.platform.win32.WinNT.OWNER_SECURITY_INFORMATION; +import static com.sun.jna.platform.win32.WinNT.PROTECTED_DACL_SECURITY_INFORMATION; +import static com.sun.jna.platform.win32.WinNT.PROTECTED_SACL_SECURITY_INFORMATION; +import static com.sun.jna.platform.win32.WinNT.SACL_SECURITY_INFORMATION; +import static com.sun.jna.platform.win32.WinNT.SE_DACL_PROTECTED; +import static com.sun.jna.platform.win32.WinNT.SE_SACL_PROTECTED; +import static com.sun.jna.platform.win32.WinNT.STANDARD_RIGHTS_READ; +import static com.sun.jna.platform.win32.WinNT.TOKEN_DUPLICATE; +import static com.sun.jna.platform.win32.WinNT.TOKEN_IMPERSONATE; +import static com.sun.jna.platform.win32.WinNT.TOKEN_QUERY; +import static com.sun.jna.platform.win32.WinNT.UNPROTECTED_DACL_SECURITY_INFORMATION; +import static com.sun.jna.platform.win32.WinNT.UNPROTECTED_SACL_SECURITY_INFORMATION; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -25,30 +49,33 @@ import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; -import com.sun.jna.WString; +import com.sun.jna.platform.win32.WinBase.FE_EXPORT_FUNC; +import com.sun.jna.platform.win32.WinBase.FE_IMPORT_FUNC; import com.sun.jna.platform.win32.WinBase.FILETIME; +import com.sun.jna.platform.win32.WinDef.BOOLByReference; +import com.sun.jna.platform.win32.WinDef.DWORD; +import com.sun.jna.platform.win32.WinDef.DWORDByReference; +import com.sun.jna.platform.win32.WinDef.ULONG; +import com.sun.jna.platform.win32.WinDef.ULONGByReference; import com.sun.jna.platform.win32.WinNT.ACCESS_ACEStructure; import com.sun.jna.platform.win32.WinNT.ACL; import com.sun.jna.platform.win32.WinNT.EVENTLOGRECORD; +import com.sun.jna.platform.win32.WinNT.GENERIC_MAPPING; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; +import com.sun.jna.platform.win32.WinNT.PRIVILEGE_SET; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.platform.win32.WinNT.PSIDByReference; import com.sun.jna.platform.win32.WinNT.SECURITY_DESCRIPTOR_RELATIVE; +import com.sun.jna.platform.win32.WinNT.SECURITY_IMPERSONATION_LEVEL; import com.sun.jna.platform.win32.WinNT.SID_AND_ATTRIBUTES; import com.sun.jna.platform.win32.WinNT.SID_NAME_USE; import com.sun.jna.platform.win32.WinReg.HKEY; import com.sun.jna.platform.win32.WinReg.HKEYByReference; -import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.LongByReference; import com.sun.jna.ptr.PointerByReference; -import static com.sun.jna.platform.win32.WinDef.BOOLByReference; -import static com.sun.jna.platform.win32.WinDef.DWORD; -import static com.sun.jna.platform.win32.WinDef.DWORDByReference; -import static com.sun.jna.platform.win32.WinNT.*; - /** * Advapi32 utility API. @@ -595,9 +622,9 @@ public static String registryGetStringValue(HKEY hKey, String value) { && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { throw new Win32Exception(rc); } - return Native.toString(data); + return Native.toString(data); } - + /** * Get a registry REG_EXPAND_SZ value. * @@ -658,7 +685,7 @@ public static String registryGetExpandableStringValue(HKEY hKey, String value) { } return Native.toString(data); } - + /** * Get a registry REG_MULTI_SZ value. * @@ -731,7 +758,7 @@ public static String[] registryGetStringArray(HKEY hKey, String value) { } return result.toArray(new String[0]); } - + /** * Get a registry REG_BINARY value. * @@ -792,7 +819,7 @@ public static byte[] registryGetBinaryValue(HKEY hKey, String value) { } return data; } - + /** * Get a registry DWORD value. * @@ -852,7 +879,7 @@ public static int registryGetIntValue(HKEY hKey, String value) { } return data.getValue(); } - + /** * Get a registry QWORD value. * @@ -880,7 +907,7 @@ public static long registryGetLongValue(HKEY root, String key, String value) { } } } - + /** * Get a registry QWORD value. * @@ -1509,7 +1536,7 @@ public static HKEYByReference registryGetKey(HKEY root, String keyPath, return phkKey; } - + /** * Close the registry key * @@ -1994,20 +2021,23 @@ public void close() { // @Override - @todo restore Override annotation after we move to source // level 1.6 - public Iterator iterator() { + @Override + public Iterator iterator() { return this; } // @Override - @todo restore Override annotation after we move to source // level 1.6 - public boolean hasNext() { + @Override + public boolean hasNext() { read(); return !_done; } // @Override - @todo restore Override annotation after we move to source // level 1.6 - public EventLogRecord next() { + @Override + public EventLogRecord next() { read(); EventLogRecord record = new EventLogRecord(_pevlr); _dwRead -= record.getLength(); @@ -2017,7 +2047,8 @@ public EventLogRecord next() { // @Override - @todo restore Override annotation after we move to source // level 1.6 - public void remove() { + @Override + public void remove() { } } @@ -2139,13 +2170,13 @@ private static Memory getSecurityDescriptorForFile(final String absoluteFilePath * @return Memory containing the self relative security descriptor */ public static Memory getSecurityDescriptorForObject(final String absoluteObjectPath, int objectType, boolean getSACL) { - - int infoType = OWNER_SECURITY_INFORMATION + + int infoType = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION - | (getSACL ? SACL_SECURITY_INFORMATION : 0); + | (getSACL ? SACL_SECURITY_INFORMATION : 0); - PointerByReference ppSecurityDescriptor = new PointerByReference(); + PointerByReference ppSecurityDescriptor = new PointerByReference(); int lastError = Advapi32.INSTANCE.GetNamedSecurityInfo( absoluteObjectPath, @@ -2160,14 +2191,14 @@ public static Memory getSecurityDescriptorForObject(final String absoluteObjectP if (lastError != 0) { throw new Win32Exception(lastError); } - - int nLength = Advapi32.INSTANCE.GetSecurityDescriptorLength(ppSecurityDescriptor.getValue()); + + int nLength = Advapi32.INSTANCE.GetSecurityDescriptorLength(ppSecurityDescriptor.getValue()); final Memory memory = new Memory(nLength); memory.write(0, ppSecurityDescriptor.getValue().getByteArray(0, nLength), 0, nLength); Kernel32.INSTANCE.LocalFree(ppSecurityDescriptor.getValue()); return memory; } - + /** * Set a self relative security descriptor for the given object type. * @@ -2202,53 +2233,53 @@ public static void setSecurityDescriptorForObject(final String absoluteObjectPat int objectType, SECURITY_DESCRIPTOR_RELATIVE securityDescriptor, boolean setOwner, - boolean setGroup, + boolean setGroup, boolean setDACL, boolean setSACL, boolean setDACLProtectedStatus, boolean setSACLProtectedStatus) { - + final PSID psidOwner = securityDescriptor.getOwner(); final PSID psidGroup = securityDescriptor.getGroup(); final ACL dacl = securityDescriptor.getDiscretionaryACL(); final ACL sacl = securityDescriptor.getSystemACL(); - int infoType = 0; + int infoType = 0; // Parameter validation and infoType flag setting. if (setOwner) { - if (psidOwner == null) + if (psidOwner == null) throw new IllegalArgumentException("SECURITY_DESCRIPTOR_RELATIVE does not contain owner"); if (!Advapi32.INSTANCE.IsValidSid(psidOwner)) - throw new IllegalArgumentException("Owner PSID is invalid"); + throw new IllegalArgumentException("Owner PSID is invalid"); infoType |= OWNER_SECURITY_INFORMATION; } if (setGroup) { - if (psidGroup == null) + if (psidGroup == null) throw new IllegalArgumentException("SECURITY_DESCRIPTOR_RELATIVE does not contain group"); if (!Advapi32.INSTANCE.IsValidSid(psidGroup)) - throw new IllegalArgumentException("Group PSID is invalid"); + throw new IllegalArgumentException("Group PSID is invalid"); infoType |= GROUP_SECURITY_INFORMATION; } - if (setDACL) { - if (dacl == null) + if (setDACL) { + if (dacl == null) throw new IllegalArgumentException("SECURITY_DESCRIPTOR_RELATIVE does not contain DACL"); if (!Advapi32.INSTANCE.IsValidAcl(dacl.getPointer())) - throw new IllegalArgumentException("DACL is invalid"); + throw new IllegalArgumentException("DACL is invalid"); infoType |= DACL_SECURITY_INFORMATION; } if (setSACL) { - if (sacl == null) + if (sacl == null) throw new IllegalArgumentException("SECURITY_DESCRIPTOR_RELATIVE does not contain SACL"); if (!Advapi32.INSTANCE.IsValidAcl(sacl.getPointer())) - throw new IllegalArgumentException("SACL is invalid"); + throw new IllegalArgumentException("SACL is invalid"); infoType |= SACL_SECURITY_INFORMATION; } - /* - * Control bits SE_DACL_PROTECTED/SE_SACL_PROTECTED indicate the *ACL is protected. The *ACL_SECURITY_INFORMATION flags + /* + * Control bits SE_DACL_PROTECTED/SE_SACL_PROTECTED indicate the *ACL is protected. The *ACL_SECURITY_INFORMATION flags * are meta flags for SetNamedSecurityInfo and are not stored in the SD. If either *ACLProtectedStatus is set, * get the current status from the securityDescriptor and apply as such, otherwise the ACL remains at its default. */ @@ -2350,9 +2381,9 @@ public static boolean accessCheck(File file, AccessCheckPermission permissionToC return hasAccess; } - + /** - * Gets a file's Security Descriptor. Convenience wrapper getSecurityDescriptorForObject. + * Gets a file's Security Descriptor. Convenience wrapper getSecurityDescriptorForObject. * * @param file * File object containing a path to a file system object. @@ -2367,9 +2398,9 @@ public static SECURITY_DESCRIPTOR_RELATIVE getFileSecurityDescriptor(File file, sdr = new SECURITY_DESCRIPTOR_RELATIVE(securityDesc); return sdr; } - + /** - * Sets a file's Security Descriptor. Convenience wrapper setSecurityDescriptorForObject. + * Sets a file's Security Descriptor. Convenience wrapper setSecurityDescriptorForObject. * @param file * File object containing a path to a file system object. * @param securityDescriptor @@ -2377,7 +2408,7 @@ public static SECURITY_DESCRIPTOR_RELATIVE getFileSecurityDescriptor(File file, * @param setOwner * Set the owner. See {@link Advapi32#SetNamedSecurityInfo} for process privilege requirements in setting the owner. * @param setGroup - * Set the group. + * Set the group. * @param setDACL * Set the DACL. * @param setSACL @@ -2385,13 +2416,13 @@ public static SECURITY_DESCRIPTOR_RELATIVE getFileSecurityDescriptor(File file, * @param setDACLProtectedStatus * Set DACL protected status as contained within securityDescriptor.control. * @param setSACLProtectedStatus - * Set SACL protected status as contained within securityDescriptor.control. * + * Set SACL protected status as contained within securityDescriptor.control. * */ public static void setFileSecurityDescriptor( File file, SECURITY_DESCRIPTOR_RELATIVE securityDescriptor, boolean setOwner, - boolean setGroup, + boolean setGroup, boolean setDACL, boolean setSACL, boolean setDACLProtectedStatus, @@ -2399,7 +2430,7 @@ public static void setFileSecurityDescriptor( { setSecurityDescriptorForObject(file.getAbsolutePath().replaceAll("/", "\\"), AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT, securityDescriptor, setOwner, setGroup, setDACL, setSACL, setDACLProtectedStatus, setSACLProtectedStatus); } - + /** * Encrypts a file or directory. * @@ -2432,7 +2463,7 @@ public static void decryptFile(File file) { * @param file * The file to check the status for. * @return The status of the file. - */ + */ public static int fileEncryptionStatus(File file) { DWORDByReference status = new DWORDByReference(); String lpFileName = file.getAbsolutePath(); @@ -2482,7 +2513,7 @@ public static void backupEncryptedFile(File src, File destDir) { if (src.isDirectory()) { writeFlag.setValue(CREATE_FOR_IMPORT | CREATE_FOR_DIR); } - + // open encrypted file for export String srcFileName = src.getAbsolutePath(); PointerByReference pvContext = new PointerByReference(); @@ -2507,7 +2538,7 @@ public DWORD callback(Pointer pbData, Pointer pvCallbackContext, } }; - if (Advapi32.INSTANCE.ReadEncryptedFileRaw(pfExportCallback, null, + if (Advapi32.INSTANCE.ReadEncryptedFileRaw(pfExportCallback, null, pvContext.getValue()) != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } @@ -2533,12 +2564,12 @@ public DWORD callback(Pointer pbData, Pointer pvCallbackContext, final IntByReference elementsReadWrapper = new IntByReference(0); FE_IMPORT_FUNC pfImportCallback = new FE_IMPORT_FUNC() { @Override - public DWORD callback(Pointer pbData, Pointer pvCallbackContext, + public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONGByReference ulLength) { int elementsRead = elementsReadWrapper.getValue(); int remainingElements = outputStream.size() - elementsRead; int length = Math.min(remainingElements, ulLength.getValue().intValue()); - pbData.write(0, outputStream.toByteArray(), elementsRead, + pbData.write(0, outputStream.toByteArray(), elementsRead, length); elementsReadWrapper.setValue(elementsRead + length); ulLength.setValue(new ULONG(length)); @@ -2546,7 +2577,7 @@ public DWORD callback(Pointer pbData, Pointer pvCallbackContext, } }; - if (Advapi32.INSTANCE.WriteEncryptedFileRaw(pfImportCallback, null, + if (Advapi32.INSTANCE.WriteEncryptedFileRaw(pfImportCallback, null, pvContext.getValue()) != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMEarlyBindingObject.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMEarlyBindingObject.java index 8d55229d9f..8ca80f89e5 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMEarlyBindingObject.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMEarlyBindingObject.java @@ -14,7 +14,6 @@ import com.sun.jna.WString; import com.sun.jna.platform.win32.Guid.CLSID; -import com.sun.jna.platform.win32.Guid.IID; import com.sun.jna.platform.win32.Guid.REFIID; import com.sun.jna.platform.win32.OaIdl.DISPID; import com.sun.jna.platform.win32.OaIdl.DISPIDByReference; @@ -22,7 +21,6 @@ import com.sun.jna.platform.win32.OleAuto; import com.sun.jna.platform.win32.OleAuto.DISPPARAMS; import com.sun.jna.platform.win32.Variant.VARIANT; -import com.sun.jna.platform.win32.Variant.VARIANT.ByReference; import com.sun.jna.platform.win32.WinDef.LCID; import com.sun.jna.platform.win32.WinDef.UINT; import com.sun.jna.platform.win32.WinDef.UINTByReference; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMException.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMException.java index 8431a63733..fbec1d7b5c 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMException.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMException.java @@ -1,14 +1,14 @@ /* Copyright (c) 2012 Tobias Wolf, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32.COM; @@ -18,19 +18,20 @@ // TODO: Auto-generated Javadoc /** * Exception class for all COM related classes. - * + * * @author Tobias Wolf, wolf.tobias@gmx.net */ public class COMException extends RuntimeException { + private static final long serialVersionUID = 1L; /** The p excep info. */ private EXCEPINFO pExcepInfo; /** The pu arg err. */ private IntByReference puArgErr; - + private int uArgErr; - + /** * Instantiates a new automation exception. */ @@ -40,7 +41,7 @@ public COMException() { /** * Instantiates a new automation exception. - * + * * @param message * the message * @param cause @@ -52,7 +53,7 @@ public COMException(String message, Throwable cause) { /** * Instantiates a new automation exception. - * + * * @param message * the message */ @@ -62,7 +63,7 @@ public COMException(String message) { /** * Instantiates a new automation exception. - * + * * @param message * the message * @param pExcepInfo @@ -79,7 +80,7 @@ public COMException(String message, EXCEPINFO pExcepInfo, /** * Instantiates a new automation exception. - * + * * @param cause * the cause */ @@ -89,7 +90,7 @@ public COMException(Throwable cause) { /** * Gets the excep info. - * + * * @return the excep info */ public EXCEPINFO getExcepInfo() { @@ -98,7 +99,7 @@ public EXCEPINFO getExcepInfo() { /** * Gets the arg err. - * + * * @return the arg err */ public IntByReference getArgErr() { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMInvoker.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMInvoker.java index 91ed340233..3295e82394 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMInvoker.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMInvoker.java @@ -27,8 +27,7 @@ protected int _invokeNativeInt(int vtableId, Object[] args) { return func.invokeInt(args); } - protected Object _invokeNativeObject(int vtableId, Object[] args, - Class returnType) { + protected Object _invokeNativeObject(int vtableId, Object[] args, Class returnType) { Pointer vptr = this.getPointer().getPointer(0); // we take the vtable id and multiply with the pointer size (4 bytes on // 32bit OS) @@ -36,7 +35,7 @@ protected Object _invokeNativeObject(int vtableId, Object[] args, * Pointer.SIZE)); return func.invoke(returnType, args); } - + protected void _invokeNativeVoid(int vtableId, Object[] args) { Pointer vptr = this.getPointer().getPointer(0); // we take the vtable id and multiply with the pointer size (4 bytes on @@ -45,5 +44,5 @@ protected void _invokeNativeVoid(int vtableId, Object[] args) { * Pointer.SIZE)); func.invokeVoid(args); } - + } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMUtils.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMUtils.java index d2e15e44a0..6cb36bd5e0 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/COMUtils.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/COMUtils.java @@ -21,7 +21,6 @@ import com.sun.jna.platform.win32.Advapi32Util.InfoKey; import com.sun.jna.platform.win32.Kernel32Util; import com.sun.jna.platform.win32.OaIdl.EXCEPINFO; -import com.sun.jna.platform.win32.WTypes.BSTR; import com.sun.jna.platform.win32.WinNT; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.platform.win32.WinReg; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/Dispatch.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/Dispatch.java index d8448f24e6..5e47f172a1 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/Dispatch.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/Dispatch.java @@ -15,7 +15,6 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; -import com.sun.jna.platform.win32.Guid.IID; import com.sun.jna.platform.win32.Guid.REFIID; import com.sun.jna.platform.win32.OaIdl.DISPID; import com.sun.jna.platform.win32.OaIdl.DISPIDByReference; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchListener.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchListener.java index c3f0e79e85..498b00c268 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchListener.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchListener.java @@ -12,11 +12,8 @@ */ package com.sun.jna.platform.win32.COM; -import java.util.Arrays; import java.util.List; -import com.sun.jna.CallbackThreadInitializer; -import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; @@ -35,22 +32,23 @@ import com.sun.jna.ptr.PointerByReference; public class DispatchListener extends Structure { + public static final List FIELDS = createFieldsOrder("vtbl"); public DispatchListener(IDispatchCallback callback) { this.vtbl = this.constructVTable(); this.initVTable(callback); super.write(); } public DispatchVTable.ByReference vtbl; - + @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "vtbl" }); + return FIELDS; } - + protected DispatchVTable.ByReference constructVTable() { return new DispatchVTable.ByReference(); } - + protected void initVTable(final IDispatchCallback callback) { this.vtbl.QueryInterfaceCallback = new DispatchVTable.QueryInterfaceCallback() { @Override diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchVTable.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchVTable.java index ad8a61c823..3d6785b40c 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchVTable.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/DispatchVTable.java @@ -12,16 +12,11 @@ */ package com.sun.jna.platform.win32.COM; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.WString; -import com.sun.jna.platform.win32.COM.UnknownVTable.AddRefCallback; -import com.sun.jna.platform.win32.COM.UnknownVTable.QueryInterfaceCallback; -import com.sun.jna.platform.win32.COM.UnknownVTable.ReleaseCallback; import com.sun.jna.platform.win32.Guid.REFIID; import com.sun.jna.platform.win32.OaIdl.DISPID; import com.sun.jna.platform.win32.OaIdl.DISPIDByReference; @@ -35,13 +30,17 @@ import com.sun.jna.platform.win32.WinNT; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; -import com.sun.jna.win32.DLLCallback; import com.sun.jna.win32.StdCallLibrary; public class DispatchVTable extends Structure { public static class ByReference extends DispatchVTable implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder( + "QueryInterfaceCallback", "AddRefCallback", "ReleaseCallback", + "GetTypeInfoCountCallback", "GetTypeInfoCallback", + "GetIDsOfNamesCallback", "InvokeCallback"); + public QueryInterfaceCallback QueryInterfaceCallback; public AddRefCallback AddRefCallback; public ReleaseCallback ReleaseCallback; @@ -52,8 +51,7 @@ public static class ByReference extends DispatchVTable implements Structure.ByRe @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "QueryInterfaceCallback", "AddRefCallback", "ReleaseCallback","GetTypeInfoCountCallback", "GetTypeInfoCallback", - "GetIDsOfNamesCallback", "InvokeCallback" }); + return FIELDS; } public static interface QueryInterfaceCallback extends StdCallLibrary.StdCallCallback { @@ -67,7 +65,7 @@ public static interface AddRefCallback extends StdCallLibrary.StdCallCallback { public static interface ReleaseCallback extends StdCallLibrary.StdCallCallback { int invoke(Pointer thisPointer); } - + public static interface GetTypeInfoCountCallback extends StdCallLibrary.StdCallCallback { WinNT.HRESULT invoke(Pointer thisPointer, UINTByReference pctinfo); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IEnumIDList.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IEnumIDList.java index 7887816a35..9658155947 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/IEnumIDList.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IEnumIDList.java @@ -6,10 +6,8 @@ import com.sun.jna.Function; import com.sun.jna.Pointer; -import com.sun.jna.platform.win32.Guid; import com.sun.jna.platform.win32.Guid.IID; import com.sun.jna.platform.win32.Guid.REFIID; -import com.sun.jna.platform.win32.WinDef; import com.sun.jna.platform.win32.WinNT; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.ptr.IntByReference; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IMoniker.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IMoniker.java index 41cfde79c3..d6beb1e537 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/IMoniker.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IMoniker.java @@ -14,7 +14,6 @@ import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WTypes.BSTRByReference; -import com.sun.jna.platform.win32.WTypes.LPSTR; import com.sun.jna.platform.win32.WinNT.HRESULT; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/IShellFolder.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/IShellFolder.java index 4464eaa9de..5c8517f6e2 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/IShellFolder.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/IShellFolder.java @@ -6,7 +6,6 @@ import com.sun.jna.Function; import com.sun.jna.Pointer; -import com.sun.jna.platform.win32.Guid; import com.sun.jna.platform.win32.Guid.IID; import com.sun.jna.platform.win32.Guid.REFIID; import com.sun.jna.platform.win32.WinDef; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/ITypeInfo.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/ITypeInfo.java index 7026cf4f3c..7a7d341cb3 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/ITypeInfo.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/ITypeInfo.java @@ -17,7 +17,6 @@ import com.sun.jna.platform.win32.OaIdl.FUNCDESC; import com.sun.jna.platform.win32.OaIdl.HREFTYPE; import com.sun.jna.platform.win32.OaIdl.HREFTYPEByReference; -import com.sun.jna.platform.win32.OaIdl.HREFTYPEByReference; import com.sun.jna.platform.win32.OaIdl.INVOKEKIND; import com.sun.jna.platform.win32.OaIdl.MEMBERID; import com.sun.jna.platform.win32.OaIdl.TYPEATTR; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/Moniker.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/Moniker.java index db695646d5..b332719d71 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/Moniker.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/Moniker.java @@ -14,9 +14,7 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; import com.sun.jna.platform.win32.WTypes.BSTRByReference; -import com.sun.jna.platform.win32.WTypes.LPSTR; import com.sun.jna.platform.win32.WinNT; import com.sun.jna.platform.win32.Guid.CLSID; import com.sun.jna.platform.win32.WinNT.HRESULT; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/Unknown.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/Unknown.java index 1f3f18ef3f..7cc8d4a316 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/Unknown.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/Unknown.java @@ -14,7 +14,6 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.platform.win32.Guid.IID; import com.sun.jna.platform.win32.Guid.REFIID; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.ptr.PointerByReference; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownListener.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownListener.java index be1af2f36b..75d7cc1004 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownListener.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownListener.java @@ -12,18 +12,17 @@ */ package com.sun.jna.platform.win32.COM; -import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.platform.win32.Guid; import com.sun.jna.platform.win32.Guid.REFIID; -import com.sun.jna.platform.win32.WinError; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.ptr.PointerByReference; public class UnknownListener extends Structure { + public static final List FIELDS = createFieldsOrder("vtbl"); + public UnknownVTable.ByReference vtbl; public UnknownListener(IUnknownCallback callback) { this.vtbl = this.constructVTable(); @@ -31,17 +30,15 @@ public UnknownListener(IUnknownCallback callback) { super.write(); } - public UnknownVTable.ByReference vtbl; - @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "vtbl" }); + return FIELDS; } - + protected UnknownVTable.ByReference constructVTable() { return new UnknownVTable.ByReference(); } - + protected void initVTable(final IUnknownCallback callback) { this.vtbl.QueryInterfaceCallback = new UnknownVTable.QueryInterfaceCallback() { @Override diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownVTable.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownVTable.java index e1052abad3..f5faa32a74 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownVTable.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/UnknownVTable.java @@ -12,7 +12,6 @@ */ package com.sun.jna.platform.win32.COM; -import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; @@ -26,13 +25,14 @@ public class UnknownVTable extends Structure { public static class ByReference extends UnknownVTable implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("QueryInterfaceCallback", "AddRefCallback", "ReleaseCallback"); public QueryInterfaceCallback QueryInterfaceCallback; public AddRefCallback AddRefCallback; public ReleaseCallback ReleaseCallback; @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "QueryInterfaceCallback", "AddRefCallback", "ReleaseCallback" }); + return FIELDS; } public static interface QueryInterfaceCallback extends StdCallLibrary.StdCallCallback { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/TlbImp.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/TlbImp.java index b983f0dcff..b2cdc2a8a1 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/TlbImp.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/TlbImp.java @@ -98,9 +98,9 @@ public void startCOM2Java() { if (typekind.value == TYPEKIND.TKIND_ENUM) { this.createCOMEnum(i, this.getPackageName(), typeLibUtil); } else if (typekind.value == TYPEKIND.TKIND_RECORD) { - this.logInfo("'TKIND_RECORD' objects are currently not supported!"); + TlbImp.logInfo("'TKIND_RECORD' objects are currently not supported!"); } else if (typekind.value == TYPEKIND.TKIND_MODULE) { - this.logInfo("'TKIND_MODULE' objects are currently not supported!"); + TlbImp.logInfo("'TKIND_MODULE' objects are currently not supported!"); } else if (typekind.value == TYPEKIND.TKIND_INTERFACE) { this.createCOMInterface(i, this.getPackageName(), typeLibUtil); @@ -111,9 +111,9 @@ public void startCOM2Java() { this.createCOMCoClass(i, this.getPackageName(), typeLibUtil, bindingMode); } else if (typekind.value == TYPEKIND.TKIND_ALIAS) { - this.logInfo("'TKIND_ALIAS' objects are currently not supported!"); + TlbImp.logInfo("'TKIND_ALIAS' objects are currently not supported!"); } else if (typekind.value == TYPEKIND.TKIND_UNION) { - this.logInfo("'TKIND_UNION' objects are currently not supported!"); + TlbImp.logInfo("'TKIND_UNION' objects are currently not supported!"); } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCmdlineArgs.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCmdlineArgs.java index ca2da32d47..d90b85adb1 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCmdlineArgs.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCmdlineArgs.java @@ -14,8 +14,8 @@ import java.util.Hashtable; -public class TlbCmdlineArgs extends Hashtable implements - TlbConst { +public class TlbCmdlineArgs extends Hashtable implements TlbConst { + private static final long serialVersionUID = 1L; public TlbCmdlineArgs(String[] args) { this.readCmdArgs(args); @@ -70,7 +70,7 @@ public String getBindingMode() { else return BINDING_MODE_VTABLE; } - + public void showCmdHelp() { String helpStr = "usage: TlbImp [-tlb.id -tlb.major.version -tlb.minor.version] [-tlb.file] [-bind.mode vTable, dispId] [-output.dir]" + CRCR diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.java index 3c1a512ac4..14de7ed353 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbDispInterface.java @@ -13,12 +13,9 @@ package com.sun.jna.platform.win32.COM.tlb.imp; import com.sun.jna.platform.win32.OaIdl.FUNCDESC; -import com.sun.jna.platform.win32.OaIdl.HREFTYPE; import com.sun.jna.platform.win32.OaIdl.INVOKEKIND; import com.sun.jna.platform.win32.OaIdl.MEMBERID; import com.sun.jna.platform.win32.OaIdl.TYPEATTR; -import com.sun.jna.platform.win32.WinDef.WORD; -import com.sun.jna.platform.win32.COM.ITypeInfo; import com.sun.jna.platform.win32.COM.TypeInfoUtil; import com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc; import com.sun.jna.platform.win32.COM.TypeLibUtil; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbParameterNotFoundException.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbParameterNotFoundException.java index 620e1e50fd..bc0174dd64 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbParameterNotFoundException.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbParameterNotFoundException.java @@ -13,8 +13,10 @@ package com.sun.jna.platform.win32.COM.tlb.imp; public class TlbParameterNotFoundException extends RuntimeException { + private static final long serialVersionUID = 1L; public TlbParameterNotFoundException() { + super(); } public TlbParameterNotFoundException(String msg) { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java index 3e4ac9b656..ca73bcd783 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/CallbackProxy.java @@ -13,15 +13,11 @@ package com.sun.jna.platform.win32.COM.util; import java.lang.Thread.UncaughtExceptionHandler; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; @@ -29,7 +25,6 @@ import com.sun.jna.Pointer; import com.sun.jna.WString; import com.sun.jna.platform.win32.Guid; -import com.sun.jna.platform.win32.WinDef; import com.sun.jna.platform.win32.Guid.IID; import com.sun.jna.platform.win32.Guid.REFIID; import com.sun.jna.platform.win32.OaIdl.DISPID; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/IConnectionPointContainer.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/IConnectionPointContainer.java index 7a95144bba..a2e9bb089f 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/IConnectionPointContainer.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/IConnectionPointContainer.java @@ -13,7 +13,6 @@ package com.sun.jna.platform.win32.COM.util; import com.sun.jna.platform.win32.COM.util.annotation.ComInterface; -import com.sun.jna.platform.win32.COM.util.annotation.ComMethod; @ComInterface(iid="{B196B284-BAB4-101A-B69C-00AA00341D07}") public interface IConnectionPointContainer extends IRawDispatchHandle { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java index 307c0ffd77..013f9cd3eb 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java @@ -14,7 +14,6 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; -import java.util.Date; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -35,7 +34,6 @@ import com.sun.jna.platform.win32.Variant; import com.sun.jna.platform.win32.Variant.VARIANT; import com.sun.jna.platform.win32.Variant.VariantArg; -import com.sun.jna.platform.win32.WTypes; import com.sun.jna.platform.win32.WinDef; import com.sun.jna.platform.win32.WinDef.DWORDByReference; import com.sun.jna.platform.win32.WinDef.LCID; @@ -49,7 +47,6 @@ import com.sun.jna.platform.win32.COM.Dispatch; import com.sun.jna.platform.win32.COM.IDispatch; import com.sun.jna.platform.win32.COM.IDispatchCallback; -import com.sun.jna.platform.win32.COM.Unknown; import com.sun.jna.platform.win32.COM.util.annotation.ComInterface; import com.sun.jna.platform.win32.COM.util.annotation.ComMethod; import com.sun.jna.platform.win32.COM.util.annotation.ComProperty; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java b/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java index 9dd2b2ced4..4dc22e8be1 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java @@ -1,14 +1,14 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; @@ -16,7 +16,6 @@ import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT; import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB; -import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIOptions; @@ -26,86 +25,86 @@ * @author dblock[at]dblock.org */ public interface Crypt32 extends StdCallLibrary { - + Crypt32 INSTANCE = Native.loadLibrary("Crypt32", Crypt32.class, W32APIOptions.DEFAULT_OPTIONS); - + /** * The CryptProtectData function performs encryption on the data in a DATA_BLOB - * structure. Typically, only a user with the same logon credential as the encrypter + * structure. Typically, only a user with the same logon credential as the encrypter * can decrypt the data. In addition, the encryption and decryption usually must be * done on the same computer. * @param pDataIn - * Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted. + * Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted. * @param szDataDescr - * String with a readable description of the data to be encrypted. This description - * string is included with the encrypted data. This parameter is optional and can + * String with a readable description of the data to be encrypted. This description + * string is included with the encrypted data. This parameter is optional and can * be set to NULL, except on Windows 2000. * @param pOptionalEntropy - * Pointer to a DATA_BLOB structure that contains a password or other additional - * entropy used to encrypt the data. The DATA_BLOB structure used in the encryption + * Pointer to a DATA_BLOB structure that contains a password or other additional + * entropy used to encrypt the data. The DATA_BLOB structure used in the encryption * phase must also be used in the decryption phase. This parameter can be set to NULL * for no additional entropy. * @param pvReserved - * Reserved for future use and must be set to NULL. + * Reserved for future use and must be set to NULL. * @param pPromptStruct - * Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about - * where and when prompts are to be displayed and what the content of those prompts + * Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about + * where and when prompts are to be displayed and what the content of those prompts * should be. This parameter can be set to NULL in both the encryption and decryption * phases. * @param dwFlags - * One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT, + * One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT, * CRYPTPROTECT_VERIFY_PROTECTION. * @param pDataOut - * Pointer to a DATA_BLOB structure that receives the encrypted data. When you have - * finished using the DATA_BLOB structure, free its pbData member by calling the - * LocalFree function. + * Pointer to a DATA_BLOB structure that receives the encrypted data. When you have + * finished using the DATA_BLOB structure, free its pbData member by calling the + * LocalFree function. * @return - * If the function succeeds, the function returns TRUE. If the function fails, + * If the function succeeds, the function returns TRUE. If the function fails, * it returns FALSE. For extended error information, call GetLastError. */ public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr, - DATA_BLOB pOptionalEntropy, Pointer pvReserved, + DATA_BLOB pOptionalEntropy, Pointer pvReserved, CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, int dwFlags, DATA_BLOB pDataOut); - + /** * The CryptUnprotectData function decrypts and does an integrity check of the data in * a DATA_BLOB structure. Usually, only a user with the same logon credentials as the * encrypter can decrypt the data. In addition, the encryption and decryption must be - * done on the same computer. + * done on the same computer. * @param pDataIn - * Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB - * structure's cbData member holds the length of the pbData member's byte string that - * contains the text to be encrypted. + * Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB + * structure's cbData member holds the length of the pbData member's byte string that + * contains the text to be encrypted. * @param szDataDescr - * Pointer to a string-readable description of the encrypted data included with the - * encrypted data. This parameter can be set to NULL. When you have finished using - * ppszDataDescr, free it by calling the LocalFree function. + * Pointer to a string-readable description of the encrypted data included with the + * encrypted data. This parameter can be set to NULL. When you have finished using + * ppszDataDescr, free it by calling the LocalFree function. * @param pOptionalEntropy - * Pointer to a DATA_BLOB structure that contains a password or other additional - * entropy used when the data was encrypted. This parameter can be set to NULL; - * however, if an optional entropy DATA_BLOB structure was used in the encryption + * Pointer to a DATA_BLOB structure that contains a password or other additional + * entropy used when the data was encrypted. This parameter can be set to NULL; + * however, if an optional entropy DATA_BLOB structure was used in the encryption * phase, that same DATA_BLOB structure must be used for the decryption phase. * @param pvReserved - * Reserved for future use; must be set to NULL. + * Reserved for future use; must be set to NULL. * @param pPromptStruct - * Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about - * where and when prompts are to be displayed and what the content of those prompts - * should be. This parameter can be set to NULL. + * Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about + * where and when prompts are to be displayed and what the content of those prompts + * should be. This parameter can be set to NULL. * @param dwFlags - * DWORD value that specifies options for this function. This parameter can be zero, - * in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN. + * DWORD value that specifies options for this function. This parameter can be zero, + * in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN. * @param pDataOut - * Pointer to a DATA_BLOB structure where the function stores the decrypted data. + * Pointer to a DATA_BLOB structure where the function stores the decrypted data. * When you have finished using the DATA_BLOB structure, free its pbData member by - * calling the LocalFree function. + * calling the LocalFree function. * @return - * If the function succeeds, the return value is TRUE. If the function fails, the + * If the function succeeds, the return value is TRUE. If the function fails, the * return value is FALSE. */ public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr, - DATA_BLOB pOptionalEntropy, Pointer pvReserved, + DATA_BLOB pOptionalEntropy, Pointer pvReserved, CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, int dwFlags, DATA_BLOB pDataOut); @@ -113,7 +112,7 @@ public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDe /** * The CertAddEncodedCertificateToSystemStore function opens the specified * system store and adds the encoded certificate to it. - * + * * @param szCertStoreName * A null-terminated string that contains the name of the system * store for the encoded certificate. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/DBT.java b/contrib/platform/src/com/sun/jna/platform/win32/DBT.java index 5380efe27a..f6bf7a51c8 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/DBT.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/DBT.java @@ -12,7 +12,6 @@ */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Native; @@ -25,10 +24,9 @@ /** * Based on dbt.h (various types) - * + * * @author Tobias Wolf, wolf.tobias@gmx.net */ -@SuppressWarnings("serial") public interface DBT { /** The dbt no disk space. */ @@ -65,29 +63,26 @@ public interface DBT { int DBT_CUSTOMEVENT = 0x8006; /** The guid devinterface usb device. */ - public GUID GUID_DEVINTERFACE_USB_DEVICE = new GUID( + GUID GUID_DEVINTERFACE_USB_DEVICE = new GUID( "{A5DCBF10-6530-11D2-901F-00C04FB951ED}"); /** The guid devinterface hid. */ - public GUID GUID_DEVINTERFACE_HID = new GUID( - "{4D1E55B2-F16F-11CF-88CB-001111000030}"); + GUID GUID_DEVINTERFACE_HID = new GUID("{4D1E55B2-F16F-11CF-88CB-001111000030}"); /** The guid devinterface volume. */ - public GUID GUID_DEVINTERFACE_VOLUME = new GUID( - "{53F5630D-B6BF-11D0-94F2-00A0C91EFB8B}"); + GUID GUID_DEVINTERFACE_VOLUME = new GUID("{53F5630D-B6BF-11D0-94F2-00A0C91EFB8B}"); /** The guid devinterface keyboard. */ - public GUID GUID_DEVINTERFACE_KEYBOARD = new GUID( - "{884b96c3-56ef-11d1-bc8c-00a0c91405dd}"); + GUID GUID_DEVINTERFACE_KEYBOARD = new GUID("{884b96c3-56ef-11d1-bc8c-00a0c91405dd}"); /** The guid devinterface mouse. */ - public GUID GUID_DEVINTERFACE_MOUSE = new GUID( - "{378DE44C-56EF-11D1-BC8C-00A0C91405DD}"); + GUID GUID_DEVINTERFACE_MOUSE = new GUID("{378DE44C-56EF-11D1-BC8C-00A0C91405DD}"); /** * The Class DEV_BROADCAST_HDR. */ public class DEV_BROADCAST_HDR extends Structure { + public static final List FIELDS = createFieldsOrder("dbch_size", "dbch_devicetype", "dbch_reserved"); /** The dbch_size. */ public int dbch_size = size(); @@ -102,11 +97,12 @@ public class DEV_BROADCAST_HDR extends Structure { * Instantiates a new dev broadcast hdr. */ public DEV_BROADCAST_HDR() { + super(); } /** * Instantiates a new dev broadcast hdr. - * + * * @param pointer * the pointer */ @@ -116,7 +112,7 @@ public DEV_BROADCAST_HDR(long pointer) { /** * Instantiates a new dev broadcast hdr. - * + * * @param memory * the memory */ @@ -125,14 +121,9 @@ public DEV_BROADCAST_HDR(Pointer memory) { read(); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dbch_size", "dbch_devicetype", - "dbch_reserved" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -161,6 +152,8 @@ protected List getFieldOrder() { * The Class DEV_BROADCAST_OEM. */ public class DEV_BROADCAST_OEM extends Structure { + public static final List FIELDS = createFieldsOrder("dbco_size", "dbco_devicetype", + "dbco_reserved", "dbco_identifier", "dbco_suppfunc"); /** The dbco_size. */ public int dbco_size = size(); @@ -181,12 +174,12 @@ public class DEV_BROADCAST_OEM extends Structure { * Instantiates a new dev broadcast oem. */ public DEV_BROADCAST_OEM() { - // TODO Auto-generated constructor stub + super(); } /** * Instantiates a new dev broadcast oem. - * + * * @param memory * the memory */ @@ -195,14 +188,9 @@ public DEV_BROADCAST_OEM(Pointer memory) { read(); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dbco_size", "dbco_devicetype", - "dbco_reserved", "dbco_identifier", "dbco_suppfunc" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -210,7 +198,8 @@ protected List getFieldOrder() { * The Class DEV_BROADCAST_DEVNODE. */ public class DEV_BROADCAST_DEVNODE extends Structure { - + public static final List FIELDS = createFieldsOrder("dbcd_size", "dbcd_devicetype", + "dbcd_reserved", "dbcd_devnode"); /** The dbcd_size. */ public int dbcd_size = size(); @@ -227,12 +216,12 @@ public class DEV_BROADCAST_DEVNODE extends Structure { * Instantiates a new dev broadcast devnode. */ public DEV_BROADCAST_DEVNODE() { - // TODO Auto-generated constructor stub + super(); } /** * Instantiates a new dev broadcast devnode. - * + * * @param memory * the memory */ @@ -241,14 +230,9 @@ public DEV_BROADCAST_DEVNODE(Pointer memory) { read(); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dbcd_size", "dbcd_devicetype", - "dbcd_reserved", "dbcd_devnode" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -256,6 +240,8 @@ protected List getFieldOrder() { * The Class DEV_BROADCAST_VOLUME. */ public class DEV_BROADCAST_VOLUME extends Structure { + public static final List FIELDS = createFieldsOrder("dbcv_size", "dbcv_devicetype", + "dbcv_reserved", "dbcv_unitmask", "dbcv_flags"); /** The dbcv_size. */ public int dbcv_size = size(); @@ -276,12 +262,12 @@ public class DEV_BROADCAST_VOLUME extends Structure { * Instantiates a new dev broadcast volume. */ public DEV_BROADCAST_VOLUME() { - // TODO Auto-generated constructor stub + super(); } /** * Instantiates a new dev broadcast volume. - * + * * @param memory * the memory */ @@ -290,14 +276,9 @@ public DEV_BROADCAST_VOLUME(Pointer memory) { read(); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dbcv_size", "dbcv_devicetype", - "dbcv_reserved", "dbcv_unitmask", "dbcv_flags" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -311,6 +292,7 @@ protected List getFieldOrder() { * The Class DEV_BROADCAST_PORT. */ public class DEV_BROADCAST_PORT extends Structure { + public static final List FIELDS = createFieldsOrder("dbcp_size", "dbcp_devicetype", "dbcp_reserved", "dbcp_name"); /** The dbcp_size. */ public int dbcp_size = size(); @@ -328,12 +310,12 @@ public class DEV_BROADCAST_PORT extends Structure { * Instantiates a new dev broadcast port. */ public DEV_BROADCAST_PORT() { - // TODO Auto-generated constructor stub + super(); } /** * Instantiates a new dev broadcast port. - * + * * @param memory * the memory */ @@ -342,14 +324,9 @@ public DEV_BROADCAST_PORT(Pointer memory) { read(); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dbcp_size", "dbcp_devicetype", - "dbcp_reserved", "dbcp_name" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -357,6 +334,8 @@ protected List getFieldOrder() { * The Class DEV_BROADCAST_NET. */ public class DEV_BROADCAST_NET extends Structure { + public static final List FIELDS = createFieldsOrder("dbcn_size", "dbcn_devicetype", + "dbcn_reserved", "dbcn_resource", "dbcn_flags"); /** The dbcn_size. */ public int dbcn_size = size(); @@ -377,12 +356,12 @@ public class DEV_BROADCAST_NET extends Structure { * Instantiates a new dev broadcast net. */ public DEV_BROADCAST_NET() { - // TODO Auto-generated constructor stub + super(); } /** * Instantiates a new dev broadcast net. - * + * * @param memory * the memory */ @@ -391,14 +370,9 @@ public DEV_BROADCAST_NET(Pointer memory) { read(); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dbcn_size", "dbcn_devicetype", - "dbcn_reserved", "dbcn_resource", "dbcn_flags" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -406,6 +380,8 @@ protected List getFieldOrder() { * The Class DEV_BROADCAST_DEVICEINTERFACE. */ public class DEV_BROADCAST_DEVICEINTERFACE extends Structure { + public static final List FIELDS = createFieldsOrder("dbcc_size", "dbcc_devicetype", + "dbcc_reserved", "dbcc_classguid", "dbcc_name"); /** The dbcc_size. */ public int dbcc_size; @@ -426,12 +402,12 @@ public class DEV_BROADCAST_DEVICEINTERFACE extends Structure { * Instantiates a new dev broadcast deviceinterface. */ public DEV_BROADCAST_DEVICEINTERFACE() { - // TODO Auto-generated constructor stub + super(); } /** * Dev broadcast hdr. - * + * * @param pointer * the pointer */ @@ -441,7 +417,7 @@ public DEV_BROADCAST_DEVICEINTERFACE(long pointer) { /** * Instantiates a new dev broadcast deviceinterface. - * + * * @param memory * the memory */ @@ -456,21 +432,16 @@ public DEV_BROADCAST_DEVICEINTERFACE(Pointer memory) { /** * Gets the dbcc_name. - * + * * @return the dbcc_name */ public String getDbcc_name() { return Native.toString(this.dbcc_name); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dbcc_size", "dbcc_devicetype", - "dbcc_reserved", "dbcc_classguid", "dbcc_name" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -478,6 +449,9 @@ protected List getFieldOrder() { * The Class DEV_BROADCAST_HANDLE. */ public class DEV_BROADCAST_HANDLE extends Structure { + public static final List FIELDS = createFieldsOrder("dbch_size", "dbch_devicetype", + "dbch_reserved", "dbch_handle", "dbch_hdevnotify", + "dbch_eventguid", "dbch_nameoffset", "dbch_data"); /** The dbch_size. */ public int dbch_size = size(); @@ -507,12 +481,12 @@ public class DEV_BROADCAST_HANDLE extends Structure { * Instantiates a new dev broadcast handle. */ public DEV_BROADCAST_HANDLE() { - // TODO Auto-generated constructor stub + super(); } /** * Instantiates a new dev broadcast handle. - * + * * @param memory * the memory */ @@ -521,15 +495,9 @@ public DEV_BROADCAST_HANDLE(Pointer memory) { read(); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dbch_size", "dbch_devicetype", - "dbch_reserved", "dbch_handle", "dbch_hdevnotify", - "dbch_eventguid", "dbch_nameoffset", "dbch_data" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java b/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java index eb84634016..cb2836abc1 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java @@ -1,29 +1,27 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.WinNT.PSID; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from DsGetDC.h. Windows SDK 6.0a - * + * * @author dblock[at]dblock.org */ public interface DsGetDC { @@ -38,13 +36,10 @@ public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { } - public DOMAIN_CONTROLLER_INFO() { - } - - public DOMAIN_CONTROLLER_INFO(Pointer memory) { - super(memory); - read(); - } + public static final List FIELDS = createFieldsOrder("DomainControllerName", + "DomainControllerAddress", "DomainControllerAddressType", + "DomainGuid", "DomainName", "DnsForestName", "Flags", + "DcSiteName", "ClientSiteName"); /** * Pointer to a null-terminated string that specifies the computer name @@ -111,11 +106,18 @@ public DOMAIN_CONTROLLER_INFO(Pointer memory) { */ public String ClientSiteName; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "DomainControllerName", - "DomainControllerAddress", "DomainControllerAddressType", - "DomainGuid", "DomainName", "DnsForestName", "Flags", - "DcSiteName", "ClientSiteName" }); + public DOMAIN_CONTROLLER_INFO() { + super(); + } + + public DOMAIN_CONTROLLER_INFO(Pointer memory) { + super(memory); + read(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -129,10 +131,13 @@ public static class ByReference extends PDOMAIN_CONTROLLER_INFO } + public static final List FIELDS = createFieldsOrder("dci"); + public DOMAIN_CONTROLLER_INFO.ByReference dci; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dci" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -177,6 +182,10 @@ public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("NetbiosDomainName", + "DnsDomainName", "Flags", "ParentIndex", "TrustType", + "TrustAttributes", "DomainSid", "DomainGuid"); + /** * Pointer to a null-terminated string that contains the NetBIOS name of * the domain. @@ -220,13 +229,13 @@ public static class ByReference extends DS_DOMAIN_TRUSTS implements */ public GUID DomainGuid; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "NetbiosDomainName", - "DnsDomainName", "Flags", "ParentIndex", "TrustType", - "TrustAttributes", "DomainSid", "DomainGuid" }); + @Override + protected List getFieldOrder() { + return FIELDS; } public DS_DOMAIN_TRUSTS() { + super(); } public DS_DOMAIN_TRUSTS(Pointer p) { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Guid.java b/contrib/platform/src/com/sun/jna/platform/win32/Guid.java index a948ad3620..1ac91bb87c 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Guid.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Guid.java @@ -22,7 +22,7 @@ // TODO: Auto-generated Javadoc /** * Ported from Guid.h. Microsoft Windows SDK 6.0A. - * + * * @author dblock[at]dblock.org */ public interface Guid { @@ -53,14 +53,13 @@ public ByValue(Pointer memory) { super(memory); } } - + /** * The Class ByReference. * * @author Tobias Wolf, wolf.tobias@gmx.net */ - public static class ByReference extends GUID implements - Structure.ByReference { + public static class ByReference extends GUID implements Structure.ByReference { /** * Instantiates a new by reference. @@ -71,7 +70,7 @@ public ByReference() { /** * Instantiates a new by reference. - * + * * @param guid * the guid */ @@ -86,7 +85,7 @@ public ByReference(GUID guid) { /** * Instantiates a new by reference. - * + * * @param memory * the memory */ @@ -95,6 +94,8 @@ public ByReference(Pointer memory) { } } + public static final List FIELDS = createFieldsOrder("Data1", "Data2", "Data3", "Data4"); + /** The Data1. */ public int Data1; @@ -116,12 +117,10 @@ public GUID() { /** * Instantiates a new guid. - * - * @param guid - * the guid + * + * @param guid the guid */ public GUID(GUID guid) { - super(); this.Data1 = guid.Data1; this.Data2 = guid.Data2; this.Data3 = guid.Data3; @@ -132,7 +131,7 @@ public GUID(GUID guid) { /** * Instantiates a new guid. - * + * * @param guid * the guid */ @@ -142,7 +141,7 @@ public GUID(String guid) { /** * Instantiates a new guid. - * + * * @param data * the data */ @@ -152,7 +151,7 @@ public GUID(byte[] data) { /** * Instantiates a new guid. - * + * * @param memory * the memory */ @@ -161,9 +160,33 @@ public GUID(Pointer memory) { read(); } + @Override + public boolean equals(Object o) { + if (o == null) { + return false; + } + if (this == o) { + return true; + } + if (getClass() != o.getClass()) { + return false; + } + + GUID other = (GUID) o; + return (this.Data1 == other.Data1) + && (this.Data2 == other.Data2) + && (this.Data3 == other.Data3) + && Arrays.equals(this.Data4, other.Data4); + } + + @Override + public int hashCode() { + return this.Data1 + this.Data2 & 0xFFFF + this.Data3 & 0xFFFF + Arrays.hashCode(this.Data4); + } + /** * From binary. - * + * * @param data * the data * @return the guid @@ -210,7 +233,7 @@ public static GUID fromBinary(byte[] data) { /** * From string. - * + * * @param guid * the guid * @return the guid @@ -282,7 +305,7 @@ public static GUID fromString(String guid) { /** * Generates a new guid. Code taken from the standard jdk implementation * (see UUID class). - * + * * @return the guid */ public static GUID newGuid() { @@ -300,7 +323,7 @@ public static GUID newGuid() { /** * To byte array. - * + * * @return the byte[] */ public byte[] toByteArray() { @@ -335,7 +358,7 @@ public byte[] toByteArray() { /** * The value of this Guid, formatted as follows: * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. - * + * * @return the string */ public String toGuidString() { @@ -362,20 +385,14 @@ public String toGuidString() { * Write fields to backing memory. */ protected void writeFieldsToMemory() { - this.writeField("Data1"); - this.writeField("Data2"); - this.writeField("Data3"); - this.writeField("Data4"); + for (String name : FIELDS) { + this.writeField(name); + } } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Data1", "Data2", "Data3", - "Data4" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -402,17 +419,17 @@ public ByReference() { /** * Instantiates a new by reference. - * + * * @param guid * the guid */ public ByReference(GUID guid) { super(guid); } - + /** * Instantiates a new by reference. - * + * * @param memory * the memory */ @@ -427,7 +444,7 @@ public ByReference(Pointer memory) { public CLSID() { super(); } - + /** * Instantiates a new clsid. * @@ -436,7 +453,7 @@ public CLSID() { public CLSID(String guid) { super(guid); } - + /** * Instantiates a new clsid. * @@ -463,7 +480,7 @@ public REFIID() { /** * Instantiates a new refiid. - * + * * @param memory * the memory */ @@ -473,7 +490,7 @@ public REFIID(Pointer memory) { /** * Instantiates a new refiid. - * + * * @param data * the data */ @@ -502,7 +519,7 @@ public IID() { /** * Instantiates a new iid. - * + * * @param memory * the memory */ @@ -521,7 +538,7 @@ public IID(String iid) { /** * Instantiates a new iid. - * + * * @param data * the data */ diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java b/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java index badd31e365..e0eb6aee36 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java @@ -1,18 +1,17 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; @@ -25,25 +24,33 @@ * @author dblock[at]dblock.org */ public interface LMAccess { - + public static class LOCALGROUP_INFO_0 extends Structure { + public static final List FIELDS = createFieldsOrder("lgrui0_name"); + + public String lgrui0_name; + public LOCALGROUP_INFO_0() { super(); } - + public LOCALGROUP_INFO_0(Pointer memory) { super(memory); read(); } - - public String lgrui0_name; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "lgrui0_name" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } public static class LOCALGROUP_INFO_1 extends Structure { + public static final List FIELDS = createFieldsOrder("lgrui1_name", "lgrui1_comment"); + + public String lgrui1_name; + public String lgrui1_comment; + public LOCALGROUP_INFO_1() { super(); } @@ -53,28 +60,33 @@ public LOCALGROUP_INFO_1(Pointer memory) { read(); } - public String lgrui1_name; - public String lgrui1_comment; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "lgrui1_name", "lgrui1_comment" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } - + // // bit masks for the NetUserEnum filter parameter. // - + int FILTER_TEMP_DUPLICATE_ACCOUNT = 0x0001; int FILTER_NORMAL_ACCOUNT = 0x0002; // int FILTER_PROXY_ACCOUNT = 0x0004; int FILTER_INTERDOMAIN_TRUST_ACCOUNT = 0x0008; int FILTER_WORKSTATION_TRUST_ACCOUNT = 0x0010; - int FILTER_SERVER_TRUST_ACCOUNT = 0x0020; - + int FILTER_SERVER_TRUST_ACCOUNT = 0x0020; + /** * The USER_INFO_0 structure contains a user account name. */ public static class USER_INFO_0 extends Structure { + public static final List FIELDS = createFieldsOrder("usri0_name"); + /** + * Pointer to a Unicode string that specifies the name of the user account. + */ + public String usri0_name; + public USER_INFO_0() { super(); } @@ -84,57 +96,49 @@ public USER_INFO_0(Pointer memory) { read(); } - /** - * Pointer to a Unicode string that specifies the name of the user account. - */ - public String usri0_name; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "usri0_name" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } - + /** - * The USER_INFO_1 structure contains information about a user account, including - * account name, password data, privilege level, and the path to the user's home + * The USER_INFO_1 structure contains information about a user account, including + * account name, password data, privilege level, and the path to the user's home * directory. */ public static class USER_INFO_1 extends Structure { - public USER_INFO_1() { - super(); - } - - public USER_INFO_1(Pointer memory) { - super(memory); - read(); - } + public static final List FIELDS = createFieldsOrder( + "usri1_name", "usri1_password", "usri1_password_age", "usri1_priv", + "usri1_home_dir", "usri1_comment", "usri1_flags", "usri1_script_path"); /** - * Pointer to a Unicode string that specifies the name of the user + * Pointer to a Unicode string that specifies the name of the user * account. */ public String usri1_name; /** * Pointer to a Unicode string that specifies the password of the user - * indicated by the usri1_name member. + * indicated by the usri1_name member. */ public String usri1_password; /** - * Specifies a DWORD value that indicates the number of seconds that have + * Specifies a DWORD value that indicates the number of seconds that have * elapsed since the usri1_password member was last changed. */ public int usri1_password_age; /** - * Specifies a DWORD value that indicates the level of privilege assigned + * Specifies a DWORD value that indicates the level of privilege assigned * to the usri1_name member. */ public int usri1_priv; /** - * Pointer to a Unicode string specifying the path of the home directory - * for the user specified in the usri1_name member. + * Pointer to a Unicode string specifying the path of the home directory + * for the user specified in the usri1_name member. */ public String usri1_home_dir; /** - * Pointer to a Unicode string that contains a comment to associate with + * Pointer to a Unicode string that contains a comment to associate with * the user account. */ public String usri1_comment; @@ -143,55 +147,59 @@ public USER_INFO_1(Pointer memory) { */ public int usri1_flags; /** - * Pointer to a Unicode string specifying the path for the user's - * logon script file. + * Pointer to a Unicode string specifying the path for the user's + * logon script file. */ public String usri1_script_path; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "usri1_name", "usri1_password", "usri1_password_age", "usri1_priv", "usri1_home_dir", "usri1_comment", "usri1_flags", "usri1_script_path" }); + public USER_INFO_1() { + super(); + } + + public USER_INFO_1(Pointer memory) { + super(memory); + read(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } } - + /** - * The USER_INFO_23 structure contains information about a user account, - * including the account name, the user's full name, a comment associated with the account, + * The USER_INFO_23 structure contains information about a user account, + * including the account name, the user's full name, a comment associated with the account, * and the user's security identifier (SID). * - * Note : - * The USER_INFO_23 structure supersedes the USER_INFO_20 structure. + * Note : + * The USER_INFO_23 structure supersedes the USER_INFO_20 structure. * It is recommended that applications use the USER_INFO_23 structure instead of the USER_INFO_20 structure. */ public static class USER_INFO_23 extends Structure { - public USER_INFO_23() { - super(); - } + public static final List FIELDS = createFieldsOrder( + "usri23_name", "usri23_full_name", "usri23_comment", "usri23_flags", "usri23_user_sid"); - public USER_INFO_23(Pointer memory) { - useMemory(memory); - read(); - } - - /** - * A pointer to a Unicode string that specifies the name of the user account. + /** + * A pointer to a Unicode string that specifies the name of the user account. * Calls to the NetUserSetInfo function ignore this member. */ public String usri23_name; - /** - * A pointer to a Unicode string that contains the full name of the user. + /** + * A pointer to a Unicode string that contains the full name of the user. * This string can be a null string, or it can have any number of characters before the terminating null character. */ public String usri23_full_name; - /** - * A pointer to a Unicode string that contains a comment associated with the user account. + /** + * A pointer to a Unicode string that contains a comment associated with the user account. * This string can be a null string, or it can have any number of characters before the terminating null character. */ public String usri23_comment; - /** - * This member can be one or more of the following values. - * Note that setting user account control flags may require certain privileges and control access rights. + /** + * This member can be one or more of the following values. + * Note that setting user account control flags may require certain privileges and control access rights. * For more information, see the Remarks section of the NetUserSetInfo function. - * Value Meaning + * Value Meaning * UF_SCRIPT The logon script executed. This value must be set. * UF_ACCOUNTDISABLE The user's account is disabled. * UF_HOMEDIR_REQUIRED The home directory is required. This value is ignored. @@ -207,9 +215,9 @@ public USER_INFO_23(Pointer memory) { * UF_TRUSTED_FOR_DELEGATION The account is enabled for delegation. This is a security-sensitive setting; accounts with this option enabled should be tightly controlled. This setting allows a service running under the account to assume a client's identity and authenticate as that user to other remote servers on the network. * UF_PASSWORD_EXPIRED The user's password has expired. Windows 2000: This value is not supported. * UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION The account is trusted to authenticate a user outside of the Kerberos security package and delegate that user through constrained delegation. This is a security-sensitive setting; accounts with this option enabled should be tightly controlled. This setting allows a service running under the account to assert a client's identity and authenticate as that user to specifically configured services on the network. Windows XP/2000: This value is not supported. - * + * * The following values describe the account type. Only one value can be set. You cannot change the account type using the NetUserSetInfo function. - * Value Meaning + * Value Meaning * UF_NORMAL_ACCOUNT This is a default account type that represents a typical user. * UF_TEMP_DUPLICATE_ACCOUNT This is an account for users whose primary account is in another domain. This account provides user access to this domain, but not to any domain that trusts this domain. The User Manager refers to this account type as a local user account. * UF_WORKSTATION_TRUST_ACCOUNT This is a computer account for a computer that is a member of this domain. @@ -217,21 +225,37 @@ public USER_INFO_23(Pointer memory) { * UF_INTERDOMAIN_TRUST_ACCOUNT This is a permit to trust account for a domain that trusts other domains. */ public int usri23_flags; - /** - * A pointer to a SID structure that contains the security identifier (SID) + /** + * A pointer to a SID structure that contains the security identifier (SID) * that uniquely identifies the user. The NetUserAdd and NetUserSetInfo functions ignore this member. */ public PSID.ByReference usri23_user_sid; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "usri23_name", "usri23_full_name", "usri23_comment", "usri23_flags", "usri23_user_sid" }); + + public USER_INFO_23() { + super(); + } + + public USER_INFO_23(Pointer memory) { + useMemory(memory); + read(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } - } - + } + /** * The GROUP_USERS_INFO_0 structure contains global group member information. */ public static class GROUP_USERS_INFO_0 extends Structure { + public static final List FIELDS = createFieldsOrder("grui0_name"); + /** + * Pointer to a null-terminated Unicode character string that specifies a name. + */ + public String grui0_name; + public GROUP_USERS_INFO_0() { super(); } @@ -241,20 +265,22 @@ public GROUP_USERS_INFO_0(Pointer memory) { read(); } - /** - * Pointer to a null-terminated Unicode character string that specifies a name. - */ - public String grui0_name; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "grui0_name" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } - + /** * The LOCALGROUP_USERS_INFO_0 structure contains local group member information. */ public static class LOCALGROUP_USERS_INFO_0 extends Structure { + public static final List FIELDS = createFieldsOrder("lgrui0_name"); + /** + * Pointer to a Unicode string specifying the name of a local group to which the user belongs. + */ + public String lgrui0_name; + public LOCALGROUP_USERS_INFO_0() { super(); } @@ -264,22 +290,26 @@ public LOCALGROUP_USERS_INFO_0(Pointer memory) { read(); } - /** - * Pointer to a Unicode string specifying the name of a local group to which the user belongs. - */ - public String lgrui0_name; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "lgrui0_name" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } - + /** * The GROUP_INFO_0 structure contains the name of a global group in the security * database, which is the security accounts manager (SAM) database or, in the case * of domain controllers, the Active Directory. */ public static class GROUP_INFO_0 extends Structure { + public static final List FIELDS = createFieldsOrder("grpi0_name"); + + /** + * Pointer to a null-terminated Unicode character string that specifies + * the name of the global group. + */ + public String grpi0_name; + public GROUP_INFO_0() { super(); } @@ -289,22 +319,31 @@ public GROUP_INFO_0(Pointer memory) { read(); } - /** - * Pointer to a null-terminated Unicode character string that specifies - * the name of the global group. - */ - public String grpi0_name; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "grpi0_name" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } /** - * The GROUP_INFO_1 structure contains a global group name and a comment to + * The GROUP_INFO_1 structure contains a global group name and a comment to * associate with the group. */ - public static class GROUP_INFO_1 extends Structure { + public static class GROUP_INFO_1 extends Structure { + public static final List FIELDS = createFieldsOrder("grpi1_name", "grpi1_comment"); + + /** + * Pointer to a null-terminated Unicode character string that specifies + * the name of the global group. + */ + public String grpi1_name; + /** + * Pointer to a null-terminated Unicode character string that specifies + * a remark associated with the global group. This member can be a null + * string. The comment can contain MAXCOMMENTSZ characters. + */ + public String grpi1_comment; + public GROUP_INFO_1() { super(); } @@ -314,20 +353,9 @@ public GROUP_INFO_1(Pointer memory) { read(); } - /** - * Pointer to a null-terminated Unicode character string that specifies - * the name of the global group. - */ - public String grpi1_name; - /** - * Pointer to a null-terminated Unicode character string that specifies - * a remark associated with the global group. This member can be a null - * string. The comment can contain MAXCOMMENTSZ characters. - */ - public String grpi1_comment; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "grpi1_name", "grpi1_comment" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -336,83 +364,91 @@ protected List getFieldOrder() { * name, identifier, and resource attributes. */ public static class GROUP_INFO_2 extends Structure { - public GROUP_INFO_2() { - super(); - } - - public GROUP_INFO_2(Pointer memory) { - super(memory); - read(); - } + public static final List FIELDS = createFieldsOrder( + "grpi2_name", "grpi2_comment", "grpi2_group_id", "grpi2_attributes"); /** - * Pointer to a null-terminated Unicode character string that + * Pointer to a null-terminated Unicode character string that * specifies the name of the global group. */ public String grpi2_name; /** - * Pointer to a null-terminated Unicode character string that contains a - * remark associated with the global group. This member can be a null string. - * The comment can contain MAXCOMMENTSZ characters. + * Pointer to a null-terminated Unicode character string that contains a + * remark associated with the global group. This member can be a null string. + * The comment can contain MAXCOMMENTSZ characters. */ public String grpi2_comment; /** - * Specifies a DWORD value that contains the relative identifier (RID) of + * Specifies a DWORD value that contains the relative identifier (RID) of * the global group. */ public int grpi2_group_id; /** - * These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, - * and SE_GROUP_ENABLED_BY_DEFAULT. + * These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, + * and SE_GROUP_ENABLED_BY_DEFAULT. */ public int grpi2_attributes; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "grpi2_name", "grpi2_comment", "grpi2_group_id", "grpi2_attributes" }); - } - } - /** - * The GROUP_INFO_3 structure contains information about a global group, including - * name, security identifier (SID), and resource attributes. - */ - public static class GROUP_INFO_3 extends Structure { - public GROUP_INFO_3() { + public GROUP_INFO_2() { super(); } - public GROUP_INFO_3(Pointer memory) { + public GROUP_INFO_2(Pointer memory) { super(memory); read(); } + @Override + protected List getFieldOrder() { + return FIELDS; + } + } + + /** + * The GROUP_INFO_3 structure contains information about a global group, including + * name, security identifier (SID), and resource attributes. + */ + public static class GROUP_INFO_3 extends Structure { + public static final List FIELDS = createFieldsOrder( + "grpi3_name", "grpi3_comment", "grpi3_group_sid", "grpi3_attributes"); + /** - * Pointer to a null-terminated Unicode character string that - * specifies the name of the global group. + * Pointer to a null-terminated Unicode character string that + * specifies the name of the global group. */ public String grpi3_name; /** - * Pointer to a null-terminated Unicode character string that - * contains a remark associated with the global group. This member can be - * a null string. The comment can contain MAXCOMMENTSZ characters. + * Pointer to a null-terminated Unicode character string that + * contains a remark associated with the global group. This member can be + * a null string. The comment can contain MAXCOMMENTSZ characters. */ public String grpi3_comment; /** - * Pointer to a SID structure that contains the security identifier (SID) that + * Pointer to a SID structure that contains the security identifier (SID) that * uniquely identifies the global group. */ public PSID.ByReference grpi3_group_sid; /** - * These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, and + * These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, and * SE_GROUP_ENABLED_BY_DEFAULT. */ public int grpi3_attributes; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "grpi3_name", "grpi3_comment", "grpi3_group_sid", "grpi3_attributes" }); + + public GROUP_INFO_3() { + super(); + } + + public GROUP_INFO_3(Pointer memory) { + super(memory); + read(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } } - + // // Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)). // diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMShare.java b/contrib/platform/src/com/sun/jna/platform/win32/LMShare.java index bd6ce1a9d5..650b3f61c6 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMShare.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMShare.java @@ -1,23 +1,21 @@ /* Copyright (c) 2015 Adam Marcionek, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from LMShare.h. @@ -64,15 +62,10 @@ public interface LMShare { /** * Contains information about the shared resource, including name of the resource, type and permissions, number of connections, and other pertinent information. */ - public static class SHARE_INFO_2 extends Structure { - public SHARE_INFO_2() { - super(); - } - - public SHARE_INFO_2(Pointer memory) { - super(memory); - read(); - } + public static class SHARE_INFO_2 extends Structure { + public static final List FIELDS = createFieldsOrder("shi2_netname", + "shi2_type", "shi2_remark", "shi2_permissions", "shi2_max_uses", "shi2_current_uses", + "shi2_path", "shi2_passwd"); /** * Pointer to a Unicode string specifying the name of a shared resource. Calls to the NetShareSetInfo function ignore this member. @@ -123,32 +116,31 @@ public SHARE_INFO_2(Pointer memory) { * This member can be no longer than SHPWLEN+1 bytes (including a terminating null character). Calls to the NetShareSetInfo function ignore this member. */ public String shi2_passwd; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "shi2_netname", - "shi2_type", - "shi2_remark", - "shi2_permissions", - "shi2_max_uses", - "shi2_current_uses", - "shi2_path", - "shi2_passwd" }); - } - } - /** - * Contains information about the shared resource, including name of the resource, type and permissions, number of connections, and other pertinent information. - */ - public static class SHARE_INFO_502 extends Structure { - public SHARE_INFO_502() { + public SHARE_INFO_2() { super(); } - public SHARE_INFO_502(Pointer memory) { + public SHARE_INFO_2(Pointer memory) { super(memory); read(); } + @Override + protected List getFieldOrder() { + return FIELDS; + } + } + + /** + * Contains information about the shared resource, including name of the resource, type and permissions, number of connections, and other pertinent information. + */ + public static class SHARE_INFO_502 extends Structure { + public static final List FIELDS = createFieldsOrder("shi502_netname", + "shi502_type", "shi502_remark", "shi502_permissions", "shi502_max_uses", + "shi502_current_uses", "shi502_path", "shi502_passwd", "shi502_reserved", + "shi502_security_descriptor"); + /** * Pointer to a Unicode string specifying the name of a shared resource. Calls to the NetShareSetInfo function ignore this member. */ @@ -209,17 +201,18 @@ public SHARE_INFO_502(Pointer memory) { */ public Pointer shi502_security_descriptor; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "shi502_netname", - "shi502_type", - "shi502_remark", - "shi502_permissions", - "shi502_max_uses", - "shi502_current_uses", - "shi502_path", - "shi502_passwd", - "shi502_reserved", - "shi502_security_descriptor" }); + public SHARE_INFO_502() { + super(); + } + + public SHARE_INFO_502(Pointer memory) { + super(memory); + read(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } - } + } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java index 2882e09d0f..de6c1eaceb 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LowLevelMonitorConfigurationAPI.java @@ -16,7 +16,6 @@ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Structure; @@ -33,8 +32,8 @@ public interface LowLevelMonitorConfigurationAPI /** * Contains information from a monitor's timing report. */ - class MC_TIMING_REPORT extends Structure - { + class MC_TIMING_REPORT extends Structure { + public static final List FIELDS = createFieldsOrder("dwHorizontalFrequencyInHZ", "dwVerticalFrequencyInHZ", "bTimingStatusByte"); /** * The monitor's horizontal synchronization frequency in Hz. */ @@ -46,15 +45,14 @@ class MC_TIMING_REPORT extends Structure public DWORD dwVerticalFrequencyInHZ; /** - * Timing status byte. For more information about this value, see the Display Data Channel Command + * Timing status byte. For more information about this value, see the Display Data Channel Command * Interface (DDC/CI) standard. */ public BYTE bTimingStatusByte; @Override - protected List getFieldOrder() - { - return Arrays.asList("dwHorizontalFrequencyInHZ", "dwVerticalFrequencyInHZ", "bTimingStatusByte"); + protected List getFieldOrder() { + return FIELDS; } } @@ -64,7 +62,7 @@ protected List getFieldOrder() enum MC_VCP_CODE_TYPE { /** - * Momentary VCP code. Sending a command of this type causes the monitor to initiate a self-timed + * Momentary VCP code. Sending a command of this type causes the monitor to initiate a self-timed * operation and then revert to its original state. Examples include display tests and degaussing. */ MC_MOMENTARY, diff --git a/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java b/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java index 425f7ab6f1..3889735960 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java @@ -1,18 +1,17 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Memory; @@ -28,36 +27,38 @@ * @author dblock[at]dblock.org */ public interface NTSecApi { - + /** - * The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA) + * The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA) * functions to specify a Unicode string. */ public static class LSA_UNICODE_STRING extends Structure { public static class ByReference extends LSA_UNICODE_STRING implements Structure.ByReference { } - + + public static final List FIELDS = createFieldsOrder("Length", "MaximumLength", "Buffer"); /** - * Specifies the length, in bytes, of the string pointed to by the Buffer member, + * Specifies the length, in bytes, of the string pointed to by the Buffer member, * not including the terminating null character, if any. */ public short Length; /** - * Specifies the total size, in bytes, of the memory allocated for Buffer. Up to + * Specifies the total size, in bytes, of the memory allocated for Buffer. Up to * MaximumLength bytes can be written into the buffer without trampling memory. */ public short MaximumLength; /** - * Pointer to a wide character string. Note that the strings returned by the + * Pointer to a wide character string. Note that the strings returned by the * various LSA functions might not be null terminated. */ public Pointer Buffer; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Length", "MaximumLength", "Buffer" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } - + /** * String representation of the buffer. * @return @@ -78,14 +79,14 @@ public String getString() { * Pointer to an LSA_UNICODE_STRING. */ public static class PLSA_UNICODE_STRING { - public static class ByReference extends PLSA_UNICODE_STRING + public static class ByReference extends PLSA_UNICODE_STRING implements Structure.ByReference { } - + public LSA_UNICODE_STRING.ByReference s; } - + /** * Record contains an included top-level name. */ @@ -100,25 +101,32 @@ public static class ByReference extends PLSA_UNICODE_STRING int ForestTrustDomainInfo = 2; public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure { + public static final List FIELDS = createFieldsOrder("Sid", "DnsName", "NetbiosName"); + public PSID.ByReference Sid; public LSA_UNICODE_STRING DnsName; public LSA_UNICODE_STRING NetbiosName; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Sid", "DnsName", "NetbiosName" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } - + public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure { + public static final List FIELDS = createFieldsOrder("Length", "Buffer"); + public int Length; public Pointer Buffer; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Length", "Buffer" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } - - public static class LSA_FOREST_TRUST_RECORD extends Structure { - + + public static class LSA_FOREST_TRUST_RECORD extends Structure { + public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference { } @@ -127,19 +135,20 @@ public static class UNION extends Union { public static class ByReference extends UNION implements Structure.ByReference { } - + public LSA_UNICODE_STRING TopLevelName; public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo; public LSA_FOREST_TRUST_BINARY_DATA Data; } - + + public static final List FIELDS = createFieldsOrder("Flags", "ForestTrustType", "Time", "u"); /** * Flags that control the behavior of the operation. */ public int Flags; - + /** - * LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record. + * LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record. * The following table shows the possible values. * ForestTrustTopLevelName * Record contains an included top-level name. @@ -152,19 +161,21 @@ public static class ByReference extends UNION implements Structure.ByReference */ public int ForestTrustType; public LARGE_INTEGER Time; - + /** - * Data type depending on ForestTrustType. + * Data type depending on ForestTrustType. */ public UNION u; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Flags", "ForestTrustType", "Time", "u" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } - + + @Override public void read() { super.read(); - + switch(ForestTrustType) { case NTSecApi.ForestTrustTopLevelName: case NTSecApi.ForestTrustTopLevelNameEx: @@ -177,44 +188,49 @@ public void read() { u.setType(LSA_FOREST_TRUST_BINARY_DATA.class); break; } - + u.read(); } } - + public static class PLSA_FOREST_TRUST_RECORD extends Structure { public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference { - + } - + + public static final List FIELDS = createFieldsOrder("tr"); + public LSA_FOREST_TRUST_RECORD.ByReference tr; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "tr" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } - + public static class LSA_FOREST_TRUST_INFORMATION extends Structure { - + public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference { - + } - + + public static final List FIELDS = createFieldsOrder("RecordCount", "Entries"); /** - * Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the + * Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the * Entries member. */ public int RecordCount; /** - * Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures, + * Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures, * each of which contains one piece of forest trust information. */ public PLSA_FOREST_TRUST_RECORD.ByReference Entries; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "RecordCount", "Entries" }); + @Override + protected List getFieldOrder() { + return FIELDS; } - + /** * Get an array of LSA_FOREST_TRUST_RECORD entries. * @return @@ -225,19 +241,21 @@ public PLSA_FOREST_TRUST_RECORD[] getEntries() { } } /** - * The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority + * The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority * forest trust information. */ public static class PLSA_FOREST_TRUST_INFORMATION extends Structure { - + public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference { - + } + public static final List FIELDS = createFieldsOrder("fti"); public LSA_FOREST_TRUST_INFORMATION.ByReference fti; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "fti" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java b/contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java index abd4bae730..a76a870e07 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java @@ -3,7 +3,6 @@ */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.IntegerType; @@ -52,6 +51,10 @@ public static class ByReference extends EXCEPINFO implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("wCode", "wReserved", "bstrSource", + "bstrDescription", "bstrHelpFile", "dwHelpContext", + "pvReserved", "pfnDeferredFillIn", "scode"); + /** The w code. */ public WORD wCode; @@ -83,11 +86,12 @@ public static class ByReference extends EXCEPINFO implements * Instantiates a new excepinfo. */ public EXCEPINFO() { + super(); } /** * Instantiates a new excepinfo. - * + * * @param p * the p */ @@ -95,21 +99,14 @@ public EXCEPINFO(Pointer p) { super(p); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ @Override - protected List getFieldOrder() { - return Arrays - .asList(new String[] { "wCode", "wReserved", "bstrSource", - "bstrDescription", "bstrHelpFile", "dwHelpContext", - "pvReserved", "pfnDeferredFillIn", "scode" }); + protected List getFieldOrder() { + return FIELDS; } } public static class VARIANT_BOOL extends IntegerType { + private static final long serialVersionUID = 1L; public static final int SIZE = 2; public VARIANT_BOOL() { @@ -122,6 +119,7 @@ public VARIANT_BOOL(long value) { } public static class _VARIANT_BOOL extends VARIANT_BOOL { + private static final long serialVersionUID = 1L; public _VARIANT_BOOL() { this(0); @@ -175,23 +173,20 @@ public static class ByReference extends DATE implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("date"); public double date; public DATE() { + super(); } public DATE(double date) { this.date = date; } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "date" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -199,6 +194,8 @@ protected List getFieldOrder() { * The Class DISPID. */ public static class DISPID extends LONG { + private static final long serialVersionUID = 1L; + public DISPID() { this(0); } @@ -228,6 +225,8 @@ public DISPID getValue() { } public static class MEMBERID extends DISPID { + private static final long serialVersionUID = 1L; + public MEMBERID() { this(0); } @@ -362,9 +361,11 @@ public ByReference(TYPEKIND typekind) { } } + public static final List FIELDS = createFieldsOrder("value"); public int value; public TYPEKIND() { + super(); } public TYPEKIND(int value) { @@ -396,8 +397,8 @@ public TYPEKIND(Pointer pointer) { public static final int TKIND_MAX = TYPEKIND.TKIND_UNION + 1; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "value" }); + protected List getFieldOrder() { + return FIELDS; } }; @@ -406,9 +407,12 @@ public static class ByReference extends DESCKIND implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("value"); + public int value; public DESCKIND() { + super(); } public DESCKIND(int value) { @@ -434,8 +438,8 @@ public DESCKIND(Pointer pointer) { public static final int DESCKIND_MAX = DESCKIND.DESCKIND_IMPLICITAPPOBJ + 1; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "value" }); + protected List getFieldOrder() { + return FIELDS; } }; @@ -444,6 +448,9 @@ public static class ByReference extends SAFEARRAY implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder( + "cDims", "fFeatures", "cbElements", "cLocks", "pvData", "rgsabound"); + public USHORT cDims; public USHORT fFeatures; public ULONG cbElements; @@ -454,6 +461,7 @@ public static class ByReference extends SAFEARRAY implements public SAFEARRAYBOUND[] rgsabound = { new SAFEARRAYBOUND() }; public SAFEARRAY() { + super(); } public SAFEARRAY(Pointer pointer) { @@ -462,9 +470,8 @@ public SAFEARRAY(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "cDims", "fFeatures", - "cbElements", "cLocks", "pvData", "rgsabound" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -473,11 +480,13 @@ public static class ByReference extends SAFEARRAYBOUND implements Structure.ByReference { } - public ULONG cElements; + public static final List FIELDS = createFieldsOrder("cElements", "lLbound"); + public ULONG cElements; public LONG lLbound; public SAFEARRAYBOUND() { + super(); } public SAFEARRAYBOUND(Pointer pointer) { @@ -492,8 +501,8 @@ public SAFEARRAYBOUND(int cElements, int lLbound) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "cElements", "lLbound" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -516,6 +525,8 @@ public CURRENCY(Pointer pointer) { } public static class _CURRENCY extends Structure { + public static final List FIELDS = createFieldsOrder("Lo", "Hi"); + public ULONG Lo; public LONG Hi; @@ -529,30 +540,19 @@ public _CURRENCY(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Lo", "Hi" }); + protected List getFieldOrder() { + return FIELDS; } } } public static class DECIMAL extends Structure { + public static final List FIELDS = createFieldsOrder("wReserved", "decimal1", "Hi32", "decimal2"); public static class ByReference extends DECIMAL implements Structure.ByReference { }; - public DECIMAL() { - super(); - } - - public DECIMAL(Pointer pointer) { - super(pointer); - } - - public short wReserved; - public _DECIMAL1 decimal1; - public NativeLong Hi32; - public _DECIMAL2 decimal2; public static class _DECIMAL1 extends Union { @@ -560,7 +560,6 @@ public static class _DECIMAL1 extends Union { public _DECIMAL1_DECIMAL decimal1_DECIMAL; public _DECIMAL1() { - super(); this.setType("signscale"); } @@ -571,6 +570,7 @@ public _DECIMAL1(Pointer pointer) { } public static class _DECIMAL1_DECIMAL extends Structure { + public static final List FIELDS = createFieldsOrder("scale", "sign"); public BYTE scale; public BYTE sign; @@ -583,14 +583,13 @@ public _DECIMAL1_DECIMAL(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "scale", "sign" }); + protected List getFieldOrder() { + return FIELDS; } } } public static class _DECIMAL2 extends Union { - public ULONGLONG Lo64; public _DECIMAL2_DECIMAL decimal2_DECIMAL; @@ -605,6 +604,8 @@ public _DECIMAL2(Pointer pointer) { } public static class _DECIMAL2_DECIMAL extends Structure { + public static final List FIELDS = createFieldsOrder("Lo32", "Mid32"); + public BYTE Lo32; public BYTE Mid32; @@ -617,16 +618,28 @@ public _DECIMAL2_DECIMAL(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Lo32", "Mid32" }); + protected List getFieldOrder() { + return FIELDS; } } } + public short wReserved; + public _DECIMAL1 decimal1; + public NativeLong Hi32; + public _DECIMAL2 decimal2; + + public DECIMAL() { + super(); + } + + public DECIMAL(Pointer pointer) { + super(pointer); + } + @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "wReserved", "decimal1", - "Hi32", "decimal2" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -635,9 +648,11 @@ public static class ByReference extends SYSKIND implements Structure.ByReference { } - public int value; + public static final List FIELDS = createFieldsOrder("value"); + public int value; public SYSKIND() { + super(); } public SYSKIND(int value) { @@ -655,8 +670,8 @@ public SYSKIND(Pointer pointer) { public static final int SYS_WIN64 = SYSKIND.SYS_MAC + 1; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "value" }); + protected List getFieldOrder() { + return FIELDS; } }; @@ -665,9 +680,11 @@ public static class ByReference extends LIBFLAGS implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("value"); public int value; public LIBFLAGS() { + super(); } public LIBFLAGS(int value) { @@ -685,8 +702,8 @@ public LIBFLAGS(Pointer pointer) { public static final int LIBFLAG_FHASDISKIMAGE = 0x8; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "value" }); + protected List getFieldOrder() { + return FIELDS; } }; @@ -695,6 +712,7 @@ public static class ByReference extends TLIBATTR implements Structure.ByReference { public ByReference() { + super(); } public ByReference(Pointer pointer) { @@ -703,6 +721,9 @@ public ByReference(Pointer pointer) { } }; + public static final List FIELDS = createFieldsOrder("guid", "lcid", "syskind", + "wMajorVerNum", "wMinorVerNum", "wLibFlags"); + public GUID guid; public LCID lcid; public SYSKIND syskind; @@ -720,9 +741,8 @@ public TLIBATTR(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "guid", "lcid", "syskind", - "wMajorVerNum", "wMinorVerNum", "wLibFlags" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -769,6 +789,11 @@ public static class ByReference extends FUNCDESC implements Structure.ByReference { }; + public static final List FIELDS = createFieldsOrder("memid", "lprgscode", + "lprgelemdescParam", "funckind", "invkind", "callconv", + "cParams", "cParamsOpt", "oVft", "cScodes", "elemdescFunc", + "wFuncFlags"); + public MEMBERID memid; public ScodeArg.ByReference lprgscode; public ElemDescArg.ByReference lprgelemdescParam; @@ -783,6 +808,7 @@ public static class ByReference extends FUNCDESC implements public WORD wFuncFlags; public FUNCDESC() { + super(); } public FUNCDESC(Pointer pointer) { @@ -798,10 +824,7 @@ public FUNCDESC(Pointer pointer) { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "memid", "lprgscode", - "lprgelemdescParam", "funckind", "invkind", "callconv", - "cParams", "cParamsOpt", "oVft", "cScodes", "elemdescFunc", - "wFuncFlags" }); + return FIELDS; } } @@ -810,9 +833,12 @@ public static class ByReference extends ElemDescArg implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("elemDescArg"); + public ELEMDESC[] elemDescArg = { new ELEMDESC() }; public ElemDescArg() { + super(); } public ElemDescArg(Pointer pointer) { @@ -821,8 +847,8 @@ public ElemDescArg(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "elemDescArg" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -831,9 +857,12 @@ public static class ByReference extends ScodeArg implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("scodeArg"); + public SCODE[] scodeArg = { new SCODE() }; public ScodeArg() { + super(); } public ScodeArg(Pointer pointer) { @@ -842,8 +871,8 @@ public ScodeArg(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "scodeArg" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -852,6 +881,9 @@ public static class ByReference extends VARDESC implements Structure.ByReference { }; + public static final List FIELDS = createFieldsOrder("memid", "lpstrSchema", "_vardesc", + "elemdescVar", "wVarFlags", "varkind"); + // / C type : MEMBERID public MEMBERID memid; // / C type : LPOLESTR @@ -883,7 +915,6 @@ public static class ByReference extends _VARDESC implements public VARIANT.ByReference lpvarValue; public _VARDESC() { - super(); setType("lpvarValue"); this.read(); } @@ -900,14 +931,12 @@ public _VARDESC(Pointer pointer) { * C type : VARIANT* */ public _VARDESC(VARIANT.ByReference lpvarValue) { - super(); this.lpvarValue = lpvarValue; setType("lpvarValue"); } // / @param oInst [case()] public _VARDESC(NativeLong oInst) { - super(); this.oInst = oInst; setType("oInst"); } @@ -924,9 +953,8 @@ public VARDESC(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays.asList("memid", "lpstrSchema", "_vardesc", - "elemdescVar", "wVarFlags", "varkind"); + protected List getFieldOrder() { + return FIELDS; } } @@ -935,6 +963,7 @@ public static class ByReference extends ELEMDESC implements Structure.ByReference { }; + public static final List FIELDS = createFieldsOrder("tdesc", "_elemdesc"); /** * the type of the element
    * C type : TYPEDESC @@ -991,18 +1020,19 @@ public _ELEMDESC(IDLDESC idldesc) { } }; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "tdesc", "_elemdesc" }); - } - public ELEMDESC() { + super(); } public ELEMDESC(Pointer pointer) { super(pointer); this.read(); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } public static class FUNCKIND extends Structure { @@ -1021,9 +1051,12 @@ public static class ByReference extends FUNCKIND implements // / native declaration : line 24 public static final int FUNC_DISPATCH = FUNC_STATIC + 1; + public static final List FIELDS = createFieldsOrder("value"); + public int value; public FUNCKIND() { + super(); } public FUNCKIND(int value) { @@ -1032,8 +1065,8 @@ public FUNCKIND(int value) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "value" }); + protected List getFieldOrder() { + return FIELDS; } }; @@ -1051,9 +1084,11 @@ public static class ByReference extends INVOKEKIND implements // / native declaration : line 33 public static final INVOKEKIND INVOKE_PROPERTYPUTREF = new INVOKEKIND(8); + public static final List FIELDS = createFieldsOrder("value"); public int value; public INVOKEKIND() { + super(); } public INVOKEKIND(int value) { @@ -1062,8 +1097,8 @@ public INVOKEKIND(int value) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "value" }); + protected List getFieldOrder() { + return FIELDS; } }; @@ -1072,6 +1107,8 @@ public static class ByReference extends CALLCONV implements Structure.ByReference { }; + public static final List FIELDS = createFieldsOrder("value"); + // / native declaration : line 4 public static final int CC_FASTCALL = 0; // / native declaration : line 5 @@ -1106,7 +1143,7 @@ public CALLCONV(int value) { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "value" }); + return FIELDS; } }; @@ -1124,9 +1161,12 @@ public static class ByReference extends VARKIND implements // / native declaration : line 7 public static final int VAR_DISPATCH = VAR_CONST + 1; + public static final List FIELDS = createFieldsOrder("value"); + public int value; public VARKIND() { + super(); } public VARKIND(int value) { @@ -1134,8 +1174,8 @@ public VARKIND(int value) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "value" }); + protected List getFieldOrder() { + return FIELDS; } }; @@ -1144,23 +1184,6 @@ public static class ByReference extends TYPEDESC implements Structure.ByReference { }; - public _TYPEDESC _typedesc; - - public VARTYPE vt; - - public TYPEDESC() { - this.read(); - } - - public TYPEDESC(Pointer pointer) { - super(pointer); - this.read(); - } - - public TYPEDESC(_TYPEDESC _typedesc, VARTYPE vt) { - this._typedesc = _typedesc; - this.vt = vt; - } public static class _TYPEDESC extends Union { /** @@ -1209,8 +1232,27 @@ public HREFTYPE getHreftype() { } }; - protected List getFieldOrder() { - return Arrays.asList("_typedesc", "vt"); + public static final List FIELDS = createFieldsOrder("_typedesc", "vt"); + public _TYPEDESC _typedesc; + public VARTYPE vt; + + public TYPEDESC() { + this.read(); + } + + public TYPEDESC(Pointer pointer) { + super(pointer); + this.read(); + } + + public TYPEDESC(_TYPEDESC _typedesc, VARTYPE vt) { + this._typedesc = _typedesc; + this.vt = vt; + } + + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -1219,6 +1261,7 @@ public static class ByReference extends IDLDESC implements Structure.ByReference { public ByReference() { + super(); } public ByReference(IDLDESC idldesc) { @@ -1226,6 +1269,8 @@ public ByReference(IDLDESC idldesc) { } }; + public static final List FIELDS = createFieldsOrder("dwReserved", "wIDLFlags"); + // / C type : ULONG_PTR public ULONG_PTR dwReserved; public USHORT wIDLFlags; @@ -1241,18 +1286,18 @@ public IDLDESC(Pointer pointer) { // / @param dwReserved C type : ULONG_PTR public IDLDESC(ULONG_PTR dwReserved, USHORT wIDLFlags) { - super(); this.dwReserved = dwReserved; this.wIDLFlags = wIDLFlags; } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwReserved", "wIDLFlags" }); + protected List getFieldOrder() { + return FIELDS; } } public class ARRAYDESC extends Structure { + public static final List FIELDS = createFieldsOrder("tdescElem", "cDims", "rgbounds"); // / C type : TYPEDESC public TYPEDESC tdescElem; public short cDims; @@ -1271,8 +1316,9 @@ public ARRAYDESC(Pointer pointer) { this.read(); } - protected List getFieldOrder() { - return Arrays.asList("tdescElem", "cDims", "rgbounds"); + @Override + protected List getFieldOrder() { + return FIELDS; } /** @@ -1283,9 +1329,7 @@ protected List getFieldOrder() { * [size_is]
    * C type : SAFEARRAYBOUND[1] */ - public ARRAYDESC(TYPEDESC tdescElem, short cDims, - SAFEARRAYBOUND rgbounds[]) { - super(); + public ARRAYDESC(TYPEDESC tdescElem, short cDims, SAFEARRAYBOUND rgbounds[]) { this.tdescElem = tdescElem; this.cDims = cDims; if (rgbounds.length != this.rgbounds.length) @@ -1304,6 +1348,8 @@ public static class ByReference extends PARAMDESC implements Structure.ByReference { }; + public static final List FIELDS = createFieldsOrder("pparamdescex", "wParamFlags"); + // replaced PARAMDESCEX.ByReference with Pointer // because of JNA 4 has a problem with ByReference public Pointer pparamdescex; @@ -1319,9 +1365,8 @@ public PARAMDESC(Pointer pointer) { } @Override - protected List getFieldOrder() { - return Arrays - .asList(new String[] { "pparamdescex", "wParamFlags" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -1330,6 +1375,8 @@ public static class ByReference extends PARAMDESCEX implements Structure.ByReference { }; + public static final List FIELDS = createFieldsOrder("cBytes", "varDefaultValue"); + public ULONG cBytes; public VariantArg varDefaultValue; @@ -1344,11 +1391,13 @@ public PARAMDESCEX(Pointer pointer) { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "cBytes", "varDefaultValue" }); + return FIELDS; } } public static class HREFTYPE extends DWORD { + private static final long serialVersionUID = 1L; + public HREFTYPE() { super(); } @@ -1371,6 +1420,7 @@ public void setValue(HREFTYPE value) { getPointer().setInt(0, value.intValue()); } + @Override public HREFTYPE getValue() { return new HREFTYPE(getPointer().getInt(0)); } @@ -1381,6 +1431,13 @@ public static class ByReference extends TYPEATTR implements Structure.ByReference { }; + public static final List FIELDS = createFieldsOrder("guid", "lcid", "dwReserved", "memidConstructor", + "memidDestructor", "lpstrSchema", "cbSizeInstance", + "typekind", "cFuncs", "cVars", "cImplTypes", + "cbSizeVft", "cbAlignment", "wTypeFlags", + "wMajorVerNum", "wMinorVerNum", "tdescAlias", + "idldescType"); + // / C type : GUID public GUID guid; // / C type : LCID @@ -1417,14 +1474,9 @@ public TYPEATTR(Pointer pointer) { this.read(); } - protected List getFieldOrder() { - return Arrays - .asList("guid", "lcid", "dwReserved", "memidConstructor", - "memidDestructor", "lpstrSchema", "cbSizeInstance", - "typekind", "cFuncs", "cVars", "cImplTypes", - "cbSizeVft", "cbAlignment", "wTypeFlags", - "wMajorVerNum", "wMinorVerNum", "tdescAlias", - "idldescType"); + @Override + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java b/contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java index 6b36dd9332..d602890e87 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java @@ -12,7 +12,6 @@ */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Native; @@ -32,7 +31,6 @@ import com.sun.jna.platform.win32.WinDef.PVOID; import com.sun.jna.platform.win32.WinDef.UINT; import com.sun.jna.platform.win32.WinNT.HRESULT; -import com.sun.jna.platform.win32.COM.TypeLib; import com.sun.jna.ptr.DoubleByReference; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.StdCallLibrary; @@ -41,7 +39,7 @@ // TODO: Auto-generated Javadoc /** * Oleaut32.dll Interface. - * + * * @author scott.palmer */ public interface OleAuto extends StdCallLibrary { @@ -103,7 +101,7 @@ public interface OleAuto extends StdCallLibrary { /** * This function allocates a new string and copies the passed string into * it. - * + * * @param sz * Null-terminated UNICODE string to copy. * @return Null if there is insufficient memory or if a null pointer is @@ -115,7 +113,7 @@ public interface OleAuto extends StdCallLibrary { * This function frees a string allocated previously by SysAllocString, * SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or * SysReAllocStringLen. - * + * * @param bstr * Unicode string that was allocated previously, or NULL. Setting * this parameter to NULL causes the function to simply return. @@ -127,7 +125,7 @@ public interface OleAuto extends StdCallLibrary { * field to VT_EMPTY. Unlike VariantClear, this function does not interpret * the current contents of the VARIANTARG. Use VariantInit to initialize new * local variables of type VARIANTARG (or VARIANT). - * + * * @param pvarg * The variant to initialize. */ @@ -138,7 +136,7 @@ public interface OleAuto extends StdCallLibrary { * field to VT_EMPTY. Unlike VariantClear, this function does not interpret * the current contents of the VARIANTARG. Use VariantInit to initialize new * local variables of type VARIANTARG (or VARIANT). - * + * * @param pvarg * The variant to initialize. */ @@ -149,11 +147,11 @@ public interface OleAuto extends StdCallLibrary { * (pvargDest must point to a valid initialized variant, and not simply to * an uninitialized memory location). Then pvargDest receives an exact copy * of the contents of pvargSrc. - * + * * If pvargSrc is a VT_BSTR, a copy of the string is made. If pvargSrcis a * VT_ARRAY, the entire array is copied. If pvargSrc is a VT_DISPATCH or * VT_UNKNOWN, AddRef is called to increment the object's reference count. - * + * * If the variant to be copied is a COM object that is passed by reference, * the vtfield of the pvargSrcparameter is VT_DISPATCH | VT_BYREF or * VT_UNKNOWN | VT_BYREF. In this case, VariantCopy does not increment the @@ -162,9 +160,9 @@ public interface OleAuto extends StdCallLibrary { * to determine if it is necessary to increment the reference count of the * object. It is therefore the responsibility of the caller to call * IUnknown::AddRef on the object or not, as appropriate. - * + * * Note The VariantCopy method is not threadsafe. - * + * * @param pvargDest * [out] The destination variant. * @param pvargSrc @@ -177,13 +175,13 @@ public interface OleAuto extends StdCallLibrary { * Use this function to clear variables of type VARIANTARG (or VARIANT) * before the memory containing the VARIANTARG is freed (as when a local * variable goes out of scope). - * + * * The function clears a VARIANTARG by setting the vt field to VT_EMPTY. The * current contents of the VARIANTARG are released first. If the vtfield is * VT_BSTR, the string is freed. If the vtfield is VT_DISPATCH, the object * is released. If the vt field has the VT_ARRAY bit set, the array is * freed. - * + * * If the variant to be cleared is a COM object that is passed by reference, * the vtfield of the pvargparameter is VT_DISPATCH | VT_BYREF or VT_UNKNOWN * | VT_BYREF. In this case, VariantClear does not release the object. @@ -191,7 +189,7 @@ public interface OleAuto extends StdCallLibrary { * object, VariantClear has no way to determine if it is necessary to * release the object. It is therefore the responsibility of the caller to * release the object or not, as appropriate. - * + * * In certain cases, it may be preferable to clear a variant in code without * calling VariantClear. For example, you can change the type of a VT_I4 * variant to another type without calling this function. Safearrays of BSTR @@ -200,13 +198,13 @@ public interface OleAuto extends StdCallLibrary { * handled. Safearrays of variant will also have VariantClear called on each * member. Using VariantClear in these cases ensures that code will continue * to work if Automation adds new variant types in the future. - * + * * Do not use VariantClear on unitialized variants; use VariantInit to * initialize a new VARIANTARG or VARIANT. - * + * * Variants containing arrays with outstanding references cannot be cleared. * Attempts to do so will return an HRESULT containing DISP_E_ARRAYISLOCKED. - * + * * @param pvarg * [in, out] The variant to clear. * @return the hresult @@ -216,21 +214,21 @@ public interface OleAuto extends StdCallLibrary { /** * Creates a new array descriptor, allocates and initializes the data for * the array, and returns a pointer to the new array descriptor. - * + * * @param vt * [in] The base type of the array (the VARTYPE of each element * of the array). The VARTYPE is restricted to a subset of the * variant types. Neither the VT_ARRAY nor the VT_BYREF flag can * be set. VT_EMPTY and VT_NULL are not valid base types for the * array. All other types are legal. cDims - * + * * @param cDims * the c dims * @param rgsabound * the rgsabound - * + * * @return Return value - * + * * A safe array descriptor, or null if the array could not be * created. */ @@ -239,7 +237,7 @@ SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims, /** * Stores the data element at the specified location in the array. - * + * * @param psa * [in] An array descriptor created by SafeArrayCreate. * @param idx @@ -249,22 +247,22 @@ SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims, * VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not * require another level of indirection. * @return Return value - * + * * This function can return one of these values. - * + * * S_OK Success. - * + * * DISP_E_BADINDEX The specified index is not valid. - * + * * E_INVALIDARG One of the arguments is not valid. - * + * * E_OUTOFMEMORY Memory could not be allocated for the element. */ HRESULT SafeArrayPutElement(SAFEARRAY psa, long[] idx, VARIANT pv); /** * Retrieves a single element of the array. - * + * * @param psa * [in] An array descriptor created by SafeArrayCreate. * @param rgIndices @@ -273,17 +271,17 @@ SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims, * left-most dimension is stored at rgIndices[psa->cDims - 1]. * @param pv * [out] The element of the array. - * + * * @return Return value - * + * * This function can return one of these values. - * + * * S_OK Success. - * + * * DISP_E_BADINDEX The specified index is not valid. - * + * * E_INVALIDARG One of the arguments is not valid. - * + * * E_OUTOFMEMORY Memory could not be allocated for the element. */ HRESULT SafeArrayGetElement(SAFEARRAY psa, long[] rgIndices, Pointer pv); @@ -291,36 +289,36 @@ SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims, /** * Increments the lock count of an array, and places a pointer to the array * data in pvData of the array descriptor. - * + * * @param psa * [in] An array descriptor created by SafeArrayCreate. - * + * * @return Return value - * + * * This function can return one of these values. - * + * * S_OK Success. - * + * * E_INVALIDARG The argument psa is not valid. - * + * * E_UNEXPECTED The array could not be locked. */ HRESULT SafeArrayLock(SAFEARRAY psa); /** * Decrements the lock count of an array so it can be freed or resized. - * + * * @param psa * [in] An array descriptor created by SafeArrayCreate. - * + * * @return Return value - * + * * This function can return one of these values. - * + * * S_OK Success. - * + * * E_INVALIDARG The argument psa is not valid. - * + * * E_UNEXPECTED The array could not be locked. */ HRESULT SafeArrayUnLock(SAFEARRAY psa); @@ -328,7 +326,7 @@ SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims, /** * Retrieves a pointer to a running object that has been registered with * OLE. - * + * * @param rclsid * [in] The class identifier (CLSID) of the active object from * the OLE registration database. @@ -336,9 +334,9 @@ SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims, * Reserved for future use. Must be null. * @param ppunk * [out] The requested active object. - * + * * @return Return value - * + * * If this function succeeds, it returns S_OK. Otherwise, it returns * an HRESULT error code. */ @@ -355,6 +353,7 @@ public class DISPPARAMS extends Structure { public static class ByReference extends DISPPARAMS implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("rgvarg", "rgdispidNamedArgs", "cArgs", "cNamedArgs"); /** The rgvarg. */ public VariantArg.ByReference rgvarg; @@ -377,7 +376,7 @@ public DISPPARAMS() { /** * Instantiates a new dispparams. - * + * * @param memory * the memory */ @@ -386,21 +385,15 @@ public DISPPARAMS(Pointer memory) { this.read(); } - /* - * (non-Javadoc) - * - * @see com.sun.jna.Structure#getFieldOrder() - */ @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "rgvarg", "rgdispidNamedArgs", - "cArgs", "cNamedArgs" }); + protected List getFieldOrder() { + return FIELDS; } } /** * Uses registry information to load a type library. - * + * * @param rguid * The GUID of the library. * @param wVerMajor @@ -411,24 +404,24 @@ protected List getFieldOrder() { * The national language code of the library. * @param pptlib * The loaded type library. - * + * * This function can return one of these values: S_OK Success. - * + * * E_INVALIDARG One or more of the arguments is not valid. - * + * * E_OUTOFMEMORY Insufficient memory to complete the operation. - * + * * TYPE_E_IOERROR The function could not write to the file. - * + * * TYPE_E_INVALIDSTATE The type library could not be opened. - * + * * TYPE_E_INVDATAREAD The function could not read from the file. - * + * * TYPE_E_UNSUPFORMAT The type library has an older format. - * + * * TYPE_E_UNKNOWNLCID The LCID could not be found in the * OLE-supported DLLs. - * + * * TYPE_E_CANTLOADLIBRARY The type library or DLL could not be * loaded. * @return status @@ -437,50 +430,51 @@ protected List getFieldOrder() { /** * Loads and registers a type library. - * + * * @param szFile * The name of the file from which the method should attempt to * load a type library. - * + * * @param pptlib * The loaded type library. Return value - * + * * This function can return one of these values. - * + * * S_OK Success. - * + * * E_INVALIDARG One or more of the arguments is not valid. - * + * * E_OUTOFMEMORY Insufficient memory to complete the operation. - * + * * TYPE_E_IOERROR The function could not write to the file. - * + * * TYPE_E_INVALIDSTATE The type library could not be opened. - * + * * TYPE_E_INVDATAREAD The function could not read from the file. - * + * * TYPE_E_UNSUPFORMAT The type library has an older format. - * + * * TYPE_E_UNKNOWNLCID The LCID could not be found in the * OLE-supported DLLs. - * + * * TYPE_E_CANTLOADLIBRARY The type library or DLL could not be * loaded. * @return status */ HRESULT LoadTypeLib(String szFile, PointerByReference pptlib); /** @deprecated use the String version */ - HRESULT LoadTypeLib(WString szFile, PointerByReference pptlib); + @Deprecated + HRESULT LoadTypeLib(WString szFile, PointerByReference pptlib); /** * Converts a system time to a variant representation. - * + * * @param lpSystemTime * [in] The system time. - * + * * @param pvtime * [out] The variant time. - * + * * @return The function returns TRUE on success and FALSE otherwise. */ int SystemTimeToVariantTime(SYSTEMTIME lpSystemTime, DoubleByReference pvtime); diff --git a/contrib/platform/src/com/sun/jna/platform/win32/OpenGL32.java b/contrib/platform/src/com/sun/jna/platform/win32/OpenGL32.java index 8b5145750b..f71f2288a6 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/OpenGL32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/OpenGL32.java @@ -1,10 +1,10 @@ /* Copyright (c) 2011 Timothy Wall, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -15,7 +15,6 @@ import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinDef.HDC; -import com.sun.jna.platform.win32.WinDef.HGLRC; import com.sun.jna.win32.StdCallLibrary; /** diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Pdh.java b/contrib/platform/src/com/sun/jna/platform/win32/Pdh.java index ad22a021f3..61a8733d52 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Pdh.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Pdh.java @@ -12,7 +12,6 @@ */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Native; @@ -47,7 +46,7 @@ public interface Pdh extends StdCallLibrary { * LPVOID CALLBACK AllocateMemory(_In_ SIZE_T AllocSize,_In_ LPVOID pContext) * void CALLBACK FreeMemory(LPVOID pBuffer,LPVOID pContext) */ - + /** * Connects to the specified computer. * @param szMachineName The name of the computer to connect to. If @@ -84,7 +83,7 @@ public interface Pdh extends StdCallLibrary { * @see PdhOpenQuery */ int PdhOpenQuery(String szDataSource, DWORD_PTR dwUserData, HANDLEByReference phQuery); - + /** * Closes all counters contained in the specified query, closes all * handles related to the query, and frees all memory associated with @@ -101,6 +100,10 @@ public interface Pdh extends StdCallLibrary { * @see Windows Server 2003 Performance Counters Reference */ public class PDH_COUNTER_PATH_ELEMENTS extends Structure { + public static final List FIELDS = createFieldsOrder( + "szMachineName", "szObjectName", "szInstanceName", + "szParentInstance", "dwInstanceIndex", "szCounterName"); + public String szMachineName; public String szObjectName; public String szInstanceName; @@ -110,8 +113,7 @@ public class PDH_COUNTER_PATH_ELEMENTS extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList("szMachineName", "szObjectName", "szInstanceName", - "szParentInstance", "dwInstanceIndex", "szCounterName"); + return FIELDS; } } @@ -131,7 +133,7 @@ protected List getFieldOrder() { * zero on input, the function returns PDH_MORE_DATA and sets this parameter * to the required buffer size. If the buffer is larger than the required * size, the function sets this parameter to the actual size of the buffer - * that was used. + * that was used. * @param dwFlags Format of the input and output counter values. * @return ERROR_SUCCESS (or PDH_MORE_DATA) * @see PdhMakeCounterPath @@ -166,6 +168,8 @@ protected List getFieldOrder() { * @see PDH_RAW_COUNTER */ public class PDH_RAW_COUNTER extends Structure { + public static final List FIELDS = createFieldsOrder("CStatus", "TimeStamp", "FirstValue", "SecondValue", "MultiCount"); + /** Counter status that indicates if the counter value is valid. */ public int CStatus; /** Local time for when the data was collected */ @@ -183,7 +187,7 @@ public class PDH_RAW_COUNTER extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList("CStatus", "TimeStamp", "FirstValue", "SecondValue", "MultiCount"); + return FIELDS; } } @@ -226,7 +230,7 @@ protected List getFieldOrder() { * @see PdhCollectQueryData */ int PdhCollectQueryData(HANDLE hQuery); - + /** * Uses a separate thread to collect the current raw data value for all counters * in the specified query. The function then signals the application-defined @@ -241,7 +245,7 @@ protected List getFieldOrder() { * @see PdhCollectQueryDataEx */ int PdhCollectQueryDataEx(HANDLE hQuery, int dwIntervalTime, HANDLE hNewDataEvent); - + /** * Collects the current raw data value for all counters in the specified * query and updates the status code of each counter. @@ -252,27 +256,29 @@ protected List getFieldOrder() { * @see PdhCollectQueryDataWithTime */ int PdhCollectQueryDataWithTime(HANDLE hQuery, LONGLONGByReference pllTimeStamp); - + /** * Information on time intervals as applied to the sampling of performance data. * @see PDH_TIME_INFO */ public class PDH_TIME_INFO extends Structure { + public static final List FIELDS = createFieldsOrder("StartTime", "EndTime", "SampleCount"); /** Starting time of the sample interval, in local FILETIME format. */ public long StartTime; /** Ending time of the sample interval, in local FILETIME format. */ public long EndTime; /** Number of samples collected during the interval. */ public int SampleCount; - + + @Override protected List getFieldOrder() { - return Arrays.asList("StartTime", "EndTime", "SampleCount"); + return FIELDS; } } - + /** - * @param hQuery Handle to the query. - * @param pInfo A {@link PDH_TIME_INFO} structure that specifies the time range. + * @param hQuery Handle to the query. + * @param pInfo A {@link PDH_TIME_INFO} structure that specifies the time range. * @return ERROR_SUCCESS if successful * @see PdhSetQueryTimeRange */ diff --git a/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java index bd129357d9..602b0ec7a1 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/PhysicalMonitorEnumerationAPI.java @@ -16,7 +16,6 @@ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Structure; @@ -40,14 +39,14 @@ public interface PhysicalMonitorEnumerationAPI final int PHYSICAL_MONITOR_DESCRIPTION_SIZE = 128; /****************************************************************************** - Physical Monitor Structures + Physical Monitor Structures ******************************************************************************/ /** * Contains a handle and text description corresponding to a physical monitor. */ - public class PHYSICAL_MONITOR extends Structure - { + public class PHYSICAL_MONITOR extends Structure { + public static final List FIELDS = createFieldsOrder("hPhysicalMonitor", "szPhysicalMonitorDescription"); /** * Handle to the physical monitor. */ @@ -59,9 +58,8 @@ public class PHYSICAL_MONITOR extends Structure public char[] szPhysicalMonitorDescription = new char[PHYSICAL_MONITOR_DESCRIPTION_SIZE]; @Override - protected List getFieldOrder() - { - return Arrays.asList("hPhysicalMonitor", "szPhysicalMonitorDescription"); + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Psapi.java b/contrib/platform/src/com/sun/jna/platform/win32/Psapi.java index 72a21368ae..8a0bd0139c 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Psapi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Psapi.java @@ -1,18 +1,17 @@ /* Copyright (c) 2015 Andreas "PAX" L\u00FCck, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Native; @@ -28,16 +27,16 @@ * The process status application programming interface (PSAPI) is a helper * library that makes it easier for you to obtain information about processes * and device drivers. - * + * * @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de */ public interface Psapi extends StdCallLibrary { Psapi INSTANCE = Native.loadLibrary("psapi", Psapi.class, W32APIOptions.DEFAULT_OPTIONS); - + /** * Retrieves the fully qualified path for the file containing the specified * module. - * + * * @param process * A handle to the process that contains the module. * @param module @@ -57,11 +56,11 @@ public interface Psapi extends StdCallLibrary { * {@link Kernel32Util#getLastErrorMessage()}. */ int GetModuleFileNameExA(HANDLE process, HANDLE module, byte[] lpFilename, int nSize); - + /** * Retrieves the fully qualified path for the file containing the specified * module. - * + * * @param process * A handle to the process that contains the module. * @param module @@ -85,7 +84,7 @@ public interface Psapi extends StdCallLibrary { /** * Retrieves the fully qualified path for the file containing the specified * module. - * + * * @param process * A handle to the process that contains the module. * @param module @@ -105,9 +104,9 @@ public interface Psapi extends StdCallLibrary { * {@link Kernel32Util#getLastErrorMessage()}. */ int GetModuleFileNameEx(HANDLE process, HANDLE module, Pointer lpFilename, int nSize); - + /** - * + * * The EnumProcessModules function is primarily designed for use by * debuggers and similar applications that must extract module information * from another process.
    @@ -154,7 +153,7 @@ public interface Psapi extends StdCallLibrary { * To ensure correct resolution of symbols, add Psapi.lib to the TARGETLIBS * macro and compile the program with -DPSAPI_VERSION=1.
    * To use run-time dynamic linking, load Psapi.dll. - * + * * @param hProcess * A handle to the process. * @param lphModule @@ -170,7 +169,7 @@ public interface Psapi extends StdCallLibrary { * @see MSDN/a> */ boolean EnumProcessModules(HANDLE hProcess, HMODULE[] lphModule, int cb, IntByReference lpcbNeeded); - + /** * To get information for the calling process, pass the handle returned by * GetCurrentProcess.
    @@ -193,7 +192,7 @@ public interface Psapi extends StdCallLibrary { * To ensure correct resolution of symbols, add Psapi.lib to the TARGETLIBS * macro and compile the program with -DPSAPI_VERSION=1.
    * To use run-time dynamic linking, load Psapi.dll. - * + * * @param hProcess * A handle to the process that contains the module. The handle * must have the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ @@ -201,7 +200,7 @@ public interface Psapi extends StdCallLibrary { * Access Rights. * @param hModule * A handle to the module. - * + * * @param lpmodinfo * A pointer to the MODULEINFO structure that receives * information about the module. @@ -213,7 +212,7 @@ public interface Psapi extends StdCallLibrary { * @see
    MSDN */ boolean GetModuleInformation(HANDLE hProcess, HMODULE hModule, MODULEINFO lpmodinfo, int cb); - + /** * @param hProcess * A handle to the process. The handle must have the @@ -236,13 +235,15 @@ public interface Psapi extends StdCallLibrary { int GetProcessImageFileName(HANDLE hProcess, char[] lpImageFileName, int nSize); class MODULEINFO extends Structure { + public static final List FIELDS = createFieldsOrder("lpBaseOfDll", "SizeOfImage", "EntryPoint"); + public Pointer EntryPoint; public Pointer lpBaseOfDll; public int SizeOfImage; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "lpBaseOfDll", "SizeOfImage", "EntryPoint" }); + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/SetupApi.java b/contrib/platform/src/com/sun/jna/platform/win32/SetupApi.java index 8ffd701bb0..f5ab082ce5 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/SetupApi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/SetupApi.java @@ -10,7 +10,6 @@ */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Native; @@ -36,14 +35,14 @@ public interface SetupApi extends StdCallLibrary { */ GUID GUID_DEVINTERFACE_DISK = new GUID("53F56307-B6BF-11D0-94F2-00A0C91EFB8B"); - + /** * Drivers for serial ports register instances of this device interface * class to notify the operating system and applications of the presence of * COM ports. */ GUID GUID_DEVINTERFACE_COMPORT = new GUID("86E0D1E0-8089-11D0-9CE4-08003E301F73"); - + /** * Return only the device that is associated with the system default device interface, if one is set, for the * specified device interface classes. @@ -91,21 +90,21 @@ public interface SetupApi extends StdCallLibrary { /** * Open/Create/Delete device key. - * + * * @see #SetupDiOpenDevRegKey */ int DIREG_DEV = 0x00000001; /** * Open/Create/Delete driver key - * + * * @see #SetupDiOpenDevRegKey */ int DIREG_DRV = 0x00000002; /** * Delete both driver and Device key - * + * * @see #SetupDiOpenDevRegKey */ int DIREG_BOTH = 0x00000004; @@ -297,7 +296,7 @@ boolean SetupDiGetDeviceRegistryProperty(HANDLE DeviceInfoSet, SP_DEVINFO_DATA D * The specified device instance must be registered before this function is called. However, be aware that the * operating system automatically registers PnP device instances. For information about how to register non-PnP * device instances, see SetupDiRegisterDeviceInfo. - * + * * @param deviceInfoSet * A handle to the device information set that contains a device information element that represents the * device for which to open a registry key. @@ -355,8 +354,8 @@ boolean SetupDiGetDeviceRegistryProperty(HANDLE DeviceInfoSet, SP_DEVINFO_DATA D *

    * Call SetupDiEnumDeviceInterfaces to get a context structure for a device interface element (versus a device * information element). - * - * + * + * * @param deviceInfoSet * A handle to the device information set for which to return an {@link SP_DEVINFO_DATA} structure that * represents a device information element. @@ -384,14 +383,7 @@ public ByReference(Pointer memory) { } } - public SP_DEVICE_INTERFACE_DATA() { - cbSize = size(); - } - - public SP_DEVICE_INTERFACE_DATA(Pointer memory) { - super(memory); - read(); - } + public static final List FIELDS = createFieldsOrder("cbSize", "InterfaceClassGuid", "Flags", "Reserved"); /** * The size, in bytes, of the SP_DEVICE_INTERFACE_DATA structure. @@ -415,9 +407,19 @@ public SP_DEVICE_INTERFACE_DATA(Pointer memory) { * Reserved. Do not use. */ public Pointer Reserved; - + + public SP_DEVICE_INTERFACE_DATA() { + cbSize = size(); + } + + public SP_DEVICE_INTERFACE_DATA(Pointer memory) { + super(memory); + read(); + } + + @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "cbSize", "InterfaceClassGuid", "Flags", "Reserved" }); + return FIELDS; } } @@ -435,14 +437,7 @@ public ByReference(Pointer memory) { } } - public SP_DEVINFO_DATA() { - cbSize = size(); - } - - public SP_DEVINFO_DATA(Pointer memory) { - super(memory); - read(); - } + public static final List FIELDS = createFieldsOrder("cbSize", "InterfaceClassGuid", "DevInst", "Reserved"); /** * The size, in bytes, of the SP_DEVINFO_DATA structure. @@ -467,9 +462,19 @@ public SP_DEVINFO_DATA(Pointer memory) { * Reserved. For internal use only. */ public Pointer Reserved; - + + public SP_DEVINFO_DATA() { + cbSize = size(); + } + + public SP_DEVINFO_DATA(Pointer memory) { + super(memory); + read(); + } + + @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "cbSize", "InterfaceClassGuid", "DevInst", "Reserved" }); + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Shell32Util.java b/contrib/platform/src/com/sun/jna/platform/win32/Shell32Util.java index 4f556c5c69..107c91968f 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Shell32Util.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Shell32Util.java @@ -1,14 +1,14 @@ /* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; @@ -16,7 +16,6 @@ import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.HWND; -import com.sun.jna.platform.win32.WinDef.LPVOID; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HRESULT; import com.sun.jna.ptr.PointerByReference; @@ -27,7 +26,7 @@ * @author markus[at]headcrashing[dot]eu */ public abstract class Shell32Util { - + /** * Get a special folder path. * @param hwnd @@ -41,15 +40,15 @@ public abstract class Shell32Util { */ public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) { char[] pszPath = new char[WinDef.MAX_PATH]; - HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd, - nFolder, null, dwFlags, + HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd, + nFolder, null, dwFlags, pszPath); if (! hr.equals(W32Errors.S_OK)) { throw new Win32Exception(hr); } return Native.toString(pszPath); } - + /** * Get a special folder path. * @param nFolder @@ -60,9 +59,9 @@ public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) { public static String getFolderPath(int nFolder) { return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT); } - + /** - * Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. This function replaces + * Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. This function replaces * {@link #getFolderPath}. That older function is now simply a wrapper for getKnownFolderPath * @param guid the KNOWNFOLDERS GUID as defined in {@link KnownFolders} * @return the path of the known folder. The returned path does not include a trailing backslash. For example, diff --git a/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java index 2495c97ee3..9f159450f7 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java @@ -1,18 +1,17 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Platform; @@ -39,12 +38,12 @@ public interface ShellAPI extends StdCallLibrary { int STRUCTURE_ALIGNMENT = Platform.is64Bit() ? Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE; TypeMapper TYPE_MAPPER = Boolean.getBoolean("w32.ascii") ? W32APITypeMapper.ASCII : W32APITypeMapper.UNICODE; - + int FO_MOVE = 0x0001; int FO_COPY = 0x0002; int FO_DELETE = 0x0003; int FO_RENAME = 0x0004; - + int FOF_MULTIDESTFILES = 0x0001; int FOF_CONFIRMMOUSE = 0x0002; int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still) @@ -62,18 +61,21 @@ public interface ShellAPI extends StdCallLibrary { int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION) int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts) int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all - + int PO_DELETE = 0x0013; // printer is being deleted int PO_RENAME = 0x0014; // printer is being renamed int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time. /** - * Contains information that the SHFileOperation function uses to perform file operations. + * Contains information that the SHFileOperation function uses to perform file operations. */ public static class SHFILEOPSTRUCT extends Structure { + public static final List FIELDS = createFieldsOrder( + "hwnd", "wFunc", "pFrom", "pTo", "fFlags", "fAnyOperationsAborted", "pNameMappings", "lpszProgressTitle"); + /** - * A window handle to the dialog box to display information about + * A window handle to the dialog box to display information about * the status of the file operation. */ public HANDLE hwnd; @@ -82,7 +84,7 @@ public static class SHFILEOPSTRUCT extends Structure { */ public int wFunc; /** - * A pointer to one or more source file names, double null-terminated. + * A pointer to one or more source file names, double null-terminated. */ public String pFrom; /** @@ -94,25 +96,26 @@ public static class SHFILEOPSTRUCT extends Structure { */ public short fFlags; /** - * When the function returns, this member contains TRUE if any file operations - * were aborted before they were completed; otherwise, FALSE. An operation can - * be manually aborted by the user through UI or it can be silently aborted by + * When the function returns, this member contains TRUE if any file operations + * were aborted before they were completed; otherwise, FALSE. An operation can + * be manually aborted by the user through UI or it can be silently aborted by * the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set. */ public boolean fAnyOperationsAborted; /** - * When the function returns, this member contains a handle to a name mapping - * object that contains the old and new names of the renamed files. This member - * is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. + * When the function returns, this member contains a handle to a name mapping + * object that contains the old and new names of the renamed files. This member + * is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. */ public Pointer pNameMappings; /** - * A pointer to the title of a progress dialog box. This is a null-terminated string. + * A pointer to the title of a progress dialog box. This is a null-terminated string. */ public String lpszProgressTitle; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "hwnd", "wFunc", "pFrom", "pTo", "fFlags", "fAnyOperationsAborted", "pNameMappings", "lpszProgressTitle" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } /** Use this to encode pFrom/pTo paths. @@ -127,11 +130,9 @@ public String encodePaths(String[] paths) { } return encoded + "\0"; } - - } - - /** + + /** * Appbar message value to send. This parameter can be one of the following * values. */ @@ -178,11 +179,11 @@ public String encodePaths(String[] paths) { /** Left edge. */ int ABE_LEFT = 0; /** Top edge. */ - int ABE_TOP = 1; + int ABE_TOP = 1; /** Right edge. */ - int ABE_RIGHT = 2; + int ABE_RIGHT = 2; /** Bottom edge. */ - int ABE_BOTTOM = 3; + int ABE_BOTTOM = 3; /** * Contains information about a system appbar message. @@ -191,6 +192,8 @@ public static class APPBARDATA extends Structure { public static class ByReference extends APPBARDATA implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("cbSize", "hWnd", "uCallbackMessage", "uEdge", "rc", "lParam"); + public DWORD cbSize; public HWND hWnd; public UINT uCallbackMessage; @@ -207,8 +210,8 @@ public APPBARDATA(Pointer p) { } @Override - protected List getFieldOrder() { - return Arrays.asList("cbSize", "hWnd", "uCallbackMessage", "uEdge", "rc", "lParam"); + protected List getFieldOrder() { + return FIELDS; } } @@ -218,7 +221,7 @@ protected List getFieldOrder() { * "https://msdn.microsoft.com/en-us/library/windows/desktop/bb762154(v=vs.85).aspx"> * ShellExecuteEx. *

    - * + * *
     	 * typedef struct _SHELLEXECUTEINFO {
     	 *   DWORD     cbSize;
    @@ -241,7 +244,7 @@ protected List getFieldOrder() {
     	 *   HANDLE    hProcess;
     	 * } SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
     	 * 
    - * + * *

    Remarks

    *

    * The SEE_MASK_NOASYNC flag must be specified if the @@ -294,11 +297,11 @@ protected List getFieldOrder() { * >Copy *

    - * + * *
     	 * sei.lpParameters = "An example: \"\"\"quoted text\"\"\"";
     	 * 
    - * + * *
    *

    * In this case, the application receives three parameters: An, @@ -306,7 +309,9 @@ protected List getFieldOrder() { *

    */ public class SHELLEXECUTEINFO extends Structure { - + public static final List FIELDS = createFieldsOrder("cbSize", "fMask", "hwnd", "lpVerb", "lpFile", "lpParameters", + "lpDirectory", "nShow", "hInstApp", "lpIDList", "lpClass", "hKeyClass", "dwHotKey", "hMonitor", + "hProcess"); /** *

    * Type: DWORD @@ -316,7 +321,7 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public int cbSize = size(); - + /** *

    * Type: ULONG @@ -611,7 +616,7 @@ public class SHELLEXECUTEINFO extends Structure { * */ public int fMask; - + /** *

    * Type: HWND @@ -623,7 +628,7 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public HWND hwnd; - + /** *

    * Type: LPCTSTR @@ -709,7 +714,7 @@ public class SHELLEXECUTEINFO extends Structure { * */ public String lpVerb; - + /** *

    * Type: LPCTSTR @@ -737,7 +742,7 @@ public class SHELLEXECUTEINFO extends Structure { * included with the name, the current directory is assumed. */ public String lpFile; - + /** *

    * Type: LPCTSTR @@ -750,7 +755,7 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public String lpParameters; - + /** *

    * Type: LPCTSTR @@ -763,7 +768,7 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public String lpDirectory; - + /** *

    * Type: int @@ -779,7 +784,7 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public int nShow; - + /** *

    * Type: HINSTANCE @@ -907,7 +912,7 @@ public class SHELLEXECUTEINFO extends Structure { * */ public HINSTANCE hInstApp; - + /** *

    * Type: LPVOID @@ -924,12 +929,12 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public Pointer lpIDList; - + /** *

    * Type: LPCTSTR *

    - * + * *

    * The address of a null-terminated string that specifies one of the * following: @@ -952,7 +957,7 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public String lpClass; - + /** *

    * Type: HKEY @@ -965,7 +970,7 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public HKEY hKeyClass; - + /** *

    * Type: DWORD @@ -982,14 +987,14 @@ public class SHELLEXECUTEINFO extends Structure { *

    */ public int dwHotKey; - + /** * This is actually a union: - * + * *
     		 * union { HANDLE hIcon; HANDLE hMonitor; } DUMMYUNIONNAME;
     		 * 
    - * + * * DUMMYUNIONNAME *
    *
    hIcon
    @@ -1022,7 +1027,7 @@ public class SHELLEXECUTEINFO extends Structure { *
    */ public HANDLE hMonitor; - + /** *

    * Type: HANDLE @@ -1052,11 +1057,10 @@ public class SHELLEXECUTEINFO extends Structure { * . */ public HANDLE hProcess; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "cbSize", "fMask", "hwnd", "lpVerb", "lpFile", "lpParameters", - "lpDirectory", "nShow", "hInstApp", "lpIDList", "lpClass", "hKeyClass", "dwHotKey", "hMonitor", - "hProcess", }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java b/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java index b249ce2f0c..be8ea16902 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java @@ -1,18 +1,17 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Memory; @@ -34,9 +33,9 @@ public interface Sspi { // Flags for the fCredentialUse parameter of AcquireCredentialsHandle /** - * Validate an incoming server credential. Inbound credentials might be validated + * Validate an incoming server credential. Inbound credentials might be validated * by using an authenticating authority when InitializeSecurityContext or - * AcceptSecurityContext is called. If such an authority is not available, the function will + * AcceptSecurityContext is called. If such an authority is not available, the function will * fail and return SEC_E_NO_AUTHENTICATING_AUTHORITY. Validation is package specific. */ int SECPKG_CRED_INBOUND = 1; @@ -46,11 +45,11 @@ public interface Sspi { */ int SECPKG_CRED_OUTBOUND = 2; - + // Flags for the TargetDataRep parameter of AcceptSecurityContext and InitializeSecurityContext /** - * Specifies Native data representation. + * Specifies Native data representation. */ int SECURITY_NATIVE_DREP = 0x10; @@ -58,7 +57,7 @@ public interface Sspi { // Flags for the fContextReq parameter of InitializeSecurityContext or AcceptSecurityContext. /** - * The security package allocates output buffers for you. + * The security package allocates output buffers for you. * When you have finished using the output buffers, free them by calling the FreeContextBuffer function. */ int ISC_REQ_ALLOCATE_MEMORY = 0x00000100; @@ -74,8 +73,8 @@ public interface Sspi { int ISC_REQ_CONNECTION = 0x00000800; /** - * The server can use the context to authenticate to other servers as the client. - * The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos. + * The server can use the context to authenticate to other servers as the client. + * The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos. * Ignore this flag for constrained delegation. */ int ISC_REQ_DELEGATE = 0x00000001; @@ -96,7 +95,7 @@ public interface Sspi { int ISC_REQ_MUTUAL_AUTH = 0x00000002; /** - * Detect replayed messages that have been encoded by using the + * Detect replayed messages that have been encoded by using the * EncryptMessage or MakeSignature functions. */ int ISC_REQ_REPLAY_DETECT = 0x00000004; @@ -126,31 +125,31 @@ public interface Sspi { */ int SECBUFFER_DATA = 1; /** - * This buffer type is used to indicate the security token portion of the message. + * This buffer type is used to indicate the security token portion of the message. * This is read-only for input parameters or read/write for output parameters. */ int SECBUFFER_TOKEN = 2; - + /** * Security handle. */ - public static class SecHandle extends Structure { - public Pointer dwLower; - public Pointer dwUpper; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwLower", "dwUpper" }); - } + public static class SecHandle extends Structure { public static class ByReference extends SecHandle implements Structure.ByReference { } - + + public static final List FIELDS = createFieldsOrder("dwLower", "dwUpper"); + + public Pointer dwLower; + public Pointer dwUpper; + /** * An empty SecHandle. */ public SecHandle() { + super(); } - + /** * Returns true if the handle is NULL. * @return @@ -159,6 +158,11 @@ public SecHandle() { public boolean isNull() { return dwLower == null && dwUpper == null; } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } /** @@ -168,43 +172,46 @@ public static class PSecHandle extends Structure { public static class ByReference extends PSecHandle implements Structure.ByReference { } - + + public static final List FIELDS = createFieldsOrder("secHandle"); /** * The first entry in an array of SecPkgInfo structures. */ public SecHandle.ByReference secHandle; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "secHandle" }); - } - + public PSecHandle() { + super(); } public PSecHandle(SecHandle h) { super(h.getPointer()); read(); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } - + /** * Credentials handle. */ - public static class CredHandle extends SecHandle { + public static class CredHandle extends SecHandle { } - + /** * Security context handle. */ - public static class CtxtHandle extends SecHandle { + public static class CtxtHandle extends SecHandle { } /** - * The SecBuffer structure describes a buffer allocated by a transport application + * The SecBuffer structure describes a buffer allocated by a transport application * to pass to a security package. */ public static class SecBuffer extends Structure { - + /** * A ByReference SecBuffer. */ @@ -214,7 +221,7 @@ public static class ByReference extends SecBuffer implements Structure.ByReferen */ public ByReference() { } - + /** * Create a SecBuffer of a given type and size. * @param type @@ -230,13 +237,14 @@ public ByReference(int type, byte[] token) { super(type, token); } } - + + public static final List FIELDS = createFieldsOrder("cbBuffer", "BufferType", "pvBuffer"); /** * Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member. */ public int cbBuffer; /** - * Bit flags that indicate the type of buffer. Must be one of the values of + * Bit flags that indicate the type of buffer. Must be one of the values of * the SecBufferType enumeration. */ public int BufferType = SECBUFFER_EMPTY; @@ -244,17 +252,14 @@ public ByReference(int type, byte[] token) { * A pointer to a buffer. */ public Pointer pvBuffer; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "cbBuffer", "BufferType", "pvBuffer" }); - } - + /** * Create a new SECBUFFER_EMPTY buffer. */ public SecBuffer() { + super(); } - + /** * Create a SecBuffer of a given type and size. * @param type @@ -263,11 +268,11 @@ public SecBuffer() { * Buffer size, eg. MAX_TOKEN_SIZE. */ public SecBuffer(int type, int size) { - cbBuffer = size; + cbBuffer = size; pvBuffer = new Memory(size); BufferType = type; } - + /** * Create a SecBuffer of a given type with initial data. * @param type @@ -276,12 +281,12 @@ public SecBuffer(int type, int size) { * Existing token. */ public SecBuffer(int type, byte[] token) { - cbBuffer = token.length; + cbBuffer = token.length; pvBuffer = new Memory(token.length); pvBuffer.write(0, token, 0, token.length); BufferType = type; } - + /** * Get buffer bytes. * @return @@ -290,10 +295,15 @@ public SecBuffer(int type, byte[] token) { public byte[] getBytes() { return pvBuffer == null ? null : pvBuffer.getByteArray(0, cbBuffer); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } public static class SecBufferDesc extends Structure { - + public static final List FIELDS = createFieldsOrder("ulVersion", "cBuffers", "pBuffers"); /** * Version number. */ @@ -309,27 +319,22 @@ public static class SecBufferDesc extends Structure { new SecBuffer.ByReference() }; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "ulVersion", "cBuffers", "pBuffers" }); - } - /** * Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer. */ public SecBufferDesc() { + super(); } - + /** * Create a new SecBufferDesc with initial data. - * @param type - * Token type. - * @param token - * Initial token data. + * @param type Token type. + * @param token Initial token data. */ public SecBufferDesc(int type, byte[] token) { pBuffers[0] = new SecBuffer.ByReference(type, token); } - + /** * Create a new SecBufferDesc with one SecBuffer of a given type and size. * @param type type @@ -337,37 +342,38 @@ public SecBufferDesc(int type, byte[] token) { */ public SecBufferDesc(int type, int tokenSize) { pBuffers[0] = new SecBuffer.ByReference(type, tokenSize); - } - + } + public byte[] getBytes() { return pBuffers[0].getBytes(); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } - + /** * A security integer. */ public static class SECURITY_INTEGER extends Structure { + public static final List FIELDS = createFieldsOrder("dwLower", "dwUpper"); public int dwLower; public int dwUpper; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwLower", "dwUpper" }); - } - /** - * An security integer of 0. - */ - public SECURITY_INTEGER() { + @Override + protected List getFieldOrder() { + return FIELDS; } } - + /** * A timestamp. */ public static class TimeStamp extends SECURITY_INTEGER { } - + /** * A pointer to an array of SecPkgInfo structures. */ @@ -376,29 +382,34 @@ public static class PSecPkgInfo extends Structure { public static class ByReference extends PSecPkgInfo implements Structure.ByReference { } - + + public static final List FIELDS = createFieldsOrder("pPkgInfo"); + /** * The first entry in an array of SecPkgInfo structures. */ public SecPkgInfo.ByReference pPkgInfo; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "pPkgInfo" }); - } - + public PSecPkgInfo() { + super(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } - + /** * An array of SecPkgInfo structures. */ + @Override public SecPkgInfo.ByReference[] toArray(int size) { return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size); } } - + /** - * The SecPkgInfo structure provides general information about a security package, + * The SecPkgInfo structure provides general information about a security package, * such as its name and capabilities. */ public static class SecPkgInfo extends Structure { @@ -406,24 +417,27 @@ public static class SecPkgInfo extends Structure { /** * A reference pointer to a SecPkgInfo structure. */ - public static class ByReference extends SecPkgInfo implements Structure.ByReference { + public static class ByReference extends SecPkgInfo implements Structure.ByReference { } - + + public static final List FIELDS = createFieldsOrder( + "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment"); + /** * Set of bit flags that describes the capabilities of the security package. */ - public int fCapabilities; + public int fCapabilities; /** - * Specifies the version of the package protocol. Must be 1. + * Specifies the version of the package protocol. Must be 1. */ public short wVersion = 1; /** - * Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of - * the DCE registered security systems, the reserved value SECPKG_ID_NONE is used. + * Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of + * the DCE registered security systems, the reserved value SECPKG_ID_NONE is used. */ public short wRPCID; /** - * Specifies the maximum size, in bytes, of the token. + * Specifies the maximum size, in bytes, of the token. */ public int cbMaxToken; /** @@ -431,19 +445,14 @@ public static class ByReference extends SecPkgInfo implements Structure.ByRefere */ public String Name; /** - * Pointer to a null-terminated string. This can be any additional string passed - * back by the package. + * Pointer to a null-terminated string. This can be any additional string passed + * back by the package. */ public String Comment; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment" }); - } - /** - * Create a new package info. - */ - public SecPkgInfo() { + @Override + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java b/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java index 1821d271fd..9e258fa4ea 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java @@ -10,7 +10,6 @@ */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Native; @@ -92,14 +91,9 @@ public ByReference(Pointer memory) { } } - public PROCESSENTRY32() { - dwSize = new WinDef.DWORD(size()); - } - - public PROCESSENTRY32(Pointer memory) { - super(memory); - read(); - } + public static final List FIELDS = createFieldsOrder( + "dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", + "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile"); /** * The size of the structure, in bytes. Before calling the Process32First function, set this member to @@ -155,113 +149,125 @@ public PROCESSENTRY32(Pointer memory) { */ public char[] szExeFile = new char[WinDef.MAX_PATH]; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile" }); + public PROCESSENTRY32() { + dwSize = new WinDef.DWORD(size()); + } + + public PROCESSENTRY32(Pointer memory) { + super(memory); + read(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } } - /** * Describes an entry from a list of the modules belonging to the specified * process. - * + * * @see MSDN */ public class MODULEENTRY32W extends Structure { - + /** * A representation of a MODULEENTRY32 structure as a reference */ public static class ByReference extends MODULEENTRY32W implements Structure.ByReference { public ByReference() { } - + public ByReference(Pointer memory) { super(memory); } } - - public MODULEENTRY32W() { - dwSize = new WinDef.DWORD(size()); - } - - public MODULEENTRY32W(Pointer memory) { - super(memory); - read(); - } - + + public static final List FIELDS = createFieldsOrder( + "dwSize", "th32ModuleID", "th32ProcessID", "GlblcntUsage", + "ProccntUsage", "modBaseAddr", "modBaseSize", "hModule", "szModule", "szExePath"); + /** * The size of the structure, in bytes. Before calling the Module32First * function, set this member to sizeof(MODULEENTRY32). If you do not * initialize dwSize, Module32First fails. */ public DWORD dwSize; - + /** * This member is no longer used, and is always set to one. */ public DWORD th32ModuleID; - + /** * The identifier of the process whose modules are to be examined. */ public DWORD th32ProcessID; - + /** * The load count of the module, which is not generally meaningful, and * usually equal to 0xFFFF. */ public DWORD GlblcntUsage; - + /** * The load count of the module (same as GlblcntUsage), which is not * generally meaningful, and usually equal to 0xFFFF. */ public DWORD ProccntUsage; - + /** * The base address of the module in the context of the owning process. */ public Pointer modBaseAddr; - + /** * The size of the module, in bytes. */ public DWORD modBaseSize; - + /** * A handle to the module in the context of the owning process. */ public HMODULE hModule; - + /** * The module name. */ public char[] szModule = new char[MAX_MODULE_NAME32 + 1]; - + /** * The module path. */ public char[] szExePath = new char[Kernel32.MAX_PATH]; - + + public MODULEENTRY32W() { + dwSize = new WinDef.DWORD(size()); + } + + public MODULEENTRY32W(Pointer memory) { + super(memory); + read(); + } + /** * @return The module name. */ public String szModule() { return Native.toString(this.szModule); } - + /** * @return The module path. */ public String szExePath() { return Native.toString(this.szExePath); } - + @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwSize", "th32ModuleID", "th32ProcessID", "GlblcntUsage", - "ProccntUsage", "modBaseAddr", "modBaseSize", "hModule", "szModule", "szExePath" }); + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/User32.java b/contrib/platform/src/com/sun/jna/platform/win32/User32.java index cf26621c5c..9798c65aca 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/User32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/User32.java @@ -15,7 +15,6 @@ import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; import com.sun.jna.platform.win32.WinGDI.ICONINFO; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.IntByReference; @@ -69,7 +68,7 @@ public interface User32 extends StdCallLibrary, WinUser, WinNT { *

    */ int SW_SHOWDEFAULT = 10; - + /** * This function retrieves a handle to a display device context (DC) for the * client area of the specified window. The display device context can be @@ -1297,8 +1296,6 @@ boolean SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, * error information, call {@link Kernel32#GetLastError}. */ boolean UnregisterClass(String lpClassName, HINSTANCE hInstance); - /** @deprecated use the String version */ - boolean UnregisterClass(WString lpClassName, HINSTANCE hInstance); /** * Creates an overlapped, pop-up, or child window with an extended window @@ -1470,11 +1467,6 @@ HWND CreateWindowEx(int dwExStyle, String lpClassName, String lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam); - /** @deprecated use the String version */ - HWND CreateWindowEx(int dwExStyle, WString lpClassName, - String lpWindowName, int dwStyle, int x, int y, int nWidth, - int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, - LPVOID lpParam); /** * Destroys the specified window. The function sends WM_DESTROY and @@ -2021,13 +2013,13 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, * @see GetRawInputDeviceList */ int GetRawInputDeviceList(RAWINPUTDEVICELIST[] pRawInputDeviceList, IntByReference puiNumDevices, int cbSize); - - + + /** * Retrieves a handle to the desktop window. The desktop window covers the * entire screen. The desktop window is the area on top of which other * windows are painted. - * + * * @return Type: HWND The return value is a handle to the desktop window. */ HWND GetDesktopWindow(); @@ -2035,7 +2027,7 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, /** * The PrintWindow function copies a visual window into the specified device * context (DC), typically a printer DC. - * + * * @param hWnd * A handle to the window that will be copied. * @param dest @@ -2054,7 +2046,7 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, /** * Determines whether the specified window is enabled for mouse and keyboard * input. - * + * * @param hWnd * A handle to the window to be tested. * @return If the window is enabled, the return value is true (nonzero).
    @@ -2069,7 +2061,7 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, * because the window could be destroyed after this function was called.
    * Further, because window handles are recycled the handle could even point * to a different window. - * + * * @param hWnd * A handle to the window to be tested. * @return If the window handle identifies an existing window, the return @@ -2141,7 +2133,7 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, /** * Retrieves the handle to the ancestor of the specified window. - * + * * @param hwnd * A handle to the window whose ancestor is to be retrieved. If * this parameter is the desktop window, the function returns @@ -2165,7 +2157,7 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, /** * Retrieves the position of the mouse cursor, in screen coordinates. - * + * * @param p * lpPoint [out]
    * Type: LPPOINT
    @@ -2182,7 +2174,7 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, * If the new coordinates are not within the screen rectangle set by the * most recent ClipCursor function call, the system automatically adjusts * the coordinates so that the cursor stays within the rectangle. - * + * * @param x * The new x-coordinate of the cursor, in screen coordinates. * @param y @@ -2277,7 +2269,7 @@ HANDLE SetWinEventHook(int eventMin, int eventMax, HMODULE hmodWinEventProc, Win /** * Removes an event hook function created by a previous call to * SetWinEventHook. - * + * * @param hook * Type: HWINEVENTHOOK
    * Handle to the event hook returned in the previous call to @@ -2295,7 +2287,7 @@ HANDLE SetWinEventHook(int eventMin, int eventMax, HMODULE hmodWinEventProc, Win /** * Copies the specified icon from another module to the current module. - * + * * @param hIcon * A handle to the icon to be copied. * @return If the function succeeds, the return value is a handle to the @@ -2313,7 +2305,7 @@ HANDLE SetWinEventHook(int eventMin, int eventMax, HMODULE hmodWinEventProc, Win * the GetClassLongPtr function.
    * (Pointers and handles are 32 bits on 32-bit Windows and 64 bits on 64-bit * Windows.) - * + * * @param hWnd * A handle to the window and, indirectly, the class to which the * window belongs. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Variant.java b/contrib/platform/src/com/sun/jna/platform/win32/Variant.java index 4f30ab7491..a3efa4f02f 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Variant.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Variant.java @@ -1,10 +1,8 @@ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.Date; import java.util.List; -import com.sun.jna.IntegerType; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.Union; @@ -40,7 +38,6 @@ import com.sun.jna.platform.win32.WinDef.USHORTByReference; import com.sun.jna.platform.win32.COM.Dispatch; import com.sun.jna.platform.win32.COM.IDispatch; -import com.sun.jna.platform.win32.COM.IRecordInfo; import com.sun.jna.platform.win32.COM.Unknown; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.DoubleByReference; @@ -197,7 +194,7 @@ public VARIANT(DATE value) { public VARIANT(byte value) { this(new BYTE(value)); } - + public VARIANT(BYTE value) { this(); this.setValue(Variant.VT_UI1, value); @@ -573,22 +570,34 @@ protected DATE fromJavaDate(Date javaDate) { } public static class _VARIANT extends Structure { + public static final List FIELDS = createFieldsOrder("vt", + "wReserved1", "wReserved2", "wReserved3", "__variant"); - public VARTYPE vt; - public short wReserved1; - public short wReserved2; - public short wReserved3; - public __VARIANT __variant; + public static class __VARIANT extends Union { + public static class BRECORD extends Structure { + public static class ByReference extends BRECORD implements + Structure.ByReference { + } - public _VARIANT() { - } + public static final List FIELDS = createFieldsOrder("pvRecord", "pRecInfo"); - public _VARIANT(Pointer pointer) { - super(pointer); - this.read(); - } + public PVOID pvRecord; + public Pointer pRecInfo; + + public BRECORD() { + super(); + } + + public BRECORD(Pointer pointer) { + super(pointer); + } + + @Override + protected List getFieldOrder() { + return FIELDS; + } + } - public static class __VARIANT extends Union { // LONGLONG VT_I8 public LONGLONG llVal; // LONG VT_I4 @@ -679,29 +688,6 @@ public static class __VARIANT extends Union { public UINTByReference puintVal; // BRECORD VT_RECORD public BRECORD pvRecord; - - public static class BRECORD extends Structure { - public static class ByReference extends BRECORD implements - Structure.ByReference { - } - - public PVOID pvRecord; - - public Pointer pRecInfo; - - public BRECORD() { - } - - public BRECORD(Pointer pointer) { - super(pointer); - } - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "pvRecord", - "pRecInfo" }); - } - } public __VARIANT() { super(); @@ -714,10 +700,24 @@ public __VARIANT(Pointer pointer) { } } + public VARTYPE vt; + public short wReserved1; + public short wReserved2; + public short wReserved3; + public __VARIANT __variant; + + public _VARIANT() { + super(); + } + + public _VARIANT(Pointer pointer) { + super(pointer); + this.read(); + } + @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "vt", "wReserved1", - "wReserved2", "wReserved3", "__variant" }); + protected List getFieldOrder() { + return FIELDS; } } } @@ -734,9 +734,11 @@ public ByReference(VARIANT[] variantArg) { } } + public static final List FIELDS = createFieldsOrder("variantArg"); public VARIANT[] variantArg = new VARIANT[1]; public VariantArg() { + super(); } /** @@ -746,21 +748,21 @@ public VariantArg() { public VariantArg(Pointer pointer) { super(pointer); } - + public VariantArg(VARIANT[] variantArg) { this.variantArg = variantArg; } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "variantArg" }); + protected List getFieldOrder() { + return FIELDS; } - + public void setArraySize(int size) { this.variantArg = new VARIANT[size]; this.read(); } - + } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java b/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java index 8431a9f8be..76a40f9399 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java @@ -10,7 +10,6 @@ */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Pointer; @@ -35,13 +34,13 @@ public ByReference(Pointer memory) { } } - public VS_FIXEDFILEINFO() { - } - - public VS_FIXEDFILEINFO(Pointer memory) { - super(memory); - read(); - } + public static final List FIELDS = createFieldsOrder( + "dwSignature", "dwStrucVersion", + "dwFileVersionMS", "dwFileVersionLS", + "dwProductVersionMS", "dwProductVersionLS", + "dwFileFlagsMask", "dwFileFlags", "dwFileOS", + "dwFileType", "dwFileSubtype", + "dwFileDateMS", "dwFileDateLS"); /** * Contains the value 0xFEEF04BD. This is used with the szKey member of the VS_VERSIONINFO structure when @@ -115,41 +114,51 @@ public VS_FIXEDFILEINFO(Pointer memory) { * The least significant 32 bits of the file's 64-bit binary creation date and time stamp. */ public WinDef.DWORD dwFileDateLS; - + + public VS_FIXEDFILEINFO() { + super(); + } + + public VS_FIXEDFILEINFO(Pointer memory) { + super(memory); + read(); + } + public int getFileVersionMajor() { return dwFileVersionMS.intValue() >>> 16; } - + public int getFileVersionMinor() { return dwFileVersionMS.intValue() & 0xffff; } - + public int getFileVersionRevision() { return dwFileVersionLS.intValue() >>> 16; } - + public int getFileVersionBuild() { return dwFileVersionLS.intValue() & 0xffff; } - + public int getProductVersionMajor() { return dwProductVersionMS.intValue() >>> 16; } - + public int getProductVersionMinor() { return dwProductVersionMS.intValue() & 0xffff; } - + public int getProductVersionRevision() { return dwProductVersionLS.intValue() >>> 16; } - + public int getProductVersionBuild() { return dwProductVersionLS.intValue() & 0xffff; } - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwSignature", "dwStrucVersion", "dwFileVersionMS", "dwFileVersionLS", "dwProductVersionMS", "dwProductVersionLS", "dwFileFlagsMask", "dwFileFlags", "dwFileOS", "dwFileType", "dwFileSubtype", "dwFileDateMS", "dwFileDateLS" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WTypes.java b/contrib/platform/src/com/sun/jna/platform/win32/WTypes.java index c4873128ef..b3eafa0b16 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WTypes.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WTypes.java @@ -25,7 +25,7 @@ /** * Constant defined in WTypes.h - * + * * @author scott.palmer * @author Tobias Wolf, wolf.tobias@gmx.net */ @@ -233,6 +233,8 @@ public String toString() { } public static class VARTYPE extends USHORT { + private static final long serialVersionUID = 1L; + public VARTYPE() { this(0); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java b/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java index 9693f94f5f..1c8934a012 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java @@ -1,18 +1,17 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Native; @@ -25,29 +24,16 @@ * @author dblock[at]dblock.org */ public interface Wdm { - + /** - * The KEY_BASIC_INFORMATION structure defines a subset of + * The KEY_BASIC_INFORMATION structure defines a subset of * the full information that is available for a registry key. */ - public static class KEY_BASIC_INFORMATION extends Structure { - public KEY_BASIC_INFORMATION() { - super(); - } + public static class KEY_BASIC_INFORMATION extends Structure { + public static final List FIELDS = createFieldsOrder("LastWriteTime", "TitleIndex", "NameLength", "Name"); - public KEY_BASIC_INFORMATION(int size) { - NameLength = size - 16; // write time, title index and name length - Name = new char[NameLength]; - allocateMemory(); - } - - public KEY_BASIC_INFORMATION(Pointer memory) { - super(memory); - read(); - } - /** - * The last time the key or any of its values changed. + * The last time the key or any of its values changed. */ public long LastWriteTime; /** @@ -55,17 +41,33 @@ public KEY_BASIC_INFORMATION(Pointer memory) { */ public int TitleIndex; /** - * Specifies the size in bytes of the following name. + * Specifies the size in bytes of the following name. */ public int NameLength; /** - * A string of Unicode characters naming the key. + * A string of Unicode characters naming the key. * The string is not null-terminated. */ public char[] Name; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "LastWriteTime", "TitleIndex", "NameLength", "Name" }); + + public KEY_BASIC_INFORMATION() { + super(); + } + + public KEY_BASIC_INFORMATION(int size) { + NameLength = size - 16; // write time, title index and name length + Name = new char[NameLength]; + allocateMemory(); + } + + public KEY_BASIC_INFORMATION(Pointer memory) { + super(memory); + read(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } /** * Name of the key. @@ -74,19 +76,20 @@ protected List getFieldOrder() { public String getName() { return Native.toString(Name); } - + + @Override public void read() { super.read(); Name = new char[NameLength / 2]; - readField("Name"); + readField("Name"); } } - + /** - * The KEY_INFORMATION_CLASS enumeration type represents + * The KEY_INFORMATION_CLASS enumeration type represents * the type of information to supply about a registry key. */ - public abstract class KEY_INFORMATION_CLASS { + public abstract class KEY_INFORMATION_CLASS { public static final int KeyBasicInformation = 0; public static final int KeyNodeInformation = 1; public static final int KeyFullInformation = 2; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java b/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java index 160babb23e..7d78ed6800 100755 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java @@ -23,10 +23,8 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.Union; -import com.sun.jna.platform.win32.WinDef.DWORDLONG; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByteByReference; -import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.StdCallLibrary.StdCallCallback; /** @@ -294,7 +292,7 @@ public long toTime() { public long toLong() { return toDate().getTime(); } - + /** *

    Converts the two 32-bit unsigned integer parts of this filetime * into a 64-bit unsigned integer representing the number of @@ -1184,9 +1182,11 @@ public DWORD callback(Pointer pbData, Pointer pvCallbackContext, * ReadTotalTimeoutConstant, ReadFile times out. * * @author Markus - * */ public static class COMMTIMEOUTS extends Structure { + public static final List FIELDS = createFieldsOrder("ReadIntervalTimeout", "ReadTotalTimeoutMultiplier", + "ReadTotalTimeoutConstant", "WriteTotalTimeoutMultiplier", "WriteTotalTimeoutConstant"); + /** * * The maximum time allowed to elapse before the arrival of the next @@ -1250,13 +1250,10 @@ public static class COMMTIMEOUTS extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "ReadIntervalTimeout", "ReadTotalTimeoutMultiplier", - "ReadTotalTimeoutConstant", "WriteTotalTimeoutMultiplier", "WriteTotalTimeoutConstant" }); + return FIELDS; } } - - /** * Defines the control setting for a serial communications device. */ diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java b/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java index 2f3239086a..ba241dd0b8 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java @@ -1,18 +1,17 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Memory; @@ -27,15 +26,25 @@ * @author dblock[at]dblock.org */ public interface WinCrypt { - + /** * The CryptoAPI CRYPTOAPI_BLOB structure is used for an arbitrary array of bytes. */ public static class DATA_BLOB extends Structure { + public static final List FIELDS = createFieldsOrder("cbData", "pbData"); + /** + * The count of bytes in the buffer pointed to by pbData. + */ + public int cbData; + /** + * A pointer to a block of data bytes. + */ + public Pointer pbData; + public DATA_BLOB() { super(); } - + public DATA_BLOB(Pointer memory) { super(memory); read(); @@ -47,22 +56,15 @@ public DATA_BLOB(byte [] data) { cbData = data.length; allocateMemory(); } - + public DATA_BLOB(String s) { this(Native.toByteArray(s)); } - - /** - * The count of bytes in the buffer pointed to by pbData. - */ - public int cbData; - /** - * A pointer to a block of data bytes. - */ - public Pointer pbData; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "cbData", "pbData" }); + + + @Override + protected List getFieldOrder() { + return FIELDS; } /** * Get byte data. @@ -72,23 +74,15 @@ protected List getFieldOrder() { public byte[] getData() { return pbData == null ? null : pbData.getByteArray(0, cbData); } - } - + } + /** - * The CRYPTPROTECT_PROMPTSTRUCT structure provides the text of a prompt and + * The CRYPTPROTECT_PROMPTSTRUCT structure provides the text of a prompt and * information about when and where that prompt is to be displayed when using - * the CryptProtectData and CryptUnprotectData functions. + * the CryptProtectData and CryptUnprotectData functions. */ public static class CRYPTPROTECT_PROMPTSTRUCT extends Structure { - public CRYPTPROTECT_PROMPTSTRUCT() { - super(); - } - - public CRYPTPROTECT_PROMPTSTRUCT(Pointer memory) { - super(memory); - read(); - } - + public static final List FIELDS = createFieldsOrder("cbSize", "dwPromptFlags", "hwndApp", "szPrompt"); /** * Size of this structure in bytes. */ @@ -98,19 +92,29 @@ public CRYPTPROTECT_PROMPTSTRUCT(Pointer memory) { */ public int dwPromptFlags; /** - * Window handle to the parent window. + * Window handle to the parent window. */ public HWND hwndApp; /** - * A string containing the text of a prompt to be displayed. + * A string containing the text of a prompt to be displayed. */ public String szPrompt; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "cbSize", "dwPromptFlags", "hwndApp", "szPrompt" }); + + public CRYPTPROTECT_PROMPTSTRUCT() { + super(); + } + + public CRYPTPROTECT_PROMPTSTRUCT(Pointer memory) { + super(memory); + read(); + } + + @Override + protected List getFieldOrder() { + return FIELDS; } } - + // // CryptProtect PromptStruct dwPromtFlags // @@ -126,7 +130,7 @@ protected List getFieldOrder() { /** * Reserved, don't use. */ - int CRYPTPROTECT_PROMPT_RESERVED = 0x04; + int CRYPTPROTECT_PROMPT_RESERVED = 0x04; /** * Default to strong variant UI protection (user supplied password currently). */ @@ -140,18 +144,18 @@ protected List getFieldOrder() { // CryptProtectData and CryptUnprotectData dwFlags // /** - * For remote-access situations where ui is not an option, if UI was specified - * on protect or unprotect operation, the call will fail and GetLastError() will + * For remote-access situations where ui is not an option, if UI was specified + * on protect or unprotect operation, the call will fail and GetLastError() will * indicate ERROR_PASSWORD_RESTRICTION. */ int CRYPTPROTECT_UI_FORBIDDEN = 0x1; /** - * Per machine protected data -- any user on machine where CryptProtectData + * Per machine protected data -- any user on machine where CryptProtectData * took place may CryptUnprotectData. */ int CRYPTPROTECT_LOCAL_MACHINE = 0x4; /** - * Force credential synchronize during CryptProtectData() + * Force credential synchronize during CryptProtectData() * Synchronize is only operation that occurs during this operation. */ int CRYPTPROTECT_CRED_SYNC = 0x8; @@ -177,112 +181,112 @@ protected List getFieldOrder() { * @see MSDN */ int CRYPT_E_ASN1_ERROR = 0x80093100; - + /** * ASN.1 internal encode or decode error * @see MSDN */ int CRYPT_E_ASN1_INTERNAL = 0x80093101; - + /** * ASN.1 unexpected end of data * @see MSDN */ int CRYPT_E_ASN1_EOD = 0x80093102; - + /** * ASN.1 corrupted data * @see MSDN */ int CRYPT_E_ASN1_CORRUPT = 0x80093103; - + /** * ASN.1 value too large * @see MSDN */ int CRYPT_E_ASN1_LARGE = 0x80093104; - + /** * ASN.1 constraint violated * @see MSDN */ int CRYPT_E_ASN1_CONSTRAINT = 0x80093105; - + /** * ASN.1 out of memory * @see MSDN */ int CRYPT_E_ASN1_MEMORY = 0x80093106; - + /** * ASN.1 buffer overflow * @see MSDN */ int CRYPT_E_ASN1_OVERFLOW = 0x80093107; - + /** * ASN.1 function not supported for this PDU * @see MSDN */ int CRYPT_E_ASN1_BADPDU = 0x80093108; - + /** * ASN.1 bad arguments to function call * @see MSDN */ int CRYPT_E_ASN1_BADARGS = 0x80093109; - + /** * ASN.1 bad real value * @see MSDN */ int CRYPT_E_ASN1_BADREAL = 0x8009310A; - + /** * ASN.1 bad tag value met * @see MSDN */ int CRYPT_E_ASN1_BADTAG = 0x8009310B; - + /** * ASN.1 bad choice value * @see MSDN */ int CRYPT_E_ASN1_CHOICE = 0x8009310C; - + /** * ASN.1 bad encoding rule * @see MSDN */ int CRYPT_E_ASN1_RULE = 0x8009310D; - + /** * ASN.1 bad Unicode (UTF8) * @see MSDN */ int CRYPT_E_ASN1_UTF8 = 0x8009310E; - + /** * ASN.1 bad PDU type * @see MSDN */ int CRYPT_E_ASN1_PDU_TYPE = 0x80093133; - + /** * ASN.1 not yet implemented * @see MSDN */ int CRYPT_E_ASN1_NYI = 0x80093134; - + /** * ASN.1 skipped unknown extensions * @see MSDN */ int CRYPT_E_ASN1_EXTENDED = 0x80093201; - + /** * ASN.1 end of data expected * @see MSDN */ - int CRYPT_E_ASN1_NOEOD = 0x80093202; + int CRYPT_E_ASN1_NOEOD = 0x80093202; } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java b/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java index 3c531fca88..db5671f00f 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java @@ -13,7 +13,6 @@ package com.sun.jna.platform.win32; import java.awt.Rectangle; -import java.util.Arrays; import java.util.List; import com.sun.jna.IntegerType; @@ -755,7 +754,7 @@ public WPARAM(long value) { * The Class RECT. */ public class RECT extends Structure { - + public static final List FIELDS = createFieldsOrder("left", "top", "right", "bottom"); /** The left. */ public int left; @@ -770,7 +769,7 @@ public class RECT extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList("left", "top", "right", "bottom"); + return FIELDS; } /** @@ -1056,14 +1055,21 @@ public class POINT extends Structure { /** * The Class ByReference. */ - public static class ByReference extends POINT implements - Structure.ByReference { + public static class ByReference extends POINT implements Structure.ByReference { + } + public static final List FIELDS = createFieldsOrder("x", "y"); + + /** The x. */ + public int x; + /** The y. */ + public int y; /** * Instantiates a new point. */ public POINT() { + super(); } /** @@ -1077,9 +1083,6 @@ public POINT(Pointer memory) { read(); } - /** The y. */ - public int x, y; - /** * Instantiates a new point. * @@ -1095,7 +1098,7 @@ public POINT(int x, int y) { @Override protected List getFieldOrder() { - return Arrays.asList("x", "y"); + return FIELDS; } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java b/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java index 40e1f38a4c..44cf364640 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java @@ -1,18 +1,17 @@ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.NativeLong; @@ -23,7 +22,7 @@ import com.sun.jna.platform.win32.WinDef.RECT; /** - * Ported from WinGDI.h. + * Ported from WinGDI.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org * @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de @@ -32,42 +31,46 @@ public interface WinGDI { int RDH_RECTANGLES = 1; class RGNDATAHEADER extends Structure { + public static final List FIELDS = createFieldsOrder("dwSize", "iType", "nCount", "nRgnSize", "rcBound"); public int dwSize = size(); public int iType = RDH_RECTANGLES; // required public int nCount; public int nRgnSize; public RECT rcBound; - - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwSize", "iType", "nCount", "nRgnSize", "rcBound" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } - + class RGNDATA extends Structure { + public static final List FIELDS = createFieldsOrder("rdh", "Buffer" ); public RGNDATAHEADER rdh; public byte[] Buffer; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "rdh", "Buffer" }); - } - - public RGNDATA() { - this(1); + public RGNDATA() { + this(1); } public RGNDATA(int bufferSize) { Buffer = new byte[bufferSize]; allocateMemory(); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } HANDLE HGDI_ERROR = new HANDLE(Pointer.createConstant(0xFFFFFFFF)); - + int RGN_AND = 1; int RGN_OR = 2; int RGN_XOR = 3; int RGN_DIFF = 4; int RGN_COPY = 5; - + int ERROR = 0; int NULLREGION = 1; int SIMPLEREGION = 2; @@ -75,14 +78,14 @@ public RGNDATA(int bufferSize) { int ALTERNATE = 1; int WINDING = 2; - + int BI_RGB = 0; int BI_RLE8 = 1; int BI_RLE4 = 2; int BI_BITFIELDS = 3; int BI_JPEG = 4; int BI_PNG = 5; - + int PFD_TYPE_RGBA = 0; int PFD_TYPE_COLORINDEX = 1; @@ -106,6 +109,10 @@ public RGNDATA(int bufferSize) { int PFD_SUPPORT_DIRECTDRAW = 0x00002000; class BITMAPINFOHEADER extends Structure { + public static final List FIELDS = createFieldsOrder("biSize", + "biWidth", "biHeight", "biPlanes", "biBitCount", "biCompression", + "biSizeImage", "biXPelsPerMeter", "biYPelsPerMeter", "biClrUsed", "biClrImportant"); + public int biSize = size(); public int biWidth; public int biHeight; @@ -117,46 +124,60 @@ class BITMAPINFOHEADER extends Structure { public int biYPelsPerMeter; public int biClrUsed; public int biClrImportant; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "biSize", "biWidth", "biHeight", "biPlanes", "biBitCount", "biCompression", "biSizeImage", "biXPelsPerMeter", "biYPelsPerMeter", "biClrUsed", "biClrImportant" }); + + @Override + protected List getFieldOrder() { + return FIELDS; } } - + class RGBQUAD extends Structure { + public static final List FIELDS = createFieldsOrder("rgbBlue", "rgbGreen", "rgbRed", "rgbReserved"); + public byte rgbBlue; public byte rgbGreen; public byte rgbRed; public byte rgbReserved = 0; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "rgbBlue", "rgbGreen", "rgbRed", "rgbReserved" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } - + class BITMAPINFO extends Structure { + public static final List FIELDS = createFieldsOrder("bmiHeader", "bmiColors"); + public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER(); public RGBQUAD[] bmiColors = new RGBQUAD[1]; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "bmiHeader", "bmiColors" }); + public BITMAPINFO() { + this(1); } - public BITMAPINFO() { this(1); } public BITMAPINFO(int size) { bmiColors = new RGBQUAD[size]; } + @Override + protected List getFieldOrder() { + return FIELDS; + } } - + class ICONINFO extends Structure { + public static final List FIELDS = createFieldsOrder("fIcon", "xHotspot", "yHotspot", "hbmMask", "hbmColor"); + public boolean fIcon; public int xHotspot; public int yHotspot; public HBITMAP hbmMask; public HBITMAP hbmColor; - protected List getFieldOrder() { - return Arrays.asList(new String[] { "fIcon", "xHotspot", - "yHotspot", "hbmMask", "hbmColor" }); + @Override + protected List getFieldOrder() { + return FIELDS; } } - + class BITMAP extends Structure { + public static final List FIELDS = createFieldsOrder("bmType", "bmWidth", "bmHeight", + "bmWidthBytes", "bmPlanes", "bmBitsPixel", "bmBits"); public NativeLong bmType; public NativeLong bmWidth; public NativeLong bmHeight; @@ -164,20 +185,24 @@ class BITMAP extends Structure { public short bmPlanes; public short bmBitsPixel; public Pointer bmBits; - protected List getFieldOrder() { - return Arrays.asList("bmType", "bmWidth", "bmHeight", - "bmWidthBytes", "bmPlanes", "bmBitsPixel", "bmBits"); + @Override + protected List getFieldOrder() { + return FIELDS; } } - + class DIBSECTION extends Structure { + public static final List FIELDS = createFieldsOrder("dsBm", "dsBmih", "dsBitfields", "dshSection", "dsOffset"); + public BITMAP dsBm; public BITMAPINFOHEADER dsBmih; public int[] dsBitfields = new int[3]; public HANDLE dshSection; - public int dsOffset; - protected List getFieldOrder() { - return Arrays.asList("dsBm", "dsBmih", "dsBitfields", "dshSection", "dsOffset"); + public int dsOffset; + + @Override + protected List getFieldOrder() { + return FIELDS; } } @@ -188,8 +213,12 @@ protected List getFieldOrder() { * The PIXELFORMATDESCRIPTOR structure describes the pixel format of a drawing surface. */ class PIXELFORMATDESCRIPTOR extends Structure { + public static final List FIELDS = createFieldsOrder("nSize", "nVersion", "dwFlags", "iPixelType", + "cColorBits", "cRedBits", "cRedShift", "cGreenBits", "cGreenShift", "cBlueBits", "cBlueShift", "cAlphaBits", "cAlphaShift", + "cAccumBits", "cAccumRedBits", "cAccumGreenBits", "cAccumBlueBits", "cAccumAlphaBits", + "cDepthBits", "cStencilBits", "cAuxBuffers", "iLayerType", "bReserved", "dwLayerMask", "dwVisibleMask", "dwDamageMask"); + public PIXELFORMATDESCRIPTOR() { - super(); nSize = (short) size(); } @@ -306,13 +335,9 @@ public static class ByReference extends PIXELFORMATDESCRIPTOR implements Structu */ public int dwDamageMask; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "nSize", "nVersion", "dwFlags", "iPixelType", - "cColorBits", "cRedBits", "cRedShift", "cGreenBits", "cGreenShift", "cBlueBits", "cBlueShift", "cAlphaBits", "cAlphaShift", - "cAccumBits", "cAccumRedBits", "cAccumGreenBits", "cAccumBlueBits", "cAccumAlphaBits", - "cDepthBits", "cStencilBits", "cAuxBuffers", "iLayerType", "bReserved", "dwLayerMask", "dwVisibleMask", "dwDamageMask", }); + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java b/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java index 005fa16ea8..06ef14c216 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java @@ -12,10 +12,9 @@ */ package com.sun.jna.platform.win32; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import com.sun.jna.FromNativeContext; import com.sun.jna.IntegerType; @@ -240,6 +239,7 @@ public abstract class TOKEN_TYPE { * (LUID) and its attributes. */ public static class LUID_AND_ATTRIBUTES extends Structure { + public static final List FIELDS = createFieldsOrder("Luid", "Attributes"); /** * Specifies an LUID value. */ @@ -252,18 +252,19 @@ public static class LUID_AND_ATTRIBUTES extends Structure { */ public DWORD Attributes; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Luid", "Attributes" }); - } - public LUID_AND_ATTRIBUTES() { + super(); } public LUID_AND_ATTRIBUTES(LUID luid, DWORD attributes) { this.Luid = luid; this.Attributes = attributes; } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } /** @@ -271,20 +272,7 @@ public LUID_AND_ATTRIBUTES(LUID luid, DWORD attributes) { * and its attributes. SIDs are used to uniquely identify users or groups. */ public static class SID_AND_ATTRIBUTES extends Structure { - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Sid", "Attributes" }); - } - - public SID_AND_ATTRIBUTES() { - super(); - } - - public SID_AND_ATTRIBUTES(Pointer memory) { - super(memory); - } - + public static final List FIELDS = createFieldsOrder("Sid", "Attributes"); /** * Pointer to a SID structure. */ @@ -295,6 +283,19 @@ public SID_AND_ATTRIBUTES(Pointer memory) { * flags. Its meaning depends on the definition and use of the SID. */ public int Attributes; + + public SID_AND_ATTRIBUTES() { + super(); + } + + public SID_AND_ATTRIBUTES(Pointer memory) { + super(memory); + } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } /** @@ -302,11 +303,13 @@ public SID_AND_ATTRIBUTES(Pointer memory) { * (SID) that will be applied to newly created objects. */ public static class TOKEN_OWNER extends Structure { - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Owner" }); - } + public static final List FIELDS = createFieldsOrder("Owner"); + /** + * Pointer to a SID structure representing a user who will become the + * owner of any objects created by a process using this access token. + * The SID must be one of the user or group SIDs already in the token. + */ + public PSID.ByReference Owner; // PSID public TOKEN_OWNER() { super(); @@ -321,21 +324,16 @@ public TOKEN_OWNER(Pointer memory) { read(); } - /** - * Pointer to a SID structure representing a user who will become the - * owner of any objects created by a process using this access token. - * The SID must be one of the user or group SIDs already in the token. - */ - public PSID.ByReference Owner; // PSID + @Override + protected List getFieldOrder() { + return FIELDS; + } } public static class PSID extends Structure { public static class ByReference extends PSID implements Structure.ByReference { } - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "sid" }); - } + public static final List FIELDS = createFieldsOrder("sid"); + public Pointer sid; public PSID() { super(); @@ -365,7 +363,10 @@ public String getSidString() { return Advapi32Util.convertSidToStringSid(this); } - public Pointer sid; + @Override + protected List getFieldOrder() { + return FIELDS; + } } public static class PSIDByReference extends ByReference { @@ -398,11 +399,13 @@ public PSID getValue() { * token. */ public static class TOKEN_USER extends Structure { - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "User" }); - } + public static final List FIELDS = createFieldsOrder("User"); + /** + * Specifies a SID_AND_ATTRIBUTES structure representing the user + * associated with the access token. There are currently no attributes + * defined for user security identifiers (SIDs). + */ + public SID_AND_ATTRIBUTES User; public TOKEN_USER() { super(); @@ -417,12 +420,10 @@ public TOKEN_USER(int size) { super(new Memory(size)); } - /** - * Specifies a SID_AND_ATTRIBUTES structure representing the user - * associated with the access token. There are currently no attributes - * defined for user security identifiers (SIDs). - */ - public SID_AND_ATTRIBUTES User; + @Override + protected List getFieldOrder() { + return FIELDS; + } } /** @@ -430,11 +431,12 @@ public TOKEN_USER(int size) { * identifiers (SIDs) in an access token. */ public static class TOKEN_GROUPS extends Structure { - - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "GroupCount", "Group0" }); - } + public static final List FIELDS = createFieldsOrder("GroupCount", "Group0"); + /** + * Specifies the number of groups in the access token. + */ + public int GroupCount; + public SID_AND_ATTRIBUTES Group0; public TOKEN_GROUPS() { super(); @@ -449,12 +451,6 @@ public TOKEN_GROUPS(int size) { super(new Memory(size)); } - /** - * Specifies the number of groups in the access token. - */ - public int GroupCount; - public SID_AND_ATTRIBUTES Group0; - /** * Specifies an array of SID_AND_ATTRIBUTES structures that contain a * set of SIDs and corresponding attributes. @@ -463,6 +459,10 @@ public TOKEN_GROUPS(int size) { public SID_AND_ATTRIBUTES[] getGroups() { return (SID_AND_ATTRIBUTES[]) Group0.toArray(GroupCount); } + @Override + protected List getFieldOrder() { + return FIELDS; + } } /** @@ -470,15 +470,11 @@ public SID_AND_ATTRIBUTES[] getGroups() { * It is also used to indicate which, if any, privileges are held by a user or group requesting access to an object. */ public static class PRIVILEGE_SET extends Structure { + public static final List FIELDS = createFieldsOrder("PrivilegeCount", "Control", "Privileges"); public DWORD PrivilegeCount; public DWORD Control; public LUID_AND_ATTRIBUTES Privileges[]; - @Override - protected List getFieldOrder() { - return Arrays.asList("PrivilegeCount", "Control", "Privileges"); - } - public PRIVILEGE_SET() { this(0); } @@ -493,7 +489,7 @@ public PRIVILEGE_SET(int nbOfPrivileges) { } } - /** Initialize a TOKEN_PRIVILEGES instance from initialized memory. + /** Initialize a TOKEN_PRIVILEGES instance from initialized memory. * @param p base address */ public PRIVILEGE_SET(Pointer p) { @@ -505,6 +501,11 @@ public PRIVILEGE_SET(Pointer p) { } read(); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } /** @@ -512,6 +513,7 @@ public PRIVILEGE_SET(Pointer p) { * privileges for an access token. */ public static class TOKEN_PRIVILEGES extends Structure { + public static final List FIELDS = createFieldsOrder("PrivilegeCount", "Privileges"); /** * This must be set to the number of entries in the Privileges array. */ @@ -523,11 +525,6 @@ public static class TOKEN_PRIVILEGES extends Structure { */ public LUID_AND_ATTRIBUTES Privileges[]; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "PrivilegeCount", "Privileges" }); - } - /** Creates an empty instance with no privileges. */ public TOKEN_PRIVILEGES() { this(0); @@ -551,6 +548,11 @@ public TOKEN_PRIVILEGES(Pointer p) { Privileges = new LUID_AND_ATTRIBUTES[count]; read(); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } /** @@ -682,7 +684,7 @@ public abstract class SID_NAME_USE { * typically returns a failure status indicator.
    * This value cannot be used with PAGE_NOACCESS. This flag is not supported * by the CreateFileMapping function. - * + * * @see * MSDN @@ -694,7 +696,7 @@ public abstract class SID_NAME_USE { * An attempt to read from, write to, or execute the committed region * results in an access violation.
    * This flag is not supported by the CreateFileMapping function. - * + * * @see MSDN */ int PAGE_NOACCESS = 0x01; @@ -705,7 +707,7 @@ public abstract class SID_NAME_USE { * violation.
    * If Data Execution Prevention is enabled, an attempt to execute code in * the committed region results in an access violation. - * + * * @see MSDN */ int PAGE_READONLY = 0x02; @@ -714,11 +716,11 @@ public abstract class SID_NAME_USE { * Enables read-only or read/write access to the committed region of pages.
    * If Data Execution Prevention is enabled, attempting to execute code in * the committed region results in an access violation. - * + * * @see MSDN */ int PAGE_READWRITE = 0x04; - + /** * Enables read-only or copy-on-write access to a mapped view of a file * mapping object. An attempt to write to a committed copy-on-write page @@ -726,16 +728,16 @@ public abstract class SID_NAME_USE { * private page is marked as PAGE_READWRITE, and the change is written to * the new page. If Data Execution Prevention is enabled, attempting to * execute code in the committed region results in an access violation. - * + * * @see MSDN */ int PAGE_WRITECOPY = 0x08; - + /** * Enables execute access to the committed region of pages. An attempt to * write to the committed region results in an access violation. This flag * is not supported by the CreateFileMapping function. - * + * * @see MSDN */ int PAGE_EXECUTE = 0x10; @@ -746,7 +748,7 @@ public abstract class SID_NAME_USE { * Windows Server 2003 and Windows XP: This attribute is not supported by * the CreateFileMapping function until Windows XP with SP2 and Windows * Server 2003 with SP1. - * + * * @see MSDN */ int PAGE_EXECUTE_READ = 0x20; @@ -756,7 +758,7 @@ public abstract class SID_NAME_USE { * of pages. Windows Server 2003 and Windows XP: This attribute is not * supported by the CreateFileMapping function until Windows XP with SP2 and * Windows Server 2003 with SP1. - * + * * @see MSDN */ int PAGE_EXECUTE_READWRITE = 0x40; @@ -843,18 +845,15 @@ public abstract class SID_NAME_USE { * for input. */ public static class FILE_NOTIFY_INFORMATION extends Structure { + public static final List FIELDS = createFieldsOrder("NextEntryOffset", "Action", "FileNameLength", "FileName"); public int NextEntryOffset; public int Action; public int FileNameLength; // filename is not nul-terminated, so we can't use a String/WString public char[] FileName = new char[1]; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "NextEntryOffset", "Action", "FileNameLength", "FileName" }); - } - private FILE_NOTIFY_INFORMATION() { + super(); } public FILE_NOTIFY_INFORMATION(int size) { @@ -874,6 +873,11 @@ public String getFilename() { return new String(FileName, 0, FileNameLength / 2); } + @Override + protected List getFieldOrder() { + return FIELDS; + } + @Override public void read() { // avoid reading filename until we know how long it is @@ -1126,12 +1130,13 @@ public FILE_NOTIFY_INFORMATION next() { * that generated it until the system is restarted. */ public static class LUID extends Structure { + public static final List FIELDS = createFieldsOrder("LowPart", "HighPart"); public int LowPart; public int HighPart; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "LowPart", "HighPart" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -1144,6 +1149,7 @@ public static class ByReference extends LARGE_INTEGER implements } public static class LowHigh extends Structure { + public static final List FIELDS = createFieldsOrder("LowPart", "HighPart"); public DWORD LowPart; public DWORD HighPart; @@ -1162,7 +1168,7 @@ public LowHigh(DWORD low, DWORD high) { @Override protected List getFieldOrder() { - return Arrays.asList("LowPart", "HighPart"); + return FIELDS; } public long longValue() { @@ -1818,6 +1824,9 @@ public abstract class WELL_KNOWN_SID_TYPE { * operating system. This structure is used with the GetVersionEx function. */ public static class OSVERSIONINFO extends Structure { + public static final List FIELDS = createFieldsOrder( + "dwOSVersionInfoSize", "dwMajorVersion", "dwMinorVersion", "dwBuildNumber", "dwPlatformId", "szCSDVersion"); + /** * Size of this data structure, in bytes. Set this member to * sizeof(OSVERSIONINFO) before calling the GetVersionEx function. @@ -1850,11 +1859,6 @@ public static class OSVERSIONINFO extends Structure { */ public char szCSDVersion[]; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwOSVersionInfoSize", "dwMajorVersion", "dwMinorVersion", "dwBuildNumber", "dwPlatformId", "szCSDVersion" }); - } - public OSVERSIONINFO() { szCSDVersion = new char[128]; dwOSVersionInfoSize = new DWORD(size()); // sizeof(OSVERSIONINFO) @@ -1864,6 +1868,11 @@ public OSVERSIONINFO(Pointer memory) { super(memory); read(); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } /** @@ -1873,6 +1882,14 @@ public OSVERSIONINFO(Pointer memory) { * installed on the system. */ public static class OSVERSIONINFOEX extends Structure { + public static final List FIELDS = createFieldsOrder( + "dwOSVersionInfoSize", + "dwMajorVersion", "dwMinorVersion", "dwBuildNumber", + "dwPlatformId", + "szCSDVersion", + "wServicePackMajor", "wServicePackMinor", + "wSuiteMask", "wProductType", "wReserved"); + /** * The size of this data structure, in bytes. */ @@ -1936,11 +1953,6 @@ public static class OSVERSIONINFOEX extends Structure { */ public byte wReserved; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "dwOSVersionInfoSize", "dwMajorVersion", "dwMinorVersion", "dwBuildNumber", "dwPlatformId", "szCSDVersion", "wServicePackMajor", "wServicePackMinor", "wSuiteMask", "wProductType", "wReserved"}); - } - public OSVERSIONINFOEX() { szCSDVersion = new char[128]; dwOSVersionInfoSize = new DWORD(size()); // sizeof(OSVERSIONINFOEX) @@ -1950,8 +1962,11 @@ public OSVERSIONINFOEX(Pointer memory) { super(memory); read(); } - - + + @Override + protected List getFieldOrder() { + return FIELDS; + } /** * @return The major version number of the operating system. @@ -2093,6 +2108,12 @@ public byte getProductType() { * returned by the ReadEventLog function. */ public static class EVENTLOGRECORD extends Structure { + public static final List FIELDS = createFieldsOrder( + "Length", "Reserved", "RecordNumber", "TimeGenerated", "TimeWritten", + "EventID", "EventType", "NumStrings", "EventCategory", "ReservedFlags", + "ClosingRecordNumber", "StringOffset", "UserSidLength", "UserSidOffset", + "DataLength", "DataOffset"); + /** * Size of this event record, in bytes. Note that this value is stored * at both ends of the entry to ease moving forward or backward through @@ -2195,18 +2216,19 @@ public static class EVENTLOGRECORD extends Structure { */ public DWORD DataOffset; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Length", "Reserved", "RecordNumber", "TimeGenerated", "TimeWritten", "EventID", "EventType", "NumStrings", "EventCategory", "ReservedFlags", "ClosingRecordNumber", "StringOffset", "UserSidLength", "UserSidOffset", "DataLength", "DataOffset"}); - } - public EVENTLOGRECORD() { + super(); } public EVENTLOGRECORD(Pointer p) { super(p); read(); } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } // @@ -2290,28 +2312,28 @@ public EVENTLOGRECORD(Pointer p) { * operating system targeted by your application (for example, #define * _WIN32_WINNT _WIN32_WINNT_WINXP).
    * For more information, see Using the Windows Headers. - * + * * @see MSDN */ - int PROCESS_ALL_ACCESS = WinNT.PROCESS_CREATE_PROCESS + int PROCESS_ALL_ACCESS = WinNT.PROCESS_CREATE_PROCESS | WinNT.PROCESS_CREATE_THREAD | WinNT.PROCESS_DUP_HANDLE - | WinNT.PROCESS_QUERY_INFORMATION + | WinNT.PROCESS_QUERY_INFORMATION | WinNT.PROCESS_QUERY_LIMITED_INFORMATION - | WinNT.PROCESS_SET_INFORMATION + | WinNT.PROCESS_SET_INFORMATION | WinNT.PROCESS_SET_QUOTA | WinNT.PROCESS_SUSPEND_RESUME - | WinNT.PROCESS_SYNCHRONIZE + | WinNT.PROCESS_SYNCHRONIZE | WinNT.PROCESS_TERMINATE - | WinNT.PROCESS_VM_OPERATION + | WinNT.PROCESS_VM_OPERATION | WinNT.PROCESS_VM_READ - | WinNT.PROCESS_VM_WRITE - | WinNT.DELETE - | WinNT.READ_CONTROL + | WinNT.PROCESS_VM_WRITE + | WinNT.DELETE + | WinNT.READ_CONTROL | WinNT.WRITE_DAC | WinNT.WRITE_OWNER - | WinNT.SYNCHRONIZE; - + | WinNT.SYNCHRONIZE; + /** * Required to retrieve certain information about a process, such as its * token, exit code, and priority class (see @@ -2357,7 +2379,7 @@ public EVENTLOGRECORD(Pointer p) { * {@code Kernel32.QueryFullProcessImageName()}. */ int PROCESS_NAME_NATIVE = 0x00000001; - + /** * Required to perform an operation on the address space of a process (see * {@code Kernel32.VirtualProtectEx()} and @@ -2416,11 +2438,14 @@ public static class ByReference extends SECURITY_DESCRIPTOR implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("data"); + public byte[] data; + public SECURITY_DESCRIPTOR() { + super(); } public SECURITY_DESCRIPTOR(byte[] data) { - super(); this.data = data; useMemory(new Memory(data.length)); } @@ -2430,22 +2455,25 @@ public SECURITY_DESCRIPTOR(Pointer memory) { read(); } - public byte[] data; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "data" }); + protected List getFieldOrder() { + return FIELDS; } } public static class ACL extends Structure { + public static final List FIELDS = createFieldsOrder("AclRevision", "Sbz1", "AclSize", "AceCount", "Sbz2"); - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "AclRevision", "Sbz1", "AclSize", "AceCount", "Sbz2" }); - } + public byte AclRevision; + public byte Sbz1; + public short AclSize; + public short AceCount; + public short Sbz2; + + private ACCESS_ACEStructure[] ACEs; public ACL() { + super(); } public ACL(Pointer pointer) { @@ -2457,34 +2485,30 @@ public ACL(Pointer pointer) { Pointer share = pointer.share(offset); // ACE_HEADER.AceType final byte aceType = share.getByte(0); - ACCESS_ACEStructure ace = null; + ACCESS_ACEStructure ace; switch (aceType) { - case ACCESS_ALLOWED_ACE_TYPE: - ace = new ACCESS_ALLOWED_ACE(share); - break; - case ACCESS_DENIED_ACE_TYPE: - ace = new ACCESS_DENIED_ACE(share); - break; - default: - throw new IllegalArgumentException("Unknown ACE type " - + aceType); + case ACCESS_ALLOWED_ACE_TYPE: + ace = new ACCESS_ALLOWED_ACE(share); + break; + case ACCESS_DENIED_ACE_TYPE: + ace = new ACCESS_DENIED_ACE(share); + break; + default: + throw new IllegalArgumentException("Unknown ACE type " + aceType); } ACEs[i] = ace; offset += ace.AceSize; } } - public byte AclRevision; - public byte Sbz1; - public short AclSize; - public short AceCount; - public short Sbz2; - - private ACCESS_ACEStructure[] ACEs; - public ACCESS_ACEStructure[] getACEStructures() { return ACEs; } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } public static class SECURITY_DESCRIPTOR_RELATIVE extends Structure { @@ -2492,6 +2516,8 @@ public static class ByReference extends SECURITY_DESCRIPTOR_RELATIVE implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder("Revision", "Sbz1", "Control", "Owner", "Group", "Sacl", "Dacl"); + public byte Revision; public byte Sbz1; public short Control; @@ -2500,17 +2526,13 @@ public static class ByReference extends SECURITY_DESCRIPTOR_RELATIVE public int Sacl; public int Dacl; - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "Revision", "Sbz1", "Control", "Owner", "Group", "Sacl", "Dacl" }); - } - private ACL DACL; private PSID OWNER; private PSID GROUP; private ACL SACL; public SECURITY_DESCRIPTOR_RELATIVE() { + super(); } public SECURITY_DESCRIPTOR_RELATIVE(byte[] data) { @@ -2555,23 +2577,28 @@ private final void setMembers() { OWNER = new PSID(getPointer().share(Owner)); } } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } public static abstract class ACEStructure extends Structure { + public static final List FIELDS = createFieldsOrder("AceType", "AceFlags", "AceSize"); + public byte AceType; public byte AceFlags; public short AceSize; PSID psid; - public ACEStructure() { } - public ACEStructure(Pointer p) { - super(p); + public ACEStructure() { + super(); } - @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "AceType", "AceFlags", "AceSize" }); + public ACEStructure(Pointer p) { + super(p); } public String getSidString() { @@ -2581,11 +2608,19 @@ public String getSidString() { public PSID getSID() { return psid; } + + @Override + protected List getFieldOrder() { + return FIELDS; + } } /* ACE header */ public static class ACE_HEADER extends ACEStructure { - public ACE_HEADER() { } + public ACE_HEADER() { + super(); + } + public ACE_HEADER(Pointer p) { super(p); read(); @@ -2596,13 +2631,31 @@ public ACE_HEADER(Pointer p) { * ACCESS_ALLOWED_ACE and ACCESS_DENIED_ACE have the same structure layout */ public static abstract class ACCESS_ACEStructure extends ACEStructure { - @Override - protected List getFieldOrder() { - List list = new ArrayList(super.getFieldOrder()); - list.addAll(Arrays.asList(new String[] { "Mask", "SidStart"})); - return list; + public static final List EXTRA_ABSTRACT_FIELDS = createFieldsOrder("Mask", "SidStart"); + private static final AtomicReference> fieldsHolder = new AtomicReference>(null); + private static List resolveEffectiveFields(List baseFields) { + List fields; + synchronized (fieldsHolder) { + fields = fieldsHolder.get(); + if (fields == null) { + fields = createFieldsOrder(baseFields, EXTRA_ABSTRACT_FIELDS); + fieldsHolder.set(fields); + } + } + + return fields; } - public ACCESS_ACEStructure() { } + + public int Mask; + /** + * first 4 bytes of the SID + */ + public DWORD SidStart; + + public ACCESS_ACEStructure() { + super(); + } + public ACCESS_ACEStructure(Pointer p) { super(p); read(); @@ -2615,17 +2668,18 @@ public ACCESS_ACEStructure(Pointer p) { psid = new PSID(data); } - public int Mask; - - /** - * first 4 bytes of the SID - */ - public DWORD SidStart; + @Override + protected List getFieldOrder() { + return resolveEffectiveFields(super.getFieldOrder()); + } } /* Access allowed ACE */ public static class ACCESS_ALLOWED_ACE extends ACCESS_ACEStructure { - public ACCESS_ALLOWED_ACE() { } + public ACCESS_ALLOWED_ACE() { + super(); + } + public ACCESS_ALLOWED_ACE(Pointer p) { super(p); } @@ -2633,7 +2687,10 @@ public ACCESS_ALLOWED_ACE(Pointer p) { /* Access denied ACE */ public static class ACCESS_DENIED_ACE extends ACCESS_ACEStructure { - public ACCESS_DENIED_ACE() { } + public ACCESS_DENIED_ACE() { + super(); + } + public ACCESS_DENIED_ACE(Pointer p) { super(p); } @@ -2681,14 +2738,17 @@ public static class GENERIC_MAPPING extends Structure { public static class ByReference extends GENERIC_MAPPING implements Structure.ByReference { } + public static final List FIELDS = createFieldsOrder( + "genericRead", "genericWrite", "genericExecute", "genericAll"); + public DWORD genericRead; public DWORD genericWrite; public DWORD genericExecute; public DWORD genericAll; @Override - protected List getFieldOrder() { - return Arrays.asList("genericRead", "genericWrite", "genericExecute", "genericAll"); + protected List getFieldOrder() { + return FIELDS; } } @@ -2697,6 +2757,8 @@ protected List getFieldOrder() { * {@link Kernel32#GetLogicalProcessorInformation} function. */ public static class SYSTEM_LOGICAL_PROCESSOR_INFORMATION extends Structure { + public static final List FIELDS = createFieldsOrder("processorMask", "relationship", "payload"); + /** * The processor mask identifying the processors described by this structure. A processor mask is a bit * vector in which each set bit represents an active processor in the relationship. @@ -2721,6 +2783,7 @@ public static class SYSTEM_LOGICAL_PROCESSOR_INFORMATION extends Structure { public AnonymousUnionPayload payload; public SYSTEM_LOGICAL_PROCESSOR_INFORMATION() { + super(); } public SYSTEM_LOGICAL_PROCESSOR_INFORMATION(Pointer memory) { @@ -2729,8 +2792,8 @@ public SYSTEM_LOGICAL_PROCESSOR_INFORMATION(Pointer memory) { } @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "processorMask", "relationship", "payload" }); + protected List getFieldOrder() { + return FIELDS; } public static class AnonymousUnionPayload extends Union { @@ -2764,6 +2827,7 @@ public static class AnonymousUnionPayload extends Union { } public static class AnonymousStructProcessorCore extends Structure { + public static final List FIELDS = createFieldsOrder("flags"); /** *

    If the value of this mmeber is {@code 1}, the logical processors identified by the value of the * {@link #processorMask} member share functional units, as in Hyperthreading or SMT. Otherwise, the @@ -2775,12 +2839,13 @@ public static class AnonymousStructProcessorCore extends Structure { public BYTE flags; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "flags" }); + protected List getFieldOrder() { + return FIELDS; } } public static class AnonymousStructNumaNode extends Structure { + public static final List FIELDS = createFieldsOrder("nodeNumber"); /** * Identifies the NUMA node. Valid values are {@code 0} to the highest NUMA node number inclusive. * A non-NUMA multiprocessor system will report that all processors belong to one NUMA node. @@ -2788,8 +2853,8 @@ public static class AnonymousStructNumaNode extends Structure { public DWORD nodeNumber; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "nodeNumber" }); + protected List getFieldOrder() { + return FIELDS; } } } @@ -2846,6 +2911,7 @@ public interface LOGICAL_PROCESSOR_RELATIONSHIP { * Describes the cache attributes. */ public static class CACHE_DESCRIPTOR extends Structure { + public static final List FIELDS = createFieldsOrder("level", "associativity", "lineSize", "size", "type"); /** * The cache level. This member can be 1, 2 or 3, corresponding to L1, L2 or L3 cache, respectively (other * values may be supported in the future.) @@ -2876,8 +2942,8 @@ public static class CACHE_DESCRIPTOR extends Structure { public int /* PROCESSOR_CACHE_TYPE */ type; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[] { "level", "associativity", "lineSize", "size", "type" }); + protected List getFieldOrder() { + return FIELDS; } } @@ -2939,6 +3005,8 @@ public static abstract class PROCESSOR_CACHE_TYPE { int MEM_PRIVATE = 0x20000; public static class MEMORY_BASIC_INFORMATION extends Structure { + public static final List FIELDS = createFieldsOrder("baseAddress", "allocationBase", "allocationProtect", + "regionSize", "state", "protect", "type"); /** * A pointer to the base address of the region of pages. @@ -2989,11 +3057,8 @@ public static class MEMORY_BASIC_INFORMATION extends Structure { public DWORD type; @Override - protected List getFieldOrder() { - return Arrays.asList(new String[]{ - "baseAddress", "allocationBase", "allocationProtect", - "regionSize", "state", "protect", "type" - }); + protected List getFieldOrder() { + return FIELDS; } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinPerf.java b/contrib/platform/src/com/sun/jna/platform/win32/WinPerf.java index 0dc4ce4f35..564a08b376 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinPerf.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinPerf.java @@ -12,7 +12,6 @@ */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Structure; @@ -30,6 +29,13 @@ public interface WinPerf { * @see PERF_DATA_BLOCK */ public class PERF_DATA_BLOCK extends Structure { + public static final List FIELDS = createFieldsOrder( + "Signature", "LittleEndian", "Version", + "Revision", "TotalByteLength", "HeaderLength", + "NumObjectTypes", "DefaultObject", "SystemTime", + "PerfTime", "PerfFreq", "PerfTime100nSec", + "SystemNameLength", "SystemNameOffset"); + public char[] Signature = new char[4]; public int LittleEndian; public int Version; @@ -47,11 +53,7 @@ public class PERF_DATA_BLOCK extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList("Signature", "LittleEndian", "Version", - "Revision", "TotalByteLength", "HeaderLength", - "NumObjectTypes", "DefaultObject", "SystemTime", - "PerfTime", "PerfFreq", "PerfTime100nSec", - "SystemNameLength", "SystemNameOffset"); + return FIELDS; } }; @@ -60,6 +62,10 @@ protected List getFieldOrder() { * @see PERF_INSTANCE_DEFINITION */ public class PERF_INSTANCE_DEFINITION extends Structure { + public static final List FIELDS = createFieldsOrder( + "ByteLength", "ParentObjectTitleIndex", "ParentObjectInstance", + "UniqueID", "NameOffset", "NameLength"); + public int ByteLength; public int ParentObjectTitleIndex; public int ParentObjectInstance; @@ -69,12 +75,11 @@ public class PERF_INSTANCE_DEFINITION extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList("ByteLength", "ParentObjectTitleIndex", "ParentObjectInstance", - "UniqueID", "NameOffset", "NameLength"); + return FIELDS; } }; - public static final int PERF_NO_INSTANCES = -1; // no instances (see NumInstances above) + int PERF_NO_INSTANCES = -1; // no instances (see NumInstances above) // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -96,121 +101,121 @@ protected List getFieldOrder() { // // select one of the following to indicate the counter's data size // - public static final int PERF_SIZE_DWORD = 0x00000000; // 32 bit field - public static final int PERF_SIZE_LARGE = 0x00000100; // 64 bit field - public static final int PERF_SIZE_ZERO = 0x00000200; // for Zero Length fields - public static final int PERF_SIZE_VARIABLE_LEN = 0x00000300; // length is in CounterLength field + int PERF_SIZE_DWORD = 0x00000000; // 32 bit field + int PERF_SIZE_LARGE = 0x00000100; // 64 bit field + int PERF_SIZE_ZERO = 0x00000200; // for Zero Length fields + int PERF_SIZE_VARIABLE_LEN = 0x00000300; // length is in CounterLength field // of Counter Definition struct // // select one of the following values to indicate the counter field usage // - public static final int PERF_TYPE_NUMBER = 0x00000000; // a number (not a counter) - public static final int PERF_TYPE_COUNTER = 0x00000400; // an increasing numeric value - public static final int PERF_TYPE_TEXT = 0x00000800; // a text field - public static final int PERF_TYPE_ZERO = 0x00000C00; // displays a zero + int PERF_TYPE_NUMBER = 0x00000000; // a number (not a counter) + int PERF_TYPE_COUNTER = 0x00000400; // an increasing numeric value + int PERF_TYPE_TEXT = 0x00000800; // a text field + int PERF_TYPE_ZERO = 0x00000C00; // displays a zero // // If the PERF_TYPE_NUMBER field was selected, then select one of the // following to describe the Number // - public static final int PERF_NUMBER_HEX = 0x00000000; // display as HEX value - public static final int PERF_NUMBER_DECIMAL = 0x00010000; // display as a decimal integer - public static final int PERF_NUMBER_DEC_1000 = 0x00020000; // display as a decimal/1000 + int PERF_NUMBER_HEX = 0x00000000; // display as HEX value + int PERF_NUMBER_DECIMAL = 0x00010000; // display as a decimal integer + int PERF_NUMBER_DEC_1000 = 0x00020000; // display as a decimal/1000 // // If the PERF_TYPE_COUNTER value was selected then select one of the // following to indicate the type of counter // - public static final int PERF_COUNTER_VALUE = 0x00000000; // display counter value - public static final int PERF_COUNTER_RATE = 0x00010000; // divide ctr / delta time - public static final int PERF_COUNTER_FRACTION = 0x00020000; // divide ctr / base - public static final int PERF_COUNTER_BASE = 0x00030000; // base value used in fractions - public static final int PERF_COUNTER_ELAPSED = 0x00040000; // subtract counter from current time - public static final int PERF_COUNTER_QUEUELEN = 0x00050000; // Use Queuelen processing func. - public static final int PERF_COUNTER_HISTOGRAM = 0x00060000; // Counter begins or ends a histogram - public static final int PERF_COUNTER_PRECISION = 0x00070000; // divide ctr / private clock + int PERF_COUNTER_VALUE = 0x00000000; // display counter value + int PERF_COUNTER_RATE = 0x00010000; // divide ctr / delta time + int PERF_COUNTER_FRACTION = 0x00020000; // divide ctr / base + int PERF_COUNTER_BASE = 0x00030000; // base value used in fractions + int PERF_COUNTER_ELAPSED = 0x00040000; // subtract counter from current time + int PERF_COUNTER_QUEUELEN = 0x00050000; // Use Queuelen processing func. + int PERF_COUNTER_HISTOGRAM = 0x00060000; // Counter begins or ends a histogram + int PERF_COUNTER_PRECISION = 0x00070000; // divide ctr / private clock // // If the PERF_TYPE_TEXT value was selected, then select one of the // following to indicate the type of TEXT data. // - public static final int PERF_TEXT_UNICODE = 0x00000000; // type of text in text field - public static final int PERF_TEXT_ASCII = 0x00010000; // ASCII using the CodePage field + int PERF_TEXT_UNICODE = 0x00000000; // type of text in text field + int PERF_TEXT_ASCII = 0x00010000; // ASCII using the CodePage field // // Timer SubTypes // - public static final int PERF_TIMER_TICK = 0x00000000; // use system perf. freq for base - public static final int PERF_TIMER_100NS = 0x00100000; // use 100 NS timer time base units - public static final int PERF_OBJECT_TIMER = 0x00200000; // use the object timer freq + int PERF_TIMER_TICK = 0x00000000; // use system perf. freq for base + int PERF_TIMER_100NS = 0x00100000; // use 100 NS timer time base units + int PERF_OBJECT_TIMER = 0x00200000; // use the object timer freq // // Any types that have calculations performed can use one or more of // the following calculation modification flags listed here // - public static final int PERF_DELTA_COUNTER = 0x00400000; // compute difference first - public static final int PERF_DELTA_BASE = 0x00800000; // compute base diff as well - public static final int PERF_INVERSE_COUNTER = 0x01000000; // show as 1.00-value (assumes: - public static final int PERF_MULTI_COUNTER = 0x02000000; // sum of multiple instances + int PERF_DELTA_COUNTER = 0x00400000; // compute difference first + int PERF_DELTA_BASE = 0x00800000; // compute base diff as well + int PERF_INVERSE_COUNTER = 0x01000000; // show as 1.00-value (assumes: + int PERF_MULTI_COUNTER = 0x02000000; // sum of multiple instances // // Select one of the following values to indicate the display suffix (if any) // - public static final int PERF_DISPLAY_NO_SUFFIX = 0x00000000; // no suffix - public static final int PERF_DISPLAY_PER_SEC = 0x10000000; // "/sec" - public static final int PERF_DISPLAY_PERCENT = 0x20000000; // "%" - public static final int PERF_DISPLAY_SECONDS = 0x30000000; // "secs" - public static final int PERF_DISPLAY_NOSHOW = 0x40000000; // value is not displayed + int PERF_DISPLAY_NO_SUFFIX = 0x00000000; // no suffix + int PERF_DISPLAY_PER_SEC = 0x10000000; // "/sec" + int PERF_DISPLAY_PERCENT = 0x20000000; // "%" + int PERF_DISPLAY_SECONDS = 0x30000000; // "secs" + int PERF_DISPLAY_NOSHOW = 0x40000000; // value is not displayed // // Predefined counter types // // 32-bit Counter. Divide delta by delta time. Display suffix: "/sec" - public static final int PERF_COUNTER_COUNTER = + int PERF_COUNTER_COUNTER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC); // 64-bit Timer. Divide delta by delta time. Display suffix: "%" - public static final int PERF_COUNTER_TIMER = + int PERF_COUNTER_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix. - public static final int PERF_COUNTER_QUEUELEN_TYPE = + int PERF_COUNTER_QUEUELEN_TYPE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix. - public static final int PERF_COUNTER_LARGE_QUEUELEN_TYPE = + int PERF_COUNTER_LARGE_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product using 100 Ns timebase. // Divide delta by delta time. No Display Suffix. - public static final int PERF_COUNTER_100NS_QUEUELEN_TYPE = + int PERF_COUNTER_100NS_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // Queue Length Space-Time Product using Object specific timebase. // Divide delta by delta time. No Display Suffix. - public static final int PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE = + int PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_QUEUELEN | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // 64-bit Counter. Divide delta by delta time. Display Suffix: "/sec" - public static final int PERF_COUNTER_BULK_COUNT = + int PERF_COUNTER_BULK_COUNT = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PER_SEC); // Indicates the counter is not a counter but rather Unicode text Display as text. - public static final int PERF_COUNTER_TEXT = + int PERF_COUNTER_TEXT = (PERF_SIZE_VARIABLE_LEN | PERF_TYPE_TEXT | PERF_TEXT_UNICODE | PERF_DISPLAY_NO_SUFFIX); // Indicates the data is a counter which should not be // time averaged on display (such as an error counter on a serial line) // Display as is. No Display Suffix. - public static final int PERF_COUNTER_RAWCOUNT = + int PERF_COUNTER_RAWCOUNT = (PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL | PERF_DISPLAY_NO_SUFFIX); // Same as PERF_COUNTER_RAWCOUNT except its size is a large integer - public static final int PERF_COUNTER_LARGE_RAWCOUNT = + int PERF_COUNTER_LARGE_RAWCOUNT = (PERF_SIZE_LARGE | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL | PERF_DISPLAY_NO_SUFFIX); @@ -218,36 +223,36 @@ protected List getFieldOrder() { // Indicates the data is a counter which should not be // time averaged on display (such as an error counter on a serial line) // Display as is. No Display Suffix. - public static final int PERF_COUNTER_RAWCOUNT_HEX = + int PERF_COUNTER_RAWCOUNT_HEX = (PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_HEX | PERF_DISPLAY_NO_SUFFIX); // Same as PERF_COUNTER_RAWCOUNT_HEX except its size is a large integer - public static final int PERF_COUNTER_LARGE_RAWCOUNT_HEX = + int PERF_COUNTER_LARGE_RAWCOUNT_HEX = (PERF_SIZE_LARGE | PERF_TYPE_NUMBER | PERF_NUMBER_HEX | PERF_DISPLAY_NO_SUFFIX); // A count which is either 1 or 0 on each sampling interrupt (% busy) // Divide delta by delta base. Display Suffix: "%" - public static final int PERF_SAMPLE_FRACTION = + int PERF_SAMPLE_FRACTION = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DELTA_COUNTER | PERF_DELTA_BASE | PERF_DISPLAY_PERCENT); // A count which is sampled on each sampling interrupt (queue length) // Divide delta by delta time. No Display Suffix. - public static final int PERF_SAMPLE_COUNTER = + int PERF_SAMPLE_COUNTER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // A label: no data is associated with this counter (it has 0 length) // Do not display. - public static final int PERF_COUNTER_NODATA = + int PERF_COUNTER_NODATA = (PERF_SIZE_ZERO | PERF_DISPLAY_NOSHOW); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 - delta divided by delta time. Display suffix: "%" - public static final int PERF_COUNTER_TIMER_INV = + int PERF_COUNTER_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); @@ -256,7 +261,7 @@ protected List getFieldOrder() { // sampled %. You must check for >0 before dividing by this! This // counter will directly follow the numerator counter. It should not // be displayed to the user. - public static final int PERF_SAMPLE_BASE = + int PERF_SAMPLE_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000001); // for compatibility with pre-beta versions @@ -265,14 +270,14 @@ protected List getFieldOrder() { // in seconds which is the average time of some operation. This // timer times total operations, and the base is the number of opera- // tions. Display Suffix: "sec" - public static final int PERF_AVERAGE_TIMER = + int PERF_AVERAGE_TIMER = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_SECONDS); // Used as the denominator in the computation of time or count // averages. Must directly follow the numerator counter. Not dis- // played to the user. - public static final int PERF_AVERAGE_BASE = + int PERF_AVERAGE_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000002); // for compatibility with pre-beta versions @@ -281,33 +286,33 @@ protected List getFieldOrder() { // A bulk count which, when divided (typically) by the number of // operations, gives (typically) the number of bytes per operation. // No Display Suffix. - public static final int PERF_AVERAGE_BULK = + int PERF_AVERAGE_BULK = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_NOSHOW); // 64-bit Timer in object specific units. Display delta divided by // delta time as returned in the object type header structure. Display suffix: "%" - public static final int PERF_OBJ_TIME_TIMER = + int PERF_OBJ_TIME_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer in 100 nsec units. Display delta divided by // delta time. Display suffix: "%" - public static final int PERF_100NSEC_TIMER = + int PERF_100NSEC_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer inverse (e.g., idle is measured, but display busy %) // Display 100 - delta divided by delta time. Display suffix: "%" - public static final int PERF_100NSEC_TIMER_INV = + int PERF_100NSEC_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // 64-bit Timer. Divide delta by delta time. Display suffix: "%" // Timer for multiple instances, so result can exceed 100%. - public static final int PERF_COUNTER_MULTI_TIMER = + int PERF_COUNTER_MULTI_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_DELTA_COUNTER | PERF_TIMER_TICK | PERF_MULTI_COUNTER | PERF_DISPLAY_PERCENT); @@ -316,20 +321,20 @@ protected List getFieldOrder() { // Display 100 * _MULTI_BASE - delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result // can exceed 100%. Followed by a counter of type _MULTI_BASE. - public static final int PERF_COUNTER_MULTI_TIMER_INV = + int PERF_COUNTER_MULTI_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_RATE | PERF_DELTA_COUNTER | PERF_MULTI_COUNTER | PERF_TIMER_TICK | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); // Number of instances to which the preceding _MULTI_..._INV counter // applies. Used as a factor to get the percentage. - public static final int PERF_COUNTER_MULTI_BASE = + int PERF_COUNTER_MULTI_BASE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_MULTI_COUNTER | PERF_DISPLAY_NOSHOW); // 64-bit Timer in 100 nsec units. Display delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result can exceed 100%. - public static final int PERF_100NSEC_MULTI_TIMER = + int PERF_100NSEC_MULTI_TIMER = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_DELTA_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_MULTI_COUNTER | PERF_DISPLAY_PERCENT); @@ -338,7 +343,7 @@ protected List getFieldOrder() { // Display 100 * _MULTI_BASE - delta divided by delta time. // Display suffix: "%" Timer for multiple instances, so result // can exceed 100%. Followed by a counter of type _MULTI_BASE. - public static final int PERF_100NSEC_MULTI_TIMER_INV = + int PERF_100NSEC_MULTI_TIMER_INV = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_DELTA_COUNTER | PERF_COUNTER_RATE | PERF_TIMER_100NS | PERF_MULTI_COUNTER | PERF_INVERSE_COUNTER | PERF_DISPLAY_PERCENT); @@ -346,22 +351,22 @@ protected List getFieldOrder() { // Indicates the data is a fraction of the following counter which // should not be time averaged on display (such as free space over // total space.) Display as is. Display the quotient as "%". - public static final int PERF_RAW_FRACTION = + int PERF_RAW_FRACTION = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_PERCENT); - public static final int PERF_LARGE_RAW_FRACTION = + int PERF_LARGE_RAW_FRACTION = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_FRACTION | PERF_DISPLAY_PERCENT); // Indicates the data is a base for the preceding counter which should // not be time averaged on display (such as free space over total space.) - public static final int PERF_RAW_BASE = + int PERF_RAW_BASE = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW | 0x00000003); // for compatibility with pre-beta versions - public static final int PERF_LARGE_RAW_BASE = + int PERF_LARGE_RAW_BASE = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_BASE | PERF_DISPLAY_NOSHOW ); @@ -372,7 +377,7 @@ protected List getFieldOrder() { // the sample time as indicated by the PERF_OBJECT_TIMER bit and the // difference is scaled by the PerfFreq of the Object to convert the time // units into seconds. - public static final int PERF_ELAPSED_TIME = + int PERF_ELAPSED_TIME = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_ELAPSED | PERF_OBJECT_TIMER | PERF_DISPLAY_SECONDS); // @@ -380,7 +385,7 @@ protected List getFieldOrder() { // define a range of values to be displayed in a histogram. // - public static final int PERF_COUNTER_HISTOGRAM_TYPE = 0x80000000; // Counter begins or ends a histogram + int PERF_COUNTER_HISTOGRAM_TYPE = 0x80000000; // Counter begins or ends a histogram // // This counter is used to display the difference from one sample // to the next. The counter value is a constantly increasing number @@ -389,11 +394,11 @@ protected List getFieldOrder() { // which shouldn't be a problem as long as the counter value is // increasing or unchanged. // - public static final int PERF_COUNTER_DELTA = + int PERF_COUNTER_DELTA = (PERF_SIZE_DWORD | PERF_TYPE_COUNTER | PERF_COUNTER_VALUE | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); - public static final int PERF_COUNTER_LARGE_DELTA = + int PERF_COUNTER_LARGE_DELTA = (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_VALUE | PERF_DELTA_COUNTER | PERF_DISPLAY_NO_SUFFIX); // @@ -414,38 +419,38 @@ protected List getFieldOrder() { // definition of the PERF_PRECISION_*_TIMER in the Object header // // The timer used has the same frequency as the System Performance Timer - public static final int PERF_PRECISION_SYSTEM_TIMER = - (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | + int PERF_PRECISION_SYSTEM_TIMER = + (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_TIMER_TICK | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT ); // // The timer used has the same frequency as the 100 NanoSecond Timer - public static final int PERF_PRECISION_100NS_TIMER = - (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | + int PERF_PRECISION_100NS_TIMER = + (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_TIMER_100NS | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT ); // // The timer used is of the frequency specified in the Object header's // PerfFreq field (PerfTime is ignored) - public static final int PERF_PRECISION_OBJECT_TIMER = - (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | + int PERF_PRECISION_OBJECT_TIMER = + (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_PRECISION | PERF_OBJECT_TIMER | PERF_DELTA_COUNTER | PERF_DISPLAY_PERCENT ); // // This is the timestamp to use in the computation of the timer specified // in the previous description block - public static final int PERF_PRECISION_TIMESTAMP = PERF_LARGE_RAW_BASE; + int PERF_PRECISION_TIMESTAMP = PERF_LARGE_RAW_BASE; // // The following are used to determine the level of detail associated // with the counter. The user will be setting the level of detail // that should be displayed at any given time. // // - public static final int PERF_DETAIL_NOVICE = 100; // The uninformed can understand it - public static final int PERF_DETAIL_ADVANCED = 200; // For the advanced user - public static final int PERF_DETAIL_EXPERT = 300; // For the expert user - public static final int PERF_DETAIL_WIZARD = 400; // For the system designer + int PERF_DETAIL_NOVICE = 100; // The uninformed can understand it + int PERF_DETAIL_ADVANCED = 200; // For the advanced user + int PERF_DETAIL_EXPERT = 300; // For the expert user + int PERF_DETAIL_WIZARD = 400; // For the system designer - public static final int PERF_NO_UNIQUE_ID = -1; + int PERF_NO_UNIQUE_ID = -1; - public static final int PERF_QUERY_OBJECTS = 0x80000000; - public static final int PERF_QUERY_GLOBAL = 0x80000001; - public static final int PERF_QUERY_COSTLY = 0x80000002; + int PERF_QUERY_OBJECTS = 0x80000000; + int PERF_QUERY_GLOBAL = 0x80000001; + int PERF_QUERY_COSTLY = 0x80000002; } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinRas.java b/contrib/platform/src/com/sun/jna/platform/win32/WinRas.java index 331042abf0..e8babbbb63 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinRas.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinRas.java @@ -1,10 +1,10 @@ /* Copyright (c) 2011 Timothy Wall, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -99,9 +99,8 @@ public RASEAPINFO(String s) { */ public Pointer pbEapInfo; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSizeofEapInfo", "pbEapInfo", }); } /** @@ -148,9 +147,8 @@ public RASDEVSPECIFICINFO(String s) { */ public Pointer pbDevSpecificInfo; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "pbDevSpecificInfo", }); } /** @@ -219,9 +217,8 @@ public static class ByReference extends RASDIALEXTENSIONS implements Structure.B */ public RASDEVSPECIFICINFO RasDevSpecificInfo; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "dwfOptions", "hwndParent", "reserved", "reserved1", "RasEapInfo", "fSkipPppAuth", "RasDevSpecificInfo", }); } } @@ -277,9 +274,8 @@ public static class ByReference extends RASDIALPARAMS implements Structure.ByRef */ public char[] szDomain = new char[DNLEN + 1]; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "szEntryName", "szPhoneNumber", "szCallbackNumber", "szUserName", "szPassword", "szDomain", }); } } @@ -348,9 +344,8 @@ public static class ByReference extends RASCONN implements Structure.ByReference */ public GUID guidCorrelationId; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "hrasconn", "szEntryName", "szDeviceType", "szDeviceName", "szPhonebook", "dwSubEntry", "guidEntry", "dwFlags", "luid", "guidCorrelationId" }); } } @@ -430,9 +425,8 @@ public RAS_STATS(Pointer memory) { */ public int dwConnectDuration; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "dwBytesXmited", "dwBytesRcved", "dwFramesXmited", "dwFramesRcved", "dwCrcErr", "dwTimeoutErr", "dwAlignmentErr", "dwHardwareOverrunErr", "dwFramingErr", "dwBufferOverrunErr", "dwCompressionRatioIn", "dwCompressionRatioOut", "dwBps", "dwConnectDuration", }); } } @@ -455,9 +449,8 @@ public RASIPV4ADDR(Pointer memory) { */ public byte[] addr = new byte[8]; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "addr", }); } } @@ -480,9 +473,8 @@ public RASIPV6ADDR(Pointer memory) { */ public byte[] addr = new byte[16]; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "addr", }); } } @@ -534,9 +526,8 @@ public static class ByReference extends RASPPPIP implements Structure.ByReferenc */ public int dwServerOptions; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "dwError", "szIpAddress", "szServerIpAddress", "dwOptions", "dwServerOptions",}); } } @@ -572,9 +563,8 @@ public static class ByReference extends UNION implements Structure.ByReference */ public UNION u; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwType", "u", }); } @@ -654,9 +644,8 @@ public RASCONNSTATUS(Pointer memory) { */ public int rasconnsubstate; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "rasconnstate", "dwError", "szDeviceType", "szDeviceName", "szPhoneNumber", "localEndPoint", "remoteEndPoint", "rasconnsubstate" }); } } @@ -699,9 +688,8 @@ public static class ByReference extends RASCREDENTIALS implements Structure.ByRe */ public char[] szDomain = new char[DNLEN + 1]; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "dwMask", "szUserName", "szPassword", "szDomain", }); } } @@ -722,9 +710,8 @@ public RASIPADDR(Pointer memory) { public byte[] addr = new byte[4]; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "addr", }); } } @@ -1016,9 +1003,8 @@ public static class ByReference extends RASENTRY implements Structure.ByReferenc */ public int dwNetworkOutageTime; - @SuppressWarnings("rawtypes") @Override - protected List getFieldOrder() { + protected List getFieldOrder() { return Arrays.asList(new String[] { "dwSize", "dwfOptions", "dwCountryID", "dwCountryCode", "szAreaCode", "szLocalPhoneNumber", "dwAlternateOffset", "ipaddr", "ipaddrDns", "ipaddrDnsAlt", "ipaddrWins", "ipaddrWinsAlt", "dwFrameSize", "dwfNetProtocols", "dwFramingProtocol", "szScript", "szAutodialDll", "szAutodialFunc", "szDeviceType", "szDeviceName", "szX25PadType", "szX25Address", "szX25Facilities", "szX25UserData" , diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java index 3811321cd8..36ab452206 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java @@ -416,7 +416,7 @@ public static interface WinEventProc extends Callback { void callback(HANDLE hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime); } - + /** Specifies the width and height of a rectangle. */ public class SIZE extends Structure { public int cx, cy; @@ -441,6 +441,8 @@ protected List getFieldOrder() { int AC_SRC_NO_ALPHA = 0x02; public class BLENDFUNCTION extends Structure { + public static final List FIELDS = createFieldsOrder("BlendOp", "BlendFlags", "SourceConstantAlpha", "AlphaFormat"); + public byte BlendOp = AC_SRC_OVER; // only valid value public byte BlendFlags = 0; // only valid value public byte SourceConstantAlpha; @@ -448,8 +450,7 @@ public class BLENDFUNCTION extends Structure { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "BlendOp", "BlendFlags", - "SourceConstantAlpha", "AlphaFormat" }); + return FIELDS; } } @@ -912,14 +913,14 @@ protected List getFieldOrder() { * BS_RIGHTBUTTON style. */ int BS_LEFTTEXT = 0x00000020; - + /** * Used by User32.SetWindowPos.
    * Prevents the window from receiving the WM_WINDOWPOSCHANGING message. */ int SWP_NOSENDCHANGING = 0x0400; - - + + /** * Contains information about a simulated message generated by an input * device other than a keyboard or mouse. @@ -1314,12 +1315,12 @@ public HMONITOR(Pointer p) /** *

    The MONITORINFO structure contains information about a display monitor.

    - * The {@link User32#GetMonitorInfo} function stores + * The {@link User32#GetMonitorInfo} function stores * information into a MONITORINFO structure

    - * The MONITORINFO structure is a subset of the MONITORINFOEX structure. + * The MONITORINFO structure is a subset of the MONITORINFOEX structure. */ - public class MONITORINFO extends Structure - { + public class MONITORINFO extends Structure { + public static final List FIELDS = createFieldsOrder("cbSize", "rcMonitor", "rcWork", "dwFlags"); /** * The size, in bytes, of the structure. */ @@ -1349,21 +1350,20 @@ public class MONITORINFO extends Structure public int dwFlags; @Override - protected List getFieldOrder() - { - return Arrays.asList("cbSize", "rcMonitor", "rcWork", "dwFlags"); + protected List getFieldOrder() { + return FIELDS; } } /** *

    The MONITORINFOEX structure contains information about a display monitor.

    - * The {@link User32#GetMonitorInfo} function stores + * The {@link User32#GetMonitorInfo} function stores * information into a MONITORINFOEX structure

    - * The MONITORINFOEX structure is a superset of the MONITORINFO structure. - * The MONITORINFOEX structure adds a string member to contain a name for the display monitor. + * The MONITORINFOEX structure is a superset of the MONITORINFO structure. + * The MONITORINFOEX structure adds a string member to contain a name for the display monitor. */ - public class MONITORINFOEX extends Structure - { + public class MONITORINFOEX extends Structure { + public static final List FIELDS = createFieldsOrder("cbSize", "rcMonitor", "rcWork", "dwFlags", "szDevice"); /** * The size, in bytes, of the structure. */ @@ -1399,35 +1399,33 @@ public class MONITORINFOEX extends Structure */ public char[] szDevice; - public MONITORINFOEX() - { + public MONITORINFOEX() { szDevice = new char[CCHDEVICENAME]; cbSize = size(); } @Override - protected List getFieldOrder() - { - return Arrays.asList("cbSize", "rcMonitor", "rcWork", "dwFlags", "szDevice"); + protected List getFieldOrder() { + return FIELDS; } } /** * An application-defined callback function that is called by the {@link User32#EnumDisplayMonitors} function. *

    - * You can use the EnumDisplayMonitors function to enumerate the set of display monitors that intersect - * the visible region of a specified device context and, optionally, a clipping rectangle. To do this, + * You can use the EnumDisplayMonitors function to enumerate the set of display monitors that intersect + * the visible region of a specified device context and, optionally, a clipping rectangle. To do this, * set the hdc parameter to a non-NULL value, and set the lprcClip parameter as needed. *

    - * You can also use the EnumDisplayMonitors function to enumerate one or more of the display monitors on - * the desktop, without supplying a device context. To do this, set the hdc parameter of + * You can also use the EnumDisplayMonitors function to enumerate one or more of the display monitors on + * the desktop, without supplying a device context. To do this, set the hdc parameter of * EnumDisplayMonitors to NULL and set the lprcClip parameter as needed. *

    - * In all cases, EnumDisplayMonitors calls a specified MonitorEnumProc function once for each display - * monitor in the calculated enumeration set. The MonitorEnumProc function always receives a handle to - * the display monitor. If the hdc parameter of EnumDisplayMonitors is non-NULL, the MonitorEnumProc - * function also receives a handle to a device context whose color format is appropriate for the - * display monitor. You can then paint into the device context in a manner that is optimal for the + * In all cases, EnumDisplayMonitors calls a specified MonitorEnumProc function once for each display + * monitor in the calculated enumeration set. The MonitorEnumProc function always receives a handle to + * the display monitor. If the hdc parameter of EnumDisplayMonitors is non-NULL, the MonitorEnumProc + * function also receives a handle to a device context whose color format is appropriate for the + * display monitor. You can then paint into the device context in a manner that is optimal for the * display monitor. */ public interface MONITORENUMPROC extends StdCallCallback @@ -1496,25 +1494,25 @@ public interface MONITORENUMPROC extends StdCallCallback /* GetAncestor properties */ /** * Retrieves the parent window. This does not include the owner, as it does with the GetParent function. - * + * * @see MSDN */ int GA_PARENT = 1; - + /** * Retrieves the root window by walking the chain of parent windows. - * + * * @see MSDN */ int GA_ROOT = 2; - + /** * Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent. - * + * * @see MSDN */ int GA_ROOTOWNER = 3; - + /* GetClassLong properties */ /** * Retrieves an ATOM value that uniquely identifies the window class. This @@ -1524,18 +1522,18 @@ public interface MONITORENUMPROC extends StdCallCallback /** * Retrieves a handle to the icon associated with the class. - * + * * @see MSDN */ int GCL_HICON = -14; /** * Retrieves a handle to the small icon associated with the class. - * + * * @see MSDN */ int GCL_HICONSM = -34; - + /** * Retrieves the size, in bytes, of the extra memory associated with the * class. @@ -1740,6 +1738,7 @@ public interface MONITORENUMPROC extends StdCallCallback * @see */ public class RAWINPUTDEVICELIST extends Structure { + public static final List FIELDS = createFieldsOrder("hDevice", "dwType"); public HANDLE hDevice; public int dwType; @@ -1757,7 +1756,7 @@ public int sizeof() { @Override protected List getFieldOrder() { - return Arrays.asList("hDevice", "dwType"); + return FIELDS; } @Override diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Wininet.java b/contrib/platform/src/com/sun/jna/platform/win32/Wininet.java index ecf84c997e..e1c4c59b14 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Wininet.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Wininet.java @@ -1,18 +1,17 @@ /* Copyright (c) 2015 Michael Freeman, All Rights Reserved - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * Lesser General Public License for more details. */ package com.sun.jna.platform.win32; -import java.util.Arrays; import java.util.List; import com.sun.jna.Native; @@ -79,7 +78,7 @@ public interface Wininet extends StdCallLibrary { /** * Closes the specified cache enumeration handle. - * + * * @param hFind * Handle returned by a previous call to the * FindFirstUrlCacheEntry function. @@ -106,7 +105,7 @@ public interface Wininet extends StdCallLibrary { /** * Begins the enumeration of the Internet cache. - * + * * @param lpszUrlSearchPattern * A pointer to a string that contains the source name pattern to * search for.
    @@ -171,7 +170,7 @@ boolean FindNextUrlCacheEntry(HANDLE hEnumHandle, INTERNET_CACHE_ENTRY_INFO lpNe /** * Contains information about an entry in the Internet cache. - * + * *
          * 
          * typedef struct _INTERNET_CACHE_ENTRY_INFO {
    @@ -195,14 +194,20 @@ boolean FindNextUrlCacheEntry(HANDLE hEnumHandle, INTERNET_CACHE_ENTRY_INFO lpNe
          *     DWORD dwExemptDelta;
          *   };
          * } INTERNET_CACHE_ENTRY_INFO, *LPINTERNET_CACHE_ENTRY_INFO;
    -     * 
    +     *
          *     
          * 
    - * + * * @see https://msdn.microsoft.com/en-us/library/windows/desktop/aa385134(v= * vs.85).aspx */ static class INTERNET_CACHE_ENTRY_INFO extends Structure { + public static final List FIELDS = createFieldsOrder( + "dwStructSize", "lpszSourceUrlName", "lpszLocalFileName", + "CacheEntryType", "dwUseCount", "dwHitRate", "dwSizeLow", "dwSizeHigh", "LastModifiedTime", + "ExpireTime", "LastAccessTime", "LastSyncTime", "lpHeaderInfo", "dwHeaderInfoSize", + "lpszFileExtension", "u", "additional"); + /** * Size of this structure, in bytes. This value can be used to help * determine the version of the cache system. @@ -330,7 +335,7 @@ public INTERNET_CACHE_ENTRY_INFO(int size) { /** * A union of the last two distinct fields in INTERNET_CACHE_ENTRY_INFO - * + * *
              * 
              *             union {
    @@ -352,11 +357,8 @@ public static class UNION extends Union {
             }
     
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList("dwStructSize", "lpszSourceUrlName", "lpszLocalFileName",
    -                    "CacheEntryType", "dwUseCount", "dwHitRate", "dwSizeLow", "dwSizeHigh", "LastModifiedTime",
    -                    "ExpireTime", "LastAccessTime", "LastSyncTime", "lpHeaderInfo", "dwHeaderInfoSize",
    -                    "lpszFileExtension", "u", "additional");
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
     
             @Override
    diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java b/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java
    index c697f11a42..b6abeeb18d 100644
    --- a/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java
    +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java
    @@ -10,7 +10,6 @@
      */
     package com.sun.jna.platform.win32;
     
    -import java.util.Arrays;
     import java.util.List;
     
     import com.sun.jna.Pointer;
    @@ -41,13 +40,7 @@ public ByReference(Pointer memory) {
                 }
             }
     
    -        public STORAGE_DEVICE_NUMBER() {
    -        }
    -
    -        public STORAGE_DEVICE_NUMBER(Pointer memory) {
    -            super(memory);
    -            read();
    -        }
    +		public static final List FIELDS = createFieldsOrder("DeviceType", "DeviceNumber", "PartitionNumber");
     
             /**
              * The type of device. Values from 0 through 32,767 are reserved for use by Microsoft. Values from 32,768
    @@ -64,9 +57,19 @@ public STORAGE_DEVICE_NUMBER(Pointer memory) {
              * The partition number of the device, if the device can be partitioned. Otherwise, this member is -1.
              */
             public int PartitionNumber;
    -        
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "DeviceType", "DeviceNumber", "PartitionNumber" });
    +
    +        public STORAGE_DEVICE_NUMBER() {
    +            super();
    +        }
    +
    +        public STORAGE_DEVICE_NUMBER(Pointer memory) {
    +            super(memory);
    +            read();
    +        }
    +
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     }
    diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winnetwk.java b/contrib/platform/src/com/sun/jna/platform/win32/Winnetwk.java
    index 07933e60f6..5a37ca6ede 100644
    --- a/contrib/platform/src/com/sun/jna/platform/win32/Winnetwk.java
    +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winnetwk.java
    @@ -1,20 +1,19 @@
     /* Copyright (c) 2015 Adam Marcionek, All Rights Reserved
    - * 
    + *
      *
      * This library is free software; you can redistribute it and/or
      * modify it under the terms of the GNU Lesser General Public
      * License as published by the Free Software Foundation; either
      * version 2.1 of the License, or (at your option) any later version.
    - * 
    + *
      * This library is distributed in the hope that it will be useful,
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    - * Lesser General Public License for more details.  
    + * Lesser General Public License for more details.
      */
     
     package com.sun.jna.platform.win32;
     
    -import java.util.Arrays;
     import java.util.List;
     
     import com.sun.jna.Pointer;
    @@ -22,7 +21,7 @@
     
     /**
      * Ported from AccCtrl.h. Microsoft Windows SDK 7.1
    - * 
    + *
      * @author amarcionek[at]gmail.com
      */
     
    @@ -283,19 +282,8 @@ public ByReference(Pointer memory) {
                 }
             }
     
    -        public NETRESOURCE() {
    -
    -        }
    -
    -        public NETRESOURCE(Pointer address) {
    -            super(address);
    -            read();
    -        }
    -
    -        @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList("dwScope", "dwType", "dwDisplayType", "dwUsage", "lpLocalName", "lpRemoteName", "lpComment", "lpProvider");
    -        }
    +        public static final List FIELDS = createFieldsOrder(
    +                "dwScope", "dwType", "dwDisplayType", "dwUsage", "lpLocalName", "lpRemoteName", "lpComment", "lpProvider");
     
             /**
              * The scope of the enumeration. This member can be one of the values
    @@ -333,11 +321,11 @@ protected List getFieldOrder() {
              * If the entry is a network resource, this member is a pointer to a
              * null-terminated character string that specifies the remote network
              * name.
    -         * 
    +         *
              * If the entry is a current or persistent connection, lpRemoteName
              * member points to the network name associated with the name pointed to
              * by the lpLocalName member.
    -         * 
    +         *
              * The string can be MAX_PATH characters in length, and it must follow
              * the network provider's naming conventions
              */
    @@ -356,6 +344,20 @@ protected List getFieldOrder() {
              * the WNetGetProviderName function.
              */
             public String lpProvider;
    +
    +        public NETRESOURCE() {
    +            super();
    +        }
    +
    +        public NETRESOURCE(Pointer address) {
    +            super(address);
    +            read();
    +        }
    +
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
    +        }
         }
     
         //
    @@ -373,7 +375,7 @@ public static class UNIVERSAL_NAME_INFO extends Structure {
             public static class ByReference extends REMOTE_NAME_INFO implements Structure.ByReference {
     
                 public ByReference() {
    -
    +                super();
                 }
     
                 public ByReference(Pointer memory) {
    @@ -381,8 +383,15 @@ public ByReference(Pointer memory) {
                 }
             }
     
    -        public UNIVERSAL_NAME_INFO() {
    +        public static final List FIELDS = createFieldsOrder("lpUniversalName");
    +        /**
    +         * Pointer to the null-terminated UNC name string that identifies a
    +         * network resource.
    +         */
    +        public String lpUniversalName;
     
    +        public UNIVERSAL_NAME_INFO() {
    +            super();
             }
     
             public UNIVERSAL_NAME_INFO(Pointer address) {
    @@ -390,15 +399,9 @@ public UNIVERSAL_NAME_INFO(Pointer address) {
                 read();
             }
     
    -        /**
    -         * Pointer to the null-terminated UNC name string that identifies a
    -         * network resource.
    -         */
    -        public String lpUniversalName;
    -
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList("lpUniversalName");
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     
    @@ -421,14 +424,7 @@ public ByReference(Pointer memory) {
                 }
             }
     
    -        public REMOTE_NAME_INFO() {
    -
    -        }
    -
    -        public REMOTE_NAME_INFO(Pointer address) {
    -            super(address);
    -            read();
    -        }
    +        public static final List FIELDS = createFieldsOrder("lpUniversalName", "lpConnectionName", "lpRemainingPath");
     
             /**
              * Pointer to the null-terminated UNC name string that identifies a
    @@ -447,9 +443,18 @@ public REMOTE_NAME_INFO(Pointer address) {
              */
             public String lpRemainingPath;
     
    +        public REMOTE_NAME_INFO() {
    +            super();
    +        }
    +
    +        public REMOTE_NAME_INFO(Pointer address) {
    +            super(address);
    +            read();
    +        }
    +
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList("lpUniversalName", "lpConnectionName", "lpRemainingPath");
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     }
    diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java b/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java
    index 7e81cdd79b..a82872b9e8 100644
    --- a/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java
    +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java
    @@ -1,18 +1,17 @@
     /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
    - * 
    + *
      * This library is free software; you can redistribute it and/or
      * modify it under the terms of the GNU Lesser General Public
      * License as published by the Free Software Foundation; either
      * version 2.1 of the License, or (at your option) any later version.
    - * 
    + *
      * This library is distributed in the hope that it will be useful,
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    - * Lesser General Public License for more details.  
    + * Lesser General Public License for more details.
      */
     package com.sun.jna.platform.win32;
     
    -import java.util.Arrays;
     import java.util.List;
     
     import com.sun.jna.Memory;
    @@ -32,7 +31,7 @@
     
     /**
      * Ported from Winspool.h. Windows SDK 6.0a
    - * 
    + *
      * @author dblock[at]dblock.org
      */
     public interface Winspool extends StdCallLibrary {
    @@ -97,7 +96,7 @@ public interface Winspool extends StdCallLibrary {
         /**
          * The EnumPrinters function enumerates available printers, print servers,
          * domains, or print providers.
    -     * 
    +     *
          * @param Flags
          *            The types of print objects that the function should enumerate.
          * @param Name
    @@ -160,59 +159,67 @@ boolean EnumPrinters(int Flags, String Name, int Level,
                 IntByReference pcReturned);
     
         public static class PRINTER_INFO_1 extends Structure {
    +        public static final List FIELDS = createFieldsOrder("Flags", "pDescription", "pName", "pComment");
    +
             public int Flags;
             public String pDescription;
             public String pName;
             public String pComment;
     
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "Flags", "pDescription",
    -                    "pName", "pComment" });
    -        }
    -
             public PRINTER_INFO_1() {
    +            super();
             }
     
             public PRINTER_INFO_1(int size) {
                 super(new Memory(size));
             }
    +
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
    +        }
         }
     
         public static class PRINTER_INFO_4 extends Structure {
    +        public static final List FIELDS = createFieldsOrder("pPrinterName", "pServerName", "Attributes");
    +
             public String pPrinterName;
             public String pServerName;
             public DWORD Attributes;
     
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "pPrinterName", "pServerName",
    -                    "Attributes" });
    -        }
    -
             public PRINTER_INFO_4() {
    +            super();
             }
     
             public PRINTER_INFO_4(int size) {
                 super(new Memory(size));
             }
    +
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
    +        }
         }
     
         public class LPPRINTER_DEFAULTS extends Structure {
    +        public static final List FIELDS = createFieldsOrder("pDatatype", "pDevMode", "DesiredAccess");
    +
             public String pDatatype;
    -        PVOID pDevMode;
    -        int DesiredAccess;
    +        public PVOID pDevMode;
    +        public int DesiredAccess;
     
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "pDatatype", "pDevMode",
    -                    "DesiredAccess" });
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     
         /**
          * The OpenPrinter function retrieves a handle to the specified printer or
          * print server or other types of handles in the print subsystem.
    -     * 
    +     *
          * @see MSDN
    -     * 
    +     *
          * @param pPrinterName
          *            [in] A pointer to a null-terminated string that specifies the
          *            name of the printer or print server, the printer object, the
    @@ -254,9 +261,9 @@ boolean OpenPrinter(
          * FindNextPrinterChangeNotification function to retrieve information about
          * the change, and to reset the change notification object for use in the
          * next wait operation.
    -     * 
    +     *
          * @see MSDN
    -     * 
    +     *
          * @param hPrinter
          *            [in] A handle to the printer or print server that you want to
          *            monitor. Use the OpenPrinter or AddPrinter function to
    @@ -266,12 +273,12 @@ boolean OpenPrinter(
          *            to enter a signaled state. A change notification occurs when
          *            one or more of the specified conditions are met. The fdwFilter
          *            parameter can be zero if pPrinterNotifyOptions is non-NULL.
    -     * 
    +     *
          * @param fdwOptions
    -     *            Reserved; must be zero. 
    -     * @param pPrinterNotifyOptions 
    +     *            Reserved; must be zero.
    +     * @param pPrinterNotifyOptions
          *            [in, optional] A pointer to a PRINTER_NOTIFY_OPTIONS
    -     *            structure. The pTypes member of this structure is an array of 
    +     *            structure. The pTypes member of this structure is an array of
          *            one or more PRINTER_NOTIFY_OPTIONS_TYPE structures, each of which
          *            specifies a printer information field to monitor. A change
          *            notification occurs when one or more of the specified fields
    @@ -280,7 +287,7 @@ boolean OpenPrinter(
          *            new printer information. This parameter can be NULL if
          *            fdwFilter is nonzero. For a list of fields that can be
          *            monitored, see PRINTER_NOTIFY_OPTIONS_TYPE.
    -     * 
    +     *
          * @return If the function succeeds, the return value is a handle to a
          *         change notification object associated with the specified printer
          *         or print server. If the function fails, the return value is
    @@ -304,9 +311,9 @@ HANDLE FindFirstPrinterChangeNotification(
          * changes occurs to the printer or print server. The
          * FindFirstPrinterChangeNotification function creates the change
          * notification object and specifies the set of changes to be monitored.
    -     * 
    +     *
          * @see MSDN
    -     * 
    +     *
          * @param hChange
          *            [in] A handle to a change notification object associated with
          *            a printer or print server. You obtain such a handle by calling
    @@ -321,7 +328,7 @@ HANDLE FindFirstPrinterChangeNotification(
          *            those specified in the fdwFilter parameter of the
          *            FindFirstPrinterChangeNotification call. The system sets one
          *            or more of the following bit flags.
    -     * 
    +     *
          * @param pPrinterNotifyOptions
          *            [in, optional] A pointer to a PRINTER_NOTIFY_OPTIONS
          *            structure. Set the Flags member of this structure to
    @@ -329,7 +336,7 @@ HANDLE FindFirstPrinterChangeNotification(
          *            return the current data for all monitored printer information
          *            fields. The function ignores all other members of the
          *            structure. This parameter can be NULL.
    -     * 
    +     *
          * @param ppPrinterNotifyInfo
          *            [out, optional] A pointer to a pointer variable that receives
          *            a pointer to a system-allocated, read-only buffer. Call the
    @@ -351,7 +358,7 @@ HANDLE FindFirstPrinterChangeNotification(
          *            no additional notifications will be sent until you make a
          *            second FindNextPrinterChangeNotification call that specifies
          *            PRINTER_NOTIFY_OPTIONS_REFRESH.
    -     * 
    +     *
          * @return If the function succeeds, the return value is a nonzero value. If
          *         the function fails, the return value is zero.
          */
    @@ -371,14 +378,14 @@ boolean FindNextPrinterChangeNotification(
          * FindFirstPrinterChangeNotification function. The printer or print server
          * associated with the change notification object will no longer be
          * monitored by that object.
    -     * 
    +     *
          * @see MSDN
    -     * 
    +     *
          * @param hChange
          *            [in] A handle to the change notification object to be closed.
          *            This is a handle created by calling the
          *            FindFirstPrinterChangeNotification function.
    -     * 
    +     *
          * @return If the function succeeds, the return value is a nonzero value. If
          *         the function fails, the return value is zero.
          */
    @@ -405,6 +412,12 @@ boolean EnumJobs(
                 IntByReference pcReturned);
     
         public static class JOB_INFO_1 extends Structure {
    +        public static final List FIELDS = createFieldsOrder(
    +                "JobId", "pPrinterName",
    +                "pMachineName", "pUserName", "pDocument", "pDatatype",
    +                "pStatus", "Status", "Priority", "Position", "TotalPages",
    +                "PagesPrinted", "Submitted");
    +
             public int JobId;
             public String pPrinterName;
             public String pMachineName;
    @@ -419,14 +432,13 @@ public static class JOB_INFO_1 extends Structure {
             public int PagesPrinted;
             public SYSTEMTIME Submitted;
     
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "JobId", "pPrinterName",
    -                    "pMachineName", "pUserName", "pDocument", "pDatatype",
    -                    "pStatus", "Status", "Priority", "Position", "TotalPages",
    -                    "PagesPrinted", "Submitted" });
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
     
             public JOB_INFO_1() {
    +            super();
             }
     
             public JOB_INFO_1(int size) {
    diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java b/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java
    index cc34077935..f672bfc6e7 100644
    --- a/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java
    +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java
    @@ -1,19 +1,18 @@
     /* Copyright (c) 2010 EugineLev, All Rights Reserved
    - * 
    + *
      * This library is free software; you can redistribute it and/or
      * modify it under the terms of the GNU Lesser General Public
      * License as published by the Free Software Foundation; either
      * version 2.1 of the License, or (at your option) any later version.
    - * 
    + *
      * This library is distributed in the hope that it will be useful,
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    - * Lesser General Public License for more details.  
    + * Lesser General Public License for more details.
      */
     package com.sun.jna.platform.win32;
     
     
    -import java.util.Arrays;
     import java.util.List;
     
     import com.sun.jna.Memory;
    @@ -27,42 +26,44 @@
      * Microsoft Windows SDK 7.0A.
      * @author EugineLev
      */
    -public interface Winsvc {	
    +public interface Winsvc {
     
         /**
          *  Contains status information for a service. The ControlService, EnumDependentServices,
          *  EnumServicesStatus, and QueryServiceStatus functions use this structure. A service
    -     *  uses this structure in the SetServiceStatus function to report its current status 
    +     *  uses this structure in the SetServiceStatus function to report its current status
          *  to the service control manager.
          */
         public static class SERVICE_STATUS extends Structure {
    -		
    +        public static final List FIELDS = createFieldsOrder(
    +                "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint");
    +
             /**
    -         * dwServiceType - the type of service. This member can be one 
    +         * dwServiceType - the type of service. This member can be one
              * of the following values:
    -         * SERVICE_KERNEL_DRIVER, SERVICE_FILE_SYSTEM_DRIVER, 
    -         * SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_SHARE_PROCESS, 
    +         * SERVICE_KERNEL_DRIVER, SERVICE_FILE_SYSTEM_DRIVER,
    +         * SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_SHARE_PROCESS,
     
    -         * If the service type is either SERVICE_WIN32_OWN_PROCESS or 
    -         * SERVICE_WIN32_SHARE_PROCESS, and the service is running in the 
    -         * context of the LocalSystem account, the following type may also 
    +         * If the service type is either SERVICE_WIN32_OWN_PROCESS or
    +         * SERVICE_WIN32_SHARE_PROCESS, and the service is running in the
    +         * context of the LocalSystem account, the following type may also
              * be specified:
              * SERVICE_INTERACTIVE_PROCESS
    -         * 
    +         *
              * These values can be found in WinNT.h
              */
             public int dwServiceType;
    -		
    +
             /**
    -         * dwCurrentState - The current state of the service. 
    +         * dwCurrentState - The current state of the service.
              * This member can be one of the following values:
              * SERVICE_STOPPED, SERVICE_START_PENDING, SERVICE_STOP_PENDING, SERVICE_RUNNING,
    -         * SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, SERVICE_PAUSED	
    +         * SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, SERVICE_PAUSED
              */
             public int dwCurrentState;
    -		
    +
             /**
    -         * dwControlsAccepted - The control codes the service accepts and processes 
    +         * dwControlsAccepted - The control codes the service accepts and processes
              * in its handler function:
              * SERVICE_ACCEPT_STOP, SERVICE_ACCEPT_PAUSE_CONTINUE, SERVICE_ACCEPT_SHUTDOWN,
              * SERVICE_ACCEPT_PARAMCHANGE,  SERVICE_ACCEPT_NETBINDCHANGE, SERVICE_ACCEPT_HARDWAREPROFILECHANGE,
    @@ -70,77 +71,82 @@ public static class SERVICE_STATUS extends Structure {
              * SERVICE_ACCEPT_TIMECHANGE, SERVICE_ACCEPT_TRIGGEREVENT
              */
             public int dwControlsAccepted;
    -		
    +
             /**
    -         * dwWin32ExitCode - The error code the service uses to report an error that occurs 
    +         * dwWin32ExitCode - The error code the service uses to report an error that occurs
              * when it is starting or stopping. To return an error code specific to the service,
              * the service must set this value to ERROR_SERVICE_SPECIFIC_ERROR to indicate that
              * the dwServiceSpecificExitCode member contains the error code. The service should
              * set this value to NO_ERROR when it is running and on normal termination.
              */
             public int dwWin32ExitCode;
    -		
    +
             /**
              * dwServiceSpecificExitCode - A service-specific error code that the service returns
              * when an error occurs while the service is starting or stopping. This value is
              * ignored unless the dwWin32ExitCode member is set to ERROR_SERVICE_SPECIFIC_ERROR.
              */
             public int dwServiceSpecificExitCode;
    -		
    +
             /**
              * dwCheckPoint - The check-point value the service increments periodically to report
              * its progress during a lengthy start, stop, pause, or continue operation.
              */
             public int dwCheckPoint;
    -		
    +
             /**
    -         * dwWaitHint - The estimated time required for a pending start, stop, pause, or continue 
    +         * dwWaitHint - The estimated time required for a pending start, stop, pause, or continue
              * operation, in milliseconds.
              */
             public int dwWaitHint;
     
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
    -        }
    -        
             public SERVICE_STATUS() {
                 super();
             }
     
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
    +        }
         }
     
         /**
    -     * Contains process status information for a service. The ControlServiceEx, 
    +     * Contains process status information for a service. The ControlServiceEx,
          * EnumServicesStatusEx, NotifyServiceStatusChange, and QueryServiceStatusEx
          * functions use this structure.
          */
         public class SERVICE_STATUS_PROCESS extends Structure {
    +        public static final List FIELDS = createFieldsOrder(
    +                "dwServiceType", "dwCurrentState", "dwControlsAccepted",
    +                "dwWin32ExitCode", "dwServiceSpecificExitCode",
    +                "dwCheckPoint", "dwWaitHint", "dwProcessId", "dwServiceFlags");
    +
             /**
    -         * dwServiceType - the type of service. This member can be one 
    +         * dwServiceType - the type of service. This member can be one
              * of the following values:
    -         * SERVICE_KERNEL_DRIVER, SERVICE_FILE_SYSTEM_DRIVER, 
    -         * SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_SHARE_PROCESS, 
    +         * SERVICE_KERNEL_DRIVER, SERVICE_FILE_SYSTEM_DRIVER,
    +         * SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_SHARE_PROCESS,
     
    -         * If the service type is either SERVICE_WIN32_OWN_PROCESS or 
    -         * SERVICE_WIN32_SHARE_PROCESS, and the service is running in the 
    -         * context of the LocalSystem account, the following type may also 
    +         * If the service type is either SERVICE_WIN32_OWN_PROCESS or
    +         * SERVICE_WIN32_SHARE_PROCESS, and the service is running in the
    +         * context of the LocalSystem account, the following type may also
              * be specified:
              * SERVICE_INTERACTIVE_PROCESS
    -         * 
    +         *
              * These values can be found in WinNT.h
              */
             public int   dwServiceType;
    -		
    +
             /**
    -         * dwCurrentState - The current state of the service. 
    +         * dwCurrentState - The current state of the service.
              * This member can be one of the following values:
              * SERVICE_STOPPED, SERVICE_START_PENDING, SERVICE_STOP_PENDING, SERVICE_RUNNING,
    -         * SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, SERVICE_PAUSED	
    +         * SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, SERVICE_PAUSED
              */
             public int   dwCurrentState;
    -		
    +
             /**
    -         * dwControlsAccepted - The control codes the service accepts and processes 
    +         * dwControlsAccepted - The control codes the service accepts and processes
              * in its handler function:
              * SERVICE_ACCEPT_STOP, SERVICE_ACCEPT_PAUSE_CONTINUE, SERVICE_ACCEPT_SHUTDOWN,
              * SERVICE_ACCEPT_PARAMCHANGE,  SERVICE_ACCEPT_NETBINDCHANGE, SERVICE_ACCEPT_HARDWAREPROFILECHANGE,
    @@ -148,64 +154,66 @@ public class SERVICE_STATUS_PROCESS extends Structure {
              * SERVICE_ACCEPT_TIMECHANGE, SERVICE_ACCEPT_TRIGGEREVENT
              */
             public int   dwControlsAccepted;
    -		
    +
             /**
    -         * dwWin32ExitCode - The error code the service uses to report an error that occurs 
    +         * dwWin32ExitCode - The error code the service uses to report an error that occurs
              * when it is starting or stopping. To return an error code specific to the service,
              * the service must set this value to ERROR_SERVICE_SPECIFIC_ERROR to indicate that
              * the dwServiceSpecificExitCode member contains the error code. The service should
              * set this value to NO_ERROR when it is running and on normal termination.
              */
             public int   dwWin32ExitCode;
    -		
    +
             /**
              * dwServiceSpecificExitCode - A service-specific error code that the service returns
              * when an error occurs while the service is starting or stopping. This value is
              * ignored unless the dwWin32ExitCode member is set to ERROR_SERVICE_SPECIFIC_ERROR.
              */
             public int   dwServiceSpecificExitCode;
    -		
    +
             /**
              * dwCheckPoint - The check-point value the service increments periodically to report
              * its progress during a lengthy start, stop, pause, or continue operation.
              */
             public int   dwCheckPoint;
    -		
    +
             /**
    -         * dwWaitHint - The estimated time required for a pending start, stop, pause, or continue 
    +         * dwWaitHint - The estimated time required for a pending start, stop, pause, or continue
              * operation, in milliseconds.
              */
             public int   dwWaitHint;
    -		
    +
             /**
              * dwProcessId - The process identifier of the service.
              */
             public int   dwProcessId;
    -		
    +
             /**
              * This member can be one of the following values: 0, or SERVICE_RUNS_IN_SYSTEM_PROCESS
              */
             public int   dwServiceFlags;
    -		
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint", "dwProcessId", "dwServiceFlags" });
    -        }
    -        
    +
             public SERVICE_STATUS_PROCESS() {
    +            super();
             }
    -		
    +
             public SERVICE_STATUS_PROCESS(int size) {
                 super(new Memory(size));
             }
    +
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
    +        }
         }
    -	
    +
         //
         // Service flags for QueryServiceStatusEx
         //
         int SERVICE_RUNS_IN_SYSTEM_PROCESS = 0x00000001;
    -	
    +
         public static class SC_HANDLE extends HANDLE { }
    -	
    +
         //
         // Service Control Manager object specific access types
         //
    @@ -216,10 +224,10 @@ public static class SC_HANDLE extends HANDLE { }
         int SC_MANAGER_QUERY_LOCK_STATUS	= 0x0010;
         int SC_MANAGER_MODIFY_BOOT_CONFIG	= 0x0020;
     
    -    int SC_MANAGER_ALL_ACCESS = 
    -        WinNT.STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT 
    -        | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE 
    -        | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS  
    +    int SC_MANAGER_ALL_ACCESS =
    +        WinNT.STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT
    +        | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE
    +        | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS
             | SC_MANAGER_MODIFY_BOOT_CONFIG;
     
         //
    @@ -236,10 +244,10 @@ public static class SC_HANDLE extends HANDLE { }
         int SERVICE_USER_DEFINED_CONTROL	= 0x0100;
     
         int SERVICE_ALL_ACCESS =
    -        WinNT.STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG 
    -        | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS 
    -        | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START | SERVICE_STOP 
    -        | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE 
    +        WinNT.STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG
    +        | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS
    +        | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START | SERVICE_STOP
    +        | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE
             | SERVICE_USER_DEFINED_CONTROL;
     
         //
    @@ -262,7 +270,7 @@ public static class SC_HANDLE extends HANDLE { }
         //	int SERVICE_CONTROL_PRESHUTDOWN		= 0x0000000F;
         //	int SERVICE_CONTROL_TIMECHANGE		= 0x00000010;
         //	int SERVICE_CONTROL_TRIGGEREVENT	= 0x00000020;
    -	
    +
         //
         // Service State -- for CurrentState
         //
    @@ -288,11 +296,11 @@ public static class SC_HANDLE extends HANDLE { }
         int SERVICE_ACCEPT_PRESHUTDOWN				= 0x00000100;
         int SERVICE_ACCEPT_TIMECHANGE				= 0x00000200;
         int SERVICE_ACCEPT_TRIGGEREVENT				= 0x00000400;
    -	
    +
         /**
    -     * The SC_STATUS_TYPE enumeration type contains values 
    +     * The SC_STATUS_TYPE enumeration type contains values
          */
    -    public abstract class SC_STATUS_TYPE { 
    +    public abstract class SC_STATUS_TYPE {
             public static final int SC_STATUS_PROCESS_INFO = 0;
         }
     
    diff --git a/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java b/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java
    index 5911806c98..ecc78b47c5 100644
    --- a/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/WindowUtilsTest.java
    @@ -32,13 +32,8 @@
     import java.awt.event.MouseEvent;
     import java.awt.geom.Area;
     import java.awt.image.BufferedImage;
    -import java.io.File;
    -import java.io.FileInputStream;
     import java.lang.ref.WeakReference;
     import java.util.Arrays;
    -import java.util.List;
    -
    -import javax.imageio.ImageIO;
     import javax.swing.JButton;
     import javax.swing.JComponent;
     import javax.swing.JFrame;
    @@ -50,14 +45,7 @@
     
     import junit.framework.TestCase;
     
    -import com.sun.jna.Native;
     import com.sun.jna.Platform;
    -import com.sun.jna.Pointer;
    -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;
     
     // NOTE: java.awt.Robot can't properly capture transparent pixels
     // Transparency tests are disabled until this can be resolved
    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 d81b9ad9d3..1b11b5cd5c 100644
    --- a/contrib/platform/test/com/sun/jna/platform/mac/SystemBTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/mac/SystemBTest.java
    @@ -24,7 +24,6 @@
     import com.sun.jna.platform.mac.SystemB.VMStatistics64;
     
     import com.sun.jna.Memory;
    -import com.sun.jna.Native;
     import com.sun.jna.Platform;
     import com.sun.jna.Pointer;
     import com.sun.jna.ptr.IntByReference;
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java
    index e49a253875..17666b6b3b 100755
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java
    @@ -1008,9 +1008,6 @@ public void testGetNamedSecurityInfoForFileWithSACL() throws Exception {
             tp.Privileges[0] = new WinNT.LUID_AND_ATTRIBUTES(pLuid, new DWORD(WinNT.SE_PRIVILEGE_ENABLED));
             assertTrue(Advapi32.INSTANCE.AdjustTokenPrivileges(tokenAdjust, false, tp, 0, null, null));
     
    -        // create a temp file
    -        File file = createTempFile();
    -
             int infoType = OWNER_SECURITY_INFORMATION
                            | GROUP_SECURITY_INFORMATION
                            | DACL_SECURITY_INFORMATION
    @@ -1021,20 +1018,25 @@ public void testGetNamedSecurityInfoForFileWithSACL() throws Exception {
             PointerByReference ppDacl = new PointerByReference();
             PointerByReference ppSacl = new PointerByReference();
             PointerByReference ppSecurityDescriptor = new PointerByReference();
    -
    -        assertEquals(Advapi32.INSTANCE.GetNamedSecurityInfo(
    -                     file.getAbsolutePath(),
    -                     AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    -                     infoType,
    -                     ppsidOwner,
    -                     ppsidGroup,
    -                     ppDacl,
    -                     ppSacl,
    -                     ppSecurityDescriptor), 0);
    -
    -        // Clean up resources
    -        Kernel32.INSTANCE.LocalFree(ppSecurityDescriptor.getValue());
    -        file.delete();
    +        // create a temp file
    +        File file = createTempFile();
    +        String filePath = file.getAbsolutePath();
    +        try {
    +            assertEquals("GetNamedSecurityInfo(" + filePath + ")", 0,
    +                         Advapi32.INSTANCE.GetNamedSecurityInfo(
    +                                 filePath,
    +                                 AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    +                                 infoType,
    +                                 ppsidOwner,
    +                                 ppsidGroup,
    +                                 ppDacl,
    +                                 ppSacl,
    +                                 ppSecurityDescriptor));
    +            // Clean up resources
    +            Kernel32.INSTANCE.LocalFree(ppSecurityDescriptor.getValue());
    +        } finally {
    +            file.delete();
    +        }
             if (impersontating) {
             	Advapi32.INSTANCE.SetThreadToken(null, null);
             }
    @@ -1049,9 +1051,6 @@ public void testGetNamedSecurityInfoForFileWithSACL() throws Exception {
         }
     
         public void testSetNamedSecurityInfoForFileNoSACL() throws Exception {
    -        // create a temp file
    -        File file = createTempFile();
    -
             int infoType = OWNER_SECURITY_INFORMATION
                            | GROUP_SECURITY_INFORMATION
                            | DACL_SECURITY_INFORMATION;
    @@ -1060,28 +1059,37 @@ public void testSetNamedSecurityInfoForFileNoSACL() throws Exception {
             PointerByReference ppsidGroup = new PointerByReference();
             PointerByReference ppDacl = new PointerByReference();
             PointerByReference ppSecurityDescriptor = new PointerByReference();
    -
    -        assertEquals(Advapi32.INSTANCE.GetNamedSecurityInfo(
    -                      file.getAbsolutePath(),
    -                      AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    -                      infoType,
    -                      ppsidOwner,
    -                      ppsidGroup,
    -                      ppDacl,
    -                      null,
    -                      ppSecurityDescriptor), 0);
    -
    -        assertEquals(Advapi32.INSTANCE.SetNamedSecurityInfo(
    -                      file.getAbsolutePath(),
    -                      AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    -                      infoType,
    -                      ppsidOwner.getValue(),
    -                      ppsidGroup.getValue(),
    -                      ppDacl.getValue(),
    -                      null), 0);
    -
    -        Kernel32.INSTANCE.LocalFree(ppSecurityDescriptor.getValue());
    -        file.delete();
    +        // create a temp file
    +        File file = createTempFile();
    +        String filePath = file.getAbsolutePath();
    +        try {
    +            assertEquals("GetNamedSecurityInfo(" + filePath + ")", 0,
    +                         Advapi32.INSTANCE.GetNamedSecurityInfo(
    +                                 filePath,
    +                                 AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    +                                 infoType,
    +                                 ppsidOwner,
    +                                 ppsidGroup,
    +                                 ppDacl,
    +                                 null,
    +                                 ppSecurityDescriptor));
    +
    +            try {
    +                assertEquals("SetNamedSecurityInfo(" + filePath + ")", 0,
    +                             Advapi32.INSTANCE.SetNamedSecurityInfo(
    +                                     filePath,
    +                                     AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    +                                     infoType,
    +                                     ppsidOwner.getValue(),
    +                                     ppsidGroup.getValue(),
    +                                     ppDacl.getValue(),
    +                                     null));
    +            } finally {
    +                Kernel32.INSTANCE.LocalFree(ppSecurityDescriptor.getValue());
    +            }
    +        } finally {
    +            file.delete();
    +        }
         }
     
         public void testSetNamedSecurityInfoForFileWithSACL() throws Exception {
    @@ -1139,36 +1147,44 @@ public void testSetNamedSecurityInfoForFileWithSACL() throws Exception {
             PointerByReference ppDacl = new PointerByReference();
             PointerByReference ppSacl = new PointerByReference();
             PointerByReference ppSecurityDescriptor = new PointerByReference();
    +        String filePath = file.getAbsolutePath();
    +        try {
    +            assertEquals("GetNamedSecurityInfo(" + filePath + ")", 0,
    +                    Advapi32.INSTANCE.GetNamedSecurityInfo(
    +                          filePath,
    +                          AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    +                          infoType,
    +                          ppsidOwner,
    +                          ppsidGroup,
    +                          ppDacl,
    +                          ppSacl,
    +                          ppSecurityDescriptor));
    +
    +            try {
    +                // Send the DACL as a SACL
    +                assertEquals("SetNamedSecurityInfo(" + filePath + ")", 0,
    +                        Advapi32.INSTANCE.SetNamedSecurityInfo(
    +                              filePath,
    +                              AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    +                              infoType,
    +                              ppsidOwner.getValue(),
    +                              ppsidGroup.getValue(),
    +                              ppDacl.getValue(),
    +                              ppDacl.getValue()));
    +            } finally {
    +                // Clean up resources
    +                Kernel32.INSTANCE.LocalFree(ppSecurityDescriptor.getValue());
    +            }
    +        } finally {
    +            file.delete();
    +        }
     
    -        assertEquals(Advapi32.INSTANCE.GetNamedSecurityInfo(
    -                      file.getAbsolutePath(),
    -                      AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    -                      infoType,
    -                      ppsidOwner,
    -                      ppsidGroup,
    -                      ppDacl,
    -                      ppSacl,
    -                      ppSecurityDescriptor), 0);
    -
    -        // Send the DACL as a SACL
    -        assertEquals(Advapi32.INSTANCE.SetNamedSecurityInfo(
    -                      file.getAbsolutePath(),
    -                      AccCtrl.SE_OBJECT_TYPE.SE_FILE_OBJECT,
    -                      infoType,
    -                      ppsidOwner.getValue(),
    -                      ppsidGroup.getValue(),
    -                      ppDacl.getValue(),
    -                      ppDacl.getValue()), 0);
    -
    -        // Clean up resources
    -        Kernel32.INSTANCE.LocalFree(ppSecurityDescriptor.getValue());
    -        file.delete();
             if (impersontating) {
    -            Advapi32.INSTANCE.SetThreadToken(null, null);
    +            assertTrue("SetThreadToken", Advapi32.INSTANCE.SetThreadToken(null, null));
             }
             else {
                 tp.Privileges[0] = new WinNT.LUID_AND_ATTRIBUTES(pLuid, new DWORD(0));
    -            Advapi32.INSTANCE.AdjustTokenPrivileges(tokenAdjust, false, tp, 0, null, null);
    +            assertTrue("AdjustTokenPrivileges", Advapi32.INSTANCE.AdjustTokenPrivileges(tokenAdjust, false, tp, 0, null, null));
             }
             if (phToken.getValue() != null)
                 Kernel32.INSTANCE.CloseHandle(phToken.getValue());
    @@ -1527,22 +1543,22 @@ private File createTempFile() throws Exception {
             fileWriter.close();
             return file;
         }
    -    
    +
         public void testCreateProcessWithLogonW() {
         	String winDir = Kernel32Util.getEnvironmentVariable("WINDIR");
         	assertNotNull("No WINDIR value returned", winDir);
         	assertTrue("Specified WINDIR does not exist: " + winDir, new File(winDir).exists());
    -    	
    +
         	STARTUPINFO si = new STARTUPINFO();
         	si.lpDesktop = null;
         	PROCESS_INFORMATION results = new PROCESS_INFORMATION();
    -    	
    +
         	// i have the same combination on my luggage
    -    	boolean result = Advapi32.INSTANCE.CreateProcessWithLogonW("A" + System.currentTimeMillis(), "localhost", "12345", Advapi32.LOGON_WITH_PROFILE, new File(winDir, "notepad.exe").getAbsolutePath(), "", 0, null, "", si, results); 
    -    
    +    	boolean result = Advapi32.INSTANCE.CreateProcessWithLogonW("A" + System.currentTimeMillis(), "localhost", "12345", Advapi32.LOGON_WITH_PROFILE, new File(winDir, "notepad.exe").getAbsolutePath(), "", 0, null, "", si, results);
    +
         	// we tried to run notepad as a bogus user, so it should fail.
         	assertFalse("CreateProcessWithLogonW should have returned false because the username was bogus.", result);
    -    	
    +
         	// should fail with "the user name or password is incorrect" (error 1326)
         	assertEquals("GetLastError() should have returned ERROR_LOGON_FAILURE because the username was bogus.", W32Errors.ERROR_LOGON_FAILURE, Native.getLastError());
         }
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/ComEventCallbacks_Test.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/ComEventCallbacks_Test.java
    index 516413647d..f7b8a0ce67 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/ComEventCallbacks_Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/ComEventCallbacks_Test.java
    @@ -29,7 +29,6 @@
     import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
     import com.sun.jna.platform.win32.Ole32;
     import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
    -import com.sun.jna.platform.win32.User32;
     import com.sun.jna.platform.win32.Variant.VARIANT;
     import com.sun.jna.platform.win32.WTypes;
     import com.sun.jna.platform.win32.WinDef;
    @@ -40,7 +39,6 @@
     import com.sun.jna.platform.win32.WinDef.WORD;
     import com.sun.jna.platform.win32.WinError;
     import com.sun.jna.platform.win32.WinNT.HRESULT;
    -import com.sun.jna.platform.win32.WinUser;
     import com.sun.jna.ptr.IntByReference;
     import com.sun.jna.ptr.PointerByReference;
     
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/ConnectionPointContainer_Test.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/ConnectionPointContainer_Test.java
    index c5a6fb5499..be1f41b1ba 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/ConnectionPointContainer_Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/ConnectionPointContainer_Test.java
    @@ -22,7 +22,6 @@
     import com.sun.jna.platform.win32.Guid.CLSID;
     import com.sun.jna.platform.win32.Guid.IID;
     import com.sun.jna.platform.win32.Guid.REFIID;
    -import com.sun.jna.platform.win32.OaIdl;
     import com.sun.jna.platform.win32.OaIdl.DISPID;
     import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
     import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
    @@ -30,8 +29,6 @@
     import com.sun.jna.platform.win32.Guid;
     import com.sun.jna.platform.win32.Kernel32;
     import com.sun.jna.platform.win32.Ole32;
    -import com.sun.jna.platform.win32.OleAuto;
    -import com.sun.jna.platform.win32.Variant;
     import com.sun.jna.platform.win32.WTypes;
     import com.sun.jna.platform.win32.WinDef;
     import com.sun.jna.platform.win32.WinError;
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/IDispatchTest.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/IDispatchTest.java
    index 61bdd8eb62..d13b5273d8 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/IDispatchTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/IDispatchTest.java
    @@ -18,7 +18,6 @@
     import com.sun.jna.platform.win32.Guid.CLSID;
     import com.sun.jna.platform.win32.Guid.REFIID;
     import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
    -import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
     import com.sun.jna.platform.win32.Guid;
     import com.sun.jna.platform.win32.Kernel32;
     import com.sun.jna.platform.win32.Ole32;
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/IShellFolderTest.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/IShellFolderTest.java
    index f76876673d..401f05ec82 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/IShellFolderTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/IShellFolderTest.java
    @@ -10,7 +10,6 @@
     import com.sun.jna.Pointer;
     import com.sun.jna.platform.win32.*;
     import com.sun.jna.ptr.PointerByReference;
    -import junit.framework.TestCase;
     
     public class IShellFolderTest extends TestCase {
     
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/ITypeInfoTest.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/ITypeInfoTest.java
    index db8fcfc755..8872c249e5 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/ITypeInfoTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/ITypeInfoTest.java
    @@ -14,7 +14,6 @@
     
     import junit.framework.TestCase;
     
    -import com.sun.jna.Native;
     import com.sun.jna.platform.win32.OaIdl.HREFTYPEByReference;
     import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
     import com.sun.jna.platform.win32.OaIdl.MEMBERID;
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/ITypeLibTest.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/ITypeLibTest.java
    index 5715d6ea4f..67c852b7a2 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/ITypeLibTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/ITypeLibTest.java
    @@ -14,7 +14,6 @@
     
     import junit.framework.TestCase;
     
    -import com.sun.jna.Native;
     import com.sun.jna.WString;
     import com.sun.jna.platform.win32.Guid.CLSID;
     import com.sun.jna.platform.win32.Kernel32;
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ProxyObject_Test.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ProxyObject_Test.java
    index 30a55dc892..a7bb257056 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ProxyObject_Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/ProxyObject_Test.java
    @@ -14,28 +14,14 @@
     
     import static org.junit.Assert.*;
     
    -import java.util.List;
    -
    -import javax.management.InvalidApplicationException;
    -
     import org.junit.After;
     import org.junit.Before;
     import org.junit.Test;
     
    -import com.sun.jna.platform.win32.COM.COMException;
    -import com.sun.jna.platform.win32.COM.COMUtils;
     import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
     import com.sun.jna.platform.win32.COM.util.annotation.ComObject;
     import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
     import com.sun.jna.platform.win32.COM.util.annotation.ComProperty;
    -import com.sun.jna.platform.win32.Guid.IID;
    -import com.sun.jna.platform.win32.Ole32;
    -import com.sun.jna.platform.win32.Ole32Util;
    -import com.sun.jna.platform.win32.OleAuto;
    -import com.sun.jna.platform.win32.Variant;
    -import com.sun.jna.platform.win32.WinDef;
    -import com.sun.jna.platform.win32.WinNT;
    -import com.sun.jna.ptr.PointerByReference;
     
     public class ProxyObject_Test {
     
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/RunningObjectTable_Test.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/RunningObjectTable_Test.java
    index 544bec0365..6d7c85f11b 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/util/RunningObjectTable_Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/util/RunningObjectTable_Test.java
    @@ -21,19 +21,10 @@
     import org.junit.Test;
     
     import com.sun.jna.platform.win32.COM.COMException;
    -import com.sun.jna.platform.win32.COM.COMUtils;
     import com.sun.jna.platform.win32.COM.util.annotation.ComInterface;
     import com.sun.jna.platform.win32.COM.util.annotation.ComObject;
     import com.sun.jna.platform.win32.COM.util.annotation.ComMethod;
     import com.sun.jna.platform.win32.COM.util.annotation.ComProperty;
    -import com.sun.jna.platform.win32.Guid.IID;
    -import com.sun.jna.platform.win32.Ole32;
    -import com.sun.jna.platform.win32.Ole32Util;
    -import com.sun.jna.platform.win32.OleAuto;
    -import com.sun.jna.platform.win32.Variant;
    -import com.sun.jna.platform.win32.WinDef;
    -import com.sun.jna.platform.win32.WinNT;
    -import com.sun.jna.ptr.PointerByReference;
     
     public class RunningObjectTable_Test {
     
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java
    index 36f3436687..ad440d910e 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Crypt32Test.java
    @@ -12,17 +12,8 @@
      */
     package com.sun.jna.platform.win32;
     
    -import java.io.File;
    -import java.io.FileInputStream;
    -import java.io.IOException;
    -import java.io.InputStream;
    -import java.net.URISyntaxException;
    -
    -import com.sun.jna.Memory;
     import com.sun.jna.Native;
    -import com.sun.jna.Pointer;
     import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
    -import com.sun.jna.platform.win32.WinDef.DWORD;
     import com.sun.jna.ptr.PointerByReference;
     
     import junit.framework.TestCase;
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java
    index 644bc0dd5e..5db76e98b1 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Kernel32Test.java
    @@ -334,12 +334,16 @@ public void testOpenProcess() {
         public void testQueryFullProcessImageName() {
             HANDLE h = Kernel32.INSTANCE.OpenProcess(0, false, Kernel32.INSTANCE.GetCurrentProcessId());
             assertNotNull("Failed (" + Kernel32.INSTANCE.GetLastError() + ") to get process handle", h);
    -        
    -        char[] path = new char[WinDef.MAX_PATH];
    -        IntByReference lpdwSize = new IntByReference(path.length);
    -        boolean b = Kernel32.INSTANCE.QueryFullProcessImageName(h, 0, path, lpdwSize);
    -        assertTrue("Failed (" + Kernel32.INSTANCE.GetLastError() + ") to query process image name", b);
    -        assertTrue("Failed to query process image name, empty path returned", lpdwSize.getValue() > 0);
    +
    +        try {
    +            char[] path = new char[WinDef.MAX_PATH];
    +            IntByReference lpdwSize = new IntByReference(path.length);
    +            boolean b = Kernel32.INSTANCE.QueryFullProcessImageName(h, 0, path, lpdwSize);
    +            assertTrue("Failed (" + Kernel32.INSTANCE.GetLastError() + ") to query process image name", b);
    +            assertTrue("Failed to query process image name, empty path returned", lpdwSize.getValue() > 0);
    +        } finally {
    +            assertTrue("CloseHandle", Kernel32.INSTANCE.CloseHandle(h));
    +        }
         }
     
         public void testGetTempPath() {
    @@ -412,7 +416,7 @@ public void testGetSystemTimes() {
           assertTrue(kernelTime >= idleTime);
           assertTrue(userTime >= 0);
         }
    -    
    +
         public void testIsWow64Process() {
             try {
                 IntByReference isWow64 = new IntByReference(42);
    @@ -1016,8 +1020,8 @@ public boolean invoke(HMODULE module, Pointer type, Pointer name, Pointer lParam
             assertFalse("EnumResourceNames should have failed.", result);
             assertEquals("GetLastError should be set to 1813", WinError.ERROR_RESOURCE_TYPE_NOT_FOUND, Kernel32.INSTANCE.GetLastError());
         }
    -    
    -    
    +
    +
         public void testEnumResourceTypes() {
             final List types = new ArrayList();
             WinBase.EnumResTypeProc ertp = new WinBase.EnumResTypeProc() {
    @@ -1025,7 +1029,7 @@ public void testEnumResourceTypes() {
                 @Override
                 public boolean invoke(HMODULE module, Pointer type, Pointer lParam) {
                     // simulate IS_INTRESOURCE macro defined in WinUser.h
    -                // basically that means that if "type" is less than or equal to 65,535 
    +                // basically that means that if "type" is less than or equal to 65,535
                     // it assumes it's an ID.
                     // otherwise it assumes it's a pointer to a string
                     if (Pointer.nativeValue(type) <= 65535) {
    @@ -1043,7 +1047,7 @@ public boolean invoke(HMODULE module, Pointer type, Pointer lParam) {
             assertEquals("GetLastError should be set to 0", WinError.ERROR_SUCCESS, Kernel32.INSTANCE.GetLastError());
             assertTrue("EnumResourceTypes should return some resource type names", types.size() > 0);
         }
    -    
    +
         public void testModule32FirstW() {
             HANDLE snapshot = Kernel32.INSTANCE.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPMODULE, new DWORD(Kernel32.INSTANCE.GetCurrentProcessId()));
             if (snapshot == null) {
    @@ -1051,7 +1055,7 @@ public void testModule32FirstW() {
             }
     
             Win32Exception we = null;
    -        Tlhelp32.MODULEENTRY32W first = new Tlhelp32.MODULEENTRY32W();        
    +        Tlhelp32.MODULEENTRY32W first = new Tlhelp32.MODULEENTRY32W();
             try {
                 if (!Kernel32.INSTANCE.Module32FirstW(snapshot, first)) {
                     throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    @@ -1069,17 +1073,17 @@ public void testModule32FirstW() {
                     }
                 }
             }
    -        
    +
             if (we != null) {
                 throw we;
             }
    -        
    +
             // not sure if this will be run against java.exe or javaw.exe but this
             // check tests both
             assertTrue("The first module in the current process should be java.exe or javaw.exe", first.szModule().startsWith("java"));
             assertEquals("The process ID of the module ID should be our process ID", Kernel32.INSTANCE.GetCurrentProcessId(), first.th32ProcessID.intValue());
         }
    -    
    +
         public void testModule32NextW() {
             HANDLE snapshot = Kernel32.INSTANCE.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPMODULE, new DWORD(Kernel32.INSTANCE.GetCurrentProcessId()));
             if (snapshot == null) {
    @@ -1087,7 +1091,7 @@ public void testModule32NextW() {
             }
     
             Win32Exception we = null;
    -        Tlhelp32.MODULEENTRY32W first = new Tlhelp32.MODULEENTRY32W();        
    +        Tlhelp32.MODULEENTRY32W first = new Tlhelp32.MODULEENTRY32W();
             try {
                 if (!Kernel32.INSTANCE.Module32NextW(snapshot, first)) {
                     throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    @@ -1105,11 +1109,11 @@ public void testModule32NextW() {
                     }
                 }
             }
    -        
    +
             if (we != null) {
                 throw we;
             }
    -        
    +
             // not sure if this will be run against java.exe or javaw.exe but this
             // check tests both
             assertTrue("The first module in the current process should be java.exe or javaw.exe", first.szModule().startsWith("java"));
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Kernel32UtilTest.java b/contrib/platform/test/com/sun/jna/platform/win32/Kernel32UtilTest.java
    index 90060c2be8..a27932e8d1 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Kernel32UtilTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Kernel32UtilTest.java
    @@ -261,9 +261,12 @@ public final void testWritePrivateProfileSection() throws IOException {
         public final void testQueryFullProcessImageName() {
             HANDLE h = Kernel32.INSTANCE.OpenProcess(0, false, Kernel32.INSTANCE.GetCurrentProcessId());
             assertNotNull("Failed (" + Kernel32.INSTANCE.GetLastError() + ") to get process handle", h);
    -
    -        String name = Kernel32Util.QueryFullProcessImageName(h, 0);
    -        assertTrue("Failed to query process image name, empty path returned", name.length() > 0);
    +        try {
    +            String name = Kernel32Util.QueryFullProcessImageName(h, 0);
    +            assertTrue("Failed to query process image name, empty path returned", name.length() > 0);
    +        } finally {
    +            assertTrue("CloseHandle", Kernel32.INSTANCE.CloseHandle(h));
    +        }
         }
     
         public void testGetResource() {
    @@ -278,29 +281,29 @@ public void testGetResource() {
             assertNotNull("The 'ICO_MYCOMPUTER' resource in explorer.exe should have some content.", results);
             assertTrue("The 'ICO_MYCOMPUTER' resource in explorer.exe should have some content.", results.length > 0);
         }
    -    
    +
         public void testGetResourceNames() {
             String winDir = Kernel32Util.getEnvironmentVariable("WINDIR");
             assertNotNull("No WINDIR value returned", winDir);
             assertTrue("Specified WINDIR does not exist: " + winDir, new File(winDir).exists());
    -        
    +
             // On Windows 7, "14" is the type assigned to the "My Computer" icon
             // (which is named "ICO_MYCOMPUTER")
             Map> names = Kernel32Util.getResourceNames(new File(winDir, "explorer.exe").getAbsolutePath());
    -        
    +
             assertNotNull("explorer.exe should contain some resources in it.", names);
             assertTrue("explorer.exe should contain some resource types in it.", names.size() > 0);
             assertTrue("explorer.exe should contain a resource of type '14' in it.", names.containsKey("14"));
             assertTrue("resource type 14 should have a name named ICO_MYCOMPUTER associated with it.", names.get("14").contains("ICO_MYCOMPUTER"));
         }
    -    
    +
         public void testGetModules() {
             List results = Kernel32Util.getModules(Kernel32.INSTANCE.GetCurrentProcessId());
    -        
    +
             // not sure if this will be run against java.exe or javaw.exe but these checks should work with both
             assertNotNull("There should be some modules returned from this helper", results);
             assertTrue("The first module in this process should be java.exe or javaw.exe", results.get(0).szModule().startsWith("java"));
    -        
    +
             // since this is supposed to return all the modules in a process, there should be an EXE and at least 1 Windows DLL
             // so assert total count is at least two
             assertTrue("This is supposed to return all the modules in a process, so there should be an EXE and at least 1 Windows API DLL.", results.size() > 2);
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java
    index 0e1c269949..df8930c5b1 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java
    @@ -1,14 +1,14 @@
     /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
    - * 
    + *
      * This library is free software; you can redistribute it and/or
      * modify it under the terms of the GNU Lesser General Public
      * License as published by the Free Software Foundation; either
      * version 2.1 of the License, or (at your option) any later version.
    - * 
    + *
      * This library is distributed in the hope that it will be useful,
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    - * Lesser General Public License for more details.  
    + * Lesser General Public License for more details.
      */
     package com.sun.jna.platform.win32;
     
    @@ -53,16 +53,16 @@ public void testNetGetJoinInformation() {
         	assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(
         			lpNameBuffer.getValue()));
         }
    -    
    +
         public void testNetGetLocalGroups() {
         	for(int i = 0; i < 2; i++) {
     			PointerByReference bufptr = new PointerByReference();
     			IntByReference entriesRead = new IntByReference();
    -			IntByReference totalEntries = new IntByReference();		
    -	    	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetLocalGroupEnum(null, i, bufptr, 
    -	    			LMCons.MAX_PREFERRED_LENGTH, 
    -	    			entriesRead, 
    -	    			totalEntries, 
    +			IntByReference totalEntries = new IntByReference();
    +	    	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetLocalGroupEnum(null, i, bufptr,
    +	    			LMCons.MAX_PREFERRED_LENGTH,
    +	    			entriesRead,
    +	    			totalEntries,
     	    			null));
     	    	assertTrue(entriesRead.getValue() > 0);
     	    	assertEquals(totalEntries.getValue(), entriesRead.getValue());
    @@ -70,11 +70,11 @@ public void testNetGetLocalGroups() {
     	    			bufptr.getValue()));
         	}
         }
    -    
    +
         public void testNetGetDCName() {
         	PointerByReference lpNameBuffer = new PointerByReference();
         	IntByReference BufferType = new IntByReference();
    -    	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGetJoinInformation(null, lpNameBuffer, BufferType));    	
    +    	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGetJoinInformation(null, lpNameBuffer, BufferType));
         	if (BufferType.getValue() == LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) {
     	    	PointerByReference bufptr = new PointerByReference();
     	    	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGetDCName(null, null, bufptr));
    @@ -84,7 +84,7 @@ public void testNetGetDCName() {
         	}
         	assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue()));
         }
    -    
    +
         public void testNetUserGetGroups() {
         	User[] users = Netapi32Util.getUsers();
         	assertTrue(users.length >= 1);
    @@ -92,16 +92,16 @@ public void testNetUserGetGroups() {
         	IntByReference entriesread = new IntByReference();
         	IntByReference totalentries = new IntByReference();
         	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserGetGroups(
    -    			null, users[0].name, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, 
    +    			null, users[0].name, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH,
         			entriesread, totalentries));
    -    	GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue());    	
    +    	GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue());
         	GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
             for (GROUP_USERS_INFO_0 localGroupInfo : lgroups) {
             	assertTrue(localGroupInfo.grui0_name.length() > 0);
             }
         	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
         }
    -    
    +
         public void testNetUserGetLocalGroups() {
         	String currentUser = Secur32Util.getUserNameEx(
     				EXTENDED_NAME_FORMAT.NameSamCompatible);
    @@ -109,44 +109,44 @@ public void testNetUserGetLocalGroups() {
         	IntByReference entriesread = new IntByReference();
         	IntByReference totalentries = new IntByReference();
         	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserGetLocalGroups(
    -    			null, currentUser, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, 
    +    			null, currentUser, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH,
         			entriesread, totalentries));
    -    	LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());    	
    +    	LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());
         	LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
             for (LOCALGROUP_USERS_INFO_0 localGroupInfo : lgroups) {
             	assertTrue(localGroupInfo.lgrui0_name.length() > 0);
             }
         	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
    -    }    
    -    
    +    }
    +
         public void testNetGroupEnum() {
         	PointerByReference bufptr = new PointerByReference();
         	IntByReference entriesread = new IntByReference();
         	IntByReference totalentries = new IntByReference();
         	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGroupEnum(
    -    			null, 2, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));    	
    -    	GROUP_INFO_2 group = new GROUP_INFO_2(bufptr.getValue());    	
    +    			null, 2, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));
    +    	GROUP_INFO_2 group = new GROUP_INFO_2(bufptr.getValue());
         	GROUP_INFO_2[] groups = (GROUP_INFO_2[]) group.toArray(entriesread.getValue());
             for (GROUP_INFO_2 grpi : groups) {
             	assertTrue(grpi.grpi2_name.length() > 0);
             }
         	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
         }
    -    
    +
         public void testNetUserEnum() {
         	PointerByReference bufptr = new PointerByReference();
         	IntByReference entriesread = new IntByReference();
         	IntByReference totalentries = new IntByReference();
    -    	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserEnum(    			
    -    			null, 1, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));    	
    -    	USER_INFO_1 userinfo = new USER_INFO_1(bufptr.getValue());    	
    +    	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserEnum(
    +    			null, 1, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));
    +    	USER_INFO_1 userinfo = new USER_INFO_1(bufptr.getValue());
         	USER_INFO_1[] userinfos = (USER_INFO_1[]) userinfo.toArray(entriesread.getValue());
             for (USER_INFO_1 ui : userinfos) {
             	assertTrue(ui.usri1_name.length() > 0);
             }
         	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
    -    }    
    -    
    +    }
    +
         public void testNetUserAdd() {
         	USER_INFO_1 userInfo = new USER_INFO_1();
         	userInfo.usri1_name = "JNANetapi32TestUser";
    @@ -159,7 +159,7 @@ public void testNetUserAdd() {
         	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel(
         			Kernel32Util.getComputerName(), userInfo.usri1_name.toString()));
         }
    -    
    +
         public void testNetUserChangePassword() {
         	USER_INFO_1 userInfo = new USER_INFO_1();
         	userInfo.usri1_name = "JNANetapi32TestUser";
    @@ -177,35 +177,35 @@ public void testNetUserChangePassword() {
     	    	assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel(
     	    			Kernel32Util.getComputerName(), userInfo.usri1_name.toString()));
         	}
    -    }    
    -    
    +    }
    +
         public void testNetUserDel() {
         	assertEquals(LMErr.NERR_UserNotFound, Netapi32.INSTANCE.NetUserDel(
         			Kernel32Util.getComputerName(), "JNANetapi32TestUserDoesntExist"));
         }
    -    
    +
         public void testDsGetDcName() {
         	if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
         		return;
    -    	
    +
             PDOMAIN_CONTROLLER_INFO.ByReference pdci = new PDOMAIN_CONTROLLER_INFO.ByReference();
         	assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.DsGetDcName(
         			null, null, null, null, 0, pdci));
         	assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(
         			pdci.getPointer()));
         }
    -    
    +
         public void testDsGetForestTrustInformation() {
         	if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
         		return;
     
    -    	String domainController = Netapi32Util.getDCName();    	
    +    	String domainController = Netapi32Util.getDCName();
         	PLSA_FOREST_TRUST_INFORMATION.ByReference pfti = new PLSA_FOREST_TRUST_INFORMATION.ByReference();
         	assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsGetForestTrustInformation(
         			domainController, null, 0, pfti));
    -    	
    +
         	assertTrue(pfti.fti.RecordCount >= 0);
    -    	
    +
         	for (PLSA_FOREST_TRUST_RECORD precord : pfti.fti.getEntries()) {
         		LSA_FOREST_TRUST_RECORD.UNION data = precord.tr.u;
     			switch(precord.tr.ForestTrustType) {
    @@ -230,22 +230,22 @@ public void testDsGetForestTrustInformation() {
         			break;
     			}
         	}
    -    	
    +
         	assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(
    -    			pfti.getPointer()));   	
    +    			pfti.getPointer()));
         }
    -    
    -    
    +
    +
         public void testDsEnumerateDomainTrusts() {
         	if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
         		return;
     
         	IntByReference domainTrustCount = new IntByReference();
             PointerByReference domainsPointerRef = new PointerByReference();
    -        assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts(null, 
    +        assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts(null,
                     DsGetDC.DS_DOMAIN_VALID_FLAGS, domainsPointerRef, domainTrustCount));
         	assertTrue(domainTrustCount.getValue() >= 0);
    -    	
    +
             DS_DOMAIN_TRUSTS domainTrustRefs = new DS_DOMAIN_TRUSTS(domainsPointerRef.getValue());
             DS_DOMAIN_TRUSTS[] domainTrusts = (DS_DOMAIN_TRUSTS[]) domainTrustRefs.toArray(new DS_DOMAIN_TRUSTS[domainTrustCount.getValue()]);
     
    @@ -255,9 +255,9 @@ public void testDsEnumerateDomainTrusts() {
     			assertTrue(Advapi32Util.convertSidToStringSid(trust.DomainSid).startsWith("S-"));
     			assertTrue(Ole32Util.getStringFromGUID(trust.DomainGuid).startsWith("{"));
         	}
    -    	
     
    -    	assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(domainTrustRefs.getPointer()));   	    	
    +
    +    	assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(domainTrustRefs.getPointer()));
         }
     
         public void testNetShareAddShareInfo2() throws Exception {
    @@ -286,7 +286,7 @@ public void testNetShareAddShareInfo2() throws Exception {
                 throw new Exception("testNetShareAddShareInfo2 failed with invalid parameter on structure offset: " + parm_err.getValue());
             }
     
    -        assertEquals(LMErr.NERR_Success, winError);
    +        assertEquals("Failed to add share", LMErr.NERR_Success, winError);
     
             Netapi32.INSTANCE.NetShareDel(null, shi.shi2_netname, 0);
         }
    @@ -342,10 +342,10 @@ public void testNetShareDel() throws Exception {
             shi.write();
     
             IntByReference parm_err = new IntByReference(0);
    -        assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetShareAdd(null, // Use local computer
    +        assertEquals("Failed to add share", LMErr.NERR_Success, Netapi32.INSTANCE.NetShareAdd(null, // Use local computer
                     2, shi.getPointer(), parm_err));
     
    -        assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetShareDel(null, shi.shi2_netname, 0));
    +        assertEquals("Failed to delete share", LMErr.NERR_Success, Netapi32.INSTANCE.NetShareDel(null, shi.shi2_netname, 0));
         }
     
         private File createTempFolder() throws Exception {
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32UtilTest.java b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32UtilTest.java
    index 9c3b5d0d5e..38cc8e6867 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32UtilTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32UtilTest.java
    @@ -1,14 +1,14 @@
     /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
    - * 
    + *
      * This library is free software; you can redistribute it and/or
      * modify it under the terms of the GNU Lesser General Public
      * License as published by the Free Software Foundation; either
      * version 2.1 of the License, or (at your option) any later version.
    - * 
    + *
      * This library is distributed in the hope that it will be useful,
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    - * Lesser General Public License for more details.  
    + * Lesser General Public License for more details.
      */
     package com.sun.jna.platform.win32;
     
    @@ -61,24 +61,24 @@ public static void main(String[] args) {
     			System.out.println("    site: " + dc.clientSiteName);
     			System.out.println("  forest: " + dc.dnsForestName);
     			System.out.println("    guid: " + Ole32Util.getStringFromGUID(dc.domainGuid));
    -		}		
    +		}
     		// domain trusts
     		if (Netapi32Util.getJoinStatus() == LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) {
     			DomainTrust[] trusts = Netapi32Util.getDomainTrusts();
     			System.out.println("Domain trusts: (" + trusts.length + ")");
     			for(DomainTrust trust : trusts) {
    -				System.out.println(" " + trust.NetbiosDomainName + ": " + trust.DnsDomainName 
    +				System.out.println(" " + trust.NetbiosDomainName + ": " + trust.DnsDomainName
     						+ " (" + trust.DomainSidString + ")");
     			}
     		}
         }
    -    
    +
     	public void testGetDomain() {
     		String computerName = System.getenv("COMPUTERNAME");
     		String domain = Netapi32Util.getDomainName(computerName);
     		assertTrue(domain.length() > 0);
     	}
    -	
    +
     	public void testGetLocalGroups() {
     		Netapi32Util.LocalGroup[] localGroups = Netapi32Util.getLocalGroups();
     		assertNotNull(localGroups);
    @@ -96,7 +96,7 @@ public void testGetUsers() {
     		}
     		assertTrue(users.length > 0);
     	}
    -	
    +
     	public void testGetUserInfo() {
     		if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
     			return;
    @@ -104,12 +104,11 @@ public void testGetUserInfo() {
     	}
     
     	public void testGetUserInfoWithDomainSpecified() {
    -		UserInfo userInfo = Netapi32Util.getUserInfo(Advapi32Util.getUserName(), 
    -				System.getenv("USERDOMAIN"));
    -		assertNotNull(userInfo);
    -		assertTrue(Advapi32.INSTANCE.IsValidSid(userInfo.sid));
    +		UserInfo userInfo = Netapi32Util.getUserInfo(Advapi32Util.getUserName(), System.getenv("USERDOMAIN"));
    +		assertNotNull("No user info retrieved", userInfo);
    +		assertTrue("Invalid user SID", Advapi32.INSTANCE.IsValidSid(userInfo.sid));
     	}
    -    
    +
     	public void testGetGlobalGroups() {
     		Netapi32Util.Group[] groups = Netapi32Util.getGlobalGroups();
     		assertNotNull(groups);
    @@ -118,7 +117,7 @@ public void testGetGlobalGroups() {
     		}
     		assertTrue(groups.length > 0);
     	}
    -	
    +
     	public void testGetCurrentUserLocalGroups() {
     		Netapi32Util.Group[] localGroups = Netapi32Util.getCurrentUserLocalGroups();
     		assertNotNull(localGroups);
    @@ -134,25 +133,25 @@ public void testGetJoinStatus() {
     				|| joinStatus == LMJoin.NETSETUP_JOIN_STATUS.NetSetupUnjoined
     				|| joinStatus == LMJoin.NETSETUP_JOIN_STATUS.NetSetupWorkgroupName);
     	}
    -	
    +
     	public void testGetDCName() {
     		if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
     			return;
    -		
    +
     		String domainController = Netapi32Util.getDCName();
     		assertTrue(domainController.length() > 0);
     		assertTrue(domainController.startsWith("\\\\"));
     	}
    -	
    +
     	public void testGetDC() {
     		if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
     			return;
    -			
    +
     		DomainController dc = Netapi32Util.getDC();
    -		assertTrue(dc.address.startsWith("\\\\"));
    -		assertTrue(dc.domainName.length() > 0);
    +		assertTrue("Invalid address prefix: " + dc.address, dc.address.startsWith("\\\\"));
    +		assertTrue("Empty domain name", dc.domainName.length() > 0);
     	}
    -	
    +
     	public void testGetDomainTrusts() {
     		if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
     			return;
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Ole32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Ole32Test.java
    index 31978794f5..73ce524542 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Ole32Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Ole32Test.java
    @@ -16,9 +16,7 @@
     
     import com.sun.jna.Native;
     import com.sun.jna.Pointer;
    -import com.sun.jna.platform.win32.BaseTSD.SIZE_T;
     import com.sun.jna.platform.win32.Guid.GUID;
    -import com.sun.jna.platform.win32.WinDef.LPVOID;
     import com.sun.jna.platform.win32.WinNT.HRESULT;
     import com.sun.jna.ptr.PointerByReference;
     
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/OleAutoTest.java b/contrib/platform/test/com/sun/jna/platform/win32/OleAutoTest.java
    index 9318205381..e37d447d62 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/OleAutoTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/OleAutoTest.java
    @@ -14,7 +14,6 @@
     
     import junit.framework.TestCase;
     
    -import com.sun.jna.Native;
     import com.sun.jna.WString;
     import com.sun.jna.platform.win32.Guid.CLSID;
     import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/OleAutoUtilTest.java b/contrib/platform/test/com/sun/jna/platform/win32/OleAutoUtilTest.java
    index 7431e1802b..7c3c83efd3 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/OleAutoUtilTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/OleAutoUtilTest.java
    @@ -17,7 +17,6 @@
     import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
     import com.sun.jna.platform.win32.Variant.VARIANT;
     import com.sun.jna.platform.win32.WinDef.SHORT;
    -import com.sun.jna.platform.win32.COM.COMException;
     
     /**
      * @author Tobias Wolf, wolf.tobias@gmx.net
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java
    index 66171e4151..cf83e053e3 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Shell32Test.java
    @@ -1,14 +1,14 @@
     /* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, All Rights Reserved
    - * 
    + *
      * This library is free software; you can redistribute it and/or
      * modify it under the terms of the GNU Lesser General Public
      * License as published by the Free Software Foundation; either
      * version 2.1 of the License, or (at your option) any later version.
    - * 
    + *
      * This library is distributed in the hope that it will be useful,
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    - * Lesser General Public License for more details.  
    + * Lesser General Public License for more details.
      */
     package com.sun.jna.platform.win32;
     
    @@ -17,7 +17,6 @@
     import java.io.IOException;
     
     import com.sun.jna.Native;
    -import com.sun.jna.WString;
     import com.sun.jna.platform.win32.Guid.GUID;
     import com.sun.jna.platform.win32.ShellAPI.APPBARDATA;
     import com.sun.jna.platform.win32.ShellAPI.SHELLEXECUTEINFO;
    @@ -46,27 +45,26 @@ public static void main(String[] args) {
     
         public void testSHGetFolderPath() {
         	char[] pszPath = new char[WinDef.MAX_PATH];
    -    	assertEquals(W32Errors.S_OK, Shell32.INSTANCE.SHGetFolderPath(null, 
    -                                                                      ShlObj.CSIDL_PROGRAM_FILES, null, ShlObj.SHGFP_TYPE_CURRENT, 
    -                                                                      pszPath));
    -    	assertTrue(Native.toString(pszPath).length() > 0);
    +    	assertEquals("Failed to retrieve path", W32Errors.S_OK,
    +    	        Shell32.INSTANCE.SHGetFolderPath(null, ShlObj.CSIDL_PROGRAM_FILES, null, ShlObj.SHGFP_TYPE_CURRENT, pszPath));
    +    	assertTrue("Empty path", Native.toString(pszPath).length() > 0);
         }
     
         public void testSHGetDesktopFolder() {
             PointerByReference ppshf = new PointerByReference();
             WinNT.HRESULT hr = Shell32.INSTANCE.SHGetDesktopFolder(ppshf);
    -        assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
    -        assertTrue(ppshf.getValue() != null);
    +        assertTrue("Failed to get folder: " + hr.intValue(), W32Errors.SUCCEEDED(hr.intValue()));
    +        assertTrue("No folder value", ppshf.getValue() != null);
             // should release the interface, but we need Com4JNA to do that.
         }
     
         public final void testSHGetSpecialFolderPath() {
             final char[] pszPath = new char[WinDef.MAX_PATH];
    -        assertTrue(Shell32.INSTANCE.SHGetSpecialFolderPath(null, pszPath, ShlObj.CSIDL_APPDATA, false));
    -        assertFalse(Native.toString(pszPath).isEmpty());
    +        assertTrue("SHGetSpecialFolderPath", Shell32.INSTANCE.SHGetSpecialFolderPath(null, pszPath, ShlObj.CSIDL_APPDATA, false));
    +        assertFalse("No path", Native.toString(pszPath).isEmpty());
         }
     
    -    
    +
         private void newAppBar() {
             APPBARDATA data = new APPBARDATA.ByReference();
             data.cbSize.setValue(data.size());
    @@ -115,7 +113,7 @@ public void testResizeDesktopFromBottom() throws InterruptedException {
         }
     
         public void testResizeDesktopFromTop() throws InterruptedException {
    -        
    +
             newAppBar();
     
             APPBARDATA data = new APPBARDATA.ByReference();
    @@ -142,12 +140,12 @@ public void testSHGetKnownFolderPath() {
             HANDLE token = null;
             GUID guid = KnownFolders.FOLDERID_Fonts;
             HRESULT hr = Shell32.INSTANCE.SHGetKnownFolderPath(guid, flags, token, outPath);
    -        
    +
             Ole32.INSTANCE.CoTaskMemFree(outPath.getValue());
    -        
    +
             assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
         }
    -    
    +
         public void testSHEmptyRecycleBin() {
             File file = new File(System.getProperty("java.io.tmpdir"), System.nanoTime() + ".txt");
             try {
    @@ -161,7 +159,7 @@ public void testSHEmptyRecycleBin() {
     
                 int result = Shell32.INSTANCE.SHEmptyRecycleBin(null, null,
                                                                 Shell32.SHERB_NOCONFIRMATION | Shell32.SHERB_NOPROGRESSUI | Shell32.SHERB_NOSOUND);
    -            // for reasons I can not find documented on MSDN, 
    +            // for reasons I can not find documented on MSDN,
                 // the function returns the following:
                 // 0 when the recycle bin has items in it
                 // -2147418113 when the recycle bin has no items in it
    @@ -207,7 +205,7 @@ public void testShellExecuteEx() {
     
         /**
          * Creates (if needed) and fills the specified file with some content (10 lines of the same text)
    -     * 
    +     *
          * @param file
          *            The file to fill with content
          * @throws IOException
    @@ -225,12 +223,12 @@ private void fillTempFile(File file) throws IOException {
                 fileWriter.close();
             }
         }
    -    
    +
         public void testExtractIconEx() {
             String winDir = Kernel32Util.getEnvironmentVariable("WINDIR");
             assertNotNull("No WINDIR value returned", winDir);
             assertTrue("Specified WINDIR does not exist: " + winDir, new File(winDir).exists());
    -        
    +
             int iconCount = Shell32.INSTANCE.ExtractIconEx(new File(winDir, "explorer.exe").getAbsolutePath(), -1, null, null, 1);
             assertTrue("Should be at least two icons in explorer.exe", iconCount > 1);
         }
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/VariantTest.java b/contrib/platform/test/com/sun/jna/platform/win32/VariantTest.java
    index 49824b7f44..55bdad57eb 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/VariantTest.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/VariantTest.java
    @@ -2,7 +2,6 @@
     
     import junit.framework.TestCase;
     
    -import com.sun.jna.Native;
     import com.sun.jna.platform.win32.OaIdl.DATE;
     import com.sun.jna.platform.win32.Variant.VARIANT;
     import com.sun.jna.platform.win32.WinBase.SYSTEMTIME;
    @@ -19,6 +18,7 @@ public static void main(String[] args) {
         }
     
         public VariantTest() {
    +        super();
         }
     
         public void testVariantClear() {
    @@ -73,7 +73,7 @@ public void testVariantConstructors() {
             VARIANT variant = new VARIANT((short) 1);
             variant = new VARIANT((byte) 1);
             variant = new VARIANT('1');
    -        variant = new VARIANT((int) 1);
    +        variant = new VARIANT(1);
             variant = new VARIANT((long) 1);
             variant = new VARIANT((float) 1);
             variant = new VARIANT((double) 1);
    diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Wtsapi32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Wtsapi32Test.java
    index 937b879b23..d8daffcaf7 100644
    --- a/contrib/platform/test/com/sun/jna/platform/win32/Wtsapi32Test.java
    +++ b/contrib/platform/test/com/sun/jna/platform/win32/Wtsapi32Test.java
    @@ -5,7 +5,6 @@
     import com.sun.jna.Native;
     import junit.framework.TestCase;
     
    -import com.sun.jna.Pointer;
     import com.sun.jna.platform.win32.WinDef.HWND;
     
     public class Wtsapi32Test extends TestCase {
    diff --git a/src/com/sun/jna/CallbackReference.java b/src/com/sun/jna/CallbackReference.java
    index 9fe8f76e80..1031364c59 100644
    --- a/src/com/sun/jna/CallbackReference.java
    +++ b/src/com/sun/jna/CallbackReference.java
    @@ -68,14 +68,15 @@ static void setCallbackThreadInitializer(Callback cb, CallbackThreadInitializer
         }
     
         static class AttachOptions extends Structure {
    +        public static final List FIELDS = createFieldsOrder("daemon", "detach", "name");
             public boolean daemon;
             public boolean detach;
             public String name;
             // Thread name must be UTF8-encoded
             { setStringEncoding("utf8"); }
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "daemon", "detach", "name", });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     
    diff --git a/src/com/sun/jna/Structure.java b/src/com/sun/jna/Structure.java
    index e3a86f61e3..8c3182022b 100644
    --- a/src/com/sun/jna/Structure.java
    +++ b/src/com/sun/jna/Structure.java
    @@ -31,7 +31,6 @@
     import java.util.Map;
     import java.util.Set;
     import java.util.WeakHashMap;
    -import java.util.zip.Adler32;
     
     /**
      * Represents a native structure with a Java peer class.  When used as a
    @@ -123,8 +122,8 @@ public interface ByReference { }
         //public static final int ALIGN_8 = 6;
     
         protected static final int CALCULATE_SIZE = -1;
    -    static final Map layoutInfo = new WeakHashMap();
    -    static final Map fieldOrder = new WeakHashMap();
    +    static final Map, LayoutInfo> layoutInfo = new WeakHashMap, LayoutInfo>();
    +    static final Map, List> fieldOrder = new WeakHashMap, List>();
     
         // This field is accessed by native code
         private Pointer memory;
    @@ -133,10 +132,10 @@ public interface ByReference { }
         private String encoding;
         private int actualAlignType;
         private int structAlignment;
    -    private Map structFields;
    +    private Map structFields;
         // Keep track of native C strings which have been allocated,
         // corresponding to String fields of this Structure
    -    private final Map nativeStrings = new HashMap();
    +    private final Map nativeStrings = new HashMap();
         private TypeMapper typeMapper;
         // This field is accessed by native code
         private long typeInfo;
    @@ -193,11 +192,11 @@ protected Structure(Pointer p, int alignType, TypeMapper mapper) {
          * calling this method.
          * @return {@link Map} of field names to field representations.
          */
    -    Map fields() {
    +    Map fields() {
             return structFields;
         }
     
    -    /** 
    +    /**
          * @return the type mapper in effect for this Structure.
          */
         TypeMapper getTypeMapper() {
    @@ -270,7 +269,7 @@ protected void setAlignType(int alignType) {
     
         /**
          * Obtain auto-allocated memory for use with struct represenations.
    -     * @param size desired size 
    +     * @param size desired size
          * @return newly-allocated memory
          */
         protected Memory autoAllocate(int size) {
    @@ -441,24 +440,26 @@ public Pointer getPointer() {
     
         // Keep track of ByReference reads to avoid redundant reads of the same
         // address
    -    private static final ThreadLocal reads = new ThreadLocal() {
    -        protected synchronized Object initialValue() {
    -            return new HashMap();
    +    private static final ThreadLocal> reads = new ThreadLocal>() {
    +        @Override
    +        protected synchronized Map initialValue() {
    +            return new HashMap();
             }
         };
     
         // Keep track of what is currently being read/written to avoid redundant
         // reads (avoids problems with circular references).
    -    private static final ThreadLocal busy = new ThreadLocal() {
    -        protected synchronized Object initialValue() {
    +    private static final ThreadLocal> busy = new ThreadLocal>() {
    +        @Override
    +        protected synchronized Set initialValue() {
                 return new StructureSet();
             }
         };
    -    
    +
         /** Avoid using a hash-based implementation since the hash code
                 for a Structure is not immutable.
          */
    -    static class StructureSet extends AbstractCollection implements Set {
    +    static class StructureSet extends AbstractCollection implements Set {
             Structure[] elements;
             private int count;
             private void ensureCapacity(int size) {
    @@ -474,19 +475,21 @@ else if (elements.length < size) {
             public Structure[] getElements() {
     			return elements;
     		}
    +        @Override
             public int size() { return count; }
    +        @Override
             public boolean contains(Object o) {
    -            return indexOf(o) != -1;
    +            return indexOf((Structure) o) != -1;
             }
    -        public boolean add(Object o) {
    +        @Override
    +        public boolean add(Structure o) {
                 if (!contains(o)) {
                     ensureCapacity(count+1);
    -                elements[count++] = (Structure)o;
    +                elements[count++] = o;
                 }
                 return true;
             }
    -        private int indexOf(Object o) {
    -            Structure s1 = (Structure)o;
    +        private int indexOf(Structure s1) {
                 for (int i=0;i < count;i++) {
                     Structure s2 = elements[i];
                     if (s1 == s2
    @@ -498,8 +501,9 @@ private int indexOf(Object o) {
                 }
                 return -1;
             }
    +        @Override
             public boolean remove(Object o) {
    -            int idx = indexOf(o);
    +            int idx = indexOf((Structure) o);
                 if (idx != -1) {
                     if (--count >= 0) {
                         elements[idx] = elements[count];
    @@ -512,7 +516,8 @@ public boolean remove(Object o) {
             /** Simple implementation so that toString() doesn't break.
                 Provides an iterator over a snapshot of this Set.
             */
    -        public Iterator iterator() {
    +        @Override
    +        public Iterator iterator() {
                 Structure[] e = new Structure[count];
                 if (count > 0) {
                     System.arraycopy(elements, 0, e, 0, count);
    @@ -520,12 +525,12 @@ public Iterator iterator() {
                 return Arrays.asList(e).iterator();
             }
         }
    -    
    -    static Set busy() {
    -        return (Set)busy.get();
    +
    +    static Set busy() {
    +        return busy.get();
         }
    -    static Map reading() {
    -        return (Map)reads.get();
    +    static Map reading() {
    +        return reads.get();
         }
     
         /** Performs auto-read only if uninitialized. */
    @@ -560,8 +565,7 @@ public void read() {
                 reading().put(getPointer(), this);
             }
             try {
    -            for (Iterator i=fields().values().iterator();i.hasNext();) {
    -                StructField structField = (StructField)i.next();
    +            for (StructField structField : fields().values()) {
                     readField(structField);
                 }
             }
    @@ -579,7 +583,7 @@ public void read() {
          */
         protected int fieldOffset(String name) {
     	ensureAllocated();
    -	StructField f = (StructField)fields().get(name);
    +	StructField f = fields().get(name);
             if (f == null)
                 throw new IllegalArgumentException("No such field: " + name);
     	return f.offset;
    @@ -593,7 +597,7 @@ protected int fieldOffset(String name) {
          */
         public Object readField(String name) {
             ensureAllocated();
    -        StructField f = (StructField)fields().get(name);
    +        StructField f = fields().get(name);
             if (f == null)
                 throw new IllegalArgumentException("No such field: " + name);
             return readField(f);
    @@ -647,13 +651,13 @@ private void setFieldValue(Field field, Object value, boolean overrideFinal) {
          * @param address the native struct *
          * @return Updated Structure.ByReference object
          */
    -    static Structure updateStructureByReference(Class type, Structure s, Pointer address) {
    +    static Structure updateStructureByReference(Class type, Structure s, Pointer address) {
             if (address == null) {
                 s = null;
             }
             else {
                 if (s == null || !address.equals(s.getPointer())) {
    -                Structure s1 = (Structure)reading().get(address);
    +                Structure s1 = reading().get(address);
                     if (s1 != null && type.equals(s1.getClass())) {
                         s = s1;
                         s.autoRead();
    @@ -682,7 +686,7 @@ protected Object readField(StructField structField) {
             int offset = structField.offset;
     
             // Determine the type of the field
    -        Class fieldType = structField.type;
    +        Class fieldType = structField.type;
             FromNativeConverter readConverter = structField.readConverter;
             if (readConverter != null) {
                 fieldType = readConverter.nativeType();
    @@ -748,8 +752,7 @@ public void write() {
             busy().add(this);
             try {
                 // Write all fields, except those marked 'volatile'
    -            for (Iterator i=fields().values().iterator();i.hasNext();) {
    -                StructField sf = (StructField)i.next();
    +            for (StructField sf : fields().values()) {
                     if (!sf.isVolatile) {
                         writeField(sf);
                     }
    @@ -767,7 +770,7 @@ public void write() {
          */
         public void writeField(String name) {
             ensureAllocated();
    -        StructField f = (StructField)fields().get(name);
    +        StructField f = fields().get(name);
             if (f == null)
                 throw new IllegalArgumentException("No such field: " + name);
             writeField(f);
    @@ -782,7 +785,7 @@ public void writeField(String name) {
          */
         public void writeField(String name, Object value) {
             ensureAllocated();
    -        StructField structField = (StructField)fields().get(name);
    +        StructField structField = fields().get(name);
             if (structField == null)
                 throw new IllegalArgumentException("No such field: " + name);
             setFieldValue(structField.field, value);
    @@ -804,7 +807,7 @@ protected void writeField(StructField structField) {
             Object value = getFieldValue(structField.field);
     
             // Determine the type of the field
    -        Class fieldType = structField.type;
    +        Class fieldType = structField.type;
             ToNativeConverter converter = structField.writeConverter;
             if (converter != null) {
                 value = converter.toNative(value, new StructureWriteContext(this, structField.field));
    @@ -824,7 +827,7 @@ protected void writeField(StructField structField) {
                         return;
                     }
                     NativeString nativeString = wide
    -                    ? new NativeString(value.toString(), true) 
    +                    ? new NativeString(value.toString(), true)
                         : new NativeString(value.toString(), encoding);
                     // Keep track of allocated C strings to avoid
                     // premature garbage collection of the memory.
    @@ -874,7 +877,7 @@ protected void writeField(StructField structField) {
          * guaranteed to be predictable.
          * @return ordered list of field names
          */
    -    protected abstract List getFieldOrder();
    +    protected abstract List getFieldOrder();
     
         /**
          * Force a compile-time error on the old method of field definition
    @@ -882,6 +885,7 @@ protected void writeField(StructField structField) {
          * @deprecated Use the required method getFieldOrder() instead to
          * indicate the order of fields in this structure.
          */
    +    @Deprecated
         protected final void setFieldOrder(String[] fields) {
             throw new Error("This method is obsolete, use getFieldOrder() instead");
         }
    @@ -890,11 +894,11 @@ protected final void setFieldOrder(String[] fields) {
          * @param fields list of fields to be sorted
          * @param names list of names representing the desired sort order
          */
    -    protected void sortFields(List fields, List names) {
    +    protected void sortFields(List fields, List names) {
             for (int i=0;i < names.size();i++) {
    -            String name = (String)names.get(i);
    +            String name = names.get(i);
                 for (int f=0;f < fields.size();f++) {
    -                Field field = (Field)fields.get(f);
    +                Field field = fields.get(f);
                     if (name.equals(field.getName())) {
                         Collections.swap(fields, i, f);
                         break;
    @@ -907,18 +911,18 @@ protected void sortFields(List fields, List names) {
          * @return ordered list of public {@link java.lang.reflect.Field} available on
          * this {@link Structure} class.
          */
    -    protected List getFieldList() {
    -        List flist = new ArrayList();
    -        for (Class cls = getClass();
    +    protected List getFieldList() {
    +        List flist = new ArrayList();
    +        for (Class cls = getClass();
                  !cls.equals(Structure.class);
                  cls = cls.getSuperclass()) {
    -            List classFields = new ArrayList();
    +            List classFields = new ArrayList();
                 Field[] fields = cls.getDeclaredFields();
                 for (int i=0;i < fields.length;i++) {
                     int modifiers = fields[i].getModifiers();
    -                if (Modifier.isStatic(modifiers)
    -                    || !Modifier.isPublic(modifiers))
    +                if (Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
                         continue;
    +                }
                     classFields.add(fields[i]);
                 }
                 flist.addAll(0, classFields);
    @@ -929,19 +933,47 @@ protected List getFieldList() {
         /** Cache field order per-class.
          * @return (cached) ordered list of fields
          */
    -    private List fieldOrder() {
    +    private List fieldOrder() {
    +        Class clazz = getClass();
             synchronized(fieldOrder) {
    -            List list = (List)fieldOrder.get(getClass());
    +            List list = fieldOrder.get(clazz);
                 if (list == null) {
                     list = getFieldOrder();
    -                fieldOrder.put(getClass(), list);
    +                fieldOrder.put(clazz, list);
                 }
                 return list;
             }
         }
     
    -    private List sort(Collection c) {
    -        List list = new ArrayList(c);
    +    public static List createFieldsOrder(List baseFields, String ... extraFields) {
    +        return createFieldsOrder(baseFields, Arrays.asList(extraFields));
    +    }
    +
    +    public static List createFieldsOrder(List baseFields, List extraFields) {
    +        List fields = new ArrayList(baseFields.size() + extraFields.size());
    +        fields.addAll(baseFields);
    +        fields.addAll(extraFields);
    +        return Collections.unmodifiableList(fields);
    +    }
    +
    +    /**
    +     * @param field The (single) field name
    +     * @return @return An un-modifiable list containing the field name
    +     */
    +    public static List createFieldsOrder(String field) {
    +        return Collections.unmodifiableList(Collections.singletonList(field));
    +    }
    +
    +    /**
    +     * @param fields The structure field names in correct order
    +     * @return An un-modifiable list of the fields
    +     */
    +    public static List createFieldsOrder(String ... fields) {
    +        return Collections.unmodifiableList(Arrays.asList(fields));
    +    }
    +
    +    private static > List sort(Collection c) {
    +        List list = new ArrayList(c);
             Collections.sort(list);
             return list;
         }
    @@ -953,13 +985,14 @@ private List sort(Collection c) {
             @throws Error if force is true and field order data not yet specified
             and can't be generated automatically.
         **/
    -    protected List getFields(boolean force) {
    -        List flist = getFieldList();
    -        Set names = new HashSet();
    -        for (Iterator i=flist.iterator();i.hasNext();) {
    -            names.add(((Field)i.next()).getName());
    +    protected List getFields(boolean force) {
    +        List flist = getFieldList();
    +        Set names = new HashSet();
    +        for (Field f : flist) {
    +            names.add(f.getName());
             }
    -        List fieldOrder = fieldOrder();
    +
    +        List fieldOrder = fieldOrder();
             if (fieldOrder.size() != flist.size() && flist.size() > 1) {
                 if (force) {
                     throw new Error("Structure.getFieldOrder() on " + getClass()
    @@ -974,7 +1007,7 @@ protected List getFields(boolean force) {
                 return null;
             }
     
    -        Set orderedNames = new HashSet(fieldOrder);
    +        Set orderedNames = new HashSet(fieldOrder);
             if (!orderedNames.equals(names)) {
                 throw new Error("Structure.getFieldOrder() on " + getClass()
                                 + " returns names ("
    @@ -984,7 +1017,6 @@ protected List getFields(boolean force) {
             }
     
             sortFields(flist, fieldOrder);
    -
             return flist;
         }
     
    @@ -1010,7 +1042,7 @@ protected int calculateSize(boolean force) {
          * @param type Structure subclass to check
          * @return native size of the given Structure subclass
          */
    -    static int size(Class type) {
    +    static int size(Class type) {
             return size(type, null);
         }
     
    @@ -1019,10 +1051,10 @@ static int size(Class type) {
          * @param value optional instance of the given class
          * @return native size of the Structure subclass
          */
    -    static int size(Class type, Structure value) {
    +    static int size(Class type, Structure value) {
             LayoutInfo info;
             synchronized(layoutInfo) {
    -            info = (LayoutInfo)layoutInfo.get(type);
    +            info = layoutInfo.get(type);
             }
             int sz = (info != null && !info.variable) ? info.size : CALCULATE_SIZE;
             if (sz == CALCULATE_SIZE) {
    @@ -1035,7 +1067,7 @@ static int size(Class type, Structure value) {
         }
     
         /**
    -     * @param force whether to force size calculation.  
    +     * @param force whether to force size calculation.
          * @param avoidFFIType set false in certain situations to avoid recursive
          * type lookup.
          * @return calculated size, or {@link #CALCULATE_SIZE} if there is not yet
    @@ -1043,9 +1075,10 @@ static int size(Class type, Structure value) {
          */
         int calculateSize(boolean force, boolean avoidFFIType) {
             int size = CALCULATE_SIZE;
    +        Class clazz = getClass();
             LayoutInfo info;
             synchronized(layoutInfo) {
    -            info = (LayoutInfo)layoutInfo.get(getClass());
    +            info = layoutInfo.get(clazz);
             }
             if (info == null
                 || this.alignType != info.alignType
    @@ -1063,10 +1096,10 @@ int calculateSize(boolean force, boolean avoidFFIType) {
                         // type mapper; this way we don't override the cache
                         // prematurely when processing subclasses that call
                         // setAlignType() or setTypeMapper() in the constructor
    -                    if (!layoutInfo.containsKey(getClass())
    +                    if (!layoutInfo.containsKey(clazz)
                             || this.alignType != ALIGN_DEFAULT
                             || this.typeMapper != null) {
    -                        layoutInfo.put(getClass(), info);
    +                        layoutInfo.put(clazz, info);
                         }
                     }
                 }
    @@ -1081,7 +1114,7 @@ int calculateSize(boolean force, boolean avoidFFIType) {
         private static class LayoutInfo {
             private int size = CALCULATE_SIZE;
             private int alignment = 1;
    -        private final Map fields = Collections.synchronizedMap(new LinkedHashMap());
    +        private final Map fields = Collections.synchronizedMap(new LinkedHashMap());
             private int alignType = ALIGN_DEFAULT;
             private TypeMapper typeMapper;
             private boolean variable;
    @@ -1089,7 +1122,7 @@ private static class LayoutInfo {
             private StructField typeInfoField;
         }
     
    -    private void validateField(String name, Class type) {
    +    private void validateField(String name, Class type) {
             if (typeMapper != null) {
                 ToNativeConverter toNative = typeMapper.getToNativeConverter(type);
                 if (toNative != null) {
    @@ -1113,9 +1146,8 @@ private void validateField(String name, Class type) {
     
         /** ensure all fields are of valid type. */
         private void validateFields() {
    -        List fields = getFieldList();
    -        for (Iterator i=fields.iterator();i.hasNext();) {
    -            Field f = (Field)i.next();
    +        List fields = getFieldList();
    +        for (Field f : fields) {
                 validateField(f.getName(), f.getType());
             }
         }
    @@ -1126,7 +1158,7 @@ private void validateFields() {
          */
         private LayoutInfo deriveLayout(boolean force, boolean avoidFFIType) {
             int calculatedSize = 0;
    -        List fields = getFields(force);
    +        List fields = getFields(force);
             if (fields == null) {
                 return null;
             }
    @@ -1136,11 +1168,11 @@ private LayoutInfo deriveLayout(boolean force, boolean avoidFFIType) {
             info.typeMapper = this.typeMapper;
     
             boolean firstField = true;
    -        for (Iterator i=fields.iterator();i.hasNext();firstField=false) {
    -            Field field = (Field)i.next();
    +        for (Iterator i=fields.iterator();i.hasNext();firstField=false) {
    +            Field field = i.next();
                 int modifiers = field.getModifiers();
     
    -            Class type = field.getType();
    +            Class type = field.getType();
                 if (type.isArray()) {
                     info.variable = true;
                 }
    @@ -1187,7 +1219,7 @@ private LayoutInfo deriveLayout(boolean force, boolean avoidFFIType) {
                     // can't calculate size yet, defer until later
                     return null;
                 }
    -            Class nativeType = type;
    +            Class nativeType = type;
                 if (NativeMapped.class.isAssignableFrom(type)) {
                     NativeMappedConverter tc = NativeMappedConverter.getInstance(type);
                     nativeType = tc.nativeType();
    @@ -1278,9 +1310,8 @@ else if (writeConverter != null || readConverter != null) {
          */
         private void initializeFields() {
             // Get the full field list, don't care about sorting
    -        List flist = getFieldList();
    -        for (Iterator i = flist.iterator(); i.hasNext();) {
    -            Field f = (Field) i.next();
    +        List flist = getFieldList();
    +        for (Field f : flist) {
                 try {
                     Object o = f.get(this);
                     if (o == null) {
    @@ -1293,7 +1324,7 @@ private void initializeFields() {
             }
         }
     
    -    private Object initializeField(Field field, Class type) {
    +    private Object initializeField(Field field, Class type) {
             Object value = null;
             if (Structure.class.isAssignableFrom(type)
                 && !(ByReference.class.isAssignableFrom(type))) {
    @@ -1345,12 +1376,12 @@ protected int getStructAlignment() {
          * @param type field type
          * @param value field value, if available
          * @param isFirstElement is this field the first element in the struct?
    -     * @return the native byte alignment 
    +     * @return the native byte alignment
          */
         // TODO: write getNaturalAlignment(stack/alloc) + getEmbeddedAlignment(structs)
         // TODO: move this into a native call which detects default alignment
         // automatically
    -    protected int getNativeAlignment(Class type, Object value, boolean isFirstElement) {
    +    protected int getNativeAlignment(Class type, Object value, boolean isFirstElement) {
             int alignment = 1;
             if (NativeMapped.class.isAssignableFrom(type)) {
                 NativeMappedConverter tc = NativeMappedConverter.getInstance(type);
    @@ -1407,25 +1438,26 @@ else if (actualAlignType == ALIGN_GNUC) {
             return alignment;
         }
     
    -    /** 
    +    /**
          * If jna.dump_memory is true, will include a native memory dump
          * of the Structure's backing memory.
    -     * @return String representation of this object. 
    +     * @return String representation of this object.
          */
    +    @Override
         public String toString() {
             return toString(Boolean.getBoolean("jna.dump_memory"));
         }
     
         /**
          * @param debug If true, will include a native memory dump of the
    -     * Structure's backing memory. 
    +     * Structure's backing memory.
          * @return String representation of this object.
          */
         public String toString(boolean debug) {
             return toString(0, true, debug);
         }
     
    -    private String format(Class type) {
    +    private String format(Class type) {
             String s = type.getName();
             int dot = s.lastIndexOf(".");
             return s.substring(dot + 1);
    @@ -1446,8 +1478,8 @@ private String toString(int indent, boolean showContents, boolean dumpMemory) {
             if (!showContents) {
                 contents = "...}";
             }
    -        else for (Iterator i=fields().values().iterator();i.hasNext();) {
    -            StructField sf = (StructField)i.next();
    +        else for (Iterator i = fields().values().iterator(); i.hasNext();) {
    +            StructField sf = i.next();
                 Object value = getFieldValue(sf.field);
                 String type = format(sf.type);
                 String index = "";
    @@ -1545,7 +1577,7 @@ public Structure[] toArray(int size) {
             return toArray((Structure[])Array.newInstance(getClass(), size));
         }
     
    -    private Class baseClass() {
    +    private Class baseClass() {
             if ((this instanceof Structure.ByReference
                  || this instanceof Structure.ByValue)
                 && Structure.class.isAssignableFrom(getClass().getSuperclass())) {
    @@ -1560,11 +1592,11 @@ private Class baseClass() {
          * @return equality result
          */
         public boolean dataEquals(Structure s) {
    -	return dataEquals(s, false);
    +        return dataEquals(s, false);
         }
     
         /** Return whether the given Structure's backing data is identical to
    -     * this one, optionally clearing and re-writing native memory before checking. 
    +     * this one, optionally clearing and re-writing native memory before checking.
          * @param s Structure to compare
          * @param clear whether to clear native memory
          * @return equality result
    @@ -1589,18 +1621,20 @@ public boolean dataEquals(Structure s, boolean clear) {
             return false;
         }
     
    -    /** 
    +    /**
          * @return whether the given structure's type and pointer match.
          */
    +    @Override
         public boolean equals(Object o) {
             return o instanceof Structure
                 && o.getClass() == getClass()
                 && ((Structure)o).getPointer().equals(getPointer());
         }
     
    -    /** 
    +    /**
          * @return hash code for this structure's pointer.
          */
    +    @Override
         public int hashCode() {
             Pointer p = getPointer();
             if (p != null) {
    @@ -1621,7 +1655,7 @@ protected void cacheTypeInfo(Pointer p) {
          * @return Native pointer to the corresponding type information
          */
         Pointer getFieldTypeInfo(StructField f) {
    -        Class type = f.type;
    +        Class type = f.type;
             Object value = getFieldValue(f.field);
             if (typeMapper != null) {
                 ToNativeConverter nc = typeMapper.getToNativeConverter(type);
    @@ -1633,7 +1667,7 @@ Pointer getFieldTypeInfo(StructField f) {
             return FFIType.get(value, type);
         }
     
    -    /** 
    +    /**
          * @return native type information for this structure.
          */
         Pointer getTypeInfo() {
    @@ -1711,7 +1745,7 @@ static Pointer getTypeInfo(Object obj) {
          * #newInstance(Class,Pointer)}, except that it additionally calls
          * {@link #conditionalAutoRead()}.
          */
    -    private static Structure newInstance(Class type, long init) {
    +    private static Structure newInstance(Class type, long init) {
             try {
                 Structure s = newInstance(type, init == 0 ? PLACEHOLDER_MEMORY : new Pointer(init));
                 if (init != 0) {
    @@ -1732,10 +1766,10 @@ private static Structure newInstance(Class type, long init) {
          * @return the new instance
          * @throws IllegalArgumentException if the instantiation fails
          */
    -    public static Structure newInstance(Class type, Pointer init) throws IllegalArgumentException {
    +    public static Structure newInstance(Class type, Pointer init) throws IllegalArgumentException {
             try {
    -            Constructor ctor = type.getConstructor(new Class[] { Pointer.class });
    -            return (Structure)ctor.newInstance(new Object[] { init });
    +            Constructor ctor = type.getConstructor(Pointer.class);
    +            return (Structure)ctor.newInstance(init);
             }
             catch(NoSuchMethodException e) {
                 // Not defined, fall back to the default
    @@ -1768,7 +1802,7 @@ public static Structure newInstance(Class type, Pointer init) throws IllegalArgu
          * @return the new instance
          * @throws IllegalArgumentException if the instantiation fails
          */
    -    public static Structure newInstance(Class type) throws IllegalArgumentException {
    +    public static Structure newInstance(Class type) throws IllegalArgumentException {
             try {
                 Structure s = (Structure)type.newInstance();
                 if (s instanceof ByValue) {
    @@ -1794,7 +1828,7 @@ public static Structure newInstance(Class type) throws IllegalArgumentException
         StructField typeInfoField() {
             LayoutInfo info;
             synchronized(layoutInfo) {
    -            info = (LayoutInfo)layoutInfo.get(getClass());
    +            info = layoutInfo.get(getClass());
             }
             if (info != null) {
                 return info.typeInfoField;
    @@ -1804,7 +1838,7 @@ StructField typeInfoField() {
     
         protected static class StructField extends Object {
             public String name;
    -        public Class type;
    +        public Class type;
             public Field field;
             public int size = -1;
             public int offset = -1;
    @@ -1813,6 +1847,7 @@ protected static class StructField extends Object {
             public FromNativeConverter readConverter;
             public ToNativeConverter writeConverter;
             public FromNativeContext context;
    +        @Override
             public String toString() {
                 return name + "@" + offset + "[" + size + "] (" + type + ")";
             }
    @@ -1823,10 +1858,14 @@ public String toString() {
          */
         static class FFIType extends Structure {
             public static class size_t extends IntegerType {
    +            private static final long serialVersionUID = 1L;
    +
                 public size_t() { this(0); }
                 public size_t(long value) { super(Native.SIZE_T_SIZE, value); }
             }
    -        private static Map typeInfoMap = new WeakHashMap();
    +
    +        private static final Map typeInfoMap = new WeakHashMap();
    +
             // Native.initIDs initializes these fields to their appropriate
             // pointer values.  These are in a separate class from FFIType so that
             // they may be initialized prior to loading the FFIType class
    @@ -1845,6 +1884,7 @@ private static class FFITypes {
                 private static Pointer ffi_type_sint64;
                 private static Pointer ffi_type_pointer;
             }
    +
             static {
                 if (Native.POINTER_SIZE == 0)
                     throw new Error("Native library not initialized");
    @@ -1896,15 +1936,14 @@ private FFIType(Structure ref) {
                 else {
                     els = new Pointer[ref.fields().size() + 1];
                     int idx = 0;
    -                for (Iterator i=ref.fields().values().iterator();i.hasNext();) {
    -                    StructField sf = (StructField)i.next();
    +                for (StructField sf : ref.fields().values()) {
                         els[idx++] = ref.getFieldTypeInfo(sf);
                     }
                 }
                 init(els);
             }
             // Represent fixed-size arrays as structures of N identical elements
    -        private FFIType(Object array, Class type) {
    +        private FFIType(Object array, Class type) {
                 int length = Array.getLength(array);
                 Pointer[] els = new Pointer[length+1];
                 Pointer p = get(null, type.getComponentType());
    @@ -1913,7 +1952,9 @@ private FFIType(Object array, Class type) {
                 }
                 init(els);
             }
    -        protected List getFieldOrder() {
    +
    +        @Override
    +        protected List getFieldOrder() {
                 return Arrays.asList(new String[] { "size", "alignment", "type", "elements" });
             }
             private void init(Pointer[] els) {
    @@ -1927,11 +1968,11 @@ static Pointer get(Object obj) {
                 if (obj == null)
                     return FFITypes.ffi_type_pointer;
                 if (obj instanceof Class)
    -                return get(null, (Class)obj);
    +                return get(null, (Class)obj);
                 return get(obj, obj.getClass());
             }
     
    -        private static Pointer get(Object obj, Class cls) {
    +        private static Pointer get(Object obj, Class cls) {
                 TypeMapper mapper = Native.getTypeMapper(cls);
                 if (mapper != null) {
                     ToNativeConverter nc = mapper.getToNativeConverter(cls);
    @@ -1983,6 +2024,7 @@ public AutoAllocated(int size) {
                 // Always clear new structure memory
                 super.clear();
             }
    +        @Override
             public String toString() {
                 return "auto-" + super.toString();
             }
    @@ -2058,7 +2100,7 @@ public void autoWrite() {
          * @param nativeType field type to examine
          * @return native size (in bytes) of the requested field type
          */
    -    protected int getNativeSize(Class nativeType) {
    +    protected int getNativeSize(Class nativeType) {
             return getNativeSize(nativeType, null);
         }
     
    @@ -2068,7 +2110,7 @@ protected int getNativeSize(Class nativeType) {
          * @param value instance of the field type
          * @return native size (in bytes) of the requested field type
          */
    -    protected int getNativeSize(Class nativeType, Object value) {
    +    protected int getNativeSize(Class nativeType, Object value) {
             return Native.getNativeSize(nativeType, value);
         }
     
    @@ -2076,13 +2118,14 @@ protected int getNativeSize(Class nativeType, Object value) {
          * Structure needs a valid pointer but want to avoid actually reading from it.
          */
         private static final Pointer PLACEHOLDER_MEMORY = new Pointer(0) {
    +        @Override
             public Pointer share(long offset, long sz) { return this; }
         };
     
         /** Indicate whether the given Structure class can be created by JNA.
          * @param cls Structure subclass to check
          */
    -    static void validate(Class cls) {
    +    static void validate(Class cls) {
             Structure.newInstance(cls, PLACEHOLDER_MEMORY);
         }
     }
    diff --git a/src/com/sun/jna/Union.java b/src/com/sun/jna/Union.java
    index c5f3b94b55..52bce98bf9 100644
    --- a/src/com/sun/jna/Union.java
    +++ b/src/com/sun/jna/Union.java
    @@ -14,7 +14,6 @@
     
     import java.lang.reflect.Field;
     import java.util.ArrayList;
    -import java.util.Iterator;
     import java.util.List;
     
     /** Represents a native union.  When writing to native memory, the field
    @@ -54,11 +53,11 @@ protected Union(Pointer p, int alignType, TypeMapper mapper) {
         /** Unions do not need a field order, so automatically provide a value to
          * satisfy checking in the Structure superclass.
          */
    -    protected List getFieldOrder() {
    -        List flist = getFieldList();
    -        ArrayList list = new ArrayList();
    -        for (Iterator i=flist.iterator();i.hasNext();) {
    -            Field f = (Field)i.next();
    +    @Override
    +    protected List getFieldOrder() {
    +        List flist = getFieldList();
    +        List list = new ArrayList(flist.size());
    +        for (Field f : flist) {
                 list.add(f.getName());
             }
             return list;
    @@ -71,10 +70,9 @@ protected List getFieldOrder() {
          * @throws IllegalArgumentException if the type does not correspond to
          * any declared union field.
          */
    -    public void setType(Class type) {
    +    public void setType(Class type) {
             ensureAllocated();
    -        for (Iterator i=fields().values().iterator();i.hasNext();) {
    -            StructField f = (StructField)i.next();
    +        for (StructField f : fields().values()) {
                 if (f.type == type) {
                     activeField = f;
                     return;
    @@ -91,7 +89,7 @@ public void setType(Class type) {
          */
         public void setType(String fieldName) {
             ensureAllocated();
    -        StructField f = (StructField) fields().get(fieldName);
    +        StructField f = fields().get(fieldName);
             if (f != null) {
                 activeField = f;
             }
    @@ -105,6 +103,7 @@ public void setType(String fieldName) {
          * @return the new field value, after updating
          * @throws IllegalArgumentException if no field exists with the given name
          */
    +    @Override
         public Object readField(String fieldName) {
             ensureAllocated();
             setType(fieldName);
    @@ -115,6 +114,7 @@ public Object readField(String fieldName) {
          * The given field will become the active one.
          * @throws IllegalArgumentException if no field exists with the given name
          */
    +    @Override
         public void writeField(String fieldName) {
             ensureAllocated();
             setType(fieldName);
    @@ -125,6 +125,7 @@ public void writeField(String fieldName) {
          * The given field will become the active one.
          * @throws IllegalArgumentException if no field exists with the given name
          */
    +    @Override
         public void writeField(String fieldName, Object value) {
             ensureAllocated();
             setType(fieldName);
    @@ -143,10 +144,9 @@ public void writeField(String fieldName, Object value) {
          * @param type class type of the Structure field to read
          * @return the Structure field with the given type
          */
    -    public Object getTypedValue(Class type) {
    +    public Object getTypedValue(Class type) {
             ensureAllocated();
    -        for (Iterator i=fields().values().iterator();i.hasNext();) {
    -            StructField f = (StructField)i.next();
    +        for (StructField f : fields().values()) {
                 if (f.type == type) {
                     activeField = f;
                     read();
    @@ -181,10 +181,9 @@ public Object setTypedValue(Object object) {
          * @param type type to search for
          * @return StructField of matching type
          */
    -    private StructField findField(Class type) {
    +    private StructField findField(Class type) {
             ensureAllocated();
    -        for (Iterator i=fields().values().iterator();i.hasNext();) {
    -            StructField f = (StructField)i.next();
    +        for (StructField f : fields().values()) {
                 if (f.type.isAssignableFrom(type)) {
                     return f;
                 }
    @@ -193,6 +192,7 @@ private StructField findField(Class type) {
         }
     
         /** Only the currently selected field will be written. */
    +    @Override
         protected void writeField(StructField field) {
             if (field == activeField) {
                 super.writeField(field);
    @@ -203,6 +203,7 @@ protected void writeField(StructField field) {
          * selected.  Structures may contain pointer-based fields which can
          * crash the VM if not properly initialized.
          */
    +    @Override
         protected Object readField(StructField field) {
             if (field == activeField
                 || (!Structure.class.isAssignableFrom(field.type)
    @@ -213,12 +214,13 @@ protected Object readField(StructField field) {
             // Field not accessible
             // TODO: read by-value structures, to the extent possible; need a
             // "read cautiously" method to "read" to indicate we want to avoid
    -        // pointer-based fields 
    +        // pointer-based fields
             return null;
         }
     
         /** All fields are considered the "first" element. */
    -    protected int getNativeAlignment(Class type, Object value, boolean isFirstElement) {
    +    @Override
    +    protected int getNativeAlignment(Class type, Object value, boolean isFirstElement) {
             return super.getNativeAlignment(type, value, true);
         }
     }
    diff --git a/test/com/sun/jna/ArgumentsMarshalTest.java b/test/com/sun/jna/ArgumentsMarshalTest.java
    index cf16174234..1bbb76a9a9 100644
    --- a/test/com/sun/jna/ArgumentsMarshalTest.java
    +++ b/test/com/sun/jna/ArgumentsMarshalTest.java
    @@ -44,7 +44,7 @@ public static class ByReference extends CheckFieldAlignment
                 public double doubleField;
     
                 @Override
    -            public List getFieldOrder() {
    +            public List getFieldOrder() {
                     return Arrays.asList(new String[] { "int8Field", "int16Field", "int32Field", "int64Field", "floatField", "doubleField" });
                 }
                 public CheckFieldAlignment() {
    @@ -105,7 +105,7 @@ public TestPointerType() { }
             class MinTestStructure extends Structure {
                 public int field;
                 @Override
    -            protected List getFieldOrder() {
    +            protected List getFieldOrder() {
                     return Arrays.asList(new String[] { "field" });
                 }
             }
    @@ -115,7 +115,7 @@ class VariableSizedStructure extends Structure {
                 public int length;
                 public byte[] buffer;
                 @Override
    -            protected List getFieldOrder() {
    +            protected List getFieldOrder() {
                     return Arrays.asList(new String[] { "length", "buffer" });
                 }
                 public VariableSizedStructure(String arg) {
    @@ -131,7 +131,7 @@ public static interface TestCallback extends Callback {
                 }
                 public TestCallback cb;
                 @Override
    -            protected List getFieldOrder() {
    +            protected List getFieldOrder() {
                     return Arrays.asList(new String[] { "cb" });
                 }
             }
    @@ -264,6 +264,7 @@ public interface NativeMappedLibrary extends Library {
             long returnInt64Argument(size_t arg);
         }
         public static class size_t extends IntegerType {
    +        private static final long serialVersionUID = 1L;
             public size_t() {
                 this(0);
             }
    @@ -283,7 +284,7 @@ public Object fromNative(Object nativeValue, FromNativeContext context) {
                 return new Custom(((Integer)nativeValue).intValue());
             }
             @Override
    -        public Class nativeType() {
    +        public Class nativeType() {
                 return Integer.class;
             }
             @Override
    @@ -381,7 +382,7 @@ class TestStructure extends Structure implements Structure.ByValue {
                 public Pointer[] parray = new Pointer[2];
                 public byte[] barray = new byte[2];
                 @Override
    -            protected List getFieldOrder() {
    +            protected List getFieldOrder() {
                     return Arrays.asList(new String[] { "b", "c", "s", "i", "j", "f", "d", "parray", "barray" });
                 }
             }
    diff --git a/test/com/sun/jna/CallbacksTest.java b/test/com/sun/jna/CallbacksTest.java
    index c7d38c01bc..b511e50f99 100644
    --- a/test/com/sun/jna/CallbacksTest.java
    +++ b/test/com/sun/jna/CallbacksTest.java
    @@ -193,7 +193,7 @@ interface CustomCallback extends Callback {
             class CbStruct extends Structure {
                 public Callback cb;
                 @Override
    -            protected List getFieldOrder() {
    +            protected List getFieldOrder() {
                     return Arrays.asList(new String[] { "cb" });
                 }
             }
    diff --git a/test/com/sun/jna/DirectTest.java b/test/com/sun/jna/DirectTest.java
    index 0a6b1ba67d..769b5aec79 100644
    --- a/test/com/sun/jna/DirectTest.java
    +++ b/test/com/sun/jna/DirectTest.java
    @@ -13,9 +13,6 @@
     package com.sun.jna;
     
     import junit.framework.*;
    -import com.sun.jna.*;
    -import com.sun.jna.ptr.PointerByReference;
    -import java.lang.ref.*;
     import java.lang.reflect.Method;
     import java.io.File;
     import java.net.MalformedURLException;
    @@ -36,7 +33,7 @@ public static void main(java.lang.String[] argList) {
         static class MathLibrary {
     
             public static native double cos(double x);
    -        
    +
             static {
                 Native.register(Platform.MATH_LIBRARY_NAME);
             }
    @@ -48,6 +45,8 @@ interface MathInterface extends Library {
     
         static class CLibrary {
             public static class size_t extends IntegerType {
    +            private static final long serialVersionUID = 1L;
    +
                 public size_t() {
                     super(Native.POINTER_SIZE);
                 }
    @@ -64,7 +63,7 @@ public size_t(long value) {
             public static native int strlen(String s1);
             public static native int strlen(Pointer p);
             public static native int strlen(byte[] b);
    -        
    +
             static {
                 Native.register(Platform.C_LIBRARY_NAME);
             }
    @@ -87,7 +86,9 @@ interface NativeLongCallback extends Callback {
         }
     
         static class TestLibrary implements TestInterface {
    +        @Override
             public native int callInt32CallbackRepeatedly(Int32Callback cb, int arg1, int arg2, int count);
    +        @Override
             public native NativeLong callLongCallbackRepeatedly(NativeLongCallback cb, NativeLong arg1, NativeLong arg2, int count);
             static {
                 Native.register("testlib");
    @@ -108,12 +109,13 @@ public TestLoader(ClassLoader parent) throws MalformedURLException {
                           new File(BUILDDIR + "/test-classes").toURI().toURL(),
                       }, new CloverLoader(parent));
             }
    -        protected Class findClass(String name) throws ClassNotFoundException {
    +        @Override
    +        protected Class findClass(String name) throws ClassNotFoundException {
                 String boot = System.getProperty("jna.boot.library.path");
                 if (boot != null) {
                     System.setProperty("jna.boot.library.path", "");
                 }
    -            Class cls = super.findClass(name);
    +            Class cls = super.findClass(name);
                 if (boot != null) {
                     System.setProperty("jna.boot.library.path", boot);
                 }
    @@ -130,7 +132,7 @@ public void testRegisterMethods() throws Exception {
                         Native.registered(MathLibrary.class));
         }
     
    -    private Class returnCallingClass() {
    +    private Class returnCallingClass() {
             return Native.getCallingClass();
         }
     
    @@ -142,15 +144,15 @@ public void testFindCallingClass() {
         public void testFindNativeClass() {
             class UnregisterLibrary {
                 class Inner {
    -                public Class findDirectMappedClass() {
    +                public Class findDirectMappedClass() {
                         return findDirectMappedClassInner();
                     }
    -                public Class findDirectMappedClassInner() {
    +                public Class findDirectMappedClassInner() {
                         return Native.findDirectMappedClass(Native.getCallingClass());
                     };
                 }
                 public native double cos(double x);
    -            public Class findDirectMappedClass() {
    +            public Class findDirectMappedClass() {
                     return new Inner().findDirectMappedClass();
                 };
             }
    @@ -161,8 +163,9 @@ public Class findDirectMappedClass() {
         public static class DirectMapping {
             public static class DirectStructure extends Structure {
                 public int field;
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            @Override
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             public static interface DirectCallback extends Callback {
    @@ -215,8 +218,9 @@ public static class DirectMappingStatic {
             }
             public static class DirectStructure extends Structure {
                 public int field;
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            @Override
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             public static interface DirectCallback extends Callback {
    @@ -249,6 +253,7 @@ static class RemappedCLibrary {
     
         public void testDirectMappingFunctionMapper() {
             FunctionMapper MAPPER = new FunctionMapper() {
    +            @Override
                 public String getFunctionName(NativeLibrary lib, Method method) {
                     String name = method.getName();
                     if (name.startsWith("_prefixed_")) {
    diff --git a/test/com/sun/jna/ReturnTypesTest.java b/test/com/sun/jna/ReturnTypesTest.java
    index c8a31f4446..d07fa7d98e 100644
    --- a/test/com/sun/jna/ReturnTypesTest.java
    +++ b/test/com/sun/jna/ReturnTypesTest.java
    @@ -12,7 +12,6 @@
      */
     package com.sun.jna;
     
    -import java.util.Arrays;
     import java.util.HashMap;
     import java.util.List;
     import java.util.Map;
    @@ -36,6 +35,7 @@ public class ReturnTypesTest extends TestCase {
         public static interface TestLibrary extends Library {
     
             public static class SimpleStructure extends Structure {
    +            public static final List FIELDS = createFieldsOrder("value");
                 public double value;
                 public static int allocations = 0;
                 public SimpleStructure() { }
    @@ -46,43 +46,48 @@ protected void allocateMemory(int size) {
                     ++allocations;
                 }
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "value" });
    +            protected List getFieldOrder() {
    +                return FIELDS;
                 }
             }
     
             public static class TestSmallStructure extends Structure {
                 public static class ByValue extends TestSmallStructure implements Structure.ByValue { }
    +
    +            public static final List FIELDS = createFieldsOrder("c1", "c2", "s");
                 public byte c1;
                 public byte c2;
                 public short s;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "c1", "c2", "s" });
    +            protected List getFieldOrder() {
    +                return FIELDS;
                 }
             }
     
             public static class TestStructure extends Structure {
                 public static class ByValue extends TestStructure implements Structure.ByValue { }
    +
    +            public static final List FIELDS = createFieldsOrder("c", "s", "i", "j", "inner");
                 public byte c;
                 public short s;
                 public int i;
                 public long j;
                 public SimpleStructure inner;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "c", "s", "i", "j", "inner" });
    +            protected List getFieldOrder() {
    +                return FIELDS;
                 }
             }
     
    -        class CheckFieldAlignment extends Structure {
    +        public static class CheckFieldAlignment extends Structure {
    +            public static final List FIELDS = createFieldsOrder("int32Field", "int64Field", "floatField", "doubleField");
                 public int int32Field = 1;
                 public long int64Field = 2;
                 public float floatField = 3f;
                 public double doubleField = 4d;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "int32Field", "int64Field", "floatField", "doubleField" });
    +            protected List getFieldOrder() {
    +                return FIELDS;
                 }
             }
     
    @@ -194,6 +199,7 @@ public interface NativeMappedLibrary extends Library {
             size_t returnInt64Magic();
         }
         public static class size_t extends IntegerType {
    +        private static final long serialVersionUID = 1L;
             public size_t() {
                 this(0);
             }
    @@ -213,7 +219,7 @@ public Object fromNative(Object nativeValue, FromNativeContext context) {
                 return new Custom(((Integer)nativeValue).intValue());
             }
             @Override
    -        public Class nativeType() {
    +        public Class nativeType() {
                 return Integer.class;
             }
             @Override
    diff --git a/test/com/sun/jna/StructureBufferFieldTest.java b/test/com/sun/jna/StructureBufferFieldTest.java
    index 98b060fb10..08c1fcc296 100644
    --- a/test/com/sun/jna/StructureBufferFieldTest.java
    +++ b/test/com/sun/jna/StructureBufferFieldTest.java
    @@ -15,7 +15,6 @@
     import java.nio.Buffer;
     import java.nio.ByteBuffer;
     import java.nio.DoubleBuffer;
    -import java.util.Arrays;
     import java.util.List;
     
     import junit.framework.TestCase;
    @@ -31,10 +30,12 @@ public static void main(java.lang.String[] argList) {
         }
     
         static class BufferStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("buffer", "dbuffer");
             public Buffer buffer;
             public DoubleBuffer dbuffer;
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "buffer", "dbuffer" }); 
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testBufferFieldWriteNULL() {
    diff --git a/test/com/sun/jna/StructureByValueTest.java b/test/com/sun/jna/StructureByValueTest.java
    index 698909a526..33e2a586d2 100644
    --- a/test/com/sun/jna/StructureByValueTest.java
    +++ b/test/com/sun/jna/StructureByValueTest.java
    @@ -12,7 +12,6 @@
      */
     package com.sun.jna;
     
    -import java.util.Arrays;
     import java.util.List;
     
     import junit.framework.TestCase;
    @@ -26,10 +25,11 @@ public static void main(java.lang.String[] argList) {
     
         public static class TestNativeMappedInStructure extends Structure {
             public static class ByValue extends TestNativeMappedInStructure implements Structure.ByValue { }
    +        public static final List FIELDS = createFieldsOrder("field");
             public NativeLong field;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testNativeMappedInByValue() {
    @@ -58,38 +58,43 @@ protected void tearDown() {
     
         public static abstract class ByValueStruct extends Structure implements Structure.ByValue { }
         public static class ByValue8 extends ByValueStruct {
    +        public static final List FIELDS = createFieldsOrder("data");
             public byte data;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "data" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class ByValue16 extends ByValueStruct {
    +        public static final List FIELDS = createFieldsOrder("data");
             public short data;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "data" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class ByValue32 extends ByValueStruct {
    +        public static final List FIELDS = createFieldsOrder("data");
             public int data;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "data" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class ByValue64 extends ByValueStruct {
    +        public static final List FIELDS = createFieldsOrder("data");
             public long data;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "data" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class ByValue128 extends ByValueStruct {
    +        public static final List FIELDS = createFieldsOrder("data", "data1");
             public long data, data1;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "data", "data1" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         final long MAGIC = 0x0123456789ABCDEFL;
    diff --git a/test/com/sun/jna/StructureTest.java b/test/com/sun/jna/StructureTest.java
    index 33ac7f8396..2534ef9a6d 100644
    --- a/test/com/sun/jna/StructureTest.java
    +++ b/test/com/sun/jna/StructureTest.java
    @@ -14,8 +14,11 @@
     
     import java.util.ArrayList;
     import java.util.Arrays;
    +import java.util.Collections;
     import java.util.List;
     import java.util.Map;
    +import java.util.concurrent.atomic.AtomicReference;
    +
     import junit.framework.TestCase;
     
     import com.sun.jna.Structure.StructureSet;
    @@ -39,8 +42,8 @@ public void testSimpleSize() throws Exception {
             class TestStructure extends Structure {
                 public int field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             Structure s = new TestStructure();
    @@ -51,8 +54,8 @@ public void testInitializeFromPointer() {
             class TestStructureX extends Structure {
                 public int field1, field2;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field1", "field2" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field1", "field2");
                 }
                 public TestStructureX() {
                 }
    @@ -74,8 +77,8 @@ public void testInitializeWithTypeMapper() {
             class TestStructure extends Structure {
                 public int field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
                 public TestStructure(TypeMapper m) {
                     super(ALIGN_DEFAULT, m);
    @@ -88,25 +91,26 @@ public TestStructure(TypeMapper m) {
     
         // must be public to populate array
         public static class TestAllocStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("f0", "f1", "f2", "f3");
             public int f0;
             public int f1;
             public int f2;
             public int f3;
    +
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "f0", "f1", "f2", "f3" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     
    -
         public void testFieldsAllocated() {
             class TestStructure extends Structure {
                 public TestStructure() { }
                 public TestStructure(Pointer p) { super(p); }
                 public int field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
                 public int fieldCount() { ensureAllocated(); return fields().size(); }
             }
    @@ -122,8 +126,8 @@ class TestStructure extends Structure {
                 public TestStructure(Pointer p) { super(p); }
                 public int field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             try {
    @@ -159,8 +163,8 @@ class TestStructure extends Structure {
                 public float f;
                 public double d;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "b", "s", "i", "l", "f", "d" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("b", "s", "i", "l", "f", "d");
                 }
             }
             Structure s = new TestStructure();
    @@ -179,8 +183,8 @@ class TestStructure extends Structure {
                 public float f;
                 public double d;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "b", "s", "i", "l", "f", "d" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("b", "s", "i", "l", "f", "d");
                 }
             }
             Structure s = new TestStructure();
    @@ -203,54 +207,60 @@ protected void ensureAllocated() {
         }
         // Do NOT change the order of naming w/o changing testlib.c as well
         public static class TestStructure0 extends FilledStructure {
    +        public static final List FIELDS = createFieldsOrder("field0", "field1");
             public byte field0 = 0x01;
             public short field1 = 0x0202;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field0", "field1" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class TestStructure1 extends FilledStructure {
    +        public static final List FIELDS = createFieldsOrder("field0", "field1");
             public byte field0 = 0x01;
             public int field1 = 0x02020202;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field0", "field1" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class TestStructure2 extends FilledStructure {
    +        public static final List FIELDS = createFieldsOrder("field0", "field1");
             public short field0 = 0x0101;
             public int field1 = 0x02020202;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field0", "field1" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class TestStructure3 extends FilledStructure {
    +        public static final List FIELDS = createFieldsOrder("field0", "field1", "field2");
             public int field0 = 0x01010101;
             public short field1 = 0x0202;
             public int field2 = 0x03030303;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field0", "field1", "field2" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class TestStructure4 extends FilledStructure {
    +        public static final List FIELDS = createFieldsOrder("field0", "field1", "field2", "field3");
             public int field0 = 0x01010101;
             public long field1 = 0x0202020202020202L;
             public int field2 = 0x03030303;
             public long field3 = 0x0404040404040404L;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field0", "field1", "field2", "field3" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class TestStructure5 extends FilledStructure {
    +        public static final List FIELDS = createFieldsOrder("field0", "field1");
             public long field0 = 0x0101010101010101L;
             public byte field1 = 0x02;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field0", "field1" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public interface SizeTest extends Library {
    @@ -259,7 +269,7 @@ public interface SizeTest extends Library {
         private void testStructureSize(int index) {
             try {
                 SizeTest lib = Native.loadLibrary("testlib", SizeTest.class);
    -            Class cls = Class.forName(getClass().getName() + "$TestStructure" + index);
    +            Class cls = Class.forName(getClass().getName() + "$TestStructure" + index);
                 Structure s = Structure.newInstance(cls);
                 assertEquals("Incorrect size for structure " + index + "=>" + s.toString(true), lib.getStructureSize(index), s.size());
             }
    @@ -296,7 +306,7 @@ private void testAlignStruct(int index) {
             try {
                 IntByReference offset = new IntByReference();
                 LongByReference value = new LongByReference();
    -            Class cls = Class.forName(getClass().getName() + "$TestStructure" + index);
    +            Class cls = Class.forName(getClass().getName() + "$TestStructure" + index);
                 Structure s = (Structure)cls.newInstance();
                 int result = lib.testStructureAlignment(s, index, offset, value);
                 assertEquals("Wrong native value at field " + result
    @@ -330,8 +340,8 @@ public void testAlignStruct5() {
         public void testStructureWithNoFields() {
             class TestStructure extends Structure {
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] {});
    +            protected List getFieldOrder() {
    +                return Collections.emptyList();
                 }
             }
             try {
    @@ -339,6 +349,7 @@ protected List getFieldOrder() {
                 fail("Structure should not be instantiable if it has no public member fields");
             }
             catch(IllegalArgumentException e) {
    +            // expected - ignored
             }
         }
     
    @@ -346,8 +357,8 @@ public void testStructureWithOnlyNonPublicMemberFields() {
             class TestStructure extends Structure {
                 int field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] {"field"});
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             try {
    @@ -355,6 +366,7 @@ protected List getFieldOrder() {
                 fail("Structure should not be instantiable if it has no public member fields");
             }
             catch(Error e) {
    +            // expected - ignored
             }
         }
     
    @@ -368,6 +380,8 @@ public static class ByReference extends PublicTestStructure implements Structure
                 public ByReference() { }
                 public ByReference(Pointer p) { super(p); }
             }
    +
    +        public static final List FIELDS = createFieldsOrder("x", "y");
             public int x = 1, y = 2;
             public PublicTestStructure() { }
             public PublicTestStructure(Pointer p) { super(p); read(); }
    @@ -378,8 +392,8 @@ protected void allocateMemory(int size) {
                 ++allocations;
             }
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "x", "y" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testStructureField() {
    @@ -387,8 +401,8 @@ class TestStructure extends Structure {
                 public PublicTestStructure s1, s2;
                 public int after;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "s1", "s2", "after" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("s1", "s2", "after");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -417,8 +431,8 @@ class TestStructure extends Structure {
                 public PublicTestStructure.ByValue s1, s2;
                 public int after;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "s1", "s2", "after" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("s1", "s2", "after");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -442,7 +456,7 @@ protected List getFieldOrder() {
                          s.s2.getPointer());
         }
     
    -    static class TestUnion extends Union {
    +    public static class TestUnion extends Union {
             public int u_int;
             public float u_float;
             public double u_double;
    @@ -453,8 +467,8 @@ class TestStructure extends Structure {
                 public TestUnion s_union;
                 public int s_int;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "s_long", "s_union", "s_int" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("s_long", "s_union", "s_int");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -480,8 +494,8 @@ class TestStructure extends Structure {
                 public NonAllocatingTestStructure s1;
                 public TestStructure() { }
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "s1" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("s1");
                 }
             }
             TestStructure ts = new TestStructure();
    @@ -492,8 +506,8 @@ public void testPrimitiveArrayField() {
             class TestStructure extends Structure {
                 public byte[] buffer = new byte[1024];
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "buffer" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("buffer");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -514,8 +528,8 @@ class TestStructure extends Structure {
                 public PublicTestStructure[] inner2 = (PublicTestStructure[])
                     new PublicTestStructure().toArray(2);
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "inner", "inner2" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("inner", "inner2");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -554,11 +568,13 @@ protected List getFieldOrder() {
         }
     
         public static class ToArrayTestStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("inner");
             public PublicTestStructure[] inner =
                 (PublicTestStructure[])new PublicTestStructure().toArray(2);
    +
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "inner" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testToArrayWithStructureArrayField() {
    @@ -576,8 +592,8 @@ public void testUninitializedNestedArrayFails() {
             class TestStructure extends Structure {
                 public Pointer[] buffer;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "buffer" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("buffer");
                 }
             }
             Structure s = new TestStructure();
    @@ -612,8 +628,8 @@ public TestStructure() {
                 public double[] da = new double[3];
                 public PublicTestStructure nested;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "z", "b", "c", "s", "i", "l", "f", "d", "ba", "ca", "sa", "ia", "la", "fa", "da", "nested" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("z", "b", "c", "s", "i", "l", "f", "d", "ba", "ca", "sa", "ia", "la", "fa", "da", "nested");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -673,8 +689,8 @@ public void testNativeLongSize() throws Exception {
             class TestStructure extends Structure {
                 public NativeLong l;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "l" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("l");
                 }
             }
             Structure s = new TestStructure();
    @@ -686,8 +702,8 @@ class TestStructure extends Structure {
                 public int i;
                 public NativeLong l;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "i", "l" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("i", "l");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -710,8 +726,8 @@ class TestStructure extends Structure {
                 public int i;
                 public NativeLong l;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "i", "l" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("i", "l");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -735,42 +751,44 @@ public void testMemoryField() {
             class MemoryFieldStructure extends Structure {
                 public Memory m;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "m" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("m");
                 }
             }
             new MemoryFieldStructure().size();
         }
     
         public void testDisallowFunctionPointerAsField() {
    -        class BadFieldStructure extends Structure {
    +        class DisallowFunctionPointer extends Structure {
                 public Function cb;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "cb" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("cb");
                 }
             }
             try {
    -            new BadFieldStructure().size();
    +            new DisallowFunctionPointer().size();
                 fail("Function fields should not be allowed");
             }
             catch(IllegalArgumentException e) {
    +            // expected - ignored
             }
         }
     
         public static class BadFieldStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("badField");
             public Object badField;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "badField" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testUnsupportedField() {
             class BadNestedStructure extends Structure {
                 public BadFieldStructure badStruct = new BadFieldStructure();
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "badStruct" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("badStruct");
                 }
             }
             try {
    @@ -778,8 +796,7 @@ protected List getFieldOrder() {
                 fail("Should throw IllegalArgumentException on bad field");
             }
             catch(IllegalArgumentException e) {
    -            assertTrue("Exception should include field name: " + e,
    -                       e.getMessage().indexOf("badField") != -1);
    +            assertTrue("Exception should include field name: " + e.getMessage(), e.getMessage().indexOf("badField") != -1);
             }
             try {
                 new BadNestedStructure();
    @@ -817,8 +834,8 @@ public void testByReferenceArraySync() {
             class TestStructure extends Structure {
                 public PublicTestStructure.ByReference ref;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "ref" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("ref");
                 }
             }
             TestStructure ts = new TestStructure();
    @@ -841,11 +858,12 @@ protected List getFieldOrder() {
             assertEquals("Array element not read: " + array[1], VALUE, array[1].y);
         }
     
    -    static class CbStruct extends Structure {
    +    public static class CbStruct extends Structure {
    +        public static final List FIELDS = createFieldsOrder("cb");
             public Callback cb;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "cb" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testCallbackWrite() {
    @@ -867,8 +885,8 @@ public void testUninitializedArrayField() {
             class UninitializedArrayFieldStructure extends Structure {
                 public byte[] array;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "array" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("array");
                 }
             }
             try {
    @@ -881,10 +899,11 @@ protected List getFieldOrder() {
         }
     
         public static class StructureWithArrayOfStructureField extends Structure {
    +        public static final List FIELDS = createFieldsOrder("array");
             public Structure[] array;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "array" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testPlainStructureArrayField() {
    @@ -893,21 +912,25 @@ public void testPlainStructureArrayField() {
                 fail("Structure[] should not be allowed as a field of Structure");
             }
             catch(IllegalArgumentException e) {
    +            // expected - ignored
             }
             catch(Exception e) {
                 fail("Wrong exception thrown when Structure[] field encountered in a Structure: " + e);
             }
         }
     
    -    public void testPointerArrayField() {
    -        class ArrayOfPointerStructure extends Structure {
    -            final static int SIZE = 10;
    -            public Pointer[] array = new Pointer[SIZE];
    -            @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "array" });
    -            }
    +    public static class ArrayOfPointerStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("array");
    +        final static int SIZE = 10;
    +        public Pointer[] array = new Pointer[SIZE];
    +
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
    +    }
    +
    +    public void testPointerArrayField() {
             ArrayOfPointerStructure s = new ArrayOfPointerStructure();
             int size = s.size();
             assertEquals("Wrong size", ArrayOfPointerStructure.SIZE * Pointer.SIZE, size);
    @@ -918,15 +941,18 @@ protected List getFieldOrder() {
             assertEquals("Wrong first element", s.getPointer(), s.array[0]);
         }
     
    -    public void testVolatileStructureField() {
    -        class VolatileStructure extends Structure {
    -            public volatile int counter;
    -            public int value;
    -            @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "counter", "value" });
    -            }
    +    public static class VolatileStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("counter", "value");
    +        public volatile int counter;
    +        public int value;
    +
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
    +    }
    +
    +    public void testVolatileStructureField() {
             VolatileStructure s = new VolatileStructure();
             s.counter = 1;
             s.value = 1;
    @@ -944,25 +970,23 @@ protected List getFieldOrder() {
         }
     
         public static class StructureWithPointers extends Structure {
    +        public static final List FIELDS = createFieldsOrder("s1", "s2");
             public PublicTestStructure.ByReference s1;
             public PublicTestStructure.ByReference s2;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "s1", "s2" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testStructureByReferenceField() {
             StructureWithPointers s = new StructureWithPointers();
    -        assertEquals("Wrong size for structure with structure references",
    -                     Pointer.SIZE * 2, s.size());
    -
    +        assertEquals("Wrong size for structure with structure references", Pointer.SIZE * 2, s.size());
             assertNull("Initial refs should be null", s.s1);
         }
     
         public void testRegenerateStructureByReferenceField() {
             StructureWithPointers s = new StructureWithPointers();
    -        PublicTestStructure.ByReference inner =
    -            new PublicTestStructure.ByReference();
    +        PublicTestStructure.ByReference inner = new PublicTestStructure.ByReference();
             PublicTestStructure.allocations = 0;
             s.s1 = inner;
             s.write();
    @@ -993,8 +1017,8 @@ class TestStructure extends Structure {
                     { setPointer(new Memory(256)); }
                 };
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "p", "p2" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("p", "p2");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -1013,8 +1037,8 @@ class TestStructure extends Structure {
                 public String s;
                 public WString ws;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "s", "ws" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("s", "ws");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -1036,17 +1060,19 @@ protected List getFieldOrder() {
     
         // Ensure string cacheing doesn't interfere with wrapped structure writes.
         public static class StructureFromPointer extends Structure {
    +        public static final List FIELDS = createFieldsOrder("s", "ws");
             public String s;
             public WString ws;
    -        @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "s", "ws" });
    -        }
             public StructureFromPointer(Pointer p) {
                 super(p);
                 read();
             }
             public StructureFromPointer() {
    +            super();
    +        }
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     
    @@ -1054,8 +1080,8 @@ public void testInitializeStructureFieldWithStrings() {
             class ContainingStructure extends Structure {
                 public StructureFromPointer inner;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "inner" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("inner");
                 }
             }
             final String VALUE = getName() + UNICODE;
    @@ -1104,8 +1130,8 @@ public void testStructureByReferenceArrayField() {
             class TestStructure extends Structure {
                 public PublicTestStructure.ByReference[] array = new PublicTestStructure.ByReference[2];
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "array" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("array");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -1135,8 +1161,8 @@ public void testAutoReadWriteStructureByReferenceArrayField() {
             class TestStructure extends Structure {
                 public PublicTestStructure.ByReference field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -1155,39 +1181,40 @@ protected List getFieldOrder() {
                          VALUE*2, array[1].x);
         }
     
    -    static class NestedTypeInfoStructure extends Structure {
    +    public static class NestedTypeInfoStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("inner", "dummy");
             public static class Inner extends Structure {
    +            public static final List FIELDS = createFieldsOrder("dummy");
                 public int dummy;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "dummy" });
    +            protected List getFieldOrder() {
    +                return FIELDS;
                 }
             }
             public Inner inner;
             public int dummy;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "inner", "dummy" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public static class size_t extends IntegerType {
    +        private static final long serialVersionUID = 1L;
             public size_t() { this(0); }
             public size_t(long value) { super(Native.POINTER_SIZE, value); }
         }
         /** Same structure as the internal representation, to be initialized from
          * the internal FFIType native data.
          */
    -    class TestFFIType extends Structure {
    +    public static class TestFFIType extends Structure {
    +        public static final List FIELDS = createFieldsOrder("size", "alignment", "type", "elements");
             // NOTE: this field is not normally initialized by libffi
             // We force initialize by calling initialize_ffi_type
             public size_t size;
             public short alignment;
             public short type;
             public Pointer elements;
    -        @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "size", "alignment", "type", "elements" });
    -        }
    +
             public TestFFIType(Pointer p) {
                 super(p);
                 read();
    @@ -1199,6 +1226,10 @@ public TestFFIType(Pointer p) {
                 read();
                 assertEquals("Test FFIType size improperly initialized: " + TestFFIType.this, size, TestFFIType.this.size.intValue());
             }
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
    +        }
         }
         public void testNestedStructureTypeInfo() {
             NestedTypeInfoStructure s = new NestedTypeInfoStructure();
    @@ -1221,8 +1252,8 @@ public void testInnerArrayTypeInfo() {
             class TestStructure extends Structure {
                 public int[] inner = new int[5];
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "inner" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("inner");
                 }
             }
             Structure s = new TestStructure();
    @@ -1247,8 +1278,8 @@ class TestStructure extends Structure {
                 public int intField;
                 public PublicTestStructure inner;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "intField", "inner" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("intField", "inner");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -1279,8 +1310,8 @@ public void testNativeMappedWrite() {
         	class TestStructure extends Structure {
                 public ByteByReference ref;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "ref" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("ref");
                 }
         	}
         	TestStructure s = new TestStructure();
    @@ -1297,8 +1328,8 @@ public void testNativeMappedRead() {
         	class TestStructure extends Structure {
                 public ByteByReference ref;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "ref" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("ref");
                 }
         	}
         	TestStructure s = new TestStructure();
    @@ -1316,10 +1347,11 @@ protected List getFieldOrder() {
         }
     
         public static class ROStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("field");
             public final int field;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
             {
                 // Initialize in ctor to avoid compiler replacing
    @@ -1369,8 +1401,8 @@ public void testNativeMappedArrayField() {
             class TestStructure extends Structure {
                 public NativeLong[] longs = new NativeLong[SIZE];
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "longs" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("longs");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -1406,8 +1438,8 @@ class TestStructure extends Structure {
                 public NativeLong nl = INITIAL;
                 public NativeLong uninitialized;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "nl", "uninitialized" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("nl", "uninitialized");
                 }
             }
             TestStructure ts = new TestStructure();
    @@ -1430,15 +1462,15 @@ public void testThrowErrorOnMissingFieldOrderOnDerivedStructure() {
             class TestStructure extends Structure {
                 public int f1, f2;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "f1", "f2" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("f1", "f2");
                 }
             }
    -        class TestStructure2 extends TestStructure {
    +        class NoFieldOrder extends TestStructure {
                 public int f3;
             }
             try {
    -            new TestStructure2();
    +            new NoFieldOrder();
                 fail("Expected an error when structure fails to provide field order");
             }
             catch(Error e) {
    @@ -1449,8 +1481,8 @@ public void testThrowErrorOnIncorrectFieldOrderNameMismatch() {
             class TestStructure extends Structure {
                 public int f1, f2;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "F1", "F2" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("F1", "F2");
                 }
             }
             try {
    @@ -1465,8 +1497,8 @@ public void testThrowErrorOnIncorrectFieldOrderCount() {
             class TestStructure extends Structure {
                 public int f1, f2;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "f1", "f2", "f3" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("f1", "f2", "f3");
                 }
             }
             try {
    @@ -1474,32 +1506,48 @@ protected List getFieldOrder() {
                 fail("Expected an error when creating a structure with wrong number of fiels in getFieldOrder()");
             }
             catch(Error e) {
    +            // expected - ignored
             }
         }
     
    -    class XTestStructure extends Structure {
    -	public int first = 1;
    -	@Override
    -    protected List getFieldOrder() {
    -	    return Arrays.asList(new String[] { "first" }); }
    +    public static class XTestStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("first");
    +        public int first = 1;
    +    	@Override
    +        protected List getFieldOrder() {
    +    	    return FIELDS;
    +	    }
         }
    -    class XTestStructureSub extends XTestStructure {
    -	public int second = 2;
    -	@Override
    -    protected List getFieldOrder() {
    -	    List list = new ArrayList(super.getFieldOrder());
    -	    list.addAll(Arrays.asList(new String[] { "second" }));
    -	    return list;
    -	}
    +
    +    public static class XTestStructureSub extends XTestStructure {
    +        public static final List EXTRA_FIELDS = createFieldsOrder("second");
    +        private static final AtomicReference> fieldsHolder = new AtomicReference>(null);
    +        private static List resolveEffectiveFields(List baseFields) {
    +            List fields;
    +            synchronized (fieldsHolder) {
    +                fields = fieldsHolder.get();
    +                if (fields == null) {
    +                    fields = createFieldsOrder(baseFields, EXTRA_FIELDS);
    +                    fieldsHolder.set(fields);
    +                }
    +            }
    +
    +            return fields;
    +        }
    +    	public int second = 2;
    +
    +    	@Override
    +        protected List getFieldOrder() {
    +    	    return resolveEffectiveFields(super.getFieldOrder());
    +    	}
         }
    +
         public void testInheritedStructureFieldOrder() {
             XTestStructureSub s = new XTestStructureSub();
             assertEquals("Wrong size", 8, s.size());
             s.write();
    -        assertEquals("Wrong first field: " + s,
    -                     s.first, s.getPointer().getInt(0));
    -        assertEquals("Wrong second field: " + s,
    -                     s.second, s.getPointer().getInt(4));
    +        assertEquals("Wrong first field: " + s, s.first, s.getPointer().getInt(0));
    +        assertEquals("Wrong second field: " + s, s.second, s.getPointer().getInt(4));
         }
     
         public void testVariedStructureFieldOrder() {
    @@ -1510,7 +1558,7 @@ class TestStructure extends Structure {
                 public int three = 3;
                 public int two = 2;
                 @Override
    -            protected List getFieldOrder() {
    +            protected List getFieldOrder() {
                     return Arrays.asList(ORDER);
                 }
             }
    @@ -1518,38 +1566,28 @@ class DerivedTestStructure extends TestStructure {
                 public int five = 5;
                 public int four = 4;
                 @Override
    -            protected List getFieldOrder() {
    -                List list = new ArrayList(super.getFieldOrder());
    -                list.addAll(Arrays.asList(new String[] { "four", "five" }));
    +            protected List getFieldOrder() {
    +                List list = new ArrayList(super.getFieldOrder());
    +                list.addAll(Arrays.asList("four", "five"));
                     return list;
                 }
             }
     
             TestStructure s = new TestStructure();
    -        assertEquals("Wrong field order",
    -                     Arrays.asList(ORDER), s.getFieldOrder());
    +        assertEquals("Wrong field order", Arrays.asList(ORDER), s.getFieldOrder());
             s.write();
    -        assertEquals("Wrong first field: " + s,
    -                     s.one, s.getPointer().getInt(0));
    -        assertEquals("Wrong second field: " + s,
    -                     s.two, s.getPointer().getInt(4));
    -        assertEquals("Wrong third field: " + s,
    -                     s.three, s.getPointer().getInt(8));
    +        assertEquals("Wrong first field: " + s, s.one, s.getPointer().getInt(0));
    +        assertEquals("Wrong second field: " + s, s.two, s.getPointer().getInt(4));
    +        assertEquals("Wrong third field: " + s, s.three, s.getPointer().getInt(8));
     
             DerivedTestStructure s2 = new DerivedTestStructure();
    -        assertEquals("Wrong field order",
    -                     Arrays.asList(ORDER2), s2.getFieldOrder());
    +        assertEquals("Wrong field order", Arrays.asList(ORDER2), s2.getFieldOrder());
             s2.write();
    -        assertEquals("Wrong first field: " + s2,
    -                     s2.one, s2.getPointer().getInt(0));
    -        assertEquals("Wrong second field: " + s2,
    -                     s2.two, s2.getPointer().getInt(4));
    -        assertEquals("Wrong third field: " + s2,
    -                     s2.three, s2.getPointer().getInt(8));
    -        assertEquals("Wrong derived field (1): " + s2,
    -                     s2.four, s2.getPointer().getInt(12));
    -        assertEquals("Wrong derived field (2): " + s2,
    -                     s2.five, s2.getPointer().getInt(16));
    +        assertEquals("Wrong first field: " + s2, s2.one, s2.getPointer().getInt(0));
    +        assertEquals("Wrong second field: " + s2, s2.two, s2.getPointer().getInt(4));
    +        assertEquals("Wrong third field: " + s2, s2.three, s2.getPointer().getInt(8));
    +        assertEquals("Wrong derived field (1): " + s2, s2.four, s2.getPointer().getInt(12));
    +        assertEquals("Wrong derived field (2): " + s2, s2.five, s2.getPointer().getInt(16));
         }
     
         public void testCustomTypeMapper() {
    @@ -1562,7 +1600,7 @@ public Object fromNative(Object value, FromNativeContext context) {
                             return new TestField();
                         }
                         @Override
    -                    public Class nativeType() {
    +                    public Class nativeType() {
                             return String.class;
                         }
                         @Override
    @@ -1578,8 +1616,8 @@ public TestStructure() {
                     super(mapper);
                 }
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             Structure s = new TestStructure();
    @@ -1591,8 +1629,8 @@ class TestStructure extends Structure {
                 public Boolean zfield;
                 public Integer field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "zfield", "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("zfield", "field");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -1607,8 +1645,8 @@ class OtherStructure extends Structure {
                 public int[] second = new int[4];
                 public Pointer[] third = new Pointer[4];
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "first", "second", "third" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("first", "second", "third");
                 }
             }
             class TestStructure extends Structure {
    @@ -1616,8 +1654,8 @@ class TestStructure extends Structure {
                 public int[] second = new int[4];
                 public Pointer[] third = new Pointer[4];
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "first", "second", "third" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("first", "second", "third");
                 }
                 public TestStructure() { }
                 public TestStructure(Pointer p) { super(p); }
    @@ -1643,8 +1681,8 @@ public void testStructureHashCodeMatchesWhenEqual() {
             class TestStructure extends Structure {
                 public int first;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "first" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("first");
                 }
             }
             TestStructure s1 = new TestStructure();
    @@ -1652,12 +1690,10 @@ protected List getFieldOrder() {
             assertFalse("hashCode should be different for two different structures", s1.hashCode() == s2.hashCode());
     
             s2.useMemory(s1.getPointer());
    -        assertEquals("hashCode should match when structures have same pointer",
    -                     s1.hashCode(), s2.hashCode());
    +        assertEquals("hashCode should match when structures have same pointer", s1.hashCode(), s2.hashCode());
     
             s2.useMemory(s1.getPointer());
    -        assertEquals("hashCode should match when structures have same pointer",
    -                     s1.hashCode(), s2.hashCode());
    +        assertEquals("hashCode should match when structures have same pointer", s1.hashCode(), s2.hashCode());
         }
     
         public void testRecursiveWrite() {
    @@ -1667,8 +1703,8 @@ public TestStructureByRef() { }
                 public int unique;
                 public TestStructureByRef s;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "unique", "s" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("unique", "s");
                 }
             }
             TestStructureByRef s = new TestStructureByRef();
    @@ -1678,31 +1714,26 @@ protected List getFieldOrder() {
             s.s.unique = 2;
     
             s.write();
    -        assertEquals("Structure field contents not written",
    -                     1, s.getPointer().getInt(0));
    -        assertEquals("ByReference structure field contents not written",
    -                     2, s.s.getPointer().getInt(0));
    +        assertEquals("Structure field contents not written", 1, s.getPointer().getInt(0));
    +        assertEquals("ByReference structure field contents not written", 2, s.s.getPointer().getInt(0));
     
             s.s.unique = 0;
             Structure value = s.s;
             s.read();
             assertEquals("ByReference structure field not preserved", value, s.s);
    -
    -        assertEquals("ByReference structure field contents not read",
    -                     2, s.s.unique);
    -
    -        assertTrue("Temporary storage should be cleared",
    -                   s.busy().isEmpty());
    +        assertEquals("ByReference structure field contents not read", 2, s.s.unique);
    +        assertTrue("Temporary storage should be cleared", Structure.busy().isEmpty());
         }
     
         public static class CyclicTestStructure extends Structure {
             public static class ByReference extends CyclicTestStructure implements Structure.ByReference {}
    +        public static final List FIELDS = createFieldsOrder("next");
             public CyclicTestStructure(Pointer p) { super(p); }
             public CyclicTestStructure() { }
             public CyclicTestStructure.ByReference next;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "next" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
         public void testCyclicRead() {
    @@ -1718,18 +1749,16 @@ public void testCyclicRead() {
             value = s.next;
             s.next.next = null;
             s.read();
    -        assertSame("ByReference structure field should reuse existing value",
    -                   value, s.next);
    -        assertSame("Nested ByReference structure field should reuse existing value",
    -                   value, s.next.next);
    +        assertSame("ByReference structure field should reuse existing value", value, s.next);
    +        assertSame("Nested ByReference structure field should reuse existing value", value, s.next.next);
         }
     
         public void testAvoidMemoryAllocationInPointerCTOR() {
             class TestStructure extends Structure {
                 public int field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
                 public TestStructure(Pointer p) {
                     super(p);
    @@ -1749,8 +1778,8 @@ class TestStructure extends Structure {
                 public int intField;
                 public byte[] arrayField = new byte[256];
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "intField", "arrayField" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("intField", "arrayField");
                 }
                 public TestStructure(Pointer p) {
                     super(p);
    @@ -1780,6 +1809,7 @@ public TestStructure(Pointer p) {
     
     
         public static class TestByReferenceArrayField extends Structure {
    +        public static final List FIELDS = createFieldsOrder("value1", "array", "value2");
             public TestByReferenceArrayField() { }
             public TestByReferenceArrayField(Pointer m) {
                 super(m);
    @@ -1789,8 +1819,8 @@ public TestByReferenceArrayField(Pointer m) {
             public ByReference[] array = new ByReference[13];
             public int value2;
             @Override
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "value1", "array", "value2" });
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
     
             public static class ByReference extends TestByReferenceArrayField implements Structure.ByReference { }
    @@ -1817,8 +1847,8 @@ public void testEquals() {
             class TestStructure extends Structure {
                 public int field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
                 public TestStructure() { }
                 public TestStructure(Pointer p) { super(p); read(); }
    @@ -1835,8 +1865,8 @@ public void testStructureLayoutCacheing() {
             class TestStructure extends Structure {
                 public int field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             Structure ts = new TestStructure(); ts.ensureAllocated();
    @@ -1849,8 +1879,8 @@ public void testStructureLayoutVariableNoCache() {
             class TestStructure extends Structure {
                 public byte[] variable;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "variable" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("variable");
                 }
                 public TestStructure(int size) {
                     this.variable = new byte[size];
    @@ -1869,7 +1899,7 @@ class TestTypeMapper extends DefaultTypeMapper {
                 {
                     TypeConverter tc = new TypeConverter() {
                         @Override
    -                    public Class nativeType() { return int.class; }
    +                    public Class nativeType() { return int.class; }
                         @Override
                         public Object fromNative(Object nativeValue, FromNativeContext c) {
                             return new Boolean(nativeValue.equals(new Integer(0)));
    @@ -1887,8 +1917,8 @@ public Object toNative(Object value, ToNativeContext c) {
             class TestStructure extends Structure {
                 public boolean field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
                 public TestStructure() {
                     super(m);
    @@ -1909,8 +1939,8 @@ class TestStructure extends Structure {
                 public byte first;
                 public int second;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "first", "second" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("first", "second");
                 }
                 public TestStructure() {
                     setAlignType(ALIGN_NONE);
    @@ -1940,7 +1970,7 @@ public FromNativeConverter getFromNativeConverter(Class cls) {
                         || boolean.class.equals(cls)) {
                         return new FromNativeConverter() {
                             @Override
    -                        public Class nativeType() {
    +                        public Class nativeType() {
                                 return byte.class;
                             }
                             @Override
    @@ -1962,7 +1992,7 @@ public Object toNative(Object value, ToNativeContext context) {
                                 return new Byte(Boolean.TRUE.equals(value) ? (byte)1 : (byte)0);
                             }
                             @Override
    -                        public Class nativeType() {
    +                        public Class nativeType() {
                                 return byte.class;
                             }
                         };
    @@ -1979,8 +2009,8 @@ public TestStructure() {
                     super(mapper);
                 }
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "b", "s", "p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("b", "s", "p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7");
                 }
             }
             Structure s = new TestStructure();
    @@ -1995,8 +2025,8 @@ public void testDefaultStringEncoding() {
             class TestStructure extends Structure {
                 public String field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -2009,8 +2039,8 @@ public void testStringFieldEncoding() throws Exception {
             class TestStructure extends Structure {
                 public String field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
             TestStructure s = new TestStructure();
    @@ -2039,8 +2069,8 @@ public void testThreadLocalSetReleasesReferences() {
         	class TestStructure extends Structure {
                 public String field;
                 @Override
    -            protected List getFieldOrder() {
    -                return Arrays.asList(new String[] { "field" });
    +            protected List getFieldOrder() {
    +                return Arrays.asList("field");
                 }
             }
     
    diff --git a/test/com/sun/jna/UnionTest.java b/test/com/sun/jna/UnionTest.java
    index 6f2d0d0c70..9659a19a9e 100644
    --- a/test/com/sun/jna/UnionTest.java
    +++ b/test/com/sun/jna/UnionTest.java
    @@ -12,7 +12,6 @@
      */
     package com.sun.jna;
     
    -import java.util.Arrays;
     import java.util.List;
     
     import junit.framework.TestCase;
    @@ -21,24 +20,30 @@
     public class UnionTest extends TestCase {
     
         public static class TestStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("value");
             public String value;
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "value" });
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     
         public static class BigTestStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("field1", "field2");
             public long field1;
             public long field2;
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "field1", "field2" });
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     
         public static class IntStructure extends Structure {
    +        public static final List FIELDS = createFieldsOrder("value");
             public int value;
    -        protected List getFieldOrder() {
    -            return Arrays.asList(new String[] { "value" });
    +        @Override
    +        protected List getFieldOrder() {
    +            return FIELDS;
             }
         }
     
    @@ -132,6 +137,7 @@ public void testWriteTypedUnion() {
             // write an instance of an interface
             u = new StructUnion();
             Func1 func1 = new Func1() {
    +            @Override
                 public void callback() {
                     System.out.println("hi");
                 }