< prev index next >

test/jdk/com/sun/jdi/ReferrersTest.java

Print this page

  1 /*
  2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */

437         } else {
438             System.out.println("(" + which + ") "  + objRef);
439             indent(level);
440             System.out.println("    " + allReferrers.size() + " referrers for " + objRef + " took " + (end - start) + " ms");
441         }
442 
443         // We have to stop going up a referrer chain in some cases
444         Type rt = objRef.type();
445         if (rt instanceof ClassType) {
446             ClassType ct = (ClassType)rt;
447             String name = ct.name();
448             if (name.equals("sun.awt.SoftCache$ValueCell")) {
449                 return;
450             }
451             if (name.equals("java.lang.ref.Finalizer")) {
452                 return;
453             }
454             if (name.equals("java.lang.ref.SoftReference")) {
455                 return;
456             }



457             // oh oh, should really check for a subclass of ClassLoader :-)
458             if (name.indexOf("ClassLoader") >= 0) {
459                 return;
460             }
461             // No doubt there are other reasons to stop ...
462         }
463         int itemNumber = 1;
464         int allSize = allReferrers.size();
465         for (ObjectReference objx: allReferrers) {
466             showReferrers(objx, level + 1, allSize, itemNumber++);
467         }
468     }
469 }

  1 /*
  2  * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */

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