1 2 12 package com.versant.core.compiler; 13 14 import com.versant.lib.pizzacompiler.compiler.SrcCompiler; 15 16 import java.util.Map ; 17 import java.util.Collection ; 18 import java.util.HashMap ; 19 import java.util.Iterator ; 20 import java.io.PrintStream ; 21 import java.io.ByteArrayOutputStream ; 22 23 import com.versant.core.common.BindingSupportImpl; 24 25 29 public class PizzaClassCompiler implements ClassCompiler { 30 31 public Map compile(Map classMap, ClassLoader loader) { 32 try { 33 ByteArrayOutputStream buf = new ByteArrayOutputStream (); 34 PrintStream out = new PrintStream (buf, false); 35 Collection c = SrcCompiler.compile(classMap, loader, out); 36 out.close(); 37 if (buf.size() > 0) { 38 String msg = buf.toString(); 39 throw BindingSupportImpl.getInstance().internal(msg); 40 } 41 HashMap ans = new HashMap (); 42 for (Iterator i = c.iterator(); i.hasNext(); ) { 43 byte[] bytecode = (byte[])i.next(); 44 ans.put(ClassFileUtils.getClassName(bytecode), bytecode); 45 } 46 return ans; 47 } catch (Throwable t) { 48 if (BindingSupportImpl.getInstance().isOwnException(t)) { 49 throw (RuntimeException )t; 50 } 51 throw BindingSupportImpl.getInstance().internal(t.toString(), t); 52 } 53 } 54 55 } 56 57 | Popular Tags |