Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pvojtechovsky committed Mar 16, 2018
1 parent 641cc92 commit caa2e7e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/test/java/spoon/test/metamodel/SpoonMetaModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,18 @@ public static String getConceptName(CtType<?> type) {
*/
public static CtClass<?> getImplementationOfInterface(CtInterface<?> iface) {
String impl = replaceApiToImplPackage(iface.getQualifiedName()) + CLASS_SUFFIX;
Class implClass;
return (CtClass<?>) getType(impl, iface);
}

private static CtType<?> getType(String qualifiedName, CtElement anElement) {
Class aClass;
try {
implClass = iface.getClass().getClassLoader().loadClass(impl);
aClass = anElement.getClass().getClassLoader().loadClass(qualifiedName);
} catch (ClassNotFoundException e) {
//OK, that interface has no implementation class
return null;
}
return (CtClass<?>) iface.getFactory().Type().get(implClass);
return anElement.getFactory().Type().get(aClass);
}

private static final String modelApiPackage = "spoon.reflect";
Expand All @@ -174,7 +178,7 @@ public static CtInterface<?> getInterfaceOfImplementation(CtClass<?> impl) {
}
iface = iface.substring(0, iface.length() - CLASS_SUFFIX.length());
iface = iface.replace("spoon.support.reflect", "spoon.reflect");
return (CtInterface<?>) impl.getFactory().Type().get(iface);
return (CtInterface<?>) getType(iface, impl);
}

private static Factory createFactory(File spoonJavaSourcesDirectory) {
Expand Down

0 comments on commit caa2e7e

Please # to comment.