JDK 11 jdk.attach.jmod - Attach Module

JDK 11 jdk.attach.jmod is the JMOD file for JDK 11 Attach module.

JDK 11 Attach module compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\jdk.attach.jmod.

JDK 11 Attach module compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.

JDK 11 Attach module source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\jdk.attach.

You can click and view the content of each source code file in the list below.

✍: FYIcenter

sun/tools/attach/AttachProviderImpl.java

/*
 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
package sun.tools.attach;

import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
import com.sun.tools.attach.AttachNotSupportedException;

import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class AttachProviderImpl extends HotSpotAttachProvider {

    public AttachProviderImpl() {
        String os = System.getProperty("os.name");
        if (os.startsWith("Windows 9") || os.equals("Windows Me")) {
            throw new RuntimeException(
                "This provider is not supported on this version of Windows");
        }
        String arch = System.getProperty("os.arch");
        if (!arch.equals("x86") && !arch.equals("amd64")) {
            throw new RuntimeException(
                "This provider is not supported on this processor architecture");
        }
    }

    public String name() {
        return "sun";
    }

    public String type() {
        return "windows";
    }

    public VirtualMachine attachVirtualMachine(String vmid)
        throws AttachNotSupportedException, IOException
    {
        checkAttachPermission();

        // AttachNotSupportedException will be thrown if the target VM can be determined
        // to be not attachable.
        testAttachable(vmid);

        return new VirtualMachineImpl(this, vmid);
    }

    public List<VirtualMachineDescriptor> listVirtualMachines() {
        // If the temporary file system is secure then we use the default
        // implementation, otherwise we create a list of Windows processes.
        if (isTempPathSecure()) {
            return super.listVirtualMachines();
        } else {
            return listJavaProcesses();
        }
    }

    /**
     * Returns true if the temporary file system supports security
     */
    private static boolean isTempPathSecure() {
        if (!wasTempPathChecked) {
            synchronized (AttachProviderImpl.class) {
                if (!wasTempPathChecked) {
                    // get the value of TMP/TEMP, ignoring UNC, and paths that
                    // aren't absolute
                    String temp = tempPath();
                    if ((temp != null) && (temp.length() >= 3) &&
                        (temp.charAt(1) == ':') && (temp.charAt(2) == '\\'))
                    {
                        // check if the volume supports security
                        long flags = volumeFlags(temp.substring(0, 3));
                        isTempPathSecure = ((flags & FS_PERSISTENT_ACLS) != 0);
                    }
                    wasTempPathChecked = true;
                }
            }
        }

        return isTempPathSecure;
    }

    // flag to indicate persistent ACLs are supported
    private static final long FS_PERSISTENT_ACLS = 0x8L;

    // indicates if we've checked the temporary file system
    private static volatile boolean wasTempPathChecked;

    // indicates if the temporary file system is secure (only valid when
    // wasTempPathChecked is true)
    private static boolean isTempPathSecure;

    // returns the value of TMP/TEMP
    private static native String tempPath();

    // returns the flags for the given volume
    private static native long volumeFlags(String volume);


    /**
     * Returns a list of virtual machine descriptors derived from an enumeration
     * of the process list.
     */
    private List<VirtualMachineDescriptor> listJavaProcesses() {
        ArrayList<VirtualMachineDescriptor> list =
            new ArrayList<VirtualMachineDescriptor>();

        // Use localhost in the display name
        String host = "localhost";
        try {
            host = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException uhe) {
            // ignore
        }

        // Enumerate all processes.
        // For those processes that have loaded a library named "jvm.dll"
        // then we attempt to attach. If we succeed then we have a 6.0+ VM.
        int processes[] = new int[1024];
        int count = enumProcesses(processes, processes.length);
        for (int i=0; i<count; i++) {
            if (isLibraryLoadedByProcess("jvm.dll", processes[i])) {
                String pid = Integer.toString(processes[i]);
                try {
                    new VirtualMachineImpl(this, pid).detach();

                    // FIXME - for now we don't have an appropriate display
                    // name so we use pid@hostname
                    String name = pid + "@" + host;

                    list.add(new HotSpotVirtualMachineDescriptor(this, pid, name));
                } catch (AttachNotSupportedException x) {
                } catch (IOException ioe) {
                }
            }
        }

        return list;
    }

    // enumerates processes using psapi's EnumProcesses
    private static native int enumProcesses(int[] processes, int max);

    // indicates if a library of a given name has been loaded by a process
    private static native boolean isLibraryLoadedByProcess(String library,
                                                           int processId);


    // native functions in this library
    static {
        System.loadLibrary("attach");
    }

}

sun/tools/attach/AttachProviderImpl.java

 

Or download all of them as a single archive file:

File name: jdk.attach-11.0.1-src.zip
File size: 27192 bytes
Release date: 2018-11-04
Download 

 

JDK 11 jdk.charsets.jmod - Charsets Module

JDK 11 jdk.aot.jmod - AOT Compiler Module

Download and Use JDK 11

⇑⇑ FAQ for JDK (Java Development Kit)

2020-08-13, 7812👍, 0💬