Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ClassNotFound when building shadow class by reflection #1012

Merged
merged 1 commit into from
Nov 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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