ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode ClassPathLoader.java
Date Sun, 18 Nov 2001 12:25:55 GMT
sbailliez    01/11/18 04:25:55

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode
                        ClassPathLoader.java
  Log:
  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.
  
  Revision  Changes    Path
  1.3       +3 -10     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java
  
  Index: ClassPathLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassPathLoader.java	2001/10/28 21:30:23	1.2
  +++ ClassPathLoader.java	2001/11/18 12:25:55	1.3
  @@ -151,24 +151,17 @@
   			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]);
   				}
   			}
   		}
   		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 */
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message