emma

16:35:33.246 INFO  jd.cli.Main - Decompiling emma.jar
package com.vladium.app;

public abstract interface IAppVersion
{
  public static final int APP_MAJOR_VERSION = 2;
  public static final int APP_MINOR_VERSION = 0;
  public static final int APP_BUILD_ID = 5312;
  public static final String APP_BUILD_RELEASE_TAG = "";
  public static final String APP_BUILD_DATE = "2005/06/12 19:32:43";
  public static final String APP_BUG_REPORT_LINK = "http://sourceforge.net/projects/emma";
  public static final String APP_HOME_SITE_LINK = "http://emma.sourceforge.net/";
  public static final String APP_BUILD_ID_AND_TAG = "5312";
  public static final String APP_VERSION = "2.0";
  public static final String APP_VERSION_WITH_BUILD_ID_AND_TAG = "2.0.5312";
}

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

import com.vladium.logging.Logger;
import com.vladium.util.IProperties;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public abstract class AppLoggers
{
  public static final String PREFIX_VERBOSITY = "verbosity.";
  public static final String PROPERTY_VERBOSITY_LEVEL = "verbosity.level";
  public static final String DEFAULT_VERBOSITY_LEVEL = "info";
  public static final String PROPERTY_VERBOSITY_FILTER = "verbosity.filter";
  private static final String COMMA_DELIMITERS = ", \t\r\n";
  
  public static Logger create(String appName, IProperties properties, Logger base)
  {
    if (properties == null) {
      throw new IllegalArgumentException("null input: properties");
    }
    String _level = properties.getProperty("verbosity.level", "info");
    
    int level = Logger.stringToLevel(_level);
    
    String _filter = properties.getProperty("verbosity.filter");
    Set temp = null;
    if (_filter != null)
    {
      StringTokenizer tokenizer = new StringTokenizer(_filter, ", \t\r\n");
      if (tokenizer.countTokens() > 0)
      {
        temp = new HashSet(tokenizer.countTokens());
        while (tokenizer.hasMoreTokens()) {
          temp.add(tokenizer.nextToken());
        }
      }
    }
    Set filter = temp;
    
    return Logger.create(level, null, appName, filter, base);
  }
}

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

import com.vladium.emma.data.mergeCommand;
import com.vladium.emma.instr.instrCommand;
import com.vladium.emma.report.reportCommand;
import com.vladium.util.IConstants;
import com.vladium.util.Property;
import com.vladium.util.Strings;
import com.vladium.util.XProperties;
import com.vladium.util.args.IOptsParser;
import com.vladium.util.args.IOptsParser.Factory;
import com.vladium.util.args.IOptsParser.IOpt;
import com.vladium.util.args.IOptsParser.IOpts;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;

public abstract class Command
{
  protected final String m_usageToolName;
  protected final String[] m_args;
  protected File m_propertyFile;
  protected Properties m_propertyOverrides;
  protected boolean m_exit;
  protected PrintWriter m_out;
  protected static final String COMMA_DELIMITERS = ", \t\r\n";
  
  public static Command create(String name, String usageName, String[] args)
  {
    Command tool;
    Command tool;
    if ("run".equals(name))
    {
      tool = new runCommand(usageName, args);
    }
    else
    {
      Command tool;
      if ("instr".equals(name))
      {
        tool = new instrCommand(usageName, args);
      }
      else
      {
        Command tool;
        if ("report".equals(name)) {
          tool = new reportCommand(usageName, args);
        } else if ("merge".equals(name)) {
          tool = new mergeCommand(usageName, args);
        } else {
          throw new IllegalArgumentException("unknown command: [" + name + "]");
        }
      }
    }
    tool.initialize();
    
    return tool;
  }
  
  public abstract void run();
  
  protected Command(String usageToolName, String[] args)
  {
    m_usageToolName = usageToolName;
    m_args = (args != null ? (String[])args.clone() : IConstants.EMPTY_STRING_ARRAY);
  }
  
  protected abstract String usageArgsMsg();
  
  protected void initialize()
  {
    m_exit = false;
    if (m_out != null) {
      try
      {
        m_out.flush();
      }
      catch (Throwable ignore) {}
    }
    m_out = new PrintWriter(System.out, true);
  }
  
  protected final String getToolName()
  {
    String clsName = getClass().getName();
    
    return clsName.substring(0, clsName.length() - 7);
  }
  
  protected final IOptsParser getOptParser(ClassLoader loader)
  {
    return IOptsParser.Factory.create(usageResName(getToolName()), loader, usageMsgPrefix(m_usageToolName), USAGE_OPT_NAMES);
  }
  
