Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Service Load MethodHandles.Lookup #3531

Open
SentryMan opened this issue Dec 19, 2024 · 0 comments
Open

Enhancement: Service Load MethodHandles.Lookup #3531

SentryMan opened this issue Dec 19, 2024 · 0 comments

Comments

@SentryMan
Copy link
Contributor

SentryMan commented Dec 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant