public static boolean loadEkstaziAgent() {
        // TODO: need to synchronize globally, as we may end up running
        // initialization multiple times, which would lead to:
        // "libattach.so already loaded in another classloader".
        try {
            // Note that this class can be loaded by different classloaders, so
            // we cannot simply use static field to check if the class has been
            // initialized.
            if (System.getProperty(AGENT_LOADER_INIT) != null) {
                return true;
            }
            System.setProperty(AGENT_LOADER_INIT, "");

            URL agentJarURL = Types.extractJarURL(EkstaziAgent.class);
            return loadAgent(agentJarURL);
        } catch (Exception ex) {
            if (System.getProperty("java.version").startsWith("9")) {
                throw new RuntimeException("Running with Java 9 requires -Djdk.attach.allowAttachSelf=true");
            }
            return false;
        }
    }
public static boolean loadEkstaziAgent ( ) { try { if ( System . getProperty ( AGENT_LOADER_INIT ) != null ) { return true ; } System . setProperty ( AGENT_LOADER_INIT , "" ) ; URL agentJarURL = Types . extractJarURL ( EkstaziAgent . class ) ; return loadAgent ( agentJarURL ) ; } catch ( Exception ex ) { if ( System . getProperty ( "java.version" ) . startsWith ( "9" ) ) { throw new RuntimeException ( "Running with Java 9 requires -Djdk.attach.allowAttachSelf=true" ) ; } return false ; } }
Attaches an agent (where this class belongs) to the current
VirtualMachine.

TODO: Can we detect if VirtualMachine is loaded by trying to load it
again.

@return True if the agent is successfully attached, false otherwise.