Search in sources :

Example 41 with Clazz

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

the class ClassParserTest method testGeneratedClass.

public void testGeneratedClass() throws Exception {
    InputStream in = getClass().getResourceAsStream("XDbCmpXView.clazz");
    assertNotNull(in);
    Clazz clazz = new Clazz(a, "test", null);
    clazz.parseClassFile(in);
    clazz.getReferred();
}
Also used : InputStream(java.io.InputStream) Clazz(aQute.bnd.osgi.Clazz)

Example 42 with Clazz

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

the class ClassParserTest method testLargeClass2.

public static void testLargeClass2() throws IOException {
    try {
        URL url = new URL("jar:file:jar/ecj_3.2.2.jar!/org/eclipse/jdt/internal/compiler/parser/Parser.class");
        InputStream in = url.openStream();
        assertNotNull(in);
        Clazz clazz = new Clazz(a, "test", null);
        clazz.parseClassFile(in);
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : InputStream(java.io.InputStream) Clazz(aQute.bnd.osgi.Clazz) URL(java.net.URL) IOException(java.io.IOException)

Example 43 with Clazz

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

the class ClassParserTest method testLargeClass.

/**
	 * This class threw an exception because we were using skip instead of
	 * skipBytes. skip is not guaranteed to real skip the amount of bytes, not
	 * even if there are still bytes left. It seems to be able to stop skipping
	 * if it is at the end of a buffer or so :-( Idiots. The
	 * DataInputStream.skipBytes works correctly.
	 * 
	 * @throws IOException
	 */
public void testLargeClass() throws IOException {
    InputStream in = getClass().getResourceAsStream("Parser.jclass");
    assertNotNull(in);
    try {
        Clazz clazz = new Clazz(a, "test", null);
        clazz.parseClassFile(in);
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : InputStream(java.io.InputStream) Clazz(aQute.bnd.osgi.Clazz) IOException(java.io.IOException)

Example 44 with Clazz

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

the class ClassParserTest method testCodehauseGROOVY_6169.

/**
	 * https://jira.codehaus.org/browse/GROOVY-6169 There are several components
	 * involved here, but the symptoms point to the Groovy compiler. Gradle uses
	 * BND to populate the OSGi 'Import-Package' manifest header. The import
	 * from Groovy source is lost and does not appear in the OSGi manifest. This
	 * causes problems when deploying the bundle to OSGi. There's a repro
	 * package attached. It includes two Gradle projects, one using Java, one
	 * using Groovy. They use the same source file contents, but with different
	 * file types. They produce different manifest files, one that imports slf4j
	 * and one that doesn't. You can tweak the build.gradle to use different
	 * Groovy releases. I first discovered this problem using v1.8.7, but saw
	 * the same results with v1.8.9. The problem was apparently fixed in v2.1,
	 * using a groovy-all-2.1.0 a correct manifest file is created.
	 */
public static void testCodehauseGROOVY_6169() throws Exception {
    Clazz c = new Clazz(a, "foo", new FileResource(IO.getFile("jar/BugReproLoggerGroovy189.jclass")));
    c.parseClassFile();
    assertTrue(c.getReferred().contains(a.getPackageRef("org.slf4j")));
}
Also used : FileResource(aQute.bnd.osgi.FileResource) Clazz(aQute.bnd.osgi.Clazz)

Example 45 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)

Aggregations

Clazz (aQute.bnd.osgi.Clazz)56 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)7 HashMap (java.util.HashMap)7 FileInputStream (java.io.FileInputStream)6 Resource (aQute.bnd.osgi.Resource)5 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 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 TreeSet (java.util.TreeSet)4 Parameters (aQute.bnd.header.Parameters)3