Skip to content

Enhancement: Service Load MethodHandles.Lookup #3531

@SentryMan

Description

@SentryMan

When using JPMS, MethodHandles.publicLookup()/MethodHandles.lookup() as currently used by ebean require a user to add an exports my.package directive to allow ebean to access the fields/methods/constructors of entities/DTOs.

The way around this is to pass a MethodHandles.Lookup from the entity/DTO class's module for ebean to use. I'm thinking we could create a new interface:

import java.lang.invoke.MethodHandles.Lookup;

public interface LookupProvider {

  Lookup provideLookup();

}

And have the querybean generator generate an implementation that can be service loaded.

public class Example implements LookupProvider {

  private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();

  @Override
  public Lookup provideLookup() {
    return LOOKUP;
  }
}

In this way, ebean can gain free reign to access the fields/methods/constructors of entities/DTOs without needing exports/opens directives from the user.

Related to #3530

Would like to get #3528 merged before I start on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions