diff options
author | dnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-11-06 12:21:53 +0000 |
---|---|---|
committer | dnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-11-06 12:21:53 +0000 |
commit | fbe5f9bad121c7b7841bfa83412e116e406d4c4b (patch) | |
tree | 7c4d00ba06963543ca5f09366e74c7881ef7b36c /libjava | |
parent | 30b2dbfc8344e6862e9213688a8eb848ffebecaa (diff) |
Merge with basic-improvements as of 2002-11-05.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@58858 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
36 files changed, 690 insertions, 372 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 4db95b01eea..0ec5797d2b4 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,176 @@ +2002-11-04 R. A. Rivas Diaz <rivasdiaz@yahoo.com> + + * gnu/java/security/provider/SHA.java (engineGetDigestLength): + Return 20. + * gnu/java/security/provider/MD5.java (engineGetDigestLength): + Return 16. + +2002-11-03 Tom Tromey <tromey@redhat.com> + + * java/lang/ClassLoader.java (loadClass): Call loadClass on + VMClassLoader, not findClass. + +2002-11-03 Jeff Sturm <jsturm@one-point.com> + + * resolve.cc (METHOD_NOT_THERE, METHOD_INACCESSIBLE): Remove. + (_Jv_ResolvePoolEntry): Use _Jv_Method.index, not + _Jv_DetermineVTableIndex, to determine vtable offset. + (_Jv_DetermineVTableIndex): Remove. + (_Jv_PrepareClass): Don't layout vtable. Use _Jv_MakeVTable instead. + + * java/lang/Class.h (friend int _Jv_DetermineVTableIndex): Remove. + +2002-11-03 Tom Tromey <tromey@redhat.com> + + * java/nio/channels/AlreadyConnectedException.java: Extend + IllegalStateException, per spec. + +2002-10-31 Stephen Crawley <crawley@dstc.edu.au> + + * java/lang/Double.java (valueOf): Return new Double(parseDouble(s)). + +2002-10-31 Wu Gansha <gansha.wu@intel.com>: + + * java/util/ArrayList.java (readObject, writeObject): Only read/write + size items. + +2002-10-31 Wu Gansha <gansha.wu@intel.com>: + + * java/io/DataInputStream.java (convertFromUTF): Give StringBuffer an + initial estimated size to avoid enlarge buffer frequently. + +2002-10-31 Wu Gansha <gansha.wu@intel.com>: + + * java/lang/reflect/Proxy.java (ProxyType): Set loader to System + ClassLoader when null. + (ProxyType.hashCode): Loader null check no longer needed. + (ProxyType.sameTypes): New method. + (ProxyType.equals): Use new method. + +2002-10-31 Mark Wielaard <mark@klomp.org> + + * java/net/URLDecoder.java (decode): Initialize Stringbuffer size to + length of String. + * java/net/URLEncoder.java (encode): Likewise. + +2002-10-31 Mark Wielaard <mark@klomp.org> + + * java/util/zip/ZipInputStream.java (getNextEntry): Throw IOException + when stream is closed. + (closeEntry): Likewise. + (read): Likewise. + * java/util/zip/ZipOutputStream.java (putNextEntry): Throw + ZipException when no entry active. + (closeEntry): Likewise. + (write): Likewise. + +2002-11-02 Tom Tromey <tromey@redhat.com> + + * java/lang/Class.h: Move JV_STATE_ERROR before JV_STATE_DONE. + * java/lang/natClass.cc (initializeClass): Don't return just + because self==thread. + + For PR java/8415: + * java/lang/reflect/natMethod.cc (getType): Use _Jv_FindClass. + * prims.cc (_Jv_FindClassFromSignature): Indentation fix. + +2002-11-02 Andreas Schwab <schwab@suse.de> + + * Makefile.am (AM_MAKEFLAGS): Don't pass JC1FLAGS, CC and CXX, do + pass GCJFLAGS. + (FLAGS_TO_PASS): Define. + * Makefile.in: Regenerated. + +2002-11-01 Michael Koch <konqueror@gmx.de> + + * java/nio/ByteOrder.java: New file. + * java/nio/channels/DatagramChannel.java: + (DatagramChannel): New constructor. + * java/nio/channels/Pipe.java: New file. + * java/nio/channels/SelectableChannel.java: New file. + * java/nio/channels/SelectionKey.java: New file. + * java/nio/channels/Selector.java: New file. + * java/nio/channels/ServerSocketChannel.java + (ServerSocketChannel): New constructor. + * java/nio/channels/SocketChannel.java + (SocketChannel): New constructor. + * java/nio/channels/Pipe.java: New file. + * java/nio/channels/spi/AbstractChannel.java: New file. + * java/nio/channels/spi/AbstractInterruptibleChannel.java: New file. + * java/nio/channels/spi/AbstractSelectableChannel.java: + License added + (AbstractSelectableChannel): New stubbed method. + * java/nio/channels/spi/AbstractSelectionKey.java: New file. + * java/nio/channels/spi/AbstractSelector.java: New file. + * java/nio/channels/spi/SelectorProvider.java: New file. + * java/nio/charset/Charset.java: New file. + * java/nio/charset/CoderMalfunctionError.java: New file. + * java/nio/charset/CodingErrorAction.java: New file. + * java/nio/charset/spi/CharsetProvider.java + (charsetForName): Uncommented. + * Makefile.am (java_native_source_files): Added new files. + * Makefile.in: Regenerated. + +2002-11-01 Michael Koch <konqueror@gmx.de> + + * java/net/InetAddress.java: + (isAnyLocalAddress): Implemented. + (isLoopbackAddress): Implemented, comment added. + (isLinkLocalAddress): Implemented, documentation added. + (isSiteLocalAddress): Implemented, documentation added. + (isMCGlobal): Implemented, documentation added. + (isMCNodeLocal): Implemented, documentation added. + (isMCLinkLocal): Implemented, documentation added. + (isMCSiteLocal): Implemented, documentation added. + (isMCOrgLocal): Implemented, documentation added. + (getHostName): Documentation added. + (getCanonicalHostName): Implemented, documentation added. + (getAddress): Documentation added. + (hashCode): Documentation added. + (equals): Documentation added. + (toString): Fixed implementation. + (getByAddress): Use Inet4Address and Inet6Address. + (lookup): New linewrap. + (getByName): SecurityManager check added, support Inet4Address and + Inet6address, comments added. + (getAllByName): SecurityManager check added, comments added. + * java/net/Inet6Address.java: + (Inet6Address): Initialize parent class with addr instead of null. + * java/net/URL.java + (equals): Documentation added. + (getFile): Documentation added. + (hashCode): Documentation added. + * java/net/natInetAddress.cc: + (aton): Fix IPv6 support. + * java/net/natPlainDatagramSocketImpl.cc: + (peek): Throw PortUnreachableException when suitable. + (peekData): Throw PortUnreachableException when suitable. + (send): Throw PortUnreachableException when suitable. + (receive): Throw PortUnreachableException when suitable. + +2002-10-27 Mark Wielaard <mark@klomp.org> + + * java/util/zip/ZipFile.java (readLeShort): Take and use DataInput as + argument. + (readLeShort): Likewise and use byte[]. + (readLeInt): Likewise. + (readEntries): Use new versions of methods and use byte[] for reading + a complete zip entry. Add ZipFile name to exceptions. + (entries): Add ZipFile name to exceptions. + (getEntry): Likewise. + (checkLocalHeader): Use new versions of methods and add ZipFile name + to exceptions. + +2002-10-31 Mark Anderson <mark@panonet.net> + + * java/awt/GridBagLayout.java (setConstraints): New stubbed method + added + +2002-10-25 Krister Walfridsson <cato@df.lth.se> + + * configure.in: Disable hash sync when not using threads. + * configure: Regenerated. + 2002-10-24 Tom Tromey <tromey@redhat.com> * java/lang/natRuntime.cc (_Jv_SetDLLSearchPath): New function. diff --git a/libjava/Makefile.am b/libjava/Makefile.am index bbcd51d8e38..861b5ab211c 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -1958,6 +1958,7 @@ java/net/UnknownHostException.java \ java/net/UnknownServiceException.java \ java/nio/Buffer.java \ java/nio/ByteBuffer.java \ +java/nio/ByteOrder.java \ java/nio/MappedByteBuffer.java \ java/nio/channels/AlreadyConnectedException.java \ java/nio/channels/ByteChannel.java \ @@ -1967,13 +1968,25 @@ java/nio/channels/DatagramChannel.java \ java/nio/channels/GatheringByteChannel.java \ java/nio/channels/IllegalBlockingModeException.java \ java/nio/channels/InterruptibleChannel.java \ +java/nio/channels/Pipe.java \ java/nio/channels/ReadableByteChannel.java \ java/nio/channels/ScatteringByteChannel.java \ +java/nio/channels/SelectableChannel.java \ +java/nio/channels/SelectionKey.java \ +java/nio/channels/Selector.java \ java/nio/channels/ServerSocketChannel.java \ java/nio/channels/SocketChannel.java \ java/nio/channels/WritableByteChannel.java \ java/nio/channels/spi/AbstractSelectableChannel.java \ +java/nio/channels/spi/AbstractChannel.java \ +java/nio/channels/spi/AbstractInterruptibleChannel.java \ +java/nio/channels/spi/AbstractSelectionKey.java \ +java/nio/channels/spi/AbstractSelector.java \ +java/nio/channels/spi/SelectorProvider.java \ +java/nio/charset/Charset.java \ java/nio/charset/CharacterCodingException.java \ +java/nio/charset/CoderMalfunctionError.java \ +java/nio/charset/CodingErrorAction.java \ java/nio/charset/IllegalCharsetNameException.java \ java/nio/charset/MalformedInputException.java \ java/nio/charset/UnmappableCharacterException.java \ @@ -2435,7 +2448,7 @@ AM_MAKEFLAGS = \ "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \ - "JC1FLAGS=$(JC1FLAGS)" \ + "GCJFLAGS=$(GCJFLAGS)" \ "LDFLAGS=$(LDFLAGS)" \ "LIBCFLAGS=$(LIBCFLAGS)" \ "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \ @@ -2451,8 +2464,6 @@ AM_MAKEFLAGS = \ "prefix=$(prefix)" \ "AR=$(AR)" \ "AS=$(AS)" \ - "CC=$(CC)" \ - "CXX=$(CXX)" \ "LD=$(LD)" \ "LIBCFLAGS=$(LIBCFLAGS)" \ "NM=$(NM)" \ @@ -2460,6 +2471,9 @@ AM_MAKEFLAGS = \ "RANLIB=$(RANLIB)" \ "DESTDIR=$(DESTDIR)" +# Subdir rules rely on $(FLAGS_TO_PASS) +FLAGS_TO_PASS = $(AM_MAKEFLAGS) + CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.host MAKEOVERRIDES= diff --git a/libjava/Makefile.in b/libjava/Makefile.in index b45966030c4..cd06f284648 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -1708,6 +1708,7 @@ java/net/UnknownHostException.java \ java/net/UnknownServiceException.java \ java/nio/Buffer.java \ java/nio/ByteBuffer.java \ +java/nio/ByteOrder.java \ java/nio/MappedByteBuffer.java \ java/nio/channels/AlreadyConnectedException.java \ java/nio/channels/ByteChannel.java \ @@ -1717,13 +1718,25 @@ java/nio/channels/DatagramChannel.java \ java/nio/channels/GatheringByteChannel.java \ java/nio/channels/IllegalBlockingModeException.java \ java/nio/channels/InterruptibleChannel.java \ +java/nio/channels/Pipe.java \ java/nio/channels/ReadableByteChannel.java \ java/nio/channels/ScatteringByteChannel.java \ +java/nio/channels/SelectableChannel.java \ +java/nio/channels/SelectionKey.java \ +java/nio/channels/Selector.java \ java/nio/channels/ServerSocketChannel.java \ java/nio/channels/SocketChannel.java \ java/nio/channels/WritableByteChannel.java \ java/nio/channels/spi/AbstractSelectableChannel.java \ +java/nio/channels/spi/AbstractChannel.java \ +java/nio/channels/spi/AbstractInterruptibleChannel.java \ +java/nio/channels/spi/AbstractSelectionKey.java \ +java/nio/channels/spi/AbstractSelector.java \ +java/nio/channels/spi/SelectorProvider.java \ +java/nio/charset/Charset.java \ java/nio/charset/CharacterCodingException.java \ +java/nio/charset/CoderMalfunctionError.java \ +java/nio/charset/CodingErrorAction.java \ java/nio/charset/IllegalCharsetNameException.java \ java/nio/charset/MalformedInputException.java \ java/nio/charset/UnmappableCharacterException.java \ @@ -2125,7 +2138,7 @@ AM_MAKEFLAGS = \ "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \ - "JC1FLAGS=$(JC1FLAGS)" \ + "GCJFLAGS=$(GCJFLAGS)" \ "LDFLAGS=$(LDFLAGS)" \ "LIBCFLAGS=$(LIBCFLAGS)" \ "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \ @@ -2141,8 +2154,6 @@ AM_MAKEFLAGS = \ "prefix=$(prefix)" \ "AR=$(AR)" \ "AS=$(AS)" \ - "CC=$(CC)" \ - "CXX=$(CXX)" \ "LD=$(LD)" \ "LIBCFLAGS=$(LIBCFLAGS)" \ "NM=$(NM)" \ @@ -2151,6 +2162,9 @@ AM_MAKEFLAGS = \ "DESTDIR=$(DESTDIR)" +# Subdir rules rely on $(FLAGS_TO_PASS) +FLAGS_TO_PASS = $(AM_MAKEFLAGS) + CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.host MAKEOVERRIDES = @@ -2959,7 +2973,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/net/natInetAddress.P .deps/java/net/natNetworkInterface.P \ .deps/java/net/natPlainDatagramSocketImpl.P \ .deps/java/net/natPlainSocketImpl.P .deps/java/nio/Buffer.P \ -.deps/java/nio/ByteBuffer.P .deps/java/nio/MappedByteBuffer.P \ +.deps/java/nio/ByteBuffer.P .deps/java/nio/ByteOrder.P \ +.deps/java/nio/MappedByteBuffer.P \ .deps/java/nio/channels/AlreadyConnectedException.P \ .deps/java/nio/channels/ByteChannel.P .deps/java/nio/channels/Channel.P \ .deps/java/nio/channels/ClosedChannelException.P \ @@ -2967,13 +2982,25 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/nio/channels/GatheringByteChannel.P \ .deps/java/nio/channels/IllegalBlockingModeException.P \ .deps/java/nio/channels/InterruptibleChannel.P \ +.deps/java/nio/channels/Pipe.P \ .deps/java/nio/channels/ReadableByteChannel.P \ .deps/java/nio/channels/ScatteringByteChannel.P \ +.deps/java/nio/channels/SelectableChannel.P \ +.deps/java/nio/channels/SelectionKey.P \ +.deps/java/nio/channels/Selector.P \ .deps/java/nio/channels/ServerSocketChannel.P \ .deps/java/nio/channels/SocketChannel.P \ .deps/java/nio/channels/WritableByteChannel.P \ +.deps/java/nio/channels/spi/AbstractChannel.P \ +.deps/java/nio/channels/spi/AbstractInterruptibleChannel.P \ .deps/java/nio/channels/spi/AbstractSelectableChannel.P \ +.deps/java/nio/channels/spi/AbstractSelectionKey.P \ +.deps/java/nio/channels/spi/AbstractSelector.P \ +.deps/java/nio/channels/spi/SelectorProvider.P \ .deps/java/nio/charset/CharacterCodingException.P \ +.deps/java/nio/charset/Charset.P \ +.deps/java/nio/charset/CoderMalfunctionError.P \ +.deps/java/nio/charset/CodingErrorAction.P \ .deps/java/nio/charset/IllegalCharsetNameException.P \ .deps/java/nio/charset/MalformedInputException.P \ .deps/java/nio/charset/UnmappableCharacterException.P \ diff --git a/libjava/configure b/libjava/configure index 514a1aa294e..4e34cc94706 100755 --- a/libjava/configure +++ b/libjava/configure @@ -3327,7 +3327,7 @@ if test -d sysdep; then true; else mkdir sysdep; fi HASH_SYNC_SPEC= # Hash synchronization is only useful with posix threads right now. -if test "$enable_hash_synchronization" = yes; then +if test "$enable_hash_synchronization" = yes && test "$THREADS" != "none"; then HASH_SYNC_SPEC=-fhash-synchronization cat >> confdefs.h <<\EOF #define JV_HASH_SYNCHRONIZATION 1 diff --git a/libjava/configure.in b/libjava/configure.in index e11928e70a4..59f821accce 100644 --- a/libjava/configure.in +++ b/libjava/configure.in @@ -445,7 +445,7 @@ AC_LINK_FILES(sysdep/$sysdeps_dir/locks.h, sysdep/locks.h) HASH_SYNC_SPEC= # Hash synchronization is only useful with posix threads right now. -if test "$enable_hash_synchronization" = yes; then +if test "$enable_hash_synchronization" = yes && test "$THREADS" != "none"; then HASH_SYNC_SPEC=-fhash-synchronization AC_DEFINE(JV_HASH_SYNCHRONIZATION, 1, [Define if hash synchronization is in use]) fi diff --git a/libjava/gnu/java/security/provider/MD5.java b/libjava/gnu/java/security/provider/MD5.java index 9a789dfa2e2..41956fc87e1 100644 --- a/libjava/gnu/java/security/provider/MD5.java +++ b/libjava/gnu/java/security/provider/MD5.java @@ -77,7 +77,7 @@ public class MD5 extends MessageDigest implements Cloneable public int engineGetDigestLength() { - return 20; + return 16; } // Intialize the A,B,C,D needed for the hash diff --git a/libjava/gnu/java/security/provider/SHA.java b/libjava/gnu/java/security/provider/SHA.java index 90459466a89..6b8d3ba5c1e 100644 --- a/libjava/gnu/java/security/provider/SHA.java +++ b/libjava/gnu/java/security/provider/SHA.java @@ -1,5 +1,5 @@ /* SHA.java -- Class implementing the SHA-1 algorithm as specified in [1]. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -58,7 +58,7 @@ public class SHA extends MessageDigest implements Cloneable public int engineGetDigestLength() { - return 16; + return 20; } public void engineUpdate (byte b) diff --git a/libjava/java/awt/GridBagLayout.java b/libjava/java/awt/GridBagLayout.java index 29e1beac43d..e93d6b1828c 100644 --- a/libjava/java/awt/GridBagLayout.java +++ b/libjava/java/awt/GridBagLayout.java @@ -89,4 +89,8 @@ public class GridBagLayout public void invalidateLayout(Container target) { } + + public void setConstraints(Component comp, GridBagConstraints constraints) + { + } } diff --git a/libjava/java/io/DataInputStream.java b/libjava/java/io/DataInputStream.java index 1223e3e7fe5..52c0c7a7b82 100644 --- a/libjava/java/io/DataInputStream.java +++ b/libjava/java/io/DataInputStream.java @@ -734,7 +734,9 @@ public class DataInputStream extends FilterInputStream implements DataInput static String convertFromUTF(byte[] buf) throws EOFException, UTFDataFormatException { - StringBuffer strbuf = new StringBuffer(); + // Give StringBuffer an initial estimated size to avoid + // enlarge buffer frequently + StringBuffer strbuf = new StringBuffer(buf.length/2 + 2); for (int i = 0; i < buf.length; ) { diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index 9a8d4183b6f..bd2903d47cf 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -46,9 +46,10 @@ enum JV_STATE_LINKED = 9, // Strings interned. JV_STATE_IN_PROGRESS = 10, // <Clinit> running. - JV_STATE_DONE = 12, // - JV_STATE_ERROR = 14 // must be last. + JV_STATE_ERROR = 12, + + JV_STATE_DONE = 14 // Must be last. }; struct _Jv_Field; @@ -330,8 +331,6 @@ private: #ifdef INTERPRETER friend jboolean _Jv_IsInterpretedClass (jclass); friend void _Jv_InitField (jobject, jclass, _Jv_Field*); - friend int _Jv_DetermineVTableIndex (jclass, _Jv_Utf8Const *, - _Jv_Utf8Const*); friend void _Jv_InitField (jobject, jclass, int); friend _Jv_word _Jv_ResolvePoolEntry (jclass, int); friend _Jv_Method *_Jv_SearchMethodInClass (jclass cls, jclass klass, diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java index 2c0e21133d9..1b3b310cab3 100644 --- a/libjava/java/lang/ClassLoader.java +++ b/libjava/java/lang/ClassLoader.java @@ -177,14 +177,18 @@ public abstract class ClassLoader if (c == null) { - try { - if (parent != null) - return parent.loadClass (name, link); - else - c = gnu.gcj.runtime.VMClassLoader.instance.findClass (name); - } catch (ClassNotFoundException ex) { - /* ignore, we'll try findClass */; - } + try + { + ClassLoader cl = parent; + if (parent == null) + cl = gnu.gcj.runtime.VMClassLoader.instance; + if (cl != this) + c = cl.loadClass (name, link); + } + catch (ClassNotFoundException ex) + { + /* ignore, we'll try findClass */; + } } if (c == null) diff --git a/libjava/java/lang/Double.java b/libjava/java/lang/Double.java index 22f2b5f524a..199f64ee5b8 100644 --- a/libjava/java/lang/Double.java +++ b/libjava/java/lang/Double.java @@ -191,10 +191,7 @@ public final class Double extends Number implements Comparable */ public static Double valueOf(String s) { - // XXX just call new Double(parseDouble(s)); - if (s == null) - throw new NullPointerException(); - return new Double(s); + return new Double(parseDouble(s)); } /** diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc index fca074152ce..9e861111563 100644 --- a/libjava/java/lang/natClass.cc +++ b/libjava/java/lang/natClass.cc @@ -741,9 +741,7 @@ java::lang::Class::initializeClass (void) wait (); // Steps 3 & 4. - if (state == JV_STATE_DONE - || state == JV_STATE_IN_PROGRESS - || thread == self) + if (state == JV_STATE_DONE || state == JV_STATE_IN_PROGRESS) { _Jv_MonitorExit (this); return; diff --git a/libjava/java/lang/reflect/Proxy.java b/libjava/java/lang/reflect/Proxy.java index 972ac19c37a..82cf3722263 100644 --- a/libjava/java/lang/reflect/Proxy.java +++ b/libjava/java/lang/reflect/Proxy.java @@ -462,7 +462,6 @@ public class Proxy implements Serializable private static native Class generateProxyClass0(ClassLoader loader, ProxyData data); - /** * Helper class for mapping unique ClassLoader and interface combinations * to proxy classes. @@ -490,6 +489,8 @@ public class Proxy implements Serializable */ ProxyType(ClassLoader loader, Class[] interfaces) { + if (loader == null) + loader = ClassLoader.getSystemClassLoader(); this.loader = loader; this.interfaces = interfaces; } @@ -501,12 +502,56 @@ public class Proxy implements Serializable */ public int hashCode() { - int hash = (loader == null) ? 0 : loader.hashCode(); + //loader is always not null + int hash = loader.hashCode(); for (int i = 0; i < interfaces.length; i++) hash = hash * 31 + interfaces[i].hashCode(); return hash; } + // A more comprehensive comparison of two arrays, + // ignore array element order, and + // ignore redundant elements + private static boolean sameTypes(Class arr1[], Class arr2[]) { + if (arr1.length == 1 && arr2.length == 1) { + return arr1[0] == arr2[0]; + } + + // total occurrance of elements of arr1 in arr2 + int total_occ_of_arr1_in_arr2 = 0; + each_type: + for (int i = arr1.length; --i >= 0; ) + { + Class t = arr1[i]; + for (int j = i; --j >= 0; ) + { + if (t == arr1[j]) + { //found duplicate type + continue each_type; + } + } + + // count c(a unique element of arr1)'s + // occurrences in arr2 + int occ_in_arr2 = 0; + for (int j = arr2.length; --j >= 0; ) + { + if (t == arr2[j]) + { + ++occ_in_arr2; + } + } + if (occ_in_arr2 == 0) + { // t does not occur in arr2 + return false; + } + + total_occ_of_arr1_in_arr2 += occ_in_arr2; + } + // now, each element of arr2 must have been visited + return total_occ_of_arr1_in_arr2 == arr2.length; + } + /** * Calculates equality. * @@ -518,15 +563,10 @@ public class Proxy implements Serializable ProxyType pt = (ProxyType) other; if (loader != pt.loader || interfaces.length != pt.interfaces.length) return false; - int i = interfaces.length; - while (--i >= 0) - if (interfaces[i] != pt.interfaces[i]) - return false; - return true; + return sameTypes(interfaces, pt.interfaces); } } // class ProxyType - /** * Helper class which allows hashing of a method name and signature * without worrying about return type, declaring class, or throws clause, @@ -681,7 +721,6 @@ public class Proxy implements Serializable } } // class ProxySignature - /** * A flat representation of all data needed to generate bytecode/instantiate * a proxy class. This is basically a struct. @@ -820,7 +859,6 @@ public class Proxy implements Serializable } } // class ProxyData - /** * Does all the work of building a class. By making this a nested class, * this code is not loaded in memory if the VM has a native diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc index 95801e87570..9b697d25024 100644 --- a/libjava/java/lang/reflect/natMethod.cc +++ b/libjava/java/lang/reflect/natMethod.cc @@ -202,13 +202,12 @@ java::lang::reflect::Method::getType () } exception_types - = (JArray<jclass> *) JvNewObjectArray (count, - &java::lang::Class::class$, + = (JArray<jclass> *) JvNewObjectArray (count, &java::lang::Class::class$, NULL); jclass *elts = elements (exception_types); for (int i = 0; i < count; ++i) - elts[i] = _Jv_FindClassFromSignature (method->throws[i]->data, - declaringClass->getClassLoader ()); + elts[i] = _Jv_FindClass (method->throws[i], + declaringClass->getClassLoader ()); } void diff --git a/libjava/java/net/Inet6Address.java b/libjava/java/net/Inet6Address.java index de496b148ee..8d3c0c3af44 100644 --- a/libjava/java/net/Inet6Address.java +++ b/libjava/java/net/Inet6Address.java @@ -67,7 +67,7 @@ public final class Inet6Address extends InetAddress */ protected Inet6Address (byte[] addr, String host) { - super (null, host); + super (addr, host); this.ipaddress = addr; } diff --git a/libjava/java/net/InetAddress.java b/libjava/java/net/InetAddress.java index c4ea6efd0d9..c15c0f6dc41 100644 --- a/libjava/java/net/InetAddress.java +++ b/libjava/java/net/InetAddress.java @@ -113,8 +113,9 @@ public class InetAddress implements Serializable */ public boolean isAnyLocalAddress () { - // FIXME: implement this - return false; + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + return addr == zeros; } /** @@ -124,89 +125,169 @@ public class InetAddress implements Serializable */ public boolean isLoopbackAddress () { - // FIXME: implement this - return addr [0] == 0x7F; + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + + return addr[0] == 0x7F; } /** + * Utility routine to check if InetAddress is a link local address + * * @since 1.4 */ public boolean isLinkLocalAddress () { - // FIXME: implement this + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + + // XXX: This seems to not exist with IPv4 addresses return false; } /** + * Utility routine to check if InetAddress is a site local address + * * @since 1.4 */ public boolean isSiteLocalAddress () { - // FIXME: implement this + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + + // 10.0.0.0/8 + if (addr[0] == 0x0A) + return true; + + // XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here: + // it says 172.16.0.0 - 172.255.255.255 are site local addresses + + // 172.16.0.0/12 + if (addr[0] == 0xAC && (addr[1] & 0xF0) == 0x01) + return true; + + // 192.168.0.0/16 + if (addr[0] == 0xC0 && addr[1] == 0xA8) + return true; + + // XXX: Do we need to check more addresses here ? return false; } /** + * Utility routine to check if InetAddress is a global multicast address + * * @since 1.4 */ public boolean isMCGlobal () { - // FIXME: implement this + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + + // XXX: This seems to not exist with IPv4 addresses return false; } /** + * Utility reoutine to check if InetAddress is a node local multicast address + * * @since 1.4 */ public boolean isMCNodeLocal () { - // FIXME: implement this + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + + // XXX: This seems to not exist with IPv4 addresses return false; } /** + * Utility reoutine to check if InetAddress is a link local multicast address + * * @since 1.4 */ public boolean isMCLinkLocal () { - // FIXME: implement this - return false; + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + + if (!isMulticastAddress ()) + return false; + + return (addr[0] == 0xE0 + && addr[1] == 0x00 + && addr[2] == 0x00); } /** + * Utility reoutine to check if InetAddress is a site local multicast address + * * @since 1.4 */ public boolean isMCSiteLocal () { - // FIXME: implement this + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + + // XXX: This seems to not exist with IPv4 addresses return false; } /** + * Utility reoutine to check if InetAddress is a organization local + * multicast address + * * @since 1.4 */ public boolean isMCOrgLocal () { - // FIXME: implement this + // This is the IPv4 implementation. + // Any class derived from InetAddress should override this. + + // XXX: This seems to not exist with IPv4 addresses return false; } + /** + * Returns the hostname represented by this InetAddress + */ public String getHostName () { if (hostName == null) lookup (null, this, false); + return hostName; } /** + * Returns the canonical hostname represented by this InetAddress + * * @since 1.4 */ public String getCanonicalHostName () { - // FIXME: implement this - return ""; + SecurityManager sm = System.getSecurityManager (); + if (sm != null) + { + try + { + sm.checkConnect (hostName, -1); + } + catch (SecurityException e) + { + return getHostAddress (); + } + } + + // Try to find the FDQN now + InetAddress address = new InetAddress (getAddress (), null); + return address.getHostName (); } + /** + * Returns the IP address of this InetAddress as array of bytes + */ public byte[] getAddress () { // An experiment shows that JDK1.2 returns a different byte array each @@ -284,9 +365,13 @@ public class InetAddress implements Serializable break; sbuf.append('.'); } + return sbuf.toString(); } + /** + * Returns a hashcode of the InetAddress + */ public int hashCode() { // There hashing algorithm is not specified, but a simple experiment @@ -299,6 +384,9 @@ public class InetAddress implements Serializable return hash; } + /** + * Compares the InetAddress object with another one. + */ public boolean equals (Object obj) { if (obj == null || ! (obj instanceof InetAddress)) @@ -325,7 +413,12 @@ public class InetAddress implements Serializable */ public String toString() { - return getHostName()+'/'+getHostAddress(); + String hostname = getHostName (); + + if (hostname == "") + hostname = getHostAddress (); + + return hostname + '/' + getHostAddress (); } /** @@ -346,7 +439,10 @@ public class InetAddress implements Serializable if (addr.length != 4 && addr.length != 16) throw new UnknownHostException ("IP address has illegal length"); - return new InetAddress (addr, ""); + if (addr.length == 4) + return new Inet4Address (addr, null); + + return new Inet6Address (addr, null); } /** @@ -376,8 +472,8 @@ public class InetAddress implements Serializable * Otherwise, return null. */ private static native byte[] aton (String host); - private static native InetAddress[] lookup - (String hostname, InetAddress addr, boolean all); + private static native InetAddress[] lookup (String hostname, + InetAddress addr, boolean all); /** * Determines the IP address of a host, given the host's name. @@ -387,17 +483,43 @@ public class InetAddress implements Serializable * @exception SecurityException If a security manager exists and its * checkConnect method doesn't allow the operation */ - public static InetAddress getByName (String host) + public static InetAddress getByName (String hostname) throws UnknownHostException { - if (host == null) + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkConnect (hostname, -1); + + // Default to current host if necessary + if (hostname == null) return getLocalHost(); - byte[] address = aton(host); + + // Assume that the host string is an IP address + byte[] address = aton (hostname); if (address != null) - return new InetAddress(address, null); - InetAddress iaddr = new InetAddress(null, host); - lookup(host, iaddr, false); - return iaddr; + { + if (address.length == 4) + return new Inet4Address (address, null); + else if (address.length == 16) + { + if ((address[10] == 0xFF) && (address[11] == 0xFF)) + { + byte[] ip4addr = new byte[4]; + ip4addr[0] = address[12]; + ip4addr[1] = address[13]; + ip4addr[2] = address[14]; + ip4addr[3] = address[15]; + return new Inet4Address (ip4addr, null); + } + return new Inet6Address (address, null); + } + else + throw new UnknownHostException ("Address has invalid length"); + } + + // Try to resolve the host by DNS + InetAddress[] addresses = getAllByName (hostname); + return addresses[0]; } /** @@ -409,20 +531,28 @@ public class InetAddress implements Serializable * @exception SecurityException If a security manager exists and its * checkConnect method doesn't allow the operation */ - public static InetAddress[] getAllByName (String host) + public static InetAddress[] getAllByName (String hostname) throws UnknownHostException { - byte[] address = aton(host); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkConnect(hostname, -1); + + // Check if hostname is an IP address + byte[] address = aton (hostname); if (address != null) { InetAddress[] result = new InetAddress[1]; result[0] = new InetAddress(address, null); return result; } - return lookup(host, null, true); + + // Try to resolve the hostname by DNS + return lookup (hostname, null, true); } static final byte[] zeros = {0,0,0,0}; + /* dummy InetAddress, used to bind socket to any (all) network interfaces */ static final InetAddress ANY_IF = new InetAddress(zeros, null); diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java index b485c51231d..00dad2c7871 100644 --- a/libjava/java/net/URL.java +++ b/libjava/java/net/URL.java @@ -254,6 +254,9 @@ public final class URL implements Serializable hashCode = hashCode(); // Used for serialization. } + /** + * Checks if two URLs are equal + */ public boolean equals(Object obj) { if (obj == null || ! (obj instanceof URL)) @@ -287,6 +290,9 @@ public final class URL implements Serializable return getContent(); } + /** + * Returns the file of the URL + */ public String getFile() { return file; @@ -367,6 +373,9 @@ public final class URL implements Serializable return query; } + /** + * Returns a hashcode computed by the URLStreamHandler of this URL + */ public int hashCode() { // JCL book says this is computed using (only) the hashcodes of the diff --git a/libjava/java/net/URLDecoder.java b/libjava/java/net/URLDecoder.java index 8cdcf943825..36747409983 100644 --- a/libjava/java/net/URLDecoder.java +++ b/libjava/java/net/URLDecoder.java @@ -63,7 +63,7 @@ import java.io.UnsupportedEncodingException; public class URLDecoder { /** - * Constructor for compatibility with Sun's JDK. + * Public contructor. Note that this class has only static methods. */ public URLDecoder () { @@ -116,8 +116,6 @@ public class URLDecoder public static String decode(String s, String encoding) throws UnsupportedEncodingException { - StringBuffer result = new StringBuffer(); - // First convert all '+' characters to spaces. String str = s.replace('+', ' '); @@ -126,6 +124,7 @@ public class URLDecoder int start = 0; byte[] bytes = null; int length = str.length(); + StringBuffer result = new StringBuffer(length); while ((i = str.indexOf('%', start)) >= 0) { // Add all non-encoded characters to the result buffer diff --git a/libjava/java/net/URLEncoder.java b/libjava/java/net/URLEncoder.java index 345ef2404d5..0f106e820de 100644 --- a/libjava/java/net/URLEncoder.java +++ b/libjava/java/net/URLEncoder.java @@ -1,5 +1,5 @@ /* URLEncoder.java -- Class to convert strings to a properly encoded URL - Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,7 +39,7 @@ package java.net; import java.io.UnsupportedEncodingException; -/** +/* * Written using on-line Java Platform 1.2/1.4 API Specification, as well * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). * Status: Believed complete and correct. @@ -102,11 +102,11 @@ public class URLEncoder public static String encode(String s, String encoding) throws UnsupportedEncodingException { - StringBuffer result = new StringBuffer(); int length = s.length(); int start = 0; int i = 0; + StringBuffer result = new StringBuffer(length); while (true) { while ( i < length && isSafe(s.charAt(i)) ) diff --git a/libjava/java/net/natInetAddress.cc b/libjava/java/net/natInetAddress.cc index 15e5db732a2..c0083714287 100644 --- a/libjava/java/net/natInetAddress.cc +++ b/libjava/java/net/natInetAddress.cc @@ -121,7 +121,7 @@ java::net::InetAddress::aton (jstring host) #endif #if defined (HAVE_INET_PTON) && defined (HAVE_INET6) char inet6_addr[16]; - if (len == 0 && inet_pton (AF_INET6, hostname, inet6_addr) > 0) + if (len != 0 && inet_pton (AF_INET6, hostname, inet6_addr) > 0) { bytes = inet6_addr; blen = 16; diff --git a/libjava/java/net/natPlainDatagramSocketImpl.cc b/libjava/java/net/natPlainDatagramSocketImpl.cc index 84de798d944..60b25d22bfa 100644 --- a/libjava/java/net/natPlainDatagramSocketImpl.cc +++ b/libjava/java/net/natPlainDatagramSocketImpl.cc @@ -65,6 +65,7 @@ _Jv_bind (int fd, struct sockaddr *addr, int addrlen) #include <java/net/InetAddress.h> #include <java/net/NetworkInterface.h> #include <java/net/DatagramPacket.h> +#include <java/net/PortUnreachableException.h> #include <java/lang/InternalError.h> #include <java/lang/Object.h> #include <java/lang/Boolean.h> @@ -328,6 +329,8 @@ java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *i) return rport; error: char* strerr = strerror (errno); + if (errno == ECONNREFUSED) + throw new PortUnreachableException (JvNewStringUTF (strerr)); throw new java::io::IOException (JvNewStringUTF (strerr)); } @@ -390,6 +393,8 @@ java::net::PlainDatagramSocketImpl::peekData(java::net::DatagramPacket *p) return rport; error: char* strerr = strerror (errno); + if (errno == ECONNREFUSED) + throw new PortUnreachableException (JvNewStringUTF (strerr)); throw new java::io::IOException (JvNewStringUTF (strerr)); } @@ -441,6 +446,8 @@ java::net::PlainDatagramSocketImpl::send (java::net::DatagramPacket *p) return; char* strerr = strerror (errno); + if (errno == ECONNREFUSED) + throw new PortUnreachableException (JvNewStringUTF (strerr)); throw new java::io::IOException (JvNewStringUTF (strerr)); } @@ -503,6 +510,8 @@ java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *p) return; error: char* strerr = strerror (errno); + if (errno == ECONNREFUSED) + throw new PortUnreachableException (JvNewStringUTF (strerr)); throw new java::io::IOException (JvNewStringUTF (strerr)); } diff --git a/libjava/java/nio/channels/AlreadyConnectedException.java b/libjava/java/nio/channels/AlreadyConnectedException.java index 29e3cda0efa..3e3956b52b5 100644 --- a/libjava/java/nio/channels/AlreadyConnectedException.java +++ b/libjava/java/nio/channels/AlreadyConnectedException.java @@ -37,13 +37,11 @@ exception statement from your version. */ package java.nio.channels; -import java.io.IOException; +import java.io.*; -public class AlreadyConnectedException extends IOException + +public class AlreadyConnectedException extends IllegalStateException { - /** - * Creates the exception - */ public AlreadyConnectedException() { } diff --git a/libjava/java/nio/channels/DatagramChannel.java b/libjava/java/nio/channels/DatagramChannel.java index 74a26c64ec5..301f33e20a0 100644 --- a/libjava/java/nio/channels/DatagramChannel.java +++ b/libjava/java/nio/channels/DatagramChannel.java @@ -38,10 +38,13 @@ exception statement from your version. */ package java.nio.channels; import java.nio.channels.spi.AbstractSelectableChannel; +import java.nio.channels.spi.SelectorProvider; -public class DatagramChannel +public abstract class DatagramChannel extends AbstractSelectableChannel { + public DatagramChannel (SelectorProvider provider) + { + super (provider); + } } - - diff --git a/libjava/java/nio/channels/ServerSocketChannel.java b/libjava/java/nio/channels/ServerSocketChannel.java index e5d95c1bfbb..e423bd10b43 100644 --- a/libjava/java/nio/channels/ServerSocketChannel.java +++ b/libjava/java/nio/channels/ServerSocketChannel.java @@ -38,8 +38,13 @@ exception statement from your version. */ package java.nio.channels; import java.nio.channels.spi.AbstractSelectableChannel; +import java.nio.channels.spi.SelectorProvider; -public class ServerSocketChannel +public abstract class ServerSocketChannel extends AbstractSelectableChannel { + public ServerSocketChannel (SelectorProvider provider) + { + super (provider); + } } diff --git a/libjava/java/nio/channels/SocketChannel.java b/libjava/java/nio/channels/SocketChannel.java index 05fc8a55f63..dc6e1d2d96a 100644 --- a/libjava/java/nio/channels/SocketChannel.java +++ b/libjava/java/nio/channels/SocketChannel.java @@ -38,8 +38,13 @@ exception statement from your version. */ package java.nio.channels; import java.nio.channels.spi.AbstractSelectableChannel; +import java.nio.channels.spi.SelectorProvider; -public class SocketChannel +public abstract class SocketChannel extends AbstractSelectableChannel { + public SocketChannel (SelectorProvider provider) + { + super (provider); + } } diff --git a/libjava/java/nio/channels/spi/AbstractSelectableChannel.java b/libjava/java/nio/channels/spi/AbstractSelectableChannel.java index 99f7233f00b..42bb1f24bb4 100644 --- a/libjava/java/nio/channels/spi/AbstractSelectableChannel.java +++ b/libjava/java/nio/channels/spi/AbstractSelectableChannel.java @@ -1,7 +1,51 @@ +/* AbstractSelectableChannel.java -- + Copyright (C) 2002 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., 59 Temple Place, Suite 330, Boston, MA +02111-1307 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.channels.spi; +import java.nio.channels.SelectableChannel; + public abstract class AbstractSelectableChannel + extends SelectableChannel { + protected AbstractSelectableChannel (SelectorProvider provider) + { + } + public final boolean isBlocking() { return true; diff --git a/libjava/java/nio/charset/spi/CharsetProvider.java b/libjava/java/nio/charset/spi/CharsetProvider.java index 2eddf6161ea..32346a0457c 100644 --- a/libjava/java/nio/charset/spi/CharsetProvider.java +++ b/libjava/java/nio/charset/spi/CharsetProvider.java @@ -37,7 +37,7 @@ exception statement from your version. */ package java.nio.charset.spi; -//import java.nio.charset.Charset; +import java.nio.charset.Charset; import java.util.Iterator; /** @@ -84,5 +84,5 @@ public abstract class CharsetProvider * * @return the charset, or null if not supported */ - //public abstract Charset charsetForName(String name); + public abstract Charset charsetForName(String name); } // class CharsetProvider diff --git a/libjava/java/util/ArrayList.java b/libjava/java/util/ArrayList.java index 2d2146ddf59..c6f6b86991d 100644 --- a/libjava/java/util/ArrayList.java +++ b/libjava/java/util/ArrayList.java @@ -558,7 +558,9 @@ public class ArrayList extends AbstractList // We serialize unused list entries to preserve capacity. int len = data.length; s.writeInt(len); - for (int i = 0; i < len; i++) + // it would be more efficient to just write "size" items, + // this need readObject read "size" items too. + for (int i = 0; i < size; i++) s.writeObject(data[i]); } @@ -578,7 +580,7 @@ public class ArrayList extends AbstractList s.defaultReadObject(); int capacity = s.readInt(); data = new Object[capacity]; - for (int i = 0; i < capacity; i++) + for (int i = 0; i < size; i++) data[i] = s.readObject(); } } diff --git a/libjava/java/util/zip/ZipFile.java b/libjava/java/util/zip/ZipFile.java index 6dbed7cdaee..2eb1156d2bc 100644 --- a/libjava/java/util/zip/ZipFile.java +++ b/libjava/java/util/zip/ZipFile.java @@ -1,5 +1,5 @@ /* java.util.zip.ZipFile - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -36,6 +36,10 @@ 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.ByteArrayInputStream; +import java.io.DataInput; +import java.io.DataInputStream; import java.io.File; import java.io.InputStream; import java.io.IOException; @@ -102,9 +106,9 @@ public class ZipFile implements ZipConstants /** * Opens a Zip file reading the given File in the given mode. * - * If the OPEN_DELETE mode is specified, the zip file will be deleted at some time moment - * after it is opened. It will be deleted before the zip file is closed or the Virtual Machine - * exits. + * If the OPEN_DELETE mode is specified, the zip file will be deleted at + * some time moment after it is opened. It will be deleted before the zip + * file is closed or the Virtual Machine exits. * * The contents of the zip file will be accessible until it is closed. * @@ -121,7 +125,8 @@ public class ZipFile implements ZipConstants { if ((mode & OPEN_DELETE) != 0) { - throw new IllegalArgumentException("OPEN_DELETE mode not supported yet in java.util.zip.ZipFile"); + throw new IllegalArgumentException + ("OPEN_DELETE mode not supported yet in java.util.zip.ZipFile"); } this.raf = new RandomAccessFile(file, "r"); this.name = file.getName(); @@ -133,8 +138,11 @@ public class ZipFile implements ZipConstants * @exception IOException if a i/o error occured. * @exception EOFException if the file ends prematurely */ - private final int readLeShort() throws IOException { - return raf.readUnsignedByte() | raf.readUnsignedByte() << 8; + private final int readLeShort(DataInput di) throws IOException + { + byte[] b = new byte[2]; + di.readFully(b); + return (b[0] & 0xff) | (b[1] & 0xff) << 8; } /** @@ -142,8 +150,12 @@ public class ZipFile implements ZipConstants * @exception IOException if a i/o error occured. * @exception EOFException if the file ends prematurely */ - private final int readLeInt() throws IOException { - return readLeShort() | readLeShort() << 16; + private final int readLeInt(DataInput di) throws IOException + { + byte[] b = new byte[4]; + di.readFully(b); + return ((b[0] & 0xff) | (b[1] & 0xff) << 8) + | ((b[2] & 0xff) | (b[3] & 0xff) << 8) << 16; } /** @@ -164,36 +176,43 @@ public class ZipFile implements ZipConstants { if (pos < 0) throw new ZipException - ("central directory not found, probably not a zip file"); + ("central directory not found, probably not a zip file: " + name); raf.seek(pos--); } - while (readLeInt() != ENDSIG); + while (readLeInt(raf) != ENDSIG); if (raf.skipBytes(ENDTOT - ENDNRD) != ENDTOT - ENDNRD) - throw new EOFException(); - int count = readLeShort(); + throw new EOFException(name); + int count = readLeShort(raf); if (raf.skipBytes(ENDOFF - ENDSIZ) != ENDOFF - ENDSIZ) - throw new EOFException(); - int centralOffset = readLeInt(); + throw new EOFException(name); + int centralOffset = readLeInt(raf); entries = new ZipEntry[count]; raf.seek(centralOffset); + byte[] ebs = new byte[24]; + ByteArrayInputStream ebais = new ByteArrayInputStream(ebs); + DataInputStream edip = new DataInputStream(ebais); for (int i = 0; i < count; i++) { - if (readLeInt() != CENSIG) - throw new ZipException("Wrong Central Directory signature"); + if (readLeInt(raf) != CENSIG) + throw new ZipException("Wrong Central Directory signature: " + name); if (raf.skipBytes(CENHOW - CENVEM) != CENHOW - CENVEM) - throw new EOFException(); - int method = readLeShort(); - int dostime = readLeInt(); - int crc = readLeInt(); - int csize = readLeInt(); - int size = readLeInt(); - int nameLen = readLeShort(); - int extraLen = readLeShort(); - int commentLen = readLeShort(); + throw new EOFException(name); + + raf.readFully(ebs); + ebais.reset(); + int method = readLeShort(edip); + int dostime = readLeInt(edip); + int crc = readLeInt(edip); + int csize = readLeInt(edip); + int size = readLeInt(edip); + int nameLen = readLeShort(edip); + int extraLen = readLeShort(edip); + int commentLen = readLeShort(edip); + if (raf.skipBytes(CENOFF - CENDSK) != CENOFF - CENDSK) - throw new EOFException(); - int offset = readLeInt(); + throw new EOFException(name); + int offset = readLeInt(raf); byte[] buffer = new byte[Math.max(nameLen, commentLen)]; @@ -244,7 +263,7 @@ public class ZipFile implements ZipConstants public Enumeration entries() { if (entries == null) - throw new IllegalStateException("ZipFile has closed"); + throw new IllegalStateException("ZipFile has closed: " + name); return new ZipEntryEnumeration(entries); } @@ -265,7 +284,7 @@ public class ZipFile implements ZipConstants public ZipEntry getEntry(String name) { if (entries == null) - throw new IllegalStateException("ZipFile has closed"); + throw new IllegalStateException("ZipFile has closed: " + name); int index = getEntryIndex(name); return index >= 0 ? (ZipEntry) entries[index].clone() : null; } @@ -283,24 +302,24 @@ public class ZipFile implements ZipConstants synchronized (raf) { raf.seek(entry.offset); - if (readLeInt() != LOCSIG) - throw new ZipException("Wrong Local header signature"); + if (readLeInt(raf) != LOCSIG) + throw new ZipException("Wrong Local header signature: " + name); /* skip version and flags */ if (raf.skipBytes(LOCHOW - LOCVER) != LOCHOW - LOCVER) - throw new EOFException(); + throw new EOFException(name); - if (entry.getMethod() != readLeShort()) - throw new ZipException("Compression method mismatch"); + if (entry.getMethod() != readLeShort(raf)) + throw new ZipException("Compression method mismatch: " + name); /* Skip time, crc, size and csize */ if (raf.skipBytes(LOCNAM - LOCTIM) != LOCNAM - LOCTIM) - throw new EOFException(); + throw new EOFException(name); - if (entry.getName().length() != readLeShort()) - throw new ZipException("file name length mismatch"); + if (entry.getName().length() != readLeShort(raf)) + throw new ZipException("file name length mismatch: " + name); - int extraLen = entry.getName().length() + readLeShort(); + int extraLen = entry.getName().length() + readLeShort(raf); return entry.offset + LOCHDR + extraLen; } } diff --git a/libjava/java/util/zip/ZipInputStream.java b/libjava/java/util/zip/ZipInputStream.java index 710ca74c201..c9a6c0159e7 100644 --- a/libjava/java/util/zip/ZipInputStream.java +++ b/libjava/java/util/zip/ZipInputStream.java @@ -139,7 +139,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants public ZipEntry getNextEntry() throws IOException { if (crc == null) - throw new IllegalStateException("Closed."); + throw new IOException("Stream closed."); if (entry != null) closeEntry(); @@ -216,7 +216,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants public void closeEntry() throws IOException { if (crc == null) - throw new IllegalStateException("Closed."); + throw new IOException("Stream closed."); if (entry == null) return; @@ -287,7 +287,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants public int read(byte[] b, int off, int len) throws IOException { if (crc == null) - throw new IllegalStateException("Closed."); + throw new IOException("Stream closed."); if (entry == null) return -1; boolean finished = false; diff --git a/libjava/java/util/zip/ZipOutputStream.java b/libjava/java/util/zip/ZipOutputStream.java index e4fb864a955..44c4a9cc9b1 100644 --- a/libjava/java/util/zip/ZipOutputStream.java +++ b/libjava/java/util/zip/ZipOutputStream.java @@ -158,12 +158,12 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant * is not set in the entry, the current time is used. * @param entry the entry. * @exception IOException if an I/O error occured. - * @exception IllegalStateException if stream was finished + * @exception ZipException if stream was finished. */ public void putNextEntry(ZipEntry entry) throws IOException { if (entries == null) - throw new IllegalStateException("ZipOutputStream was finished"); + throw new ZipException("ZipOutputStream was finished"); int method = entry.getMethod(); int flags = 0; @@ -249,12 +249,12 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant /** * Closes the current entry. * @exception IOException if an I/O error occured. - * @exception IllegalStateException if no entry is active. + * @exception ZipException if no entry is active. */ public void closeEntry() throws IOException { if (curEntry == null) - throw new IllegalStateException("No open entry"); + throw new ZipException("No open entry"); /* First finish the deflater, if appropriate */ if (curMethod == DEFLATED) @@ -300,12 +300,12 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant /** * Writes the given buffer to the current entry. * @exception IOException if an I/O error occured. - * @exception IllegalStateException if no entry is active. + * @exception ZipException if no entry is active. */ public void write(byte[] b, int off, int len) throws IOException { if (curEntry == null) - throw new IllegalStateException("No open entry."); + throw new ZipException("No open entry."); switch (curMethod) { diff --git a/libjava/prims.cc b/libjava/prims.cc index 710139bab06..76c25877b7d 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -657,7 +657,6 @@ _Jv_FindClassFromSignature (char *sig, java::lang::ClassLoader *loader) ; _Jv_Utf8Const *name = _Jv_makeUtf8Const (&sig[1], i - 1); return _Jv_FindClass (name, loader); - } case '[': { diff --git a/libjava/resolve.cc b/libjava/resolve.cc index f3b98a7a348..e9fe4ad5af2 100644 --- a/libjava/resolve.cc +++ b/libjava/resolve.cc @@ -55,10 +55,6 @@ static void throw_class_format_error (jstring msg) static void throw_class_format_error (char *msg) __attribute__ ((__noreturn__)); -// Exceptional return values for _Jv_DetermineVTableIndex -#define METHOD_NOT_THERE (-2) -#define METHOD_INACCESSIBLE (-1) - static int get_alignment_from_class (jclass); static _Jv_ResolvedMethod* @@ -237,7 +233,6 @@ _Jv_ResolvePoolEntry (jclass klass, int index) _Jv_Utf8Const *method_name = pool->data[name_index].utf8; _Jv_Utf8Const *method_signature = pool->data[type_index].utf8; - int vtable_index = -1; _Jv_Method *the_method = 0; jclass found_class = 0; @@ -314,15 +309,9 @@ _Jv_ResolvePoolEntry (jclass klass, int index) throw new java::lang::NoSuchMethodError (sb->toString()); } - if (pool->tags[index] == JV_CONSTANT_InterfaceMethodref) - vtable_index = -1; - else - vtable_index = _Jv_DetermineVTableIndex (found_class, method_name, - method_signature); - - if (vtable_index == METHOD_NOT_THERE) - throw_incompatible_class_change_error - (JvNewStringLatin1 ("method not found")); + int vtable_index = -1; + if (pool->tags[index] != JV_CONSTANT_InterfaceMethodref) + vtable_index = (jshort)the_method->index; pool->data[index].rmethod = _Jv_BuildResolvedMethod(the_method, @@ -374,116 +363,6 @@ _Jv_SearchMethodInClass (jclass cls, jclass klass, return 0; } -/** FIXME: this is a terribly inefficient algorithm! It would improve - things if compiled classes to know vtable offset, and _Jv_Method had - a field for this. - - Returns METHOD_NOT_THERE if this class does not declare the given method. - Returns METHOD_INACCESSIBLE if the given method does not appear in the - vtable, i.e., it is static, private, final or a constructor. - Otherwise, returns the vtable index. */ -int -_Jv_DetermineVTableIndex (jclass klass, - _Jv_Utf8Const *name, - _Jv_Utf8Const *signature) -{ - using namespace java::lang::reflect; - - jclass super_class = klass->getSuperclass (); - - if (super_class != NULL) - { - int prev = _Jv_DetermineVTableIndex (super_class, - name, - signature); - if (prev != METHOD_NOT_THERE) - return prev; - } - - /* at this point, we know that the super-class does not declare - * the method. Otherwise, the above call would have found it, and - * determined the result of this function (-1 or some positive - * number). - */ - - _Jv_Method *meth = _Jv_GetMethodLocal (klass, name, signature); - - /* now, if we do not declare this method, return zero */ - if (meth == NULL) - return METHOD_NOT_THERE; - - /* so now, we know not only that the super class does not declare the - * method, but we do! So, this is a first declaration of the method. */ - - /* now, the checks for things that are declared in this class, but do - * not go into the vtable. There are three cases. - * 1) the method is static, private or final - * 2) the class itself is final, or - * 3) it is the method <init> - */ - - if ((meth->accflags & (Modifier::STATIC - | Modifier::PRIVATE - | Modifier::FINAL)) != 0 - || (klass->accflags & Modifier::FINAL) != 0 - || _Jv_equalUtf8Consts (name, init_name)) - return METHOD_INACCESSIBLE; - - /* reaching this point, we know for sure, that the method in question - * will be in the vtable. The question is where. */ - - /* the base offset, is where we will start assigning vtable - * indexes for this class. It is 0 for base classes - * and for non-base classes it is the - * number of entries in the super class' vtable. */ - - int base_offset; - if (super_class == 0) - base_offset = 0; - else - base_offset = super_class->vtable_method_count; - - /* we will consider methods 0..this_method_index-1. And for each one, - * determine if it is new (i.e., if it appears in the super class), - * and if it should go in the vtable. If so, increment base_offset */ - - int this_method_index = meth - (&klass->methods[0]); - - for (int i = 0; i < this_method_index; i++) - { - _Jv_Method *m = &klass->methods[i]; - - /* fist some checks for things that surely do not go in the - * vtable */ - - if ((m->accflags & (Modifier::STATIC | Modifier::PRIVATE)) != 0) - continue; - if (_Jv_equalUtf8Consts (m->name, init_name)) - continue; - - /* Then, we need to know if this method appears in the - superclass. (This is where this function gets expensive) */ - _Jv_Method *sm = _Jv_LookupDeclaredMethod (super_class, - m->name, - m->signature); - - /* if it was somehow declared in the superclass, skip this */ - if (sm != NULL) - continue; - - /* but if it is final, and not declared in the super class, - * then we also skip it */ - if ((m->accflags & Modifier::FINAL) != 0) - continue; - - /* finally, we can assign the index of this method */ - /* m->vtable_index = base_offset */ - base_offset += 1; - } - - return base_offset; -} - /* this is installed in place of abstract methods */ static void _Jv_abstractMethodError () @@ -651,107 +530,8 @@ _Jv_PrepareClass(jclass klass) return; } - /* Now onto the actual job: vtable layout. First, count how many new - methods we have */ - int new_method_count = 0; - - jclass super_class = clz->getSuperclass (); - - for (int i = 0; i < clz->method_count; i++) - { - _Jv_Method *this_meth = &clz->methods[i]; - - if ((this_meth->accflags & (Modifier::STATIC | Modifier::PRIVATE)) != 0 - || _Jv_equalUtf8Consts (this_meth->name, init_name)) - { - /* skip this, it doesn't go in the vtable */ - continue; - } - - _Jv_Method *orig_meth = _Jv_LookupDeclaredMethod (super_class, - this_meth->name, - this_meth->signature); - - if (orig_meth == 0) - { - // new methods that are final, also don't go in the vtable - if ((this_meth->accflags & Modifier::FINAL) != 0) - continue; - - new_method_count += 1; - continue; - } - - if ((orig_meth->accflags & (Modifier::STATIC - | Modifier::PRIVATE - | Modifier::FINAL)) != 0 - || ((orig_meth->accflags & Modifier::ABSTRACT) == 0 - && (this_meth->accflags & Modifier::ABSTRACT) != 0 - && (klass->accflags & Modifier::ABSTRACT) == 0)) - { - clz->state = JV_STATE_ERROR; - clz->notifyAll (); - throw new java::lang::IncompatibleClassChangeError (clz->getName ()); - } - - /* FIXME: At this point, if (loader != super_class->loader), we - * need to "impose class loader constraints" for the types - * involved in the signature of this method */ - } - - /* determine size */ - int vtable_count = (super_class->vtable_method_count) + new_method_count; - clz->vtable_method_count = vtable_count; - - /* allocate vtable structure */ - _Jv_VTable *vtable = _Jv_VTable::new_vtable (vtable_count); - vtable->clas = clz; - vtable->gc_descr = _Jv_BuildGCDescr(clz); - - { - jclass effective_superclass = super_class; - - /* If super_class is abstract or an interface it has no vtable. - We need to find a real one... */ - while (effective_superclass && effective_superclass->vtable == NULL) - effective_superclass = effective_superclass->superclass; - - /* If we ended up without a superclass, use Object. */ - if (! effective_superclass) - effective_superclass = &java::lang::Object::class$; - - /* copy super class' vtable entries. */ - if (effective_superclass && effective_superclass->vtable) - for (int i = 0; i < effective_superclass->vtable_method_count; ++i) - vtable->set_method (i, effective_superclass->vtable->get_method (i)); - } - - /* now, install our own vtable entries, reprise... */ - for (int i = 0; i < clz->method_count; i++) - { - _Jv_Method *this_meth = &clz->methods[i]; - - int index = _Jv_DetermineVTableIndex (clz, - this_meth->name, - this_meth->signature); - - if (index == METHOD_NOT_THERE) - throw_internal_error ("method now found in own class"); - - if (index != METHOD_INACCESSIBLE) - { - if (index > clz->vtable_method_count) - throw_internal_error ("vtable problem..."); - - if (clz->interpreted_methods[i] == 0) - vtable->set_method(index, (void*)&_Jv_abstractMethodError); - else - vtable->set_method(index, this_meth->ncode); - } - } - - /* finally, assign the vtable! */ - clz->vtable = vtable; + clz->vtable_method_count = -1; + _Jv_MakeVTable (clz); /* wooha! we're done. */ clz->state = JV_STATE_PREPARED; diff --git a/libjava/testsuite/ChangeLog b/libjava/testsuite/ChangeLog index 18cfe853c8a..b7c1548f70e 100644 --- a/libjava/testsuite/ChangeLog +++ b/libjava/testsuite/ChangeLog @@ -1,3 +1,49 @@ +2002-11-04 Tom Tromey <tromey@redhat.com> + + * libjava.compile/pr7912.java: New file. + +2002-11-04 Andrew Haley <aph@redhat.com> + + * libjava.lang/utilTest.java: New. + * libjava.lang/utilTest.out: New. + +2002-11-04 Anthony Green <green@redhat.com> + + * libjava.loader/MyLoader.java: New constructor. + * libjava.loader/TestParent.java: New file. + * libjava.loader/TestParent.out: New file. + +2002-11-04 Anthony Green <green@redhat.com> + + * libjava.loader/TestEarlyGC.java, + libjava.loader/TestEarlyGC.out: New files (from + Jeff Sturm). + +2002-11-04 Anthony Green <green@redhat.com> + + * libjava.loader/dummy.java, libjava.loader/loader.exp, + libjava.loader/MyLoader.java, libjava.loader/TestLeak.java, + libjava.loader/TestLeak.out, libjava.loader/TestMultiple.java, + libjava.loader/TestMultiple.out: New files. + +2002-11-02 Tom Tromey <tromey@redhat.com> + + * libjava.lang/initexc.java (fail): Static initializers must be + able to complete normally. From Eric Blake. + + * libjava.lang/initexc.java: New file. + * libjava.lang/initexc.out: New file. + +2002-11-01 Tom Tromey <tromey@redhat.com> + + For PR java/8415: + * libjava.lang/pr8415.java: New file. + * libjava.lang/pr8415.out: New file. + + * libjava.mauve/mauve.exp (find_mauve_sources): New proc. + (test_mauve): Use it. + (test_mauve_sim): Likewise. + 2002-10-24 Tom Tromey <tromey@redhat.com> * libjava.lang/Primes.java: Removed. diff --git a/libjava/testsuite/libjava.mauve/mauve.exp b/libjava/testsuite/libjava.mauve/mauve.exp index 4a26b27242d..a9a1c98d6ac 100644 --- a/libjava/testsuite/libjava.mauve/mauve.exp +++ b/libjava/testsuite/libjava.mauve/mauve.exp @@ -52,12 +52,27 @@ proc mauve_compute_uses {aName} { return [lsort [array names uses]] } +# Find Mauve sources. At end, env(MAUVEDIR) points to sources. +# Returns 0 if sources not found, 1 otherwise. +proc find_mauve_sources {} { + global env srcdir + + if {[info exists env(MAUVEDIR)]} { + return 1 + } elseif {[file isdirectory $srcdir/libjava.mauve/mauve]} { + set env(MAUVEDIR) $srcdir/libjava.mauve/mauve + return 1 + } + + return 0 +} + # Run all the Mauve tests. Return 1 on success, 0 on any failure. If # the tests are skipped, that is treated like success. proc test_mauve {} { global srcdir objdir subdir env - if {! [info exists env(MAUVEDIR)]} then { + if {! [find_mauve_sources]} then { verbose "MAUVEDIR not set; not running Mauve tests" return 1 } @@ -220,7 +235,7 @@ proc test_mauve {} { proc test_mauve_sim {} { global srcdir subdir env - if {! [info exists env(MAUVEDIR)]} then { + if {! [find_mauve_sources]} then { verbose "MAUVEDIR not set; not running Mauve tests" return 1 } |