  protected final boolean processOpt(IOptsParser.IOpt opt)
  {
    String on = opt.getCanonicalName();
    if ("exit".equals(on))
    {
      m_exit = getOptionalBooleanOptValue(opt);
      return true;
    }
    if ("p".equals(on))
    {
      m_propertyFile = new File(opt.getFirstValue());
      return true;
    }
    if ("verbose".equals(on))
    {
      setPropertyOverride("verbosity.level", "verbose");
      return true;
    }
    if ("quiet".equals(on))
    {
      setPropertyOverride("verbosity.level", "warning");
      return true;
    }
    if ("silent".equals(on))
    {
      setPropertyOverride("verbosity.level", "severe");
      return true;
    }
    if ("debug".equals(on))
    {
      if (opt.getValueCount() == 0) {
        setPropertyOverride("verbosity.level", "trace1");
      } else {
        setPropertyOverride("verbosity.level", opt.getFirstValue());
      }
      return true;
    }
    if ("debugcls".equals(on))
    {
      setPropertyOverride("verbosity.filter", Strings.toListForm(Strings.merge(opt.getValues(), ", \t\r\n", true), ','));
      return true;
    }
    return false;
  }
  
  protected final void processCmdPropertyOverrides(IOptsParser.IOpts parsedopts)
  {
    IOptsParser.IOpt[] popts = parsedopts.getOpts("D");
    if ((popts != null) && (popts.length != 0))
    {
      Properties cmdOverrides = new XProperties();
      for (int o = 0; o < popts.length; o++)
      {
        IOptsParser.IOpt opt = popts[o];
        String on = opt.getName().substring(opt.getPatternPrefix().length());
        
        cmdOverrides.setProperty(on, opt.getFirstValue());
      }
      m_propertyOverrides = Property.combine(cmdOverrides, m_propertyOverrides);
    }
  }
  
  protected final boolean processFilePropertyOverrides()
  {
    if (m_propertyFile != null)
    {
      try
      {
        fileOverrides = Property.getPropertiesFromFile(m_propertyFile);
      }
      catch (IOException ioe)
      {
        Properties fileOverrides;
        exit(true, "property override file [" + m_propertyFile.getAbsolutePath() + "] could not be read", ioe, 1);
        return false;
      }
      Properties fileOverrides;
      m_propertyOverrides = Property.combine(m_propertyOverrides, fileOverrides);
    }
    return true;
  }
  
  protected final void usageexit(IOptsParser parser, int level, String msg)
  {
    if (msg != null)
    {
      m_out.print(usageMsgPrefix(m_usageToolName));
      m_out.println(msg);
    }
    if (parser != null)
    {
      m_out.println();
      m_out.print(usageMsgPrefix(m_usageToolName));
      m_out.println(toolNameToCommandName(m_usageToolName) + " " + usageArgsMsg() + ",");
      m_out.println("  where options include:");
      m_out.println();
      parser.usage(m_out, level, 80);
    }
    m_out.println();
    exit(true, null, null, 1);
  }
  
  protected final void exit(boolean showBuildID, String msg, Throwable t, int rc)
    throws EMMARuntimeException
  {
    if (showBuildID) {
      m_out.println("[EMMA v2.0, build 5312]");
    }
    if (msg != null)
    {
      m_out.print(toolNameToCommandName(m_usageToolName) + ": ");m_out.println(msg);
    }
    if (rc != 0)
    {
      if (m_exit)
      {
        if (t != null) {
          t.printStackTrace(m_out);
        }
        System.exit(rc);
      }
      else
      {
        if ((t instanceof EMMARuntimeException)) {
          throw ((EMMARuntimeException)t);
        }
        if (t != null) {
          throw (msg != null ? new EMMARuntimeException(msg, t) : new EMMARuntimeException("unexpected failure: ", t));
        }
      }
    }
    else if (m_exit) {
      System.exit(0);
    }
  }
  
  protected static boolean getOptionalBooleanOptValue(IOptsParser.IOpt opt)
  {
    if (opt.getValueCount() == 0) {
      return true;
    }
    String v = opt.getFirstValue().toLowerCase();
    
    return Property.toBoolean(v);
  }
  
  protected static String[] getListOptValue(IOptsParser.IOpt opt, String delimiters, boolean processAtFiles)
    throws IOException
  {
    return Strings.mergeAT(opt.getValues(), delimiters, processAtFiles);
  }
  
  protected static String usageMsgPrefix(String toolName)
  {
    return toolNameToCommandName(toolName).concat(" usage: ");
  }
  
  protected static String usageResName(String toolName)
  {
    return toolName.replace('.', '/').concat("_usage.res");
  }
  
