Package javax.tools.diagnostics.runtime.java

Examples of javax.tools.diagnostics.runtime.java.JavaRuntime


   
    assertEquals("More than 0 monitors returned. There are none.",0,count);
  }

  public void testGetJVM() throws IOException, DataUnavailable, CorruptDataException {
    JavaRuntime runtime=getJavaRuntime();

   
    ImagePointer pointer=(ImagePointer) runtime.getJavaVM();
    assertNotNull(pointer);

  }
View Full Code Here


    assertNotNull(pointer);

  }

  public void testGetVMArguments() throws CorruptDataException, IOException {
    JavaRuntime runtime=getJavaRuntime();
    try {
      runtime.getJavaVMInitArgs();
      fail("expected DataUnavailable exception");
    } catch(DataUnavailable du) {

    }
View Full Code Here

   * If the JavaRuntime object returned by getJavaRuntime() changes,
   * the setup method is run, otherwise it exists early as it will already
   * have run.
   */
  protected void setUp() throws Exception {   
    JavaRuntime runtime=getJavaRuntime();
    // return if JavaRuntime changes. This is unsafe and bad.
    if (runtime.equals(staticRuntime)) {
      return;
    }
    staticRuntime = runtime;
   
    JavaObject theJavaObject=null;
    Iterator heaps = runtime.getHeaps().iterator();
    JavaClass theJavaClass = null;
   
    while (heaps.hasNext()) {
      Object nextHeap = heaps.next();
      if (nextHeap instanceof CorruptData) {
View Full Code Here

  public ImageFactory getFactory() {
    return capabilities.factory;
  }

  public JavaRuntime defaultJavaRuntime() {
    JavaRuntime runtime = null;
    Iterator it = defaultImageProcess().getRuntimes().iterator();
   
    assertFalse(null == it);
    while ((null == runtime) && (it.hasNext())) {
      Object maybeRuntime = it.next();
View Full Code Here

    assertNotNull(runtime);
    return runtime;
  }

  public JavaThread defaultJavaThread() {
    JavaRuntime time = defaultJavaRuntime();
    assertNotNull(time);
    Iterator it = time.getThreads().iterator();
    assertNotNull(it);
    assertTrue(it.hasNext());
    //threads without stack frames aren't very useful for testing so ignore them
    // unless they are the only ones
    JavaThread candidate = null;
View Full Code Here

    }
    return null;
  }

  public JavaHeap defaultJavaHeap() {
    JavaRuntime runtime  = defaultJavaRuntime();
    Iterator it = runtime.getHeaps().iterator();
    assertNotNull(it);
    assertTrue(it.hasNext());
    JavaHeap heap = (JavaHeap) it.next();

    // This should use Middleware Heap as default
View Full Code Here

 
    return thread;
  }

  public JavaMethod defaultJavaMethod() {
    JavaRuntime runtime = defaultJavaRuntime();
    Iterator it = runtime.getCompiledMethods().iterator();
    if (it.hasNext()) {
      return (JavaMethod) it.next();
    } else {
      System.err.println("Warning:  No compiled methods found!  This core must have been without JIT!");
      throw new TestNotImplementedException();
View Full Code Here

   * throw the expected exceptions.
   */
  public void testGetObjectAtAddress()
  {
    JavaHeap heap = defaultJavaHeap();
    JavaRuntime runtime = defaultJavaRuntime();
    ImageAddressSpace addressSpace = defaultAddressSpace();
    ImagePointer address=null;
    ImagePointer unalignedAddress=null;
    Iterator heapSections = heap.getSections().iterator();


    //determine the heap start and end address
    long heapStartAddress = Long.MAX_VALUE;
    long heapEndAddress = 0;

    Object nextElement = null;

    ImageSection currentSection = null;
    long sectionStart = 0;

    while (heapSections.hasNext()) {
      nextElement = heapSections.next();
      if (nextElement instanceof ImageSection) {
        currentSection = (ImageSection) nextElement;
        sectionStart = currentSection.getBaseAddress().getAddress();
        if (sectionStart < heapStartAddress) {
          heapStartAddress = sectionStart;
        }
        if (sectionStart + currentSection.getSize() > heapEndAddress) {
          heapEndAddress = sectionStart + currentSection.getSize();
        }

      }

    }

    //check that every object in the heap can be retrieved by address
    boolean exception=false;
    for (Iterator objects = heap.getObjects().iterator();objects.hasNext();) {
      Object potentialObject = objects.next();
      JavaObject object = null;
      if (potentialObject instanceof JavaObject) {
        object = (JavaObject)potentialObject;
      } else {
        continue;
      }
      address=(ImagePointer)object.getID();
      try {
        runtime.getObjectAtAddress(address).getJavaClass();
        if (unalignedAddress == null) {
          unalignedAddress = address.add(1);
        }
      } catch (Exception e) {
        e.printStackTrace();
        exception=true;
        break;
      }

    }
    assertFalse(exception);


    // Check an address BEFORE the start of the heap. For some JVMs, off-heap objects are supported
    exception=false;
    try {
      long addr1 = ((heapStartAddress-1000) & (Long.MAX_VALUE-7L));
      runtime.getObjectAtAddress(addressSpace.getPointer(addr1));
    } catch (IllegalArgumentException e) {
            e.printStackTrace();
      exception=true;
    } catch (Exception e) {
    }
    assertFalse(exception);

    // Check an address AFTER the first object but not aligned with an object boundary.
    // unalignedAddress is expected to throw a IllegalArgumentException
   
    exception=false;
    try {
      runtime.getObjectAtAddress(unalignedAddress);
    } catch (IllegalArgumentException e) {
    // IllegalArgumentException is the expected behaviour
    } catch (CorruptDataException e) {
      exception=true;
      e.printStackTrace();
View Full Code Here

*/
public class TestJavaHeapRoots  extends TCKJavaRuntimeTestcase {

 
  public void testHeapRoots() {
    JavaRuntime runtime=getJavaRuntime();
   
    List<JavaReference> references=runtime.getHeapRoots();
   
    if(references.isEmpty()) return; // no threads to test
   
    int counter=0;
   
View Full Code Here

public class TestJavaRuntime extends TCKJavaRuntimeTestcase {

 
  public void testCanGetJavaRuntime() {
   
    JavaRuntime runtime=getJavaRuntime();
    assertNotNull(runtime);
   
  }
View Full Code Here

TOP

Related Classes of javax.tools.diagnostics.runtime.java.JavaRuntime

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.