krickert commented on code in PR #1512:
URL: https://github.com/apache/opennlp/pull/1512#discussion_r4442875577
##########
opennlp-core/opennlp-ml/opennlp-dl/src/main/java/opennlp/dl/AbstractDL.java:
##########
@@ -245,6 +255,32 @@ protected static OrtSession.SessionOptions
sessionOptions(final InferenceOptions
return sessionOptions;
}
+ private static <T> T initializeNative(final Supplier<T> nativeOperation) {
Review Comment:
Please add Javadoc to the three new helper methods, including their
parameters, return values, and exception behavior.
Even though these are private, they are doing specific non-standard behavior
so a small javadoc is justified.
##########
opennlp-core/opennlp-ml/opennlp-dl/src/main/java/opennlp/dl/AbstractDL.java:
##########
@@ -245,6 +255,32 @@ protected static OrtSession.SessionOptions
sessionOptions(final InferenceOptions
return sessionOptions;
}
+ private static <T> T initializeNative(final Supplier<T> nativeOperation) {
+ return initializeNative(nativeOperation,
+ System.getProperty("os.name"), System.getProperty("os.arch"));
+ }
+
+ static <T> T initializeNative(final Supplier<T> nativeOperation, final
String osName,
+ final String architecture) {
+ try {
+ return nativeOperation.get();
+ } catch (UnsatisfiedLinkError e) {
+ throw nativeLibraryError(e, osName, architecture);
Review Comment:
Confirmed locally through two consecutive calls to sessionOptions: the first
gets the platform guidance; the second throws NoClassDefFoundError without it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]