Converter build fails with Java 12
No additional unit tests needed as the existing unit tests already cover
this when run under Java 12
@@ -91,11 +91,23 @@ class ConvertingImpl extends AbstractSpecifying<Converting>
Set<Class< ? >> nmv = new HashSet<>(cim.keySet());
nmv.addAll(Arrays.<Class< ? >> asList(String.class, Class.class,
Comparable.class, CharSequence.class, Map.Entry.class));
+ // The following classes are only available from Java 12 onwards
+ addClassIfAvailable("java.lang.constant.Constable", nmv);
+ addClassIfAvailable("java.lang.constant.ConstantDesc", nmv);
INTERFACE_IMPLS = Collections.unmodifiableMap(iim);
NO_MAP_VIEW_TYPES = Collections.unmodifiableSet(nmv);
}
+ private static void addClassIfAvailable(String cls, Collection<Class<?>> collection) {
+ try {
+ Class<?> clazz = ConvertingImpl.class.getClassLoader().loadClass(cls);
+ collection.add(clazz);
+ } catch (Exception ex) {
+ // Class not available, to nothing
+ }
+ }
+
private final InternalConverter converter;
private volatile Object object;
private volatile Class< ? > sourceClass;
