3
Question
There is some feature that some language makes available to be able to add at runtime a class to the running software, that is, the software to recognize and thus be able to instantiate objects of this class and manipulate them?
Let us imagine the following situation:
Take with example the language Java. We have this abstract class available as a skeleton for users to implement:
public abstract class TypeGeneral {
MyAttribute my_atr; // um objeto qualquer que toda implementação
// de TypeGeneral tem que ter
public General(MyAttribute e) {
my_atr = e;
}
public abstract void run(); // <==
public MyAttribute getAttr() { /*...*/ }
public MyAttribute setAttr(MyAttribute e) { /*...*/ }
// ...
}
I was wondering if there are any features that give the possibility that after the user makes his or her class extending the TypeGeneral
, and thus implementing the method run()
, can, at runtime, add it to the system that is running, and the system, recognizing it, makes manipulations with the objects of it.
I saw something about Reflection
, but could not adapt to my problem. Someone?
Preferred languages
Java
Python
C#
C++
Does anyone suggest a better title? Don’t edit, suggest right here.
– Christian Felipe
This is highly dependent on the language and the execution environment. It would be interesting to restrict your domain more.
– Pablo Almeida
I know there’s a way, but me Java I don’t know the details of how to do.
– Maniero
Java has Classloader, see if it fits you: http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html
– Piovezan
In what language do you know @bigown? It might be in one of the other 3 I quoted... I’ll look here @Piovezan
– Christian Felipe
The question has the tag [tag:java], until not to get wide.
– Maniero
For example in a Web environment @Pablo Almeida, with some of these languages, where the server would receive from each user its implementations and return to each one the functionality added by its implementation.
– Christian Felipe
I put
java
on account of the example I present @bigown kk– Christian Felipe