Skip to content

Use assertions to verify Supplier never invoked by constructors #9

@realityforge

Description

@realityforge

We should add java assertions to generated suppliers to verify that the supplier is not invoked in the binding code (i.e. @Injector constructors or provider methods on @Fragment types). It may also be able to assert that they are not invoked before the injector is initialized but it is unclear if this can be done safely in a concurrent scenario or is even reasonable to do in a concurrent scenario.

This would involve adding a flag to Injector that is set when fully initialized and then checking this flag inside supplier. To ensure this code is stripped in production builds the assignment and verification would need to be done via asserts like assert state = 1; and assert state != 0, "Supplier N invoked before component construction complete";

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions