Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread David Holmes
On 16/01/2018 11:08 PM, jeffrey kutcher wrote: Trying to find documentation for the method resolution process. The JVMS defines the rules for method resolution (and subsequent selection). David -- Found this: https://stackoverflow.com/questions/6021109/java-runtime-method-resolution

Re: Reflection: how does one access a protected member in a superclass reflectively?

2018-01-16 Thread John Rose
On Jan 16, 2018, at 1:08 PM, Jochen Theodorou wrote: > > which is a big deal of a problem if the class, that is supposed to be exposed > to the framework is not under the control of the framework. And there is no > good solution (rewriting the bytecode for example is no good

Re: Reflection: how does one access a protected member in a superclass reflectively?

2018-01-16 Thread John Rose
On Jan 16, 2018, at 10:37 AM, Rony G. Flatscher wrote: > > Well that is probably the core of the problem: who needs to be the subclass, > the reflector or the > object to be reflected upon (whose inheritance tree is being walked up > towards the root class, and > if

Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread Kevin Rushforth
No, the fact that it returns a subtype is irrelevant to a program that uses it as an instance of the base class. The key here is to know what the formal declaration of the return type is, either statically or via reflection (e.g., using Method::getGenericReturnType). -- Kevin jeffrey

Re: Reflection: how does one access a protected member in a superclass reflectively?

2018-01-16 Thread Alan Bateman
On 16/01/2018 13:50, Rony G. Flatscher wrote: The excercise here is as follows: * there are classes in "mod_A" which get extended in "mod_B" and once more extended in "mod_C". * Hence "mod_B" requires "mod_A", and "mod_C" requires "mod_B", where "mod_B" exports to "mod_C" only *

Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread jeffrey kutcher
Then in this case, shouldn't getChildren() not be permitted? You're exposing a non-public sub-type. On Tuesday, January 16, 2018, 8:23:50 AM CST, Kevin Rushforth wrote: There are many good reasons for using non-public classes in the implementation of a

Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread Kevin Rushforth
There are many good reasons for using non-public classes in the implementation of a class library, the main one being to keep implementation details from leaking into the public API. So while I "get" that it causes difficulties in your specific case, I don't agree that the solution is to avoid

Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread jeffrey kutcher
Thanks Dalibor. On Tuesday, January 16, 2018, 7:45:55 AM CST, dalibor topic wrote: Try https://docs.oracle.com/javase/specs/jls/se9/html/jls-15.html#jls-15.12.4 for example. On 16.01.2018 14:29, jeffrey kutcher wrote: > Did that. There's nothing in there by

Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread jeffrey kutcher
There's nothing in the JLS by that name however, section 4.5 Parameterized Types, might be close to what I'm looking for. Even in a single inheritance system, resolving methods and types is a multi-dimensional process. I still say that by not allowing private inner classes, resolving this issue

Re: Reflection: how does one access a protected member in a superclass reflectively?

2018-01-16 Thread Rony G. Flatscher
On 16.01.2018 10:18, Alan Bateman wrote: > On 15/01/2018 20:56, Rony G. Flatscher wrote: >> : >> >> So the question is, how can I reflectively access "mtest1.Class01A" static >> protected field >> "myClassName" from "mtest3.Class03a" in Java 9? >> > The scenario in your mail is complicated but if

Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread dalibor topic
On 16.01.2018 14:08, jeffrey kutcher wrote> Is there official documentation explaining the method resolution process somewhere? I'd suggest taking a look at the Java Language specification and JVM specification for details. cheers, dalibor topic -- Dalibor Topic |

Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread jeffrey kutcher
Trying to find documentation for the method resolution process. Found this: https://stackoverflow.com/questions/6021109/java-runtime-method-resolution which leads to http://www.cowtowncoder.com/blog/archives/2010/12/entry_436.html Maybe this is an opportunity for someone to put together a

Re: How does one handle a java method which returns a non-public sub-type via reflection?

2018-01-16 Thread Peter Levart
On 01/15/2018 11:02 PM, David Holmes wrote: I recall a very similar discussion in the past. You have to start with (public) statically known types, not with the dynamic type of the instances involved. In essence you have to reflectively emulate the method resolution process that occurs with

Re: Reflection: how does one access a protected member in a superclass reflectively?

2018-01-16 Thread Alan Bateman
On 15/01/2018 20:56, Rony G. Flatscher wrote: : So the question is, how can I reflectively access "mtest1.Class01A" static protected field "myClassName" from "mtest3.Class03a" in Java 9? The scenario in your mail is complicated but if I read it correctly then I would expect this code in