Android Open Source - grooidshell-example Grooid Class Loader






From Project

Back to project page grooidshell-example.

License

The source code is released under:

Apache License

If you think the Android project grooidshell-example listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package groovy.lang;
//  w ww.  j a  v  a2s  .  co m
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.control.CompilationUnit;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.SourceUnit;

import java.security.AccessController;
import java.security.PrivilegedAction;

import groovyjarjarasm.asm.ClassWriter;

/**
 * An extension of {@link groovy.lang.GroovyClassLoader} which handles the fact
 * that classes generated by Groovy will not be directly loadable by the dex
 * class loader.
 *
 * @author Cdric Champeau
 */
public class GrooidClassLoader extends GroovyClassLoader {

    public GrooidClassLoader(ClassLoader loader, CompilerConfiguration config) {
        super(loader, config);
    }

    @Override
    protected ClassCollector createCollector(CompilationUnit unit, SourceUnit su) {
        InnerLoader loader = AccessController.doPrivileged(new PrivilegedAction<InnerLoader>() {
            public InnerLoader run() {
                return new InnerLoader(GrooidClassLoader.this);
            }
        });
        return new ClassCollector(loader, unit, su) {
            @Override
            protected Class onClassNode(ClassWriter classWriter, ClassNode classNode) {
                try {
                    return super.onClassNode(classWriter, classNode);
                } catch (Exception e) {
                    return null;
                }
            }
        };
    }
}




Java Source Code List

groovy.lang.GrooidClassLoader.java
me.champeau.groovydroid.GrooidShell.java
me.champeau.groovydroid.util.SystemUiHiderBase.java
me.champeau.groovydroid.util.SystemUiHiderHoneycomb.java
me.champeau.groovydroid.util.SystemUiHider.java