Tie become_java! and concrete extension (fixes #4165)#6141
Tie become_java! and concrete extension (fixes #4165)#6141headius merged 21 commits intojruby:masterfrom
Conversation
|
Putting this on my todo list to review... perhaps early next week? Maybe you have some thoughts @kares? |
|
While investigating annotations, it appears that jrubyc and become_java! have different syntaxes: java_annotation 'Deprecated'
java_signature 'void my_method()'vs java_signature '@Deprecated void my_method()'jrubyc uses at least the former and become_java! only saves the latter. As such, I've implemented parameters for the latter, but that brings up what to do with fields. Should |
|
As per conversation on matrix with @enebo, This PR now has the following API changes: |
| end | ||
|
|
||
| def java_annotation(anno) | ||
| STDERR.puts "java_annotation is deprecated. Use java_signature '@#{anno} ...' instead. Called from: #{caller.first}" |
There was a problem hiding this comment.
minor: we probably just want to use warn or some kind of warnings on the native end.
There was a problem hiding this comment.
Yeah use Kernel#warn or Warnings#warn so it can be silenced if necessary.
|
Great work so far Patrick! Think it makes sense to have as its going, I did like the previous Not sure if current scope imports are respected (or whether they worked using |
headius
left a comment
There was a problem hiding this comment.
Just a few small changes. I will address your original questions in a separate comment.
| * Copyright (C) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de> | ||
| * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> | ||
| * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> | ||
| * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> |
There was a problem hiding this comment.
Remove attributions unrelated to this file. If you really want to add yourself, go ahead, but since the audit trail is in git I don't believe we need to have these.
| /* | ||
| * To change this template, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ |
| /* | ||
| * To change this template, choose Tools | Templates | ||
| * and open the template in the editor. | ||
| */ |
|
|
||
| /** | ||
| * | ||
| * @author enebo |
|
|
||
| } | ||
| else | ||
| { |
There was a problem hiding this comment.
Style issues here and other places... close brace and open brace should be on same line as else, if's open brace should be on same line, etc.
| end | ||
|
|
||
| def java_annotation(anno) | ||
| STDERR.puts "java_annotation is deprecated. Use java_signature '@#{anno} ...' instead. Called from: #{caller.first}" |
There was a problem hiding this comment.
Yeah use Kernel#warn or Warnings#warn so it can be silenced if necessary.
|
Addressing the original 4 question bullets:
I'm not sure exactly what you mean. What you have seems fine to me, maybe?
Usually if I feel like I'm passing around the same arguments too many places, it might be time for a data object that contains all of them together. It's not a huge deal either way for this PR, but perhaps we can refactor this to be more OO and not have to pass so many params all over.
I think these are fine as-is.
If this is no longer being used then it's fine to remove. |
| } | ||
| if (reifiedClass == null) { | ||
| throw context.runtime.newTypeError("requested class " + klass.getName() + " was not reifiable"); | ||
| } |
There was a problem hiding this comment.
@headius This bit of code does not distinguish between Failed Reified Ruby classes and Concretized Classes. getReified is null if either it's a failure to reify or a java proxy class. Should the logic be split between those two cases, and if so, how?
There was a problem hiding this comment.
Aha, so you think maybe we need another way to know a given class is a java proxy class. Perhaps we add another boolean flag to RubyClass like isJavaSubclass or isJavaProxy?
There was a problem hiding this comment.
so you think maybe we need...
No, I am asking if we do. I have no strong opinion on these internals, but I do think the error message could be a misleading if we care to tell users about the difference between concrete vs reified, so I'm wondering if you think we should disambiguate.
Secondarily, I think it's safe for this code path to be retried for failed reified and failed concrete multiple times, but that might have implications I'm not aware of
The reason I hesitated was because all of the items came from the ruby class, and so the obvious thing was to just pass the ruby class down, but I wasn't sure if that would break existing encapsulation design too much. Creating a small mirror of RubyClass things also seemed kind of silly if we could just use RubyClass |
|
I am fine merging this once review comments are addressed and CI is green. Thank you for your help and patience @byteit101! |
|
This might help the failures (annotation API is no longer part of JDK): https://gist.github.com/headius/cde16ee9fe14767549ed0036ec0a04dc |
Still in progress, but allow concrete class extension to define non-extended fields and signatures (required for jrubyfx to use the built in FXMLLoader that uses reflection on passed in classes)
Notable questions: