emma

if (oin != null) {
        try
        {
          oin.close();
        }
        catch (Exception ignore) {}
      }
    }
  }
  
  public static void writeCoverageData(ICoverageData data, OutputStream out)
    throws IOException
  {
    ObjectOutputStream oout = new ObjectOutputStream(out);
    oout.writeObject(data);
  }
  
  public static int[] readIntArray(DataInput in)
    throws IOException
  {
    int length = in.readInt();
    if (length == -1) {
      return null;
    }
    int[] result = new int[length];
    
    int i = length;
    for (;;)
    {
      i--;
      if (i < 0) {
        break;
      }
      result[i] = in.readInt();
    }
    return result;
  }
  
  public static boolean[] readBooleanArray(DataInput in)
    throws IOException
  {
    int length = in.readInt();
    if (length == -1) {
      return null;
    }
    boolean[] result = new boolean[length];
    
    int i = length;
    for (;;)
    {
      i--;
      if (i < 0) {
        break;
      }
      result[i] = in.readBoolean();
    }
    return result;
  }
  
  public static void writeIntArray(int[] array, DataOutput out)
    throws IOException
  {
    if (array == null)
    {
      out.writeInt(-1);
    }
    else
    {
      int length = array.length;
      out.writeInt(length);
      
      int i = length;
      for (;;)
      {
        i--;
        if (i < 0) {
          break;
        }
        out.writeInt(array[i]);
      }
    }
  }
  
  public static void writeBooleanArray(boolean[] array, DataOutput out)
    throws IOException
  {
    if (array == null)
    {
      out.writeInt(-1);
    }
    else
    {
      int length = array.length;
      out.writeInt(length);
      
      int i = length;
      for (;;)
      {
        i--;
        if (i < 0) {
          break;
        }
        out.writeBoolean(array[i]);
      }
    }
  }
  
  private static final class UCFileInputStream
    extends FileInputStream
  {
    public void close() {}
    
    UCFileInputStream(FileDescriptor fd)
    {
      super();
    }
  }
  
  private static final class UCFileOutputStream
    extends FileOutputStream
  {
    public void close() {}
    
    UCFileOutputStream(FileDescriptor fd)
    {
      super();
    }
  }
  
  private static final class RandomAccessFileInputStream
    extends BufferedInputStream
  {
    private long m_count;
    
    public final int read()
      throws IOException
    {
      int rc = super.read();
      if (rc >= 0) {
        m_count += 1L;
      }
      return rc;
    }
    
    public final int read(byte[] b, int off, int len)
      throws IOException
    {
      int rc = super.read(b, off, len);
      if (rc >= 0) {
        m_count += rc;
      }
      return rc;
    }
    
    public final int read(byte[] b)
      throws IOException
    {
      int rc = super.read(b);
      if (rc >= 0) {
        m_count += rc;
      }
      return rc;
    }
    
    public void close() {}
    
    RandomAccessFileInputStream(RandomAccessFile raf, int bufSize)
      throws IOException
    {
      super(bufSize);
    }
    
    final long getCount()
    {
      return m_count;
    }
  }
  
  private static final class RandomAccessFileOutputStream
    extends BufferedOutputStream
  {
    private long m_count;
    
    public final void write(byte[] b, int off, int len)
      throws IOException
    {
      super.write(b, off, len);
      m_count += len;
    }
    
    public final void write(byte[] b)
      throws IOException
    {
      super.write(b);
      m_count += b.length;
    }
    
    public final void write(int b)
      throws IOException
    {
      super.write(b);
      m_count += 1L;
    }
    
    public void close() {}
    
    RandomAccessFileOutputStream(RandomAccessFile raf, int bufSize)
      throws IOException
    {
      super(bufSize);
    }
    
    final long getCount()
    {
      return m_count;
    }
  }
  
  private static IMergeable[] mergeload(File file)
    throws IOException
  {
    Logger log = Logger.getLogger();
    boolean trace1 = log.atTRACE1();
    boolean trace2 = log.atTRACE2();
    String method = "mergeload";
    
    long start = 0L;
    if (trace1) {
      start = System.currentTimeMillis();
    }
    IMergeable[] result = new IMergeable[2];
    if (!file.exists()) {
      throw new IOException("input file does not exist: [" + file.getAbsolutePath() + "]");
    }
    RandomAccessFile raf = null;
    try
    {
      raf = new RandomAccessFile(file, "r");
      
      long length = raf.length();
      if (trace1) {
        log.trace1("mergeload", "[" + file + "]: file length = " + length);
      }
      if (length < 24L) {
        throw new IOException("file [" + file.getAbsolutePath() + "] is corrupt or was not created by " + "EMMA");
      }
      if (length > 24L)
      {
        raf.seek(24L);
        
        long position = 24L;
        
        long entrystart = 0L;
        for (;;)
        {
          if (trace2) {
            log.trace2("mergeload", "[" + file + "]: position " + raf.getFilePointer());
          }
          if (position >= length) {
            break;
          }
          long entryLength = raf.readLong();
          if ((entryLength <= 0L) || (position + entryLength + 9L > length)) {
            break;
          }
          byte type = raf.readByte();
          if ((type < 0) || (type >= result.length)) {
            break;
          }
          if (trace2) {
            log.trace2("mergeload", "[" + file + "]: found valid entry of size " + entryLength + " and type " + type);
          }
          if (trace2) {
            entrystart = System.currentTimeMillis();
          }
          IMergeable data = readEntry(raf, type, entryLength);
          if (trace2) {
            log.trace2("mergeload", "entry read in " + (System.currentTimeMillis() - entrystart) + " ms");
          }
          IMergeable current = result[type];
          if (current == null) {
            result[type] = data;
          } else {
            result[type] = current.merge(data);
          }
          position += entryLength + 9L;
          
          raf.seek(position);
        }
      }
    }
    finally
    {
      if (raf != null) {
        try
        {
          raf.close();
        }
        catch (Throwable ignore) {}
      }
      raf = null;
    }
    if (trace1)
    {
      long end = System.currentTimeMillis();
      
      log.trace1("mergeload", "[" + file + "]: file processed in " + (end - start) + " ms");
    }
    return result;
  }
  
  private static void persist(IMergeable data, byte type, File file)
    throws IOException
  {
    Logger log = Logger.getLogger();
    boolean trace1 = log.atTRACE1();
    boolean trace2 = log.atTRACE2();
    String method = "persist";
    
    long start = 0L;
    if (trace1) {
      start = System.currentTimeMillis();
    }
    RandomAccessFile raf = null;
    try
    {
      boolean overwrite = false;
      boolean truncate = false;
      if (file.exists())
      {
        if (!file.isFile()) {
          throw new IOException("can persist in normal files only: " + file.getAbsolutePath());
        }
        raf = new RandomAccessFile(file, "rw");
        
        long length = raf.length();
        if (trace1) {
          log.trace1("persist", "[" + file + "]: existing file length = " + length);
        }
        if (length < 4L)
        {
          overwrite = true;
          truncate = length > 0L;
        }
        else
        {
          int magic = raf.readInt();
          if (magic != 1162693953) {
            throw new IOException("cannot overwrite [" + file.getAbsolutePath() + "]: not created by " + "EMMA");
          }
          if (length < 24L)
          {
            overwrite = true;
            truncate = true;
          }
          else
          {
            long dataVersion = raf.readLong();
            if (dataVersion != 32L)
            {
              int major = 0;int minor = 0;int build = 0;
              boolean gotAppVersion = false;
              try
              {
                major = raf.readInt();
                minor = raf.readInt();
                build = raf.readInt();
                
                gotAppVersion = true;
              }
              catch (Throwable ignore) {}
              if (gotAppVersion) {
                throw new IOException("cannot merge new data into [" + file.getAbsolutePath() + "]: created by another " + "EMMA" + " version [" + makeAppVersion(major, minor, build) + "]");
              }
              throw new IOException("cannot merge new data into [" + file.getAbsolutePath() + "]: created by another " + "EMMA" + " version");
            }
            raf.seek(24L);
            if (length == 24L)
            {
              writeEntry(log, raf, 24L, data, type);
            }
            else
            {
              long position = 24L;
              for (;;)
              {
                if (trace2) {
                  log.trace2("persist", "[" + file + "]: position " + raf.getFilePointer());
                }
                if (position >= length) {
                  break;
                }
                long entryLength = raf.readLong();
                if ((entryLength <= 0L) || (position + entryLength + 9L > length)) {
                  break;
                }
                if (trace2) {
                  log.trace2("persist", "[" + file + "]: found valid entry of size " + entryLength);
                }
                position += entryLength + 9L;
                raf.seek(position);
              }
              if (trace2) {
                log.trace2("persist", "[" + file + "]: adding entry at position " + position);
              }
              writeEntry(log, raf, position, data, type);
            }
          }
        }
      }
      else
      {
        if (trace1) {
          log.trace1("persist", "[" + file + "]: creating a new file");
        }
        File parent = file.getParentFile();
        if (parent != null) {
          parent.mkdirs();
        }
        raf = new RandomAccessFile(file, "rw");
        
        overwrite = true;
      }
      if (overwrite)
      {
        if (truncate) {
          raf.seek(0L);
        }
        writeFileHeader(raf);
        
        writeEntry(log, raf, 24L, data, type);
      }
    }
    finally
    {
      if (raf != null) {
        try
        {
          raf.close();
        }
        catch (Throwable ignore) {}
      }
      raf = null;
    }
    if (trace1)
    {
      long end = System.currentTimeMillis();
      
      log.trace1("persist", "[" + file + "]: file processed in " + (end - start) + " ms");
    }
  }
  
  private static void writeFileHeader(DataOutput out)
    throws IOException
  {
    out.writeInt(1162693953);
    
    out.writeLong(32L);
    
    out.writeInt(2);
    out.writeInt(0);
    out.writeInt(5312);
  }
  
  private static void writeEntryHeader(DataOutput out, byte type)
    throws IOException
  {
    out.writeLong(0L);
    out.writeByte(type);
  }
  
  private static void writeEntry(Logger log, RandomAccessFile raf, long marker, IMergeable data, byte type)
    throws IOException
  {
    writeEntryHeader(raf, type);
    
    RandomAccessFileOutputStream rafout = new RandomAccessFileOutputStream(raf, 32768);
    
    DataOutputStream dout = new DataOutputStream(rafout);
    switch (type)
    {
    case 0: 
      MetaData.writeExternal((MetaData)data, dout);
      break;
    default: 
      CoverageData.writeExternal((CoverageData)data, dout);
    }
    dout.flush();
    dout = null;
    
    raf.setLength(raf.getFilePointer());
    
    raf.seek(marker);
    raf.writeLong(rafout.getCount());
    raf.getFD().sync();
    if (log.atTRACE2()) {
      log.trace2("writeEntry", "entry [" + data.getClass().getName() + "] length: " + rafout.getCount());
    }
  }
  
  private static IMergeable readEntry(RandomAccessFile raf, byte type, long entryLength)
    throws IOException
  {
    RandomAccessFileInputStream rafin = new RandomAccessFileInputStream(raf, 32768);
    
    DataInputStream din = new DataInputStream(rafin);
    Object data;
    Object data;
    switch (type)
    {
    case 0: 
      data = MetaData.readExternal(din);
      break;
    default: 
      data = CoverageData.readExternal(din);
    }
    return (IMergeable)data;
  }
  
  private static String makeAppVersion(int major, int minor, int build)
  {
    StringBuffer buf = new StringBuffer();
    
    buf.append(major);
    buf.append('.');
    buf.append(minor);
    buf.append('.');
    buf.append(build);
    
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.DataFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

public final class ICoverageData$DataHolder
{
  public final boolean[][] m_coverage;
  public final long m_stamp;
  
  public ICoverageData$DataHolder(boolean[][] coverage, long stamp)
  {
    m_coverage = coverage;
    m_stamp = stamp;
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.ICoverageData.DataHolder
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

public abstract interface ICoverageData
  extends IMergeable
{
  public abstract Object lock();
  
  public abstract ICoverageData shallowCopy();
  
  public abstract int size();
  
  public abstract DataHolder getCoverage(ClassDescriptor paramClassDescriptor);
  
  public abstract void addClass(boolean[][] paramArrayOfBoolean, String paramString, long paramLong);
  
  public static final class DataHolder
  {
    public final boolean[][] m_coverage;
    public final long m_stamp;
    
    public DataHolder(boolean[][] coverage, long stamp)
    {
      m_coverage = coverage;
      m_stamp = stamp;
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.ICoverageData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

import java.io.Serializable;

public abstract interface IMergeable
  extends Serializable
{
  public abstract boolean isEmpty();
  
  public abstract IMergeable merge(IMergeable paramIMergeable);
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.IMergeable
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

import java.util.Iterator;

public abstract interface IMetaData
  extends IMergeable
{
  public abstract Object lock();
  
  public abstract IMetaData shallowCopy();
  
  public abstract CoverageOptions getOptions();
  
  public abstract int size();
  
  public abstract boolean hasSrcFileData();
  
  public abstract boolean hasLineNumberData();
  
  public abstract boolean hasDescriptor(String paramString);
  
  public abstract Iterator iterator();
  
  public abstract boolean add(ClassDescriptor paramClassDescriptor, boolean paramBoolean);
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.IMetaData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

public abstract interface IMetadataConstants
{
  public static final int METHOD_NO_LINE_NUMBER_TABLE = 1;
  public static final int METHOD_ABSTRACT_OR_NATIVE = 2;
  public static final int METHOD_EXCLUDED = 4;
  public static final int METHOD_ADDED = 8;
  public static final int METHOD_NO_BLOCK_DATA = 14;
  public static final int METHOD_NO_LINE_DATA = 15;
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.IMetadataConstants
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

public abstract interface ISessionData
{
  public abstract IMetaData getMetaData();
  
  public abstract ICoverageData getCoverageData();
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.ISessionData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

import com.vladium.emma.EMMARuntimeException;
import com.vladium.emma.IAppErrorCodes;
import com.vladium.emma.Processor;
import com.vladium.logging.Logger;
import com.vladium.util.Files;
import com.vladium.util.IConstants;
import com.vladium.util.IProperties;
import com.vladium.util.asserts..assert;
import com.vladium.util.exception.Exceptions;
import java.io.File;
import java.io.IOException;

public final class MergeProcessor
  extends Processor
  implements IAppErrorCodes
{
  private File[] m_dataPath;
  private File m_sdataOutFile;
  private int m_dataFileCount;
  
  public static MergeProcessor create()
  {
    return new MergeProcessor();
  }
  
  public final synchronized void setDataPath(String[] path)
  {
    if ((path == null) || (path.length == 0)) {
      m_dataPath = IConstants.EMPTY_FILE_ARRAY;
    } else {
      m_dataPath = Files.pathToFiles(path, true);
    }
  }
  
  public final synchronized void setSessionOutFile(String fileName)
  {
    if (fileName == null)
    {
      m_sdataOutFile = null;
    }
    else
    {
      File _file = new File(fileName);
      if ((_file.exists()) && (!_file.isFile())) {
        throw new IllegalArgumentException("not a file: [" + _file.getAbsolutePath() + "]");
      }
      m_sdataOutFile = _file;
    }
  }
  
  protected void validateState()
  {
    super.validateState();
    if (m_dataPath == null) {
      throw new IllegalStateException("data path not set");
    }
  }
  
  protected void _run(IProperties toolProperties)
  {
    Logger log = m_log;
    
    boolean verbose = m_log.atVERBOSE();
    if (verbose)
    {
      log.verbose("[EMMA v2.0, build 5312 (2005/06/12 19:32:43)]");
      
      log.verbose("input data path:");
      log.verbose("{");
      for (int p = 0; p < m_dataPath.length; p++)
      {
        File f = m_dataPath[p];
        String nonexistent = f.exists() ? "" : "{nonexistent} ";
        
        log.verbose("  " + nonexistent + f.getAbsolutePath());
      }
      log.verbose("}");
    }
    else
    {
      log.info("processing input files ...");
    }
    File sdataOutFile = m_sdataOutFile;
    if (sdataOutFile == null) {
      sdataOutFile = new File(toolProperties.getProperty("session.out.file", "coverage.es"));
    }
    RuntimeException failure = null;
    try
    {
      IMetaData mdata = null;
      ICoverageData cdata = null;
      try
      {
        long start = log.atINFO() ? System.currentTimeMillis() : 0L;
        for (int f = 0; f < m_dataPath.length; f++)
        {
          File dataFile = m_dataPath[f];
          if (verbose) {
            log.verbose("processing input file [" + dataFile.getAbsolutePath() + "] ...");
          }
          IMergeable[] fileData = DataFactory.load(dataFile);
          
          IMetaData _mdata = (IMetaData)fileData[0];
          if (_mdata != null)
          {
            if (verbose) {
              log.verbose("  loaded " + _mdata.size() + " metadata entries");
            }
            if (mdata == null) {
              mdata = _mdata;
            } else {
              mdata = (IMetaData)mdata.merge(_mdata);
            }
          }
          ICoverageData _cdata = (ICoverageData)fileData[1];
          if (_cdata != null)
          {
            if (verbose) {
              log.verbose("  loaded " + _cdata.size() + " coverage data entries");
            }
            if (cdata == null) {
              cdata = _cdata;
            } else {
              cdata = (ICoverageData)cdata.merge(_cdata);
            }
          }
          m_dataFileCount += 1;
        }
        if (log.atINFO())
        {
          long end = System.currentTimeMillis();
          
          log.info(m_dataFileCount + " file(s) read and merged in " + (end - start) + " ms");
        }
        if (((mdata == null) || (mdata.isEmpty())) && ((cdata == null) || (cdata.isEmpty())))
        {
          log.warning("nothing to do: no metadata or coverage data found in any of the input files"); return;
        }
      }
      catch (IOException ioe)
      {
        ioe.printStackTrace(System.out);
      }
      if (verbose)
      {
        if (mdata != null) {
          log.verbose("  merged metadata contains " + mdata.size() + " entries");
        }
        if (cdata != null) {
          log.verbose("  merged coverage data contains " + cdata.size() + " entries");
        }
      }
      .assert.ASSERT(sdataOutFile != null, "sdataOutFile not null");
      
      boolean rename = false;
      File tempDataOutFile = null;
      
      File canonicalDataOutFile = Files.canonicalizeFile(sdataOutFile);
      for (int f = 0; f < m_dataPath.length; f++)
      {
        File canonicalDataFile = Files.canonicalizeFile(m_dataPath[f]);
        if (canonicalDataOutFile.equals(canonicalDataFile))
        {
          rename = true;
          break;
        }
      }
      if (rename)
      {
        File tempFileDir = canonicalDataOutFile.getParentFile();
        if (tempFileDir == null) {
          tempFileDir = new File("");
        }
        String tempFileName = Files.getFileName(canonicalDataOutFile) + "emma";
        String tempFileExt = ".et";
        try
        {
          tempDataOutFile = Files.createTempFile(tempFileDir, tempFileName, ".et");
        }
        catch (IOException ioe)
        {
          throw new EMMARuntimeException(ioe);
        }
        log.warning("the specified output file is one of the input files [" + canonicalDataOutFile + "]");
        log.warning("all merged data will be written to a temp file first [" + tempDataOutFile.getAbsolutePath() + "]");
      }
      long start = log.atINFO() ? System.currentTimeMillis() : 0L;
      
      File persistFile = null;
      try
      {
        persistFile = tempDataOutFile != null ? tempDataOutFile : canonicalDataOutFile;
        if ((mdata == null) || (mdata.isEmpty())) {
          DataFactory.persist(cdata, persistFile, false);
        } else if ((cdata == null) || (cdata.isEmpty())) {
          DataFactory.persist(mdata, persistFile, false);
        } else {
          DataFactory.persist(new SessionData(mdata, cdata), persistFile, false);
        }
      }
      catch (IOException ioe)
      {
        if (persistFile != null) {
          persistFile.delete();
        }
        throw new EMMARuntimeException(ioe);
      }
      catch (Error e)
      {
        if (persistFile != null) {
          persistFile.delete();
        }
        throw e;
      }
      if (rename) {
        if (!Files.renameFile(tempDataOutFile, canonicalDataOutFile, true)) {
          throw new EMMARuntimeException("could not rename temporary file [" + tempDataOutFile.getAbsolutePath() + "] to [" + canonicalDataOutFile + "]: make sure the original file is not locked and can be deleted");
        }
      }
      if (log.atINFO())
      {
        long end = System.currentTimeMillis();
        
        log.info("merged/compacted data written to [" + canonicalDataOutFile + "] {in " + (end - start) + " ms}");
      }
    }
    catch (SecurityException se)
    {
      failure = new EMMARuntimeException("SECURITY_RESTRICTION:", new String[] { "EMMA" }, se);
    }
    catch (RuntimeException re)
    {
      failure = re;
    }
    finally
    {
      reset();
    }
    if (failure != null)
    {
      if (Exceptions.unexpectedFailure(failure, EXPECTED_FAILURES)) {
        throw new EMMARuntimeException("UNEXPECTED_FAILURE", new Object[] { failure.toString(), "http://sourceforge.net/projects/emma" }, failure);
      }
      throw failure;
    }
  }
  
  private MergeProcessor()
  {
    m_dataPath = IConstants.EMPTY_FILE_ARRAY;
  }
  
  private void reset()
  {
    m_dataFileCount = 0;
  }
  
  private static final Class[] EXPECTED_FAILURES = { EMMARuntimeException.class, IllegalArgumentException.class, IllegalStateException.class };
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.MergeProcessor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

import com.vladium.logging.Logger;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

final class MetaData
  implements IMetaData, Cloneable
{
  private final CoverageOptions m_options;
  private boolean m_hasSrcFileInfo;
  private boolean m_hasLineNumberInfo;
  private HashMap m_classMap;
  private transient HashSet m_packagesWarned;
  
  public IMetaData shallowCopy()
  {
    try
    {
      _clone = (MetaData)super.clone();
    }
    catch (CloneNotSupportedException cnse)
    {
      MetaData _clone;
      throw new Error(cnse.toString());
    }
    MetaData _clone;
    HashMap _classMap;
    synchronized (lock())
    {
      _classMap = (HashMap)m_classMap.clone();
    }
    HashMap _classMap;
    m_classMap = _classMap;
    
    return _clone;
  }
  
  public CoverageOptions getOptions()
  {
    return m_options;
  }
  
  public int size()
  {
    return m_classMap.size();
  }
  
  public boolean hasSrcFileData()
  {
    return m_hasSrcFileInfo;
  }
  
  public boolean hasLineNumberData()
  {
    return m_hasLineNumberInfo;
  }
  
  public Iterator iterator()
  {
    return m_classMap.values().iterator();
  }
  
  public boolean hasDescriptor(String classVMName)
  {
    return m_classMap.containsKey(classVMName);
  }
  
  public Object lock()
  {
    return m_classMap;
  }
  
  public boolean add(ClassDescriptor cls, boolean overwrite)
  {
    String classVMName = cls.getClassVMName();
    if ((overwrite) || (!m_classMap.containsKey(classVMName)))
    {
      m_classMap.put(classVMName, cls);
      
      boolean incompleteDebugInfo = false;
      if (!cls.hasSrcFileInfo())
      {
        m_hasSrcFileInfo = false;
        incompleteDebugInfo = true;
      }
      if (!cls.hasCompleteLineNumberInfo())
      {
        m_hasLineNumberInfo = false;
        incompleteDebugInfo = true;
      }
      if (incompleteDebugInfo)
      {
        Logger log = Logger.getLogger();
        if (log.atINFO())
        {
          String packageVMName = cls.getPackageVMName();
          if (m_packagesWarned.add(packageVMName)) {
            log.info("package [" + packageVMName + "] contains classes [" + cls.getName() + "] without full debug info");
          }
        }
      }
      return true;
    }
    return false;
  }
  
  public boolean isEmpty()
  {
    return m_classMap.isEmpty();
  }
  
  public IMergeable merge(IMergeable rhs)
  {
    if ((rhs == null) || (rhs.isEmpty()) || (rhs == this)) {
      return this;
    }
    MetaData rhsmdata = (MetaData)rhs;
    Map rhsclasses = m_classMap;
    for (Iterator entries = rhsclasses.entrySet().iterator(); entries.hasNext();)
    {
      Map.Entry entry = (Map.Entry)entries.next();
      
      String classVMName = (String)entry.getKey();
      Object rhsdescriptor = entry.getValue();
      
      m_classMap.put(classVMName, rhsdescriptor);
    }
    if (!rhsmdata.hasSrcFileData()) {
      m_hasSrcFileInfo = false;
    }
    if (!rhsmdata.hasLineNumberData()) {
      m_hasLineNumberInfo = false;
    }
    return this;
  }
  
  MetaData(CoverageOptions options)
  {
    m_options = options;
    
    m_hasSrcFileInfo = true;
    m_hasLineNumberInfo = true;
    
    m_classMap = new HashMap();
    m_packagesWarned = new HashSet();
  }
  
  static MetaData readExternal(DataInput in)
    throws IOException
  {
    CoverageOptions options = CoverageOptions.readExternal(in);
    
    boolean hasSrcFileInfo = in.readBoolean();
    boolean hasLineNumberInfo = in.readBoolean();
    
    int size = in.readInt();
    HashMap classMap = new HashMap(size);
    for (int i = 0; i < size; i++)
    {
      String classVMName = in.readUTF();
      ClassDescriptor cls = ClassDescriptor.readExternal(in);
      
      classMap.put(classVMName, cls);
    }
    return new MetaData(options, classMap, hasSrcFileInfo, hasLineNumberInfo);
  }
  
  static void writeExternal(MetaData mdata, DataOutput out)
    throws IOException
  {
    CoverageOptions.writeExternal(m_options, out);
    
    out.writeBoolean(m_hasSrcFileInfo);
    out.writeBoolean(m_hasLineNumberInfo);
    
    Map classMap = m_classMap;
    
    int size = classMap.size();
    out.writeInt(size);
    
    Iterator entries = classMap.entrySet().iterator();
    for (int i = 0; i < size; i++)
    {
      Map.Entry entry = (Map.Entry)entries.next();
      
      String classVMName = (String)entry.getKey();
      ClassDescriptor cls = (ClassDescriptor)entry.getValue();
      
      out.writeUTF(classVMName);
      ClassDescriptor.writeExternal(cls, out);
    }
  }
  
  private MetaData(CoverageOptions options, HashMap classMap, boolean hasSrcFileInfo, boolean hasLineNumberInfo)
  {
    m_options = options;
    
    m_hasSrcFileInfo = hasSrcFileInfo;
    m_hasLineNumberInfo = hasLineNumberInfo;
    
    m_classMap = classMap;
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.MetaData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

import com.vladium.util.IConstants;
import com.vladium.util.IntObjectMap;
import com.vladium.util.IntSet;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.Serializable;

public final class MethodDescriptor
  implements IConstants, IMetadataConstants, Serializable
{
  private final String m_name;
  private final String m_descriptor;
  private final int m_status;
  private final int[] m_blockSizes;
  private final int[][] m_blockMap;
  private final int m_firstLine;
  private IntObjectMap m_lineMap;
  
  public MethodDescriptor(String name, String descriptor, int status, int[] blockSizes, int[][] blockMap, int firstLine)
  {
    if (name == null) {
      throw new IllegalArgumentException("null input: name");
    }
    if (descriptor == null) {
      throw new IllegalArgumentException("null input: descriptor");
    }
    if ((status & 0xE) == 0)
    {
      int blockCount = blockSizes.length;
      
      m_blockSizes = blockSizes;
      if ((status & 0xF) == 0)
      {
        if ((blockMap == null) || (blockMap.length == 0)) {
          throw new IllegalArgumentException("null or empty input: blockMap");
        }
        m_blockMap = blockMap;
        m_firstLine = firstLine;
      }
      else
      {
        m_blockMap = ((int[][])null);
        m_firstLine = 0;
      }
    }
    else
    {
      m_blockSizes = null;
      m_blockMap = ((int[][])null);
      m_firstLine = 0;
    }
    m_name = name;
    m_descriptor = descriptor;
    m_status = status;
  }
  
  public String getName()
  {
    return m_name;
  }
  
  public String getDescriptor()
  {
    return m_descriptor;
  }
  
  public int getStatus()
  {
    return m_status;
  }
  
  public int getBlockCount()
  {
    return m_blockSizes.length;
  }
  
  public int[] getBlockSizes()
  {
    return m_blockSizes;
  }
  
  public int[][] getBlockMap()
  {
    return m_blockMap;
  }
  
  public IntObjectMap getLineMap()
  {
    IntObjectMap lineMap = m_lineMap;
    if (lineMap != null) {
      return lineMap;
    }
    if ((m_status & 0xF) == 0)
    {
      lineMap = new IntObjectMap();
      int[][] blockMap = m_blockMap;
      
      int bl = 0;
      for (int blCount = blockMap.length; bl < blCount; bl++)
      {
        int[] lines = blockMap[bl];
        if (lines != null)
        {
          int lineCount = lines.length;
          for (int l = 0; l < lineCount; l++)
          {
            int line = lines[l];
            IntSet blockIDs = (IntSet)lineMap.get(line);
            if (blockIDs == null)
            {
              blockIDs = new IntSet();
              lineMap.put(line, blockIDs);
            }
            blockIDs.add(bl);
          }
        }
      }
      int[] lines = lineMap.keys();
      int l = 0;
      for (int lineCount = lines.length; l < lineCount; l++)
      {
        int line = lines[l];
        int[] blockIDs = ((IntSet)lineMap.get(line)).values();
        
        lineMap.put(line, blockIDs);
      }
      m_lineMap = lineMap;
      
      return lineMap;
    }
    return null;
  }
  
  public int getFirstLine()
  {
    return m_firstLine;
  }
  
  public boolean hasLineNumberInfo()
  {
    return (m_status & 0xF) == 0;
  }
  
  public String toString()
  {
    return toString("");
  }
  
  public String toString(String indent)
  {
    StringBuffer s = new StringBuffer(indent + "method [" + m_name + "] descriptor:");
    if ((m_status & 0xF) == 0)
    {
      for (int bl = 0; bl < m_blockMap.length; bl++)
      {
        s.append(IConstants.EOL);
        s.append(indent + "  " + "block " + bl + " (" + m_blockSizes[bl] + " instrs) : ");
        
        int[] lines = m_blockMap[bl];
        for (int l = 0; l < lines.length; l++)
        {
          if (l != 0) {
            s.append(", ");
          }
          s.append(lines[l]);
        }
      }
      s.append(IConstants.EOL);
      s.append(indent + "  " + "---");
      
      int[] lines = m_lineMap.keys();
      for (int l = 0; l < lines.length; l++)
      {
        s.append(IConstants.EOL);
        s.append(indent + "  " + "line " + lines[l] + ": ");
        
        int[] blocks = (int[])m_lineMap.get(lines[l]);
        for (int bl = 0; bl < blocks.length; bl++)
        {
          if (bl != 0) {
            s.append(", ");
          }
          s.append(blocks[bl]);
        }
      }
    }
    else
    {
      s.append(" <no line info>");
    }
    return s.toString();
  }
  
  static MethodDescriptor readExternal(DataInput in)
    throws IOException
  {
    String name = in.readUTF();
    String descriptor = in.readUTF();
    
    int status = in.readInt();
    
    int[] blockSizes = null;
    int[][] blockMap = (int[][])null;
    int firstLine = 0;
    if ((status & 0xE) == 0)
    {
      blockSizes = DataFactory.readIntArray(in);
      if ((status & 0xF) == 0)
      {
        int length = in.readInt();
        blockMap = new int[length][];
        for (int i = 0; i < length; i++) {
          blockMap[i] = DataFactory.readIntArray(in);
        }
        firstLine = in.readInt();
      }
    }
    return new MethodDescriptor(name, descriptor, status, blockSizes, blockMap, firstLine);
  }
  
  static void writeExternal(MethodDescriptor method, DataOutput out)
    throws IOException
  {
    out.writeUTF(m_name);
    out.writeUTF(m_descriptor);
    
    int status = m_status;
    out.writeInt(status);
    if ((status & 0xE) == 0)
    {
      DataFactory.writeIntArray(m_blockSizes, out);
      if ((status & 0xF) == 0)
      {
        int[][] blockMap = m_blockMap;
        int length = blockMap.length;
        out.writeInt(length);
        for (int i = 0; i < length; i++) {
          DataFactory.writeIntArray(blockMap[i], out);
        }
        out.writeInt(m_firstLine);
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.MethodDescriptor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

import java.io.Serializable;

public final class SessionData
  implements ISessionData, Serializable
{
  private final IMetaData m_mdata;
  private final ICoverageData m_cdata;
  
  public IMetaData getMetaData()
  {
    return m_mdata;
  }
  
  public ICoverageData getCoverageData()
  {
    return m_cdata;
  }
  
  public SessionData(IMetaData mdata, ICoverageData cdata)
  {
    if (mdata == null) {
      throw new IllegalArgumentException("null input: mdata");
    }
    if (cdata == null) {
      throw new IllegalArgumentException("null input: cdata");
    }
    m_mdata = mdata;
    m_cdata = cdata;
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.SessionData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.data;

import com.vladium.emma.Command;
import com.vladium.emma.EMMARuntimeException;
import com.vladium.util.ClassLoaderResolver;
import com.vladium.util.args.IOptsParser;
import com.vladium.util.args.IOptsParser.IOpt;
import com.vladium.util.args.IOptsParser.IOpts;
import java.io.IOException;

public final class mergeCommand
  extends Command
{
  private String[] m_datapath;
  private String m_outFileName;
  
  public mergeCommand(String usageToolName, String[] args)
  {
    super(usageToolName, args);
  }
  
  public synchronized void run()
  {
    ClassLoader loader;
    try
    {
      loader = ClassLoaderResolver.getClassLoader();
    }
    catch (Throwable t)
    {
      ClassLoader loader;
      loader = getClass().getClassLoader();
    }
    try
    {
      IOptsParser parser = getOptParser(loader);
      IOptsParser.IOpts parsedopts = parser.parse(m_args);
      
      int usageRequestLevel = parsedopts.usageRequestLevel();
      if (usageRequestLevel > 0)
      {
        usageexit(parser, usageRequestLevel, null);
        return;
      }
      IOptsParser.IOpt[] opts = parsedopts.getOpts();
      if (opts == null)
      {
        parsedopts.error(m_out, 80);
        usageexit(parser, 1, null);
        return;
      }
      try
      {
        for (int o = 0; o < opts.length; o++)
        {
          IOptsParser.IOpt opt = opts[o];
          String on = opt.getCanonicalName();
          if (!processOpt(opt)) {
            if ("in".equals(on)) {
              m_datapath = getListOptValue(opt, PATH_DELIMITERS, true);
            } else if ("out".equals(on)) {
              m_outFileName = opt.getFirstValue();
            }
          }
        }
        if (!processFilePropertyOverrides()) {
          return;
        }
        processCmdPropertyOverrides(parsedopts);
      }
      catch (IOException ioe)
      {
        throw new EMMARuntimeException("ARGS_IO_FAILURE", ioe);
      }
      MergeProcessor processor = MergeProcessor.create();
      processor.setAppName("EMMA");
      
      processor.setDataPath(m_datapath);
      processor.setSessionOutFile(m_outFileName);
      processor.setPropertyOverrides(m_propertyOverrides);
      
      processor.run();
    }
    catch (EMMARuntimeException yre)
    {
      exit(true, yre.getMessage(), yre, 2);
      return;
    }
    catch (Throwable t)
    {
      exit(true, "unexpected failure: ", t, 2);
      return;
    }
    exit(false, null, null, 0);
  }
  
  protected void initialize()
  {
    super.initialize();
  }
  
  protected String usageArgsMsg()
  {
    return "[options]";
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.mergeCommand
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.vladium.emma.filter;

import com.vladium.util.WCMatcher;
import java.util.Iterator;
import java.util.List;

final class IInclExclFilter$Factory$WCInclExclFilter
  implements IInclExclFilter
{
  private final WCMatcher[] m_inclusions;
  private final WCMatcher[] m_exclusions;
  
  public boolean included(String s)
  {
    if (s == null) {
      return false;
    }
    char[] chars = s.toCharArray();
    
    WCMatcher[] inclusions = m_inclusions;
    WCMatcher[] exclusions = m_exclusions;
    if (inclusions != null)
    {
      boolean included = false;
      
      int i = 0;
      for (int iLimit = inclusions.length; i < iLimit; i++) {
        if (inclusions[i].matches(chars))
        {
          included = true;
          break;
        }
      }
      if (!included) {
        return false;
      }
    }
    if (exclusions != null)
    {
      int x = 0;
      for (int xLimit = exclusions.length; x < xLimit; x++) {
        if (exclusions[x].matches(chars)) {
          return false;
        }
      }
    }
    return true;
  }
  
  IInclExclFilter$Factory$WCInclExclFilter(String[] inclusions, String[] exclusions)
  {
    if ((inclusions == null) || (inclusions.length == 0))
    {
      m_inclusions = null;
    }
    else
    {
      m_inclusions = new WCMatcher[inclusions.length];
      for (int i = 0; i < inclusions.length; i++) {
        m_inclusions[i] = WCMatcher.compile(inclusions[i]);
      }
    }
    if ((exclusions =
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd