Package org.jboss.profiler.jvmti

Examples of org.jboss.profiler.jvmti.ReferenceDataPoint


    jvmti.notifyOnReferences("/tmp/tst.refs",new JVMTICallBack(){

      int count=0;
      public void notifyReference(long referenceHolder, long referencedObject,long classTag, long index, long method, byte referenceType)
      {
        list.add(new ReferenceDataPoint(referenceHolder, referencedObject,classTag, index, method, referenceType));
      }
      public void notifyClass(long classTag, Class clazz) {
        fail("This shouldn't be called now");
      }
      public void notifyObject(long classTag, long objectId, long bytes) {
        fail("This shouldn't be called now");
      }
    });
   
    long tag = jvmti.getTagOnObject(a);
    Object newObject = jvmti.getObjectOnTag(tag);
    assertSame(a,newObject);
   
    int count=0;
    Iterator iter = list.iterator();
    while (iter.hasNext())
    {
      ReferenceDataPoint point = (ReferenceDataPoint)iter.next();
      //System.out.println("point=" + point);
      if (point.getClassTag()!=0 )
      {
        Object obj = jvmti.getObjectOnTag(point.getClassTag());
        if (!(obj instanceof Class))
        {
          System.out.println("point=" + point);
          System.out.println("obj=" + obj);
          fail("Object was supposed to be a Class");
        }
      }
     

      if (point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_STATIC_FIELD || point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_FIELD)
      {
        try
        {

          Object referenced = jvmti.getObjectOnTag(point.getReferencedObject());
          Object obj = jvmti.getObjectOnTag(point.getReferenceHolder());
          Field field = jvmti.getObjectField(obj .getClass(),(int)point.getIndex());
          Class clazz = (Class)jvmti.getObjectOnTag(point.getClassTag());
          /*if (field==null)
          {
            System.out.println(point);
            System.out.println(referenced + " couldn't find field " +point.getIndex() + " on " + obj);
            Field field2 = jvmti.getObjectField(obj .getClass(),(int)point.getIndex());
          }
          assertNotNull(field);  -- I would like to enforce this, but it seems impossible due to internal classes on JVM */
        }
        catch (NullPointerException e)
        {
        }
      }
      else if (point.getReferenceType()==JVMTICallBack.THREAD_REFERENCE)
      {
        try
        {
        Object classTag = jvmti.getObjectOnTag(point.getClassTag());
        Object objReferenced = jvmti.getObjectOnTag(point.getReferencedObject());
        Object objHolder = jvmti.getObjectOnTag(point.getReferenceHolder());
       
        String methodName= jvmti.getMethodClass(point.getMethod()).getName() + "::" +
        jvmti.getMethodName(point.getMethod()) + jvmti.getMethodSignature(point.getMethod());
        //System.out.println(objReferenced + " being referenced at "+methodName);
        }
        catch (NullPointerException e)
        {
          // this can happen here;
        }
      }
     
    }
   
    System.out.println();
   
    long tagOnA = jvmti.getTagOnObject(a.b);
    iter = list.iterator();
    while (iter.hasNext())
    {
      ReferenceDataPoint point = (ReferenceDataPoint)iter.next();
     
      if (tagOnA == point.getReferencedObject() && (point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_FIELD  || point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_STATIC_FIELD))
      {
        Object obj = jvmti.getObjectOnTag(point.getReferenceHolder());
        Field field  = null;
       
        if (point.getReferenceType()==JVMTICallBack.JVMTI_REFERENCE_FIELD)
        {
          field  = jvmti.getObjectField((Class)obj.getClass() ,(int)point.getIndex());
        }
        else
        {
          field  = jvmti.getObjectField((Class)obj ,(int)point.getIndex());
        }
        System.out.println(obj + " being referenced at " + field);
      }
      else if (tagOnA == point.getReferencedObject() && (point.getReferenceType()==JVMTICallBack.THREAD_REFERENCE))
      {
        Object classTag = jvmti.getObjectOnTag(point.getClassTag());
        Object objReferenced = jvmti.getObjectOnTag(point.getReferencedObject());
        Object objHolder = jvmti.getObjectOnTag(point.getReferenceHolder());
       
        System.out.println("classTag=" + classTag);
        System.out.println("objReferenced=" + objReferenced);
        System.out.println("objHolder=" + objHolder);
        System.out.println("name=" +jvmti.getMethodClass(point.getMethod()).getName() + "::" +
            jvmti.getMethodName(point.getMethod()) + jvmti.getMethodSignature(point.getMethod()));
      }
    }
   
   
    try
View Full Code Here

TOP

Related Classes of org.jboss.profiler.jvmti.ReferenceDataPoint

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.