class AgentPremain {

    @SuppressWarnings("return.type.incompatible")
    static File getGlowrootJarFile(CodeSource codeSource) throws Exception {
        if (codeSource == null) {
            if (System.getProperty("glowroot.test.dir") != null) {
                // this is ok, running tests under delegating javaagent
                return null;
            }
            throw new IOException("Could not determine glowroot jar location");
        }
        File codeSourceFile = new File(codeSource.getLocation().toURI());
        if (codeSourceFile.getName().endsWith(".jar")) {
            return codeSourceFile;
        }
        if (System.getProperty("glowroot.test.dir") != null) {
            // this is ok, running tests under delegating javaagent
            return null;
        }
        throw new IOException("Could not determine glowroot jar location");
    }

    private  AgentPremain();

}