Netflix / archaius

Library for configuration management API
Apache License 2.0
2.46k stars 485 forks source link

Make ArchaiusType equals / hashCode compatible with ParameterizedTypeImpl #704

Closed kilink closed 6 months ago

kilink commented 6 months ago

Make ArchaiusType's equals / hashCode / toString match what JDK's ParameterizedTypeImpl does, so that equivalent ParameterizedType instances hash and compare equal with ArchaiusType. Update toString to match what ParameterizedTypeImpl does as well.

Additionally, add do a defensive copy of the returned array in getActualTypeArguments, and add basic unit tests.

kilink commented 6 months ago

See JDK implementation of these methods here: https://github.com/openjdk/jdk/blob/d10f277bd39bb5ac9bd48939c916de607fef8ace/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java

kilink commented 6 months ago

Also note the Javadoc for ParameterizedType, which states:

Instances of classes that implement this interface must implement an equals() method that equates any two instances that share the same generic type declaration and have equal type parameters.