Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

In this page you can find the example usage for java.lang ClassNotFoundException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.fop.fonts.FontCache.java

/**
 * Reads a font cache file and returns its contents.
 *
 * @param cacheFile//from w  ww  .  ja  v a2 s.co  m
 *            the cache file
 * @return the font cache deserialized from the file (or null if no cache
 *         file exists or if it could not be read)
 */
public static FontCache loadFrom(File cacheFile) {
    if (cacheFile.exists()) {
        try {
            if (log.isTraceEnabled()) {
                log.trace("Loading font cache from " + cacheFile.getCanonicalPath());
            }
            InputStream in = new BufferedInputStream(new FileInputStream(cacheFile));
            ObjectInputStream oin = new ObjectInputStream(in);
            try {
                return (FontCache) oin.readObject();
            } finally {
                IOUtils.closeQuietly(oin);
            }
        } catch (ClassNotFoundException e) {
            // We don't really care about the exception since it's just a
            // cache file
            log.warn("Could not read font cache. Discarding font cache file. Reason: " + e.getMessage());
        } catch (IOException ioe) {
            // We don't really care about the exception since it's just a
            // cache file
            log.warn("I/O exception while reading font cache (" + ioe.getMessage()
                    + "). Discarding font cache file.");
            try {
                cacheFile.delete();
            } catch (SecurityException ex) {
                log.warn("Failed to delete font cache file: " + cacheFile.getAbsolutePath());
            }
        }
    }
    return null;
}

From source file:Browser.java

/**
 * Called by a static initializer to load any classes, fields, and methods 
 * required at runtime to locate the user's web browser.
 * @return <code>true</code> if all intialization succeeded
 *         <code>false</code> if any portion of the initialization failed
 *//*  w  ww.  jav  a2 s .c o  m*/
private static boolean loadClasses() {
    switch (jvm) {
    case MRJ_2_0:
        try {
            Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
            Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
            Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
            Class aeClass = Class.forName("com.apple.MacOS.ae");
            aeDescClass = Class.forName("com.apple.MacOS.AEDesc");

            aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { int.class });
            appleEventConstructor = appleEventClass.getDeclaredConstructor(
                    new Class[] { int.class, int.class, aeTargetClass, int.class, int.class });
            aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class });

            makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[] { String.class });
            putParameter = appleEventClass.getDeclaredMethod("putParameter",
                    new Class[] { int.class, aeDescClass });
            sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] {});

            Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject");
            keyDirectObject = (Integer) keyDirectObjectField.get(null);
            Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID");
            kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null);
            Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID");
            kAnyTransactionID = (Integer) anyTransactionIDField.get(null);
        } catch (ClassNotFoundException cnfe) {
            errorMessage = cnfe.getMessage();
            return false;
        } catch (NoSuchMethodException nsme) {
            errorMessage = nsme.getMessage();
            return false;
        } catch (NoSuchFieldException nsfe) {
            errorMessage = nsfe.getMessage();
            return false;
        } catch (IllegalAccessException iae) {
            errorMessage = iae.getMessage();
            return false;
        }
        break;

    case MRJ_2_1:
        try {
            mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
            mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType");
            Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType");
            kSystemFolderType = systemFolderField.get(null);
            findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass });
            getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class });
            getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class });
        } catch (ClassNotFoundException cnfe) {
            errorMessage = cnfe.getMessage();
            return false;
        } catch (NoSuchFieldException nsfe) {
            errorMessage = nsfe.getMessage();
            return false;
        } catch (NoSuchMethodException nsme) {
            errorMessage = nsme.getMessage();
            return false;
        } catch (SecurityException se) {
            errorMessage = se.getMessage();
            return false;
        } catch (IllegalAccessException iae) {
            errorMessage = iae.getMessage();
            return false;
        }
        break;

    case MRJ_3_0:
        try {
            Class linker = Class.forName("com.apple.mrj.jdirect.Linker");
            Constructor constructor = linker.getConstructor(new Class[] { Class.class });
            linkage = constructor.newInstance(new Object[] { Browser.class });
        } catch (ClassNotFoundException cnfe) {
            errorMessage = cnfe.getMessage();
            return false;
        } catch (NoSuchMethodException nsme) {
            errorMessage = nsme.getMessage();
            return false;
        } catch (InvocationTargetException ite) {
            errorMessage = ite.getMessage();
            return false;
        } catch (InstantiationException ie) {
            errorMessage = ie.getMessage();
            return false;
        } catch (IllegalAccessException iae) {
            errorMessage = iae.getMessage();
            return false;
        }
        break;

    case MRJ_3_1:
        try {
            mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
            openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class });
        } catch (ClassNotFoundException cnfe) {
            errorMessage = cnfe.getMessage();
            return false;
        } catch (NoSuchMethodException nsme) {
            errorMessage = nsme.getMessage();
            return false;
        }
        break;

    default:
        break;
    }
    return true;
}

