EMMA Coverage Report (generated Sat Jun 02 16:47:50 EDT 2012)
[all classes][net.sf.madmap]

COVERAGE SUMMARY FOR SOURCE FILE [HprofBinClassElement.java]

nameclass, %method, %block, %line, %
HprofBinClassElement.java100% (1/1)71%  (10/14)95%  (334/353)92%  (54.2/59)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HprofBinClassElement100% (1/1)71%  (10/14)95%  (334/353)92%  (54.2/59)
setLoader (long): void 0%   (0/1)0%   (0/4)0%   (0/1)
setRefSize (int): void 0%   (0/1)0%   (0/3)0%   (0/1)
setSuper (long): void 0%   (0/1)0%   (0/4)0%   (0/1)
setTrace (long): void 0%   (0/1)0%   (0/1)0%   (0/1)
setNonStaticTypeInfo (ArrayList): void 100% (1/1)62%  (8/13)81%  (2.4/3)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
HprofBinClassElement (long, String): void 100% (1/1)100% (21/21)100% (6/6)
buildSuperTypeInfo (AbstractMap): ArrayList 100% (1/1)100% (45/45)100% (8/8)
getNonStaticTypeInfo (): ArrayList 100% (1/1)100% (3/3)100% (1/1)
getRefSize (): int 100% (1/1)100% (2/2)100% (1/1)
getSizeForTypeInfo (): int 100% (1/1)100% (36/36)100% (10/10)
getSuper (): long 100% (1/1)100% (3/3)100% (1/1)
toString (): String 100% (1/1)100% (192/192)100% (18/18)
updateLoadClass (int, long, long, long, ArrayList, ArrayList): void 100% (1/1)100% (18/18)100% (6/6)

1/*
2 * Copyright 2008 Eric Caspole
3 * 
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5 * file except in compliance with the License. You may obtain a copy of the License at
6 * 
7 * http://www.apache.org/licenses/LICENSE-2.0
8 * 
9 * Unless required by applicable law or agreed to in writing, software distributed under
10 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14 
15package net.sf.madmap;
16 
17import java.io.*;
18import java.util.*;
19 
20/**
21 * HprofBinClassElement is the representation of a java class in a binary heap dump. 
22 * 
23 * @author ecaspole
24 *  
25 */
26public class HprofBinClassElement  extends HprofClassElement {
27  ArrayList<Byte> _nonstatic_type_info = null;
28  
29  static int  _refSize;
30  public static void setRefSize(int sz)  { _refSize = sz; }
31  public static int  getRefSize()        { return _refSize; }
32  
33  void setLoader(long loader)  { _loader = loader; }
34  void setSuper(long sooper)  { _super = sooper; }
35  long getSuper()  { return _super; }
36 
37  void setTrace(long trace)  { /* ignored for now */; }
38  
39  void setNonStaticTypeInfo(ArrayList<Byte> info) { 
40    assert info != null: "should not be null";
41    _nonstatic_type_info = info; 
42  }
43  ArrayList<Byte> getNonStaticTypeInfo()          { return _nonstatic_type_info; }
44 
45  public void updateLoadClass(int trc, long instanceSize, long sooperclass, long loader, ArrayList n, ArrayList r) {
46    _super        = sooperclass;
47    _loader       = loader;
48    _instance_size = instanceSize;
49    if (( n != null ) && ( r != null )) { 
50      buildActualChildrenRefs( n, r );
51    }
52  }
53  
54  public HprofBinClassElement( long addr, String tn ) {
55    super(addr, tn);
56    _nonstatic_type_info = new ArrayList<Byte>();
57    _nonstatic_names = new ArrayList();
58  }
59  
60  public int getSizeForTypeInfo() {
61    int totalSize = 0;
62    
63    if (_nonstatic_type_info != null) {
64      ListIterator<Byte> ityp = _nonstatic_type_info.listIterator();
65      while(ityp.hasNext()) {
66        
67        Byte typeCode = ityp.next();
68        if (typeCode == 2) {
69          totalSize += getRefSize();
70        } else {
71          totalSize += BasicTypeInfo.DUMMY.get(typeCode).getSize();
72        }
73      }
74    }
75    return totalSize;
76  }
77 
78  boolean _typeComplete = false;
79  
80  public ArrayList<Byte> buildSuperTypeInfo(java.util.AbstractMap<HprofClassElement,HprofClassElement> h) { 
81    if (getSuper() != 0 && (!_typeComplete)) {
82      int currTypeInfoSize = getSizeForTypeInfo();
83      if (currTypeInfoSize < instanceSize()) {
84        HprofBinClassElement sooper = (HprofBinClassElement)h.get(new HprofHeapElement(getSuper()));
85        _nonstatic_type_info.addAll(sooper.buildSuperTypeInfo(h));
86        _nonstatic_names.addAll(sooper.nonstatic_field_names());
87      }
88      _typeComplete = true;
89    }    
90 
91    //if (MadmapMain.runDump()) {
92    //  System. out. println ( "buildSuperTypeInfo:  0x" + Long.toHexString( this.addr() ) + " " + this.className() + 
93    //      " super: 0x" + Long.toHexString(getSuper()) + " " + _nonstatic_type_info);
94    //}
95    return _nonstatic_type_info;
96  }
97 
98  public String toString() {
99    StringBuffer p = new StringBuffer();
100  
101    p.append( "CLS " + Long.toHexString(_objectaddr) + " (name=" + _type_name + /* ", trace=" + getStackTrace() + */ ")\n" );
102    p.append( "  " + "super" + "\t" + Long.toHexString( _super ) + "\n");
103    p.append( "  " + "loader" + "\t" + Long.toHexString( _loader ) + "\n");
104    if ( _static_names != null ) {
105      for (int i = 0; i < _static_names.length; i++ ) {
106        String n = (String) _static_names[ i ];
107        Long r = (Long) _static_refs[ i ];
108        p.append( "  static " + n + "\t" + Long.toHexString( r )  + "\n");
109      }
110    }
111    if ( _nonstatic_names != null ) {
112      p.append("  # _nonstatic_names.length  : " + _nonstatic_names.size() + "\n");
113      p.append("  # _nonstatic_names = " + _nonstatic_names + "\n");
114      if (_nonstatic_type_info != null) {
115        p.append("  # _nonstatic_type_info sz = " + _nonstatic_type_info.size() + "\n");
116      }
117    }
118    p.append( "  # _instance_size = " + _instance_size + "\n");
119    p.append( "  # instance count = " + getInstanceCount() + "\n");
120    p.append( "  # instance total sz = " + getInstanceSize() + "\n");
121    
122    return p.toString();
123  }
124}

[all classes][net.sf.madmap]
EMMA 2.0.5312 (C) Vladimir Roubtsov