On Tue, 6 May 2025 12:30:01 GMT, Per Minborg <pminb...@openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/CaptureStateUtil.java line >> 390: >> >>> 388: return MhUtil.findVirtual(LOOKUP, Arena.class, "close", >>> 389: MethodType.methodType(void.class)); >>> 390: } >> >> Suggestion: >> >> return switch (index) { >> case NON_NEGATIVE_INT -> MhUtil.findStatic(LOOKUP, "nonNegative", >> MethodType.methodType(boolean.class, int.class)); >> case SUCCESS_INT -> MhUtil.findStatic(LOOKUP, "success", >> MethodType.methodType(int.class, int.class, >> MemorySegment.class)); >> case ERROR_INT -> MhUtil.findStatic(LOOKUP, "error", >> MethodType.methodType(int.class, MethodHandle.class, >> int.class, MemorySegment.class)); >> case NON_NEGATIVE_LONG -> MhUtil.findStatic(LOOKUP, >> "nonNegative", >> MethodType.methodType(boolean.class, long.class)); >> case SUCCESS_LONG -> MhUtil.findStatic(LOOKUP, "success", >> MethodType.methodType(long.class, long.class, >> MemorySegment.class)); >> case ERROR_LONG -> MhUtil.findStatic(LOOKUP, "error", >> MethodType.methodType(long.class, MethodHandle.class, >> long.class, MemorySegment.class)); >> case ACQUIRE_ARENA -> MhUtil.findStatic(LOOKUP, "acquireArena", >> MethodType.methodType(Arena.class)); >> case ALLOCATE -> MhUtil.findStatic(LOOKUP, "allocate", >> MethodType.methodType(MemorySegment.class, Arena.class)); >> case ARENA_CLOSE -> MhUtil.findVirtual(LOOKUP, Arena.class, >> "close", >> MethodType.methodType(void.class)); >> default -> throw new InternalError("Unknown index: " + index); >> }; >> >> Switch statement can be replaced with enhanced 'switch' > > I have the old switch format in anticipation of faster startup. enhanced 'switch' is just syntax sugar and does not affect startup speed ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25043#discussion_r2075935264