Skip to content

Commit

Permalink
Ryan's feedback rnd2
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Nov 10, 2023
1 parent 1fcb864 commit 4abd696
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private QueryCompiler(
try {
urls[0] = (classDestination.toURI().toURL());
} catch (MalformedURLException e) {
throw new RuntimeException("", e);
throw new UncheckedDeephavenException(e);
}
this.ucl = new WritableURLClassLoader(urls, parentClassLoaderToUse);

Expand Down Expand Up @@ -183,7 +183,8 @@ public static void writeClass(final File destinationDirectory, final String clas
ensureDirectories(parentDir,
() -> "Unable to create missing destination directory " + parentDir.getAbsolutePath());
if (!destinationFile.createNewFile()) {
throw new RuntimeException("Unable to create destination file " + destinationFile.getAbsolutePath());
throw new UncheckedDeephavenException(
"Unable to create destination file " + destinationFile.getAbsolutePath());
}
final ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream(data.length);
byteOutStream.write(data, 0, data.length);
Expand Down Expand Up @@ -274,7 +275,7 @@ private static void ensureDirectories(final File file, final Supplier<String> ru
// (and therefore mkdirs() would return false), but still get the directory we need (and therefore exists()
// would return true)
if (!file.mkdirs() && !file.isDirectory()) {
throw new RuntimeException(runtimeErrMsg.get());
throw new UncheckedDeephavenException(runtimeErrMsg.get());
}
}

Expand Down Expand Up @@ -396,7 +397,7 @@ private void addClassSource(File classSourceDirectory) {
try {
ucl.addURL(classSourceDirectory.toURI().toURL());
} catch (MalformedURLException e) {
throw new RuntimeException("", e);
throw new UncheckedDeephavenException(e);
}
}

Expand Down Expand Up @@ -425,7 +426,7 @@ private Class<?> compileHelper(@NotNull final String className,
try {
digest = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Unable to create SHA-256 hashing digest", e);
throw new UncheckedDeephavenException("Unable to create SHA-256 hashing digest", e);
}
final String basicHashText =
ByteUtils.byteArrToHex(digest.digest(classBody.getBytes(StandardCharsets.UTF_8)));
Expand Down Expand Up @@ -645,7 +646,8 @@ private void maybeCreateClass(String className, String code, String packageName,

final String[] splitPackageName = packageName.split("\\.");
if (splitPackageName.length == 0) {
throw new RuntimeException(String.format("packageName %s expected to have at least one .", packageName));
throw new UncheckedDeephavenException(String.format(
"packageName %s expected to have at least one .", packageName));
}
final String[] truncatedSplitPackageName = Arrays.copyOf(splitPackageName, splitPackageName.length - 1);

Expand Down Expand Up @@ -689,7 +691,7 @@ private void maybeCreateClassHelper(String fqClassName, String finalCode, String

final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
throw new RuntimeException("No Java compiler provided - are you using a JRE instead of a JDK?");
throw new UncheckedDeephavenException("No Java compiler provided - are you using a JRE instead of a JDK?");
}

final String classPathAsString = getClassPath() + File.pathSeparator + getJavaClassPath();
Expand All @@ -707,7 +709,7 @@ private void maybeCreateClassHelper(String fqClassName, String finalCode, String
null,
Collections.singletonList(new JavaSourceFromString(fqClassName, finalCode)))
.call();
} catch (final Exception err) {
} catch (final Throwable err) {
exceptionThrown = true;
throw err;
} finally {
Expand All @@ -721,7 +723,7 @@ private void maybeCreateClassHelper(String fqClassName, String finalCode, String
}
}
if (!result) {
throw new RuntimeException("Error compiling class " + fqClassName + ":\n" + compilerOutput);
throw new UncheckedDeephavenException("Error compiling class " + fqClassName + ":\n" + compilerOutput);
}
// The above has compiled into e.g.
// /tmp/workspace/cache/classes/temporaryCompilationDirectory12345/io/deephaven/test/cm12862183232603186v52_0/{various
Expand Down Expand Up @@ -753,7 +755,7 @@ private void maybeCreateClassHelper(String fqClassName, String finalCode, String
private Pair<Boolean, String> tryCompile(File basePath, Collection<File> javaFiles) throws IOException {
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
throw new RuntimeException("No Java compiler provided - are you using a JRE instead of a JDK?");
throw new UncheckedDeephavenException("No Java compiler provided - are you using a JRE instead of a JDK?");
}

final File outputDirectory = Files.createTempDirectory("temporaryCompilationDirectory").toFile();
Expand Down Expand Up @@ -844,7 +846,7 @@ private static String getJavaClassPath() {
}
}
} catch (IOException e) {
throw new RuntimeException("Error extract manifest file from " + javaClasspath + ".\n", e);
throw new UncheckedIOException("Error extract manifest file from " + javaClasspath + ".\n", e);
}
}
return javaClasspath;
Expand Down

0 comments on commit 4abd696

Please sign in to comment.