Package javax.tools.diagnostics.runtime.java

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


          }

          if (!(target instanceof JavaClass)) {
            fail("Target object for a CLASS reference not a JavaClass object.");
          }
          JavaClass targetClass = (JavaClass)target;
          assertTrue("Target class for the CLASS reference of this object different from expected.", targetClass.getName().endsWith("SetupJavaReferences"));
          Iterator refs = targetClass.getReferences().iterator();
          boolean classLoaderFound = false;
          while (refs.hasNext()) {
            Object next2 = refs.next();
            if (!(next2 instanceof JavaReference)) {
              continue;
View Full Code Here


   * Get this class directly, and find the method via getDeclaredMethods().iterator();
   *
   * @throws Exception
   */
  public void testGetDeclaredMethods() throws Exception {
    JavaClass thisClass = getScenerioReference().getJavaClass();
   
    assertNotNull("Unable to find this class", thisClass);
   
    Iterator methods = thisClass.getDeclaredMethods().iterator();
    boolean found=false;
    while(methods.hasNext()) {
      JavaMethod method = (JavaMethod) methods.next();
     
      if (method.getName().equals(SetupJavaMethod_getName.methodName)) {
View Full Code Here

     
      //System.out.println("Monitor candidate->"+monitorCandidate.getName());
      JavaObject monitorObjectCandidate = monitorCandidate.getObject();

      if (monitorObjectCandidate != null) {
        JavaClass monitorClass = monitorObjectCandidate.getJavaClass();
        if (!SetupJavaMonitor_ObjectMonitors.monitorClassName.equals(monitorClass.getName())) {
          continue;
        }

        Iterator fields = monitorClass.getDeclaredFields().iterator();

        while (fields.hasNext()) {
          Object next2 = fields.next();

          if (next2 instanceof CorruptData) {
View Full Code Here

        System.err.println("returned CorruptData `" + nextClassloader + "'");
        break;
      }

      JavaClassLoader aJavaClassloader = (JavaClassLoader) nextClassloader;
      JavaClass theJavaClass;
      try {
        JavaObject classLoaderObject = (aJavaClassloader).getObject();
       
        // The system class loader doesn't have an object.
        if (classLoaderObject == null ) {
          continue;
        }
       
        theJavaClass = classLoaderObject.getJavaClass();
        Iterator fields = theJavaClass.getDeclaredFields().iterator();

        while (fields.hasNext()) {
          Object nextField = fields.next();

          if (nextField instanceof CorruptData) {
View Full Code Here

          break;
        }

        JavaObject aJavaObject = (JavaObject) nextObject;
        try {
          JavaClass theJavaClass = aJavaObject.getJavaClass();
          String theClassName = (theJavaClass).getName();
          if (SetupJavaClass_getName.TestObjectClassName.equals(theClassName)) {
            System.out.println("theClassName "+theClassName);
            foundClassName=true;
          }
View Full Code Here

   * because of this interest in very special information.
   * It looks up the PI constant on java.lang.Math and compares it to the running VM's notion of that constant
   */
  public void testJavaStaticFieldDouble()
  {
    JavaClass math = null;
    Iterator loaders = defaultJavaRuntime().getJavaClassLoaders().iterator();
   
    while (loaders.hasNext()) {
      JavaClassLoader loader = (JavaClassLoader) loaders.next();
      try {
        for (Iterator iter = loader.getDefinedClasses().iterator(); iter.hasNext();) {
          JavaClass clazz = (JavaClass) iter.next();
          if (clazz.getName().equals("java/lang/Math")) {
            math = clazz;
            break;
          }
        }
      } catch (CorruptDataException e) {
View Full Code Here

      for (Iterator j = jcl.getDefinedClasses().iterator();j.hasNext();) {
        Object next2 = j.next();
        if (next2 instanceof CorruptData) {
          continue;
        }
        JavaClass j2 = (JavaClass)next2;
        if (j2.equals(j1)) {
          return jcl;
        }
      }
    }
    return load;
View Full Code Here

    }
    staticRuntime = runtime;
   
    JavaObject theJavaObject=null;
    Iterator heaps = runtime.getHeaps().iterator();
    JavaClass theJavaClass = null;
   
    while (heaps.hasNext()) {
      Object nextHeap = heaps.next();
      if (nextHeap instanceof CorruptData) {
        System.err.println("returned CorruptData `" + nextHeap + "'");
        break;
      }

      JavaHeap aJavaHeap = (JavaHeap) nextHeap;
      Iterator objects = aJavaHeap.getObjects().iterator();

      while (objects.hasNext()) {
        Object nextObject = objects.next();
        if (nextObject instanceof CorruptData) {
          System.err.println("returned CorruptData `" + nextObject + "'");
          break;
        }

        JavaObject aJavaObject = (JavaObject) nextObject;
        theJavaClass = aJavaObject.getJavaClass();
        String theClassName = (theJavaClass).getName();
        if (theClassName.equals(SetupJavaObject_arraycopy.TestArraysClassName)){
          theJavaObject = aJavaObject;
          break;
        }

      }
    }

    if (theJavaObject == null) {
      fail("Didn't find TestArrays object");
      return;
    }   

    Iterator fields = theJavaClass.getDeclaredFields().iterator();

    while (fields.hasNext()) {
     
     
      Object nextField = fields.next();

      if (nextField instanceof CorruptData) {
        System.err.println("returned CorruptData `" + nextField + "'");
        break;
      }

      JavaField theField = (JavaField) nextField;
      String theFieldName = theField.getName();

      if(theFieldName.equals("booleanArray")) {
        booleanDumpArray = (JavaObject) theField.get(theJavaObject);       
      } else if(theFieldName.equals("byteArray")) {
        byteDumpArray = (JavaObject) theField.get(theJavaObject);               
      } else if(theFieldName.equals("shortArray")) {
        shortDumpArray = (JavaObject) theField.get(theJavaObject);       
      } else if(theFieldName.equals("charArray")) {
        charDumpArray = (JavaObject) theField.get(theJavaObject);     
      }else if(theFieldName.equals("intArray")) {
        intDumpArray = (JavaObject) theField.get(theJavaObject);       
      } else if(theFieldName.equals("longArray")) {
        longDumpArray = (JavaObject) theField.get(theJavaObject);
      } else if(theFieldName.equals("floatArray")) {
        floatDumpArray = (JavaObject) theField.get(theJavaObject);       
      } else if(theFieldName.equals("doubleArray")) {
        doubleDumpArray = (JavaObject) theField.get(theJavaObject);
      } else if(theFieldName.equals("integerArray")) {
        integerDumpArray = (JavaObject) theField.get(theJavaObject);
      } else if (theFieldName.equals("nonArray")) {
        nonDumpArray = (JavaObject) theField.get(theJavaObject);
      } else if (theFieldName.equals("arrayArray")) {
        arrayDumpArray = (JavaObject) theField.get(theJavaObject);
      }
    }

   
    // Find the JavaField "value" in "java/lang/Integer"
    Iterator classLoaders = getJavaRuntime().getJavaClassLoaders().iterator();
    JavaClass integerClass = null;
   
    CLASSLOADERS:
      while (classLoaders.hasNext()) {
      Object next = classLoaders.next();
     
      if (next instanceof CorruptData) {
        throw new Exception("CorruptData found instead of JavaClassLoader");
      }
     
      JavaClassLoader loader = (JavaClassLoader) next;
     
      Iterator classes = loader.getDefinedClasses().iterator();
     
      while (classes.hasNext()) {
        Object next2 = classes.next();
       
        if (next2 instanceof CorruptData) {
          throw new Exception("CorruptData found instead of JavaClass java.lang.Integer");
        }

        JavaClass aClass = (JavaClass) next2;

        if (aClass.getName().equals("java/lang/Integer")) {
          integerClass = aClass;
          break CLASSLOADERS;
        }
      }
    }
View Full Code Here

    assertEquals(id, instance.getID().getAddress());
  }
 
  public void getComponentType() throws Exception {
    try{
      JavaClass clazz = instance.getComponentType();
     
      fail("Expected IllegalArgumentException from getComponentType(), got " + clazz);
    }catch(IllegalArgumentException e) {
      // Expected
    }
View Full Code Here

    JavaClassLoader loader = defaultJavaClassLoader();
   
    // Choose a class which has a superclass
    try {
      for (Iterator iter = loader.getDefinedClasses().iterator(); iter.hasNext();) {
        JavaClass clazz = (JavaClass) iter.next();
        if ( !clazz.getName().equals("java/lang/Object") &&
             !clazz.getName().equals("boolean"         ) &&
             !clazz.getName().equals("byte"            ) &&           
             !clazz.getName().equals("char"            ) &&   
             !clazz.getName().equals("double"          ) &&   
             !clazz.getName().equals("float"           ) &&   
             !clazz.getName().equals("int"             ) &&   
             !clazz.getName().equals("long"            ) &&   
             !clazz.getName().equals("short"           ) &&   
             !clazz.getName().equals("void"            ) &&   
             !clazz.isArray()                               ) {     
          return clazz;
        }
      }
    } catch (CorruptDataException e) {
      //allowed by the spec
View Full Code Here

TOP

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

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.