[Nice-commit] Nice/src/bossa/modules CompiledContent.java,1.4,1.5 Content.java,1.20,1.21 DirectoryCo
Brought to you by:
bonniot
|
From: Daniel B. <bo...@us...> - 2005-04-12 12:38:21
|
Update of /cvsroot/nice/Nice/src/bossa/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29311/src/bossa/modules Modified Files: CompiledContent.java Content.java DirectoryCompiledContent.java JarCompiledContent.java Log Message: Fix archive creation so that the most recent version of each class file is included in it (regenerated has priority over any previous version). Index: DirectoryCompiledContent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/DirectoryCompiledContent.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DirectoryCompiledContent.java 8 Mar 2005 20:11:36 -0000 1.10 --- DirectoryCompiledContent.java 12 Apr 2005 12:38:11 -0000 1.11 *************** *** 106,126 **** } } ! ! Content.Stream[] getClasses(boolean wantDispatch) { ! return getClasses(directory, wantDispatch); } ! ! static Content.Stream[] getClasses(File directory, ! final boolean wantDispatch) { ! /* ! To list out the "dispatch.class" file, ! we use the method File.compareTo(File) since it is correct ! both on case-sensitive and case-insensitive platforms. ! */ ! final File dispatchFile = ! wantDispatch ? null : new File(directory, "dispatch.class"); ! File[] classes = directory.listFiles (new FileFilter() { --- 106,118 ---- } } ! ! void addClasses(java.util.Set/*<Content.Stream>*/ classes) { ! addClasses(classes, directory); } ! ! static void addClasses(java.util.Set/*<Content.Stream>*/ classes, File directory) { ! File[] files = directory.listFiles (new FileFilter() { *************** *** 132,154 **** return true; ! return name.endsWith(".class") ! && (wantDispatch || dispatchFile.compareTo(f) != 0) ! && f.isFile(); } } ); ! Content.Stream[] res = ! new Content.Stream[classes.length + (wantDispatch ? 0 : 1)]; ! for (int i = 0; i < classes.length; i++) try{ ! res[i] = new Content.Stream ! (new BufferedInputStream(new FileInputStream(classes[i])), ! classes[i].getName()); } catch(FileNotFoundException e) {} - - return res; } ! private InputStream getFileStream(String name) { --- 124,140 ---- return true; ! return name.endsWith(".class") && f.isFile(); } } ); ! for (int i = 0; i < files.length; i++) try{ ! classes.add(new Content.Stream ! (new BufferedInputStream(new FileInputStream(files[i])), ! files[i].getName())); } catch(FileNotFoundException e) {} } ! private InputStream getFileStream(String name) { Index: CompiledContent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/CompiledContent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CompiledContent.java 2 Jul 2004 19:31:03 -0000 1.4 --- CompiledContent.java 12 Apr 2005 12:38:10 -0000 1.5 *************** *** 34,50 **** gnu.bytecode.ClassType dispatch; ! /** ! Returns the compiled classes of this source. ! ! This method is valid for sources that were not compiled ! because they were up-to-date. ! It returns the classes generated by the compilation of the ! package denoted by this source. ! ! @param wantDispatch wether the dispatch.class file must be included in the ! result. If false, an extra null element must be added at then end of ! the array. ! */ ! abstract Content.Stream[] getClasses(boolean wantDispatch); /** --- 34,38 ---- gnu.bytecode.ClassType dispatch; ! abstract void addClasses(java.util.Set/*<Content.Stream>*/ classes); /** Index: JarCompiledContent.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/JarCompiledContent.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** JarCompiledContent.java 17 Sep 2004 16:31:36 -0000 1.8 --- JarCompiledContent.java 12 Apr 2005 12:38:11 -0000 1.9 *************** *** 20,24 **** /** A compiled package located in a jar file. ! @author Daniel Bonniot (Dan...@in...) */ --- 20,24 ---- /** A compiled package located in a jar file. ! @author Daniel Bonniot (Dan...@in...) */ *************** *** 34,43 **** if (itfEntry == null) return null; ! JarEntry bytecodeEntry = jar.getJarEntry (pkgName + "/" + Package.packageClassName + ".class"); if (bytecodeEntry == null) return null; ! JarEntry dispatchEntry = jar.getJarEntry(pkgName + "/dispatch.class"); if (dispatchEntry == null) --- 34,43 ---- if (itfEntry == null) return null; ! JarEntry bytecodeEntry = jar.getJarEntry (pkgName + "/" + Package.packageClassName + ".class"); if (bytecodeEntry == null) return null; ! JarEntry dispatchEntry = jar.getJarEntry(pkgName + "/dispatch.class"); if (dispatchEntry == null) *************** *** 107,113 **** } ! Content.Stream[] getClasses(boolean wantDispatch) { - java.util.List res = new java.util.LinkedList(); String pkgPrefix = pkg.getName().replace('.', '/') + "/"; --- 107,112 ---- } ! void addClasses(java.util.Set/*<Content.Stream>*/ classes) { String pkgPrefix = pkg.getName().replace('.', '/') + "/"; *************** *** 115,142 **** while(en.hasMoreElements()) { ! JarEntry e = (JarEntry) en.nextElement(); ! String fullname = e.getName(); ! if (fullname.startsWith(pkgPrefix) ! && fullname.indexOf('/', pkgPrefix.length()) == -1 ! && fullname.endsWith(".class")) ! { ! String name = fullname.substring(pkgPrefix.length()); ! if (wantDispatch || !name.equals("dispatch.class")) ! try{ ! res.add(new Content.Stream(jar.getInputStream(e), name)); ! } ! catch(IOException ex){ ! User.error(pkg.name, ! "Error reading archive " + getName()); ! } ! } } - - int len = res.size(); - if (! wantDispatch) - len++; - return (Content.Stream[]) res.toArray(new Content.Stream[len]); } ! InputStream getBytecodeStream() { --- 114,135 ---- while(en.hasMoreElements()) { ! JarEntry e = (JarEntry) en.nextElement(); ! String fullname = e.getName(); ! if (fullname.startsWith(pkgPrefix) ! && fullname.indexOf('/', pkgPrefix.length()) == -1 ! && fullname.endsWith(".class")) ! { ! String name = fullname.substring(pkgPrefix.length()); ! try{ ! classes.add(new Content.Stream(jar.getInputStream(e), name)); ! } ! catch(IOException ex){ ! User.error(pkg.name, ! "Error reading archive " + getName()); ! } ! } } } ! InputStream getBytecodeStream() { *************** *** 149,158 **** } } ! public String getName() { return nice.tools.util.System.prettyPrint(jar); } ! public String toString() { --- 142,151 ---- } } ! public String getName() { return nice.tools.util.System.prettyPrint(jar); } ! public String toString() { Index: Content.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/modules/Content.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Content.java 12 Mar 2005 10:12:56 -0000 1.20 --- Content.java 12 Apr 2005 12:38:11 -0000 1.21 *************** *** 295,298 **** --- 295,306 ---- this.name = name; } + + public boolean equals(Object o) + { + return o instanceof Stream && name.equals(((Stream) o).name); + } + + public int hashCode() { return name.hashCode(); } + InputStream stream; String name; *************** *** 300,336 **** /** ! Returns the compiled classes of this source. ! ! This method is valid for sources that were not compiled ! because they were up-to-date. ! It returns the classes generated by the compilation of the ! package denoted by this source. */ Stream[] getClasses(boolean linkPerformed) { ! Stream[] res; if (!sourceRead) ! { ! res = compiled.getClasses(! linkPerformed); ! if (linkPerformed) ! { ! File dispatchFile = new File(getOutputDirectory(), ! "dispatch.class"); ! try{ ! res[res.length - 1] = new Stream ! (new FileInputStream(dispatchFile), "dispatch.class"); ! } ! catch(FileNotFoundException e) { ! Internal.error(pkg + ! ": dispatch class could not be added to archive" + ! "\nI expected it to be in " + dispatchFile); ! } ! } ! } ! else ! res = DirectoryCompiledContent.getClasses(getOutputDirectory(), true); ! return res; } } --- 308,327 ---- /** ! Returns the compiled classes of this source. */ Stream[] getClasses(boolean linkPerformed) { ! /* We first add the generated classes, then all those compiled classes ! that were not regenerated. The Set ensures that the previous version of ! regenerated classes is not included. ! */ ! Set res = new HashSet(); ! ! DirectoryCompiledContent.addClasses(res, getOutputDirectory()); if (!sourceRead) ! compiled.addClasses(res); ! return (Stream[]) res.toArray(new Stream[res.size()]); } } |