Skip to content

Instantly share code, notes, and snippets.

@Wavefarer42
Last active April 7, 2016 11:21
Show Gist options
  • Save Wavefarer42/7cf48cc68cfe95c360efdf7604bf0411 to your computer and use it in GitHub Desktop.
Save Wavefarer42/7cf48cc68cfe95c360efdf7604bf0411 to your computer and use it in GitHub Desktop.
Minimal Example of #572
... imports ...
public class Issue572 {
@Test(expectedExceptions = SpoonClassNotFoundException.class)
public void GivenSubclassWithParentNotInClasspath_WhenSuperclass_ThenException() throws URISyntaxException {
final URL url = Issue572.class.getClassLoader().getResource("issue572");
assert url != null;
SpoonAPI launcher = new Launcher();
launcher.getEnvironment().setNoClasspath(true);
launcher.addInputResource(Paths.get(url.toURI()).toString());
launcher.buildModel();
TypeFactory factory = launcher.getFactory().Type();
final CtType<?> subclass = factory.get("issue572.Subclass"); // returns Subclass
final CtTypeReference<?> superclass = subclass.getSuperclass(); // returns Superclass as TypeReference
final CtTypeReference<?> superSuperclass = superclass.getSuperclass(); // throws SpoonClassNotFoundException
}
}
package issue572;
import other.pack.NoClasspathSuperclass;
class Subclass extends NoClasspathSuperclass{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment