|
|
|
@ -37,16 +37,18 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
ClassBundle bundle; |
|
|
|
|
PackageIdentifier parent; |
|
|
|
|
String name; |
|
|
|
|
String fullName; |
|
|
|
|
|
|
|
|
|
boolean loadOnDemand; |
|
|
|
|
Map loadedClasses; |
|
|
|
|
|
|
|
|
|
public PackageIdentifier(ClassBundle bundle, |
|
|
|
|
PackageIdentifier parent, |
|
|
|
|
String name) { |
|
|
|
|
String fullName, String name) { |
|
|
|
|
super(name); |
|
|
|
|
this.bundle = bundle; |
|
|
|
|
this.parent = parent; |
|
|
|
|
this.fullName = fullName; |
|
|
|
|
this.name = name; |
|
|
|
|
this.loadedClasses = new HashMap(); |
|
|
|
|
} |
|
|
|
@ -64,9 +66,8 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
return; |
|
|
|
|
loadOnDemand = true; |
|
|
|
|
if ((Main.stripping & Main.STRIP_UNREACH) == 0) { |
|
|
|
|
String fullname = getFullName(); |
|
|
|
|
if (fullname.length() > 0) |
|
|
|
|
fullname += "."; |
|
|
|
|
String fullNamePrefix = |
|
|
|
|
(fullName.length() > 0) ? fullName + "." : ""; |
|
|
|
|
|
|
|
|
|
// Load all classes and packages now, so they don't get stripped
|
|
|
|
|
Enumeration enum = |
|
|
|
@ -75,21 +76,22 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
String subclazz = ((String)enum.nextElement()).intern(); |
|
|
|
|
if (loadedClasses.containsKey(subclazz)) |
|
|
|
|
continue; |
|
|
|
|
String subFull = fullname + subclazz; |
|
|
|
|
String subFull = (fullNamePrefix + subclazz).intern(); |
|
|
|
|
|
|
|
|
|
if (ClassInfo.isPackage(subFull)) { |
|
|
|
|
PackageIdentifier ident = new PackageIdentifier |
|
|
|
|
(bundle, this, subclazz); |
|
|
|
|
(bundle, this, subFull, subclazz); |
|
|
|
|
loadedClasses.put(subclazz, ident); |
|
|
|
|
ident.setLoadOnDemand(); |
|
|
|
|
} else { |
|
|
|
|
ClassIdentifier ident = new ClassIdentifier |
|
|
|
|
(this, subclazz, ClassInfo.forName(subFull)); |
|
|
|
|
(this, subFull, subclazz, ClassInfo.forName(subFull)); |
|
|
|
|
|
|
|
|
|
if (GlobalOptions.verboseLevel > 1) |
|
|
|
|
GlobalOptions.err.println("preloading Class " |
|
|
|
|
+ subFull); |
|
|
|
|
loadedClasses.put(subclazz, ident); |
|
|
|
|
bundle.addClassIdentifier(ident); |
|
|
|
|
((ClassIdentifier) ident).initClass(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -121,24 +123,24 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
if (index == -1) { |
|
|
|
|
Identifier ident = (Identifier) loadedClasses.get(name); |
|
|
|
|
if (ident == null) { |
|
|
|
|
String fullname = getFullName(); |
|
|
|
|
fullname = (fullname.length() > 0) |
|
|
|
|
? fullname + "."+ name |
|
|
|
|
: name; |
|
|
|
|
if (ClassInfo.isPackage(fullname)) { |
|
|
|
|
String subFull = |
|
|
|
|
(fullName.length() > 0) ? fullName + "."+ name : name; |
|
|
|
|
subFull = subFull.intern(); |
|
|
|
|
if (ClassInfo.isPackage(subFull)) { |
|
|
|
|
PackageIdentifier pack |
|
|
|
|
= new PackageIdentifier(bundle, this, name); |
|
|
|
|
= new PackageIdentifier(bundle, this, subFull, name); |
|
|
|
|
loadedClasses.put(name, pack); |
|
|
|
|
pack.setLoadOnDemand(); |
|
|
|
|
ident = pack; |
|
|
|
|
} else if (!ClassInfo.exists(fullname)) { |
|
|
|
|
} else if (!ClassInfo.exists(subFull)) { |
|
|
|
|
GlobalOptions.err.println("Warning: Can't find class " |
|
|
|
|
+ fullname); |
|
|
|
|
+ subFull); |
|
|
|
|
Thread.dumpStack(); |
|
|
|
|
} else { |
|
|
|
|
ident = new ClassIdentifier(this, name, |
|
|
|
|
ClassInfo.forName(fullname)); |
|
|
|
|
ident = new ClassIdentifier(this, subFull, name, |
|
|
|
|
ClassInfo.forName(subFull)); |
|
|
|
|
loadedClasses.put(name, ident); |
|
|
|
|
bundle.addClassIdentifier(ident); |
|
|
|
|
((ClassIdentifier) ident).initClass(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -148,12 +150,12 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
PackageIdentifier pack = |
|
|
|
|
(PackageIdentifier) loadedClasses.get(subpack); |
|
|
|
|
if (pack == null) { |
|
|
|
|
String fullname = getFullName(); |
|
|
|
|
fullname = (fullname.length() > 0) |
|
|
|
|
? fullname + "."+ subpack : subpack; |
|
|
|
|
if (ClassInfo.isPackage(fullname)) { |
|
|
|
|
String subFull = (fullName.length() > 0) |
|
|
|
|
? fullName + "."+ subpack : subpack; |
|
|
|
|
subFull = subFull.intern(); |
|
|
|
|
if (ClassInfo.isPackage(subFull)) { |
|
|
|
|
pack = new PackageIdentifier(bundle, this, |
|
|
|
|
subpack); |
|
|
|
|
subFull, subpack); |
|
|
|
|
loadedClasses.put(subpack, pack); |
|
|
|
|
if (loadOnDemand) |
|
|
|
|
pack.setLoadOnDemand(); |
|
|
|
@ -173,28 +175,28 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
Identifier ident = (Identifier) loadedClasses.get(component); |
|
|
|
|
if (ident == null) { |
|
|
|
|
component = component.intern(); |
|
|
|
|
String fullname = getFullName(); |
|
|
|
|
fullname = (fullname.length() > 0) |
|
|
|
|
? fullname + "." + component |
|
|
|
|
: component; |
|
|
|
|
if (ClassInfo.isPackage(fullname)) { |
|
|
|
|
String subFull = (fullName.length() > 0) |
|
|
|
|
? fullName + "."+ component : component; |
|
|
|
|
subFull = subFull.intern(); |
|
|
|
|
if (ClassInfo.isPackage(subFull)) { |
|
|
|
|
ident = new PackageIdentifier(bundle, this, |
|
|
|
|
component); |
|
|
|
|
subFull, component); |
|
|
|
|
loadedClasses.put(component, ident); |
|
|
|
|
if (loadOnDemand) |
|
|
|
|
((PackageIdentifier) ident).setLoadOnDemand(); |
|
|
|
|
} else if (ClassInfo.exists(fullname)) { |
|
|
|
|
} else if (ClassInfo.exists(subFull)) { |
|
|
|
|
if (GlobalOptions.verboseLevel > 1) |
|
|
|
|
GlobalOptions.err.println("loading Class " +fullname); |
|
|
|
|
ident = new ClassIdentifier(this, component, |
|
|
|
|
ClassInfo.forName(fullname)); |
|
|
|
|
GlobalOptions.err.println("loading Class " +subFull); |
|
|
|
|
ident = new ClassIdentifier(this, subFull, component, |
|
|
|
|
ClassInfo.forName(subFull)); |
|
|
|
|
if (loadOnDemand || matcher.matches(ident)) { |
|
|
|
|
loadedClasses.put(component, ident); |
|
|
|
|
bundle.addClassIdentifier(ident); |
|
|
|
|
((ClassIdentifier) ident).initClass(); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
GlobalOptions.err.println |
|
|
|
|
("Warning: Can't find class/package " + fullname); |
|
|
|
|
("Warning: Can't find class/package " + subFull); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (ident instanceof PackageIdentifier) { |
|
|
|
@ -209,9 +211,8 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
((PackageIdentifier) ident).loadMatchingClasses(matcher); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
String fullname = getFullName(); |
|
|
|
|
if (fullname.length() > 0) |
|
|
|
|
fullname += "."; |
|
|
|
|
String fullNamePrefix = |
|
|
|
|
(fullName.length() > 0) ? fullName + "." : ""; |
|
|
|
|
/* Load all matching classes and packages */ |
|
|
|
|
Enumeration enum = |
|
|
|
|
ClassInfo.getClassesAndPackages(getFullName()); |
|
|
|
@ -219,7 +220,7 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
String subclazz = ((String)enum.nextElement()).intern(); |
|
|
|
|
if (loadedClasses.containsKey(subclazz)) |
|
|
|
|
continue; |
|
|
|
|
String subFull = fullname + subclazz; |
|
|
|
|
String subFull = (fullNamePrefix + subclazz).intern(); |
|
|
|
|
|
|
|
|
|
if (matcher.matchesSub(this, subclazz)) { |
|
|
|
|
if (ClassInfo.isPackage(subFull)) { |
|
|
|
@ -227,19 +228,21 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
GlobalOptions.err.println("loading Package " |
|
|
|
|
+ subFull); |
|
|
|
|
PackageIdentifier ident = new PackageIdentifier |
|
|
|
|
(bundle, this, subclazz); |
|
|
|
|
(bundle, this, subFull, subclazz); |
|
|
|
|
loadedClasses.put(subclazz, ident); |
|
|
|
|
if (loadOnDemand || matcher.matches(ident)) |
|
|
|
|
ident.setLoadOnDemand(); |
|
|
|
|
} else { |
|
|
|
|
ClassIdentifier ident = new ClassIdentifier |
|
|
|
|
(this, subclazz, ClassInfo.forName(subFull)); |
|
|
|
|
(this, subFull, subclazz, |
|
|
|
|
ClassInfo.forName(subFull)); |
|
|
|
|
|
|
|
|
|
if (loadOnDemand || matcher.matches(ident)) { |
|
|
|
|
if (GlobalOptions.verboseLevel > 1) |
|
|
|
|
GlobalOptions.err.println("loading Class " |
|
|
|
|
+ subFull); |
|
|
|
|
loadedClasses.put(subclazz, ident); |
|
|
|
|
bundle.addClassIdentifier(ident); |
|
|
|
|
((ClassIdentifier) ident).initClass(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -265,111 +268,12 @@ public class PackageIdentifier extends Identifier { |
|
|
|
|
loadMatchingClasses(preserveRule); |
|
|
|
|
super.applyPreserveRule(preserveRule); |
|
|
|
|
} |
|
|
|
|
// public void preserveMatchingIdentifier(IdentifierMatcher matcher) {
|
|
|
|
|
// String component = matcher.getNextComponent(getFullName());
|
|
|
|
|
// if (component != null) {
|
|
|
|
|
// String fullname = getFullName();
|
|
|
|
|
// fullname = (fullname.length() > 0)
|
|
|
|
|
// ? fullname + "."+ component : component;
|
|
|
|
|
// Identifier ident = (Identifier) loadedClasses.get(component);
|
|
|
|
|
// if (ident == null) {
|
|
|
|
|
// if (!loadOnDemand) {
|
|
|
|
|
// GlobalOptions.err.println
|
|
|
|
|
// ("Warning: Didn't load package/class "+ fullname);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// if (ClassInfo.isPackage(fullname)) {
|
|
|
|
|
// ident = new PackageIdentifier(bundle, this,
|
|
|
|
|
// component, loadOnDemand);
|
|
|
|
|
// loadedClasses.put(component, ident);
|
|
|
|
|
// } else if (ClassInfo.exists(fullname)) {
|
|
|
|
|
// ident = new ClassIdentifier(this, component,
|
|
|
|
|
// ClassInfo.forName(fullname));
|
|
|
|
|
// loadedClasses.put(component, ident);
|
|
|
|
|
// ((ClassIdentifier) ident).initClass();
|
|
|
|
|
// if (bundle.preserveRule != null)
|
|
|
|
|
// ident.applyPreserveRule(bundle.preserveRule);
|
|
|
|
|
// } else {
|
|
|
|
|
// GlobalOptions.err.println("Warning: Can't find class "
|
|
|
|
|
// + fullname);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (matcher.matches(fullname)) {
|
|
|
|
|
// if (GlobalOptions.verboseLevel > 1)
|
|
|
|
|
// GlobalOptions.err.println("preserving "+ident);
|
|
|
|
|
// ident.setPreserved();
|
|
|
|
|
// }
|
|
|
|
|
// if (matcher.startsWith(fullname+".")) {
|
|
|
|
|
// if (ident instanceof PackageIdentifier)
|
|
|
|
|
// ((PackageIdentifier) ident)
|
|
|
|
|
// .preserveMatchingIdentifier(matcher);
|
|
|
|
|
// else
|
|
|
|
|
// ((ClassIdentifier) ident)
|
|
|
|
|
// .preserveMatchingIdentifier(matcher);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// String fullname = getFullName();
|
|
|
|
|
// if (fullname.length() > 0)
|
|
|
|
|
// fullname += ".";
|
|
|
|
|
// if (loadOnDemand) {
|
|
|
|
|
// /* Load all matching classes and packages */
|
|
|
|
|
// Enumeration enum =
|
|
|
|
|
// ClassInfo.getClassesAndPackages(getFullName());
|
|
|
|
|
// while (enum.hasMoreElements()) {
|
|
|
|
|
// String subclazz = (String)enum.nextElement();
|
|
|
|
|
// if (loadedClasses.containsKey(subclazz))
|
|
|
|
|
// continue;
|
|
|
|
|
// String subFull = fullname + subclazz;
|
|
|
|
|
|
|
|
|
|
// if (matcher.startsWith(subFull)) {
|
|
|
|
|
// if (ClassInfo.isPackage(subFull)) {
|
|
|
|
|
// System.err.println("is package: "+subFull);
|
|
|
|
|
// Identifier ident = new PackageIdentifier
|
|
|
|
|
// (bundle, this, subclazz, true);
|
|
|
|
|
// loadedClasses.put(subclazz, ident);
|
|
|
|
|
// } else {
|
|
|
|
|
// ClassIdentifier ident = new ClassIdentifier
|
|
|
|
|
// (this, subclazz, ClassInfo.forName(subFull));
|
|
|
|
|
// loadedClasses.put(subclazz, ident);
|
|
|
|
|
// ((ClassIdentifier) ident).initClass();
|
|
|
|
|
// if (bundle.preserveRule != null)
|
|
|
|
|
// ident.applyPreserveRule(bundle.preserveRule);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// for (Iterator i = loadedClasses.values().iterator();
|
|
|
|
|
// i.hasNext(); ) {
|
|
|
|
|
// Identifier ident = (Identifier) i.next();
|
|
|
|
|
// if (matcher.matches(ident.getFullName())) {
|
|
|
|
|
// if (GlobalOptions.verboseLevel > 1)
|
|
|
|
|
// GlobalOptions.err.println("Preserving "+ident);
|
|
|
|
|
// ident.setPreserved();
|
|
|
|
|
// }
|
|
|
|
|
// if (matcher.startsWith(ident.getFullName()+".")) {
|
|
|
|
|
// if (ident instanceof PackageIdentifier)
|
|
|
|
|
// ((PackageIdentifier) ident)
|
|
|
|
|
// .preserveMatchingIdentifier(matcher);
|
|
|
|
|
// else
|
|
|
|
|
// ((ClassIdentifier) ident)
|
|
|
|
|
// .preserveMatchingIdentifier(matcher);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the full qualified name. |
|
|
|
|
*/ |
|
|
|
|
public String getFullName() { |
|
|
|
|
if (parent != null) { |
|
|
|
|
if (parent.getFullName().length() > 0) |
|
|
|
|
return parent.getFullName() + "." + getName(); |
|
|
|
|
else |
|
|
|
|
return getName(); |
|
|
|
|
} else |
|
|
|
|
return ""; |
|
|
|
|
return fullName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|