https://kotlinlang.org logo
#getting-started
Title
# getting-started
s

smit01

10/27/2021, 9:02 PM
This is javap result of .class of kotlin code. So the invoke method returning java.lang.Object is marked as synthetic and bridge method that's why is it possible to have two methods with same name but different return type. At source code it's not possible but in byte code by manually generating byte code using some byte code generator can we do that?
e

ephemient

10/27/2021, 9:09 PM
Copy code
val c = Supplier<Int> { 1 } // Kotlin
Supplier<Integer> c = () -> 1; // Java
both should generate similar synthetic bridge methods
https://docs.oracle.com/javase/tutorial/java/generics/bridgeMethods.html
When compiling a class or interface that extends a parameterized class or implements a parameterized interface, the compiler may need to create a synthetic method, which is called a bridge method, as part of the type erasure process.
7 Views