All pastes #399350 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-17 23:12 UTC
rendered paste body
if (getPath()!=null) {
            InputStream in = null;
            try {
                in = ResourceLoader.getResourceAsStream(ref);
            } catch (RuntimeException e) {
                throw new ClassNotFoundException("Could not locate path: "+ref);
            }
            
            try {
                compiler.cook(in);
            } catch (Exception e) {
                throw new InterpreterException("Error compiling source: "   
                                    +e.getMessage(), e);
            }
            ClassLoader loader = compiler.getClassLoader();
            Object o = null;
            try {
                Class<?> klass = loader.loadClass(name);
                o = klass.newInstance();
            }
            catch (InstantiationException e) {
                throw new InterpreterException("Instantiation err", e);
            }
            catch (IllegalAccessException e) {
                throw new InterpreterException("Access err", e);
            }
            
            return (o!=null) ? (T)o : null;
        }
        else {
            throw new ClassNotFoundException("Path hasn't been set for Interpreter");
        }