I really can't explain this one.
I have a Java List<Byte> myList;
that is set like this:
class AJavaClass {
// ...
private List<Byte> myList;
public AJavaClass(List<Byte> myList) { this.myList = myList; }
// ...
}
AJavaClass aJavaClass = new AJavaClass(customMongoRepository.customFind());
The customMongoRepository
object is injected via Spring. It is defined like this:
public interface CustomMongoRepository extends MongoRepository<AComplexClass, String> {
List<Byte> customFind();
}
However, when looking inside aJavaClass
during execution, myList
is actually of type List<AComplexClass>
.
Now, what I understand is that the query executed in customFind
doesn't yield a List<Byte>
, but rather a List<AComplexClass>
. What I don't understand is how this doesn't throw an exception, and how a variable can contain a value of a different type.