Use Java 7+ diamond operator in compiler modules
This commit is contained in:
+4
-5
@@ -84,15 +84,14 @@ public class ProfilingInstrumenterExample extends InterceptionInstrumenterAdapto
|
||||
public static Object c = new CollectFirstArguments();
|
||||
|
||||
public static class CollectFirstArguments {
|
||||
|
||||
private final List<Object> arguments = new ArrayList<Object>(30000);
|
||||
private final List<Object> arguments = new ArrayList<>(30000);
|
||||
|
||||
public void enter(Object arg) {
|
||||
arguments.add(arg);
|
||||
}
|
||||
|
||||
public void dump(PrintStream out) {
|
||||
out.println("Different values: " + new HashSet<Object>(arguments).size());
|
||||
out.println("Different values: " + new HashSet<>(arguments).size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ public class ProfilingInstrumenterExample extends InterceptionInstrumenterAdapto
|
||||
public static Object d = new MethodCollector();
|
||||
|
||||
public static class MethodCollector {
|
||||
private final Collection<String> collected = new LinkedHashSet<String>();
|
||||
private final Collection<String> collected = new LinkedHashSet<>();
|
||||
|
||||
public void enter(@ClassName String className, @MethodName String name, @MethodDesc String desc) {
|
||||
collected.add(className + "." + name + desc);
|
||||
@@ -130,7 +129,7 @@ public class ProfilingInstrumenterExample extends InterceptionInstrumenterAdapto
|
||||
};
|
||||
|
||||
public static abstract class FirstArgumentCollector {
|
||||
private final Collection<Object> collected = new HashSet<Object>();
|
||||
private final Collection<Object> collected = new HashSet<>();
|
||||
|
||||
protected abstract boolean accept(Object arg);
|
||||
|
||||
|
||||
+16
-16
@@ -37,15 +37,15 @@ public class InterceptionInstrumenter {
|
||||
private static final Pattern ANYTHING = Pattern.compile(".*");
|
||||
private static final Type OBJECT_TYPE = Type.getType(Object.class);
|
||||
|
||||
private final Map<String, ClassMatcher> classPatterns = new LinkedHashMap<String, ClassMatcher>();
|
||||
private final Map<String, ClassMatcher> classPatterns = new LinkedHashMap<>();
|
||||
|
||||
private final Set<String> neverMatchedClassPatterns = new LinkedHashSet<String>();
|
||||
private final Set<MethodInstrumenter> neverMatchedInstrumenters = new LinkedHashSet<MethodInstrumenter>();
|
||||
private final Set<String> neverMatchedClassPatterns = new LinkedHashSet<>();
|
||||
private final Set<MethodInstrumenter> neverMatchedInstrumenters = new LinkedHashSet<>();
|
||||
|
||||
interface DumpAction {
|
||||
void dump(PrintStream out);
|
||||
}
|
||||
private final List<DumpAction> dumpTasks = new ArrayList<DumpAction>();
|
||||
private final List<DumpAction> dumpTasks = new ArrayList<>();
|
||||
|
||||
public InterceptionInstrumenter(List<Class<?>> handlerClasses) {
|
||||
for (Class<?> handlerClass : handlerClasses) {
|
||||
@@ -75,10 +75,10 @@ public class InterceptionInstrumenter {
|
||||
|
||||
FieldData fieldData = getFieldData(field, interceptorClass);
|
||||
|
||||
List<MethodData> enterData = new ArrayList<MethodData>();
|
||||
List<MethodData> normalReturnData = new ArrayList<MethodData>();
|
||||
List<MethodData> exceptionData = new ArrayList<MethodData>();
|
||||
List<Method> dumpMethods = new ArrayList<Method>();
|
||||
List<MethodData> enterData = new ArrayList<>();
|
||||
List<MethodData> normalReturnData = new ArrayList<>();
|
||||
List<MethodData> exceptionData = new ArrayList<>();
|
||||
List<Method> dumpMethods = new ArrayList<>();
|
||||
for (Method method : interceptorClass.getMethods()) {
|
||||
String name = method.getName();
|
||||
MethodData methodData = getMethodData(fieldData, method);
|
||||
@@ -237,7 +237,7 @@ public class InterceptionInstrumenter {
|
||||
return data;
|
||||
}
|
||||
|
||||
List<MethodInstrumenter> applicableInstrumenters = new ArrayList<MethodInstrumenter>();
|
||||
List<MethodInstrumenter> applicableInstrumenters = new ArrayList<>();
|
||||
for (Map.Entry<String, ClassMatcher> classPatternEntry : classPatterns.entrySet()) {
|
||||
String classPattern = classPatternEntry.getKey();
|
||||
ClassMatcher classMatcher = classPatternEntry.getValue();
|
||||
@@ -266,7 +266,7 @@ public class InterceptionInstrumenter {
|
||||
ClassReader cr = new ClassReader(classData);
|
||||
ClassWriter cw = new ClassWriter(cr, 0);
|
||||
cr.accept(new ClassVisitor(ASM5, cw) {
|
||||
private final Map<MethodInstrumenter, String> matchedMethods = new HashMap<MethodInstrumenter, String>();
|
||||
private final Map<MethodInstrumenter, String> matchedMethods = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(
|
||||
@@ -280,7 +280,7 @@ public class InterceptionInstrumenter {
|
||||
// Do not instrument synthetic methods
|
||||
if ((access & (ACC_BRIDGE | ACC_SYNTHETIC)) != 0) return mv;
|
||||
|
||||
List<MethodInstrumenter> applicableInstrumenters = new ArrayList<MethodInstrumenter>();
|
||||
List<MethodInstrumenter> applicableInstrumenters = new ArrayList<>();
|
||||
for (MethodInstrumenter instrumenter : instrumenters) {
|
||||
if (instrumenter.isApplicable(name, desc)) {
|
||||
applicableInstrumenters.add(instrumenter);
|
||||
@@ -294,9 +294,9 @@ public class InterceptionInstrumenter {
|
||||
if (applicableInstrumenters.isEmpty()) return mv;
|
||||
|
||||
boolean dumpByteCode = false;
|
||||
List<MethodData> normalReturnData = new ArrayList<MethodData>();
|
||||
List<MethodData> enterData = new ArrayList<MethodData>();
|
||||
List<MethodData> exceptionData = new ArrayList<MethodData>();
|
||||
List<MethodData> normalReturnData = new ArrayList<>();
|
||||
List<MethodData> enterData = new ArrayList<>();
|
||||
List<MethodData> exceptionData = new ArrayList<>();
|
||||
for (MethodInstrumenter instrumenter : applicableInstrumenters) {
|
||||
enterData.addAll(instrumenter.getEnterData());
|
||||
|
||||
@@ -376,7 +376,7 @@ public class InterceptionInstrumenter {
|
||||
) {
|
||||
org.jetbrains.org.objectweb.asm.commons.Method methodBeingInstrumented = new org.jetbrains.org.objectweb.asm.commons.Method(name, desc);
|
||||
|
||||
List<MethodData> allData = new ArrayList<MethodData>();
|
||||
List<MethodData> allData = new ArrayList<>();
|
||||
allData.addAll(enterData);
|
||||
allData.addAll(exceptionData);
|
||||
allData.addAll(normalReturnData);
|
||||
@@ -601,7 +601,7 @@ public class InterceptionInstrumenter {
|
||||
|
||||
private static class ClassMatcher {
|
||||
private final Pattern classPattern;
|
||||
private final List<MethodInstrumenter> instrumenters = new ArrayList<MethodInstrumenter>();
|
||||
private final List<MethodInstrumenter> instrumenters = new ArrayList<>();
|
||||
|
||||
private ClassMatcher(Pattern classPattern) {
|
||||
this.classPattern = classPattern;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ClassPreloadingUtils {
|
||||
}
|
||||
|
||||
private static URLClassLoader createFallbackClassLoader(Collection<File> files) throws IOException {
|
||||
List<URL> urls = new ArrayList<URL>(files.size());
|
||||
List<URL> urls = new ArrayList<>(files.size());
|
||||
for (File file : files) {
|
||||
urls.add(file.toURI().toURL());
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class ClassPreloadingUtils {
|
||||
return extractManifestClasspath((ResourceData) manifest);
|
||||
}
|
||||
else if (manifest instanceof ArrayList) {
|
||||
List<File> result = new ArrayList<File>();
|
||||
List<File> result = new ArrayList<>();
|
||||
for (ResourceData data : (ArrayList<ResourceData>) manifest) {
|
||||
result.addAll(extractManifestClasspath(data));
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class ClassPreloadingUtils {
|
||||
String classpathSpaceSeparated = (String) manifest.getMainAttributes().get(Attributes.Name.CLASS_PATH);
|
||||
if (classpathSpaceSeparated == null) return Collections.emptyList();
|
||||
|
||||
Collection<File> classpath = new ArrayList<File>(1);
|
||||
Collection<File> classpath = new ArrayList<>(1);
|
||||
for (String jar : classpathSpaceSeparated.split(" ")) {
|
||||
if (".".equals(jar)) continue;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ClassPreloadingUtils {
|
||||
ClassHandler handler
|
||||
) throws IOException {
|
||||
// 0.75 is HashMap.DEFAULT_LOAD_FACTOR
|
||||
Map<String, Object> resources = new HashMap<String, Object>((int) (classNumberEstimate / 0.75));
|
||||
Map<String, Object> resources = new HashMap<>((int) (classNumberEstimate / 0.75));
|
||||
|
||||
for (File jarFile : jarFiles) {
|
||||
if (handler != null) {
|
||||
@@ -154,7 +154,7 @@ public class ClassPreloadingUtils {
|
||||
resources.put(name, resourceData);
|
||||
}
|
||||
else if (previous instanceof ResourceData) {
|
||||
List<ResourceData> list = new ArrayList<ResourceData>();
|
||||
List<ResourceData> list = new ArrayList<>();
|
||||
list.add((ResourceData) previous);
|
||||
list.add(resourceData);
|
||||
resources.put(name, list);
|
||||
|
||||
@@ -140,7 +140,7 @@ public class MemoryBasedClassLoader extends ClassLoader {
|
||||
Enumeration<URL> fromParent = parent.getResources(name);
|
||||
if (!own.hasMoreElements()) return fromParent;
|
||||
|
||||
List<URL> result = new ArrayList<URL>();
|
||||
List<URL> result = new ArrayList<>();
|
||||
while (own.hasMoreElements()) {
|
||||
result.add(own.nextElement());
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public class MemoryBasedClassLoader extends ClassLoader {
|
||||
else {
|
||||
assert resources instanceof ArrayList : "Resource map should contain ResourceData or ArrayList<ResourceData>: " + name;
|
||||
List<ResourceData> resourceDatas = (ArrayList<ResourceData>) resources;
|
||||
List<URL> urls = new ArrayList<URL>(resourceDatas.size());
|
||||
List<URL> urls = new ArrayList<>(resourceDatas.size());
|
||||
for (ResourceData data : resourceDatas) {
|
||||
urls.add(data.getURL());
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class Preloader {
|
||||
List<File> instrumenters = Collections.emptyList();
|
||||
int estimate = DEFAULT_CLASS_NUMBER_ESTIMATE;
|
||||
String mainClass = null;
|
||||
List<String> arguments = new ArrayList<String>();
|
||||
List<String> arguments = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
@@ -130,7 +130,7 @@ public class Preloader {
|
||||
|
||||
private static List<File> parseClassPath(String classpath) {
|
||||
String[] paths = classpath.split(File.pathSeparator);
|
||||
List<File> files = new ArrayList<File>(paths.length);
|
||||
List<File> files = new ArrayList<>(paths.length);
|
||||
for (String path : paths) {
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
|
||||
Reference in New Issue
Block a user