Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused static initializer block #1057

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
Expand All @@ -34,9 +32,7 @@
import java.util.StringJoiner;

import javax.tools.Diagnostic;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.ToolProvider;

/** Utilities for testing. */
public class TestUtilities {
Expand Down Expand Up @@ -80,12 +76,6 @@ public class TestUtilities {
/** True if the JVM is version 21 or above. */
public static final boolean IS_AT_LEAST_21_JVM = SystemUtil.jreVersion >= 21;

static {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
OutputStream err = new ByteArrayOutputStream();
compiler.run(null, null, err, "-version");
}

/**
* Find test java sources within currentDir/tests.
*
Expand Down Expand Up @@ -120,7 +110,7 @@ public static List<File> findRelativeNestedJavaFiles(File parent, String... dirN
int i = 0;
for (String dirName : dirNames) {
dirs[i] = new File(parent, dirName);
i += 1;
++i;
}

return getJavaFilesAsArgumentList(dirs);
Expand Down Expand Up @@ -320,9 +310,15 @@ public static boolean isJavaTestFile(File file) {
return true;
}

/**
* Convert a compiler diagnostic to a string.
*
* @param diagnostic the compiler diagnostic
* @param usingAnomsgtxt whether message text should be excluded or not
* @return the compiler message string or null for certain lint warnings
*/
public static @Nullable String diagnosticToString(
Diagnostic<? extends JavaFileObject> diagnostic, boolean usingAnomsgtxt) {

String result = diagnostic.toString().trim();

// suppress Xlint warnings
Expand Down Expand Up @@ -471,7 +467,6 @@ public static void writeDiagnostics(
pw.println();
pw.println();
pw.flush();

} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Loading