Class JCJavaRuntime

java.lang.Object
com.ibm.dtfj.java.javacore.JCJavaRuntime
All Implemented Interfaces:
JavaRuntime, ManagedRuntime

public class JCJavaRuntime extends Object implements JavaRuntime
A javacore-based implementation of JavaRuntime. This supports partial object creation, meaning that a javaclass, javathread, etc.. can be partially constructed and stored, and at a later time during the javacore parsing, when more information is available, existing javaclasses, javathreads, and so on can be looked up and data added.

However, all partial objects must contain at least one immutable field. See the implementation of each runtime component for more information.

Rudimentary multiplatform support is also added in the form of unique runtime ids that must be passed during construction.
See Also:
  • Constructor Details

  • Method Details

    • getCompiledMethods

      public Iterator getCompiledMethods()
      Description copied from interface: JavaRuntime
      This is short cut method. The same result can be found by iterating over all methods in all class loaders in all classes.
      Specified by:
      getCompiledMethods in interface JavaRuntime
      Returns:
      an iterator over all of the JavaMethods in the JavaRuntime which have been compiled
      See Also:
    • getHeaps

      public Iterator getHeaps()
      Description copied from interface: JavaRuntime
      Get the set of heaps known by the VM
      Specified by:
      getHeaps in interface JavaRuntime
      Returns:
      an iterator for all of the Java heaps within this runtime. Heaps may be specific to this JavaVM instance, or may be shared between multiple JavaVM instances
      See Also:
    • getJavaClassLoaders

      public Iterator getJavaClassLoaders()
      Description copied from interface: JavaRuntime
      Get the set of class loaders active in this VM
      Specified by:
      getJavaClassLoaders in interface JavaRuntime
      Returns:
      an iterator of all of the class loaders within this JavaVM
      See Also:
    • getMonitors

      public Iterator getMonitors()
      Description copied from interface: JavaRuntime
      Provides access to the collection of monitors used in the JavaVM. This collection includes both monitors associated with managed objects (e.g. object monitors) and monitors associated with internal control structures (e.g. raw monitors)
      Specified by:
      getMonitors in interface JavaRuntime
      Returns:
      an iterator over the collection of monitors
      See Also:
    • getThreads

      public Iterator getThreads()
      Description copied from interface: JavaRuntime
      Get the set of Java threads known by the VM
      Specified by:
      getThreads in interface JavaRuntime
      Returns:
      an iterator of the JavaThreads in the runtime
      See Also:
    • getJavaVMInitArgs

      public JavaVMInitArgs getJavaVMInitArgs() throws DataUnavailable, CorruptDataException
      Description copied from interface: JavaRuntime
      Fetch the JavaVMInitArgs which were used to create this VM. See JNI_CreateJavaVM in the JNI Specification for more details.
      Specified by:
      getJavaVMInitArgs in interface JavaRuntime
      Returns:
      the JavaVMInitArgs which were used to create this VM.
      Throws:
      DataUnavailable - if the arguments are not available
      CorruptDataException
      See Also:
    • getJavaVM

      public ImagePointer getJavaVM() throws CorruptDataException
      Description copied from interface: JavaRuntime
      Get the object that represents the virtual machine
      Specified by:
      getJavaVM in interface JavaRuntime
      Returns:
      the address of the JavaVM structure which represents this JVM instance in JNI
      Throws:
      CorruptDataException
      See Also:
    • getTraceBuffer

      public Object getTraceBuffer(String arg0, boolean arg1) throws CorruptDataException
      Description copied from interface: JavaRuntime
      Fetches implementation specific trace buffers, like the verbose GC buffer or the Universal Trace Engine (UTE) buffer
      Specified by:
      getTraceBuffer in interface JavaRuntime
      Parameters:
      arg0 - a String naming the buffer to be fetched
      arg1 - true if formatting should be performed on the buffer, or false if the raw buffer contents should be returned
      Returns:
      an implementation specific result, depending on the parameters
      Throws:
      CorruptDataException
      See Also:
      • invalid reference
        com.ibm.dtfj.java.JavaRuntime#getTraceBuffer()
    • getFullVersion

      public String getFullVersion() throws CorruptDataException
      Description copied from interface: ManagedRuntime
      Get the 'full' version information for this runtime.
      Specified by:
      getFullVersion in interface ManagedRuntime
      Returns:
      a string representation of the version information for this runtime instance
      Throws:
      CorruptDataException - If the runtime presents no understandable version data
      See Also:
    • getVersion

      public String getVersion() throws CorruptDataException
      Description copied from interface: ManagedRuntime
      Get the version data available for this runtime instance.
      Specified by:
      getVersion in interface ManagedRuntime
      Returns:
      a string representing all the version data available for this runtime instance.
      Throws:
      CorruptDataException - If the runtime presents no understandable version data
      See Also:
    • getInternalID

      public String getInternalID()
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      May be used in multiple runtime environments, where each runtime in a javacore is identified uniquely. This method is generally just used during the building process only.
    • addJavaClassLoader

      public void addJavaClassLoader(JCJavaClassLoader javaClassLoader) throws JCInvalidArgumentsException
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      javaClassLoader -
    • findJavaClassLoader

      public JCJavaClassLoader findJavaClassLoader(long clLoaderID)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      javaClassLoaderName -
      Returns:
      javaclassloader if found or null
    • addMonitor

      public void addMonitor(JCJavaMonitor monitor) throws JCInvalidArgumentsException
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      monitor - must not be null
    • findMonitor

      public JCJavaMonitor findMonitor(long id)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      id -
      Returns:
      found java monitor or null
    • addJavaThread

      public void addJavaThread(JCJavaThread javaThread) throws JCInvalidArgumentsException
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      javaThread - must not be null.
    • findJavaThread

      public JCJavaThread findJavaThread(long threadID)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      In most cases, the threadID is the tid in a javacore, but in some other occasions, the id passed could be the system_thread_id or even the native thread. If a java thread is not found via tid, see if it can be found indirectly by an image thread that may be associated with the java thread (the image thread has a system thread ID as well as a native thread ID).
      Parameters:
      threadID - usually, tid in a javacore, may be id of some other internal vm datastructure.
      Returns:
      found java thread or null.
    • getImageProcess

      public JCImageProcess getImageProcess()
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Returns:
      image process containing this java runtime. This should never be null.
    • addJavaClass

      public void addJavaClass(JCJavaClass javaClass) throws JCInvalidArgumentsException
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Two separate maps are kept for classes. One based on class ID, the other based on class name. Both are used for lookups while building the runtime object. When a valid javaclass is added, it gets added at least the name-based map, and may be added to the ID-based map if the ID is available. The class name of the java class is a requirement, so this field must be set in the java class being passed.
      Parameters:
      javaClass - must not be null or exception thrown
    • findJavaClass

      public JCJavaClass findJavaClass(String javaClassName)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.
      Parameters:
      javaClassName -
      Returns:
      found class or null if not found
    • findJavaClass

      public JCJavaClass findJavaClass(long id)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      In some cases, all that is available is a class ID, so it should be possible to retrieve a class based on just an ID.
      Parameters:
      id - class address
      Returns:
      found class or null if not found
    • addJavaVMInitArgs

      public void addJavaVMInitArgs(JCJavaVMInitArgs args) throws JCInvalidArgumentsException
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      args - , must not be null
    • getHeapRoots

      public Iterator getHeapRoots()
      Description copied from interface: JavaRuntime
      Get the set of object and class roots known to the VM. Stack frame roots are not included in the set, they can be retrieved using JavaStackFrame.getHeapRoots().
      Specified by:
      getHeapRoots in interface JavaRuntime
      Returns:
      an iterator over the collection of JavaReferences representing the known global heap roots within this runtime.
      See Also:
    • getObjectAtAddress

      public JavaObject getObjectAtAddress(ImagePointer address) throws DataUnavailable
      Description copied from interface: JavaRuntime
      Gets the object located at address address in the heap.
      Specified by:
      getObjectAtAddress in interface JavaRuntime
      Parameters:
      address - the ImagePointer instance representing the start address of object in the heap;
      Returns:
      the JavaObject instance representing the located object.
      Throws:
      DataUnavailable - if any data needed to build the returned instance of JavaObject is not available.
      See Also:
    • setVersion

      public void setVersion(String version)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      args - , the version string
    • getMemoryCategories

      public Iterator getMemoryCategories() throws DataUnavailable
      Description copied from interface: JavaRuntime
      Returns iterator of the top-level memory categories used by this Java runtime.
      Specified by:
      getMemoryCategories in interface JavaRuntime
      Returns:
      Iterator of memory categories
      Throws:
      DataUnavailable
      See Also:
    • getMemorySections

      public Iterator getMemorySections(boolean includeFreed) throws DataUnavailable
      Description copied from interface: JavaRuntime
      Returns an iterator of JavaRuntimeMemorySection objects corresponding to the blocks of memory allocated by the JavaRuntime.
      Specified by:
      getMemorySections in interface JavaRuntime
      Parameters:
      includeFreed - If true, iterator will iterate over blocks of memory that have been freed, but haven't been re-used yet.
      Returns:
      Iterator of memory sections.
      Throws:
      DataUnavailable
      See Also:
    • addTopLevelMemoryCategory

      public void addTopLevelMemoryCategory(JCJavaRuntimeMemoryCategory category)
    • isJITEnabled

      public boolean isJITEnabled() throws DataUnavailable, CorruptDataException
      Description copied from interface: JavaRuntime
      Determine if the JIT was enabled for this Java runtime.
      Specified by:
      isJITEnabled in interface JavaRuntime
      Returns:
      true if the JIT was enabled, false if not
      Throws:
      DataUnavailable - if it is not possible to determine the JIT status
      CorruptDataException
    • setJITEnabled

      public void setJITEnabled(boolean enabled)
    • addJITProperty

      public void addJITProperty(String name, String value)
    • getJITProperties

      public Properties getJITProperties() throws DataUnavailable, CorruptDataException
      Description copied from interface: JavaRuntime
      Get any vendor specific properties in use by the JIT for this Java runtime
      Specified by:
      getJITProperties in interface JavaRuntime
      Returns:
      the set of properties, which may be empty if none were set.
      Throws:
      DataUnavailable - if the JIT was not enabled for this runtime
      CorruptDataException
    • getStartTime

      public long getStartTime() throws DataUnavailable, CorruptDataException
      Description copied from interface: JavaRuntime
      Get the time when the JVM was started.
      Specified by:
      getStartTime in interface JavaRuntime
      Returns:
      the time the JVM was started, in milliseconds since 1970
      Throws:
      DataUnavailable - if the JVM start time is not available
      CorruptDataException - if the JVM start time is corrupted
    • getStartTimeNanos

      public long getStartTimeNanos() throws DataUnavailable, CorruptDataException
      Description copied from interface: JavaRuntime
      Get the value of the JVM's high-resolution timer when the JVM was started.
      Specified by:
      getStartTimeNanos in interface JavaRuntime
      Returns:
      the value of the high-resolution timer when the JVM was started, in nanoseconds
      Throws:
      DataUnavailable - if the JVM start time is not available
      CorruptDataException - if the JVM start time is corrupted
    • setStartTime

      public void setStartTime(long startTime)
    • setStartTimeNanos

      public void setStartTimeNanos(long nanoTime)