I
imran
Hi,
I have a little problem on reflection (how to pass many types of
data), can someone help me please. Actually i am still beginner in
JAVA programming, and i try to design fault injection. Below is the
source code( Kit.java and Tst1.java) i modify from xito web site :
http://xito.sourceforge.net/documentation/javadoc/reflectKit/index.html
------------------------------------------------------
public class Tst1
{
private int x;
public Tst1()
{
x = 10;
}
public int sampleMethod(int ms)
{
System.out.println(ms);
return x;
}
}
-----------------------------------------------------
import org.xito.reflect.*;
import java.lang.reflect.*
import java.lang.*;
public class Kit
{
public static void main (String args[])
{
Reflection kit = Reflection.getToolKit();
try
{
Class cls = kit.findClass ("Tst1");
Object my = kit.newInstance(cls);
Object a = kit.call(my,"sampleMethod",20); //my problem here
}
catch (ClassNotFoundException err1)
{
}
catch (java.lang.reflect.InvocationTargetException err1)
{
}
catch (org.xito.reflect.reflectException err1)
{
}
}
}
I have a little problem on reflection (how to pass many types of
data), can someone help me please. Actually i am still beginner in
JAVA programming, and i try to design fault injection. Below is the
source code( Kit.java and Tst1.java) i modify from xito web site :
http://xito.sourceforge.net/documentation/javadoc/reflectKit/index.html
------------------------------------------------------
public class Tst1
{
private int x;
public Tst1()
{
x = 10;
}
public int sampleMethod(int ms)
{
System.out.println(ms);
return x;
}
}
-----------------------------------------------------
import org.xito.reflect.*;
import java.lang.reflect.*
import java.lang.*;
public class Kit
{
public static void main (String args[])
{
Reflection kit = Reflection.getToolKit();
try
{
Class cls = kit.findClass ("Tst1");
Object my = kit.newInstance(cls);
Object a = kit.call(my,"sampleMethod",20); //my problem here
}
catch (ClassNotFoundException err1)
{
}
catch (java.lang.reflect.InvocationTargetException err1)
{
}
catch (org.xito.reflect.reflectException err1)
{
}
}
}