Valhalla EG minutes 6/21/17

Paul Sandoz paul.sandoz at
Wed Jul 12 19:08:30 UTC 2017

> On 12 Jul 2017, at 11:10, Karen Kinnear <karen.kinnear at> wrote:
> I think we have been discussing two different time frames.
> For the MVT EA we won’t have nest mates, so there I was pushing back on the dependency
> and we will stick with the package private access.
> Post-EA - I totally agree with going through a lookup mechanism, and I would like to design
> this around nest mates - and have the Lookup.defineClass(…) PRIVATE
> mode be an early use case of nest mates. Totally agree with trying to pull this one off.
> It would make sense for the VCC/DVT to be nest mates, the VCC would have to be the
> nest-top so it could be loaded with or without the DVT. ( Non-MVT I would expect the valhalla
> value class to be the nest-top.)


> For byte code generation uses - I assume you are generating additional methods that
> you would want to add to the nest. Are those temporary classes?

By temporary do you mean sort of like our existing VM anonymous classes? i.e. stuff that cannot be found and is not in the system dictionary. IIUC they are the same in that regard.

Code generation for lambda forms uses U.DAC (with LambdaForm as the host class), but could theoretically if supported could add new methods to a LambdaForm nest. (Which is sort of like what we are doing explicitly with pre-generation in the jlink stage for some lambda forms and also more explicitly for VarHandle linkage, see VarHandleGuards).

> And if I understand the proposal correctly, we are replacing constant pool patching
> with Lookup.getConstant() with a private Lookup,

Yes, that looks like a promising direction to explore.

> which uses an ldc of condy underneath,
> so essentially the BSM is filling in new types in the condy constant pool entries.

Here is my understanding: there could be a condy BSM that calls Lookup.getConstant() and returns the result of invoking the returned method handle, or a class could do that explicitly in clinit and assigning the result in a static final field. If the constant is a Map there could be a condy with a key value constant, or likewise explicitly in clinit.

Off the top of my head:

  byte[] classBytes = ...
  Map constant = …
  Class<?> c = l.defineClass(classBytes, Map.class, constant);
  Map _constant = (Map) MethodHandles.privateLookupIn(c, MethodHandles.lookup()).getConstant().invokeExact();

Implementation wise underneath the covers there could be a map say of Class -> MethodHandle e.g.: somewhere in the defineClass impl:

  MethodHandle cmh = MethodHandles.constant(constantType, constantValue);
  constantMap.put(definedClass, cmh);

Then the Lookup.getConstant could be implemented as follows:

  return constantMap.get(lookupClass);

A ClassValue kind of map might be more efficient than say a ConcurrentHM.



More information about the valhalla-spec-observers mailing list