< prev index next >

test/com/sun/jdi/ReferrersTest.java

Print this page




 429 
 430         //System.out.println( "Getting referrers for " + objRef);
 431         long start, end;
 432         start = System.currentTimeMillis();
 433         allReferrers = objRef.referringObjects(99999);  //LIMIT
 434         end = System.currentTimeMillis();
 435 
 436         if (which == 0) {
 437             System.out.println(allReferrers.size() + " referrers for " + objRef + " took " + (end - start) + " ms");
 438         } else {
 439             System.out.println("(" + which + ") "  + objRef);
 440             indent(level);
 441             System.out.println("    " + allReferrers.size() + " referrers for " + objRef + " took " + (end - start) + " ms");
 442         }
 443 
 444         // We have to stop going up a referrer chain in some cases
 445         Type rt = objRef.type();
 446         if (rt instanceof ClassType) {
 447             ClassType ct = (ClassType)rt;
 448             String name = ct.name();
 449             if (name.equals("sun.misc.SoftCache$ValueCell")) {
 450                 return;
 451             }
 452             if (name.equals("java.lang.ref.Finalizer")) {
 453                 return;
 454             }
 455             if (name.equals("java.lang.ref.SoftReference")) {
 456                 return;
 457             }
 458             // oh oh, should really check for a subclass of ClassLoader :-)
 459             if (name.indexOf("ClassLoader") >= 0) {
 460                 return;
 461             }
 462             // No doubt there are other reasons to stop ...
 463         }
 464         int itemNumber = 1;
 465         int allSize = allReferrers.size();
 466         for (ObjectReference objx: allReferrers) {
 467             showReferrers(objx, level + 1, allSize, itemNumber++);
 468         }
 469     }


 429 
 430         //System.out.println( "Getting referrers for " + objRef);
 431         long start, end;
 432         start = System.currentTimeMillis();
 433         allReferrers = objRef.referringObjects(99999);  //LIMIT
 434         end = System.currentTimeMillis();
 435 
 436         if (which == 0) {
 437             System.out.println(allReferrers.size() + " referrers for " + objRef + " took " + (end - start) + " ms");
 438         } else {
 439             System.out.println("(" + which + ") "  + objRef);
 440             indent(level);
 441             System.out.println("    " + allReferrers.size() + " referrers for " + objRef + " took " + (end - start) + " ms");
 442         }
 443 
 444         // We have to stop going up a referrer chain in some cases
 445         Type rt = objRef.type();
 446         if (rt instanceof ClassType) {
 447             ClassType ct = (ClassType)rt;
 448             String name = ct.name();
 449             if (name.equals("sun.awt.SoftCache$ValueCell")) {
 450                 return;
 451             }
 452             if (name.equals("java.lang.ref.Finalizer")) {
 453                 return;
 454             }
 455             if (name.equals("java.lang.ref.SoftReference")) {
 456                 return;
 457             }
 458             // oh oh, should really check for a subclass of ClassLoader :-)
 459             if (name.indexOf("ClassLoader") >= 0) {
 460                 return;
 461             }
 462             // No doubt there are other reasons to stop ...
 463         }
 464         int itemNumber = 1;
 465         int allSize = allReferrers.size();
 466         for (ObjectReference objx: allReferrers) {
 467             showReferrers(objx, level + 1, allSize, itemNumber++);
 468         }
 469     }
< prev index next >