I am sending the message again, because the old one seems to make trouble because of the digital signed mail. Sorry, if it will arrive twice for you.
I have changed Object Teams to generate code that can call the static bootstrap method that returns the actual CallSite object for invokedynamic.
In the original version, there will be generated an invokestatic (because the bootstrap method is static). However, I want to generate an invokedynamic.
As a side note, my work bases on the Photon R4_8_maintenance branch.
When code is generated, the JDT compiler arrives in MessageSend::generateCode(*,*,*) (where MessageSend is from the assignment OT$result = base.callNext(…) ) and in line 661 it calls codeStream.invoke(Opcodes.OPC_invokestatic …) and the static
method invocation will be generated.
To generate an invokedynamic call I seem to have to use CodeStream::invokeDynamic(int bootStrapIndex, int argsSize, int returnTypeSize, char selector, char signature).
So I changed the code to be codeStream.invokeDynamic(…) and my issue is to come up with a bootStrapIndex. If I just pass a 0 or 1, it will compile but bytecode verification fails at load time with Exception in thread "main" java.lang.ClassFormatError:
Missing BootstrapMethods attribute in class file benchmark/bank/Bank$__OT__SavingsAccount.
Thus, when looking into the JDT sources to find how that function is used we see use-cases just concerned with codegen for lambdas. For example, ReferenceExpression::generateCode(*,*,*) line 405 — 407 generates the entry as following:
int invokeDynamicNumber = codeStream.classFile.recordBootstrapMethod(this);
So, since recordBootstrapMethod(*) just receives a FunctionalExpression which I do not have I am puzzled how to move forward.
Maybe you can point me to the right JDT API to generate an invokedynamic from the MessageSend, or do I have to treat the AST more differently (i.e., change how BaseReference works with the BaseReference::_wrappee member)? Or should I ask directly
at the JDT Core mailing list?
Thanks for your input.
M.Sc. Lars Schütze
Technische Universität Dresden
Chair for Compiler Construction