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

8326591: New test JmodExcludedFiles.java fails on Windows when --with-external-symbols-in-bundles=public is used #2321

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 45 additions & 18 deletions test/jdk/jdk/modules/etc/JmodExcludedFiles.java
Expand Up @@ -25,51 +25,78 @@
* @test
* @bug 8159927
* @modules java.base/jdk.internal.util
* @library /test/lib
* @run main JmodExcludedFiles
* @summary Test that JDK JMOD files do not include native debug symbols
*/

import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import jdk.test.lib.Platform;

public class JmodExcludedFiles {
private static String javaHome = System.getProperty("java.home");

public static void main(String[] args) throws Exception {
String javaHome = System.getProperty("java.home");
Path jmods = Path.of(javaHome, "jmods");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(jmods, "*.jmod")) {
for (Path jmodFile : stream) {
try (ZipFile zip = new ZipFile(jmodFile.toFile())) {
JModSymbolFileMatcher jsfm = new JModSymbolFileMatcher(jmodFile.toString());
if (zip.stream().map(ZipEntry::getName)
.anyMatch(JmodExcludedFiles::isNativeDebugSymbol)) {
.anyMatch(jsfm::isNativeDebugSymbol)) {
throw new RuntimeException(jmodFile + " is expected not to include native debug symbols");
}
}
}
}
}

private static boolean isNativeDebugSymbol(String name) {
int index = name.indexOf("/");
if (index < 0) {
throw new RuntimeException("unexpected entry name: " + name);
static class JModSymbolFileMatcher {
private String jmod;

JModSymbolFileMatcher(String jmod) {
this.jmod = jmod;
}
String section = name.substring(0, index);
if (section.equals("lib") || section.equals("bin")) {
if (System.getProperty("os.name").toLowerCase().contains("os x")) {
String n = name.substring(index+1);
int i = n.indexOf("/");
if (i != -1) {
return n.substring(0, i).endsWith(".dSYM");

boolean isNativeDebugSymbol(String name) {
int index = name.indexOf("/");
if (index < 0) {
throw new RuntimeException("unexpected entry name: " + name);
}
String section = name.substring(0, index);
if (section.equals("lib") || section.equals("bin")) {
if (Platform.isOSX()) {
String n = name.substring(index + 1);
int i = n.indexOf("/");
if (i != -1) {
if (n.substring(0, i).endsWith(".dSYM")) {
System.err.println("Found symbols in " + jmod + ": " + name);
return true;
}
}
}
if (Platform.isWindows() && name.endsWith(".pdb")) {
// on Windows we check if we should have public symbols through --with-external-symbols-in-bundles=public (JDK-8237192)
String strippedpdb = javaHome + "/bin/" + name.substring(index + 1, name.length() - 4) + ".stripped.pdb";
if (!Files.exists(Paths.get(strippedpdb))) {
System.err.println("Found symbols in " + jmod + ": " + name +
". No stripped pdb file " + strippedpdb + " exists.");
return true;
}
}
if (name.endsWith(".diz")
|| name.endsWith(".debuginfo")
|| name.endsWith(".map")) {
System.err.println("Found symbols in " + jmod + ": " + name);
return true;
}
}
return name.endsWith(".diz")
|| name.endsWith(".debuginfo")
|| name.endsWith(".map")
|| name.endsWith(".pdb");
return false;
}
return false;
}
}