Package org.gocha.jvm

Examples of org.gocha.jvm.MemoryClassLoader


        if (clsName== null) throw new IllegalStateException("getClassName()==null");
       
        try{
            byte[] data = FileUtil.readAllData(new FileInputStream(bytecodeClassFile), true);
            MemoryByteCode byteCode = new MemoryByteCode(clsName, data);
            MemoryClassLoader memClassLoader = new MemoryClassLoader();
            memClassLoader.getClassDataMap().put(clsName, byteCode);
            Class cls = memClassLoader.loadClass(clsName);
           
            Constructor constr = cls.getConstructor(Map.class);
            Object inst = constr.newInstance(mmap);
           
            TemplateCompiler.CompileResult res = new CompileResult(
View Full Code Here


        }
    }

    public CompileResult compile(Map<String,String> templates){
        try {
            MemoryClassLoader memClassLoader = new MemoryClassLoader();
            GeneratedSource source = generateJavaCode();
           
            String _className = getClassName();
           
            List<SourceCode> sources = new ArrayList<SourceCode>();
            sources.add(new MemoryJavaSource(_className, source.getSource()));
           
            Iterable<? extends ByteCode> byteCodes = getCompiler().compile(sources);
            memClassLoader.addByteCode(byteCodes);
           
//            MemoryJavaSource memSrc = new MemoryJavaSource(_className, source.getSource());
//            List<MemoryJavaSource> sources = new ArrayList<MemoryJavaSource>();
//            sources.add(memSrc);
//           
//            if( !compileFiles(memClassLoader.getClassDataMap(), sources) ){
//                throw new Error("Ошибка компиляции");
//            }
           
            Class clazz = memClassLoader.loadClass(_className);
            Constructor constructor = clazz.getConstructor(Map.class);
            Object instance = constructor.newInstance(templates);
           
            return new CompileResult(memClassLoader, sources, instance, source.getDefaultTemplates());
        } catch (InstantiationException ex) {
View Full Code Here

TOP

Related Classes of org.gocha.jvm.MemoryClassLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.