When I use the Java reflection API to get information about all methods and fields of the interface clojure.lang.IPersistentVector, e.g. using code in the REPL like this:
(require '[clojure.reflect :as refl])
(require '[clojure.pprint :as pp])
(def t1 (refl/type-reflect clojure.lang.IPersistentVector))
(pp/pprint t1)
I see not only the methods that are explicitly declared in that interface here: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IPersistentVector.java
I also see a fourth method named cons
that has the flags :public :bridge :synthetic
that has :return-type clojure.lang.IPersistentCollection
. My guess is that this is somehow because IPersistentVector extends IPersistentStack, which in turn extends IPersistentCollection, which has its own cons
method.
The Java Virtual Machine Specification for Java SE 8 says that the bridge flag for a method means "A bridge method, generated by the compiler.", and the synthetic flag means "Declared synthetic; not present in the source code." (see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.6).
Hmmm, I was going to say I had not found much in the way of explanation for why this happens, but this may be a case of rubber ducking, as I am perhaps doing different Google searches now than I was earlier when I tried to learn what is going on. This article might be explaining what is going on: http://stas-blogspot.blogspot.com/2010/03/java-bridge-methods-explained.html#:~:text=Bridge%20methods%20in%20Java%20are,the%20actual%20method%20being%20invoked.