Create a new instance of the class manager. Class manager instnaces are now associated with the interpreter. @see bsh.Interpreter#getClassManager() @see bsh.Interpreter#setClassLoader( ClassLoader )
( Interpreter interpreter )
| 134 | @see bsh.Interpreter#setClassLoader( ClassLoader ) |
| 135 | */ |
| 136 | public static BshClassManager createClassManager( Interpreter interpreter ) |
| 137 | { |
| 138 | BshClassManager manager; |
| 139 | |
| 140 | // Do we have the optional package? |
| 141 | if ( Capabilities.classExists("bsh.classpath.ClassManagerImpl") ) |
| 142 | try { |
| 143 | // Try to load the module |
| 144 | // don't refer to it directly here or we're dependent upon it |
| 145 | Class clazz = Class.forName( "bsh.classpath.ClassManagerImpl" ); |
| 146 | manager = (BshClassManager) clazz.newInstance(); |
| 147 | } catch ( Exception e ) { |
| 148 | throw new InterpreterError("Error loading classmanager", e); |
| 149 | } |
| 150 | else |
| 151 | manager = new BshClassManager(); |
| 152 | |
| 153 | if ( interpreter == null ) |
| 154 | interpreter = new Interpreter(); |
| 155 | manager.declaringInterpreter = interpreter; |
| 156 | classManagers.put(manager,null); |
| 157 | return manager; |
| 158 | } |
| 159 | |
| 160 | public boolean classExists( String name ) { |
| 161 | return ( classForName( name ) != null ); |
no test coverage detected