  protected static String toolNameToCommandName(String toolName)
  {
    int lastDot = toolName.lastIndexOf('.');
    
    return lastDot > 0 ? toolName.substring(lastDot + 1) : toolName;
  }
  
  protected static final String PATH_DELIMITERS = ",".concat(File.pathSeparator);
  protected static final String[] USAGE_OPT_NAMES = { "h", "help" };
  protected static final int STDOUT_WIDTH = 80;
  protected static final int RC_OK = 0;
  protected static final int RC_USAGE = 1;
  protected static final int RC_UNEXPECTED = 2;
  
  private void setPropertyOverride(String key, String value)
  {
    Properties propertyOverrides = m_propertyOverrides;
    if (propertyOverrides == null) {
      m_propertyOverrides = (propertyOverrides = new XProperties());
    }
    propertyOverrides.setProperty(key, value);
  }
}

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

import com.vladium.util.exception.AbstractException;

public class EMMAException
  extends AbstractException
{
  public EMMAException() {}
  
  public EMMAException(String message)
  {
    super(message);
  }
  
  public EMMAException(String message, Object[] arguments)
  {
    super(message, arguments);
  }
  
  public EMMAException(Throwable cause)
  {
    super(cause);
  }
  
  public EMMAException(String message, Throwable cause)
  {
    super(message, cause);
  }
  
  public EMMAException(String message, Object[] arguments, Throwable cause)
  {
    super(message, arguments, cause);
  }
}

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

import com.vladium.emma.report.ReportProperties;
import com.vladium.util.ClassLoaderResolver;
import com.vladium.util.IProperties;
import com.vladium.util.IProperties.Factory;
import com.vladium.util.Property;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.WeakHashMap;

public abstract class EMMAProperties
{
  public static final String GENERIC_PROPERTY_OVERRIDE_PREFIX = "D";
  public static final String DEFAULT_META_DATA_OUT_FILE = "coverage.em";
  public static final Boolean DEFAULT_META_DATA_OUT_MERGE = Boolean.TRUE;
  public static final String PREFIX_META_DATA = "metadata.";
  public static final String PROPERTY_META_DATA_OUT_FILE = "metadata.out.file";
  public static final String PROPERTY_META_DATA_OUT_MERGE = "metadata.out.merge";
  public static final String DEFAULT_COVERAGE_DATA_OUT_FILE = "coverage.ec";
  public static final Boolean DEFAULT_COVERAGE_DATA_OUT_MERGE = Boolean.TRUE;
  public static final String PREFIX_COVERAGE_DATA = "coverage.";
  public static final String PROPERTY_COVERAGE_DATA_OUT_FILE = "coverage.out.file";
  public static final String PROPERTY_COVERAGE_DATA_OUT_MERGE = "coverage.out.merge";
  public static final String DEFAULT_SESSION_DATA_OUT_FILE = "coverage.es";
  public static final Boolean DEFAULT_SESSION_DATA_OUT_MERGE = Boolean.TRUE;
  public static final String PREFIX_SESSION_DATA = "session.";
  public static final String PROPERTY_SESSION_DATA_OUT_FILE = "session.out.file";
  public static final String PROPERTY_SESSION_DATA_OUT_MERGE = "session.out.merge";
  public static final String PROPERTY_TEMP_FILE_EXT = ".et";
  public static final Map SYSTEM_PROPERTY_REDIRECTS;
  private static long s_timestamp;
  
  public static synchronized long getTimeStamp()
  {
    long result = s_timestamp;
    if (result == 0L) {
      s_timestamp = result = System.currentTimeMillis();
    }
    return result;
  }
  
  public 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();
  }
  
  public static IProperties wrap(Properties properties)
  {
    if (properties == null) {
      return null;
    }
    return IProperties.Factory.wrap(properties, ReportProperties.REPORT_PROPERTY_MAPPER);
  }
  
  public static synchronized IProperties getAppProperties()
  {
    ClassLoader loader = ClassLoaderResolver.getClassLoader();
    
    return getAppProperties(loader);
  }
  
  public static synchronized IProperties getAppProperties(ClassLoader loader)
  {
    IProperties properties = (IProperties)s_properties.get(loader);
    if (properties != null) {
      return properties;
    }
    String appName = "emma";
    
    IProperties systemRedirects = wrap(Property.getSystemPropertyRedirects(SYSTEM_PROPERTY_REDIRECTS));
    IProperties appDefaults = wrap(Property.getProperties("emma_default.properties", loader));
    
    String fileName = Property.getSystemProperty("emma.properties");
    File file = fileName != null ? new File(fileName) : null;
    
    IProperties systemFile = wrap(Property.getLazyPropertiesFromFile(file));
    
    IProperties system = wrap(Property.getSystemProperties("emma"));
    IProperties userOverrides = wrap(Property.getProperties("emma.properties", loader));
    
    properties = IProperties.Factory.combine(userOverrides, IProperties.Factory.combine(system, IProperties.Factory.combine(systemFile, IProperties.Factory.combine(appDefaults, systemRedirects))));
    
    s_properties.put(loader, properties);
    
    return properties;
  }
  
  private static final Map s_properties = new WeakHashMap();
  
  static
  {
    Map redirects = new HashMap();
    redirects.put("report.".concat("out.encoding"), "file.encoding");
    
    redirects.put("report.".concat("out.dir"), "user.dir");
    
    SYSTEM_PROPERTY_REDIRECTS = Collections.unmodifiableMap(redirects);
  }
}

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

