Skip to content

WITHDRAWN: Java complexity does not count catch (not a bug: branch contract corollary 1) #8867

Closed

Description

@squid-protocol

What is wrong

In Java, a catch clause does not add to complexity. In retrofit (2,616 functions) the oracle sees a branch in 681 functions and the family in 425 (recall 0.62, precision 0.99). Among the branches the family missed, catch clauses account for 307 functions and && for 11.

Reproduce

class A {
    int caught() {
        try {
            return 1;
        } catch (Exception e) {
            return 2;
        }
    }
}

complexity == 0 for caught, though the exception path is a second route through the function. The try/catch/&&/|| forms are all standard McCabe decision points.

Expected

Either catch (and &&, || where it does not) counts toward complexity and struct_branch for Java, or the family definition says it does not and #8862 records why. Check the other languages with exception handlers (C#, Kotlin, Scala, JavaScript counts it at 0.96/0.96, Python at 0.99/0.98).

Part of #8863. Time the change; add the case above as a test.

Activity

  1. added
    bug
    core-engine
    on Nov 21, 2026
  2. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-21T17:51Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  3. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Withdrawn (2026-11-21): this is not a bug. The branch contract (docs/branch_rule_contract.md, corollary 1) says: "A handler is not a decision. catch/rescue/except/finally/ensure/trap, the guarded-region opener ... and the raiser (throw) mark where control leaves or arrives; the decision was made by the throw. They are safety's constructs." The engine was changed to that on purpose across 27 rules, so Java not counting catch as a branch is the contract working. My oracle counted catch as a branch because I had not read the contract's corollaries; the oracle now follows them (tests/tools PR #8864), and two independent agents hit the same contradiction. I am marking this invalid and retitling it; closing it is the maintainer's call.

  4. changed the title [-]Java: complexity does not count catch clauses (recall 0.62, 307 functions)[/-] [+]WITHDRAWN: Java complexity does not count catch (not a bug: branch contract corollary 1)[/+] on Nov 21, 2026
  5. added
    invalid
    on Nov 21, 2026
  6. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Leftovers: (1) csharp and groovy branch also lack &&/||. (2) The family oracle (#8864) should not count catch as a branch for Java: branch_rule_contract.md corollary 1 says a handler is not a decision. (3) keyword-rosetta has no Java && plant.

  7. added a commit that references this issue on Nov 21, 2026
    e475ba5
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

    bugclaim:melekcore-engineinvalidpriority: medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions