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

Apply minor polish to ClassInclusionReport #17971

Merged
merged 1 commit into from
Jun 17, 2021
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 @@ -18,9 +18,11 @@
public final class ClassInclusionReport {

private final Set<String> includedClasses;
private final Path usedClassesReport;

private ClassInclusionReport(Set<String> strings, Path usedClassesReport) {
includedClasses = strings;
private ClassInclusionReport(Set<String> includedClasses, Path usedClassesReport) {
this.includedClasses = includedClasses;
this.usedClassesReport = usedClassesReport;
}

/**
Expand Down Expand Up @@ -55,26 +57,24 @@ public void assertContains(final String typeName) {
final boolean contains = includedClasses.contains(typeName);
if (!contains) {
Assertions.fail(
"Type '" + typeName + "' was not found in the report in " + getUsedClassesReport()
.toString());
"Type '" + typeName + "' was not found in the report in " + usedClassesReport);
}
}

public void assertContainsNot(final String typeName) {
final boolean contains = includedClasses.contains(typeName);
if (contains) {
Assertions.fail("Type '" + typeName + "' was found in the report in " + getUsedClassesReport()
.toString());
Assertions.fail("Type '" + typeName + "' was found in the report in " + usedClassesReport);
}
}

private static Path getUsedClassesReport() {
final Path reportsPath = nativeImageReportsPath();
final File[] usedClassesReports = reportsPath.toFile().listFiles((dir, name) -> name.toLowerCase(Locale.ROOT)
.startsWith("used_classes_"));
Assertions.assertNotNull(usedClassesReports, "Could not identify the native image build directory");
Assertions.assertEquals(1, usedClassesReports.length, "Could not identify the native image build directory");
final Path usedClassesReport = usedClassesReports[0].toPath();
return usedClassesReport;
return usedClassesReports[0].toPath();
}

private static Path nativeImageReportsPath() {
Expand All @@ -89,6 +89,7 @@ private static Path locateNativeImageBuildDirectory() {
Path buildPath = Paths.get("target");
final File[] files = buildPath.toFile().listFiles((dir, name) -> name.toLowerCase(Locale.ROOT)
.endsWith("-native-image-source-jar"));
Assertions.assertNotNull(files, "Could not identify the native image build directory");
Assertions.assertEquals(1, files.length, "Could not identify the native image build directory");
return files[0].toPath();
}
Expand Down