Exception when trying to instantiate Reflections
See original GitHub issueUnder JDK8:
Code:
Reflections reflections = new Reflections("my.package");
Exception
java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;
at org.reflections.Reflections.expandSuperTypes(Reflections.java:380) ~[reflections-0.9.11.jar:na]
at org.reflections.Reflections.<init>(Reflections.java:126) ~[reflections-0.9.11.jar:na]
at org.reflections.Reflections.<init>(Reflections.java:168) ~[reflections-0.9.11.jar:na]
at org.reflections.Reflections.<init>(Reflections.java:141) ~[reflections-0.9.11.jar:na]
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Java Reflection - Instantiation Exception Interface
@Tunaki I think the OP wants to translate the above code into a reflective call - Class.forName("com.package.RequestDocument.Factory).getMethod( ...
Read more >How to Resolve the Instantiation Exception in Java - Rollbar
The InstantiationException in Java is thrown when the JVM cannot instantiate a Java type at runtime using the Class.newInstance() method.
Read more >What Causes java.lang.reflect.InvocationTargetException?
It mainly occurs when we work with the reflection layer and try to invoke a method or constructor that throws an underlying exception...
Read more >Creating New Class Instances
This reflection Java tutorial describes using reflection for accessing and manipulating classes, fields, methods, and constructors.
Read more >instantiate a class without throwing a exception - Java Reflection
instantiate a class without throwing a exception - Java Reflection ... Class<T> clazz) throws WrappedRuntimeException { try { T result = clazz.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
20.0 is pulled in by Reflections most likely, but 18.0 is probably winning. You could try setting up managed dependencies to force only 20. I currently force
24.1-jre
and it works well.@haixuan8192 I didn’t. I couldn’t use the library so I used Java’s plain Reflection code form the JDK library.