From b32514771e84e4df39b33fe07f4bb93a7b32541d Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Mon, 8 May 2023 22:11:11 +0200 Subject: [PATCH] fix NPE --- transform.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transform.java b/transform.java index 54fd3fa..f6c1304 100644 --- a/transform.java +++ b/transform.java @@ -29,9 +29,9 @@ public class transform { "String", "String"); public static void main(String[] args) throws IOException, URISyntaxException { - var headersPath = Path.of(transform.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent().resolve("headers.txt"); // Parse arguments + Path headersPath = null; Path sourcePath = null; Path outputPath = null; boolean tempJava17 = false; @@ -72,6 +72,9 @@ public class transform { } // Check required arguments if (sourcePath == null || outputPath == null) throw getHelp(); + if (headersPath == null) { + headersPath = Path.of(transform.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent().resolve("headers.txt"); + } boolean java17 = tempJava17; boolean overwrite = tempOverwrite; var headers = Files.readString(headersPath, StandardCharsets.UTF_8);