protected void clearReferences() {

        // Unregister any JDBC drivers loaded by this classloader
        Enumeration drivers = DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            Driver driver = (Driver) drivers.nextElement();
            if (driver.getClass().getClassLoader() == this) {
                try {
                    DriverManager.deregisterDriver(driver);
                } catch (SQLException e) {
                    log.warn("SQL driver deregistration failed", e);
                }
            }
        }
        
        // Null out any static or final fields from loaded classes,
        // as a workaround for apparent garbage collection bugs
        if (ENABLE_CLEAR_REFERENCES) {
            Iterator loadedClasses = ((HashMap)((HashMap) resourceEntries).clone()).values().iterator();
            while (loadedClasses.hasNext()) {
                ResourceEntry entry = (ResourceEntry) loadedClasses.next();
                if (entry.loadedClass != null) {
                    Class clazz = entry.loadedClass;
                    try {
                        Field[] fields = clazz.getDeclaredFields();
                        for (int i = 0; i < fields.length; i++) {
                            Field field = fields[i];
                            int mods = field.getModifiers();
                            if (field.getType().isPrimitive() 
                                    || (field.getName().indexOf("$") != -1)) {
                                continue;
                            }
                            if (Modifier.isStatic(mods)) {
                                try {
                                    field.setAccessible(true);
                                    if (Modifier.isFinal(mods)) {
                                        if (!((field.getType().getName().startsWith("java."))
                                                || (field.getType().getName().startsWith("javax.")))) {
                                            nullInstance(field.get(null));
                                        }
                                    } else {
                                        field.set(null, null);
                                        if (log.isDebugEnabled()) {
                                            log.debug("Set field " + field.getName() 
                                                    + " to null in class " + clazz.getName());
                                        }
                                    }
                                } catch (Throwable t) {
                                    if (log.isDebugEnabled()) {
                                        log.debug("Could not set field " + field.getName() 
                                                + " to null in class " + clazz.getName(), t);
                                    }
                                }
                            }
                        }
                    } catch (Throwable t) {
                        if (log.isDebugEnabled()) {
                            log.debug("Could not clean fields for class " + clazz.getName(), t);
                        }
                    }
                }
            }
        }
        
         // Clear the IntrospectionUtils cache.
        IntrospectionUtils.clear();
        
        // Clear the classloader reference in common-logging
        org.apache.juli.logging.LogFactory.release(this);
        
        // Clear the classloader reference in the VM's bean introspector
        java.beans.Introspector.flushCaches();

    }
protected void clearReferences ( ) { Enumeration drivers = DriverManager . getDrivers ( ) ; while ( drivers . hasMoreElements ( ) ) { Driver driver = ( Driver ) drivers . nextElement ( ) ; if ( driver . getClass ( ) . getClassLoader ( ) == this ) { try { DriverManager . deregisterDriver ( driver ) ; } catch ( SQLException e ) { log . warn ( "SQL driver deregistration failed" , e ) ; } } } if ( ENABLE_CLEAR_REFERENCES ) { Iterator loadedClasses = ( ( HashMap ) ( ( HashMap ) resourceEntries ) . clone ( ) ) . values ( ) . iterator ( ) ; while ( loadedClasses . hasNext ( ) ) { ResourceEntry entry = ( ResourceEntry ) loadedClasses . next ( ) ; if ( entry . loadedClass != null ) { Class clazz = entry . loadedClass ; try { Field [ ] fields = clazz . getDeclaredFields ( ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { Field field = fields [ i ] ; int mods = field . getModifiers ( ) ; if ( field . getType ( ) . isPrimitive ( ) || ( field . getName ( ) . indexOf ( "$" ) != - 1 ) ) { continue ; } if ( Modifier . isStatic ( mods ) ) { try { field . setAccessible ( true ) ; if ( Modifier . isFinal ( mods ) ) { if ( ! ( ( field . getType ( ) . getName ( ) . startsWith ( "java." ) ) || ( field . getType ( ) . getName ( ) . startsWith ( "javax." ) ) ) ) { nullInstance ( field . get ( null ) ) ; } } else { field . set ( null , null ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Set field " + field . getName ( ) + " to null in class " + clazz . getName ( ) ) ; } } } catch ( Throwable t ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Could not set field " + field . getName ( ) + " to null in class " + clazz . getName ( ) , t ) ; } } } } } catch ( Throwable t ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Could not clean fields for class " + clazz . getName ( ) , t ) ; } } } } } IntrospectionUtils . clear ( ) ; org . apache . juli . logging . LogFactory . release ( this ) ; java . beans . Introspector . flushCaches ( ) ; }
Clear references.