Changeset 4315

Show
Ignore:
Timestamp:
11/06/09 07:53:57 (3 weeks ago)
Author:
dr2chase
Message:

Output classes are now stored in jar files, hooray

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/ByteCodeWriter.java

    r3912 r4315  
    2020import com.sun.fortress.repository.ProjectProperties; 
    2121import java.io.FileOutputStream; 
     22import java.io.IOException; 
     23import java.util.jar.JarOutputStream; 
     24import java.util.zip.ZipEntry; 
    2225 
    2326public class ByteCodeWriter { 
     
    2528    static Character slash = '/'; 
    2629 
     30    public static void writeJarredClass(JarOutputStream jos, String file, byte[] bytes) { 
     31        String fileName = file.replace(dot, slash) + ".class"; 
     32        ZipEntry ze = new ZipEntry(fileName); 
     33        try { 
     34            jos.putNextEntry(ze); 
     35            jos.write(bytes); 
     36            jos.closeEntry(); 
     37        } catch (IOException e) { 
     38            throw new RuntimeException(e); 
     39        } 
     40    
     41    } 
     42     
    2743    public static void writeClass(String repository, String file, byte[] bytes) { 
    2844        String fileName = repository + file.replace(dot, slash) + ".class"; 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/NamingCzar.java

    r4311 r4315  
    572572    } 
    573573 
    574     private static String javaPackageClassForApi(APIName api, String sep) { 
     574    public static String javaPackageClassForApi(APIName api, String sep) { 
    575575        return javaPackageClassForApi(api.getText(), sep); 
    576576    } 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/codegen/CodeGen.java

    r4311 r4315  
    1717package com.sun.fortress.compiler.codegen; 
    1818 
     19import java.io.BufferedOutputStream; 
     20import java.io.FileNotFoundException; 
    1921import java.io.FileOutputStream; 
     22import java.io.IOException; 
    2023import java.io.PrintWriter; 
    2124import java.math.BigInteger; 
    2225import java.util.*; 
     26import java.util.jar.JarOutputStream; 
    2327 
    2428import org.objectweb.asm.*; 
     
    101105    private final ComponentIndex ci; 
    102106    private GlobalEnvironment env; 
     107    private final JarOutputStream jos; 
    103108 
    104109    private static final int NO_SELF = -1; 
     
    130135        this.emittingFunctionalMethodWrappers = c.emittingFunctionalMethodWrappers; 
    131136        this.currentTraitObjectDecl = c.currentTraitObjectDecl; 
     137        this.jos = c.jos; 
    132138 
    133139        this.component = c.component; 
     
    143149        component = c; 
    144150        packageAndClassName = NamingCzar.javaPackageClassForApi(c.getName()); 
     151        String dotted = NamingCzar.javaPackageClassForApi(c.getName(), "."); 
     152        try { 
     153            this.jos = new JarOutputStream(new BufferedOutputStream( new FileOutputStream(NamingCzar.cache + dotted + ".jar"))); 
     154        } catch (FileNotFoundException e) { 
     155            throw new RuntimeException(e); 
     156        } catch (IOException e) { 
     157            throw new RuntimeException(e); 
     158        } 
    145159        this.ta = ta; 
    146160        this.pa = pa; 
     
    356370            CheckClassAdapter.verify(new ClassReader(cw.toByteArray()), true, pw); 
    357371 
    358         ByteCodeWriter.writeClass(NamingCzar.cache, file, cw.toByteArray()); 
     372        ByteCodeWriter.writeJarredClass(jos, file, cw.toByteArray()); 
    359373        debug( "Writing class ", file); 
    360374    } 
     
    637651 
    638652        dumpClass( packageAndClassName ); 
     653         
     654        try { 
     655            jos.close(); 
     656        } catch (IOException e) { 
     657            throw new RuntimeException(e); 
     658        } 
    639659    } 
    640660 
  • trunk/bin/run

    r4230 r4315  
    2929fi 
    3030 
    31 CP="$FORTRESS_HOME/default_repository/caches/bytecode_cache${SEP}$FORTRESS_HOME/default_repository/caches/nativewrapper_cache${SEP}$FORTRESS_HOME/ProjectFortress/build${SEP}$FORTRESS_HOME/ProjectFortress/third_party/junit/junit.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/asm/asm-all-3.1.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/xtc/xtc.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/jsr166y/jsr166y.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/plt/plt.jar${SEP}$JAVA_HOME/lib/tools.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/unsigned/unsigned.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/astgen/astgen.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/scala/scala-compiler-2.7.5.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/scala/scala-library-2.7.5.jar${SEP}$CP" 
    32  
     31CP="$FORTRESS_HOME/default_repository/caches/bytecode_cache${SEP}$FORTRESS_HOME/default_repository/caches/bytecode_cache/*${SEP}$FORTRESS_HOME/default_repository/caches/nativewrapper_cache${SEP}$FORTRESS_HOME/ProjectFortress/build${SEP}$FORTRESS_HOME/ProjectFortress/third_party/junit/junit.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/asm/asm-all-3.1.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/xtc/xtc.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/jsr166y/jsr166y.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/plt/plt.jar${SEP}$JAVA_HOME/lib/tools.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/unsigned/unsigned.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/astgen/astgen.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/scala/scala-compiler-2.7.5.jar${SEP}$FORTRESS_HOME/ProjectFortress/third_party/scala/scala-library-2.7.5.jar${SEP}$CP" 
     32# echo $CP 
    3333if [ -z "$JAVA_HOME" ] ; then 
    3434  JAVACMD=java