-
Notifications
You must be signed in to change notification settings - Fork 159
Closed
Description
This issue is about my idea, that, I think, will be very useful.
Native API methods are often designed agains java code conventions (which is normal). A common example is:
int doSomething(ResultType *resultVariable);where method returns an error code. Java variant of the method whould look like this:
ResultType doSomething() throws LibraryError;So the default method feature, that appeared in Java 8, can be used to bring some comfort in your code.
interface MyNativeLibrary {
ErrorCode doSomething(ResultType resultVariable);
default ResultType doSomething() throws LibraryError
{
ResultType resultValue = new ResultType();
ErrorCode error = doSomething (resultValue);
if (error != ErrorCode.OK) {
throw new LibraryError (error);
}
return resultValue;
}
}To use native interfaces like this, LibraryLoaders should ignore default methods while generating a new stub.
I understand that the library is currently targeted for jdk7+, but I hope, there is a workaround to implement this feature for jdk8+ only.
I'd like to know your opinion about this feature.
Metadata
Metadata
Assignees
Labels
No labels