feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class AllClassesQuery extends QueryHandler {
|
||||
|
||||
boolean excludePlatform;
|
||||
boolean oqlSupported;
|
||||
|
||||
public AllClassesQuery(boolean excludePlatform, boolean oqlSupported) {
|
||||
this.excludePlatform = excludePlatform;
|
||||
this.oqlSupported = oqlSupported;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (excludePlatform) {
|
||||
startHtml("All Classes (excluding platform)");
|
||||
} else {
|
||||
startHtml("All Classes (including platform)");
|
||||
}
|
||||
|
||||
Iterator classes = snapshot.getClasses();
|
||||
String lastPackage = null;
|
||||
while (classes.hasNext()) {
|
||||
JavaClass clazz = (JavaClass) classes.next();
|
||||
if (excludePlatform && PlatformClasses.isPlatformClass(clazz)) {
|
||||
// skip this..
|
||||
continue;
|
||||
}
|
||||
String name = clazz.getName();
|
||||
int pos = name.lastIndexOf(".");
|
||||
String pkg;
|
||||
if (name.startsWith("[")) { // Only in ancient heap dumps
|
||||
pkg = "<Arrays>";
|
||||
} else if (pos == -1) {
|
||||
pkg = "<Default Package>";
|
||||
} else {
|
||||
pkg = name.substring(0, pos);
|
||||
}
|
||||
if (!pkg.equals(lastPackage)) {
|
||||
out.print("<h2>Package ");
|
||||
print(pkg);
|
||||
out.println("</h2>");
|
||||
}
|
||||
lastPackage = pkg;
|
||||
printClass(clazz);
|
||||
if (clazz.getId() != -1) {
|
||||
print(" [" + clazz.getIdString() + "]");
|
||||
}
|
||||
out.println("<br>");
|
||||
}
|
||||
|
||||
out.println("<h2>Other Queries</h2>");
|
||||
out.println("<ul>");
|
||||
|
||||
out.println("<li>");
|
||||
printAnchorStart();
|
||||
if (excludePlatform) {
|
||||
out.print("allClassesWithPlatform/\">");
|
||||
print("All classes including platform");
|
||||
} else {
|
||||
out.print("\">");
|
||||
print("All classes excluding platform");
|
||||
}
|
||||
out.println("</a>");
|
||||
|
||||
out.println("<li>");
|
||||
printAnchorStart();
|
||||
out.print("showRoots/\">");
|
||||
print("Show all members of the rootset");
|
||||
out.println("</a>");
|
||||
|
||||
out.println("<li>");
|
||||
printAnchorStart();
|
||||
out.print("showInstanceCounts/includePlatform/\">");
|
||||
print("Show instance counts for all classes (including platform)");
|
||||
out.println("</a>");
|
||||
|
||||
out.println("<li>");
|
||||
printAnchorStart();
|
||||
out.print("showInstanceCounts/\">");
|
||||
print("Show instance counts for all classes (excluding platform)");
|
||||
out.println("</a>");
|
||||
|
||||
out.println("<li>");
|
||||
printAnchorStart();
|
||||
out.print("histo/\">");
|
||||
print("Show heap histogram");
|
||||
out.println("</a>");
|
||||
|
||||
out.println("<li>");
|
||||
printAnchorStart();
|
||||
out.print("finalizerSummary/\">");
|
||||
print("Show finalizer summary");
|
||||
out.println("</a>");
|
||||
|
||||
if (oqlSupported) {
|
||||
out.println("<li>");
|
||||
printAnchorStart();
|
||||
out.print("oql/\">");
|
||||
print("Execute Object Query Language (OQL) query");
|
||||
out.println("</a>");
|
||||
}
|
||||
|
||||
out.println("</ul>");
|
||||
|
||||
endHtml();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
108
jdkSrc/jdk8/com/sun/tools/hat/internal/server/AllRootsQuery.java
Normal file
108
jdkSrc/jdk8/com/sun/tools/hat/internal/server/AllRootsQuery.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import com.sun.tools.hat.internal.util.ArraySorter;
|
||||
import com.sun.tools.hat.internal.util.Comparer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class AllRootsQuery extends QueryHandler {
|
||||
|
||||
public AllRootsQuery() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
startHtml("All Members of the Rootset");
|
||||
|
||||
Root[] roots = snapshot.getRootsArray();
|
||||
ArraySorter.sort(roots, new Comparer() {
|
||||
public int compare(Object lhs, Object rhs) {
|
||||
Root left = (Root) lhs;
|
||||
Root right = (Root) rhs;
|
||||
int d = left.getType() - right.getType();
|
||||
if (d != 0) {
|
||||
return -d; // More interesting values are *higher*
|
||||
}
|
||||
return left.getDescription().compareTo(right.getDescription());
|
||||
}
|
||||
});
|
||||
|
||||
int lastType = Root.INVALID_TYPE;
|
||||
|
||||
for (int i= 0; i < roots.length; i++) {
|
||||
Root root = roots[i];
|
||||
|
||||
if (root.getType() != lastType) {
|
||||
lastType = root.getType();
|
||||
out.print("<h2>");
|
||||
print(root.getTypeName() + " References");
|
||||
out.println("</h2>");
|
||||
}
|
||||
|
||||
printRoot(root);
|
||||
if (root.getReferer() != null) {
|
||||
out.print("<small> (from ");
|
||||
printThingAnchorTag(root.getReferer().getId());
|
||||
print(root.getReferer().toString());
|
||||
out.print(")</a></small>");
|
||||
}
|
||||
out.print(" :<br>");
|
||||
|
||||
JavaThing t = snapshot.findThing(root.getId());
|
||||
if (t != null) { // It should always be
|
||||
print("--> ");
|
||||
printThing(t);
|
||||
out.println("<br>");
|
||||
}
|
||||
}
|
||||
|
||||
out.println("<h2>Other Queries</h2>");
|
||||
out.println("<ul>");
|
||||
out.println("<li>");
|
||||
printAnchorStart();
|
||||
out.print("\">");
|
||||
print("Show All Classes");
|
||||
out.println("</a>");
|
||||
out.println("</ul>");
|
||||
|
||||
endHtml();
|
||||
}
|
||||
}
|
||||
190
jdkSrc/jdk8/com/sun/tools/hat/internal/server/ClassQuery.java
Normal file
190
jdkSrc/jdk8/com/sun/tools/hat/internal/server/ClassQuery.java
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import com.sun.tools.hat.internal.util.ArraySorter;
|
||||
import com.sun.tools.hat.internal.util.Comparer;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class ClassQuery extends QueryHandler {
|
||||
|
||||
|
||||
public ClassQuery() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
startHtml("Class " + query);
|
||||
JavaClass clazz = snapshot.findClass(query);
|
||||
if (clazz == null) {
|
||||
error("class not found: " + query);
|
||||
} else {
|
||||
printFullClass(clazz);
|
||||
}
|
||||
endHtml();
|
||||
}
|
||||
|
||||
protected void printFullClass(JavaClass clazz) {
|
||||
out.print("<h1>");
|
||||
print(clazz.toString());
|
||||
out.println("</h1>");
|
||||
|
||||
out.println("<h2>Superclass:</h2>");
|
||||
printClass(clazz.getSuperclass());
|
||||
|
||||
out.println("<h2>Loader Details</h2>");
|
||||
out.println("<h3>ClassLoader:</h3>");
|
||||
printThing(clazz.getLoader());
|
||||
|
||||
out.println("<h3>Signers:</h3>");
|
||||
printThing(clazz.getSigners());
|
||||
|
||||
out.println("<h3>Protection Domain:</h3>");
|
||||
printThing(clazz.getProtectionDomain());
|
||||
|
||||
out.println("<h2>Subclasses:</h2>");
|
||||
JavaClass[] sc = clazz.getSubclasses();
|
||||
for (int i = 0; i < sc.length; i++) {
|
||||
out.print(" ");
|
||||
printClass(sc[i]);
|
||||
out.println("<br>");
|
||||
}
|
||||
|
||||
out.println("<h2>Instance Data Members:</h2>");
|
||||
JavaField[] ff = clazz.getFields().clone();
|
||||
ArraySorter.sort(ff, new Comparer() {
|
||||
public int compare(Object lhs, Object rhs) {
|
||||
JavaField left = (JavaField) lhs;
|
||||
JavaField right = (JavaField) rhs;
|
||||
return left.getName().compareTo(right.getName());
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < ff.length; i++) {
|
||||
out.print(" ");
|
||||
printField(ff[i]);
|
||||
out.println("<br>");
|
||||
}
|
||||
|
||||
out.println("<h2>Static Data Members:</h2>");
|
||||
JavaStatic[] ss = clazz.getStatics();
|
||||
for (int i = 0; i < ss.length; i++) {
|
||||
printStatic(ss[i]);
|
||||
out.println("<br>");
|
||||
}
|
||||
|
||||
out.println("<h2>Instances</h2>");
|
||||
|
||||
printAnchorStart();
|
||||
print("instances/" + encodeForURL(clazz));
|
||||
out.print("\">");
|
||||
out.println("Exclude subclasses</a><br>");
|
||||
|
||||
printAnchorStart();
|
||||
print("allInstances/" + encodeForURL(clazz));
|
||||
out.print("\">");
|
||||
out.println("Include subclasses</a><br>");
|
||||
|
||||
|
||||
if (snapshot.getHasNewSet()) {
|
||||
out.println("<h2>New Instances</h2>");
|
||||
|
||||
printAnchorStart();
|
||||
print("newInstances/" + encodeForURL(clazz));
|
||||
out.print("\">");
|
||||
out.println("Exclude subclasses</a><br>");
|
||||
|
||||
printAnchorStart();
|
||||
print("allNewInstances/" + encodeForURL(clazz));
|
||||
out.print("\">");
|
||||
out.println("Include subclasses</a><br>");
|
||||
}
|
||||
|
||||
out.println("<h2>References summary by Type</h2>");
|
||||
printAnchorStart();
|
||||
print("refsByType/" + encodeForURL(clazz));
|
||||
out.print("\">");
|
||||
out.println("References summary by type</a>");
|
||||
|
||||
printReferencesTo(clazz);
|
||||
}
|
||||
|
||||
protected void printReferencesTo(JavaHeapObject obj) {
|
||||
if (obj.getId() == -1) {
|
||||
return;
|
||||
}
|
||||
out.println("<h2>References to this object:</h2>");
|
||||
out.flush();
|
||||
Enumeration referers = obj.getReferers();
|
||||
while (referers.hasMoreElements()) {
|
||||
JavaHeapObject ref = (JavaHeapObject) referers.nextElement();
|
||||
printThing(ref);
|
||||
print (" : " + ref.describeReferenceTo(obj, snapshot));
|
||||
// If there are more than one references, this only gets the
|
||||
// first one.
|
||||
out.println("<br>");
|
||||
}
|
||||
|
||||
out.println("<h2>Other Queries</h2>");
|
||||
out.println("Reference Chains from Rootset");
|
||||
long id = obj.getId();
|
||||
|
||||
out.print("<ul><li>");
|
||||
printAnchorStart();
|
||||
out.print("roots/");
|
||||
printHex(id);
|
||||
out.print("\">");
|
||||
out.println("Exclude weak refs</a>");
|
||||
|
||||
out.print("<li>");
|
||||
printAnchorStart();
|
||||
out.print("allRoots/");
|
||||
printHex(id);
|
||||
out.print("\">");
|
||||
out.println("Include weak refs</a></ul>");
|
||||
|
||||
printAnchorStart();
|
||||
out.print("reachableFrom/");
|
||||
printHex(id);
|
||||
out.print("\">");
|
||||
out.println("Objects reachable from here</a><br>");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import java.util.*;
|
||||
|
||||
public class FinalizerObjectsQuery extends QueryHandler {
|
||||
public void run() {
|
||||
Enumeration objs = snapshot.getFinalizerObjects();
|
||||
startHtml("Objects pending finalization");
|
||||
|
||||
out.println("<a href='/finalizerSummary/'>Finalizer summary</a>");
|
||||
|
||||
out.println("<h1>Objects pending finalization</h1>");
|
||||
|
||||
while (objs.hasMoreElements()) {
|
||||
printThing((JavaHeapObject)objs.nextElement());
|
||||
out.println("<br>");
|
||||
}
|
||||
|
||||
endHtml();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import java.util.*;
|
||||
|
||||
public class FinalizerSummaryQuery extends QueryHandler {
|
||||
public void run() {
|
||||
Enumeration objs = snapshot.getFinalizerObjects();
|
||||
startHtml("Finalizer Summary");
|
||||
|
||||
out.println("<p align='center'>");
|
||||
out.println("<b><a href='/'>All Classes (excluding platform)</a></b>");
|
||||
out.println("</p>");
|
||||
|
||||
printFinalizerSummary(objs);
|
||||
endHtml();
|
||||
}
|
||||
|
||||
private static class HistogramElement {
|
||||
public HistogramElement(JavaClass clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public void updateCount() {
|
||||
this.count++;
|
||||
}
|
||||
|
||||
public int compare(HistogramElement other) {
|
||||
long diff = other.count - count;
|
||||
return (diff == 0L)? 0 : ((diff > 0L)? +1 : -1);
|
||||
}
|
||||
|
||||
public JavaClass getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
private JavaClass clazz;
|
||||
private long count;
|
||||
}
|
||||
|
||||
private void printFinalizerSummary(Enumeration objs) {
|
||||
int count = 0;
|
||||
Map<JavaClass, HistogramElement> map = new HashMap<JavaClass, HistogramElement>();
|
||||
|
||||
while (objs.hasMoreElements()) {
|
||||
JavaHeapObject obj = (JavaHeapObject) objs.nextElement();
|
||||
count++;
|
||||
JavaClass clazz = obj.getClazz();
|
||||
if (! map.containsKey(clazz)) {
|
||||
map.put(clazz, new HistogramElement(clazz));
|
||||
}
|
||||
HistogramElement element = map.get(clazz);
|
||||
element.updateCount();
|
||||
}
|
||||
|
||||
out.println("<p align='center'>");
|
||||
out.println("<b>");
|
||||
out.println("Total ");
|
||||
if (count != 0) {
|
||||
out.print("<a href='/finalizerObjects/'>instances</a>");
|
||||
} else {
|
||||
out.print("instances");
|
||||
}
|
||||
out.println(" pending finalization: ");
|
||||
out.print(count);
|
||||
out.println("</b></p><hr>");
|
||||
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// calculate and print histogram
|
||||
HistogramElement[] elements = new HistogramElement[map.size()];
|
||||
map.values().toArray(elements);
|
||||
Arrays.sort(elements, new Comparator<HistogramElement>() {
|
||||
public int compare(HistogramElement o1, HistogramElement o2) {
|
||||
return o1.compare(o2);
|
||||
}
|
||||
});
|
||||
|
||||
out.println("<table border=1 align=center>");
|
||||
out.println("<tr><th>Count</th><th>Class</th></tr>");
|
||||
for (int j = 0; j < elements.length; j++) {
|
||||
out.println("<tr><td>");
|
||||
out.println(elements[j].getCount());
|
||||
out.println("</td><td>");
|
||||
printClass(elements[j].getClazz());
|
||||
out.println("</td><tr>");
|
||||
}
|
||||
out.println("</table>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.JavaClass;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Prints histogram sortable by class name, count and size.
|
||||
*
|
||||
*/
|
||||
public class HistogramQuery extends QueryHandler {
|
||||
public void run() {
|
||||
JavaClass[] classes = snapshot.getClassesArray();
|
||||
Comparator<JavaClass> comparator;
|
||||
if (query.equals("count")) {
|
||||
comparator = new Comparator<JavaClass>() {
|
||||
public int compare(JavaClass first, JavaClass second) {
|
||||
long diff = (second.getInstancesCount(false) -
|
||||
first.getInstancesCount(false));
|
||||
return (diff == 0)? 0: ((diff < 0)? -1 : + 1);
|
||||
}
|
||||
};
|
||||
} else if (query.equals("class")) {
|
||||
comparator = new Comparator<JavaClass>() {
|
||||
public int compare(JavaClass first, JavaClass second) {
|
||||
return first.getName().compareTo(second.getName());
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// default sort is by total size
|
||||
comparator = new Comparator<JavaClass>() {
|
||||
public int compare(JavaClass first, JavaClass second) {
|
||||
long diff = (second.getTotalInstanceSize() -
|
||||
first.getTotalInstanceSize());
|
||||
return (diff == 0)? 0: ((diff < 0)? -1 : + 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
Arrays.sort(classes, comparator);
|
||||
|
||||
startHtml("Heap Histogram");
|
||||
|
||||
out.println("<p align='center'>");
|
||||
out.println("<b><a href='/'>All Classes (excluding platform)</a></b>");
|
||||
out.println("</p>");
|
||||
|
||||
out.println("<table align=center border=1>");
|
||||
out.println("<tr><th><a href='/histo/class'>Class</a></th>");
|
||||
out.println("<th><a href='/histo/count'>Instance Count</a></th>");
|
||||
out.println("<th><a href='/histo/size'>Total Size</a></th></tr>");
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
JavaClass clazz = classes[i];
|
||||
out.println("<tr><td>");
|
||||
printClass(clazz);
|
||||
out.println("</td>");
|
||||
out.println("<td>");
|
||||
out.println(clazz.getInstancesCount(false));
|
||||
out.println("</td>");
|
||||
out.println("<td>");
|
||||
out.println(clazz.getTotalInstanceSize());
|
||||
out.println("</td></tr>");
|
||||
}
|
||||
out.println("</table>");
|
||||
|
||||
endHtml();
|
||||
}
|
||||
}
|
||||
220
jdkSrc/jdk8/com/sun/tools/hat/internal/server/HttpReader.java
Normal file
220
jdkSrc/jdk8/com/sun/tools/hat/internal/server/HttpReader.java
Normal file
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
/**
|
||||
* Reads a single HTTP query from a socket, and starts up a QueryHandler
|
||||
* to server it.
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
import java.net.Socket;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
import com.sun.tools.hat.internal.model.Snapshot;
|
||||
import com.sun.tools.hat.internal.oql.OQLEngine;
|
||||
import com.sun.tools.hat.internal.util.Misc;
|
||||
|
||||
public class HttpReader implements Runnable {
|
||||
|
||||
|
||||
private Socket socket;
|
||||
private PrintWriter out;
|
||||
private Snapshot snapshot;
|
||||
private OQLEngine engine;
|
||||
|
||||
public HttpReader (Socket s, Snapshot snapshot, OQLEngine engine) {
|
||||
this.socket = s;
|
||||
this.snapshot = snapshot;
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = new BufferedInputStream(socket.getInputStream());
|
||||
out = new PrintWriter(new BufferedWriter(
|
||||
new OutputStreamWriter(
|
||||
socket.getOutputStream())));
|
||||
out.println("HTTP/1.0 200 OK");
|
||||
out.println("Cache-Control: no-cache");
|
||||
out.println("Pragma: no-cache");
|
||||
out.println();
|
||||
if (in.read() != 'G' || in.read() != 'E'
|
||||
|| in.read() != 'T' || in.read() != ' ') {
|
||||
outputError("Protocol error");
|
||||
}
|
||||
int data;
|
||||
StringBuilder queryBuf = new StringBuilder();
|
||||
while ((data = in.read()) != -1 && data != ' ') {
|
||||
char ch = (char) data;
|
||||
queryBuf.append(ch);
|
||||
}
|
||||
String query = queryBuf.toString();
|
||||
query = java.net.URLDecoder.decode(query, "UTF-8");
|
||||
QueryHandler handler = null;
|
||||
if (snapshot == null) {
|
||||
outputError("The heap snapshot is still being read.");
|
||||
return;
|
||||
} else if (query.equals("/")) {
|
||||
handler = new AllClassesQuery(true, engine != null);
|
||||
handler.setUrlStart("");
|
||||
handler.setQuery("");
|
||||
} else if (query.startsWith("/oql/")) {
|
||||
if (engine != null) {
|
||||
handler = new OQLQuery(engine);
|
||||
handler.setUrlStart("");
|
||||
handler.setQuery(query.substring(5));
|
||||
}
|
||||
} else if (query.startsWith("/oqlhelp/")) {
|
||||
if (engine != null) {
|
||||
handler = new OQLHelp();
|
||||
handler.setUrlStart("");
|
||||
handler.setQuery("");
|
||||
}
|
||||
} else if (query.equals("/allClassesWithPlatform/")) {
|
||||
handler = new AllClassesQuery(false, engine != null);
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery("");
|
||||
} else if (query.equals("/showRoots/")) {
|
||||
handler = new AllRootsQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery("");
|
||||
} else if (query.equals("/showInstanceCounts/includePlatform/")) {
|
||||
handler = new InstancesCountQuery(false);
|
||||
handler.setUrlStart("../../");
|
||||
handler.setQuery("");
|
||||
} else if (query.equals("/showInstanceCounts/")) {
|
||||
handler = new InstancesCountQuery(true);
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery("");
|
||||
} else if (query.startsWith("/instances/")) {
|
||||
handler = new InstancesQuery(false);
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(11));
|
||||
} else if (query.startsWith("/newInstances/")) {
|
||||
handler = new InstancesQuery(false, true);
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(14));
|
||||
} else if (query.startsWith("/allInstances/")) {
|
||||
handler = new InstancesQuery(true);
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(14));
|
||||
} else if (query.startsWith("/allNewInstances/")) {
|
||||
handler = new InstancesQuery(true, true);
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(17));
|
||||
} else if (query.startsWith("/object/")) {
|
||||
handler = new ObjectQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(8));
|
||||
} else if (query.startsWith("/class/")) {
|
||||
handler = new ClassQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(7));
|
||||
} else if (query.startsWith("/roots/")) {
|
||||
handler = new RootsQuery(false);
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(7));
|
||||
} else if (query.startsWith("/allRoots/")) {
|
||||
handler = new RootsQuery(true);
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(10));
|
||||
} else if (query.startsWith("/reachableFrom/")) {
|
||||
handler = new ReachableQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(15));
|
||||
} else if (query.startsWith("/rootStack/")) {
|
||||
handler = new RootStackQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(11));
|
||||
} else if (query.startsWith("/histo/")) {
|
||||
handler = new HistogramQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(7));
|
||||
} else if (query.startsWith("/refsByType/")) {
|
||||
handler = new RefsByTypeQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery(query.substring(12));
|
||||
} else if (query.startsWith("/finalizerSummary/")) {
|
||||
handler = new FinalizerSummaryQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery("");
|
||||
} else if (query.startsWith("/finalizerObjects/")) {
|
||||
handler = new FinalizerObjectsQuery();
|
||||
handler.setUrlStart("../");
|
||||
handler.setQuery("");
|
||||
}
|
||||
|
||||
if (handler != null) {
|
||||
handler.setOutput(out);
|
||||
handler.setSnapshot(snapshot);
|
||||
handler.run();
|
||||
} else {
|
||||
outputError("Query '" + query + "' not implemented");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void outputError(String msg) {
|
||||
out.println();
|
||||
out.println("<html><body bgcolor=\"#ffffff\">");
|
||||
out.println(Misc.encodeHtml(msg));
|
||||
out.println("</body></html>");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import com.sun.tools.hat.internal.util.ArraySorter;
|
||||
import com.sun.tools.hat.internal.util.Comparer;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class InstancesCountQuery extends QueryHandler {
|
||||
|
||||
|
||||
private boolean excludePlatform;
|
||||
|
||||
public InstancesCountQuery(boolean excludePlatform) {
|
||||
this.excludePlatform = excludePlatform;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (excludePlatform) {
|
||||
startHtml("Instance Counts for All Classes (excluding platform)");
|
||||
} else {
|
||||
startHtml("Instance Counts for All Classes (including platform)");
|
||||
}
|
||||
|
||||
JavaClass[] classes = snapshot.getClassesArray();
|
||||
if (excludePlatform) {
|
||||
int num = 0;
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (! PlatformClasses.isPlatformClass(classes[i])) {
|
||||
classes[num++] = classes[i];
|
||||
}
|
||||
}
|
||||
JavaClass[] tmp = new JavaClass[num];
|
||||
System.arraycopy(classes, 0, tmp, 0, tmp.length);
|
||||
classes = tmp;
|
||||
}
|
||||
ArraySorter.sort(classes, new Comparer() {
|
||||
public int compare(Object lhso, Object rhso) {
|
||||
JavaClass lhs = (JavaClass) lhso;
|
||||
JavaClass rhs = (JavaClass) rhso;
|
||||
int diff = lhs.getInstancesCount(false)
|
||||
- rhs.getInstancesCount(false);
|
||||
if (diff != 0) {
|
||||
return -diff; // Sort from biggest to smallest
|
||||
}
|
||||
String left = lhs.getName();
|
||||
String right = rhs.getName();
|
||||
if (left.startsWith("[") != right.startsWith("[")) {
|
||||
// Arrays at the end
|
||||
if (left.startsWith("[")) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return left.compareTo(right);
|
||||
}
|
||||
});
|
||||
|
||||
String lastPackage = null;
|
||||
long totalSize = 0;
|
||||
long instances = 0;
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
JavaClass clazz = classes[i];
|
||||
int count = clazz.getInstancesCount(false);
|
||||
print("" + count);
|
||||
printAnchorStart();
|
||||
print("instances/" + encodeForURL(classes[i]));
|
||||
out.print("\"> ");
|
||||
if (count == 1) {
|
||||
print("instance");
|
||||
} else {
|
||||
print("instances");
|
||||
}
|
||||
out.print("</a> ");
|
||||
if (snapshot.getHasNewSet()) {
|
||||
Enumeration objects = clazz.getInstances(false);
|
||||
int newInst = 0;
|
||||
while (objects.hasMoreElements()) {
|
||||
JavaHeapObject obj = (JavaHeapObject)objects.nextElement();
|
||||
if (obj.isNew()) {
|
||||
newInst++;
|
||||
}
|
||||
}
|
||||
print("(");
|
||||
printAnchorStart();
|
||||
print("newInstances/" + encodeForURL(classes[i]));
|
||||
out.print("\">");
|
||||
print("" + newInst + " new");
|
||||
out.print("</a>) ");
|
||||
}
|
||||
print("of ");
|
||||
printClass(classes[i]);
|
||||
out.println("<br>");
|
||||
instances += count;
|
||||
totalSize += classes[i].getTotalInstanceSize();
|
||||
}
|
||||
out.println("<h2>Total of " + instances + " instances occupying " + totalSize + " bytes.</h2>");
|
||||
|
||||
out.println("<h2>Other Queries</h2>");
|
||||
out.println("<ul>");
|
||||
|
||||
out.print("<li>");
|
||||
printAnchorStart();
|
||||
if (!excludePlatform) {
|
||||
out.print("showInstanceCounts/\">");
|
||||
print("Show instance counts for all classes (excluding platform)");
|
||||
} else {
|
||||
out.print("showInstanceCounts/includePlatform/\">");
|
||||
print("Show instance counts for all classes (including platform)");
|
||||
}
|
||||
out.println("</a>");
|
||||
|
||||
out.print("<li>");
|
||||
printAnchorStart();
|
||||
out.print("allClassesWithPlatform/\">");
|
||||
print("Show All Classes (including platform)");
|
||||
out.println("</a>");
|
||||
|
||||
out.print("<li>");
|
||||
printAnchorStart();
|
||||
out.print("\">");
|
||||
print("Show All Classes (excluding platform)");
|
||||
out.println("</a>");
|
||||
|
||||
out.println("</ul>");
|
||||
|
||||
endHtml();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class InstancesQuery extends QueryHandler {
|
||||
|
||||
private boolean includeSubclasses;
|
||||
private boolean newObjects;
|
||||
|
||||
public InstancesQuery(boolean includeSubclasses) {
|
||||
this.includeSubclasses = includeSubclasses;
|
||||
}
|
||||
|
||||
public InstancesQuery(boolean includeSubclasses, boolean newObjects) {
|
||||
this.includeSubclasses = includeSubclasses;
|
||||
this.newObjects = newObjects;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
JavaClass clazz = snapshot.findClass(query);
|
||||
String instancesOf;
|
||||
if (newObjects)
|
||||
instancesOf = "New instances of ";
|
||||
else
|
||||
instancesOf = "Instances of ";
|
||||
if (includeSubclasses) {
|
||||
startHtml(instancesOf + query + " (including subclasses)");
|
||||
} else {
|
||||
startHtml(instancesOf + query);
|
||||
}
|
||||
if (clazz == null) {
|
||||
error("Class not found");
|
||||
} else {
|
||||
out.print("<strong>");
|
||||
printClass(clazz);
|
||||
out.print("</strong><br><br>");
|
||||
Enumeration objects = clazz.getInstances(includeSubclasses);
|
||||
long totalSize = 0;
|
||||
long instances = 0;
|
||||
while (objects.hasMoreElements()) {
|
||||
JavaHeapObject obj = (JavaHeapObject) objects.nextElement();
|
||||
if (newObjects && !obj.isNew())
|
||||
continue;
|
||||
printThing(obj);
|
||||
out.println("<br>");
|
||||
totalSize += obj.getSize();
|
||||
instances++;
|
||||
}
|
||||
out.println("<h2>Total of " + instances + " instances occupying " + totalSize + " bytes.</h2>");
|
||||
}
|
||||
endHtml();
|
||||
}
|
||||
}
|
||||
60
jdkSrc/jdk8/com/sun/tools/hat/internal/server/OQLHelp.java
Normal file
60
jdkSrc/jdk8/com/sun/tools/hat/internal/server/OQLHelp.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* This handles Object Query Language (OQL) help.
|
||||
*
|
||||
* @author A. Sundararajan
|
||||
*/
|
||||
|
||||
class OQLHelp extends QueryHandler {
|
||||
|
||||
public OQLHelp() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
InputStream is = getClass().getResourceAsStream("/com/sun/tools/hat/resources/oqlhelp.html");
|
||||
int ch = -1;
|
||||
try {
|
||||
is = new BufferedInputStream(is);
|
||||
while ( (ch = is.read()) != -1) {
|
||||
out.print((char)ch);
|
||||
}
|
||||
} catch (Exception exp) {
|
||||
printException(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
104
jdkSrc/jdk8/com/sun/tools/hat/internal/server/OQLQuery.java
Normal file
104
jdkSrc/jdk8/com/sun/tools/hat/internal/server/OQLQuery.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.oql.*;
|
||||
|
||||
/**
|
||||
* This handles Object Query Language (OQL) queries.
|
||||
*
|
||||
* @author A. Sundararajan
|
||||
*/
|
||||
|
||||
class OQLQuery extends QueryHandler {
|
||||
|
||||
public OQLQuery(OQLEngine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
startHtml("Object Query Language (OQL) query");
|
||||
String oql = null;
|
||||
if (query != null && !query.equals("")) {
|
||||
int index = query.indexOf("?query=");
|
||||
if (index != -1 && query.length() > 7) {
|
||||
oql = query.substring(index + 7);
|
||||
}
|
||||
}
|
||||
out.println("<p align='center'><table>");
|
||||
out.println("<tr><td><b>");
|
||||
out.println("<a href='/'>All Classes (excluding platform)</a>");
|
||||
out.println("</b></td>");
|
||||
out.println("<td><b><a href='/oqlhelp/'>OQL Help</a></b></td></tr>");
|
||||
out.println("</table></p>");
|
||||
out.println("<form action='/oql/' method='get'>");
|
||||
out.println("<p align='center'>");
|
||||
out.println("<textarea name='query' cols=80 rows=10>");
|
||||
if (oql != null) {
|
||||
println(oql);
|
||||
}
|
||||
out.println("</textarea>");
|
||||
out.println("</p>");
|
||||
out.println("<p align='center'>");
|
||||
out.println("<input type='submit' value='Execute'></input>");
|
||||
out.println("</p>");
|
||||
out.println("</form>");
|
||||
if (oql != null) {
|
||||
executeQuery(oql);
|
||||
}
|
||||
endHtml();
|
||||
}
|
||||
|
||||
private void executeQuery(String q) {
|
||||
try {
|
||||
out.println("<table border='1'>");
|
||||
engine.executeQuery(q, new ObjectVisitor() {
|
||||
public boolean visit(Object o) {
|
||||
out.println("<tr><td>");
|
||||
try {
|
||||
out.println(engine.toHtml(o));
|
||||
} catch (Exception e) {
|
||||
printException(e);
|
||||
}
|
||||
out.println("</td></tr>");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
out.println("</table>");
|
||||
} catch (OQLException exp) {
|
||||
printException(exp);
|
||||
}
|
||||
}
|
||||
|
||||
private OQLEngine engine;
|
||||
}
|
||||
146
jdkSrc/jdk8/com/sun/tools/hat/internal/server/ObjectQuery.java
Normal file
146
jdkSrc/jdk8/com/sun/tools/hat/internal/server/ObjectQuery.java
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import com.sun.tools.hat.internal.util.ArraySorter;
|
||||
import com.sun.tools.hat.internal.util.Comparer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class ObjectQuery extends ClassQuery {
|
||||
// We inherit printFullClass from ClassQuery
|
||||
|
||||
public ObjectQuery() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
startHtml("Object at " + query);
|
||||
long id = parseHex(query);
|
||||
JavaHeapObject thing = snapshot.findThing(id);
|
||||
//
|
||||
// In the following, I suppose we really should use a visitor
|
||||
// pattern. I'm not that strongly motivated to do this, however:
|
||||
// This is the only typecase there is, and the default for an
|
||||
// unrecognized type is to do something reasonable.
|
||||
//
|
||||
if (thing == null) {
|
||||
error("object not found");
|
||||
} else if (thing instanceof JavaClass) {
|
||||
printFullClass((JavaClass) thing);
|
||||
} else if (thing instanceof JavaValueArray) {
|
||||
print(((JavaValueArray) thing).valueString(true));
|
||||
printAllocationSite(thing);
|
||||
printReferencesTo(thing);
|
||||
} else if (thing instanceof JavaObjectArray) {
|
||||
printFullObjectArray((JavaObjectArray) thing);
|
||||
printAllocationSite(thing);
|
||||
printReferencesTo(thing);
|
||||
} else if (thing instanceof JavaObject) {
|
||||
printFullObject((JavaObject) thing);
|
||||
printAllocationSite(thing);
|
||||
printReferencesTo(thing);
|
||||
} else {
|
||||
// We should never get here
|
||||
print(thing.toString());
|
||||
printReferencesTo(thing);
|
||||
}
|
||||
endHtml();
|
||||
}
|
||||
|
||||
|
||||
private void printFullObject(JavaObject obj) {
|
||||
out.print("<h1>instance of ");
|
||||
print(obj.toString());
|
||||
out.print(" <small>(" + obj.getSize() + " bytes)</small>");
|
||||
out.println("</h1>\n");
|
||||
|
||||
out.println("<h2>Class:</h2>");
|
||||
printClass(obj.getClazz());
|
||||
|
||||
out.println("<h2>Instance data members:</h2>");
|
||||
final JavaThing[] things = obj.getFields();
|
||||
final JavaField[] fields = obj.getClazz().getFieldsForInstance();
|
||||
Integer[] hack = new Integer[things.length];
|
||||
for (int i = 0; i < things.length; i++) {
|
||||
hack[i] = new Integer(i);
|
||||
}
|
||||
ArraySorter.sort(hack, new Comparer() {
|
||||
public int compare(Object lhs, Object rhs) {
|
||||
JavaField left = fields[((Integer) lhs).intValue()];
|
||||
JavaField right = fields[((Integer) rhs).intValue()];
|
||||
return left.getName().compareTo(right.getName());
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < things.length; i++) {
|
||||
int index = hack[i].intValue();
|
||||
printField(fields[index]);
|
||||
out.print(" : ");
|
||||
printThing(things[index]);
|
||||
out.println("<br>");
|
||||
}
|
||||
}
|
||||
|
||||
private void printFullObjectArray(JavaObjectArray arr) {
|
||||
JavaThing[] elements = arr.getElements();
|
||||
out.println("<h1>Array of " + elements.length + " objects</h1>");
|
||||
|
||||
out.println("<h2>Class:</h2>");
|
||||
printClass(arr.getClazz());
|
||||
|
||||
out.println("<h2>Values</h2>");
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
out.print("" + i + " : ");
|
||||
printThing(elements[i]);
|
||||
out.println("<br>");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Print the StackTrace where this was allocated
|
||||
//
|
||||
private void printAllocationSite(JavaHeapObject obj) {
|
||||
StackTrace trace = obj.getAllocatedFrom();
|
||||
if (trace == null || trace.getFrames().length == 0) {
|
||||
return;
|
||||
}
|
||||
out.println("<h2>Object allocated from:</h2>");
|
||||
printStackTrace(trace);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.JavaClass;
|
||||
import com.sun.tools.hat.internal.model.Snapshot;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This class is a helper that determines if a class is a "platform"
|
||||
* class or not. It's a platform class if its name starts with one of
|
||||
* the prefixes to be found in /com/sun/tools/hat/resources/platform_names.txt.
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
public class PlatformClasses {
|
||||
|
||||
static String[] names = null;
|
||||
|
||||
|
||||
public static synchronized String[] getNames() {
|
||||
if (names == null) {
|
||||
LinkedList<String> list = new LinkedList<String>();
|
||||
InputStream str
|
||||
= PlatformClasses.class
|
||||
.getResourceAsStream("/com/sun/tools/hat/resources/platform_names.txt");
|
||||
if (str != null) {
|
||||
try {
|
||||
BufferedReader rdr
|
||||
= new BufferedReader(new InputStreamReader(str));
|
||||
for (;;) {
|
||||
String s = rdr.readLine();
|
||||
if (s == null) {
|
||||
break;
|
||||
} else if (s.length() > 0) {
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
rdr.close();
|
||||
str.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
// Shouldn't happen, and if it does, continuing
|
||||
// is the right thing to do anyway.
|
||||
}
|
||||
}
|
||||
names = list.toArray(new String[list.size()]);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPlatformClass(JavaClass clazz) {
|
||||
// all classes loaded by bootstrap loader are considered
|
||||
// platform classes. In addition, the older name based filtering
|
||||
// is also done for compatibility.
|
||||
if (clazz.isBootstrap()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = clazz.getName();
|
||||
// skip even the array classes of the skipped classes.
|
||||
if (name.startsWith("[")) {
|
||||
int index = name.lastIndexOf('[');
|
||||
if (index != -1) {
|
||||
if (name.charAt(index + 1) != 'L') {
|
||||
// some primitive array.
|
||||
return true;
|
||||
}
|
||||
// skip upto 'L' after the last '['.
|
||||
name = name.substring(index + 2);
|
||||
}
|
||||
}
|
||||
String[] nms = getNames();
|
||||
for (int i = 0; i < nms.length; i++) {
|
||||
if (name.startsWith(nms[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
239
jdkSrc/jdk8/com/sun/tools/hat/internal/server/QueryHandler.java
Normal file
239
jdkSrc/jdk8/com/sun/tools/hat/internal/server/QueryHandler.java
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import com.sun.tools.hat.internal.util.Misc;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
abstract class QueryHandler {
|
||||
|
||||
protected String urlStart;
|
||||
protected String query;
|
||||
protected PrintWriter out;
|
||||
protected Snapshot snapshot;
|
||||
|
||||
abstract void run();
|
||||
|
||||
|
||||
void setUrlStart(String s) {
|
||||
urlStart = s;
|
||||
}
|
||||
|
||||
void setQuery(String s) {
|
||||
query = s;
|
||||
}
|
||||
|
||||
void setOutput(PrintWriter o) {
|
||||
this.out = o;
|
||||
}
|
||||
|
||||
void setSnapshot(Snapshot ss) {
|
||||
this.snapshot = ss;
|
||||
}
|
||||
|
||||
protected String encodeForURL(String s) {
|
||||
try {
|
||||
s = URLEncoder.encode(s, "UTF-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
// Should never happen
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
protected void startHtml(String title) {
|
||||
out.print("<html><title>");
|
||||
print(title);
|
||||
out.println("</title>");
|
||||
out.println("<body bgcolor=\"#ffffff\"><center><h1>");
|
||||
print(title);
|
||||
out.println("</h1></center>");
|
||||
}
|
||||
|
||||
protected void endHtml() {
|
||||
out.println("</body></html>");
|
||||
}
|
||||
|
||||
protected void error(String msg) {
|
||||
println(msg);
|
||||
}
|
||||
|
||||
protected void printAnchorStart() {
|
||||
out.print("<a href=\"");
|
||||
out.print(urlStart);
|
||||
}
|
||||
|
||||
protected void printThingAnchorTag(long id) {
|
||||
printAnchorStart();
|
||||
out.print("object/");
|
||||
printHex(id);
|
||||
out.print("\">");
|
||||
}
|
||||
|
||||
protected void printObject(JavaObject obj) {
|
||||
printThing(obj);
|
||||
}
|
||||
|
||||
protected void printThing(JavaThing thing) {
|
||||
if (thing == null) {
|
||||
out.print("null");
|
||||
return;
|
||||
}
|
||||
if (thing instanceof JavaHeapObject) {
|
||||
JavaHeapObject ho = (JavaHeapObject) thing;
|
||||
long id = ho.getId();
|
||||
if (id != -1L) {
|
||||
if (ho.isNew())
|
||||
out.println("<strong>");
|
||||
printThingAnchorTag(id);
|
||||
}
|
||||
print(thing.toString());
|
||||
if (id != -1) {
|
||||
if (ho.isNew())
|
||||
out.println("[new]</strong>");
|
||||
out.print(" (" + ho.getSize() + " bytes)");
|
||||
out.println("</a>");
|
||||
}
|
||||
} else {
|
||||
print(thing.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void printRoot(Root root) {
|
||||
StackTrace st = root.getStackTrace();
|
||||
boolean traceAvailable = (st != null) && (st.getFrames().length != 0);
|
||||
if (traceAvailable) {
|
||||
printAnchorStart();
|
||||
out.print("rootStack/");
|
||||
printHex(root.getIndex());
|
||||
out.print("\">");
|
||||
}
|
||||
print(root.getDescription());
|
||||
if (traceAvailable) {
|
||||
out.print("</a>");
|
||||
}
|
||||
}
|
||||
|
||||
protected void printClass(JavaClass clazz) {
|
||||
if (clazz == null) {
|
||||
out.println("null");
|
||||
return;
|
||||
}
|
||||
printAnchorStart();
|
||||
out.print("class/");
|
||||
print(encodeForURL(clazz));
|
||||
out.print("\">");
|
||||
print(clazz.toString());
|
||||
out.println("</a>");
|
||||
}
|
||||
|
||||
protected String encodeForURL(JavaClass clazz) {
|
||||
if (clazz.getId() == -1) {
|
||||
return encodeForURL(clazz.getName());
|
||||
} else {
|
||||
return clazz.getIdString();
|
||||
}
|
||||
}
|
||||
|
||||
protected void printField(JavaField field) {
|
||||
print(field.getName() + " (" + field.getSignature() + ")");
|
||||
}
|
||||
|
||||
protected void printStatic(JavaStatic member) {
|
||||
JavaField f = member.getField();
|
||||
printField(f);
|
||||
out.print(" : ");
|
||||
if (f.hasId()) {
|
||||
JavaThing t = member.getValue();
|
||||
printThing(t);
|
||||
} else {
|
||||
print(member.getValue().toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void printStackTrace(StackTrace trace) {
|
||||
StackFrame[] frames = trace.getFrames();
|
||||
for (int i = 0; i < frames.length; i++) {
|
||||
StackFrame f = frames[i];
|
||||
String clazz = f.getClassName();
|
||||
out.print("<font color=purple>");
|
||||
print(clazz);
|
||||
out.print("</font>");
|
||||
print("." + f.getMethodName() + "(" + f.getMethodSignature() + ")");
|
||||
out.print(" <bold>:</bold> ");
|
||||
print(f.getSourceFileName() + " line " + f.getLineNumber());
|
||||
out.println("<br>");
|
||||
}
|
||||
}
|
||||
|
||||
protected void printException(Throwable t) {
|
||||
println(t.getMessage());
|
||||
out.println("<pre>");
|
||||
StringWriter sw = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(sw));
|
||||
print(sw.toString());
|
||||
out.println("</pre>");
|
||||
}
|
||||
|
||||
protected void printHex(long addr) {
|
||||
if (snapshot.getIdentifierSize() == 4) {
|
||||
out.print(Misc.toHex((int)addr));
|
||||
} else {
|
||||
out.print(Misc.toHex(addr));
|
||||
}
|
||||
}
|
||||
|
||||
protected long parseHex(String value) {
|
||||
return Misc.parseHex(value);
|
||||
}
|
||||
|
||||
protected void print(String str) {
|
||||
out.print(Misc.encodeHtml(str));
|
||||
}
|
||||
|
||||
protected void println(String str) {
|
||||
out.println(Misc.encodeHtml(str));
|
||||
}
|
||||
}
|
||||
111
jdkSrc/jdk8/com/sun/tools/hat/internal/server/QueryListener.java
Normal file
111
jdkSrc/jdk8/com/sun/tools/hat/internal/server/QueryListener.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
import java.net.Socket;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.BufferedOutputStream;
|
||||
|
||||
import com.sun.tools.hat.internal.model.Snapshot;
|
||||
import com.sun.tools.hat.internal.oql.OQLEngine;
|
||||
|
||||
public class QueryListener implements Runnable {
|
||||
|
||||
|
||||
private Snapshot snapshot;
|
||||
private OQLEngine engine;
|
||||
private int port;
|
||||
|
||||
public QueryListener(int port) {
|
||||
this.port = port;
|
||||
this.snapshot = null; // Client will setModel when it's ready
|
||||
this.engine = null; // created when snapshot is set
|
||||
}
|
||||
|
||||
public void setModel(Snapshot ss) {
|
||||
this.snapshot = ss;
|
||||
if (OQLEngine.isOQLSupported()) {
|
||||
this.engine = new OQLEngine(ss);
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
waitForRequests();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void waitForRequests() throws IOException {
|
||||
ServerSocket ss = new ServerSocket(port);
|
||||
Thread last = null;
|
||||
for (;;) {
|
||||
Socket s = ss.accept();
|
||||
Thread t = new Thread(new HttpReader(s, snapshot, engine));
|
||||
if (snapshot == null) {
|
||||
t.setPriority(Thread.NORM_PRIORITY+1);
|
||||
} else {
|
||||
t.setPriority(Thread.NORM_PRIORITY-1);
|
||||
if (last != null) {
|
||||
try {
|
||||
last.setPriority(Thread.NORM_PRIORITY-2);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
// If the thread is no longer alive, we'll get a
|
||||
// NullPointerException
|
||||
}
|
||||
}
|
||||
t.start();
|
||||
last = t;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class ReachableQuery extends QueryHandler {
|
||||
// We inherit printFullClass from ClassQuery
|
||||
|
||||
|
||||
public ReachableQuery() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
startHtml("Objects Reachable From " + query);
|
||||
long id = parseHex(query);
|
||||
JavaHeapObject root = snapshot.findThing(id);
|
||||
ReachableObjects ro = new ReachableObjects(root,
|
||||
snapshot.getReachableExcludes());
|
||||
// Now, print out the sorted list, but start with root
|
||||
long totalSize = ro.getTotalSize();
|
||||
JavaThing[] things = ro.getReachables();
|
||||
long instances = things.length;
|
||||
|
||||
out.print("<strong>");
|
||||
printThing(root);
|
||||
out.println("</strong><br>");
|
||||
out.println("<br>");
|
||||
for (int i = 0; i < things.length; i++) {
|
||||
printThing(things[i]);
|
||||
out.println("<br>");
|
||||
}
|
||||
|
||||
printFields(ro.getUsedFields(), "Data Members Followed");
|
||||
printFields(ro.getExcludedFields(), "Excluded Data Members");
|
||||
out.println("<h2>Total of " + instances + " instances occupying " + totalSize + " bytes.</h2>");
|
||||
|
||||
endHtml();
|
||||
}
|
||||
|
||||
private void printFields(String[] fields, String title) {
|
||||
if (fields.length == 0) {
|
||||
return;
|
||||
}
|
||||
out.print("<h3>");
|
||||
print(title);
|
||||
out.println("</h3>");
|
||||
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
print(fields[i]);
|
||||
out.println("<br>");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* References by type summary
|
||||
*
|
||||
*/
|
||||
public class RefsByTypeQuery extends QueryHandler {
|
||||
public void run() {
|
||||
JavaClass clazz = snapshot.findClass(query);
|
||||
if (clazz == null) {
|
||||
error("class not found: " + query);
|
||||
} else {
|
||||
Map<JavaClass, Long> referrersStat = new HashMap<JavaClass, Long>();
|
||||
final Map<JavaClass, Long> refereesStat = new HashMap<JavaClass, Long>();
|
||||
Enumeration instances = clazz.getInstances(false);
|
||||
while (instances.hasMoreElements()) {
|
||||
JavaHeapObject instance = (JavaHeapObject) instances.nextElement();
|
||||
if (instance.getId() == -1) {
|
||||
continue;
|
||||
}
|
||||
Enumeration e = instance.getReferers();
|
||||
while (e.hasMoreElements()) {
|
||||
JavaHeapObject ref = (JavaHeapObject) e.nextElement();
|
||||
JavaClass cl = ref.getClazz();
|
||||
if (cl == null) {
|
||||
System.out.println("null class for " + ref);
|
||||
continue;
|
||||
}
|
||||
Long count = referrersStat.get(cl);
|
||||
if (count == null) {
|
||||
count = new Long(1);
|
||||
} else {
|
||||
count = new Long(count.longValue() + 1);
|
||||
}
|
||||
referrersStat.put(cl, count);
|
||||
}
|
||||
instance.visitReferencedObjects(
|
||||
new AbstractJavaHeapObjectVisitor() {
|
||||
public void visit(JavaHeapObject obj) {
|
||||
JavaClass cl = obj.getClazz();
|
||||
Long count = refereesStat.get(cl);
|
||||
if (count == null) {
|
||||
count = new Long(1);
|
||||
} else {
|
||||
count = new Long(count.longValue() + 1);
|
||||
}
|
||||
refereesStat.put(cl, count);
|
||||
}
|
||||
}
|
||||
);
|
||||
} // for each instance
|
||||
|
||||
startHtml("References by Type");
|
||||
out.println("<p align='center'>");
|
||||
printClass(clazz);
|
||||
if (clazz.getId() != -1) {
|
||||
println("[" + clazz.getIdString() + "]");
|
||||
}
|
||||
out.println("</p>");
|
||||
|
||||
if (referrersStat.size() != 0) {
|
||||
out.println("<h3 align='center'>Referrers by Type</h3>");
|
||||
print(referrersStat);
|
||||
}
|
||||
|
||||
if (refereesStat.size() != 0) {
|
||||
out.println("<h3 align='center'>Referees by Type</h3>");
|
||||
print(refereesStat);
|
||||
}
|
||||
|
||||
endHtml();
|
||||
} // clazz != null
|
||||
} // run
|
||||
|
||||
private void print(final Map<JavaClass, Long> map) {
|
||||
out.println("<table border='1' align='center'>");
|
||||
Set<JavaClass> keys = map.keySet();
|
||||
JavaClass[] classes = new JavaClass[keys.size()];
|
||||
keys.toArray(classes);
|
||||
Arrays.sort(classes, new Comparator<JavaClass>() {
|
||||
public int compare(JavaClass first, JavaClass second) {
|
||||
Long count1 = map.get(first);
|
||||
Long count2 = map.get(second);
|
||||
return count2.compareTo(count1);
|
||||
}
|
||||
});
|
||||
|
||||
out.println("<tr><th>Class</th><th>Count</th></tr>");
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
JavaClass clazz = classes[i];
|
||||
out.println("<tr><td>");
|
||||
out.print("<a href='/refsByType/");
|
||||
print(clazz.getIdString());
|
||||
out.print("'>");
|
||||
print(clazz.getName());
|
||||
out.println("</a>");
|
||||
out.println("</td><td>");
|
||||
out.println(map.get(clazz));
|
||||
out.println("</td></tr>");
|
||||
}
|
||||
out.println("</table>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
|
||||
/**
|
||||
* Query to show the StackTrace for a given root
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class RootStackQuery extends QueryHandler {
|
||||
|
||||
public RootStackQuery() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
int index = (int) parseHex(query);
|
||||
Root root = snapshot.getRootAt(index);
|
||||
if (root == null) {
|
||||
error("Root at " + index + " not found");
|
||||
return;
|
||||
}
|
||||
StackTrace st = root.getStackTrace();
|
||||
if (st == null || st.getFrames().length == 0) {
|
||||
error("No stack trace for " + root.getDescription());
|
||||
return;
|
||||
}
|
||||
startHtml("Stack Trace for " + root.getDescription());
|
||||
out.println("<p>");
|
||||
printStackTrace(st);
|
||||
out.println("</p>");
|
||||
endHtml();
|
||||
}
|
||||
|
||||
}
|
||||
147
jdkSrc/jdk8/com/sun/tools/hat/internal/server/RootsQuery.java
Normal file
147
jdkSrc/jdk8/com/sun/tools/hat/internal/server/RootsQuery.java
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The Original Code is HAT. The Initial Developer of the
|
||||
* Original Code is Bill Foote, with contributions from others
|
||||
* at JavaSoft/Sun.
|
||||
*/
|
||||
|
||||
package com.sun.tools.hat.internal.server;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.tools.hat.internal.model.*;
|
||||
import com.sun.tools.hat.internal.util.ArraySorter;
|
||||
import com.sun.tools.hat.internal.util.Comparer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Bill Foote
|
||||
*/
|
||||
|
||||
|
||||
class RootsQuery extends QueryHandler {
|
||||
|
||||
private boolean includeWeak;
|
||||
|
||||
public RootsQuery(boolean includeWeak) {
|
||||
this.includeWeak = includeWeak;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
long id = parseHex(query);
|
||||
JavaHeapObject target = snapshot.findThing(id);
|
||||
if (target == null) {
|
||||
startHtml("Object not found for rootset");
|
||||
error("object not found");
|
||||
endHtml();
|
||||
return;
|
||||
}
|
||||
if (includeWeak) {
|
||||
startHtml("Rootset references to " + target
|
||||
+ " (includes weak refs)");
|
||||
} else {
|
||||
startHtml("Rootset references to " + target
|
||||
+ " (excludes weak refs)");
|
||||
}
|
||||
out.flush();
|
||||
|
||||
ReferenceChain[] refs
|
||||
= snapshot.rootsetReferencesTo(target, includeWeak);
|
||||
ArraySorter.sort(refs, new Comparer() {
|
||||
public int compare(Object lhs, Object rhs) {
|
||||
ReferenceChain left = (ReferenceChain) lhs;
|
||||
ReferenceChain right = (ReferenceChain) rhs;
|
||||
Root leftR = left.getObj().getRoot();
|
||||
Root rightR = right.getObj().getRoot();
|
||||
int d = leftR.getType() - rightR.getType();
|
||||
if (d != 0) {
|
||||
return -d; // More interesting values are *higher*
|
||||
}
|
||||
return left.getDepth() - right.getDepth();
|
||||
}
|
||||
});
|
||||
|
||||
out.print("<h1>References to ");
|
||||
printThing(target);
|
||||
out.println("</h1>");
|
||||
int lastType = Root.INVALID_TYPE;
|
||||
for (int i= 0; i < refs.length; i++) {
|
||||
ReferenceChain ref = refs[i];
|
||||
Root root = ref.getObj().getRoot();
|
||||
if (root.getType() != lastType) {
|
||||
lastType = root.getType();
|
||||
out.print("<h2>");
|
||||
print(root.getTypeName() + " References");
|
||||
out.println("</h2>");
|
||||
}
|
||||
out.print("<h3>");
|
||||
printRoot(root);
|
||||
if (root.getReferer() != null) {
|
||||
out.print("<small> (from ");
|
||||
printThingAnchorTag(root.getReferer().getId());
|
||||
print(root.getReferer().toString());
|
||||
out.print(")</a></small>");
|
||||
|
||||
}
|
||||
out.print(" :</h3>");
|
||||
while (ref != null) {
|
||||
ReferenceChain next = ref.getNext();
|
||||
JavaHeapObject obj = ref.getObj();
|
||||
print("--> ");
|
||||
printThing(obj);
|
||||
if (next != null) {
|
||||
print(" (" +
|
||||
obj.describeReferenceTo(next.getObj(), snapshot)
|
||||
+ ":)");
|
||||
}
|
||||
out.println("<br>");
|
||||
ref = next;
|
||||
}
|
||||
}
|
||||
|
||||
out.println("<h2>Other queries</h2>");
|
||||
|
||||
if (includeWeak) {
|
||||
printAnchorStart();
|
||||
out.print("roots/");
|
||||
printHex(id);
|
||||
out.print("\">");
|
||||
out.println("Exclude weak refs</a><br>");
|
||||
endHtml();
|
||||
}
|
||||
|
||||
if (!includeWeak) {
|
||||
printAnchorStart();
|
||||
out.print("allRoots/");
|
||||
printHex(id);
|
||||
out.print("\">");
|
||||
out.println("Include weak refs</a><br>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user