On 13.12.2016 16:56, Alan Bateman wrote:
> On 13/12/2016 15:47, Rony G. Flatscher wrote:
>
>> :
>>
>> So the current code does not take protected members into account. If 
>> protected members (cf. Alex'
>> comment)  get added, wouldn't e.g. java.lang.reflect.Method.invoke(...)  or
>> java.lang.reflect.Field.get(...) be the place to check in the next step, 
>> throwing an
>> IllegalAccessException if the object is not instantiated from a subclass of 
>> the class the protected
>> method to invoke or protected Field to get is defined?
>>
> If you mean you are asking for setAccessible(true) to succeed but still do 
> the access check then
> it will cause a lot of complications.
>
> So I'm curious, are you calling setAccessible on protected members that you 
> do have access or not?
> If you do have access (you are in the same package or a sub-type) then you 
> don't need to call
> setAccessible. On the other hand, if you are looking to use the 
> AccessibleObject to get into a
> different subtype then you are out of luck, the package needs to be open to 
> you to do that.
The reason for the question is a language binding (to IBM's Object Rexx in the 
open-sourced form
called open Object Rexx, ooRexx, and heavily improved since in the hands of the 
Rexx Language
Assocation, www.rexxla.org) to Java that I have created 2000 (yup, quite some 
time) using Apache's
Bean scripting framework BSF (rooted in another open-source project at IBM) and 
have constantly
improved since then. The ooRexx Java bridge is available for Windows, Linux and 
MacOSX.

ooRexx is an interpreted language implemented in C++, the bridge to Java is 
realized via JNI and a
Java framework. It allows proxying Java objects with Rexx objects (no strong 
typing, caseless, quite
a few Smalltalk concepts, sending ooRexx messages cause the appropriate Java 
classes, members to be
looked up, methods to be invoked on behalf of the Rexx program), and proxying 
Rexx objects with Java
objects (causing Java method invocations to result in sending appropriate Rexx 
messages to the
proxied Rexx objects), including the ability to implement Java interface or 
abstract classes in
ooRexx (i.e. implement the abstract methods with ooRexx methods). The fact that 
ooRexx is based on
classic Rexx carrying forward the Rexx philosophy of "human-centricness" in its 
design makes it an
easy to learn language, yet a powerful one, which allows me at a Business 
Administration University
to teach oo-programming from zero knowledge to becoming able to interact and 
exploit Windows-OLE, C#
and then Java within one (sic!) semester with a four hour class. The Java 
support is intentionally
used to teach and demonstrate that it is rather easy to create applications, 
that do not lock-in
businesses into specific operating systems. ooRexx "surfing Java" allows one to 
do the same thing:
create applications that are open on all major operating system platforms by 
virtue of exploiting
Java under the covers.

To make a long story short: I have always adhered to the Java rules for the 
Rexx users, in that they
are only allowed to access public Java classes, public fields and public 
methods ("there must be a
reason why the Java language has defined these rules" :) ). The exception are 
protected members of a
Java class that are accessed via instances of subclasses (maybe even created 
for ooRexx on the fly
at runtime) in order to adhere to the Java model as close as possible. So the 
classic Java
reflection (BSF4Rexx the initial Rexx-Java bridge worked even with Java 1.1.8, 
sic!, on OS/2)
mechanism is really at the heart of this implementation, hence the question.

---rony

P.S.: Even if it is the first time you might have heard of Rexx/ooRexx do not 
mistake that with
Rexx/ooRexx not being deployed in quite a few large shops on quite a large 
scale in addition. For me
a great value lies in ooRexx easy syntax that allows me to teach it and the oo 
concepts faster than
in any other programming language that I have experimented with in the past 25 
years with Business
Administration students.

Reply via email to