import com.vladium.util.exception.AbstractRuntimeException;

public class EMMARuntimeException
  extends AbstractRuntimeException
{
  public EMMARuntimeException() {}
  
  public EMMARuntimeException(String message)
  {
    super(message);
  }
  
  public EMMARuntimeException(String message, Object[] arguments)
  {
    super(message, arguments);
  }
  
  public EMMARuntimeException(Throwable cause)
  {
    super(cause);
  }
  
  public EMMARuntimeException(String message, Throwable cause)
  {
    super(message, cause);
  }
  
  public EMMARuntimeException(String message, Object[] arguments, Throwable cause)
  {
    super(message, arguments, cause);
  }
}

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

class IAppConstants$1
{
  static Class class$com$vladium$emma$IAppConstants;
  
  static Class class$(String x0)
  {
    try
    {
      return Class.forName(x0);
    }
    catch (ClassNotFoundException x1)
    {
      throw new NoClassDefFoundError(x1.getMessage());
    }
  }
}

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

import com.vladium.app.IAppVersion;
import com.vladium.jcd.lib.Types;

public abstract interface IAppConstants
  extends IAppVersion
{
  public static final String APP_NAME = "EMMA";
  public static final String APP_NAME_LC = "emma";
  public static final String APP_COPYRIGHT = "(C) Vladimir Roubtsov";
  public static final String APP_THROWABLE_BUILD_ID = "[EMMA v2.0.5312]";
  public static final String APP_USAGE_BUILD_ID = "[EMMA v2.0, build 5312]";
  public static final String APP_VERBOSE_BUILD_ID = "[EMMA v2.0, build 5312 (2005/06/12 19:32:43)]";
  public static final String APP_USAGE_PREFIX = "EMMA usage: ";
  public static final String APP_PACKAGE = Types.getClassPackageName(1.class$com$vladium$emma$IAppConstants == null ? (1.class$com$vladium$emma$IAppConstants = 1.class$("com.vladium.emma.IAppConstants")) : 1.class$com$vladium$emma$IAppConstants);
  public static final long DATA_FORMAT_VERSION = 32L;
}

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

public abstract interface IAppErrorCodes
{
  public static final String UNEXPECTED_FAILURE = "UNEXPECTED_FAILURE";
  public static final String INVALID_PARAMETER_VALUE = "INVALID_PARAMETER_VALUE";
  public static final String INVALID_COLUMN_NAME = "INVALID_COLUMN_NAME";
  public static final String REQUIRED_PARAMETER_MISSING = "REQUIRED_PARAMETER_MISSING";
  public static final String SECURITY_RESTRICTION = "SECURITY_RESTRICTION:";
  public static final String MAIN_CLASS_BAD_DELEGATION = "MAIN_CLASS_BAD_DELEGATION";
  public static final String MAIN_CLASS_NOT_FOUND = "MAIN_CLASS_NOT_FOUND";
  public static final String MAIN_CLASS_LOAD_FAILURE = "MAIN_CLASS_LOAD_FAILURE";
  public static final String MAIN_METHOD_NOT_FOUND = "MAIN_METHOD_NOT_FOUND";
  public static final String MAIN_METHOD_FAILURE = "MAIN_METHOD_FAILURE";
  public static final String REPORT_GEN_FAILURE = "REPORT_GEN_FAILURE";
  public static final String REPORT_IO_FAILURE = "REPORT_IO_FAILURE";
  public static final String CLASS_STAMP_MISMATCH = "CLASS_STAMP_MISMATCH";
  public static final String OUT_MKDIR_FAILURE = "OUT_MKDIR_FAILURE";
  public static final String INSTR_IO_FAILURE = "INSTR_IO_FAILURE";
  public static final String OUT_IO_FAILURE = "OUT_IO_FAILURE";
  public static final String ARGS_IO_FAILURE = "ARGS_IO_FAILURE";
}

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