From source file:fxts.stations.util.BrowserLauncher.java

/**
 * Called by a static initializer to load any classes, fields, and methods required at runtime
 * to locate the user's web browser.//from  ww w .  j  a  v a2 s.c o  m
 *
 * @return <code>true</code> if all intialization succeeded
 *         <code>false</code> if any portion of the initialization failed
 */
private static boolean loadClasses() {
    switch (jvm) {
    case MRJ_2_0:
        try {
            Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
            Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
            Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
            Class aeClass = Class.forName("com.apple.MacOS.ae");
            aeDescClass = Class.forName("com.apple.MacOS.AEDesc");
            aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { int.class });
            appleEventConstructor = appleEventClass.getDeclaredConstructor(
                    new Class[] { int.class, int.class, aeTargetClass, int.class, int.class });
            aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class });
            makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[] { String.class });
            putParameter = appleEventClass.getDeclaredMethod("putParameter",
                    new Class[] { int.class, aeDescClass });
            sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] {});
            Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject");
            keyDirectObject = (Integer) keyDirectObjectField.get(null);
            Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID");
            kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null);
            Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID");
            kAnyTransactionID = (Integer) anyTransactionIDField.get(null);
        } catch (ClassNotFoundException cnfe) {
            errorMessage = cnfe.getMessage();
            return false;
        } catch (NoSuchMethodException nsme) {
            errorMessage = nsme.getMessage();
            return false;
        } catch (NoSuchFieldException nsfe) {
            errorMessage = nsfe.getMessage();
            return false;
        } catch (IllegalAccessException iae) {
            errorMessage = iae.getMessage();
            return false;
        }
        break;
    case MRJ_2_1:
        try {
            mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
            mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType");
            Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType");
            kSystemFolderType = systemFolderField.get(null);
            findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass });
            getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class });
            getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class });
        } catch (ClassNotFoundException cnfe) {
            errorMessage = cnfe.getMessage();
            return false;
        } catch (NoSuchFieldException nsfe) {
            errorMessage = nsfe.getMessage();
            return false;
        } catch (NoSuchMethodException nsme) {
            errorMessage = nsme.getMessage();
            return false;
        } catch (SecurityException se) {
            errorMessage = se.getMessage();
            return false;
        } catch (IllegalAccessException iae) {
            errorMessage = iae.getMessage();
            return false;
        }
        break;
    case MRJ_3_0:
        try {
            Class linker = Class.forName("com.apple.mrj.jdirect.Linker");
            Constructor constructor = linker.getConstructor(new Class[] { Class.class });
            linkage = constructor.newInstance(new Object[] { BrowserLauncher.class });
        } catch (ClassNotFoundException cnfe) {
            errorMessage = cnfe.getMessage();
            return false;
        } catch (NoSuchMethodException nsme) {
            errorMessage = nsme.getMessage();
            return false;
        } catch (InvocationTargetException ite) {
            errorMessage = ite.getMessage();
            return false;
        } catch (InstantiationException ie) {
            errorMessage = ie.getMessage();
            return false;
        } catch (IllegalAccessException iae) {
            errorMessage = iae.getMessage();
            return false;
        }
        break;
    case MRJ_3_1:
        try {
            mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils");
            openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class });
        } catch (ClassNotFoundException cnfe) {
            errorMessage = cnfe.getMessage();
            return false;
        } catch (NoSuchMethodException nsme) {
            errorMessage = nsme.getMessage();
            return false;
        }
        break;
    default:
        break;
    }
    return true;
}

