Search in sources :

Example 1 with Descriptors

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

the class ClazzTest method testDynamicInstr.

/**
	 * Complaint from Groovy that the dynamic instruction fails.
	 * 
	 * <pre>
	 *  [bndwrap]
	 * java.lang.ArrayIndexOutOfBoundsException: 15 [bndwrap] at
	 * aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:387) [bndwrap] at
	 * aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:308) [bndwrap] at
	 * aQute.bnd.osgi.Clazz.parseClassFileWithCollector(Clazz.java:297)
	 * [bndwrap] at aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:286)
	 * [bndwrap] at aQute.bnd.osgi.Analyzer.analyzeJar(Analyzer.java:1489)
	 * [bndwrap] at
	 * aQute.bnd.osgi.Analyzer.analyzeBundleClasspath(Analyzer.java:1387)
	 * [bndwrap] Invalid class file:
	 * groovy/inspect/swingui/AstNodeToScriptVisitor.class [bndwrap] Exception:
	 * 15
	 * </pre>
	 */
public void testDynamicInstr() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        c.parseClassFile(new FileInputStream("jar/AstNodeToScriptVisitor.jclass"), new ClassDataCollector() {
        });
        Set<PackageRef> referred = c.getReferred();
        Descriptors d = new Descriptors();
        assertFalse(referred.contains(d.getPackageRef("")));
        System.out.println(referred);
    }
}
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 2 with Descriptors

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

the class ClazzTest method testClassForNameFalsePickup.

/**
	 * Check if the class is not picking up false references when the
	 * CLass.forName name is constructed. The DeploymentAdminPermission.1.jclass
	 * turned out to use Class.forName with a name that was prefixed with a
	 * package from a property. bnd discovered the suffix
	 * (.DeploymentAdminPermission) but this ended up in the default package. So
	 * now the clazz parser tests that the name guessed for Class.forName must
	 * actually resemble a class name.
	 */
public void testClassForNameFalsePickup() throws Exception {
    try (Analyzer a = new Analyzer()) {
        Clazz c = new Clazz(a, "", null);
        c.parseClassFile(new FileInputStream("jar/DeploymentAdminPermission.1.jclass"), new ClassDataCollector() {
        });
        Set<PackageRef> referred = c.getReferred();
        Descriptors d = new Descriptors();
        assertFalse(referred.contains(d.getPackageRef("")));
        System.out.println(referred);
    }
}
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 3 with Descriptors

use of aQute.bnd.osgi.Descriptors 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 4 with Descriptors

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

the class DescriptorsTest method testReferences.

public static void testReferences() {
    Descriptors d = new Descriptors();
    TypeRef r = d.getTypeRef("[B");
    assertNotNull(r);
    assertEquals("byte[]", r.getFQN());
    assertNotNull(r.getPackageRef());
    assertEquals(".", r.getPackageRef().getFQN());
    PackageRef a = d.getPackageRef("a.b.c");
    PackageRef b = d.getPackageRef("a/b/c");
    assertTrue(a == b);
}
Also used : TypeRef(aQute.bnd.osgi.Descriptors.TypeRef) Descriptors(aQute.bnd.osgi.Descriptors) PackageRef(aQute.bnd.osgi.Descriptors.PackageRef)

Aggregations

Descriptors (aQute.bnd.osgi.Descriptors)4 PackageRef (aQute.bnd.osgi.Descriptors.PackageRef)4 Analyzer (aQute.bnd.osgi.Analyzer)3 ClassDataCollector (aQute.bnd.osgi.ClassDataCollector)3 Clazz (aQute.bnd.osgi.Clazz)3 FileInputStream (java.io.FileInputStream)3 TypeRef (aQute.bnd.osgi.Descriptors.TypeRef)1