From 9255ffe1540e7badc8e5583035095aa1e90de840 Mon Sep 17 00:00:00 2001 From: robert <robert@semmle.com> Date: Mon, 15 Apr 2019 16:35:10 +0100 Subject: [PATCH] Log failure reason in TensorFlow.init() --- .../src/main/java/org/tensorflow/TensorFlow.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java b/tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java index c90655f25dd..a9debb0063d 100644 --- a/tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java +++ b/tensorflow/java/src/main/java/org/tensorflow/TensorFlow.java @@ -63,7 +63,19 @@ public final class TensorFlow { /** Load the TensorFlow runtime C library. */ static void init() { - NativeLibrary.load(); + try { + NativeLibrary.load(); + } catch (Exception e) { + /* + * This code is called during static initialization of this and of other classes. + * If this fails then a NoClassDefFoundError is thrown however this does not + * include a cause. Printing the exception manually here ensures that the + * necessary information to fix the problem is available. + */ + System.err.println("Failed to load TensorFlow native library"); + e.printStackTrace(); + throw e; + } } static {