From source file:com.google.code.ddom.commons.cl.ClassLoaderLocal.java

private static Map<ClassLoaderLocal<?>, Object> getClassLoaderLocalMap(ClassLoader cl) {
    if (cl == ClassLoaderLocal.class.getClassLoader()) {
        return ClassLoaderLocalMapHolder.locals;
    } else {/* ww w .j  a va  2 s . c o  m*/
        Class<?> holderClass;
        try {
            holderClass = cl.loadClass(holderClassName);
            if (holderClass.getClassLoader() != cl) {
                holderClass = null;
            }
        } catch (ClassNotFoundException ex) {
            holderClass = null;
        }
        if (holderClass == null) {
            try {
                holderClass = (Class<?>) defineClassMethod.invoke(cl, holderClassName, holderClassDef, 0,
                        holderClassDef.length);
            } catch (Exception ex) {
                // TODO: can we get here? maybe if two threads call getClassLoaderLocalMap concurrently?
                throw new Error(ex);
            }
        }
        Field field;
        try {
            field = holderClass.getDeclaredField("locals");
        } catch (NoSuchFieldException ex) {
            throw new NoSuchFieldError(ex.getMessage());
        }
        try {
            return (Map<ClassLoaderLocal<?>, Object>) field.get(0);
        } catch (IllegalAccessException ex) {
            throw new Error(ex);
        }
    }
}

From source file:org.colombbus.tangara.Main.java

/**
 * Creates the GUI and shows it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *///  www  .j  a v a  2s .c  o m
private static void createAndShowGUI() {
    Class<?> typeClass = Program.class;
    try {
        try {
            String lang = Configuration.instance().getLanguage();
            String className = "org.colombbus.tangara." + lang + ".Program_" + lang;
            typeClass = Class.forName(className);
        } catch (ClassNotFoundException e) {
            // If the class in this language doesn't exist, we load the
            // English version of Program.
            typeClass = Class.forName("org.colombbus.tangara.en.Program_en");
        }
        Program.INSTANCE = (Program) typeClass.newInstance();
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        exit();
    }

    // Forces the program initialization for error and output stream
    // initalization
    Program.init();
    LOG.info("Application starting..."); //$NON-NLS-1$
    // Try to set the System Look&Feel
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        LOG.error("Unable to load native look and feel"); //$NON-NLS-1$
    }
    Configuration conf = Configuration.instance();
    // binds the system program
    Program programme = Program.instance();
    programme.setHistoryDepth(conf.getHistoryDepth());
    programme.setCurrentDirectory(conf.getUserHome());

    // bean permits to translate to Program the commands in the chosen
    // language.
    String beanName = Messages.getString("Main.bean.program");
    try {
        // We declare the bean for Program.
        Configuration.instance().getManager().declareBean(beanName, programme, typeClass);
    } catch (BSFException e) {
        LOG.error(e.getMessage(), e);
        exit();
    }

    Class<?> tools = Program.instance().getTranslatedClassForName("Tools");
    try {
        Tools a = (Tools) tools.newInstance();
        String toolsName = Messages.getString("Main.bean.tools");
        Configuration.instance().getManager().declareBean(toolsName, a, tools);
    } catch (Exception e) {
        LOG.error("Error while casting tools " + e);
    }

    // -------------------------------------------------------------------------------------------

    // In normal execution of Tangara, we use an EditorFrame
    // In jar file mode we use a ProgramFrame
    // programMode is false for normal mode
    if (!programMode) {
        // Creates the frame
        frame = new EditorFrame(conf, helpEngine);
        programme.setFrame(frame);
        // binds the game area and sets in which language will be the
        // GraphicsPane
        GraphicsPane graphicsPane = frame.getGraphicsPane();
        graphicsPane.declareBeanForTheScreen();

        // sets the shell for Program
        programme.setBSFEngine(conf.getEngine());

        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                // allows to divide the main panel and makes the GUI ready
                frame.afterInit();
            }
        });
        checkForUpdate();

    } else { // .jar file mode
        frame = new FileOpenFrame();
        programme.setFrame(frame);

        // bind the game area
        GraphicsPane graphicsPane = frame.getGraphicsPane();
        graphicsPane.declareBeanForTheScreen();

        // sets the shell for Program and sets in which language will be the
        // GraphicsPane
        programme.setBSFEngine(conf.getEngine());

        executeProgram();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                // allows to divide the main panel and makes the GUI ready
                frame.afterInit();
            }
        });
    }
}

