adds a constructor with com.sun.jna.Pointer to LibKevent.Kevent which in it's turn calls constructor from super
What this PR solves?
an issue with extra and unnecessary lookup for a constructor and extra exception handling.
Problem description:
When in com.zaxxer.nuprocess.osx.ProcessKqueue#registerProcess an array of Kevent is created by using method com.sun.jna.Structure#toArray(int),
Kevent[] events = (Kevent[]) new Kevent().toArray(4);
then eventually method com.sun.jna.Structure#newInstance(java.lang.Class<?>, com.sun.jna.Pointer) searches for constructor which accepts Pointer. And there is a try..catch with some additional logic which calls com.sun.jna.Structure#useMemory.
Currently when creating thousands of processes, it ads extra unnecessary calls which seems not really optimal.
Since the LibKevent.Kevent is a subclass of com.sun.jna.Structure, then it looks reasonable to implement it's constructor com.sun.jna.Structure#Structure(com.sun.jna.Pointer)
Without this patch I see thousands of exceptions with following stack trace in jmc
What this PR does?
com.sun.jna.Pointer
toLibKevent.Kevent
which in it's turn calls constructor from superWhat this PR solves?
Problem description:
When in
com.zaxxer.nuprocess.osx.ProcessKqueue#registerProcess
an array of Kevent is created by using methodcom.sun.jna.Structure#toArray(int)
,then eventually method
com.sun.jna.Structure#newInstance(java.lang.Class<?>, com.sun.jna.Pointer)
searches for constructor which accepts Pointer. And there is a try..catch with some additional logic which callscom.sun.jna.Structure#useMemory
.Currently when creating thousands of processes, it ads extra unnecessary calls which seems not really optimal. Since the
LibKevent.Kevent
is a subclass ofcom.sun.jna.Structure
, then it looks reasonable to implement it's constructorcom.sun.jna.Structure#Structure(com.sun.jna.Pointer)
Without this patch I see thousands of exceptions with following stack trace in
jmc