Fix an edge case in the Reflector's search for a public method declaration

Description

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 // all: package demo; public interface IBar { void stuff(); } class Bar { public void stuff() { System.out.println("stuff"); } } class SubBar extends Bar implements IBar { // implements IBar, via non-public superclass Bar } public class Factory { public static IBar get() { return new SubBar(); } }

Can't invoke from Clojure:

1 2 3 4 (import '[demo Factory IBar]) (def inst (Factory/get)) ;; instance of SubBar, inferred as IBar (.stuff inst) ;; IllegalArgumentException Can't call public method of non-public class: public void demo.Bar.stuff() clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88)

Cause: The Reflector is not taking into account that a non-public class can implement an interface, and have a non-public parent class contain an implementation of a method on that interface.

Approach: The solution I took is to pass in the target object's class instead of the declaring class of the method object.

Patch: clj-1609-3.patch + clj-1609-test.patch

Screened by: Fogus

Environment

None

Status

Assignee

Unassigned

Reporter

Jeremy Heiler

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Affects versions

Release 1.6

Priority

Major
Configure