cvs commit: jakarta-bcel/src/java/org/apache/bcel/util ClassLoader.java ClassLoaderRepository.java Repository.java

[email protected]
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
mdahm       2002/06/06 04:33:20

  Modified:    src/java/org/apache/bcel/util ClassLoader.java
                        ClassLoaderRepository.java Repository.java
  Log:
  Added removeClass
  
  Revision  Changes    Path
  1.5       +24 -26    jakarta-bcel/src/java/org/apache/bcel/util/ClassLoader.java
  
  Index: ClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/util/ClassLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClassLoader.java	10 May 2002 14:45:56 -0000	1.4
  +++ ClassLoader.java	6 Jun 2002 11:33:20 -0000	1.5
  @@ -79,7 +79,7 @@
    * where to use the system class loader in the constructor. The default value contains
    * "java.", "sun.", "javax."</p>
    *
  - * @version $Id: ClassLoader.java,v 1.4 2002/05/10 14:45:56 ddp Exp $
  + * @version $Id: ClassLoader.java,v 1.5 2002/06/06 11:33:20 mdahm Exp $
    * @author  <A HREF="mailto:[email protected]">M. Dahm</A>
    * @see JavaWrapper
    * @see ClassPath
  @@ -89,42 +89,40 @@
     private String[] ignored_packages = {
       "java.", "javax.", "sun."
     };
  -    private Repository repository = 
  -	SyntheticRepository.getInstance();
  -    private java.lang.ClassLoader deferTo = ClassLoader.getSystemClassLoader();
  +  private Repository repository = SyntheticRepository.getInstance();
  +  private java.lang.ClassLoader deferTo = ClassLoader.getSystemClassLoader();
   
     public ClassLoader() {
     }
   
  -    public ClassLoader( java.lang.ClassLoader deferTo ) {
  -	this.deferTo = deferTo;
  -	this.repository = new ClassLoaderRepository( deferTo );
  -    }
  +  public ClassLoader(java.lang.ClassLoader deferTo) {
  +    this.deferTo = deferTo;
  +    this.repository = new ClassLoaderRepository(deferTo);
  +  }
   
     /** @param ignored_packages classes contained in these packages will be loaded
      * with the system class loader
      */
     public ClassLoader(String[] ignored_packages) {
  -      addIgnoredPkgs( ignored_packages );
  +    addIgnoredPkgs(ignored_packages);
     }
   
  -    public ClassLoader( java.lang.ClassLoader deferTo, 
  -			String [] ignored_packages ) {
  -	this.deferTo = deferTo;
  -	this.repository = new ClassLoaderRepository( deferTo );
  +  public ClassLoader(java.lang.ClassLoader deferTo, String [] ignored_packages) {
  +    this.deferTo = deferTo;
  +    this.repository = new ClassLoaderRepository(deferTo);
   
  -	addIgnoredPkgs( ignored_packages );
  -    }
  +    addIgnoredPkgs(ignored_packages);
  +  }
   
  -    private void addIgnoredPkgs( String[] ignored_packages ) {
  -	String[] new_p = new String[ignored_packages.length + this.ignored_packages.length];
  +  private void addIgnoredPkgs(String[] ignored_packages) {
  +    String[] new_p = new String[ignored_packages.length + this.ignored_packages.length];
   	
  -	System.arraycopy(this.ignored_packages, 0, new_p, 0, this.ignored_packages.length);
  -	System.arraycopy(ignored_packages, 0, new_p, this.ignored_packages.length,
  -			 ignored_packages.length);
  +    System.arraycopy(this.ignored_packages, 0, new_p, 0, this.ignored_packages.length);
  +    System.arraycopy(ignored_packages, 0, new_p, this.ignored_packages.length,
  +		     ignored_packages.length);
   
  -	this.ignored_packages = new_p;
  -    }
  +    this.ignored_packages = new_p;
  +  }
     
     protected Class loadClass(String class_name, boolean resolve) 
       throws ClassNotFoundException 
  @@ -152,9 +150,9 @@
   	if(class_name.indexOf("$$BCEL$$") >= 0)
   	  clazz = createClass(class_name);
   	else { // Fourth try: Load classes via repository
  -	    if ( (clazz = repository.loadClass( class_name )) != null) {
  -		clazz = modifyClass( clazz );
  -	    }
  +	  if ((clazz = repository.loadClass(class_name)) != null) {
  +	    clazz = modifyClass(clazz);
  +	  }
   	  else
   	    throw new ClassNotFoundException(class_name);
   	}
  @@ -192,7 +190,7 @@
      *
      * The default implementation interprets the string as a encoded compressed
      * Java class, unpacks and decodes it with the Utility.decode() method, and
  -   * parses thee resulting byte array and returns the resulting JavaClass object.
  +   * parses the resulting byte array and returns the resulting JavaClass object.
      *
      * @param class_name compressed byte code with "$$BCEL$$" in it
      */
  
  
  
  1.2       +7 -0      jakarta-bcel/src/java/org/apache/bcel/util/ClassLoaderRepository.java
  
  Index: ClassLoaderRepository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/util/ClassLoaderRepository.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClassLoaderRepository.java	8 May 2002 20:59:29 -0000	1.1
  +++ ClassLoaderRepository.java	6 Jun 2002 11:33:20 -0000	1.2
  @@ -89,6 +89,13 @@
   	clazz.setRepository( this );
       }
   
  +  /**
  +   * Remove class from repository
  +   */
  +  public void removeClass(JavaClass clazz) {
  +    loadedClasses.remove(clazz.getClassName());
  +  }
  +
       /**
        * Find an already defined JavaClass.
        */
  
  
  
  1.2       +6 -0      jakarta-bcel/src/java/org/apache/bcel/util/Repository.java
  
  Index: Repository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-bcel/src/java/org/apache/bcel/util/Repository.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Repository.java	8 May 2002 20:59:29 -0000	1.1
  +++ Repository.java	6 Jun 2002 11:33:20 -0000	1.2
  @@ -62,12 +62,18 @@
        * Store the provided class under "clazz.getClassName()" 
        */
       public void storeClass( JavaClass clazz );
  +
  +    /**
  +     * Remove class from repository
  +     */
  +    public void removeClass( JavaClass clazz );
       
       /**
        * Find the class with the name provided, if the class
        * isn't there, return NULL.
        */
       public JavaClass findClass( String className );
  +
   
       /**
        * Find the class with the name provided, if the class
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.