From: <ls...@us...> - 2009-03-20 19:22:32
|
Revision: 5131 http://jnode.svn.sourceforge.net/jnode/?rev=5131&view=rev Author: lsantha Date: 2009-03-20 19:22:25 +0000 (Fri, 20 Mar 2009) Log Message: ----------- Integrated java.io.PrintStream from OpenJDK. Modified Paths: -------------- trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java trunk/core/descriptors/org.classpath.core.xml trunk/core/src/core/org/jnode/vm/VmSystem.java Added Paths: ----------- trunk/core/src/openjdk/java/java/io/PrintStream.java trunk/core/src/openjdk/java/java/nio/ trunk/core/src/openjdk/java/java/nio/charset/ trunk/core/src/openjdk/java/java/nio/charset/Charset.java Removed Paths: ------------- trunk/core/src/classpath/java/java/io/PrintStream.java trunk/core/src/classpath/java/java/nio/charset/Charset.java Modified: trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java 2009-03-20 18:59:22 UTC (rev 5130) +++ trunk/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java 2009-03-20 19:22:25 UTC (rev 5131) @@ -1319,6 +1319,9 @@ addCompileHighOptLevel("java.nio.ByteBuffer*"); addCompileHighOptLevel("java.nio.DirectByteBuffer*"); addCompileHighOptLevel("java.nio.ByteOrder"); + addCompileHighOptLevel("java.nio.Char*"); + addCompileHighOptLevel("java.nio.charset.spi"); + addCompileHighOptLevel("java.nio.charset"); addCompileHighOptLevel("java.security.ProtectionDomain"); addCompileHighOptLevel("java.security.AccessController"); @@ -1404,7 +1407,21 @@ // addCompileHighOptLevel("sun.reflect.generics.tree"); // addCompileHighOptLevel("sun.reflect.generics.visitor"); // addCompileHighOptLevel("sun.reflect.misc"); + addCompileHighOptLevel("sun.misc.VM"); addCompileHighOptLevel("sun.nio"); + addCompileHighOptLevel("sun.nio.cs.US_ASCII"); + addCompileHighOptLevel("sun.nio.cs.ISO_8859_1*"); + addCompileHighOptLevel("sun.nio.cs.Surrogate*"); + addCompileHighOptLevel("sun.nio.cs.StreamEncoder"); + addCompileHighOptLevel("sun.nio.cs.SingleByteDecoder"); + addCompileHighOptLevel("sun.nio.cs.SingleByteEncoder"); + addCompileHighOptLevel("sun.nio.cs.FastCharsetProvider"); + addCompileHighOptLevel("sun.nio.cs.StandardCharsets"); + addCompileHighOptLevel("sun.nio.cs.HistoricallyNamedCharset"); + addCompileHighOptLevel("sun.nio.cs.StreamDecoder"); + addCompileHighOptLevel("sun.nio.cs.ThreadLocalCoders"); + addCompileHighOptLevel("sun.nio.cs.Unicode*"); + addCompileHighOptLevel("sun.nio.cs.UTF*"); if (false) { addCompileHighOptLevel("org.mmtk.plan"); Modified: trunk/core/descriptors/org.classpath.core.xml =================================================================== --- trunk/core/descriptors/org.classpath.core.xml 2009-03-20 18:59:22 UTC (rev 5130) +++ trunk/core/descriptors/org.classpath.core.xml 2009-03-20 19:22:25 UTC (rev 5131) @@ -49,11 +49,9 @@ <export name="sun.misc.Service"/> <export name="sun.misc.ServiceConfigurationError"/> + <export name="sun.misc.VM"/> - <export name="sun.nio.cs.StreamEncoder"/> - <export name="sun.nio.cs.StreamDecoder"/> - <export name="sun.nio.cs.HistoricallyNamedCharset"/> - <export name="sun.nio.cs.ThreadLocalCoders"/> + <export name="sun.nio.cs.*"/> <export name="sun.text.*"/> <export name="sun.text.normalizer.*"/> Deleted: trunk/core/src/classpath/java/java/io/PrintStream.java =================================================================== --- trunk/core/src/classpath/java/java/io/PrintStream.java 2009-03-20 18:59:22 UTC (rev 5130) +++ trunk/core/src/classpath/java/java/io/PrintStream.java 2009-03-20 19:22:25 UTC (rev 5131) @@ -1,688 +0,0 @@ -/* PrintStream.java -- OutputStream for printing output - Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.io; - -import java.util.Locale; -import java.util.Formatter; - -import gnu.classpath.SystemProperties; - -/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 - * "The Java Language Specification", ISBN 0-201-63451-1 - * Status: Believed complete and correct to 1.3 - */ - -/** - * This class prints Java primitive values and object to a stream as - * text. None of the methods in this class throw an exception. However, - * errors can be detected by calling the <code>checkError()</code> method. - * Additionally, this stream can be designated as "autoflush" when - * created so that any writes are automatically flushed to the underlying - * output sink when the current line is terminated. - * <p> - * This class converts char's into byte's using the system default encoding. - * - * @author Aaron M. Renn (ar...@ur...) - * @author Tom Tromey (tr...@cy...) - * @author Andrew John Hughes (gnu...@me...) - */ -public class PrintStream extends FilterOutputStream implements Appendable -{ - /* Notice the implementation is quite similar to OutputStreamWriter. - * This leads to some minor duplication, because neither inherits - * from the other, and we want to maximize performance. */ - - // Line separator string. - private static final char[] line_separator - = SystemProperties.getProperty("line.separator", "\n").toCharArray(); - - /** - * Encoding name - */ - private String encoding; - - /** - * This boolean indicates whether or not an error has ever occurred - * on this stream. - */ - private boolean error_occurred = false; - - /** - * This is <code>true</code> if auto-flush is enabled, - * <code>false</code> otherwise - */ - private boolean auto_flush; - - /** - * This method initializes a new <code>PrintStream</code> object to write - * to the specified output File. Doesn't autoflush. - * - * @param file The <code>File</code> to write to. - * @throws FileNotFoundException if an error occurs while opening the file. - * - * @since 1.5 - */ - public PrintStream (File file) - throws FileNotFoundException - { - this (new FileOutputStream(file), false); - } - - /** - * This method initializes a new <code>PrintStream</code> object to write - * to the specified output File. Doesn't autoflush. - * - * @param file The <code>File</code> to write to. - * @param encoding The name of the character encoding to use for this - * object. - * @throws FileNotFoundException If an error occurs while opening the file. - * @throws UnsupportedEncodingException If the charset specified by - * <code>encoding</code> is invalid. - * - * @since 1.5 - */ - public PrintStream (File file, String encoding) - throws FileNotFoundException,UnsupportedEncodingException - { - this (new FileOutputStream(file), false, encoding); - } - - /** - * This method initializes a new <code>PrintStream</code> object to write - * to the specified output File. Doesn't autoflush. - * - * @param fileName The name of the <code>File</code> to write to. - * @throws FileNotFoundException if an error occurs while opening the file, - * - * @since 1.5 - */ - public PrintStream (String fileName) - throws FileNotFoundException - { - this (new FileOutputStream(new File(fileName)), false); - } - - /** - * This method initializes a new <code>PrintStream</code> object to write - * to the specified output File. Doesn't autoflush. - * - * @param fileName The name of the <code>File</code> to write to. - * @param encoding The name of the character encoding to use for this - * object. - * @throws FileNotFoundException if an error occurs while opening the file. - * @throws UnsupportedEncodingException If the charset specified by - * <code>encoding</code> is invalid. - * - * @since 1.5 - */ - public PrintStream (String fileName, String encoding) - throws FileNotFoundException,UnsupportedEncodingException - { - this (new FileOutputStream(new File(fileName)), false, encoding); - } - - /** - * This method initializes a new <code>PrintStream</code> object to write - * to the specified output sink. Doesn't autoflush. - * - * @param out The <code>OutputStream</code> to write to. - */ - public PrintStream (OutputStream out) - { - this (out, false); - } - - /** - * This method initializes a new <code>PrintStream</code> object to write - * to the specified output sink. This constructor also allows "auto-flush" - * functionality to be specified where the stream will be flushed after - * every <code>print</code> or <code>println</code> call, when the - * <code>write</code> methods with array arguments are called, or when a - * single new-line character is written. - * <p> - * - * @param out The <code>OutputStream</code> to write to. - * @param auto_flush <code>true</code> to flush the stream after every - * line, <code>false</code> otherwise - */ - public PrintStream (OutputStream out, boolean auto_flush) - { - super (out); - - try { - this.encoding = SystemProperties.getProperty("file.encoding"); - } catch (SecurityException e){ - this.encoding = "ISO8859_1"; - } catch (IllegalArgumentException e){ - this.encoding = "ISO8859_1"; - } catch (NullPointerException e){ - this.encoding = "ISO8859_1"; - } - this.auto_flush = auto_flush; - } - - /** - * This method initializes a new <code>PrintStream</code> object to write - * to the specified output sink. This constructor also allows "auto-flush" - * functionality to be specified where the stream will be flushed after - * every <code>print</code> or <code>println</code> call, when the - * <code>write</code> methods with array arguments are called, or when a - * single new-line character is written. - * <p> - * - * @param out The <code>OutputStream</code> to write to. - * @param auto_flush <code>true</code> to flush the stream after every - * line, <code>false</code> otherwise - * @param encoding The name of the character encoding to use for this - * object. - */ - public PrintStream (OutputStream out, boolean auto_flush, String encoding) - throws UnsupportedEncodingException - { - super (out); - - new String(new byte[]{0}, encoding); // check if encoding is supported - this.encoding = encoding; - this.auto_flush = auto_flush; - } - - /** - * This method checks to see if an error has occurred on this stream. Note - * that once an error has occurred, this method will continue to report - * <code>true</code> forever for this stream. Before checking for an - * error condition, this method flushes the stream. - * - * @return <code>true</code> if an error has occurred, - * <code>false</code> otherwise - */ - public boolean checkError () - { - flush (); - return error_occurred; - } - - /** - * This method can be called by subclasses to indicate that an error - * has occurred and should be reported by <code>checkError</code>. - */ - protected void setError () - { - error_occurred = true; - } - - /** - * This method closes this stream and all underlying streams. - */ - public void close () - { - try - { - flush(); - out.close(); - } - catch (InterruptedIOException iioe) - { - Thread.currentThread().interrupt(); - } - catch (IOException e) - { - setError (); - } - } - - /** - * This method flushes any buffered bytes to the underlying stream and - * then flushes that stream as well. - */ - public void flush () - { - try - { - out.flush(); - } - catch (InterruptedIOException iioe) - { - Thread.currentThread().interrupt(); - } - catch (IOException e) - { - setError (); - } - } - - private synchronized void print (String str, boolean println) - { - try - { - writeChars(str, 0, str.length()); - if (println) - writeChars(line_separator, 0, line_separator.length); - if (auto_flush) - flush(); - } - catch (InterruptedIOException iioe) - { - Thread.currentThread().interrupt(); - } - catch (IOException e) - { - setError (); - } - } - - private synchronized void print (char[] chars, int pos, int len, - boolean println) - { - try - { - writeChars(chars, pos, len); - if (println) - writeChars(line_separator, 0, line_separator.length); - if (auto_flush) - flush(); - } - catch (InterruptedIOException iioe) - { - Thread.currentThread().interrupt(); - } - catch (IOException e) - { - setError (); - } - } - - private void writeChars(char[] buf, int offset, int count) - throws IOException - { - byte[] bytes = (new String(buf, offset, count)).getBytes(encoding); - out.write(bytes, 0, bytes.length); - } - - private void writeChars(String str, int offset, int count) - throws IOException - { - byte[] bytes = str.substring(offset, offset+count).getBytes(encoding); - out.write(bytes, 0, bytes.length); - } - - /** - * This methods prints a boolean value to the stream. <code>true</code> - * values are printed as "true" and <code>false</code> values are printed - * as "false". - * - * @param bool The <code>boolean</code> value to print - */ - public void print (boolean bool) - { - print(String.valueOf(bool), false); - } - - /** - * This method prints an integer to the stream. The value printed is - * determined using the <code>String.valueOf()</code> method. - * - * @param inum The <code>int</code> value to be printed - */ - public void print (int inum) - { - print(String.valueOf(inum), false); - } - - /** - * This method prints a long to the stream. The value printed is - * determined using the <code>String.valueOf()</code> method. - * - * @param lnum The <code>long</code> value to be printed - */ - public void print (long lnum) - { - print(String.valueOf(lnum), false); - } - - /** - * This method prints a float to the stream. The value printed is - * determined using the <code>String.valueOf()</code> method. - * - * @param fnum The <code>float</code> value to be printed - */ - public void print (float fnum) - { - print(String.valueOf(fnum), false); - } - - /** - * This method prints a double to the stream. The value printed is - * determined using the <code>String.valueOf()</code> method. - * - * @param dnum The <code>double</code> value to be printed - */ - public void print (double dnum) - { - print(String.valueOf(dnum), false); - } - - /** - * This method prints an <code>Object</code> to the stream. The actual - * value printed is determined by calling the <code>String.valueOf()</code> - * method. - * - * @param obj The <code>Object</code> to print. - */ - public void print (Object obj) - { - print(obj == null ? "null" : obj.toString(), false); - } - - /** - * This method prints a <code>String</code> to the stream. The actual - * value printed depends on the system default encoding. - * - * @param str The <code>String</code> to print. - */ - public void print (String str) - { - print(str == null ? "null" : str, false); - } - - /** - * This method prints a char to the stream. The actual value printed is - * determined by the character encoding in use. - * - * @param ch The <code>char</code> value to be printed - */ - public synchronized void print (char ch) - { - print(new char[]{ch}, 0, 1, false); - } - - /** - * This method prints an array of characters to the stream. The actual - * value printed depends on the system default encoding. - * - * @param charArray The array of characters to print. - */ - public void print (char[] charArray) - { - print(charArray, 0, charArray.length, false); - } - - /** - * This method prints a line separator sequence to the stream. The value - * printed is determined by the system property <xmp>line.separator</xmp> - * and is not necessarily the Unix '\n' newline character. - */ - public void println () - { - print(line_separator, 0, line_separator.length, false); - } - - /** - * This methods prints a boolean value to the stream. <code>true</code> - * values are printed as "true" and <code>false</code> values are printed - * as "false". - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param bool The <code>boolean</code> value to print - */ - public void println (boolean bool) - { - print(String.valueOf(bool), true); - } - - /** - * This method prints an integer to the stream. The value printed is - * determined using the <code>String.valueOf()</code> method. - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param inum The <code>int</code> value to be printed - */ - public void println (int inum) - { - print(String.valueOf(inum), true); - } - - /** - * This method prints a long to the stream. The value printed is - * determined using the <code>String.valueOf()</code> method. - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param lnum The <code>long</code> value to be printed - */ - public void println (long lnum) - { - print(String.valueOf(lnum), true); - } - - /** - * This method prints a float to the stream. The value printed is - * determined using the <code>String.valueOf()</code> method. - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param fnum The <code>float</code> value to be printed - */ - public void println (float fnum) - { - print(String.valueOf(fnum), true); - } - - /** - * This method prints a double to the stream. The value printed is - * determined using the <code>String.valueOf()</code> method. - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param dnum The <code>double</code> value to be printed - */ - public void println (double dnum) - { - print(String.valueOf(dnum), true); - } - - /** - * This method prints an <code>Object</code> to the stream. The actual - * value printed is determined by calling the <code>String.valueOf()</code> - * method. - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param obj The <code>Object</code> to print. - */ - public void println (Object obj) - { - print(obj == null ? "null" : obj.toString(), true); - } - - /** - * This method prints a <code>String</code> to the stream. The actual - * value printed depends on the system default encoding. - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param str The <code>String</code> to print. - */ - public void println (String str) - { - print (str == null ? "null" : str, true); - } - - /** - * This method prints a char to the stream. The actual value printed is - * determined by the character encoding in use. - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param ch The <code>char</code> value to be printed - */ - public synchronized void println (char ch) - { - print(new char[]{ch}, 0, 1, true); - } - - /** - * This method prints an array of characters to the stream. The actual - * value printed depends on the system default encoding. - * <p> - * This method prints a line termination sequence after printing the value. - * - * @param charArray The array of characters to print. - */ - public void println (char[] charArray) - { - print(charArray, 0, charArray.length, true); - } - - /** - * This method writes a byte of data to the stream. If auto-flush is - * enabled, printing a newline character will cause the stream to be - * flushed after the character is written. - * - * @param oneByte The byte to be written - */ - public void write (int oneByte) - { - try - { - out.write (oneByte & 0xff); - - if (auto_flush && (oneByte == '\n')) - flush (); - } - catch (InterruptedIOException iioe) - { - Thread.currentThread ().interrupt (); - } - catch (IOException e) - { - setError (); - } - } - - /** - * This method writes <code>len</code> bytes from the specified array - * starting at index <code>offset</code> into the array. - * - * @param buffer The array of bytes to write - * @param offset The index into the array to start writing from - * @param len The number of bytes to write - */ - public void write (byte[] buffer, int offset, int len) - { - try - { - out.write (buffer, offset, len); - - if (auto_flush) - flush (); - } - catch (InterruptedIOException iioe) - { - Thread.currentThread ().interrupt (); - } - catch (IOException e) - { - setError (); - } - } - - /** @since 1.5 */ - public PrintStream append(char c) - { - print(c); - return this; - } - - /** @since 1.5 */ - public PrintStream append(CharSequence cs) - { - print(cs == null ? "null" : cs.toString()); - return this; - } - - /** @since 1.5 */ - public PrintStream append(CharSequence cs, int start, int end) - { - print(cs == null ? "null" : cs.subSequence(start, end).toString()); - return this; - } - - /** @since 1.5 */ - public PrintStream printf(String format, Object... args) - { - return format(format, args); - } - - /** @since 1.5 */ - public PrintStream printf(Locale locale, String format, Object... args) - { - return format(locale, format, args); - } - - /** @since 1.5 */ - public PrintStream format(String format, Object... args) - { - return format(Locale.getDefault(), format, args); - } - - /** @since 1.5 */ - public PrintStream format(Locale locale, String format, Object... args) - { - Formatter f = new Formatter(this, locale); - f.format(format, args); - return this; - } - - //jnode + opnjdk - /** - * Clears the internal error state of this stream. - * - * <p> This method will cause subsequent invocations of {@link - * #checkError()} to return <tt>false</tt> until another write - * operation fails and invokes {@link #setError()}. - * - * @since 1.6 - */ - protected void clearError() { - error_occurred = false; - } -} // class PrintStream Deleted: trunk/core/src/classpath/java/java/nio/charset/Charset.java =================================================================== --- trunk/core/src/classpath/java/java/nio/charset/Charset.java 2009-03-20 18:59:22 UTC (rev 5130) +++ trunk/core/src/classpath/java/java/nio/charset/Charset.java 2009-03-20 19:22:25 UTC (rev 5131) @@ -1,395 +0,0 @@ -/* Charset.java -- - Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.nio.charset; - -import gnu.classpath.ServiceFactory; -import gnu.classpath.SystemProperties; -import gnu.java.nio.charset.Provider; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.spi.CharsetProvider; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Locale; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; - -/** - * @author Jesse Rosenstock - * @since 1.4 - * @status updated to 1.5 - */ -public abstract class Charset implements Comparable<Charset> -{ - private CharsetEncoder cachedEncoder; - private CharsetDecoder cachedDecoder; - - /** - * Extra Charset providers. - */ - private static CharsetProvider[] providers; - - private final String canonicalName; - private final String[] aliases; - - protected Charset (String canonicalName, String[] aliases) - { - checkName (canonicalName); - if (aliases != null) - { - int n = aliases.length; - for (int i = 0; i < n; ++i) - checkName (aliases[i]); - } - - cachedEncoder = null; - cachedDecoder = null; - this.canonicalName = canonicalName; - this.aliases = aliases; - } - - /** - * @throws IllegalCharsetNameException if the name is illegal - */ - private static void checkName (String name) - { - int n = name.length (); - - if (n == 0) - throw new IllegalCharsetNameException (name); - - char ch = name.charAt (0); - if (!(('A' <= ch && ch <= 'Z') - || ('a' <= ch && ch <= 'z') - || ('0' <= ch && ch <= '9'))) - throw new IllegalCharsetNameException (name); - - for (int i = 1; i < n; ++i) - { - ch = name.charAt (i); - if (!(('A' <= ch && ch <= 'Z') - || ('a' <= ch && ch <= 'z') - || ('0' <= ch && ch <= '9') - || ch == '-' || ch == '.' || ch == ':' || ch == '_')) - throw new IllegalCharsetNameException (name); - } - } - - /** - * Returns the system default charset. - * - * This may be set by the user or VM with the file.encoding - * property. - * - * @since 1.5 - */ - public static Charset defaultCharset() - { - String encoding; - - try - { - encoding = SystemProperties.getProperty("file.encoding"); - } - catch(SecurityException e) - { - // Use fallback. - encoding = "ISO-8859-1"; - } - catch(IllegalArgumentException e) - { - // Use fallback. - encoding = "ISO-8859-1"; - } - - try - { - return forName(encoding); - } - catch(UnsupportedCharsetException e) - { - // Ignore. - } - catch(IllegalCharsetNameException e) - { - // Ignore. - } - catch(IllegalArgumentException e) - { - // Ignore. - } - - throw new IllegalStateException("Can't get default charset!"); - } - - public static boolean isSupported (String charsetName) - { - return charsetForName (charsetName) != null; - } - - /** - * Returns the Charset instance for the charset of the given name. - * - * @param charsetName - * @return the Charset instance for the indicated charset - * @throws UnsupportedCharsetException if this VM does not support - * the charset of the given name. - * @throws IllegalCharsetNameException if the given charset name is - * legal. - * @throws IllegalArgumentException if <code>charsetName</code> is null. - */ - public static Charset forName (String charsetName) - { - // Throws IllegalArgumentException as the JDK does. - if(charsetName == null) - throw new IllegalArgumentException("Charset name must not be null."); - - Charset cs = charsetForName (charsetName); - if (cs == null) - throw new UnsupportedCharsetException (charsetName); - return cs; - } - - /** - * Retrieves a charset for the given charset name. - * - * @return A charset object for the charset with the specified name, or - * <code>null</code> if no such charset exists. - * - * @throws IllegalCharsetNameException if the name is illegal - */ - private static Charset charsetForName(String charsetName) - { - checkName (charsetName); - // Try the default provider first - // (so we don't need to load external providers unless really necessary) - // if it is an exotic charset try loading the external providers. - Charset cs = provider().charsetForName(charsetName); - if (cs == null) - { - CharsetProvider[] providers = providers2(); - for (int i = 0; i < providers.length; i++) - { - cs = providers[i].charsetForName(charsetName); - if (cs != null) - break; - } - } - return cs; - } - - public static SortedMap<String, Charset> availableCharsets() - { - TreeMap<String, Charset> charsets - = new TreeMap(String.CASE_INSENSITIVE_ORDER); - for (Iterator<Charset> i = provider().charsets(); i.hasNext(); ) - { - Charset cs = i.next(); - charsets.put(cs.name(), cs); - } - - CharsetProvider[] providers = providers2(); - for (int j = 0; j < providers.length; j++) - { - for (Iterator<Charset> i = providers[j].charsets(); i.hasNext(); ) - { - Charset cs = (Charset) i.next(); - charsets.put(cs.name(), cs); - } - } - - return Collections.unmodifiableSortedMap(charsets); - } - - private static CharsetProvider provider() - { - return Provider.provider(); - } - - /** - * We need to support multiple providers, reading them from - * java.nio.charset.spi.CharsetProvider in the resource directory - * META-INF/services. This returns the "extra" charset providers. - */ - private static CharsetProvider[] providers2() - { - if (providers == null) - { - try - { - Iterator i = ServiceFactory.lookupProviders(CharsetProvider.class); - LinkedHashSet set = new LinkedHashSet(); - while (i.hasNext()) - set.add(i.next()); - - providers = new CharsetProvider[set.size()]; - set.toArray(providers); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - return providers; - } - - public final String name () - { - return canonicalName; - } - - public final Set<String> aliases () - { - if (aliases == null) - return Collections.<String>emptySet(); - - // should we cache the aliasSet instead? - int n = aliases.length; - HashSet<String> aliasSet = new HashSet<String> (n); - for (int i = 0; i < n; ++i) - aliasSet.add (aliases[i]); - return Collections.unmodifiableSet (aliasSet); - } - - public String displayName () - { - return canonicalName; - } - - public String displayName (Locale locale) - { - return canonicalName; - } - - public final boolean isRegistered () - { - return (!canonicalName.startsWith ("x-") - && !canonicalName.startsWith ("X-")); - } - - public abstract boolean contains (Charset cs); - - public abstract CharsetDecoder newDecoder (); - - public abstract CharsetEncoder newEncoder (); - - public boolean canEncode () - { - return true; - } - - // NB: This implementation serializes different threads calling - // Charset.encode(), a potential performance problem. It might - // be better to remove the cache, or use ThreadLocal to cache on - // a per-thread basis. - public final synchronized ByteBuffer encode (CharBuffer cb) - { - try - { - if (cachedEncoder == null) - { - cachedEncoder = newEncoder () - .onMalformedInput (CodingErrorAction.REPLACE) - .onUnmappableCharacter (CodingErrorAction.REPLACE); - } else - cachedEncoder.reset(); - return cachedEncoder.encode (cb); - } - catch (CharacterCodingException e) - { - throw new AssertionError (e); - } - } - - public final ByteBuffer encode (String str) - { - return encode (CharBuffer.wrap (str)); - } - - // NB: This implementation serializes different threads calling - // Charset.decode(), a potential performance problem. It might - // be better to remove the cache, or use ThreadLocal to cache on - // a per-thread basis. - public final synchronized CharBuffer decode (ByteBuffer bb) - { - try - { - if (cachedDecoder == null) - { - cachedDecoder = newDecoder () - .onMalformedInput (CodingErrorAction.REPLACE) - .onUnmappableCharacter (CodingErrorAction.REPLACE); - } else - cachedDecoder.reset(); - - return cachedDecoder.decode (bb); - } - catch (CharacterCodingException e) - { - throw new AssertionError (e); - } - } - - public final int compareTo (Charset other) - { - return canonicalName.compareToIgnoreCase (other.canonicalName); - } - - public final int hashCode () - { - return canonicalName.hashCode (); - } - - public final boolean equals (Object ob) - { - if (ob instanceof Charset) - return canonicalName.equalsIgnoreCase (((Charset) ob).canonicalName); - else - return false; - } - - public final String toString () - { - return canonicalName; - } -} Modified: trunk/core/src/core/org/jnode/vm/VmSystem.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmSystem.java 2009-03-20 18:59:22 UTC (rev 5130) +++ trunk/core/src/core/org/jnode/vm/VmSystem.java 2009-03-20 19:22:25 UTC (rev 5131) @@ -123,13 +123,13 @@ // Initialize resource manager final ResourceManager rm = ResourceManagerImpl.initialize(); - VmSystem.out = getSystemOut(); - /* Initialize the system classloader */ VmSystemClassLoader loader = (VmSystemClassLoader) (getVmClass(VmProcessor.current()).getLoader()); systemLoader = loader; loader.initialize(); + VmSystem.out = getSystemOut(); + // Initialize VmThread VmThread.initialize(); @@ -226,6 +226,8 @@ bootOutStream = new PrintStream(bootOut, true); VmIOContext.setGlobalOutStream(bootOutStream); VmIOContext.setGlobalErrStream(bootOutStream); + setOut(bootOutStream); + setErr(bootOutStream); return bootOutStream; } else if (VmIsolate.isRoot()) { return bootOutStream; @@ -278,6 +280,7 @@ // Standard Java properties res.put("file.separator", "/"); +// res.put("file.encoding", "ISO-8859-1"); res.put("java.awt.graphicsenv", "org.jnode.awt.JNodeGraphicsEnvironment"); //todo // res.put("java.awt.printerjob", ""); @@ -944,7 +947,7 @@ static class SystemOutputStream extends OutputStream { - private final StringBuffer data = new StringBuffer(); + private StringBuffer data; /** * @see java.io.OutputStream#write(int) @@ -952,6 +955,11 @@ public void write(int b) throws IOException { final char ch = (char) (b & 0xFF); Unsafe.debug(ch); + if(data == null) { + synchronized (this) { + data = new StringBuffer(); + } + } data.append(ch); } @@ -961,6 +969,8 @@ * @return data written to the system output stream */ public String getData() { + if(data == null) + return ""; return data.toString(); } } Added: trunk/core/src/openjdk/java/java/io/PrintStream.java =================================================================== --- trunk/core/src/openjdk/java/java/io/PrintStream.java (rev 0) +++ trunk/core/src/openjdk/java/java/io/PrintStream.java 2009-03-20 19:22:25 UTC (rev 5131) @@ -0,0 +1,1096 @@ +/* + * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.io; + +import java.util.Formatter; +import java.util.Locale; + + +/** + * A <code>PrintStream</code> adds functionality to another output stream, + * namely the ability to print representations of various data values + * conveniently. Two other features are provided as well. Unlike other output + * streams, a <code>PrintStream</code> never throws an + * <code>IOException</code>; instead, exceptional situations merely set an + * internal flag that can be tested via the <code>checkError</code> method. + * Optionally, a <code>PrintStream</code> can be created so as to flush + * automatically; this means that the <code>flush</code> method is + * automatically invoked after a byte array is written, one of the + * <code>println</code> methods is invoked, or a newline character or byte + * (<code>'\n'</code>) is written. + * + * <p> All characters printed by a <code>PrintStream</code> are converted into + * bytes using the platform's default character encoding. The <code>{@link + * PrintWriter}</code> class should be used in situations that require writing + * characters rather than bytes. + * + * @author Frank Yellin + * @author Mark Reinhold + * @since JDK1.0 + */ + +public class PrintStream extends FilterOutputStream + implements Appendable, Closeable +{ + + private boolean autoFlush = false; + private boolean trouble = false; + private Formatter formatter; + + /** + * Track both the text- and character-output streams, so that their buffers + * can be flushed without flushing the entire stream. + */ + private BufferedWriter textOut; + private OutputStreamWriter charOut; + + /** + * Creates a new print stream. This stream will not flush automatically. + * + * @param out The output stream to which values and objects will be + * printed + * + * @see java.io.PrintWriter#PrintWriter(java.io.OutputStream) + */ + public PrintStream(OutputStream out) { + this(out, false); + } + + /* Initialization is factored into a private constructor (note the swapped + * parameters so that this one isn't confused with the public one) and a + * separate init method so that the following two public constructors can + * share code. We use a separate init method so that the constructor that + * takes an encoding will throw an NPE for a null stream before it throws + * an UnsupportedEncodingException for an unsupported encoding. + */ + + private PrintStream(boolean autoFlush, OutputStream out) + { + super(out); + if (out == null) + throw new NullPointerException("Null output stream"); + this.autoFlush = autoFlush; + } + + private void init(OutputStreamWriter osw) { + this.charOut = osw; + this.textOut = new BufferedWriter(osw); + } + + /** + * Creates a new print stream. + * + * @param out The output stream to which values and objects will be + * printed + * @param autoFlush A boolean; if true, the output buffer will be flushed + * whenever a byte array is written, one of the + * <code>println</code> methods is invoked, or a newline + * character or byte (<code>'\n'</code>) is written + * + * @see java.io.PrintWriter#PrintWriter(java.io.OutputStream, boolean) + */ + public PrintStream(OutputStream out, boolean autoFlush) { + this(autoFlush, out); + init(new OutputStreamWriter(this)); + } + + /** + * Creates a new print stream. + * + * @param out The output stream to which values and objects will be + * printed + * @param autoFlush A boolean; if true, the output buffer will be flushed + * whenever a byte array is written, one of the + * <code>println</code> methods is invoked, or a newline + * character or byte (<code>'\n'</code>) is written + * @param encoding The name of a supported + * <a href="../lang/package-summary.html#charenc"> + * character encoding</a> + * + * @throws UnsupportedEncodingException + * If the named encoding is not supported + * + * @since 1.4 + */ + public PrintStream(OutputStream out, boolean autoFlush, String encoding) + throws UnsupportedEncodingException + { + this(autoFlush, out); + init(new OutputStreamWriter(this, encoding)); + } + + /** + * Creates a new print stream, without automatic line flushing, with the + * specified file name. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the + * {@linkplain java.nio.charset.Charset#defaultCharset() default charset} + * for this instance of the Java virtual machine. + * + * @param fileName + * The name of the file to use as the destination of this print + * stream. If the file exists, then it will be truncated to + * zero size; otherwise, a new file will be created. The output + * will be written to the file and is buffered. + * + * @throws FileNotFoundException + * If the given file object does not denote an existing, writable + * regular file and a new regular file of that name cannot be + * created, or if some other error occurs while opening or + * creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(fileName)} denies write + * access to the file + * + * @since 1.5 + */ + public PrintStream(String fileName) throws FileNotFoundException { + this(false, new FileOutputStream(fileName)); + init(new OutputStreamWriter(this)); + } + + /** + * Creates a new print stream, without automatic line flushing, with the + * specified file name and charset. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param fileName + * The name of the file to use as the destination of this print + * stream. If the file exists, then it will be truncated to + * zero size; otherwise, a new file will be created. The output + * will be written to the file and is buffered. + * + * @param csn + * The name of a supported {@linkplain java.nio.charset.Charset + * charset} + * + * @throws FileNotFoundException + * If the given file object does not denote an existing, writable + * regular file and a new regular file of that name cannot be + * created, or if some other error occurs while opening or + * creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(fileName)} denies write + * access to the file + * + * @throws UnsupportedEncodingException + * If the named charset is not supported + * + * @since 1.5 + */ + public PrintStream(String fileName, String csn) + throws FileNotFoundException, UnsupportedEncodingException + { + this(false, new FileOutputStream(fileName)); + init(new OutputStreamWriter(this, csn)); + } + + /** + * Creates a new print stream, without automatic line flushing, with the + * specified file. This convenience constructor creates the necessary + * intermediate {@link java.io.OutputStreamWriter OutputStreamWriter}, + * which will encode characters using the {@linkplain + * java.nio.charset.Charset#defaultCharset() default charset} for this + * instance of the Java virtual machine. + * + * @param file + * The file to use as the destination of this print stream. If the + * file exists, then it will be truncated to zero size; otherwise, + * a new file will be created. The output will be written to the + * file and is buffered. + * + * @throws FileNotFoundException + * If the given file object does not denote an existing, writable + * regular file and a new regular file of that name cannot be + * created, or if some other error occurs while opening or + * creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(file.getPath())} + * denies write access to the file + * + * @since 1.5 + */ + public PrintStream(File file) throws FileNotFoundException { + this(false, new FileOutputStream(file)); + init(new OutputStreamWriter(this)); + } + + /** + * Creates a new print stream, without automatic line flushing, with the + * specified file and charset. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param file + * The file to use as the destination of this print stream. If the + * file exists, then it will be truncated to zero size; otherwise, + * a new file will be created. The output will be written to the + * file and is buffered. + * + * @param csn + * The name of a supported {@linkplain java.nio.charset.Charset + * charset} + * + * @throws FileNotFoundException + * If the given file object does not denote an existing, writable + * regular file and a new regular file of that name cannot be + * created, or if some other error occurs while opening or + * creating the file + * + * @throws SecurityException + * If a security manager is presentand {@link + * SecurityManager#checkWrite checkWrite(file.getPath())} + * denies write access to the file + * + * @throws UnsupportedEncodingException + * If the named charset is not supported + * + * @since 1.5 + */ + public PrintStream(File file, String csn) + throws FileNotFoundException, UnsupportedEncodingException + { + this(false, new FileOutputStream(file)); + init(new OutputStreamWriter(this, csn)); + } + + /** Check to make sure that the stream has not been closed */ + private void ensureOpen() throws IOException { + if (out == null) + throw new IOException("Stream closed"); + } + + /** + * Flushes the stream. This is done by writing any buffered output bytes to + * the underlying output stream and then flushing that stream. + * + * @see java.io.OutputStream#flush() + */ + public void flush() { + synchronized (this) { + try { + ensureOpen(); + out.flush(); + } + catch (IOException x) { + trouble = true; + } + } + } + + private boolean closing = false; /* To avoid recursive closing */ + + /** + * Closes the stream. This is done by flushing the stream and then closing + * the underlying output stream. + * + * @see java.io.OutputStream#close() + */ + public void close() { + synchronized (this) { + if (! closing) { + closing = true; + try { + textOut.close(); + out.close(); + } + catch (IOException x) { + trouble = true; + } + textOut = null; + charOut = null; + out = null; + } + } + } + + /** + * Flushes the stream and checks its error state. The internal error state + * is set to <code>true</code> when the underlying output stream throws an + * <code>IOException</code> other than <code>InterruptedIOException</code>, + * and when the <code>setError</code> method is invoked. If an operation + * on the underlying output stream throws an + * <code>InterruptedIOException</code>, then the <code>PrintStream</code> + * converts the exception back into an interrupt by doing: + * <pre> + * Thread.currentThread().interrupt(); + * </pre> + * or the equivalent. + * + * @return <code>true</code> if and only if this stream has encountered an + * <code>IOException</code> other than + * <code>InterruptedIOException</code>, or the + * <code>setError</code> method has been invoked + */ + public boolean checkError() { + if (out != null) + flush(); + if (out instanceof java.io.PrintStream) { + PrintStream ps = (PrintStream) out; + return ps.checkError(); + } + return trouble; + } + + /** + * Sets the error state of the stream to <code>true</code>. + * + * <p> This method will cause subsequent invocations of {@link + * #checkError()} to return <tt>true</tt> until {@link + * #clearError()} is invoked. + * + * @since JDK1.1 + */ + protected void setError() { + trouble = true; + } + + /** + * Clears the internal error state of this stream. + * + * <p> This method will cause subsequent invocations of {@link + * #checkError()} to return <tt>false</tt> until another write + * operation fails and invokes {@link #setError()}. + * + * @since 1.6 + */ + protected void clearError() { + trouble = false; + } + + /* + * Exception-catching, synchronized output operations, + * which also implement the write() methods of OutputStream + */ + + /** + * Writes the specified byte to this stream. If the byte is a newline and + * automatic flushing is enabled then the <code>flush</code> method will be + * invoked. + * + * <p> Note that the byte is written as given; to write a character that + * will be translated according to the platform's default character + * encoding, use the <code>print(char)</code> or <code>println(char)</code> + * methods. + * + * @param b The byte to be written + * @see #print(char) + * @see #println(char) + */ + public void write(int b) { + try { + synchronized (this) { + ensureOpen(); + out.write(b); + if ((b == '\n') && autoFlush) + out.flush(); + } + } + catch (InterruptedIOException x) { + Thread.currentThread().interrupt(); + } + catch (IOException x) { + trouble = true; + } + } + + /** + * Writes <code>len</code> bytes from the specified byte array starting at + * offset <code>off</code> to this stream. If automatic flushing is + * enabled then the <code>flush</code> method will be invoked. + * + * <p> Note that the bytes will be written as given; to write characters + * that will be translated according to the platform's default character + * encoding, use the <code>print(char)</code> or <code>println(char)</code> + * methods. + * + * @param buf A byte array + * @param off Offset from which to start taking bytes + * @param len Number of bytes to write + */ + public void write(byte buf[], int off, int len) { + try { + synchronized (this) { + ensureOpen(); + out.write(buf, off, len); + if (autoFlush) + out.flush(); + } + } + catch (InterruptedIOException x) { + Thread.currentThread().interrupt(); + } + catch (IOException x) { + trouble = true; + } + } + + /* + * The following private methods on the text- and character-output streams + * always flush the stream buffers, so that writes to the underlying byte + * stream occur as promptly as with the original PrintStream. + */ + + private void write(char buf[]) { + try { + synchronized (this) { + ensureOpen(); + textOut.write(buf); + textOut.flushBuffer(); + charOut.flushBuffer(); + if (autoFlush) { + for (int i = 0; i < buf.length; i++) + if (buf[i] == '\n') + out.flush(); + } + } + } + catch (InterruptedIOException x) { + Thread.currentThread().interrupt(); + } + catch (IOException x) { + trouble = true; + } + } + + private void write(String s) { + try { + synchronized (this) { + ensureOpen(); + textOut.write(s); + textOut.flushBuffer(); + charOut.flushBuffer(); + if (autoFlush && (s.indexOf('\n') >= 0)) + out.flush(); + } + } + catch (InterruptedIOException x) { + Thread.currentThread().interrupt(); + } + catch (IOException x) { + trouble = true; + } + } + + private void newLine() { + try { + synchronized (this) { + ensureOpen(); + textOut.newLine(); + textOut.flushBuffer(); + charOut.flushBuffer(); + if (autoFlush) + out.flush(); + } + } + catch (InterruptedIOException x) { + Thread.currentThread().interrupt(); + } + catch (IOException x) { + trouble = true; + } + } + + /* Methods that do not terminate lines */ + + /** + * Prints a boolean value. The string produced by <code>{@link + * java.lang.String#valueOf(boolean)}</code> is translated into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the + * <code>{@link #write(int)}</code> method. + * + * @param b The <code>boolean</code> to be printed + */ + public void print(boolean b) { + write(b ? "true" : "false"); + } + + /** + * Prints a character. The character is translated into one or more bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the + * <code>{@link #write(int)}</code> method. + * + * @param c The <code>char</code> to be printed + */ + public void print(char c) { + write(String.valueOf(c)); + } + + /** + * Prints an integer. The string produced by <code>{@link + * java.lang.String#valueOf(int)}</code> is translated into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the + * <code>{@link #write(int)}</code> method. + * + * @param i The <code>int</code> to be printed + * @see java.lang.Integer#toString(int) + */ + public void print(int i) { + write(String.valueOf(i)); + } + + /** + * Prints a long integer. The string produced by <code>{@link + * java.lang.String#valueOf(long)}</code> is translated into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the + * <code>{@link #write(int)}</code> method. + * + * @param l The <code>long</code> to be printed + * @see java.lang.Long#toString(long) + */ + public void print(long l) { + write(String.valueOf(l)); + } + + /** + * Prints a floating-point number. The string produced by <code>{@link + * java.lang.String#valueOf(float)}</code> is translated into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the + * <code>{@link #write(int)}</code> method. + * + * @para... [truncated message content] |
From: <cr...@us...> - 2009-03-22 02:02:12
|
Revision: 5140 http://jnode.svn.sourceforge.net/jnode/?rev=5140&view=rev Author: crawley Date: 2009-03-22 02:02:07 +0000 (Sun, 22 Mar 2009) Log Message: ----------- Javadocs and FIXMEs Modified Paths: -------------- trunk/core/src/core/org/jnode/util/AccessControllerUtils.java trunk/core/src/core/org/jnode/util/BooleanUtils.java trunk/core/src/core/org/jnode/util/ByteBufferInputStream.java trunk/core/src/core/org/jnode/util/ByteQueue.java trunk/gui/src/driver/org/jnode/driver/ps2/PS2ByteChannel.java trunk/gui/src/driver/org/jnode/driver/ps2/PS2Driver.java Modified: trunk/core/src/core/org/jnode/util/AccessControllerUtils.java =================================================================== --- trunk/core/src/core/org/jnode/util/AccessControllerUtils.java 2009-03-21 14:59:56 UTC (rev 5139) +++ trunk/core/src/core/org/jnode/util/AccessControllerUtils.java 2009-03-22 02:02:07 UTC (rev 5140) @@ -33,8 +33,8 @@ * Calls AccessController.doPrivileged and unwraps any exception wrapped * in the PrivilegedActionException. * - * @param action - * @return + * @param action a typed action + * @return an instance of the action's type. * @throws Exception */ public static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws Exception { Modified: trunk/core/src/core/org/jnode/util/BooleanUtils.java =================================================================== --- trunk/core/src/core/org/jnode/util/BooleanUtils.java 2009-03-21 14:59:56 UTC (rev 5139) +++ trunk/core/src/core/org/jnode/util/BooleanUtils.java 2009-03-22 02:02:07 UTC (rev 5140) @@ -26,10 +26,11 @@ public class BooleanUtils { /** - * Returns true if value equals "true", "on", "yes" or "1". + * Returns {@code true} if value equals "true", "on", "yes" or "1". * - * @param value Can be null - * @return + * @param value A string value to be interpreted as a boolean, or {@code null} + * which will be mapped to {@code false}. + * @return the value's boolean interpretation. */ public static boolean valueOf(String value) { if (value == null) { Modified: trunk/core/src/core/org/jnode/util/ByteBufferInputStream.java =================================================================== --- trunk/core/src/core/org/jnode/util/ByteBufferInputStream.java 2009-03-21 14:59:56 UTC (rev 5139) +++ trunk/core/src/core/org/jnode/util/ByteBufferInputStream.java 2009-03-22 02:02:07 UTC (rev 5140) @@ -24,6 +24,10 @@ import java.io.InputStream; import java.nio.ByteBuffer; +/** + * @author epr + * @author Andrei DORE + */ public class ByteBufferInputStream extends InputStream { private final ByteBuffer buf; @@ -31,10 +35,7 @@ this.buf = buf; } - /** - * @Override - * @see java.io.InputStream#read() - */ + @Override public int read() throws IOException { if (buf.remaining() > 0) { return buf.get() & 0xFF; @@ -44,9 +45,6 @@ } @Override - /** - * @author Andrei DORE - */ public int available() throws IOException { return buf.remaining(); } Modified: trunk/core/src/core/org/jnode/util/ByteQueue.java =================================================================== --- trunk/core/src/core/org/jnode/util/ByteQueue.java 2009-03-21 14:59:56 UTC (rev 5139) +++ trunk/core/src/core/org/jnode/util/ByteQueue.java 2009-03-22 02:02:07 UTC (rev 5140) @@ -21,14 +21,20 @@ package org.jnode.util; /** - * ByteQueue.java - * <p/> - * a simple fixed-length Queue. + * A simple fixed-length Queue for buffering bytes. This queue is designed to + * never block on the input side. If the queue is full when 'push' is called, + * a byte will be discarded from the head of the queue to make space at the + * tail for the new byte. * * @author epr */ public class ByteQueue { - + // FIXME ... Looking at the way this class is used, I think it may needs an + // atomic drain operation and/or a close operation. + + /** + * The default queue size. + */ static final int Q_SIZE = 10; private final byte[] data; @@ -36,15 +42,28 @@ private int top = 0; private int bottom = 0; + /** + * Create a queue with the default size. + */ public ByteQueue() { this(Q_SIZE); } + /** + * Create a queue with the supplied size. + * @param size the queue size in bytes; should be >= 1. + */ public ByteQueue(int size) { this.data = new byte[size + 1]; this.size = size; } + /** + * Add a byte at the tail of the queue. This method does not block. + * If the queue is full when 'push' is called, space for the byte is + * made by removing (and discarding) the byte at the head of the queue. + * @param o the byte to be added to the queue. + */ public synchronized void push(byte o) { data[bottom] = o; bottom++; @@ -60,12 +79,20 @@ notifyAll(); } + /** + * Remove a byte from the head of the queue, blocking until one becomes + * available. If the thread calling this method is interrupted while waiting + * for data, the method returns a zero byte. + * + * @return the byte removed, or zero if the method call was interrupted. + */ public synchronized byte pop() { while (top == bottom) { /* Q is empty */ try { wait(); } catch (InterruptedException ie) { - // TODO: better throw a NoSuchElementException or alike!!! + // FIXME ... this approach to handling interrupts is broken. The + // exception should be allowed to propagate return 0; } } /* wait for push to fill Q */ @@ -79,6 +106,17 @@ return r; } + /** + * Remove a byte from the head of the queue, blocking with a timeout if data is + * not immediately available. Unlike {@link #pop()}, this method does <b>not</b> + * return zero when interrupted! + * + * @param timeout the maximum time (in milliseconds) to wait for data to become + * available. If zero, the method will wait as long as necessary. + * @return the byte removed from the queue. + * @throw InterruptedException if the method call is interrupted. + * @throw TimeoutException if no data is available within the required time. + */ public synchronized byte pop(long timeout) throws TimeoutException, InterruptedException { while (top == bottom) { /* Q is empty */ @@ -98,13 +136,16 @@ } /** - * Wait until there is data in the queue and return the first - * element, without removing it. + * Return the byte at the head of the queue without removing it. If data is + * not immediately available, the method will block (with a timeout) until + * data is available. Unlike {@link #pop()}, this method does <b>not</b> + * return zero when interrupted! * - * @param timeout - * @return - * @throws TimeoutException - * @throws InterruptedException + * @param timeout the maximum time (in milliseconds) to wait for data to become + * available. If zero, the method will wait as long as necessary. + * @return the byte removed from the queue. + * @throw InterruptedException if the method call is interrupted. + * @throw TimeoutException if no data is available within the required time. */ public synchronized byte peek(long timeout) throws TimeoutException, InterruptedException { @@ -117,7 +158,13 @@ return data[top]; } + /** + * Test if there is no data in the queue. + * @return {@code true} if the queue is empty, {@code false} otherwise. + */ public boolean isEmpty() { + // FIXME ... this should be synchronized. return (top == bottom); } + } Modified: trunk/gui/src/driver/org/jnode/driver/ps2/PS2ByteChannel.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/ps2/PS2ByteChannel.java 2009-03-21 14:59:56 UTC (rev 5139) +++ trunk/gui/src/driver/org/jnode/driver/ps2/PS2ByteChannel.java 2009-03-22 02:02:07 UTC (rev 5140) @@ -55,7 +55,7 @@ throw new ClosedChannelException(); } - // ToDo: proper exception handling (if end of queue -> IOException) + // FIXME: proper exception handling (if end of queue -> IOException) int i; for (i = 0; i < dst.remaining(); i++) { dst.put(queue.pop()); @@ -116,6 +116,8 @@ * Remove all data from this channel */ public void clear() { + // FIXME ... there is synchronization issues here. The 'isEmpty' method + // is not synchronized, so we may not see the real state of the queue. while (!queue.isEmpty()) { queue.pop(); } Modified: trunk/gui/src/driver/org/jnode/driver/ps2/PS2Driver.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/ps2/PS2Driver.java 2009-03-21 14:59:56 UTC (rev 5139) +++ trunk/gui/src/driver/org/jnode/driver/ps2/PS2Driver.java 2009-03-22 02:02:07 UTC (rev 5140) @@ -59,11 +59,8 @@ */ protected synchronized void startDevice() throws DriverException { init(); - getDevice().registerAPI(CharacterDeviceAPI.class, this); // make sure - // it's at - // least a - // character - // device + // Make sure it's at least a character device + getDevice().registerAPI(CharacterDeviceAPI.class, this); } /** @@ -89,7 +86,7 @@ throw new ClosedChannelException(); } - // ToDo: proper exception handling (if end of queue -> IOException) + // FIXME: proper exception handling (if end of queue -> IOException) int i; for (i = 0; i < dst.remaining(); i++) { dst.put(queue.pop()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-03-24 14:22:50
|
Revision: 5149 http://jnode.svn.sourceforge.net/jnode/?rev=5149&view=rev Author: crawley Date: 2009-03-24 13:40:22 +0000 (Tue, 24 Mar 2009) Log Message: ----------- Javadoc fixes Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/scheduler/VmProcessor.java trunk/fs/src/fs/org/jnode/fs/ext2/BlockReservation.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2DirectoryRecord.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Utils.java trunk/fs/src/fs/org/jnode/fs/ext2/GroupDescriptor.java trunk/fs/src/fs/org/jnode/fs/ext2/INode.java trunk/fs/src/fs/org/jnode/fs/ext2/INodeReservation.java trunk/fs/src/fs/org/jnode/fs/ext2/Superblock.java trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemFormatter.java trunk/fs/src/fs/org/jnode/fs/fat/FatUtils.java Modified: trunk/core/src/core/org/jnode/vm/scheduler/VmProcessor.java =================================================================== --- trunk/core/src/core/org/jnode/vm/scheduler/VmProcessor.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/core/src/core/org/jnode/vm/scheduler/VmProcessor.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -205,7 +205,7 @@ /** * Get the processor that the current thread is running on. * - * @return + * @return the current processor */ @Inline @org.jnode.vm.annotation.Uninterruptible Modified: trunk/fs/src/fs/org/jnode/fs/ext2/BlockReservation.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/BlockReservation.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/BlockReservation.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -84,7 +84,7 @@ /** * Returns how many free blocks are in the block group * - * @return + * @return the free block count */ public long getFreeBlocksCount() { return freeBlocksCount; Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Directory.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -415,7 +415,7 @@ * Read the entries from the device and return the result in a new * FSEntryTable * - * @return + * @return the FSEntryTable containing the directory's entries. */ protected FSEntryTable readEntries() throws IOException { Ext2FSEntryIterator it = new Ext2FSEntryIterator(iNode); Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2DirectoryRecord.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2DirectoryRecord.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2DirectoryRecord.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -43,10 +43,10 @@ private Ext2FileSystem fs; /** - * @param data: the data that makes up the directory block - * @param offset: the offset where the current DirectoryRecord begins within + * @param data the data that makes up the directory block + * @param offset the offset where the current DirectoryRecord begins within * the block - * @param fileOffset: the offset from the beginning of the directory file + * @param fileOffset the offset from the beginning of the directory file */ public Ext2DirectoryRecord(Ext2FileSystem fs, byte[] data, int offset, int fileOffset) { this.fs = fs; @@ -196,8 +196,8 @@ * length. The directoryRecord's <code>fileOffset</code> will be set to * <code>beginning</code>. * - * @param beginning: the offset where the record begins - * @param end: the offset where the record should end (usually the size a + * @param beginning the offset where the record begins + * @param end the offset where the record should end (usually the size a * filesystem block) */ protected synchronized void expandRecord(long beginning, long end) throws FileSystemException { Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2File.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -164,9 +164,8 @@ } /** - * @see org.jnode.fs.FSFile#read(long, byte[], int, int) + * @see org.jnode.fs.FSFile#read(long, ByteBuffer) */ - //public void read(long fileOffset, byte[] dest, int off, int len) public void read(long fileOffset, ByteBuffer destBuf) throws IOException { final int len = destBuf.remaining(); final int off = 0; @@ -234,9 +233,8 @@ * methods write(byte[], int, int), setPosition(long), setLength(long) in * org.jnode.fs.service.def.FileHandleImpl) * - * @see org.jnode.fs.FSFile#write(long, byte[], int, int) + * @see org.jnode.fs.FSFile#write(long, ByteBuffer) */ - //public void write(long fileOffset, byte[] src, int off, int len) public void write(long fileOffset, ByteBuffer srcBuf) throws IOException { final int len = srcBuf.remaining(); final int off = 0; Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -371,9 +371,9 @@ /** * Update the block in cache, or write the block to disk * - * @param nr: block number - * @param data: block data - * @param forceWrite: if forceWrite is false, the block is only updated in + * @param nr block number + * @param data block data + * @param forceWrite if forceWrite is false, the block is only updated in * the cache (if it was in the cache). If forceWrite is true, or * the block is not in the cache, write it to disk. * @throws IOException @@ -416,7 +416,7 @@ } } - /** + /* * Helper class for timedWrite * * @author blind @@ -511,7 +511,7 @@ * allocates it with preallocation. * * @param blockNr - * @return + * @return the block reservation * @throws IOException */ public BlockReservation testAndSetBlock(long blockNr) throws IOException { @@ -557,9 +557,9 @@ /** * Create a new INode * - * @param preferredBlockBroup: first try to allocate the inode in this block + * @param preferredBlockBroup first try to allocate the inode in this block * group - * @return + * @return the INode */ protected INode createINode(int preferredBlockBroup, int fileFormat, int accessRights, int uid, int gid) throws FileSystemException, IOException { @@ -612,7 +612,7 @@ * Find a free INode in the inode bitmap and allocate it * * @param blockGroup - * @return + * @return the INode reservation * @throws IOException */ protected INodeReservation findFreeINode(int blockGroup) throws IOException { @@ -812,7 +812,7 @@ * (S_FEATURE_RO_COMPAT) * * @param mask - * @return + * @return {@code true} if the filesystem uses the feature, otherwise {@code false}. */ protected boolean hasROFeature(long mask) { return (mask & superblock.getFeatureROCompat()) != 0; @@ -823,7 +823,7 @@ * (S_FEATURE_INCOMPAT) * * @param mask - * @return + * @return {@code true} if the filesystem uses the feature, otherwise {@code false}. */ protected boolean hasIncompatFeature(long mask) { return (mask & superblock.getFeatureIncompat()) != 0; Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemFormatter.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -34,8 +34,8 @@ private BlockSize blockSize; /** - * - * @param blockSizeKb size of blocks in KB + * + * @param blockSize size of blocks in KB */ public Ext2FileSystemFormatter(BlockSize blockSize) { super(new Ext2FileSystemType()); Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystemType.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -54,7 +54,7 @@ } /** - * @see org.jnode.fs.FileSystemType#supports(PartitionTableEntry, byte[], FSBlockDeviceAPI) + * @see org.jnode.fs.BlockDeviceFileSystemType#supports(PartitionTableEntry, byte[], FSBlockDeviceAPI) */ public boolean supports(PartitionTableEntry pte, byte[] firstSector, FSBlockDeviceAPI devApi) { if (pte != null) { Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Utils.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Utils.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2Utils.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -34,7 +34,7 @@ * * @param a * @param b - * @return + * @return the result of the computation */ public static long ceilDiv(long a, long b) { return (int) ((a + b - 1) / b); @@ -109,9 +109,8 @@ } /** - * - * @param time - * @return + * @param time the time in seconds since the UNIX epoch + * @return the decoded time in a {@link Calendar} */ public static Calendar decodeDate(long time) { Calendar ref = Calendar.getInstance(); @@ -122,9 +121,8 @@ } /** - * - * @param time - * @return + * @param date the time encoded as a {@link Date} + * @return the time in seconds since the UNIX epocj */ public static long encodeDate(Date date) { Calendar ref = Calendar.getInstance(); Modified: trunk/fs/src/fs/org/jnode/fs/ext2/GroupDescriptor.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/GroupDescriptor.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/GroupDescriptor.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -210,7 +210,7 @@ } /** - * @return + * @return the dirty flag for the descriptor */ public boolean isDirty() { return dirty; Modified: trunk/fs/src/fs/org/jnode/fs/ext2/INode.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/INode.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -94,7 +94,7 @@ setMtime(time); setDtime(0); setLinksCount(0); - //TODO: set other pesistent parameters? + //TODO: set other persistent parameters? setDirty(true); @@ -144,7 +144,7 @@ /** * Return the number of the group that contains the inode. * - * @return + * @return the group number */ protected long getGroup() { return desc.getGroup(); @@ -157,7 +157,7 @@ /** * return the number of direct blocks that an indirect block can point to * - * @return + * @return the count */ private final int getIndirectCount() { return fs.getSuperblock().getBlockSize() >> 2; //a block index is 4 @@ -173,8 +173,8 @@ * direct blocks, getIndirectCount() simple indirect blocks, * getIndirectCount()^2 double indirect blocks, 45th triple indirect block). * - * @param indirectionLevel: - * 0: direct block, 1: indirect block, ... + * @param indirectionLevel 0 is a direct block, 1 is a simple indirect block, and + * so on. */ private final long indirectRead(long dataBlockNr, long offset, int indirectionLevel) throws IOException { @@ -195,7 +195,7 @@ * register the address of the <code>offset</code> th block. Also see * indirectRead(). * - * @param allocatedBlocks: + * @param allocatedBlocks * (the number of blocks allocated so far)-1 */ private final void indirectWrite(long dataBlockNr, long offset, long allocatedBlocks, @@ -276,8 +276,8 @@ * a block] * * @param i - * @return @throws - * IOException + * @return the block number + * @throws IOException */ private long getDataBlockNr(long i) throws IOException { final long blockCount = getAllocatedBlockCount(); @@ -324,8 +324,8 @@ * beginning of the file, and not an absolute block number) * * @param i - * @return @throws - * IOException + * @return the data block + * @throws IOException */ public byte[] getDataBlock(long i) throws IOException { return fs.getBlock(getDataBlockNr(i)); @@ -585,7 +585,7 @@ * case, it is not counted by getSizeInBlocks(), because it returns the size * of the file in blocks, counting only written bytes * - * @return + * @return the count */ protected long getAllocatedBlockCount() { if (desc.getLastAllocatedBlockIndex() != -1) { @@ -598,6 +598,7 @@ /** * Allocate the ith data block of the inode (i is a sequential index from * the beginning of the file, and not an absolute block number) + * @param i */ public synchronized void allocateDataBlock(long i) throws FileSystemException, IOException { if (i < getAllocatedBlockCount()) { @@ -625,7 +626,7 @@ * should be the one that follows the last allocated block (that's why the * <code>index</code> parameter is needed). * - * @param index: + * @param index * the block to be found should be around the (index-1)th block * of the inode (which is already allocated, unless index==0) */ @@ -772,7 +773,7 @@ * Return the size in ext2-blocks (getBlocks() returns the size in 512-byte * blocks, but an ext2 block can be of different size). * - * @return + * @return the size */ public long getSizeInBlocks() { return Ext2Utils.ceilDiv(getSize(), getExt2FileSystem().getBlockSize()); Modified: trunk/fs/src/fs/org/jnode/fs/ext2/INodeReservation.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/INodeReservation.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/INodeReservation.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -39,7 +39,7 @@ * Results of an attempt to reserve an inode in a block group. * * @param successful - * @param index: begins at index 0 (shows the index in the inode bitmap and + * @param index begins at index 0 (shows the index in the inode bitmap and * inode table). The actual inode number is * <code>INODEX_PER_GROUP*groupNr + index + 1</code>, as * inodes begin at 1 (this is what getInodeNr(groupNr) returns) @@ -55,7 +55,7 @@ } /** - * Returns the successful. + * Returns the successful flag. * * @return boolean */ @@ -64,7 +64,7 @@ } /** - * @return + * @return the group number */ public int getGroup() { return group; @@ -78,7 +78,7 @@ } /** - * @return + * @return the index */ public int getIndex() { return index; Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Superblock.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Superblock.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Superblock.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -693,7 +693,7 @@ } /** - * @return + * @return the Superblock's dirty flag */ public boolean isDirty() { return dirty; Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemFormatter.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemFormatter.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/fat/FatFileSystemFormatter.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -51,8 +51,8 @@ /** * - * @param device - * @return + * @param device a device that supports the {@link FSBlockDeviceAPI}. + * @return the formatted FAT file system. * @throws FileSystemException */ public FatFileSystem format(Device device) throws FileSystemException { Modified: trunk/fs/src/fs/org/jnode/fs/fat/FatUtils.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/fat/FatUtils.java 2009-03-24 12:32:31 UTC (rev 5148) +++ trunk/fs/src/fs/org/jnode/fs/fat/FatUtils.java 2009-03-24 13:40:22 UTC (rev 5149) @@ -89,7 +89,7 @@ * Return the name (without extension) of a full file name * * @param nameExt - * @return + * @return the name part */ public static String splitName(String nameExt) { int i = nameExt.indexOf('.'); @@ -104,7 +104,7 @@ * Return the extension (without name) of a full file name * * @param nameExt - * @return + * @return the extension part */ public static String splitExt(String nameExt) { int i = nameExt.indexOf('.'); @@ -118,9 +118,9 @@ /** * Normalize full file name in DOS 8.3 format from the name and the ext * - * @param name - * @param ext - * @return + * @param name a DOS 8 name + * @param ext a DOS 3 extension + * @return the normalized DOS 8.3 name */ public static String normalizeName(String name, String ext) { if (ext.length() > 0) { @@ -133,8 +133,8 @@ /** * Normalize full file name in DOS 8.3 format from the given full name * - * @param nameExt - * @return + * @param nameExt a DOS 8.3 name + extension + * @return the normalized DOS 8.3 name */ public static String normalizeName(String nameExt) { if (nameExt.equals(".")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-03-25 14:02:32
|
Revision: 5154 http://jnode.svn.sourceforge.net/jnode/?rev=5154&view=rev Author: crawley Date: 2009-03-25 14:02:21 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Javadoc fixes Modified Paths: -------------- trunk/core/src/classpath/gnu/gnu/java/awt/ClasspathToolkit.java trunk/core/src/classpath/gnu/gnu/java/awt/peer/ClasspathFontPeer.java trunk/fs/src/driver/org/jnode/driver/block/scsi/cdrom/SCSICDROMDriver.java trunk/gui/src/awt/org/jnode/awt/JNodeAwtContext.java trunk/gui/src/awt/org/jnode/awt/JNodeGenericPeer.java trunk/gui/src/awt/org/jnode/awt/font/FontProvider.java trunk/gui/src/awt/org/jnode/awt/font/JNodeFontPeer.java trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFFontProvider.java Modified: trunk/core/src/classpath/gnu/gnu/java/awt/ClasspathToolkit.java =================================================================== --- trunk/core/src/classpath/gnu/gnu/java/awt/ClasspathToolkit.java 2009-03-25 13:09:26 UTC (rev 5153) +++ trunk/core/src/classpath/gnu/gnu/java/awt/ClasspathToolkit.java 2009-03-25 14:02:21 UTC (rev 5154) @@ -90,7 +90,7 @@ * * <p>This method is specific to GNU Classpath. It gets called by * the Classpath implementation of {@link - * GraphicsEnvironment.getLocalGraphcisEnvironment()}. + * GraphicsEnvironment#getLocalGraphicsEnvironment()}. */ public abstract GraphicsEnvironment getLocalGraphicsEnvironment(); Modified: trunk/core/src/classpath/gnu/gnu/java/awt/peer/ClasspathFontPeer.java =================================================================== --- trunk/core/src/classpath/gnu/gnu/java/awt/peer/ClasspathFontPeer.java 2009-03-25 13:09:26 UTC (rev 5153) +++ trunk/core/src/classpath/gnu/gnu/java/awt/peer/ClasspathFontPeer.java 2009-03-25 14:02:21 UTC (rev 5154) @@ -619,9 +619,9 @@ public abstract boolean canDisplay (Font font, char c); /** - * Implementation of {@link Font#canDisplay(String)}, - * {@link Font#canDisplay(char [], int, int)}, and - * {@link Font#canDisplay(CharacterIterator, int, int)}. + * Implementation of {@link Font#canDisplayUpTo(String)}, + * {@link Font#canDisplayUpTo(char [], int, int)}, and + * {@link Font#canDisplayUpTo(CharacterIterator, int, int)}. * * @param font the font this peer is being called from. This may be * useful if you are sharing peers between Font objects. Otherwise it may @@ -757,8 +757,7 @@ /** - * Implementation of {@link Font#createGlyphVector(FontRenderContext, - * int[])}. + * Implementation of {@link Font#createGlyphVector(FontRenderContext, int[])}. * * @param font the font object that the created GlyphVector will return * when it gets asked for its font. This argument is needed because the @@ -788,8 +787,6 @@ /** - * Implementation of {@link Font#getFontMetrics()} - * * @param font the font this peer is being called from. This may be * useful if you are sharing peers between Font objects. Otherwise it may * be ignored. Modified: trunk/fs/src/driver/org/jnode/driver/block/scsi/cdrom/SCSICDROMDriver.java =================================================================== --- trunk/fs/src/driver/org/jnode/driver/block/scsi/cdrom/SCSICDROMDriver.java 2009-03-25 13:09:26 UTC (rev 5153) +++ trunk/fs/src/driver/org/jnode/driver/block/scsi/cdrom/SCSICDROMDriver.java 2009-03-25 14:02:21 UTC (rev 5154) @@ -55,9 +55,6 @@ this.blockAlignment = new FSBlockAlignmentSupport(this, 2048); } - /** - * @see org.jnode.driver.Driver#startDevice() - */ protected void startDevice() throws DriverException { this.locked = false; this.changed = true; @@ -70,9 +67,6 @@ dev.registerAPI(FSBlockDeviceAPI.class, blockAlignment); } - /** - * @see org.jnode.driver.Driver#stopDevice() - */ protected void stopDevice() throws DriverException { try { unlock(); @@ -86,39 +80,24 @@ } } - /** - * @see org.jnode.driver.block.FSBlockDeviceAPI#getPartitionTableEntry() - */ public PartitionTableEntry getPartitionTableEntry() { return null; } - /** - * @see org.jnode.driver.block.FSBlockDeviceAPI#getSectorSize() - */ public int getSectorSize() throws IOException { processChanged(); return capacity.getBlockLength(); } - /** - * @see org.jnode.driver.block.BlockDeviceAPI#flush() - */ public void flush() throws IOException { // Do nothing } - /** - * @see org.jnode.driver.block.BlockDeviceAPI#getLength() - */ public long getLength() throws IOException { processChanged(); return capacity.getBlockLength() & capacity.getLogicalBlockAddress(); } - /** - * @see org.jnode.driver.block.BlockDeviceAPI#read(long, byte[], int, int) - */ public void read(long devOffset, ByteBuffer destBuf) throws IOException { //TODO optimize it also to use ByteBuffer at lower level @@ -152,9 +131,6 @@ destBA.refreshByteBuffer(); } - /** - * @see org.jnode.driver.block.BlockDeviceAPI#write(long, byte[], int, int) - */ public void write(long devOffset, ByteBuffer src) throws IOException { throw new IOException("Readonly device"); @@ -163,7 +139,7 @@ /** * Can this device be locked. * - * @return + * @return {@code true} if the device can be locked, otherwise {@code false}. */ public boolean canLock() { return true; @@ -172,7 +148,7 @@ /** * Can this device be ejected. * - * @return + * @return {@code true} if the device can be ejected, otherwise {@code false}. */ public boolean canEject() { return true; Modified: trunk/gui/src/awt/org/jnode/awt/JNodeAwtContext.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/JNodeAwtContext.java 2009-03-25 13:09:26 UTC (rev 5153) +++ trunk/gui/src/awt/org/jnode/awt/JNodeAwtContext.java 2009-03-25 14:02:21 UTC (rev 5154) @@ -33,14 +33,14 @@ /** * Gets the desktop pane that holds all the Frames. * - * @return + * @return the desktop pane */ public JDesktopPane getDesktop(); /** * Gets the root container of the screen, that holds the desktop. * - * @return + * @return the root container */ public JComponent getAwtRoot(); Modified: trunk/gui/src/awt/org/jnode/awt/JNodeGenericPeer.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/JNodeGenericPeer.java 2009-03-25 13:09:26 UTC (rev 5153) +++ trunk/gui/src/awt/org/jnode/awt/JNodeGenericPeer.java 2009-03-25 14:02:21 UTC (rev 5154) @@ -36,7 +36,7 @@ } /** - * @return + * @return the target component */ public final compT getTargetComponent() { return this.targetComponent; Modified: trunk/gui/src/awt/org/jnode/awt/font/FontProvider.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/FontProvider.java 2009-03-25 13:09:26 UTC (rev 5153) +++ trunk/gui/src/awt/org/jnode/awt/font/FontProvider.java 2009-03-25 14:02:21 UTC (rev 5154) @@ -87,25 +87,25 @@ * Translates the font into a font that is provided by this provider. * * @param font - * @return + * @return the translated font */ public F getCompatibleFont(Font font); /** - * Creates a font peer from the given name or return null if not supported/provided. + * Creates a font peer from the given name or return {@code null} if not supported/provided. * As said in {@link org.jnode.awt.JNodeToolkit#getClasspathFontPeer(String, java.util.Map)} javadoc : * "We don't know what kind of "name" the user requested (logical, face, family)". * * @param name * @param attrs - * @return + * @return the font peer or {@code null}. */ public JNodeFontPeer<? extends FontProvider<F>, F> createFontPeer(String name, Map attrs); /** * Read and create a Font from the given InputStream * @param stream - * @return + * @return the font */ public F createFont(InputStream stream) throws FontFormatException, IOException; } Modified: trunk/gui/src/awt/org/jnode/awt/font/JNodeFontPeer.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/JNodeFontPeer.java 2009-03-25 13:09:26 UTC (rev 5153) +++ trunk/gui/src/awt/org/jnode/awt/font/JNodeFontPeer.java 2009-03-25 14:02:21 UTC (rev 5154) @@ -53,15 +53,8 @@ this.provider = provider; } - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#canDisplay(java.awt.Font, char) - */ public abstract boolean canDisplay(Font font, char c); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#canDisplayUpTo(java.awt.Font, - * java.text.CharacterIterator, int, int) - */ @Override public final int canDisplayUpTo(Font font, CharacterIterator i, int start, int limit) { int upTo = -1; @@ -76,93 +69,41 @@ return upTo; } - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#createGlyphVector(java.awt.Font, - * java.awt.font.FontRenderContext, java.text.CharacterIterator) - */ @Override public final GlyphVector createGlyphVector(Font font, FontRenderContext frc, CharacterIterator ci) { return TGlyphVector.create(font, frc, ci); } - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#createGlyphVector(java.awt.Font, - * java.awt.font.FontRenderContext, int[]) - */ @Override public final GlyphVector createGlyphVector(Font font, FontRenderContext ctx, int[] glyphCodes) { return new StandardGlyphVector(font, glyphCodes, ctx); } - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getBaselineFor(java.awt.Font, - * char) - */ public abstract byte getBaselineFor(Font font, char c); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getFontMetrics(java.awt.Font) - */ public abstract FontMetrics getFontMetrics(Font font); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getGlyphName(java.awt.Font, int) - */ public abstract String getGlyphName(Font font, int glyphIndex); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getLineMetrics(java.awt.Font, - * java.text.CharacterIterator, int, int, - * java.awt.font.FontRenderContext) - */ public abstract LineMetrics getLineMetrics(Font font, CharacterIterator ci, int begin, int limit, FontRenderContext rc); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getMaxCharBounds(java.awt.Font, - * java.awt.font.FontRenderContext) - */ public abstract Rectangle2D getMaxCharBounds(Font font, FontRenderContext rc); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getMissingGlyphCode(java.awt.Font) - */ public abstract int getMissingGlyphCode(Font font); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getNumGlyphs(java.awt.Font) - */ public abstract int getNumGlyphs(Font font); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getPostScriptName(java.awt.Font) - */ public abstract String getPostScriptName(Font font); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getStringBounds(java.awt.Font, - * java.text.CharacterIterator, int, int, - * java.awt.font.FontRenderContext) - */ public abstract Rectangle2D getStringBounds(Font font, CharacterIterator ci, int begin, int limit, FontRenderContext frc); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#getSubFamilyName(java.awt.Font, - * java.util.Locale) - */ public abstract String getSubFamilyName(Font font, Locale locale); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#hasUniformLineMetrics(java.awt.Font) - */ public abstract boolean hasUniformLineMetrics(Font font); - /** - * @see gnu.java.awt.peer.ClasspathFontPeer#layoutGlyphVector(java.awt.Font, - * java.awt.font.FontRenderContext, char[], int, int, int) - */ public abstract GlyphVector layoutGlyphVector(Font font, FontRenderContext frc, char[] chars, int start, int limit, int flags); @@ -174,7 +115,7 @@ * this peer's provider provides. * * @param font any instance of {@link Font} (might not be an instance of F) - * @return + * @return the Font */ protected final F getCompatibleFont(Font font) { return provider.getCompatibleFont(font); Modified: trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFFontProvider.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFFontProvider.java 2009-03-25 13:09:26 UTC (rev 5153) +++ trunk/gui/src/awt/org/jnode/awt/font/bdf/BDFFontProvider.java 2009-03-25 14:02:21 UTC (rev 5154) @@ -84,7 +84,7 @@ * * @param name * @param attrs - * @return + * @return the font peer */ @Override public BDFFontPeer createFontPeer(String name, Map attrs) { @@ -114,7 +114,7 @@ * Read an create a Font from the given InputStream * * @param stream - * @return + * @return the font */ @Override public BDFFont createFont(InputStream stream) throws FontFormatException, IOException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-03-26 13:55:21
|
Revision: 5158 http://jnode.svn.sourceforge.net/jnode/?rev=5158&view=rev Author: crawley Date: 2009-03-26 13:46:39 +0000 (Thu, 26 Mar 2009) Log Message: ----------- Fixed the last of the Javadoc warnings Modified Paths: -------------- trunk/core/src/classpath/vm/java/net/VMNetAPI.java trunk/gui/src/awt/org/jnode/awt/image/JNodeImageGraphics.java trunk/gui/src/desktop/org/jnode/desktop/DesktopPlugin.java trunk/gui/src/driver/org/jnode/driver/video/FrameBufferAPI.java trunk/gui/src/driver/org/jnode/driver/video/vgahw/VgaState.java trunk/net/src/driver/org/jnode/driver/net/NetDeviceEvent.java trunk/net/src/driver/org/jnode/driver/net/WirelessNetDeviceAPI.java trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100RxFD.java trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2CommFrame.java trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Constants.java trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessDeviceCore.java trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java trunk/net/src/net/org/jnode/net/NetworkLayer.java trunk/net/src/net/org/jnode/net/arp/ARPNetworkLayer.java trunk/net/src/net/org/jnode/net/ipv4/layer/IPv4NetworkLayer.java trunk/net/src/net/org/jnode/net/nfs/nfs2/NFS2Client.java trunk/net/src/net/org/jnode/net/nfs/nfs2/mount/Mount1Client.java trunk/net/src/net/org/jnode/net/wireless/p80211Header.java Modified: trunk/core/src/classpath/vm/java/net/VMNetAPI.java =================================================================== --- trunk/core/src/classpath/vm/java/net/VMNetAPI.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/core/src/classpath/vm/java/net/VMNetAPI.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -32,7 +32,7 @@ * Gets a network device by its name, or null if not found. * * @param name - * @return + * @return the device or {@code null} */ public VMNetDevice getByName(String name); @@ -47,13 +47,9 @@ /** * Return a network device by its address * - * @param addr - * The address of the interface to return - * - * @exception SocketException - * If an error occurs - * @exception NullPointerException - * If the specified addess is null + * @param addr The address of the interface to return + * @exception SocketException If an error occurs + * @exception NullPointerException If the specified address is {@code null} */ public VMNetDevice getByInetAddress(InetAddress addr) throws SocketException; @@ -75,7 +71,7 @@ /** * Gets the address of a host by its name. * @param hostname - * @return + * @return the address * @throws UnknownHostException */ public byte[][] getHostByName(String hostname) @@ -84,7 +80,7 @@ /** * Gets the name of a host by its address. * @param ip The host address. - * @return + * @return the host name * @throws UnknownHostException */ public String getHostByAddr(byte[] ip) Modified: trunk/gui/src/awt/org/jnode/awt/image/JNodeImageGraphics.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/image/JNodeImageGraphics.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/gui/src/awt/org/jnode/awt/image/JNodeImageGraphics.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -20,6 +20,8 @@ package org.jnode.awt.image; +import gnu.java.awt.java2d.AbstractGraphics2D; + import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.Shape; @@ -121,7 +123,7 @@ * Returns a WritableRaster that is used by this class to perform the * rendering in. It is not necessary that the target surface immediately * reflects changes in the raster. Updates to the raster are notified via - * {@link #updateRaster}. + * {@link AbstractGraphics2D#updateRaster}. * * @return the destination raster */ Modified: trunk/gui/src/desktop/org/jnode/desktop/DesktopPlugin.java =================================================================== --- trunk/gui/src/desktop/org/jnode/desktop/DesktopPlugin.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/gui/src/desktop/org/jnode/desktop/DesktopPlugin.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -40,22 +40,16 @@ /** * Gets the applications (apps) extensions point * - * @return + * @return the extension point */ public ExtensionPoint getAppsExtensionPoint() { return getDescriptor().getExtensionPoint("apps"); } - /** - * @see org.jnode.plugin.Plugin#startPlugin() - */ protected void startPlugin() throws PluginException { System.setProperty("jnode.desktop", "org.jnode.desktop.classic.Desktop"); } - /** - * @see org.jnode.plugin.Plugin#stopPlugin() - */ protected void stopPlugin() throws PluginException { // Nothing to do } Modified: trunk/gui/src/driver/org/jnode/driver/video/FrameBufferAPI.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/FrameBufferAPI.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/gui/src/driver/org/jnode/driver/video/FrameBufferAPI.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -62,7 +62,6 @@ * The old owner (if any) will receive a request to stop using the underlying FrameBuffer device. * * @param owner - * @return {@code true} if owner can now start using exclusively the underlying FrameBuffer device. */ public void requestOwnership(FrameBufferAPIOwner owner); @@ -70,7 +69,6 @@ * Request the ownership on the underlying FrameBuffer device. * * @param owner - * @return {@code true} if owner can now start using exclusively the underlying FrameBuffer device. */ public void releaseOwnership(FrameBufferAPIOwner owner); Modified: trunk/gui/src/driver/org/jnode/driver/video/vgahw/VgaState.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/vgahw/VgaState.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/gui/src/driver/org/jnode/driver/video/vgahw/VgaState.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -259,7 +259,7 @@ * Gets the length of the palette. * * @param io - * @return + * @return the palette size */ protected int getPaletteSize(VgaIO io) { return 256; @@ -388,9 +388,6 @@ } } - /** - * @see java.lang.Object#toString() - */ public String toString() { return "VGA[SEQ:" + NumberUtils.hex(seq, 2) + ", CRT:" + NumberUtils.hex(crt, 2) + ", GRA:" + NumberUtils.hex(gra, 2) + ", ATT:" + NumberUtils.hex(att, 2) + Modified: trunk/net/src/driver/org/jnode/driver/net/NetDeviceEvent.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/NetDeviceEvent.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/driver/org/jnode/driver/net/NetDeviceEvent.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -47,7 +47,7 @@ /** * Gets the device that it the source of this event. * - * @return + * @return the Device */ public final Device getDevice() { return (Device) getSource(); Modified: trunk/net/src/driver/org/jnode/driver/net/WirelessNetDeviceAPI.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/WirelessNetDeviceAPI.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/driver/org/jnode/driver/net/WirelessNetDeviceAPI.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -32,7 +32,7 @@ /** * Gets the current authentication mode. * - * @return + * @return the authentication mode */ public AuthenticationMode getAuthenticationMode(); Modified: trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -342,7 +342,7 @@ * @param owner * @param low * @param length - * @return + * @return the IOResource for the ports */ private IOResource claimPorts(final ResourceManager rm, final ResourceOwner owner, final int low, final int length) throws ResourceNotFreeException, DriverException { @@ -380,7 +380,7 @@ /** * @param cmd * @param cmdLength - * @return + * @return the return value */ final int doEepromCmd(int cmd, int cmdLength) { int retVal = 0; @@ -421,7 +421,7 @@ /** * @param phy_id * @param location - * @return + * @return the 16-bit word read */ public final int mdioRead(int phy_id, int location) { int val; @@ -443,7 +443,7 @@ * @param phy_id * @param location * @param value - * @return + * @return the control word */ public final int mdioWrite(int phy_id, int location, int value) { int val; Modified: trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100RxFD.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100RxFD.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100RxFD.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -45,14 +45,17 @@ * Offset within mem of first UDP */ private final int firstUPDOffset; + /** * Offset within mem of first ethernet frame */ private final int firstFrameOffset; + /** * 32-bit address first UDP */ private final Address firstUPDAddress; + /** * 32-bit address of first ethernet frame */ @@ -168,7 +171,7 @@ } /** - * @return + * @return data read from the device */ public byte[] getDataBuffer() { byte[] buf = new byte[DataBufferSize]; @@ -177,7 +180,7 @@ } /** - * @return + * @return a packet read from the device in a SocketBuffer */ public SocketBuffer getPacket() { int pktLen = this.getCount() & 0x3fff; Modified: trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2CommFrame.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2CommFrame.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2CommFrame.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -63,7 +63,7 @@ * * @param src * @param srcOffset - * @return + * @return the status */ public static final int getStatus(byte[] src, int srcOffset) { return LittleEndian.getUInt16(src, srcOffset); @@ -74,7 +74,7 @@ * * @param src * @param srcOffset - * @return + * @return the data length */ public static final int getDataLength(byte[] src, int srcOffset) { return LittleEndian.getUInt16(src, srcOffset + 58); Modified: trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Constants.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Constants.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Constants.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -190,17 +190,17 @@ /** * Gets the code value. * - * @return + * @return the code value */ public final int getCode() { return code; } /** - * Gets the result value by its code. + * Gets the Result value by its code. * * @param code - * @return + * @return the Result value */ public static final Result getByCode(int code) { for (Result r : Result.values()) { @@ -611,10 +611,10 @@ } /** - * Get the enum by its value. + * Get an InformationType by its value. * * @param value - * @return + * @return the InformationType */ public static InformationType getByValue(int value) { for (InformationType it : values()) { @@ -647,10 +647,10 @@ } /** - * Get the enum by its value. + * Get the LinkStatus by its value. * * @param value - * @return + * @return the LinkStatus */ public static LinkStatus getByValue(int value) { for (LinkStatus ls : values()) { Modified: trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessDeviceCore.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessDeviceCore.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessDeviceCore.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -38,7 +38,7 @@ /** * Gets the current authentication mode. * - * @return + * @return the authentication mode */ protected abstract AuthenticationMode getAuthenticationMode() throws DriverException; Modified: trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -78,7 +78,7 @@ /** * Gets the wireless device core. * - * @return + * @return the WirelessDeviceCore */ protected final WirelessDeviceCore getWirelessCore() { return (WirelessDeviceCore) getDeviceCore(); Modified: trunk/net/src/net/org/jnode/net/NetworkLayer.java =================================================================== --- trunk/net/src/net/org/jnode/net/NetworkLayer.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/net/org/jnode/net/NetworkLayer.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -96,7 +96,7 @@ * Gets the protocol addresses for a given name, or null if not found. * * @param hostname - * @return + * @return the addresses or {@code null} */ public ProtocolAddress[] getHostByName(String hostname); } Modified: trunk/net/src/net/org/jnode/net/arp/ARPNetworkLayer.java =================================================================== --- trunk/net/src/net/org/jnode/net/arp/ARPNetworkLayer.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/net/org/jnode/net/arp/ARPNetworkLayer.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -53,10 +53,12 @@ * My logger */ private static final Logger log = Logger.getLogger(ARPNetworkLayer.class); + /** * My statistics */ private final ARPStatistics stat = new ARPStatistics(); + /** * ARP cache */ @@ -294,7 +296,7 @@ * Gets the protocol addresses for a given name, or null if not found. * * @param hostname - * @return + * @return the addresses or {@code null} */ public ProtocolAddress[] getHostByName(String hostname) { return null; Modified: trunk/net/src/net/org/jnode/net/ipv4/layer/IPv4NetworkLayer.java =================================================================== --- trunk/net/src/net/org/jnode/net/ipv4/layer/IPv4NetworkLayer.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/net/org/jnode/net/ipv4/layer/IPv4NetworkLayer.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -384,7 +384,7 @@ * Gets the protocol addresses for a given name, or null if not found. * * @param hostname - * @return + * @return the addresses or {@code null} */ public ProtocolAddress[] getHostByName(String hostname) { try { Modified: trunk/net/src/net/org/jnode/net/nfs/nfs2/NFS2Client.java =================================================================== --- trunk/net/src/net/org/jnode/net/nfs/nfs2/NFS2Client.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/net/org/jnode/net/nfs/nfs2/NFS2Client.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -514,17 +514,14 @@ /** * Set the attributes for file. * - * - * @param fileHandle - * file handle. - * @param mode - * mode. + * @param fileHandle file handle. + * @param mode mode. * @param uid * @param gid * @param size * @param lastAccessed * @param lastModified - * @return + * @return the FileAttribute set * @throws NFS2Exception * @throws IOException */ Modified: trunk/net/src/net/org/jnode/net/nfs/nfs2/mount/Mount1Client.java =================================================================== --- trunk/net/src/net/org/jnode/net/nfs/nfs2/mount/Mount1Client.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/net/org/jnode/net/nfs/nfs2/mount/Mount1Client.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -188,8 +188,7 @@ /** * Call remote procedure mount. * - * @param dirPath - * parameter (of type DirPath) to the remote procedure call. + * @param path parameter (of type DirPath) to the remote procedure call. * @return Result from remote procedure call (of type MountResult). * @throws OncRpcException * if an ONC/RPC error occurs. Modified: trunk/net/src/net/org/jnode/net/wireless/p80211Header.java =================================================================== --- trunk/net/src/net/org/jnode/net/wireless/p80211Header.java 2009-03-26 13:04:02 UTC (rev 5157) +++ trunk/net/src/net/org/jnode/net/wireless/p80211Header.java 2009-03-26 13:46:39 UTC (rev 5158) @@ -54,7 +54,6 @@ * @param address3 * @param sequenceControl * @param address4 - * @param dataLength */ public p80211Header(int frameControl, int durationId, EthernetAddress address1, EthernetAddress address2, EthernetAddress address3, int sequenceControl, @@ -111,10 +110,8 @@ * layers have set their header data and can be used e.g. to update checksum * values. * - * @param skbuf - * The buffer - * @param offset - * The offset to the first byte (in the buffer) of this header + * @param skbuf The buffer + * @param offset The offset to the first byte (in the buffer) of this header * (since low layer headers are already prefixed) */ public void finalizeHeader(SocketBuffer skbuf, int offset) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-03-27 23:38:04
|
Revision: 5162 http://jnode.svn.sourceforge.net/jnode/?rev=5162&view=rev Author: chrisboertien Date: 2009-03-27 23:37:52 +0000 (Fri, 27 Mar 2009) Log Message: ----------- More openjdk java.util.zip, implemented gzip commands, fixed a bug in FileHandleImpl Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleImpl.java trunk/shell/descriptors/org.jnode.shell.command.xml Added Paths: ----------- trunk/core/src/openjdk/java/java/util/zip/CheckedInputStream.java trunk/core/src/openjdk/java/java/util/zip/CheckedOutputStream.java trunk/core/src/openjdk/java/java/util/zip/DeflaterOutputStream.java trunk/core/src/openjdk/java/java/util/zip/GZIPInputStream.java trunk/core/src/openjdk/java/java/util/zip/GZIPOutputStream.java trunk/core/src/openjdk/java/java/util/zip/InflaterInputStream.java trunk/shell/src/shell/org/jnode/shell/command/GUNZIPCommand.java trunk/shell/src/shell/org/jnode/shell/command/GZIP.java trunk/shell/src/shell/org/jnode/shell/command/GZIPCommand.java trunk/shell/src/shell/org/jnode/shell/command/ZCATCommand.java Removed Paths: ------------- trunk/core/src/classpath/java/java/util/zip/CheckedInputStream.java trunk/core/src/classpath/java/java/util/zip/CheckedOutputStream.java trunk/core/src/classpath/java/java/util/zip/DeflaterOutputStream.java trunk/core/src/classpath/java/java/util/zip/GZIPInputStream.java trunk/core/src/classpath/java/java/util/zip/GZIPOutputStream.java trunk/core/src/classpath/java/java/util/zip/InflaterInputStream.java Deleted: trunk/core/src/classpath/java/java/util/zip/CheckedInputStream.java =================================================================== --- trunk/core/src/classpath/java/java/util/zip/CheckedInputStream.java 2009-03-27 10:15:56 UTC (rev 5161) +++ trunk/core/src/classpath/java/java/util/zip/CheckedInputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -1,135 +0,0 @@ -/* CheckedInputStream.java - Compute checksum of data being read - Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.util.zip; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - -/* Written using on-line Java Platform 1.2 API Specification - * and JCL book. - * Believed complete and correct. - */ - -/** - * InputStream that computes a checksum of the data being read using a - * supplied Checksum object. - * - * @see Checksum - * - * @author Tom Tromey - * @date May 17, 1999 - */ -public class CheckedInputStream extends FilterInputStream -{ - /** - * Creates a new CheckInputStream on top of the supplied OutputStream - * using the supplied Checksum. - */ - public CheckedInputStream (InputStream in, Checksum sum) - { - super (in); - this.sum = sum; - } - - /** - * Returns the Checksum object used. To get the data checksum computed so - * far call <code>getChecksum.getValue()</code>. - */ - public Checksum getChecksum () - { - return sum; - } - - /** - * Reads one byte, updates the checksum and returns the read byte - * (or -1 when the end of file was reached). - */ - public int read () throws IOException - { - int x = in.read(); - if (x != -1) - sum.update(x); - return x; - } - - /** - * Reads at most len bytes in the supplied buffer and updates the checksum - * with it. Returns the number of bytes actually read or -1 when the end - * of file was reached. - */ - public int read (byte[] buf, int off, int len) throws IOException - { - int r = in.read(buf, off, len); - if (r != -1) - sum.update(buf, off, r); - return r; - } - - /** - * Skips n bytes by reading them in a temporary buffer and updating the - * the checksum with that buffer. Returns the actual number of bytes skiped - * which can be less then requested when the end of file is reached. - */ - public long skip (long n) throws IOException - { - if (n == 0) - return 0; - - int min = (int) Math.min(n, 1024); - byte[] buf = new byte[min]; - - long s = 0; - while (n > 0) - { - int r = in.read(buf, 0, min); - if (r == -1) - break; - n -= r; - s += r; - min = (int) Math.min(n, 1024); - sum.update(buf, 0, r); - } - - return s; - } - - /** The checksum object. */ - private Checksum sum; -} Deleted: trunk/core/src/classpath/java/java/util/zip/CheckedOutputStream.java =================================================================== --- trunk/core/src/classpath/java/java/util/zip/CheckedOutputStream.java 2009-03-27 10:15:56 UTC (rev 5161) +++ trunk/core/src/classpath/java/java/util/zip/CheckedOutputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -1,100 +0,0 @@ -/* CheckedOutputStream.java - Compute checksum of data being written. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.util.zip; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/* Written using on-line Java Platform 1.2 API Specification - * and JCL book. - * Believed complete and correct. - */ - -/** - * OutputStream that computes a checksum of data being written using a - * supplied Checksum object. - * - * @see Checksum - * - * @author Tom Tromey - * @date May 17, 1999 - */ -public class CheckedOutputStream extends FilterOutputStream -{ - /** - * Creates a new CheckInputStream on top of the supplied OutputStream - * using the supplied Checksum. - */ - public CheckedOutputStream (OutputStream out, Checksum cksum) - { - super (out); - this.sum = cksum; - } - - /** - * Returns the Checksum object used. To get the data checksum computed so - * far call <code>getChecksum.getValue()</code>. - */ - public Checksum getChecksum () - { - return sum; - } - - /** - * Writes one byte to the OutputStream and updates the Checksum. - */ - public void write (int bval) throws IOException - { - out.write(bval); - sum.update(bval); - } - - /** - * Writes the byte array to the OutputStream and updates the Checksum. - */ - public void write (byte[] buf, int off, int len) throws IOException - { - out.write(buf, off, len); - sum.update(buf, off, len); - } - - /** The checksum object. */ - private Checksum sum; -} Deleted: trunk/core/src/classpath/java/java/util/zip/DeflaterOutputStream.java =================================================================== --- trunk/core/src/classpath/java/java/util/zip/DeflaterOutputStream.java 2009-03-27 10:15:56 UTC (rev 5161) +++ trunk/core/src/classpath/java/java/util/zip/DeflaterOutputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -1,198 +0,0 @@ -/* DeflaterOutputStream.java - Output filter for compressing. - Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.util.zip; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/* Written using on-line Java Platform 1.2 API Specification - * and JCL book. - * Believed complete and correct. - */ - -/** - * This is a special FilterOutputStream deflating the bytes that are - * written through it. It uses the Deflater for deflating. - * - * A special thing to be noted is that flush() doesn't flush - * everything in Sun's JDK, but it does so in jazzlib. This is because - * Sun's Deflater doesn't have a way to flush() everything, without - * finishing the stream. - * - * @author Tom Tromey, Jochen Hoenicke - * @date Jan 11, 2001 - */ -public class DeflaterOutputStream extends FilterOutputStream -{ - /** - * This buffer is used temporarily to retrieve the bytes from the - * deflater and write them to the underlying output stream. - */ - protected byte[] buf; - - /** - * The deflater which is used to deflate the stream. - */ - protected Deflater def; - - /** - * Deflates everything in the def's input buffers. This will call - * <code>def.deflate()</code> until all bytes from the input buffers - * are processed. - */ - protected void deflate() throws IOException - { - while (! def.needsInput()) - { - int len = def.deflate(buf, 0, buf.length); - - // System.err.println("DOS deflated " + len + " out of " + buf.length); - if (len <= 0) - break; - out.write(buf, 0, len); - } - - if (! def.needsInput()) - throw new InternalError("Can't deflate all input?"); - } - - /** - * Creates a new DeflaterOutputStream with a default Deflater and - * default buffer size. - * @param out the output stream where deflated output should be written. - */ - public DeflaterOutputStream(OutputStream out) - { - this(out, new Deflater(), 4096); - } - - /** - * Creates a new DeflaterOutputStream with the given Deflater and - * default buffer size. - * @param out the output stream where deflated output should be written. - * @param defl the underlying deflater. - */ - public DeflaterOutputStream(OutputStream out, Deflater defl) - { - this(out, defl, 4096); - } - - /** - * Creates a new DeflaterOutputStream with the given Deflater and - * buffer size. - * @param out the output stream where deflated output should be written. - * @param defl the underlying deflater. - * @param bufsize the buffer size. - * @exception IllegalArgumentException if bufsize isn't positive. - */ - public DeflaterOutputStream(OutputStream out, Deflater defl, int bufsize) - { - super(out); - if (bufsize <= 0) - throw new IllegalArgumentException("bufsize <= 0"); - buf = new byte[bufsize]; - def = defl; - } - - /** - * Flushes the stream by calling flush() on the deflater and then - * on the underlying stream. This ensures that all bytes are - * flushed. This function doesn't work in Sun's JDK, but only in - * jazzlib. - */ - public void flush() throws IOException - { - def.flush(); - deflate(); - out.flush(); - } - - /** - * Finishes the stream by calling finish() on the deflater. This - * was the only way to ensure that all bytes are flushed in Sun's - * JDK. - */ - public void finish() throws IOException - { - def.finish(); - while (! def.finished()) - { - int len = def.deflate(buf, 0, buf.length); - if (len <= 0) - break; - out.write(buf, 0, len); - } - if (! def.finished()) - throw new InternalError("Can't deflate all input?"); - out.flush(); - } - - /** - * Calls finish() and closes the stream. - */ - public void close() throws IOException - { - finish(); - out.close(); - } - - /** - * Writes a single byte to the compressed output stream. - * @param bval the byte value. - */ - public void write(int bval) throws IOException - { - byte[] b = new byte[1]; - b[0] = (byte) bval; - write(b, 0, 1); - } - - /** - * Writes a len bytes from an array to the compressed stream. - * @param buf the byte array. - * @param off the offset into the byte array where to start. - * @param len the number of bytes to write. - */ - public void write(byte[] buf, int off, int len) throws IOException - { - def.setInput(buf, off, len); - deflate(); - } -} Deleted: trunk/core/src/classpath/java/java/util/zip/GZIPInputStream.java =================================================================== --- trunk/core/src/classpath/java/java/util/zip/GZIPInputStream.java 2009-03-27 10:15:56 UTC (rev 5161) +++ trunk/core/src/classpath/java/java/util/zip/GZIPInputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -1,355 +0,0 @@ -/* GZIPInputStream.java - Input filter for reading gzip file - Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.util.zip; - -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; - -/** - * This filter stream is used to decompress a "GZIP" format stream. - * The "GZIP" format is described in RFC 1952. - * - * @author John Leuner - * @author Tom Tromey - * @since JDK 1.1 - */ -public class GZIPInputStream - extends InflaterInputStream -{ - /** - * The magic number found at the start of a GZIP stream. - */ - public static final int GZIP_MAGIC = 0x8b1f; - - /** - * The mask for bit 0 of the flag byte. - */ - static final int FTEXT = 0x1; - - /** - * The mask for bit 1 of the flag byte. - */ - static final int FHCRC = 0x2; - - /** - * The mask for bit 2 of the flag byte. - */ - static final int FEXTRA = 0x4; - - /** - * The mask for bit 3 of the flag byte. - */ - static final int FNAME = 0x8; - - /** - * The mask for bit 4 of the flag byte. - */ - static final int FCOMMENT = 0x10; - - /** - * The CRC-32 checksum value for uncompressed data. - */ - protected CRC32 crc; - - /** - * Indicates whether or not the end of the stream has been reached. - */ - protected boolean eos; - - /** - * Indicates whether or not the GZIP header has been read in. - */ - private boolean readGZIPHeader; - - /** - * Creates a GZIPInputStream with the default buffer size. - * - * @param in The stream to read compressed data from - * (in GZIP format). - * - * @throws IOException if an error occurs during an I/O operation. - */ - public GZIPInputStream(InputStream in) - throws IOException - { - this(in, 4096); - } - - /** - * Creates a GZIPInputStream with the specified buffer size. - * - * @param in The stream to read compressed data from - * (in GZIP format). - * @param size The size of the buffer to use. - * - * @throws IOException if an error occurs during an I/O operation. - * @throws IllegalArgumentException if <code>size</code> - * is less than or equal to 0. - */ - public GZIPInputStream(InputStream in, int size) - throws IOException - { - super(in, new Inflater(true), size); - crc = new CRC32(); - readHeader(); - } - - /** - * Closes the input stream. - * - * @throws IOException if an error occurs during an I/O operation. - */ - public void close() - throws IOException - { - // Nothing to do here. - super.close(); - } - - /** - * Reads in GZIP-compressed data and stores it in uncompressed form - * into an array of bytes. The method will block until either - * enough input data becomes available or the compressed stream - * reaches its end. - * - * @param buf the buffer into which the uncompressed data will - * be stored. - * @param offset the offset indicating where in <code>buf</code> - * the uncompressed data should be placed. - * @param len the number of uncompressed bytes to be read. - */ - public int read(byte[] buf, int offset, int len) throws IOException - { - // We first have to slurp in the GZIP header, then we feed all the - // rest of the data to the superclass. - // - // As we do that we continually update the CRC32. Once the data is - // finished, we check the CRC32. - // - // This means we don't need our own buffer, as everything is done - // in the superclass. - if (!readGZIPHeader) - readHeader(); - - if (eos) - return -1; - - // System.err.println("GZIPIS.read(byte[], off, len ... " + offset + " and len " + len); - - /* We don't have to read the header, - * so we just grab data from the superclass. - */ - int numRead = super.read(buf, offset, len); - if (numRead > 0) - crc.update(buf, offset, numRead); - - if (inf.finished()) - readFooter(); - return numRead; - } - - - /** - * Reads in the GZIP header. - */ - private void readHeader() throws IOException - { - /* 1. Check the two magic bytes */ - CRC32 headCRC = new CRC32(); - int magic = in.read(); - if (magic < 0) - { - eos = true; - return; - } - int magic2 = in.read(); - if ((magic + (magic2 << 8)) != GZIP_MAGIC) - throw new IOException("Error in GZIP header, bad magic code"); - headCRC.update(magic); - headCRC.update(magic2); - - /* 2. Check the compression type (must be 8) */ - int CM = in.read(); - if (CM != Deflater.DEFLATED) - throw new IOException("Error in GZIP header, data not in deflate format"); - headCRC.update(CM); - - /* 3. Check the flags */ - int flags = in.read(); - if (flags < 0) - throw new EOFException("Early EOF in GZIP header"); - headCRC.update(flags); - - /* This flag byte is divided into individual bits as follows: - - bit 0 FTEXT - bit 1 FHCRC - bit 2 FEXTRA - bit 3 FNAME - bit 4 FCOMMENT - bit 5 reserved - bit 6 reserved - bit 7 reserved - */ - - /* 3.1 Check the reserved bits are zero */ - if ((flags & 0xd0) != 0) - throw new IOException("Reserved flag bits in GZIP header != 0"); - - /* 4.-6. Skip the modification time, extra flags, and OS type */ - for (int i=0; i< 6; i++) - { - int readByte = in.read(); - if (readByte < 0) - throw new EOFException("Early EOF in GZIP header"); - headCRC.update(readByte); - } - - /* 7. Read extra field */ - if ((flags & FEXTRA) != 0) - { - /* Skip subfield id */ - for (int i=0; i< 2; i++) - { - int readByte = in.read(); - if (readByte < 0) - throw new EOFException("Early EOF in GZIP header"); - headCRC.update(readByte); - } - if (in.read() < 0 || in.read() < 0) - throw new EOFException("Early EOF in GZIP header"); - - int len1, len2, extraLen; - len1 = in.read(); - len2 = in.read(); - if ((len1 < 0) || (len2 < 0)) - throw new EOFException("Early EOF in GZIP header"); - headCRC.update(len1); - headCRC.update(len2); - - extraLen = (len1 << 8) | len2; - for (int i = 0; i < extraLen;i++) - { - int readByte = in.read(); - if (readByte < 0) - throw new EOFException("Early EOF in GZIP header"); - headCRC.update(readByte); - } - } - - /* 8. Read file name */ - if ((flags & FNAME) != 0) - { - int readByte; - while ( (readByte = in.read()) > 0) - headCRC.update(readByte); - if (readByte < 0) - throw new EOFException("Early EOF in GZIP file name"); - headCRC.update(readByte); - } - - /* 9. Read comment */ - if ((flags & FCOMMENT) != 0) - { - int readByte; - while ( (readByte = in.read()) > 0) - headCRC.update(readByte); - - if (readByte < 0) - throw new EOFException("Early EOF in GZIP comment"); - headCRC.update(readByte); - } - - /* 10. Read header CRC */ - if ((flags & FHCRC) != 0) - { - int tempByte; - int crcval = in.read(); - if (crcval < 0) - throw new EOFException("Early EOF in GZIP header"); - - tempByte = in.read(); - if (tempByte < 0) - throw new EOFException("Early EOF in GZIP header"); - - crcval = (crcval << 8) | tempByte; - if (crcval != ((int) headCRC.getValue() & 0xffff)) - throw new IOException("Header CRC value mismatch"); - } - - readGZIPHeader = true; - //System.err.println("Read GZIP header"); - } - - private void readFooter() throws IOException - { - byte[] footer = new byte[8]; - int avail = inf.getRemaining(); - if (avail > 8) - avail = 8; - System.arraycopy(buf, len - inf.getRemaining(), footer, 0, avail); - int needed = 8 - avail; - while (needed > 0) - { - int count = in.read(footer, 8-needed, needed); - if (count <= 0) - throw new EOFException("Early EOF in GZIP footer"); - needed -= count; //Jewel Jan 16 - } - - int crcval = (footer[0] & 0xff) | ((footer[1] & 0xff) << 8) - | ((footer[2] & 0xff) << 16) | (footer[3] << 24); - if (crcval != (int) crc.getValue()) - throw new IOException("GZIP crc sum mismatch, theirs \"" - + Integer.toHexString(crcval) - + "\" and ours \"" - + Integer.toHexString( (int) crc.getValue())); - - int total = (footer[4] & 0xff) | ((footer[5] & 0xff) << 8) - | ((footer[6] & 0xff) << 16) | (footer[7] << 24); - if (total != inf.getTotalOut()) - throw new IOException("Number of bytes mismatch"); - - /* FIXME" XXX Should we support multiple members. - * Difficult, since there may be some bytes still in buf - */ - eos = true; - } -} Deleted: trunk/core/src/classpath/java/java/util/zip/GZIPOutputStream.java =================================================================== --- trunk/core/src/classpath/java/java/util/zip/GZIPOutputStream.java 2009-03-27 10:15:56 UTC (rev 5161) +++ trunk/core/src/classpath/java/java/util/zip/GZIPOutputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -1,151 +0,0 @@ -/* GZIPOutputStream.java - Create a file in gzip format - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.util.zip; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * This filter stream is used to compress a stream into a "GZIP" stream. - * The "GZIP" format is described in RFC 1952. - * - * @author John Leuner - * @author Tom Tromey - * @since JDK 1.1 - */ - -/* Written using on-line Java Platform 1.2 API Specification - * and JCL book. - * Believed complete and correct. - */ - -public class GZIPOutputStream extends DeflaterOutputStream -{ - /** - * CRC-32 value for uncompressed data - */ - protected CRC32 crc; - - /** - * Creates a GZIPOutputStream with the default buffer size - * - * @param out The stream to read data (to be compressed) from - * - */ - public GZIPOutputStream(OutputStream out) throws IOException - { - this(out, 4096); - } - - /** - * Creates a GZIPOutputStream with the specified buffer size - * - * @param out The stream to read compressed data from - * @param size Size of the buffer to use - */ - public GZIPOutputStream(OutputStream out, int size) throws IOException - { - super(out, new Deflater(Deflater.DEFAULT_COMPRESSION, true), size); - crc = new CRC32(); - int mod_time = (int) (System.currentTimeMillis() / 1000L); - byte[] gzipHeader = - { - /* The two magic bytes */ - (byte) GZIPInputStream.GZIP_MAGIC, - (byte) (GZIPInputStream.GZIP_MAGIC >> 8), - - /* The compression type */ - (byte) Deflater.DEFLATED, - - /* The flags (not set) */ - 0, - - /* The modification time */ - (byte) mod_time, (byte) (mod_time >> 8), - (byte) (mod_time >> 16), (byte) (mod_time >> 24), - - /* The extra flags */ - 0, - - /* The OS type (unknown) */ - (byte) 255 - }; - - out.write(gzipHeader); - // System.err.println("wrote GZIP header (" + gzipHeader.length + " bytes )"); - } - - public synchronized void write(byte[] buf, int off, int len) - throws IOException - { - super.write(buf, off, len); - crc.update(buf, off, len); - } - - /** - * Writes remaining compressed output data to the output stream - * and closes it. - */ - public void close() throws IOException - { - finish(); - out.close(); - } - - public void finish() throws IOException - { - super.finish(); - - int totalin = def.getTotalIn(); - int crcval = (int) (crc.getValue() & 0xffffffff); - - // System.err.println("CRC val is " + Integer.toHexString( crcval ) + " and length " + Integer.toHexString(totalin)); - - byte[] gzipFooter = - { - (byte) crcval, (byte) (crcval >> 8), - (byte) (crcval >> 16), (byte) (crcval >> 24), - - (byte) totalin, (byte) (totalin >> 8), - (byte) (totalin >> 16), (byte) (totalin >> 24) - }; - - out.write(gzipFooter); - // System.err.println("wrote GZIP trailer (" + gzipFooter.length + " bytes )"); - } -} Deleted: trunk/core/src/classpath/java/java/util/zip/InflaterInputStream.java =================================================================== --- trunk/core/src/classpath/java/java/util/zip/InflaterInputStream.java 2009-03-27 10:15:56 UTC (rev 5161) +++ trunk/core/src/classpath/java/java/util/zip/InflaterInputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -1,261 +0,0 @@ -/* InflaterInputStream.java - Input stream filter for decompressing - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 - Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.util.zip; - -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * This filter stream is used to decompress data compressed in the "deflate" - * format. The "deflate" format is described in RFC 1951. - * - * This stream may form the basis for other decompression filters, such - * as the <code>GZIPInputStream</code>. - * - * @author John Leuner - * @author Tom Tromey - * @since 1.1 - */ -public class InflaterInputStream extends FilterInputStream -{ - /** - * Decompressor for this filter - */ - protected Inflater inf; - - /** - * Byte array used as a buffer - */ - protected byte[] buf; - - /** - * Size of buffer - */ - protected int len; - - // We just use this if we are decoding one byte at a time with the - // read() call. - private byte[] onebytebuffer = new byte[1]; - - /** - * Create an InflaterInputStream with the default decompresseor - * and a default buffer size. - * - * @param in the InputStream to read bytes from - */ - public InflaterInputStream(InputStream in) - { - this(in, new Inflater(), 4096); - } - - /** - * Create an InflaterInputStream with the specified decompresseor - * and a default buffer size. - * - * @param in the InputStream to read bytes from - * @param inf the decompressor used to decompress data read from in - */ - public InflaterInputStream(InputStream in, Inflater inf) - { - this(in, inf, 4096); - } - - /** - * Create an InflaterInputStream with the specified decompresseor - * and a specified buffer size. - * - * @param in the InputStream to read bytes from - * @param inf the decompressor used to decompress data read from in - * @param size size of the buffer to use - */ - public InflaterInputStream(InputStream in, Inflater inf, int size) - { - super(in); - - if (in == null) - throw new NullPointerException("in may not be null"); - if (inf == null) - throw new NullPointerException("inf may not be null"); - if (size < 0) - throw new IllegalArgumentException("size may not be negative"); - - this.inf = inf; - this.buf = new byte [size]; - } - - /** - * Returns 0 once the end of the stream (EOF) has been reached. - * Otherwise returns 1. - */ - public int available() throws IOException - { - // According to the JDK 1.2 docs, this should only ever return 0 - // or 1 and should not be relied upon by Java programs. - if (inf == null) - throw new IOException("stream closed"); - return inf.finished() ? 0 : 1; - } - - /** - * Closes the input stream - */ - public synchronized void close() throws IOException - { - if (in != null) - in.close(); - in = null; - } - - /** - * Fills the buffer with more data to decompress. - */ - protected void fill() throws IOException - { - if (in == null) - throw new ZipException ("InflaterInputStream is closed"); - - len = in.read(buf, 0, buf.length); - - if (len < 0) - throw new ZipException("Deflated stream ends early."); - - inf.setInput(buf, 0, len); - } - - /** - * Reads one byte of decompressed data. - * - * The byte is in the lower 8 bits of the int. - */ - public int read() throws IOException - { - int nread = read(onebytebuffer, 0, 1); - if (nread > 0) - return onebytebuffer[0] & 0xff; - return -1; - } - - /** - * Decompresses data into the byte array - * - * @param b the array to read and decompress data into - * @param off the offset indicating where the data should be placed - * @param len the number of bytes to decompress - */ - public int read(byte[] b, int off, int len) throws IOException - { - if (inf == null) - throw new IOException("stream closed"); - if (len == 0) - return 0; - - int count = 0; - for (;;) - { - - try - { - count = inf.inflate(b, off, len); - } - catch (DataFormatException dfe) - { - throw new ZipException(dfe.getMessage()); - } - - if (count > 0) - return count; - - if (inf.needsDictionary() - | inf.finished()) - return -1; - else if (inf.needsInput()) - fill(); - else - throw new InternalError("Don't know what to do"); - } - } - - /** - * Skip specified number of bytes of uncompressed data - * - * @param n number of bytes to skip - */ - public long skip(long n) throws IOException - { - if (inf == null) - throw new IOException("stream closed"); - if (n < 0) - throw new IllegalArgumentException(); - - if (n == 0) - return 0; - - int buflen = (int) Math.min(n, 2048); - byte[] tmpbuf = new byte[buflen]; - - long skipped = 0L; - while (n > 0L) - { - int numread = read(tmpbuf, 0, buflen); - if (numread <= 0) - break; - n -= numread; - skipped += numread; - buflen = (int) Math.min(n, 2048); - } - - return skipped; - } - - public boolean markSupported() - { - return false; - } - - public void mark(int readLimit) - { - } - - public void reset() throws IOException - { - throw new IOException("reset not supported"); - } -} Added: trunk/core/src/openjdk/java/java/util/zip/CheckedInputStream.java =================================================================== --- trunk/core/src/openjdk/java/java/util/zip/CheckedInputStream.java (rev 0) +++ trunk/core/src/openjdk/java/java/util/zip/CheckedInputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -0,0 +1,116 @@ +/* + * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.util.zip; + +import java.io.FilterInputStream; +import java.io.InputStream; +import java.io.IOException; + +/** + * An input stream that also maintains a checksum of the data being read. + * The checksum can then be used to verify the integrity of the input data. + * + * @see Checksum + * @author David Connelly + */ +public +class CheckedInputStream extends FilterInputStream { + private Checksum cksum; + + /** + * Creates an input stream using the specified Checksum. + * @param in the input stream + * @param cksum the Checksum + */ + public CheckedInputStream(InputStream in, Checksum cksum) { + super(in); + this.cksum = cksum; + } + + /** + * Reads a byte. Will block if no input is available. + * @return the byte read, or -1 if the end of the stream is reached. + * @exception IOException if an I/O error has occurred + */ + public int read() throws IOException { + int b = in.read(); + if (b != -1) { + cksum.update(b); + } + return b; + } + + /** + * Reads into an array of bytes. If <code>len</code> is not zero, the method + * blocks until some input is available; otherwise, no + * bytes are read and <code>0</code> is returned. + * @param buf the buffer into which the data is read + * @param off the start offset in the destination array <code>b</code> + * @param len the maximum number of bytes read + * @return the actual number of bytes read, or -1 if the end + * of the stream is reached. + * @exception NullPointerException If <code>buf</code> is <code>null</code>. + * @exception IndexOutOfBoundsException If <code>off</code> is negative, + * <code>len</code> is negative, or <code>len</code> is greater than + * <code>buf.length - off</code> + * @exception IOException if an I/O error has occurred + */ + public int read(byte[] buf, int off, int len) throws IOException { + len = in.read(buf, off, len); + if (len != -1) { + cksum.update(buf, off, len); + } + return len; + } + + /** + * Skips specified number of bytes of input. + * @param n the number of bytes to skip + * @return the actual number of bytes skipped + * @exception IOException if an I/O error has occurred + */ + public long skip(long n) throws IOException { + byte[] buf = new byte[512]; + long total = 0; + while (total < n) { + long len = n - total; + len = read(buf, 0, len < buf.length ? (int)len : buf.length); + if (len == -1) { + return total; + } + total += len; + } + return total; + } + + /** + * Returns the Checksum for this input stream. + * @return the Checksum value + */ + public Checksum getChecksum() { + return cksum; + } +} Added: trunk/core/src/openjdk/java/java/util/zip/CheckedOutputStream.java =================================================================== --- trunk/core/src/openjdk/java/java/util/zip/CheckedOutputStream.java (rev 0) +++ trunk/core/src/openjdk/java/java/util/zip/CheckedOutputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -0,0 +1,84 @@ +/* + * Copyright 1996-1999 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.util.zip; + +import java.io.FilterOutputStream; +import java.io.OutputStream; +import java.io.IOException; + +/** + * An output stream that also maintains a checksum of the data being + * written. The checksum can then be used to verify the integrity of + * the output data. + * + * @see Checksum + * @author David Connelly + */ +public +class CheckedOutputStream extends FilterOutputStream { + private Checksum cksum; + + /** + * Creates an output stream with the specified Checksum. + * @param out the output stream + * @param cksum the checksum + */ + public CheckedOutputStream(OutputStream out, Checksum cksum) { + super(out); + this.cksum = cksum; + } + + /** + * Writes a byte. Will block until the byte is actually written. + * @param b the byte to be written + * @exception IOException if an I/O error has occurred + */ + public void write(int b) throws IOException { + out.write(b); + cksum.update(b); + } + + /** + * Writes an array of bytes. Will block until the bytes are + * actually written. + * @param b the data to be written + * @param off the start offset of the data + * @param len the number of bytes to be written + * @exception IOException if an I/O error has occurred + */ + public void write(byte[] b, int off, int len) throws IOException { + out.write(b, off, len); + cksum.update(b, off, len); + } + + /** + * Returns the Checksum for this output stream. + * @return the Checksum + */ + public Checksum getChecksum() { + return cksum; + } +} Added: trunk/core/src/openjdk/java/java/util/zip/DeflaterOutputStream.java =================================================================== --- trunk/core/src/openjdk/java/java/util/zip/DeflaterOutputStream.java (rev 0) +++ trunk/core/src/openjdk/java/java/util/zip/DeflaterOutputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -0,0 +1,181 @@ +/* + * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.util.zip; + +import java.io.FilterOutputStream; +import java.io.OutputStream; +import java.io.InputStream; +import java.io.IOException; + +/** + * This class implements an output stream filter for compressing data in + * the "deflate" compression format. It is also used as the basis for other + * types of compression filters, such as GZIPOutputStream. + * + * @see Deflater + * @author David Connelly + */ +public +class DeflaterOutputStream extends FilterOutputStream { + /** + * Compressor for this stream. + */ + protected Deflater def; + + /** + * Output buffer for writing compressed data. + */ + protected byte[] buf; + + /** + * Indicates that the stream has been closed. + */ + + private boolean closed = false; + + /** + * Creates a new output stream with the specified compressor and + * buffer size. + * @param out the output stream + * @param def the compressor ("deflater") + * @param size the output buffer size + * @exception IllegalArgumentException if size is <= 0 + */ + public DeflaterOutputStream(OutputStream out, Deflater def, int size) { + super(out); + if (out == null || def == null) { + throw new NullPointerException(); + } else if (size <= 0) { + throw new IllegalArgumentException("buffer size <= 0"); + } + this.def = def; + buf = new byte[size]; + } + + /** + * Creates a new output stream with the specified compressor and + * a default buffer size. + * @param out the output stream + * @param def the compressor ("deflater") + */ + public DeflaterOutputStream(OutputStream out, Deflater def) { + this(out, def, 512); + } + + boolean usesDefaultDeflater = false; + + /** + * Creates a new output stream with a default compressor and buffer size. + * @param out the output stream + */ + public DeflaterOutputStream(OutputStream out) { + this(out, new Deflater()); + usesDefaultDeflater = true; + } + + /** + * Writes a byte to the compressed output stream. This method will + * block until the byte can be written. + * @param b the byte to be written + * @exception IOException if an I/O error has occurred + */ + public void write(int b) throws IOException { + byte[] buf = new byte[1]; + buf[0] = (byte)(b & 0xff); + write(buf, 0, 1); + } + + /** + * Writes an array of bytes to the compressed output stream. This + * method will block until all the bytes are written. + * @param b the data to be written + * @param off the start offset of the data + * @param len the length of the data + * @exception IOException if an I/O error has occurred + */ + public void write(byte[] b, int off, int len) throws IOException { + if (def.finished()) { + throw new IOException("write beyond end of stream"); + } + if ((off | len | (off + len) | (b.length - (off + len))) < 0) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return; + } + if (!def.finished()) { + // Deflate no more than stride bytes at a time. This avoids + // excess copying in deflateBytes (see Deflater.c) + int stride = buf.length; + for (int i = 0; i < len; i+= stride) { + def.setInput(b, off + i, Math.min(stride, len - i)); + while (!def.needsInput()) { + deflate(); + } + } + } + } + + /** + * Finishes writing compressed data to the output stream without closing + * the underlying stream. Use this method when applying multiple filters + * in succession to the same output stream. + * @exception IOException if an I/O error has occurred + */ + public void finish() throws IOException { + if (!def.finished()) { + def.finish(); + while (!def.finished()) { + deflate(); + } + } + } + + /** + * Writes remaining compressed data to the output stream and closes the + * underlying stream. + * @exception IOException if an I/O error has occurred + */ + public void close() throws IOException { + if (!closed) { + finish(); + if (usesDefaultDeflater) + def.end(); + out.close(); + closed = true; + } + } + + /** + * Writes next block of compressed data to the output stream. + * @throws IOException if an I/O error has occurred + */ + protected void deflate() throws IOException { + int len = def.deflate(buf, 0, buf.length); + if (len > 0) { + out.write(buf, 0, len); + } + } +} Added: trunk/core/src/openjdk/java/java/util/zip/GZIPInputStream.java =================================================================== --- trunk/core/src/openjdk/java/java/util/zip/GZIPInputStream.java (rev 0) +++ trunk/core/src/openjdk/java/java/util/zip/GZIPInputStream.java 2009-03-27 23:37:52 UTC (rev 5162) @@ -0,0 +1,250 @@ +/* + * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.util.zip; + +import java.io.SequenceInputStream; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.IOException; +import java.io.EOFException; + +/** + * This class implements a stream filter for reading compressed data in + * the GZIP file format. + * + * @see InflaterInputStream + * @author David Connelly + * + */ +public +class GZIPInputStream extends InflaterInputStream { + /** + * CRC-32 for uncompressed data. + */ + protected CRC32 crc = new CRC32(); + + /** + * Indicates end of input stream. + */ + protected boolean eos; + + private boolean closed = false; + + /** + * Check to make sure that this stream has not been closed + */ + private void ensureOpen() throws IOException { + if (closed) { + throw new IOException("Stream closed"); + } + } + + /** + * Creates a new input stream with the specified buffer size. + * @param in the input stream + * @param size the input buffer size + * @exception IOException if an I/O error has occurred + * @exception IllegalArgumentException if size is <= 0 + */ + public GZIPInputStream(InputStream in, int size) throws IOException { + super(in, new Inflater(true), size); + //usesDefaultInflater = true; + readHeader(); + crc.reset(); + } + + /** + * Creates a new input stream with a default buffer size. + * @param in the input stream + * @exception IOException if an I/O error has occurred + */ + public GZIPInputStream(InputStream in) throws IOException { + this(in, 512); + } + + /** + * Reads uncompressed data into an array of bytes. If <code>len</code> is not + * zero, the method will block until some input can be decompressed; otherwise, + * no bytes are read and <code>0</code> is returned. + * @param buf the buffer into which the data is read + * @param off the start offset in the destination array <code>b</code> + * @param len the maximum number of bytes read + * @return the actual number of bytes read, or -1 if the end of the + * compressed input stream is reached + * @exception NullPointerException If <code>buf</code> is <code>null</code>. + * @exception IndexOutOfBoundsException If <code>off</code> is negative, + * <code>len</code> is negative, or <code>len</code> is greater than + * <code>buf.length - off</code> + * @exception IOException if an I/O error has occurred or the compressed + * input data is corrupt + */ + public int read(byte[] buf, int off, int len) throws IOException { + ensureOpen(); + if (eos) { + return -1; + } + len = super.read(buf, off, len); + if (len == -1) { + readTrailer(); + eos = true; + } else { + crc.update(buf, off, len); + } + return len; + } + + /** + * Closes this input stream and releases any system resources associated + * with the stream. + * @exception IOException if an I/O error has occurred + */ + public void close() throws IOException { + if (!closed) { + super.close(); + eos = true; + closed = true; + } + } + + /** + * GZIP header magic number. + */ + public final static int GZIP_MAGIC = 0x8b1f; + + /* + * File header flags. + */ + private final static int FTEXT = 1; // Extra text + private final static int FHCRC = 2; // Header CRC + private final static int FEXTRA = 4; // Extra field + private final static int FNAME = 8; // File name + private final static int FCOMMENT = 16; // File comment + + /* + * Reads GZIP member header. + */ + private void readHeader() throws IOException { + CheckedInputStream in = new CheckedInputStream(this.in, crc); + crc.reset(); + // Check header magic + if (readUShort(in) != GZIP_MAGIC) { + throw new IOException("Not in GZIP format"); + } + // Check compression method + if (readUByte(in) != 8) { + throw new IOException("Unsupported compression method"); + } + // Read flags + int flg = readUByte(in); + // Skip MTIME, XFL, and OS fields + skipBytes(in, 6); + // Skip optional extra field + if ((flg & FEXTRA) == FEXTRA) { + skipBytes(in, readUShort(in)); + } + // Skip optional file name + if ((flg & FNAME) == FNAME) { + while (readUByte(in) != 0) ; + } + // Skip optional file comment + if ((flg & FCOMMENT) == FCOMMENT) { + while (readUByte(in) != 0) ; + } + // Check optional header CRC + if ((flg & FHCRC) == FHCRC) { + int v = (int)crc.getValue() & 0xffff; + if (readUShort(in) != v) { + throw new IOException("Corrupt GZIP header"); + } + } + } + + /* + * Reads GZIP member trailer. + */ + private void readTrailer() throws IOException { + InputStream in = this.in; + int n = inf.getRemaining(); + if (n > 0) { + in = new SequenceInputStream( + new ByteArray... [truncated message content] |
From: <ls...@us...> - 2009-03-29 07:49:11
|
Revision: 5176 http://jnode.svn.sourceforge.net/jnode/?rev=5176&view=rev Author: lsantha Date: 2009-03-29 07:49:07 +0000 (Sun, 29 Mar 2009) Log Message: ----------- Security fixes. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java 2009-03-29 07:24:21 UTC (rev 5175) +++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java 2009-03-29 07:49:07 UTC (rev 5176) @@ -27,6 +27,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; import com.enterprisedt.net.ftp.FTPFile; @@ -64,16 +68,22 @@ private void ensureEntries() throws IOException { try { if (entries == null) { - entries = new HashMap<String, FTPFSEntry>(); - FTPFile[] ftpFiles = null; - synchronized (fileSystem) { - ftpFiles = fileSystem.dirDetails(path()); - } - for (FTPFile f : ftpFiles) { - FTPFSEntry e = f.isDir() ? new FTPFSDirectory(fileSystem, f) : new FTPFSFile(fileSystem, f); - e.setParent(this); - entries.put(f.getName(), e); - } + AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { + @Override + public Object run() throws Exception { + entries = new HashMap<String, FTPFSEntry>(); + FTPFile[] ftpFiles = null; + synchronized (fileSystem) { + ftpFiles = fileSystem.dirDetails(path()); + } + for (FTPFile f : ftpFiles) { + FTPFSEntry e = f.isDir() ? new FTPFSDirectory(fileSystem, f) : new FTPFSFile(fileSystem, f); + e.setParent(FTPFSDirectory.this); + entries.put(f.getName(), e); + } + return null; + } + }); } } catch (Exception e) { e.printStackTrace(); Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2009-03-29 07:24:21 UTC (rev 5175) +++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2009-03-29 07:49:07 UTC (rev 5176) @@ -48,7 +48,12 @@ FTPFileSystem(final FTPFSDevice device, final FTPFileSystemType type) { this.type = type; - this.client = new FTPClient(); + this.client = AccessController.doPrivileged(new PrivilegedAction<FTPClient>(){ + @Override + public FTPClient run() { + return new FTPClient(); + } + }); this.device = device; device.addListener(new DeviceListener() { public void deviceStarted(Device device) { Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java 2009-03-29 07:24:21 UTC (rev 5175) +++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystemType.java 2009-03-29 07:49:07 UTC (rev 5176) @@ -23,6 +23,8 @@ import org.jnode.driver.Device; import org.jnode.fs.FileSystemException; import org.jnode.fs.FileSystemType; +import java.security.AccessController; +import java.security.PrivilegedAction; /** * @author Levente S\u00e1ntha @@ -31,8 +33,14 @@ public static final Class<SMBFileSystemType> ID = SMBFileSystemType.class; static { - System.setProperty("jcifs.smb.client.attrExpirationPeriod", "10"); - System.setProperty("jcifs.smb.client.responseTimeout", "10000"); + AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override + public Object run() { + System.setProperty("jcifs.smb.client.attrExpirationPeriod", "10"); + System.setProperty("jcifs.smb.client.responseTimeout", "10000"); + return null; + } + }); } /** Modified: trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-03-29 07:24:21 UTC (rev 5175) +++ trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-03-29 07:49:07 UTC (rev 5176) @@ -17,7 +17,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.shell.syntax; import java.io.File; @@ -26,12 +26,13 @@ import org.jnode.driver.console.CompletionInfo; import org.jnode.shell.CommandLine.Token; +import sun.security.action.GetPropertyAction; /** * This argument class performs completion against the file system namespace. This * Argument class understands the {@link Argument#EXISTING} and {@link Argument#NONEXISTENT} * flags when accepting argument values, but not (yet) when completing them. - * + * * @author cr...@jn... */ public class FileArgument extends Argument<File> { @@ -61,7 +62,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void complete(final CompletionInfo completion, final String partial) { // Get last full directory from the partial pathname. final int idx = partial.lastIndexOf(File.separatorChar); final String dir; @@ -76,34 +77,41 @@ // Get the contents of that directory. (Note that the call to getProperty() // is needed because new File("").exists() returns false. According to Sun, this // behavior is "not a bug".) - final File f = dir.isEmpty() ? new File(System.getProperty("user.dir")) : new File(dir); + String user_dir = AccessController.doPrivileged(new GetPropertyAction("user.dir")); + final File f = dir.isEmpty() ? new File(user_dir) : new File(dir); final String[] names = AccessController.doPrivileged( - new PrivilegedAction <String[]>() { - public String[] run() { - if (!f.exists()) { - return null; - } else { - return f.list(); - } + new PrivilegedAction<String[]>() { + public String[] run() { + if (!f.exists()) { + return null; + } else { + return f.list(); } - }); + } + }); if (names == null) { // The dir (or user.dir) denotes a non-existent directory. // No completions are possible for this path name. return; } - final String prefix = - (dir.length() == 0) ? "" : dir.equals("/") ? "/" : dir + File.separatorChar; - for (String n : names) { - String name = prefix + n; - if (name.startsWith(partial)) { - if (new File(f, n).isDirectory()) { - completion.addCompletion(name + File.separatorChar, true); - } else { - completion.addCompletion(name); + final String prefix = (dir.length() == 0) ? "" : dir.equals("/") ? "/" : dir + File.separatorChar; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + @Override + public Object run() { + for (String n : names) { + String name = prefix + n; + if (name.startsWith(partial)) { + if (new File(f, n).isDirectory()) { + completion.addCompletion(name + File.separatorChar, true); + } else { + completion.addCompletion(name); + } + } } + return null; } - } + }); + // Completion of "." and ".." as the last pathname component have to be dealt with // explicitly. The 'f.list()' call does not include "." and ".." in the result array. int tmp = partial.length() - idx; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-03-29 07:55:30
|
Revision: 5177 http://jnode.svn.sourceforge.net/jnode/?rev=5177&view=rev Author: lsantha Date: 2009-03-29 07:55:25 +0000 (Sun, 29 Mar 2009) Log Message: ----------- OpenJDK integration. Modified Paths: -------------- trunk/all/conf/openjdk-annotations.properties trunk/core/descriptors/org.classpath.core.xml trunk/core/src/core/org/jnode/security/JNodePolicy.java trunk/fs/descriptors/org.jnode.fs.ftpfs.xml Added Paths: ----------- trunk/core/src/openjdk/java/java/security/CodeSource.java trunk/core/src/openjdk/java/java/security/Policy.java trunk/core/src/openjdk/java/java/security/ProtectionDomain.java trunk/core/src/openjdk/java/java/security/SecureClassLoader.java Removed Paths: ------------- trunk/core/src/classpath/java/java/security/CodeSource.java trunk/core/src/classpath/java/java/security/Policy.java trunk/core/src/classpath/java/java/security/ProtectionDomain.java trunk/core/src/classpath/java/java/security/SecureClassLoader.java Modified: trunk/all/conf/openjdk-annotations.properties =================================================================== --- trunk/all/conf/openjdk-annotations.properties 2009-03-29 07:49:07 UTC (rev 5176) +++ trunk/all/conf/openjdk-annotations.properties 2009-03-29 07:55:25 UTC (rev 5177) @@ -20,6 +20,8 @@ java/net/URLConnection.class=SharedStatics java/nio/charset/Charset.class=SharedStatics java/nio/charset/CoderResult.class=SharedStatics +# TODO Policy might need to be isolated +java/security/Policy.class=SharedStatics java/util/Currency.class=SharedStatics java/util/concurrent/locks/LockSupport.class=SharedStatics sun/awt/AppContext.class=SharedStatics Modified: trunk/core/descriptors/org.classpath.core.xml =================================================================== --- trunk/core/descriptors/org.classpath.core.xml 2009-03-29 07:49:07 UTC (rev 5176) +++ trunk/core/descriptors/org.classpath.core.xml 2009-03-29 07:55:25 UTC (rev 5177) @@ -45,6 +45,8 @@ <export name="sun.security.jca.*"/> <export name="sun.security.pkcs.ParsingException"/> <export name="sun.security.provider.SecureRandom"/> + <export name="sun.security.provider.PolicyFile"/> + <export name="sun.security.provider.PolicyParser"/> <export name="sun.security.util.*"/> <export name="sun.misc.Service"/> Deleted: trunk/core/src/classpath/java/java/security/CodeSource.java =================================================================== --- trunk/core/src/classpath/java/java/security/CodeSource.java 2009-03-29 07:49:07 UTC (rev 5176) +++ trunk/core/src/classpath/java/java/security/CodeSource.java 2009-03-29 07:55:25 UTC (rev 5177) @@ -1,378 +0,0 @@ -/* CodeSource.java -- Code location and certifcates - Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package java.security; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.net.SocketPermission; -import java.net.URL; -// Note that this overrides Certificate in this package. -import java.security.cert.Certificate; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; - -/** - * This class represents a location from which code is loaded (as - * represented by a URL), and the list of certificates that are used to - * check the signatures of signed code loaded from this source. - * - * @author Aaron M. Renn (ar...@ur...) - * @author Eric Blake (eb...@em...) - * @since 1.1 - * @status updated to 1.4 - */ -public class CodeSource implements Serializable -{ - /** - * Compatible with JDK 1.1+. - */ - private static final long serialVersionUID = 4977541819976013951L; - - /** - * This is the URL that represents the code base from which code will - * be loaded. - * - * @serial the code location - */ - private final URL location; - - /** The set of certificates for this code base. */ - private transient HashSet certs; - - /** - * This creates a new instance of <code>CodeSource</code> that loads code - * from the specified URL location and which uses the specified certificates - * for verifying signatures. - * - * @param location the location from which code will be loaded - * @param certs the list of certificates - */ - public CodeSource(URL location, Certificate[] certs) - { - this.location = location; - if (certs != null) - this.certs = new HashSet(Arrays.asList(certs)); - } - - /** - * This method returns a hash value for this object. - * - * @return a hash value for this object - */ - public int hashCode() - { - return (location == null ? 0 : location.hashCode()) - ^ (certs == null ? 0 : certs.hashCode()); - } - - /** - * This method tests the specified <code>Object</code> for equality with - * this object. This will be true if and only if the locations are equal - * and the certificate sets are identical (ignoring order). - * - * @param obj the <code>Object</code> to test against - * @return true if the specified object is equal to this one - */ - public boolean equals(Object obj) - { - if (! (obj instanceof CodeSource)) - return false; - CodeSource cs = (CodeSource) obj; - return (certs == null ? cs.certs == null : certs.equals(cs.certs)) - && (location == null ? cs.location == null - : location.equals(cs.location)); - } - - /** - * This method returns the URL specifying the location from which code - * will be loaded under this <code>CodeSource</code>. - * - * @return the code location for this <code>CodeSource</code> - */ - public final URL getLocation() - { - return location; - } - - /** - * This method returns the list of digital certificates that can be used - * to verify the signatures of code loaded under this - * <code>CodeSource</code>. - * - * @return the certifcate list for this <code>CodeSource</code> - */ - public final Certificate[] getCertificates() - { - if (certs == null) - return null; - Certificate[] c = new Certificate[certs.size()]; - certs.toArray(c); - return c; - } - - /** - * This method tests to see if a specified <code>CodeSource</code> is - * implied by this object. Effectively, to meet this test, the specified - * object must have all the certifcates this object has (but may have more), - * and must have a location that is a subset of this object's. In order - * for this object to imply the specified object, the following must be - * true: - * - * <ol> - * <li><em>codesource</em> must not be <code>null</code>.</li> - * <li>If <em>codesource</em> has a certificate list, all of it's - * certificates must be present in the certificate list of this - * code source.</li> - * <li>If this object does not have a <code>null</code> location, then - * the following addtional tests must be passed. - * - * <ol> - * <li><em>codesource</em> must not have a <code>null</code> - * location.</li> - * <li><em>codesource</em>'s location must be equal to this object's - * location, or - * <ul> - * <li><em>codesource</em>'s location protocol, port, and ref (aka, - * anchor) must equal this objects</li> - * <li><em>codesource</em>'s location host must imply this object's - * location host, as determined by contructing - * <code>SocketPermission</code> objects from each with no - * action list and using that classes's <code>implies</code> - * method</li> - * <li>If this object's location file ends with a '/', then the - * specified object's location file must start with this - * object's location file. Otherwise, the specified object's - * location file must start with this object's location file - * with the '/' character appended to it.</li> - * </ul></li> - * </ol></li> - * </ol> - * - * <p>For example, each of these locations imply the location - * "http://java.sun.com/classes/foo.jar":</p> - * - * <pre> - * http: - * http://*.sun.com/classes/* - * http://java.sun.com/classes/- - * http://java.sun.com/classes/foo.jar - * </pre> - * - * <p>Note that the code source with null location and null certificates implies - * all other code sources.</p> - * - * @param cs the <code>CodeSource</code> to test against this object - * @return true if this specified <code>CodeSource</code> is implied - */ - public boolean implies(CodeSource cs) - { - if (cs == null) - return false; - // First check the certificate list. - if (certs != null && (cs.certs == null || ! certs.containsAll(cs.certs))) - return false; - // Next check the location. - if (location == null) - return true; - if (cs.location == null - || ! location.getProtocol().equals(cs.location.getProtocol()) - || (location.getPort() != -1 - && location.getPort() != cs.location.getPort()) - || (location.getRef() != null - && ! location.getRef().equals(cs.location.getRef()))) - return false; - if (location.getHost() != null) - { - String their_host = cs.location.getHost(); - if (their_host == null) - return false; - SocketPermission our_sockperm = - new SocketPermission(location.getHost(), "accept"); - SocketPermission their_sockperm = - new SocketPermission(their_host, "accept"); - if (! our_sockperm.implies(their_sockperm)) - return false; - } - String our_file = location.getFile(); - if (our_file != null) - { - if (! our_file.endsWith("/")) - our_file += "/"; - String their_file = cs.location.getFile(); - if (their_file == null - || ! their_file.startsWith(our_file)) - return false; - } - return true; - } - - /** - * This method returns a <code>String</code> that represents this object. - * The result is in the format <code>"(" + getLocation()</code> followed - * by a space separated list of certificates (or "<no certificates>"), - * followed by <code>")"</code>. - * - * @return a <code>String</code> for this object - */ - public String toString() - { - StringBuffer sb = new StringBuffer("(").append(location); - if (certs == null || certs.isEmpty()) - sb.append(" <no certificates>"); - else - { - Iterator iter = certs.iterator(); - for (int i = certs.size(); --i >= 0; ) - sb.append(' ').append(iter.next()); - } - return sb.append(")").toString(); - } - - /** - * Reads this object from a serialization stream. - * - * @param s the input stream - * @throws IOException if reading fails - * @throws ClassNotFoundException if deserialization fails - * @serialData this reads the location, then expects an int indicating the - * number of certificates. Each certificate is a String type - * followed by an int encoding length, then a byte[] encoding - */ - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException - { - s.defaultReadObject(); - int count = s.readInt(); - certs = new HashSet(); - while (--count >= 0) - { - String type = (String) s.readObject(); - int bytes = s.readInt(); - byte[] encoded = new byte[bytes]; - for (int i = 0; i < bytes; i++) - encoded[i] = s.readByte(); - ByteArrayInputStream stream = new ByteArrayInputStream(encoded); - try - { - CertificateFactory factory = CertificateFactory.getInstance(type); - certs.add(factory.generateCertificate(stream)); - } - catch (CertificateException e) - { - // XXX Should we ignore this certificate? - } - } - } - - /** - * Writes this object to a serialization stream. - * - * @param s the output stream - * @throws IOException if writing fails - * @serialData this writes the location, then writes an int indicating the - * number of certificates. Each certificate is a String type - * followed by an int encoding length, then a byte[] encoding - */ - private void writeObject(ObjectOutputStream s) throws IOException - { - s.defaultWriteObject(); - if (certs == null) - s.writeInt(0); - else - { - int count = certs.size(); - s.writeInt(count); - Iterator iter = certs.iterator(); - while (--count >= 0) - { - Certificate c = (Certificate) iter.next(); - s.writeObject(c.getType()); - byte[] encoded; - try - { - encoded = c.getEncoded(); - } - catch (CertificateEncodingException e) - { - // XXX Should we ignore this certificate? - encoded = null; - } - if (encoded == null) - s.writeInt(0); - else - { - s.writeInt(encoded.length); - for (int i = 0; i < encoded.length; i++) - s.writeByte(encoded[i]); - } - } - } - } - - //jnode openjdk - /** - * Constructs a CodeSource and associates it with the specified - * location and set of code signers. - * - * @param url the location (URL). - * @param signers the code signers. It may be null. The contents of the - * array are copied to protect against subsequent modification. - * - * @since 1.5 - */ - public CodeSource(URL url, CodeSigner[] signers) { - this.location = url; - - // Copy the supplied signers - if (signers != null) { - this.signers = signers.clone(); - } - } - /* - * The code signers. - */ - private transient CodeSigner[] signers = null; -} // class CodeSource Deleted: trunk/core/src/classpath/java/java/security/Policy.java =================================================================== --- trunk/core/src/classpath/java/java/security/Policy.java 2009-03-29 07:49:07 UTC (rev 5176) +++ trunk/core/src/classpath/java/java/security/Policy.java 2009-03-29 07:55:25 UTC (rev 5177) @@ -1,406 +0,0 @@ -/* Policy.java --- Policy Manager Class - Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.security; - -import java.util.Collections; -import java.util.Enumeration; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * <code>Policy</code> is an abstract class for managing the system security - * policy for the Java application environment. It specifies which permissions - * are available for code from various sources. The security policy is - * represented through a subclass of <code>Policy</code>. - * - * <p>Only one <code>Policy</code> is in effect at any time. A - * {@link ProtectionDomain} initializes itself with information from this class - * on the set of permssions to grant.</p> - * - * <p>The location for the actual <code>Policy</code> could be anywhere in any - * form because it depends on the Policy implementation. The default system is - * in a flat ASCII file or it could be in a database.</p> - * - * <p>The current installed <code>Policy</code> can be accessed with - * {@link #getPolicy()} and changed with {@link #setPolicy(Policy)} if the code - * has the correct permissions.</p> - * - * <p>The {@link #refresh()} method causes the <code>Policy</code> instance to - * refresh/reload its configuration. The method used to refresh depends on the - * <code>Policy</code> implementation.</p> - * - * <p>When a protection domain initializes its permissions, it uses code like - * the following:</p> - * - * <code> - * policy = Policy.getPolicy(); - * PermissionCollection perms = policy.getPermissions(myCodeSource); - * </code> - * - * <p>The protection domain passes the <code>Policy</code> handler a - * {@link CodeSource} instance which contains the codebase URL and a public key. - * The <code>Policy</code> implementation then returns the proper set of - * permissions for that {@link CodeSource}.</p> - * - * <p>The default <code>Policy</code> implementation can be changed by setting - * the "policy.provider" security provider in the "java.security" file to the - * correct <code>Policy</code> implementation class.</p> - * - * @author Mark Benvenuto - * @see CodeSource - * @see PermissionCollection - * @see SecureClassLoader - * @since 1.2 - */ -public abstract class Policy -{ - private static Policy currentPolicy; - - /** Map of ProtectionDomains to PermissionCollections for this instance. */ - private Map pd2pc = null; - - /** - * A read-only empty PermissionCollection instance. - * @since 1.6 - */ - public static final PermissionCollection UNSUPPORTED_EMPTY_COLLECTION = - new UnsupportedEmptyCollection(); - - public Policy() - { - } - - /** - * Returns the currently installed <code>Policy</code> handler. The value - * should not be cached as it can be changed any time by - * {@link #setPolicy(Policy)}. - * - * @return the current <code>Policy</code>. - * @throws SecurityException - * if a {@link SecurityManager} is installed which disallows this - * operation. - */ - public static Policy getPolicy() - { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkPermission(new SecurityPermission("getPolicy")); - - return getCurrentPolicy(); - } - - /** - * Sets the <code>Policy</code> handler to a new value. - * - * @param policy - * the new <code>Policy</code> to use. - * @throws SecurityException - * if a {@link SecurityManager} is installed which disallows this - * operation. - */ - public static void setPolicy(Policy policy) - { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) - sm.checkPermission(new SecurityPermission("setPolicy")); - - setup(policy); - currentPolicy = policy; - } - - private static void setup(final Policy policy) - { - if (policy.pd2pc == null) - policy.pd2pc = Collections.synchronizedMap(new LinkedHashMap()); - - ProtectionDomain pd = policy.getClass().getProtectionDomain(); - if (pd.getCodeSource() != null) - { - PermissionCollection pc = null; - if (currentPolicy != null) - pc = currentPolicy.getPermissions(pd); - - if (pc == null) // assume it has all - { - pc = new Permissions(); - pc.add(new AllPermission()); - } - - policy.pd2pc.put(pd, pc); // add the mapping pd -> pc - } - } - - /** - * Ensures/forces loading of the configured policy provider, while bypassing - * the {@link SecurityManager} checks for <code>"getPolicy"</code> security - * permission. Needed by {@link ProtectionDomain}. - */ - static Policy getCurrentPolicy() - { - // FIXME: The class name of the Policy provider should really be sourced - // from the "java.security" configuration file. For now, just hard-code - // a stub implementation. - if (currentPolicy == null) - { - String pp = System.getProperty ("policy.provider"); - if (pp != null) - try - { - currentPolicy = (Policy) Class.forName(pp).newInstance(); - } - catch (Exception e) - { - // Ignored. - } - - if (currentPolicy == null) - currentPolicy = new gnu.java.security.provider.DefaultPolicy(); - } - return currentPolicy; - } - - /** - * Tests if <code>currentPolicy</code> is not <code>null</code>, - * thus allowing clients to not force loading of any policy - * provider; needed by {@link ProtectionDomain}. - */ - static boolean isSet() - { - return currentPolicy != null; - } - - /** - * Returns the set of Permissions allowed for a given {@link CodeSource}. - * - * @param codesource - * the {@link CodeSource} for which, the caller needs to find the - * set of granted permissions. - * @return a set of permissions for {@link CodeSource} specified by the - * current <code>Policy</code>. - * @throws SecurityException - * if a {@link SecurityManager} is installed which disallows this - * operation. - */ - public abstract PermissionCollection getPermissions(CodeSource codesource); - - /** - * Returns the set of Permissions allowed for a given {@link ProtectionDomain}. - * - * @param domain - * the {@link ProtectionDomain} for which, the caller needs to find - * the set of granted permissions. - * @return a set of permissions for {@link ProtectionDomain} specified by the - * current <code>Policy.</code>. - * @since 1.4 - * @see ProtectionDomain - * @see SecureClassLoader - */ - public PermissionCollection getPermissions(ProtectionDomain domain) - { - if (domain == null) - return new Permissions(); - - if (pd2pc == null) - setup(this); - - PermissionCollection result = (PermissionCollection) pd2pc.get(domain); - if (result != null) - { - Permissions realResult = new Permissions(); - for (Enumeration e = result.elements(); e.hasMoreElements(); ) - realResult.add((Permission) e.nextElement()); - - return realResult; - } - - result = getPermissions(domain.getCodeSource()); - if (result == null) - result = new Permissions(); - - PermissionCollection pc = domain.getPermissions(); - if (pc != null) - for (Enumeration e = pc.elements(); e.hasMoreElements(); ) - result.add((Permission) e.nextElement()); - - return result; - } - - /** - * Checks if the designated {@link Permission} is granted to a designated - * {@link ProtectionDomain}. - * - * @param domain - * the {@link ProtectionDomain} to test. - * @param permission - * the {@link Permission} to check. - * @return <code>true</code> if <code>permission</code> is implied by a - * permission granted to this {@link ProtectionDomain}. Returns - * <code>false</code> otherwise. - * @since 1.4 - * @see ProtectionDomain - */ - public boolean implies(ProtectionDomain domain, Permission permission) - { - if (pd2pc == null) - setup(this); - - PermissionCollection pc = (PermissionCollection) pd2pc.get(domain); - if (pc != null) - return pc.implies(permission); - - boolean result = false; - pc = getPermissions(domain); - if (pc != null) - { - result = pc.implies(permission); - pd2pc.put(domain, pc); - } - - return result; - } - - /** - * Causes this <code>Policy</code> instance to refresh / reload its - * configuration. The method used to refresh depends on the concrete - * implementation. - */ - public abstract void refresh(); - - /** - * This subclass is returned by the getInstance calls. All Policy calls - * are delegated to the underlying PolicySpi. - */ - private static class PolicyDelegate extends Policy { - - private PolicySpi spi; - private Provider p; - private String type; - private Policy.Parameters params; - - private PolicyDelegate(PolicySpi spi, Provider p, - String type, Policy.Parameters params) { - this.spi = spi; - this.p = p; - this.type = type; - this.params = params; -} - - public String getType() { return type; } - - public Policy.Parameters getParameters() { return params; } - - public Provider getProvider() { return p; } - - public PermissionCollection getPermissions(CodeSource codesource) { - return spi.engineGetPermissions(codesource); - } - public PermissionCollection getPermissions(ProtectionDomain domain) { - return spi.engineGetPermissions(domain); - } - public boolean implies(ProtectionDomain domain, Permission perm) { - return spi.engineImplies(domain, perm); - } - public void refresh() { - spi.engineRefresh(); - } - } - - /** - * This represents a marker interface for Policy parameters. - * - * @since 1.6 - */ - public static interface Parameters { } - - /** - * This class represents a read-only empty PermissionCollection object that - * is returned from the <code>getPermissions(CodeSource)</code> and - * <code>getPermissions(ProtectionDomain)</code> - * methods in the Policy class when those operations are not - * supported by the Policy implementation. - */ - private static class UnsupportedEmptyCollection - extends PermissionCollection { - - private Permissions perms; - - /** - * Create a read-only empty PermissionCollection object. - */ - public UnsupportedEmptyCollection() { - this.perms = new Permissions(); - perms.setReadOnly(); - } - - /** - * Adds a permission object to the current collection of permission - * objects. - * - * @param permission the Permission object to add. - * - * @exception SecurityException - if this PermissionCollection object - * has been marked readonly - */ - public void add(Permission permission) { - perms.add(permission); - } - - /** - * Checks to see if the specified permission is implied by the - * collection of Permission objects held in this PermissionCollection. - * - * @param permission the Permission object to compare. - * - * @return true if "permission" is implied by the permissions in - * the collection, false if not. - */ - public boolean implies(Permission permission) { - return perms.implies(permission); - } - - /** - * Returns an enumeration of all the Permission objects in the - * collection. - * - * @return an enumeration of all the Permissions. - */ - public Enumeration<Permission> elements() { - return perms.elements(); - } - } -} Deleted: trunk/core/src/classpath/java/java/security/ProtectionDomain.java =================================================================== --- trunk/core/src/classpath/java/java/security/ProtectionDomain.java 2009-03-29 07:49:07 UTC (rev 5176) +++ trunk/core/src/classpath/java/java/security/ProtectionDomain.java 2009-03-29 07:55:25 UTC (rev 5177) @@ -1,250 +0,0 @@ -/* ProtectionDomain.java -- A security domain - Copyright (C) 1998, 2003, 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.security; - -import gnu.classpath.SystemProperties; - -/** - * This class represents a group of classes, along with their granted - * permissions. The classes are identified by a {@link CodeSource}. Thus, any - * class loaded from the specified {@link CodeSource} is treated as part of - * this domain. The set of permissions is represented by an instance of - * {@link PermissionCollection}. - * - * <p>Every class in the system will belong to one and only one - * <code>ProtectionDomain</code>.</p> - * - * @author Aaron M. Renn (ar...@ur...) - * @version 0.0 - */ -public class ProtectionDomain -{ - /** This is the <code>CodeSource</code> for this protection domain. */ - private CodeSource code_source; - - /** This is the set of permissions granted to this domain. */ - private PermissionCollection perms; - - /** The {@link ClassLoader} associated with this domain. */ - private ClassLoader classloader; - - /** The array of Principals associated with this domain.. */ - private Principal[] principals; - - /** Post 1.4 the policy may be refreshed! use false for pre 1.4. */ - private boolean staticBinding; - - /** - * Initializes a new instance of <code>ProtectionDomain</code> representing - * the specified {@link CodeSource} and set of permissions. No permissions - * can be added later to the {@link PermissionCollection} and this contructor - * will call the <code>setReadOnly</code> method on the specified set of - * permissions. - * - * @param codesource - * The {@link CodeSource} for this domain. - * @param permissions - * The set of permissions for this domain. - * @see PermissionCollection#setReadOnly() - */ - public ProtectionDomain(CodeSource codesource, PermissionCollection permissions) - { - this(codesource, permissions, null, null, true); - } - - /** - * This method initializes a new instance of <code>ProtectionDomain</code> - * given its {@link CodeSource}, granted permissions, associated - * {@link ClassLoader} and {@link Principal}s. - * - * <p>Similar to the previous constructor, if the designated set of - * permissions is not <code>null</code>, the <code>setReadOnly</code> method - * is called on that set.</p> - * - * @param codesource - * The {@link CodeSource} for this domain. - * @param permissions - * The permission set for this domain. - * @param classloader - * the ClassLoader associated with this domain. - * @param principals - * the array of {@link Principal}s associated with this domain. - * @since 1.4 - * @see PermissionCollection#setReadOnly() - */ - public ProtectionDomain(CodeSource codesource, - PermissionCollection permissions, - ClassLoader classloader, Principal[] principals) - { - this(codesource, permissions, classloader, principals, false); - } - - private ProtectionDomain(CodeSource codesource, - PermissionCollection permissions, - ClassLoader classloader, Principal[] principals, - boolean staticBinding) - { - super(); - - code_source = codesource; - if (permissions != null) - { - perms = permissions; - perms.setReadOnly(); - } - - this.classloader = classloader; - this.principals = - (principals != null ? (Principal[]) principals.clone() : new Principal[0]); - this.staticBinding = staticBinding; - } - - /** - * Returns the {@link CodeSource} of this domain. - * - * @return the {@link CodeSource} of this domain. - * @since 1.2 - */ - public final CodeSource getCodeSource() - { - return code_source; - } - - /** - * Returns the {@link ClassLoader} of this domain. - * - * @return the {@link ClassLoader} of this domain. - * @since 1.4 - */ - public final ClassLoader getClassLoader() - { - return this.classloader; - } - - /** - * Returns a clone of the {@link Principal}s of this domain. - * - * @return a clone of the {@link Principal}s of this domain. - * @since 1.4 - */ - public final Principal[] getPrincipals() - { - return (Principal[]) principals.clone(); - } - - /** - * Returns the {@link PermissionCollection} of this domain. - * - * @return The {@link PermissionCollection} of this domain. - */ - public final PermissionCollection getPermissions() - { - return perms; - } - - /** - * Tests whether or not the specified {@link Permission} is implied by the - * set of permissions granted to this domain. - * - * @param permission - * the {@link Permission} to test. - * @return <code>true</code> if the specified {@link Permission} is implied - * for this domain, <code>false</code> otherwise. - */ - public boolean implies(Permission permission) - { - if (staticBinding) - return (perms == null ? false : perms.implies(permission)); - // Else dynamically bound. Do we have it? - // NOTE: this will force loading of Policy.currentPolicy - return Policy.getCurrentPolicy().implies(this, permission); - } - - /** - * Returns a string representation of this object. It will include the - * {@link CodeSource} and set of permissions associated with this domain. - * - * @return A string representation of this object. - */ - public String toString() - { - String linesep = SystemProperties.getProperty("line.separator"); - StringBuffer sb = new StringBuffer("ProtectionDomain (").append(linesep); - - if (code_source == null) - sb.append("CodeSource:null"); - else - sb.append(code_source); - - sb.append(linesep); - if (classloader == null) - sb.append("ClassLoader:null"); - else - sb.append(classloader); - - sb.append(linesep); - sb.append("Principals:"); - if (principals != null && principals.length > 0) - { - sb.append("["); - Principal pal; - for (int i = 0; i < principals.length; i++) - { - pal = principals[i]; - sb.append("'").append(pal.getName()) - .append("' of type ").append(pal.getClass().getName()); - if (i < principals.length-1) - sb.append(", "); - } - sb.append("]"); - } - else - sb.append("none"); - - sb.append(linesep); - if (!staticBinding) // include all but dont force loading Policy.currentPolicy - if (Policy.isSet()) - sb.append(Policy.getCurrentPolicy().getPermissions(this)); - else // fallback on this one's permissions - sb.append(perms); - else - sb.append(perms); - - return sb.append(linesep).append(")").append(linesep).toString(); - } -} Deleted: trunk/core/src/classpath/java/java/security/SecureClassLoader.java =================================================================== --- trunk/core/src/classpath/java/java/security/SecureClassLoader.java 2009-03-29 07:49:07 UTC (rev 5176) +++ trunk/core/src/classpath/java/java/security/SecureClassLoader.java 2009-03-29 07:55:25 UTC (rev 5177) @@ -1,200 +0,0 @@ -/* SecureClassLoader.java --- A Secure Class Loader - Copyright (C) 1999, 2004 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - -package java.security; - -import java.util.HashMap; -import sun.security.util.Debug; - -/** - * A Secure Class Loader for loading classes with additional - * support for specifying code source and permissions when - * they are retrieved by the system policy handler. - * - * @since 1.2 - * - * @author Mark Benvenuto - */ -public class SecureClassLoader extends ClassLoader -{ - java.util.WeakHashMap protectionDomainCache = new java.util.WeakHashMap(); - - protected SecureClassLoader(ClassLoader parent) - { - super(parent); - SecurityManager sm = System.getSecurityManager(); - if(sm != null) - sm.checkCreateClassLoader(); - } - - protected SecureClassLoader() - { - SecurityManager sm = System.getSecurityManager(); - if(sm != null) - sm.checkCreateClassLoader(); - } - - /** - * Creates a class using an array of bytes and a - * CodeSource. - * - * @param name the name to give the class. null if unknown. - * @param b the data representing the classfile, in classfile format. - * @param off the offset into the data where the classfile starts. - * @param len the length of the classfile data in the array. - * @param cs the CodeSource for the class or null when unknown. - * - * @return the class that was defined and optional CodeSource. - * - * @exception ClassFormatError if the byte array is not in proper classfile format. - */ - protected final Class defineClass(String name, byte[] b, int off, int len, - CodeSource cs) - { - if (cs != null) - { - ProtectionDomain protectionDomain; - - synchronized (protectionDomainCache) - { - protectionDomain = (ProtectionDomain)protectionDomainCache.get(cs); - } - - if (protectionDomain == null) - { - protectionDomain - = new ProtectionDomain(cs, getPermissions(cs), this, null); - synchronized (protectionDomainCache) - { - ProtectionDomain domain - = (ProtectionDomain)protectionDomainCache.get(cs); - if (domain == null) - protectionDomainCache.put(cs, protectionDomain); - else - protectionDomain = domain; - } - } - return super.defineClass(name, b, off, len, protectionDomain); - } - else - return super.defineClass(name, b, off, len); - } - - /** - * Returns a PermissionCollection for the specified CodeSource. - * The default implementation invokes - * java.security.Policy.getPermissions. - * - * This method is called by defineClass that takes a CodeSource - * arguement to build a proper ProtectionDomain for the class - * being defined. - */ - protected PermissionCollection getPermissions(CodeSource cs) - { - Policy policy = Policy.getCurrentPolicy(); - return policy.getPermissions(cs); - } - - //jnode + openjdk -/** - * Converts a {@link java.nio.ByteBuffer <tt>ByteBuffer</tt>} - * into an instance of class <tt>Class</tt>, with an optional CodeSource. - * Before the class can be used it must be resolved. - * <p> - * If a non-null CodeSource is supplied a ProtectionDomain is - * constructed and associated with the class being defined. - * <p> - * @param name the expected name of the class, or <code>null</code> - * if not known, using '.' and not '/' as the separator - * and without a trailing ".class" suffix. - * @param b the bytes that make up the class data. The bytes from positions - * <tt>b.position()</tt> through <tt>b.position() + b.limit() -1</tt> - * should have the format of a valid class file as defined by the - * <a href="http://java.sun.com/docs/books/vmspec/">Java Virtual - * Machine Specification</a>. - * @param cs the associated CodeSource, or <code>null</code> if none - * @return the <code>Class</code> object created from the data, - * and optional CodeSource. - * @exception ClassFormatError if the data did not contain a valid class - * @exception SecurityException if an attempt is made to add this class - * to a package that contains classes that were signed by - * a different set of certificates than this class, or if - * the class name begins with "java.". - * - * @since 1.5 - */ - protected final Class<?> defineClass(String name, java.nio.ByteBuffer b, - CodeSource cs) - { - if (cs == null) - return defineClass(name, b, (ProtectionDomain)null); - else - return defineClass(name, b, getProtectionDomain(cs)); - } - - - // HashMap that maps CodeSource to ProtectionDomain - private HashMap<CodeSource, ProtectionDomain> pdcache = - new HashMap<CodeSource, ProtectionDomain>(11); - - private static final Debug debug = Debug.getInstance("scl"); - /* - * Returned cached ProtectionDomain for the specified CodeSource. - */ - private ProtectionDomain getProtectionDomain(CodeSource cs) { - if (cs == null) - return null; - - - ProtectionDomain pd = null; - synchronized (pdcache) { - pd = pdcache.get(cs); - if (pd == null) { - PermissionCollection perms = getPermissions(cs); - pd = new ProtectionDomain(cs, perms, this, null); - if (pd != null) { - pdcache.put(cs, pd); - if (debug != null) { - debug.println(" getPermissions "+ pd); - debug.println(""); - } - } - } - } - return pd; - } -} Modified: trunk/core/src/core/org/jnode/security/JNodePolicy.java =================================================================== --- trunk/core/src/core/org/jnode/security/JNodePolicy.java 2009-03-29 07:49:07 UTC (rev 5176) +++ trunk/core/src/core/org/jnode/security/JNodePolicy.java 2009-03-29 07:55:25 UTC (rev 5177) @@ -140,7 +140,8 @@ final String id = ext.getDeclaringPluginDescriptor().getId(); final URL url; try { - url = new URL("plugin:" + id + "!/"); + //note: ".../-" match everything starting with "plugin:" + id + "!/" + url = new URL("plugin:" + id + "!/-"); final ClassLoader cl = ext.getDeclaringPluginDescriptor() .getPluginClassLoader(); final CodeSource cs = new CodeSource(url, (Certificate[]) null); Added: trunk/core/src/openjdk/java/java/security/CodeSource.java =================================================================== --- trunk/core/src/openjdk/java/java/security/CodeSource.java (rev 0) +++ trunk/core/src/openjdk/java/java/security/CodeSource.java 2009-03-29 07:55:25 UTC (rev 5177) @@ -0,0 +1,639 @@ +/* + * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.security; + + +import java.net.URL; +import java.net.SocketPermission; +import java.util.ArrayList; +import java.util.List; +import java.util.Hashtable; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.security.cert.*; + +/** + * + * <p>This class extends the concept of a codebase to + * encapsulate not only the location (URL) but also the certificate chains + * that were used to verify signed code originating from that location. + * + * @author Li Gong + * @author Roland Schemers + */ + +public class CodeSource implements java.io.Serializable { + + private static final long serialVersionUID = 4977541819976013951L; + + /** + * The code location. + * + * @serial + */ + private URL location; + + /* + * The code signers. + */ + private transient CodeSigner[] signers = null; + + /* + * The code signers. Certificate chains are concatenated. + */ + private transient java.security.cert.Certificate certs[] = null; + + // cached SocketPermission used for matchLocation + private transient SocketPermission sp; + + // for generating cert paths + private transient CertificateFactory factory = null; + + /** + * Constructs a CodeSource and associates it with the specified + * location and set of certificates. + * + * @param url the location (URL). + * + * @param certs the certificate(s). It may be null. The contents of the + * array are copied to protect against subsequent modification. + */ + public CodeSource(URL url, java.security.cert.Certificate certs[]) { + this.location = url; + + // Copy the supplied certs + if (certs != null) { + this.certs = certs.clone(); + } + } + + /** + * Constructs a CodeSource and associates it with the specified + * location and set of code signers. + * + * @param url the location (URL). + * @param signers the code signers. It may be null. The contents of the + * array are copied to protect against subsequent modification. + * + * @since 1.5 + */ + public CodeSource(URL url, CodeSigner[] signers) { + this.location = url; + + // Copy the supplied signers + if (signers != null) { + this.signers = signers.clone(); + } + } + + /** + * Returns the hash code value for this object. + * + * @return a hash code value for this object. + */ + + public int hashCode() { + if (location != null) + return location.hashCode(); + else + return 0; + } + + /** + * Tests for equality between the specified object and this + * object. Two CodeSource objects are considered equal if their + * locations are of identical value and if their signer certificate + * chains are of identical value. It is not required that + * the certificate chains be in the same order. + * + * @param obj the object to test for equality with this object. + * + * @return true if the objects are considered equal, false otherwise. + */ + public boolean equals(Object obj) { + if (obj == this) + return true; + + // objects types must be equal + if (!(obj instanceof CodeSource)) + return false; + + CodeSource cs = (CodeSource) obj; + + // URLs must match + if (location == null) { + // if location is null, then cs.location must be null as well + if (cs.location != null) return false; + } else { + // if location is not null, then it must equal cs.location + if (!location.equals(cs.location)) return false; + } + + // certs must match + return matchCerts(cs, true); + } + + /** + * Returns the location associated with this CodeSource. + * + * @return the location (URL). + */ + public final URL getLocation() { + /* since URL is practically immutable, returning itself is not + a security problem */ + return this.location; + } + + /** + * Returns the certificates associated with this CodeSource. + * <p> + * If this CodeSource object was created using the + * {@link #CodeSource(URL url, CodeSigner[] signers)} + * constructor then its certificate chains are extracted and used to + * create an array of Certificate objects. Each signer certificate is + * followed by its supporting certificate chain (which may be empty). + * Each signer certificate and its supporting certificate chain is ordered + * bottom-to-top (i.e., with the signer certificate first and the (root) + * certificate authority last). + * + * @return A copy of the certificates array, or null if there is none. + */ + public final java.security.cert.Certificate[] getCertificates() { + if (certs != null) { + return certs.clone(); + + } else if (signers != null) { + // Convert the code signers to certs + ArrayList<java.security.cert.Certificate> certChains = + new ArrayList<java.security.cert.Certificate>(); + for (int i = 0; i < signers.length; i++) { + certChains.addAll( + signers[i].getSignerCertPath().getCertificates()); + } + certs = certChains.toArray( + new java.security.cert.Certificate[certChains.size()]); + return certs.clone(); + + } else { + return null; + } + } + + /** + * Returns the code signers associated with this CodeSource. + * <p> + * If this CodeSource object was created using the + * {@link #CodeSource(URL url, Certificate[] certs)} + * constructor then its certificate chains are extracted and used to + * create an array of CodeSigner objects. Note that only X.509 certificates + * are examined - all other certificate types are ignored. + * + * @return A copy of the code signer array, or null if there is none. + * + * @since 1.5 + */ + public final CodeSigner[] getCodeSigners() { + if (signers != null) { + return signers.clone(); + + } else if (certs != null) { + // Convert the certs to code signers + signers = convertCertArrayToSignerArray(certs); + return signers.clone(); + + } else { + return null; + } + } + + /** + * Returns true if this CodeSource object "implies" the specified CodeSource. + * <P> + * More specifically, this method makes the following checks, in order. + * If any fail, it returns false. If they all succeed, it returns true.<p> + * <ol> + * <li> <i>codesource</i> must not be null. + * <li> If this object's certificates are not null, then all + * of this object's certificates must be present in <i>codesource</i>'s + * certificates. + * <li> If this object's location (getLocation()) is not null, then the + * following checks are made against this object's location and + * <i>codesource</i>'s:<p> + * <ol> + * <li> <i>codesource</i>'s location must not be null. + * + * <li> If this object's location + * equals <i>codesource</i>'s location, then return true. + * + * <li> This object's protocol (getLocation().getProtocol()) must be + * equal to <i>codesource</i>'s protocol. + * + * <li> If this object's host (getLocation().getHost()) is not null, + * then the SocketPermission + * constructed with this object's host must imply the + * SocketPermission constructed with <i>codesource</i>'s host. + * + * <li> If this object's port (getLocation().getPort()) is not + * equal to -1 (that is, if a port is specified), it must equal + * <i>codesource</i>'s port. + * + * <li> If this object's file (getLocation().getFile()) doesn't equal + * <i>codesource</i>'s file, then the following checks are made: + * If this object's file ends with "/-", + * then <i>codesource</i>'s file must start with this object's + * file (exclusive the trailing "-"). + * If this object's file ends with a "/*", + * then <i>codesource</i>'s file must start with this object's + * file and must not have any further "/" separators. + * If this object's file doesn't end with a "/", + * then <i>codesource</i>'s file must match this object's + * file with a '/' appended. + * + * <li> If this object's reference (getLocation().getRef()) is + * not null, it must equal <i>codesource</i>'s reference. + * + * </ol> + * </ol> + * <p> + * For example, the codesource objects with the following locations + * and null certificates all imply + * the codesource with the location "http://java.sun.com/classes/foo.jar" + * and null certificates: + * <pre> + * http: + * http://*.sun.com/classes/* + * http://java.sun.com/classes/- + * http://java.sun.com/classes/foo.jar + * </pre> + * + * Note that if this CodeSource has a null location and a null + * certificate chain, then it implies every other CodeSource. + * + * @param codesource CodeSource to compare against. + * + * @return true if the specified codesource is implied by this codesource, + * false if not. + */ + + public boolean implies(CodeSource codesource) + { + if (codesource == null) + return false; + + return matchCerts(codesource, false) && matchLocation(codesource); + } + + /** + * Returns true if all the certs in this + * CodeSource are also in <i>that</i>. + * + * @param that the CodeSource to check against. + * @param strict If true then a strict equality match is performed. + * Otherwise a subset match is performed. + */ + private boolean matchCerts(CodeSource that, boolean strict) + { + boolean match; + + // match any key + if (certs == null && signers == null) { + if (strict) { + return (that.certs == null && that.signers == null); + } else { + return true; + } + // both have signers + } else if (signers != null && that.signers != null) { + if (strict && signers.length != that.signers.length) { + return false; + } + for (int i = 0; i < signers.length; i++) { + match = false; + for (int j = 0; j < that.signers.length; j++) { + if (signers[i].equals(that.signers[j])) { + match = true; + break; + } + } + if (!match) return false; + } + return true; + + // both have certs + } else if (certs != null && that.certs != null) { + if (strict && certs.length != that.certs.length) { + return false; + } + for (int i = 0; i < certs.length; i++) { + match = false; + for (int j = 0; j < that.certs.length; j++) { + if (certs[i].equals(that.certs[j])) ... [truncated message content] |
From: <ls...@us...> - 2009-03-29 10:53:23
|
Revision: 5179 http://jnode.svn.sourceforge.net/jnode/?rev=5179&view=rev Author: lsantha Date: 2009-03-29 10:53:16 +0000 (Sun, 29 Mar 2009) Log Message: ----------- Added support for pure Java ISO CDROM image creation in the build - based on a patch by Gilles Duboscq. Modified Paths: -------------- trunk/all/build-x86.xml trunk/all/build.xml trunk/jnode.properties.dist Added Paths: ----------- trunk/builder/lib/iso9660.jar trunk/builder/lib/sabre.jar trunk/core/lib/ant-contrib-1.0b3.jar Modified: trunk/all/build-x86.xml =================================================================== --- trunk/all/build-x86.xml 2009-03-29 09:40:23 UTC (rev 5178) +++ trunk/all/build-x86.xml 2009-03-29 10:53:16 UTC (rev 5179) @@ -275,10 +275,36 @@ <copy file="${my-lib.dir}/grub.s1" todir="@{dir}/boot/grub" /> <copy file="${my-lib.dir}/grub.s2" todir="@{dir}/boot/grub" /> <copy file="${grub.menu.cdrom}" tofile="@{dir}/boot/grub/menu.lst" /> - <exec executable="mkisofs"> - <arg line="-o @{destfile} -R -b boot/grub/eltorito.s2 -no-emul-boot -boot-load-size 4 -boot-info-table @{dir}" /> - </exec> - </sequential> + <if> + <equals arg1="${jnode.enable.mkisofs}" arg2="true" /> + <then> + <!-- Fail on a Windows platform if there are spaces in the root dir's pathname. It will + lead to mkisofs dying with a misleading error message. bluebit / crawley 2008-05-03 --> + <fail message="Cannot build JNode from a directory with spaces in the pathname."> + <condition> + <and> + <contains string="${os.name}" substring="windows" casesensitive="false" /> + <contains string="${root.dir}" substring=" " casesensitive="false" /> + </and> + </condition> + </fail> + <exec executable="mkisofs"> + <arg line="-o @{destfile} -R -b boot/grub/eltorito.s2 -no-emul-boot -boot-load-size 4 -boot-info-table @{dir}" /> + </exec> + </then> + <else> + <taskdef name="jiic-iso" classname="de.tu_darmstadt.informatik.rbg.hatlak.iso9660.ISOTask" classpathref="cp-x86" /> + <jiic-iso basedir="@{dir}" + destfile="@{destfile}" + enableRockRidge="true" + mkisofsCompatibility="true" + bootImage="@{dir}/boot/grub/eltorito.s2" + bootImageSectorCount="4" + genBootInfoTable="true" + /> + </else> + </if> + </sequential> </macrodef> <!-- Create a full distributable bootable CDROM image --> Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2009-03-29 09:40:23 UTC (rev 5178) +++ trunk/all/build.xml 2009-03-29 10:53:16 UTC (rev 5179) @@ -1,5 +1,6 @@ <project name="JNode" default="help" basedir="."> - + <!-- if task is used from this --> + <taskdef resource="net/sf/antcontrib/antcontrib.properties"/> <!-- before including jnode.xml, we must set this property --> <condition property="memoryMaximumSize" value="1512m" else="768m"> <os arch="amd64"/> @@ -68,6 +69,9 @@ <property name="derbytools.jar" value="${root.dir}/distr/lib/derbytools.jar" /> <property name="nanoxml-java.jar" value="${root.dir}/shell/lib/nanoxml-2.2.3.jar" /> + <property name="iso9660.jar" value="${root.dir}/builder/lib/iso9660.jar" /> + <property name="sabre.jar" value="${root.dir}/builder/lib/sabre.jar" /> + <!-- libraries needed to run tests --> <property name="jmock-cglib.jar" value="${root.dir}/core/lib/jmock-cglib-1.0.1.jar"/> <property name="jmock.jar" value="${root.dir}/core/lib/jmock-1.0.1.jar"/> @@ -128,6 +132,8 @@ <pathelement location="${derby.jar}"/> <pathelement location="${derbynet.jar}"/> <pathelement location="${derbytools.jar}"/> + <pathelement location="${iso9660.jar}"/> + <pathelement location="${sabre.jar}"/> </path> <path id="cp-jnode"> @@ -158,17 +164,6 @@ </patternset> <target name="prepare"> - <!-- Fail on a Windows platform if there are spaces in the root dir's pathname. It will - lead to mkisofs dying with a misleading error message. bluebit / crawley 2008-05-03 --> - <fail message="Cannot build JNode from a directory with spaces in the pathname."> - <condition> - <and> - <contains string="${os.name}" substring="windows" casesensitive="false" /> - <contains string="${root.dir}" substring=" " casesensitive="false" /> - </and> - </condition> - </fail> - <fail message="Java Runtime version 1.6 needed. Your version is: ${java.runtime.version}"> <condition> <not> Added: trunk/builder/lib/iso9660.jar =================================================================== (Binary files differ) Property changes on: trunk/builder/lib/iso9660.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/builder/lib/sabre.jar =================================================================== (Binary files differ) Property changes on: trunk/builder/lib/sabre.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/core/lib/ant-contrib-1.0b3.jar =================================================================== (Binary files differ) Property changes on: trunk/core/lib/ant-contrib-1.0b3.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/jnode.properties.dist =================================================================== --- trunk/jnode.properties.dist 2009-03-29 09:40:23 UTC (rev 5178) +++ trunk/jnode.properties.dist 2009-03-29 10:53:16 UTC (rev 5179) @@ -103,3 +103,8 @@ # ----------------------------------------------- #jnode.security.enabled=true + +# ----------------------------------------------- +# Custom build tools +# ----------------------------------------------- +# jnode.enable.mkisofs=true This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-03-30 11:06:50
|
Revision: 5184 http://jnode.svn.sourceforge.net/jnode/?rev=5184&view=rev Author: lsantha Date: 2009-03-30 11:06:44 +0000 (Mon, 30 Mar 2009) Log Message: ----------- Fixed fs testsuite to be runnable outside JNode. Modified Paths: -------------- trunk/core/src/classpath/vm/java/io/VMIOUtils.java trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java trunk/fs/src/test/org/jnode/test/support/ContextManager.java Removed Paths: ------------- trunk/core/src/classpath/vm/java/io/VMFileSystemAPI.java Deleted: trunk/core/src/classpath/vm/java/io/VMFileSystemAPI.java =================================================================== --- trunk/core/src/classpath/vm/java/io/VMFileSystemAPI.java 2009-03-30 11:03:18 UTC (rev 5183) +++ trunk/core/src/classpath/vm/java/io/VMFileSystemAPI.java 2009-03-30 11:06:44 UTC (rev 5184) @@ -1,155 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.io; - -import org.jnode.java.io.VMFileHandle; - -/** - * The implementation of this interface is used to connect the java.io package with the JNode - * filesystem services. - * The file paths given to the various methods are absolute and canonical. - * - * @modif add mkDir mkFile Yves Galante (yve...@jm...) 01.04.2004 - * @author epr - */ -public interface VMFileSystemAPI { - - /** - * Does a given file exist? - */ - public boolean fileExists(String file); - - /** - * Is the given File a plain file? - */ - public boolean isFile(String file); - - /** - * Is the given File a directory? - */ - public boolean isDirectory(String file); - - /** - * Can the given file be read? - * - * @param file - */ - public boolean canRead(String file) throws IOException; - - /** - * Can the given file be written to? - * - * @param file - */ - public boolean canWrite(String file) throws IOException; - - public boolean canExecute(String file) throws IOException; - - /** - * Gets the length in bytes of the given file or 0 if the file does not exist. - * - * @param file - */ - public long getLength(String file); - - /** - * Gets the last modification date of the given file. - * - * @param file - */ - public long getLastModified(String file); - - /** - * Sets the last modification date of the given file. - * - * @param file - */ - public void setLastModified(String file, long time) throws IOException; - - /** - * Mark the given file as readonly. - * - * @param file - * @throws IOException - */ - public void setReadOnly(String file) throws IOException; - - public boolean setReadable(String normalizedPath, boolean enable, - boolean owneronly) throws IOException; - - public boolean setWritable(String normalizedPath, boolean enable, - boolean owneronly) throws IOException; - - public boolean setExecutable(String normalizedPath, boolean enable, - boolean owneronly) throws IOException; - - /** - * Delete the given file. - * - * @param file - * @throws IOException - */ - public void delete(String file) throws IOException; - - /** - * This method returns an array of filesystem roots. - */ - public File[] getRoots(); - - /** - * Gets an array of names of all entries of the given directory. All names are relative to the - * given directory. - * - * @param directory - * @param filter - */ - public String[] list(String directory) throws IOException; - - /** - * Open a given file - * - * @param file - * @throws IOException - */ - public VMFileHandle open(String file, VMOpenMode mode) throws IOException; - - /** - * Make a directory - * - * @param file - * @throws IOException - */ - public boolean mkDir(String file) throws IOException; - - /** - * Make a file - * - * @param file - * @throws IOException - */ - public boolean mkFile(String file, VMOpenMode mode) throws IOException; - - public long getTotalSpace(String normalizedPath) throws IOException; - - public long getFreeSpace(String normalizedPath) throws IOException; - - public long getUsableSpace(String normalizedPath) throws IOException; -} Modified: trunk/core/src/classpath/vm/java/io/VMIOUtils.java =================================================================== --- trunk/core/src/classpath/vm/java/io/VMIOUtils.java 2009-03-30 11:03:18 UTC (rev 5183) +++ trunk/core/src/classpath/vm/java/io/VMIOUtils.java 2009-03-30 11:06:44 UTC (rev 5184) @@ -22,6 +22,7 @@ import org.jnode.vm.annotation.SharedStatics; import org.jnode.java.io.VMFileHandle; +import org.jnode.java.io.VMFileSystemAPI; //todo serious review is needed /** Modified: trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java 2009-03-30 11:03:18 UTC (rev 5183) +++ trunk/fs/src/fs/org/jnode/fs/service/FileSystemService.java 2009-03-30 11:06:44 UTC (rev 5184) @@ -21,7 +21,7 @@ package org.jnode.fs.service; import java.io.IOException; -import java.io.VMFileSystemAPI; +import org.jnode.java.io.VMFileSystemAPI; import java.util.Collection; import java.util.Map; Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2009-03-30 11:03:18 UTC (rev 5183) +++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2009-03-30 11:06:44 UTC (rev 5184) @@ -23,7 +23,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.VMFileSystemAPI; +import org.jnode.java.io.VMFileSystemAPI; import java.io.VMOpenMode; import java.util.ArrayList; import java.util.HashMap; Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java 2009-03-30 11:03:18 UTC (rev 5183) +++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemPlugin.java 2009-03-30 11:06:44 UTC (rev 5184) @@ -22,7 +22,7 @@ import java.io.IOException; import java.io.VMFile; -import java.io.VMFileSystemAPI; +import org.jnode.java.io.VMFileSystemAPI; import java.io.VMIOUtils; import java.security.AccessController; import java.security.PrivilegedAction; Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java 2009-03-30 11:03:18 UTC (rev 5183) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java 2009-03-30 11:06:44 UTC (rev 5184) @@ -38,6 +38,7 @@ import org.jnode.test.fs.filesystem.tests.FileFSTest; import org.jnode.test.fs.filesystem.tests.TreeFSTest; import org.jnode.util.OsUtils; +import javax.naming.NamingException; /** * This class runs a suite of functional tests on the JNode file system @@ -49,13 +50,22 @@ * @author cr...@jn... */ public class FSTestSuite extends JFuncSuite { + private static boolean setup = false; public static void main(String[] args) throws Throwable { - if (!OsUtils.isJNode()) { + setUp(); + + JFuncRunner.run(FSTestSuite.suite()); + //JFuncRunner.main(new String[]{"-v", "--color", FSTestSuite.class.getName()}); + //JFuncRunner.main(new String[]{"-v", FSTestSuite.class.getName()}); + } + + private static void setUp() throws NamingException { + if (!setup && !OsUtils.isJNode()) { // We are not running in JNode, emulate a JNode environment. - + InitialNaming.setNameSpace(new BasicNameSpace()); - - // Build a plugin descriptor that is sufficient for the FileSystemPlugin to + + // Build a plugin descriptor that is sufficient for the FileSystemPlugin to // configure file system types for testing. DummyPluginDescriptor desc = new DummyPluginDescriptor(true); DummyExtensionPoint ep = new DummyExtensionPoint("types", "org.jnode.fs.types", "types"); @@ -67,17 +77,15 @@ extension.addElement(element); ep.addExtension(extension); } - + FileSystemService fss = new FileSystemPlugin(desc); InitialNaming.bind(FileSystemService.class, fss); } - - JFuncRunner.run(FSTestSuite.suite()); - //JFuncRunner.main(new String[]{"-v", "--color", FSTestSuite.class.getName()}); - //JFuncRunner.main(new String[]{"-v", FSTestSuite.class.getName()}); + setup = true; } public static JFuncSuite suite() throws Throwable { + setUp(); JFuncSuite suite = new JFuncSuite(); for (FSTestConfig config : new FSConfigurations()) { Modified: trunk/fs/src/test/org/jnode/test/support/ContextManager.java =================================================================== --- trunk/fs/src/test/org/jnode/test/support/ContextManager.java 2009-03-30 11:03:18 UTC (rev 5183) +++ trunk/fs/src/test/org/jnode/test/support/ContextManager.java 2009-03-30 11:06:44 UTC (rev 5184) @@ -37,6 +37,7 @@ import org.jnode.test.fs.driver.stubs.StubDeviceManager; import org.jnode.test.fs.driver.stubs.StubNameSpace; import org.jnode.test.fs.filesystem.config.OsType; +import org.jnode.emu.naming.BasicNameSpace; public class ContextManager { @@ -88,7 +89,7 @@ protected void initNaming() throws PluginException { if (OsType.OTHER_OS.isCurrentOS()) { - NameSpace namespace = new StubNameSpace(); + NameSpace namespace = new BasicNameSpace(); InitialNaming.setNameSpace(namespace); populateNameSpace(namespace); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-03-30 11:18:54
|
Revision: 5186 http://jnode.svn.sourceforge.net/jnode/?rev=5186&view=rev Author: crawley Date: 2009-03-30 11:18:43 +0000 (Mon, 30 Mar 2009) Log Message: ----------- Replace '<<' and '>>' in XML attribute strings with character entities. Modified Paths: -------------- trunk/core/descriptors/com.sun.tools.javac.xml trunk/core/descriptors/org.apache.tools.ant.xml trunk/core/descriptors/org.classpath.ext.security.xml trunk/core/descriptors/org.classpath.ext.xml.ws.tools.xml trunk/core/descriptors/org.classpath.tools.xml trunk/core/descriptors/org.jmock.xml trunk/core/descriptors/sun.tools.xml trunk/distr/descriptors/derby.xml trunk/distr/descriptors/jetty.xml trunk/distr/descriptors/net.wimpi.telnetd.xml trunk/distr/descriptors/org.jnode.apps.httpd.xml trunk/fs/descriptors/org.jnode.driver.block.xml trunk/fs/descriptors/org.jnode.fs.command.xml trunk/fs/descriptors/org.jnode.fs.ext2.test.command.xml trunk/fs/descriptors/org.jnode.fs.jfat.command.xml trunk/fs/descriptors/org.jnode.test.fs.xml trunk/gui/descriptors/org.jnode.test.gui.xml trunk/net/descriptors/org.jnode.net.command.xml trunk/net/descriptors/org.jnode.net.ipv4.xml trunk/shell/descriptors/js.xml trunk/shell/descriptors/org.beanshell.xml trunk/shell/descriptors/org.jnode.shell.bjorne.xml trunk/shell/descriptors/org.jnode.shell.command.ant.xml trunk/shell/descriptors/org.jnode.shell.command.bsh.xml trunk/shell/descriptors/org.jnode.shell.command.driver.console.xml trunk/shell/descriptors/org.jnode.shell.command.log4j.xml trunk/shell/descriptors/org.jnode.shell.command.posix.xml trunk/shell/descriptors/org.jnode.shell.command.test.xml trunk/shell/descriptors/org.jnode.shell.command.xml trunk/shell/descriptors/org.jnode.shell.help.xml trunk/shell/descriptors/org.jnode.shell.syntax.xml trunk/shell/descriptors/org.jnode.shell.xml trunk/shell/descriptors/org.jnode.test.shell.xml Modified: trunk/core/descriptors/com.sun.tools.javac.xml =================================================================== --- trunk/core/descriptors/com.sun.tools.javac.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/core/descriptors/com.sun.tools.javac.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -55,8 +55,8 @@ <extension point="org.jnode.security.permissions"> <permission class="java.lang.RuntimePermission" name="exitVM"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> - <permission class="java.util.PropertyPermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.util.PropertyPermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.util.PropertyPermission" name="*" actions="read"/> Modified: trunk/core/descriptors/org.apache.tools.ant.xml =================================================================== --- trunk/core/descriptors/org.apache.tools.ant.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/core/descriptors/org.apache.tools.ant.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -31,7 +31,7 @@ <extension point="org.jnode.security.permissions"> <!-- <permission class="java.io.FilePermission" name="build.xml" actions="read"/> --> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> <permission class="java.lang.RuntimePermission" name="setSecurityManager" actions="*" /> <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> <permission class="java.lang.RuntimePermission" name="exitVM" actions="*" /> Modified: trunk/core/descriptors/org.classpath.ext.security.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.security.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/core/descriptors/org.classpath.ext.security.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -61,7 +61,7 @@ <permission class="java.lang.RuntimePermission" name="createClassLoader"/> <permission class="java.lang.RuntimePermission" name="setContextClassLoader"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="org.jnode.security.JNodePermission" name="getVmThread"/> <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> <permission class="java.net.SocketPermission" name="*" actions="resolve"/> Modified: trunk/core/descriptors/org.classpath.ext.xml.ws.tools.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.xml.ws.tools.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/core/descriptors/org.classpath.ext.xml.ws.tools.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -91,8 +91,8 @@ <extension point="org.jnode.security.permissions"> <permission class="java.lang.RuntimePermission" name="exitVM"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> - <permission class="java.util.PropertyPermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.util.PropertyPermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.util.PropertyPermission" name="*" actions="read"/> <permission class="java.lang.RuntimePermission" name="getProtectionDomain"/> <permission class="java.lang.RuntimePermission" name="createClassLoader"/> Modified: trunk/core/descriptors/org.classpath.tools.xml =================================================================== --- trunk/core/descriptors/org.classpath.tools.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/core/descriptors/org.classpath.tools.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -35,7 +35,7 @@ <permission class="java.lang.RuntimePermission" name="createClassLoader"/> <permission class="java.lang.RuntimePermission" name="setContextClassLoader"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="org.jnode.security.JNodePermission" name="getVmThread"/> <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> <permission class="java.net.SocketPermission" name="*" actions="resolve"/> Modified: trunk/core/descriptors/org.jmock.xml =================================================================== --- trunk/core/descriptors/org.jmock.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/core/descriptors/org.jmock.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -20,6 +20,6 @@ </runtime> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="delete"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="delete"/> </extension> </plugin> \ No newline at end of file Modified: trunk/core/descriptors/sun.tools.xml =================================================================== --- trunk/core/descriptors/sun.tools.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/core/descriptors/sun.tools.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -43,7 +43,7 @@ <permission class="java.lang.RuntimePermission" name="createClassLoader"/> <permission class="java.lang.RuntimePermission" name="setContextClassLoader"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="org.jnode.security.JNodePermission" name="getVmThread"/> <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> <permission class="java.net.SocketPermission" name="*" actions="resolve"/> Modified: trunk/distr/descriptors/derby.xml =================================================================== --- trunk/distr/descriptors/derby.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/distr/descriptors/derby.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -61,7 +61,7 @@ <permission class="java.lang.RuntimePermission" name="readFileDescriptor" actions="*" /> <permission class="java.lang.RuntimePermission" name="createClassLoader" actions="*" /> <permission class="java.net.SocketPermission" name="*:1527" actions="accept,connect,listen"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> </extension> </plugin> Modified: trunk/distr/descriptors/jetty.xml =================================================================== --- trunk/distr/descriptors/jetty.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/distr/descriptors/jetty.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -69,7 +69,7 @@ <permission class="java.lang.RuntimePermission" name="modifyThread"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> <permission class="java.lang.RuntimePermission" name="setIO"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.net.SocketPermission" name="*" actions="resolve"/> <permission class="java.net.SocketPermission" name="*:1-" actions="resolve,listen"/> <permission class="java.security.SecurityPermission" name="getPolicy"/> Modified: trunk/distr/descriptors/net.wimpi.telnetd.xml =================================================================== --- trunk/distr/descriptors/net.wimpi.telnetd.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/distr/descriptors/net.wimpi.telnetd.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -29,7 +29,7 @@ <permission class="java.lang.RuntimePermission" name="exitVM"/> <!-- do we need them all like in org.jnode.shell ? only "jnode.prompt" has been checked --> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> <permission class="java.lang.RuntimePermission" name="modifyThread"/> <permission class="java.lang.RuntimePermission" name="setIO"/> Modified: trunk/distr/descriptors/org.jnode.apps.httpd.xml =================================================================== --- trunk/distr/descriptors/org.jnode.apps.httpd.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/distr/descriptors/org.jnode.apps.httpd.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -31,7 +31,7 @@ <permission class="java.util.PropertyPermission" name="user.dir" actions="read"/> <permission class="java.util.PropertyPermission" name="file.encoding" actions="read"/> <permission class="org.jnode.net.NetPermission" name="bootpClient"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.net.SocketPermission" name="*:80" actions="resolve,listen"/> </extension> </plugin> Modified: trunk/fs/descriptors/org.jnode.driver.block.xml =================================================================== --- trunk/fs/descriptors/org.jnode.driver.block.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/fs/descriptors/org.jnode.driver.block.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -18,7 +18,7 @@ </runtime> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> <permission class="java.util.PropertyPermission" name="user.dir" actions="read"/> </extension> </plugin> \ No newline at end of file Modified: trunk/fs/descriptors/org.jnode.fs.command.xml =================================================================== --- trunk/fs/descriptors/org.jnode.fs.command.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/fs/descriptors/org.jnode.fs.command.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -112,7 +112,7 @@ </extension> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> <permission class="java.net.SocketPermission" name="*:0-" actions="connect,resolve"/> <permission class="java.util.PropertyPermission" name="user.dir" actions="read,write"/> <permission class="java.util.PropertyPermission" name="*" actions="read,write"/> Modified: trunk/fs/descriptors/org.jnode.fs.ext2.test.command.xml =================================================================== --- trunk/fs/descriptors/org.jnode.fs.ext2.test.command.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/fs/descriptors/org.jnode.fs.ext2.test.command.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -26,7 +26,7 @@ </extension> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <!--<permission class="java.net.SocketPermission" name="*:0-" actions="connect,resolve"/>--> <permission class="java.util.PropertyPermission" name="user.dir" actions="read,write"/> </extension> Modified: trunk/fs/descriptors/org.jnode.fs.jfat.command.xml =================================================================== --- trunk/fs/descriptors/org.jnode.fs.jfat.command.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/fs/descriptors/org.jnode.fs.jfat.command.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -40,6 +40,6 @@ </extension> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> </extension> </plugin> \ No newline at end of file Modified: trunk/fs/descriptors/org.jnode.test.fs.xml =================================================================== --- trunk/fs/descriptors/org.jnode.test.fs.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/fs/descriptors/org.jnode.test.fs.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -65,7 +65,7 @@ <permission class="java.util.PropertyPermission" name="os.name" actions="read"/> <permission class="java.util.PropertyPermission" name="java.io.tmpdir" actions="read"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> <permission class="java.lang.reflect.ReflectPermission" name="*" actions="suppressAccessChecks"/> <permission class="java.net.SocketPermission" name="*" actions="resolve,listen,connect"/> Modified: trunk/gui/descriptors/org.jnode.test.gui.xml =================================================================== --- trunk/gui/descriptors/org.jnode.test.gui.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/gui/descriptors/org.jnode.test.gui.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -40,7 +40,7 @@ <permission class="java.util.PropertyPermission" name="user.home" actions="read"/> <permission class="java.util.PropertyPermission" name="gnu.awt.dispatchthread.priority" actions="read"/> <permission class="java.util.PropertyPermission" name="gnu.javax.swing.DebugGraphics" actions="read"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> </extension> <extension point="org.jnode.shell.aliases"> Modified: trunk/net/descriptors/org.jnode.net.command.xml =================================================================== --- trunk/net/descriptors/org.jnode.net.command.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/net/descriptors/org.jnode.net.command.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -137,6 +137,6 @@ <permission class="org.jnode.net.NetPermission" name="bootpClient"/> <permission class="org.jnode.net.NetPermission" name="dhcpClient"/> <permission class="org.jnode.net.NetPermission" name="wget"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> </extension> </plugin> Modified: trunk/net/descriptors/org.jnode.net.ipv4.xml =================================================================== --- trunk/net/descriptors/org.jnode.net.ipv4.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/net/descriptors/org.jnode.net.ipv4.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -50,7 +50,7 @@ <permission class="java.util.PropertyPermission" name="dns.search" actions="read,write"/> <!-- TFTP !?! --> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.util.PropertyPermission" name="user.dir" actions="read"/> <permission class="java.net.SocketPermission" name="*:69" actions="connect,resolve"/> Modified: trunk/shell/descriptors/js.xml =================================================================== --- trunk/shell/descriptors/js.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/js.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -19,7 +19,7 @@ </extension> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.lang.RuntimePermission" name="setSecurityManager" actions="*" /> <permission class="java.lang.RuntimePermission" name="createClassLoader" actions="*" /> <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> Modified: trunk/shell/descriptors/org.beanshell.xml =================================================================== --- trunk/shell/descriptors/org.beanshell.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.beanshell.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -15,7 +15,7 @@ </runtime> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.lang.RuntimePermission" name="setSecurityManager" actions="*" /> <permission class="java.lang.RuntimePermission" name="createClassLoader" actions="*" /> <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> Modified: trunk/shell/descriptors/org.jnode.shell.bjorne.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.bjorne.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.bjorne.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -20,7 +20,7 @@ </runtime> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.lang.RuntimePermission" name="setSecurityManager" actions="*" /> <permission class="java.lang.RuntimePermission" name="createClassLoader"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> Modified: trunk/shell/descriptors/org.jnode.shell.command.ant.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.ant.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.command.ant.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -24,7 +24,7 @@ </extension> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.lang.RuntimePermission" name="setSecurityManager" actions="*" /> <permission class="java.lang.RuntimePermission" name="createClassLoader" actions="*" /> <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> Modified: trunk/shell/descriptors/org.jnode.shell.command.bsh.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.bsh.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.command.bsh.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -33,7 +33,7 @@ </extension> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.lang.RuntimePermission" name="setSecurityManager" actions="*" /> <permission class="java.lang.RuntimePermission" name="createClassLoader" actions="*" /> <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> Modified: trunk/shell/descriptors/org.jnode.shell.command.driver.console.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.driver.console.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.command.driver.console.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -38,7 +38,7 @@ </extension> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> <permission class="java.lang.RuntimePermission" name="modifyThread"/> <permission class="java.lang.RuntimePermission" name="setIO"/> Modified: trunk/shell/descriptors/org.jnode.shell.command.log4j.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.log4j.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.command.log4j.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -37,7 +37,7 @@ <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> </extension> </plugin> \ No newline at end of file Modified: trunk/shell/descriptors/org.jnode.shell.command.posix.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.posix.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.command.posix.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -41,7 +41,7 @@ <permission class="java.lang.RuntimePermission" name="setContextClassLoader"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="org.jnode.security.JNodePermission" name="getVmThread"/> <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> <permission class="java.net.SocketPermission" name="*" actions="resolve"/> Modified: trunk/shell/descriptors/org.jnode.shell.command.test.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.test.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.command.test.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -47,7 +47,7 @@ <permission class="java.util.PropertyPermission" name="os.name" actions="read"/> <permission class="java.util.PropertyPermission" name="java.io.tmpdir" actions="read"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> <permission class="java.lang.reflect.ReflectPermission" name="*" actions="suppressAccessChecks"/> </extension> Modified: trunk/shell/descriptors/org.jnode.shell.command.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.command.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -379,7 +379,7 @@ <permission class="java.lang.RuntimePermission" name="createClassLoader"/> <permission class="java.lang.RuntimePermission" name="setContextClassLoader"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="org.jnode.security.JNodePermission" name="getVmThread"/> <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> <permission class="java.net.SocketPermission" name="*" actions="resolve"/> Modified: trunk/shell/descriptors/org.jnode.shell.help.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.help.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.help.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -14,7 +14,7 @@ </requires> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> </extension> </plugin> Modified: trunk/shell/descriptors/org.jnode.shell.syntax.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.syntax.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.syntax.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -13,7 +13,7 @@ </requires> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> </extension> </plugin> Modified: trunk/shell/descriptors/org.jnode.shell.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.shell.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -33,7 +33,7 @@ <extension-point id="syntaxes" name="System command syntaxes"/> <extension point="org.jnode.security.permissions"> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write"/> <permission class="java.lang.RuntimePermission" name="createClassLoader"/> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> <permission class="java.lang.RuntimePermission" name="modifyThread"/> Modified: trunk/shell/descriptors/org.jnode.test.shell.xml =================================================================== --- trunk/shell/descriptors/org.jnode.test.shell.xml 2009-03-30 11:15:17 UTC (rev 5185) +++ trunk/shell/descriptors/org.jnode.test.shell.xml 2009-03-30 11:18:43 UTC (rev 5186) @@ -43,7 +43,7 @@ <permission class="java.lang.RuntimePermission" name="exitVM"/> <permission class="java.util.PropertyPermission" name="*" actions="read,write"/> <permission class="org.jnode.security.JNodePermission" name="loadPlugin"/> - <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> <permission class="java.io.FilePermission" name="/jnode/tmp/test" actions="read,write,delete"/> <permission class="java.io.FilePermission" name="/jnode/tmp/test/-" actions="read,write,delete"/> </extension> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-03-30 12:20:35
|
Revision: 5187 http://jnode.svn.sourceforge.net/jnode/?rev=5187&view=rev Author: crawley Date: 2009-03-30 12:20:03 +0000 (Mon, 30 Mar 2009) Log Message: ----------- Checkstyle (mostly) and javadoc fixes. Modified Paths: -------------- trunk/builder/src/builder/org/jnode/build/PluginList.java trunk/core/src/core/org/jnode/assembler/x86/X86TextAssembler.java trunk/core/src/core/org/jnode/log4j/config/JNodeSystemAppender.java trunk/core/src/core/org/jnode/vm/VmSystem.java trunk/core/src/core/org/jnode/vm/bytecode/TypeStack.java trunk/core/src/core/org/jnode/vm/classmgr/VmPrimitiveClass.java trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86StackManager.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseIOHandler.java trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.java trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemTypeManager.java trunk/gui/src/awt/org/jnode/awt/image/JNodeBufferedImageGraphics.java trunk/gui/src/awt/org/jnode/awt/image/JNodeBufferedImageGraphics2D.java trunk/gui/src/awt/org/jnode/awt/image/JNodeImageGraphics.java trunk/shell/src/shell/org/jnode/shell/CommandShell.java Modified: trunk/builder/src/builder/org/jnode/build/PluginList.java =================================================================== --- trunk/builder/src/builder/org/jnode/build/PluginList.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/builder/src/builder/org/jnode/build/PluginList.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -28,7 +28,6 @@ import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; -import java.util.Arrays; import java.util.Hashtable; import java.util.Iterator; import java.util.List; Modified: trunk/core/src/core/org/jnode/assembler/x86/X86TextAssembler.java =================================================================== --- trunk/core/src/core/org/jnode/assembler/x86/X86TextAssembler.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/core/src/core/org/jnode/assembler/x86/X86TextAssembler.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -1155,7 +1155,7 @@ + "+" + dstIdxReg + "*" + scale + "]," + srcReg); } - public void writeMOV(int operandSize, GPR dstReg, GPR srcReg, + public void writeMOV(int operandSize, GPR dstReg, GPR srcReg, GPR srcIdxReg, int scale, int srcDisp) { println("\tmov " + dstReg + "," + size(operandSize) + "[" + srcReg + disp(srcDisp) + "+" + srcIdxReg + "*" + scale + "]"); Modified: trunk/core/src/core/org/jnode/log4j/config/JNodeSystemAppender.java =================================================================== --- trunk/core/src/core/org/jnode/log4j/config/JNodeSystemAppender.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/core/src/core/org/jnode/log4j/config/JNodeSystemAppender.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -25,14 +25,14 @@ import java.io.PrintStream; import java.io.Writer; -import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Layout; import org.apache.log4j.WriterAppender; /** * Custom Log4j appender class for appending to the current System.out or System.err. - * Unlike {@link ConsoleAppender}, this class tracks the changes to the System streams. - * (This is an interim solution until we get the equivalent of /dev/console.) + * Unlike {@link org.apache.log4j.ConsoleAppender}, this class tracks the changes to + * the System streams. (This is an interim solution until JNode gets the equivalent + * of UNIX /dev/console.) * * @author cr...@jn... */ Modified: trunk/core/src/core/org/jnode/vm/VmSystem.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmSystem.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/core/src/core/org/jnode/vm/VmSystem.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -955,7 +955,7 @@ public void write(int b) throws IOException { final char ch = (char) (b & 0xFF); Unsafe.debug(ch); - if(data == null) { + if (data == null) { synchronized (this) { data = new StringBuffer(); } @@ -969,9 +969,7 @@ * @return data written to the system output stream */ public String getData() { - if(data == null) - return ""; - return data.toString(); + return (data == null) ? "" : data.toString(); } } Modified: trunk/core/src/core/org/jnode/vm/bytecode/TypeStack.java =================================================================== --- trunk/core/src/core/org/jnode/vm/bytecode/TypeStack.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/core/src/core/org/jnode/vm/bytecode/TypeStack.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -20,10 +20,8 @@ package org.jnode.vm.bytecode; -import org.jnode.vm.JvmType; - /** - * A TypeStack is a stack of internal type numbers represented as {@link JvmType} + * A TypeStack is a stack of internal type numbers represented as {@link org.jnode.vm.JvmType} * values; i.e. integers. * * @author Ewout Prangsma (ep...@us...) @@ -35,7 +33,7 @@ private int tos; /** - * Initialize a new instance. + * Create a new empty TypeStack instance. */ public TypeStack() { stack = new byte[8]; @@ -43,14 +41,18 @@ } /** - * Initialize a new instance. + * Create a new empty TypeStack instance as copy of an existing one. + * @param src the stack whose contents is to be copied. */ public TypeStack(TypeStack src) { copyFrom(src); } /** - * Initialize a new instance. + * Set this stack's contents to be same as another stack. The + * current state of the stack (if any) is discarded. + * + * @param src the stack whose contents is to be copied. */ public void copyFrom(TypeStack src) { if (src != null) { @@ -64,14 +66,14 @@ } /** - * Empty the tstack. + * Empty the TypeStack. */ public void clear() { tos = 0; } /** - * Is this stack empty. + * Is this TypeStack empty. * * @return {@code true} if the stack is empty, otherwise {@code false}. */ @@ -80,7 +82,7 @@ } /** - * Is this stack equal to the given TypeStack. Note that this is an + * Is this TypeStack equal to the given TypeStack. Note that this is an * overload for {@link java.lang.Object#equals(java.lang.Object)} not * an override. */ @@ -99,11 +101,6 @@ return true; } - /** - * Is this stack equal to the given object? - * - * @see java.lang.Object#equals(java.lang.Object) - */ public boolean equals(Object o) { if (o instanceof TypeStack) { return equals((TypeStack) o); @@ -113,9 +110,9 @@ } /** - * Push a type of the stack. + * Push a type onto the TypeStack. * - * @param type + * @param type a {@link org.jnode.vm.JvmType} value */ public final void push(int type) { if (tos == stack.length) grow(); @@ -123,7 +120,10 @@ } /** - * Pop an item of the stack and return its given type. + * Pop a type from the TypeStack and return it. + * + * @return a {@link org.jnode.vm.JvmType} value + * @throws Error if the stack is empty */ public final int pop() { if (tos <= 0) { @@ -133,11 +133,12 @@ } /** - * Pop an item of the stack and expect a given type. + * Pop a type from the stack and check that it is the expected type. * - * @param type + * @param type the expected {@link org.jnode.vm.JvmType} value. + * @throws Error if there is a type mismatch */ - public final void pop(int type) { + public final void pop(int type) throws Error { if (tos <= 0) { throw new Error("Stack is empty"); } @@ -163,7 +164,7 @@ * @param stackIndex the stack index. This should be a number in the range * {@code 0 .. size() - 1} inclusive where {@code size() - 1} is the top element * on the stack. - * @return the internal type number at the given offset. + * @return the {@link org.jnode.vm.JvmType} value at the given offset. */ public final int getType(int stackIndex) { return stack[stackIndex]; Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmPrimitiveClass.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmPrimitiveClass.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmPrimitiveClass.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -22,16 +22,14 @@ import java.security.ProtectionDomain; -import org.jnode.vm.JvmType; - /** * @author Ewout Prangsma (ep...@us...) */ public final class VmPrimitiveClass<T> extends VmNormalClass<T> { /** - * Is this a floatingpoint type? + * Is this a floating point type? */ private final boolean floatingPoint; @@ -41,7 +39,7 @@ private final boolean wide; /** - * JvmType of this type + * The {@link org.jnode.vm.JvmType} for this type */ private final int jvmType; @@ -84,9 +82,9 @@ } /** - * Gets the {@link JvmType} value for this type. + * Gets the {@link org.jnode.vm.JvmType} value for this type. * - * @return the {@link JvmType} (integer) value + * @return the {@link org.jnode.vm.JvmType} (integer) value */ public int getJvmType() { return jvmType; Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86StackManager.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86StackManager.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86StackManager.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -21,7 +21,6 @@ package org.jnode.vm.x86.compiler; import org.jnode.assembler.x86.X86Register; -import org.jnode.vm.JvmType; /** * @author Ewout Prangsma (ep...@us...) @@ -32,7 +31,7 @@ * Write code to push the contents of the given register on the stack * * @param reg - * @see JvmType + * @param jvmType the type of the register contents as a {@link org.jnode.vm.JvmType}. */ public void writePUSH(int jvmType, X86Register.GPR reg); @@ -41,7 +40,7 @@ * * @param lsbReg * @param msbReg - * @see JvmType + * @param jvmType the type of the registers contents as a {@link org.jnode.vm.JvmType}. */ public void writePUSH64(int jvmType, X86Register.GPR lsbReg, X86Register.GPR msbReg); @@ -50,7 +49,7 @@ * Write code to push a 64-bit word on the stack * * @param reg - * @see JvmType + * @param jvmType the type of the register contents as a {@link org.jnode.vm.JvmType}. */ public void writePUSH64(int jvmType, X86Register.GPR64 reg); } Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -1647,9 +1647,8 @@ * @see org.jnode.vm.bytecode.BytecodeVisitor#visit_dup2_x2() */ public final void visit_dup2_x2() { + // TODO: port to ORP style - // TODO: port to ORP style - // Push all on the stack, since this opcode is just too complicated vstack.push(eContext); @@ -1670,7 +1669,7 @@ os.writePUSH(helper.ABX); // Value2 os.writePUSH(helper.AAX); // Value1 - // Now update the operandstack + // Now update the operand stack // cope with brain-dead definition from Sun (look-like somebody there // was to eager to optimize this and it landed in the compiler... if (c2 == 2) { Modified: trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseIOHandler.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseIOHandler.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/distr/src/apps/org/jnode/apps/vmware/disk/handler/sparse/SparseIOHandler.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -22,7 +22,6 @@ import java.io.IOException; import java.io.RandomAccessFile; -import org.apache.log4j.Logger; import org.jnode.apps.vmware.disk.descriptor.Descriptor; import org.jnode.apps.vmware.disk.extent.Extent; import org.jnode.apps.vmware.disk.handler.IOHandler; Modified: trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.java =================================================================== --- trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -37,20 +37,17 @@ import org.jnode.driver.DeviceNotFoundException; import org.jnode.driver.DriverException; import org.jnode.driver.bus.ide.IDEDevice; -import org.jnode.fs.service.FileSystemService; -import org.jnode.fs.service.def.FileSystemPlugin; -import org.jnode.emu.naming.BasicNameSpace; import org.jnode.emu.plugin.model.DummyConfigurationElement; import org.jnode.emu.plugin.model.DummyExtension; import org.jnode.emu.plugin.model.DummyExtensionPoint; import org.jnode.emu.plugin.model.DummyPluginDescriptor; +import org.jnode.fs.service.FileSystemService; +import org.jnode.fs.service.def.FileSystemPlugin; import org.jnode.naming.InitialNaming; -import org.jnode.naming.NameSpace; -import org.jnode.plugin.PluginDescriptor; -import org.jnode.test.fs.driver.stubs.StubDeviceManager; import org.jnode.test.fs.filesystem.config.FSType; import org.jnode.util.OsUtils; + public class DeviceUtils { private static final long DEFAULT_FILE_SIZE = 1024 * 1024; private static final Logger log = Logger.getLogger(FileDeviceView.class); Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -20,18 +20,16 @@ package org.jnode.fs.ftpfs; -import org.jnode.fs.FSDirectory; -import org.jnode.fs.ReadOnlyFileSystemException; - import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedExceptionAction; +import org.jnode.fs.FSDirectory; +import org.jnode.fs.ReadOnlyFileSystemException; + import com.enterprisedt.net.ftp.FTPFile; /** Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFileSystem.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -48,7 +48,7 @@ FTPFileSystem(final FTPFSDevice device, final FTPFileSystemType type) { this.type = type; - this.client = AccessController.doPrivileged(new PrivilegedAction<FTPClient>(){ + this.client = AccessController.doPrivileged(new PrivilegedAction<FTPClient>() { @Override public FTPClient run() { return new FTPClient(); Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660FileSystemType.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -27,7 +27,6 @@ import org.jnode.driver.block.FSBlockDeviceAPI; import org.jnode.fs.BlockDeviceFileSystemType; import org.jnode.fs.FileSystemException; -import org.jnode.fs.FileSystemType; import org.jnode.partitions.PartitionTableEntry; /** Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/fs/src/fs/org/jnode/fs/service/def/FileHandleManager.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -172,7 +172,7 @@ hasWriters = false; } } else { - throw new IOException("FileHandle is not known in FileData.close!!"); + throw new IOException("FileHandle is not known in FileData.close!!"); } } Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemTypeManager.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemTypeManager.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemTypeManager.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -54,7 +54,7 @@ * * @throws IllegalArgumentException if typesEP is null; */ - protected FileSystemTypeManager(ExtensionPoint typesEP) throws IllegalArgumentException{ + protected FileSystemTypeManager(ExtensionPoint typesEP) throws IllegalArgumentException { this.typesEP = typesEP; if (typesEP == null) { throw new IllegalArgumentException("The types extension-point cannot be null"); Modified: trunk/gui/src/awt/org/jnode/awt/image/JNodeBufferedImageGraphics.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/image/JNodeBufferedImageGraphics.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/gui/src/awt/org/jnode/awt/image/JNodeBufferedImageGraphics.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -20,8 +20,6 @@ package org.jnode.awt.image; -import gnu.java.awt.java2d.AbstractGraphics2D; - import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.image.BufferedImage; @@ -83,7 +81,7 @@ * Returns a WritableRaster that is used by this class to perform the * rendering in. It is not necessary that the target surface immediately * reflects changes in the raster. Updates to the raster are notified via - * {@link AbstractGraphics2D#updateRaster}. + * {@link gnu.java.awt.java2d.AbstractGraphics2D#updateRaster}. * * @return the destination raster */ Modified: trunk/gui/src/awt/org/jnode/awt/image/JNodeBufferedImageGraphics2D.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/image/JNodeBufferedImageGraphics2D.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/gui/src/awt/org/jnode/awt/image/JNodeBufferedImageGraphics2D.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -20,8 +20,6 @@ package org.jnode.awt.image; -import gnu.java.awt.java2d.AbstractGraphics2D; - import java.awt.GraphicsConfiguration; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; @@ -96,7 +94,7 @@ * Returns a WritableRaster that is used by this class to perform the * rendering in. It is not necessary that the target surface immediately * reflects changes in the raster. Updates to the raster are notified via - * {@link AbstractGraphics2D#updateRaster}. + * {@link gnu.java.awt.java2d.AbstractGraphics2D#updateRaster}. * * @return the destination raster */ Modified: trunk/gui/src/awt/org/jnode/awt/image/JNodeImageGraphics.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/image/JNodeImageGraphics.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/gui/src/awt/org/jnode/awt/image/JNodeImageGraphics.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -20,8 +20,6 @@ package org.jnode.awt.image; -import gnu.java.awt.java2d.AbstractGraphics2D; - import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.Shape; @@ -123,7 +121,7 @@ * Returns a WritableRaster that is used by this class to perform the * rendering in. It is not necessary that the target surface immediately * reflects changes in the raster. Updates to the raster are notified via - * {@link AbstractGraphics2D#updateRaster}. + * {@link gnu.java.awt.java2d.AbstractGraphics2D#updateRaster}. * * @return the destination raster */ Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-03-30 11:18:43 UTC (rev 5186) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-03-30 12:20:03 UTC (rev 5187) @@ -52,7 +52,6 @@ import org.jnode.driver.console.InputHistory; import org.jnode.driver.console.TextConsole; import org.jnode.driver.console.textscreen.KeyboardReader; -import org.jnode.driver.console.textscreen.KeyboardReaderAction; import org.jnode.naming.InitialNaming; import org.jnode.shell.alias.AliasManager; import org.jnode.shell.alias.NoSuchAliasException; @@ -726,8 +725,9 @@ /** * This method is called by the console input driver to perform command line - * completion in response to a {@link KeyboardReaderAction#KR_COMPLETE} action; - * typically a TAB character. + * completion in response to a + * {@link org.jnode.driver.console.textscreen.KeyboardReaderAction#KR_COMPLETE} + * action; typically a TAB character. */ public CompletionInfo complete(String partial) { if (!readingCommand) { @@ -768,7 +768,8 @@ /** * This method is responsible for generating incremental help in response - * to a @link KeyboardReaderAction#KR_HELP} action. + * to a @link org.jnode.driver.console.textscreen.KeyboardReaderAction#KR_HELP} + * action. */ public boolean help(String partial, PrintWriter pw) { if (!readingCommand) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-03-31 06:28:11
|
Revision: 5195 http://jnode.svn.sourceforge.net/jnode/?rev=5195&view=rev Author: chrisboertien Date: 2009-03-31 06:28:08 +0000 (Tue, 31 Mar 2009) Log Message: ----------- refactored archive commands to fs created new plugins org.jnode.fs.command.archive for new commands and org.apache.tools.archive for access to tar/bzip/zip ant classes Modified Paths: -------------- trunk/shell/descriptors/org.jnode.shell.command.xml Added Paths: ----------- trunk/fs/descriptors/org.apache.tools.archive.xml trunk/fs/descriptors/org.jnode.fs.command.archive.xml trunk/fs/src/fs/org/jnode/fs/command/archive/ trunk/fs/src/fs/org/jnode/fs/command/archive/ArchiveCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/BUnzipCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/BZip.java trunk/fs/src/fs/org/jnode/fs/command/archive/BZipCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/GUnzipCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/GZip.java trunk/fs/src/fs/org/jnode/fs/command/archive/GZipCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/TarCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/UnzipCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/ZCatCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/Zip.java trunk/fs/src/fs/org/jnode/fs/command/archive/ZipCommand.java Removed Paths: ------------- trunk/shell/src/shell/org/jnode/shell/command/GUNZIPCommand.java trunk/shell/src/shell/org/jnode/shell/command/GZIP.java trunk/shell/src/shell/org/jnode/shell/command/GZIPCommand.java trunk/shell/src/shell/org/jnode/shell/command/ZCATCommand.java Added: trunk/fs/descriptors/org.apache.tools.archive.xml =================================================================== --- trunk/fs/descriptors/org.apache.tools.archive.xml (rev 0) +++ trunk/fs/descriptors/org.apache.tools.archive.xml 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.apache.tools.archive" + name="Ant archive tools" + version="1.7.1" + provider-name="Apache Ant" + provider-url="http://ant.apache.org" + license-name="apache2.0"> + + <runtime> + <library name="ant.jar"> + <export name="org.apache.tools.tar.*" /> + <export name="org.apache.tools.zip.*" /> + <export name="org.apache.tools.bzip.*" /> + </library> + </runtime> + + <extension point="org.jnode.security.permissions"> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> + <permission class="java.lang.RuntimePermission" name="setSecurityManager" actions="*" /> + <permission class="java.lang.RuntimePermission" name="setIO" actions="*" /> + <permission class="java.lang.RuntimePermission" name="exitVM" actions="*" /> + <permission class="java.lang.RuntimePermission" name="createClassLoader" actions="*" /> + <permission class="org.jnode.security.JNodePermission" name="getVmClass" actions="*" /> + <permission class="java.util.PropertyPermission" name="*" actions="read,write"/> + </extension> +</plugin> Added: trunk/fs/descriptors/org.jnode.fs.command.archive.xml =================================================================== --- trunk/fs/descriptors/org.jnode.fs.command.archive.xml (rev 0) +++ trunk/fs/descriptors/org.jnode.fs.command.archive.xml 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plugin SYSTEM "jnode.dtd"> + +<plugin id="org.jnode.fs.command.archive" + name="JNode archive commands" + version="@VERSION@" + license-name="lgpl" + provider-name="JNode.org"> + + <requires> + <import plugin="org.apache.tools.archive" /> + <import plugin="org.jnode.shell" /> + </requires> + + <runtime> + <library name="jnode-fs.jar"> + <export name="org.jnode.fs.command.archive.*" /> + </library> + </runtime> + + <extension point="org.jnode.shell.aliases"> + <alias name="bzip2" class="org.jnode.fs.command.archive.BZipCommand" /> + <alias name="bunzip2" class="org.jnode.fs.command.archive.BUnzipCommand" /> + <alias name="bzcat" class="org.jnode.fs.command.archive.BZCatCommand" /> + <alias name="gzip" class="org.jnode.fs.command.archive.GZipCommand" /> + <alias name="gunzip" class="org.jnode.fs.command.archive.GUnzipCommand" /> + <alias name="tar" class="org.jnode.fs.command.archive.TarCommand" /> + <alias name="unzip" class="org.jnode.fs.command.archive.UnzipCommand" /> + <alias name="zcat" class="org.jnode.fs.command.archive.ZCatCommand" /> + <alias name="zip" class="org.jnode.fs.command.archive.ZipCommand" /> + </extension> + + <extension point="org.jnode.shell.syntaxes"> + + <syntax alias="tar"> + <sequence> + <alternatives description="tar operations"> + <option argLabel="doAppend" shortName="r" longName="append" /> + <option argLabel="doCreate" shortName="c" longName="create" /> + <option argLabel="doConcat" shortName="A" longName="concatenate" /> + <option argLabel="doDelete" longName="delete" /> + <option argLabel="doDiff" shortName="d" longName="diff" /> + <option argLabel="doExtract" shortName="x" longName="extract" /> + <option argLabel="doList" shortName="t" longName="list" /> + <option argLabel="doUpdate" shortName="u" longName="update" /> + </alternatives> + <optionSet description="tar options"> + <option argLabel="backup" longName="backup" /> + <option argLabel="bzip" shortName="j" longName="bzip2" /> + <option argLabel="debug" longName="debug" /> + <option argLabel="dir" shortName="C" longName="directory" /> + <option argLabel="exclude" longName="exclude" label="pattern" /> + <option argLabel="file" shortName="f" longName="file" /> + <option argLabel="fileList" shortName="T" longName="files-from"/> + <option argLabel="gzip" shortName="z" longName="gzip" /> + <option argLabel="interact" shortName="w" longName="interactive" /> + <option argLabel="keepFiles" shortName="k" longName="keep-old-files" /> + <option argLabel="noRecurse" longName="no-recursion" /> + <option argLabel="recurse" longName="recursion" /> + <option argLabel="removeFiles" longName="remove-files" /> + <option argLabel="showTotals" longName="totals" /> + <option argLabel="suffix" longName="suffix" /> + <option argLabel="useStdout" shortName="O" longName="to-stdout" /> + <option argLabel="verbose" shortName="v" longName="verbose" /> + <option argLabel="verify" shortName="W" longName="verify" /> + <option argLabel="xfile" shortName="X" longName="exclude-from"/> + <!-- + <option argLabel="minDate" shortName="N" longName="newer" /> + <option argLabel="minMTime" longName="newer-mtime" /> + --> + </optionSet> + <repeat minCount="0"> + <argument argLabel="paths" label="file/dir"/> + </repeat> + </sequence> + </syntax> + <syntax alias="gzip"> + <empty description="compress standard input to standard output" /> + <sequence description="compress files"> + <optionSet> + <option argLabel="decompress" shortName="d" longName="decompress" /> + <option argLabel="noname" shortName="n" longName="no-name" /> + <option argLabel="name" shortName="N" longName="name" /> + <option argLabel="stdout" shortName="c" longName="stdout" /> + <option argLabel="force" shortName="f" longName="force" /> + <option argLabel="quiet" shortName="q" longName="quiet" /> + <option argLabel="verbose" shortName="v" longName="verbose" /> + <option argLabel="lvl1" shortName="1" longName="fast" /> + <option argLabel="debug" longName="debug" /> + <option argLabel="recursive" shortName="r" longName="recursive" /> + <option argLabel="test" shortName="t" longName="test" /> + <option argLabel="list" shortName="l" longName="list" /> + <option argLabel="lvl9" shortName="9" longName="best" /> + </optionSet> + <optional eager="true"><option argLabel="suffix" shortName="S" longName="suffix" /></optional> + <repeat minCount="1"> + <argument argLabel="file" /> + </repeat> + </sequence> + </syntax> + <syntax alias="gunzip"> + <empty description="decompress standard input to standard output" /> + <sequence description="decompress files"> + <optionSet> + <option argLabel="debug" longName="debug" /> + <option argLabel="recursive" shortName="r" longName="recursive" /> + <option argLabel="test" shortName="t" longName="test" /> + <option argLabel="list" shortName="l" longName="list" /> + <option argLabel="noname" shortName="n" longName="no-name" /> + <option argLabel="name" shortName="N" longName="name" /> + <option argLabel="stdout" shortName="c" longName="stdout" /> + <option argLabel="force" shortName="f" longName="force" /> + <option argLabel="quiet" shortName="q" longName="quiet" /> + <option argLabel="verbose" shortName="v" longName="verbose" /> + </optionSet> + <optional eager="true"><option argLabel="suffix" shortName="S" longName="suffix" /></optional> + <repeat minCount="1"> + <argument argLabel="file" /> + </repeat> + </sequence> + </syntax> + <syntax alias="zcat"> + <empty description="decompress standard input to standard output" /> + <sequence description="decompress files to standard output"> + <optionSet> + <option argLabel="quiet" shortName="q" longName="quiet" /> + <option argLabel="verbose" shortName="v" longName="verbose" /> + <option argLabel="debug" longName="debug" /> + </optionSet> + <repeat minCount="1"> + <argument argLabel="file" /> + </repeat> + </sequence> + </syntax> + <syntax alias="zip"> + </syntax> + <syntax alias="unzip"> + </syntax> + <syntax alias="bzip2"> + </syntax> + <syntax alias="bunzip2"> + </syntax> + <syntax alias="bzcat"> + </syntax> + </extension> + + <extension point="org.jnode.security.permissions"> + <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> + <permission class="java.net.SocketPermission" name="*:0-" actions="connect,resolve"/> + <permission class="java.util.PropertyPermission" name="user.dir" actions="read,write"/> + <permission class="java.util.PropertyPermission" name="*" actions="read,write"/> + <permission class="java.net.NetPermission" name="specifyStreamHandler"/> + <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> + <permission class="java.lang.RuntimePermission" name="exitVM"/> + <permission class="org.jnode.security.JNodePermission" name="getVmClass"/> + </extension> +</plugin> Added: trunk/fs/src/fs/org/jnode/fs/command/archive/ArchiveCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/ArchiveCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/ArchiveCommand.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,185 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +import org.jnode.shell.AbstractCommand; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.IOException; + +public class ArchiveCommand extends AbstractCommand { + + protected static final int OUT_ERROR = 0x01; + protected static final int OUT_WARN = 0x02; + protected static final int OUT_NOTICE = 0x04; + protected static final int OUT_DEBUG = 0x80; + + protected int outMode = OUT_ERROR | OUT_WARN; + + protected PrintWriter stdoutWriter; + protected PrintWriter stderrWriter; + protected Reader stdinReader; + + private byte[] buffer; + + protected ArchiveCommand(String s) { + super(s); + } + + protected void setup() { + stdoutWriter = getOutput().getPrintWriter(); + stderrWriter = getError().getPrintWriter(); + stdinReader = getInput().getReader(); + } + + protected void createStreamBuffer(int size) { + buffer = new byte[size]; + } + + /** + * Pipes the contents of the InputStream into the OutputStream. + * + * This is most usefull for applying a stream filter that reads data from a source + * and pipes the contents to an output stream. + * + * @param InputStream stream to read from + * @param OutputStream stream to write to + * @param int size of buffer to use. + */ + protected void processStream(InputStream in , OutputStream out) throws IOException { + int len; + if (buffer == null) buffer = new byte[4096]; + while ((len = in.read(buffer)) > 0) { + out.write(buffer, 0, len); + } + } + + /** + * Opens a FileOutputStream for a file. + * + * If there is a problem opening the stream, the exception is caught and an error message + * is displayed. + * + * @param File the file to open the stream on + * @param boolean if the file exists, delete it first + * @param boolean if delete is true, this forces the deletion without prompting the user + * @return an OutputStream on the file, or null if there was a problem. null could also be + * returned if the delete option was chosen and the user said no to overwriting. + */ + protected OutputStream openFileWrite(File file , boolean delete , boolean forced) { + try { + boolean createNew = true; + if (file.exists()) { + if (delete) { + if (forced) { + file.delete(); + } else { + if (prompt_yn(file + "exists. Overwrite? ")) { + file.delete(); + } else { + notice("Skipping " + file); + return null; + } + } + } else { + return new FileOutputStream(file); + } + } + if (createNew && !file.createNewFile()) { + error("Could not create file: " + file); + return null; + } + return new FileOutputStream(file); + } catch (IOException ioe) { + error("Could not open stream: " + file + " : " + ioe.getLocalizedMessage()); + return null; + } + } + + /** + * Opens a FileInputStream on a file. + * + * If there is a problem opening the stream, the IOException is caught, and an + * error message displayed to the console. + * + * @param the file to open the stream on + * @return the InputStream or null if there was a problem. + */ + protected InputStream openFileRead(File file) { + try { + return new FileInputStream(file); + } catch (IOException ioe) { + error("Cannot open stream: " + file + " : " + ioe.getLocalizedMessage()); + return null; + } + } + + /** + * Prompt the user with a question asking for a yes or no answer. + * + * @param String the question to ask the user + * @return true if the user said yes, false if the user said no + */ + protected boolean prompt_yn(String s) { + int choice; + for (;;) { + stdoutWriter.print(s + " [y/n]"); + try { + choice = stdinReader.read(); + } catch (IOException _) { + choice = 0; + } + stdoutWriter.println(); + if (choice == 'y' || choice == 'n') break; + } + + return choice == 'y'; + } + + protected void out(String s) { + stdoutWriter.println(s); + } + + protected void debug(String s) { + if ((outMode & OUT_DEBUG) == OUT_DEBUG) { + stderrWriter.print("debug: "); + stderrWriter.println(s); + } + } + + protected void notice(String s) { + if ((outMode & OUT_NOTICE) == OUT_NOTICE) stdoutWriter.println(s); + } + + protected void warn(String s) { + if ((outMode & OUT_WARN) == OUT_WARN) stdoutWriter.println(s); + } + + protected void error(String s) { + if ((outMode & OUT_ERROR) == OUT_ERROR) stderrWriter.println(s); + } +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/BUnzipCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/BUnzipCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/BUnzipCommand.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,33 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +public class BUnzipCommand extends BZip { + + public BUnzipCommand() { + super("decompresses data in bzip2 format"); + registerArguments(); + } + + public void execute() { + setup(); + } +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/BZip.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/BZip.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/BZip.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,28 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +public class BZip extends ArchiveCommand { + + public BZip(String s) { + super(s); + } +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/BZipCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/BZipCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/BZipCommand.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,32 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +public class BZipCommand extends BZip { + + public BZipCommand() { + super("compresses data with bzip2"); + } + + public void execute() { + setup(); + } +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/GUnzipCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/GUnzipCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/GUnzipCommand.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,97 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +import org.jnode.shell.syntax.Argument; +import org.jnode.shell.syntax.FileArgument; +import org.jnode.shell.syntax.FlagArgument; +import org.jnode.shell.syntax.StringArgument; + +/** + * Decompresses data in the gzip format. + * + * If a list of files is given, the files will be decompressed. The original files will be deleted + * and replaced with decompressed versions unless told to write to standard output, then the original + * files are left as-is. + * + * If no files are given, then standard input is decompressed to standard output. + * + * @author Chris Boertien + */ + +public class GUnzipCommand extends GZip { + + private static final String msg_stdout = "Write output on standard output, keep original files"; + private static final String msg_force = "force overwrite of output files and compress links"; + private static final String msg_list = "list compressed file contents"; + private static final String msg_noname = "do not save or restore the original name and time stamp"; + private static final String msg_name = "save or restore the original name and time stamp"; + private static final String msg_quiet = "suppress all warning"; + private static final String msg_recurse = "operate recursively on directories"; + private static final String msg_suffix = "use suffix SUF on compressed files"; + private static final String msg_test = "test compressed file integrity"; + private static final String msg_verbose = "verbose mode"; + private static final String msg_file = "the files to compress, use stdin if FILE is '-' or no files are listed"; + + private final FileArgument ArgFile = new FileArgument("file", Argument.OPTIONAL | Argument.MULTIPLE, msg_file); + private final StringArgument ArgSuffix = new StringArgument("suffix", Argument.OPTIONAL, msg_suffix); + private final FlagArgument ArgStdout = new FlagArgument("stdout", Argument.OPTIONAL, msg_stdout); + private final FlagArgument ArgForce = new FlagArgument("force", Argument.OPTIONAL, msg_force); + private final FlagArgument ArgList = new FlagArgument("list", Argument.OPTIONAL, msg_list); + private final FlagArgument ArgNoname = new FlagArgument("noname", Argument.OPTIONAL, msg_noname); + private final FlagArgument ArgName = new FlagArgument("name", Argument.OPTIONAL, msg_name); + private final FlagArgument ArgQuiet = new FlagArgument("quiet", Argument.OPTIONAL, msg_quiet); + private final FlagArgument ArgRecurse = new FlagArgument("recursive", Argument.OPTIONAL, msg_recurse); + private final FlagArgument ArgTest = new FlagArgument("test", Argument.OPTIONAL, msg_test); + private final FlagArgument ArgVerbose = new FlagArgument("verbose", Argument.OPTIONAL, msg_verbose); + private final FlagArgument ArgDebug = new FlagArgument("debug", Argument.OPTIONAL, " "); + + public GUnzipCommand() { + super("decompresses files/data"); + registerArguments(ArgFile, ArgSuffix, ArgStdout, ArgForce, ArgList, ArgNoname, ArgName, ArgQuiet, ArgRecurse, + ArgTest, ArgVerbose, ArgDebug); + } + + public void execute() { + if (ArgQuiet.isSet()) { + outMode = 0; + } else { + if (ArgDebug.isSet()) { + outMode |= OUT_DEBUG; + } + if (ArgVerbose.isSet()) { + outMode |= OUT_NOTICE; + } + } + + if (ArgSuffix.isSet()) suffix = ArgSuffix.getValue(); + + if (ArgList.isSet()) mode = GZIP_LIST; + else if (ArgTest.isSet()) mode = GZIP_TEST; + else mode = GZIP_DECOMPRESS; + + try { + execute(ArgFile.getValues(), ArgForce.isSet(), ArgStdout.isSet(), ArgRecurse.isSet()); + } catch (Exception e) { + e.printStackTrace(); + } + } +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/GZip.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/GZip.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/GZip.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,220 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +/** + * + * TODO implement test/list + * TODO use GZIP env variable + * TODO implement name/noname flag usage + * @author chris boertien + */ +public class GZip extends ArchiveCommand { + + private static final String msg_exists_prompt = " already exists; do you wish to overwrite (y or n)? "; + private static final String msg_exists_skip = "gzip: skipping file: "; + private static final String msg_err_open = "gzip: Cannot open file: "; + private static final String msg_err_create = "gzip: Cannot create file: "; + private static final String msg_err_bad_suffix = "gzip: Invalid suffix, expecting "; + + private static final int BUFFER_SIZE = 4096; + + private File[] files; + private InputStream stdinStream; + private OutputStream stdoutStream; + + protected static final int GZIP_LIST = 1; + protected static final int GZIP_TEST = 2; + protected static final int GZIP_DECOMPRESS = 3; + protected static final int GZIP_COMPRESS = 4; + + protected String suffix = ".gz"; + protected int mode; + + protected GZip(String s) { + super(s); + createStreamBuffer(BUFFER_SIZE); + } + + public void execute(File[] files , boolean forced , boolean use_stdout , boolean recurse) throws IOException { + setup(); + stdinStream = getInput().getInputStream(); + stdoutStream = getOutput().getOutputStream(); + + switch(mode) { + case GZIP_LIST : + list(processFiles(files, recurse)); return; + case GZIP_TEST : + test(processFiles(files, recurse)); return; + case GZIP_COMPRESS : + compress(processFiles(files, recurse), forced, use_stdout); return; + case GZIP_DECOMPRESS : + decompress(processFiles(files, recurse), forced, use_stdout); return; + } + } + + protected void compress(File[] files , boolean forced , boolean use_stdout) throws IOException { + InputStream in; + OutputStream out = null; + GZIPOutputStream gzout = null; + File gzFile = null; + float sizeDiff; + + debug("Compress"); + debug("forced=" + forced); + debug("use_stdout=" + use_stdout); + + if (files == null) { + debug("stdin > stdout"); + processStream(stdinStream, new GZIPOutputStream(stdoutStream, BUFFER_SIZE)); + } else { + if (use_stdout) gzout = new GZIPOutputStream(stdoutStream, BUFFER_SIZE); + if (use_stdout) debug("files > stdout"); + else debug("files > files"); + + for (File file : files) { + debug(file.getName()); + if (!file.exists()) { + error("File does not exist: " + file.getName()); + continue; + } + if (!use_stdout) { + gzFile = new File(file.getAbsolutePath() + suffix); + if ((out = openFileWrite(gzFile, true, forced)) == null) continue; + gzout = new GZIPOutputStream(out, BUFFER_SIZE); + } + if ((in = openFileRead(file)) == null) continue; + processStream(in, gzout); + if (!use_stdout) { + gzout.finish(); + gzout.close(); + sizeDiff = ((float) gzFile.length() / (float) file.length()) * 100; + notice(file + ":\t" + sizeDiff + "% -- replaced with " + gzFile); + file.delete(); + } + in.close(); + } + if (use_stdout) gzout.finish(); + } + } + + protected void decompress(File[] files , boolean forced , boolean use_stdout) throws IOException { + InputStream in; + OutputStream out = null; + String name; + File file = null; + float sizeDiff; + + debug("Decompress"); + debug("forced=" + forced); + debug("use_stdout=" + use_stdout); + + if (use_stdout) out = stdoutStream; + + if (files == null) { + debug("stdin > stdout"); + processStream(new GZIPInputStream(stdinStream, BUFFER_SIZE), stdoutStream); + } else { + if (use_stdout) debug("files > stdout"); + else debug("files > files"); + + for (File gzFile : files) { + debug(gzFile.getName()); + if (!gzFile.exists()) { + error("File not found: " + gzFile); + continue; + } + if (!gzFile.getName().endsWith(suffix)) { + notice("gzip: " + file + ": unknown suffix -- ignored"); + continue; + } + if (!use_stdout) { + name = gzFile.getAbsolutePath(); + name = name.substring(0, name.length() - suffix.length()); + file = new File(name); + if ((out = openFileWrite(file, true, forced)) == null) continue; + } + + if ((in = new GZIPInputStream(openFileRead(gzFile), BUFFER_SIZE)) == null) continue; + processStream(in, out); + in.close(); + if (!use_stdout) { + sizeDiff = ((float) gzFile.length() / (float) file.length()) * 100; + notice(gzFile + ":\t" + sizeDiff + "% -- replaced with " + file); + gzFile.delete(); + out.close(); + } + } + } + } + + protected void test(File[] files) {} + + protected void list(File[] files) {} + + private File[] processFiles(File[] files , boolean recurse) { + if (files == null || files.length == 0) return null; + + debug("processFiles(files(" + files.length + ")," + recurse + ")"); + + ArrayList<File> _files = new ArrayList<File>(); + + for (File file : files) { + debug(file.getName()); + if (file.getName().equals("-")) { + debug("found stdin"); + return null; + } + if (!file.exists()) { + error("Cannot find file: " + file); + continue; + } + if (file.isDirectory() && recurse) { + debug("searching directory: " + file); + File[] dirList = file.listFiles(); + for (File subFile : dirList) { + debug(subFile.getName()); + if (subFile.isFile()) { + debug(subFile + " added"); + _files.add(subFile); + } + } + } else { + if (file.isFile()) { + debug(file + " added"); + _files.add(file); + } + } + } + + if (_files.size() == 0) return null; + debug("Found " + _files.size() + " files"); + return _files.toArray(files); + } +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/GZipCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/GZipCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/GZipCommand.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,106 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +import org.jnode.shell.syntax.Argument; +import org.jnode.shell.syntax.FileArgument; +import org.jnode.shell.syntax.FlagArgument; +import org.jnode.shell.syntax.StringArgument; + +/** + * Compresses or decompresses data in the gzip format. + * + * If a list of files is given, the files will be (de)compressed. The original files will be deleted + * and replaced with (de)compressed versions unless told to write to standard output, then the original + * files are left as-is. + * + * If no files are given, then standard input is (de)compressed to standard output. + * + * @author Chris Boertien + */ +public class GZipCommand extends GZip { + + private static final String msg_stdout = "Write output on standard output, keep original files"; + private static final String msg_decomp = "decompress"; + private static final String msg_force = "force overwrite of output files and compress links"; + private static final String msg_list = "list compressed file contents"; + private static final String msg_noname = "do not save or restore the original name and time stamp"; + private static final String msg_name = "save or restore the original name and time stamp"; + private static final String msg_quiet = "suppress all warning"; + private static final String msg_recurse = "operate recursively on directories"; + private static final String msg_suffix = "use suffix SUF on compressed files"; + private static final String msg_test = "test compressed file integrity"; + private static final String msg_verbose = "verbose mode"; + private static final String msg_fast = "compress faster"; + private static final String msg_best = "compress better"; + private static final String msg_file = "the files to compress, use stdin if FILE is '-' or no files are listed"; + + private final FileArgument ArgFile = new FileArgument("file", Argument.OPTIONAL | Argument.MULTIPLE, msg_file); + private final StringArgument ArgSuffix = new StringArgument("suffix", Argument.OPTIONAL, msg_suffix); + private final FlagArgument ArgStdout = new FlagArgument("stdout", Argument.OPTIONAL, msg_stdout); + private final FlagArgument ArgDecomp = new FlagArgument("decompress", Argument.OPTIONAL, msg_decomp); + private final FlagArgument ArgForce = new FlagArgument("force", Argument.OPTIONAL, msg_force); + private final FlagArgument ArgList = new FlagArgument("list", Argument.OPTIONAL, msg_list); + private final FlagArgument ArgNoname = new FlagArgument("noname", Argument.OPTIONAL, msg_noname); + private final FlagArgument ArgName = new FlagArgument("name", Argument.OPTIONAL, msg_name); + private final FlagArgument ArgQuiet = new FlagArgument("quiet", Argument.OPTIONAL, msg_quiet); + private final FlagArgument ArgRecurse = new FlagArgument("recursive", Argument.OPTIONAL, msg_recurse); + private final FlagArgument ArgTest = new FlagArgument("test", Argument.OPTIONAL, msg_test); + private final FlagArgument ArgVerbose = new FlagArgument("verbose", Argument.OPTIONAL, msg_verbose); + private final FlagArgument ArgLvl1 = new FlagArgument("lvl1", Argument.OPTIONAL, msg_fast); + private final FlagArgument ArgLvl9 = new FlagArgument("lvl9", Argument.OPTIONAL, msg_best); + private final FlagArgument ArgDebug = new FlagArgument("debug", Argument.OPTIONAL, " "); + + public GZipCommand() { + super("compresses and decompresses files/data"); + registerArguments(ArgFile, ArgSuffix, ArgDecomp, ArgNoname, ArgName, ArgStdout, ArgForce, + ArgQuiet, ArgVerbose, ArgLvl1, ArgLvl9, ArgRecurse, ArgTest, ArgList, ArgDebug); + } + + public void execute() { + if (ArgQuiet.isSet()) { + outMode = 0; + } else { + if (ArgDebug.isSet()) { + outMode |= OUT_DEBUG; + } + if (ArgVerbose.isSet()) { + outMode |= OUT_NOTICE; + } + } + + if (ArgSuffix.isSet()) suffix = ArgSuffix.getValue(); + + if (ArgList.isSet()) mode = GZIP_LIST; + else if (ArgTest.isSet()) mode = GZIP_TEST; + else if (ArgDecomp.isSet()) mode = GZIP_DECOMPRESS; + else mode = GZIP_COMPRESS; + + try { + execute(ArgFile.getValues(), ArgForce.isSet(), ArgStdout.isSet(), ArgRecurse.isSet()); + } catch (Exception e) { + e.printStackTrace(); + exit(1); + } + } + + +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/TarCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/TarCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/TarCommand.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,396 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +import org.apache.tools.tar.TarEntry; +import org.apache.tools.tar.TarInputStream; +import org.apache.tools.tar.TarOutputStream; + +import org.jnode.shell.syntax.Argument; +import org.jnode.shell.syntax.FlagArgument; +import org.jnode.shell.syntax.FileArgument; +import org.jnode.shell.syntax.StringArgument; + +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +import java.util.ArrayList; +import java.util.Collections; + +public class TarCommand extends ArchiveCommand { + + private static final String help_append = "append entries to an archive"; + private static final String help_concat = "concatenate multiple archives"; + private static final String help_create = "create a new tar archive"; + private static final String help_delete = "delete entries from an archive"; + private static final String help_diff = "find differences between the archive and file system"; + private static final String help_extract = "extract the entries from an archive"; + private static final String help_list = "list the contents of an archive"; + private static final String help_update = "only append files that are newer than the copy in the archive"; + + private static final String help_backup = "backup files instead of overwriting"; + private static final String help_bzip = "compress the archive with bzip2"; + private static final String help_dir = "change to directory"; + private static final String help_exclude = "exclude files matching <pattern>"; + private static final String help_file = "use the given archive"; + private static final String help_file_list = "get names to extract or archive from <file>"; + private static final String help_gzip = "compress the archive with gzip"; + private static final String help_interact = "ask for confirmation for every action"; + private static final String help_keep_old = "keep existing files; don't overwrite from archive"; + private static final String help_norecurse = "do not recurse into directories"; + private static final String help_paths = "files and directories to include in archive"; + private static final String help_recurse = "recurse into directories"; + private static final String help_remove = "remove files after adding them to the archive"; + private static final String help_stdout = "extract files to stdout"; + private static final String help_suffix = "append <suffix> to backup files (default ~)"; + private static final String help_totals = "display total bytes written after creating the archive"; + private static final String help_verbose = "list files processed"; + private static final String help_verify = "verify the archive after writing it"; + private static final String help_xfile = "exclude files matching patterns in <file>"; + + private static final int TAR_APPEND = 0x01; + private static final int TAR_CREATE = 0x02; + private static final int TAR_CONCAT = 0x04; + private static final int TAR_DELETE = 0x08; + private static final int TAR_UPDATE = 0x10; + private static final int TAR_LIST = 0x20; + private static final int TAR_DIFF = 0x40; + private static final int TAR_EXTRACT = 0x80; + private static final int TAR_INSERT = TAR_APPEND | TAR_CREATE; + + private final FlagArgument DoAppend = new FlagArgument("doAppend", Argument.OPTIONAL, help_append); + private final FlagArgument DoConcat = new FlagArgument("doConcat", Argument.OPTIONAL, help_concat); + private final FlagArgument DoCreate = new FlagArgument("doCreate", Argument.OPTIONAL, help_create); + private final FlagArgument DoDelete = new FlagArgument("doDelete", Argument.OPTIONAL, help_delete); + private final FlagArgument DoDiff = new FlagArgument("doDiff", Argument.OPTIONAL, help_diff); + private final FlagArgument DoExtract = new FlagArgument("doExtract", Argument.OPTIONAL, help_extract); + private final FlagArgument DoList = new FlagArgument("doList", Argument.OPTIONAL, help_list); + private final FlagArgument DoUpdate = new FlagArgument("doUpdate", Argument.OPTIONAL, help_update); + + private final FlagArgument Backup = new FlagArgument("backup", Argument.OPTIONAL, help_backup); + private final FlagArgument UseBzip = new FlagArgument("bzip", Argument.OPTIONAL, help_bzip); + private final FlagArgument Debug = new FlagArgument("debug", Argument.OPTIONAL, " "); + private final FileArgument ChangeDir = new FileArgument("dir", Argument.OPTIONAL, help_dir); + private final StringArgument Exclude = new StringArgument("exclude", Argument.OPTIONAL, help_exclude); + private final FileArgument Archive = new FileArgument("file", Argument.OPTIONAL, help_file); + private final FileArgument FileList = new FileArgument("fileList", Argument.OPTIONAL, help_file_list); + private final FlagArgument UseGzip = new FlagArgument("gzip", Argument.OPTIONAL, help_gzip); + private final FlagArgument Interact = new FlagArgument("interact", Argument.OPTIONAL, help_interact); + private final FlagArgument KeepFiles = new FlagArgument("keepFiles", Argument.OPTIONAL, help_keep_old); + private final FlagArgument NoRecurse = new FlagArgument("noRecurse", Argument.OPTIONAL, help_norecurse); + private final FlagArgument Recurse = new FlagArgument("recurse", Argument.OPTIONAL, help_recurse); + private final FlagArgument RemoveFiles = new FlagArgument("removeFiles", Argument.OPTIONAL, help_remove); + private final FlagArgument ShowTotals = new FlagArgument("showTotals", Argument.OPTIONAL, help_totals); + private final StringArgument Suffix = new StringArgument("suffix", Argument.OPTIONAL, help_suffix); + private final FlagArgument UseStdout = new FlagArgument("useStdout", Argument.OPTIONAL, help_stdout); + private final FlagArgument Verbose = new FlagArgument("verbose", Argument.OPTIONAL, help_verbose); + private final FlagArgument Verify = new FlagArgument("verify", Argument.OPTIONAL, help_verify); + private final FileArgument ExcludeFile = new FileArgument("xfile", Argument.OPTIONAL, help_xfile); + + private final FileArgument Paths = new FileArgument("paths", Argument.OPTIONAL | Argument.MULTIPLE, help_paths); + + private File archive; + private File excludeFile; + private File fileList; + private String suffix = "~"; + private String exclude = ""; + private int mode; + private boolean recurse; + private boolean pipeInOut; + private boolean backup; + private boolean bzip; + private boolean gzip; + private boolean interact; + private boolean verify; + private boolean use_stdout; + private boolean showTotals; + private boolean keepOldFiles; + + public TarCommand() { + super("Create/Modify/Extract tape archives"); + registerArguments(DoAppend, DoConcat, DoCreate, DoDelete, DoDiff, DoExtract, DoList, DoUpdate, + Backup, UseBzip, Debug, ChangeDir, Exclude, Archive, FileList, UseGzip, Interact, + KeepFiles, NoRecurse, Recurse, RemoveFiles, ShowTotals, Suffix, UseStdout, Verbose, + Verify, Paths, ExcludeFile); + } + + public void execute() { + setup(); + if (!checkMode()) { + error("required options -Acdtrux not found, or multiple options set"); + exit(1); + } + if (DoAppend.isSet()) mode = TAR_APPEND; + else if (DoConcat.isSet()) mode = TAR_CONCAT; + else if (DoCreate.isSet()) mode = TAR_CREATE; + else if (DoDelete.isSet()) mode = TAR_DELETE; + else if (DoDiff.isSet()) mode = TAR_DIFF; + else if (DoExtract.isSet()) mode = TAR_EXTRACT; + else if (DoList.isSet()) mode = TAR_LIST; + else if (DoUpdate.isSet()) mode = TAR_UPDATE; + + if (Debug.isSet()) outMode |= OUT_DEBUG; + if (Verbose.isSet()) outMode |= OUT_NOTICE; + + if (Suffix.isSet()) suffix = Suffix.getValue(); + if (Exclude.isSet()) exclude = Exclude.getValue(); + if (ExcludeFile.isSet()) excludeFile = ExcludeFile.getValue(); + if (FileList.isSet()) fileList = FileList.getValue(); + + backup = Backup.isSet(); + bzip = UseBzip.isSet(); + gzip = UseGzip.isSet(); + interact = Interact.isSet(); + verify = Verify.isSet(); + use_stdout = UseStdout.isSet(); + showTotals = ShowTotals.isSet(); + keepOldFiles = KeepFiles.isSet(); + recurse = !NoRecurse.isSet(); + if (Archive.isSet()) archive = Archive.getValue(); + else error("No archive given"); + //if (!(pipeInOut = !Archive.isSet())) archive = Archive.getValue(); + + debug("Mode: " + mode); + debug("Archive: " + archive); + debug("Suffix: " + suffix); + debug("Exclude: " + exclude); + debug("Exclude File: " + excludeFile); + debug("File List: " + fileList); + debug("Backup: " + backup); + debug("BZip: " + bzip); + debug("GZip: " + gzip); + debug("Interactive: " + interact); + debug("Recurse: " + recurse); + debug("Verify: " + verify); + debug("Use StdOut: " + use_stdout); + debug("Keep Old Files: " + keepOldFiles); + debug("Show Totals: " + showTotals); + debug("pipeInOut: " + pipeInOut); + + try { + if ((mode & TAR_INSERT) != 0) { + File[] files; + files = processFiles(Paths.getValues(), recurse); + insert(files); + return; + } + if ((mode & TAR_EXTRACT) != 0) { + extract(); + } + if ((mode & TAR_LIST) != 0) { + list(); + } + } catch (Exception e) { + e.printStackTrace(); + exit(2); + } + } + + private void insert(File[] files) throws IOException { + debug("insert"); + InputStream in; + OutputStream out; + TarOutputStream tout; + TarEntry entry; + + if (!use_stdout) { + if (mode == TAR_CREATE || (mode == TAR_APPEND && !archive.exists())) createArchive(); + + if ((out = openFileWrite(archive, false, false)) == null) { + error("Could not open stream: " + archive); + exit(1); + } + } else { + debug("out=stdout"); + out = getOutput().getOutputStream(); + } + + tout = new TarOutputStream(out); + debug("begin"); + for (File file : files) { + notice(file.getName()); + entry = new TarEntry(file); + tout.putNextEntry(entry); + + if (!file.isDirectory()) { + if ((in = openFileRead(file)) == null) continue; + processStream(in, tout); + in.close(); + } + tout.closeEntry(); + } + tout.close(); + debug("end"); + } + + private void extract() throws IOException { + TarEntry entry; + InputStream in = null; + OutputStream out; + TarInputStream tin; + File file; + + if (archive != null) { + if (archive.exists()) { + if ((in = openFileRead(archive)) == null) { + exit(1); + } + } else { + error("File does not exist: " + archive); + exit(1); + } + } else { + in = getInput().getInputStream(); + } + + tin = new TarInputStream(in); + + if (use_stdout) { + debug("out=stdout"); + out = getOutput().getOutputStream(); + } + + debug("begin"); + while ((entry = tin.getNextEntry()) != null) { + notice(entry.getName()); + file = new File(entry.getName()); + if (entry.isDirectory()) { + if (!file.exists()) { + file.mkdirs(); + } + continue; + } + if ((out = openFileWrite(file, true, false)) == null) { + continue; + } + tin.copyEntryContents(out); + out.close(); + } + tin.close(); + debug("end"); + } + + private void list() throws IOException { + TarEntry entry; + InputStream in = null; + TarInputStream tin; + + if (archive == null || !archive.exists()) { + error("Cannot find file: " + archive); + exit(1); + } + if ((in = openFileRead(archive)) == null) { + exit(1); + } + + tin = new TarInputStream(in); + + while ((entry = tin.getNextEntry()) != null) { + out(entry.getName()); + } + } + + private void diff() throws IOException { + TarEntry entry; + InputStream in = null; + TarInputStream tin; + File file; + + if (archive == null || !archive.exists()) { + error("Cannot find file: " + archive); + exit(1); + } + if ((in = openFileRead(archive)) == null) { + exit(1); + } + + tin = new TarInputStream(in); + + while ((entry = tin.getNextEntry()) != null) { + file = new File(entry.getName()); + + if (!file.exists()) { + out(file + ": Warning: No such file or directory"); + } + + if (file.lastModified() != entry.getModTime().getTime()) { + out(file + ": Mod time differs"); + } + + if (file.length() != entry.getSize()) { + out(file + ": Size differs"); + } + } + } + + private void createArchive() { + try { + if (archive.exists()) { + archive.delete(); + } + debug("creating archive: " + archive); + archive.createNewFile(); + } catch (IOException e) { + error("Could not create file: " + archive); + exit(1); + } + } + + private File[] processFiles(File[] files , boolean recurse) { + // FIXME object pollution + ArrayList<File> _files = new ArrayList<File>(); + + for (File file : files) { + if (!file.exists()) { + continue; + } + if (file.getName().equals(".") || file.getName().equals("..")) { + continue; + } + + if (file.isDirectory()) { + if (recurse) { + _files.add(file); + Collections.addAll(_files, processFiles(file.listFiles(), recurse)); + } + continue; + } + _files.add(file); + } + + return _files.toArray(files); + } + + private boolean checkMode() { + int check = 0; + if (DoAppend.isSet()) check++; + if (DoCreate.isSet()) check++; + if (DoConcat.isSet()) check++; + if (DoDelete.isSet()) check++; + if (DoDiff.isSet()) check++; + if (DoExtract.isSet()) check++; + if (DoList.isSet()) check++; + if (DoUpdate.isSet()) check++; + return check == 1; + } +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/UnzipCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/UnzipCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/UnzipCommand.java 2009-03-31 06:28:08 UTC (rev 5195) @@ -0,0 +1,42 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.fs.command.archive; + +import org.jnode.shell.AbstractCommand; +import org.jnode.shell.syntax.Argument; +import org.jnode.shell.syntax.FileArgument; +import org.jnode.shell.syntax.FlagArgument; +import org.jnode.shell.syntax.StringArgument; + +/** + * @author chris boertien + */ +public class UnzipCommand extends Zip { + + public UnzipCommand() { + super("extracts entries from zip archives"); + //registerArguments(ZipfileArg,PatternsArg); + } + + public void execute() { + setup(); + } +} Added: trunk/fs/src/fs/org/jnode/fs/command/archive/ZCatCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/ZCatCommand.java (rev 0) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/ZCatCommand.j... [truncated message content] |
From: <ls...@us...> - 2009-04-01 15:01:38
|
Revision: 5206 http://jnode.svn.sourceforge.net/jnode/?rev=5206&view=rev Author: lsantha Date: 2009-04-01 12:48:52 +0000 (Wed, 01 Apr 2009) Log Message: ----------- Added required permissions. Modified Paths: -------------- trunk/core/descriptors/org.classpath.ext.jdwp.xml trunk/shell/descriptors/org.jnode.shell.command.debug.xml Modified: trunk/core/descriptors/org.classpath.ext.jdwp.xml =================================================================== --- trunk/core/descriptors/org.classpath.ext.jdwp.xml 2009-04-01 10:27:04 UTC (rev 5205) +++ trunk/core/descriptors/org.classpath.ext.jdwp.xml 2009-04-01 12:48:52 UTC (rev 5206) @@ -22,5 +22,9 @@ <export name="gnu.classpath.jdwp.util.*"/> </library> </runtime> + + <extension point="org.jnode.security.permissions"> + <permission class="java.net.SocketPermission" name="*:1-" actions="resolve,listen,connect"/> + </extension> </fragment> Modified: trunk/shell/descriptors/org.jnode.shell.command.debug.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.debug.xml 2009-04-01 10:27:04 UTC (rev 5205) +++ trunk/shell/descriptors/org.jnode.shell.command.debug.xml 2009-04-01 12:48:52 UTC (rev 5206) @@ -42,6 +42,7 @@ <extension point="org.jnode.security.permissions"> <permission class="java.lang.RuntimePermission" name="modifyThreadGroup"/> <permission class="java.lang.RuntimePermission" name="setIO"/> + <permission class="java.lang.RuntimePermission" name="exitVM"/> <permission class="java.net.SocketPermission" name="*:1-" actions="resolve,listen,connect"/> </extension> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-04-01 18:57:35
|
Revision: 5209 http://jnode.svn.sourceforge.net/jnode/?rev=5209&view=rev Author: lsantha Date: 2009-04-01 18:57:30 +0000 (Wed, 01 Apr 2009) Log Message: ----------- Separating jnode specific code from classlib. Modified Paths: -------------- trunk/all/conf/openjdk-annotations.properties trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java Added Paths: ----------- trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java trunk/core/src/classpath/java/java/nio/channels/VMChannels.java trunk/core/src/classpath/vm/java/nio/MemoryRawData.java trunk/core/src/classpath/vm/java/nio/NativeVMDirectByteBuffer.java trunk/core/src/classpath/vm/java/nio/channels/NativeVMChannels.java Removed Paths: ------------- trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java Modified: trunk/all/conf/openjdk-annotations.properties =================================================================== --- trunk/all/conf/openjdk-annotations.properties 2009-04-01 15:03:30 UTC (rev 5208) +++ trunk/all/conf/openjdk-annotations.properties 2009-04-01 18:57:30 UTC (rev 5209) @@ -18,6 +18,7 @@ java/net/ServerSocket.class=SharedStatics java/net/Socket.class=SharedStatics java/net/URLConnection.class=SharedStatics +java/nio/VMDirectByteBuffer.class=MagicPermission java/nio/charset/Charset.class=SharedStatics java/nio/charset/CoderResult.class=SharedStatics # TODO Policy might need to be isolated Copied: trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java (from rev 5208, trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java) =================================================================== --- trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java (rev 0) +++ trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java 2009-04-01 18:57:30 UTC (rev 5209) @@ -0,0 +1,42 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package java.nio; + +import gnu.classpath.Pointer; + +public final class VMDirectByteBuffer { + + native static Pointer allocate(int capacity); + + native static void free(Pointer address); + + native static byte get(Pointer address, int index); + + native static void get(Pointer address, int index, byte[] dst, int offset, int length); + + native static void put(Pointer address, int index, byte value); + + native static void put(Pointer address, int index, byte[] src, int offset, int length); + + native static Pointer adjustAddress(Pointer address, int offset); + + native static void shiftDown(Pointer address, int dst_offset, int src_offset, int count); +} Property changes on: trunk/core/src/classpath/java/java/nio/VMDirectByteBuffer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Copied: trunk/core/src/classpath/java/java/nio/channels/VMChannels.java (from rev 5208, trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java) =================================================================== --- trunk/core/src/classpath/java/java/nio/channels/VMChannels.java (rev 0) +++ trunk/core/src/classpath/java/java/nio/channels/VMChannels.java 2009-04-01 18:57:30 UTC (rev 5209) @@ -0,0 +1,43 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package java.nio.channels; + +import java.io.InputStream; +import java.io.OutputStream; + +final class VMChannels { + /** + * This class isn't intended to be instantiated. + */ + private VMChannels() { + // Do nothing here. + } + + /** + * Constructs a stream that reads bytes from the given channel. + */ + native static InputStream newInputStream(ReadableByteChannel ch); + + /** + * Constructs a stream that writes bytes to the given channel. + */ + native static OutputStream newOutputStream(WritableByteChannel ch); +} Property changes on: trunk/core/src/classpath/java/java/nio/channels/VMChannels.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/core/src/classpath/vm/java/nio/MemoryRawData.java =================================================================== --- trunk/core/src/classpath/vm/java/nio/MemoryRawData.java (rev 0) +++ trunk/core/src/classpath/vm/java/nio/MemoryRawData.java 2009-04-01 18:57:30 UTC (rev 5209) @@ -0,0 +1,54 @@ +package java.nio; + +import gnu.classpath.Pointer; +import org.jnode.system.MemoryResource; +import org.jnode.system.ResourceManager; +import org.jnode.system.ResourceOwner; +import org.jnode.system.SimpleResourceOwner; +import org.jnode.system.ResourceNotFreeException; +import org.jnode.naming.InitialNaming; +import org.vmmagic.unboxed.Address; +import javax.naming.NameNotFoundException; + +/** + * + */ +public class MemoryRawData extends Pointer { + + final MemoryResource resource; + final Address address; + + MemoryRawData(int size) { + try { + final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME); + final ResourceOwner owner = new SimpleResourceOwner("java.nio"); + this.resource = rm.claimMemoryResource(owner, null, size, + ResourceManager.MEMMODE_NORMAL); + this.address = resource.getAddress(); + } catch (NameNotFoundException ex) { + throw new Error("Cannot find ResourceManager", ex); + } catch (ResourceNotFreeException ex) { + throw new Error("Cannot allocate direct memory", ex); + } + } + + MemoryRawData(MemoryResource resource) { + this.resource = resource; + this.address = resource.getAddress(); + } + + /** + * Wrap a bytebuffer around the given memory resource. + * + * @param resource a memory resource to wrap + * @return the new ByteBuffer + */ + public static ByteBuffer wrap(MemoryResource resource) { + final Object owner = resource.getOwner(); + final Pointer address = new MemoryRawData(resource); + final int size = resource.getSize().toInt(); + final ByteBuffer result = new DirectByteBufferImpl.ReadWrite(owner, address, size, size, 0); + result.mark(); + return result; + } +} Added: trunk/core/src/classpath/vm/java/nio/NativeVMDirectByteBuffer.java =================================================================== --- trunk/core/src/classpath/vm/java/nio/NativeVMDirectByteBuffer.java (rev 0) +++ trunk/core/src/classpath/vm/java/nio/NativeVMDirectByteBuffer.java 2009-04-01 18:57:30 UTC (rev 5209) @@ -0,0 +1,51 @@ +package java.nio; + +import gnu.classpath.Pointer; +import org.jnode.system.MemoryResource; +import org.jnode.system.ResourceNotFreeException; +import org.vmmagic.unboxed.Offset; +import org.vmmagic.unboxed.Extent; + +/** + * + */ +public class NativeVMDirectByteBuffer { + static Pointer allocate(int capacity) { + return new MemoryRawData(capacity); + } + + static void free(Pointer address) { + ((MemoryRawData) address).resource.release(); + } + + static byte get(Pointer address, int index) { + final MemoryRawData mrd = (MemoryRawData) address; + return mrd.address.loadByte(Offset.fromIntZeroExtend(index)); + } + + static void get(Pointer address, int index, byte[] dst, int offset, int length) { + ((MemoryRawData) address).resource.getBytes(index, dst, offset, length); + } + + static void put(Pointer address, int index, byte value) { + ((MemoryRawData) address).resource.setByte(index, value); + } + + static void put(Pointer address, int index, byte[] src, int offset, int length) { + ((MemoryRawData) address).resource.setBytes(src, offset, index, length); + } + + static Pointer adjustAddress(Pointer address, int offset) { + final MemoryResource res = ((MemoryRawData) address).resource; + final Extent size = res.getSize().sub(offset); + try { + return new MemoryRawData(res.claimChildResource(Offset.fromIntZeroExtend(offset), size, true)); + } catch (ResourceNotFreeException ex) { + throw new Error("Cannot adjustAddress", ex); + } + } + + static void shiftDown(Pointer address, int dst_offset, int src_offset, int count) { + ((MemoryRawData) address).resource.copy(src_offset, dst_offset, count); + } +} Deleted: trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java =================================================================== --- trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java 2009-04-01 15:03:30 UTC (rev 5208) +++ trunk/core/src/classpath/vm/java/nio/VMDirectByteBuffer.java 2009-04-01 18:57:30 UTC (rev 5209) @@ -1,122 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.nio; - -import gnu.classpath.Pointer; - -import javax.naming.NameNotFoundException; - -import org.jnode.naming.InitialNaming; -import org.jnode.system.MemoryResource; -import org.jnode.system.ResourceManager; -import org.jnode.system.ResourceNotFreeException; -import org.jnode.system.ResourceOwner; -import org.jnode.system.SimpleResourceOwner; -import org.jnode.vm.annotation.MagicPermission; -import org.vmmagic.unboxed.Address; -import org.vmmagic.unboxed.Extent; -import org.vmmagic.unboxed.Offset; - -@MagicPermission -public final class VMDirectByteBuffer { - - static Pointer allocate(int capacity) { - return new MemoryRawData(capacity); - } - - /** - * Wrap a bytebuffer around the given memory resource. - * @param resource - * @return - */ - public static ByteBuffer wrap(MemoryResource resource) { - final Object owner = resource.getOwner(); - final Pointer address = new MemoryRawData(resource); - final int size = resource.getSize().toInt(); - final ByteBuffer result = new DirectByteBufferImpl.ReadWrite(owner, address, size, size, 0); - result.mark(); - return result; - } - - static void free(Pointer address) { - ((MemoryRawData)address).resource.release(); - } - - static byte get(Pointer address, int index) { - final MemoryRawData mrd = (MemoryRawData)address; - final byte value = mrd.address.loadByte(Offset.fromIntZeroExtend(index)); - return value; - } - - static void get(Pointer address, int index, byte[] dst, int offset, - int length) { - ((MemoryRawData)address).resource.getBytes(index, dst, offset, length); - } - - static void put(Pointer address, int index, byte value) { - ((MemoryRawData)address).resource.setByte(index, value); - } - - static void put(Pointer address, int index, byte[] src, int offset, int length) - { - ((MemoryRawData)address).resource.setBytes(src, offset, index, length); - } - - static Pointer adjustAddress(Pointer address, int offset) { - final MemoryResource res = ((MemoryRawData)address).resource; - final Extent size = res.getSize().sub(offset); - try { - return new MemoryRawData(res.claimChildResource(Offset.fromIntZeroExtend(offset), size, true)); - } catch (ResourceNotFreeException ex) { - throw new Error("Cannot adjustAddress", ex); - } - } - - static void shiftDown(Pointer address, int dst_offset, int src_offset, - int count) { - ((MemoryRawData)address).resource.copy(src_offset, dst_offset, count); - } - - private static class MemoryRawData extends Pointer { - - final MemoryResource resource; - final Address address; - - public MemoryRawData(int size) { - try { - final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME); - final ResourceOwner owner = new SimpleResourceOwner("java.nio"); - this.resource = rm.claimMemoryResource(owner, null, size, - ResourceManager.MEMMODE_NORMAL); - this.address = resource.getAddress(); - } catch (NameNotFoundException ex) { - throw new Error("Cannot find ResourceManager", ex); - } catch (ResourceNotFreeException ex) { - throw new Error("Cannot allocate direct memory", ex); - } - } - - public MemoryRawData(MemoryResource resource) { - this.resource = resource; - this.address = resource.getAddress(); - } - } -} Added: trunk/core/src/classpath/vm/java/nio/channels/NativeVMChannels.java =================================================================== --- trunk/core/src/classpath/vm/java/nio/channels/NativeVMChannels.java (rev 0) +++ trunk/core/src/classpath/vm/java/nio/channels/NativeVMChannels.java 2009-04-01 18:57:30 UTC (rev 5209) @@ -0,0 +1,58 @@ +package java.nio.channels; + +import java.io.InputStream; +import java.io.FileInputStream; +import java.io.OutputStream; +import java.io.FileOutputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import gnu.java.nio.channels.FileChannelImpl; +import gnu.java.nio.ChannelInputStream; +import gnu.java.nio.ChannelOutputStream; + +/** + * + */ +public class NativeVMChannels { + /** + * Constructs a stream that reads bytes from the given channel. + */ + static InputStream newInputStream(ReadableByteChannel ch) { + if (ch instanceof FileChannelImpl) + return (FileInputStream) createStream(FileInputStream.class, ch); + + return new ChannelInputStream(ch); + } + + /** + * Constructs a stream that writes bytes to the given channel. + */ + static OutputStream newOutputStream(WritableByteChannel ch) { + if (ch instanceof FileChannelImpl) + return (FileOutputStream) createStream(FileOutputStream.class, ch); + + return new ChannelOutputStream(ch); + } + + private static Object createStream(Class streamClass, Channel ch) { + try { + Class[] argTypes = new Class[1]; + argTypes[0] = FileChannelImpl.class; + Constructor constructor = streamClass.getDeclaredConstructor(argTypes); + constructor.setAccessible(true); + Object[] args = new Object[1]; + args[0] = ch; + return constructor.newInstance(args); + } catch (IllegalAccessException e) { + // Ignored. + } catch (InstantiationException e) { + // Ignored. + } catch (InvocationTargetException e) { + // Ignored. + } catch (NoSuchMethodException e) { + // Ignored. + } + + return null; + } +} Deleted: trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java =================================================================== --- trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java 2009-04-01 15:03:30 UTC (rev 5208) +++ trunk/core/src/classpath/vm/java/nio/channels/VMChannels.java 2009-04-01 18:57:30 UTC (rev 5209) @@ -1,84 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package java.nio.channels; - -import gnu.java.nio.ChannelInputStream; -import gnu.java.nio.ChannelOutputStream; -import gnu.java.nio.channels.FileChannelImpl; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -final class VMChannels { - /** - * This class isn't intended to be instantiated. - */ - private VMChannels() { - // Do nothing here. - } - - private static Object createStream(Class streamClass, Channel ch) { - try { - Class[] argTypes = new Class[1]; - argTypes[0] = FileChannelImpl.class; - Constructor constructor = streamClass - .getDeclaredConstructor(argTypes); - constructor.setAccessible(true); - Object[] args = new Object[1]; - args[0] = ch; - return constructor.newInstance(args); - } catch (IllegalAccessException e) { - // Ignored. - } catch (InstantiationException e) { - // Ignored. - } catch (InvocationTargetException e) { - // Ignored. - } catch (NoSuchMethodException e) { - // Ignored. - } - - return null; - } - - /** - * Constructs a stream that reads bytes from the given channel. - */ - static InputStream newInputStream(ReadableByteChannel ch) { - if (ch instanceof FileChannelImpl) - return (FileInputStream) createStream(FileInputStream.class, ch); - - return new ChannelInputStream(ch); - } - - /** - * Constructs a stream that writes bytes to the given channel. - */ - static OutputStream newOutputStream(WritableByteChannel ch) { - if (ch instanceof FileChannelImpl) - return (FileOutputStream) createStream(FileOutputStream.class, ch); - - return new ChannelOutputStream(ch); - } -} Modified: trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java =================================================================== --- trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java 2009-04-01 15:03:30 UTC (rev 5208) +++ trunk/core/src/core/org/jnode/vm/MemoryResourceImpl.java 2009-04-01 18:57:30 UTC (rev 5209) @@ -21,7 +21,7 @@ package org.jnode.vm; import java.nio.ByteBuffer; -import java.nio.VMDirectByteBuffer; +import java.nio.MemoryRawData; import org.jnode.system.MemoryResource; import org.jnode.system.MultiMediaMemoryResource; @@ -139,7 +139,7 @@ * @return a bytebuffer that has the same content as this resource */ public ByteBuffer asByteBuffer() { - return VMDirectByteBuffer.wrap(this); + return MemoryRawData.wrap(this); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-04-02 19:01:08
|
Revision: 5210 http://jnode.svn.sourceforge.net/jnode/?rev=5210&view=rev Author: lsantha Date: 2009-04-02 19:01:01 +0000 (Thu, 02 Apr 2009) Log Message: ----------- Separating jnode os code from classlib. Modified Paths: -------------- trunk/all/conf/openjdk-annotations.properties trunk/core/src/core/org/jnode/debugger/DebuggerUtils.java trunk/core/src/core/org/jnode/debugger/ThreadListState.java trunk/core/src/core/org/jnode/debugger/ThreadState.java trunk/core/src/core/org/jnode/vm/isolate/VmIsolate.java trunk/core/src/core/org/jnode/vm/scheduler/IRQThread.java trunk/core/src/openjdk/vm/java/lang/reflect/NativeProxy.java trunk/core/src/openjdk/vm/sun/misc/NativeUnsafe.java trunk/core/src/test/org/jnode/test/core/StackView.java trunk/shell/src/shell/org/jnode/shell/command/ThreadCommand.java Added Paths: ----------- trunk/core/src/classpath/java/java/lang/ClassLoader.java trunk/core/src/classpath/java/java/lang/Thread.java trunk/core/src/classpath/vm/java/lang/NativeClassLoader.java trunk/core/src/classpath/vm/java/lang/NativeThread.java trunk/core/src/classpath/vm/java/lang/ThreadHelper.java Removed Paths: ------------- trunk/core/src/classpath/vm/java/lang/ClassLoader.java trunk/core/src/classpath/vm/java/lang/Thread.java Modified: trunk/all/conf/openjdk-annotations.properties =================================================================== --- trunk/all/conf/openjdk-annotations.properties 2009-04-01 18:57:30 UTC (rev 5209) +++ trunk/all/conf/openjdk-annotations.properties 2009-04-02 19:01:01 UTC (rev 5210) @@ -9,6 +9,7 @@ java/awt/image/DataBuffer.class=SharedStatics java/awt/KeyboardFocusManager.class=SharedStatics java/awt/Toolkit.class=SharedStatics +java/lang/Thread.class=SharedStatics java/lang/ThreadLocal.class=SharedStatics java/lang/Throwable.class=MagicPermission java/net/InetAddress.class=SharedStatics Copied: trunk/core/src/classpath/java/java/lang/ClassLoader.java (from rev 5209, trunk/core/src/classpath/vm/java/lang/ClassLoader.java) =================================================================== --- trunk/core/src/classpath/java/java/lang/ClassLoader.java (rev 0) +++ trunk/core/src/classpath/java/java/lang/ClassLoader.java 2009-04-02 19:01:01 UTC (rev 5210) @@ -0,0 +1,950 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package java.lang; + +import gnu.classpath.SystemProperties; +import gnu.java.util.EmptyEnumeration; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.ByteBuffer; +import java.security.AccessController; +import java.security.CodeSource; +import java.security.PermissionCollection; +import java.security.Policy; +import java.security.PrivilegedAction; +import java.security.ProtectionDomain; +import java.security.cert.Certificate; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import sun.reflect.Reflection; + +public abstract class ClassLoader { + + private final ClassLoader parent; + + //this is always a VmClassLoaderInstance + final Object vmClassLoader; + + private ProtectionDomain defaultProtectionDomain; + + /** + * All packages defined by this classloader. It is not private in order to + * allow native code (and trusted subclasses) access to this field. + */ + final HashMap<String, Package> definedPackages = new HashMap<String, Package>(); + + /** + * The desired assertion status of classes loaded by this loader, if not + * overridden by package or class instructions. + */ + // Package visible for use by Class. + boolean defaultAssertionStatus = VMClassLoader.defaultAssertionStatus(); + + /** + * The map of package assertion status overrides, or null if no package + * overrides have been specified yet. The values of the map should be + * Boolean.TRUE or Boolean.FALSE, and the unnamed package is represented by + * the null key. This map must be synchronized on this instance. + */ + // Package visible for use by Class. + Map<String, Boolean> packageAssertionStatus; + + /** + * The map of class assertion status overrides, or null if no class + * overrides have been specified yet. The values of the map should be + * Boolean.TRUE or Boolean.FALSE. This map must be synchronized on this + * instance. + */ + // Package visible for use by Class. + Map<String, Boolean> classAssertionStatus; + + static class StaticData { + /** + * The System Class Loader (a.k.a. Application Class Loader). The one + * returned by ClassLoader.getSystemClassLoader. + */ + static final ClassLoader systemClassLoader = VMClassLoader + .getSystemClassLoader(); + static { + // Find out if we have to install a default security manager. Note + // that + // this is done here because we potentially need the system class + // loader + // to load the security manager and note also that we don't need the + // security manager until the system class loader is created. + // If the runtime chooses to use a class loader that doesn't have + // the + // system class loader as its parent, it is responsible for setting + // up a security manager before doing so. + String secman = SystemProperties + .getProperty("java.security.manager"); + if (secman != null && SecurityManager.current == null) { + if (secman.equals("") || secman.equals("default")) { + SecurityManager.current = new SecurityManager(); + } else { + try { + Class< ? > cl = Class.forName(secman, false, + StaticData.systemClassLoader); + SecurityManager.current = (SecurityManager) cl + .newInstance(); + } catch (Exception x) { + throw (InternalError) new InternalError( + "Unable to create SecurityManager") + .initCause(x); + } + } + } + } + + /** + * The default protection domain, used when defining a class with a null + * parameter for the domain. + */ + static final ProtectionDomain defaultProtectionDomain; + static { + final CodeSource cs = new CodeSource(null, (Certificate[])null); + PermissionCollection perm = AccessController + .doPrivileged(new PrivilegedAction<PermissionCollection>() { + public PermissionCollection run() { + return Policy.getPolicy().getPermissions(cs); + } + }); + defaultProtectionDomain = new ProtectionDomain(cs, perm); + } + + /** + * The command-line state of the package assertion status overrides. + * This map is never modified, so it does not need to be synchronized. + */ + // Package visible for use by Class. + static final Map<String, Boolean> systemPackageAssertionStatus = VMClassLoader + .packageAssertionStatus(); + + /** + * The command-line state of the class assertion status overrides. This + * map is never modified, so it does not need to be synchronized. + */ + // Package visible for use by Class. + static final Map<String, Boolean> systemClassAssertionStatus = VMClassLoader + .classAssertionStatus(); + } + + /** + * Create a new ClassLoader with the specified parent. The parent will be + * consulted when a class or resource is requested through + * <code>loadClass()</code> or <code>getResource()</code>. Only when + * the parent classloader cannot provide the requested class or resource the + * <code>findClass()</code> or <code>findResource()</code> method of + * this classloader will be called. There may be a security check for + * <code>checkCreateClassLoader</code>. + * + * @param parent + * the classloader's parent + * @throws SecurityException + * if the security check fails + * @since 1.2 + */ + protected ClassLoader(ClassLoader parent) { + /* May we create a new classloader? */ + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkCreateClassLoader(); + } + this.parent = parent; + this.vmClassLoader = createVmJavaClassLoader0(this); + } + + private static native Object createVmJavaClassLoader0(ClassLoader instance); + + /** + * Create a new instance + * + */ + protected ClassLoader() { + this(getSystemClassLoader()); + } + + /** + * Create a new classloader wrapped around a given VmClassLoader. + * + * @param vmClassLoader + */ + protected ClassLoader(Object vmClassLoader, int discriminator) { + /* May we create a new classloader? */ + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkCreateClassLoader(); + } + if (vmClassLoader == null) { + throw new IllegalArgumentException("vmClassLoader cannot be null"); + } + checkArg0(vmClassLoader); + this.parent = null; + this.vmClassLoader = vmClassLoader; + } + + private static native void checkArg0(Object vmClassLoader); + + /** + * Create a new classloader wrapped around a given VmClassLoader, + * with a given parent loader. + * + * @param vmClassLoader + */ + protected ClassLoader(ClassLoader parent, Object vmClassLoader) { + /* May we create a new classloader? */ + checkArgs0(vmClassLoader); + this.parent = parent; + this.vmClassLoader = vmClassLoader; + } + + private static native void checkArgs0(Object vmClassLoader); + + /** + * Gets the VmClassLoader that is used by this classloader. + * This method requires special permission. + * @return + */ + public final Object getVmClassLoader() { + return getVmClassLoader0(); + } + + private native Object getVmClassLoader0(); + + /** + * Load and resolve a class with a given name. + * + * @param name + * @return Class + * @throws ClassNotFoundException + */ + public Class loadClass(String name) throws ClassNotFoundException { + // return vmClassLoader.loadClass(name, true).asClass(); + return loadClass(name, true); + } + + /** + * Load and optionally resolve a class with a given name. + * + * @param name + * @param resolve + * @return Class + * @throws ClassNotFoundException + */ + protected Class loadClass(String name, boolean resolve) + throws ClassNotFoundException { + + /* Have we already loaded this class? */ + final Class cls = findLoadedClass(name); + if (cls != null) { + return cls; + } + + /* Can the class been loaded by a parent? */ + try { + if ((parent == null) || skipParentLoader(name)) { + return loadClass0(name, resolve); + } else { + return parent.loadClass(name, resolve); + } + } catch (ClassNotFoundException e) { + // e.printStackTrace(); + } + /* Still not found, we have to do it ourself. */ + final Class c = findClass(name); + if (resolve) { + resolveClass(c); + } + return c; + } + + private static native Class loadClass0(String name, boolean resolve) throws ClassNotFoundException; + + /** + * Define a byte-array of class data into a loaded class. + * + * @param data + * @param offset + * @param length + * @return Class + * @deprecated Replaced by {@link #defineClass(String, byte[], int, int)} + */ + protected final Class defineClass(byte[] data, int offset, int length) { + return defineClass(null, data, offset, length, null); + } + + /** + * Define a byte-array of class data into a loaded class. + * + * @param name + * @param data + * @param offset + * @param length + * @return Class + */ + protected final Class defineClass(String name, byte[] data, int offset, + int length) { + return defineClass(name, data, offset, length, null); + } + + /** + * Defines a new package and creates a Package object. The package should be + * defined before any class in the package is defined with + * <code>defineClass()</code>. The package should not yet be defined + * before in this classloader or in one of its parents (which means that + * <code>getPackage()</code> should return <code>null</code>). All + * parameters except the <code>name</code> of the package may be + * <code>null</code>. + * + * <p> + * Subclasses should call this method from their <code>findClass()</code> + * implementation before calling <code>defineClass()</code> on a Class in + * a not yet defined Package (which can be checked by calling + * <code>getPackage()</code>). + * + * @param name + * the name of the Package + * @param specTitle + * the name of the specification + * @param specVendor + * the name of the specification designer + * @param specVersion + * the version of this specification + * @param implTitle + * the name of the implementation + * @param implVendor + * the vendor that wrote this implementation + * @param implVersion + * the version of this implementation + * @param sealed + * if sealed the origin of the package classes + * @return the Package object for the specified package + * @throws IllegalArgumentException + * if the package name is null or it was already defined by this + * classloader or one of its parents + * @see Package + * @since 1.2 + */ + protected Package definePackage(String name, String specTitle, + String specVendor, String specVersion, String implTitle, + String implVendor, String implVersion, URL sealed) { + if (getPackage(name) != null) + throw new IllegalArgumentException("Package " + name + + " already defined"); + Package p = new Package(name, specTitle, specVendor, specVersion, + implTitle, implVendor, implVersion, sealed, this); + synchronized (definedPackages) { + definedPackages.put(name, p); + } + return p; + } + + /** + * Define a byte-array of class data into a loaded class. + * + * @param name + * @param data + * @param offset + * @param length + * @param protDomain + * @return Class + */ + protected final Class defineClass(String name, byte[] data, int offset, + int length, ProtectionDomain protDomain) { + if (data == null) { + throw new NullPointerException(); + } + if (offset < 0 || length < 0 || (offset + length) > data.length) { + throw new IndexOutOfBoundsException(); + } + if (protDomain == null) { + + protDomain = AccessController + .doPrivileged(new PrivilegedAction<ProtectionDomain>() { + + public ProtectionDomain run() { + return getDefaultProtectionDomain(); + } + }); + } + return defineClass0(name, data, offset, length, protDomain); + } + + private native Class defineClass0(String name, byte[] data, int offset, int length, ProtectionDomain protDomain); + + /** + * Define a byte-array of class data into a loaded class. + * + * @param name + * @param data + * @param protDomain + * @return Class + */ + protected final Class defineClass(String name, ByteBuffer data, ProtectionDomain protDomain) { + if (data == null) { + throw new NullPointerException(); + } + if (protDomain == null) { + protDomain = AccessController.doPrivileged( + new PrivilegedAction<ProtectionDomain>() { + public ProtectionDomain run() { + return getDefaultProtectionDomain(); + } + }); + } + return defineClass0(name, data, protDomain); + } + + private native Class defineClass0(String name, ByteBuffer data, ProtectionDomain protDomain); + + private ProtectionDomain getDefaultProtectionDomain() { + if (defaultProtectionDomain == null) { + final CodeSource cs = new CodeSource(null, (Certificate[])null); + defaultProtectionDomain = new ProtectionDomain(cs, Policy + .getPolicy().getPermissions(cs)); + } + return defaultProtectionDomain; + } + + /** + * Resolve all references in the given class. + * + * @param c + */ + protected final void resolveClass(Class c) { + if (c == null) { + throw new NullPointerException(); + } + } + + /** + * Finds the class with the given name if it had been previously loaded + * through this class loader. + * + * @param name + * @return the Class object, or null if the class has not been loaded + */ + protected native final Class findLoadedClass(String name); + + /** + * Finds the specified class. This method should be overridden by class + * loader implementations that follow the new delegation model for loading + * classes, and will be called by the loadClass method after checking the + * parent class loader for the requested class. The default implementation + * throws ClassNotFoundException. + * + * @param name + * @return Class + * @throws ClassNotFoundException + */ + protected Class findClass(String name) throws ClassNotFoundException { + throw new ClassNotFoundException(name); + } + + /** + * Find a system class. + * + * @param name + * @return Class + * @throws ClassNotFoundException + */ + protected final Class findSystemClass(String name) + throws ClassNotFoundException { + if (name == null) { + throw new NullPointerException(); + } else { + return loadClass0(name, true); + } + } + + /** + * Gets a system resource as stream by name. + * + * @param name + * @return InputStream + */ + public static final InputStream getSystemResourceAsStream(String name) { + try { + return getSystemResourceAsStream0(name); + } catch (IOException ex) { + return null; + } + } + + private static native InputStream getSystemResourceAsStream0(String name) throws IOException; + + /** + * Gets a resource as stream by name. + * + * @param name + * @return InputStream + */ + public InputStream getResourceAsStream(String name) { + URL url = getResource(name); + if (url != null) { + try { + return url.openStream(); + } catch (IOException ex) { + // Syslog.debug("Cannot load resource " + name, ex); + return null; + } + } else { + return null; + } + } + + /** + * Gets a URL to a system resource by name. + * + * @param name + * @return URL + */ + public static final URL getSystemResource(String name) { + try { + if (name.startsWith("/")) { + return new URL("system://" + name); + } else { + return new URL("system:///" + name); + } + } catch (MalformedURLException ex) { + ex.printStackTrace(); + return null; + } + } + + /** + * Gets an URL to a resource by name. + * + * @param name + * @return URL + */ + public URL getResource(String name) { + URL result = null; + + if (parent == null) { + if (resourceExists0(name)) { + try { + if (name.startsWith("/")) { + result = new URL("system://" + name); + } else { + result = new URL("system:///" + name); + } + } catch (MalformedURLException ex) { + ex.printStackTrace(); + result = null; + } + } + } else { + result = parent.getResource(name); + } + + if (result == null) { + result = findResource(name); + } + return result; + } + + private native boolean resourceExists0(String name); + + public Enumeration getResources(String name) throws IOException { + final List<URL> urls = new ArrayList<URL>(); + getResourcesImpl(name, urls); + + return new Enumeration<URL>() + { + private Iterator<URL> it = urls.iterator(); + + public boolean hasMoreElements() { + return it.hasNext(); + } + + public URL nextElement() { + return it.next(); + } + }; + } + + protected boolean getResourcesImpl(String name, List<URL> urls) throws IOException { + URL result = null; + if (parent == null) { + if (resourceExists0(name)) { + try { + if (name.startsWith("/")) { + //todo: adjust the rt.jar path to match the future configurations + //todo: one possibility is ${java.home}/lib/rt.jar + result = new URL("jar:file:/jifs/lib/rt.jar!" + name); + //result = new URL("system://" + name); + } else { + //todo: adjust the rt.jar path to match the future configurations + //todo: one possibility is ${java.home}/lib/rt.jar + result = new URL("jar:file:/jifs/lib/rt.jar!/" + name); + //result = new URL("system:///" + name); + } + } catch (MalformedURLException ex) { + ex.printStackTrace(); + result = null; + } + if(result != null) + { + if(!urls.contains(result)) urls.add(result); + } + } + } else { + parent.getResourcesImpl(name, urls); + } + + if (result == null) { + result = findResource(name); + if(result != null) + { + if(!urls.contains(result)) urls.add(result); + } + } + + return (result != null); + } + + /** + * Finds the resource with the given name. Class loader implementations + * should override this method to specify where to find resources. + * + * @param name + * @return URL + */ + protected URL findResource(String name) { + return null; + } + + /** + * Called whenever all locations of a named resource are needed. + * It is called by <code>getResources()</code> after it has called + * <code>parent.getResources()</code>. The results are combined by + * the <code>getResources()</code> method. + * + * <p>The default implementation always returns an empty Enumeration. + * Subclasses should override it when they can provide an Enumeration of + * URLs (possibly just one element) to the named resource. + * The first URL of the Enumeration should be the same as the one + * returned by <code>findResource</code>. + * + * @param name the name of the resource to be found + * @return a possibly empty Enumeration of URLs to the named resource + * @throws IOException if I/O errors occur in the process + * @since 1.2 + */ + protected Enumeration findResources(String name) throws IOException + { + return EmptyEnumeration.getInstance(); + } + + + /** + * Returns the Package object for the requested package name. It returns + * null when the package is not defined by this classloader or one of its + * parents. + * + * @param name + * the package name to find + * @return the package, if defined + * @since 1.2 + */ + protected Package getPackage(String name) { + Package p; + if (parent == null) { + p = VMClassLoader.getPackage(name); + } else { + p = parent.getPackage(name); + } + + if (p == null) { + synchronized (definedPackages) { + p = definedPackages.get(name); + } + } + return p; + } + + /** + * Returns all Package objects defined by this classloader and its parents. + * + * @return an array of all defined packages + * @since 1.2 + */ + protected Package[] getPackages() { + // Get all our packages. + Package[] packages; + synchronized (definedPackages) { + packages = new Package[definedPackages.size()]; + definedPackages.values().toArray(packages); + } + + // If we have a parent get all packages defined by our parents. + Package[] parentPackages; + if (parent == null) + parentPackages = VMClassLoader.getPackages(); + else + parentPackages = parent.getPackages(); + + Package[] allPackages = new Package[parentPackages.length + + packages.length]; + System.arraycopy(parentPackages, 0, allPackages, 0, + parentPackages.length); + System.arraycopy(packages, 0, allPackages, parentPackages.length, + packages.length); + return allPackages; + } + + /** + * Avoid trying to load the given class via its parent classloader? + * + * @param name + * @return {@code true} if the parent classloader should be skipped. + */ + public boolean skipParentLoader(String name) { + return false; + } + + /** + * Gets the system classloader. + * + * @return ClassLoader + */ + public static native ClassLoader getSystemClassLoader(); + + public static Enumeration getSystemResources(String name) + throws IOException { + return EmptyEnumeration.getInstance(); + } + + /** + * @return + */ + public ClassLoader getParent() { + return parent; + } + + /** + * Called by <code>Runtime.loadLibrary()</code> to get an absolute path to + * a (system specific) library that was requested by a class loaded by this + * classloader. The default implementation returns <code>null</code>. It + * should be implemented by subclasses when they have a way to find the + * absolute path to a library. If this method returns null the library is + * searched for in the default locations (the directories listed in the + * <code>java.library.path</code> system property). + * + * @param name + * the (system specific) name of the requested library + * @return the full pathname to the requested library, or null + * @see Runtime#loadLibrary(String) + * @since 1.2 + */ + protected String findLibrary(String name) { + return null; + } + + /** + * Sets the signers of a class. This should be invoked after defining a + * class. + * + * @param clazz + * The class object. + * @param signers + * The signers. + */ + protected final void setSigners(Class clazz, Object[] signers) { + // TODO implement me + } + + /** + * Set the default assertion status for classes loaded by this classloader, + * used unless overridden by a package or class request. + * + * @param enabled + * true to set the default to enabled + * @see #setClassAssertionStatus(String, boolean) + * @see #setPackageAssertionStatus(String, boolean) + * @see #clearAssertionStatus() + * @since 1.4 + */ + public void setDefaultAssertionStatus(boolean enabled) { + defaultAssertionStatus = enabled; + } + + /** + * Set the default assertion status for packages, used unless overridden by + * a class request. This default also covers subpackages, unless they are + * also specified. The unnamed package should use null for the name. + * + * @param name + * the package (and subpackages) to affect + * @param enabled + * true to set the default to enabled + * @see #setDefaultAssertionStatus(boolean) + * @see #setClassAssertionStatus(String, boolean) + * @see #clearAssertionStatus() + * @since 1.4 + */ + public synchronized void setPackageAssertionStatus(String name, + boolean enabled) { + if (packageAssertionStatus == null) + packageAssertionStatus = new HashMap<String, Boolean>( + StaticData.systemPackageAssertionStatus); + packageAssertionStatus.put(name, Boolean.valueOf(enabled)); + } + + /** + * Set the default assertion status for a class. This only affects the + * status of top-level classes, any other string is harmless. + * + * @param name + * the class to affect + * @param enabled + * true to set the default to enabled + * @throws NullPointerException + * if name is null + * @see #setDefaultAssertionStatus(boolean) + * @see #setPackageAssertionStatus(String, boolean) + * @see #clearAssertionStatus() + * @since 1.4 + */ + public synchronized void setClassAssertionStatus(String name, + boolean enabled) { + if (classAssertionStatus == null) + classAssertionStatus = new HashMap<String, Boolean>( + StaticData.systemClassAssertionStatus); + // The toString() hack catches null, as required. + classAssertionStatus.put(name.toString(), Boolean.valueOf(enabled)); + } + + /** + * Resets the default assertion status of this classloader, its packages and + * classes, all to false. This allows overriding defaults inherited from the + * command line. + * + * @see #setDefaultAssertionStatus(boolean) + * @see #setClassAssertionStatus(String, boolean) + * @see #setPackageAssertionStatus(String, boolean) + * @since 1.4 + */ + public synchronized void clearAssertionStatus() { + defaultAssertionStatus = false; + packageAssertionStatus = null; + classAssertionStatus = null; + } + + //jnod+openjdk + // Returns the invoker's class loader, or null if none. + // NOTE: This must always be invoked when there is exactly one intervening + // frame from the core libraries on the stack between this method's + // invocation and the desired invoker. + static ClassLoader getCallerClassLoader() { + // NOTE use of more generic Reflection.getCallerClass() + Class caller = Reflection.getCallerClass(3); + // This can be null if the VM is requesting it + if (caller == null) { + return null; + } + // Circumvent security check since this is package-private + return caller.getClassLoader0(); + } + + // Returns true if the specified class loader can be found in this class + // loader's delegation chain. + boolean isAncestor(ClassLoader cl) { + ClassLoader acl = this; + do { + acl = acl.parent; + if (cl == acl) { + return true; + } + } while (acl != null); + return false; + } + +/** + * Returns the assertion status that would be assigned to the specified + * class if it were to be initialized at the time this method is invoked. + * If the named class has had its assertion status set, the most recent + * setting will be returned; otherwise, if any package default assertion + * status pertains to this class, the most recent setting for the most + * specific pertinent package default assertion status is returned; + * otherwise, this class loader's default assertion status is returned. + * </p> + * + * @param className + * The fully qualified class name of the class whose desired + * assertion status is being queried. + * + * @return The desired assertion status of the specified class. + * + * @see #setClassAssertionStatus(String, boolean) + * @see #setPackageAssertionStatus(String, boolean) + * @see #setDefaultAssertionStatus(boolean) + * + * @since 1.4 + */ + synchronized boolean desiredAssertionStatus(String className) { + Boolean result; + + // assert classAssertionStatus != null; + // assert packageAssertionStatus != null; + + // Check for a class entry + result = (Boolean)classAssertionStatus.get(className); + if (result != null) + return result.booleanValue(); + + // Check for most specific package entry + int dotIndex = className.lastIndexOf("."); + if (dotIndex < 0) { // default package + result = (Boolean)packageAssertionStatus.get(null); + if (result != null) + return result.booleanValue(); + } + while(dotIndex > 0) { + className = className.substring(0, dotIndex); + result = (Boolean)packageAssertionStatus.get(className); + if (result != null) + return result.booleanValue(); + dotIndex = className.lastIndexOf(".", dotIndex-1); + } + + // Return the classloader default + return defaultAssertionStatus; + } + + { + packageAssertionStatus = new HashMap(); + } + + public static void loadLibrary(Class fromClass, String libname, boolean b) { + //do nothing + } + +} Property changes on: trunk/core/src/classpath/java/java/lang/ClassLoader.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Copied: trunk/core/src/classpath/java/java/lang/Thread.java (from rev 5209, trunk/core/src/classpath/vm/java/lang/Thread.java) =================================================================== --- trunk/core/src/classpath/java/java/lang/Thread.java (rev 0) +++ trunk/core/src/classpath/java/java/lang/Thread.java 2009-04-02 19:01:01 UTC (rev 5210) @@ -0,0 +1,1390 @@ +/* Thread -- an independent thread of executable code + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang; + +import java.util.Map; +import java.util.HashMap; + + +import sun.security.util.SecurityConstants; +import sun.nio.ch.Interruptible; + +/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 +* "The Java Language Specification", ISBN 0-201-63451-1 +* plus online API docs for JDK 1.2 beta from http://www.javasoft.com. +* Status: Believed complete to version 1.4, with caveats. We do not +* implement the deprecated (and dangerous) stop, suspend, and resume +* methods. Security implementation is not complete. +*/ + +/** + * Thread represents a single thread of execution in the VM. When an + * application VM starts up, it creates a non-daemon Thread which calls the + * main() method of a particular class. There may be other Threads running, + * such as the garbage collection thread. + * + * <p>Threads have names to identify them. These names are not necessarily + * unique. Every Thread has a priority, as well, which tells the VM which + * Threads should get more running time. New threads inherit the priority + * and daemon status of the parent thread, by default. + * + * <p>There are two methods of creating a Thread: you may subclass Thread and + * implement the <code>run()</code> method, at which point you may start the + * Thread by calling its <code>start()</code> method, or you may implement + * <code>Runnable</code> in the class you want to use and then call new + * <code>Thread(your_obj).start()</code>. + * + * <p>The virtual machine runs until all non-daemon threads have died (either + * by returning from the run() method as invoked by start(), or by throwing + * an uncaught exception); or until <code>System.exit</code> is called with + * adequate permissions. + * + * <p>It is unclear at what point a Thread should be added to a ThreadGroup, + * and at what point it should be removed. Should it be inserted when it + * starts, or when it is created? Should it be removed when it is suspended + * or interrupted? The only thing that is clear is that the Thread should be + * removed when it is stopped. + * + * @author Tom Tromey + * @author John Keiser + * @author Eric Blake (eb...@em...) + * @author Andrew John Hughes (gnu...@me...) + * @see Runnable + * @see Runtime#exit(int) + * @see #run() + * @see #start() + * @see ThreadLocal + * @since 1.0 + */ +public class Thread implements Runnable +{ + /** The minimum priority for a Thread. */ + public static final int MIN_PRIORITY = 1; + + /** The priority a Thread gets by default. */ + public static final int NORM_PRIORITY = 5; + + /** The maximum priority for a Thread. */ + public static final int MAX_PRIORITY = 10; + + private static final String NONAME = "Thread"; + + /** The VM thread implementing this thread */ + final Object vmThread; + + /** The group this thread belongs to. + * + */ + ThreadGroup group; + + /** The object to run(), null if this is the target. */ + final Runnable runnable; + + /** The name of this thread */ + String name; + + /** Is this a daemon thread? */ + private boolean daemon; + + /** The context classloader of this thread */ + private ClassLoader contextClassLoader; + + /** The thread in which I was created */ + private final Thread parent; + + /** The default exception handler. */ + private static UncaughtExceptionHandler defaultHandler; + + /* ThreadLocal values pertaining to this thread. This map is maintained + * by the ThreadLocal class. */ + ThreadLocal.ThreadLocalMap threadLocals = null; + + /* + * InheritableThreadLocal values pertaining to this thread. This map is + * maintained by the InheritableThreadLocal class. + */ + ThreadLocal.ThreadLocalMap inheritableThreadLocals = null; + + /** The uncaught exception handler. */ + UncaughtExceptionHandler exceptionHandler; + + /** + * Name and number of threads created. Used only for generating unique names. + * + * @see java.lang.Thread#autoName(String) + */ + private static final HashMap<String, Integer> nameMap = new HashMap<String, Integer>(); + + /** + * Allocates a new <code>Thread</code> object. This constructor has + * the same effect as <code>Thread(null, null,</code> + * <i>gname</i><code>)</code>, where <b><i>gname</i></b> is + * a newly generated name. Automatically generated names are of the + * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer. + * <p> + * Threads created this way must have overridden their + * <code>run()</code> method to actually do anything. An example + * illustrating this method being used follows: + * <p><blockquote><pre> + * import java.lang.*; + * + * class plain01 implements Runnable { + * String name; + * plain01() { + * name = null; + * } + * plain01(String s) { + * name = s; + * } + * public void run() { + * if (name == null) + * System.out.println("A new thread created"); + * else + * System.out.println("A new thread with name " + name + + * " created"); + * } + * } + * class threadtest01 { + * public static void main(String args[] ) { + * int failed = 0 ; + * + * <b>Thread t1 = new Thread();</b> + * if (t1 != null) + * System.out.println("new Thread() succeed"); + * else { + * System.out.println("new Thread() failed"); + * failed++; + * } + * } + * } + * </pre></blockquote> + * + * @see java.lang.Thread#Thread(java.lang.ThreadGroup, + * java.lang.Runnable, java.lang.String) + */ + public Thread() + { + this(null, null, NONAME); + } + + /** + * Allocates a new <code>Thread</code> object. This constructor has + * the same effect as <code>Thread(null, target,</code> + * <i>gname</i><code>)</code>, where <i>gname</i> is + * a newly generated name. Automatically generated names are of the + * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer. + * + * @param target the object whose <code>run</code> method is called. + * @see java.lang.Thread#Thread(java.lang.ThreadGroup, + * java.lang.Runnable, java.lang.String) + */ + public Thread(Runnable target) + { + this(null, target, NONAME); + } + + /** + * Allocates a new <code>Thread</code> object. This constructor has + * the same effect as <code>Thread(null, null, name)</code>. + * + * @param name the name of the new thread. + * @see java.lang.Thread#Thread(java.lang.ThreadGroup, + * java.lang.Runnable, java.lang.String) + */ + public Thread(String name) + { + this(null, null, name); + } + + /** + * Allocates a new <code>Thread</code> object. This constructor has + * the same effect as <code>Thread(group, target,</code> + * <i>gname</i><code>)</code>, where <i>gname</i> is + * a newly generated name. Automatically generated names are of the + * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer. + * + * @param group the group to put the Thread into + * @param target the Runnable object to execute + * @throws SecurityException if this thread cannot access <code>group</code> + * @throws IllegalThreadStateException if group is destroyed + * @see #Thread(ThreadGroup, Runnable, String) + */ + public Thread(ThreadGroup group, Runnable target) + { + this(group, target, NONAME); + } + + /** + * Allocates a new <code>Thread</code> object. This constructor has + * the same effect as <code>Thread(group, null, name)</code> + * + * @param group the group to put the Thread into + * @param name the name for the Thread + * @throws NullPointerException if name is null + * @throws SecurityException if this thread cannot access <code>group</code> + * @throws IllegalThreadStateException if group is destroyed + * @see #Thread(ThreadGroup, Runnable, String) + */ + public Thread(ThreadGroup group, String name) + { + this(group, null, name); + } + + /** + * Allocates a new <code>Thread</code> object. This constructor has + * the same effect as <code>Thread(null, target, name)</code>. + * + * @param target the Runnable object to execute + * @param name the name for the Thread + * @throws NullPointerException if name is null + * @see #Thread(ThreadGroup, Runnable, String) + */ + public Thread(Runnable target, String name) + { + this(null, target, name); + } + + /** + * Allocate a new Thread object, with the specified ThreadGroup and name, and + * using the specified Runnable object's <code>run()</code> method to + * execute. If the Runnable object is null, <code>this</code> (which is + * a Runnable) is used instead. + * + * <p>If the ThreadGroup is null, the security manager is checked. If a + * manager exists and returns a non-null object for + * <code>getThreadGroup</code>, that group is used; otherwise the group + * of the creating thread is used. Note that the security manager calls + * <code>checkAccess</code> if the ThreadGroup is not null. + * + * <p>The new Thread will inherit its creator's priority and daemon status. + * These can be changed with <code>setPriority</code> and + * <code>setDaemon</code>. + * + * @param group the group to put the Thread into + * @param target the Runnable object to execute + * @param name the name for the Thread + * @throws NullPointerException if name is null + * @throws SecurityException if this thread cannot access <code>group</code> + * @throws IllegalThreadStateException if group is destroyed + * @see Runnable#run() + * @see #run() + * @see #setDaemon(boolean) + * @see #setPriority(int) + * @see SecurityManager#checkAccess(ThreadGroup) + * @see ThreadGroup#checkAccess() + */ + public Thread(ThreadGroup group, Runnable target, String name) + { + Thread current = currentThread(); + + if (group != null) { + group.checkAccess(); + } else { + group = current.getThreadGroup(); + } + + if (group == null) { + throw new InternalError("Live thread has invalid group: " + name); + } + + group.addUnstarted(); + + this.group = group; + this.runnable = target; + this.name = autoName(name); + this.parent = current; + + this.daemon = current.isDaemon(); + + this.vmThread = createVmThread0(current); + setPriority(current.getPriority()); + updateName0(); + + + if (parent.inheritableThreadLocals != null) + this.inheritableThreadLocals = ThreadLocal.createInheritedMap(parent.inheritableThreadLocals); + } + + private native Object createVmThread0(Thread current); + + /** + * Allocate a new Thread object, as if by + * <code>Thread(group, null, name)</code>, and give it the specified stack + * size, in bytes. The stack size is <b>highly platform independent</b>, + * and the virtual machine is free to round up or down, or ignore it + * completely. A higher value might let you go longer before a + * <code>StackOverflowError</code>, while a lower value might let you go + * longer before an <code>OutOfMemoryError</code>. Or, it may do absolutely + * nothing! So be careful, and expect to need to tune this value if your + * virtual machine even supports it. + * + * @param group the group to put the Thread into + * @param target the Runnable object to execute + * @param name the name for the Thread + * @param size the stack size, in bytes; 0 to be ignored + * @throws NullPointerException if name is null + * @throws SecurityException if this thread cannot access <code>group</code> + * @throws IllegalThreadStateException if group is destroyed + * @since 1.4 + */ + public Thread(ThreadGroup group, Runnable target, String name, long size) + { + Thread current = currentThread(); + + if (group != null) { + group.checkAccess(); + } else { + group = current.getThreadGroup(); + } + + if (group == null) { + throw new InternalError("Live thread has invalid group: " + name); + } + + group.addUnstarted(); + + this.group = group; + this.runnable = target; + this.name = autoName(name); + this.parent = current; + + this.daemon = current.isDaemon(); + + this.vmThread = createVmThread0(current); + setPriority(current.getPriority()); + updateName0(); + + + if (parent.inheritableThreadLocals != null) + this.inheritableThreadLocals = ThreadLocal.createInheritedMap(parent.inheritableThreadLocals); + } + + /** + * Create a new instance with a given group as containing group, a runnable + * as thread runner and a given name. + * + * @param group + * @param target + * @param name + */ + protected Thread(ThreadGroup group, Runnable target, String name, Object isolatedStatics) { + /* + if (!(this instanceof IsolateThread)) { + throw new SecurityException("Constructor can only be called from IsolateThread"); + } + */ + if (!(this.getClass().getName().startsWith("org.jnode.vm.isolate"))) { + throw new SecurityException("Constructor can only be called from IsolateThread"); + } + if (group == null) { + throw new InternalError("Isolate thread has invalid group: " + name); + } + + group.addUnstarted(); + + this.group = group; + this.runnable = target; + this.name = autoName(name); + this.parent = null; + this.daemon = false; + + this.vmThread = createVmThread1(isolatedStatics); + setPriority(this.getPriority()); + updateName0(); + + //todo review it: should thread locals be inherited accorss isolates? Probably not... + ThreadLocal.ThreadLocalMap parentLocals = currentThread().inheritableThreadLocals; + if (parentLocals != null) + this.inheritableThreadLocals = ThreadLocal.createInheritedMap(parentLocals); + } + + private native Object createVmThread1(Object isolatedStatics); + + /** + * Create a new thread from a given VmThread. Only used for the main thread. + * + * @param vmThread + * @throws IllegalArgumentException + * If the given vmThread is not the root thread or the given + * vmThread already has an associated java thread. + */ + public Thread(Object vmThread) throws IllegalArgumentException { + checkArg0(vmThread); + this.vmThread = vmThread; + this.group = ROOT_GROUP; + this.group.addUnstarted(); + this.name = autoName("System"); + this.runnable = null; + this.parent = null; + updateName0(); + } + + private static native void checkArg0(Object vmThread); + + private native void updateName0(); + /** + * Get the number of active threads in the current Thread's ThreadGroup. + * This implementation calls + * <code>currentThread().getThreadGroup().activeCount()</code>. + * + * @return the number of active threads in the current ThreadGroup + * @see ThreadGroup#activeCount() + */ + public static int activeCount() + { + return currentThread().getThreadGroup().activeCount(); + } + + /** + * Check whether the current Thread is allowed to modify this Thread. This + * passes the check on to <code>SecurityManager.checkAccess(this)</code>. + * + * @throws SecurityException if the current Thread cannot modify this Thread + * @see SecurityManager#checkAccess(Thread) + */ + public final void checkAccess() + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkAccess(this); + } + } + + /** + * Count the number of stack frames in this Thread. The Thread in question + * must be suspended when this occurs. + * + * @return the number of stack frames in this Thread + * @throws IllegalThreadStateException if this Thread is not suspended + * @deprecated pointless, since suspend is deprecated + */ + public native int countStackFrames(); + + /** + * Get the currently executing Thread. In the situation that the + * currently running thread was created by native code and doesn't + * have an associated Thread object yet, a new Thread object is + * constructed and associated with the native thread. + * + * @return the currently executing Thread + */ + public static native Thread currentThread(); + + /** + * Originally intended to destroy this thread, this method was never + * implemented by Sun, and is hence a no-op. + * + * @deprecated This method was originally intended to simply destroy + * the thread without performing any form of cleanup operation. + * However, it was never implemented. It is now deprecated + * for the same reason as <code>suspend()</code>, + * <code>stop()</code> and <code>resume()</code>; namely, + * it is prone to deadlocks. If a thread is destroyed while + * it still maintains a lock on a resource, then this resource + * will remain locked and any attempts by other threads to + * access the resource will result in a deadlock. Thus, even + * an implemented version of this method would be still be + * deprecated, due to its unsafe nature. + * @throws NoSuchMethodError as this method was never implemented. + */ + public native void destroy(); + + /** + * Print a stack trace of the current thread to stderr using the same + * format as Throwable's printStackTrace() method. + * + * @see Throwable#printStackTrace() + */ + public static void dumpStack() + { + new Throwable().printStackTrace(); + } + + /** + * Copy every active thread in the current Thread's ThreadGroup into the + * array. Extra threads are silently ignored. This implementation calls + * <code>getThreadGroup().enumerate(array)</code>, which may have a + * security check, <code>checkAccess(group)</code>. + * + * @param array the array to place the Threads into + * @return the number of Threads placed into the array + * @throws NullPointerException if array is null + * @throws SecurityException if you cannot access the ThreadGroup + * @see ThreadGroup#enumerate(Thread[]) + * @see #activeCount() + * @see SecurityManager#checkAccess(ThreadGroup) + */ + public static int enumerate(Thread[] array) + { + return currentThread().group.enumerate(array); + } + + /** + * Get this Thread's name. + * + * @return this Thread's name + */ + public final String getName() + { + return name; + } + + /** + * Get this Thread's priority. + * + * @return the Thread's priority + */ + public native final int getPriority(); + + /** + * Get the ThreadGroup this Thread belongs to. If the thread has died, this + * returns null. + * + * @return this Thread's ThreadGroup + */ + public final ThreadGroup getThreadGroup() + { + return isAlive() ? group : null; + } + + /** + * Checks whether the current thread holds the monitor on a given object. + * This allows you to do <code>assert Thread.holdsLock(obj)</code>. + * + * @param obj the object to test lock ownership on. + * @return true if the current thread is currently synchronized on obj + * @throws NullPointerException if obj is null + * @since 1.4 + */ + public static native boolean holdsLock(Object obj); + + /** + * Interrupt this Thread. First, there is a security check, + * <code>checkAccess</code>. Then, depending on the current state of the + * thread, various actions take place: + * + * <p>If the thread is waiting because of {@link #wait()}, + * {@link #sleep(long)}, or {@link #join()}, its <i>interrupt status</i> + * will be cleared, and an InterruptedException will be thrown. Notice that + * this case is only possible if an external thread called interrupt(). + * + * <p>If the thread is blocked in an interruptible I/O operation, in + * {@link java.nio.channels.InterruptibleChannel}, the <i>interrupt + * status</i> will be set, and ClosedByInterruptException will be thrown. + * + * <p>If the thread is blocked on a {@link java.nio.channels.Selector}, the + * <i>interrupt status</i> will be set, and the selection will return, with + * a possible non-zero value, as though by the wakeup() method. + * + * <p>Otherwise, the interrupt status will be set. + * + * @throws SecurityException if you cannot modify this Thread + */ + public native void interrupt(); + + /** + * Determine whether the current Thread has been interrupted, and clear + * the <i>interrupted status</i> in the process. + * + * @return whether the current Thread has been interrupted + * @see #isInterrupted() + */ + public static native boolean interrupted(); + + /** + * Determine whether the given Thread has been interrupted, but leave + * the <i>interrupted status</i> alone in the process. + * + * @return whether the Thread has been interrupted + * @see #interrupted() + */ + public native boolean isInterrupted(); + + /** + * Determine whether this Thread is alive. A thread which is alive has + * started and not yet died. + * + * @return whether this Thread is alive + */ + public native final boolean isAlive(); + + /** + * Tell whether this is a daemon Thread or not. + * + * @return whether this is a daemon Thread or not + * @see #setDaemon(boolean) + */ + public final boolean isDaemon() + { + return daemon; + } + + /** + * Wait forever for the Thread in question to die. + * + * @throws InterruptedException if the Thread is interrupted; it's + * <i>interrupted status</i> will be cleared + */ + public final synchronized void join() throws InterruptedException { + // Test interrupted status + if (isInterupted0()) { + throw new InterruptedExce... [truncated message content] |
From: <ls...@us...> - 2009-04-05 10:52:43
|
Revision: 5215 http://jnode.svn.sourceforge.net/jnode/?rev=5215&view=rev Author: lsantha Date: 2009-04-05 10:52:24 +0000 (Sun, 05 Apr 2009) Log Message: ----------- Progress with fs tests: migrating to junit-4.5 - by Stefan Anzinger Modified Paths: -------------- trunk/all/build.xml trunk/all/conf/tests-plugin-list.xml trunk/core/.classpath trunk/core/build.xml trunk/core/core.iml trunk/core/src/test/org/jnode/test/framework/TestManager.java trunk/distr/.classpath trunk/distr/build.xml trunk/fs/.classpath trunk/fs/descriptors/org.jnode.test.fs.xml trunk/fs/fs.iml trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/BasicFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/FileFSTest.java trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/TreeFSTest.java Removed Paths: ------------- trunk/core/descriptors/jcfe.xml trunk/core/descriptors/jfunc.xml trunk/core/lib/jcfe.jar trunk/core/lib/jfunc.jar trunk/core/lib/junit.jar Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/all/build.xml 2009-04-05 10:52:24 UTC (rev 5215) @@ -50,7 +50,7 @@ <property name="commons-net.jar" value="${root.dir}/core/lib/commons-net-1.1.0.jar"/> <property name="dnsjava.jar" value="${root.dir}/net/lib/dnsjava-1.6.6.jar"/> <property name="jsch.jar" value="${root.dir}/net/lib/jsch-0.1.24.jar"/> - <property name="junit.jar" value="${root.dir}/core/lib/junit.jar"/> + <property name="junit.jar" value="${root.dir}/core/lib/junit-4.5.jar"/> <property name="mmtk.jar" value="${root.dir}/core/lib/mmtk/mmtk.jar"/> <property name="mauve.jar" value="${root.dir}/core/lib/mauve.jar"/> <property name="edtftpj.jar" value="${root.dir}/fs/lib/edtftpj-1.5.2.jar"/> @@ -79,9 +79,6 @@ <property name="asm.jar" value="${root.dir}/core/lib/asm-1.5.3.jar"/> <property name="asm-attrs.jar" value="${root.dir}/core/lib/asm-attrs-1.5.3.jar"/> <property name="asm-util.jar" value="${root.dir}/core/lib/asm-util-1.5.3.jar"/> - <property name="jcfe.jar" value="${root.dir}/core/lib/jcfe.jar"/> - <property name="jfunc.jar" value="${root.dir}/core/lib/jfunc.jar"/> - <property name="junit4.jar" value="${root.dir}/distr/lib/junit-4.1.jar"/> <property name="log4j.jar" value="${root.dir}/core/lib/log4j-1.2.8.jar"/> <property name="beanshell.jar" value="${root.dir}/shell/lib/bsh-2.0b5.jar"/> @@ -121,8 +118,6 @@ <pathelement location="${basedir}/conf"/> <pathelement location="${beanshell.jar}"/> <pathelement location="${js.jar}"/> - <pathelement location="${jcfe.jar}"/> - <pathelement location="${jfunc.jar}"/> <pathelement location="${oncrpc.jar}"/> <pathelement location="${edtftpj.jar}"/> <pathelement location="${jcifs.jar}"/> @@ -249,8 +244,6 @@ <libalias name="asm-util.jar" alias="${asm-util.jar}"/> <libalias name="cglib.jar" alias="${cglib.jar}"/> <libalias name="mauve.jar" alias="${mauve.jar}"/> - <libalias name="jcfe.jar" alias="${jcfe.jar}"/> - <libalias name="jfunc.jar" alias="${jfunc.jar}"/> <libalias name="ant.jar" alias="${ant.jar}"/> <libalias name="ant-launcher.jar" alias="${ant-launcher.jar}"/> Modified: trunk/all/conf/tests-plugin-list.xml =================================================================== --- trunk/all/conf/tests-plugin-list.xml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/all/conf/tests-plugin-list.xml 2009-04-05 10:52:24 UTC (rev 5215) @@ -23,10 +23,6 @@ <plugin id="org.jnode.test.net"/> <plugin id="org.jnode.test.shell"/> <plugin id="org.jnode.shell.command.test"/> - - <!-- JUnit extensions --> - <plugin id="jcfe"/> <!-- not a JUnit extension, but needed by jfunc --> - <plugin id="jfunc"/> <plugin id="org.jnode.testrunner"/> </plugin-list> \ No newline at end of file Modified: trunk/core/.classpath =================================================================== --- trunk/core/.classpath 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/core/.classpath 2009-04-05 10:52:24 UTC (rev 5215) @@ -30,6 +30,5 @@ <classpathentry exported="true" kind="lib" path="lib/asm-attrs-1.5.3.jar"/> <classpathentry exported="true" kind="lib" path="lib/asm-util-1.5.3.jar"/> <classpathentry kind="lib" path="lib/mauve.jar" sourcepath="lib/mauve-src.jar"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/core/build.xml =================================================================== --- trunk/core/build.xml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/core/build.xml 2009-04-05 10:52:24 UTC (rev 5215) @@ -13,7 +13,7 @@ <!-- Subproject specific classpath --> <path id="my-cp"> <path refid="cp"/> - <pathelement location="${junit4.jar}"/> + <pathelement location="${junit.jar}"/> <pathelement location="${mmtk.jar}"/> <pathelement location="${mauve.jar}"/> </path> Modified: trunk/core/core.iml =================================================================== --- trunk/core/core.iml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/core/core.iml 2009-04-05 10:52:24 UTC (rev 5215) @@ -75,7 +75,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/junit-4.5.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/jmock-1.0.1.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -84,7 +84,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/jcfe.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/jmock-cglib-1.0.1.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -93,7 +93,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/jfunc.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/cglib-2.1.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -102,30 +102,12 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/lib/jmock-1.0.1.jar!/" /> + <root url="jar://$MODULE_DIR$/lib/junit-4.5.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> - <orderEntry type="module-library"> - <library> - <CLASSES> - <root url="jar://$MODULE_DIR$/lib/jmock-cglib-1.0.1.jar!/" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - </library> - </orderEntry> - <orderEntry type="module-library"> - <library> - <CLASSES> - <root url="jar://$MODULE_DIR$/lib/cglib-2.1.jar!/" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - </library> - </orderEntry> </component> </module> Deleted: trunk/core/descriptors/jcfe.xml =================================================================== --- trunk/core/descriptors/jcfe.xml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/core/descriptors/jcfe.xml 2009-04-05 10:52:24 UTC (rev 5215) @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plugin SYSTEM "jnode.dtd"> - -<plugin id="jcfe" - name="jcfe classes" - version="1" - provider-name="jcfe" - provider-url="http://www.gnufoo.org/jcfe/" - license-name="cpl"> - - <runtime> - <library name="jcfe.jar"> - <export name="*"/> - </library> - </runtime> -</plugin> \ No newline at end of file Deleted: trunk/core/descriptors/jfunc.xml =================================================================== --- trunk/core/descriptors/jfunc.xml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/core/descriptors/jfunc.xml 2009-04-05 10:52:24 UTC (rev 5215) @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plugin SYSTEM "jnode.dtd"> - -<plugin id="jfunc" - name="JFunc classes" - version="1.1" - provider-name="JFunc" - provider-url="http://jfunc.sourceforge.net/" - license-name="cpl"> - - <requires> - <import plugin="org.junit" version="3.8"/> - <import plugin="jcfe" version="1"/> - </requires> - - <runtime> - <library name="jfunc.jar"> - <export name="*"/> - </library> - </runtime> - - <extension point="org.jnode.security.permissions"> - <permission class="java.util.PropertyPermission" name="user.home" actions="read"/> - - <permission class="java.io.FilePermission" name="/jnode/home/junit.properties" actions="read"/> - <permission class="java.lang.RuntimePermission" name="exitVM" actions="*" /> - </extension> -</plugin> \ No newline at end of file Deleted: trunk/core/lib/jcfe.jar =================================================================== (Binary files differ) Deleted: trunk/core/lib/jfunc.jar =================================================================== (Binary files differ) Deleted: trunk/core/lib/junit.jar =================================================================== (Binary files differ) Modified: trunk/core/src/test/org/jnode/test/framework/TestManager.java =================================================================== --- trunk/core/src/test/org/jnode/test/framework/TestManager.java 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/core/src/test/org/jnode/test/framework/TestManager.java 2009-04-05 10:52:24 UTC (rev 5215) @@ -29,6 +29,8 @@ import java.util.Set; import java.util.StringTokenizer; import java.util.TreeSet; + +import junit.framework.JUnit4TestAdapter; import junit.framework.Test; import junit.framework.TestSuite; import org.apache.log4j.Logger; @@ -158,7 +160,7 @@ for (Class<? extends TestSuite> suiteClass : suites) { if (!matchCategory(wantedCategories, categories.get(suiteClass))) continue; - suite.addTestSuite(suiteClass); + suite.addTest(new JUnit4TestAdapter(suiteClass)); log.debug("added TestSuite " + suiteClass.getName()); } Modified: trunk/distr/.classpath =================================================================== --- trunk/distr/.classpath 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/distr/.classpath 2009-04-05 10:52:24 UTC (rev 5215) @@ -16,10 +16,10 @@ <classpathentry kind="src" path="/textui"/> <classpathentry combineaccessrules="false" kind="src" path="/fs"/> <classpathentry kind="lib" path="/shell/lib/bsh-2.0b5.jar"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="lib" path="lib/commons-logging.jar"/> <classpathentry kind="lib" path="lib/derby.jar"/> <classpathentry kind="lib" path="lib/derbynet.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> + <classpathentry kind="lib" path="/core/lib/junit.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/distr/build.xml =================================================================== --- trunk/distr/build.xml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/distr/build.xml 2009-04-05 10:52:24 UTC (rev 5215) @@ -15,7 +15,7 @@ <pathelement location="${jnode-shell.jar}"/> <pathelement location="${jnode-fs.jar}"/> - <pathelement location="${junit4.jar}"/> + <pathelement location="${junit.jar}"/> <pathelement location="${telnetd.jar}"/> <pathelement location="${jetty.jar}"/> Modified: trunk/fs/.classpath =================================================================== --- trunk/fs/.classpath 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/.classpath 2009-04-05 10:52:24 UTC (rev 5215) @@ -12,8 +12,6 @@ <classpathentry kind="lib" path="/core/lib/ant.jar"/> <classpathentry kind="lib" path="/core/lib/cglib-2.1.jar"/> <classpathentry kind="lib" path="/core/lib/commons-net-1.1.0.jar"/> - <classpathentry kind="lib" path="/core/lib/jcfe.jar"/> - <classpathentry kind="lib" path="/core/lib/jfunc.jar"/> <classpathentry kind="lib" path="/core/lib/jmock-1.0.1.jar"/> <classpathentry kind="lib" path="/core/lib/jmock-cglib-1.0.1.jar"/> <classpathentry kind="lib" path="/core/lib/junit.jar"/> Modified: trunk/fs/descriptors/org.jnode.test.fs.xml =================================================================== --- trunk/fs/descriptors/org.jnode.test.fs.xml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/descriptors/org.jnode.test.fs.xml 2009-04-05 10:52:24 UTC (rev 5215) @@ -25,8 +25,6 @@ <import plugin="net.sf.cglib" version="2.1"/> <import plugin="org.jmock" version="1.0.1"/> <import plugin="org.jmock.cglib" version="1.0.1"/> - <import plugin="jcfe" version="1"/> - <import plugin="jfunc" version="1.1"/> <import plugin="org.jnode.driver.block"/> <import plugin="org.jnode.driver.block.ramdisk"/> Modified: trunk/fs/fs.iml =================================================================== --- trunk/fs/fs.iml 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/fs.iml 2009-04-05 10:52:24 UTC (rev 5215) @@ -48,21 +48,12 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/../core/lib/junit.jar!/" /> + <root url="jar://$MODULE_DIR$/../core/lib/junit-4.5.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> </library> </orderEntry> - <orderEntry type="module-library"> - <library> - <CLASSES> - <root url="jar://$MODULE_DIR$/../core/lib/jfunc.jar!/" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - </library> - </orderEntry> </component> </module> Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/AbstractFSTest.java 2009-04-05 10:52:24 UTC (rev 5215) @@ -33,19 +33,36 @@ import org.apache.log4j.Logger; import org.jnode.driver.Device; +import org.jnode.emu.naming.BasicNameSpace; +import org.jnode.emu.plugin.model.DummyConfigurationElement; +import org.jnode.emu.plugin.model.DummyExtension; +import org.jnode.emu.plugin.model.DummyExtensionPoint; +import org.jnode.emu.plugin.model.DummyPluginDescriptor; import org.jnode.fs.FSDirectory; import org.jnode.fs.FSEntry; import org.jnode.fs.FSFile; import org.jnode.fs.FileSystem; import org.jnode.fs.FileSystemException; +import org.jnode.fs.service.FileSystemService; +import org.jnode.fs.service.def.FileSystemPlugin; +import org.jnode.naming.InitialNaming; import org.jnode.test.fs.filesystem.config.FSTestConfig; +import org.jnode.test.fs.filesystem.config.FSType; import org.jnode.test.support.TestUtils; +import org.jnode.util.OsUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; /** * @author Fabien DUMINY */ +@RunWith(Parameterized.class) public abstract class AbstractFSTest extends TestCase { protected final Logger log = Logger.getLogger(getClass()); + private static boolean setup = false; //public static final int FILE_SIZE_IN_WORDS = 256 * 1024; // 512 Ko = 256 K Words public static final int FILE_SIZE_IN_WORDS = 128; // 512 Ko = 128 K Words @@ -59,6 +76,15 @@ this.config = config; } + @Parameters + public static List<FSTestConfig[]> getData() { + List<FSTestConfig[]> config = new ArrayList<FSTestConfig[]>(); + for (FSTestConfig cfg : new FSConfigurations()) { + config.add(new FSTestConfig[] {cfg}); + } + return config; + } + /** * */ @@ -66,14 +92,38 @@ super(name); } + @Before public final void setUp() throws NameNotFoundException, FileSystemException, IOException, InstantiationException, IllegalAccessException, Exception { super.setUp(); + if (!setup && !OsUtils.isJNode()) { + // We are not running in JNode, emulate a JNode environment. + + InitialNaming.setNameSpace(new BasicNameSpace()); + + // Build a plugin descriptor that is sufficient for the FileSystemPlugin to + // configure file system types for testing. + DummyPluginDescriptor desc = new DummyPluginDescriptor(true); + DummyExtensionPoint ep = new DummyExtensionPoint("types", "org.jnode.fs.types", "types"); + desc.addExtensionPoint(ep); + for (FSType fsType : FSType.values()) { + DummyExtension extension = new DummyExtension(); + DummyConfigurationElement element = new DummyConfigurationElement(); + element.addAttribute("class", fsType.getFsTypeClass().getName()); + extension.addElement(element); + ep.addExtension(extension); + } + + FileSystemService fss = new FileSystemPlugin(desc); + InitialNaming.bind(FileSystemService.class, fss); + } + setup = true; this.device = config.getDeviceParam().createDevice(); this.fs = config.getFileSystem().format(this.device); this.fs = config.getFileSystem().mount(this.device); } + @After public final void tearDown() throws Exception { // Some tests don't call setup(config), which means that config will be null when teardown is called. if (config != null) { Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/FSTestSuite.java 2009-04-05 10:52:24 UTC (rev 5215) @@ -20,28 +20,13 @@ package org.jnode.test.fs.filesystem; -import javax.naming.NamingException; - -import junit.extensions.jfunc.JFuncSuite; -import junit.extensions.jfunc.textui.JFuncRunner; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.jnode.emu.naming.BasicNameSpace; -import org.jnode.emu.plugin.model.DummyConfigurationElement; -import org.jnode.emu.plugin.model.DummyExtension; -import org.jnode.emu.plugin.model.DummyExtensionPoint; -import org.jnode.emu.plugin.model.DummyPluginDescriptor; -import org.jnode.fs.service.FileSystemService; -import org.jnode.fs.service.def.FileSystemPlugin; -import org.jnode.naming.InitialNaming; -import org.jnode.test.fs.filesystem.config.FSTestConfig; -import org.jnode.test.fs.filesystem.config.FSType; import org.jnode.test.fs.filesystem.tests.BasicFSTest; import org.jnode.test.fs.filesystem.tests.ConcurrentAccessFSTest; import org.jnode.test.fs.filesystem.tests.FileFSTest; import org.jnode.test.fs.filesystem.tests.TreeFSTest; -import org.jnode.util.OsUtils; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; /** * This class runs a suite of functional tests on the JNode file system @@ -52,75 +37,15 @@ * @author Fabien DUMINY * @author cr...@jn... */ -public class FSTestSuite extends JFuncSuite { - private static boolean setup = false; - public static void main(String[] args) throws Throwable { - setUp(); - - JFuncRunner.run(FSTestSuite.suite()); - //JFuncRunner.main(new String[]{"-v", "--color", FSTestSuite.class.getName()}); - //JFuncRunner.main(new String[]{"-v", FSTestSuite.class.getName()}); +@RunWith(Suite.class) +@SuiteClasses({ + BasicFSTest.class, + ConcurrentAccessFSTest.class, + FileFSTest.class, + TreeFSTest.class } - - private static void setUp() throws NamingException { - if (!setup && !OsUtils.isJNode()) { - // We are not running in JNode, emulate a JNode environment. - - InitialNaming.setNameSpace(new BasicNameSpace()); - - // Build a plugin descriptor that is sufficient for the FileSystemPlugin to - // configure file system types for testing. - DummyPluginDescriptor desc = new DummyPluginDescriptor(true); - DummyExtensionPoint ep = new DummyExtensionPoint("types", "org.jnode.fs.types", "types"); - desc.addExtensionPoint(ep); - for (FSType fsType : FSType.values()) { - DummyExtension extension = new DummyExtension(); - DummyConfigurationElement element = new DummyConfigurationElement(); - element.addAttribute("class", fsType.getFsTypeClass().getName()); - extension.addElement(element); - ep.addExtension(extension); - } - - FileSystemService fss = new FileSystemPlugin(desc); - InitialNaming.bind(FileSystemService.class, fss); - } - setup = true; - } - - public static TestSuite suite() throws Throwable { - setUp(); - TestSuite allTestsSuite = new TestSuite("All FS Tests"); - - for (FSTestConfig config : new FSConfigurations()) { - TestSuite tests = new TestSuite(); - tests.setName(config.getFileSystem().toString()); - addTest(tests, new BasicFSTest(config), "testAddDirectory"); - addTest(tests, new BasicFSTest(config), "testAddFile"); - addTest(tests, new BasicFSTest(config), "testAddFileThenRemountFSAndGetFile"); - addTest(tests, new BasicFSTest(config), "testGetRootEntry"); - addTest(tests, new BasicFSTest(config), "testListRootEntries"); - addTest(tests, new BasicFSTest(config), "testRemoveThenRemountFSAndGetEntry"); - - addTest(tests, new FileFSTest(config), "testSetLength"); - addTest(tests, new FileFSTest(config), "testWriteFileInReadOnlyMode"); - addTest(tests, new FileFSTest(config), "testWriteFileThenRemountFSAndRead"); - - addTest(tests, new TreeFSTest(config), "testFSTree"); - addTest(tests, new TreeFSTest(config), "testFSTreeWithRemountAndLongName"); - addTest(tests, new TreeFSTest(config), "testFSTreeWithRemountAndShortName"); - - addTest(tests, new ConcurrentAccessFSTest(config), "testRead"); - addTest(tests, new ConcurrentAccessFSTest(config), "testWrite"); - addTest(tests, new ConcurrentAccessFSTest(config), "testReadWrite"); - - allTestsSuite.addTest(tests); - } - - return allTestsSuite; - } +) +public class FSTestSuite { - private static void addTest(TestSuite suite, TestCase test, String name) { - test.setName(name); - suite.addTest(test); - } -} +} + Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/BasicFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/BasicFSTest.java 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/BasicFSTest.java 2009-04-05 10:52:24 UTC (rev 5215) @@ -29,6 +29,7 @@ import org.jnode.test.fs.filesystem.AbstractFSTest; import org.jnode.test.fs.filesystem.config.FSTestConfig; import org.jnode.test.support.TestUtils; +import org.junit.Test; /** * @author Fabien DUMINY @@ -37,17 +38,15 @@ public BasicFSTest(FSTestConfig config) { super(config); } - - public BasicFSTest(String name) { - super(name); - } + @Test public void testGetRootEntry() throws Exception { setUp(); FSEntry rootEntry = getFs().getRootEntry(); log.debug(FSUtils.toString(rootEntry, false)); } + @Test public void testListRootEntries() throws Exception { setUp(); @@ -55,6 +54,7 @@ TestUtils.listEntries(iterator); } + @Test public void testAddDirectory() throws Exception { setUp(); @@ -89,6 +89,7 @@ TestUtils.listEntries(rootDir.iterator()); } + @Test public void testAddFile() throws Exception { setUp(); @@ -124,6 +125,7 @@ TestUtils.listEntries(rootDir.iterator()); } + @Test public void testAddFileThenRemountFSAndGetFile() throws Exception { if (!config.isReadOnly()) { setUp(); @@ -149,6 +151,7 @@ } } + @Test public void testRemoveThenRemountFSAndGetEntry() throws Exception { if (!config.isReadOnly()) { Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/ConcurrentAccessFSTest.java 2009-04-05 10:52:24 UTC (rev 5215) @@ -28,6 +28,7 @@ import org.jnode.test.fs.filesystem.AbstractFSTest; import org.jnode.test.fs.filesystem.config.FSTestConfig; import org.jnode.test.support.TestUtils; +import org.junit.Test; /** * @author Fabien DUMINY @@ -45,10 +46,7 @@ super(config); } - public ConcurrentAccessFSTest(String name) { - super(name); - } - + @Test public void testRead() throws Throwable { setUp(); @@ -61,6 +59,7 @@ monitor.waitAll(); } + @Test public void testWrite() throws Throwable { if (!config.isReadOnly()) { setUp(); @@ -73,6 +72,7 @@ } } + @Test public void testReadWrite() throws Throwable { setUp(); Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/FileFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/FileFSTest.java 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/FileFSTest.java 2009-04-05 10:52:24 UTC (rev 5215) @@ -28,6 +28,7 @@ import org.jnode.test.fs.filesystem.AbstractFSTest; import org.jnode.test.fs.filesystem.config.FSTestConfig; import org.jnode.test.support.TestUtils; +import org.junit.Test; /** * @author Fabien DUMINY @@ -37,10 +38,7 @@ super(config); } - public FileFSTest(String name) { - super(name); - } - + @Test public void testWriteFileThenRemountFSAndRead() throws Exception { setUp(); @@ -82,6 +80,7 @@ } } + @Test public void testWriteFileInReadOnlyMode() throws Exception { if (config.isReadOnly()) { setUp(); @@ -104,6 +103,7 @@ } } + @Test public void testSetLength() throws Exception { setUp(); Modified: trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/TreeFSTest.java =================================================================== --- trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/TreeFSTest.java 2009-04-05 05:50:44 UTC (rev 5214) +++ trunk/fs/src/test/org/jnode/test/fs/filesystem/tests/TreeFSTest.java 2009-04-05 10:52:24 UTC (rev 5215) @@ -26,6 +26,7 @@ import org.jnode.fs.util.FSUtils; import org.jnode.test.fs.filesystem.AbstractFSTest; import org.jnode.test.fs.filesystem.config.FSTestConfig; +import org.junit.Test; /** * @author Fabien DUMINY @@ -35,10 +36,7 @@ super(config); } - public TreeFSTest(String name) { - super(name); - } - + @Test public void testFSTree() throws IOException, Exception { if (!config.isReadOnly()) { setUp(); @@ -62,10 +60,12 @@ } } + @Test public void testFSTreeWithRemountAndShortName() throws Exception { doTestFSTreeWithRemount(config, "dir1"); } + @Test public void testFSTreeWithRemountAndLongName() throws Exception { doTestFSTreeWithRemount(config, "This is a Long FileName.extension"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-04-05 14:25:57
|
Revision: 5216 http://jnode.svn.sourceforge.net/jnode/?rev=5216&view=rev Author: fduminy Date: 2009-04-05 14:25:46 +0000 (Sun, 05 Apr 2009) Log Message: ----------- fixes for eclipse's classpath issues : - patch from Stefan Anzinger regarding upgrade to junit 4.5 - fix to exclude junit & nanoxml classes that are included in mauve.jar - fix to add ant-contrib to classpath Modified Paths: -------------- trunk/core/.classpath trunk/distr/.classpath trunk/fs/.classpath trunk/net/.classpath trunk/shell/.classpath Modified: trunk/core/.classpath =================================================================== --- trunk/core/.classpath 2009-04-05 10:52:24 UTC (rev 5215) +++ trunk/core/.classpath 2009-04-05 14:25:46 UTC (rev 5216) @@ -24,11 +24,17 @@ <classpathentry excluding="**/.svn/**" kind="src" path="src/template"/> <classpathentry kind="lib" path="lib/ant.jar"/> <classpathentry kind="lib" path="lib/log4j-1.2.8.jar"/> - <classpathentry kind="lib" path="lib/junit.jar"/> - <classpathentry kind="lib" path="lib/mmtk/mmtk.jar" sourcepath="D:/epr/cvswork/MMTk/src"/> + <classpathentry kind="lib" path="lib/junit-4.5.jar"/> + <classpathentry kind="lib" path="lib/mmtk/mmtk.jar"/> <classpathentry exported="true" kind="lib" path="lib/asm-1.5.3.jar"/> <classpathentry exported="true" kind="lib" path="lib/asm-attrs-1.5.3.jar"/> <classpathentry exported="true" kind="lib" path="lib/asm-util-1.5.3.jar"/> - <classpathentry kind="lib" path="lib/mauve.jar" sourcepath="lib/mauve-src.jar"/> + <classpathentry kind="lib" path="lib/mauve.jar" sourcepath="lib/mauve-src.jar"> + <accessrules> + <accessrule kind="nonaccessible" pattern="junit.framework/**"/> + <accessrule kind="nonaccessible" pattern="netsourceforge.nanoxml/**"/> + </accessrules> + </classpathentry> + <classpathentry kind="lib" path="lib/ant-contrib-1.0b3.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/distr/.classpath =================================================================== --- trunk/distr/.classpath 2009-04-05 10:52:24 UTC (rev 5215) +++ trunk/distr/.classpath 2009-04-05 14:25:46 UTC (rev 5216) @@ -20,6 +20,6 @@ <classpathentry kind="lib" path="lib/derby.jar"/> <classpathentry kind="lib" path="lib/derbynet.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> - <classpathentry kind="lib" path="/core/lib/junit.jar"/> + <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/fs/.classpath =================================================================== --- trunk/fs/.classpath 2009-04-05 10:52:24 UTC (rev 5215) +++ trunk/fs/.classpath 2009-04-05 14:25:46 UTC (rev 5216) @@ -14,7 +14,7 @@ <classpathentry kind="lib" path="/core/lib/commons-net-1.1.0.jar"/> <classpathentry kind="lib" path="/core/lib/jmock-1.0.1.jar"/> <classpathentry kind="lib" path="/core/lib/jmock-cglib-1.0.1.jar"/> - <classpathentry kind="lib" path="/core/lib/junit.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> + <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/net/.classpath =================================================================== --- trunk/net/.classpath 2009-04-05 10:52:24 UTC (rev 5215) +++ trunk/net/.classpath 2009-04-05 14:25:46 UTC (rev 5216) @@ -9,7 +9,7 @@ <classpathentry kind="lib" path="lib/jsch-0.1.24.jar"/> <classpathentry kind="lib" path="lib/dnsjava-1.6.6.jar" sourcepath="lib/dnsjava-1.6.6-src.zip"/> <classpathentry kind="lib" path="/core/lib/commons-net-1.1.0.jar"/> - <classpathentry kind="lib" path="/core/lib/junit.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> + <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/shell/.classpath =================================================================== --- trunk/shell/.classpath 2009-04-05 10:52:24 UTC (rev 5215) +++ trunk/shell/.classpath 2009-04-05 14:25:46 UTC (rev 5216) @@ -8,8 +8,8 @@ <classpathentry kind="lib" path="lib/rhino1.6r5-jsr223.jar"/> <classpathentry kind="lib" path="/core/lib/ant-launcher.jar"/> <classpathentry kind="lib" path="/core/lib/ant.jar"/> - <classpathentry kind="lib" path="/core/lib/junit.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="lib" path="lib/nanoxml-2.2.3.jar"/> + <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-04-05 15:19:35
|
Revision: 5220 http://jnode.svn.sourceforge.net/jnode/?rev=5220&view=rev Author: fduminy Date: 2009-04-05 15:19:33 +0000 (Sun, 05 Apr 2009) Log Message: ----------- removed hard dependency on junit 3.8 (depends on latest junit instead) Modified Paths: -------------- trunk/core/descriptors/org.jmock.xml trunk/core/descriptors/org.jnode.test.xml trunk/core/descriptors/org.jnode.testrunner.xml trunk/shell/descriptors/org.jnode.shell.command.test.xml trunk/shell/descriptors/org.jnode.test.shell.xml Modified: trunk/core/descriptors/org.jmock.xml =================================================================== --- trunk/core/descriptors/org.jmock.xml 2009-04-05 15:17:33 UTC (rev 5219) +++ trunk/core/descriptors/org.jmock.xml 2009-04-05 15:19:33 UTC (rev 5220) @@ -10,7 +10,7 @@ license-url="http://jmock.org/license.html"> <requires> - <import plugin="org.junit" version="3.8"/> + <import plugin="org.junit"/> </requires> <runtime> Modified: trunk/core/descriptors/org.jnode.test.xml =================================================================== --- trunk/core/descriptors/org.jnode.test.xml 2009-04-05 15:17:33 UTC (rev 5219) +++ trunk/core/descriptors/org.jnode.test.xml 2009-04-05 15:19:33 UTC (rev 5220) @@ -8,7 +8,7 @@ provider-name="JNode.org"> <requires> - <import plugin="org.junit" version="3.8"/> + <import plugin="org.junit"/> </requires> <runtime> @@ -35,7 +35,8 @@ <!-- TestSecurityManager --> <permission class="java.lang.RuntimePermission" name="createSecurityManager"/> - <permission class="java.lang.RuntimePermission" name="setSecurityManager"/> + <permission class="java.lang.RuntimePermission" name="setSecurityManager"/> + <permission class="java.lang.RuntimePermission" name="accessDeclaredMembers"/> </extension> </plugin> Modified: trunk/core/descriptors/org.jnode.testrunner.xml =================================================================== --- trunk/core/descriptors/org.jnode.testrunner.xml 2009-04-05 15:17:33 UTC (rev 5219) +++ trunk/core/descriptors/org.jnode.testrunner.xml 2009-04-05 15:19:33 UTC (rev 5220) @@ -11,7 +11,7 @@ priority="1"> <requires> - <import plugin="org.junit" version="3.8"/> + <import plugin="org.junit"/> </requires> <runtime> Modified: trunk/shell/descriptors/org.jnode.shell.command.test.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.command.test.xml 2009-04-05 15:17:33 UTC (rev 5219) +++ trunk/shell/descriptors/org.jnode.shell.command.test.xml 2009-04-05 15:19:33 UTC (rev 5220) @@ -9,7 +9,7 @@ <requires> <import plugin="org.jnode.runtime.core"/> - <import plugin="org.junit" version="3.8"/> + <import plugin="org.junit"/> <import plugin="org.jnode.shell.help"/> <import plugin="org.jnode.testrunner"/> </requires> @@ -50,6 +50,7 @@ <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read,write,delete"/> <permission class="java.lang.reflect.ReflectPermission" name="*" actions="suppressAccessChecks"/> + <permission class="java.lang.RuntimePermission" name="*" actions="accessDeclaredMembers"/> </extension> </plugin> Modified: trunk/shell/descriptors/org.jnode.test.shell.xml =================================================================== --- trunk/shell/descriptors/org.jnode.test.shell.xml 2009-04-05 15:17:33 UTC (rev 5219) +++ trunk/shell/descriptors/org.jnode.test.shell.xml 2009-04-05 15:19:33 UTC (rev 5220) @@ -12,7 +12,7 @@ <import plugin="org.jnode.shell"/> <import plugin="org.jnode.shell.help"/> <import plugin="org.jnode.shell.syntax"/> - <import plugin="org.junit" version="3.8"/> + <import plugin="org.junit"/> <import plugin="net.n3.nanoxml"/> <import plugin="org.jnode.shell.help"/> <import plugin="org.jnode.testrunner"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-04-06 15:03:29
|
Revision: 5227 http://jnode.svn.sourceforge.net/jnode/?rev=5227&view=rev Author: lsantha Date: 2009-04-06 15:03:21 +0000 (Mon, 06 Apr 2009) Log Message: ----------- Separating jnode specific code from classlib. Modified Paths: -------------- trunk/all/conf/openjdk-annotations.properties trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java trunk/core/build.xml trunk/core/core.iml trunk/core/descriptors/org.jnode.vm.core.xml trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java trunk/gui/src/awt/org/jnode/awt/font/renderer/SummedAreaTable.java trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingToolkit.java trunk/gui/src/driver/org/jnode/driver/video/vesa/VesaUtils.java trunk/net/src/net/org/jnode/net/arp/ARPNetworkLayer.java trunk/net/src/net/org/jnode/net/ipv4/util/ResolverImpl.java trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java Modified: trunk/all/conf/openjdk-annotations.properties =================================================================== --- trunk/all/conf/openjdk-annotations.properties 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/all/conf/openjdk-annotations.properties 2009-04-06 15:03:21 UTC (rev 5227) @@ -5,10 +5,12 @@ # package/className.class=<annotations list separated by a ','> # supported annotations : SharedStatics, MagicPermission +gnu/java/awt/ClasspathToolkit=SharedStatics java/awt/EventQueue.class=SharedStatics java/awt/image/DataBuffer.class=SharedStatics java/awt/KeyboardFocusManager.class=SharedStatics java/awt/Toolkit.class=SharedStatics +java/io/VMIOUtils.class=SharedStatics java/lang/Thread.class=SharedStatics java/lang/ThreadLocal.class=SharedStatics java/lang/Throwable.class=MagicPermission @@ -31,5 +33,5 @@ sun/awt/image/SunWritableRaster.class=SharedStatics sun/java2d/Disposer.class=SharedStatics sun/misc/SharedSecrets.class=SharedStatics -sun/misc/Unsafe.class=SharedStatics +sun/misc/Unsafe.class=SharedStatics,MagicPermission sun/misc/VM.class=SharedStatics Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java =================================================================== --- trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -33,8 +33,8 @@ import java.util.List; import java.util.Properties; import org.apache.tools.ant.BuildException; -import org.jnode.vm.annotation.MagicPermission; -import org.jnode.vm.annotation.SharedStatics; +import org.jnode.annotation.MagicPermission; +import org.jnode.annotation.SharedStatics; import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassAdapter; import org.objectweb.asm.ClassReader; Modified: trunk/core/build.xml =================================================================== --- trunk/core/build.xml 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/core/build.xml 2009-04-06 15:03:21 UTC (rev 5227) @@ -23,8 +23,6 @@ <pathelement location="${my-src.dir}/classpath/gnu"/> <pathelement location="${my-src.dir}/classpath/java"/> <pathelement location="${my-src.dir}/classpath/javax"/> - <pathelement location="${my-src.dir}/classpath/ext"/> - <pathelement location="${my-src.dir}/classpath/vm"/> <pathelement location="${my-src.dir}/classpath/tools"/> <pathelement location="${my-src.dir}/openjdk/java"/> <pathelement location="${my-src.dir}/openjdk/javax"/> @@ -32,8 +30,14 @@ <pathelement location="${my-src.dir}/openjdk/com"/> <pathelement location="${my-src.dir}/openjdk/sun"/> <pathelement location="${my-src.dir}/openjdk/svm"/> - <pathelement location="${my-src.dir}/openjdk/vm"/> + <pathelement location="${my-src.dir}/icedtea"/> + <pathelement location="${my-src.dir}/classlib"/> </path> + <path id="classpath-sources-vm"> + <pathelement location="${my-src.dir}/classpath/ext"/> + <pathelement location="${my-src.dir}/classpath/vm"/> + <pathelement location="${my-src.dir}/openjdk/vm"/> + </path> <path id="classpath-sources-corba"> <pathelement location="${my-src.dir}/openjdk/corba"/> </path> @@ -44,13 +48,12 @@ <pathelement location="${my-src.dir}/openjdk/langtools"/> </path> <path id="my-sources1"> - <path refid="classpath-sources"/> + <path refid="classpath-sources-vm"/> <pathelement location="${my-src.dir}/core"/> <pathelement location="${my-src.dir}/endorsed/nanoxml"/> <pathelement location="${my-src.dir}/vmmagic"/> <pathelement location="${my-src.dir}/mmtk-vm"/> <pathelement location="${my-src.dir}/driver"/> - <pathelement location="${my-src.dir}/icedtea"/> <pathelement location="${my-src.dir}/test"/> <pathelement location="${my-src.dir}/emu"/> </path> @@ -143,6 +146,14 @@ <pathelement location="${classpath-sources}" /> <pathelement location="${mx4j.jar}"/> <!-- should be in GNU Classpath since java 5.0 --> </bootclasspath> + <src refid="classpath-sources" /> + <classpath refid="my-cp"/> + </jnode.compile> + <jnode.compile> + <bootclasspath> + <pathelement location="${classpath-sources}" /> + <pathelement location="${mx4j.jar}"/> <!-- should be in GNU Classpath since java 5.0 --> + </bootclasspath> <src refid="my-sources" /> <classpath refid="my-cp"/> </jnode.compile> Modified: trunk/core/core.iml =================================================================== --- trunk/core/core.iml 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/core/core.iml 2009-04-06 15:03:21 UTC (rev 5227) @@ -5,6 +5,7 @@ <exclude-output /> <exclude-exploded /> <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/classlib" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/classpath/ext" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/classpath/gnu" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/classpath/java" isTestSource="false" /> Modified: trunk/core/descriptors/org.jnode.vm.core.xml =================================================================== --- trunk/core/descriptors/org.jnode.vm.core.xml 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/core/descriptors/org.jnode.vm.core.xml 2009-04-06 15:03:21 UTC (rev 5227) @@ -20,7 +20,7 @@ <export name="org.vmmagic.unboxed.*"/> <export name="org.jnode.assembler.*"/> <export name="org.jnode.vm.*"/> - <export name="org.jnode.vm.annotation.*"/> + <export name="org.jnode.annotation.*"/> <export name="org.jnode.vm.bytecode.*"/> <export name="org.jnode.vm.classmgr.*"/> <export name="org.jnode.vm.compiler.*"/> Modified: trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/fs/src/fs/org/jnode/fs/jifs/directories/JIFSDthreads.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -29,7 +29,7 @@ import org.jnode.fs.jifs.JIFSDirectory; import org.jnode.fs.jifs.JIFSFile; import org.jnode.fs.jifs.files.JIFSFthread; -import org.jnode.vm.annotation.DoPrivileged; +import org.jnode.annotation.DoPrivileged; /** Modified: trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -92,7 +92,7 @@ import org.jnode.driver.video.Surface; import org.jnode.driver.video.UnknownConfigurationException; import org.jnode.naming.InitialNaming; -import org.jnode.vm.annotation.SharedStatics; +import org.jnode.annotation.SharedStatics; import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.awt.image.ToolkitImage; Modified: trunk/gui/src/awt/org/jnode/awt/font/renderer/SummedAreaTable.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/font/renderer/SummedAreaTable.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/gui/src/awt/org/jnode/awt/font/renderer/SummedAreaTable.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -22,7 +22,7 @@ import java.util.BitSet; import org.jnode.vm.Vm; -import org.jnode.vm.annotation.Inline; +import org.jnode.annotation.Inline; /** * @author Ewout Prangsma (ep...@us...) Modified: trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingToolkit.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingToolkit.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingToolkit.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -97,7 +97,7 @@ import javax.swing.plaf.metal.OceanTheme; import org.jnode.awt.JNodeAwtContext; import org.jnode.awt.JNodeToolkit; -import org.jnode.vm.annotation.SharedStatics; +import org.jnode.annotation.SharedStatics; import sun.awt.AWTAutoShutdown; import sun.awt.AppContext; import sun.awt.SunToolkit; Modified: trunk/gui/src/driver/org/jnode/driver/video/vesa/VesaUtils.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/video/vesa/VesaUtils.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/gui/src/driver/org/jnode/driver/video/vesa/VesaUtils.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -21,7 +21,7 @@ package org.jnode.driver.video.vesa; import org.vmmagic.unboxed.Address; -import org.jnode.vm.annotation.MagicPermission; +import org.jnode.annotation.MagicPermission; @MagicPermission public class VesaUtils { Modified: trunk/net/src/net/org/jnode/net/arp/ARPNetworkLayer.java =================================================================== --- trunk/net/src/net/org/jnode/net/arp/ARPNetworkLayer.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/net/src/net/org/jnode/net/arp/ARPNetworkLayer.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -40,7 +40,7 @@ import org.jnode.net.ethernet.EthernetConstants; import org.jnode.util.Statistics; import org.jnode.util.TimeoutException; -import org.jnode.vm.annotation.SharedStatics; +import org.jnode.annotation.SharedStatics; /** * @author epr Modified: trunk/net/src/net/org/jnode/net/ipv4/util/ResolverImpl.java =================================================================== --- trunk/net/src/net/org/jnode/net/ipv4/util/ResolverImpl.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/net/src/net/org/jnode/net/ipv4/util/ResolverImpl.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -33,7 +33,7 @@ import org.jnode.net.ProtocolAddress; import org.jnode.net.Resolver; import org.jnode.net.ipv4.IPv4Address; -import org.jnode.vm.annotation.SharedStatics; +import org.jnode.annotation.SharedStatics; import org.xbill.DNS.ExtendedResolver; import org.xbill.DNS.Lookup; import org.xbill.DNS.Record; Modified: trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-04-06 14:55:27 UTC (rev 5226) +++ trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-04-06 15:03:21 UTC (rev 5227) @@ -26,7 +26,7 @@ import org.jnode.driver.console.CompletionInfo; import org.jnode.shell.CommandLine.Token; -import org.jnode.vm.annotation.DoPrivileged; +import org.jnode.annotation.DoPrivileged; import sun.security.action.GetPropertyAction; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-10 13:13:36
|
Revision: 5241 http://jnode.svn.sourceforge.net/jnode/?rev=5241&view=rev Author: chrisboertien Date: 2009-04-10 13:13:26 +0000 (Fri, 10 Apr 2009) Log Message: ----------- checkstyle fixes Signed-off-by: cluster <cluster@cluster-laptop.(none)> Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/command/FindCommand.java trunk/fs/src/fs/org/jnode/fs/command/archive/Zip.java trunk/shell/src/shell/org/jnode/shell/command/BasenameCommand.java trunk/shell/src/shell/org/jnode/shell/command/DirnameCommand.java trunk/shell/src/shell/org/jnode/shell/command/HeadCommand.java trunk/shell/src/shell/org/jnode/shell/command/TailCommand.java Modified: trunk/fs/src/fs/org/jnode/fs/command/FindCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/FindCommand.java 2009-04-10 04:41:39 UTC (rev 5240) +++ trunk/fs/src/fs/org/jnode/fs/command/FindCommand.java 2009-04-10 13:13:26 UTC (rev 5241) @@ -42,7 +42,7 @@ "descent at most to given level of directories"); private final LongArgument mindepthArg = new LongArgument("mindepth", Argument.OPTIONAL, "ignore files and directories at levels less than given level"); - private final StringArgument typeArg = new StringArgument( "type", Argument.OPTIONAL, + private final StringArgument typeArg = new StringArgument("type", Argument.OPTIONAL, "filter results to show only files of given type. valid types are 'd' for directory and 'f' for file"); private final FileArgument dirArg = new FileArgument("directory", Argument.OPTIONAL | Argument.MULTIPLE, "directory to start searching from"); Modified: trunk/fs/src/fs/org/jnode/fs/command/archive/Zip.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/archive/Zip.java 2009-04-10 04:41:39 UTC (rev 5240) +++ trunk/fs/src/fs/org/jnode/fs/command/archive/Zip.java 2009-04-10 13:13:26 UTC (rev 5241) @@ -21,18 +21,18 @@ package org.jnode.fs.command.archive; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.PrintWriter; +//import java.io.FileInputStream; +//import java.io.FileOutputStream; +//import java.io.InputStream; +//import java.io.OutputStream; +//import java.io.Reader; +//import java.io.PrintWriter; import java.io.IOException; -import java.util.Enumeration; -import java.util.zip.ZipFile; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; -import java.util.zip.ZipException; +//import java.util.Enumeration; +//import java.util.zip.ZipFile; +//import java.util.zip.ZipEntry; +//import java.util.zip.ZipOutputStream; +//import java.util.zip.ZipException; public class Zip extends ArchiveCommand { Modified: trunk/shell/src/shell/org/jnode/shell/command/BasenameCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/BasenameCommand.java 2009-04-10 04:41:39 UTC (rev 5240) +++ trunk/shell/src/shell/org/jnode/shell/command/BasenameCommand.java 2009-04-10 13:13:26 UTC (rev 5241) @@ -52,6 +52,6 @@ } } - getOutput().getPrintWriter().println(name.substring(start,end)); + getOutput().getPrintWriter().println(name.substring(start, end)); } } Modified: trunk/shell/src/shell/org/jnode/shell/command/DirnameCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/DirnameCommand.java 2009-04-10 04:41:39 UTC (rev 5240) +++ trunk/shell/src/shell/org/jnode/shell/command/DirnameCommand.java 2009-04-10 13:13:26 UTC (rev 5241) @@ -50,7 +50,7 @@ if (end == -1) { name = "."; } else { - name = name.substring(0,end); + name = name.substring(0, end); } } Modified: trunk/shell/src/shell/org/jnode/shell/command/HeadCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/HeadCommand.java 2009-04-10 04:41:39 UTC (rev 5240) +++ trunk/shell/src/shell/org/jnode/shell/command/HeadCommand.java 2009-04-10 13:13:26 UTC (rev 5241) @@ -20,10 +20,6 @@ package org.jnode.shell.command; -import org.jnode.shell.syntax.ArgumentBundle; -import org.jnode.driver.console.CompletionInfo; -import org.jnode.shell.CommandLine.Token; - import org.jnode.shell.AbstractCommand; import org.jnode.shell.syntax.Argument; import org.jnode.shell.syntax.FlagArgument; @@ -210,7 +206,7 @@ buffer = new byte[Math.min(n, bufsize)]; while (n > 0 && (len = in.read(buffer)) > 0) { len = Math.min(n, len); - out.write(buffer,0,len); + out.write(buffer, 0, len); n -= len; } } Modified: trunk/shell/src/shell/org/jnode/shell/command/TailCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/TailCommand.java 2009-04-10 04:41:39 UTC (rev 5240) +++ trunk/shell/src/shell/org/jnode/shell/command/TailCommand.java 2009-04-10 13:13:26 UTC (rev 5241) @@ -245,7 +245,7 @@ buffer = new byte[bufsize]; while ((len = in.read(buffer)) > 0) { - out.write(buffer,0,len); + out.write(buffer, 0, len); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-04-12 01:05:09
|
Revision: 5249 http://jnode.svn.sourceforge.net/jnode/?rev=5249&view=rev Author: crawley Date: 2009-04-12 01:05:05 +0000 (Sun, 12 Apr 2009) Log Message: ----------- Commit of patch from issue #2959. Adds ability to contextually set (some) Argument 'flags' from a syntax. Defines two new flags for FileArgument. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java trunk/net/src/net/org/jnode/net/syntax/IPv4AddressArgument.java trunk/net/src/net/org/jnode/net/syntax/IPv4HostArgument.java trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java trunk/shell/src/shell/org/jnode/shell/CommandLine.java trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java trunk/shell/src/shell/org/jnode/shell/command/test/SuiteCommand.java trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/Argument.java trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentBundle.java trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentSyntax.java trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/FlagArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/MuArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java trunk/shell/src/shell/org/jnode/shell/syntax/MuPreset.java trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java trunk/shell/src/shell/org/jnode/shell/syntax/OptionSyntax.java trunk/shell/src/shell/org/jnode/shell/syntax/PluginArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxSpecLoader.java trunk/shell/src/shell/org/jnode/shell/syntax/ThreadNameArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/URLArgument.java trunk/shell/src/shell/org/jnode/shell/syntax/VerbSyntax.java trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java trunk/shell/src/test/org/jnode/test/shell/syntax/MuSyntaxTest.java Modified: trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/fs/src/fs/org/jnode/fs/nfs/command/NFSHostNameArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -43,7 +43,7 @@ super(name, flags, new String[0], description); } - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { int index = partial.indexOf(':'); if (index <= 0) { return; @@ -117,7 +117,7 @@ } @Override - protected String doAccept(Token value) throws CommandSyntaxException { + protected String doAccept(Token value, int flags) throws CommandSyntaxException { int index = value.text.indexOf(':'); if (index == -1) { throw new CommandSyntaxException("missing ':'"); Modified: trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java =================================================================== --- trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/fs/src/fs/org/jnode/partitions/command/IBMPartitionTypeArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -38,7 +38,7 @@ } @Override - protected IBMPartitionTypes doAccept(Token value) throws CommandSyntaxException { + protected IBMPartitionTypes doAccept(Token value, int flags) throws CommandSyntaxException { try { int code = Integer.parseInt(value.text, 16); return IBMPartitionTypes.valueOf(code); @@ -50,7 +50,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { partial = partial.toLowerCase(); for (IBMPartitionTypes pt : IBMPartitionTypes.values()) { String code = Integer.toHexString(pt.getCode()); Modified: trunk/net/src/net/org/jnode/net/syntax/IPv4AddressArgument.java =================================================================== --- trunk/net/src/net/org/jnode/net/syntax/IPv4AddressArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/net/src/net/org/jnode/net/syntax/IPv4AddressArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -45,7 +45,7 @@ } @Override - protected IPv4Address doAccept(Token value) throws CommandSyntaxException { + protected IPv4Address doAccept(Token value, int flags) throws CommandSyntaxException { if (value.text.equals("default")) { return new IPv4Address(new byte[]{0, 0, 0, 0}, 0); } Modified: trunk/net/src/net/org/jnode/net/syntax/IPv4HostArgument.java =================================================================== --- trunk/net/src/net/org/jnode/net/syntax/IPv4HostArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/net/src/net/org/jnode/net/syntax/IPv4HostArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -43,7 +43,7 @@ } @Override - protected IPv4Address doAccept(Token value) throws CommandSyntaxException { + protected IPv4Address doAccept(Token value, int flags) throws CommandSyntaxException { try { return new IPv4Address(value.text); } catch (IllegalArgumentException ex) { Modified: trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/ArgumentCompleter.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -46,7 +46,7 @@ } public void complete(CompletionInfo completion, CommandShell shell) { - argument.complete(completion, token == null ? "" : token.text); + argument.complete(completion, token == null ? "" : token.text, 0); if (token != null) { completion.setCompletionStart(token.start); } Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -643,7 +643,7 @@ // We haven't got a command name yet, so complete the partial command name string // as an AliasArgument. AliasArgument cmdNameArg = new AliasArgument("cmdName", Argument.SINGLE); - cmdNameArg.complete(completion, cmd); + cmdNameArg.complete(completion, cmd, 0); completion.setCompletionStart(commandToken == null ? 0 : commandToken.start); } } Modified: trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/command/BindKeysCommand.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -125,7 +125,7 @@ } @Override - protected VirtualKey doAccept(Token value) throws CommandSyntaxException { + protected VirtualKey doAccept(Token value, int flags) throws CommandSyntaxException { String str = value.text; String[] parts = str.split("\\+"); int modifiers = 0; @@ -156,7 +156,7 @@ } @Override - protected Character doAccept(Token value) throws CommandSyntaxException { + protected Character doAccept(Token value, int flags) throws CommandSyntaxException { String str = value.text; String upper = str.toUpperCase(); for (int i = 0; i < ASCII_NAMES.length; i++) { Modified: trunk/shell/src/shell/org/jnode/shell/command/test/SuiteCommand.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/command/test/SuiteCommand.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/command/test/SuiteCommand.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -97,7 +97,7 @@ super(label, flags, description); } - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { Set<String> availCategories = TestManager.getInstance().getCategories(); for (String availCategory : availCategories) { if (availCategory.startsWith(partial)) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/AliasArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -49,14 +49,14 @@ } @Override - public String doAccept(Token value) throws CommandSyntaxException { + public String doAccept(Token value, int flags) throws CommandSyntaxException { if (value.text.length() == 0) { throw new CommandSyntaxException("empty alias name"); } return value.text; } - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { try { // get the alias manager final AliasManager aliasMgr = Modified: trunk/shell/src/shell/org/jnode/shell/syntax/Argument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/Argument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/Argument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -55,44 +55,70 @@ public abstract class Argument<V> { /** - * This Argument flag indicates that the Argument is optional. + * This Argument flag indicates that the Argument is optional. This is the + * opposite of MANDATORY, and is the default if neither are specified. */ public static final int OPTIONAL = 0x001; /** - * This Argument flag indicates that the Argument is mandatory. At least - * one instance of this Argument must be supplied. + * This Argument flag indicates that the Argument is mandatory; i.e that least + * one instance of this Argument must be supplied in a command line. This is + * the opposite of OPTIONAL. */ public static final int MANDATORY = 0x002; /** * This Argument flag indicates that the Argument may have at most one value. + * This is the opposite of MULTIPLE and the default if neither are specified. */ public static final int SINGLE = 0x004; /** * This Argument flag indicates that multiple instances of this Argument may - * be provided. + * be provided. This is the opposite of SINGLE. */ public static final int MULTIPLE = 0x008; /** * This Argument flag indicates that an Argument's value must denote an entity * that already exists in whatever domain that the Argument values corresponds to. + * Note that this is <b>not</b> the logical negation of NONEXISTENT! */ public static final int EXISTING = 0x010; /** * This Argument flag indicates that an Argument's value must denote an entity * that does not exists in whatever domain that the Argument values corresponds to. + * Note that this is <b>not</b> the logical negation of EXISTING! */ public static final int NONEXISTENT = 0x020; + + /** + * Flag bits in this bitset are either common flags, or reserved for future use as + * common flags. + */ + public static final int COMMON_FLAGS = 0x0000ffff; + /** + * Flag bits in this bitset are available for use as Argument-subclass specific flags. + * Flags in this range may be overridden by a Syntax. + */ + public static final int SPECIFIC_OVERRIDABLE_FLAGS = 0x00ff0000; + + /** + * Flag bits in this bitset are available for use as Argument-subclass specific flags. + * Flags in this range may NOT be overridden by a Syntax. + */ + private static final int SPECIFIC_NONOVERRIDABLE_FLAGS = 0xff000000; + + /** + * Flag bits in this bitset may not be overridden by a Syntax. + */ + public static final int NONOVERRIDABLE_FLAGS = + SINGLE | MULTIPLE | MANDATORY | OPTIONAL | SPECIFIC_NONOVERRIDABLE_FLAGS; + private final String label; - private final boolean mandatory; - private final boolean multiple; - private final boolean existing; - private final boolean nonexistent; + private final int flags; private final String description; protected final List<V> values = new ArrayList<V>(); @@ -114,6 +140,22 @@ protected Argument(String label, int flags, V[] vArray, String description) throws IllegalArgumentException { super(); + checkFlags(flags); + this.label = label; + this.description = description; + this.flags = flags; + this.vArray = vArray; + } + + /** + * Check that the supplied flags are consistent. + * <p> + * Note: this method may be overridden in child classes, but an override should + * call this method to check the common flags. + * @param flags the flags to be checked. + * @throws IllegalArgumentException + */ + protected void checkFlags(int flags) throws IllegalArgumentException { if ((flags & EXISTING) != 0 && (flags & NONEXISTENT) != 0) { throw new IllegalArgumentException("inconsistent flags: EXISTING and NONEXISTENT"); } @@ -123,33 +165,162 @@ if ((flags & MANDATORY) != 0 && (flags & OPTIONAL) != 0) { throw new IllegalArgumentException("inconsistent flags: MANDATORY and OPTIONAL"); } - this.label = label; - this.description = description; - this.mandatory = (flags & MANDATORY) != 0; - this.multiple = (flags & MULTIPLE) != 0; - this.existing = (flags & EXISTING) != 0; - this.nonexistent = (flags & NONEXISTENT) != 0; - this.vArray = vArray; } /** - * Reconstruct and return Argument flags equiivalent to those passed to the constructor. + * Return the flags as passed to the constructor. * @return the flags. */ public int getFlags() { - return ((mandatory ? MANDATORY : OPTIONAL) | (multiple ? MULTIPLE : SINGLE) | - (existing ? EXISTING : 0) | (nonexistent ? NONEXISTENT : 0)); + return flags; } + + /** + * Convert a comma-separated list of names to a flags word. The current implementation + * will silently ignore empty names; e.g. in {@code "MANDATORY,,SINGLE"} or + * {@code ",SINGLE"}. + * + * @param names the names separated by commas and optional whitespace. + * @return the flags + * @throws IllegalArgument if the list contains unknown flag names. + */ + public final int namesToFlags(String names) throws IllegalArgumentException { + String[] nameList = names.trim().split("\\s*,\\s*"); + int res = 0; + for (String name : nameList) { + if (name != null && name.length() > 0) { + res |= nameToFlag(name); + } + } + return res; + } + + /** + * Convert a flag name to a flag. + * <p> + * Note: this method may be overridden in child + * classes, but an override should end by calling this method to deal + * with flag names that it doesn't understand. + * + * @param name the name to be converted + * @return the corresponding flag + * @throws IllegalArgumentWxception if the name is not recognized + */ + public int nameToFlag(String name) throws IllegalArgumentException { + if (name.equals("MANDATORY")) { + return MANDATORY; + } else if (name.equals("OPTIONAL")) { + return OPTIONAL; + } else if (name.equals("SINGLE")) { + return SINGLE; + } else if (name.equals("MULTIPLE")) { + return MULTIPLE; + } else if (name.equals("EXISTING")) { + return EXISTING; + } else if (name.equals("NONEXISTENT")) { + return NONEXISTENT; + } else { + throw new IllegalArgumentException("unknown flag name '" + name + "'"); + } + } /** * If this method returns <code>true</code>, this Argument must be bound to an * argument in a CommandLine if it is used in a given concrete syntax. */ public boolean isMandatory() { - return mandatory; + return isMandatory(flags); } /** + * If this method returns <code>true</code>, this Argument need not be bound to an + * argument in a CommandLine if it is used in a given concrete syntax. + */ + public boolean isOptional() { + return isOptional(flags); + } + + /** + * If this method returns <code>true</code>, this element may have + * multiple instances in a CommandLine. + */ + public boolean isMultiple() { + return isMultiple(flags); + } + + /** + * If this method returns <code>true</code>, this element must have at + * most one instance in a CommandLine. + */ + public boolean isSingle() { + return isSingle(flags); + } + + /** + * If this method returns <code>true</code>, an Argument value must correspond + * to an existing entity in the domain of entities denoted by the Argument type. + */ + public boolean isExisting() { + return isExisting(flags); + } + + /** + * If this method returns <code>true</code>, an Argument value must <i>not</i> correspond + * to an existing entity in the domain of entities denoted by the Argument type. + */ + public boolean isNonexistent() { + return isNonexistent(flags); + } + + /** + * If this method returns <code>true</code>, the flags say that the corresponding Argument + * must be bound to an argument in a CommandLine if it is used in a given concrete syntax. + */ + public static boolean isMandatory(int flags) { + return (flags & MANDATORY) != 0; + } + + /** + * If this method returns <code>true</code>, the flags say that the corresponding Argument + * need not be bound to an argument in a CommandLine if it is used in a given concrete syntax. + */ + public static boolean isOptional(int flags) { + return (flags & MANDATORY) == 0; + } + + /** + * If this method returns <code>true</code>, the corresponding Argument may have + * multiple instances in a CommandLine. + */ + public static boolean isMultiple(int flags) { + return (flags & MULTIPLE) != 0; + } + + /** + * If this method returns <code>true</code>, the corresponding Argument must have at + * most one instance in a CommandLine. + */ + public static boolean isSingle(int flags) { + return (flags & MULTIPLE) == 0; + } + + /** + * If this method returns <code>true</code>, the corresponding Argument value must denote + * an existing entity. + */ + public static boolean isExisting(int flags) { + return (flags & EXISTING) != 0; + } + + /** + * If this method returns <code>true</code>, the corresponding Argument value must + * <i>not</i> denote an existing entity. + */ + public boolean isNonexistent(int flags) { + return (flags & NONEXISTENT) != 0; + } + + /** * The label is the application's identifier for the Argument. It is used to identify * the Argument in a concrete syntax specification. It can also be used by the * application for name lookup of a bound argument's values. @@ -207,12 +378,18 @@ * the caller should treat the Token as consumed. * * @param value the token that will supply the Argument's value. + * @param flags extra flags from the syntax system. These will be OR'ed with + * the Arguments existing flags. Note the cardinality flags cannot be + * overridden. */ - public final void accept(Token value) throws CommandSyntaxException { + public final void accept(Token value, int flags) + throws CommandSyntaxException, IllegalArgumentException { if (isSet() && !isMultiple()) { throw new SyntaxMultiplicityException("this argument cannot be repeated"); } - addValue(doAccept(value)); + flags = (flags & ~NONOVERRIDABLE_FLAGS) | this.flags; + checkFlags(flags); + addValue(doAccept(value, flags)); } /** @@ -220,8 +397,9 @@ * should either return a non-null V to be accepted, or throw an exception. * * @param value the token that will supply the Argument's value. + * @param flags the flags to be used. */ - protected abstract V doAccept(Token value) throws CommandSyntaxException; + protected abstract V doAccept(Token value, int flags) throws CommandSyntaxException; /** * Perform argument completion on the supplied (partial) argument value. The @@ -235,40 +413,29 @@ * @param completion the CompletionInfo object for registering any completions. * @param partial the argument string to be completed. */ - public void complete(CompletionInfo completion, String partial) { - // set no completion + public final void complete(CompletionInfo completion, String partial, int flags) { + if (isSet() && !isMultiple()) { + throw new SyntaxMultiplicityException("this argument cannot be repeated"); + } + flags = (flags & ~NONOVERRIDABLE_FLAGS) | this.flags; + checkFlags(flags); + doComplete(completion, partial, flags); } - - /** - * Test if sufficient values have been bound to the Argument to satisfy the - * the Argument's specified cardinality constraints. - */ - public boolean isSatisfied() { - return !isMandatory() || isSet(); - } - - /** - * If this method returns <code>true</code>, this element may have - * multiple instances in a CommandLine. - */ - public boolean isMultiple() { - return multiple; - } - - /** - * If this method returns <code>true</code>, an Argument value must correspond - * to an existing entity in the domain of entities denoted by the Argument type. - */ - public boolean isExisting() { - return existing; - } /** - * If this method returns <code>true</code>, an Argument value must <i>not</i> correspond - * to an existing entity in the domain of entities denoted by the Argument type. + * Perform argument completion on the supplied (partial) argument value. The + * results of the completion should be added to the supplied CompletionInfo. + * <p> + * The default behavior is to set no completion. + * Subtypes of Argument should override this method if they are capable of doing + * non-trivial completion. Completions should be registered by calling one + * of the 'addCompletion' methods on the CompletionInfo. + * + * @param completion the CompletionInfo object for registering any completions. + * @param partial the argument string to be completed. */ - public boolean isNonexistent() { - return nonexistent; + public void doComplete(CompletionInfo completion, String partial, int flags) { + // set no completion } void setBundle(ArgumentBundle bundle) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentBundle.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentBundle.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentBundle.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -111,7 +111,7 @@ try { doParse(commandLine, syntaxes, null); for (Argument<?> element : arguments) { - if (!element.isSatisfied() && element.isMandatory()) { + if (!element.isSet() && element.isMandatory()) { throw new CommandSyntaxException( "Command syntax error: required argument '" + element.getLabel() + "' not supplied"); @@ -195,7 +195,7 @@ return new EmptySyntax("default", null); } else if (arguments.length == 1) { String label = arguments[0].getLabel(); - return new OptionSyntax(label, label, null); + return new OptionSyntax(label, label, null, null); } else { // A better default syntax would only allow one Option repetition // for any Argument that accepts only one value, and would use mandatory @@ -203,7 +203,7 @@ Syntax[] syntaxes = new OptionSyntax[arguments.length]; for (int i = 0; i < syntaxes.length; i++) { String label = arguments[i].getLabel(); - syntaxes[i] = new OptionSyntax(label, label, null); + syntaxes[i] = new OptionSyntax(label, label, null, null); } return new PowersetSyntax("default", syntaxes); } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentSyntax.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentSyntax.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/ArgumentSyntax.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -32,21 +32,23 @@ public class ArgumentSyntax extends Syntax { private final String argName; + private final String flags; - public ArgumentSyntax(String label, String argName, String description) { + public ArgumentSyntax(String label, String argName, String flags, String description) { super(label, description); this.argName = argName; + this.flags = flags; if (argName.length() == 0) { throw new IllegalArgumentException("empty argName"); } } public ArgumentSyntax(String label, String argName) { - this(label, argName, null); + this(label, argName, null, null); } public ArgumentSyntax(String argName) { - this(null, argName, null); + this(null, argName, null, null); } @Override @@ -61,12 +63,19 @@ @Override public String toString() { - return "ArgumentSyntax{" + super.toString() + ",argName=" + argName + "}"; + return "ArgumentSyntax{" + super.toString() + ",argName=" + + argName + ",flags=" + flags + "}"; } @Override public MuSyntax prepare(ArgumentBundle bundle) { - return new MuArgument(label, argName); + int flags; + if (this.flags == null || this.flags.length() == 0) { + flags = 0; + } else { + flags = bundle.getArgument(argName).namesToFlags(this.flags); + } + return new MuArgument(label, argName, flags); } public String getArgName() { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/ClassNameArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -39,7 +39,7 @@ } @Override - protected String doAccept(Token token) throws CommandSyntaxException { + protected String doAccept(Token token, int flags) throws CommandSyntaxException { return token.text; } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/CountryArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -41,7 +41,7 @@ } @Override - protected String doAccept(Token token) throws CommandSyntaxException { + protected String doAccept(Token token, int flags) throws CommandSyntaxException { if (validCountries.contains(token.text)) { return token.text; } else { @@ -50,7 +50,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { for (String country : validCountries) { if (country.startsWith(partial)) { completion.addCompletion(country); Modified: trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/DeviceArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -54,7 +54,7 @@ } @Override - protected Device doAccept(Token token) throws CommandSyntaxException { + protected Device doAccept(Token token, int flags) throws CommandSyntaxException { try { final DeviceManager devMgr = getDeviceManager(); final Device device = devMgr.getDevice(token.text); @@ -70,7 +70,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { final DeviceManager devMgr = getDeviceManager(); // collect matching devices Modified: trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/EnumArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -60,7 +60,7 @@ } @Override - protected E doAccept(Token token) throws CommandSyntaxException { + protected E doAccept(Token token, int flags) throws CommandSyntaxException { try { return E.valueOf(clazz, token.text); } catch (IllegalArgumentException ex) { @@ -69,7 +69,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { for (E e : clazz.getEnumConstants()) { String eName = e.name(); if (eName.startsWith(partial)) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/FileArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -32,11 +32,44 @@ /** * This argument class performs completion against the file system namespace. This * Argument class understands the {@link Argument#EXISTING} and {@link Argument#NONEXISTENT} - * flags when accepting argument values, but not (yet) when completing them. + * flags when accepting argument values. Neither {@link Argument#EXISTING} or + * {@link Argument#NONEXISTENT} currently affect completion. (You might expect that + * {@link Argument#NONEXISTENT} would suppress completion, but consider that the user + * may want to complete the directory path for some file to be created by a command.) + * <p> + * FileArgument normally treats pathname components starting with a "-" as invalid pathnames + * and won't accept them. (The rationale is that they are probably a misplaced or unknown + * option names.) This behavior can be changed using the {@link #ALLOW_DODGY_NAMES} flag. + * <p> + * Some commands use "-" to denote (for example) "standard input" instead of a file named + * "-". To support this, FileArgument provides a {@link #HYPHEN_IS_SPECIAL} flag which + * suppresses the {@link Argument#EXISTING} and {@link Argument#NONEXISTENT} flags so that + * a "-" argument is always accepted. It is up to the command to deal with the resulting + * {@code File("-")} instance, which of course should not be opened in the normal way. + * (Note: this is an experimental feature, and may be replaced with a conceptually cleaner + * solution in the future.) * * @author cr...@jn... */ public class FileArgument extends Argument<File> { + + /** + * This Argument flag tells the FileArgument to accept filenames that, + * while strictly legal, will cause problems. At the moment, this means + * pathnames where one or more component names starts with a '-'. (Such + * names may be problematic for some commands, and are probably entered + * by mistake.) + */ + public static final int ALLOW_DODGY_NAMES = 0x00010000; + + /** + * This Argument flag tells the FileArgument that the command will + * interpret {@code File("-")} as meaning something other than a regular + * pathname, and that FileArgument should allow "-" as a valid argument + * or completion, not withstanding the existence of a real file with + * that name. This flag cannot be set by a Syntax. + */ + public static final int HYPHEN_IS_SPECIAL = 0x01000000; public FileArgument(String label, int flags, String description) { super(label, flags, new File[0], description); @@ -48,15 +81,32 @@ @Override @DoPrivileged - protected File doAccept(Token token) throws CommandSyntaxException { + protected File doAccept(Token token, int flags) throws CommandSyntaxException { if (token.text.length() > 0) { File file = new File(token.text); - if (isExisting() && !file.exists()) { - throw new CommandSyntaxException("this file or directory does not exist"); + if ((flags & HYPHEN_IS_SPECIAL) == 0 || !file.getPath().equals("-")) { + if (isExisting(flags) && !file.exists()) { + throw new CommandSyntaxException("this file or directory does not exist"); + } + if (isNonexistent(flags) && file.exists()) { + throw new CommandSyntaxException("this file or directory already exist"); + } + if ((flags & ALLOW_DODGY_NAMES) == 0) { + File f = file; + do { + // This assumes that option names start with '-'. + if (f.getName().startsWith("-")) { + if (f == file && !file.isAbsolute() && f.getParent() == null) { + // The user most likely meant this to be an option name ... + throw new CommandSyntaxException("unexpected or unknown option"); + } else { + throw new CommandSyntaxException("file or directory name starts with a '-'"); + } + } + f = f.getParentFile(); + } while (f != null); + } } - if (isNonexistent() && file.exists()) { - throw new CommandSyntaxException("this file or directory already exist"); - } return file; } else { throw new CommandSyntaxException("invalid file name"); @@ -64,7 +114,8 @@ } @Override - public void complete(final CompletionInfo completion, final String partial) { + public void doComplete(final CompletionInfo completion, + final String partial, final int flags) { // Get last full directory from the partial pathname. final int idx = partial.lastIndexOf(File.separatorChar); final String dir; @@ -121,10 +172,26 @@ (tmp == 2 && partial.endsWith("."))) { completion.addCompletion(partial + File.separatorChar, true); } + + // Add "-" as a possible completion? + if ((flags & HYPHEN_IS_SPECIAL) != 0) { + completion.addCompletion("-"); + } } @Override protected String argumentKind() { return "file"; } + + @Override + public int nameToFlag(String name) throws IllegalArgumentException { + if (name.equals("ALLOW_DODGY_NAMES")) { + return ALLOW_DODGY_NAMES; + } else if (name.equals("HYPHEN_IS_SPECIAL")) { + return HYPHEN_IS_SPECIAL; + } else{ + return super.nameToFlag(name); + } + } } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/FlagArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/FlagArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/FlagArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -38,7 +38,7 @@ } @Override - protected Boolean doAccept(Token token) throws CommandSyntaxException { + protected Boolean doAccept(Token token, int flags) throws CommandSyntaxException { return Boolean.TRUE; } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/HostNameArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -48,7 +48,7 @@ } @Override - protected String doAccept(Token token) throws CommandSyntaxException { + protected String doAccept(Token token, int flags) throws CommandSyntaxException { return token.text; } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/IntegerArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -55,7 +55,7 @@ } @Override - protected Integer doAccept(Token token) throws CommandSyntaxException { + protected Integer doAccept(Token token, int flags) throws CommandSyntaxException { try { int tmp = Integer.parseInt(token.text); if (tmp < min || tmp > max) { @@ -68,7 +68,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { // FIXME ... maybe someone could figure out how to partial // completion efficiently when max - min is large? if (max - min >= 0 && max - min < COMPLETION_THRESHOLD) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/KeyboardLayoutArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -46,12 +46,12 @@ } @Override - protected String doAccept(Token token) throws CommandSyntaxException { + protected String doAccept(Token token, int flags) throws CommandSyntaxException { return token.text; } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { try { KeyboardLayoutManager mgr = InitialNaming.lookup(KeyboardLayoutManager.NAME); // collect matching devices Modified: trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/LanguageArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -28,7 +28,7 @@ import org.jnode.shell.CommandLine.Token; /** - * This argument accepts an ISO country code. + * This argument accepts an ISO language code. * * @author cr...@jn... */ @@ -41,7 +41,7 @@ } @Override - protected String doAccept(Token token) throws CommandSyntaxException { + protected String doAccept(Token token, int flags) throws CommandSyntaxException { if (validLanguages.contains(token.text)) { return token.text; } else { @@ -50,7 +50,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { for (String language : validLanguages) { if (language.startsWith(partial)) { completion.addCompletion(language); Modified: trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/Log4jLoggerArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -48,7 +48,7 @@ * Any token is an acceptable Logger name. */ @Override - protected Logger doAccept(Token value) throws CommandSyntaxException { + protected Logger doAccept(Token value, int flags) throws CommandSyntaxException { return Logger.getLogger(value.text); } @@ -56,7 +56,7 @@ * Complete against existing logger names. */ @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { Enumeration<?> en = LogManager.getCurrentLoggers(); while (en.hasMoreElements()) { String loggerName = ((Logger) en.nextElement()).getName(); Modified: trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/LongArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -56,7 +56,7 @@ } @Override - protected Long doAccept(Token token) throws CommandSyntaxException { + protected Long doAccept(Token token, int flags) throws CommandSyntaxException { try { long tmp = Long.parseLong(token.text); if (tmp < min || tmp > max) { @@ -69,7 +69,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { // FIXME ... maybe someone could figure out how to partial // completion efficiently when max - min is large? if (max - min >= 0 && max - min < COMPLETION_THRESHOLD) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/MappedArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -62,7 +62,7 @@ * Complete partial against the domain of the valueMap. */ @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { if (caseInsensitive) { partial = partial.toLowerCase(); } @@ -77,7 +77,7 @@ * Accept token if it is in the domain of the valueMap. */ @Override - protected V doAccept(Token token) throws CommandSyntaxException { + protected V doAccept(Token token, int flags) throws CommandSyntaxException { String t = caseInsensitive ? token.text.toLowerCase() : token.text; V value = valueMap.get(t); if (value == null) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/MuArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/MuArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/MuArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -29,17 +29,19 @@ public class MuArgument extends MuSyntax { private final String argName; + private final int flags; public MuArgument(String argName) { - this (null, argName); + this (null, argName, 0); } - public MuArgument(String label, String argName) { + public MuArgument(String label, String argName, int flags) { super(label); if (argName.length() == 0) { throw new IllegalArgumentException("empty argName"); } this.argName = argName; + this.flags = flags; } @Override @@ -63,4 +65,8 @@ } return this; } + + public int getFlags() { + return flags; + } } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/MuParser.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -213,13 +213,15 @@ } break; case ARGUMENT: - String argName = ((MuArgument) syntax).getArgName(); + MuArgument muArg = (MuArgument) syntax; + String argName = muArg.getArgName(); + int flags = muArg.getFlags(); Argument<?> arg = bundle.getArgument(argName); try { if (source.hasNext()) { token = source.next(); if (completion == null || source.hasNext() || source.whitespaceAfterLast()) { - arg.accept(token); + arg.accept(token, flags); if (!backtrackStack.isEmpty()) { backtrackStack.getFirst().argsModified.add(arg); if (DEBUG) { @@ -227,13 +229,13 @@ } } } else { - arg.complete(completion, token.text); + arg.complete(completion, token.text, flags); completion.setCompletionStart(token.start); backtrack = true; } } else { if (completion != null) { - arg.complete(completion, ""); + arg.complete(completion, "", flags); } backtrack = true; } @@ -247,10 +249,11 @@ } break; case PRESET: - MuPreset preset = (MuPreset) syntax; - arg = bundle.getArgument(preset.getArgName()); + MuPreset muPreset = (MuPreset) syntax; + arg = bundle.getArgument(muPreset.getArgName()); + flags = muPreset.getFlags(); try { - arg.accept(new CommandLine.Token(preset.getPreset())); + arg.accept(new CommandLine.Token(muPreset.getPreset()), flags); if (!backtrackStack.isEmpty()) { backtrackStack.getFirst().argsModified.add(arg); if (DEBUG) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/MuPreset.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/MuPreset.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/MuPreset.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -30,18 +30,20 @@ private final String argName; private final String preset; + private final int flags; public MuPreset(String argName, String preset) { - this (null, argName, preset); + this(null, argName, preset, 0); } - public MuPreset(String label, String argName, String preset) { + public MuPreset(String label, String argName, String preset, int flags) { super(label); if (argName.length() == 0) { throw new IllegalArgumentException("empty argName"); } this.argName = argName; this.preset = preset; + this.flags = flags; } @Override @@ -69,4 +71,8 @@ public String getPreset() { return preset; } + + public int getFlags() { + return flags; + } } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/OptionSetSyntax.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -52,7 +52,7 @@ } @Override - protected Boolean doAccept(Token token) throws CommandSyntaxException { + protected Boolean doAccept(Token token, int argumentFlags) throws CommandSyntaxException { String value = token.text; int len = value.length(); if (len < 2 || value.charAt(0) != '-') { @@ -64,7 +64,7 @@ boolean found = false; for (OptionSyntax flagOption : flagOptions) { if (shortOptName.equals(flagOption.getShortOptName())) { - bundle.getArgument(flagOption).accept(new Token(shortOptName)); + bundle.getArgument(flagOption).accept(new Token(shortOptName), 0); found = true; break; } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/OptionSyntax.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/OptionSyntax.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/OptionSyntax.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -35,34 +35,35 @@ private final String longOptName; private final String shortOptName; - public OptionSyntax(String argName, String optionName, char optionChar, String description) { - super(null, argName, description); + public OptionSyntax(String argName, String optionName, char optionChar, + String flags, String description) { + super(null, argName, flags, description); this.longOptName = "--" + optionName; this.shortOptName = "-" + optionChar; } - public OptionSyntax(String argName, char optionChar, String description) { - super(null, argName, description); + public OptionSyntax(String argName, char optionChar, String flags, String description) { + super(null, argName, flags, description); this.longOptName = null; this.shortOptName = "-" + optionChar; } - public OptionSyntax(String argName, String optionName, String description) { - super(null, argName, description); + public OptionSyntax(String argName, String optionName, String flags, String description) { + super(null, argName, flags, description); this.longOptName = "--" + optionName; this.shortOptName = null; } public OptionSyntax(String argName, String optionName, char optionChar) { - this(argName, optionName, optionChar, null); + this(argName, optionName, optionChar, null, null); } public OptionSyntax(String argName, char optionChar) { - this(argName, optionChar, null); + this(argName, optionChar, null, null); } public OptionSyntax(String argName, String optionName) { - this(argName, optionName, null); + this(argName, optionName, null, null); } @Override Modified: trunk/shell/src/shell/org/jnode/shell/syntax/PluginArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/PluginArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/PluginArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -40,7 +40,7 @@ } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { try { // get the plugin manager final PluginManager piMgr = InitialNaming.lookup(PluginManager.NAME); Modified: trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/PropertyNameArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -45,12 +45,12 @@ } @Override - protected String doAccept(Token token) throws CommandSyntaxException { + protected String doAccept(Token token, int flags) throws CommandSyntaxException { return token.text; } @Override - public void complete(CompletionInfo completion, String partial) { + public void doComplete(CompletionInfo completion, String partial, int flags) { for (Object key : System.getProperties().keySet()) { String name = (String) key; if (name.startsWith(partial)) { Modified: trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/SizeArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -20,7 +20,6 @@ package org.jnode.shell.syntax; -import org.jnode.driver.console.CompletionInfo; import org.jnode.shell.CommandLine.Token; import org.jnode.util.BinaryScaleFactor; import org.jnode.util.DecimalScaleFactor; @@ -45,7 +44,7 @@ } @Override - protected Long doAccept(Token token) throws CommandSyntaxException { + protected Long doAccept(Token token, int flags) throws CommandSyntaxException { String str = token.text; ScaleFactor factor = scaleFactor(str); if (factor != null) { @@ -72,11 +71,6 @@ } @Override - public void complete(CompletionInfo completion, String partial) { - // No completion for now - } - - @Override protected String state() { return super.state() + "binaryScaling=" + binaryScaling; } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/StringArgument.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -42,7 +42,7 @@ } @Override - protected String doAccept(Token token) throws CommandSyntaxException { + protected String doAccept(Token token, int flags) throws CommandSyntaxException { return token.text; } Modified: trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxSpecLoader.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxSpecLoader.java 2009-04-11 14:18:16 UTC (rev 5248) +++ trunk/shell/src/shell/org/jnode/shell/syntax/SyntaxSpecLoader.java 2009-04-12 01:05:05 UTC (rev 5249) @@ -84,21 +84,22 @@ } String shortName = syntaxElement.getAttribute("shortName"); String longName = syntaxElement.getAttribute("longName"); + String flags = syntaxElement.getAttribute("flags"); if (shortName == null) { if (longName == null) { throw new SyntaxFailureException( "<option> element has must have a 'shortName' or 'longName' attribute"); } - return new OptionSyntax(argLabel, longName, description); + return new OptionSyntax(argLabel, longName, flags, description); } else { if (shortName.length() != 1) { throw new SyntaxFailureException( "<option> elements 'shortName' attribute must be one character long"); } if (longName == null) { - return new OptionSyntax(argLabel, shortName.charAt(0), description); + return new OptionSyntax(argLabel, shortName.charAt(0), flags, description); } else { - return new OptionSyntax(argLabel, longName, shortName.charAt(0), description); + return new OptionSyntax(argLabel, longName, shortName.charAt(0), flags, description); } } } else if (kind.equals("powerset")) { @@ -135,11 +136,12 @@ return new OptionalSyntax(label, description, eager, seq); } else if (kind.equals("argument")) { String argLabel = syntaxElement.getAttribute("argLabel"); + String flags = syntaxElement.getAttribute("flags"); if (argLabel == null) { System.out.println(syntaxElement); throw new SyntaxFailureException("<argument> element has no 'argLabel' attribute"); } - return new ArgumentSyntax(label, argLabel, description); + return new ArgumentSyntax(label, argLabel, flags, description); } else if (kind.equ... [truncated message content] |
From: <ls...@us...> - 2009-04-13 08:34:43
|
Revision: 5258 http://jnode.svn.sourceforge.net/jnode/?rev=5258&view=rev Author: lsantha Date: 2009-04-13 08:34:39 +0000 (Mon, 13 Apr 2009) Log Message: ----------- Activated precompiled classlib based build. Modified Paths: -------------- trunk/all/build.xml trunk/core/build.xml Added Paths: ----------- trunk/all/lib/classlib.pack.gz Property Changed: ---------------- trunk/all/lib/ Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2009-04-13 08:19:29 UTC (rev 5257) +++ trunk/all/build.xml 2009-04-13 08:34:39 UTC (rev 5258) @@ -45,6 +45,7 @@ <property name="jnode-mmtk-ms.jar" value="${root.dir}/core/build/classes-plan/org.jnode.vm.memmgr.mmtk.ms"/> <property name="jnode-mmtk-nogc.jar" value="${root.dir}/core/build/classes-plan/org.jnode.vm.memmgr.mmtk.nogc"/> + <property name="classlib.jar" value="${root.dir}/all/lib/classlib.jar"/> <property name="ant.jar" value="${root.dir}/core/lib/ant.jar"/> <property name="ant-launcher.jar" value="${root.dir}/core/lib/ant-launcher.jar"/> <property name="commons-net.jar" value="${root.dir}/core/lib/commons-net-1.1.0.jar"/> @@ -197,6 +198,35 @@ <mkdir dir="${descriptors.dir}"/> <mkdir dir="${plugins.dir}"/> <mkdir dir="${initjars.dir}"/> + <if> + <or> + <not> + <available file="${classlib.jar}" /> + </not> + <uptodate srcfile="${classlib.jar}" targetfile="${root.dir}/all/lib/classlib.pack.gz"/> + </or> + <then> + <delete file="${classlib.jar}"/> + <echo message="Creating ${classlib.jar}"/> + <exec executable="unpack200"> + <arg file="${root.dir}/all/lib/classlib.pack.gz"/> + <arg file="${classlib.jar}"/> + </exec> + </then> + </if> + <property name="classlib.stamp" value="${root.dir}/all/build/classlib.stamp" /> + <if> + <or> + <not> + <available file="${classlib.stamp}" /> + </not> + <uptodate srcfile="${classlib.stamp}" targetfile="${classlib.jar}"/> + </or> + <then> + <unjar src="${classlib.jar}" dest="${jnode-core.jar}"/> + <touch file="${classlib.stamp}"/> + </then> + </if> </target> <!-- Call the assemble target of all subprojects --> Property changes on: trunk/all/lib ___________________________________________________________________ Added: svn:ignore + classlib.jar Added: trunk/all/lib/classlib.pack.gz =================================================================== (Binary files differ) Property changes on: trunk/all/lib/classlib.pack.gz ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/core/build.xml =================================================================== --- trunk/core/build.xml 2009-04-13 08:19:29 UTC (rev 5257) +++ trunk/core/build.xml 2009-04-13 08:34:39 UTC (rev 5258) @@ -141,15 +141,18 @@ <!-- Compile all subproject java files --> <target name="compile" depends="prepare"> + <!-- <jnode.compile> <src refid="classpath-sources" /> <classpath refid="my-cp"/> </jnode.compile> + --> <parallel > <jnode.compile> <src refid="my-sources" /> <classpath refid="my-cp"/> </jnode.compile> + <!-- <jnode.compile> <src refid="classpath-sources-corba" /> <classpath refid="my-cp"/> @@ -162,6 +165,7 @@ <src refid="classpath-sources-langtools" /> <classpath refid="my-cp"/> </jnode.compile> + --> </parallel> <!-- Copy all non java files to class dir --> @@ -190,7 +194,7 @@ <fileset dir="${my-src.dir}/driver" excludes="${my-non-resources}"/> <fileset dir="${my-src.dir}/test" excludes="${my-non-resources}"/> </copy> - + <!-- Create & compile plan classes --> <CreatePlan package="org.jnode.vm.memmgr.mmtk.genrc"/> <CreatePlan package="org.jnode.vm.memmgr.mmtk.ms"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-14 13:13:32
|
Revision: 5267 http://jnode.svn.sourceforge.net/jnode/?rev=5267&view=rev Author: chrisboertien Date: 2009-04-14 13:13:28 +0000 (Tue, 14 Apr 2009) Log Message: ----------- add classlib.jar to ignore Modified Paths: -------------- trunk/.cvsignore trunk/.gitignore Modified: trunk/.cvsignore =================================================================== --- trunk/.cvsignore 2009-04-14 13:02:59 UTC (rev 5266) +++ trunk/.cvsignore 2009-04-14 13:13:28 UTC (rev 5267) @@ -11,3 +11,4 @@ udpout.log local bin +classlib.jar Modified: trunk/.gitignore =================================================================== --- trunk/.gitignore 2009-04-14 13:02:59 UTC (rev 5266) +++ trunk/.gitignore 2009-04-14 13:13:28 UTC (rev 5267) @@ -6,3 +6,4 @@ *.patch jnode.properties local/ +classlib.jar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-04-15 14:01:15
|
Revision: 5282 http://jnode.svn.sourceforge.net/jnode/?rev=5282&view=rev Author: crawley Date: 2009-04-15 13:35:07 +0000 (Wed, 15 Apr 2009) Log Message: ----------- Fix eclipse configs so that JNode will build following last night's reorg. Modified Paths: -------------- trunk/builder/.classpath trunk/builder/.project trunk/core/.classpath trunk/core/.project trunk/distr/.classpath trunk/distr/.project trunk/fs/.classpath trunk/fs/.project trunk/gui/.classpath trunk/gui/.project trunk/net/.classpath trunk/net/.project trunk/shell/.classpath trunk/shell/.project trunk/textui/.classpath trunk/textui/.project Modified: trunk/builder/.classpath =================================================================== --- trunk/builder/.classpath 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/builder/.classpath 2009-04-15 13:35:07 UTC (rev 5282) @@ -10,5 +10,6 @@ <classpathentry kind="lib" path="lib/xml-apis.jar"/> <classpathentry kind="lib" path="lib/bcel-5.1.jar"/> <classpathentry kind="lib" path="/shell/lib/nanoxml-2.2.3.jar"/> + <classpathentry kind="lib" path="/all/lib/classlib.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/builder/.project =================================================================== --- trunk/builder/.project 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/builder/.project 2009-04-15 13:35:07 UTC (rev 5282) @@ -3,6 +3,7 @@ <name>builder</name> <comment></comment> <projects> + <project>all</project> <project>JNode-Core</project> <project>JNode-FS</project> </projects> Modified: trunk/core/.classpath =================================================================== --- trunk/core/.classpath 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/core/.classpath 2009-04-15 13:35:07 UTC (rev 5282) @@ -2,19 +2,8 @@ <classpath> <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/vm"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/classlib"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/svm"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/emu"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/endorsed/nanoxml"/> - <classpathentry excluding="**/*-template.java|**/.svn/**" kind="src" path="src/openjdk/sun"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/org"/> - <classpathentry excluding="**/*-template.java|**/.svn/**" kind="src" path="src/openjdk/com"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/icedtea"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/gnu"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/java"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/openjdk/javax"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/tools"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/java"/> - <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/javax"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/ext"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/classpath/vm"/> <classpathentry excluding="**/.svn/**" kind="src" path="src/core"/> @@ -37,5 +26,6 @@ </accessrules> </classpathentry> <classpathentry kind="lib" path="lib/ant-contrib-1.0b3.jar"/> + <classpathentry kind="lib" path="/all/lib/classlib.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/core/.project =================================================================== --- trunk/core/.project 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/core/.project 2009-04-15 13:35:07 UTC (rev 5282) @@ -3,6 +3,7 @@ <name>core</name> <comment></comment> <projects> + <project>all</project> </projects> <buildSpec> <buildCommand> Modified: trunk/distr/.classpath =================================================================== --- trunk/distr/.classpath 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/distr/.classpath 2009-04-15 13:35:07 UTC (rev 5282) @@ -21,5 +21,6 @@ <classpathentry kind="lib" path="lib/derbynet.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/> + <classpathentry kind="lib" path="/all/lib/classlib.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/distr/.project =================================================================== --- trunk/distr/.project 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/distr/.project 2009-04-15 13:35:07 UTC (rev 5282) @@ -3,6 +3,7 @@ <name>distr</name> <comment></comment> <projects> + <project>all</project> <project>JNode-Core</project> <project>JNode-GUI</project> <project>JNode-Shell</project> Modified: trunk/fs/.classpath =================================================================== --- trunk/fs/.classpath 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/fs/.classpath 2009-04-15 13:35:07 UTC (rev 5282) @@ -16,5 +16,6 @@ <classpathentry kind="lib" path="/core/lib/jmock-cglib-1.0.1.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/> + <classpathentry kind="lib" path="/all/lib/classlib.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/fs/.project =================================================================== --- trunk/fs/.project 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/fs/.project 2009-04-15 13:35:07 UTC (rev 5282) @@ -3,6 +3,7 @@ <name>fs</name> <comment></comment> <projects> + <project>all</project> <project>JNode-Core</project> <project>JNode-Shell</project> </projects> Modified: trunk/gui/.classpath =================================================================== --- trunk/gui/.classpath 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/gui/.classpath 2009-04-15 13:35:07 UTC (rev 5282) @@ -9,5 +9,6 @@ <classpathentry kind="src" path="/core"/> <classpathentry kind="src" path="/shell"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> + <classpathentry kind="lib" path="/all/lib/classlib.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/gui/.project =================================================================== --- trunk/gui/.project 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/gui/.project 2009-04-15 13:35:07 UTC (rev 5282) @@ -3,6 +3,7 @@ <name>gui</name> <comment></comment> <projects> + <project>all</project> <project>JNode-Core</project> <project>JNode-Shell</project> </projects> Modified: trunk/net/.classpath =================================================================== --- trunk/net/.classpath 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/net/.classpath 2009-04-15 13:35:07 UTC (rev 5282) @@ -11,5 +11,6 @@ <classpathentry kind="lib" path="/core/lib/commons-net-1.1.0.jar"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/> + <classpathentry kind="lib" path="/all/lib/classlib.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/net/.project =================================================================== --- trunk/net/.project 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/net/.project 2009-04-15 13:35:07 UTC (rev 5282) @@ -3,6 +3,7 @@ <name>net</name> <comment></comment> <projects> + <project>all</project> <project>JNode-Core</project> <project>JNode-Shell</project> </projects> Modified: trunk/shell/.classpath =================================================================== --- trunk/shell/.classpath 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/shell/.classpath 2009-04-15 13:35:07 UTC (rev 5282) @@ -11,5 +11,6 @@ <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> <classpathentry kind="lib" path="lib/nanoxml-2.2.3.jar"/> <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/> + <classpathentry kind="lib" path="/all/lib/classlib.jar" sourcepath="/all/lib/classlib.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/shell/.project =================================================================== --- trunk/shell/.project 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/shell/.project 2009-04-15 13:35:07 UTC (rev 5282) @@ -3,6 +3,7 @@ <name>shell</name> <comment></comment> <projects> + <project>all</project> <project>JNode-Core</project> </projects> <buildSpec> Modified: trunk/textui/.classpath =================================================================== --- trunk/textui/.classpath 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/textui/.classpath 2009-04-15 13:35:07 UTC (rev 5282) @@ -4,5 +4,6 @@ <classpathentry exported="true" kind="src" path="/core"/> <classpathentry exported="true" kind="src" path="/shell"/> <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/> + <classpathentry kind="lib" path="/all/lib/classlib.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> Modified: trunk/textui/.project =================================================================== --- trunk/textui/.project 2009-04-15 13:34:58 UTC (rev 5281) +++ trunk/textui/.project 2009-04-15 13:35:07 UTC (rev 5282) @@ -3,6 +3,7 @@ <name>textui</name> <comment></comment> <projects> + <project>all</project> <project>JNode-Core</project> <project>JNode-Shell</project> </projects> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |