Skip to content

Comments

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

Open
MitchLewis930 wants to merge 1 commit intopr_019_beforefrom
pr_019_after
Open

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

Conversation

@MitchLewis930
Copy link

PR_019

…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.
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 00:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a direct subclass data structure to the Painless lookup system to track class hierarchy relationships for whitelisted classes.

Changes:

  • Added classesToDirectSubClasses map to store direct subclass relationships
  • Replaced copyPainlessClassMembers with buildPainlessClassHierarchy to construct the hierarchy during lookup build
  • Enhanced lookupPainlessObject method to handle interface lookups and prevent infinite loops when traversing interfaces

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
org.elasticsearch.painless.lookup Test resource file defining whitelisted classes for lookup tests
LookupTests.java New test class verifying direct subclass tracking with complex inheritance hierarchies
PainlessLookupBuilder.java Implements hierarchy building logic and integrates direct subclass tracking
PainlessLookup.java Adds direct subclass getter and refactors lookup methods to use unified traversal

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1308 to +1309
// we check for Object.class as part of the allow listed classes because
// it is possible for the compiler to work without Object
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'allow listed' to 'allowlisted' (or 'whitelisted' to match the existing terminology in the codebase).

Copilot uses AI. Check for mistakes.
Class<?> superClass = subClass.getSuperclass();

// this finds the nearest super class for a given sub class
// because the allow list may have gaps between classes
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'allow list' to 'allowlist' (or 'whitelist' to match the existing terminology in the codebase).

Copilot uses AI. Check for mistakes.
break;
} else {
// this ensures all interfaces from a sub class that
// is not allow listed are checked if they are
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'allow listed' to 'allowlisted' (or 'whitelisted' to match the existing terminology in the codebase).

Copilot uses AI. Check for mistakes.
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.

2 participants