-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
should not be able to instantiate an interface (using new) #3275
Comments
the idea is for interfaces to behave more closely to modules :
which they currently do not, although there might be some reasons for that (due the proxy machinery) :
... still its ugly and for generating a useful dynamic impl the
|
What bugs me is that Ruby doesn't clearly know what Runnable is once instantiated. If you try to instantiate another class Ruby knows where it is, but that hex code in the output, is that a normal thing to happen? |
its a generated anonymous proxy class - just like in Java (thus without a name). |
Is "new" loaded as part of the InterfaceInitializer method loading? Maybe we're loading from a general implementation of Classes in said initializer |
Ok, I think I made progress, fixing (or breaking my version even more), commenting unused method: "new_impl" (line: 442) in JavaInterfaceTemplate seems to work, yielding as a result:
Though it shouldn't say "module"... so that is possibly a problem. This did not break object generation, as I tested with:
I'm not sure this did the job, but I think it's a step onwards |
We could possibly make: module Interface < Module
end so it prints out nicer? Potential naming conflict since interface is a fairly common computery name: module Java
module Interface < Module
end
end |
@Lan5432 it is simply re-using what Ruby Class/Module hierarchies do have. its semi correct since JRuby is trying to present Java interfaces as modules (they can get included). its nice to tune but I believe you would need to do that on multiple places where Ruby is expected to print info about a module. Tom, has layout a simple plan if you're interested ... I personally would not pursuit this too much :) unfortunately travis-ci is not 💚 at the moment but you could try to tun |
@kares Yeah, I guess modifying code to make it display in a nicer way is not one of the main worries of the project. I guess I can do that on extra time, just for the sake of it. So you say adding a new spec to show this new characteristic. I can get to it to get familiar with creating specs. What about the solution itself, can we incorporate this to the project itself? There might be other modifications of the code for this particular issue, so we should check if those are necessary for the issue to be solved. |
Removing 'new' class method from interfaces #3275
... for what-ever reason
Interface.new
generates an anonymous class, currently :The text was updated successfully, but these errors were encountered: