<div dir="ltr"><div dir="ltr">Thanks! Responses inline,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 10, 2023 at 8:24 AM - <<a href="mailto:liangchenblue@gmail.com">liangchenblue@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello Liam,<div>I think your approach is quite nice. For your information, for non-static arguments like an invocation, we can compile a static factory method that returns an enum instance or use ConstantBootstraps.invoke as the non-static argument's bootstrap method. The invokestatic-putstatic sequence is 6 bytes as well.</div><div><br></div><div>If there are too many arguments, condy bootstrap method arguments may run into the constant pool size limit, though unlikely.</div></div></blockquote><div><br></div><div>Using static factory methods seems like it could be a nice way to use condy more consistently for language levels that support it, instead of switching back and forth between the two strategies depending on whether or not constant arguments were present.</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"><div dir="ltr"><div>Condy might be more costly than a plain invocation at runtime compared to plain new-dup-init sequence, without caching or precomputation involved. We need to check the initialization performance of these new enums.</div></div></blockquote><div><br></div><div>I collected some simple performance measurements of an enum with 4000 constants with and without the new strategy. The results were pretty stable, and condy came out ~0.07s faster. The startup performance implications definitely deserve more investigation and scrutiny, but those initial numbers seem encouraging.<br><br>The benchmark was roughly:<br><br>enum C {<br>  C1,<br>  // <snip><br>  C4000;<br>  public static void main(String[] args) {<br>    System.out.println(C.values().length);<br>  }<br>}<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"><div dir="ltr"><div>For the bootstrapping issue, I've left a comment on your draft PR; I think it should be controlled via a compiler flag like StringConcat.</div></div></blockquote><div><br></div><div>Done, thanks! </div></div></div>