The com.sun.jna.platform.win32.Winspool$LPPRINTER_DEFAULTS structure is not correctly bound. The members need to be public to be considered as structure members. This error was reported via the mailing list by Eric Hill:
When I include a reference to the LPPRINTER_DEFAULTS structure, I get the following error:
Exception in thread "main" java.lang.Error: Structure.getFieldOrder() on class com.sun.jna.platform.win32.Winspool$LPPRINTER_DEFAULTS returns names ([DesiredAccess, pDatatype, pDevMode]) which do not match declared field names ([pDatatype])
at com.sun.jna.Structure.getFields(Structure.java:1027)
at com.sun.jna.Structure.deriveLayout(Structure.java:1172)
at com.sun.jna.Structure.calculateSize(Structure.java:1097)
at com.sun.jna.Structure.calculateSize(Structure.java:1049)
at com.sun.jna.Structure.allocateMemory(Structure.java:403)
at com.sun.jna.Structure.<init>(Structure.java:194)
at com.sun.jna.Structure.<init>(Structure.java:182)
at com.sun.jna.Structure.<init>(Structure.java:169)
at com.sun.jna.Structure.<init>(Structure.java:161)
at com.sun.jna.platform.win32.Winspool$LPPRINTER_DEFAULTS.<init>(Winspool.java:511)
at winnative.RunMe.main(RunMe.java:20)
I looks like pDatatype is declared as public, whereas pDevMode and DesiredAccess are declared as package level. Should the fields be public or should the function work even with the fields declared at package level?
The assessment is correct. All members of a class, that are structure fields need to be public.
The
com.sun.jna.platform.win32.Winspool$LPPRINTER_DEFAULTSstructure is not correctly bound. The members need to be public to be considered as structure members. This error was reported via the mailing list by Eric Hill:The assessment is correct. All members of a class, that are structure fields need to be public.