Browse Source

Uh ! Found stupid bugs while doing some code review:

1) classes were indexed by their name instead of their fullname...
It means that a class X in package Y could shadow class X in package Z. Great !

2) I was looking for duplicate not by the key but the value.

Obviouslly it could never work, fortunately due to
heavy memory usage, I did not used this method in XMLReport.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269946 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 23 years ago
parent
commit
19fc830a16
1 changed files with 3 additions and 10 deletions
  1. +3
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java

+ 3
- 10
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java View File

@@ -151,12 +151,12 @@ public class ClassPathLoader {
long t0 = System.currentTimeMillis();
ClassFile[] classes = loader.getClasses();
long dt = System.currentTimeMillis() - t0;
System.out.println("" + classes.length + " loaded in " + dt + "ms");
System.out.println("" + classes.length + " classes loaded in " + dt + "ms");
for (int j = 0; j < classes.length; j++){
String name = classes[j].getName();
String name = classes[j].getFullName();
// do not allow duplicates entries to preserve 'classpath' behavior
// first class in wins
if ( !map.contains(name) ){
if ( !map.containsKey(name) ){
map.put(name, classes[j]);
}
}
@@ -164,13 +164,6 @@ public class ClassPathLoader {
return map;
}
/** dirty little test, should be moved to a testcase */
public static void main(String[] args) throws Exception {
ClassPathLoader cl = new ClassPathLoader("e:/jdk/jdk1.3.1/lib/tools.jar;e:/jdk/jdk1.3.1/jre/lib/rt.jar");
Hashtable map = cl.getClasses();
System.out.println("Loaded classes: " + map.size());
}
/** the loader enumeration that will return loaders */
protected class LoaderEnumeration implements Enumeration {
protected int index = 0;


Loading…
Cancel
Save