From source file:com.flexive.shared.EJBLookup.java

private static Context getOpenEJBRootContext() {
    // use reflection to return OpenEJB's system context to enable access to the configured datasource
    // in every bean - the standard OpenEJB context leads to quirky workarounds for the datasources
    try {/*from w w  w  .ja v  a  2s.co m*/
        final Class<?> clsSystem = Class.forName("org.apache.openejb.loader.SystemInstance");

        // invoke static method SystemInstance.get()
        final Object systemInstance = clsSystem.getMethod("get").invoke(null);

        // invoke getComponent on systemInstance
        final Class<?> clsContainer = Class.forName("org.apache.openejb.spi.ContainerSystem");
        final Object containerSystem = clsSystem.getMethod("getComponent", Class.class).invoke(systemInstance,
                clsContainer);

        // return system JNDI context - containerSystem.getJNDIContext()
        return (Context) clsContainer.getMethod("getJNDIContext").invoke(containerSystem);
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(
                "Lookup strategy is OpenEJB, but OpenEJB classes missing: " + e.getMessage(), e);
    } catch (Exception e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}

From source file:org.apache.hadoop.hive.ql.util.UpgradeTool.java

private static boolean isAcidInputOutputFormat(String fullTableName, StorageDescriptor sd) {
    try {/*  ww  w. j a  v a2s.co m*/
        Class inputFormatClass = sd.getInputFormat() == null ? null : Class.forName(sd.getInputFormat());
        Class outputFormatClass = sd.getOutputFormat() == null ? null : Class.forName(sd.getOutputFormat());

        if (inputFormatClass != null && outputFormatClass != null
                && Class.forName("org.apache.hadoop.hive.ql.io.AcidInputFormat")
                        .isAssignableFrom(inputFormatClass)
                && Class.forName("org.apache.hadoop.hive.ql.io.AcidOutputFormat")
                        .isAssignableFrom(outputFormatClass)) {
            return true;
        }
    } catch (ClassNotFoundException e) {
        //if a table is using some custom I/O format and it's not in the classpath, we won't mark
        //the table for Acid, but today (Hive 3.1 and earlier) OrcInput/OutputFormat is the only
        //Acid format
        LOG.error("Could not determine if " + fullTableName + " can be made Acid due to: " + e.getMessage(), e);
        return false;
    }
    return false;
}

From source file:framework.GlobalHelpers.java

public static Action findAction(String className, String action) {
    if (Config.isInProductionMode()) {
        return findActionOnProduction(className, action);
    } else {//from w w w  .ja v  a  2  s.co m
        try {
            Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
            Method[] methods = clazz.getMethods();
            Method actionMethod = null;
            for (Method method : methods) {
                if (method.getName().equals(action)) {
                    actionMethod = method;
                }
            }
            if (actionMethod != null) {
                Action instance = new Action(action, getControllerInstance(clazz), actionMethod);
                return instance;
            } else {
                return null;
            }
        } catch (ClassNotFoundException e) {
            return null;
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
}

From source file:info.guardianproject.netcipher.web.WebkitProxy.java

@TargetApi(19)
private static boolean setKitKatProxy(String appClass, Context appContext, String host, int port) {
    //Context appContext = webView.getContext().getApplicationContext();

    if (host != null) {
        System.setProperty("http.proxyHost", host);
        System.setProperty("http.proxyPort", port + "");
        System.setProperty("https.proxyHost", host);
        System.setProperty("https.proxyPort", port + "");
    }/*from  w  ww.  j a va2 s  . co m*/

    try {
        Class applictionCls = Class.forName(appClass);
        Field loadedApkField = applictionCls.getField("mLoadedApk");
        loadedApkField.setAccessible(true);
        Object loadedApk = loadedApkField.get(appContext);
        Class loadedApkCls = Class.forName("android.app.LoadedApk");
        Field receiversField = loadedApkCls.getDeclaredField("mReceivers");
        receiversField.setAccessible(true);
        ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk);
        for (Object receiverMap : receivers.values()) {
            for (Object rec : ((ArrayMap) receiverMap).keySet()) {
                Class clazz = rec.getClass();
                if (clazz.getName().contains("ProxyChangeListener")) {
                    Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
                    Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);

                    if (host != null) {
                        /*********** optional, may be need in future *************/
                        final String CLASS_NAME = "android.net.ProxyProperties";
                        Class cls = Class.forName(CLASS_NAME);
                        Constructor constructor = cls.getConstructor(String.class, Integer.TYPE, String.class);
                        constructor.setAccessible(true);
                        Object proxyProperties = constructor.newInstance(host, port, null);
                        intent.putExtra("proxy", (Parcelable) proxyProperties);
                        /*********** optional, may be need in future *************/
                    }

                    onReceiveMethod.invoke(rec, appContext, intent);
                }
            }
        }
        return true;
    } catch (ClassNotFoundException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (NoSuchFieldException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (IllegalAccessException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (IllegalArgumentException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (NoSuchMethodException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (InvocationTargetException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (InstantiationException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    }
    return false;
}

From source file:info.guardianproject.netcipher.webkit.WebkitProxy.java

@TargetApi(19)
private static boolean setKitKatProxy(String appClass, Context appContext, String host, int port) {
    //Context appContext = webView.getContext().getApplicationContext();

    if (host != null) {
        System.setProperty("http.proxyHost", host);
        System.setProperty("http.proxyPort", Integer.toString(port));
        System.setProperty("https.proxyHost", host);
        System.setProperty("https.proxyPort", Integer.toString(port));
    }/*from  w w w  .  j  a  v  a  2  s  . co  m*/

    try {
        Class applictionCls = Class.forName(appClass);
        Field loadedApkField = applictionCls.getField("mLoadedApk");
        loadedApkField.setAccessible(true);
        Object loadedApk = loadedApkField.get(appContext);
        Class loadedApkCls = Class.forName("android.app.LoadedApk");
        Field receiversField = loadedApkCls.getDeclaredField("mReceivers");
        receiversField.setAccessible(true);
        ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk);
        for (Object receiverMap : receivers.values()) {
            for (Object rec : ((ArrayMap) receiverMap).keySet()) {
                Class clazz = rec.getClass();
                if (clazz.getName().contains("ProxyChangeListener")) {
                    Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
                    Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);

                    if (host != null) {
                        /*********** optional, may be need in future *************/
                        final String CLASS_NAME = "android.net.ProxyProperties";
                        Class cls = Class.forName(CLASS_NAME);
                        Constructor constructor = cls.getConstructor(String.class, Integer.TYPE, String.class);
                        constructor.setAccessible(true);
                        Object proxyProperties = constructor.newInstance(host, port, null);
                        intent.putExtra("proxy", (Parcelable) proxyProperties);
                        /*********** optional, may be need in future *************/
                    }

                    onReceiveMethod.invoke(rec, appContext, intent);
                }
            }
        }
        return true;
    } catch (ClassNotFoundException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (NoSuchFieldException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (IllegalAccessException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (IllegalArgumentException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (NoSuchMethodException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (InvocationTargetException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    } catch (InstantiationException e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String exceptionAsString = sw.toString();
        Log.v(TAG, e.getMessage());
        Log.v(TAG, exceptionAsString);
    }
    return false;
}