Select primitive or object type to use


How can I select where my value should be compiled (JVM) as primitive type or as object type? I really need it.


Could you please explain you case? There are some discussion going on about that.

val bar: Int = 123

is always compiled like

private static int bar = 123

I need to compile it like Integer bar.

By the way, I would not want something like compiler plugin.


Make it val bar: Int? = 123

Out of curiosity. Why do you need it that way? Usually one wants to use primitives wherever it is possible.


I need to drop the object into recursion function


And? It will be boxed on-demand. Could you present the whole code?


No, I’m sorry

import java.lang.Integer

val bar: Integer = Integer(123)