Skip to content

Comments

Add a direct sub classes data structure to the Painless lookup (#76955)#9

Open
MitchLewis930 wants to merge 2 commits intopr_019_beforefrom
pr_019_after
Open

Add a direct sub classes data structure to the Painless lookup (#76955)#9
MitchLewis930 wants to merge 2 commits intopr_019_beforefrom
pr_019_after

Conversation

@MitchLewis930
Copy link

@MitchLewis930 MitchLewis930 commented Jan 30, 2026

PR_019


Note

Medium Risk
Changes core Painless symbol-resolution logic (methods/fields/runtime handles and functional-interface detection), which could affect script compilation or runtime behavior in edge cases, though covered by new targeted tests.

Overview
Adds a new classesToDirectSubClasses index to PainlessLookup, built during lookup construction, and exposes it via getDirectSubClasses for navigating the allow-listed type hierarchy (including handling gaps in the whitelist and interface relationships).

Refactors member/method resolution to use a shared lookupPainlessObject that walks superclasses and transitively walks interfaces (with de-duping), including an Object fallback for interface targets; functional-interface method selection is updated to also resolve inherited SAM methods, with new tests and a dedicated whitelist resource covering these cases.

Written by Cursor Bugbot for commit 2a11f7e. This will update automatically on new commits. Configure here.

…ic#76955)

This change has two main components.

The first is to have method/field resolution for compile-time and run-time use the same code path for 
now. This removes copying of member methods between super and sub classes and instead does a 
resolution through the class hierarchy. This allows us to correctly implement the next change.

The second is a data structure that allows for the lookup of direct sub classes for all allow listed 
classes/interfaces within Painless.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


if (painlessObject != null) {
return painlessObject;
targetInterfaces.addAll(Arrays.asList(targetInterface.getInterfaces()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interface traversal skips non-whitelisted intermediate interfaces

High Severity

The lookupPainlessObject method only adds parent interfaces to the search queue when the current interface is in the whitelist (targetPainlessClass != null). When an interface is NOT whitelisted, its parent interfaces are never searched. This is inconsistent with buildPainlessClassHierarchy which correctly continues traversing parent interfaces when an intermediate interface is not whitelisted (via the else branch). Methods and fields on whitelisted interfaces that are only reachable through non-whitelisted intermediate interfaces will fail to be found at lookup time.

Fix in Cursor Fix in Web

Co-authored-by: MitchLewis930 <MitchLewis930@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants