Boolean vs java.lang.Boolean


#1

I encountered a subtle difference between Boolean and other primitives:

	@Test
	fun test() {
		println(java.lang.Boolean::class.java.name)
		println(Boolean::class.java.name)
		println(java.lang.Number::class.java.name)
		println(Number::class.java.name)
		println(java.lang.String::class.java.name)
		println(String::class.java.name)

		println(java.lang.Boolean::class.qualifiedName)
		println(Boolean::class.qualifiedName)
		println(java.lang.Number::class.qualifiedName)
		println(Number::class.qualifiedName)
		println(java.lang.String::class.qualifiedName)
		println(String::class.qualifiedName)
	}

Prints:

java.lang.Boolean
boolean
java.lang.Number
java.lang.Number
java.lang.String
java.lang.String
kotlin.Boolean
kotlin.Boolean
kotlin.Number
kotlin.Number
kotlin.String
kotlin.String

Does anyone know why?


#2

Boolean is a primitive wrapper. Number and String are not. If you compared with Integer/Int you’d see the same pattern.

println(java.lang.Integer::class.java.name) // java.lang.Integer
println(Int::class.java.name) // int