Generally problem is: I have a class with protected default constructor, like:
I want to be able to instantiate this class, however A.class.getConstructor() throws an exception no such method. Will getDeclaredConstructor help? I notice that ReadObject implementation uses getDeclaredConstructor with following changing accessability.
getConstructor will return a Constructor reference only for a public constructor. But getDeclaredConstructor should return a Constructor reference regardless of the constructor's access level. However, to actually invoke that constructor (e.g., calling newInstance), you would need the proper access.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org