Returns the given loader or the sytem classloader if loader is null - Java Reflection

Java examples for Reflection:Class Loader

Description

Returns the given loader or the sytem classloader if loader is null

Demo Code


//package com.java2s;

public class Main {
    /**// ww  w  . j av a  2s  .  c om
     * Returns the given loader or the sytem classloader if loader is null
     * 
     * @param loader
     * @return
     */
    public static ClassLoader getLoaderOrSystemLoader(ClassLoader loader) {
        if (loader != null) {
            return loader;
        } else {
            return ClassLoader.getSystemClassLoader();
        }
    }
}

Related Tutorials