8023492: jfr.jar gets loaded even though it's not used
Reviewed-by: erikj, mgronlun
This commit is contained in:
parent
738a5097a7
commit
938247e8f4
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user