question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception when trying to instantiate Reflections

See original GitHub issue

Under 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:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
isakicommented, Apr 25, 2018

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.

0reactions
Rafaelskcommented, May 28, 2018

@haixuan8192 I didn’t. I couldn’t use the library so I used Java’s plain Reflection code form the JDK library.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found