Subclasses don't get constructors
berntie opened this issue · comments
I have the following struct:
typedef struct JnaExport
{
int AftrNr;
int KndNr;
int ObjectVersion;
char* JsonData;
tOutputStatus OutputStatus;
} AuftragskopfOutputDtoJna;
with tOutputStatus being
enum tOutputStatus
{
OUTPUTSTATUS_OK_WITH_DATA = 100,
OUTPUTSTATUS_ERROR_NOT_FOUND = -404, //
// ... many more
};
From that JNAerator generates the following Java class:
public class AuftragskopfOutputDtoJna extends Structure {
public int AftrNr;
public int KndNr;
public int ObjectVersion;
public Pointer JsonData;
public int OutputStatus;
public AuftragskopfOutputDtoJna() {
super();
}
protected List<? > getFieldOrder() {
return Arrays.asList("AftrNr", "KndNr", "ObjectVersion", "JsonData", "OutputStatus");
}
public AuftragskopfOutputDtoJna(int AftrNr, int KndNr, int ObjectVersion, Pointer JsonData, int OutputStatus) {
super();
this.AftrNr = AftrNr;
this.KndNr = KndNr;
this.ObjectVersion = ObjectVersion;
this.JsonData = JsonData;
this.OutputStatus = OutputStatus;
}
public AuftragskopfOutputDtoJna(Pointer peer) {
super(peer);
}
public static class ByReference extends AuftragskopfOutputDtoJna implements Structure.ByReference {
};
public static class ByValue extends AuftragskopfOutputDtoJna implements Structure.ByValue {
};
}
The documentation says "JNAerated structs all get ByReference and ByValue subclasses (that have a struct-pointer-copy constructor)" but my subclasses don't get that constructor. That's annoying because I don't know how to obtain a AuftragskopfOutputDtoJna.ByReference without that constructor and I'm thus forced to rely on a deprecated method for freeing memory:
/**
* ...
* @deprecated use the safer method {@link #deleteAuftragskopfOutputDto(AuftragskopfOutputDtoJna.ByReference[])} instead
*/
@Deprecated
void deleteAuftragskopfOutputDto(PointerByReference dto);
How am I supposed to fix this? And could someone update the documentation, please.