import com.vladium.logging.Logger;
import com.vladium.util.IProperties;
import com.vladium.util.IProperties.Factory;
import java.util.Properties;

public abstract class Processor
{
  protected String m_appName;
  protected IProperties m_propertyOverrides;
  protected Logger m_log;
  
  public synchronized void run()
  {
    validateState();
    
    IProperties appProperties = EMMAProperties.getAppProperties();
    
    IProperties toolProperties = IProperties.Factory.combine(m_propertyOverrides, appProperties);
    
    Logger current = Logger.getLogger();
    Logger log = AppLoggers.create(m_appName, toolProperties, current);
    if (log.atTRACE1())
    {
      log.trace1("run", "complete tool properties:");
      toolProperties.list(log.getWriter());
    }
    try
    {
      Logger.push(log);
      m_log = log;
      
      _run(toolProperties);
    }
    finally
    {
      if (m_log != null)
      {
        Logger.pop(m_log);
        m_log = null;
      }
    }
  }
  
  public final synchronized void setAppName(String appName)
  {
    m_appName = appName;
  }
  
  public final synchronized void setPropertyOverrides(Properties overrides)
  {
    m_propertyOverrides = EMMAProperties.wrap(overrides);
  }
  
  public final synchronized void setPropertyOverrides(IProperties overrides)
  {
    m_propertyOverrides = overrides;
  }
  
  protected abstract void _run(IProperties paramIProperties);
  
  protected void validateState() {}
}

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

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

public final class ClassDescriptor
  implements IConstants, Serializable
{
  private final String m_packageVMName;
  private final String m_name;
  private final long m_stamp;
  private final String m_srcFileName;
  private final MethodDescriptor[] m_methods;
  private final boolean m_hasCompleteLineNumberInfo;
  private transient int m_hash;
  
  public ClassDescriptor(String packageVMName, String name, long stamp, String srcFileName, MethodDescriptor[] methods)
  {
    if (packageVMName == null) {
      throw new IllegalArgumentException("null input: packageVMName");
    }
    if (name == null) {
      throw new IllegalArgumentException("null input: name");
    }
    if (methods == null) {
      throw new IllegalArgumentException("null input: methods");
    }
    m_packageVMName = packageVMName;
    m_name = name;
    m_stamp = stamp;
    m_srcFileName = srcFileName;
    m_methods = methods;
    
    boolean completeLineNumberInfo = true;
    for (int m = 0; m < m_methods.length; m++)
    {
      MethodDescriptor method = methods[m];
      if (((method.getStatus() & 0xE) == 0) && (!m_methods[m].hasLineNumberInfo()))
      {
        completeLineNumberInfo = false;
        break;
      }
    }
    m_hasCompleteLineNumberInfo = completeLineNumberInfo;
  }
  
  public final boolean equals(Object rhs)
  {
    if (!(rhs instanceof ClassDescriptor)) {
      return false;
    }
    ClassDescriptor _rhs = (ClassDescriptor)rhs;
    if (hashCode() != _rhs.hashCode()) {
      return false;
    }
    if (!m_name.equals(m_name)) {
      return false;
    }
    if (!m_packageVMName.equals(m_packageVMName)) {
      return false;
    }
    return true;
  }
  
  public final int hashCode()
  {
    if (m_hash == 0)
    {
      int hash = m_name.hashCode() + 16661 * m_packageVMName.hashCode();
      m_hash = hash;
      
      return hash;
    }
    return m_hash;
  }
  
  public final String getPackageVMName()
  {
    return m_packageVMName;
  }
  
  public final String getName()
  {
    return m_name;
  }
  
  public final long getStamp()
  {
    return m_stamp;
  }
  
  public final String getClassVMName()
  {
    if (m_packageVMName.length() == 0) {
      return m_name;
    }
    return m_packageVMName + "/" + m_name;
  }
  
  public final String getSrcFileName()
  {
    return m_srcFileName;
  }
  
  public final MethodDescriptor[] getMethods()
  {
    return m_methods;
  }
  
  public final boolean hasSrcFileInfo()
  {
    return m_srcFileName != null;
  }
  
  public final boolean hasCompleteLineNumberInfo()
  {
    return m_hasCompleteLineNumberInfo;
  }
  
  public String toString()
  {
    return toString("");
  }
  
  public String toString(String indent)
  {
    StringBuffer s = new StringBuffer(indent + "class [" + (m_packageVMName.length() > 0 ? m_packageVMName + "/" : "") + m_name + "] descriptor:");
    for (int m = 0; m < m_methods.length; m++)
    {
      s.append(IConstants.EOL);
      s.append(m_methods[m].toString(indent + "  "));
    }
    return s.toString();
  }
  
  static ClassDescriptor readExternal(DataInput in)
    throws IOException
  {
    String packageVMName = in.readUTF();
    String name = in.readUTF();
    
    long stamp = in.readLong();
    
    byte srcFileNameFlag = in.readByte();
    String srcFileName = srcFileNameFlag != 0 ? in.readUTF() : null;
    
    int length = in.readInt();
    MethodDescriptor[] methods = new MethodDescriptor[length];
    for (int i = 0; i < length; i++) {
      methods[i] = MethodDescriptor.readExternal(in);
    }
    return new ClassDescriptor(packageVMName, name, stamp, srcFileName, methods);
  }
  
  static void writeExternal(ClassDescriptor cls, DataOutput out)
    throws IOException
  {
    out.writeUTF(m_packageVMName);
    out.writeUTF(m_name);
    
    out.writeLong(m_stamp);
    if (m_srcFileName != null)
    {
      out.writeByte(1);
      out.writeUTF(m_srcFileName);
    }
    else
    {
      out.writeByte(0);
    }
    MethodDescriptor[] methods = m_methods;
    int length = methods.length;
    out.writeInt(length);
    for (int i = 0; i < length; i++) {
      MethodDescriptor.writeExternal(methods[i], out);
    }
  }
}

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

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

