From 19fc830a16998bf6dfbfc21a3e00417ebf7c12ab Mon Sep 17 00:00:00 2001 From: Stephane Bailliez Date: Sun, 18 Nov 2001 12:25:55 +0000 Subject: [PATCH] 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 --- .../optional/sitraka/bytecode/ClassPathLoader.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java b/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java index 4ff72749c..1dd1bcf59 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java @@ -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;