Initializes the look and feel and wraps exceptions into a runtime
exception. It's executed in the calling thread.

@param className
Full qualified name of the look and feel class.
480675
private static void initLookAndFeelIntern(final String className) {
        try {
            UIManager.setLookAndFeel(className);
        } catch (final Exception e) {
            throw new RuntimeException("Error initializing the Look And Feel!", e);
        }
    }
1355310
public static Mirror newInstanceForClassName(String className) 
	throws ClassNotFoundException, InstantiationException, IllegalAccessException
	{
		className = className.trim();
		Class<?> objClass = Class.forName(className);

		   
		return new Mirror(ClassPath.newInstance(objClass));
	}
1142840
public static Class loadClass(String className) throws ClassException {
	Set<Throwable> exceptions = new HashSet<Throwable>();
	// OSGI env
	Class clazz = _loadClass(new OSGiBasedClassLoading(), className, null, exceptions);
	if (clazz != null) {
	    return clazz;
	}

	// core classloader
	clazz = _loadClass(new ClassLoaderBasedClassLoading(SystemUtil.getCoreClassLoader()), className, null, exceptions);
	if (clazz != null) {
	    return clazz;
	}

	// loader classloader
	clazz = _loadClass(new ClassLoaderBasedClassLoading(SystemUtil.getLoaderClassLoader()), className, null, exceptions);
	if (clazz != null) {
	    return clazz;
	}

	String msg = "cannot load class through its string name, because no definition for the class with the specified name [" + className + "] could be found";
	if (exceptions.size() > 0) {
	    StringBuilder detail = new StringBuilder();
	    Iterator<Throwable> it = exceptions.iterator();
	    Throwable t;
	    while (it.hasNext()) {
		t = it.next();
		detail.append(t.getClass().getName()).append(':').append(t.getMessage()).append(';');
	    }
	    throw new ClassException(msg + " caused by (" + detail.toString() + ")");
	}
	throw new ClassException(msg);
    }
1098020
public void init() throws ConfigurationException {
		if(index == null) {
			throw new ConfigurationException("No index target");
		}
		if(!index.isUpdatable()) {
			throw new ConfigurationException("ResourceIndex is not updatable");
		}
		if(incoming == null) {
			throw new ConfigurationException("No incoming");			
		}
		if(runInterval > 0) {
			thread = new UpdateThread(this,runInterval);
			thread.start();
		}
	}
630460
public static void init()
	{
		try
		{
			init("vdmj.properties", Properties.class);
		} catch (Exception e)
		{
			System.err.println(e.getMessage());
		}

		InputStream fis = ConfigBase.class.getResourceAsStream("/"
				+ "overture.properties");

		if (fis != null)
		{
			try
			{
				java.util.Properties overtureProperties = new java.util.Properties();
				overtureProperties.load(fis);

				final String SYSTEM_KEY = "system.";
				for (Entry<Object, Object> entry : overtureProperties.entrySet())
				{
					String key = entry.getKey().toString();
					String value = entry.getValue().toString();

					if (value.indexOf("/") != -1)
					{
						// assume that this is a file path and correct it
						value = value.replace('/', File.separatorChar);
					}

					int index = key.indexOf(SYSTEM_KEY);
					if (index == 0)
					{
						String newKey = key.substring(SYSTEM_KEY.length());
						System.setProperty(newKey, value);
					}
				}
			} catch (Exception e)
			{
				throw new RuntimeException(e);
			}
		}
	}
134275
public final synchronized void init(final Class<T> pClass) throws Exception {
    this.objectClass = pClass;
    this.fieldsNames.clear();
    this.gettersMap.clear();
    this.settersMap.clear();
    Field[] fields = getUtlReflection().retrieveFields(this.objectClass);
    for (Field field : fields) {
      Method getter = getUtlReflection()
        .retrieveGetterForField(pClass, field.getName());
      Method setter = getUtlReflection()
        .retrieveSetterForField(pClass, field.getName());
      this.gettersMap.put(field.getName(), getter);
      this.settersMap.put(field.getName(), setter);
      this.fieldsNames.add(field.getName());
    }
  }
1131131
public void addAllowedClass(String className) {
        String classRegex = START + dotsToRegex(className) + ".class$";
        LOG.debug("Class regex: {}", classRegex);
        patternList.add(Pattern.compile(classRegex).matcher(""));
    }
744875
@Override
    public JavaClass loadClass(String className) throws ClassNotFoundException {
        if (className.length() == 0) {
            throw new IllegalArgumentException("Request to load empty class");
        }
        className = ClassName.toSlashedClassName(className);
        ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor(className);
        try {
            return Global.getAnalysisCache().getClassAnalysis(JavaClass.class, classDescriptor);
        } catch (CheckedAnalysisException e) {
            throw new ClassNotFoundException("Exception while looking for class " + className, e);
        }
    }
