Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No access to Java accessors during script evaluation #140

Closed
hinerm opened this issue Jan 20, 2016 · 2 comments
Closed

No access to Java accessors during script evaluation #140

hinerm opened this issue Jan 20, 2016 · 2 comments

Comments

@hinerm
Copy link

hinerm commented Jan 20, 2016

The automatic Java Bean conveniences actually make scripting in renjin unintuitive at first (for a Java developer), and even make some operations impossible (as far as I can tell).

For example, running the script:

"import(java.util.HashMap)\n"
"ageMap <- HashMap$new()\n"
"print(ageMap$getClass())";

Causes:
org.renjin.eval.EvalException: Instance of class java.util.HashMap has no member named 'getClass'

Which would be manageable, except if I try to avoid using the accessor:

"import(java.util.HashMap)\n"
"ageMap <- HashMap$new()\n"
"print(ageMap$class)";

I still get an EvalException, for "no member named class".

In other cases the automatic Bean parsing worked great. But given this, it seems like Renjin is over-aggressive in stripping away accessors.

Also, I suggest preserving both accessor and direct field members to the External_Ptrs - so code from Java will work regardless of which it was written to use.

@akbertram
Copy link
Member

Thanks for the feedback!
I think this is a fair point - and I don't think there's any reason why we couldn't expose both the getters/setters as well as the property syntax. ageMap$class should also work, so I'll take a look at that.

@hinerm
Copy link
Author

hinerm commented Jan 21, 2016

fantastic! Love the project by the way :) very easy to code against

akbertram added a commit that referenced this issue Jan 21, 2016
…r explicit getters/setters

For example, if you have:

class MyBean {
   public int getAge() {}
}

Then both

x <- MyBean$new()
x$age

and

x$getAge()

will evaluate correctly.
akbertram added a commit to akbertram/scripting-renjin that referenced this issue Feb 6, 2016
In the latest version of Renjin you can use either the getter method or the property name. 
bedatadriven/renjin#140
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

No branches or pull requests

2 participants