RFR (S) 8151223: String concatenation fails with implicit toString() on package-private class
forax at univ-mlv.fr
forax at univ-mlv.fr
Tue Mar 8 16:53:10 UTC 2016
----- Mail original -----
> De: "Aleksey Shipilev" <aleksey.shipilev at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>, compiler-dev at openjdk.java.net, "John Rose"
> <john.r.rose at oracle.com>
> Envoyé: Mardi 8 Mars 2016 17:44:59
> Objet: Re: RFR (S) 8151223: String concatenation fails with implicit toString() on package-private class
> Alas, I think this defeats the purpose of having the MethodType spelled
> out in BSM. It is probably better to fix the corner case with
> inaccessible classes, and then use the existing BSM machinery as intended.
> On 03/08/2016 06:09 PM, Remi Forax wrote:
> > Thinking a little bit more about backward compatibility,
> > there is a way to make the string concatenation meta-protocol "more binary
> > compatible".
> > Use Objects in the descriptor of invokedynamic and send a string as
> > bootstrap constant encoding the declared types provided by javac.
> > At runtime, in the bootstrap method, when decoding the declared types, if a
> > type from the declared types is not accessible, substitute it by Object.
> > Then in the generated bytecode, insert a cast to the declared type (or use
> > asType() for strategies based on the method handles).
> > Because we do the casts upfront before calling toString(), we don't loose
> > the precise types
> > (obviously, we hope here that the code that does the concatenation will be
> > inlined with the code the rest of the code
> > otherwise, we will pay the price of a cast).
> > That's said, i'm not sure it's a good idea to implement that,
> > Java is not expected to use erased type at runtime to help backward
> > compatibility.
> > regards,
> > Rémi
> > ----- Mail original -----
> >> De: "Aleksey Shipilev" <aleksey.shipilev at oracle.com>
> >> À: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>,
> >> compiler-dev at openjdk.java.net
> >> Envoyé: Mardi 8 Mars 2016 14:59:22
> >> Objet: Re: RFR (S) 8151223: String concatenation fails with implicit
> >> toString() on package-private class
> >> On 03/08/2016 02:14 PM, Maurizio Cimadamore wrote:
> >>> On 08/03/16 11:12, Maurizio Cimadamore wrote:
> >>>> On 07/03/16 22:45, Aleksey Shipilev wrote:
> >>>>> I don't think it was redundant: Object.class passes isAccessible check,
> >>>>> and we exit the loop either with a concrete subclass of Object, or
> >>>>> Object itself. But I agree we may want to check for Tag.NONE too.
> >>>> Sorry - you are obviously right here - Object is always accessible, so
> >>>> your code was indeed correct. Feel free to change it back if you like!
> >>>> Maurizio
> >>> Also one last nit:
> >>> Type componentType = ((Type.ArrayType) originalType).getComponentType();
> >>> getComponentType is an API method - there's an internal routine:
> >>> Types.elemtype which works on any type, and thus you could avoid the
> >>> cast.
> >> Thanks Maurizio, fixed both nits:
> >> http://cr.openjdk.java.net/~shade/8151223/webrev.03/
> >> -Aleksey
More information about the compiler-dev