A presenter just cited that changing to var
is useful syntactic-sugar (aligning variable names). I thought I'd check and found...
List<String> list = new ArrayList<>(); // IMO this is safer future-proof coding
list.add("HELLO WORLD");
... generates bytecode with an invokeinterface
dispatch ...
11: invokeinterface #12, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
Converting to Java 10+ var
...
var list = new ArrayList<>();
list.add("HELLO WORLD");
... generates bytecode with an invokevirtual
dispatch ...
11: invokevirtual #12 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
Should I be concerned with, say, bulk upgrading a whole application's sourcecode with var
? E.g. Will sensitive sections be slower (or faster?! given invokeinterface
involves more steps?) Aside from that, are there other non-technical impacts (I saw an interesting comment about the clarity of offline code review for example)