final class CoverageData
  implements ICoverageData, Cloneable
{
  private HashMap m_coverageMap;
  
  public Object lock()
  {
    return m_coverageMap;
  }
  
  public ICoverageData shallowCopy()
  {
    try
    {
      _clone = (CoverageData)super.clone();
    }
    catch (CloneNotSupportedException cnse)
    {
      CoverageData _clone;
      throw new Error(cnse.toString());
    }
    CoverageData _clone;
    HashMap _coverageMap;
    synchronized (lock())
    {
      _coverageMap = (HashMap)m_coverageMap.clone();
    }
    HashMap _coverageMap;
    m_coverageMap = _coverageMap;
    
    return _clone;
  }
  
  public int size()
  {
    return m_coverageMap.size();
  }
  
  public ICoverageData.DataHolder getCoverage(ClassDescriptor cls)
  {
    if (cls == null) {
      throw new IllegalArgumentException("null input: cls");
    }
    return (ICoverageData.DataHolder)m_coverageMap.get(cls.getClassVMName());
  }
  
  public void addClass(boolean[][] coverage, String classVMName, long stamp)
  {
    m_coverageMap.put(classVMName, new ICoverageData.DataHolder(coverage, stamp));
  }
  
  public boolean isEmpty()
  {
    return m_coverageMap.isEmpty();
  }
  
  public IMergeable merge(IMergeable rhs)
  {
    if ((rhs == null) || (rhs.isEmpty()) || (rhs == this)) {
      return this;
    }
    CoverageData rhscdata = (CoverageData)rhs;
    Map rhscoverageData = m_coverageMap;
    for (Iterator entries = rhscoverageData.entrySet().iterator(); entries.hasNext();)
    {
      Map.Entry entry = (Map.Entry)entries.next();
      String classVMName = (String)entry.getKey();
      
      ICoverageData.DataHolder rhsdata = (ICoverageData.DataHolder)entry.getValue();
      
      ICoverageData.DataHolder data = (ICoverageData.DataHolder)m_coverageMap.get(classVMName);
      if (data == null)
      {
        m_coverageMap.put(classVMName, rhsdata);
      }
      else if (m_stamp != m_stamp)
      {
        m_coverageMap.put(classVMName, rhsdata);
      }
      else
      {
        boolean[][] rhscoverage = m_coverage;
        boolean[][] coverage = m_coverage;
        
        int m = 0;
        for (int mLimit = coverage.length; m < mLimit; m++)
        {
          boolean[] rhsmcoverage = rhscoverage[m];
          boolean[] mcoverage = coverage[m];
          if (mcoverage != null)
          {
            int b = 0;
            for (int bLimit = mcoverage.length; b < bLimit; b++) {
              if (rhsmcoverage[b] != 0) {
                mcoverage[b] = true;
              }
            }
          }
        }
      }
    }
    return this;
  }
  
  CoverageData()
  {
    m_coverageMap = new HashMap();
  }
  
  static CoverageData readExternal(DataInput in)
    throws IOException
  {
    int size = in.readInt();
    HashMap coverageMap = new HashMap(size);
    for (int i = 0; i < size; i++)
    {
      String classVMName = in.readUTF();
      long stamp = in.readLong();
      
      int length = in.readInt();
      boolean[][] coverage = new boolean[length][];
      for (int c = 0; c < length; c++) {
        coverage[c] = DataFactory.readBooleanArray(in);
      }
      coverageMap.put(classVMName, new ICoverageData.DataHolder(coverage, stamp));
    }
    return new CoverageData(coverageMap);
  }
  
  static void writeExternal(CoverageData cdata, DataOutput out)
    throws IOException
  {
    Map coverageMap = m_coverageMap;
    
    int size = coverageMap.size();
    out.writeInt(size);
    
    Iterator entries = coverageMap.entrySet().iterator();
    for (int i = 0; i < size; i++)
    {
      Map.Entry entry = (Map.Entry)entries.next();
      
      String classVMName = (String)entry.getKey();
      ICoverageData.DataHolder data = (ICoverageData.DataHolder)entry.getValue();
      
      boolean[][] coverage = m_coverage;
      
      out.writeUTF(classVMName);
      out.writeLong(m_stamp);
      
      int length = coverage.length;
      out.writeInt(length);
      for (int c = 0; c < length; c++) {
        DataFactory.writeBooleanArray(coverage[c], out);
      }
    }
  }
  
  private CoverageData(HashMap coverageMap)
  {
    m_coverageMap = coverageMap;
  }
}

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

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.Serializable;

