From e499e9e20f14719dee31774cd487676014ab93ee Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 9 Dec 2024 21:46:15 -0800 Subject: [PATCH 1/4] Make runtime loader exception message slightly better --- .../src/main/java/edu/wpi/first/util/RuntimeLoader.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java index 452cacfe72a..1ea68a1c56b 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java @@ -16,17 +16,20 @@ public final class RuntimeLoader { * @return A load error message. */ private static String getLoadErrorMessage(String libraryName, UnsatisfiedLinkError ule) { + String jvmLocation = ProcessHandle.current().info().command().orElse("Unknown"); StringBuilder msg = new StringBuilder(512); msg.append(libraryName) .append(" could not be loaded from path.\n" + "\tattempted to load for platform ") .append(CombinedRuntimeLoader.getPlatformPath()) .append("\nLast Load Error: \n") .append(ule.getMessage()) - .append('\n'); + .append('\n') + .append(String.format("JVM Location: %s\n", jvmLocation)); if (System.getProperty("os.name").startsWith("Windows")) { msg.append( - "A common cause of this error is missing the C++ runtime.\n" - + "Download the latest at https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads\n"); + "A common cause of this error is using a JVM with an incorrect MSVC runtime.\n") + .append("Ensure you are using the WPILib JVM (The current running JVM is listed above\n") + .append("See https://wpilib.org/jvmruntime for more information\n"); } return msg.toString(); } From 1654acd1ae1245a73c7dbced45b56483ff57994e Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 9 Dec 2024 21:55:20 -0800 Subject: [PATCH 2/4] Formatting --- wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java index 1ea68a1c56b..b1b7ada61a4 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java @@ -27,9 +27,9 @@ private static String getLoadErrorMessage(String libraryName, UnsatisfiedLinkErr .append(String.format("JVM Location: %s\n", jvmLocation)); if (System.getProperty("os.name").startsWith("Windows")) { msg.append( - "A common cause of this error is using a JVM with an incorrect MSVC runtime.\n") - .append("Ensure you are using the WPILib JVM (The current running JVM is listed above\n") - .append("See https://wpilib.org/jvmruntime for more information\n"); + "A common cause of this error is using a JVM with an incorrect MSVC runtime.\n" + + "Ensure you are using the WPILib JVM (The current running JVM is listed above\n" + + "See https://wpilib.org/jvmruntime for more information\n"); } return msg.toString(); } From 567ec71d77e454ff3a2c0085e0516cdf0a32fe44 Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 9 Dec 2024 23:04:44 -0800 Subject: [PATCH 3/4] Update wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java Co-authored-by: Peter Johnson --- wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java index b1b7ada61a4..b9f406612c6 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java @@ -28,7 +28,7 @@ private static String getLoadErrorMessage(String libraryName, UnsatisfiedLinkErr if (System.getProperty("os.name").startsWith("Windows")) { msg.append( "A common cause of this error is using a JVM with an incorrect MSVC runtime.\n" - + "Ensure you are using the WPILib JVM (The current running JVM is listed above\n" + + "Ensure you are using the WPILib JVM (The current running JVM is listed above)\n" + "See https://wpilib.org/jvmruntime for more information\n"); } return msg.toString(); From 6f5a4f6f1e232135d0c377853e722f17e8f15f50 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 10 Dec 2024 08:38:43 -0700 Subject: [PATCH 4/4] Formatting --- wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java index b9f406612c6..5ceaa076ad2 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/RuntimeLoader.java @@ -28,8 +28,8 @@ private static String getLoadErrorMessage(String libraryName, UnsatisfiedLinkErr if (System.getProperty("os.name").startsWith("Windows")) { msg.append( "A common cause of this error is using a JVM with an incorrect MSVC runtime.\n" - + "Ensure you are using the WPILib JVM (The current running JVM is listed above)\n" - + "See https://wpilib.org/jvmruntime for more information\n"); + + "Ensure you are using the WPILib JVM (The current running JVM is listed above)\n" + + "See https://wpilib.org/jvmruntime for more information\n"); } return msg.toString(); }