Search in sources :

Example 1 with ClassPathOpener

use of com.android.dx.cf.direct.ClassPathOpener in project J2ME-Loader by nikita36078.

the class Main method processOne.

/**
 * Processes one pathname element.
 *
 * @param pathname {@code non-null;} the pathname to process. May
 * be the path of a class file, a jar file, or a directory
 * containing class files.
 * @param filter {@code non-null;} A filter for excluding files.
 */
private void processOne(String pathname, FileNameFilter filter) {
    ClassPathOpener opener;
    opener = new ClassPathOpener(pathname, true, filter, new FileBytesConsumer());
    if (opener.process()) {
        updateStatus(true);
    }
}
Also used : ClassPathOpener(com.android.dx.cf.direct.ClassPathOpener)

Example 2 with ClassPathOpener

use of com.android.dx.cf.direct.ClassPathOpener in project buck by facebook.

the class AnnotationLister method process.

/** Processes based on configuration specified in constructor. */
void process() {
    for (String path : args.files) {
        ClassPathOpener opener;
        opener = new ClassPathOpener(path, true, new ClassPathOpener.Consumer() {

            public boolean processFileBytes(String name, long lastModified, byte[] bytes) {
                if (!name.endsWith(".class")) {
                    return true;
                }
                ByteArray ba = new ByteArray(bytes);
                DirectClassFile cf = new DirectClassFile(ba, name, true);
                cf.setAttributeFactory(StdAttributeFactory.THE_ONE);
                AttributeList attributes = cf.getAttributes();
                Attribute att;
                String cfClassName = cf.getThisClass().getClassType().getClassName();
                if (cfClassName.endsWith(PACKAGE_INFO)) {
                    att = attributes.findFirst(AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME);
                    for (; att != null; att = attributes.findNext(att)) {
                        BaseAnnotations ann = (BaseAnnotations) att;
                        visitPackageAnnotation(cf, ann);
                    }
                    att = attributes.findFirst(AttRuntimeVisibleAnnotations.ATTRIBUTE_NAME);
                    for (; att != null; att = attributes.findNext(att)) {
                        BaseAnnotations ann = (BaseAnnotations) att;
                        visitPackageAnnotation(cf, ann);
                    }
                } else if (isMatchingInnerClass(cfClassName) || isMatchingPackage(cfClassName)) {
                    printMatch(cf);
                } else {
                    att = attributes.findFirst(AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME);
                    for (; att != null; att = attributes.findNext(att)) {
                        BaseAnnotations ann = (BaseAnnotations) att;
                        visitClassAnnotation(cf, ann);
                    }
                    att = attributes.findFirst(AttRuntimeVisibleAnnotations.ATTRIBUTE_NAME);
                    for (; att != null; att = attributes.findNext(att)) {
                        BaseAnnotations ann = (BaseAnnotations) att;
                        visitClassAnnotation(cf, ann);
                    }
                }
                return true;
            }

            public void onException(Exception ex) {
                throw new RuntimeException(ex);
            }

            public void onProcessArchiveStart(File file) {
            }
        });
        opener.process();
    }
}
Also used : ClassPathOpener(com.android.dx.cf.direct.ClassPathOpener) DirectClassFile(com.android.dx.cf.direct.DirectClassFile) Attribute(com.android.dx.cf.iface.Attribute) AttributeList(com.android.dx.cf.iface.AttributeList) BaseAnnotations(com.android.dx.cf.attrib.BaseAnnotations) ByteArray(com.android.dx.util.ByteArray) File(java.io.File) DirectClassFile(com.android.dx.cf.direct.DirectClassFile)

Example 3 with ClassPathOpener

use of com.android.dx.cf.direct.ClassPathOpener in project buck by facebook.

the class Main method processOne.

/**
     * Processes one pathname element.
     *
     * @param pathname {@code non-null;} the pathname to process. May
     * be the path of a class file, a jar file, or a directory
     * containing class files.
     * @param filter {@code non-null;} A filter for excluding files.
     */
private void processOne(String pathname, FileNameFilter filter) {
    ClassPathOpener opener;
    opener = new ClassPathOpener(pathname, true, filter, new FileBytesConsumer());
    if (opener.process()) {
        updateStatus(true);
    }
}
Also used : ClassPathOpener(com.android.dx.cf.direct.ClassPathOpener)

Aggregations

ClassPathOpener (com.android.dx.cf.direct.ClassPathOpener)3 BaseAnnotations (com.android.dx.cf.attrib.BaseAnnotations)1 DirectClassFile (com.android.dx.cf.direct.DirectClassFile)1 Attribute (com.android.dx.cf.iface.Attribute)1 AttributeList (com.android.dx.cf.iface.AttributeList)1 ByteArray (com.android.dx.util.ByteArray)1 File (java.io.File)1