public final class CoverageOptions
  implements Serializable
{
  private final boolean m_excludeSyntheticMethods;
  private final boolean m_excludeBridgeMethods;
  private final boolean m_doSUIDCompensation;
  
  public boolean excludeSyntheticMethods()
  {
    return m_excludeSyntheticMethods;
  }
  
  public boolean excludeBridgeMethods()
  {
    return m_excludeBridgeMethods;
  }
  
  public boolean doSUIDCompensation()
  {
    return m_doSUIDCompensation;
  }
  
  CoverageOptions(boolean excludeSyntheticMethods, boolean excludeBridgeMethods, boolean doSUIDCompensation)
  {
    m_excludeSyntheticMethods = excludeSyntheticMethods;
    m_excludeBridgeMethods = excludeBridgeMethods;
    m_doSUIDCompensation = doSUIDCompensation;
  }
  
  static CoverageOptions readExternal(DataInput in)
    throws IOException
  {
    return new CoverageOptions(in.readBoolean(), in.readBoolean(), in.readBoolean());
  }
  
  static void writeExternal(CoverageOptions options, DataOutput out)
    throws IOException
  {
    out.writeBoolean(m_excludeSyntheticMethods);
    out.writeBoolean(m_excludeBridgeMethods);
    out.writeBoolean(m_doSUIDCompensation);
  }
}

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

import com.vladium.util.IProperties;
import com.vladium.util.Property;
import java.util.Properties;

public abstract class CoverageOptionsFactory
{
  public static CoverageOptions create(Properties properties)
  {
    boolean excludeSyntheticMethods = Property.toBoolean(properties.getProperty("instr.exclude_synthetic_methods", "true"));
    
    boolean excludeBridgeMethods = Property.toBoolean(properties.getProperty("instr.exclude_bridge_methods", "true"));
    
    boolean doSUIDCompensaton = Property.toBoolean(properties.getProperty("instr.do_suid_compensation", "true"));
    
    return new CoverageOptions(excludeSyntheticMethods, excludeBridgeMethods, doSUIDCompensaton);
  }
  
  public static CoverageOptions create(IProperties properties)
  {
    boolean excludeSyntheticMethods = Property.toBoolean(properties.getProperty("instr.exclude_synthetic_methods", "true"));
    
    boolean excludeBridgeMethods = Property.toBoolean(properties.getProperty("instr.exclude_bridge_methods", "true"));
    
    boolean doSUIDCompensaton = Property.toBoolean(properties.getProperty("instr.do_suid_compensation", "true"));
    
    return new CoverageOptions(excludeSyntheticMethods, excludeBridgeMethods, doSUIDCompensaton);
  }
}

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

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.RandomAccessFile;

final class DataFactory$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() {}
  
  DataFactory$RandomAccessFileInputStream(RandomAccessFile raf, int bufSize)
    throws IOException
  {
    super(new DataFactory.UCFileInputStream(raf.getFD()), bufSize);
  }
  
  final long getCount()
  {
    return m_count;
  }
}

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

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;

final class DataFactory$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() {}
  
  DataFactory$RandomAccessFileOutputStream(RandomAccessFile raf, int bufSize)
    throws IOException
  {
    super(new DataFactory.UCFileOutputStream(raf.getFD()), bufSize);
  }
  
  final long getCount()
  {
    return m_count;
  }
}

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

