<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
class Wrap {<br>
public static void main(String[] args) {<br>
String x = run(() -> "hi", Wrap::withMessage);<br>
System.out.println(x);<br>
}<br>
<br>
static <T> T run(Supplier<T> s, Function<Supplier<T>, Supplier<T>> mapper) {<br>
return mapper.apply(s).get();<br>
}<br>
<br>
static <T> Supplier<T> withMessage(Supplier<T> s) {<br>
return () -> {<br>
System.out.println("before");<br>
try {<br>
return s.get();<br>
} finally {<br>
System.out.println("after");<br>
}<br>
};<br>
}<br>
}<br>
</blockquote><div><br></div><div>Here you have a single invocation point of the "executor", and it is very tightly coupled with its user, but normally that is not how people use real executors (and thus I wouldn't need it for the above). Similarly why an ExecutorService (assuming only its submit(Callable) method) can't be implemented with a function, consider the following scenario (ignore the errors due to the checked exceptions):</div><div><br></div><div>```</div><div>class MyTool {<br> private final SynchronousExecutor executor;<br> <br> MyTool(SynchronousExecutor executor) {<br> this.executor = executor;<br> }<br> <br> Path writeHash(Path file) {<br> String str = executor.execute(() -> Files.readString(file));<br><br> var hashPath = file.resolveSibling(file.getFileName() + ".hash");<br> var hash = Integer.toString(str.hashCode());<br> return executor.execute(() -> Files.writeString(hashPath, hash));<br> }<br>}<br></div><div>```</div><div><br></div><div>where `SynchronousExecutor` is defined as:</div><div><br></div><div>```</div><div>interface SynchronousExecutor {<br> <T> T execute(Supplier<? extends T> action);<br>}<br></div><div>```</div><div><br></div><div>and maybe implemented similar to what you did:</div><div><br></div><div>```</div><div>class WithMessagExecutor implements SynchronousExecutor {<br> public <T> T execute(Supplier<? extends T> action) {<br> System.out.println("before");<br> try {<br> return action.get();<br> } finally {<br> System.out.println("after");<br> }<br> }<br>}<br></div><div>```</div><div><br></div><div>Do this with `Function` or whatever similar. You can't.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
<br>
If by “LTS” you're referring to the support service that Oracle’s sales team offer for some releases that they pick to help legacy applications then it is unrelated to OpenJDK and the development of features (even if the number of people who are using them is larger due to widespread misunderstandings). We let sales pick their LTS and try to ignore it in the development process.<br><br></blockquote><div><br></div><div>It doesn't matter much, because - as far as I have seen - the practical reality is that a vast amount (I would bet that it is a clear majority) of people (especially libraries) move from LTS to LTS (for whatever reason, be it legitimate or not). Though of course, if I were you, I wouldn't bother myself with it as well.</div><div> </div></div></div>