privatestaticvoid testCanonicalName() { class LocalClass {} // Local class; no canonical name
Object o = new Object() {}; // Anonymous class; no canonical name
Object[] objectArray = {};
Map<Class<?>, String> expectedCanonicalName = new HashMap<>();
// If a component type doesn't have a canonical name, neither // does an array of that type.
expectedCanonicalName.put(LocalClass.class.arrayType(), null);
expectedCanonicalName.put(o.getClass().arrayType(), null);
for (var entry : expectedCanonicalName.entrySet()) { var key = entry.getKey(); var expectedName = entry.getValue();
String canonicalName = key.getCanonicalName(); if (!Objects.equals(canonicalName, expectedName)) {
System.err.println("Unexpected canonical name '" +
canonicalName + "' found for " +
key + ", expected " + expectedName); thrownew RuntimeException();
}
}
}
privatestaticvoid testSimpleName() { class ALocalClass {} // Local class
Object o = new Object() {}; // Anonymous class, empty simple name
Object[] objectArray = {};
Map<Class<?>, String> expectedSimpleName = new HashMap<>();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.