Package javax.tools.diagnostics.runtime.java

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


   
      List<JavaVariable> variables=m.getVariables();
      assertNotNull("Entry "+counter+":variables list is null",variables);
     
      try {
        JavaClass clazz=m.getDeclaringClass();
        assertNotNull("Entry "+counter+":declaring class is null - DataUnavailable should have been thrown instead",clazz);
      } catch (CorruptDataException e) {
        // allowed
      } catch (DataUnavailable e) {
        // allowed
View Full Code Here


  {
    try {
      JavaObject object = _testClass.getObject();
      assertNotNull(object);
      /* validate that the object is an instance of java/lang/Class */
      JavaClass javaLangClass = object.getJavaClass();
      assertNotNull(javaLangClass);
      assertEquals(javaLangClass.getName(), "java/lang/Class");
     
    } catch (CorruptDataException e) {
      //allowed by the spec
    } catch (Exception e) {
      //if we caught anything else, this is an error
View Full Code Here

   * Test method for 'javax.tools.diagnostics.runtime.java.JavaClass.getSuperclass()'
   */
  public void testGetSuperclass()
  {
    try {
      JavaClass superClass = _testClass.getSuperclass();
      assertNotNull(superClass);
    } catch (CorruptDataException e) {
      //allowed by the spec
    } catch (Exception e) {
      //if we caught anything else, this is an error
View Full Code Here

   *
   * Ensures that we get a non-null component type which has a non-null, non-empty length
   */
  public void testGetComponentType()
  {
    JavaClass arrayClass = null;
    JavaClass component = null;
    try {
      arrayClass = _arrayInstance.getJavaClass();
      component = arrayClass.getComponentType();
    } catch (CorruptDataException e) {
      //allowed by the spec
    }
    assertNotNull(component);
    String name=null;
    try {
      name = component.getName();
    } catch (CorruptDataException e) {
    }
    assertNotNull(name);
    assertTrue(name.length() > 0);
   
View Full Code Here

        Object instance = references.next();
        assertTrue((instance instanceof JavaObject) || (instance instanceof CorruptData));
        if (instance instanceof JavaObject) {
          // ensure that these are valid objects by reading the class
          JavaObject object = (JavaObject)instance;
          JavaClass clazz = object.getJavaClass();
          assertNotNull(clazz);
        }
      }
    } catch (Exception e) {
      //if we caught anything else, this is an error
View Full Code Here

  {
    try {
      //search all the loaders for a class which we know we had in the address space
      String candidateClass = this.getClass().getName()+"$Sub";
      candidateClass = candidateClass.replace('.', '/');
      JavaClass subclass = _findClassForName(candidateClass);
      if (null == subclass) {
        //not finding this testing class makes this test useless
        //note that this can also happen if we are working with a corrupt core file
        throw new TestNotImplementedException();
      }
      JavaClass superclass = null;
      try {
        superclass = subclass.getSuperclass();
      } catch (CorruptDataException e) {
        //even though this would be valid, it isn't helpful for our case
        throw new TestNotImplementedException();
      }
      if (null == superclass) {
        //not finding this testing class makes this test useless
        throw new TestNotImplementedException();
      }
      //now make sure that none of the fields in subclass are in superclass
      Iterator subfields = subclass.getDeclaredFields().iterator();
      while (subfields.hasNext()) {
        Object subtest = subfields.next();
        Iterator superfields = superclass.getDeclaredFields().iterator();
       
        while (superfields.hasNext()) {
          Object supertest = superfields.next();
          assertFalse(supertest.equals(subtest));
        }
View Full Code Here

  }

  private void subTestGetJavaClass(int counter, int objcounter,
      JavaObject object) {
    try {
      JavaClass clazz=object.getJavaClass();
      assertNotNull("Entry "+counter+"/"+objcounter+" getJavaClass is null",clazz);
    } catch (CorruptDataException e3) {
      // allowed
    }
  }
View Full Code Here

  }

  private JavaClass _findClassForName(String candidateClass)
  {
    Iterator allLoaders = defaultJavaRuntime().getJavaClassLoaders().iterator();
    JavaClass subclass = null;
    while (allLoaders.hasNext() && (null == subclass)) {
      JavaClassLoader loader = (JavaClassLoader) allLoaders.next();
      Iterator classes = loader.getDefinedClasses().iterator();
      while (classes.hasNext()  && (null == subclass)) {
        JavaClass oneClass = (JavaClass) classes.next();
        try {
          if (oneClass.getName().equals(candidateClass)) {
            subclass = oneClass;
            break;
          }
        } catch (CorruptDataException e) {
          //even though this would be valid, it isn't helpful for our case
View Full Code Here

   */
  public void testArraylets()
  {
    String staticSizeName = "DTFJ_ARRAYLET_LENGTH";
    String staticName = "DTFJ_ARRAYLET_TEST_INSTANCE";
    JavaClass candidateClass = _findClassForName("org/apache/kato/tests/scenarios/ArrayletTest");
   
    if (null != candidateClass) {
      int size = 0;
      JavaObject container = null;
      Iterator fields = candidateClass.getDeclaredFields().iterator();
     
      try {
        while (fields.hasNext()) {
          JavaField field = (JavaField) fields.next();
          String fieldName = field.getName();
         
          if (fieldName.equals(staticSizeName)) {
            size = field.getInt(null);
          } else  if (fieldName.equals(staticName)) {
            container = (JavaObject) field.get(null);
          }
        }
        //now ensure that we actually have something to test with
        if ((0 != size) && (null != container)) {
          //now, pull apart the fields of the container
          JavaClass containerClass = container.getJavaClass();
          Iterator theseFields = containerClass.getDeclaredFields().iterator();
          while (theseFields.hasNext()) {
            JavaField oneField = (JavaField) theseFields.next();
            if (oneField.getName().equals("DTFJ_ARRAYLET_INTS")) {
              //run the int test
              JavaObject array = (JavaObject) oneField.get(container);
View Full Code Here

   *
   * Ensures that we get a class which has a name (that should imply that it is sane)
   */
  public void testGetJavaClass()
  {
    JavaClass theClass = null;
    try {
      theClass = _object.getJavaClass();
    } catch (CorruptDataException e) {
    }
    assertNotNull(theClass);
    try {
      assertNotNull(theClass.getName());
    } catch (CorruptDataException e) {
      //this would be wrong since we are supposed to get a sane object back
      assertTrue(false);
    }
  }
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.