Skip to content

Commit

Permalink
fix(shadow): no ClassNotFoundException when building shadow classes b…
Browse files Browse the repository at this point in the history
…y reflection (#1012)
  • Loading branch information
pvojtechovsky authored and monperrus committed Nov 28, 2016
1 parent a970b09 commit 010ccfc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/spoon/reflect/factory/TypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import spoon.reflect.visitor.CtScanner;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.DefaultCoreFactory;
import spoon.support.SpoonClassNotFoundException;
import spoon.support.StandardEnvironment;
import spoon.support.visitor.java.JavaReflectionTreeBuilder;

Expand Down Expand Up @@ -473,7 +474,12 @@ public <T> CtType<T> get(Class<?> cl) {
if (aType == null) {
final CtType<T> shadowClass = (CtType<T>) this.shadowCache.get(cl);
if (shadowClass == null) {
final CtType<T> newShadowClass = new JavaReflectionTreeBuilder(createFactory()).scan((Class<T>) cl);
CtType<T> newShadowClass;
try {
newShadowClass = new JavaReflectionTreeBuilder(createFactory()).scan((Class<T>) cl);
} catch (Throwable e) {
throw new SpoonClassNotFoundException("cannot create shadow class: " + cl.getName(), e);
}
newShadowClass.setFactory(factory);
newShadowClass.accept(new CtScanner() {
@Override
Expand Down

0 comments on commit 010ccfc

Please sign in to comment.