提交 b39b6f8a 编写于 作者: S sla

8023492: jfr.jar gets loaded even though it's not used

Reviewed-by: erikj, mgronlun
上级 e122507b
......@@ -173,6 +173,44 @@ class JarMetaIndex {
*/
private HashMap<String, HashSet<String>> knownPrefixMap = new HashMap<>();
/*
* A class for mapping package prefixes to the number of
* levels of package elements to include.
*/
static class ExtraLevel {
public ExtraLevel(String prefix, int levels) {
this.prefix = prefix;
this.levels = levels;
}
String prefix;
int levels;
}
/*
* A list of the special-cased package names.
*/
private static ArrayList<ExtraLevel> extraLevels = new ArrayList<>();
static {
// The order of these statements is significant,
// since we stop looking after the first match.
// Need more precise information to disambiguate
// (illegal) references from applications to
// obsolete backported collections classes in
// com/sun/java/util
extraLevels.add(new ExtraLevel("com/sun/java/util/", Integer.MAX_VALUE));
extraLevels.add(new ExtraLevel("com/sun/java/", 4));
// Need more information than just first two package
// name elements to determine that classes in
// deploy.jar are not in rt.jar
extraLevels.add(new ExtraLevel("com/sun/", 3));
// Need to make sure things in jfr.jar aren't
// confused with other com/oracle/** packages
extraLevels.add(new ExtraLevel("com/oracle/jrockit", 3));
}
/*
* We add maximum 5 second level entries to "sun", "java" and
* "javax" entries. Tune this parameter to get a balance on the
......@@ -237,39 +275,25 @@ class JarMetaIndex {
String[] pkgElements = name.split("/");
// Last one is the class name; definitely ignoring that
if (pkgElements.length > 2) {
String meta = null;
// Need more information than just first two package
// name elements to determine that classes in
// deploy.jar are not in rt.jar
if (pkgElements.length > 3 &&
pkgElements[0].equals("com") &&
pkgElements[1].equals("sun")) {
// Need more precise information to disambiguate
// (illegal) references from applications to
// obsolete backported collections classes in
// com/sun/java/util
if (pkgElements.length > 4 &&
pkgElements[2].equals("java")) {
int bound = 0;
if (pkgElements[3].equals("util")) {
// Take all of the packages
bound = pkgElements.length - 1;
} else {
// Trim it somewhat more
bound = 4;
}
meta = "";
for (int j = 0; j < bound; j++) {
meta += pkgElements[j] + "/";
}
} else {
meta = pkgElements[0] + "/" + pkgElements[1]
+ "/" + pkgElements[2] + "/";
String meta = "";
// Default is 2 levels of package elements
int levels = 2;
// But for some packages we add more elements
for(ExtraLevel el : extraLevels) {
if (name.startsWith(el.prefix)) {
levels = el.levels;
break;
}
} else {
meta = pkgElements[0] + "/" + pkgElements[1] + "/";
}
indexSet.add(meta);
for (int i = 0; i < levels && i < pkgElements.length - 1; i++) {
meta += pkgElements[i] + "/";
}
if (!meta.equals("")) {
indexSet.add(meta);
}
}
} // end of "while" loop;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册