Example usage for com.google.gwt.dev.asm ClassReader accept

List of usage examples for com.google.gwt.dev.asm ClassReader accept

Introduction

In this page you can find the example usage for com.google.gwt.dev.asm ClassReader accept.

Prototype

public void accept(final ClassVisitor classVisitor, final int flags) 

Source Link

Document

Makes the given visitor visit the Java class of this ClassReader .

Usage

From source file:com.google.web.bindery.requestfactory.server.RequestFactoryInterfaceValidator.java

License:Apache License

/**
 * Load the classfile for the given binary name and apply the provided
 * visitor./*from   w w w .j  av  a  2  s . c  o  m*/
 * 
 * @return <code>true</code> if the visitor was successfully visited
 */
private boolean visit(ErrorContext logger, String internalName, ClassVisitor visitor) {
    assert Name.isInternalName(internalName) : "internalName";
    logger.spam("Visiting " + internalName);
    InputStream inputStream = null;
    try {
        inputStream = loader.getResourceAsStream(internalName + ".class");
        if (inputStream == null) {
            logger.poison("Could not find class file for " + internalName);
            return false;
        }
        ClassReader reader = new ClassReader(inputStream);
        reader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
        return true;
    } catch (IOException e) {
        logger.poison("Unable to open " + internalName, e);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException ignored) {
            }
        }
    }
    return false;
}

From source file:com.google.web.bindery.requestfactory.server.RequestFactoryJarExtractor.java

License:Apache License

/**
 * Load the classfile for the given binary name and apply the provided
 * visitor.//from w w  w  . j  av a  2  s. com
 * 
 * @return <code>true</code> if the visitor was successfully visited
 */
private static boolean visit(ErrorContext logger, Loader loader, String internalName, ClassVisitor visitor) {
    assert Name.isInternalName(internalName) : "internalName";
    logger.spam("Visiting " + internalName);
    InputStream inputStream = null;
    try {
        inputStream = loader.getResourceAsStream(internalName + ".class");
        if (inputStream == null) {
            System.err.println("Could not find class file for " + internalName);
            logger.poison("Could not find class file for " + internalName);
            return false;
        }
        ClassReader reader = new ClassReader(inputStream);
        reader.accept(visitor, 0);
        return true;
    } catch (IOException e) {
        logger.poison("Unable to open " + internalName, e);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException ignored) {
            }
        }
    }
    return false;
}