Skip to content

LPPRINTER_DEFAULTS needs to declare structure members public #834

@matthiasblaesing

Description

@matthiasblaesing

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions