--- /dev/null 2016-10-25 08:46:44.038854975 +0200
+++ new/src/share/classes/sun/evtracing/processing/statistics/aggregator/MethodAggregator.java 2016-10-25 10:40:57.222809335 +0200
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved.
+ *
+ * This file is part of the Lock Contention Tracing Subsystem for the HotSpot
+ * Virtual Machine, which is developed at Christian Doppler Laboratory on
+ * Monitoring and Evolution of Very-Large-Scale Software Systems. Please
+ * contact us at if you need additional information
+ * or have any questions.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work. If not, see .
+ *
+ */
+package sun.evtracing.processing.statistics.aggregator;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.TreeMap;
+import sun.evtracing.parser.metadata.JavaMethod;
+import sun.evtracing.parser.metadata.JavaStack;
+import sun.evtracing.parser.metadata.MethodFilter;
+import sun.evtracing.parser.metadata.JavaStackDeepComparator;
+
+public abstract class MethodAggregator extends ComplexAggregator {
+
+ MethodAggregator(AggregatorFactory extends MethodAggregator> factory) {
+ super(factory);
+ }
+
+ MethodAggregator(MethodAggregator x, MethodAggregator y) {
+ super(x, y);
+ }
+
+ @Override
+ public Map children() {
+ // use custom comparator to avoid equals() in JavaMethod; since the
+ // stack has already been merged, just add every method to the map
+ final Comparator cmp = (JavaMethod m1, JavaMethod m2) -> 1;
+ Map methods = new TreeMap<>(cmp);
+ children.forEach((stack, agg) -> {
+ JavaMethod method;
+ if (!stack.isSet()) {
+ method = JavaMethod.MISSING;
+ } else if (JavaStack.UNKNOWN.equals(stack)) {
+ method = JavaMethod.UNKNOWN;
+ } else if (JavaStack.UNCONTENDED.equals(stack)) {
+ method = JavaMethod.UNCONTENDED;
+ } else if (JavaStack.READERS.equals(stack)) {
+ method = JavaMethod.READERS;
+ } else if (JavaStack.HIDDEN.equals(stack)) {
+ method = JavaMethod.HIDDEN;
+ } else {
+ MethodFilter filter = factory().configuration().filter();
+ method = filter.getFirstUnmatched(stack);
+ }
+ methods.put(method, agg);
+ });
+ return Collections.unmodifiableMap(methods);
+ }
+
+ @Override
+ protected JavaStack createDurationFilteredChild() {
+ return JavaStack.HIDDEN;
+ }
+
+ @Override
+ public void merge() {
+ MethodFilter filter = factory().configuration().filter();
+ mergeChildren(JavaStackDeepComparator.forTopMethodOnly(filter));
+ }
+
+}