Hello all
I try to use objenesis to create some objects.
I have some problems with ArrayList and String
For arraylist
Objenesis objenesis = new ObjenesisStd(); // or ObjenesisSerializer
ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(ArrayList.class);
Object o1 = thingyInstantiator.newInstance();
That work but when i want to add elements to the created list ((ArrayList) o1).add("aaa")) i have npe error
Exception in thread "main" java.lang.NullPointerException
at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:186)
at java.util.ArrayList.add(ArrayList.java:411)
at instanciator.TestObjenesisHelper.main(TestObjenesisHelper.java:41)
I have the same type of error when i want to put data in a string created by Objenesis
My system version is the following
java version "1.7.0_15"
OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.10.1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
I don't know if the problem i with my use of Objenesis or from my system?
Thanks in advance
Thierry