Skip to content

java func_start: type-use annotation between modifier and return type not matched (e.g. 'protected @Nullable Foo bar(...)') #1486

Closed

Description

@squid-protocol

Summary

func_recall for java is 87.6% (233/266 found), with 0 extra_functions -- GitGalaxy isn't
over-matching, it's under-matching. Root-caused to a single recurring shape.

LANGUAGE_DEFINITIONS["java"]["rules"]["func_start"] in
gitgalaxy/standards/language_standards.py only allows annotations in the leading position,
before any modifiers:

^[ \t]*(?:@[\w.]+(?:\([^)]*\))?[ \t\n]*){0,10}(?!...)(?:(?:public|protected|private|static|final|abstract|synchronized|native|default|<...>)[ \t\n]+){0,5}(?:(?:[a-zA-Z_$][\w<>$\[\]?.,]*[ \t\n]+){1,5}...)

Real Java (JSR-308 type-use annotations, e.g. @Nullable/@NonNull) commonly places the
annotation between a modifier and the return type instead:

protected @Nullable AnnotationAttributes getAttributes(AnnotationMetadata metadata) {

The regex has no alternative for this position, so the whole declaration goes unmatched.

Confirmed repro

language-crucible/data/java/springboot/AutoConfigurationImportSelector.java:176:
protected @Nullable AnnotationAttributes getAttributes(AnnotationMetadata metadata) { --
confirmed absent from GitGalaxy's own function_data for this file. This shape
(^\s*(public|protected|private|static|final)\s+@[A-Za-z]) occurs 47 times across the 7-file
java crucible corpus (grep count per file: OnClassCondition.java 7, ServletWebServerApplicationContext.java
5, AutoConfigurationImportSelector.java 3, SpringApplication.java 20, Binder.java 5,
WebMvcAutoConfiguration.java 7) -- almost certainly the dominant cause of the 33 missing
functions (266 real - 233 found).

Suggested fix shape

Allow an annotation to appear between/after modifiers too, not just in the single leading
position -- e.g. change the modifier-repetition group to alternate between a modifier keyword and
an annotation on each iteration ((?:(?:public|protected|...)|@[\w.]+(?:\([^)]*\))?)[ \t\n]+){0,5}
shape, or add a second optional annotation-group between the modifier group and the return-type
group). Keep the existing ReDoS-safety bounds ({0,5}/{0,10} caps) intact -- this is purely about
where annotations are allowed to appear, not removing any existing bound.

Scope note

This affects GitGalaxy's actual func_start extraction (epic #813's extraction-hardening scope),
not just measurement -- confirmed via direct regex/corpus inspection, not an audit-tool artifact.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-negative
    on Aug 13, 2026
  2. added this to the v2.4.8 milestone on Aug 16, 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

    bugcore-enginetestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions