----- Mail original ----- > De: "Johannes Kuhn" <i...@j-kuhn.de> > À: "core-libs-dev" <core-libs-dev@openjdk.java.net> > Envoyé: Vendredi 22 Novembre 2019 04:23:31 > Objet: Looking for Sponsor: JDK-8229959 Convert proxy class to use constant > dynamic
> Hi everyone, Hi Johannes, > > a few hours ago I signed the Oracle Contributor Agreement. felicitation ! > I'd like to work on JDK-8229959: Convert proxy class to use constant > dynamic. > > Without further ado, here are some questions and answers you may ask: > > * What are you exactly planing to do? > I'd like to replace the GETSTATIC instruction with an LDC instruction in > the current generated bytecode for the proxies. > > * What benefits would such a change have? > First, it allows us to drop the static final fields and the class > initializer for the generated proxy classes. > Second, it allows the code (both generated and generator) to be more > clear by moving the essential parts together. > Third, it might bring some performance improvement, because the > j.l.r.Method lookup is delayed to it's first use - which in some cases > might never happen. > > * Are you able to write such a patch? > Yes. I have some experience with the Java bytecode, ASM and ConstantDynamic. > > * But java.lang.reflect.Method is not immutable/persistent? > That's not a question, but you are right. j.l.r.Method has > setAccessible, modifying the Method instance. Still, the current > implementation shares the same Method instance with all proxies with the > same interfaces in the same ClassLoader. i wonder if some codes in the wild rely on that ? > > * What should the bootstrap method look like? > The bootstrap method will take one additional argument, a direct > MethodHandle to the to be resolved method, and should crack it using > it's passed Lookup and then reflect it as Method. In other words, it > should do `return lookup.revealDirect(mh).reflectAs(Method.class, lookup);` > > * Where should this bootstrap method reside? > I'm glad you asked. After some thoughts, there are two promising places > where I could put it: > a) As private static method in the proxy itself. > Benefits: No public API changes. Also allows easy migration to option b) > if pursued later. > Downsides: The bootstrap method will be duplicated into every proxy class. > b) As a public static method in the java.* namespace, preferably in > java.lang.invoke.ConstantBootstraps. > Benefits: Only one single implementation in the JVM. > Downside: Changes to the public API. Also leads to other questions like > "Should j.l.r.Member implement Constable?" and "Should I add a subclass > of j.l.c.DynamicConstantDesc for this bootstrap method?" > I prefer option a), but I'm fine with both options. Please let me know > what you think, or if you think of a better way. There is perhaps a better way, as part of the branch nestmates of valhalla, Mandy has added a way to transfer a live object to a Class when defining it, with that you can send all the Methods as an array and in the bootstrap method of a condy, access to the right method by extracting it from the array using an index. It will avoid the whole serialization/deserialization of Methods dance. Here is an example: https://gist.github.com/forax/d0f0034190bc479b86ce977fb94ca176 I believe those changes are planned for Java 14 so will be integrated very soon. > > * What do I expect from my Sponsor? > I expect my sponsor lo believe that this change will improve the > OpenJDK. If consensus shows a preference for option b) above (bootstrap > in j.l.i.ConstantBootstaps), a guidance what requests have to be made > and where. In that case, I volunteer to write those requests and send > them to my sponsor, who can (at their sole discretion) forward it to the > relevant places. > > If you have any additional questions, please don't hesitate to answer to > this mail. I will try to answer all questions to the best of my ability. > regards, > With best regards, > Johannes Kuhn Rémi