001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.insane.scanner;
043:
044: import java.lang.reflect.Field;
045:
046: /**
047: * A visitor interface that is called by the engine during the heap scan.
048: *
049: * @author Nenik
050: */
051: public interface Visitor {
052: /**
053: * A new type was found.
054: * It is guaranteed to be reported before first instance of given class.
055: * It is also guaranteed that all superclasses and interfaces will be
056: * reported before a subclass.
057: *
058: * @param cls the new type found.
059: */
060: public void visitClass(Class cls);
061:
062: /**
063: * A new object instance was found.
064: * It is guaranteed to be reported before first reference sourced from
065: * or targetted to this instance.
066: * It is also guaranteed that the instance's class will be reported
067: * before the instance.
068: *
069: * @param map The {@link ObjectMap} containing this object.
070: * @param object the reported instance.
071: */
072: public void visitObject(ObjectMap map, Object object);
073:
074: /**
075: * A reference from object <code>from</code> to object <code>to</code>
076: * was found as the contents of the field <code>ref</code>.
077: *
078: * It is guaranteed that both <code>from</code> and <code>to</code> objects
079: * will be reported before the reference.
080: *
081: * @param map The {@link ObjectMap} containing the objects.
082: * @param from The object from which the reference sources.
083: * @param to The object to which the reference points.
084: * @param ref The representation of the reference. Describes the class
085: * the referring field is declared in, and how it is named.
086: */
087: public void visitObjectReference(ObjectMap map, Object from,
088: Object to, Field ref);
089:
090: /**
091: * A new reference to target object was found. The object <code>to</code>
092: * is referenced by <code>index</code>-th slot of the array <code>from</code>
093: *
094: * It is guaranteed that both <code>from</code> and <code>to</code> objects
095: * will be reported before the reference.
096: *
097: * @param map The {@link ObjectMap} containing the objects.
098: * @param from The object from which the reference sources.
099: * @param to The object to which the reference points.
100: * @param index The array index of the <code>to<code> reference in
101: * <code>from</code> array.
102: */
103: public void visitArrayReference(ObjectMap map, Object from,
104: Object to, int index);
105:
106: /**
107: * A new reference static reference to target object was found.
108: *
109: * It is guaranteed that the <code>to</code> object will be reported before
110: * the reference.
111: *
112: * @param map The {@link ObjectMap} containing the object.
113: * @param to The object to which the reference points.
114: * @param ref The representation of the reference. Describes the class
115: * the referring field is declared in, and how it is named.
116: */
117: public void visitStaticReference(ObjectMap map, Object to, Field ref);
118: }
|