Search in sources :

Example 46 with Clazz

use of aQute.bnd.osgi.Clazz in project bnd by bndtools.

the class ClassParserTest method testParameterAnnotation.

public void testParameterAnnotation() throws Exception {
    InputStream in = getClass().getResourceAsStream("Test2.jclass");
    assertNotNull(in);
    Clazz clazz = new Clazz(a, "test", null);
    clazz.parseClassFile(in);
    Set<PackageRef> set = clazz.getReferred();
    assertTrue(set.contains(a.getPackageRef("test")));
    assertTrue(set.contains(a.getPackageRef("test/annotations")));
}
Also used : InputStream(java.io.InputStream) Clazz(aQute.bnd.osgi.Clazz) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef)

Example 47 with Clazz

use of aQute.bnd.osgi.Clazz in project bnd by bndtools.

the class ClassParserTest method testWildcards.

// public void testImplemented() throws Exception {
// Builder a = new Builder();
// a.addClasspath(new File("bin"));
// a.setProperty("Private-Package", "test");
// a.build();
// Clazz c = a.getClassspace().get("testresources/Implemented.class");
// Set<PackageRef> s = Create.set();
//
// Clazz.getImplementedPackages(s, a, c);
// assertTrue(s.contains( a.getPackageRef("aQute/bnd/service")));
// }
public void testWildcards() throws Exception {
    Clazz c = new Clazz(a, "genericstest", null);
    c.parseClassFile(getClass().getResourceAsStream("WithGenerics.class"));
    System.err.println(c.getReferred());
    assertEquals("size ", 5, c.getReferred().size());
    assertTrue(c.getReferred().contains(a.getPackageRef("aQute/bnd/osgi")));
    assertTrue(c.getReferred().contains(a.getPackageRef("java/util")));
    assertTrue(c.getReferred().contains(a.getPackageRef("java/net")));
    assertTrue(c.getReferred().contains(a.getPackageRef("java/lang")));
}
Also used : Clazz(aQute.bnd.osgi.Clazz)

Example 48 with Clazz

use of aQute.bnd.osgi.Clazz in project bnd by bndtools.

the class ClazzTest method testUnusedClassConstant.

/**
	 * There is an unused class constant in the This actually looks wrong since
	 */
public void testUnusedClassConstant() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        c.parseClassFile(new FileInputStream("testresources/TestWeavingHook.jclass"), new ClassDataCollector() {
        });
        // TODO test someething here
        System.out.println(c.getReferred());
    }
}
Also used : Clazz(aQute.bnd.osgi.Clazz) Analyzer(aQute.bnd.osgi.Analyzer) ClassDataCollector(aQute.bnd.osgi.ClassDataCollector) FileInputStream(java.io.FileInputStream)

Example 49 with Clazz

use of aQute.bnd.osgi.Clazz in project bnd by bndtools.

the class ClazzTest method testModuleInfo.

public void testModuleInfo() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        c.parseClassFile(new FileInputStream("jar/module-info.jclass"), new ClassDataCollector() {
        });
        assertTrue(c.isModule());
        Set<PackageRef> referred = c.getReferred();
        Descriptors d = new Descriptors();
        assertFalse(referred.contains(d.getPackageRef("")));
    }
}
Also used : Clazz(aQute.bnd.osgi.Clazz) Descriptors(aQute.bnd.osgi.Descriptors) Analyzer(aQute.bnd.osgi.Analyzer) ClassDataCollector(aQute.bnd.osgi.ClassDataCollector) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef) FileInputStream(java.io.FileInputStream)

Example 50 with Clazz

use of aQute.bnd.osgi.Clazz in project bnd by bndtools.

the class ClazzTest method testAnalyzerCrawlInvokeInterfaceAIOOBException.

public void testAnalyzerCrawlInvokeInterfaceAIOOBException() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        c.parseClassFile(new FileInputStream("jar/AnalyzerCrawlInvokerInterfaceAIOOBTest.jclass"), new ClassDataCollector() {
        });
        Set<PackageRef> referred = c.getReferred();
        System.out.println(referred);
    }
}
Also used : Clazz(aQute.bnd.osgi.Clazz) Analyzer(aQute.bnd.osgi.Analyzer) ClassDataCollector(aQute.bnd.osgi.ClassDataCollector) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef) FileInputStream(java.io.FileInputStream)

Aggregations

Clazz (aQute.bnd.osgi.Clazz)52 Analyzer (aQute.bnd.osgi.Analyzer)14 ClassDataCollector (aQute.bnd.osgi.ClassDataCollector)14 TypeRef (aQute.bnd.osgi.Descriptors.TypeRef)12 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)8 InputStream (java.io.InputStream)8 FileResource (aQute.bnd.osgi.FileResource)7 File (java.io.File)6 FileInputStream (java.io.FileInputStream)6 HashMap (java.util.HashMap)6 MethodDef (aQute.bnd.osgi.Clazz.MethodDef)4 Descriptors (aQute.bnd.osgi.Descriptors)4 Instruction (aQute.bnd.osgi.Instruction)4 Jar (aQute.bnd.osgi.Jar)4 Map (java.util.Map)4 TreeSet (java.util.TreeSet)4 Attrs (aQute.bnd.header.Attrs)3 Parameters (aQute.bnd.header.Parameters)3 Annotation (aQute.bnd.osgi.Annotation)3 Builder (aQute.bnd.osgi.Builder)3