Skip to content

Method invocation incorrectly resolves to property getter instead of calling the actual method #780

@jrburk

Description

@jrburk

Description

When a class has both a void method and a boolean isXxx() getter with related names, Beanshell 3.0.0-SNAPSHOT incorrectly invokes the property getter instead of the void method when calling xxx().

Example

    public interface Shutter {
        void up();           // Method I want to call
        boolean isUp();      // Getter for "up" property
    
        void down();         // This works correctly
        boolean isDown();    // Getter for "down" property
    }

The issue appears to be in bsh/Reflect.java:

invokeObjectMethod() (around line 54-80) attempts to resolve the method with resolveExpectedJavaMethod()
When this fails or in certain code paths, it falls back to property resolution
getObjectProperty() (around line 500-530) uses BshClassManager.memberCache.get(cls).findGetter(propName)
findGetter() matches the JavaBeans pattern and finds isUp() for property "up"
The property getter is invoked instead of the actual method

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions