> On 6 Jul 2017, at 15:58, John Rose <john.r.r...@oracle.com> wrote: > > On Jul 6, 2017, at 1:02 PM, Paul Sandoz <paul.san...@oracle.com > <mailto:paul.san...@oracle.com>> wrote: >> >> In terms of what we have today we could easily do: >> >> // lookup must have private access to the lookup class, which becomes the >> “host” class >> Class<?> defineAnonymousClass(byte[] data) >> >> is that ending gaining too much? > > Sure, that's OK, or else an 'isAnonymous' optional argument. > The difficult part here is specifying exactly what is a "host class". >
Agreed, that’s the tricky bit. >> That still leaves the possibility of another method in the future say: >> >> Class<?> defineClass(boolean isAnon, byte[] data, Object constant) >> >> That’s a little fuzzy since it’s not clear to me how the generated class >> locates the constant (synthetic static final field of known name? substitute >> the last entry in the CP if appropriately defined in the class bytes as >> substitutable?). > > On Jul 6, 2017, at 1:12 PM, Remi Forax <fo...@univ-mlv.fr > <mailto:fo...@univ-mlv.fr>> wrote: >> >> Lookup.getConstant() with a private Lookup ? > > Exactly, an ad hoc API point like that. Would fit nicely with a BSM and > CONSTANT_ConstantDynamic and ldc. Or a private static final and > code in <clinit>. I like that. Perhaps those associated constants could be squirrelled away in a ClassValue, and any class could participate and receive an ad-hoc constant. > > If you need several of them, a Map<String,Object> would be your > friend. This doesn't need to be baked into the Lookup API, just a > design pattern, supported nicely by a slightly different BSM. > And there could be a condy for extracting a value for a given key from the Map constant. Paul.