private static void setSystemClassLoaderClassPath() throws Exception {
        Log.d("Setting classpath");
        // We use agent class as we do not extract this class in newly created
        // jar (otherwise we may end up creating one -magic jar from another);
        // also it will exist even without JUnit classes).
        URL url = EkstaziAgent.class.getResource(EkstaziAgent.class.getSimpleName() + ".class");
        String origPath = url.getFile().replace("file:", "").replaceAll(".jar!.*", ".jar");
        File junitJar = new File(origPath);
        File xtsJar = new File(origPath.replaceAll(".jar", "-magic.jar"));

        boolean isCreated = false;
        // If extracted (Tool) jar is newer than junit*.jar, there is no reason
        // to extract files again, so just return in that case.
        if (FileUtil.isSecondNewerThanFirst(junitJar, xtsJar)) {
            // We cannot return here, as we have to include jar on the path.
            isCreated = true;
        } else {
            // Extract new jar as junit.jar is newer.
            String[] includePrefixes = { Names.EKSTAZI_PACKAGE_BIN };
            String[] excludePrefixes = { EkstaziAgent.class.getName() };
            isCreated = JarXtractor.extract(junitJar, xtsJar, includePrefixes, excludePrefixes);
        }

        // Add jar to classpath if it was successfully created, otherwise throw
        // an exception.
        if (isCreated) {
            addURL(xtsJar.toURI().toURL());
        } else {
            throw new RuntimeException("Could not extract Tool classes in separate jar.");
        }
    }
private static void setSystemClassLoaderClassPath ( ) throws Exception { Log . d ( "Setting classpath" ) ; URL url = EkstaziAgent . class . getResource ( EkstaziAgent . class . getSimpleName ( ) + ".class" ) ; String origPath = url . getFile ( ) . replace ( "file:" , "" ) . replaceAll ( ".jar!.*" , ".jar" ) ; File junitJar = new File ( origPath ) ; File xtsJar = new File ( origPath . replaceAll ( ".jar" , "-magic.jar" ) ) ; boolean isCreated = false ; if ( FileUtil . isSecondNewerThanFirst ( junitJar , xtsJar ) ) { isCreated = true ; } else { String [ ] includePrefixes = { Names . EKSTAZI_PACKAGE_BIN } ; String [ ] excludePrefixes = { EkstaziAgent . class . getName ( ) } ; isCreated = JarXtractor . extract ( junitJar , xtsJar , includePrefixes , excludePrefixes ) ; } if ( isCreated ) { addURL ( xtsJar . toURI ( ) . toURL ( ) ) ; } else { throw new RuntimeException ( "Could not extract Tool classes in separate jar." ) ; } }
Set paths from the current class loader to the path of system class
loader. This method should be invoked only once.