abhiCR7 / reflections

Automatically exported from code.google.com/p/reflections
Do What The F*ck You Want To Public License
0 stars 0 forks source link

java.lang.NoSuchMethodException for non-public constructor #187

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create a class with a non-public constructor
2. call Reflections.getConstructorsAnnotatedWith on that class

What is the expected output? What do you see instead?

java.lang.NoSuchMethodException: ClassWithNonpublicConstructor.<init>()
    at java.lang.Class.getConstructor0(Class.java:2892)
    at java.lang.Class.getConstructor(Class.java:1723)
    at org.reflections.util.Utils.getMemberFromDescriptor(Utils.java:83)

What version of the product are you using? On what operating system?

0.9.9-RC1 (since 0.9.9 has an unrelated problem)

The patch is simple:

Utils.java:
- return aClass.getConstructor(parameterTypes);
+ return aClass.getDeclaredConstructor(parameterTypes);

Original issue reported on code.google.com by ril...@novomind.com on 26 Feb 2015 at 2:40