import java.io.FileDescriptor;
import java.io.FileInputStream;

final class DataFactory$UCFileInputStream
  extends FileInputStream
{
  public void close() {}
  
  DataFactory$UCFileInputStream(FileDescriptor fd)
  {
    super(fd);
  }
}

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

import java.io.FileDescriptor;
import java.io.FileOutputStream;

final class DataFactory$UCFileOutputStream
  extends FileOutputStream
{
  public void close() {}
  
  DataFactory$UCFileOutputStream(FileDescriptor fd)
  {
    super(fd);
  }
}

/* Location:
 * Qualified Name:     com.vladium.emma.data.DataFactory.UCFileOutputStream
 * 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.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.net.URL;
import java.net.URLConnection;

public abstract class DataFactory
{
  public static final byte TYPE_METADATA = 0;
  public static final byte TYPE_COVERAGEDATA = 1;
  private static final int NULL_ARRAY_LENGTH = -1;
  private static final int MAGIC = 1162693953;
  private static final long UNKNOWN = 0L;
  private static final int FILE_HEADER_LENGTH = 24;
  private static final int ENTRY_HEADER_LENGTH = 9;
  private static final boolean DO_FSYNC = true;
  private static final int IO_BUF_SIZE = 32768;
  
  public static IMergeable[] load(File file)
    throws IOException
  {
    if (file == null) {
      throw new IllegalArgumentException("null input: file");
    }
    return mergeload(file);
  }
  
  public static void persist(IMetaData data, File file, boolean merge)
    throws IOException
  {
    if (data == null) {
      throw new IllegalArgumentException("null input: data");
    }
    if (file == null) {
      throw new IllegalArgumentException("null input: file");
    }
    if ((!merge) && (file.exists())) {
      if (!file.delete()) {
        throw new IOException("could not delete file [" + file.getAbsolutePath() + "]");
      }
    }
    persist(data, (byte)0, file);
  }
  
  public static void persist(ICoverageData data, File file, boolean merge)
    throws IOException
  {
    if (data == null) {
      throw new IllegalArgumentException("null input: data");
    }
    if (file == null) {
      throw new IllegalArgumentException("null input: file");
    }
    if ((!merge) && (file.exists())) {
      if (!file.delete()) {
        throw new IOException("could not delete file [" + file.getAbsolutePath() + "]");
      }
    }
    persist(data, (byte)1, file);
  }
  
  public static void persist(ISessionData data, File file, boolean merge)
    throws IOException
  {
    if (data == null) {
      throw new IllegalArgumentException("null input: data");
    }
    if (file == null) {
      throw new IllegalArgumentException("null input: file");
    }
    if ((!merge) && (file.exists())) {
      if (!file.delete()) {
        throw new IOException("could not delete file [" + file.getAbsolutePath() + "]");
      }
    }
    persist(data.getMetaData(), (byte)0, file);
    persist(data.getCoverageData(), (byte)1, file);
  }
  
  public static IMetaData newMetaData(CoverageOptions options)
  {
    return new MetaData(options);
  }
  
  public static ICoverageData newCoverageData()
  {
    return new CoverageData();
  }
  
  public static IMetaData readMetaData(URL url)
    throws IOException, ClassNotFoundException
  {
    ObjectInputStream oin = null;
    try
    {
      oin = new ObjectInputStream(new BufferedInputStream(url.openStream(), 32768));
      
      return (IMetaData)oin.readObject();
    }
    finally
    {
      if (oin != null) {
        try
        {
          oin.close();
        }
        catch (Exception ignore) {}
      }
    }
  }
  
  public static void writeMetaData(IMetaData data, OutputStream out)
    throws IOException
  {
    ObjectOutputStream oout = new ObjectOutputStream(out);
    oout.writeObject(data);
  }
  
  public static void writeMetaData(IMetaData data, URL url)
    throws IOException
  {
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);
    
    OutputStream out = null;
    try
    {
      out = connection.getOutputStream();
      
      writeMetaData(data, out);
      out.flush();
    }
    finally
    {
      if (out != null) {
        try
        {
          out.close();
        }
        catch (Exception ignore) {}
      }
    }
  }
  
  public static ICoverageData readCoverageData(URL url)
    throws IOException, ClassNotFoundException
  {
    ObjectInputStream oin = null;
    try
    {
      oin = new ObjectInputStream(new BufferedInputStream(url.openStream(), 32768));
      
      return (ICoverageData)oin.readObject();
    }
    finally
    {
      
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