Search in sources :

Example 1 with DatasetClassRewriter

use of co.cask.cdap.common.dataset.DatasetClassRewriter in project cdap by caskdata.

the class DatasetClassRewriterTest method rewrite.

private ClassDefinition rewrite(Class<? extends Dataset> dataset) throws Exception {
    DatasetClassRewriter rewriter = new DatasetClassRewriter();
    URL url = dataset.getClassLoader().getResource(dataset.getName().replace('.', '/') + ".class");
    Assert.assertNotNull(url);
    try (InputStream is = url.openStream()) {
        return new ClassDefinition(rewriter.rewriteClass(dataset.getName(), is), Type.getInternalName(dataset));
    }
}
Also used : InputStream(java.io.InputStream) ClassDefinition(co.cask.cdap.internal.asm.ClassDefinition) DatasetClassRewriter(co.cask.cdap.common.dataset.DatasetClassRewriter) URL(java.net.URL)

Aggregations

DatasetClassRewriter (co.cask.cdap.common.dataset.DatasetClassRewriter)1 ClassDefinition (co.cask.cdap.internal.asm.ClassDefinition)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1