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<>();
|
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
|
* We add maximum 5 second level entries to "sun", "java" and
|
||||||
* "javax" entries. Tune this parameter to get a balance on the
|
* "javax" entries. Tune this parameter to get a balance on the
|
||||||
@ -237,39 +275,25 @@ class JarMetaIndex {
|
|||||||
String[] pkgElements = name.split("/");
|
String[] pkgElements = name.split("/");
|
||||||
// Last one is the class name; definitely ignoring that
|
// Last one is the class name; definitely ignoring that
|
||||||
if (pkgElements.length > 2) {
|
if (pkgElements.length > 2) {
|
||||||
String meta = null;
|
String meta = "";
|
||||||
// Need more information than just first two package
|
|
||||||
// name elements to determine that classes in
|
// Default is 2 levels of package elements
|
||||||
// deploy.jar are not in rt.jar
|
int levels = 2;
|
||||||
if (pkgElements.length > 3 &&
|
|
||||||
pkgElements[0].equals("com") &&
|
// But for some packages we add more elements
|
||||||
pkgElements[1].equals("sun")) {
|
for(ExtraLevel el : extraLevels) {
|
||||||
// Need more precise information to disambiguate
|
if (name.startsWith(el.prefix)) {
|
||||||
// (illegal) references from applications to
|
levels = el.levels;
|
||||||
// obsolete backported collections classes in
|
break;
|
||||||
// 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] + "/";
|
|
||||||
}
|
}
|
||||||
} 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;
|
} // end of "while" loop;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user