someList = new ArrayList<Integer>();
someList.add(new Integer(123));
someList.add(new Integer(456));
someList.add(new Integer(789));
try {
List list = (List)ErasureDemo.class.getDeclaredField("someList").get(null);
list.add(new String("Hello"));
for (Object element : list) {
((Integer)element).intValue();
}
} catch (final Exception ex) {
System.out.println();
ex.printStackTrace();
}
try {
List list2 = new ArrayList();
list2.add(new Integer(3));
list2.add(new String("Hello"));
Class[] paramTypes = new Class[] {List.class};
Object[] methargs = new Object[] {list2};
Method meth = ErasureDemo.class.getDeclaredMethod("someMethod", paramTypes);
meth.invoke(null, methargs);
} catch (final Exception ex) {
System.out.println();
ex.printStackTrace();
}