GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [apex] New Rule: Invocable Classes require a no argument constructor · Issue #6793 · pmd/pmd

[apex] New Rule: Invocable Classes require a no argument constructor #6793

New issue
Copy link
New issue
Copy link
Closed
#6794
Closed
[apex] New Rule: Invocable Classes require a no argument constructor#6793
#6794
Copy link
Labels
a:new-ruleProposal to add a new built-in rule
Milestone
7.26.0

Description

@FishOfPrey
FishOfPrey
opened on Jun 19, 2026
Issue body actions

Proposed Rule Name: InvocableClassNoArgConstructor

Proposed Category: Error Prone

Description:
Apex classes that declare @InvocableVariable fields or properties must expose an
accessible no-argument constructor. Salesforce Flow instantiates these classes via a
zero-arg constructor. When a developer adds any explicit constructor, Apex no longer
synthesises a default one, so Flow cannot create an instance and throws a runtime error. E.g. System.TypeException: MyInvocableClass does not have a no-arg constructor.

Global classes have an additional requirement: the no-arg constructor must be global
so that it remains accessible from managed packages.

Summer '26 Release Note: Provide Visible No-Argument Constructors for Custom Apex Classes Used as Invocable Action Parameters

Code Sample:

// BAD: explicit constructor eliminates the default constructor;
// Flow cannot instantiate this class at runtime
public class FlowInput {
    @InvocableVariable
    public String recordId;

    public FlowInput(String recordId) {
        this.recordId = recordId;
    }
}

// BAD (global class): no-arg constructor is not global;
// cross-package Flows cannot instantiate this class
global class FlowInput {
    @InvocableVariable
    global String recordId;

    private FlowInput() {}

    public FlowInput(String recordId) {
        this.recordId = recordId;
    }
}

// GOOD: explicit no-arg constructor restores Flow compatibility
public class FlowInput {
    @InvocableVariable
    public String recordId;

    public FlowInput() {}

    public FlowInput(String recordId) {
        this.recordId = recordId;
    }
}

// GOOD (global class): global no-arg constructor is accessible from managed packages
global class FlowInput {
    @InvocableVariable
    global String recordId;

    global FlowInput() {}

    global FlowInput(String recordId) {
        this.recordId = recordId;
    }
}

Possible Properties:

No — the rule has a single clear failure condition (missing accessible no-arg constructor) with no thresholds or configurable behaviour warranted.

Activity

  1. FishOfPrey
    added
    a:new-ruleProposal to add a new built-in rule
    on Jun 19, 2026
  2. adangel
    added this to the 7.26.0 milestone on Jun 23, 2026
  3. adangel
    added a commit that references this issue on Jun 23, 2026

    [doc] Update release notes (pmd#6793, pmd#6794)

    d453286
  4. adangel
    closed this as completedin #6794on Jun 23, 2026
  5. adangel
    marked [apex] Any class with an annotation starting with "@Invocable" must have a no-parameter constructor #6647 as a duplicate of this issue on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:new-ruleProposal to add a new built-in rule

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.26.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.