I used reflection to invoke a private constructor of a class in order to solve insufficient branch coverage issue shown by sonar scan report. This is the snippet of my code I was working:
// reflection to access a private constructor of a class
Constructor<CMISBridgeMaps> c = CMISBridgeMaps.class.getDeclaredConstructor(new Class[0]);
c.setAccessible(true);
cmisBridgeMaps = c.newInstance(new Object[0]);
The above code solved my sonar scan critical issue. But unfortunately fortify is now showing the Access specifier manipulation issue on the following line:
c.setAccessible(true);
How can I solve both fortify and sonarcube issues? Any help would be greatly appreciated.