src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java
Print this page
rev 10195 : 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
Reviewed-by: chegar, psandoz
Contributed-by: otaviojava@java.net
*** 213,231 ****
switch (type) {
case HPROF_UTF8: {
long id = readID();
byte[] chars = new byte[(int)length - identifierSize];
in.readFully(chars);
! names.put(new Long(id), new String(chars));
break;
}
case HPROF_LOAD_CLASS: {
int serialNo = in.readInt(); // Not used
long classID = readID();
int stackTraceSerialNo = in.readInt();
long classNameID = readID();
! Long classIdI = new Long(classID);
String nm = getNameFromID(classNameID).replace('/', '.');
classNameFromObjectID.put(classIdI, nm);
if (classNameFromSerialNo != null) {
classNameFromSerialNo.put(new Integer(serialNo), nm);
}
--- 213,231 ----
switch (type) {
case HPROF_UTF8: {
long id = readID();
byte[] chars = new byte[(int)length - identifierSize];
in.readFully(chars);
! names.put(id, new String(chars));
break;
}
case HPROF_LOAD_CLASS: {
int serialNo = in.readInt(); // Not used
long classID = readID();
int stackTraceSerialNo = in.readInt();
long classNameID = readID();
! Long classIdI = classID;
String nm = getNameFromID(classNameID).replace('/', '.');
classNameFromObjectID.put(classIdI, nm);
if (classNameFromSerialNo != null) {
classNameFromSerialNo.put(new Integer(serialNo), nm);
}
*** 301,311 ****
int lineNumber = in.readInt();
if (lineNumber < StackFrame.LINE_NUMBER_NATIVE) {
warn("Weird stack frame line number: " + lineNumber);
lineNumber = StackFrame.LINE_NUMBER_UNKNOWN;
}
! stackFrames.put(new Long(id),
new StackFrame(methodName, methodSig,
className, sourceFile,
lineNumber));
}
break;
--- 301,311 ----
int lineNumber = in.readInt();
if (lineNumber < StackFrame.LINE_NUMBER_NATIVE) {
warn("Weird stack frame line number: " + lineNumber);
lineNumber = StackFrame.LINE_NUMBER_UNKNOWN;
}
! stackFrames.put(id,
new StackFrame(methodName, methodSig,
className, sourceFile,
lineNumber));
}
break;
*** 317,327 ****
int serialNo = in.readInt();
int threadSeq = in.readInt(); // Not used
StackFrame[] frames = new StackFrame[in.readInt()];
for (int i = 0; i < frames.length; i++) {
long fid = readID();
! frames[i] = stackFrames.get(new Long(fid));
if (frames[i] == null) {
throw new IOException("Stack frame " + toHex(fid) + " not found");
}
}
stackTraces.put(new Integer(serialNo),
--- 317,327 ----
int serialNo = in.readInt();
int threadSeq = in.readInt(); // Not used
StackFrame[] frames = new StackFrame[in.readInt()];
for (int i = 0; i < frames.length; i++) {
long fid = readID();
! frames[i] = stackFrames.get(fid);
if (frames[i] == null) {
throw new IOException("Stack frame " + toHex(fid) + " not found");
}
}
stackTraces.put(new Integer(serialNo),
*** 617,627 ****
}
return to;
}
private String getNameFromID(long id) throws IOException {
! return getNameFromID(new Long(id));
}
private String getNameFromID(Long id) throws IOException {
if (id.longValue() == 0L) {
return "";
--- 617,627 ----
}
return to;
}
private String getNameFromID(long id) throws IOException {
! return getNameFromID(id);
}
private String getNameFromID(Long id) throws IOException {
if (id.longValue() == 0L) {
return "";
*** 701,711 ****
type = signatureFromTypeId(type);
}
String signature = "" + ((char) type);
fields[i] = new JavaField(fieldName, signature);
}
! String name = classNameFromObjectID.get(new Long(id));
if (name == null) {
warn("Class name not found for " + toHex(id));
name = "unknown-name@" + toHex(id);
}
JavaClass c = new JavaClass(id, name, superId, classLoaderId, signersId,
--- 701,711 ----
type = signatureFromTypeId(type);
}
String signature = "" + ((char) type);
fields[i] = new JavaField(fieldName, signature);
}
! String name = classNameFromObjectID.get(id);
if (name == null) {
warn("Class name not found for " + toHex(id));
name = "unknown-name@" + toHex(id);
}
JavaClass c = new JavaClass(id, name, superId, classLoaderId, signersId,