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

Fix vmcheck exclusions #4336

Merged
merged 1 commit into from
Jan 18, 2019
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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
* Copyright (c) 2001, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -35,8 +35,10 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;


@Test(groups = { "level.extended" })
Expand Down Expand Up @@ -99,8 +101,12 @@ private void loadClassesFromJarfile(String jarfilePath) {
while ((classNames.size() < MAX_CLASSES) && jarfileEntries.hasMoreElements()) {
JarEntry entry = jarfileEntries.nextElement();
String jarEntryName = entry.getName();
if (filterFileName(jarEntryName)) {
if (includeFile(jarEntryName)) {
String testClassName = convertFileNameToClassName(jarEntryName);
/* Prevent spurious macro expansion by the shell */
if (testClassName.contains("$")) { //$NON-NLS-1$
testClassName = "'"+testClassName+"'"; //$NON-NLS-1$ //$NON-NLS-2$
}
classNames.add(testClassName);
}
}
Expand All @@ -115,28 +121,41 @@ private void loadClassesFromJarfile(String jarfilePath) {
}
}

private boolean filterFileName(String jarEntryName) {
if (!jarEntryName.endsWith(".class")) {
return false;
}

/*
* the AWT native libraries have known issues if loaded manually.
* See CMVC 188841 and 188910
*/
if (jarEntryName.startsWith("sun/awt")
|| jarEntryName.startsWith("sun/java2d")

/* sun.reflect.misc.Trampoline need to be excluded as per CMVC 197245 */
|| jarEntryName.startsWith("sun/reflect/misc/Trampoline")

/* Classes that compile stubs will throw errors if loaded: OpenJ9 Issue #732 */
|| jarEntryName.equals("java/util/PropertyPermission.class")
|| jarEntryName.startsWith("java/lang/invoke"))
{
return false;
}
return true;
/**
* Certain packages cannot be loaded via Class.forName()
* as they may require certain machine setups or permissions,
* e.g. access to a display.
*/
@SuppressWarnings("nls")
private static final HashSet<String> excludedPackages =
new HashSet<String>(Arrays.asList(new String[] {
"com.apple.eawt",
"com.apple.laf",
"com.sun.beans.editors",
"com.sun.imageio.plugins",
"com.sun.java.swing",
"com.sun.naming.internal",
"com.sun.xml.internal",
"java.applet",
"java.awt",
"java.lang.invoke",
"java.util.PropertyPermission",
"javax.imageio.ImageIO",
"javax.swing",
"sun.applet",
"sun.awt",
"sun.font",
"sun.java2d",
"sun.lwawt",
"sun.print",
"sun.reflect.misc.Trampoline",
"sun.security.tools.policytool",
"sun.swing"
}).stream().map(s -> s.replace('.', '/')).collect(Collectors.toList()));

private static boolean includeFile(String jarEntryName) {
return jarEntryName.endsWith(".class") //$NON-NLS-1$
&& !excludedPackages.stream().anyMatch(p -> jarEntryName.startsWith(p));
}

private void createAndRunNewClassloadingTester(String jarfilePath, ArrayList<String> classNames)
Expand Down