Reputation: 95
I am working on a kind of Framework. Here I will have to call a particular method on a particular class with particular parameters. I will receive parameter values in string form.
like inputs will be,
class name : com.classes.MyClass
method name : setPrimtiveType
Value : "true"
type of value : boolean
Here the problem is that the method I am trying to call via reflection accepts primitive type. this type is also an input to set the particular parameter.
I am not getting any in reflection so this can be achieved.
Upvotes: 0
Views: 1496
Reputation: 135992
if this is your class
class MyClass {
public static void setPrimitiveType(boolean v) {
}
}
then this is how to set boolean value
MyClass.class.getMethod("setPrimitiveType", boolean.class).invoke(null, true);
Upvotes: 1