/*
* JavaInspect - Utility to visualize java software
- * Copyright (C) 2013-2015, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright (C) 2013-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
public class ClassDescriptor implements GraphElement, Comparable<ClassDescriptor> {
private static final int MAX_REFERECNES_COUNT = 10;
- private final Map<String, FieldDescriptor> nameToFieldMap = new TreeMap<String, FieldDescriptor>();
- private final SortedSet<MethodDescriptor> methods = new TreeSet<MethodDescriptor>();
+ final List<ClassDescriptor> interfaces = new ArrayList<>();
+ private final Map<String, FieldDescriptor> nameToFieldMap = new TreeMap<>();
+ private final SortedSet<MethodDescriptor> methods = new TreeSet<>();
private final ClassGraph classGraph;
boolean isEnum;
boolean isInterface;
boolean isArray;
- List<ClassDescriptor> interfaces = new ArrayList<ClassDescriptor>();
ClassDescriptor superClass;
private String fullyQualifiedName;
/**
this.classGraph = classGraph;
}
- protected void analyzeClass(final Class<? extends Object> clazz) {
+ protected void analyzeClass(final Class<?> clazz) {
fullyQualifiedName = clazz.getName();
if (!isVisible())
return;
- indexFields(clazz.getDeclaredFields());
- indexFields(clazz.getFields());
+ try {
+ indexFields(clazz.getDeclaredFields());
+ indexFields(clazz.getFields());
+ } catch (NoClassDefFoundError error) {
+ // TODO: better logging of this error
+ System.out.println(error.toString());
+ }
indexMethods(clazz);
result.append("\n");
result.append(" // field references to other classes\n");
- for (final Map.Entry<String, FieldDescriptor> entry : nameToFieldMap
- .entrySet())
- result.append(entry.getValue().getDot());
+ nameToFieldMap.forEach((fieldName, field) -> result.append(field.getDot()));
}
private void enlistFields(final StringBuffer result) {
@Override
public String getGraphId() {
- final String result = "class_"
- + fullyQualifiedName.replace('.', '_').replace(";", "")
- .replace("[L", "").replace('$', '_');
- return result;
+
+ return "class_"
+ + fullyQualifiedName
+ .replace('.', '_')
+ .replace(";", "")
+ .replace("[[", "")
+ .replace("[L", "")
+ .replace("[[L", "") // array of arrays
+ .replace("[[[L", "") // array of arrays of arrays
+ .replace('$', '_');
}
private String getInterfaceColor() {
return;
}
- return;
}
private void indexFields(final Field[] fields) {
getOrCreateFieldDescriptor(field);
}
- private void indexMethods(final Class<? extends Object> clazz) {
+ private void indexMethods(final Class<?> clazz) {
for (final Method method : clazz.getMethods()) {
final MethodDescriptor methodDescriptor = new MethodDescriptor(
this, method.getName());