444754
public static synchronized void init ()
    {
        // only initialize ourselves once
        if (_keys != null) {
            return;
        } else {
            _keys = new ArrayList<Class<?>>();
            _values = new ArrayList<String>();
        }

        // first try loading the properties file without a leading slash
        ClassLoader cld = ExceptionMap.class.getClassLoader();
        InputStream config = ConfigUtil.getStream(PROPS_NAME, cld);
        if (config == null) {
            log.warning("Unable to load " + PROPS_NAME + " from CLASSPATH.");

        } else {
            // otherwise process ye old config file.
            try {
                // we'll do some serious jiggery pokery to leverage the parsing
                // implementation provided by java.util.Properties. god bless
                // method overloading
                final ArrayList<String> classes = new ArrayList<String>();
                Properties loader = new Properties() {
                    @Override public Object put (Object key, Object value) {
                        classes.add((String)key);
                        _values.add((String)value);
                        return key;
                    }
                };
                loader.load(config);

                // now cruise through and resolve the exceptions named as
                // keys and throw out any that don't appear to exist
                for (int i = 0; i < classes.size(); i++) {
                    String exclass = classes.get(i);
                    try {
                        Class<?> cl = Class.forName(exclass);
                        // replace the string with the class object
                        _keys.add(cl);

                    } catch (Throwable t) {
                        log.warning("Unable to resolve exception class.", "class", exclass,
                                    "error", t);
                        _values.remove(i);
                        i--; // back on up a notch
                    }
                }

            } catch (IOException ioe) {
                log.warning("Error reading exception mapping file: " + ioe);
            }
        }
    }
215209
public void setExceptions(Class<?>[] exceptions) {
		for (Class<?> exception : exceptions) {
			// uses simple name because exception may be declared into .client package
			this.exceptions.add(exception.getSimpleName());
		}
	}
333296
public void setHandler(String handlerClassName) {

        try {
            m_handler = (I_CmsStaticExportHandler)Class.forName(handlerClassName).newInstance();
        } catch (Exception e) {
            // should never happen
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
557071
@Override
	public void init(final ServletConfig config) throws ServletException {
		try {
			ContextClassLoaderUtils.doWithClassLoader(jasperClassLoader,
					new Callable<Void>() {

						@Override
						public Void call() throws Exception {
							config.getServletContext().setAttribute(
									org.apache.tomcat.InstanceManager.class
											.getName(), new InstanceManager());
							jasperServlet.init(config);
							return null;
						}

					});
		} catch (ServletException e) {
			// re-thrown
			throw e;
			//CHECKSTYLE:OFF
		} catch (Exception ignore) {
			// ignored as it should never happen
			LOG.error("Ignored exception", ignore);
		}
		//CHECKSTYLE:ON
	}
1310651
public static Class<?> loadClass(String classname) {
        Class<?> c = null;

        // First try a simple Class.forName()
        try { c = Class.forName(classname); } catch (ClassNotFoundException e) { }
        // Didn't work?  Try using this class's classloader.
        if (c == null) {
            try { c = ReflectionUtils.class.getClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { }
        }
        // Still didn't work?  Try the thread's context classloader.
        if (c == null) {
            try { c = Thread.currentThread().getContextClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { }
        }

        return c;
    }
1133869
@SuppressWarnings("unchecked")
    public static <E> E getObject(String className) {
        if (className == null) {
            return (E) null;
        }
        try {
            return (E) Class.forName(className).newInstance();
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
791578
@SuppressWarnings("all")
	protected Object newInstance(String className) {
		log.debug("Loading class: {}", className);
		Object instance = null;
		Class<?> clazz = null;
		if ("".equals(className) || className == null)
			return instance;
		try {
			// check for special DS class aliases
			if (className.length() == 3) {
				className = classAliases.get(className);
			}
			if (className.startsWith("flex.")) {
				// Use Red5 compatibility class instead
				className = "org.red5.compatibility." + className;
				log.debug("Modified classname: {}", className);
			}
			if (!classAllowed(className)) {
				log.error("Class creation is not allowed {}", className);
			} else {
				clazz = Thread.currentThread().getContextClassLoader()
						.loadClass(className);
				instance = clazz.newInstance();
			}
		} catch (InstantiationException iex) {
			try {
				// check for default ctor
				clazz.getConstructor(null);
				log.error("Error loading class: {}", className);
			} catch (NoSuchMethodException nse) {
				log.error(
						"Error loading class: {}; this can be resolved by adding a default constructor to your class",
						className);
			}
			log.debug("Exception was: {}", iex);
		} catch (Exception ex) {
			log.error("Error loading class: {}", className);
			log.debug("Exception was: {}", ex);
		}
		return instance;
	}
335060
public void compileAndRun() throws Exception {
		synchronized (this.monitor) {
			try {
				stop();
				Class<?>[] compiledSources = compile();
				monitorForChanges();
				// Run in new thread to ensure that the context classloader is setup
				this.runThread = new RunThread(compiledSources);
				this.runThread.start();
				this.runThread.join();
			}
			catch (Exception ex) {
				if (this.fileWatchThread == null) {
					throw ex;
				}
				else {
					ex.printStackTrace();
				}
			}
		}
	}
905070
public void addException(String className) {
        if (mExceptions == null) {
            addAttribute(new ExceptionsAttr(mCp));
        }

        ConstantClassInfo cci = ConstantClassInfo.make(mCp, className);
        mExceptions.addException(cci);
    }