private static ExecutionData defensiveCopy(ExecutionData data) { boolean[] src = data.getProbes(); boolean[] dest = new boolean[src.length]; System.arraycopy(src, 0, dest, 0, src.length); return new ExecutionData(data.getId(), data.getName(), dest); }
assertCompatibility(other.getId(), other.getName(), other.getProbes().length); final boolean[] otherData = other.getProbes(); for (int i = 0; i < probes.length; i++) { if (otherData[i]) {
/** * Adds the given {@link ExecutionData} object into the store. If there is * already execution data with this same class id, this structure is merged * with the given one. * * @param data * execution data to add or merge * @throws IllegalStateException * if the given {@link ExecutionData} object is not compatible * to a corresponding one, that is already contained * @see ExecutionData#assertCompatibility(long, String, int) */ public void put(final ExecutionData data) throws IllegalStateException { final Long id = Long.valueOf(data.getId()); final ExecutionData entry = entries.get(id); if (entry == null) { entries.put(id, data); names.add(data.getName()); } else { entry.merge(data); } }
private void executionDataTable(final HTMLElement body) throws IOException { final HTMLElement table = body.table(Styles.COVERAGETABLE); { final HTMLElement tr = table.thead().tr(); tr.td().text("Class"); tr.td().text("Id"); } final HTMLElement tbody = table.tbody(); final ILanguageNames names = context.getLanguageNames(); for (final ExecutionData e : executionData) { final HTMLElement tr = tbody.tr(); final String link = index.getLinkToClass(e.getId()); final String qualifiedName = names.getQualifiedClassName(e .getName()); if (link == null) { tr.td().span(Styles.EL_CLASS).text(qualifiedName); } else { tr.td().a(link, Styles.EL_CLASS).text(qualifiedName); } final String id = String.format("%016x", Long.valueOf(e.getId())); tr.td().code().text(id); } }
private Collection<File> classFilesOfStore(ExecutionDataStore executionDataStore) { Collection<File> result = Lists.newArrayList(); for (ExecutionData data : executionDataStore.getContents()) { String vmClassName = data.getName(); File classFile = classFilesCache.get(vmClassName); if (classFile != null) { result.add(classFile); } } return result; }
/** * Retrieves the execution probe array for a given class. The passed * {@link Object} array instance is used for parameters and the return value * as follows. Call parameters: * * <ul> * <li>args[0]: class id ({@link Long}) * <li>args[1]: vm class name ({@link String}) * <li>args[2]: probe count ({@link Integer}) * </ul> * * Return value: * * <ul> * <li>args[0]: probe array (<code>boolean[]</code>) * </ul> * * @param args * parameter array of length 3 */ public void getProbes(final Object[] args) { final Long classid = (Long) args[0]; final String name = (String) args[1]; final int probecount = ((Integer) args[2]).intValue(); args[0] = getExecutionData(classid, name, probecount).getProbes(); }
/** * Subtracts the probes in the given {@link ExecutionData} object from the * store. I.e. for all set probes in the given data object the corresponding * probes in this store will be unset. If there is no execution data with id * of the given data object this operation will have no effect. * * @param data * execution data to subtract * @throws IllegalStateException * if the given {@link ExecutionData} object is not compatible * to a corresponding one, that is already contained * @see ExecutionData#assertCompatibility(long, String, int) */ public void subtract(final ExecutionData data) throws IllegalStateException { final Long id = Long.valueOf(data.getId()); final ExecutionData entry = entries.get(id); if (entry != null) { entry.merge(data, false); } }
/** * Returns the coverage data for the class with the given identifier. If * there is no data available under the given id a new entry is created. * * @param id * class identifier * @param name * VM name of the class * @param probecount * probe data length * @return execution data */ public ExecutionData get(final Long id, final String name, final int probecount) { ExecutionData entry = entries.get(id); if (entry == null) { entry = new ExecutionData(id.longValue(), name, probecount); entries.put(id, entry); names.add(name); } else { entry.assertCompatibility(id.longValue(), name, probecount); } return entry; }
private void readExecutionData() throws IOException { if (executionDataVisitor == null) { throw new IOException("No execution data visitor."); } final long id = in.readLong(); final String name = in.readUTF(); final boolean[] probes = in.readBooleanArray(); executionDataVisitor.visitClassExecution(new ExecutionData(id, name, probes)); }
private void copyToAgentExecutionStore(ExecutionDataStore dataStore) throws Exception { Field f = null; try { f = UUID.class.getDeclaredField("$jacocoAccess"); } catch (Exception e) { f = UnknownError.class.getDeclaredField("$jacocoAccess"); } Object executor = f.get(null); Method m = executor.getClass().getDeclaredMethod("getProbes", Object[].class); m.setAccessible(true); for (ExecutionData data : dataStore.getContents()) { Object[] probeData = new Object[] {data.getId(), data.getName(), data.getProbes().length}; m.invoke(executor, new Object[] {probeData}); boolean[] resultData = (boolean[]) probeData[0]; for (int i = 0; i < data.getProbes().length; i++) { if (!resultData[i]) { resultData[i] = data.getProbes()[i]; } } } }
/** * Retrieves the execution probe array for a given class. The passed * {@link Object} array instance is used for parameters and the return value * as follows. Call parameters: * <p> * <ul> * <li>args[0]: class id ({@link Long}) * <li>args[1]: vm class name ({@link String}) * <li>args[2]: probe count ({@link Integer}) * </ul> * <p> * Return value: * <p> * <ul> * <li>args[0]: probe array (<code>boolean[]</code>) * </ul> * * @param args * parameter array of length 3 */ public void swapExecutionData(Object[] args) { final Long classid = (Long) args[0]; final String name = (String) args[1]; final int probecount = (Integer) args[2]; synchronized (runtimeData) { args[0] = runtimeData.getExecutionData(classid, name, probecount).getProbes(); } }
private static ExecutionData defensiveCopy(ExecutionData data) { boolean[] src = data.getProbes(); boolean[] dest = new boolean[src.length]; System.arraycopy(src, 0, dest, 0, src.length); return new ExecutionData(data.getId(), data.getName(), dest); }
private void copyToAgentExecutionStore(ExecutionDataStore dataStore) throws Exception { Field f = null; try { f = UUID.class.getDeclaredField("$jacocoAccess"); } catch (Exception e) { f = UnknownError.class.getDeclaredField("$jacocoAccess"); } Object executor = f.get(null); Method m = executor.getClass().getDeclaredMethod("getProbes", Object[].class); m.setAccessible(true); for (ExecutionData data : dataStore.getContents()) { Object[] probeData = new Object[] {data.getId(), data.getName(), data.getProbes().length}; m.invoke(executor, new Object[] {probeData}); boolean[] resultData = (boolean[]) probeData[0]; for (int i = 0; i < data.getProbes().length; i++) { if (!resultData[i]) { resultData[i] = data.getProbes()[i]; } } } }
private CoverageBuilder analyze2(ExecutionDataStore executionDataStore) { CoverageBuilder coverageBuilder = new CoverageBuilder(); Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder); for (File binaryDir : fileSystem.binaryDirs()) { for (ExecutionData data : executionDataStore.getContents()) { String vmClassName = data.getName(); String classFileName = vmClassName.replace('.', '/') + ".class"; File classFile = new File(binaryDir, classFileName); if (classFile.isFile()) { try { analyzer.analyzeAll(classFile); } catch (Exception e) { JaCoCoUtils.LOG.warn("Exception during analysis of file " + classFile.getAbsolutePath(), e); } } } } return coverageBuilder; }
/** * Retrieves the execution probe array for a given class. The passed * {@link Object} array instance is used for parameters and the return value * as follows. Call parameters: * <p> * <ul> * <li>args[0]: class id ({@link Long}) * <li>args[1]: vm class name ({@link String}) * <li>args[2]: probe count ({@link Integer}) * </ul> * <p> * Return value: * <p> * <ul> * <li>args[0]: probe array (<code>boolean[]</code>) * </ul> * * @param args * parameter array of length 3 */ public void swapExecutionData(Object[] args) { final Long classid = (Long) args[0]; final String name = (String) args[1]; final int probecount = (Integer) args[2]; synchronized (runtimeData) { args[0] = runtimeData.getExecutionData(classid, name, probecount).getProbes(); } }
private static ExecutionData defensiveCopy(ExecutionData data) { boolean[] src = data.getProbes(); boolean[] dest = new boolean[src.length]; System.arraycopy(src, 0, dest, 0, src.length); return new ExecutionData(data.getId(), data.getName(), dest); } }
private CoverageBuilder analyze2(ExecutionDataStore executionDataStore) { CoverageBuilder coverageBuilder = new CoverageBuilder(); Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder); for (ExecutionData data : executionDataStore.getContents()) { String vmClassName = data.getName(); File classFile = classFilesCache.get(vmClassName); if (classFile != null) { analyzeClassFile(analyzer, classFile); } } return coverageBuilder; }