On Tue, 30 Jul 2024 06:54:04 GMT, Kim Barrett <kbarr...@openjdk.org> wrote:
>> src/hotspot/share/prims/jni.cpp line 1151: >> >>> 1149: \ >>> 1150: EntryProbe; \ >>> 1151: ResultType ret{}; \ >> >> This looks bogus. ResultType is just a macro variable and could be a >> primitive type. ?? Does the local need initializing? > > This is value-initialization syntax. Value-initialization of a primitive > type is zero-initialization. > > However, I think we don't need the local variable at all. Here and in the > other 5(?) similar places, rather than > > ResultType ret{}; > ... > ret = jvalue.get_##ResultType(); > return ret; > > I think we could just have > > ... > return jvalue.get_##ResultType(); Looks like eliminating the variable doesn't work. It gets used in a `DT_RETURN_MARK_FOR` form, which needs the address of the return value. That address is obtained using a reference. Taking a reference to an uninitialized variable is (I think) okay, so long as one doesn't attempt to use the uninitialized value. But then the assignment could be problematic if it's uninitialized and the assignment operator is non-trivial. I expect the compiler will optimize away a trivial zero initialization if it's not needed. So ensuring it is value-initialized seems like the cleanest thing to do. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20385#discussion_r1696441217