Skip to content

Conversation

SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Nov 18, 2024

Currently, this generates invalid code:

@Singleton
public class LazyBean {
  @Inject Provider<Integer> intProvider;

  public LazyBean() throws Exception {}
}

Now properly generates code:

@Generated("io.avaje.inject.generator")
public final class LazyBean$DI  {

  public static void build(Builder builder) {
    if (builder.isAddBeanFor(LazyBean.class)) {
      builder.registerProvider(() -> {
      try {
          var bean = new LazyBean();
          bean.intProvider = builder.getProvider(Integer.class);
          return bean;
      } catch (Throwable e) {
        throw new RuntimeException("Error during wiring", e);
      }
     });
    }
  }

}

@SentryMan SentryMan added the bug Something isn't working label Nov 18, 2024
@SentryMan SentryMan added this to the 10.6 milestone Nov 18, 2024
@SentryMan SentryMan requested a review from rbygrave November 18, 2024 04:45
@SentryMan SentryMan self-assigned this Nov 18, 2024
@SentryMan SentryMan enabled auto-merge November 18, 2024 04:48
@SentryMan SentryMan merged commit cfc8399 into avaje:master Nov 19, 2024
7 checks passed
@SentryMan SentryMan deleted the lazy-checked branch June 24, 2025 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants