From ae113853c459c52b0211d069481334fdd881730d Mon Sep 17 00:00:00 2001 From: Geoffrey Keating Date: Tue, 24 Dec 2002 02:10:15 +0000 Subject: Merge to tag pch-merge-20021218 git-svn-id: https://gcc.gnu.org/svn/gcc/branches/pch-branch@60460 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 565 ++++++- libjava/Makefile.am | 7 +- libjava/Makefile.in | 31 +- libjava/acinclude.m4 | 26 +- libjava/aclocal.m4 | 65 +- libjava/boehm.cc | 36 +- libjava/configure | 541 ++++--- libjava/configure.host | 5 +- libjava/configure.in | 3 + libjava/defineclass.cc | 14 +- libjava/gnu/gcj/protocol/jar/Connection.java | 31 +- libjava/gnu/gcj/runtime/VMClassLoader.java | 21 +- libjava/gnu/java/nio/ByteBufferImpl.java | 83 +- libjava/gnu/java/nio/CharBufferImpl.java | 231 ++- libjava/gnu/java/nio/DatagramChannelImpl.java | 2 + libjava/gnu/java/nio/DoubleBufferImpl.java | 72 +- libjava/gnu/java/nio/FloatBufferImpl.java | 96 +- libjava/gnu/java/nio/IntBufferImpl.java | 116 +- libjava/gnu/java/nio/LongBufferImpl.java | 110 +- libjava/gnu/java/nio/SelectionKeyImpl.java | 16 +- libjava/gnu/java/nio/SelectorImpl.java | 169 +- libjava/gnu/java/nio/ServerSocketChannelImpl.java | 13 +- libjava/gnu/java/nio/ShortBufferImpl.java | 98 +- libjava/gnu/java/nio/SocketChannelImpl.java | 17 +- libjava/include/java-interp.h | 6 + libjava/include/jni.h | 14 +- libjava/include/posix.h | 8 + libjava/include/win32.h | 12 +- libjava/interpret.cc | 12 +- libjava/java/awt/image/ColorModel.java | 4 +- libjava/java/beans/Introspector.java | 28 +- libjava/java/io/CharArrayWriter.java | 33 +- libjava/java/lang/Character.java | 4 +- libjava/java/lang/Class.h | 15 +- libjava/java/lang/ClassLoader.java | 199 ++- libjava/java/lang/SecurityManager.java | 1639 ++++++++++++-------- libjava/java/lang/VMSecurityManager.java | 8 +- libjava/java/lang/VMThrowable.java | 26 +- libjava/java/lang/natClass.cc | 95 +- libjava/java/lang/natClassLoader.cc | 89 +- libjava/java/lang/natRuntime.cc | 68 +- libjava/java/lang/natVMThrowable.cc | 97 -- libjava/java/net/InetAddress.java | 15 +- libjava/java/net/JarURLConnection.java | 20 +- libjava/java/net/Socket.java | 3 + libjava/java/net/SocketPermission.java | 13 +- libjava/java/net/URLClassLoader.java | 1189 ++++++++++---- libjava/java/net/natPlainDatagramSocketImpl.cc | 3 - libjava/java/net/natPlainSocketImpl.cc | 3 - libjava/java/nio/channels/DatagramChannel.java | 52 + libjava/java/nio/channels/SocketChannel.java | 57 + libjava/java/security/SecureRandom.java | 196 +-- libjava/java/security/Security.java | 4 +- libjava/java/security/spec/DSAParameterSpec.java | 2 +- libjava/java/security/spec/DSAPrivateKeySpec.java | 2 +- libjava/java/security/spec/DSAPublicKeySpec.java | 2 +- libjava/java/util/Locale.java | 2 + libjava/java/util/ResourceBundle.java | 63 +- libjava/java/util/jar/JarFile.java | 70 +- libjava/java/util/natResourceBundle.cc | 15 +- libjava/java/util/zip/ZipEntry.java | 99 +- libjava/java/util/zip/ZipFile.java | 137 +- libjava/java/util/zip/ZipInputStream.java | 2 +- .../transaction/HeuristicCommitException.java | 44 +- .../javax/transaction/HeuristicMixedException.java | 44 +- .../transaction/HeuristicRollbackException.java | 44 +- .../transaction/InvalidTransactionException.java | 39 +- .../javax/transaction/NotSupportedException.java | 44 +- libjava/javax/transaction/RollbackException.java | 44 +- libjava/javax/transaction/Status.java | 44 +- libjava/javax/transaction/Synchronization.java | 44 +- libjava/javax/transaction/SystemException.java | 44 +- libjava/javax/transaction/Transaction.java | 63 +- libjava/javax/transaction/TransactionManager.java | 63 +- .../transaction/TransactionRequiredException.java | 39 +- .../TransactionRolledbackException.java | 39 +- libjava/javax/transaction/UserTransaction.java | 58 +- libjava/javax/transaction/xa/XAException.java | 39 +- libjava/javax/transaction/xa/XAResource.java | 41 +- libjava/javax/transaction/xa/Xid.java | 41 +- libjava/jni.cc | 5 +- libjava/prims.cc | 12 +- libjava/resolve.cc | 7 - libjava/testsuite/ChangeLog | 37 + libjava/testsuite/lib/libjava.exp | 30 +- libjava/testsuite/libjava.jacks/jacks.exp | 22 +- libjava/testsuite/libjava.jacks/jacks.xfail | 42 +- libjava/testsuite/libjava.jni/jni.exp | 5 +- libjava/testsuite/libjava.loader/loader.exp | 6 +- libjava/testsuite/libjava.mauve/mauve.exp | 20 +- libjava/testsuite/libjava.mauve/xfails | 9 - libjava/verify.cc | 81 +- 92 files changed, 4909 insertions(+), 2815 deletions(-) delete mode 100644 libjava/java/lang/natVMThrowable.cc (limited to 'libjava') diff --git a/libjava/ChangeLog b/libjava/ChangeLog index c2b65f4306f..ae8559c70a4 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,427 @@ +2002-12-13 Casey Marshall + Mark Wielaard + + * java/security/SecurityRandom (digest): Removed field. + (SecureRandom): Check all providers for case-insensitive SecureRandom + implementation. Don't ignore classname == null. Fallback to SHA1PRNG + if necessary. + (getInstance(String,Provider,boolean): New method. + (getInstance(String)): Use new method. + (getInstance(String,String)): Likewise. + (getInstance(String,Provider)): Likewise. + +2002-12-13 Casey Marshall + + * java/security/Security.java (loadProviders): Increment i only once. + +2002-12-12 Mark Wielaard + + * java/lang/ClassLoader.java (resolveClass0): Transform + ClassNotFoundException to NoClassDefFoundError. Transform all other + throwables to LinkageError. + +2002-12-11 Tom Tromey + + * java/lang/ClassLoader.java (findLoadedClass): Now synchronized. + + * java/lang/ClassLoader.java (loadedClasses): New field. + (defineClass): Fixed indentation. Put new class in + loadedClasses. + (findLoadedClass): Implement here. + * java/lang/natClassLoader.cc (findLoadedClass): Removed. + +2002-12-10 Tom Tromey + + * Makefile.in: Rebuilt. + * Makefile.am (nat_source_files): Added natVMClassLoader.cc. + * gnu/gcj/runtime/natVMClassLoader.cc: New file. + (gnu::gcj::runtime::VMClassLoader::findClass): Moved here. + * java/lang/natClassLoader.cc + (gnu::gcj::runtime::VMClassLoader::findClass): Removed. + +2002-12-10 Mark Wielaard + Tom Tromey + + * java/net/URLClassLoader.java (getCanonicalFileURL): New method. + (JarURLLoader): Use it. + (FileURLLoader): Likewise. + (JarURLResource.getURL): Use chained exception. + (FileResource.getURL): Likewise. + (FileURLLoader.getResource): Use canonical file name. + (addURL): Indentation fix. + +2002-12-10 Tom Tromey + + * include/win32.h: Fixed typo in "DISABLE_JAVA_NET". + From Laurent Bardet . + +2002-12-09 Tom Tromey + + * include/win32.h (_Jv_platform_solib_prefix): New define. + (_Jv_platform_solib_suffix): Likewise. + * include/posix.h (_Jv_platform_solib_prefix): New define. + (_Jv_platform_solib_suffix): Likewise. + * java/lang/natRuntime.cc: Include StackTrace.h. + (_load): Use findLibrary and new platform defines. + (nativeGetLibname): Use new platform defines. + + * java/util/natResourceBundle.cc (getCallingClassLoader): Assume + `t' won't be null. + +2002-12-08 Mark Wielaard + + * gnu/gcj/protocol/jar/Connection.java (getJarFile): download and + cache remote jar files. + * gnu/gcj/runtime/VMClassLoader.java: Don't construct jar URL, only + add File.separator to URL when it is a directory. + * java/lang/ClassLoader.java: Add Classpath javadoc. + (parent): final. + (getParent): Add (disabled) security check. + (findLibrary): New default method. + * java/net/JarURLConnection.java (getManifest): Implement. + (getInputStream): Only create InputStream when entry exists. + (getHeaders): Only use jarFileURLConnection or JarEntry to set length + when they exist. + * java/net/URLClassLoader.java: New/Rewritten version from Classpath. + +2002-12-08 Mark Wielaard + + * java/util/ResourceBundle.java (resourceBundleCache): Not final. + (lastDefaultLocale): New field. + (getBundle): When Locale.getDefault != lastDefaultLocale reset + resourceBundleCache. + +2002-12-06 Mark Wielaard + + * java/net/InetAddress.java (toString): Use hostname when not null, + don't do an explicit reverse getHostName() lookup. + * java/net/Socket.java (setSocketImplFactory): When fac == null throw + NullPointerException. + +2002-12-06 Tom Tromey + + * include/java-interp.h (class _Jv_InterpMethod): Added + JV_MARKOBJ_DECL. + * boehm.cc (_Jv_MarkObj): Consolidated interpreter code. Also + mark `prepared' field of interpreted method. + * interpret.cc (compile): Use _Jv_AllocBytes. + +2002-12-05 Andrew Haley + + * gnu/gcj/runtime/natStackTrace.cc (fillInStackTrace): Throw + #ifdef (HAVE_BACKTRACE) around the whole function body. + +2002-12-05 Tom Tromey + + * java/lang/Class.h (_Jv_SetVTableEntries): Updated declaration. + * resolve.cc: Don't include AbstractMethodError.h. + (_Jv_abstractMethodError): Removed. + * defineclass.cc (handleMethodsBegin): Initialize method index to + -1. + * java/lang/natClass.cc (_Jv_LayoutVTableMethods): Don't set + method index for "new" final method. + (_Jv_SetVTableEntries): Compare index against -1 instead of using + isVirtualMethod. Added `flags' argument. + (_Jv_MakeVTable): Throw exception for abstract method in concrete + class. + +2002-12-04 Tom Tromey + + * java/net/SocketPermission.java (hashCode): Rewrote. + +2002-12-04 Tom Tromey + + * Makefile.in: Rebuilt. + * Makefile.am (nat_source_files): Added natVMSecurityManager, + natResourceBundle. + * java/util/ResourceBundle.java (Security): Removed. + (getCallingClassLoader): Now native. + * java/util/natResourceBundle.cc: New file. + * java/lang/natVMSecurityManager.cc: New file. + * java/lang/VMSecurityManager.java (getClassContext): Now native. + +2002-12-03 Mark Wielaard + + * java/util/jar/JarFile.java (manifest): Not final. + (manifestRead): New field. + (JarFile): Don't read Manifest in constructor. + (getManifest): New method. + (JarEnumeration.nextElement): Use new method. + (getEntry): Likewise. + * java/util/zip/ZipFile.java (name): Final. + (raf): Likewsie. + (entries): Change type to Hashtable. + (closed): New field. + (ZipFile): Don't read enties in constructor. + (readEntries): Use Hashtable. + (close): Set new close flag and set entries to null inside + synchronized block. + (entries): Contruct enumeration using new getEntries() method and + entries Hashtable. + (getEntryIndex): Removed. + (getEntries): New method. + (getEntry): Use new getEntries() method and entries Hastable. + (getInputStream): Likewise. + (size): Return getEntries().size(). + (ZipEntryEnumeration): Wrap entries Hashtable elements. + * java/util/zip/ZipEntry.java (cal): Don't initialize. + (time): Removed + (dostime): New field. + (zipFileIndex): Removed. + (ZipEntry(ZipEntry)): Copy dostime. + (setDOSTime): Now final and doesn't convert dos time. + (getDOSTime): Likewise. + (setTime): Convert dos time. + (getTime): Likewise. + (getCalendar): New method. + (setExtra): Use setTime(). + * java/util/zip/ZipInputStream.java (getNextEntry): Format error msg. + +2002-12-03 Tom Tromey + + * java/lang/Character.java (forDigit): Formatting fix. + +2002-12-03 Raif Naffah + + * java/security/spec/DSAParameterSpec.java (getP): Return p, not q. + * java/security/spec/DSAPrivateKeySpec.java (getP): Likewise. + * java/security/spec/DSAPublicKeySpec.java (getP): Likewise. + +2002-12-03 Andrew Haley + + * java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Call + _Jv_PushClass. + (_Jv_InitNewClassFields): Set protectionDomain and chain = NULL. + (_Jv_PopClass): New. + (_Jv_PushClass): New. + * java/lang/natClass.cc (forName (jstring)): Use a StackTrace to + discover the ClassLoader of our caller. + (_Jv_CheckArrayStore): Don't check that a class is assignment + compatible with Object. + * java/lang/natVMTHrowable.cc: Delete. + * gnu/gcj/runtime/StackTrace.java: New, partly copied from + java.lang.VMThrowable. + (StackTrace(), StackTrace(int)): New constructors. + (classAt, methodAt, update, methodAtAddress): New methods. + (map): New field. + * java/lang/VMThrowable.java: Use StackTrace instead of + natVMTHrowable. + * java/lang/Class.h (getClassLoaderInternal): New. + (class Class): Be friendly with _Jv_PopClass and _Jv_PushClass. + Be friendly with gnu::gcj::runtime::StackTrace. + (Object.chain): New field. + * include/java-interp.h (class _Jv_InterpMethod): Be friendly with + gnu::gcj::runtime::StackTrace. + * gnu/gcj/runtime/natStackTrace.cc: New file. + * gnu/gcj/runtime/MethodRef.java: New file. + * prims.cc (_Jv_NewObjectArray): Use getClassLoaderInternal() + instead of getClassLoader(). + * verify.cc (class _Jv_BytecodeVerifier): Likewise. + java::lang::VMThrowable. + * Makefile.am (core_java_source_files): Add MethodRef.java, + StackTrace.java. + (nat_source_files): Remove natVMThrowable.cc; add natStackTrace.cc. + * Makefile.in: Rebuild. + +2002-12-02 Kaz Kojima + + * configure.host [sh-linux* | sh[34]*-linux*]: Don't set + CHECKREFSPEC and EXCEPTIONSPEC. Set can_unwind_signal to + yes also for sh-linux* and sh[34]*-linux*. + * configure.in: Add sh-linux* and sh[34]*-linux* cases and + set SIGNAL_HANDLER to use DWARF2 exception for them. + * configure: Regenerate. + +2002-12-02 Tom Tromey + + * jni.cc: Added `name' argument. + * include/jni.h (struct JNINativeInterface) [DefineClass]: Added + `const char *' argument. + (class _Jv_JNIEnv) [DefineClass]: Likewise. + +2002-12-01 Tom Tromey + + Bug compatibility, for PR libgcj/8738: + * java/io/CharArrayWriter.java (close): Do nothing. + (flush): Likewise. + (reset): Don't touch `closed'. + (write(int)): Don't throw IOException. + (write(char[],int,int)): Likewise. + (write(String,int,int)): Likewise. + (closed): Removed. + +2002-12-01 Mark Wielaard + + * java/lang/SecurityManager.java: Remerge comments, indenting and + checkXXX methods with Classpath. + +2002-11-29 Scott Gilbertson + + * java/awt/image/ColorModel.java (getUnnormalizedComponents, + getNormalizedComponents): Fix calculation which was using one too + many bits in the unnormalized format. + +2002-11-29 Gary Benson + + For PR libgcj/8759: + * java/beans/Introspector.java (flushCaches): New method. + (flushFromCaches): Likewise. + +2002-11-29 Michael Koch + + * java/nio/channels/DatagramChannel.java + (open): Added exception documentation. + (write): Added exception documentation. + (connect): Added exception documentation. + (disconnect): Added exception documentation. + (isConnected): Added exception documentation. + (read): Added exception documentation. + (receive): Added exception documentation. + (send): Added exception documentation. + (validOps): Added exception documentation. + * java/nio/channels/SocketChannel.java + (open): Added exception documentation. + (read): Added exception documentation. + (write): Added exception documentation. + (connect): Added exception documentation. + (finishConnect): Added exception documentation. + +2002-11-29 Michael Koch + + * gnu/java/nio/DatagramChannelImpl: + (fd): New member variable to store file descriptor of socket. + * gnu/java/nio/SelectionKeyImpl.java: + (ops): Removed. + (readyOps): New member variable. + (interestOps): New member variable. + (readyOps): Implemented. + (readyOps): New method to set member variable readyOps. + (interestOps): Replaced ops by interestOps. + * gnu/java/nio/SelectorImpl.java: + (SelectorImpl): Initialize key sets. + (select): Call select with -1 instead of Long.MAX_VALUE). + (java_do_select): Make it a native method. + (getFDsAsArray): New helper method. + (select): Remove canceled keys, give only interested file discriptors + to java_do_select, set ready ops. + (add): No need to initialize keys set here. + (add_selected): No need to initialize selected set here. + (deregisterCanceledKeys): New helper method. + (register): Set interest ops, set attachments, added handling of datagram + channels. + * gnu/java/nio/ServerSocketChannelImpl: + (SocketAccept): Renamed from NioSocketAccept. + (implConfigureBlocking): Implemented. + (accept): Use SocketAccept instead of NioSocketAccept. + * gnu/java/nio/SocketChannelImpl: + Reactivate native methods. + +2002-11-29 Michael Koch + + * gnu/java/nio/natByteBufferImpl.cc, + gnu/java/nio/natCharBufferImpl.cc, + gnu/java/nio/natDoubleBufferImpl.cc, + gnu/java/nio/natFloatBufferImpl.cc, + gnu/java/nio/natIntBufferImpl.cc, + gnu/java/nio/natLongBufferImpl.cc, + gnu/java/nio/natSelectorImpl.cc, + gnu/java/nio/natServerSocketChannelImpl.cc, + gnu/java/nio/natShortBufferImpl.cc, + gnu/java/nio/natSocketChannelImpl.cc: + New files that implement native functionalities. + +2002-11-29 Michael Koch + + * gnu/java/nio/ByteBufferImpl.java + (ByteBufferImpl): Moved position() after limit. + (nio_*): Use native implementation. + * gnu/java/nio/CharBufferImpl.java: + Reformated. + (endian): New member variable string endianess of buffer. + (CharBufferImpl): Moved position() after limit. + (nio_*): Use native implementation. + (subSequence): Implemented. + * gnu/java/nio/DoubleBufferImpl.java + (DoubleBufferImpl): Moved position() after limit. + (nio_*): Use native implementation. + * gnu/java/nio/FloatBufferImpl.java + Reformated. + (FloatBufferImpl): Moved position() after limit. + (nio_*): Use native implementation. + * gnu/java/nio/IntBufferImpl.java + Added needed imports, Reformated. + (IntBufferImpl): Moved position() after limit. + (nio_*): Use native implementation. + * gnu/java/nio/LongBufferImpl.java + Reformated. + (LongBufferImpl): Moved position() after limit. + (nio_*): Use native implementation. + * gnu/java/nio/ShortBufferImpl.java + Reformated. + (ShortBufferImpl): Moved position() after limit. + (nio_*): Use native implementation. + +2002-11-27 Julian Dolby + + * java/util/Locale.java (toString): Improve efficiency if country + and variant are both empty. + +2002-11-26 Tom Tromey + + * verify.cc (pop_init_ref): New method. + (verify_instructions_0) [op_iaload, op_laload, op_faload, + op_daload, op_aaload, op_baload, op_caload, op_saload, op_iastore, + op_lastore, op_fastore, op_dastore, op_aastore, op_bastore, + op_castore, op_sastore, op_areturn, op_arraylength, op_checkcast, + op_instanceof, op_monitorenter, op_monitorexit]: Use it. + (verify_instructions_0) [op_invokevirtual, op_invokespecial, + op_invokestatic, op_invokeinterface]: Use pop_init_ref. Don't + let `this' argument be uninitialized. Don't let `null' be passed + as `this' to construtor. + +2002-11-26 Mark Wielaard + + * javax/transaction/HeuristicCommitException.java: Classpath merge. + * javax/transaction/HeuristicMixedException.java: Likewise. + * javax/transaction/HeuristicRollbackException.java: Likewise. + * javax/transaction/InvalidTransactionException.java: Likewise. + * javax/transaction/NotSupportedException.java: Likewise. + * javax/transaction/RollbackException.java: Likewise. + * javax/transaction/Status.java: Likewise. + * javax/transaction/Synchronization.java: Likewise. + * javax/transaction/SystemException.java: Likewise. + * javax/transaction/Transaction.java: Likewise. + * javax/transaction/TransactionManager.java: Likewise. + * javax/transaction/TransactionRequiredException.java: Likewise. + * javax/transaction/TransactionRolledbackException.java: Likewise. + * javax/transaction/UserTransaction.java: Likewise. + * javax/transaction/xa/XAException.java: Likewise. + * javax/transaction/xa/XAResource.java: Likewise. + * javax/transaction/xa/Xid.java: Likewise. + +2002-11-26 Andreas Tobler + + * java/net/natPlainDatagramSocketImpl.cc (socklen_t): Don't + define. + * java/net/natPlainSocketImpl.cc (socklen_t): Don't define. + * include/posix.h (socklen_t): Define if not already defined. + +2002-11-25 Tom Tromey + + * verify.cc (type::compatible): Backed out broken change. + + * verify.cc (type::compatible): Check initialization status + first. + * interpret.cc (run) [insn_invokespecial, invokespecial_resolved]: + Don't use NULLCHECK. + +2002-11-23 H.J. Lu + + * acinclude.m4 (AC_COMPILE_CHECK_SIZEOF): Removed. + Include ../config/accross.m4. + * aclocal.m4; Rebuild. + * configure: Likewise. + 2002-11-23 Mark Wielaard * javax/naming/AuthenticationException.java: Update copyright header. @@ -103,12 +527,12 @@ * include/posix.h: I put too much into the #ifndef DISABLE_JAVA_NET. Only the new network functions should be in it. - + 2002-11-21 Michael Koch * include/posix.h: Moved new functions into a #ifndef DISABLE_JAVA_NET * include/win32.h: Moved new functions into a #ifndef DISABLE_JAVA_NET - + 2002-11-21 Michael Koch * java/nio/channels/AsynchronousCloseException.java, @@ -171,7 +595,7 @@ * Makefile.am (ordinary_java_source_files): Added java/nio/channels/FileChannel.java. * Makefile.in: Regenerated. - + 2002-11-20 Michael Koch * java/io/FileInputStream.java @@ -215,9 +639,9 @@ 2002-11-18 Jesse Rosenstock - * java/nio/charset/CoderResult.java (Cache.get): Fix a bug - that was causing CoderResults to be cached, not WeakReferences - to CoderResults. + * java/nio/charset/CoderResult.java (Cache.get): Fix a bug + that was causing CoderResults to be cached, not WeakReferences + to CoderResults. 2002-11-18 Joerg Brunsmann @@ -590,7 +1014,7 @@ 2002-11-07 Mark Wielaard - Merge Orp RMI patches from Wu Gansha + Merge Orp RMI patches from Wu Gansha * java/rmi/MarshalledObject.java (equals): Check hashcode first. * java/rmi/server/RMIClassLoader.java (MyClassLoader): Create/Use @@ -737,13 +1161,13 @@ 2002-10-31 Wu Gansha : - * java/util/ArrayList.java (readObject, writeObject): Only read/write - size items. + * java/util/ArrayList.java (readObject, writeObject): Only read/write + size items. 2002-10-31 Wu Gansha : - * java/io/DataInputStream.java (convertFromUTF): Give StringBuffer an - initial estimated size to avoid enlarge buffer frequently. + * java/io/DataInputStream.java (convertFromUTF): Give StringBuffer an + initial estimated size to avoid enlarge buffer frequently. 2002-10-31 Wu Gansha : @@ -755,7 +1179,7 @@ 2002-10-31 Mark Wielaard - * java/net/URLDecoder.java (decode): Initialize Stringbuffer size to + * java/net/URLDecoder.java (decode): Initialize Stringbuffer size to length of String. * java/net/URLEncoder.java (encode): Likewise. @@ -921,12 +1345,13 @@ * aclocal.m4 (CHECK_FOR_BROKEN_MINGW_LD): added * configure.in: enabled hash sync on Win32 - * include/win32-threads.h (_Jv_ThreadId_t): added. - * java/lang/natObject.cc (_Jv_MonitorEnter, _Jv_MonitorExit, + * include/win32-threads.h (_Jv_ThreadId_t): added. + * java/lang/natObject.cc (_Jv_MonitorEnter, _Jv_MonitorExit, heavy_lock_obj_finalization_proc, wait, notify, notifyAll): removed some posix-isms, use Thread::sleep() instead of usleep, added code to clear bottom three bits if platform has a broken - linker. * include/win32-threads.h (_Jv_ThreadId_t): added. + linker. + * include/win32-threads.h (_Jv_ThreadId_t): added. 2002-10-19 Ranjit Mathew @@ -1962,7 +2387,7 @@ java/net/URLConnection.java: add/update of some @since/@deprecated 2002-08-27 Tony Kimball - Tom Tromey + Tom Tromey * java/net/natPlainDatagramSocketImpl.cc (NATIVE_CLOSE): New define. @@ -2576,7 +3001,7 @@ 2002-08-01 Kaz Kojima * configure.host: Add SH support. - * sysdep/sh/locks.h: New file. + * sysdep/sh/locks.h: New file. 2002-07-31 Bryce McKinlay @@ -2615,7 +3040,7 @@ argument to _load. 2002-07-24 Tom Tromey - Tony Kimball + Tony Kimball * java/io/natFileDescriptorWin32.cc (setLength): New method. * java/io/natFileDescriptorPosix.cc (setLength): New method. @@ -2742,7 +3167,7 @@ * java/lang/natRuntime.cc (nativeGetLibname): Added missing `#'. 2002-07-04 Tom Tromey - Jeff Sturm + Jeff Sturm Fix for PR libgcj/7060: * java/lang/Class.h (_getMethod): Renamed from getMethod. @@ -2753,7 +3178,7 @@ (_getMethod): New native method. 2002-07-02 Tom Tromey - David Hovemeyer + David Hovemeyer * java/text/ChoiceFormat.java (format(double,StringBuffer,FieldPosition)): Fix fencepost error @@ -3134,8 +3559,8 @@ 2002-06-06 Adam Megacz - * java/io/natFileDescriptorWin32.cc (open): Disable Win32 file - locking, just like the Sun JVM does. + * java/io/natFileDescriptorWin32.cc (open): Disable Win32 file + locking, just like the Sun JVM does. 2002-06-05 H.J. Lu (hjl@gnu.org) @@ -3238,7 +3663,7 @@ * Makefile.am: Add new CertPath classes. * Makefile.in: Rebuilt. - * gnu/java/util/EmptyEnumeration.java: New file from classpath. + * gnu/java/util/EmptyEnumeration.java: New file from classpath. 2002-05-24 Bryce McKinlay @@ -3593,8 +4018,8 @@ 2002-04-07 Mark Wielaard - * java/util/AbstractMap.java (putAll): Use entrySet size. - (toString): Explicitly use getKey() and getValue(). + * java/util/AbstractMap.java (putAll): Use entrySet size. + (toString): Explicitly use getKey() and getValue(). 2002-04-07 Mark Wielaard @@ -3635,7 +4060,7 @@ 2002-04-05 Adam Megacz - * exception.cc (abort): added static modifier + * exception.cc (abort): added static modifier 2002-04-04 Adam Megacz @@ -3682,14 +4107,14 @@ 2002-04-01 Mark Wielaard - * java/util/BitSet.java (BitSet(int)): if nbits < 0 throw - NegativeArraySizeException - (clear(int)): Use sign extended shift. - (flip(int)): Likewise. - (get(int)): Likewise. - (nextClearBit(int)): Likewise. - (nextSetBit(int)): Likewise. - (set(int)): Likewise. + * java/util/BitSet.java (BitSet(int)): if nbits < 0 throw + NegativeArraySizeException + (clear(int)): Use sign extended shift. + (flip(int)): Likewise. + (get(int)): Likewise. + (nextClearBit(int)): Likewise. + (nextSetBit(int)): Likewise. + (set(int)): Likewise. 2002-04-01 Mark Wielaard @@ -3733,10 +4158,10 @@ 2002-03-25 Andrew Haley , Hans Boehm - * include/dwarf2-signal.h (MAKE_THROW_FRAME): Add for IA-64. - (INIT_SEGV, INIT_FPE): Add versions that use __libc_sigaction - instead of syscall on IA-64. - Add FIXME comment. + * include/dwarf2-signal.h (MAKE_THROW_FRAME): Add for IA-64. + (INIT_SEGV, INIT_FPE): Add versions that use __libc_sigaction + instead of syscall on IA-64. + Add FIXME comment. 2002-03-27 Anthony Green @@ -3966,7 +4391,7 @@ 2002-03-10 Adam Megacz - * java/net/natPlainSocketImpl.cc: Added #include . + * java/net/natPlainSocketImpl.cc: Added #include . 2002-03-10 Tom Tromey @@ -4027,17 +4452,17 @@ 2002-03-09 Adam Megacz - * java/io/natFileDescriptorWin32.cc (read): Return -1 if zero - bytes read and no failure code returned. + * java/io/natFileDescriptorWin32.cc (read): Return -1 if zero + bytes read and no failure code returned. 2002-03-09 Adam Megacz - * win32.cc (_CRT_MT, __mingwthr_key_dtor) Added fake - definitions to simulate -mthreads. + * win32.cc (_CRT_MT, __mingwthr_key_dtor) Added fake + definitions to simulate -mthreads. 2002-03-09 Adam Megacz - * win32.cc (_Jv_platform_gettimeofday) Cast 1000 to long long to + * win32.cc (_Jv_platform_gettimeofday) Cast 1000 to long long to avoid precision loss. 2002-03-09 Per Bothner @@ -4048,13 +4473,13 @@ 2002-03-09 Adam Megacz - * java/lang/Win32Process.java (ConcreteProcess): Now throws an - IOException so that Throwable.printStackTrace fails correctly. + * java/lang/Win32Process.java (ConcreteProcess): Now throws an + IOException so that Throwable.printStackTrace fails correctly. 2002-03-08 Adam Megacz - * java/net/natPlainSocketImpl.cc (read, write, close): Formatting - fixed. + * java/net/natPlainSocketImpl.cc (read, write, close): Formatting + fixed. 2002-03-09 Bryce McKinlay @@ -4072,23 +4497,23 @@ 2002-03-07 Adam Megacz - * java/net/natPlainSocketImpl.cc: Changed USE_WINSOCK to - WIN32, and added thunks for read(), write(), and close(). - * java/net/natPlainSocketImpl.cc (accept, read, read): - Disabled timeouts on WIN32 pending discussion. + * java/net/natPlainSocketImpl.cc: Changed USE_WINSOCK to + WIN32, and added thunks for read(), write(), and close(). + * java/net/natPlainSocketImpl.cc (accept, read, read): + Disabled timeouts on WIN32 pending discussion. 2002-03-07 Adam Megacz - * win32.cc (_Jv_platform_gettimeofday): Now takes no args, - returns jlong. Added implementation - * posix.cc (_Jv_platform_gettimeofday): Now takes no args, - returns jlong. - * win32.h (_Jv_platform_gettimeofday): Now takes no args, - returns jlong. - * posix.h (_Jv_platform_gettimeofday): Now takes no args, - returns jlong. - * java/lang/natSystem.cc (currentTimeMillis): Now uses updated - _Jv_platform_gettimeofday signature. + * win32.cc (_Jv_platform_gettimeofday): Now takes no args, + returns jlong. Added implementation + * posix.cc (_Jv_platform_gettimeofday): Now takes no args, + returns jlong. + * win32.h (_Jv_platform_gettimeofday): Now takes no args, + returns jlong. + * posix.h (_Jv_platform_gettimeofday): Now takes no args, + returns jlong. + * java/lang/natSystem.cc (currentTimeMillis): Now uses updated + _Jv_platform_gettimeofday signature. 2002-03-07 Bryce McKinlay @@ -4109,10 +4534,10 @@ 2002-03-06 Adam Megacz - * java/io/FileDescriptor.java: Initialize in/out/err in init(). - * java/io/natFileDescriptorWin32.cc (init()): Added function. - * java/io/natFileDescriptorPosix.cc (init()): Added function. - * java/io/natFileDescriptorEcos.cc (init()): Added function. + * java/io/FileDescriptor.java: Initialize in/out/err in init(). + * java/io/natFileDescriptorWin32.cc (init()): Added function. + * java/io/natFileDescriptorPosix.cc (init()): Added function. + * java/io/natFileDescriptorEcos.cc (init()): Added function. 2002-03-06 Eric Blake @@ -4386,12 +4811,12 @@ 2002-02-12 Adam Megacz - * java/lang/Win32Process.java: Filled in a placeholder + * java/lang/Win32Process.java: Filled in a placeholder implementation so Win32 will build. 2002-02-12 Adam Megacz - * java/io/natFilePosix.cc: Copied this from natFile.cc. + * java/io/natFilePosix.cc: Copied this from natFile.cc. * java/io/natFile.cc: Removed from repository. * configure.in: Added AC_LINK_FILES for natFile${PLATFORM}. @@ -4547,8 +4972,8 @@ * prims.cc (_Jv_RunMain): Use DISABLE_MAIN_ARGS. * configure: Rebuilt. * configure.in: Add --disable-main-args option. Test for - opendir function. Replace AC_CHECK_SIZEOF with - AC_COMPILE_CHECK_SIZEOF. + opendir function. Replace AC_CHECK_SIZEOF with + AC_COMPILE_CHECK_SIZEOF. * java/io/natFile.cc (performList): Check HAVE_OPENDIR. * aclocal.m4: Rebuilt. * acinclude.m4: Add AC_COMPILE_CHECK_SIZEOF. diff --git a/libjava/Makefile.am b/libjava/Makefile.am index 34135e77e99..0db820f360f 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -1720,8 +1720,10 @@ gnu/gcj/runtime/FileDeleter.java \ gnu/gcj/runtime/FinalizerThread.java \ gnu/gcj/runtime/FirstThread.java \ gnu/gcj/runtime/JNIWeakRef.java \ +gnu/gcj/runtime/MethodRef.java \ gnu/gcj/runtime/NameFinder.java \ gnu/gcj/runtime/SharedLibLoader.java \ +gnu/gcj/runtime/StackTrace.java \ gnu/gcj/runtime/StringBuffer.java \ gnu/gcj/runtime/VMClassLoader.java \ gnu/java/io/ClassLoaderObjectInputStream.java \ @@ -2316,7 +2318,9 @@ gnu/gcj/runtime/natFinalizerThread.cc \ gnu/gcj/runtime/natFirstThread.cc \ gnu/gcj/runtime/natNameFinder.cc \ gnu/gcj/runtime/natSharedLibLoader.cc \ +gnu/gcj/runtime/natStackTrace.cc \ gnu/gcj/runtime/natStringBuffer.cc \ +gnu/gcj/runtime/natVMClassLoader.cc \ java/io/natFile.cc \ java/io/natFileDescriptor.cc \ java/io/natObjectInputStream.cc \ @@ -2334,7 +2338,7 @@ java/lang/natString.cc \ java/lang/natStringBuffer.cc \ java/lang/natSystem.cc \ java/lang/natThread.cc \ -java/lang/natVMThrowable.cc \ +java/lang/natVMSecurityManager.cc \ java/lang/ref/natReference.cc \ java/lang/reflect/natArray.cc \ java/lang/reflect/natConstructor.cc \ @@ -2346,6 +2350,7 @@ java/net/natInetAddress.cc \ java/net/natPlainDatagramSocketImpl.cc \ java/net/natPlainSocketImpl.cc \ java/text/natCollator.cc \ +java/util/natResourceBundle.cc \ java/util/natTimeZone.cc \ java/util/zip/natDeflater.cc \ java/util/zip/natInflater.cc diff --git a/libjava/Makefile.in b/libjava/Makefile.in index 239bd09db32..c8d722f0521 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -1470,8 +1470,10 @@ gnu/gcj/runtime/FileDeleter.java \ gnu/gcj/runtime/FinalizerThread.java \ gnu/gcj/runtime/FirstThread.java \ gnu/gcj/runtime/JNIWeakRef.java \ +gnu/gcj/runtime/MethodRef.java \ gnu/gcj/runtime/NameFinder.java \ gnu/gcj/runtime/SharedLibLoader.java \ +gnu/gcj/runtime/StackTrace.java \ gnu/gcj/runtime/StringBuffer.java \ gnu/gcj/runtime/VMClassLoader.java \ gnu/java/io/ClassLoaderObjectInputStream.java \ @@ -2065,7 +2067,9 @@ gnu/gcj/runtime/natFinalizerThread.cc \ gnu/gcj/runtime/natFirstThread.cc \ gnu/gcj/runtime/natNameFinder.cc \ gnu/gcj/runtime/natSharedLibLoader.cc \ +gnu/gcj/runtime/natStackTrace.cc \ gnu/gcj/runtime/natStringBuffer.cc \ +gnu/gcj/runtime/natVMClassLoader.cc \ java/io/natFile.cc \ java/io/natFileDescriptor.cc \ java/io/natObjectInputStream.cc \ @@ -2083,7 +2087,7 @@ java/lang/natString.cc \ java/lang/natStringBuffer.cc \ java/lang/natSystem.cc \ java/lang/natThread.cc \ -java/lang/natVMThrowable.cc \ +java/lang/natVMSecurityManager.cc \ java/lang/ref/natReference.cc \ java/lang/reflect/natArray.cc \ java/lang/reflect/natConstructor.cc \ @@ -2095,6 +2099,7 @@ java/net/natInetAddress.cc \ java/net/natPlainDatagramSocketImpl.cc \ java/net/natPlainSocketImpl.cc \ java/text/natCollator.cc \ +java/util/natResourceBundle.cc \ java/util/natTimeZone.cc \ java/util/zip/natDeflater.cc \ java/util/zip/natInflater.cc @@ -2234,7 +2239,8 @@ gnu/gcj/convert/natOutput_SJIS.lo gnu/gcj/io/natSimpleSHSStream.lo \ gnu/gcj/io/shs.lo gnu/gcj/protocol/core/natCoreInputStream.lo \ gnu/gcj/runtime/natFinalizerThread.lo gnu/gcj/runtime/natFirstThread.lo \ gnu/gcj/runtime/natNameFinder.lo gnu/gcj/runtime/natSharedLibLoader.lo \ -gnu/gcj/runtime/natStringBuffer.lo java/io/natFile.lo \ +gnu/gcj/runtime/natStackTrace.lo gnu/gcj/runtime/natStringBuffer.lo \ +gnu/gcj/runtime/natVMClassLoader.lo java/io/natFile.lo \ java/io/natFileDescriptor.lo java/io/natObjectInputStream.lo \ java/io/natObjectOutputStream.lo java/lang/natCharacter.lo \ java/lang/natClass.lo java/lang/natClassLoader.lo \ @@ -2242,14 +2248,15 @@ java/lang/natConcreteProcess.lo java/lang/natDouble.lo \ java/lang/natFloat.lo java/lang/natMath.lo java/lang/natObject.lo \ java/lang/natRuntime.lo java/lang/natString.lo \ java/lang/natStringBuffer.lo java/lang/natSystem.lo \ -java/lang/natThread.lo java/lang/natVMThrowable.lo \ +java/lang/natThread.lo java/lang/natVMSecurityManager.lo \ java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \ java/lang/reflect/natConstructor.lo java/lang/reflect/natField.lo \ java/lang/reflect/natMethod.lo java/lang/reflect/natProxy.lo \ java/net/natNetworkInterface.lo java/net/natInetAddress.lo \ java/net/natPlainDatagramSocketImpl.lo java/net/natPlainSocketImpl.lo \ -java/text/natCollator.lo java/util/natTimeZone.lo \ -java/util/zip/natDeflater.lo java/util/zip/natInflater.lo +java/text/natCollator.lo java/util/natResourceBundle.lo \ +java/util/natTimeZone.lo java/util/zip/natDeflater.lo \ +java/util/zip/natInflater.lo libgcjx_la_OBJECTS = gnu/gcj/xlib/natClip.lo \ gnu/gcj/xlib/natColormap.lo gnu/gcj/xlib/natDisplay.lo \ gnu/gcj/xlib/natDrawable.lo gnu/gcj/xlib/natFont.lo \ @@ -2349,15 +2356,17 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/gnu/gcj/runtime/FileDeleter.P \ .deps/gnu/gcj/runtime/FinalizerThread.P \ .deps/gnu/gcj/runtime/FirstThread.P .deps/gnu/gcj/runtime/JNIWeakRef.P \ -.deps/gnu/gcj/runtime/NameFinder.P \ +.deps/gnu/gcj/runtime/MethodRef.P .deps/gnu/gcj/runtime/NameFinder.P \ .deps/gnu/gcj/runtime/SharedLibLoader.P \ -.deps/gnu/gcj/runtime/StringBuffer.P \ +.deps/gnu/gcj/runtime/StackTrace.P .deps/gnu/gcj/runtime/StringBuffer.P \ .deps/gnu/gcj/runtime/VMClassLoader.P \ .deps/gnu/gcj/runtime/natFinalizerThread.P \ .deps/gnu/gcj/runtime/natFirstThread.P \ .deps/gnu/gcj/runtime/natNameFinder.P \ .deps/gnu/gcj/runtime/natSharedLibLoader.P \ -.deps/gnu/gcj/runtime/natStringBuffer.P .deps/gnu/gcj/xlib/Clip.P \ +.deps/gnu/gcj/runtime/natStackTrace.P \ +.deps/gnu/gcj/runtime/natStringBuffer.P \ +.deps/gnu/gcj/runtime/natVMClassLoader.P .deps/gnu/gcj/xlib/Clip.P \ .deps/gnu/gcj/xlib/Colormap.P .deps/gnu/gcj/xlib/Display.P \ .deps/gnu/gcj/xlib/Drawable.P .deps/gnu/gcj/xlib/Font.P \ .deps/gnu/gcj/xlib/GC.P .deps/gnu/gcj/xlib/Pixmap.P \ @@ -2956,7 +2965,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/lang/natMath.P .deps/java/lang/natObject.P \ .deps/java/lang/natRuntime.P .deps/java/lang/natString.P \ .deps/java/lang/natStringBuffer.P .deps/java/lang/natSystem.P \ -.deps/java/lang/natThread.P .deps/java/lang/natVMThrowable.P \ +.deps/java/lang/natThread.P .deps/java/lang/natVMSecurityManager.P \ .deps/java/lang/ref/PhantomReference.P .deps/java/lang/ref/Reference.P \ .deps/java/lang/ref/ReferenceQueue.P \ .deps/java/lang/ref/SoftReference.P .deps/java/lang/ref/WeakReference.P \ @@ -3284,8 +3293,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/util/jar/JarException.P .deps/java/util/jar/JarFile.P \ .deps/java/util/jar/JarInputStream.P \ .deps/java/util/jar/JarOutputStream.P .deps/java/util/jar/Manifest.P \ -.deps/java/util/natTimeZone.P .deps/java/util/regex/Matcher.P \ -.deps/java/util/regex/Pattern.P \ +.deps/java/util/natResourceBundle.P .deps/java/util/natTimeZone.P \ +.deps/java/util/regex/Matcher.P .deps/java/util/regex/Pattern.P \ .deps/java/util/regex/PatternSyntaxException.P \ .deps/java/util/zip/Adler32.P .deps/java/util/zip/CRC32.P \ .deps/java/util/zip/CheckedInputStream.P \ diff --git a/libjava/acinclude.m4 b/libjava/acinclude.m4 index d205aa029dd..5908f40c5d5 100644 --- a/libjava/acinclude.m4 +++ b/libjava/acinclude.m4 @@ -1,28 +1,4 @@ -AC_DEFUN([AC_COMPILE_CHECK_SIZEOF], -[changequote(<<, >>)dnl -dnl The name to #define. -define(<>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl -dnl The cache variable name. -define(<>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl -changequote([, ])dnl -AC_MSG_CHECKING(size of $1) -AC_CACHE_VAL(AC_CV_NAME, -[for ac_size in 4 8 1 2 16 12 $2 ; do # List sizes in rough order of prevalence. - AC_TRY_COMPILE([#include "confdefs.h" -#include -$2 -], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size) - if test x$AC_CV_NAME != x ; then break; fi -done -]) -if test x$AC_CV_NAME = x ; then - AC_MSG_ERROR([cannot determine a size for $1]) -fi -AC_MSG_RESULT($AC_CV_NAME) -AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) -undefine([AC_TYPE_NAME])dnl -undefine([AC_CV_NAME])dnl -]) +sinclude(../config/accross.m4) AC_DEFUN(LIBGCJ_CONFIGURE, [ diff --git a/libjava/aclocal.m4 b/libjava/aclocal.m4 index 26e735711b9..2253b6b4d7c 100644 --- a/libjava/aclocal.m4 +++ b/libjava/aclocal.m4 @@ -1,6 +1,6 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4 +dnl aclocal.m4 generated automatically by aclocal 1.4-p5 -dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -10,31 +10,7 @@ dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. -AC_DEFUN([AC_COMPILE_CHECK_SIZEOF], -[changequote(<<, >>)dnl -dnl The name to #define. -define(<>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl -dnl The cache variable name. -define(<>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl -changequote([, ])dnl -AC_MSG_CHECKING(size of $1) -AC_CACHE_VAL(AC_CV_NAME, -[for ac_size in 4 8 1 2 16 12 $2 ; do # List sizes in rough order of prevalence. - AC_TRY_COMPILE([#include "confdefs.h" -#include -$2 -], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size) - if test x$AC_CV_NAME != x ; then break; fi -done -]) -if test x$AC_CV_NAME = x ; then - AC_MSG_ERROR([cannot determine a size for $1]) -fi -AC_MSG_RESULT($AC_CV_NAME) -AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) -undefine([AC_TYPE_NAME])dnl -undefine([AC_CV_NAME])dnl -]) +sinclude(../config/accross.m4) AC_DEFUN(LIBGCJ_CONFIGURE, [ @@ -295,7 +271,7 @@ AC_DEFUN([AM_LC_MESSAGES], dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) -AC_DEFUN(AM_INIT_AUTOMAKE, +AC_DEFUN([AM_INIT_AUTOMAKE], [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) @@ -323,7 +299,7 @@ AC_REQUIRE([AC_PROG_MAKE_SET])]) # Check to make sure that the build environment is sane. # -AC_DEFUN(AM_SANITY_CHECK, +AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 @@ -364,7 +340,7 @@ AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. -AC_DEFUN(AM_MISSING_PROG, +AC_DEFUN([AM_MISSING_PROG], [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. @@ -383,7 +359,7 @@ AC_SUBST($1)]) # serial 1 -AC_DEFUN(AM_MAINTAINER_MODE, +AC_DEFUN([AM_MAINTAINER_MODE], [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode is disabled by default AC_ARG_ENABLE(maintainer-mode, @@ -400,7 +376,7 @@ AC_DEFUN(AM_MAINTAINER_MODE, # Define a conditional. -AC_DEFUN(AM_CONDITIONAL, +AC_DEFUN([AM_CONDITIONAL], [AC_SUBST($1_TRUE) AC_SUBST($1_FALSE) if $2; then @@ -413,7 +389,7 @@ fi]) # Like AC_CONFIG_HEADER, but automatically create stamp file. -AC_DEFUN(AM_CONFIG_HEADER, +AC_DEFUN([AM_CONFIG_HEADER], [AC_PREREQ([2.12]) AC_CONFIG_HEADER([$1]) dnl When config.status generates a header, we must update the stamp-h file. @@ -434,26 +410,3 @@ for am_file in <<$1>>; do done<<>>dnl>>) changequote([,]))]) -AC_DEFUN([CHECK_FOR_BROKEN_MINGW_LD], -[ -AC_MSG_CHECKING(whether 'ld' is at least 2.13) -LD_PROG=`$CC --print-prog-name=ld` -LD_VERSION=`$LD_PROG --version` -LD_VERSION_MAJOR=`echo "$LD_VERSION" | head -1 | cut -d '.' -f 1 | cut -d ' ' -f 4` -LD_VERSION_MINOR=`echo "$LD_VERSION" | head -1 | cut -d '.' -f 2` -if expr "$LD_VERSION_MAJOR" \> 2 > /dev/null; then - LD_OK="ok" -else - if expr "$LD_VERSION_MAJOR" = 2 && expr "$LD_VERSION_MINOR" \>= 13 > /dev/null; then - LD_OK="ok" - fi -fi -if test "x$LD_OK" != x; then - AC_MSG_RESULT([yes; major=$LD_VERSION_MAJOR, minor=$LD_VERSION_MINOR]) -else - AC_MSG_RESULT([no; major=$LD_VERSION_MAJOR, minor=$LD_VERSION_MINOR]) - AC_MSG_WARN([ld <2.13 detected; enabling JV_LINKER_CANNOT_8BYTE_ALIGN_STATICS hack...]) - AC_DEFINE(JV_LINKER_CANNOT_8BYTE_ALIGN_STATICS, 1, - [Indicate that linker is not able to 8-byte align static data]) -fi[]dnl -])# CHECK_FOR_BROKEN_MINGW_LD diff --git a/libjava/boehm.cc b/libjava/boehm.cc index 466c9223ac8..90796f2ddf0 100644 --- a/libjava/boehm.cc +++ b/libjava/boehm.cc @@ -39,7 +39,6 @@ extern "C" ptr_t GC_debug_generic_malloc (size_t size, int k, GC_EXTRA_PARAMS); }; -// We must check for plausibility ourselves. #define MAYBE_MARK(Obj, Top, Limit, Source, Exit) \ Top=GC_MARK_AND_PUSH((GC_PTR)Obj, Top, Limit, (GC_PTR *)Source) @@ -153,19 +152,6 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) p = (ptr_t) c->methods[i].signature; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, cm2label); - - // FIXME: `ncode' entry? - -#ifdef INTERPRETER - // The interpreter installs a heap-allocated - // trampoline here, so we'll mark it. - if (_Jv_IsInterpretedClass (c)) - { - p = (ptr_t) c->methods[i].ncode; - MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, - cm3label); - } -#endif } } @@ -221,7 +207,7 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) #ifdef INTERPRETER if (_Jv_IsInterpretedClass (c)) { - _Jv_InterpClass* ic = (_Jv_InterpClass*)c; + _Jv_InterpClass* ic = (_Jv_InterpClass*) c; p = (ptr_t) ic->interpreted_methods; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, cElabel); @@ -231,6 +217,26 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /* env */) p = (ptr_t) ic->interpreted_methods[i]; MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, \ cFlabel); + + // Mark the direct-threaded code. + if ((c->methods[i].accflags + & java::lang::reflect::Modifier::NATIVE) == 0) + { + _Jv_InterpMethod *im + = (_Jv_InterpMethod *) ic->interpreted_methods[i]; + if (im) + { + p = (ptr_t) im->prepared; + MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, ic, \ + cFlabel); + } + } + + // The interpreter installs a heap-allocated trampoline + // here, so we'll mark it. + p = (ptr_t) c->methods[i].ncode; + MAYBE_MARK (p, mark_stack_ptr, mark_stack_limit, c, + cm3label); } p = (ptr_t) ic->field_initializers; diff --git a/libjava/configure b/libjava/configure index 4160fef7d68..0721b6ae196 100755 --- a/libjava/configure +++ b/libjava/configure @@ -1644,7 +1644,7 @@ else if { (eval echo configure:1645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in - *.c | *.o | *.obj) ;; + *.$ac_ext | *.c | *.o | *.obj) ;; *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; esac done @@ -2563,7 +2563,7 @@ if test -z "$CXXCPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CXXCPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - ac_ext=C + ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' @@ -2589,18 +2589,15 @@ else fi rm -f conftest* ac_cv_prog_CXXCPP="$CXXCPP" - ac_ext=c +ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross - fi - CXXCPP="$ac_cv_prog_CXXCPP" -else - ac_cv_prog_CXXCPP=$CXXCPP fi +CXXCPP="$ac_cv_prog_CXXCPP" echo "$ac_t""$CXXCPP" 1>&6 @@ -2815,7 +2812,7 @@ INTERPRETER="$libgcj_interpreter" echo $ac_n "checking for exception model to use""... $ac_c" 1>&6 -echo "configure:2819: checking for exception model to use" >&5 +echo "configure:2816: checking for exception model to use" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -2830,7 +2827,7 @@ if test "${enable_sjlj_exceptions+set}" = set; then : else cat > conftest.$ac_ext << EOF -#line 2834 "configure" +#line 2831 "configure" struct S { ~S(); }; void bar(); void foo() @@ -2841,7 +2838,7 @@ void foo() EOF old_CXXFLAGS="$CXXFLAGS" CXXFLAGS=-S -if { (eval echo configure:2845: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2842: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then enable_sjlj_exceptions=yes elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then @@ -2949,30 +2946,7 @@ case "$TARGET_ECOS" in PLATFORM=Win32 PLATFORMOBJS=win32.lo PLATFORMH=win32.h - -echo $ac_n "checking whether 'ld' is at least 2.13""... $ac_c" 1>&6 -echo "configure:2955: checking whether 'ld' is at least 2.13" >&5 -LD_PROG=`$CC --print-prog-name=ld` -LD_VERSION=`$LD_PROG --version` -LD_VERSION_MAJOR=`echo "$LD_VERSION" | head -1 | cut -d '.' -f 1 | cut -d ' ' -f 4` -LD_VERSION_MINOR=`echo "$LD_VERSION" | head -1 | cut -d '.' -f 2` -if expr "$LD_VERSION_MAJOR" \> 2 > /dev/null; then - LD_OK="ok" -else - if expr "$LD_VERSION_MAJOR" = 2 && expr "$LD_VERSION_MINOR" \>= 13 > /dev/null; then - LD_OK="ok" - fi -fi -if test "x$LD_OK" != x; then - echo "$ac_t""yes; major=$LD_VERSION_MAJOR, minor=$LD_VERSION_MINOR" 1>&6 -else - echo "$ac_t""no; major=$LD_VERSION_MAJOR, minor=$LD_VERSION_MINOR" 1>&6 - echo "configure: warning: ld <2.13 detected; enabling JV_LINKER_CANNOT_8BYTE_ALIGN_STATICS hack..." 1>&2 - cat >> confdefs.h <<\EOF -#define JV_LINKER_CANNOT_8BYTE_ALIGN_STATICS 1 -EOF - -fi + CHECK_FOR_BROKEN_MINGW_LD ;; *) PLATFORM=Posix @@ -2995,7 +2969,7 @@ esac echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:2999: checking how to run the C preprocessor" >&5 +echo "configure:2973: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -3010,13 +2984,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3020: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2994: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -3027,13 +3001,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3037: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3011: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -3044,13 +3018,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3054: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3028: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -3075,7 +3049,7 @@ fi echo "$ac_t""$CPP" 1>&6 cat > conftest.$ac_ext < EOF @@ -3090,7 +3064,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3105,7 +3079,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3120,7 +3094,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3137,7 +3111,7 @@ rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3152,7 +3126,7 @@ fi rm -f conftest* cat > conftest.$ac_ext < EOF @@ -3204,7 +3178,7 @@ ZLIBTESTSPEC= libsubdir=.libs echo $ac_n "checking for garbage collector to use""... $ac_c" 1>&6 -echo "configure:3208: checking for garbage collector to use" >&5 +echo "configure:3182: checking for garbage collector to use" >&5 # Check whether --enable-java-gc or --disable-java-gc was given. if test "${enable_java_gc+set}" = set; then enableval="$enable_java_gc" @@ -3257,7 +3231,7 @@ esac echo $ac_n "checking for thread model used by GCC""... $ac_c" 1>&6 -echo "configure:3261: checking for thread model used by GCC" >&5 +echo "configure:3235: checking for thread model used by GCC" >&5 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` echo "$ac_t""$THREADS" 1>&6 @@ -3465,12 +3439,12 @@ else for ac_func in strerror ioctl select fstat open fsync sleep opendir do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3469: checking for $ac_func" >&5 +echo "configure:3443: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3520,12 +3494,12 @@ done for ac_func in gmtime_r localtime_r readdir_r getpwuid_r getcwd do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3524: checking for $ac_func" >&5 +echo "configure:3498: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3575,12 +3549,12 @@ done for ac_func in access stat mkdir rename rmdir unlink realpath utime chmod do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3579: checking for $ac_func" >&5 +echo "configure:3553: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3581: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3630,12 +3604,12 @@ done for ac_func in nl_langinfo setlocale do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3634: checking for $ac_func" >&5 +echo "configure:3608: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3685,12 +3659,12 @@ done for ac_func in inet_aton inet_addr do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3689: checking for $ac_func" >&5 +echo "configure:3663: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3740,12 +3714,12 @@ done for ac_func in inet_pton uname inet_ntoa do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3744: checking for $ac_func" >&5 +echo "configure:3718: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3795,12 +3769,12 @@ done for ac_func in fork execvp pipe sigaction ftruncate do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3799: checking for $ac_func" >&5 +echo "configure:3773: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3851,17 +3825,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3855: checking for $ac_hdr" >&5 +echo "configure:3829: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3865: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3839: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3888,12 +3862,12 @@ fi done echo $ac_n "checking for backtrace""... $ac_c" 1>&6 -echo "configure:3892: checking for backtrace" >&5 +echo "configure:3866: checking for backtrace" >&5 if eval "test \"`echo '$''{'ac_cv_func_backtrace'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3894: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_backtrace=yes" else @@ -3952,7 +3926,7 @@ fi echo $ac_n "checking for dladdr in -ldl""... $ac_c" 1>&6 -echo "configure:3956: checking for dladdr in -ldl" >&5 +echo "configure:3930: checking for dladdr in -ldl" >&5 ac_lib_var=`echo dl'_'dladdr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3960,7 +3934,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3949: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4001,7 +3975,7 @@ do ac_safe=`echo "$ac_file" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_file""... $ac_c" 1>&6 -echo "configure:4005: checking for $ac_file" >&5 +echo "configure:3979: checking for $ac_file" >&5 if eval "test \"`echo '$''{'ac_cv_file_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4059,7 +4033,7 @@ fi echo $ac_n "checking for iconv""... $ac_c" 1>&6 -echo "configure:4063: checking for iconv" >&5 +echo "configure:4037: checking for iconv" >&5 if eval "test \"`echo '$''{'am_cv_func_iconv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4067,7 +4041,7 @@ else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat > conftest.$ac_ext < #include @@ -4077,7 +4051,7 @@ iconv_t cd = iconv_open("",""); iconv_close(cd); ; return 0; } EOF -if { (eval echo configure:4081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_func_iconv=yes else @@ -4089,7 +4063,7 @@ rm -f conftest* am_save_LIBS="$LIBS" LIBS="$LIBS $am_cv_libiconv_ldpath -liconv" cat > conftest.$ac_ext < #include @@ -4099,7 +4073,7 @@ iconv_t cd = iconv_open("",""); iconv_close(cd); ; return 0; } EOF -if { (eval echo configure:4103: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_lib_iconv=yes am_cv_func_iconv=yes @@ -4120,13 +4094,13 @@ echo "$ac_t""$am_cv_func_iconv" 1>&6 EOF echo $ac_n "checking for iconv declaration""... $ac_c" 1>&6 -echo "configure:4124: checking for iconv declaration" >&5 +echo "configure:4098: checking for iconv declaration" >&5 if eval "test \"`echo '$''{'am_cv_proto_iconv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4145,7 +4119,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:4149: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4123: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_proto_iconv_arg1="" else @@ -4174,19 +4148,19 @@ EOF if test $ac_cv_header_locale_h = yes; then echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 -echo "configure:4178: checking for LC_MESSAGES" >&5 +echo "configure:4152: checking for LC_MESSAGES" >&5 if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return LC_MESSAGES ; return 0; } EOF -if { (eval echo configure:4190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_val_LC_MESSAGES=yes else @@ -4207,12 +4181,12 @@ EOF fi fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:4211: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:4185: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4220,7 +4194,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:4224: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4198: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -4241,12 +4215,12 @@ EOF fi echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6 -echo "configure:4245: checking for tm_zone in struct tm" >&5 +echo "configure:4219: checking for tm_zone in struct tm" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_cv_struct_tm> @@ -4254,7 +4228,7 @@ int main() { struct tm tm; tm.tm_zone; ; return 0; } EOF -if { (eval echo configure:4258: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4232: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm_zone=yes else @@ -4274,12 +4248,12 @@ EOF else echo $ac_n "checking for tzname""... $ac_c" 1>&6 -echo "configure:4278: checking for tzname" >&5 +echo "configure:4252: checking for tzname" >&5 if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifndef tzname /* For SGI. */ @@ -4289,7 +4263,7 @@ int main() { atoi(*tzname); ; return 0; } EOF -if { (eval echo configure:4293: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_var_tzname=yes else @@ -4314,12 +4288,12 @@ fi for ac_func in gethostbyname_r do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4318: checking for $ac_func" >&5 +echo "configure:4292: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4369,7 +4343,7 @@ EOF # We look for the one that returns `int'. # Hopefully this check is robust enough. cat > conftest.$ac_ext < EOF @@ -4389,7 +4363,7 @@ rm -f conftest* *" -D_REENTRANT "*) ;; *) echo $ac_n "checking whether gethostbyname_r declaration requires -D_REENTRANT""... $ac_c" 1>&6 -echo "configure:4393: checking whether gethostbyname_r declaration requires -D_REENTRANT" >&5 +echo "configure:4367: checking whether gethostbyname_r declaration requires -D_REENTRANT" >&5 if eval "test \"`echo '$''{'libjava_cv_gethostbyname_r_needs_reentrant'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4402,14 +4376,14 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext < int main() { gethostbyname_r("", 0, 0); ; return 0; } EOF -if { (eval echo configure:4413: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4387: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libjava_cv_gethostbyname_r_needs_reentrant=no else @@ -4419,14 +4393,14 @@ else CPPFLAGS_SAVE="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -D_REENTRANT" cat > conftest.$ac_ext < int main() { gethostbyname_r("", 0, 0); ; return 0; } EOF -if { (eval echo configure:4430: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4404: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libjava_cv_gethostbyname_r_needs_reentrant=yes else @@ -4461,12 +4435,12 @@ EOF esac echo $ac_n "checking for struct hostent_data""... $ac_c" 1>&6 -echo "configure:4465: checking for struct hostent_data" >&5 +echo "configure:4439: checking for struct hostent_data" >&5 if eval "test \"`echo '$''{'libjava_cv_struct_hostent_data'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4455: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libjava_cv_struct_hostent_data=yes else @@ -4509,7 +4483,7 @@ done # to exist where expected. (The root issue: AC_CHECK_FUNCS assumes C # linkage check is enough, yet C++ code requires proper prototypes.) cat > conftest.$ac_ext < EOF @@ -4520,12 +4494,12 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | for ac_func in gethostbyaddr_r do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4524: checking for $ac_func" >&5 +echo "configure:4498: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4575,7 +4549,7 @@ EOF # We look for the one that returns `int'. # Hopefully this check is robust enough. cat > conftest.$ac_ext < EOF @@ -4602,12 +4576,12 @@ rm -f conftest* for ac_func in gethostname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4606: checking for $ac_func" >&5 +echo "configure:4580: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4654,7 +4628,7 @@ EOF EOF cat > conftest.$ac_ext < EOF @@ -4685,12 +4659,12 @@ done for ac_func in pthread_mutexattr_settype pthread_mutexattr_setkind_np do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4689: checking for $ac_func" >&5 +echo "configure:4663: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4743,12 +4717,12 @@ done for ac_func in sched_yield do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4747: checking for $ac_func" >&5 +echo "configure:4721: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4793,7 +4767,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for sched_yield in -lrt""... $ac_c" 1>&6 -echo "configure:4797: checking for sched_yield in -lrt" >&5 +echo "configure:4771: checking for sched_yield in -lrt" >&5 ac_lib_var=`echo rt'_'sched_yield | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4801,7 +4775,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lrt $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4838,7 +4812,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for sched_yield in -lposix4""... $ac_c" 1>&6 -echo "configure:4842: checking for sched_yield in -lposix4" >&5 +echo "configure:4816: checking for sched_yield in -lposix4" >&5 ac_lib_var=`echo posix4'_'sched_yield | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4846,7 +4820,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix4 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4835: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4893,7 +4867,7 @@ done # We can save a little space at runtime if the mutex has m_count # or __m_count. This is a nice hack for Linux. cat > conftest.$ac_ext < int main() { @@ -4902,7 +4876,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:4906: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4880: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define PTHREAD_MUTEX_HAVE_M_COUNT 1 @@ -4914,7 +4888,7 @@ else rm -rf conftest* cat > conftest.$ac_ext < int main() { @@ -4923,7 +4897,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:4927: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4901: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define PTHREAD_MUTEX_HAVE___M_COUNT 1 @@ -4943,12 +4917,12 @@ rm -f conftest* for ac_func in gettimeofday time ftime do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4947: checking for $ac_func" >&5 +echo "configure:4921: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4949: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5002,12 +4976,12 @@ done for ac_func in memmove do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5006: checking for $ac_func" >&5 +echo "configure:4980: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5008: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5060,12 +5034,12 @@ done for ac_func in memcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5064: checking for $ac_func" >&5 +echo "configure:5038: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5117,7 +5091,7 @@ done fi echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:5121: checking for dlopen in -ldl" >&5 +echo "configure:5095: checking for dlopen in -ldl" >&5 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5125,7 +5099,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5114: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5181,7 +5155,7 @@ fi #-------------------------------------------------------------------- echo $ac_n "checking for socket libraries""... $ac_c" 1>&6 -echo "configure:5185: checking for socket libraries" >&5 +echo "configure:5159: checking for socket libraries" >&5 if eval "test \"`echo '$''{'gcj_cv_lib_sockets'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5189,12 +5163,12 @@ else gcj_checkBoth=0 unset ac_cv_func_connect echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:5193: checking for connect" >&5 +echo "configure:5167: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -5240,7 +5214,7 @@ fi if test "$gcj_checkSocket" = 1; then unset ac_cv_func_connect echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6 -echo "configure:5244: checking for main in -lsocket" >&5 +echo "configure:5218: checking for main in -lsocket" >&5 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5248,14 +5222,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5282,12 +5256,12 @@ fi LIBS="$LIBS -lsocket -lnsl" unset ac_cv_func_accept echo $ac_n "checking for accept""... $ac_c" 1>&6 -echo "configure:5286: checking for accept" >&5 +echo "configure:5260: checking for accept" >&5 if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5288: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_accept=yes" else @@ -5337,12 +5311,12 @@ fi gcj_oldLibs=$LIBS LIBS="$LIBS $gcj_cv_lib_sockets" echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:5341: checking for gethostbyname" >&5 +echo "configure:5315: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -5383,7 +5357,7 @@ if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6 -echo "configure:5387: checking for main in -lnsl" >&5 +echo "configure:5361: checking for main in -lnsl" >&5 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5391,14 +5365,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5376: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5430,7 +5404,7 @@ echo "$ac_t""$gcj_cv_lib_sockets" 1>&6 if test "$with_system_zlib" = yes; then echo $ac_n "checking for deflate in -lz""... $ac_c" 1>&6 -echo "configure:5434: checking for deflate in -lz" >&5 +echo "configure:5408: checking for deflate in -lz" >&5 ac_lib_var=`echo z'_'deflate | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5438,7 +5412,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5476,7 +5450,7 @@ fi # requires -ldl. if test "$GC" = boehm; then echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6 -echo "configure:5480: checking for main in -ldl" >&5 +echo "configure:5454: checking for main in -ldl" >&5 ac_lib_var=`echo dl'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5484,14 +5458,14 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -5557,7 +5531,7 @@ fi # Extract the first word of "${ac_tool_prefix}gcj", so it can be a program name with args. set dummy ${ac_tool_prefix}gcj; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5561: checking for $ac_word" >&5 +echo "configure:5535: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GCJ'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5589,7 +5563,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "gcj", so it can be a program name with args. set dummy gcj; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5593: checking for $ac_word" >&5 +echo "configure:5567: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GCJ'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5651,13 +5625,13 @@ exec 5>>./config.log CPPFLAGS=$GCJ_SAVE_CPPFLAGS echo $ac_n "checking size of void *""... $ac_c" 1>&6 -echo "configure:5655: checking size of void *" >&5 +echo "configure:5629: checking size of void *" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_void_p'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else for ac_size in 4 8 1 2 16 12 ; do # List sizes in rough order of prevalence. cat > conftest.$ac_ext < @@ -5667,7 +5641,7 @@ int main() { switch (0) case 0: case (sizeof (void *) == $ac_size):; ; return 0; } EOF -if { (eval echo configure:5671: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5645: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sizeof_void_p=$ac_size else @@ -5768,18 +5742,18 @@ EOF echo $ac_n "checking for g++ -ffloat-store bug""... $ac_c" 1>&6 -echo "configure:5772: checking for g++ -ffloat-store bug" >&5 +echo "configure:5746: checking for g++ -ffloat-store bug" >&5 save_CFLAGS="$CFLAGS" CFLAGS="-x c++ -O2 -ffloat-store" cat > conftest.$ac_ext < int main() { ; return 0; } EOF -if { (eval echo configure:5783: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5757: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""no" 1>&6 else @@ -5799,17 +5773,17 @@ for ac_hdr in unistd.h bstring.h sys/time.h sys/types.h fcntl.h sys/ioctl.h sys/ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5803: checking for $ac_hdr" >&5 +echo "configure:5777: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5813: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5787: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5839,17 +5813,17 @@ for ac_hdr in dirent.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5843: checking for $ac_hdr" >&5 +echo "configure:5817: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5879,17 +5853,17 @@ for ac_hdr in inttypes.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5883: checking for $ac_hdr" >&5 +echo "configure:5857: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5867: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5925,12 +5899,12 @@ fi done echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:5929: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:5903: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5946,7 +5920,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:5950: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5924: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -5968,12 +5942,12 @@ fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:5972: checking for ANSI C header files" >&5 +echo "configure:5946: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -5981,7 +5955,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5959: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5998,7 +5972,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -6016,7 +5990,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -6037,7 +6011,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -6048,7 +6022,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:6052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -6072,12 +6046,12 @@ EOF fi echo $ac_n "checking for ssize_t""... $ac_c" 1>&6 -echo "configure:6076: checking for ssize_t" >&5 +echo "configure:6050: checking for ssize_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -6106,9 +6080,9 @@ fi echo $ac_n "checking for in_addr_t""... $ac_c" 1>&6 -echo "configure:6110: checking for in_addr_t" >&5 +echo "configure:6084: checking for in_addr_t" >&5 cat > conftest.$ac_ext < #if STDC_HEADERS @@ -6122,7 +6096,7 @@ int main() { in_addr_t foo; ; return 0; } EOF -if { (eval echo configure:6126: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6100: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_IN_ADDR_T 1 @@ -6138,16 +6112,16 @@ fi rm -f conftest* echo $ac_n "checking whether struct ip_mreq is in netinet/in.h""... $ac_c" 1>&6 -echo "configure:6142: checking whether struct ip_mreq is in netinet/in.h" >&5 +echo "configure:6116: checking whether struct ip_mreq is in netinet/in.h" >&5 cat > conftest.$ac_ext < int main() { struct ip_mreq mreq; ; return 0; } EOF -if { (eval echo configure:6151: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6125: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_STRUCT_IP_MREQ 1 @@ -6163,16 +6137,16 @@ fi rm -f conftest* echo $ac_n "checking whether struct ipv6_mreq is in netinet/in.h""... $ac_c" 1>&6 -echo "configure:6167: checking whether struct ipv6_mreq is in netinet/in.h" >&5 +echo "configure:6141: checking whether struct ipv6_mreq is in netinet/in.h" >&5 cat > conftest.$ac_ext < int main() { struct ipv6_mreq mreq6; ; return 0; } EOF -if { (eval echo configure:6176: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6150: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_STRUCT_IPV6_MREQ 1 @@ -6188,16 +6162,16 @@ fi rm -f conftest* echo $ac_n "checking whether struct sockaddr_in6 is in netinet/in.h""... $ac_c" 1>&6 -echo "configure:6192: checking whether struct sockaddr_in6 is in netinet/in.h" >&5 +echo "configure:6166: checking whether struct sockaddr_in6 is in netinet/in.h" >&5 cat > conftest.$ac_ext < int main() { struct sockaddr_in6 addr6; ; return 0; } EOF -if { (eval echo configure:6201: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6175: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_INET6 1 @@ -6213,9 +6187,9 @@ fi rm -f conftest* echo $ac_n "checking for socklen_t in sys/socket.h""... $ac_c" 1>&6 -echo "configure:6217: checking for socklen_t in sys/socket.h" >&5 +echo "configure:6191: checking for socklen_t in sys/socket.h" >&5 cat > conftest.$ac_ext < @@ -6224,7 +6198,7 @@ int main() { socklen_t x = 5; ; return 0; } EOF -if { (eval echo configure:6228: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6202: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_SOCKLEN_T 1 @@ -6240,16 +6214,16 @@ fi rm -f conftest* echo $ac_n "checking for tm_gmtoff in struct tm""... $ac_c" 1>&6 -echo "configure:6244: checking for tm_gmtoff in struct tm" >&5 +echo "configure:6218: checking for tm_gmtoff in struct tm" >&5 cat > conftest.$ac_ext < int main() { struct tm tim; tim.tm_gmtoff = 0; ; return 0; } EOF -if { (eval echo configure:6253: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6227: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define STRUCT_TM_HAS_GMTOFF 1 @@ -6262,16 +6236,16 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6 echo $ac_n "checking for global timezone variable""... $ac_c" 1>&6 -echo "configure:6266: checking for global timezone variable" >&5 +echo "configure:6240: checking for global timezone variable" >&5 cat > conftest.$ac_ext < int main() { void i(){long z2 = 2*timezone;} ; return 0; } EOF -if { (eval echo configure:6275: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6249: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_TIMEZONE 1 @@ -6284,16 +6258,16 @@ else rm -rf conftest* echo "$ac_t""no" 1>&6 echo $ac_n "checking for global _timezone variable""... $ac_c" 1>&6 -echo "configure:6288: checking for global _timezone variable" >&5 +echo "configure:6262: checking for global _timezone variable" >&5 cat > conftest.$ac_ext < int main() { long z2 = _timezone; ; return 0; } EOF -if { (eval echo configure:6297: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6271: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_UNDERSCORE_TIMEZONE 1 @@ -6315,19 +6289,19 @@ rm -f conftest* # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:6319: checking for working alloca.h" >&5 +echo "configure:6293: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:6331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -6348,12 +6322,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:6352: checking for alloca" >&5 +echo "configure:6326: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -6413,12 +6387,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:6417: checking whether alloca needs Cray hooks" >&5 +echo "configure:6391: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6447: checking for $ac_func" >&5 +echo "configure:6421: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6498,7 +6472,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:6502: checking stack direction for C alloca" >&5 +echo "configure:6476: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6506,7 +6480,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -6552,7 +6526,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6556: checking for $ac_word" >&5 +echo "configure:6530: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6614,6 +6588,9 @@ case "${host}" in sparc*-*-linux*) SIGNAL_HANDLER=include/dwarf2-signal.h ;; + sh-*-linux* | sh[34]*-*-linux*) + SIGNAL_HANDLER=include/dwarf2-signal.h + ;; *mingw*) SIGNAL_HANDLER=include/win32-signal.h ;; @@ -6642,7 +6619,7 @@ fi # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 -echo "configure:6646: checking for X" >&5 +echo "configure:6623: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then @@ -6704,12 +6681,12 @@ if test "$ac_x_includes" = NO; then # First, try using that file with no special directory specified. cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6713: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6690: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -6778,14 +6755,14 @@ if test "$ac_x_libraries" = NO; then ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6766: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. @@ -6891,17 +6868,17 @@ else case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 -echo "configure:6895: checking whether -R must be followed by a space" >&5 +echo "configure:6872: checking whether -R must be followed by a space" >&5 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6882: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_nospace=yes else @@ -6917,14 +6894,14 @@ rm -f conftest* else LIBS="$ac_xsave_LIBS -R $x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_space=yes else @@ -6956,7 +6933,7 @@ rm -f conftest* # libraries were built with DECnet support. And karl@cs.umb.edu says # the Alpha needs dnet_stub (dnet does not exist). echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 -echo "configure:6960: checking for dnet_ntoa in -ldnet" >&5 +echo "configure:6937: checking for dnet_ntoa in -ldnet" >&5 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6964,7 +6941,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6997,7 +6974,7 @@ fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 -echo "configure:7001: checking for dnet_ntoa in -ldnet_stub" >&5 +echo "configure:6978: checking for dnet_ntoa in -ldnet_stub" >&5 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7005,7 +6982,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7045,12 +7022,12 @@ fi # The nsl library prevents programs from opening the X display # on Irix 5.2, according to dickey@clark.net. echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:7049: checking for gethostbyname" >&5 +echo "configure:7026: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7054: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -7094,7 +7071,7 @@ fi if test $ac_cv_func_gethostbyname = no; then echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:7098: checking for gethostbyname in -lnsl" >&5 +echo "configure:7075: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7102,7 +7079,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7094: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7143,12 +7120,12 @@ fi # -lsocket must be given before -lnsl if both are needed. # We assume that if connect needs -lnsl, so does gethostbyname. echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:7147: checking for connect" >&5 +echo "configure:7124: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -7192,7 +7169,7 @@ fi if test $ac_cv_func_connect = no; then echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:7196: checking for connect in -lsocket" >&5 +echo "configure:7173: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7200,7 +7177,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7235,12 +7212,12 @@ fi # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. echo $ac_n "checking for remove""... $ac_c" 1>&6 -echo "configure:7239: checking for remove" >&5 +echo "configure:7216: checking for remove" >&5 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_remove=yes" else @@ -7284,7 +7261,7 @@ fi if test $ac_cv_func_remove = no; then echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 -echo "configure:7288: checking for remove in -lposix" >&5 +echo "configure:7265: checking for remove in -lposix" >&5 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7292,7 +7269,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7284: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7327,12 +7304,12 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo $ac_n "checking for shmat""... $ac_c" 1>&6 -echo "configure:7331: checking for shmat" >&5 +echo "configure:7308: checking for shmat" >&5 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_shmat=yes" else @@ -7376,7 +7353,7 @@ fi if test $ac_cv_func_shmat = no; then echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 -echo "configure:7380: checking for shmat in -lipc" >&5 +echo "configure:7357: checking for shmat in -lipc" >&5 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7384,7 +7361,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lipc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7376: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7428,7 +7405,7 @@ fi # libraries we check for below, so use a different variable. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 -echo "configure:7432: checking for IceConnectionNumber in -lICE" >&5 +echo "configure:7409: checking for IceConnectionNumber in -lICE" >&5 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7436,7 +7413,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else diff --git a/libjava/configure.host b/libjava/configure.host index f5d1ef07cda..8f3f3bb9ad2 100644 --- a/libjava/configure.host +++ b/libjava/configure.host @@ -144,8 +144,6 @@ case "${host}" in sysdeps_dir=sh libgcj_flags="${libgcj_flags} -mieee" libgcj_interpreter=yes - CHECKREFSPEC=-fcheck-references - EXCEPTIONSPEC= enable_hash_synchronization_default=yes ;; esac @@ -161,7 +159,8 @@ case "${host}" in s390*-linux* | \ sparc*-linux* | \ ia64-* | \ - x86_64*-linux*) + x86_64*-linux* | \ + sh-linux* | sh[34]*-linux*) can_unwind_signal=yes ;; *-*-darwin*) diff --git a/libjava/configure.in b/libjava/configure.in index 59f821accce..868dc1cffde 100644 --- a/libjava/configure.in +++ b/libjava/configure.in @@ -921,6 +921,9 @@ case "${host}" in sparc*-*-linux*) SIGNAL_HANDLER=include/dwarf2-signal.h ;; + sh-*-linux* | sh[[34]]*-*-linux*) + SIGNAL_HANDLER=include/dwarf2-signal.h + ;; *mingw*) SIGNAL_HANDLER=include/win32-signal.h ;; diff --git a/libjava/defineclass.cc b/libjava/defineclass.cc index 6a250dadda6..dc350028cdd 100644 --- a/libjava/defineclass.cc +++ b/libjava/defineclass.cc @@ -1184,15 +1184,17 @@ void _Jv_ClassReader::handleFieldsEnd () void _Jv_ClassReader::handleMethodsBegin (int count) { - def->methods = (_Jv_Method*) - _Jv_AllocBytes (sizeof (_Jv_Method)*count); + def->methods = (_Jv_Method *) _Jv_AllocBytes (sizeof (_Jv_Method) * count); def->interpreted_methods = (_Jv_MethodBase **) _Jv_AllocBytes (sizeof (_Jv_MethodBase *) * count); for (int i = 0; i < count; i++) - def->interpreted_methods[i] = 0; + { + def->interpreted_methods[i] = 0; + def->methods[i].index = (_Jv_ushort) -1; + } def->method_count = count; } @@ -1376,12 +1378,14 @@ throw_internal_error (char *msg) throw new java::lang::InternalError (JvNewStringLatin1 (msg)); } -static void throw_incompatible_class_change_error (jstring msg) +static void +throw_incompatible_class_change_error (jstring msg) { throw new java::lang::IncompatibleClassChangeError (msg); } -static void throw_class_circularity_error (jstring msg) +static void +throw_class_circularity_error (jstring msg) { throw new java::lang::ClassCircularityError (msg); } diff --git a/libjava/gnu/gcj/protocol/jar/Connection.java b/libjava/gnu/gcj/protocol/jar/Connection.java index 60641182f3a..c9db04997dc 100644 --- a/libjava/gnu/gcj/protocol/jar/Connection.java +++ b/libjava/gnu/gcj/protocol/jar/Connection.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation +/* Copyright (C) 1999, 2002 Free Software Foundation This file is part of libgcj. @@ -9,19 +9,21 @@ details. */ package gnu.gcj.protocol.jar; import java.net.URL; +import java.net.URLConnection; import java.net.JarURLConnection; import java.net.URLStreamHandler; import java.net.MalformedURLException; import java.net.ProtocolException; import java.io.IOException; +import java.io.InputStream; +import java.io.File; +import java.io.FileOutputStream; import java.util.jar.JarFile; +import java.util.zip.ZipFile; import java.util.Hashtable; /** * Written using on-line Java Platform 1.2 API Specification. - * Status: Needs a way to download jar files and store them in the local file - * system. I don't know how to do that in a portable way. For now, it can only handle - * connections to a jar:file: url's. * * @author Kresten Krab Thorup * @date Aug 10, 1999. @@ -70,14 +72,19 @@ public class Connection extends JarURLConnection } else { - /* - FIXME: Here we need to download and cache the jar - file in the local file system! Stupid design. Why - can't we just create a JarFile from a bag of bytes? - */ - - throw new java.io.IOException("cannot create jar file from " + - jarFileURL); + URLConnection urlconn = jarFileURL.openConnection(); + InputStream is = urlconn.getInputStream(); + byte[] buf = new byte[4*1024]; + File f = File.createTempFile("cache", "jar"); + FileOutputStream fos = new FileOutputStream(f); + int len = 0; + while((len = is.read(buf)) != -1) + fos.write(buf, 0, len); + fos.close(); + // Always verify the Manifest, open read only and delete when done. + // XXX ZipFile.OPEN_DELETE not yet implemented. + // jf = new JarFile(f, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE); + jarfile = new JarFile(f, true, ZipFile.OPEN_READ); } return jarfile; diff --git a/libjava/gnu/gcj/runtime/VMClassLoader.java b/libjava/gnu/gcj/runtime/VMClassLoader.java index 77d21606621..fd0c32c2c57 100644 --- a/libjava/gnu/gcj/runtime/VMClassLoader.java +++ b/libjava/gnu/gcj/runtime/VMClassLoader.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2001 Free Software Foundation +/* Copyright (C) 1999, 2001, 2002 Free Software Foundation This file is part of libgcj. @@ -33,23 +33,10 @@ public final class VMClassLoader extends java.net.URLClassLoader String e = st.nextToken (); try { - if (e.endsWith(".jar") || e.endsWith (".zip")) - { - File archive = new File (e); - try { - p.addElement(new URL("jar", "", -1, "file://" - + archive.getCanonicalPath () - + "!/")); - } catch (IOException ex) { - // empty - } - } - else if (e.endsWith ("/")) - p.addElement (new URL("file", "", -1, e)); - else if (new File (e).isDirectory ()) - p.addElement (new URL("file", "", -1, e + "/")); + if (!e.endsWith (File.separator) && new File (e).isDirectory ()) + p.addElement (new URL("file", "", -1, e + File.separator)); else - /* Ignore path element. */; + p.addElement (new URL("file", "", -1, e)); } catch (java.net.MalformedURLException x) { diff --git a/libjava/gnu/java/nio/ByteBufferImpl.java b/libjava/gnu/java/nio/ByteBufferImpl.java index e27207ef55c..54fba2492e1 100644 --- a/libjava/gnu/java/nio/ByteBufferImpl.java +++ b/libjava/gnu/java/nio/ByteBufferImpl.java @@ -54,24 +54,24 @@ public final class ByteBufferImpl extends ByteBuffer public ByteBufferImpl (int cap, int off, int lim) { this.cap = cap; - position (off); limit (lim); + position (off); this.backing_buffer = new byte[cap]; } public ByteBufferImpl (byte[] array, int off, int lim) { this.cap = array.length; - position (off); limit (lim); + position (off); this.backing_buffer = array; } public ByteBufferImpl (ByteBufferImpl copy) { this.cap = copy.capacity (); - position (copy.position ()); limit (copy.limit ()); + position (copy.position ()); ro = copy.ro; backing_buffer = copy.backing_buffer; } @@ -81,71 +81,50 @@ public final class ByteBufferImpl extends ByteBuffer position (position () + toAdd); } -// private static native byte[] nio_cast(byte[]copy); -// private static native byte[] nio_cast(char[]copy); -// private static native byte[] nio_cast(short[]copy); -// private static native byte[] nio_cast(long[]copy); -// private static native byte[] nio_cast(int[]copy); -// private static native byte[] nio_cast(float[]copy); -// private static native byte[] nio_cast(double[]copy); - - private static byte[] nio_cast(byte[]copy) { return null; }; - private static byte[] nio_cast(char[]copy) { return null; }; - private static byte[] nio_cast(short[]copy) { return null; }; - private static byte[] nio_cast(long[]copy) { return null; }; - private static byte[] nio_cast(int[]copy) { return null; }; - private static byte[] nio_cast(float[]copy) { return null; }; - private static byte[] nio_cast(double[]copy) { return null; }; + private static native byte[] nio_cast(byte[]copy); + private static native byte[] nio_cast(char[]copy); + private static native byte[] nio_cast(short[]copy); + private static native byte[] nio_cast(long[]copy); + private static native byte[] nio_cast(int[]copy); + private static native byte[] nio_cast(float[]copy); + private static native byte[] nio_cast(double[]copy); + ByteBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native byte nio_get_Byte(ByteBufferImpl b, int index, int limit); -// private static native void nio_put_Byte(ByteBufferImpl b, int index, int limit, byte value); - private static byte nio_get_Byte(ByteBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Byte(ByteBufferImpl b, int index, int limit, byte value) { }; + private static native byte nio_get_Byte(ByteBufferImpl b, int index, int limit); + private static native void nio_put_Byte(ByteBufferImpl b, int index, int limit, byte value); public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/1); return res; } ByteBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native char nio_get_Char(ByteBufferImpl b, int index, int limit); -// private static native void nio_put_Char(ByteBufferImpl b, int index, int limit, char value); - private static char nio_get_Char(ByteBufferImpl b, int index, int limit) { return ' '; }; - private static void nio_put_Char(ByteBufferImpl b, int index, int limit, char value) { }; + private static native char nio_get_Char(ByteBufferImpl b, int index, int limit); + private static native void nio_put_Char(ByteBufferImpl b, int index, int limit, char value); public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/1); return res; } ByteBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native short nio_get_Short(ByteBufferImpl b, int index, int limit); -// private static native void nio_put_Short(ByteBufferImpl b, int index, int limit, short value); - private static short nio_get_Short(ByteBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Short(ByteBufferImpl b, int index, int limit, short value) { }; + private static native short nio_get_Short(ByteBufferImpl b, int index, int limit); + private static native void nio_put_Short(ByteBufferImpl b, int index, int limit, short value); public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/1); return res; } ByteBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native int nio_get_Int(ByteBufferImpl b, int index, int limit); -// private static native void nio_put_Int(ByteBufferImpl b, int index, int limit, int value); - private static int nio_get_Int(ByteBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Int(ByteBufferImpl b, int index, int limit, int value) { }; + private static native int nio_get_Int(ByteBufferImpl b, int index, int limit); + private static native void nio_put_Int(ByteBufferImpl b, int index, int limit, int value); public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/1); return res; } ByteBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native long nio_get_Long(ByteBufferImpl b, int index, int limit); -// private static native void nio_put_Long(ByteBufferImpl b, int index, int limit, long value); - private static long nio_get_Long(ByteBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Long(ByteBufferImpl b, int index, int limit, long value) { }; + private static native long nio_get_Long(ByteBufferImpl b, int index, int limit); + private static native void nio_put_Long(ByteBufferImpl b, int index, int limit, long value); public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/1); return res; } ByteBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native float nio_get_Float(ByteBufferImpl b, int index, int limit); -// private static native void nio_put_Float(ByteBufferImpl b, int index, int limit, float value); - private static float nio_get_Float(ByteBufferImpl b, int index, int limit) { return 0.0f; }; - private static void nio_put_Float(ByteBufferImpl b, int index, int limit, float value) { }; + private static native float nio_get_Float(ByteBufferImpl b, int index, int limit); + private static native void nio_put_Float(ByteBufferImpl b, int index, int limit, float value); public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/1); return res; } ByteBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native double nio_get_Double(ByteBufferImpl b, int index, int limit); -// private static native void nio_put_Double(ByteBufferImpl b, int index, int limit, double value); - private static double nio_get_Double(ByteBufferImpl b, int index, int limit) { return 0.0d; }; - private static void nio_put_Double(ByteBufferImpl b, int index, int limit, double value) { }; + private static native double nio_get_Double(ByteBufferImpl b, int index, int limit); + private static native void nio_put_Double(ByteBufferImpl b, int index, int limit, double value); public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/1); return res; } - + public boolean isReadOnly() { return ro; @@ -157,19 +136,19 @@ public final class ByteBufferImpl extends ByteBuffer A.array_offset = position(); return A; } - + public ByteBuffer duplicate() { return new ByteBufferImpl(this); } - + public ByteBuffer asReadOnlyBuffer() { ByteBufferImpl a = new ByteBufferImpl(this); a.ro = true; return a; } - + public ByteBuffer compact() { return this; @@ -179,7 +158,7 @@ public final class ByteBufferImpl extends ByteBuffer { return backing_buffer != null; } - + final public byte get() { byte e = backing_buffer[position()]; @@ -198,7 +177,7 @@ public final class ByteBufferImpl extends ByteBuffer { return backing_buffer[index]; } - + final public ByteBuffer put(int index, byte b) { backing_buffer[index] = b; diff --git a/libjava/gnu/java/nio/CharBufferImpl.java b/libjava/gnu/java/nio/CharBufferImpl.java index 5253646cc8c..399dd6096b8 100644 --- a/libjava/gnu/java/nio/CharBufferImpl.java +++ b/libjava/gnu/java/nio/CharBufferImpl.java @@ -48,176 +48,165 @@ import java.nio.ShortBuffer; public final class CharBufferImpl extends CharBuffer { - private int array_offset; private boolean ro; + + private ByteOrder endian = ByteOrder.BIG_ENDIAN; public CharBufferImpl(int cap, int off, int lim) { this.backing_buffer = new char[cap]; this.cap = cap; - this.position(off); this.limit(lim); + this.position(off); } public CharBufferImpl(char[] array, int off, int lim) { this.backing_buffer = array; this.cap = array.length; - this.position(off); this.limit(lim); + this.position(off); } public CharBufferImpl (CharBufferImpl copy) { backing_buffer = copy.backing_buffer; ro = copy.ro; - position (copy.position ()); limit (copy.limit()); + position (copy.position ()); } void inc_pos (int a) { position (position () + a); } - -// private static native char[] nio_cast(byte[]copy); -// private static native char[] nio_cast(char[]copy); -// private static native char[] nio_cast(short[]copy); -// private static native char[] nio_cast(long[]copy); -// private static native char[] nio_cast(int[]copy); -// private static native char[] nio_cast(float[]copy); -// private static native char[] nio_cast(double[]copy); - - private static char[] nio_cast(byte[]copy) { return null; }; - private static char[] nio_cast(char[]copy) { return null; }; - private static char[] nio_cast(short[]copy) { return null; }; - private static char[] nio_cast(long[]copy) { return null; }; - private static char[] nio_cast(int[]copy) { return null; }; - private static char[] nio_cast(float[]copy) { return null; }; - private static char[] nio_cast(double[]copy) { return null; }; CharBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native byte nio_get_Byte(CharBufferImpl b, int index, int limit); -// private static native void nio_put_Byte(CharBufferImpl b, int index, int limit, byte value); - private static byte nio_get_Byte(CharBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Byte(CharBufferImpl b, int index, int limit, byte value) { }; - public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/2); return res; } + private static native byte nio_get_Byte(CharBufferImpl b, int index, int limit); + private static native void nio_put_Byte(CharBufferImpl b, int index, int limit, byte value); + public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/2); return res; } CharBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native char nio_get_Char(CharBufferImpl b, int index, int limit); -// private static native void nio_put_Char(CharBufferImpl b, int index, int limit, char value); - private static char nio_get_Char(CharBufferImpl b, int index, int limit) { return ' '; }; - private static void nio_put_Char(CharBufferImpl b, int index, int limit, char value) { }; - public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; } + private static native char nio_get_Char(CharBufferImpl b, int index, int limit); + private static native void nio_put_Char(CharBufferImpl b, int index, int limit, char value); + public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; } CharBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native short nio_get_Short(CharBufferImpl b, int index, int limit); -// private static native void nio_put_Short(CharBufferImpl b, int index, int limit, short value); - private static short nio_get_Short(CharBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Short(CharBufferImpl b, int index, int limit, short value) { }; - public java.nio. ShortBuffer asShortBuffer() { gnu.java.nio. ShortBufferImpl res = new gnu.java.nio. ShortBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; } + private static native short nio_get_Short(CharBufferImpl b, int index, int limit); + private static native void nio_put_Short(CharBufferImpl b, int index, int limit, short value); + public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; } CharBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native int nio_get_Int(CharBufferImpl b, int index, int limit); -// private static native void nio_put_Int(CharBufferImpl b, int index, int limit, int value); - private static int nio_get_Int(CharBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Int(CharBufferImpl b, int index, int limit, int value) { }; - public java.nio. IntBuffer asIntBuffer() { gnu.java.nio. IntBufferImpl res = new gnu.java.nio. IntBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; } + private static native int nio_get_Int(CharBufferImpl b, int index, int limit); + private static native void nio_put_Int(CharBufferImpl b, int index, int limit, int value); + public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; } CharBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native long nio_get_Long(CharBufferImpl b, int index, int limit); -// private static native void nio_put_Long(CharBufferImpl b, int index, int limit, long value); - private static long nio_get_Long(CharBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Long(CharBufferImpl b, int index, int limit, long value) { }; - public java.nio. LongBuffer asLongBuffer() { gnu.java.nio. LongBufferImpl res = new gnu.java.nio. LongBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; } + private static native long nio_get_Long(CharBufferImpl b, int index, int limit); + private static native void nio_put_Long(CharBufferImpl b, int index, int limit, long value); + public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; } CharBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native float nio_get_Float(CharBufferImpl b, int index, int limit); -// private static native void nio_put_Float(CharBufferImpl b, int index, int limit, float value); - private static float nio_get_Float(CharBufferImpl b, int index, int limit) { return 0.0f; }; - private static void nio_put_Float(CharBufferImpl b, int index, int limit, float value) { }; - public java.nio. FloatBuffer asFloatBuffer() { gnu.java.nio. FloatBufferImpl res = new gnu.java.nio. FloatBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; } + private static native float nio_get_Float(CharBufferImpl b, int index, int limit); + private static native void nio_put_Float(CharBufferImpl b, int index, int limit, float value); + public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; } CharBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native double nio_get_Double(CharBufferImpl b, int index, int limit); -// private static native void nio_put_Double(CharBufferImpl b, int index, int limit, double value); - private static double nio_get_Double(CharBufferImpl b, int index, int limit) { return 0.0d; }; - private static void nio_put_Double(CharBufferImpl b, int index, int limit, double value) { }; - public java.nio. DoubleBuffer asDoubleBuffer() { gnu.java.nio. DoubleBufferImpl res = new gnu.java.nio. DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; } + private static native double nio_get_Double(CharBufferImpl b, int index, int limit); + private static native void nio_put_Double(CharBufferImpl b, int index, int limit, double value); + public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; } + + private static native char[] nio_cast(byte[]copy); + private static native char[] nio_cast(char[]copy); + private static native char[] nio_cast(short[]copy); + private static native char[] nio_cast(long[]copy); + private static native char[] nio_cast(int[]copy); + private static native char[] nio_cast(float[]copy); + private static native char[] nio_cast(double[]copy); + public boolean isReadOnly() - { - return ro; - } - public CharBuffer slice() - { - CharBufferImpl A = new CharBufferImpl(this); - A.array_offset = position(); - return A; - } - public CharBuffer duplicate() - { - return new CharBufferImpl(this); - } - public CharBuffer asReadOnlyBuffer() - { - CharBufferImpl a = new CharBufferImpl(this); - a.ro = true; - return a; - } - public CharBuffer compact() - { - return this; - } - public boolean isDirect() - { - return backing_buffer != null; - } + { + return ro; + } + + public CharBuffer slice() + { + CharBufferImpl buffer = new CharBufferImpl (this); + buffer.array_offset = position (); + return buffer; + } + + public CharBuffer duplicate() + { + return new CharBufferImpl(this); + } + + public CharBuffer asReadOnlyBuffer() + { + CharBufferImpl a = new CharBufferImpl(this); + a.ro = true; + return a; + } + + public CharBuffer compact() + { + return this; + } + + public boolean isDirect() + { + return backing_buffer != null; + } + + final public CharSequence subSequence (int start, int end) + { + if (start < 0 || + end > length () || + start > end) + throw new IndexOutOfBoundsException (); + + // No support for direct buffers yet. + // assert array () != null; + return new CharBufferImpl (array (), position () + start, + position () + end); + } + final public char get() - { - char e = backing_buffer[position()]; - position(position()+1); - return e; - } + { + char e = backing_buffer[position()]; + position(position()+1); + return e; + } + final public CharBuffer put(char b) - { - backing_buffer[position()] = b; - position(position()+1); - return this; - } - final public char get(int index) - { - return backing_buffer[index]; - } - final public java.nio. CharBuffer put(int index, char b) - { - backing_buffer[index] = b; - return this; - } - - final public char getChar() { return get(); } final public java.nio. CharBuffer putChar(char value) { return put(value); } final public char getChar(int index) { return get(index); } final public java.nio. CharBuffer putChar(int index, char value) { return put(index, value); }; - final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public java.nio. CharBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public java.nio. CharBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; - final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public java.nio. CharBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public java.nio. CharBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; }; - final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public java.nio. CharBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public java.nio. CharBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; }; - final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public java.nio. CharBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public java.nio. CharBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; }; - final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public java.nio. CharBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public java.nio. CharBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; - - public String toString() - { - if (backing_buffer != null) - { - return new String(backing_buffer, position(), limit()); - } - return super.toString(); - } + { + backing_buffer[position()] = b; + position(position()+1); + return this; + } + + final public char getChar() { return get(); } final public CharBuffer putChar(char value) { return put(value); } final public char getChar(int index) { return get(index); } final public CharBuffer putChar(int index, char value) { return put(index, value); }; + final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public CharBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public CharBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public CharBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public CharBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public CharBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public CharBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public CharBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public CharBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public CharBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public CharBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; - public final ByteOrder order() + final public char get(int index) { - return endian; + return backing_buffer[index]; } + + final public CharBuffer put(int index, char b) + { + backing_buffer[index] = b; + return this; + } + - public CharSequence subSequence(int a, int b) + public final ByteOrder order() { - return null; + return endian; } } diff --git a/libjava/gnu/java/nio/DatagramChannelImpl.java b/libjava/gnu/java/nio/DatagramChannelImpl.java index b192ef2367d..a1e0be15912 100644 --- a/libjava/gnu/java/nio/DatagramChannelImpl.java +++ b/libjava/gnu/java/nio/DatagramChannelImpl.java @@ -45,6 +45,8 @@ import java.nio.channels.spi.SelectorProvider; public class DatagramChannelImpl extends DatagramChannel { + int fd; + protected DatagramChannelImpl (SelectorProvider provider) { super (provider); diff --git a/libjava/gnu/java/nio/DoubleBufferImpl.java b/libjava/gnu/java/nio/DoubleBufferImpl.java index 40628679ef0..de0e6717fd0 100644 --- a/libjava/gnu/java/nio/DoubleBufferImpl.java +++ b/libjava/gnu/java/nio/DoubleBufferImpl.java @@ -54,24 +54,24 @@ public final class DoubleBufferImpl extends DoubleBuffer { this.backing_buffer = new double[cap]; this.cap = cap; - this.position(off); this.limit(lim); + this.position(off); } public DoubleBufferImpl(double[] array, int off, int lim) { this.backing_buffer = array; this.cap = array.length; - this.position(off); this.limit(lim); + this.position(off); } public DoubleBufferImpl(DoubleBufferImpl copy) { backing_buffer = copy.backing_buffer; ro = copy.ro; - position(copy.position()); limit(copy.limit()); + position(copy.position()); } void inc_pos(int a) @@ -79,71 +79,49 @@ public final class DoubleBufferImpl extends DoubleBuffer position(position() + a); } -// private static native double[] nio_cast(byte[]copy); -// private static native double[] nio_cast(char[]copy); -// private static native double[] nio_cast(short[]copy); -// private static native double[] nio_cast(long[]copy); -// private static native double[] nio_cast(int[]copy); -// private static native double[] nio_cast(float[]copy); -// private static native double[] nio_cast(double[]copy); - - private static double[] nio_cast(byte[]copy) { return null; }; - private static double[] nio_cast(char[]copy) { return null; }; - private static double[] nio_cast(short[]copy) { return null; }; - private static double[] nio_cast(long[]copy) { return null; }; - private static double[] nio_cast(int[]copy) { return null; }; - private static double[] nio_cast(float[]copy) { return null; }; - private static double[] nio_cast(double[]copy) { return null; }; - DoubleBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native byte nio_get_Byte(DoubleBufferImpl b, int index, int limit); -// private static native void nio_put_Byte(DoubleBufferImpl b, int index, int limit, byte value); - private static byte nio_get_Byte(DoubleBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Byte(DoubleBufferImpl b, int index, int limit, byte value) { }; + private static native byte nio_get_Byte(DoubleBufferImpl b, int index, int limit); + private static native void nio_put_Byte(DoubleBufferImpl b, int index, int limit, byte value); public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/8); return res; } DoubleBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native char nio_get_Char(DoubleBufferImpl b, int index, int limit); -// private static native void nio_put_Char(DoubleBufferImpl b, int index, int limit, char value); - private static char nio_get_Char(DoubleBufferImpl b, int index, int limit) { return ' '; }; - private static void nio_put_Char(DoubleBufferImpl b, int index, int limit, char value) { }; + private static native char nio_get_Char(DoubleBufferImpl b, int index, int limit); + private static native void nio_put_Char(DoubleBufferImpl b, int index, int limit, char value); public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; } DoubleBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native short nio_get_Short(DoubleBufferImpl b, int index, int limit); -// private static native void nio_put_Short(DoubleBufferImpl b, int index, int limit, short value); - private static short nio_get_Short(DoubleBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Short(DoubleBufferImpl b, int index, int limit, short value) { }; + private static native short nio_get_Short(DoubleBufferImpl b, int index, int limit); + private static native void nio_put_Short(DoubleBufferImpl b, int index, int limit, short value); public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; } DoubleBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native int nio_get_Int(DoubleBufferImpl b, int index, int limit); -// private static native void nio_put_Int(DoubleBufferImpl b, int index, int limit, int value); - private static int nio_get_Int(DoubleBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Int(DoubleBufferImpl b, int index, int limit, int value) { }; + private static native int nio_get_Int(DoubleBufferImpl b, int index, int limit); + private static native void nio_put_Int(DoubleBufferImpl b, int index, int limit, int value); public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; } DoubleBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native long nio_get_Long(DoubleBufferImpl b, int index, int limit); -// private static native void nio_put_Long(DoubleBufferImpl b, int index, int limit, long value); - private static long nio_get_Long(DoubleBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Long(DoubleBufferImpl b, int index, int limit, long value) { }; + private static native long nio_get_Long(DoubleBufferImpl b, int index, int limit); + private static native void nio_put_Long(DoubleBufferImpl b, int index, int limit, long value); public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; } DoubleBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native float nio_get_Float(DoubleBufferImpl b, int index, int limit); -// private static native void nio_put_Float(DoubleBufferImpl b, int index, int limit, float value); - private static float nio_get_Float(DoubleBufferImpl b, int index, int limit) { return 0.0f; }; - private static void nio_put_Float(DoubleBufferImpl b, int index, int limit, float value) { }; + private static native float nio_get_Float(DoubleBufferImpl b, int index, int limit); + private static native void nio_put_Float(DoubleBufferImpl b, int index, int limit, float value); public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; } DoubleBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native double nio_get_Double(DoubleBufferImpl b, int index, int limit); -// private static native void nio_put_Double(DoubleBufferImpl b, int index, int limit, double value); - private static double nio_get_Double(DoubleBufferImpl b, int index, int limit) { return 0.0d; }; - private static void nio_put_Double(DoubleBufferImpl b, int index, int limit, double value) { }; + private static native double nio_get_Double(DoubleBufferImpl b, int index, int limit); + private static native void nio_put_Double(DoubleBufferImpl b, int index, int limit, double value); public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; } + private static native double[] nio_cast(byte[]copy); + private static native double[] nio_cast(char[]copy); + private static native double[] nio_cast(short[]copy); + private static native double[] nio_cast(long[]copy); + private static native double[] nio_cast(int[]copy); + private static native double[] nio_cast(float[]copy); + private static native double[] nio_cast(double[]copy); + public boolean isReadOnly() { return ro; diff --git a/libjava/gnu/java/nio/FloatBufferImpl.java b/libjava/gnu/java/nio/FloatBufferImpl.java index 0df0f72bd08..bab47425f1d 100644 --- a/libjava/gnu/java/nio/FloatBufferImpl.java +++ b/libjava/gnu/java/nio/FloatBufferImpl.java @@ -54,24 +54,24 @@ public final class FloatBufferImpl extends FloatBuffer { this.backing_buffer = new float[cap]; this.cap = cap; - this.position(off); this.limit(lim); + this.position(off); } public FloatBufferImpl(float[] array, int off, int lim) { this.backing_buffer = array; this.cap = array.length; - this.position(off); this.limit(lim); + this.position(off); } public FloatBufferImpl(FloatBufferImpl copy) { backing_buffer = copy.backing_buffer; ro = copy.ro; - position(copy.position()); limit(copy.limit()); + position(copy.position()); } void inc_pos(int a) @@ -79,27 +79,9 @@ public final class FloatBufferImpl extends FloatBuffer position(position() + a); } -// private static native float[] nio_cast(byte[]copy); -// private static native float[] nio_cast(char[]copy); -// private static native float[] nio_cast(short[]copy); -// private static native float[] nio_cast(long[]copy); -// private static native float[] nio_cast(int[]copy); -// private static native float[] nio_cast(float[]copy); -// private static native float[] nio_cast(double[]copy); - - private static float[] nio_cast(byte[]copy) { return null; }; - private static float[] nio_cast(char[]copy) { return null; }; - private static float[] nio_cast(short[]copy) { return null; }; - private static float[] nio_cast(long[]copy) { return null; }; - private static float[] nio_cast(int[]copy) { return null; }; - private static float[] nio_cast(float[]copy) { return null; }; - private static float[] nio_cast(double[]copy) { return null; }; - FloatBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast (copy) : null; } -// private static native byte nio_get_Byte (FloatBufferImpl b, int index, int limit); -// private static native void nio_put_Byte (FloatBufferImpl b, int index, int limit, byte value); - private static byte nio_get_Byte (FloatBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Byte (FloatBufferImpl b, int index, int limit, byte value) { }; + private static native byte nio_get_Byte (FloatBufferImpl b, int index, int limit); + private static native void nio_put_Byte (FloatBufferImpl b, int index, int limit, byte value); public ByteBuffer asByteBuffer() { @@ -109,72 +91,68 @@ public final class FloatBufferImpl extends FloatBuffer } FloatBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native char nio_get_Char(FloatBufferImpl b, int index, int limit); -// private static native void nio_put_Char(FloatBufferImpl b, int index, int limit, char value); - private static char nio_get_Char(FloatBufferImpl b, int index, int limit) { return ' '; }; - private static void nio_put_Char(FloatBufferImpl b, int index, int limit, char value) { }; + private static native char nio_get_Char(FloatBufferImpl b, int index, int limit); + private static native void nio_put_Char(FloatBufferImpl b, int index, int limit, char value); public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } FloatBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native short nio_get_Short(FloatBufferImpl b, int index, int limit); -// private static native void nio_put_Short(FloatBufferImpl b, int index, int limit, short value); - private static short nio_get_Short(FloatBufferImpl b, int index, int limit) { return 0;}; - private static void nio_put_Short(FloatBufferImpl b, int index, int limit, short value) { }; + private static native short nio_get_Short(FloatBufferImpl b, int index, int limit); + private static native void nio_put_Short(FloatBufferImpl b, int index, int limit, short value); public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } FloatBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native int nio_get_Int(FloatBufferImpl b, int index, int limit); -// private static native void nio_put_Int(FloatBufferImpl b, int index, int limit, int value); - private static int nio_get_Int(FloatBufferImpl b, int index, int limit) { return 0;}; - private static void nio_put_Int(FloatBufferImpl b, int index, int limit, int value) { }; + private static native int nio_get_Int(FloatBufferImpl b, int index, int limit); + private static native void nio_put_Int(FloatBufferImpl b, int index, int limit, int value); public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; } FloatBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native long nio_get_Long(FloatBufferImpl b, int index, int limit); -// private static native void nio_put_Long(FloatBufferImpl b, int index, int limit, long value); - private static long nio_get_Long(FloatBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Long(FloatBufferImpl b, int index, int limit, long value) { }; + private static native long nio_get_Long(FloatBufferImpl b, int index, int limit); + private static native void nio_put_Long(FloatBufferImpl b, int index, int limit, long value); public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } FloatBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native float nio_get_Float(FloatBufferImpl b, int index, int limit); -// private static native void nio_put_Float(FloatBufferImpl b, int index, int limit, float value); - private static float nio_get_Float(FloatBufferImpl b, int index, int limit) { return 0.0f; }; - private static void nio_put_Float(FloatBufferImpl b, int index, int limit, float value) { }; + private static native float nio_get_Float(FloatBufferImpl b, int index, int limit); + private static native void nio_put_Float(FloatBufferImpl b, int index, int limit, float value); public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; } FloatBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native double nio_get_Double(FloatBufferImpl b, int index, int limit); -// private static native void nio_put_Double(FloatBufferImpl b, int index, int limit, double value); - private static double nio_get_Double(FloatBufferImpl b, int index, int limit) { return 0.0d; }; - private static void nio_put_Double(FloatBufferImpl b, int index, int limit, double value) { }; + private static native double nio_get_Double(FloatBufferImpl b, int index, int limit); + private static native void nio_put_Double(FloatBufferImpl b, int index, int limit, double value); public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } + + private static native float[] nio_cast(byte[]copy); + private static native float[] nio_cast(char[]copy); + private static native float[] nio_cast(short[]copy); + private static native float[] nio_cast(long[]copy); + private static native float[] nio_cast(int[]copy); + private static native float[] nio_cast(float[]copy); + private static native float[] nio_cast(double[]copy); public boolean isReadOnly() { return ro; } - public java.nio. FloatBuffer slice() + public FloatBuffer slice() { FloatBufferImpl A = new FloatBufferImpl(this); A.array_offset = position(); return A; } - public java.nio. FloatBuffer duplicate() + public FloatBuffer duplicate() { return new FloatBufferImpl(this); } - public java.nio. FloatBuffer asReadOnlyBuffer() + public FloatBuffer asReadOnlyBuffer() { FloatBufferImpl a = new FloatBufferImpl(this); a.ro = true; return a; } - public java.nio. FloatBuffer compact() + public FloatBuffer compact() { return this; } @@ -191,7 +169,7 @@ public final class FloatBufferImpl extends FloatBuffer return e; } - final public java.nio. FloatBuffer put(float b) + final public FloatBuffer put(float b) { backing_buffer[position()] = b; position(position()+1); @@ -203,16 +181,16 @@ public final class FloatBufferImpl extends FloatBuffer return backing_buffer[index]; } - final public java.nio. FloatBuffer put(int index, float b) + final public FloatBuffer put(int index, float b) { backing_buffer[index] = b; return this; } - final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public java.nio. FloatBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public java.nio. FloatBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; - final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public java.nio. FloatBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public java.nio. FloatBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; - final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public java.nio. FloatBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public java.nio. FloatBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; }; - final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public java.nio. FloatBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public java.nio. FloatBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; }; - final public float getFloat() { return get(); } final public java.nio. FloatBuffer putFloat(float value) { return put(value); } final public float getFloat(int index) { return get(index); } final public java.nio. FloatBuffer putFloat(int index, float value) { return put(index, value); }; - final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public java.nio. FloatBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public java.nio. FloatBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; + final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public FloatBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public FloatBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public FloatBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public FloatBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public FloatBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public FloatBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public FloatBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public FloatBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; }; + final public float getFloat() { return get(); } final public FloatBuffer putFloat(float value) { return put(value); } final public float getFloat(int index) { return get(index); } final public FloatBuffer putFloat(int index, float value) { return put(index, value); }; + final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public FloatBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public FloatBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; } diff --git a/libjava/gnu/java/nio/IntBufferImpl.java b/libjava/gnu/java/nio/IntBufferImpl.java index db1754da2f7..cccc418487c 100644 --- a/libjava/gnu/java/nio/IntBufferImpl.java +++ b/libjava/gnu/java/nio/IntBufferImpl.java @@ -37,7 +37,13 @@ exception statement from your version. */ package gnu.java.nio; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.nio.LongBuffer; +import java.nio.ShortBuffer; public final class IntBufferImpl extends IntBuffer { @@ -48,24 +54,24 @@ public final class IntBufferImpl extends IntBuffer { this.backing_buffer = new int[cap]; this.cap = cap; - this.position(off); this.limit(lim); + this.position(off); } public IntBufferImpl(int[] array, int off, int lim) { this.backing_buffer = array; this.cap = array.length; - this.position(off); this.limit(lim); + this.position(off); } public IntBufferImpl(IntBufferImpl copy) { backing_buffer = copy.backing_buffer; ro = copy.ro; - position(copy.position()); limit(copy.limit()); + position(copy.position()); } void inc_pos(int a) @@ -73,96 +79,74 @@ public final class IntBufferImpl extends IntBuffer position(position() + a); } -// private static native int[] nio_cast(byte[]copy); -// private static native int[] nio_cast(char[]copy); -// private static native int[] nio_cast(short[]copy); -// private static native int[] nio_cast(long[]copy); -// private static native int[] nio_cast(int[]copy); -// private static native int[] nio_cast(float[]copy); -// private static native int[] nio_cast(double[]copy); - - private static int[] nio_cast(byte[]copy) { return null; }; - private static int[] nio_cast(char[]copy) { return null; }; - private static int[] nio_cast(short[]copy) { return null; }; - private static int[] nio_cast(long[]copy) { return null; }; - private static int[] nio_cast(int[]copy) { return null; }; - private static int[] nio_cast(float[]copy) { return null; }; - private static int[] nio_cast(double[]copy) { return null; }; - IntBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native byte nio_get_Byte(IntBufferImpl b, int index, int limit); -// private static native void nio_put_Byte(IntBufferImpl b, int index, int limit, byte value); - private static byte nio_get_Byte(IntBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Byte(IntBufferImpl b, int index, int limit, byte value) { }; - public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/4); return res; } + private static native byte nio_get_Byte(IntBufferImpl b, int index, int limit); + private static native void nio_put_Byte(IntBufferImpl b, int index, int limit, byte value); + public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/4); return res; } IntBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native char nio_get_Char(IntBufferImpl b, int index, int limit); -// private static native void nio_put_Char(IntBufferImpl b, int index, int limit, char value); - private static char nio_get_Char(IntBufferImpl b, int index, int limit) { return ' '; }; - private static void nio_put_Char(IntBufferImpl b, int index, int limit, char value) { }; - public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } + private static native char nio_get_Char(IntBufferImpl b, int index, int limit); + private static native void nio_put_Char(IntBufferImpl b, int index, int limit, char value); + public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } IntBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native short nio_get_Short(IntBufferImpl b, int index, int limit); -// private static native void nio_put_Short(IntBufferImpl b, int index, int limit, short value); - private static short nio_get_Short(IntBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Short(IntBufferImpl b, int index, int limit, short value) { }; - public java.nio. ShortBuffer asShortBuffer() { gnu.java.nio. ShortBufferImpl res = new gnu.java.nio. ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } + private static native short nio_get_Short(IntBufferImpl b, int index, int limit); + private static native void nio_put_Short(IntBufferImpl b, int index, int limit, short value); + public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } IntBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native int nio_get_Int(IntBufferImpl b, int index, int limit); -// private static native void nio_put_Int(IntBufferImpl b, int index, int limit, int value); - private static int nio_get_Int(IntBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Int(IntBufferImpl b, int index, int limit, int value) { }; - public java.nio. IntBuffer asIntBuffer() { gnu.java.nio. IntBufferImpl res = new gnu.java.nio. IntBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; } + private static native int nio_get_Int(IntBufferImpl b, int index, int limit); + private static native void nio_put_Int(IntBufferImpl b, int index, int limit, int value); + public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; } IntBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native long nio_get_Long(IntBufferImpl b, int index, int limit); -// private static native void nio_put_Long(IntBufferImpl b, int index, int limit, long value); - private static long nio_get_Long(IntBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Long(IntBufferImpl b, int index, int limit, long value) { }; - public java.nio. LongBuffer asLongBuffer() { gnu.java.nio. LongBufferImpl res = new gnu.java.nio. LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } + private static native long nio_get_Long(IntBufferImpl b, int index, int limit); + private static native void nio_put_Long(IntBufferImpl b, int index, int limit, long value); + public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } IntBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native float nio_get_Float(IntBufferImpl b, int index, int limit); -// private static native void nio_put_Float(IntBufferImpl b, int index, int limit, float value); - private static float nio_get_Float(IntBufferImpl b, int index, int limit) { return 0.0f; }; - private static void nio_put_Float(IntBufferImpl b, int index, int limit, float value) { }; - public java.nio. FloatBuffer asFloatBuffer() { gnu.java.nio. FloatBufferImpl res = new gnu.java.nio. FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; } + private static native float nio_get_Float(IntBufferImpl b, int index, int limit); + private static native void nio_put_Float(IntBufferImpl b, int index, int limit, float value); + public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; } IntBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native double nio_get_Double(IntBufferImpl b, int index, int limit); -// private static native void nio_put_Double(IntBufferImpl b, int index, int limit, double value); - private static double nio_get_Double(IntBufferImpl b, int index, int limit) { return 0.0d; }; - private static void nio_put_Double(IntBufferImpl b, int index, int limit, double value) { }; - public java.nio. DoubleBuffer asDoubleBuffer() { gnu.java.nio. DoubleBufferImpl res = new gnu.java.nio. DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } + private static native double nio_get_Double(IntBufferImpl b, int index, int limit); + private static native void nio_put_Double(IntBufferImpl b, int index, int limit, double value); + public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } + + private static native int[] nio_cast(byte[]copy); + private static native int[] nio_cast(char[]copy); + private static native int[] nio_cast(short[]copy); + private static native int[] nio_cast(long[]copy); + private static native int[] nio_cast(int[]copy); + private static native int[] nio_cast(float[]copy); + private static native int[] nio_cast(double[]copy); public boolean isReadOnly() { return ro; } - public java.nio. IntBuffer slice() + public IntBuffer slice() { IntBufferImpl A = new IntBufferImpl(this); A.array_offset = position(); return A; } - public java.nio. IntBuffer duplicate() + public IntBuffer duplicate() { return new IntBufferImpl(this); } - public java.nio. IntBuffer asReadOnlyBuffer() + public IntBuffer asReadOnlyBuffer() { IntBufferImpl a = new IntBufferImpl(this); a.ro = true; return a; } - public java.nio. IntBuffer compact() + public IntBuffer compact() { return this; } @@ -179,7 +163,7 @@ public final class IntBufferImpl extends IntBuffer return e; } - final public java.nio. IntBuffer put(int b) + final public IntBuffer put(int b) { backing_buffer[position()] = b; position(position()+1); @@ -191,16 +175,16 @@ public final class IntBufferImpl extends IntBuffer return backing_buffer[index]; } - final public java.nio. IntBuffer put(int index, int b) + final public IntBuffer put(int index, int b) { backing_buffer[index] = b; return this; } - final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public java.nio. IntBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public java.nio. IntBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; - final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public java.nio. IntBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public java.nio. IntBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; - final public int getInt() { return get(); } final public java.nio. IntBuffer putInt(int value) { return put(value); } final public int getInt(int index) { return get(index); } final public java.nio. IntBuffer putInt(int index, int value) { return put(index, value); }; - final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public java.nio. IntBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public java.nio. IntBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; }; - final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public java.nio. IntBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public java.nio. IntBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; }; - final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public java.nio. IntBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public java.nio. IntBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; + final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public IntBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public IntBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public IntBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public IntBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; + final public int getInt() { return get(); } final public IntBuffer putInt(int value) { return put(value); } final public int getInt(int index) { return get(index); } final public IntBuffer putInt(int index, int value) { return put(index, value); }; + final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public IntBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public IntBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public IntBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public IntBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public IntBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public IntBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; } diff --git a/libjava/gnu/java/nio/LongBufferImpl.java b/libjava/gnu/java/nio/LongBufferImpl.java index 096481f4b8d..8f29b06939f 100644 --- a/libjava/gnu/java/nio/LongBufferImpl.java +++ b/libjava/gnu/java/nio/LongBufferImpl.java @@ -54,24 +54,24 @@ public final class LongBufferImpl extends LongBuffer { this.backing_buffer = new long[cap]; this.cap = cap ; - this.position(off); this.limit(lim); + this.position(off); } public LongBufferImpl(long[] array, int off, int lim) { this.backing_buffer = array; this.cap = array.length; - this.position(off); this.limit(lim); + this.position(off); } public LongBufferImpl(LongBufferImpl copy) { backing_buffer = copy.backing_buffer; ro = copy.ro; - position(copy.position()); limit(copy.limit()); + position(copy.position()); } void inc_pos(int a) @@ -79,96 +79,74 @@ public final class LongBufferImpl extends LongBuffer position(position() + a); } -// private static native long[] nio_cast(byte[]copy); -// private static native long[] nio_cast(char[]copy); -// private static native long[] nio_cast(short[]copy); -// private static native long[] nio_cast(long[]copy); -// private static native long[] nio_cast(int[]copy); -// private static native long[] nio_cast(float[]copy); -// private static native long[] nio_cast(double[]copy); - - private static long[] nio_cast(byte[]copy) { return null; }; - private static long[] nio_cast(char[]copy) { return null; }; - private static long[] nio_cast(short[]copy) { return null; }; - private static long[] nio_cast(long[]copy) { return null; }; - private static long[] nio_cast(int[]copy) { return null; }; - private static long[] nio_cast(float[]copy) { return null; }; - private static long[] nio_cast(double[]copy) { return null; }; - LongBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native byte nio_get_Byte(LongBufferImpl b, int index, int limit); -// private static native void nio_put_Byte(LongBufferImpl b, int index, int limit, byte value); - private static byte nio_get_Byte(LongBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Byte(LongBufferImpl b, int index, int limit, byte value) { }; - public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/8); return res; } + private static native byte nio_get_Byte(LongBufferImpl b, int index, int limit); + private static native void nio_put_Byte(LongBufferImpl b, int index, int limit, byte value); + public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/8); return res; } LongBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native char nio_get_Char(LongBufferImpl b, int index, int limit); -// private static native void nio_put_Char(LongBufferImpl b, int index, int limit, char value); - private static char nio_get_Char(LongBufferImpl b, int index, int limit) { return ' '; }; - private static void nio_put_Char(LongBufferImpl b, int index, int limit, char value) { }; - public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; } + private static native char nio_get_Char(LongBufferImpl b, int index, int limit); + private static native void nio_put_Char(LongBufferImpl b, int index, int limit, char value); + public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; } LongBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native short nio_get_Short(LongBufferImpl b, int index, int limit); -// private static native void nio_put_Short(LongBufferImpl b, int index, int limit, short value); - private static short nio_get_Short(LongBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Short(LongBufferImpl b, int index, int limit, short value) { }; - public java.nio. ShortBuffer asShortBuffer() { gnu.java.nio. ShortBufferImpl res = new gnu.java.nio. ShortBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; } + private static native short nio_get_Short(LongBufferImpl b, int index, int limit); + private static native void nio_put_Short(LongBufferImpl b, int index, int limit, short value); + public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/8); return res; } LongBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native int nio_get_Int(LongBufferImpl b, int index, int limit); -// private static native void nio_put_Int(LongBufferImpl b, int index, int limit, int value); - private static int nio_get_Int(LongBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Int(LongBufferImpl b, int index, int limit, int value) { }; - public java.nio. IntBuffer asIntBuffer() { gnu.java.nio. IntBufferImpl res = new gnu.java.nio. IntBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; } + private static native int nio_get_Int(LongBufferImpl b, int index, int limit); + private static native void nio_put_Int(LongBufferImpl b, int index, int limit, int value); + public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; } LongBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native long nio_get_Long(LongBufferImpl b, int index, int limit); -// private static native void nio_put_Long(LongBufferImpl b, int index, int limit, long value); - private static long nio_get_Long(LongBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Long(LongBufferImpl b, int index, int limit, long value) { }; - public java.nio. LongBuffer asLongBuffer() { gnu.java.nio. LongBufferImpl res = new gnu.java.nio. LongBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; } + private static native long nio_get_Long(LongBufferImpl b, int index, int limit); + private static native void nio_put_Long(LongBufferImpl b, int index, int limit, long value); + public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; } LongBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native float nio_get_Float(LongBufferImpl b, int index, int limit); -// private static native void nio_put_Float(LongBufferImpl b, int index, int limit, float value); - private static float nio_get_Float(LongBufferImpl b, int index, int limit) { return 0.0f; }; - private static void nio_put_Float(LongBufferImpl b, int index, int limit, float value) { }; - public java.nio. FloatBuffer asFloatBuffer() { gnu.java.nio. FloatBufferImpl res = new gnu.java.nio. FloatBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; } + private static native float nio_get_Float(LongBufferImpl b, int index, int limit); + private static native void nio_put_Float(LongBufferImpl b, int index, int limit, float value); + public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/8); return res; } LongBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native double nio_get_Double(LongBufferImpl b, int index, int limit); -// private static native void nio_put_Double(LongBufferImpl b, int index, int limit, double value); - private static double nio_get_Double(LongBufferImpl b, int index, int limit) { return 0.0d; }; - private static void nio_put_Double(LongBufferImpl b, int index, int limit, double value) { }; - public java.nio. DoubleBuffer asDoubleBuffer() { gnu.java.nio. DoubleBufferImpl res = new gnu.java.nio. DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; } + private static native double nio_get_Double(LongBufferImpl b, int index, int limit); + private static native void nio_put_Double(LongBufferImpl b, int index, int limit, double value); + public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/8); return res; } + + private static native long[] nio_cast(byte[]copy); + private static native long[] nio_cast(char[]copy); + private static native long[] nio_cast(short[]copy); + private static native long[] nio_cast(long[]copy); + private static native long[] nio_cast(int[]copy); + private static native long[] nio_cast(float[]copy); + private static native long[] nio_cast(double[]copy); public boolean isReadOnly() { return ro; } - public java.nio. LongBuffer slice() + public LongBuffer slice() { LongBufferImpl A = new LongBufferImpl(this); A.array_offset = position(); return A; } - public java.nio. LongBuffer duplicate() + public LongBuffer duplicate() { return new LongBufferImpl(this); } - public java.nio. LongBuffer asReadOnlyBuffer() + public LongBuffer asReadOnlyBuffer() { LongBufferImpl a = new LongBufferImpl(this); a.ro = true; return a; } - public java.nio. LongBuffer compact() + public LongBuffer compact() { return this; } @@ -185,7 +163,7 @@ public final class LongBufferImpl extends LongBuffer return e; } - final public java.nio. LongBuffer put(long b) + final public LongBuffer put(long b) { backing_buffer[position()] = b; position(position()+1); @@ -197,16 +175,16 @@ public final class LongBufferImpl extends LongBuffer return backing_buffer[index]; } - final public java.nio. LongBuffer put(int index, long b) + final public LongBuffer put(int index, long b) { backing_buffer[index] = b; return this; } - final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public java.nio. LongBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public java.nio. LongBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; - final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public java.nio. LongBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public java.nio. LongBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; - final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public java.nio. LongBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public java.nio. LongBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; }; - final public long getLong() { return get(); } final public java.nio. LongBuffer putLong(long value) { return put(value); } final public long getLong(int index) { return get(index); } final public java.nio. LongBuffer putLong(int index, long value) { return put(index, value); }; - final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public java.nio. LongBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public java.nio. LongBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; }; - final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public java.nio. LongBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public java.nio. LongBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; + final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public LongBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public LongBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; + final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public LongBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public LongBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; + final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public LongBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public LongBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; }; + final public long getLong() { return get(); } final public LongBuffer putLong(long value) { return put(value); } final public long getLong(int index) { return get(index); } final public LongBuffer putLong(int index, long value) { return put(index, value); }; + final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public LongBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public LongBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public LongBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public LongBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; } diff --git a/libjava/gnu/java/nio/SelectionKeyImpl.java b/libjava/gnu/java/nio/SelectionKeyImpl.java index 8ef6f7f27cb..5763d6880d3 100644 --- a/libjava/gnu/java/nio/SelectionKeyImpl.java +++ b/libjava/gnu/java/nio/SelectionKeyImpl.java @@ -44,7 +44,9 @@ import java.nio.channels.spi.AbstractSelectionKey; public class SelectionKeyImpl extends AbstractSelectionKey { - int fd, ops; + int fd; + int readyOps; + int interestOps; SelectorImpl impl; SelectableChannel ch; @@ -62,17 +64,23 @@ public class SelectionKeyImpl extends AbstractSelectionKey public int readyOps () { - return 0; + return readyOps; + } + + public SelectionKey readyOps (int ops) + { + readyOps = ops; + return this; } public int interestOps () { - return ops; + return interestOps; } public SelectionKey interestOps (int ops) { - this.ops = ops; + interestOps = ops; return this; } diff --git a/libjava/gnu/java/nio/SelectorImpl.java b/libjava/gnu/java/nio/SelectorImpl.java index 7d3d88c75f4..0b513f9da52 100644 --- a/libjava/gnu/java/nio/SelectorImpl.java +++ b/libjava/gnu/java/nio/SelectorImpl.java @@ -56,6 +56,10 @@ public class SelectorImpl extends AbstractSelector public SelectorImpl (SelectorProvider provider) { super (provider); + + keys = new HashSet (); + selected = new HashSet (); + canceled = new HashSet (); } public Set keys () @@ -70,16 +74,48 @@ public class SelectorImpl extends AbstractSelector public int select () { - return select (Long.MAX_VALUE); + return select (-1); } -// private static native int java_do_select(int[] read, int[] write, -// int[] except, long timeout); + // A timeout value of -1 means block forever. + private static native int java_do_select (int[] read, int[] write, + int[] except, long timeout); - private static int java_do_select(int[] read, int[] write, - int[] except, long timeout) + private int[] getFDsAsArray (int ops) { - return 0; + int[] result; + int counter = 0; + Iterator it = keys.iterator (); + + // Count the number of file descriptors needed + while (it.hasNext ()) + { + SelectionKeyImpl key = (SelectionKeyImpl) it.next (); + + if ((key.interestOps () & ops) != 0) + { + counter++; + } + } + + result = new int[counter]; + + counter = 0; + it = keys.iterator (); + + // Fill the array with the file descriptors + while (it.hasNext ()) + { + SelectionKeyImpl key = (SelectionKeyImpl) it.next (); + + if ((key.interestOps () & ops) != 0) + { + result[counter] = key.fd; + counter++; + } + } + + return result; } public int select (long timeout) @@ -94,40 +130,79 @@ public class SelectorImpl extends AbstractSelector return 0; } - int[] read = new int[keys.size ()]; - int[] write = new int[keys.size ()]; - int[] except = new int[keys.size ()]; - int i = 0; + int ret = 0; + + deregisterCanceledKeys (); + + // Set only keys with the needed interest ops into the arrays. + int[] read = getFDsAsArray (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT); + int[] write = getFDsAsArray (SelectionKey.OP_WRITE | SelectionKey.OP_CONNECT); + int[] except = new int [0]; // FIXME: We dont need to check this yet + + // Call the native select () on all file descriptors. + int anzahl = read.length + write.length + except.length; + ret = java_do_select (read, write, except, timeout); + Iterator it = keys.iterator (); while (it.hasNext ()) - { - SelectionKeyImpl k = (SelectionKeyImpl) it.next (); - read[i] = k.fd; - write[i] = k.fd; - except[i] = k.fd; - i++; - } + { + int ops = 0; + SelectionKeyImpl key = (SelectionKeyImpl) it.next (); - int ret = java_do_select (read, write, except, timeout); + // If key is already selected retrieve old ready ops. + if (selected.contains (key)) + { + ops = key.readyOps (); + } - i = 0; - it = keys.iterator (); + // Set new ready read/accept ops + for (int i = 0; i < read.length; i++) + { + if (key.fd == read[i]) + { + if (key.channel () instanceof ServerSocketChannelImpl) + { + ops = ops | SelectionKey.OP_ACCEPT; + } + else + { + ops = ops | SelectionKey.OP_READ; + } + } + } - while (it.hasNext ()) - { - SelectionKeyImpl k = (SelectionKeyImpl) it.next (); + // Set new ready write ops + for (int i = 0; i < write.length; i++) + { + if (key.fd == write[i]) + { + ops = ops | SelectionKey.OP_WRITE; + +// if (key.channel ().isConnected ()) +// { +// ops = ops | SelectionKey.OP_WRITE; +// } +// else +// { +// ops = ops | SelectionKey.OP_CONNECT; +// } + } + } + + // FIXME: We dont handle exceptional file descriptors yet. - if (read[i] != -1 || - write[i] != -1 || - except[i] != -1) + // If key is not yet selected add it. + if (!selected.contains (key)) { - add_selected (k); + add_selected (key); } - i++; - } + // Set new ready ops + key.readyOps (key.interestOps () & ops); + } + deregisterCanceledKeys (); return ret; } @@ -143,25 +218,30 @@ public class SelectorImpl extends AbstractSelector public void add (SelectionKeyImpl k) { - if (keys == null) - keys = new HashSet (); - keys.add (k); } void add_selected (SelectionKeyImpl k) { - if (selected == null) - selected = new HashSet (); - - selected.add(k); + selected.add (k); } protected void implCloseSelector () { closed = true; } - + + private void deregisterCanceledKeys () + { + Iterator it = canceled.iterator (); + + while (it.hasNext ()) + { + keys.remove ((SelectionKeyImpl) it.next ()); + it.remove (); + } + } + protected SelectionKey register (SelectableChannel ch, int ops, Object att) { return register ((AbstractSelectableChannel) ch, ops, att); @@ -176,6 +256,8 @@ public class SelectorImpl extends AbstractSelector // FileChannelImpl fc = (FileChannelImpl) ch; // SelectionKeyImpl impl = new SelectionKeyImpl (ch, this, fc.fd); // keys.add (impl); +// impl.interestOps (ops); +// impl.attach (att); // return impl; // } // else @@ -185,13 +267,26 @@ public class SelectorImpl extends AbstractSelector SocketChannelImpl sc = (SocketChannelImpl) ch; SelectionKeyImpl impl = new SelectionKeyImpl (ch, this, sc.fd); add (impl); + impl.interestOps (ops); + impl.attach (att); return impl; } + else if (ch instanceof DatagramChannelImpl) + { + DatagramChannelImpl dc = (DatagramChannelImpl) ch; + SelectionKeyImpl impl = new SelectionKeyImpl (ch, this, dc.fd); + add (impl); + impl.interestOps (ops); + impl.attach (att); + return impl; + } else if (ch instanceof ServerSocketChannelImpl) { ServerSocketChannelImpl ssc = (ServerSocketChannelImpl) ch; SelectionKeyImpl impl = new SelectionKeyImpl (ch, this, ssc.fd); add (impl); + impl.interestOps (ops); + impl.attach (att); return impl; } else diff --git a/libjava/gnu/java/nio/ServerSocketChannelImpl.java b/libjava/gnu/java/nio/ServerSocketChannelImpl.java index e75c68d8166..4a51f2a4b61 100644 --- a/libjava/gnu/java/nio/ServerSocketChannelImpl.java +++ b/libjava/gnu/java/nio/ServerSocketChannelImpl.java @@ -54,14 +54,8 @@ class ServerSocketChannelImpl extends ServerSocketChannel boolean connected = false; // InetSocketAddress sa; -// private static native int NioSocketAccept (ServerSocketChannelImpl server, -// SocketChannelImpl s); - - private static int NioSocketAccept (ServerSocketChannelImpl server, - SocketChannelImpl s) - { - return 0; - } + private static native int SocketAccept (ServerSocketChannelImpl server, + SocketChannelImpl s); protected ServerSocketChannelImpl (SelectorProvider provider) { @@ -101,13 +95,14 @@ class ServerSocketChannelImpl extends ServerSocketChannel protected void implConfigureBlocking (boolean block) { + blocking = block; } public SocketChannel accept () { SocketChannelImpl result = new SocketChannelImpl (provider ()); result.sa = new InetSocketAddress (0); - int res = NioSocketAccept (this, result); + int res = SocketAccept (this,result); return result; } diff --git a/libjava/gnu/java/nio/ShortBufferImpl.java b/libjava/gnu/java/nio/ShortBufferImpl.java index 15a0cd667f3..bccb2d0f65a 100644 --- a/libjava/gnu/java/nio/ShortBufferImpl.java +++ b/libjava/gnu/java/nio/ShortBufferImpl.java @@ -54,24 +54,24 @@ public final class ShortBufferImpl extends ShortBuffer { this.backing_buffer = new short[cap]; this.cap = cap ; - this.position(off); this.limit(lim); + this.position(off); } public ShortBufferImpl(short[] array, int off, int lim) { this.backing_buffer = array; this.cap = array.length; - this.position(off); this.limit(lim); + this.position(off); } public ShortBufferImpl(ShortBufferImpl copy) { backing_buffer = copy.backing_buffer; ro = copy.ro; - position(copy.position()); limit(copy.limit()); + position(copy.position()); } void inc_pos(int a) @@ -79,70 +79,48 @@ public final class ShortBufferImpl extends ShortBuffer position(position() + a); } -// private static native short[] nio_cast(byte[]copy); -// private static native short[] nio_cast(char[]copy); -// private static native short[] nio_cast(short[]copy); -// private static native short[] nio_cast(long[]copy); -// private static native short[] nio_cast(int[]copy); -// private static native short[] nio_cast(float[]copy); -// private static native short[] nio_cast(double[]copy); - - private static short[] nio_cast(byte[]copy) { return null; }; - private static short[] nio_cast(char[]copy) { return null; }; - private static short[] nio_cast(short[]copy) { return null; }; - private static short[] nio_cast(long[]copy) { return null; }; - private static short[] nio_cast(int[]copy) { return null; }; - private static short[] nio_cast(float[]copy) { return null; }; - private static short[] nio_cast(double[]copy) { return null; }; - ShortBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native byte nio_get_Byte(ShortBufferImpl b, int index, int limit); -// private static native void nio_put_Byte(ShortBufferImpl b, int index, int limit, byte value); - private static byte nio_get_Byte(ShortBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Byte(ShortBufferImpl b, int index, int limit, byte value) { }; - public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/2); return res; } + private static native byte nio_get_Byte(ShortBufferImpl b, int index, int limit); + private static native void nio_put_Byte(ShortBufferImpl b, int index, int limit, byte value); + public ByteBuffer asByteBuffer() { ByteBufferImpl res = new ByteBufferImpl(backing_buffer); res.limit((limit()*1)/2); return res; } ShortBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native char nio_get_Char(ShortBufferImpl b, int index, int limit); -// private static native void nio_put_Char(ShortBufferImpl b, int index, int limit, char value); - private static char nio_get_Char(ShortBufferImpl b, int index, int limit) { return ' '; }; - private static void nio_put_Char(ShortBufferImpl b, int index, int limit, char value) { }; - public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; } + private static native char nio_get_Char(ShortBufferImpl b, int index, int limit); + private static native void nio_put_Char(ShortBufferImpl b, int index, int limit, char value); + public CharBuffer asCharBuffer() { CharBufferImpl res = new CharBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; } ShortBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native short nio_get_Short(ShortBufferImpl b, int index, int limit); -// private static native void nio_put_Short(ShortBufferImpl b, int index, int limit, short value); - private static short nio_get_Short(ShortBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Short(ShortBufferImpl b, int index, int limit, short value) { }; - public java.nio. ShortBuffer asShortBuffer() { gnu.java.nio. ShortBufferImpl res = new gnu.java.nio. ShortBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; } + private static native short nio_get_Short(ShortBufferImpl b, int index, int limit); + private static native void nio_put_Short(ShortBufferImpl b, int index, int limit, short value); + public ShortBuffer asShortBuffer() { ShortBufferImpl res = new ShortBufferImpl(backing_buffer); res.limit((limit()*2)/2); return res; } ShortBufferImpl(int[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native int nio_get_Int(ShortBufferImpl b, int index, int limit); -// private static native void nio_put_Int(ShortBufferImpl b, int index, int limit, int value); - private static int nio_get_Int(ShortBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Int(ShortBufferImpl b, int index, int limit, int value) { }; - public java.nio. IntBuffer asIntBuffer() { gnu.java.nio. IntBufferImpl res = new gnu.java.nio. IntBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; } + private static native int nio_get_Int(ShortBufferImpl b, int index, int limit); + private static native void nio_put_Int(ShortBufferImpl b, int index, int limit, int value); + public IntBuffer asIntBuffer() { IntBufferImpl res = new IntBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; } ShortBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native long nio_get_Long(ShortBufferImpl b, int index, int limit); -// private static native void nio_put_Long(ShortBufferImpl b, int index, int limit, long value); - private static long nio_get_Long(ShortBufferImpl b, int index, int limit) { return 0; }; - private static void nio_put_Long(ShortBufferImpl b, int index, int limit, long value) { }; - public java.nio. LongBuffer asLongBuffer() { gnu.java.nio. LongBufferImpl res = new gnu.java.nio. LongBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; } + private static native long nio_get_Long(ShortBufferImpl b, int index, int limit); + private static native void nio_put_Long(ShortBufferImpl b, int index, int limit, long value); + public LongBuffer asLongBuffer() { LongBufferImpl res = new LongBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; } ShortBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native float nio_get_Float(ShortBufferImpl b, int index, int limit); -// private static native void nio_put_Float(ShortBufferImpl b, int index, int limit, float value); - private static float nio_get_Float(ShortBufferImpl b, int index, int limit) { return 0.0f; }; - private static void nio_put_Float(ShortBufferImpl b, int index, int limit, float value) { }; - public java.nio. FloatBuffer asFloatBuffer() { gnu.java.nio. FloatBufferImpl res = new gnu.java.nio. FloatBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; } + private static native float nio_get_Float(ShortBufferImpl b, int index, int limit); + private static native void nio_put_Float(ShortBufferImpl b, int index, int limit, float value); + public FloatBuffer asFloatBuffer() { FloatBufferImpl res = new FloatBufferImpl(backing_buffer); res.limit((limit()*4)/2); return res; } ShortBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } -// private static native double nio_get_Double(ShortBufferImpl b, int index, int limit); -// private static native void nio_put_Double(ShortBufferImpl b, int index, int limit, double value); - private static double nio_get_Double(ShortBufferImpl b, int index, int limit) { return 0.0d; }; - private static void nio_put_Double(ShortBufferImpl b, int index, int limit, double value) { }; - public java.nio. DoubleBuffer asDoubleBuffer() { gnu.java.nio. DoubleBufferImpl res = new gnu.java.nio. DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; } + private static native double nio_get_Double(ShortBufferImpl b, int index, int limit); + private static native void nio_put_Double(ShortBufferImpl b, int index, int limit, double value); + public DoubleBuffer asDoubleBuffer() { DoubleBufferImpl res = new DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/2); return res; } + + private static native short[] nio_cast(byte[]copy); + private static native short[] nio_cast(char[]copy); + private static native short[] nio_cast(short[]copy); + private static native short[] nio_cast(long[]copy); + private static native short[] nio_cast(int[]copy); + private static native short[] nio_cast(float[]copy); + private static native short[] nio_cast(double[]copy); public boolean isReadOnly() { @@ -203,10 +181,10 @@ public final class ShortBufferImpl extends ShortBuffer return this; } - final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public java.nio. ShortBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public java.nio. ShortBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; - final public short getShort() { return get(); } final public java.nio. ShortBuffer putShort(short value) { return put(value); } final public short getShort(int index) { return get(index); } final public java.nio. ShortBuffer putShort(int index, short value) { return put(index, value); }; - final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public java.nio. ShortBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public java.nio. ShortBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; }; - final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public java.nio. ShortBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public java.nio. ShortBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; }; - final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public java.nio. ShortBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public java.nio. ShortBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; }; - final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public java.nio. ShortBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public java.nio. ShortBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; + final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public ShortBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public ShortBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; + final public short getShort() { return get(); } final public ShortBuffer putShort(short value) { return put(value); } final public short getShort(int index) { return get(index); } final public ShortBuffer putShort(int index, short value) { return put(index, value); }; + final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public ShortBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public ShortBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; }; + final public long getLong() { long a = nio_get_Long(this, position(), limit()); inc_pos(8); return a; } final public ShortBuffer putLong(long value) { nio_put_Long(this, position(), limit(), value); inc_pos(8); return this; } final public long getLong(int index) { long a = nio_get_Long(this, index, limit()); return a; } final public ShortBuffer putLong(int index, long value) { nio_put_Long(this, index, limit(), value); return this; }; + final public float getFloat() { float a = nio_get_Float(this, position(), limit()); inc_pos(4); return a; } final public ShortBuffer putFloat(float value) { nio_put_Float(this, position(), limit(), value); inc_pos(4); return this; } final public float getFloat(int index) { float a = nio_get_Float(this, index, limit()); return a; } final public ShortBuffer putFloat(int index, float value) { nio_put_Float(this, index, limit(), value); return this; }; + final public double getDouble() { double a = nio_get_Double(this, position(), limit()); inc_pos(8); return a; } final public ShortBuffer putDouble(double value) { nio_put_Double(this, position(), limit(), value); inc_pos(8); return this; } final public double getDouble(int index) { double a = nio_get_Double(this, index, limit()); return a; } final public ShortBuffer putDouble(int index, double value) { nio_put_Double(this, index, limit(), value); return this; }; } diff --git a/libjava/gnu/java/nio/SocketChannelImpl.java b/libjava/gnu/java/nio/SocketChannelImpl.java index b43108ba473..9f2de278d81 100644 --- a/libjava/gnu/java/nio/SocketChannelImpl.java +++ b/libjava/gnu/java/nio/SocketChannelImpl.java @@ -57,25 +57,14 @@ public class SocketChannelImpl extends SocketChannel boolean connected = false; InetSocketAddress sa; -/* static native int SocketCreate(); - static native int SocketConnect(int fd, InetAddress a, int port); - static native int SocketBind(int fd, InetAddress host, int port); + static native int SocketConnect(int fd, InetAddress addr, int port); + static native int SocketBind(int fd, InetAddress addr, int port); static native int SocketListen(int fd, int backlog); static native int SocketAvailable(int fd); static native int SocketClose(int fd); static native int SocketRead(int fd, byte b[], int off, int len); static native int SocketWrite(int fd, byte b[], int off, int len); -*/ - - static int SocketCreate() { return 0; }; - static int SocketConnect(int fd, InetAddress a, int port) { return 0; }; - static int SocketBind(int fd, InetAddress host, int port) { return 0; }; - static int SocketListen(int fd, int backlog) { return 0; }; - static int SocketAvailable(int fd) { return 0; }; - static int SocketClose(int fd) { return 0; }; - static int SocketRead(int fd, byte b[], int off, int len) { return 0; }; - static int SocketWrite(int fd, byte b[], int off, int len) { return 0; }; public SocketChannelImpl(SelectorProvider provider) { @@ -87,7 +76,7 @@ public class SocketChannelImpl extends SocketChannel System.err.println("failed to create socket:"+fd); } } - + public void finalizer() { if (connected) diff --git a/libjava/include/java-interp.h b/libjava/include/java-interp.h index e3f96713ce7..a44db38ca85 100644 --- a/libjava/include/java-interp.h +++ b/libjava/include/java-interp.h @@ -21,6 +21,7 @@ details. */ #include #include +#include extern "C" { #include @@ -140,8 +141,13 @@ class _Jv_InterpMethod : public _Jv_MethodBase friend class _Jv_ClassReader; friend class _Jv_BytecodeVerifier; friend class gnu::gcj::runtime::NameFinder; + friend class gnu::gcj::runtime::StackTrace; friend void _Jv_PrepareClass(jclass); + +#ifdef JV_MARKOBJ_DECL + friend JV_MARKOBJ_DECL; +#endif }; class _Jv_InterpClass : public java::lang::Class diff --git a/libjava/include/jni.h b/libjava/include/jni.h index 0b98ab2c5c4..31f57985683 100644 --- a/libjava/include/jni.h +++ b/libjava/include/jni.h @@ -249,14 +249,15 @@ struct JNINativeInterface _Jv_func reserved3; jint (JNICALL *GetVersion) (JNIEnv *); - jclass (JNICALL *DefineClass) (JNIEnv *, jobject, - const jbyte *, jsize); + jclass (JNICALL *DefineClass) (JNIEnv *, const char *, + jobject, const jbyte *, + jsize); jclass (JNICALL *FindClass) (JNIEnv *, const char *); jmethodID (JNICALL *FromReflectedMethod) (JNIEnv *, jobject); jfieldID (JNICALL *FromReflectedField) (JNIEnv *, jobject); - jobject (JNICALL *ToReflectedMethod) (JNIEnv *, jclass, jmethodID, - jboolean); + jobject (JNICALL *ToReflectedMethod) (JNIEnv *, jclass, + jmethodID, jboolean); jclass (JNICALL *GetSuperclass) (JNIEnv *, jclass); jboolean (JNICALL *IsAssignableFrom) (JNIEnv *, jclass, jclass); @@ -687,8 +688,9 @@ public: jint GetVersion () { return p->GetVersion (this); } - jclass DefineClass (jobject obj0, const jbyte * val1, jsize val2) - { return p->DefineClass (this, obj0, val1, val2); } + jclass DefineClass (const char *name, jobject obj0, const jbyte * val1, + jsize val2) + { return p->DefineClass (this, name, obj0, val1, val2); } jclass FindClass (const char * val0) { return p->FindClass (this, val0); } diff --git a/libjava/include/posix.h b/libjava/include/posix.h index 447cadaf790..cdcdb5d45ac 100644 --- a/libjava/include/posix.h +++ b/libjava/include/posix.h @@ -40,6 +40,10 @@ details. */ #include #include +// Prefix and suffix for shared libraries. +#define _Jv_platform_solib_prefix "lib" +#define _Jv_platform_solib_suffix ".so" + #ifndef DISABLE_JAVA_NET #include #endif @@ -58,6 +62,10 @@ _Jv_platform_close_on_exec (jint fd) #ifndef DISABLE_JAVA_NET +#ifndef HAVE_SOCKLEN_T +#define socklen_t int +#endif + static inline int _Jv_socket (int domain, int type, int protocol) { diff --git a/libjava/include/win32.h b/libjava/include/win32.h index 62bc0c33cbb..d4c0ab6c18d 100644 --- a/libjava/include/win32.h +++ b/libjava/include/win32.h @@ -22,7 +22,11 @@ details. */ #include -#ifndef DISBALE_JAVA_NET +// Prefix and suffix for shared libraries. +#define _Jv_platform_solib_prefix "" +#define _Jv_platform_solib_suffix ".dll" + +#ifndef DISABLE_JAVA_NET // these errors cannot occur on Win32 #define ENOTCONN 0 @@ -32,7 +36,7 @@ details. */ #define ENOPROTOOPT 109 #endif -#endif // DISBALE_JAVA_NET +#endif // DISABLE_JAVA_NET extern void _Jv_platform_initialize (void); extern void _Jv_platform_initProperties (java::util::Properties*); @@ -44,7 +48,7 @@ _Jv_platform_close_on_exec (jint) // Ignore. } -#ifndef DISBALE_JAVA_NET +#ifndef DISABLE_JAVA_NET static inline int _Jv_socket (int domain, int type, int protocol) @@ -94,7 +98,7 @@ _Jv_read(int s, void *buf, int len) return ::recv (s, (char*) buf, len, 0); } -#endif /* DISBALE_JAVA_NET */ +#endif /* DISABLE_JAVA_NET */ #define HAVE_BACKTRACE diff --git a/libjava/interpret.cc b/libjava/interpret.cc index d3f919bac13..9791b4a5cd8 100644 --- a/libjava/interpret.cc +++ b/libjava/interpret.cc @@ -312,7 +312,7 @@ _Jv_InterpMethod::compile (const void * const *insn_targets) if (! first_pass) { - insns = (insn_slot *) _Jv_Malloc (sizeof (insn_slot) * next); + insns = (insn_slot *) _Jv_AllocBytes (sizeof (insn_slot) * next); next = 0; } @@ -2795,7 +2795,10 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) sp -= rmeth->stack_item_count; - NULLCHECK (sp[0].o); + // We don't use NULLCHECK here because we can't rely on that + // working for . So instead we do an explicit test. + if (! sp[0].o) + throw new java::lang::NullPointerException; fun = (void (*)()) rmeth->method->ncode; @@ -2813,7 +2816,10 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args) { rmeth = (_Jv_ResolvedMethod *) AVAL (); sp -= rmeth->stack_item_count; - NULLCHECK (sp[0].o); + // We don't use NULLCHECK here because we can't rely on that + // working for . So instead we do an explicit test. + if (! sp[0].o) + throw new java::lang::NullPointerException; fun = (void (*)()) rmeth->method->ncode; } goto perform_invoke; diff --git a/libjava/java/awt/image/ColorModel.java b/libjava/java/awt/image/ColorModel.java index 9cbbf4ba317..14a1b2e73b9 100644 --- a/libjava/java/awt/image/ColorModel.java +++ b/libjava/java/awt/image/ColorModel.java @@ -424,7 +424,7 @@ public abstract class ColorModel implements Transparency for (int i=0; ibeanClass, * first by looking for explicit information, next by diff --git a/libjava/java/io/CharArrayWriter.java b/libjava/java/io/CharArrayWriter.java index 7cf94255b80..6f749b4833c 100644 --- a/libjava/java/io/CharArrayWriter.java +++ b/libjava/java/io/CharArrayWriter.java @@ -1,5 +1,5 @@ /* CharArrayWriter.java -- Write chars to a buffer - 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. @@ -98,19 +98,13 @@ public class CharArrayWriter extends Writer */ public void close () { - closed = true; } /** * This method flushes all buffered chars to the stream. */ - public void flush () throws IOException + public void flush () { - synchronized (lock) - { - if (closed) - throw new IOException ("Stream closed"); - } } /** @@ -123,9 +117,6 @@ public class CharArrayWriter extends Writer synchronized (lock) { count = 0; - // Allow this to reopen the stream. - // FIXME - what does the JDK do? - closed = false; } } @@ -187,13 +178,10 @@ public class CharArrayWriter extends Writer * * @param oneChar The char to be read passed as an int */ - public void write (int oneChar) throws IOException + public void write (int oneChar) { synchronized (lock) { - if (closed) - throw new IOException ("Stream closed"); - resize (1); buf[count++] = (char) oneChar; } @@ -207,13 +195,10 @@ public class CharArrayWriter extends Writer * @param offset The index into the buffer to start writing data from * @param len The number of chars to write */ - public void write (char[] buffer, int offset, int len) throws IOException + public void write (char[] buffer, int offset, int len) { synchronized (lock) { - if (closed) - throw new IOException ("Stream closed"); - if (len >= 0) resize (len); System.arraycopy(buffer, offset, buf, count, len); @@ -230,13 +215,10 @@ public class CharArrayWriter extends Writer * @param offset The index into the string to start writing data from * @param len The number of chars to write */ - public void write (String str, int offset, int len) throws IOException + public void write (String str, int offset, int len) { synchronized (lock) { - if (closed) - throw new IOException ("Stream closed"); - if (len >= 0) resize (len); str.getChars(offset, offset + len, buf, count); @@ -289,9 +271,4 @@ public class CharArrayWriter extends Writer * The number of chars that have been written to the buffer */ protected int count; - - /** - * True if the stream has been closed. - */ - private boolean closed; } diff --git a/libjava/java/lang/Character.java b/libjava/java/lang/Character.java index 9955215f871..c5da892b71f 100644 --- a/libjava/java/lang/Character.java +++ b/libjava/java/lang/Character.java @@ -2079,8 +2079,8 @@ public final class Character implements Serializable, Comparable */ public static char forDigit(int digit, int radix) { - if (radix < MIN_RADIX || radix > MAX_RADIX || - digit < 0 || digit >= radix) + if (radix < MIN_RADIX || radix > MAX_RADIX + || digit < 0 || digit >= radix) return '\0'; return (char) (digit < 10 ? ('0' + digit) : ('a' - 10 + digit)); } diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index bd2903d47cf..4ccf3886431 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -20,6 +20,7 @@ details. */ #include #include #include +#include // We declare these here to avoid including gcj/cni.h. extern "C" void _Jv_InitClass (jclass klass); @@ -138,6 +139,13 @@ public: java::lang::ClassLoader *getClassLoader (void); + // This is an internal method that circumvents the usual security + // checks when getting the class loader. + java::lang::ClassLoader *getClassLoaderInternal (void) + { + return loader; + } + java::lang::reflect::Constructor *getConstructor (JArray *); JArray *getConstructors (void); java::lang::reflect::Constructor *getDeclaredConstructor (JArray *); @@ -296,6 +304,8 @@ private: java::lang::ClassLoader *loader); friend jclass _Jv_FindClassInCache (_Jv_Utf8Const *name, java::lang::ClassLoader *loader); + friend jclass _Jv_PopClass (void); + friend void _Jv_PushClass (jclass k); friend void _Jv_NewArrayClass (jclass element, java::lang::ClassLoader *loader, _Jv_VTable *array_vtable = 0); @@ -315,7 +325,7 @@ private: friend jshort _Jv_FindIIndex (jclass *, jshort *, jshort); friend void _Jv_LinkOffsetTable (jclass); friend void _Jv_LayoutVTableMethods (jclass klass); - friend void _Jv_SetVTableEntries (jclass, _Jv_VTable *); + friend void _Jv_SetVTableEntries (jclass, _Jv_VTable *, jboolean *); friend void _Jv_MakeVTable (jclass); // Return array class corresponding to element type KLASS, creating it if @@ -349,6 +359,7 @@ private: #endif friend class _Jv_BytecodeVerifier; + friend class gnu::gcj::runtime::StackTrace; // Chain for class pool. jclass next; @@ -403,6 +414,8 @@ private: jclass arrayclass; // Security Domain to which this class belongs (or null). java::security::ProtectionDomain *protectionDomain; + // Used by Jv_PopClass and _Jv_PushClass to communicate with StackTrace. + jclass chain; }; #endif /* __JAVA_LANG_CLASS_H__ */ diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java index 1b3b310cab3..033b2cc4a6e 100644 --- a/libjava/java/lang/ClassLoader.java +++ b/libjava/java/lang/ClassLoader.java @@ -13,7 +13,6 @@ package java.lang; import java.io.InputStream; import java.io.IOException; import java.net.URL; -import java.net.URLConnection; import java.security.AllPermission; import java.security.CodeSource; import java.security.Permission; @@ -23,15 +22,78 @@ import java.security.ProtectionDomain; import java.util.*; /** - * The class ClassLoader is intended to be subclassed by - * applications in order to describe new ways of loading classes, - * such as over the network. + * The ClassLoader is a way of customizing the way Java gets its classes + * and loads them into memory. The verifier and other standard Java things + * still run, but the ClassLoader is allowed great flexibility in determining + * where to get the classfiles and when to load and resolve them. For that + * matter, a custom ClassLoader can perform on-the-fly code generation or + * modification! * - * @author Kresten Krab Thorup + *

Every classloader has a parent classloader that is consulted before + * the 'child' classloader when classes or resources should be loaded. + * This is done to make sure that classes can be loaded from an hierarchy of + * multiple classloaders and classloaders do not accidentially redefine + * already loaded classes by classloaders higher in the hierarchy. + * + *

The grandparent of all classloaders is the bootstrap classloader, which + * loads all the standard system classes as implemented by GNU Classpath. The + * other special classloader is the system classloader (also called + * application classloader) that loads all classes from the CLASSPATH + * (java.class.path system property). The system classloader + * is responsible for finding the application classes from the classpath, + * and delegates all requests for the standard library classes to its parent + * the bootstrap classloader. Most programs will load all their classes + * through the system classloaders. + * + *

The bootstrap classloader in GNU Classpath is implemented as a couple of + * static (native) methods on the package private class + * java.lang.VMClassLoader, the system classloader is an + * instance of gnu.java.lang.SystemClassLoader + * (which is a subclass of java.net.URLClassLoader). + * + *

Users of a ClassLoader will normally just use the methods + *

    + *
  • loadClass() to load a class.
  • + *
  • getResource() or getResourceAsStream() + * to access a resource.
  • + *
  • getResources() to get an Enumeration of URLs to all + * the resources provided by the classloader and its parents with the + * same name.
  • + *
+ * + *

Subclasses should implement the methods + *

    + *
  • findClass() which is called by loadClass() + * when the parent classloader cannot provide a named class.
  • + *
  • findResource() which is called by + * getResource() when the parent classloader cannot provide + * a named resource.
  • + *
  • findResources() which is called by + * getResource() to combine all the resources with the + * same name from the classloader and its parents.
  • + *
  • findLibrary() which is called by + * Runtime.loadLibrary() when a class defined by the + * classloader wants to load a native library.
  • + *
+ * + * @author John Keiser + * @author Mark Wielaard + * @author Eric Blake + * @author Kresten Krab Thorup + * @see Class + * @since 1.0 + * @status still missing 1.4 functionality */ - public abstract class ClassLoader { + /** + * All classes loaded by this classloader. VM's may choose to implement + * this cache natively; but it is here available for use if necessary. It + * is not private in order to allow native code (and trusted subclasses) + * access to this field. + */ + final Map loadedClasses = new HashMap(); + /** * The desired assertion status of classes loaded by this loader, if not * overridden by package or class instructions. @@ -73,12 +135,40 @@ public abstract class ClassLoader // Package visible for use by Class. Map classAssertionStatus; - private ClassLoader parent; + /** + * The classloader that is consulted before this classloader. + * If null then the parent is the bootstrap classloader. + */ + private final ClassLoader parent; + + /** + * All packages defined by this classloader. It is not private in order to + * allow native code (and trusted subclasses) access to this field. + */ private HashMap definedPackages = new HashMap(); + /** + * Returns the parent of this classloader. If the parent of this + * classloader is the bootstrap classloader then this method returns + * null. A security check may be performed on + * RuntimePermission("getClassLoader"). + * + * @throws SecurityException if the security check fails + * @since 1.2 + */ public final ClassLoader getParent () { - /* FIXME: security */ + // Check if we may return the parent classloader + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + { + /* FIXME: security, getClassContext() not implemented. + Class c = VMSecurityManager.getClassContext()[1]; + ClassLoader cl = c.getClassLoader(); + if (cl != null && cl != this) + sm.checkPermission(new RuntimePermission("getClassLoader")); + */ + } return parent; } @@ -360,35 +450,36 @@ public abstract class ClassLoader + "are meaningless"); // as per 5.3.5.1 - if (name != null && findLoadedClass (name) != null) + if (name != null && findLoadedClass (name) != null) throw new java.lang.LinkageError ("class " + name + " already loaded"); - + if (protectionDomain == null) protectionDomain = defaultProtectionDomain; - try { - // Since we're calling into native code here, - // we better make sure that any generated - // exception is to spec! - - return defineClass0 (name, data, off, len, protectionDomain); - - } catch (LinkageError x) { - throw x; // rethrow - - } catch (java.lang.VirtualMachineError x) { - throw x; // rethrow - - } catch (java.lang.Throwable x) { - // This should never happen, or we are beyond spec. - - throw new InternalError ("Unexpected exception " - + "while defining class " - + name + ": " - + x.toString ()); - } + try + { + Class retval = defineClass0 (name, data, off, len, protectionDomain); + loadedClasses.put(retval.getName(), retval); + return retval; + } + catch (LinkageError x) + { + throw x; // rethrow + } + catch (java.lang.VirtualMachineError x) + { + throw x; // rethrow + } + catch (java.lang.Throwable x) + { + // This should never happen, or we are beyond spec. + throw new InternalError ("Unexpected exception " + + "while defining class " + + name + ": " + + x.toString ()); + } } /** This is the entry point of defineClass into the native code */ @@ -444,15 +535,22 @@ public abstract class ClassLoader { markClassErrorState0 (clazz); - if (x instanceof Error) - throw (Error)x; + LinkageError e; + if (x instanceof LinkageError) + e = (LinkageError)x; + else if (x instanceof ClassNotFoundException) + { + e = new NoClassDefFoundError("while resolving class: " + + clazz.getName()); + e.initCause (x); + } else { - InternalError e - = new InternalError ("unexpected exception during linking"); + e = new LinkageError ("unexpected exception during linking: " + + clazz.getName()); e.initCause (x); - throw e; } + throw e; } } } @@ -521,6 +619,8 @@ public abstract class ClassLoader * 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) @@ -546,6 +646,7 @@ public abstract class ClassLoader /** * Returns all Package objects defined by this classloader and its parents. * + * @return an array of all defined packages * @since 1.2 */ protected Package[] getPackages() @@ -577,6 +678,26 @@ public abstract class ClassLoader return allPackages; } + /** + * Called by Runtime.loadLibrary() to get an absolute path + * to a (system specific) library that was requested by a class loaded + * by this classloader. The default implementation returns + * null. 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 java.library.path 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() + * @since 1.2 + */ + protected String findLibrary(String name) + { + return null; + } + /** * Returns a class found in a system-specific way, typically * via the java.class.path system property. Loads the @@ -616,8 +737,10 @@ public abstract class ClassLoader * @param name class to find. * @return the class loaded, or null. */ - protected final native Class findLoadedClass(String name); - + protected final synchronized Class findLoadedClass(String name) + { + return (Class) loadedClasses.get(name); + } /** * Get a resource using the system classloader. diff --git a/libjava/java/lang/SecurityManager.java b/libjava/java/lang/SecurityManager.java index 3ae049c403f..e54ebc62f70 100644 --- a/libjava/java/lang/SecurityManager.java +++ b/libjava/java/lang/SecurityManager.java @@ -1,5 +1,5 @@ -/* java.lang.SecurityManager - Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. +/* SecurityManager.java -- security checks for privileged actions + Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -7,7 +7,7 @@ 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 @@ -38,736 +38,999 @@ exception statement from your version. */ package java.lang; -import java.net.*; -import java.util.*; -import java.io.*; +import java.awt.AWTPermission; +import java.io.File; +import java.io.FileDescriptor; +import java.io.FilePermission; +import java.lang.reflect.Member; +import java.net.InetAddress; +import java.net.SocketPermission; +import java.security.AllPermission; +import java.security.Permission; +import java.security.Security; +import java.security.SecurityPermission; +import java.util.PropertyPermission; /** - ** SecurityManager is a class you can extend to create - ** your own Java security policy. By default, there is - ** no SecurityManager installed in 1.1, which means that - ** all things are permitted to all people.

- ** - ** The default methods in this class deny all - ** things to all people. - ** - ** @author John Keiser - ** @version 1.1.0, 31 May 1998 - ** @since JDK1.0 - **/ -public class SecurityManager { - /** Tells whether or not the SecurityManager is currently - ** performing a security check. - **/ - protected boolean inCheck; - - /** Tells whether or not the SecurityManager is currently - ** performing a security check. - ** - ** @return whether or not the SecurityManager is - ** currently performing a security check. - **/ - public boolean getInCheck() { - return inCheck; - } + * SecurityManager is a class you can extend to create your own Java + * security policy. By default, there is no SecurityManager installed in + * 1.1, which means that all things are permitted to all people. The security + * manager, if set, is consulted before doing anything with potentially + * dangerous results, and throws a SecurityException if the + * action is forbidden. + * + *

A typical check is as follows, just before the dangerous operation:
+ *

+ * SecurityManager sm = System.getSecurityManager();
+ * if (sm != null)
+ *   sm.checkABC(argument, ...);
+ * 
+ * Note that this is thread-safe, by caching the security manager in a local + * variable rather than risking a NullPointerException if the mangager is + * changed between the check for null and before the permission check. + * + *

The special method checkPermission is a catchall, and + * the default implementation calls + * AccessController.checkPermission. In fact, all the other + * methods default to calling checkPermission. + * + *

Sometimes, the security check needs to happen from a different context, + * such as when called from a worker thread. In such cases, use + * getSecurityContext to take a snapshot that can be passed + * to the worker thread:
+ *

+ * Object context = null;
+ * SecurityManager sm = System.getSecurityManager();
+ * if (sm != null)
+ *   context = sm.getSecurityContext(); // defaults to an AccessControlContext
+ * // now, in worker thread
+ * if (sm != null)
+ *   sm.checkPermission(permission, context);
+ * 
+ *
+ * 

Permissions fall into these categories: File, Socket, Net, Security, + * Runtime, Property, AWT, Reflect, and Serializable. Each of these + * permissions have a property naming convention, that follows a hierarchical + * naming convention, to make it easy to grant or deny several permissions + * at once. Some permissions also take a list of permitted actions, such + * as "read" or "write", to fine-tune control even more. The permission + * java.security.AllPermission grants all permissions. + * + *

The default methods in this class deny all things to all people. You + * must explicitly grant permission for anything you want to be legal when + * subclassing this class. + * + * @author John Keiser + * @author Eric Blake + * @see ClassLoader + * @see SecurityException + * @see #checkTopLevelWindow(Object) + * @see System#getSecurityManager() + * @see System#setSecurityManager(SecurityManager) + * @see AccessController + * @see AccessControlContext + * @see AccessControlException + * @see Permission + * @see BasicPermission + * @see java.io.FilePermission + * @see java.net.SocketPermission + * @see java.util.PropertyPermission + * @see RuntimePermission + * @see java.awt.AWTPermission + * @see Policy + * @see SecurityPermission + * @see ProtectionDomain + * @since 1.0 + * @status still missing 1.4 functionality + */ +public class SecurityManager +{ + /** + * Tells whether or not the SecurityManager is currently performing a + * security check. + * @deprecated Use {@link #checkPermission(Permission)} instead. + */ + protected boolean inCheck; - /** Get a list of all the classes currently executing - ** methods on the Java stack. getClassContext()[0] is - ** the currently executing method - ** Spec Note: does not say whether - ** the stack will include the getClassContext() call or - ** the one just before it. - ** - ** @return an array containing all the methods on classes - ** on the Java execution stack. - **/ - protected Class[] getClassContext() { - return VMSecurityManager.getClassContext(); - } + /** + * Construct a new security manager. There may be a security check, of + * RuntimePermission("createSecurityManager"). + * + * @throws SecurityException if permission is denied + */ + public SecurityManager() + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkPermission(new RuntimePermission("createSecurityManager")); + } - /** Find the ClassLoader for the most recent class on the - ** stack that was loaded by an explicit ClassLoader. If - ** everything on the stack was loaded by the system - ** classloader, null is returned. - ** - ** @return the most recent ClassLoader on the execution - ** stack. - **/ - protected ClassLoader currentClassLoader() { - return VMSecurityManager.currentClassLoader(); - } + /** + * Tells whether or not the SecurityManager is currently performing a + * security check. + * + * @return true if the SecurityManager is in a security check + * @see #inCheck + * @deprecated use {@link #checkPermission(Permission)} instead + */ + public boolean getInCheck() + { + return inCheck; + } - /** Find the most recent class on the stack that was - ** loaded by an explicit ClassLoader. If everything on - ** the stack was loaded by the system classloader, null - ** is returned. - ** - ** @return the most recent loaded Class on the execution - ** stack. - **/ - protected Class currentLoadedClass() { - Class[] c = getClassContext(); - for(int i=0;i + *

  • All methods on the stack are from system classes
  • + *
  • All methods on the stack up to the first "privileged" caller, as + * created by {@link AccessController.doPrivileged(PrivilegedAction)}, + * are from system classes
  • + *
  • A check of java.security.AllPermission succeeds.
  • + * + * + * @return the most recent non-system ClassLoader on the execution stack + * @deprecated use {@link #checkPermission(Permission)} instead + */ + protected ClassLoader currentClassLoader() + { + return VMSecurityManager.currentClassLoader(); + } - /** Tell whether there is a class loaded with an explicit - ** ClassLoader on the stack. - ** - ** @return whether there is a class loaded with an - ** explicit ClassLoader on the stack. - **/ - protected boolean inClassLoader() { - return classLoaderDepth() != -1; - } + /** + * Find the first non-system class on the execution stack. A non-system + * class is one whose ClassLoader is not equal to + * {@link ClassLoader#getSystemClassLoader()} or its ancestors. This + * will return null in three cases:
    + *
  • All methods on the stack are from system classes
  • + *
  • All methods on the stack up to the first "privileged" caller, as + * created by {@link AccessController.doPrivileged(PrivilegedAction)}, + * are from system classes
  • + *
  • A check of java.security.AllPermission succeeds.
  • + *
    + * + * @return the most recent non-system Class on the execution stack + * @deprecated use {@link #checkPermission(Permission)} instead + */ + protected Class currentLoadedClass() + { + Class[] c = getClassContext(); + for (int i = 0; i < c.length; i++) + if (c[i].getClassLoader() != null) + return c[i]; + return null; + } + /** + * Get the depth of a particular class on the execution stack. + * + * @param className the fully-qualified name to search for + * @return the index of the class on the stack, or -1 + * @deprecated use {@link #checkPermission(Permission)} instead + */ + protected int classDepth(String className) + { + Class[] c = getClassContext(); + for (int i = 0; i < c.length; i++) + if (className.equals(c[i].getName())) + return i; + return -1; + } - /** Get the depth of a particular class on the execution - ** stack. - ** - ** @param className the fully-qualified name of the class - ** to search for on the stack. - ** @return the index of the class on the stack, or -1 if - ** the class is not on the stack. - **/ - protected int classDepth(String className) { - Class[] c = getClassContext(); - for(int i=0;i + *
  • All methods on the stack are from system classes
  • + *
  • All methods on the stack up to the first "privileged" caller, as + * created by {@link AccessController.doPrivileged(PrivilegedAction)}, + * are from system classes
  • + *
  • A check of java.security.AllPermission succeeds.
  • + *
    + * + * @return the index of the most recent non-system Class on the stack + * @deprecated use {@link #checkPermission(Permission)} instead + */ + protected int classLoaderDepth() + { + Class[] c = getClassContext(); + for (int i = 0; i < c.length; i++) + if (c[i].getClassLoader() != null) + return i; + return -1; + } - /** Tell whether the specified class is on the execution - ** stack. - ** - ** @param className the fully-qualified name of the class - ** to search for on the stack. - ** @return whether the specified class is on the - ** execution stack. - **/ - protected boolean inClass(String className) { - return classDepth(className) != -1; - } + /** + * Tell whether the specified class is on the execution stack. + * + * @param className the fully-qualified name of the class to find + * @return whether the specified class is on the execution stack + * @deprecated use {@link #checkPermission(Permission)} instead + */ + protected boolean inClass(String className) + { + return classDepth(className) != -1; + } - /** Get an implementation-dependent Object that contains - ** enough information about the current environment to be - ** able to perform standard security checks later. This - ** is used by trusted methods that need to verify that - ** their callers have sufficient access to perform - ** certain operations.

    - ** - ** Currently the only methods that use this are checkRead() - ** and checkConnect(). - ** - ** @see checkConnect(java.lang.String,int,java.lang.Object) - ** @see checkRead(java.lang.String,java.lang.Object) - **/ - public Object getSecurityContext() { - return new SecurityContext(getClassContext()); - } + /** + * Tell whether there is a class loaded with an explicit ClassLoader on + * the stack. + * + * @return whether a class with an explicit ClassLoader is on the stack + * @deprecated use {@link #checkPermission(Permission)} instead + */ + protected boolean inClassLoader() + { + return classLoaderDepth() != -1; + } - /** Check if the current thread is allowed to create a - ** ClassLoader.

    - ** - ** This method is called from ClassLoader.ClassLoader(), - ** in other words, whenever a ClassLoader is created.

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.ClassLoader#ClassLoader() - **/ - public void checkCreateClassLoader() { - throw new SecurityException("Cannot create new ClassLoaders."); - } + /** + * Get an implementation-dependent Object that contains enough information + * about the current environment to be able to perform standard security + * checks later. This is used by trusted methods that need to verify that + * their callers have sufficient access to perform certain operations. + * + *

    Currently the only methods that use this are checkRead() and + * checkConnect(). The default implementation returns an + * AccessControlContext. + * + * @return a security context + * @see #checkConnect(String, int, Object) + * @see #checkRead(String, Object) + * @see AccessControlContext + * @see AccessController#getContext() + */ + public Object getSecurityContext() + { + // XXX Should be: return AccessController.getContext(); + return new SecurityContext(getClassContext()); + } - /** Check if the current thread is allowed to modify this - ** other Thread.

    - ** - ** Called by Thread.stop(), suspend(), resume(), and - ** interrupt(), destroy(), setPriority(), setName() and - ** setDaemon().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param g the Thread to check against - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.Thread#stop() - ** @see java.lang.Thread#suspend() - ** @see java.lang.Thread#resume() - ** @see java.lang.Thread#interrupt() - ** @see java.lang.Thread#destroy() - ** @see java.lang.Thread#setPriority(int) - ** @see java.lang.Thread#setName(java.lang.String) - ** @see java.lang.Thread#setDaemon(boolean) - **/ - public void checkAccess(Thread t) { - throw new SecurityException("Cannot modify Threads."); - } + /** + * Check if the current thread is allowed to perform an operation that + * requires the specified Permission. This defaults to + * AccessController.checkPermission. + * + * @param perm the Permission required + * @throws SecurityException if permission is denied + * @throws NullPointerException if perm is null + * @since 1.2 + */ + public void checkPermission(Permission perm) + { + // XXX Should be: AccessController.checkPermission(perm); + throw new SecurityException("Operation not allowed"); + } - /** Check if the current thread is allowed to modify this - ** ThreadGroup.

    - ** - ** Called by Thread.Thread() (to add a thread to the - ** ThreadGroup), ThreadGroup.ThreadGroup() (to add this - ** ThreadGroup to a parent), ThreadGroup.stop(), - ** suspend(), resume(), interrupt(), destroy(), - ** setDaemon(), and setMaxPriority().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param g the ThreadGroup to check against - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.Thread#Thread() - ** @see java.lang.ThreadGroup#ThreadGroup() - ** @see java.lang.ThreadGroup#stop() - ** @see java.lang.ThreadGroup#suspend() - ** @see java.lang.ThreadGroup#resume() - ** @see java.lang.ThreadGroup#interrupt() - ** @see java.lang.ThreadGroup#setDaemon(boolean) - ** @see java.lang.ThreadGroup#setMaxPriority(int) - **/ - public void checkAccess(ThreadGroup g) { - throw new SecurityException("Cannot modify ThreadGroups."); - } + /** + * Check if the current thread is allowed to perform an operation that + * requires the specified Permission. This is done in a + * context previously returned by getSecurityContext(). The + * default implementation expects context to be an AccessControlContext, + * and it calls AccessControlContext.checkPermission(perm). + * + * @param perm the Permission required + * @param context a security context + * @throws SecurityException if permission is denied, or if context is + * not an AccessControlContext + * @throws NullPointerException if perm is null + * @see #getSecurityContext() + * @see AccessControlContext#checkPermission(Permission) + * @since 1.2 + */ + public void checkPermission(Permission perm, Object context) + { + // XXX Should be: + // if (! (context instanceof AccessControlContext)) + // throw new SecurityException("Missing context"); + // ((AccessControlContext) context).checkPermission(perm); + throw new SecurityException("Operation not allowed"); + } - /** Check if the current thread is allowed to exit the - ** JVM with the given status.

    - ** - ** This method is called from Runtime.exit().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param status the status to exit with - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.Runtime#exit() - ** @see java.lang.Runtime#exit(int) - **/ - public void checkExit(int status) { - throw new SecurityException("Cannot exit JVM."); - } + /** + * Check if the current thread is allowed to create a ClassLoader. This + * method is called from ClassLoader.ClassLoader(), and checks + * RuntimePermission("createClassLoader"). If you override + * this, you should call super.checkCreateClassLoader() rather + * than throwing an exception. + * + * @throws SecurityException if permission is denied + * @see ClassLoader#ClassLoader() + */ + public void checkCreateClassLoader() + { + checkPermission(new RuntimePermission("createClassLoader")); + } - /** Check if the current thread is allowed to execute the - ** given program.

    - ** - ** This method is called from Runtime.exec().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param program the name of the program to exec - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.Runtime#exec(java.lang.String[],java.lang.String[]) - **/ - public void checkExec(String program) { - throw new SecurityException("Cannot execute programs."); - } + /** + * Check if the current thread is allowed to modify another Thread. This is + * called by Thread.stop(), suspend(), resume(), interrupt(), destroy(), + * setPriority(), setName(), and setDaemon(). The default implementation + * checks RuntimePermission("modifyThread") on system threads (ie. + * threads in ThreadGroup with a null parent), and returns silently on + * other threads. + * + *

    If you override this, you must do two things. First, call + * super.checkAccess(t), to make sure you are not relaxing + * requirements. Second, if the calling thread has + * RuntimePermission("modifyThread"), return silently, so that + * core classes (the Classpath library!) can modify any thread. + * + * @param t the other Thread to check + * @throws SecurityException if permission is denied + * @throws NullPointerException if t is null + * @see Thread#stop() + * @see Thread#suspend() + * @see Thread#resume() + * @see Thread#setPriority(int) + * @see Thread#setName(String) + * @see Thread#setDaemon(boolean) + */ + public void checkAccess(Thread t) + { + if (t.group != null && t.group.getParent() != null) + checkPermission(new RuntimePermission("modifyThread")); + } - /** Check if the current thread is allowed to link in the - ** given native library.

    - ** - ** This method is called from Runtime.load() (and hence, - ** by loadLibrary() as well).

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param filename the full name of the library to load - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.Runtime#load(java.lang.String) - **/ - public void checkLink(String filename) { - throw new SecurityException("Cannot link native libraries."); - } + /** + * Check if the current thread is allowed to modify a ThreadGroup. This is + * called by Thread.Thread() (to add a thread to the ThreadGroup), + * ThreadGroup.ThreadGroup() (to add this ThreadGroup to a parent), + * ThreadGroup.stop(), suspend(), resume(), interrupt(), destroy(), + * setDaemon(), and setMaxPriority(). The default implementation + * checks RuntimePermission("modifyThread") on the system group (ie. + * the one with a null parent), and returns silently on other groups. + * + *

    If you override this, you must do two things. First, call + * super.checkAccess(t), to make sure you are not relaxing + * requirements. Second, if the calling thread has + * RuntimePermission("modifyThreadGroup"), return silently, + * so that core classes (the Classpath library!) can modify any thread. + * + * @param g the ThreadGroup to check + * @throws SecurityException if permission is denied + * @throws NullPointerException if g is null + * @see Thread#Thread() + * @see ThreadGroup#ThreadGroup() + * @see ThreadGroup#stop() + * @see ThreadGroup#suspend() + * @see ThreadGroup#resume() + * @see ThreadGroup#interrupt() + * @see ThreadGroup#setDaemon(boolean) + * @see ThreadGroup#setMaxPriority(int) + */ + public void checkAccess(ThreadGroup g) + { + if (g.getParent() != null) + checkPermission(new RuntimePermission("modifyThreadGroup")); + } - /** Check if the current thread is allowed to read the - ** given file using the FileDescriptor.

    - ** - ** This method is called from - ** FileInputStream.FileInputStream().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param desc the FileDescriptor representing the file - ** to access - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.io.FileInputStream#FileInputStream(java.io.FileDescriptor) - **/ - public void checkRead(FileDescriptor desc) { - throw new SecurityException("Cannot read files via file descriptors."); - } + /** + * Check if the current thread is allowed to exit the JVM with the given + * status. This method is called from Runtime.exit() and Runtime.halt(). + * The default implementation checks + * RuntimePermission("exitVM"). If you override this, call + * super.checkExit rather than throwing an exception. + * + * @param status the status to exit with + * @throws SecurityException if permission is denied + * @see Runtime#exit(int) + * @see Runtime#halt(int) + */ + public void checkExit(int status) + { + checkPermission(new RuntimePermission("exitVM")); + } - /** Check if the current thread is allowed to read the - ** given file.

    - ** - ** This method is called from - ** FileInputStream.FileInputStream(), - ** RandomAccessFile.RandomAccessFile(), File.exists(), - ** canRead(), isFile(), isDirectory(), lastModified(), - ** length() and list().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param filename the full name of the file to access - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.io.File - ** @see java.io.FileInputStream#FileInputStream(java.lang.String) - ** @see java.io.RandomAccessFile#RandomAccessFile(java.lang.String) - **/ - public void checkRead(String filename) { - throw new SecurityException("Cannot read files via file names."); - } + /** + * Check if the current thread is allowed to execute the given program. This + * method is called from Runtime.exec(). If the name is an absolute path, + * the default implementation checks + * FilePermission(program, "execute"), otherwise it checks + * FilePermission("<<ALL FILES>>", "execute"). If + * you override this, call super.checkExec rather than + * throwing an exception. + * + * @param program the name of the program to exec + * @throws SecurityException if permission is denied + * @throws NullPointerException if program is null + * @see Runtime#exec(String[], String[], File) + */ + public void checkExec(String program) + { + if (! program.equals(new File(program).getAbsolutePath())) + program = "<>"; + checkPermission(new FilePermission(program, "execute")); + } - /** Check if the current thread is allowed to read the - ** given file. using the given SecurityContext.

    - ** - ** I know of no core class that calls this method.

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param filename the full name of the file to access - ** @param securityContext the Security Context to - ** determine access for. - ** @exception SecurityException if the operation is not - ** permitted. - **/ - public void checkRead(String filename, Object securityContext) { - throw new SecurityException("Cannot read files via file names."); - } + /** + * Check if the current thread is allowed to link in the given native + * library. This method is called from Runtime.load() (and hence, by + * loadLibrary() as well). The default implementation checks + * RuntimePermission("loadLibrary." + filename). If you + * override this, call super.checkLink rather than throwing + * an exception. + * + * @param filename the full name of the library to load + * @throws SecurityException if permission is denied + * @throws NullPointerException if filename is null + * @see Runtime#load(String) + */ + public void checkLink(String filename) + { + // Use the toString() hack to do the null check. + checkPermission(new RuntimePermission("loadLibrary." + + filename.toString())); + } - /** Check if the current thread is allowed to write to the - ** given file using the FileDescriptor.

    - ** - ** This method is called from - ** FileOutputStream.FileOutputStream().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param desc the FileDescriptor representing the file - ** to access - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.io.FileOutputStream#FileOutputStream(java.io.FileDescriptor) - **/ - public void checkWrite(FileDescriptor desc) { - throw new SecurityException("Cannot write files via file descriptors."); - } + /** + * Check if the current thread is allowed to read the given file using the + * FileDescriptor. This method is called from + * FileInputStream.FileInputStream(). The default implementation checks + * RuntimePermission("readFileDescriptor"). If you override + * this, call super.checkRead rather than throwing an + * exception. + * + * @param desc the FileDescriptor representing the file to access + * @throws SecurityException if permission is denied + * @throws NullPointerException if desc is null + * @see FileInputStream#FileInputStream(FileDescriptor) + */ + public void checkRead(FileDescriptor desc) + { + if (desc == null) + throw new NullPointerException(); + checkPermission(new RuntimePermission("readFileDescriptor")); + } - /** Check if the current thread is allowed to write to the - ** given file.

    - ** - ** This method is called from - ** FileOutputStream.FileOutputStream(), - ** RandomAccessFile.RandomAccessFile(), - ** File.canWrite(), mkdir(), and renameTo().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param filename the full name of the file to access - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.io.File#canWrite() - ** @see java.io.File#mkdir() - ** @see java.io.File#renameTo() - ** @see java.io.FileOutputStream#FileOutputStream(java.lang.String) - ** @see java.io.RandomAccessFile#RandomAccessFile(java.lang.String) - **/ - public void checkWrite(String filename) { - throw new SecurityException("Cannot write files via file names."); - } + /** + * Check if the current thread is allowed to read the given file. This + * method is called from FileInputStream.FileInputStream(), + * RandomAccessFile.RandomAccessFile(), File.exists(), canRead(), isFile(), + * isDirectory(), lastModified(), length() and list(). The default + * implementation checks FilePermission(filename, "read"). If + * you override this, call super.checkRead rather than + * throwing an exception. + * + * @param filename the full name of the file to access + * @throws SecurityException if permission is denied + * @throws NullPointerException if filename is null + * @see File + * @see FileInputStream#FileInputStream(String) + * @see RandomAccessFile#RandomAccessFile(String) + */ + public void checkRead(String filename) + { + checkPermission(new FilePermission(filename, "read")); + } - /** Check if the current thread is allowed to delete the - ** given file.

    - ** - ** This method is called from File.delete().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param filename the full name of the file to delete - ** @exception SecurityException if th operation is not - ** permitted. - ** @see java.io.File#delete() - **/ - public void checkDelete(String filename) { - throw new SecurityException("Cannot delete files."); - } + /** + * Check if the current thread is allowed to read the given file. using the + * given security context. The context must be a result of a previous call + * to getSecurityContext(). The default implementation checks + * AccessControlContext.checkPermission(new FilePermission(filename, + * "read")). If you override this, call super.checkRead + * rather than throwing an exception. + * + * @param filename the full name of the file to access + * @param context the context to determine access for + * @throws SecurityException if permission is denied, or if context is + * not an AccessControlContext + * @throws NullPointerException if filename is null + * @see #getSecurityContext() + * @see AccessControlContext#checkPermission(Permission) + */ + public void checkRead(String filename, Object context) + { + // XXX Should be: + // if (! (context instanceof AccessControlContext)) + // throw new SecurityException("Missing context"); + // AccessControlContext ac = (AccessControlContext) context; + // ac.checkPermission(new FilePermission(filename, "read")); + throw new SecurityException("Cannot read files via file names."); + } - /** Check if the current thread is allowed to connect to a - ** given host on a given port.

    - ** - ** This method is called from Socket.Socket(). - ** - ** SecurityManager's implementation always denies access. - ** - ** @param host the host to connect to - ** @param port the port to connect on - ** @exception SecurityException if the operation is not - ** permitted - ** @see java.net.Socket#Socket() - **/ - public void checkConnect(String host, int port) { - throw new SecurityException("Cannot make network connections."); - } + /** + * Check if the current thread is allowed to write the given file using the + * FileDescriptor. This method is called from + * FileOutputStream.FileOutputStream(). The default implementation checks + * RuntimePermission("writeFileDescriptor"). If you override + * this, call super.checkWrite rather than throwing an + * exception. + * + * @param desc the FileDescriptor representing the file to access + * @throws SecurityException if permission is denied + * @throws NullPointerException if desc is null + * @see FileOutputStream#FileOutputStream(FileDescriptor) + */ + public void checkWrite(FileDescriptor desc) + { + if (desc == null) + throw new NullPointerException(); + checkPermission(new RuntimePermission("writeFileDescriptor")); + } - /** Check if the current thread is allowed to connect to a - ** given host on a given port using a specific security - ** context to determine access.

    - ** - ** This method is not called in the 1.1 core classes.

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param host the host to connect to - ** @param port the port to connect on - ** @param securityContext the security context to - ** determine access with - ** @exception SecurityException if the operation is not - ** permitted - **/ - public void checkConnect(String host, int port, Object securityContext) { - throw new SecurityException("Cannot make network connections."); - } + /** + * Check if the current thread is allowed to write the given file. This + * method is called from FileOutputStream.FileOutputStream(), + * RandomAccessFile.RandomAccessFile(), File.canWrite(), mkdir(), and + * renameTo(). The default implementation checks + * FilePermission(filename, "write"). If you override this, + * call super.checkWrite rather than throwing an exception. + * + * @param filename the full name of the file to access + * @throws SecurityException if permission is denied + * @throws NullPointerException if filename is null + * @see File + * @see File#canWrite() + * @see File#mkdir() + * @see File#renameTo() + * @see FileOutputStream#FileOutputStream(String) + * @see RandomAccessFile#RandomAccessFile(String) + */ + public void checkWrite(String filename) + { + checkPermission(new FilePermission(filename, "write")); + } - /** Check if the current thread is allowed to listen to a - ** specific port for data.

    - ** - ** This method is called by ServerSocket.ServerSocket().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param port the port to listen on - ** @exception SecurityException if the operation is not - ** permitted - ** @see java.net.ServerSocket#ServerSocket(int) - **/ - public void checkListen(int port) { - throw new SecurityException("Cannot listen for connections."); - } + /** + * Check if the current thread is allowed to delete the given file. This + * method is called from File.delete(). The default implementation checks + * FilePermission(filename, "delete"). If you override this, + * call super.checkDelete rather than throwing an exception. + * + * @param filename the full name of the file to delete + * @throws SecurityException if permission is denied + * @throws NullPointerException if filename is null + * @see File#delete() + */ + public void checkDelete(String filename) + { + checkPermission(new FilePermission(filename, "delete")); + } - /** Check if the current thread is allowed to accept a - ** connection from a particular host on a particular - ** port.

    - ** - ** This method is called by ServerSocket.implAccept().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param host the host which wishes to connect - ** @param port the port the connection will be on - ** @exception SecurityException if the operation is not - ** permitted - ** @see java.net.ServerSocket#accept() - **/ - public void checkAccept(String host, int port) { - throw new SecurityException("Cannot accept connections."); - } + /** + * Check if the current thread is allowed to connect to a given host on a + * given port. This method is called from Socket.Socket(). A port number + * of -1 indicates the caller is attempting to determine an IP address, so + * the default implementation checks + * SocketPermission(host, "resolve"). Otherwise, the default + * implementation checks + * SocketPermission(host + ":" + port, "connect"). If you + * override this, call super.checkConnect rather than throwing + * an exception. + * + * @param host the host to connect to + * @param port the port to connect on + * @throws SecurityException if permission is denied + * @throws NullPointerException if host is null + * @see Socket#Socket() + */ + public void checkConnect(String host, int port) + { + if (port == -1) + checkPermission(new SocketPermission(host, "resolve")); + else + // Use the toString() hack to do the null check. + checkPermission(new SocketPermission(host.toString() + ":" + port, + "connect")); + } - /** Check if the current thread is allowed to read and - ** write multicast to a particular address.

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @XXX where is it called? - ** - ** @param addr the address to multicast to. - ** @exception SecurityException if the operation is not - ** permitted. - **/ - public void checkMulticast(InetAddress addr) { - throw new SecurityException("Cannot read or write multicast."); - } + /** + * Check if the current thread is allowed to connect to a given host on a + * given port, using the given security context. The context must be a + * result of a previous call to getSecurityContext. A port + * number of -1 indicates the caller is attempting to determine an IP + * address, so the default implementation checks + * AccessControlContext.checkPermission(new SocketPermission(host, + * "resolve")). Otherwise, the default implementation checks + * AccessControlContext.checkPermission(new SocketPermission(host + * + ":" + port, "connect")). If you override this, call + * super.checkConnect rather than throwing an exception. + * + * @param host the host to connect to + * @param port the port to connect on + * @param context the context to determine access for + * @throws SecurityException if permission is denied, or if context is + * not an AccessControlContext + * @throws NullPointerException if host is null + * @see #getSecurityContext() + * @see AccessControlContext#checkPermission(Permission) + */ + public void checkConnect(String host, int port, Object securityContext) + { + // XXX Should be: + // if (! (context instanceof AccessControlContext)) + // throw new SecurityException("Missing context"); + // AccessControlContext ac = (AccessControlContext) context; + // if (port == -1) + // ac.checkPermission(new SocketPermission(host, "resolve")); + // else + // // Use the toString() hack to do the null check. + // ac.checkPermission(new SocketPermission(host.toString + ":" +port, + // "connect")); + throw new SecurityException("Cannot make network connections."); + } - /** Check if the current thread is allowed to read and - ** write multicast to a particular address with a - ** particular ttl value.

    - ** - ** SecurityManager's implementation always denies access.

    - ** - ** @XXX where is it called? - ** - ** @XXX what the hell is ttl? Expand abbreviation. - ** - ** @param addr the address to multicast to. - ** @param ttl the ttl value to use - ** @exception SecurityException if the operation is not - ** permitted. - **/ - public void checkMulticast(InetAddress addr, byte ttl) { - throw new SecurityException("Cannot read or write multicast."); - } + /** + * Check if the current thread is allowed to listen to a specific port for + * data. This method is called by ServerSocket.ServerSocket(). The default + * implementation checks + * SocketPermission("localhost:" + (port == 0 ? "1024-" : "" + port), + * "listen"). If you override this, call + * super.checkListen rather than throwing an exception. + * + * @param port the port to listen on + * @throws SecurityException if permission is denied + * @see ServerSocket#ServerSocket(int) + */ + public void checkListen(int port) + { + checkPermission(new SocketPermission("localhost:" + + (port == 0 ? "1024-" : "" +port), + "listen")); + } - /** - ** Check if the current thread is allowed to perform an - ** operation that requires the specified Permission. - ** - ** @param perm The Permission required. - ** @exception SecurityException If the operation is not allowed. - **/ - public void checkPermission(java.security.Permission perm) { - throw new SecurityException("Operation not allowed"); - } + /** + * Check if the current thread is allowed to accept a connection from a + * particular host on a particular port. This method is called by + * ServerSocket.implAccept(). The default implementation checks + * SocketPermission(host + ":" + port, "accept"). If you + * override this, call super.checkAccept rather than throwing + * an exception. + * + * @param host the host which wishes to connect + * @param port the port the connection will be on + * @throws SecurityException if permission is denied + * @throws NullPointerException if host is null + * @see ServerSocket#accept() + */ + public void checkAccept(String host, int port) + { + // Use the toString() hack to do the null check. + checkPermission(new SocketPermission(host.toString() + ":" + port, + "accept")); + } - /** - ** Check if the current thread is allowed to perform an - ** operation that requires the specified Permission. - ** - ** @param perm The Permission required. - ** @param context A security context - ** @exception SecurityException If the operation is not allowed. - ** @since 1.2 - **/ - public void checkPermission(java.security.Permission perm, - Object context) { - throw new SecurityException("Operation not allowed"); - } + /** + * Check if the current thread is allowed to read and write multicast to + * a particular address. The default implementation checks + * SocketPermission(addr.getHostAddress(), "accept,connect"). + * If you override this, call super.checkMulticast rather than + * throwing an exception. + * + * @param addr the address to multicast to + * @throws SecurityException if permission is denied + * @throws NullPointerException if host is null + * @since 1.1 + */ + public void checkMulticast(InetAddress addr) + { + checkPermission(new SocketPermission(addr.getHostAddress(), + "accept,connect")); + } - /** Check if the current thread is allowed to read or - ** write all the system properties at once.

    - ** - ** This method is called by System.getProperties() - ** and setProperties().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.System#getProperties() - ** @see java.lang.System#setProperties(java.util.Properties) - **/ - public void checkPropertiesAccess() { - throw new SecurityException("Cannot access all system properties at once."); - } + /** + *Check if the current thread is allowed to read and write multicast to + * a particular address with a particular ttl (time-to-live) value. The + * default implementation ignores ttl, and checks + * SocketPermission(addr.getHostAddress(), "accept,connect"). + * If you override this, call super.checkMulticast rather than + * throwing an exception. + * + * @param addr the address to multicast to + * @param ttl value in use for multicast send + * @throws SecurityException if permission is denied + * @throws NullPointerException if host is null + * @since 1.1 + * @deprecated use {@link #checkPermission(Permission)} instead + */ + public void checkMulticast(InetAddress addr, byte ttl) + { + checkPermission(new SocketPermission(addr.getHostAddress(), + "accept,connect")); + } - /** Check if the current thread is allowed to read or - ** write a particular system property.

    - ** - ** This method is called by System.getProperty() and - ** setProperty().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @exception SecurityException is the operation is not - ** permitted. - ** @see java.lang.System#getProperty(java.lang.String) - ** @see java.lang.System#setProperty(java.lang.String,java.lang.String) - **/ - public void checkPropertyAccess(String name) { - throw new SecurityException("Cannot access individual system properties."); - } + /** + * Check if the current thread is allowed to read or write all the system + * properties at once. This method is called by System.getProperties() + * and setProperties(). The default implementation checks + * PropertyPermission("*", "read,write"). If you override + * this, call super.checkPropertiesAccess rather than + * throwing an exception. + * + * @throws SecurityException if permission is denied + * @see System#getProperties() + * @see System#setProperties(Properties) + */ + public void checkPropertiesAccess() + { + checkPermission(new PropertyPermission("*", "read,write")); + } - /** Check if the current thread is allowed to create a - ** top-level window. If it is not, the operation should - ** still go through, but some sort of nonremovable - ** warning should be placed on the window to show that it - ** is untrusted.

    - ** - ** This method is called by Window.Window().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param window the window to create - ** @see java.awt.Window#Window(java.awt.Frame) - **/ - public boolean checkTopLevelWindow(Object window) { - return false; - } + /** + * Check if the current thread is allowed to read a particular system + * property (writes are checked directly via checkPermission). This method + * is called by System.getProperty() and setProperty(). The default + * implementation checks PropertyPermission(key, "read"). If + * you override this, call super.checkPropertyAccess rather + * than throwing an exception. + * + * @throws SecurityException if permission is denied + * @throws NullPointerException if key is null + * @throws IllegalArgumentException if key is "" + * @see System#getProperty(String) + */ + public void checkPropertyAccess(String key) + { + checkPermission(new PropertyPermission(key, "read")); + } - /** Check if the current thread is allowed to create a - ** print job.

    - ** - ** This method is called by Toolkit.getPrintJob(). (I - ** assume so, at least, it just don't say nothing about - ** it in the spec.)

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.awt.Toolkit.getPrintJob(java.awt.Frame,java.lang.String,java.util.Properties) - **/ - public void checkPrintJobAccess() { - throw new SecurityException("Cannot create print jobs."); - } + /** + * Check if the current thread is allowed to create a top-level window. If + * it is not, the operation should still go through, but some sort of + * nonremovable warning should be placed on the window to show that it + * is untrusted. This method is called by Window.Window(). The default + * implementation checks + * AWTPermission("showWindowWithoutWarningBanner"), and returns + * true if no exception was thrown. If you override this, use + * return super.checkTopLevelWindow rather than returning + * false. + * + * @param window the window to create + * @return true if there is permission to show the window without warning + * @throws NullPointerException if window is null + * @see Window#Window(Frame) + */ + public boolean checkTopLevelWindow(Object window) + { + if (window == null) + throw new NullPointerException(); + try + { + checkPermission(new AWTPermission("showWindowWithoutWarningBanner")); + return true; + } + catch (SecurityException e) + { + return false; + } + } - /** Check if the current thread is allowed to use the - ** system clipboard.

    - ** - ** This method is called by Toolkit.getSystemClipboard(). - ** (I assume.)

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.awt.Toolkit#getSystemClipboard() - **/ - public void checkSystemClipboardAccess() { - throw new SecurityException("Cannot access the system clipboard."); - } + /** + * Check if the current thread is allowed to create a print job. This + * method is called by Toolkit.getPrintJob(). The default implementation + * checks RuntimePermission("queuePrintJob"). If you override + * this, call super.checkPrintJobAccess rather than throwing + * an exception. + * + * @throws SecurityException if permission is denied + * @see Toolkit#getPrintJob(Frame, String, Properties) + * @since 1.1 + */ + public void checkPrintJobAccess() + { + checkPermission(new RuntimePermission("queuePrintJob")); + } - /** Check if the current thread is allowed to use the AWT - ** event queue.

    - ** - ** This method is called by Toolkit.getSystemEventQueue().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.awt.Toolkit#getSystemEventQueue() - **/ - public void checkAwtEventQueueAccess() { - throw new SecurityException("Cannot access the AWT event queue."); - } + /** + * Check if the current thread is allowed to use the system clipboard. This + * method is called by Toolkit.getSystemClipboard(). The default + * implementation checks AWTPermission("accessClipboard"). If + * you override this, call super.checkSystemClipboardAccess + * rather than throwing an exception. + * + * @throws SecurityException if permission is denied + * @see Toolkit#getSystemClipboard() + * @since 1.1 + */ + public void checkSystemClipboardAccess() + { + checkPermission(new AWTPermission("accessClipboard")); + } - /** Check if the current thread is allowed to access the - ** specified package at all.

    - ** - ** This method is called by ClassLoader.loadClass() in - ** user-created ClassLoaders.

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param packageName the package name to check access to - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.ClassLoader#loadClass(java.lang.String,boolean) - **/ - public void checkPackageAccess(String packageName) { - throw new SecurityException("Cannot access packages via the ClassLoader."); - } + /** + * Check if the current thread is allowed to use the AWT event queue. This + * method is called by Toolkit.getSystemEventQueue(). The default + * implementation checks AWTPermission("accessEventQueue"). + * you override this, call super.checkAwtEventQueueAccess + * rather than throwing an exception. + * + * @throws SecurityException if permission is denied + * @see Toolkit#getSystemEventQueue() + * @since 1.1 + */ + public void checkAwtEventQueueAccess() + { + // Should be: checkPermission(new AWTPermission("accessEventQueue")); + throw new SecurityException("Cannot access the AWT event queue."); + } - /** Check if the current thread is allowed to define - ** classes the specified package. If the class already - ** created, though, ClassLoader.loadClass() can still - ** return the Class if checkPackageAccess() checks out.

    - ** - ** This method is called by ClassLoader.loadClass() in - ** user-created ClassLoaders.

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param packageName the package name to check access to - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.ClassLoader#loadClass(java.lang.String,boolean) - **/ - public void checkPackageDefinition(String packageName) { - throw new SecurityException("Cannot load classes into any packages via the ClassLoader."); - } + /** + * Check if the current thread is allowed to access the specified package + * at all. This method is called by ClassLoader.loadClass() in user-created + * ClassLoaders. The default implementation gets a list of all restricted + * packages, via Security.getProperty("package.access"). Then, + * if packageName starts with or equals any restricted package, it checks + * RuntimePermission("accessClassInPackage." + packageName). + * If you override this, you should call + * super.checkPackageAccess before doing anything else. + * + * @param packageName the package name to check access to + * @throws SecurityException if permission is denied + * @throws NullPointerException if packageName is null + * @see ClassLoader#loadClass(String, boolean) + * @see Security#getProperty(String) + */ + public void checkPackageAccess(String packageName) + { + checkPackageList(packageName, "access", "accessClassInPackage."); + } - /** Check if the current thread is allowed to set the - ** current socket factory.

    - ** - ** This method is called by Socket.setSocketImplFactory(), - ** ServerSocket.setSocketFactory(), and - ** URL.setURLStreamHandlerFactory().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory) - ** @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory) - ** @see java.net.URL#setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory) - **/ - public void checkSetFactory() { - throw new SecurityException("Cannot set the socket factory."); - } + /** + * Check if the current thread is allowed to define a class into the + * specified package. This method is called by ClassLoader.loadClass() in + * user-created ClassLoaders. The default implementation gets a list of all + * restricted packages, via + * Security.getProperty("package.definition"). Then, if + * packageName starts with or equals any restricted package, it checks + * RuntimePermission("defineClassInPackage." + packageName). + * If you override this, you should call + * super.checkPackageDefinition before doing anything else. + * + * @param packageName the package name to check access to + * @throws SecurityException if permission is denied + * @throws NullPointerException if packageName is null + * @see ClassLoader#loadClass(String, boolean) + * @see Security#getProperty(String) + */ + public void checkPackageDefinition(String packageName) + { + checkPackageList(packageName, "definition", "defineClassInPackage."); + } - /** Check if the current thread is allowed to get certain - ** types of Methods, Fields and Constructors from a Class - ** object.

    - ** - ** This method is called by Class.getMethod[s](), - ** Class.getField[s](), Class.getConstructor[s], - ** Class.getDeclaredMethod[s](), - ** Class.getDeclaredField[s](), and - ** Class.getDeclaredConstructor[s]().

    - ** - ** SecurityManager's implementation always denies access. - ** - ** @param c the Class to check - ** @param memberType the type of members to check - ** against, either Member.DECLARED or - ** Member.PUBLIC. - ** @exception SecurityException if the operation is not - ** permitted. - ** @see java.lang.Class - ** @see java.lang.reflect.Member#DECLARED - ** @see java.lang.reflect.Member#PUBLIC - **/ - public void checkMemberAccess(Class c, int memberType) { - throw new SecurityException("Cannot access members of classes."); - } + /** + * Check if the current thread is allowed to set the current socket factory. + * This method is called by Socket.setSocketImplFactory(), + * ServerSocket.setSocketFactory(), and URL.setURLStreamHandlerFactory(). + * The default implementation checks + * RuntimePermission("setFactory"). If you override this, call + * super.checkSetFactory rather than throwing an exception. + * + * @throws SecurityException if permission is denied + * @see Socket#setSocketImplFactory(SocketImplFactory) + * @see ServerSocket#setSocketFactory(SocketImplFactory) + * @see URL#setURLStreamHandlerFactory(URLStreamHandlerFactory) + */ + public void checkSetFactory() + { + checkPermission(new RuntimePermission("setFactory")); + } - /** Test whether a particular security action may be - ** taken. - ** @param action the desired action to take - ** @exception SecurityException if the action is denied. - ** @XXX I have no idea what actions must be tested - ** or where. - **/ - public void checkSecurityAccess(String action) { - checkPermission (new java.security.SecurityPermission (action)); - } + /** + * Check if the current thread is allowed to get certain types of Methods, + * Fields and Constructors from a Class object. This method is called by + * Class.getMethod[s](), Class.getField[s](), Class.getConstructor[s], + * Class.getDeclaredMethod[s](), Class.getDeclaredField[s](), and + * Class.getDeclaredConstructor[s](). The default implementation allows + * PUBLIC access, and access to classes defined by the same classloader as + * the code performing the reflection. Otherwise, it checks + * RuntimePermission("accessDeclaredMembers"). If you override + * this, do not call super.checkMemberAccess, as this would + * mess up the stack depth check that determines the ClassLoader requesting + * the access. + * + * @param c the Class to check + * @param memberType either DECLARED or PUBLIC + * @throws SecurityException if permission is denied, including when + * memberType is not DECLARED or PUBLIC + * @throws NullPointerException if c is null + * @see Class + * @see Member#DECLARED + * @see Member#PUBLIC + * @since 1.1 + */ + public void checkMemberAccess(Class c, int memberType) + { + if (c == null) + throw new NullPointerException(); + if (memberType == Member.PUBLIC) + return; + // XXX Allow access to classes created by same classloader before next + // check. + checkPermission(new RuntimePermission("accessDeclaredMembers")); + } - /** Get the ThreadGroup that a new Thread should belong - ** to by default.

    - ** - ** Called by Thread.Thread().

    - ** - ** SecurityManager's implementation just uses the - ** ThreadGroup of the current Thread.

    - ** - ** Spec Note: it is not clear whether - ** the new Thread is guaranteed to pass the - ** checkAccessThreadGroup() test when using this - ** ThreadGroup. I presume so. - ** - ** @return the ThreadGroup to put the new Thread into. - **/ - public ThreadGroup getThreadGroup() { - return Thread.currentThread().getThreadGroup(); - } + /** + * Test whether a particular security action may be taken. The default + * implementation checks SecurityPermission(action). If you + * override this, call super.checkSecurityAccess rather than + * throwing an exception. + * + * @param action the desired action to take + * @throws SecurityException if permission is denied + * @throws NullPointerException if action is null + * @throws IllegalArgumentException if action is "" + * @since 1.1 + */ + public void checkSecurityAccess(String action) + { + checkPermission(new SecurityPermission(action)); + } - public SecurityManager () { - if (System.getSecurityManager () != null) - throw new SecurityException (); - } -} + /** + * Get the ThreadGroup that a new Thread should belong to by default. Called + * by Thread.Thread(). The default implementation returns the current + * ThreadGroup of the current Thread. Spec Note: it is not + * clear whether the new Thread is guaranteed to pass the + * checkAccessThreadGroup() test when using this ThreadGroup, but I presume + * so. + * + * @return the ThreadGroup to put the new Thread into + * @since 1.1 + */ + public ThreadGroup getThreadGroup() + { + return Thread.currentThread().getThreadGroup(); + } + + /** + * Helper that checks a comma-separated list of restricted packages, from + * Security.getProperty("package.definition"), for the given + * package access permission. If packageName starts with or equals any + * restricted package, it checks + * RuntimePermission(permission + packageName). + * + * @param packageName the package name to check access to + * @param restriction the list of restrictions, after "package." + * @param permission the base permission, including the '.' + * @throws SecurityException if permission is denied + * @throws NullPointerException if packageName is null + * @see #checkPackageAccess(String) + * @see #checkPackageDefinition(String) + */ + void checkPackageList(String packageName, String restriction, + String permission) + { + // Use the toString() hack to do the null check. + Permission p = new RuntimePermission(permission + packageName.toString()); + String list = Security.getProperty("package." + restriction); + if (list == null) + return; + while (! "".equals(packageName)) + { + for (int index = list.indexOf(packageName); + index != -1; index = list.indexOf(packageName, index + 1)) + { + int packageNameCount = packageName.length(); + if (index + packageNameCount == list.length() + || list.charAt(index + packageNameCount) == ',') + { + checkPermission(p); + return; + } + } + int index = packageName.lastIndexOf('.'); + packageName = index < 0 ? "" : packageName.substring(0, index); + } + } +} // class SecurityManager +// XXX This class is unnecessary. class SecurityContext { Class[] classes; SecurityContext(Class[] classes) { diff --git a/libjava/java/lang/VMSecurityManager.java b/libjava/java/lang/VMSecurityManager.java index fd16804b8f2..f6f0645ac75 100644 --- a/libjava/java/lang/VMSecurityManager.java +++ b/libjava/java/lang/VMSecurityManager.java @@ -1,6 +1,6 @@ /* * java.lang.SecurityManager: part of the Java Class Libraries project. - * Copyright (C) 1998, 2001 Free Software Foundation + * Copyright (C) 1998, 2001, 2002 Free Software Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -43,11 +43,7 @@ class VMSecurityManager ** @return an array containing all the methods on classes ** on the Java execution stack. **/ - static Class[] getClassContext() - { - // FIXME: can't yet implement this for libgcj. - return new Class[0]; - } + static native Class[] getClassContext(); /** Get the current ClassLoader--the one nearest to the ** top of the stack. diff --git a/libjava/java/lang/VMThrowable.java b/libjava/java/lang/VMThrowable.java index 0a2c9229649..4c3385757c4 100644 --- a/libjava/java/lang/VMThrowable.java +++ b/libjava/java/lang/VMThrowable.java @@ -38,9 +38,10 @@ exception statement from your version. */ package java.lang; import gnu.gcj.runtime.NameFinder; +import gnu.gcj.runtime.StackTrace; /** - * VM dependant state and support methods Throwabele. + * VM dependent state and support methods Throwable. * It is deliberately package local and final and should only be accessed * by the Throwable class. *

    @@ -50,8 +51,7 @@ import gnu.gcj.runtime.NameFinder; */ final class VMThrowable { - private gnu.gcj.RawData stackTraceAddrs; - private int length; + private gnu.gcj.runtime.StackTrace trace; /** * Private contructor, create VMThrowables with fillInStackTrace(); @@ -67,7 +67,20 @@ final class VMThrowable * @return a new VMThrowable containing the current execution stack trace. * @see Throwable#fillInStackTrace() */ - static native VMThrowable fillInStackTrace(Throwable t); + static VMThrowable fillInStackTrace(Throwable t) + { + VMThrowable state = null; + + /* FIXME: size of the stack trace is limited to 128 elements. + It's undoubtedly sensible to limit the stack trace, but 128 is + rather arbitrary. It may be better to configure this. */ + if (trace_enabled) + { + state = new VMThrowable (); + state.trace = new gnu.gcj.runtime.StackTrace(128); + } + return state; + } /** * Returns an StackTraceElement array based on the execution @@ -80,10 +93,11 @@ final class VMThrowable StackTraceElement[] getStackTrace(Throwable t) { StackTraceElement[] result; - if (stackTraceAddrs != null) + if (trace != null) { NameFinder nameFinder = new NameFinder(); - result = nameFinder.lookup(t, stackTraceAddrs, length); + result = nameFinder.lookup(t, trace.stackTraceAddrs(), + trace.length()); nameFinder.close(); } else diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc index fb412f224b9..bafac789b0d 100644 --- a/libjava/java/lang/natClass.cc +++ b/libjava/java/lang/natClass.cc @@ -36,6 +36,7 @@ details. */ #include #include #include +#include #include #include #include @@ -47,7 +48,10 @@ details. */ #include #include #include +#include #include +#include +#include #include @@ -71,7 +75,6 @@ java::lang::Class::forName (jstring className, jboolean initialize, if (! _Jv_VerifyClassName (name)) throw new java::lang::ClassNotFoundException (className); - // FIXME: should use bootstrap class loader if loader is null. jclass klass = (buffer[0] == '[' ? _Jv_FindClassFromSignature (name->data, loader) : _Jv_FindClass (name, loader)); @@ -88,8 +91,23 @@ java::lang::Class::forName (jstring className, jboolean initialize, jclass java::lang::Class::forName (jstring className) { - // FIXME: should use class loader from calling method. - return forName (className, true, NULL); + java::lang::ClassLoader *loader = NULL; + gnu::gcj::runtime::StackTrace *t + = new gnu::gcj::runtime::StackTrace(4); + java::lang::Class *klass = NULL; + try + { + for (int i = 1; !klass; i++) + { + klass = t->classAt (i); + } + loader = klass->getClassLoader(); + } + catch (::java::lang::ArrayIndexOutOfBoundsException *e) + { + } + + return forName (className, true, loader); } java::lang::ClassLoader * @@ -1040,6 +1058,8 @@ _Jv_CheckArrayStore (jobject arr, jobject obj) { JvAssert (arr != NULL); jclass elt_class = (JV_CLASS (arr))->getComponentType(); + if (elt_class == &java::lang::Object::class$) + return; jclass obj_class = JV_CLASS (obj); if (__builtin_expect (! _Jv_IsAssignableFrom (elt_class, obj_class), false)) @@ -1536,7 +1556,7 @@ _Jv_LinkOffsetTable(jclass klass) } // Returns true if METH should get an entry in a VTable. -static bool +static jboolean isVirtualMethod (_Jv_Method *meth) { using namespace java::lang::reflect; @@ -1554,7 +1574,7 @@ _Jv_LayoutVTableMethods (jclass klass) if (klass->vtable != NULL || klass->isInterface() || klass->vtable_method_count != -1) return; - + jclass superclass = klass->superclass; if (superclass != NULL && superclass->vtable_method_count == -1) @@ -1562,48 +1582,59 @@ _Jv_LayoutVTableMethods (jclass klass) JvSynchronize sync (superclass); _Jv_LayoutVTableMethods (superclass); } - + int index = (superclass == NULL ? 0 : superclass->vtable_method_count); for (int i = 0; i < klass->method_count; ++i) { _Jv_Method *meth = &klass->methods[i]; _Jv_Method *super_meth = NULL; - - if (!isVirtualMethod(meth)) - continue; - + + if (! isVirtualMethod (meth)) + continue; + if (superclass != NULL) super_meth = _Jv_LookupDeclaredMethod (superclass, meth->name, meth->signature); - + if (super_meth) meth->index = super_meth->index; - else + else if (! (meth->accflags & java::lang::reflect::Modifier::FINAL)) meth->index = index++; } - + klass->vtable_method_count = index; } -// Set entries in VTABLE for virtual methods declared in KLASS. If KLASS has -// an immediate abstract parent, recursivly do its methods first. +// Set entries in VTABLE for virtual methods declared in KLASS. If +// KLASS has an immediate abstract parent, recursively do its methods +// first. FLAGS is used to determine which slots we've actually set. void -_Jv_SetVTableEntries (jclass klass, _Jv_VTable *vtable) +_Jv_SetVTableEntries (jclass klass, _Jv_VTable *vtable, jboolean *flags) { using namespace java::lang::reflect; jclass superclass = klass->getSuperclass(); if (superclass != NULL && (superclass->getModifiers() & Modifier::ABSTRACT)) - _Jv_SetVTableEntries (superclass, vtable); - + _Jv_SetVTableEntries (superclass, vtable, flags); + for (int i = klass->method_count - 1; i >= 0; i--) { _Jv_Method *meth = &klass->methods[i]; - if (!isVirtualMethod(meth)) + if (meth->index == (_Jv_ushort) -1) continue; - vtable->set_method(meth->index, meth->ncode); + if ((meth->accflags & Modifier::ABSTRACT)) + { + // FIXME: we should set abstract slots to a function that + // throws AbstractMethodError. How can we do that on IA-64? + flags[meth->index] = false; + } + else + { + vtable->set_method(meth->index, meth->ncode); + flags[meth->index] = true; + } } } @@ -1619,7 +1650,7 @@ _Jv_MakeVTable (jclass klass) if (klass->vtable != NULL || klass->isInterface() || (klass->accflags & Modifier::ABSTRACT)) return; - + // out before we can create a vtable. if (klass->vtable_method_count == -1) _Jv_LayoutVTableMethods (klass); @@ -1627,7 +1658,11 @@ _Jv_MakeVTable (jclass klass) // Allocate the new vtable. _Jv_VTable *vtable = _Jv_VTable::new_vtable (klass->vtable_method_count); klass->vtable = vtable; - + + jboolean flags[klass->vtable_method_count]; + for (int i = 0; i < klass->vtable_method_count; ++i) + flags[i] = false; + // Copy the vtable of the closest non-abstract superclass. jclass superclass = klass->superclass; if (superclass != NULL) @@ -1642,7 +1677,10 @@ _Jv_MakeVTable (jclass klass) } for (int i = 0; i < superclass->vtable_method_count; ++i) - vtable->set_method (i, superclass->vtable->get_method (i)); + { + vtable->set_method (i, superclass->vtable->get_method (i)); + flags[i] = true; + } } // Set the class pointer and GC descriptor. @@ -1651,5 +1689,14 @@ _Jv_MakeVTable (jclass klass) // For each virtual declared in klass and any immediate abstract // superclasses, set new vtable entry or override an old one. - _Jv_SetVTableEntries (klass, vtable); + _Jv_SetVTableEntries (klass, vtable, flags); + + // It is an error to have an abstract method in a concrete class. + if (! (klass->accflags & Modifier::ABSTRACT)) + { + for (int i = 0; i < klass->vtable_method_count; ++i) + if (! flags[i]) + // FIXME: messsage. + throw new java::lang::AbstractMethodError (); + } } diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index 8bff16997b9..aeee08a6265 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -189,63 +189,6 @@ java::lang::VMClassLoader::getPrimitiveClass (jchar type) return _Jv_FindClassFromSignature (sig, NULL); } -// This is the findClass() implementation for the System classloader. It is -// the only native method in VMClassLoader, so we define it here. -jclass -gnu::gcj::runtime::VMClassLoader::findClass (jstring name) -{ - _Jv_Utf8Const *name_u = _Jv_makeUtf8Const (name); - jclass klass = _Jv_FindClassInCache (name_u, 0); - - if (! klass) - { - // Turn `gnu.pkg.quux' into `lib-gnu-pkg-quux'. Then search for - // a module named (eg, on Linux) `lib-gnu-pkg-quux.so', followed - // by `lib-gnu-pkg.so' and `lib-gnu.so'. If loading one of - // these causes the class to appear in the cache, then use it. - java::lang::StringBuffer *sb = new java::lang::StringBuffer (JvNewStringLatin1("lib-")); - // Skip inner classes - jstring cn; - jint ci = name->indexOf('$'); - if (ci == -1) - cn = name; - else - cn = name->substring (0, ci); - jstring so_base_name = (sb->append (cn)->toString ())->replace ('.', '-'); - - // Compare against `3' because that is the length of "lib". - while (! klass && so_base_name && so_base_name->length() > 3) - { - using namespace ::java::lang; - Runtime *rt = Runtime::getRuntime(); - jboolean loaded = rt->loadLibraryInternal (so_base_name); - - jint nd = so_base_name->lastIndexOf ('-'); - if (nd == -1) - so_base_name = NULL; - else - so_base_name = so_base_name->substring (0, nd); - - if (loaded) - klass = _Jv_FindClassInCache (name_u, 0); - } - } - - // Now try loading using the interpreter. - if (! klass) - { - klass = java::net::URLClassLoader::findClass (name); - } - - return klass; -} - -jclass -java::lang::ClassLoader::findLoadedClass (jstring name) -{ - return _Jv_FindClassInCache (_Jv_makeUtf8Const (name), this); -} - /** This function does class-preparation for compiled classes. NOTE: It contains replicated functionality from _Jv_ResolvePoolEntry, and this is intentional, since that function @@ -326,6 +269,8 @@ _Jv_PrepareCompiledClass (jclass klass) _Jv_LinkOffsetTable(klass); klass->notifyAll (); + + _Jv_PushClass (klass); } @@ -587,6 +532,8 @@ _Jv_InitNewClassFields (jclass ret) ret->ancestors = NULL; ret->idt = NULL; ret->arrayclass = NULL; + ret->protectionDomain = NULL; + ret->chain = NULL; } jclass @@ -732,3 +679,31 @@ _Jv_NewArrayClass (jclass element, java::lang::ClassLoader *loader, element->arrayclass = array_class; } + +static jclass stack_head; + +// These two functions form a stack of classes. When a class is loaded +// it is pushed onto the stack by the class loader; this is so that +// StackTrace can quickly determine which classes have been loaded. + +jclass +_Jv_PopClass (void) +{ + JvSynchronize sync (&java::lang::Class::class$); + if (stack_head) + { + jclass tmp = stack_head; + stack_head = tmp->chain; + return tmp; + } + return NULL; +} + +void +_Jv_PushClass (jclass k) +{ + JvSynchronize sync (&java::lang::Class::class$); + jclass tmp = stack_head; + stack_head = k; + k->chain = tmp; +} diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc index 6737dbcbbfa..f5177b0aa35 100644 --- a/libjava/java/lang/natRuntime.cc +++ b/libjava/java/lang/natRuntime.cc @@ -27,6 +27,8 @@ details. */ #include #include #include +#include +#include #include @@ -161,18 +163,56 @@ java::lang::Runtime::_load (jstring path, jboolean do_search) using namespace java::lang; #ifdef USE_LTDL jint len = _Jv_GetStringUTFLength (path); - char buf[len + 1 + 3]; + char buf[len + 1 + strlen (_Jv_platform_solib_prefix) + + strlen (_Jv_platform_solib_suffix)]; int offset = 0; -#ifndef WIN32 - // On Unix boxes, prefix library name with `lib', for loadLibrary. if (do_search) { - strcpy (buf, "lib"); - offset = 3; + strcpy (buf, _Jv_platform_solib_prefix); + offset = strlen (_Jv_platform_solib_prefix); } -#endif jsize total = JvGetStringUTFRegion (path, 0, path->length(), &buf[offset]); buf[offset + total] = '\0'; + + char *lib_name = buf; + + if (do_search) + { + ClassLoader *sys = ClassLoader::getSystemClassLoader(); + ClassLoader *look = NULL; + gnu::gcj::runtime::StackTrace *t = new gnu::gcj::runtime::StackTrace(10); + for (int i = 0; i < 10; ++i) + { + jclass klass = t->classAt(i); + if (klass != NULL) + { + ClassLoader *loader = klass->getClassLoaderInternal(); + if (loader != NULL && loader != sys) + { + look = loader; + break; + } + } + } + if (look != NULL) + { + // Don't include solib prefix in string passed to + // findLibrary. + jstring name = look->findLibrary(JvNewStringUTF(&buf[offset])); + if (name != NULL) + { + len = _Jv_GetStringUTFLength (name); + lib_name = (char *) _Jv_AllocBytes(len + 1); + total = JvGetStringUTFRegion (name, 0, + name->length(), lib_name); + lib_name[total] = '\0'; + // Don't append suffixes any more; we have the full file + // name. + do_search = false; + } + } + } + lt_dlhandle h; // FIXME: make sure path is absolute. { @@ -180,7 +220,7 @@ java::lang::Runtime::_load (jstring path, jboolean do_search) // concurrent modification by class registration calls which may be run // during the dlopen(). JvSynchronize sync (&java::lang::Class::class$); - h = do_search ? lt_dlopenext (buf) : lt_dlopen (buf); + h = do_search ? lt_dlopenext (lib_name) : lt_dlopen (lib_name); } if (h == NULL) { @@ -602,19 +642,9 @@ java::lang::Runtime::nativeGetLibname (jstring pathname, jstring libname) #endif } - // FIXME: use platform function here. -#ifndef WIN32 - sb->append (JvNewStringLatin1 ("lib")); -#endif - + sb->append (JvNewStringLatin1 (_Jv_platform_solib_prefix)); sb->append(libname); - - // FIXME: use platform function here. -#ifdef WIN32 - sb->append (JvNewStringLatin1 ("dll")); -#else - sb->append (JvNewStringLatin1 ("so")); -#endif + sb->append (JvNewStringLatin1 (_Jv_platform_solib_suffix)); return sb->toString(); } diff --git a/libjava/java/lang/natVMThrowable.cc b/libjava/java/lang/natVMThrowable.cc deleted file mode 100644 index c1b030d4288..00000000000 --- a/libjava/java/lang/natVMThrowable.cc +++ /dev/null @@ -1,97 +0,0 @@ -// natVMThrowable.cc - native helper methods for Throwable - -/* Copyright (C) 2000, 2002 Free Software Foundation, Inc - - This file is part of libgcj. - -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - -/** - * @author Andrew Haley - * @author Mark Wielaard - * - * Native helper methods for VM specific Throwable support. - */ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#ifdef HAVE_EXECINFO_H -#include -#endif - -/* FIXME: size of the stack trace is limited to 128 elements. It's - undoubtedly sensible to limit the stack trace, but 128 is rather - arbitrary. It may be better to configure this. */ - -java::lang::VMThrowable * -java::lang::VMThrowable::fillInStackTrace (java::lang::Throwable*) -{ - if (! trace_enabled) - return NULL; -#if defined (HAVE_BACKTRACE) - VMThrowable* state = new VMThrowable; - void *p[128]; - - // We subtract 1 from the number of elements because we don't want - // to include the calls to fillInStackTrace in the trace. - int n = backtrace (p, 128) - 1; - - _Jv_frame_info *addrs; - if (n > 0) - { -#ifdef INTERPRETER - extern void _Jv_StartOfInterpreter (void); - extern void _Jv_EndOfInterpreter (void); - - java::lang::Thread *thread = java::lang::Thread::currentThread(); - _Jv_MethodChain *interp_frame - = (thread ? reinterpret_cast<_Jv_MethodChain *> (thread->interp_frame) - : NULL); -#endif // INTERPRETER - - state->length = n; - int len = n; - addrs = (_Jv_frame_info *) _Jv_Malloc (n * sizeof (_Jv_frame_info)); - for (n = 0; n < len; n++) - { - addrs[n].addr = p[n]; -#ifdef INTERPRETER - if (p[n] >= &_Jv_StartOfInterpreter && p[n] <= &_Jv_EndOfInterpreter) - { - addrs[n].interp = (void *) interp_frame->self; - interp_frame = interp_frame->next; - } - else - addrs[n].interp = 0; -#endif // INTERPRETER - } - } - else - addrs = NULL; - - state->stackTraceAddrs = reinterpret_cast (addrs); - - return state; -#endif - return NULL; -} diff --git a/libjava/java/net/InetAddress.java b/libjava/java/net/InetAddress.java index c15c0f6dc41..4a32352b481 100644 --- a/libjava/java/net/InetAddress.java +++ b/libjava/java/net/InetAddress.java @@ -1,6 +1,6 @@ // INetAddress.java -- An Internet Protocol (IP) address. -/* Copyright (C) 1998, 1999, 2000 Free Software Foundation +/* Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation This file is part of libgcj. @@ -413,12 +413,13 @@ public class InetAddress implements Serializable */ public String toString() { - String hostname = getHostName (); - - if (hostname == "") - hostname = getHostAddress (); - - return hostname + '/' + getHostAddress (); + String result; + String address = getHostAddress(); + if (hostName != null) + result = hostName + "/" + address; + else + result = address; + return result; } /** diff --git a/libjava/java/net/JarURLConnection.java b/libjava/java/net/JarURLConnection.java index a90c7f33037..6f4cd1fe7ea 100644 --- a/libjava/java/net/JarURLConnection.java +++ b/libjava/java/net/JarURLConnection.java @@ -134,7 +134,11 @@ public abstract class JarURLConnection extends URLConnection if (jarfile != null) { // this is the easy way... - return jarfile.getInputStream (jarfile.getEntry (element)); + ZipEntry entry = jarfile.getEntry(element); + if (entry != null) + return jarfile.getInputStream (entry); + else + return null; } else { @@ -320,12 +324,17 @@ public abstract class JarURLConnection extends URLConnection // to add others later and for consistency, we'll implement it this way. // Add the only header we know about right now: Content-length. - long len; + long len = -1; if (element == null) - len = jarFileURLConnection.getContentLength (); + if (jarFileURLConnection != null) + len = jarFileURLConnection.getContentLength (); else - len = getJarEntry ().getSize (); + { + JarEntry entry = getJarEntry(); + if (entry != null) + len = entry.getSize (); + } String line = "Content-length: " + len; hdrVec.addElement(line); @@ -381,7 +390,6 @@ public abstract class JarURLConnection extends URLConnection { JarFile file = getJarFile (); - // FIXME: implement this - return null; + return (file != null) ? file.getManifest() : null; } } diff --git a/libjava/java/net/Socket.java b/libjava/java/net/Socket.java index b900801a16b..592f39a3dd3 100644 --- a/libjava/java/net/Socket.java +++ b/libjava/java/net/Socket.java @@ -892,6 +892,9 @@ public class Socket if (sm != null) sm.checkSetFactory(); + if (fac == null) + throw new SocketException("SocketImplFactory cannot be null"); + factory = fac; } diff --git a/libjava/java/net/SocketPermission.java b/libjava/java/net/SocketPermission.java index 0f41395f36a..18fb7ef2f1f 100644 --- a/libjava/java/net/SocketPermission.java +++ b/libjava/java/net/SocketPermission.java @@ -1,5 +1,5 @@ /* SocketPermission.java -- Class modeling permissions for socket operations - Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -166,12 +166,11 @@ public final class SocketPermission extends Permission public int hashCode() { int hash = 100; - - // FIXME: Get a real hash function - for (int i = 0; i < hostport.length(); i++) - hash = hash + (int) hostport.charAt(i) * 7; - - return (hash); + if (hostport != null) + hash += hostport.hashCode(); + if (actions != null) + hash += actions.hashCode(); + return hash; } /** diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java index 5e059cf9cb6..c6dc4b1d44d 100644 --- a/libjava/java/net/URLClassLoader.java +++ b/libjava/java/net/URLClassLoader.java @@ -1,332 +1,724 @@ -/* Copyright (C) 1999, 2000, 2002 Free Software Foundation +/* URLClassLoader.java -- ClassLoader that loads classes from one or more URLs + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +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.net; -import java.io.*; -import java.util.jar.*; -import java.util.Enumeration; -import java.util.Vector; +import java.io.ByteArrayOutputStream; +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FilterInputStream; +import java.io.FilePermission; +import java.io.InputStream; +import java.io.IOException; +import java.security.AccessController; +import java.security.AccessControlContext; import java.security.CodeSource; import java.security.SecureClassLoader; +import java.security.PrivilegedAction; import java.security.PermissionCollection; import java.security.cert.Certificate; +import java.util.Enumeration; +import java.util.Vector; +import java.util.HashMap; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.Manifest; +import java.util.zip.ZipException; /** + * A secure class loader that can load classes and resources from + * multiple locations. Given an array of URLs this class + * loader will retrieve classes and resources by fetching them from + * possible remote locations. Each URL is searched in + * order in which it was added. If the file portion of the + * URL ends with a '/' character then it is interpreted + * as a base directory, otherwise it is interpreted as a jar file from + * which the classes/resources are resolved. + * + *

    New instances can be created by two static + * newInstance() methods or by three public + * contructors. Both ways give the option to supply an initial array + * of URLs and (optionally) a parent classloader (that is + * different from the standard system class loader).

    + * + *

    Normally creating a URLClassLoader throws a + * SecurityException if a SecurityManager is + * installed and the checkCreateClassLoader() method does + * not return true. But the newInstance() methods may be + * used by any code as long as it has permission to acces the given + * URLs. URLClassLoaders created by the + * newInstance() methods also explicitly call the + * checkPackageAccess() method of + * SecurityManager if one is installed before trying to + * load a class. Note that only subclasses of + * URLClassLoader can add new URLs after the + * URLClassLoader had been created. But it is always possible to get + * an array of all URLs that the class loader uses to resolve classes + * and resources by way of the getURLs() method.

    + * + *

    Open issues: + *

      + * + *
    • Should the URLClassLoader actually add the locations found in + * the manifest or is this the responsibility of some other + * loader/(sub)class? (see + * Extension Mechanism Architecture - Bundles Extensions)
    • + * + *
    • How does definePackage() and sealing work + * precisely?
    • + * + *
    • We save and use the security context (when a created by + * newInstance() but do we have to use it in more + * places?
    • + * + *
    • The use of URLStreamHandlers has not been tested.
    • + * + *
    + *

    + * * @since 1.2 + * + * @author Mark Wielaard (mark@klomp.org) + * @author Wu Gansha (gansha.wu@intel.com) */ + public class URLClassLoader extends SecureClassLoader { - // The URLStreamHandlerFactory - URLStreamHandlerFactory factory = null; + // Class Variables - // `path' contains simply the URL's we're using for the searching. - private Vector path; + /** + * A global cache to store mappings between URLLoader and URL, + * so we can avoid do all the homework each time the same URL + * comes. + * XXX - Keeps these loaders forever which prevents garbage collection. + */ + private static HashMap urlloaders = new HashMap(); + + /** + * A cache to store mappings between handler factory and its + * private protocol handler cache (also a HashMap), so we can avoid + * create handlers each time the same protocol comes. + */ + private static HashMap factoryCache = new HashMap(5); - // If path[n] is a zip/jar, then this holds a JarURLConnection for - // that thing, otherwise, path[n] is null. - private Vector info; + // Instance variables - private URLStreamHandler getHandler0 (String protocol) - { - if (factory != null) - return factory.createURLStreamHandler(protocol); - else - return null; - } + /** Locations to load classes from */ + private final Vector urls = new Vector(); /** - * Createa a new URL class loader object - * - * @exception SecurityException If a security manager exists and its - * checkCreateClassLoader method doesn't allow creation of a class loader + * Store pre-parsed information for each url into this vector + * each element is a URL loader, corresponding to the URL of + * the same index in "urls" */ - public URLClassLoader (URL[] urls) - { - this (urls, null, null); - } - + private final Vector urlinfos = new Vector(); + + /** Factory used to get the protocol handlers of the URLs */ + private final URLStreamHandlerFactory factory; + /** - * Createa a new URL class loader object - * - * @exception SecurityException If a security manager exists and its - * checkCreateClassLoader method doesn't allow creation of a class loader + * The security context when created from newInstance() + * or null when created through a normal constructor or when no + * SecurityManager was installed. */ - public URLClassLoader (URL[] urls, ClassLoader parent) - { - this (urls, parent, null); - } + private final AccessControlContext securityContext; - // A File URL may actually be a Jar URL. Convert if possible. - private URL jarFileize (URL url) + // Helper classes + + /** + * A URLLoader contains all logic to load resources from a + * given base URL. + */ + static abstract class URLLoader { - if (! url.getProtocol ().equals ("jar")) - { - String f = url.getFile (); + /** + * Our classloader to get info from if needed. + */ + final URLClassLoader classloader; - // If it ends with '/' we'll take it for a directory, - // otherwise it's a jar file. This is how JDK 1.2 defines - // it, so we will not try to be smart here. - if (f.charAt (f.length ()-1) != '/') - { - try - { - url = new URL ("jar", "", -1, (url.toExternalForm ())+"!/", - getHandler0 ("jar")); - } - catch (MalformedURLException x) - { - /* ignore */ - } - } - } - return url; + /** + * The base URL from which all resources are loaded. + */ + final URL baseURL; + + /** + * A CodeSource without any associated certificates. + * It is common for classes to not have certificates associated + * with them. If they come from the same URLLoader + * then it is safe to share the associated CodeSource + * between them since CodeSource is immutable. + */ + final CodeSource noCertCodeSource; + + URLLoader(URLClassLoader classloader, URL baseURL) + { + this.classloader = classloader; + this.baseURL = baseURL; + this.noCertCodeSource = new CodeSource(baseURL, null); + } + + /** + * Returns a Resource loaded by this + * URLLoader, or null when no + * Resource with the given name exists. + */ + abstract Resource getResource(String s); + + /** + * Returns the Manifest associated with the + * Resources loaded by this URLLoader or + * null there is no such Manifest. + */ + Manifest getManifest() + { + return null; + } } - protected void addURL (URL url) + /** + * A Resource represents a resource in some + * URLLoader. It also contains all information (e.g., + * URL, CodeSource, Manifest and + * InputStream) that is necessary for loading resources + * and creating classes from a URL. + */ + static abstract class Resource { - JarURLConnection conn = null; - - // Convert a Jar File URL into Jar URL if possible. - url = jarFileize (url); + final URLLoader loader; + final String name; + + Resource(URLLoader loader, String name) + { + this.loader = loader; + this.name = name; + } + + /** + * Returns the non-null CodeSource associated with + * this resource. + */ + CodeSource getCodeSource() + { + Certificate[] certs = getCertificates(); + if (certs != null) + return loader.noCertCodeSource; + else + return new CodeSource(loader.baseURL, certs); + } - path.addElement (url); + /** + * Returns Certificates associated with this + * resource, or null when there are none. + */ + Certificate[] getCertificates() + { + return null; + } + + /** + * Return a URL that can be used to access this resource. + */ + abstract URL getURL(); - if (url.getProtocol ().equals ("jar")) + /** + * Returns the size of this Resource in bytes or + * -1 when unknown. + */ + abstract int getLength(); + + /** + * Returns the non-null InputStream through which + * this resource can be loaded. + */ + abstract InputStream getInputStream() throws IOException; + } + + static URL getCanonicalFileURL(URL url) + { + if ("file".equals(url.getProtocol())) { try { - conn = (JarURLConnection) url.openConnection (); + File f = new File(url.getFile()).getCanonicalFile(); + url = new URL("file", "", f.toString()); } - catch (java.io.IOException x) + catch (IOException ignore) { - /* ignore */ } } - - info.addElement (conn); + return url; } /** - * Createa a new URL class loader object - * - * @exception SecurityException If a security manager exists and its - * checkCreateClassLoader method doesn't allow creation of a class loader + * A JarURLLoader is a type of URLLoader + * only loading from jar url. */ - public URLClassLoader (URL[] urls, ClassLoader parent, - URLStreamHandlerFactory fac) - { - super (parent); + final static class JarURLLoader extends URLLoader + { + final JarFile jarfile; // The canonical jar file for this url + final URL baseJarURL; // Base jar: url for all resources loaded from jar - SecurityManager s = System.getSecurityManager(); - if (s != null) - s.checkCreateClassLoader(); + public JarURLLoader(URLClassLoader classloader, URL baseURL) + { + super(classloader, getCanonicalFileURL(baseURL)); - factory = fac; + // cache url prefix for all resources in this jar url + String external = baseURL.toExternalForm(); + StringBuffer sb = new StringBuffer(external.length() + 6); + sb.append("jar:"); + sb.append(external); + sb.append("!/"); + String jarURL = sb.toString(); - if (urls == null || urls.length == 0) - { - path = new Vector (1); - info = new Vector (1); - return; - } + URL baseJarURL = null; + JarFile jarfile = null; + try + { + baseJarURL + = new URL(null, jarURL, classloader.getURLStreamHandler("jar")); + jarfile + = ((JarURLConnection) baseJarURL.openConnection()).getJarFile(); + } + catch (IOException ioe) { /* ignored */ } - path = new Vector (urls.length); - info = new Vector (urls.length); + this.baseJarURL = baseJarURL; + this.jarfile = jarfile; + } - for (int i = 0; i < urls.length; i++) - { - // Convert a Jar File URL into a Jar URL if possible. - URL u = jarFileize(urls[i]); + /** get resource with the name "name" in the jar url */ + Resource getResource(String name) + { + if (jarfile == null) + return null; - path.addElement (u); + JarEntry je = jarfile.getJarEntry(name); + if(je != null) + return new JarURLResource(this, name, je); + else + return null; + } - if (u.getProtocol ().equals ("jar")) - { - JarURLConnection conn = null; - try - { - conn = (JarURLConnection) u.openConnection (); - } - catch (java.io.IOException x) - { - /* ignore */ - } - info.addElement (conn); - } - else - { - info.addElement (null); - } - } + Manifest getManifest() + { + try + { + return (jarfile == null) ? null : jarfile.getManifest(); + } + catch (IOException ioe) + { + return null; + } + } } - public URL[] getURLs () + final static class JarURLResource extends Resource { - URL[] urls = new URL[path.size()]; - path.copyInto (urls); - return urls; + private final JarEntry entry; + + JarURLResource(JarURLLoader loader, String name, JarEntry entry) + { + super(loader, name); + this.entry = entry; + } + + InputStream getInputStream() throws IOException + { + return ((JarURLLoader)loader).jarfile.getInputStream(entry); + } + + int getLength() + { + return (int)entry.getSize(); + } + + Certificate[] getCertificates() + { + return entry.getCertificates(); + } + + URL getURL() + { + try + { + return new URL(((JarURLLoader)loader).baseJarURL, name, + loader.classloader.getURLStreamHandler("jar")); + } + catch(MalformedURLException e) + { + InternalError ie = new InternalError(); + ie.initCause(e); + throw ie; + } + } } - + /** - * Returns an Enumeration of URLs representing all of the resources on the - * URL search path having the specified name - * - * @exception IOException If an error occurs + * Loader for remote directories. */ - public Enumeration findResources (String name) + final static class RemoteURLLoader extends URLLoader { - Vector results = new Vector (); + final private String protocol; - for (int i = 0; i < path.size(); i++) - { - URL u = (URL)path.elementAt (i); - - try { - JarURLConnection conn = (JarURLConnection) info.elementAt (i); - - if (conn != null) + RemoteURLLoader(URLClassLoader classloader, URL url) + { + super(classloader, url); + protocol = url.getProtocol(); + } + + /** + * Get a remote resource. + * Returns null if no such resource exists. + */ + Resource getResource(String name) + { + try + { + URL url = new URL(baseURL, name, + classloader.getURLStreamHandler(protocol)); + URLConnection connection = url.openConnection(); + + // Open the connection and check the stream + // just to be sure it exists. + int length = connection.getContentLength(); + InputStream stream = connection.getInputStream(); + + // We can do some extra checking if it is a http request + if (connection instanceof HttpURLConnection) { - if (conn.getJarFile().getJarEntry (name) != null) - results.addElement (new URL(u, name, - getHandler0 (u.getProtocol()))); + int response + = ((HttpURLConnection)connection).getResponseCode(); + if (response/100 != 2) + return null; } + + if (stream != null) + return new RemoteResource(this, name, url, stream, length); else - { - URL p = new URL (u, name, getHandler0 (u.getProtocol())); - - InputStream is = p.openStream(); - if (is != null) - { - is.close(); - results.addElement (p); - } - } - - // if we get an exception ... try the next path element - } catch (IOException x) { - continue; + return null; } - } - - return results.elements (); + catch (IOException ioe) + { + return null; + } + } } - public URL findResource (String name) + /** + * A resource from some remote location. + */ + final static class RemoteResource extends Resource { - for (int i = 0; i < path.size(); i++) - { - URL u = (URL)path.elementAt (i); - - try { - JarURLConnection conn = (JarURLConnection) info.elementAt (i); - - if (conn != null) - { - if (conn.getJarFile().getJarEntry (name) != null) - return new URL(u, name, getHandler0 (u.getProtocol())); - } - else - { - URL p = new URL (u, name, getHandler0 (u.getProtocol())); + final private URL url; + final private InputStream stream; + final private int length; - InputStream is = p.openStream(); - if (is != null) - { - is.close(); - return p; - } - } - - // if we get an exception ... try the next path element - } catch (IOException x) { - continue; + RemoteResource(RemoteURLLoader loader, String name, URL url, + InputStream stream, int length) + { + super(loader, name); + this.url = url; + this.stream = stream; + this.length = length; + } + + InputStream getInputStream() throws IOException + { + return stream; + } + + public int getLength() + { + return length; + } + + public URL getURL() + { + return url; + } + } + + /** + * A FileURLLoader is a type of URLLoader + * only loading from file url. + */ + final static class FileURLLoader extends URLLoader + { + File dir; //the canonical file for this file url + + FileURLLoader(URLClassLoader classloader, URL url) + { + super(classloader, getCanonicalFileURL(url)); + dir = new File(baseURL.getFile()); + } + + /** get resource with the name "name" in the file url */ + Resource getResource(String name) + { + File file = new File(dir, name); + try + { + file = file.getCanonicalFile(); } - } + catch (IOException ignore) + { + } + if (file.exists() && !file.isDirectory()) + return new FileResource(this, name, file); + return null; + } + } - return null; + final static class FileResource extends Resource + { + final File file; + + FileResource(FileURLLoader loader, String name, File file) + { + super(loader, name); + this.file = file; + } + + InputStream getInputStream() throws IOException + { + return new FileInputStream(file); + } + + public int getLength() + { + return (int)file.length(); + } + + public URL getURL() + { + try + { + return new URL(loader.baseURL, name, + loader.classloader.getURLStreamHandler("file")); + } + catch(MalformedURLException e) + { + InternalError ie = new InternalError(); + ie.initCause(e); + throw ie; + } + } } + + // Constructors /** - * Finds and loads the class with the specified name from the - * URL search path + * Creates a URLClassLoader that gets classes from the supplied URLs. + * To determine if this classloader may be created the constructor of + * the super class (SecureClassLoader) is called first, which + * can throw a SecurityException. Then the supplied URLs are added + * in the order given to the URLClassLoader which uses these URLs to + * load classes and resources (after using the default parent ClassLoader). * - * @exception ClassNotFoundException If the class could not be found + * @exception SecurityException if the SecurityManager disallows the + * creation of a ClassLoader. + * @param urls Locations that should be searched by this ClassLoader when + * resolving Classes or Resources. + * @see SecureClassLoader */ - protected Class findClass (String name) - throws ClassNotFoundException + public URLClassLoader(URL[] urls) throws SecurityException { - if (name == null) - throw new ClassNotFoundException ("null"); + super(); + this.factory = null; + this.securityContext = null; + addURLs(urls); + } - try - { - URL url = getResource (name.replace ('.', '/') + ".class"); + /** + * Private constructor used by the static + * newInstance(URL[]) method. Creates an + * URLClassLoader without any URLs + * yet. This is used to bypass the normal security check for + * creating classloaders, but remembers the security context which + * will be used when defining classes. The URLs to + * load from must be added by the newInstance() method + * in the security context of the caller. + * + * @param securityContext the security context of the unprivileged code. + */ + private URLClassLoader(AccessControlContext securityContext) + { + super(); + this.factory = null; + this.securityContext = securityContext; + } - if (url == null) - throw new ClassNotFoundException (name); + /** + * Creates a URLClassLoader that gets classes from the supplied + * URLs. + * To determine if this classloader may be created the constructor of + * the super class (SecureClassLoader) is called first, which + * can throw a SecurityException. Then the supplied URLs are added + * in the order given to the URLClassLoader which uses these URLs to + * load classes and resources (after using the supplied parent ClassLoader). + * @exception SecurityException if the SecurityManager disallows the + * creation of a ClassLoader. + * @exception SecurityException + * @param urls Locations that should be searched by this ClassLoader when + * resolving Classes or Resources. + * @param parent The parent class loader used before trying this class + * loader. + * @see SecureClassLoader + */ + public URLClassLoader(URL[] urls, ClassLoader parent) + throws SecurityException + { + super(parent); + this.factory = null; + this.securityContext = null; + addURLs(urls); + } - URLConnection connection = url.openConnection (); - InputStream is = connection.getInputStream (); + /** + * Private constructor used by the static + * newInstance(URL[]) method. Creates an + * URLClassLoader with the given parent but without any + * URLs yet. This is used to bypass the normal security + * check for creating classloaders, but remembers the security + * context which will be used when defining classes. The + * URLs to load from must be added by the + * newInstance() method in the security context of the + * caller. + * + * @param securityContext the security context of the unprivileged code. + */ + private URLClassLoader(ClassLoader parent, + AccessControlContext securityContext) + { + super(parent); + this.factory = null; + this.securityContext = securityContext; + } - int len = connection.getContentLength (); - byte[] data = new byte[len]; + /** + * Creates a URLClassLoader that gets classes from the supplied URLs. + * To determine if this classloader may be created the constructor of + * the super class (SecureClassLoader) is called first, which + * can throw a SecurityException. Then the supplied URLs are added + * in the order given to the URLClassLoader which uses these URLs to + * load classes and resources (after using the supplied parent ClassLoader). + * It will use the supplied URLStreamHandlerFactory to get the + * protocol handlers of the supplied URLs. + * @exception SecurityException if the SecurityManager disallows the + * creation of a ClassLoader. + * @exception SecurityException + * @param urls Locations that should be searched by this ClassLoader when + * resolving Classes or Resources. + * @param parent The parent class loader used before trying this class + * loader. + * @param factory Used to get the protocol handler for the URLs. + * @see SecureClassLoader + */ + public URLClassLoader(URL[] urls, + ClassLoader parent, + URLStreamHandlerFactory factory) + throws SecurityException + { + super(parent); + this.securityContext = null; + this.factory = factory; + addURLs(urls); - int left = len; - int off = 0; - while (left > 0) - { - int c = is.read (data, off, len-off); - if (c == -1 || c == 0) - throw new InternalError ("premature end of file"); - left -= c; - off += c; - } + // If this factory is still not in factoryCache, add it, + // since we only support three protocols so far, 5 is enough + // for cache initial size + synchronized(factoryCache) + { + if(factory != null && factoryCache.get(factory) == null) + factoryCache.put(factory, new HashMap(5)); + } + } - // Now construct the CodeSource (if loaded from a jar file) - CodeSource source = null; - if (url.getProtocol().equals("jar")) - { - Certificate[] certificates = - ((JarURLConnection) connection).getCertificates(); - String u = url.toExternalForm (); - u = u.substring (4); //skip "jar:" - int i = u.indexOf ('!'); - if (i >= 0) - u = u.substring (0, i); - url = new URL(u); - - source = new CodeSource(url, certificates); - } - else if (url.getProtocol().equals("file")) + // Methods + + /** + * Adds a new location to the end of the internal URL store. + * @param newUrl the location to add + */ + protected void addURL(URL newUrl) + { + synchronized(urlloaders) + { + if (newUrl == null) + return; // Silently ignore... + + // check global cache to see if there're already url loader + // for this url + URLLoader loader = (URLLoader)urlloaders.get(newUrl); + if (loader == null) { - try - { - String u = url.toExternalForm(); - // Skip "file:" and then get canonical directory name. - File f = new File(u.substring(5)); - f = f.getCanonicalFile(); - url = new URL("file", "", f.getParent()); - source = new CodeSource (url, null); - } - catch (IOException ignore) - { - } + String file = newUrl.getFile(); + // Check that it is not a directory + if (! (file.endsWith("/") || file.endsWith(File.separator))) + loader = new JarURLLoader(this, newUrl); + else if ("file".equals(newUrl.getProtocol())) + loader = new FileURLLoader(this, newUrl); + else + loader = new RemoteURLLoader(this, newUrl); + + // cache it + urlloaders.put(newUrl, loader); } - return defineClass (name, data, 0, len, source); - } - catch (java.io.IOException x) - { - throw new ClassNotFoundException(name); + urls.add(newUrl); + urlinfos.add(loader); } } + /** + * Adds an array of new locations to the end of the internal URL store. + * @param newUrls the locations to add + */ + private void addURLs(URL[] newUrls) + { + for (int i = 0; i < newUrls.length; i++) + { + addURL(newUrls[i]); + } + } + /** * Defines a Package based on the given name and the supplied manifest * information. The manifest indicates the tile, version and @@ -362,36 +754,231 @@ public class URLClassLoader extends SecureClassLoader // Look if the Manifest indicates that this package is sealed // XXX - most likely not completely correct! // Shouldn't we also check the sealed attribute of the complete jar? - // http://java.sun.com/products/jdk/1.3/docs/guide/extensions/spec.html#bundled + // http://java.sun.com/products/jdk/1.4/docs/guide/extensions/spec.html#bundled // But how do we get that jar manifest here? String sealed = attr.getValue(Attributes.Name.SEALED); if ("false".equals(sealed)) - { - // Make sure that the URL is null so the package is not - // sealed. - url = null; - } + { + // make sure that the URL is null so the package is not sealed + url = null; + } return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, url); } /** - * Returns the permissions needed to access a particular code source. - * These permissions includes those returned by - * SecureClassLoader.getPermissions and the actual permissions - * to access the objects referenced by the URL of the code source. - * The extra permissions added depend on the protocol and file portion of - * the URL in the code source. If the URL has the "file" protocol ends with - * a / character then it must be a directory and a file Permission to read - * everthing in that directory and all subdirectories is added. If the URL - * had the "file" protocol and doesn't end with a / character then it must - * be a normal file and a file permission to read that file is added. If the - * URL has any other protocol then a socket permission to connect and accept - * connections from the host portion of the URL is added. + * Finds (the first) class by name from one of the locations. The locations + * are searched in the order they were added to the URLClassLoader. + * + * @param className the classname to find + * @exception ClassNotFoundException when the class could not be found or + * loaded + * @return a Class object representing the found class + */ + protected Class findClass(final String className) + throws ClassNotFoundException + { + // Just try to find the resource by the (almost) same name + String resourceName = className.replace('.', '/') + ".class"; + Resource resource = findURLResource(resourceName); + if (resource == null) + throw new ClassNotFoundException(className + " not found in " + urls); + + // Try to read the class data, create the CodeSource, Package and + // construct the class (and watch out for those nasty IOExceptions) + try + { + byte [] data; + InputStream in = resource.getInputStream(); + int length = resource.getLength(); + if (length != -1) + { + // We know the length of the data. + // Just try to read it in all at once + data = new byte[length]; + int pos = 0; + while(length - pos > 0) + { + int len = in.read(data, pos, length - pos); + if (len == -1) + throw new EOFException("Not enough data reading from: " + + in); + pos += len; + } + } + else + { + // We don't know the data length. + // Have to read it in chunks. + ByteArrayOutputStream out = new ByteArrayOutputStream(4096); + byte b[] = new byte[4096]; + int l = 0; + while (l != -1) + { + l = in.read(b); + if (l != -1) + out.write(b, 0, l); + } + data = out.toByteArray(); + } + final byte[] classData = data; + + // Now get the CodeSource + final CodeSource source = resource.getCodeSource(); + + // Find out package name + String packageName = null; + int lastDot = className.lastIndexOf('.'); + if (lastDot != -1) + packageName = className.substring(0, lastDot); + + if (packageName != null && getPackage(packageName) == null) + { + // define the package + Manifest manifest = resource.loader.getManifest(); + if (manifest == null) + definePackage(packageName, + null, null, null, null, null, null, null); + else + definePackage(packageName, manifest, resource.loader.baseURL); + } + + // And finally construct the class! + SecurityManager sm = System.getSecurityManager(); + if (sm != null && securityContext != null) + { + return (Class)AccessController.doPrivileged + (new PrivilegedAction() + { + public Object run() + { + return defineClass(className, classData, + 0, classData.length, + source); + } + }, securityContext); + } + else + return defineClass(className, classData, + 0, classData.length, + source); + } + catch (IOException ioe) + { + throw new ClassNotFoundException(className, ioe); + } + } + + /** + * Finds the first occurrence of a resource that can be found. The locations + * are searched in the order they were added to the URLClassLoader. + * + * @param resourceName the resource name to look for + * @return the URLResource for the resource if found, null otherwise + */ + private Resource findURLResource(String resourceName) + { + int max = urls.size(); + for (int i = 0; i < max; i++) + { + URLLoader loader = (URLLoader)urlinfos.elementAt(i); + if (loader == null) + continue; + + Resource resource = loader.getResource(resourceName); + if (resource != null) + return resource; + } + return null; + } + + /** + * Finds the first occurrence of a resource that can be found. + * + * @param resourceName the resource name to look for + * @return the URL if found, null otherwise + */ + public URL findResource(String resourceName) + { + Resource resource = findURLResource(resourceName); + if (resource != null) + return resource.getURL(); + + // Resource not found + return null; + } + + /** + * If the URLStreamHandlerFactory has been set this return the appropriate + * URLStreamHandler for the given protocol, if not set returns null. + * + * @param protocol the protocol for which we need a URLStreamHandler + * @return the appropriate URLStreamHandler or null + */ + URLStreamHandler getURLStreamHandler(String protocol) + { + if (factory == null) + return null; + + URLStreamHandler handler; + synchronized (factoryCache) + { + // check if there're handler for the same protocol in cache + HashMap cache = (HashMap)factoryCache.get(factory); + handler = (URLStreamHandler)cache.get(protocol); + if(handler == null) + { + // add it to cache + handler = factory.createURLStreamHandler(protocol); + cache.put(protocol, handler); + } + } + return handler; + } + + /** + * Finds all the resources with a particular name from all the locations. + * + * @exception IOException when an error occurs accessing one of the + * locations + * @param resourceName the name of the resource to lookup + * @return a (possible empty) enumeration of URLs where the resource can be + * found + */ + public Enumeration findResources(String resourceName) throws IOException + { + Vector resources = new Vector(); + int max = urls.size(); + for (int i = 0; i < max; i++) + { + URLLoader loader = (URLLoader)urlinfos.elementAt(i); + Resource resource = loader.getResource(resourceName); + if (resource != null) + resources.add(resource.getURL()); + } + return resources.elements(); + } + + /** + * Returns the permissions needed to access a particular code + * source. These permissions includes those returned by + * SecureClassLoader.getPermissions() and the actual + * permissions to access the objects referenced by the URL of the + * code source. The extra permissions added depend on the protocol + * and file portion of the URL in the code source. If the URL has + * the "file" protocol ends with a '/' character then it must be a + * directory and a file Permission to read everything in that + * directory and all subdirectories is added. If the URL had the + * "file" protocol and doesn't end with a '/' character then it must + * be a normal file and a file permission to read that file is + * added. If the URL has any other protocol then a + * socket permission to connect and accept connections from the host + * portion of the URL is added. + * * @param source The codesource that needs the permissions to be accessed * @return the collection of permissions needed to access the code resource - * @see SecureClassLoader.getPermissions() + * @see java.security.SecureClassLoader#getPermissions() */ protected PermissionCollection getPermissions(CodeSource source) { @@ -408,7 +995,7 @@ public class URLClassLoader extends SecureClassLoader { String file = url.getFile(); // If the file end in / it must be an directory - if (file.endsWith("/")) + if (file.endsWith("/") || file.endsWith(File.separator)) { // Grant permission to read everything in that directory and // all subdirectories @@ -424,35 +1011,81 @@ public class URLClassLoader extends SecureClassLoader else { // Grant permission to connect to and accept connections from host - String host = url.getHost(); + String host = url.getHost(); + if (host != null) permissions.add(new SocketPermission(host, "connect,accept")); } return permissions; } + + /** + * Returns all the locations that this class loader currently uses the + * resolve classes and resource. This includes both the initially supplied + * URLs as any URLs added later by the loader. + * @return All the currently used URLs + */ + public URL[] getURLs() + { + return (URL[]) urls.toArray(new URL[urls.size()]); + } /** - * Creates a new instance of a URLClassLoader that gets classes from the - * supplied URLs. This class loader will have as parent the standard - * system class loader. - * @param urls the initial URLs used to resolve classes and resources + * Creates a new instance of a URLClassLoader that gets + * classes from the supplied URLs. This class loader + * will have as parent the standard system class loader. + * + * @param urls the initial URLs used to resolve classes and + * resources + * + * @exception SecurityException when the calling code does not have + * permission to access the given URLs */ - public static URLClassLoader newInstance(URL[] urls) throws - SecurityException + public static URLClassLoader newInstance(URL urls[]) + throws SecurityException { - return new URLClassLoader(urls); + return newInstance(urls, null); } /** - * Creates a new instance of a URLClassLoader that gets classes from the - * supplied URLs and with the supplied loader as parent class loader. - * @param urls the initial URLs used to resolve classes and resources + * Creates a new instance of a URLClassLoader that gets + * classes from the supplied URLs and with the supplied + * loader as parent class loader. + * + * @param urls the initial URLs used to resolve classes and + * resources * @param parent the parent class loader + * + * @exception SecurityException when the calling code does not have + * permission to access the given URLs */ - public static URLClassLoader newInstance(URL[] urls, - ClassLoader parent) + public static URLClassLoader newInstance(URL urls[], + final ClassLoader parent) throws SecurityException { - return new URLClassLoader(urls, parent); + SecurityManager sm = System.getSecurityManager(); + if (sm == null) + return new URLClassLoader(urls, parent); + else + { + final Object securityContext = sm.getSecurityContext(); + // XXX - What to do with anything else then an AccessControlContext? + if (!(securityContext instanceof AccessControlContext)) + throw new SecurityException + ("securityContext must be AccessControlContext: " + + securityContext); + + URLClassLoader loader = + (URLClassLoader)AccessController.doPrivileged(new PrivilegedAction() + { + public Object run() + { + return new URLClassLoader + (parent, (AccessControlContext)securityContext); + } + }); + loader.addURLs(urls); + return loader; + } } } diff --git a/libjava/java/net/natPlainDatagramSocketImpl.cc b/libjava/java/net/natPlainDatagramSocketImpl.cc index cbc029a18da..5546061c503 100644 --- a/libjava/java/net/natPlainDatagramSocketImpl.cc +++ b/libjava/java/net/natPlainDatagramSocketImpl.cc @@ -151,9 +151,6 @@ java::net::PlainDatagramSocketImpl::getOption (jint) #else /* DISABLE_JAVA_NET */ -#ifndef HAVE_SOCKLEN_T -typedef int socklen_t; -#endif union SockAddr { diff --git a/libjava/java/net/natPlainSocketImpl.cc b/libjava/java/net/natPlainSocketImpl.cc index 9cd0f3b9dff..114c2102ac5 100644 --- a/libjava/java/net/natPlainSocketImpl.cc +++ b/libjava/java/net/natPlainSocketImpl.cc @@ -61,9 +61,6 @@ read(int s, void *buf, int len) #include #endif -#ifndef HAVE_SOCKLEN_T -typedef int socklen_t; -#endif #include #include diff --git a/libjava/java/nio/channels/DatagramChannel.java b/libjava/java/nio/channels/DatagramChannel.java index eefa443cb29..6c457557b95 100644 --- a/libjava/java/nio/channels/DatagramChannel.java +++ b/libjava/java/nio/channels/DatagramChannel.java @@ -61,6 +61,8 @@ public abstract class DatagramChannel /** * Opens a datagram channel. + * + * @exception IOException If an error occurs */ public static DatagramChannel open () throws IOException { @@ -82,6 +84,9 @@ public abstract class DatagramChannel /** * Writes data to this channel. + * + * @exception IOException If an error occurs + * @exception NotYetConnectedException The channel's socket is not connected. */ public final long write (ByteBuffer[] srcs) { @@ -95,16 +100,31 @@ public abstract class DatagramChannel /** * Connects this channel's socket. + * + * @exception AsynchronousCloseException If another thread closes this channel + * while the connect operation is in progress. + * @exception ClosedByInterruptException If another thread interrupts the + * current thread while the read operation is in progress, thereby closing the + * channel and setting the current thread's interrupt status. + * @exception ClosedChannelException If this channel is closed. + * @exception IOException If an error occurs. + * @exception SecurityException If a security manager has been installed and + * it does not permit datagrams to be sent to the given address. */ public abstract DatagramChannel connect (SocketAddress remote); /** * Disonnects this channel's socket. + * + * @exception IOException If an error occurs */ public abstract DatagramChannel disconnect (); /** * Tells whether or not this channel's socket is connected. + * + * @exception IOException If an error occurs. + * @exception NotYetConnectedException The channel's socket is not connected. */ public abstract boolean isConnected (); @@ -115,16 +135,39 @@ public abstract class DatagramChannel /** * Reads data from this channel. + * + * @exception IOException If an error occurs. + * @exception NotYetConnectedException The channel's socket is not connected. */ public abstract long read (ByteBuffer[] dsts, int offset, int length); /** * Receives a datagram via this channel. + * + * @exception AsynchronousCloseException If another thread closes this channel + * while the connect operation is in progress. + * @exception ClosedByInterruptException If another thread interrupts the + * current thread while the read operation is in progress, thereby closing the + * channel and setting the current thread's interrupt status. + * @exception ClosedChannelException If this channel is closed. + * @exception IOException If an error occurs + * @exception SecurityException If a security manager has been installed and + * it does not permit datagrams to be sent to the given address. */ public abstract SocketAddress receive (ByteBuffer dst); /** * Sends a datagram via this channel. + * + * @exception AsynchronousCloseException If another thread closes this channel + * while the connect operation is in progress. + * @exception ClosedByInterruptException If another thread interrupts the + * current thread while the read operation is in progress, thereby closing the + * channel and setting the current thread's interrupt status. + * @exception ClosedChannelException If this channel is closed. + * @exception IOException If an error occurs + * @exception SecurityException If a security manager has been installed and + * it does not permit datagrams to be sent to the given address. */ public abstract int send (ByteBuffer src, SocketAddress target); @@ -135,16 +178,25 @@ public abstract class DatagramChannel /** * Writes data to this channel. + * + * @exception IOException If an error occurs. + * @exception NotYetConnectedException The channel's socket is not connected. */ public abstract int write (ByteBuffer src); /** * Writes data to this channel. + * + * @exception IOException If an error occurs. + * @exception NotYetConnectedException The channel's socket is not connected. */ public abstract long write (ByteBuffer[] srcs, int offset, int length); /** * Retrieves the valid operations for this channel. + * + * @exception IOException If an error occurs. + * @exception NotYetConnectedException The channel's socket is not connected. */ public final int validOps () { diff --git a/libjava/java/nio/channels/SocketChannel.java b/libjava/java/nio/channels/SocketChannel.java index 1d93430947e..368a8ee468c 100644 --- a/libjava/java/nio/channels/SocketChannel.java +++ b/libjava/java/nio/channels/SocketChannel.java @@ -60,6 +60,8 @@ abstract public class SocketChannel extends AbstractSelectableChannel /** * Opens a socket channel. + * + * @exception IOException If an error occurs */ public static SocketChannel open () throws IOException { @@ -68,6 +70,18 @@ abstract public class SocketChannel extends AbstractSelectableChannel /** * Opens a channel and connects it to a remote address. + * + * @exception AsynchronousCloseException If this channel is already connected. + * @exception ClosedByInterruptException If another thread interrupts the + * current thread while the connect operation is in progress, thereby closing + * the channel and setting the current thread's interrupt status. + * @exception IOException If an error occurs + * @exception SecurityException If a security manager has been installed and + * it does not permit access to the given remote endpoint. + * @exception UnresolvedAddressException If the given remote address is not + * fully resolved. + * @exception UnsupportedAddressTypeException If the type of the given remote + * address is not supported. */ public static SocketChannel open (SocketAddress remote) throws IOException { @@ -82,6 +96,9 @@ abstract public class SocketChannel extends AbstractSelectableChannel /** * Reads data from the channel. + * + * @exception IOException If an error occurs + * @exception NotYetConnectedException If this channel is not yet connected. */ public final long read (ByteBuffer[] dsts) { @@ -97,6 +114,9 @@ abstract public class SocketChannel extends AbstractSelectableChannel /** * Writes data to the channel. + * + * @exception IOException If an error occurs + * @exception NotYetConnectedException If this channel is not yet connected. */ public final long write (ByteBuffer[] dsts) { @@ -120,16 +140,44 @@ abstract public class SocketChannel extends AbstractSelectableChannel /** * Reads data from the channel. + * + * @exception IOException If an error occurs + * @exception NotYetConnectedException If this channel is not yet connected. */ public abstract int read (ByteBuffer dst); /** * Connects the channel's socket to the remote address. + * + * @exception AlreadyConnectedException If this channel is already connected. + * @exception AsynchronousCloseException If this channel is already connected. + * @exception ClosedByInterruptException If another thread interrupts the + * current thread while the connect operation is in progress, thereby closing + * the channel and setting the current thread's interrupt status. + * @exception ClosedChannelException If this channel is closed. + * @exception ConnectionPendingException If a non-blocking connection + * operation is already in progress on this channel. + * @exception IOException If an error occurs + * @exception SecurityException If a security manager has been installed and + * it does not permit access to the given remote endpoint. + * @exception UnresolvedAddressException If the given remote address is not + * fully resolved. + * @exception UnsupportedAddressTypeException If the type of the given remote + * address is not supported. */ public abstract boolean connect (SocketAddress remote) throws IOException; /** * Finishes the process of connecting a socket channel. + * + * @exception AsynchronousCloseException If this channel is already connected. + * @exception ClosedByInterruptException If another thread interrupts the + * current thread while the connect operation is in progress, thereby closing + * the channel and setting the current thread's interrupt status. + * @exception ClosedChannelException If this channel is closed. + * @exception IOException If an error occurs + * @exception NoConnectionPendingException If this channel is not connected + * and a connection operation has not been initiated. */ public abstract boolean finishConnect (); @@ -145,6 +193,9 @@ abstract public class SocketChannel extends AbstractSelectableChannel /** * Reads data from the channel. + * + * @exception IOException If an error occurs + * @exception NotYetConnectedException If this channel is not yet connected. */ public abstract long read (ByteBuffer[] dsts, int offset, int length); @@ -155,11 +206,17 @@ abstract public class SocketChannel extends AbstractSelectableChannel /** * Writes data to the channel. + * + * @exception IOException If an error occurs + * @exception NotYetConnectedException If this channel is not yet connected. */ public abstract int write (ByteBuffer src); /** * Writes data to the channel. + * + * @exception IOException If an error occurs + * @exception NotYetConnectedException If this channel is not yet connected. */ public abstract long write (ByteBuffer[] srcs, int offset, int length); } diff --git a/libjava/java/security/SecureRandom.java b/libjava/java/security/SecureRandom.java index 31701cb6fd9..a0b7f95f397 100644 --- a/libjava/java/security/SecureRandom.java +++ b/libjava/java/security/SecureRandom.java @@ -1,5 +1,5 @@ /* SecureRandom.java --- Secure Random class implmentation - Copyright (C) 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,7 +53,6 @@ public class SecureRandom extends Random //Serialized Field long counter = 0; //Serialized - MessageDigest digest = null; Provider provider = null; byte[] randomBytes = null; //Always null int randomBytesUsed = 0; @@ -83,41 +82,29 @@ public class SecureRandom extends Random Enumeration e; for (i = 0; i < p.length; i++) { - e = p[i].propertyNames(); - while (e.hasMoreElements()) - { - key = (String) e.nextElement(); - if (key.startsWith("SecureRandom.")) - if ((classname = p[i].getProperty(key)) != null) - break; + e = p[i].propertyNames(); + while (e.hasMoreElements()) + { + key = (String) e.nextElement(); + if (key.startsWith("SECURERANDOM.")) + { + if ((classname = p[i].getProperty(key)) != null) + { + try + { + secureRandomSpi = (SecureRandomSpi) Class. + forName(classname).newInstance(); + provider = p[i]; + return; + } + catch (Throwable ignore) { } + } + } } - if (classname != null) - break; } - //if( classname == null) - // throw new NoSuchAlgorithmException(); - - try - { - this.secureRandomSpi = - (SecureRandomSpi) Class.forName(classname).newInstance(); - - //s.algorithm = algorithm; - this.provider = p[i]; - } - catch (ClassNotFoundException cnfe) - { - //throw new NoSuchAlgorithmException("Class not found"); - } - catch (InstantiationException ie) - { - //throw new NoSuchAlgorithmException("Class instantiation failed"); - } - catch (IllegalAccessException iae) - { - //throw new NoSuchAlgorithmException("Illegal Access"); - } + // Nothing found. Fall back to SHA1PRNG + secureRandomSpi = new gnu.java.security.provider.SHA1PRNG(); } /** @@ -167,40 +154,17 @@ public class SecureRandom extends Random NoSuchAlgorithmException { Provider p[] = Security.getProviders(); - - //Format of Key: SecureRandom.algname - StringBuffer key = new StringBuffer("SecureRandom."); - key.append(algorithm); - - String classname = null; - int i; - for (i = 0; i < p.length; i++) - { - if ((classname = p[i].getProperty(key.toString())) != null) - break; - } - - if (classname == null) - throw new NoSuchAlgorithmException(); - - try - { - return new SecureRandom((SecureRandomSpi) Class.forName(classname). - newInstance(), p[i]); - } - catch (ClassNotFoundException cnfe) - { - throw new NoSuchAlgorithmException("Class not found"); - } - catch (InstantiationException ie) - { - throw new NoSuchAlgorithmException("Class instantiation failed"); - } - catch (IllegalAccessException iae) + for (int i = 0; i < p.length; i++) { - throw new NoSuchAlgorithmException("Illegal Access"); + try + { + return getInstance(algorithm, p[i]); + } + catch (NoSuchAlgorithmException ignored) { } } + // None found. + throw new NoSuchAlgorithmException(algorithm); } /** @@ -222,33 +186,91 @@ public class SecureRandom extends Random Provider p = Security.getProvider(provider); if (p == null) throw new NoSuchProviderException(); + + return getInstance(algorithm, p); + } - //Format of Key: SecureRandom.algName - StringBuffer key = new StringBuffer("SecureRandom."); - key.append(algorithm); + /** + Returns an instance of a SecureRandom. It creates the class for + the specified algorithm from the given provider. - String classname = p.getProperty(key.toString()); - if (classname == null) - throw new NoSuchAlgorithmException(); + @param algorithm The SecureRandom algorithm to create. + @param provider The provider to get the instance from. - try - { - return new SecureRandom((SecureRandomSpi) Class.forName(classname). - newInstance(), p); - } - catch (ClassNotFoundException cnfe) - { - throw new NoSuchAlgorithmException("Class not found"); - } - catch (InstantiationException ie) - { - throw new NoSuchAlgorithmException("Class instantiation failed"); - } - catch (IllegalAccessException iae) + @throws NoSuchAlgorithmException If the algorithm cannot be found, or + if the class cannot be instantiated. + */ + public static SecureRandom getInstance(String algorithm, + Provider provider) throws + NoSuchAlgorithmException + { + return getInstance(algorithm, provider, true); + } + + /** + Creates the instance of SecureRandom, recursing to resolve aliases. + + @param algorithm The SecureRandom algorithm to create. + @param provider The provider to get the implementation from. + @param recurse Whether or not to recurse to resolve aliases. + + @throws NoSuchAlgorithmException If the algorithm cannot be found, + if there are too many aliases, or if the class cannot be + instantiated. + */ + private static SecureRandom getInstance(String algorithm, + Provider provider, + boolean recurse) + throws NoSuchAlgorithmException + { + String msg = algorithm; + for (Enumeration e = provider.propertyNames(); e.hasMoreElements(); ) { - throw new NoSuchAlgorithmException("Illegal Access"); + // We could replace the boolean with an integer, incrementing it + // every + String key = (String) e.nextElement(); + if (key.startsWith("SECURERANDOM.") + && key.substring(13).equalsIgnoreCase(algorithm)) + { + try + { + Class c = Class.forName(provider.getProperty(key)); + return new SecureRandom((SecureRandomSpi) c.newInstance(), + provider); + } + catch (Throwable ignored) { } + } + else if (key.startsWith("ALG.ALIAS.SECURERANDOM.") + && key.substring(23).equalsIgnoreCase(algorithm) && recurse) + { + try + { + // First see if this alias refers to a class in this + // provider. + return getInstance(provider.getProperty(key), provider, false); + } + catch (NoSuchAlgorithmException nsae) + { + Provider[] provs = Security.getProviders(); + for (int i = 0; i < provs.length; i++) + { + if (provs[i] == provider) + continue; + // Now try other providers for the implementation + try + { + return getInstance(provider.getProperty(key), + provs[i], false); + } + catch (NoSuchAlgorithmException nsae2) + { + msg = nsae2.getMessage(); + } + } + } + } } - + throw new NoSuchAlgorithmException(algorithm); } /** diff --git a/libjava/java/security/Security.java b/libjava/java/security/Security.java index 8c84c3f7978..bf7a993ad47 100644 --- a/libjava/java/security/Security.java +++ b/libjava/java/security/Security.java @@ -89,7 +89,7 @@ public final class Security extends Object int i = 1; String name; - while ((name = secprops.getProperty("security.provider." + i++)) != + while ((name = secprops.getProperty("security.provider." + i)) != null) { Exception exception = null; @@ -97,7 +97,6 @@ public final class Security extends Object try { providers.addElement(Class.forName(name).newInstance()); - i++; } catch (ClassNotFoundException x) { @@ -114,6 +113,7 @@ public final class Security extends Object if (exception != null) System.err.println ("Error loading security provider " + name + ": " + exception); + i++; } } catch (FileNotFoundException ignored) diff --git a/libjava/java/security/spec/DSAParameterSpec.java b/libjava/java/security/spec/DSAParameterSpec.java index 59bddc00f58..fa0ebce7a7a 100644 --- a/libjava/java/security/spec/DSAParameterSpec.java +++ b/libjava/java/security/spec/DSAParameterSpec.java @@ -74,7 +74,7 @@ public class DSAParameterSpec extends Object implements AlgorithmParameterSpec, */ public BigInteger getP() { - return this.q; + return this.p; } /** diff --git a/libjava/java/security/spec/DSAPrivateKeySpec.java b/libjava/java/security/spec/DSAPrivateKeySpec.java index 9b21563a444..b4025d61cb3 100644 --- a/libjava/java/security/spec/DSAPrivateKeySpec.java +++ b/libjava/java/security/spec/DSAPrivateKeySpec.java @@ -87,7 +87,7 @@ public class DSAPrivateKeySpec extends Object implements KeySpec */ public BigInteger getP() { - return this.q; + return this.p; } /** diff --git a/libjava/java/security/spec/DSAPublicKeySpec.java b/libjava/java/security/spec/DSAPublicKeySpec.java index eee42a91587..5eb70ba07c3 100644 --- a/libjava/java/security/spec/DSAPublicKeySpec.java +++ b/libjava/java/security/spec/DSAPublicKeySpec.java @@ -87,7 +87,7 @@ public class DSAPublicKeySpec extends Object implements KeySpec */ public BigInteger getP() { - return this.q; + return this.p; } /** diff --git a/libjava/java/util/Locale.java b/libjava/java/util/Locale.java index df5dac15b37..22e19384c59 100644 --- a/libjava/java/util/Locale.java +++ b/libjava/java/util/Locale.java @@ -420,6 +420,8 @@ public final class Locale implements Serializable, Cloneable { if (language.length() == 0 && country.length() == 0) return ""; + else if (country.length() == 0 && variant.length() == 0) + return language; StringBuffer result = new StringBuffer(language); result.append('_').append(country); if (variant.length() != 0) diff --git a/libjava/java/util/ResourceBundle.java b/libjava/java/util/ResourceBundle.java index bfb6b306337..2a4e34887c4 100644 --- a/libjava/java/util/ResourceBundle.java +++ b/libjava/java/util/ResourceBundle.java @@ -42,8 +42,6 @@ import java.lang.ref.Reference; import java.lang.ref.SoftReference; import java.io.InputStream; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import gnu.classpath.Configuration; /** @@ -105,44 +103,7 @@ public abstract class ResourceBundle */ private Locale locale; - /** - * We override SecurityManager in order to access getClassContext(). - */ - private static final class Security extends SecurityManager - { - /** - * Avoid accessor method of private constructor. - */ - Security() - { - } - - /** - * Return the ClassLoader of the class which called into this - * ResourceBundle, or null if it cannot be determined. - */ - ClassLoader getCallingClassLoader() - { - Class[] stack = getClassContext(); - for (int i = 0; i < stack.length; i++) - if (stack[i] != Security.class && stack[i] != ResourceBundle.class) - return stack[i].getClassLoader(); - return null; - } - } - - /** A security context for grabbing the correct class loader. */ - private static final Security security - = (Security) AccessController.doPrivileged(new PrivilegedAction() - { - // This will always work since java.util classes have (all) system - // permissions. - public Object run() - { - return new Security(); - } - } - ); + private static native ClassLoader getCallingClassLoader(); /** * The resource bundle cache. This is a two-level hash map: The key @@ -150,7 +111,13 @@ public abstract class ResourceBundle * second hash map is the localized name, the value is a soft * references to the resource bundle. */ - private static final Map resourceBundleCache = new HashMap(); + private static Map resourceBundleCache; + + /** + * The last default Locale we saw. If this ever changes then we have to + * reset our caches. + */ + private static Locale lastDefaultLocale; /** * The `empty' locale is created once in order to optimize @@ -256,7 +223,7 @@ public abstract class ResourceBundle public static final ResourceBundle getBundle(String baseName) { return getBundle(baseName, Locale.getDefault(), - security.getCallingClassLoader()); + getCallingClassLoader()); } /** @@ -274,7 +241,7 @@ public abstract class ResourceBundle public static final ResourceBundle getBundle(String baseName, Locale locale) { - return getBundle(baseName, locale, security.getCallingClassLoader()); + return getBundle(baseName, locale, getCallingClassLoader()); } /** @@ -351,6 +318,12 @@ public abstract class ResourceBundle { // This implementation searches the bundle in the reverse direction // and builds the parent chain on the fly. + Locale defaultLocale = Locale.getDefault(); + if (defaultLocale != lastDefaultLocale) + { + resourceBundleCache = new HashMap(); + lastDefaultLocale = defaultLocale; + } HashMap cache = (HashMap) resourceBundleCache.get(classLoader); StringBuffer sb = new StringBuffer(60); sb.append(baseName).append('_').append(locale); @@ -398,9 +371,9 @@ public abstract class ResourceBundle // bundle. ResourceBundle bundle = tryLocalBundle(baseName, locale, classLoader, baseBundle, cache); - if (bundle == baseBundle && !locale.equals(Locale.getDefault())) + if (bundle == baseBundle && !locale.equals(defaultLocale)) { - bundle = tryLocalBundle(baseName, Locale.getDefault(), + bundle = tryLocalBundle(baseName, defaultLocale, classLoader, baseBundle, cache); // We need to record that the argument locale maps to the // bundle we just found. If we didn't find a bundle, record diff --git a/libjava/java/util/jar/JarFile.java b/libjava/java/util/jar/JarFile.java index 25179d2558c..d6fd9846b6e 100644 --- a/libjava/java/util/jar/JarFile.java +++ b/libjava/java/util/jar/JarFile.java @@ -67,18 +67,22 @@ public class JarFile extends ZipFile /** * The manifest of this file, if any, otherwise null. - * Read by the constructor. + * Read when first needed. */ - private final Manifest manifest; + private Manifest manifest; - /** Wether to verify the manifest and all entries */ + /** Wether to verify the manifest and all entries. */ private boolean verify; + /** Wether the has already been loaded. */ + private boolean manifestRead = false; + // Constructors /** - * Creates a new JarFile, tries to read the manifest and if the manifest - * exists verifies it. + * Creates a new JarFile. All jar entries are verified (when a Manifest file + * for this JarFile exists). You need to actually open and read the complete + * jar entry (with getInputStream()) to check its signature. * * @param fileName the name of the file to open * @exception FileNotFoundException if the fileName cannot be found @@ -90,8 +94,10 @@ public class JarFile extends ZipFile } /** - * Creates a new JarFile, tries to read the manifest and if the manifest - * exists and verify is true verfies it. + * Creates a new JarFile. If verify is true then all jar entries are + * verified (when a Manifest file for this JarFile exists). You need to + * actually open and read the complete jar entry + * (with getInputStream()) to check its signature. * * @param fileName the name of the file to open * @param verify checks manifest and entries when true and a manifest @@ -103,14 +109,12 @@ public class JarFile extends ZipFile FileNotFoundException, IOException { super(fileName); - manifest = readManifest(); - if (verify) - verify(); } /** - * Creates a new JarFile, tries to read the manifest and if the manifest - * exists verifies it. + * Creates a new JarFile. All jar entries are verified (when a Manifest file + * for this JarFile exists). You need to actually open and read the complete + * jar entry (with getInputStream()) to check its signature. * * @param file the file to open as a jar file * @exception FileNotFoundException if the file does not exits @@ -122,8 +126,10 @@ public class JarFile extends ZipFile } /** - * Creates a new JarFile, tries to read the manifest and if the manifest - * exists and verify is true verfies it. + * Creates a new JarFile. If verify is true then all jar entries are + * verified (when a Manifest file for this JarFile exists). You need to + * actually open and read the complete jar entry + * (with getInputStream()) to check its signature. * * @param file the file to open to open as a jar file * @param verify checks manifest and entries when true and a manifest @@ -135,13 +141,13 @@ public class JarFile extends ZipFile IOException { super(file); - manifest = readManifest(); - if (verify) - verify(); } /** - * Creates a new JarFile with the indicated mode, tries to read the + * Creates a new JarFile with the indicated mode. If verify is true then + * all jar entries are verified (when a Manifest file for this JarFile + * exists). You need to actually open and read the complete jar entry + * (with getInputStream()) to check its signature. * manifest and if the manifest exists and verify is true verfies it. * * @param file the file to open to open as a jar file @@ -159,9 +165,6 @@ public class JarFile extends ZipFile FileNotFoundException, IOException, IllegalArgumentException { super(file, mode); - manifest = readManifest(); - if (verify) - verify(); } // Methods @@ -241,6 +244,16 @@ public class JarFile extends ZipFile { ZipEntry zip = (ZipEntry) entries.nextElement(); JarEntry jar = new JarEntry(zip); + Manifest manifest; + try + { + manifest = getManifest(); + } + catch (IOException ioe) + { + manifest = null; + } + if (manifest != null) { jar.attr = manifest.getAttributes(jar.getName()); @@ -261,6 +274,16 @@ public class JarFile extends ZipFile if (entry != null) { JarEntry jarEntry = new JarEntry(entry); + Manifest manifest; + try + { + manifest = getManifest(); + } + catch (IOException ioe) + { + manifest = null; + } + if (manifest != null) { jarEntry.attr = manifest.getAttributes(name); @@ -301,8 +324,11 @@ public class JarFile extends ZipFile * Returns the manifest for this JarFile or null when the JarFile does not * contain a manifest file. */ - public Manifest getManifest() + public Manifest getManifest() throws IOException { + if (!manifestRead) + manifest = readManifest(); + return manifest; } } diff --git a/libjava/java/util/natResourceBundle.cc b/libjava/java/util/natResourceBundle.cc index adb83f92b26..21a9565c996 100644 --- a/libjava/java/util/natResourceBundle.cc +++ b/libjava/java/util/natResourceBundle.cc @@ -16,24 +16,17 @@ details. */ #include #include #include -#include #include java::lang::ClassLoader * java::util::ResourceBundle::getCallingClassLoader () { gnu::gcj::runtime::StackTrace *t = new gnu::gcj::runtime::StackTrace(6); - try - { - for (int i = 3; ; ++i) - { - jclass klass = t->classAt(i); - if (klass != NULL) - return klass->getClassLoaderInternal(); - } - } - catch (::java::lang::ArrayIndexOutOfBoundsException *e) + for (int i = 3; i < 6; ++i) { + jclass klass = t->classAt(i); + if (klass != NULL) + return klass->getClassLoaderInternal(); } return NULL; } diff --git a/libjava/java/util/zip/ZipEntry.java b/libjava/java/util/zip/ZipEntry.java index 5a43b1f5a2e..c9f1b1d7d44 100644 --- a/libjava/java/util/zip/ZipEntry.java +++ b/libjava/java/util/zip/ZipEntry.java @@ -55,19 +55,18 @@ public class ZipEntry implements ZipConstants, Cloneable private static int KNOWN_CRC = 4; private static int KNOWN_TIME = 8; - private static Calendar cal = Calendar.getInstance(); + private static Calendar cal; private String name; private int size; private int compressedSize; private int crc; - private int time; + private int dostime; private short known = 0; private short method = -1; private byte[] extra = null; private String comment = null; - int zipFileIndex = -1; /* used by ZipFile */ int flags; /* used by ZipOutputStream */ int offset; /* used by ZipFile and ZipOutputStream */ @@ -104,53 +103,24 @@ public class ZipEntry implements ZipConstants, Cloneable size = e.size; compressedSize = e.compressedSize; crc = e.crc; - time = e.time; + dostime = e.dostime; method = e.method; extra = e.extra; comment = e.comment; } - void setDOSTime(int dostime) + final void setDOSTime(int dostime) { - int sec = 2 * (dostime & 0x1f); - int min = (dostime >> 5) & 0x3f; - int hrs = (dostime >> 11) & 0x1f; - int day = (dostime >> 16) & 0x1f; - int mon = ((dostime >> 21) & 0xf) - 1; - int year = ((dostime >> 25) & 0x7f) + 1980; /* since 1900 */ - - // Guard against invalid or missing date causing - // IndexOutOfBoundsException. - try - { - synchronized (cal) - { - cal.set(year, mon, day, hrs, min, sec); - time = (int) (cal.getTime().getTime() / 1000L); - } - known |= KNOWN_TIME; - } - catch (RuntimeException ex) - { - /* Ignore illegal time stamp */ - known &= ~KNOWN_TIME; - } + this.dostime = dostime; + known |= KNOWN_TIME; } - int getDOSTime() + final int getDOSTime() { if ((known & KNOWN_TIME) == 0) return 0; - synchronized (cal) - { - cal.setTime(new Date(time*1000L)); - return (cal.get(cal.YEAR) - 1980 & 0x7f) << 25 - | (cal.get(cal.MONTH) + 1) << 21 - | (cal.get(cal.DAY_OF_MONTH)) << 16 - | (cal.get(cal.HOUR_OF_DAY)) << 11 - | (cal.get(cal.MINUTE)) << 5 - | (cal.get(cal.SECOND)) >> 1; - } + else + return dostime; } /** @@ -190,7 +160,18 @@ public class ZipEntry implements ZipConstants, Cloneable */ public void setTime(long time) { - this.time = (int) (time / 1000L); + Calendar cal = getCalendar(); + synchronized (cal) + { + cal.setTime(new Date(time*1000L)); + dostime = (cal.get(cal.YEAR) - 1980 & 0x7f) << 25 + | (cal.get(cal.MONTH) + 1) << 21 + | (cal.get(cal.DAY_OF_MONTH)) << 16 + | (cal.get(cal.HOUR_OF_DAY)) << 11 + | (cal.get(cal.MINUTE)) << 5 + | (cal.get(cal.SECOND)) >> 1; + } + dostime = (int) (dostime / 1000L); this.known |= KNOWN_TIME; } @@ -200,7 +181,39 @@ public class ZipEntry implements ZipConstants, Cloneable */ public long getTime() { - return (known & KNOWN_TIME) != 0 ? time * 1000L : -1; + if ((known & KNOWN_TIME) == 0) + return -1; + + int sec = 2 * (dostime & 0x1f); + int min = (dostime >> 5) & 0x3f; + int hrs = (dostime >> 11) & 0x1f; + int day = (dostime >> 16) & 0x1f; + int mon = ((dostime >> 21) & 0xf) - 1; + int year = ((dostime >> 25) & 0x7f) + 1980; /* since 1900 */ + + try + { + cal = getCalendar(); + synchronized (cal) + { + cal.set(year, mon, day, hrs, min, sec); + return cal.getTime().getTime(); + } + } + catch (RuntimeException ex) + { + /* Ignore illegal time stamp */ + known &= ~KNOWN_TIME; + return -1; + } + } + + private static synchronized Calendar getCalendar() + { + if (cal == null) + cal = Calendar.getInstance(); + + return cal; } /** @@ -320,11 +333,11 @@ public class ZipEntry implements ZipConstants, Cloneable int flags = extra[pos]; if ((flags & 1) != 0) { - time = ((extra[pos+1] & 0xff) + long time = ((extra[pos+1] & 0xff) | (extra[pos+2] & 0xff) << 8 | (extra[pos+3] & 0xff) << 16 | (extra[pos+4] & 0xff) << 24); - known |= KNOWN_TIME; + setTime(time); } } pos += len; diff --git a/libjava/java/util/zip/ZipFile.java b/libjava/java/util/zip/ZipFile.java index 2eb1156d2bc..eb79d03e594 100644 --- a/libjava/java/util/zip/ZipFile.java +++ b/libjava/java/util/zip/ZipFile.java @@ -46,6 +46,7 @@ import java.io.IOException; import java.io.EOFException; import java.io.RandomAccessFile; import java.util.Enumeration; +import java.util.Hashtable; import java.util.NoSuchElementException; /** @@ -61,21 +62,26 @@ import java.util.NoSuchElementException; public class ZipFile implements ZipConstants { - /** Mode flag to open a zip file for reading - * + /** + * Mode flag to open a zip file for reading. */ - public static final int OPEN_READ = 0x1; - /** Mode flag to delete a zip file after reading - * + /** + * Mode flag to delete a zip file after reading. */ - public static final int OPEN_DELETE = 0x4; - private String name; - RandomAccessFile raf; - ZipEntry[] entries; + // Name of this zip file. + private final String name; + + // File from which zip entries are read. + private final RandomAccessFile raf; + + // The entries of this zip file when initialized and not yet closed. + private Hashtable entries; + + private boolean closed = false; /** * Opens a Zip file with the given name for reading. @@ -87,7 +93,6 @@ public class ZipFile implements ZipConstants { this.raf = new RandomAccessFile(name, "r"); this.name = name; - readEntries(); } /** @@ -100,7 +105,6 @@ public class ZipFile implements ZipConstants { this.raf = new RandomAccessFile(file, "r"); this.name = file.getName(); - readEntries(); } /** @@ -130,7 +134,6 @@ public class ZipFile implements ZipConstants } this.raf = new RandomAccessFile(file, "r"); this.name = file.getName(); - readEntries(); } /** @@ -160,7 +163,7 @@ public class ZipFile implements ZipConstants /** * Read the central directory of a zip file and fill the entries - * array. This is called exactly once by the constructors. + * array. This is called exactly once when first needed. * @exception IOException if a i/o error occured. * @exception ZipException if the central directory is malformed */ @@ -187,7 +190,7 @@ public class ZipFile implements ZipConstants throw new EOFException(name); int centralOffset = readLeInt(raf); - entries = new ZipEntry[count]; + entries = new Hashtable(count); raf.seek(centralOffset); byte[] ebs = new byte[24]; ByteArrayInputStream ebais = new ByteArrayInputStream(ebs); @@ -236,9 +239,8 @@ public class ZipFile implements ZipConstants raf.readFully(buffer, 0, commentLen); entry.setComment(new String(buffer, 0, commentLen)); } - entry.zipFileIndex = i; entry.offset = offset; - entries[i] = entry; + entries.put(name, entry); } } @@ -250,9 +252,10 @@ public class ZipFile implements ZipConstants */ public void close() throws IOException { - entries = null; synchronized (raf) { + closed = true; + entries = null; raf.close(); } } @@ -262,17 +265,34 @@ public class ZipFile implements ZipConstants */ public Enumeration entries() { - if (entries == null) - throw new IllegalStateException("ZipFile has closed: " + name); - return new ZipEntryEnumeration(entries); + try + { + return new ZipEntryEnumeration(getEntries().elements()); + } + catch (IOException ioe) + { + return null; + } } - private int getEntryIndex(String name) + /** + * Checks that the ZipFile is still open and reads entries when necessary. + * + * @exception IllegalStateException when the ZipFile has already been closed. + * @exception IOEexception when the entries could not be read. + */ + private Hashtable getEntries() throws IOException { - for (int i = 0; i < entries.length; i++) - if (name.equals(entries[i].getName())) - return i; - return -1; + synchronized(raf) + { + if (closed) + throw new IllegalStateException("ZipFile has closed: " + name); + + if (entries == null) + readEntries(); + + return entries; + } } /** @@ -283,10 +303,16 @@ public class ZipFile implements ZipConstants * @see #entries */ public ZipEntry getEntry(String name) { - if (entries == null) - throw new IllegalStateException("ZipFile has closed: " + name); - int index = getEntryIndex(name); - return index >= 0 ? (ZipEntry) entries[index].clone() : null; + try + { + Hashtable entries = getEntries(); + ZipEntry entry = (ZipEntry) entries.get(name); + return entry != null ? (ZipEntry) entry.clone() : null; + } + catch (IOException ioe) + { + return null; + } } /** @@ -334,21 +360,16 @@ public class ZipFile implements ZipConstants */ public InputStream getInputStream(ZipEntry entry) throws IOException { - if (entries == null) - throw new IllegalStateException("ZipFile has closed"); - int index = entry.zipFileIndex; - if (index < 0 || index >= entries.length - || entries[index].getName() != entry.getName()) - { - index = getEntryIndex(entry.getName()); - if (index < 0) - throw new NoSuchElementException(); - } - - long start = checkLocalHeader(entries[index]); - int method = entries[index].getMethod(); + Hashtable entries = getEntries(); + String name = entry.getName(); + ZipEntry zipEntry = (ZipEntry) entries.get(name); + if (zipEntry == null) + throw new NoSuchElementException(name); + + long start = checkLocalHeader(zipEntry); + int method = zipEntry.getMethod(); InputStream is = new PartialInputStream - (raf, start, entries[index].getCompressedSize()); + (raf, start, zipEntry.getCompressedSize()); switch (method) { case ZipOutputStream.STORED: @@ -375,42 +396,34 @@ public class ZipFile implements ZipConstants { try { - return entries.length; + return getEntries().size(); } - catch (NullPointerException ex) + catch (IOException ioe) { - throw new IllegalStateException("ZipFile has closed"); + return 0; } } private static class ZipEntryEnumeration implements Enumeration { - ZipEntry[] array; - int ptr = 0; + private final Enumeration elements; - public ZipEntryEnumeration(ZipEntry[] arr) + public ZipEntryEnumeration(Enumeration elements) { - array = arr; + this.elements = elements; } public boolean hasMoreElements() { - return ptr < array.length; + return elements.hasMoreElements(); } public Object nextElement() { - try - { - /* We return a clone, just to be safe that the user doesn't - * change the entry. - */ - return array[ptr++].clone(); - } - catch (ArrayIndexOutOfBoundsException ex) - { - throw new NoSuchElementException(); - } + /* We return a clone, just to be safe that the user doesn't + * change the entry. + */ + return ((ZipEntry)elements.nextElement()).clone(); } } diff --git a/libjava/java/util/zip/ZipInputStream.java b/libjava/java/util/zip/ZipInputStream.java index c9a6c0159e7..c4905978d74 100644 --- a/libjava/java/util/zip/ZipInputStream.java +++ b/libjava/java/util/zip/ZipInputStream.java @@ -151,7 +151,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants return null; } if (header != LOCSIG) - throw new ZipException("Wrong Local header signature" + throw new ZipException("Wrong Local header signature: " + Integer.toHexString(header)); /* skip version */ readLeShort(); diff --git a/libjava/javax/transaction/HeuristicCommitException.java b/libjava/javax/transaction/HeuristicCommitException.java index 0646a2352d1..e1ef8e2def2 100644 --- a/libjava/javax/transaction/HeuristicCommitException.java +++ b/libjava/javax/transaction/HeuristicCommitException.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* HeuristicCommitException.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,7 +43,7 @@ package javax.transaction; * @date May 25, 2001 */ -public class HeuristicCommitException extends java.lang.Exception +public class HeuristicCommitException extends Exception { public HeuristicCommitException () { diff --git a/libjava/javax/transaction/HeuristicMixedException.java b/libjava/javax/transaction/HeuristicMixedException.java index f351da32fe2..68986b60672 100644 --- a/libjava/javax/transaction/HeuristicMixedException.java +++ b/libjava/javax/transaction/HeuristicMixedException.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* HeuristicMixedException.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,7 +43,7 @@ package javax.transaction; * @date May 25, 2001 */ -public class HeuristicMixedException extends java.lang.Exception +public class HeuristicMixedException extends Exception { public HeuristicMixedException () { diff --git a/libjava/javax/transaction/HeuristicRollbackException.java b/libjava/javax/transaction/HeuristicRollbackException.java index 7ad3782710e..72ac3b4d4d5 100644 --- a/libjava/javax/transaction/HeuristicRollbackException.java +++ b/libjava/javax/transaction/HeuristicRollbackException.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* HeuristicRollbackException.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,7 +43,7 @@ package javax.transaction; * @date May 25, 2001 */ -public class HeuristicRollbackException extends java.lang.Exception +public class HeuristicRollbackException extends Exception { public HeuristicRollbackException () { diff --git a/libjava/javax/transaction/InvalidTransactionException.java b/libjava/javax/transaction/InvalidTransactionException.java index f5bb7184e2d..0c47912be46 100644 --- a/libjava/javax/transaction/InvalidTransactionException.java +++ b/libjava/javax/transaction/InvalidTransactionException.java @@ -1,11 +1,40 @@ -/* Copyright (C) 2001 Free Software Foundation +/* InvalidTransactionException.java -- + Copyright (C) 2001, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +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 javax.transaction; import java.rmi.RemoteException; diff --git a/libjava/javax/transaction/NotSupportedException.java b/libjava/javax/transaction/NotSupportedException.java index 767babbeba4..b239574fcb4 100644 --- a/libjava/javax/transaction/NotSupportedException.java +++ b/libjava/javax/transaction/NotSupportedException.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* NotSupportedException.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,7 +43,7 @@ package javax.transaction; * @date May 25, 2001 */ -public class NotSupportedException extends java.lang.Exception +public class NotSupportedException extends Exception { public NotSupportedException () { diff --git a/libjava/javax/transaction/RollbackException.java b/libjava/javax/transaction/RollbackException.java index 7bc77eeaa13..c8706f5bb86 100644 --- a/libjava/javax/transaction/RollbackException.java +++ b/libjava/javax/transaction/RollbackException.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* RollbackException.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,7 +43,7 @@ package javax.transaction; * @date May 25, 2001 */ -public class RollbackException extends java.lang.Exception +public class RollbackException extends Exception { public RollbackException () { diff --git a/libjava/javax/transaction/Status.java b/libjava/javax/transaction/Status.java index 84f1e7ca4c7..7068602b197 100644 --- a/libjava/javax/transaction/Status.java +++ b/libjava/javax/transaction/Status.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* Status.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,7 +43,7 @@ package javax.transaction; * @date May 25, 2001 */ -public abstract interface Status +public interface Status { public static final int STATUS_ACTIVE = 0; public static final int STATUS_MARKED_ROLLBACK = 1; diff --git a/libjava/javax/transaction/Synchronization.java b/libjava/javax/transaction/Synchronization.java index 046f64d9cf8..7a1dfa5ce26 100644 --- a/libjava/javax/transaction/Synchronization.java +++ b/libjava/javax/transaction/Synchronization.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* Synchronization.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,7 +43,7 @@ package javax.transaction; * @date May 25, 2001 */ -public abstract interface Synchronization +public interface Synchronization { public void beforeCompletion(); public void afterCompletion(int status); diff --git a/libjava/javax/transaction/SystemException.java b/libjava/javax/transaction/SystemException.java index e279acaca35..ed9c9e4f273 100644 --- a/libjava/javax/transaction/SystemException.java +++ b/libjava/javax/transaction/SystemException.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* SystemException.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,7 +43,7 @@ package javax.transaction; * @date May 25, 2001 */ -public class SystemException extends java.lang.Exception +public class SystemException extends Exception { public int errorCode; diff --git a/libjava/javax/transaction/Transaction.java b/libjava/javax/transaction/Transaction.java index 632707c6ccc..11aca01211e 100644 --- a/libjava/javax/transaction/Transaction.java +++ b/libjava/javax/transaction/Transaction.java @@ -1,12 +1,43 @@ -/* Copyright (C) 2001 Free Software Foundation +/* Transaction.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; + import javax.transaction.xa.XAResource; /** @@ -14,20 +45,26 @@ import javax.transaction.xa.XAResource; * @date May 25, 2001 */ -public abstract interface Transaction +public interface Transaction { public void commit() throws RollbackException, HeuristicMixedException, - HeuristicRollbackException, java.lang.SecurityException, SystemException; + HeuristicRollbackException, SecurityException, SystemException; + public boolean delistResource(XAResource xaRes, int flag) - throws java.lang.IllegalStateException, SystemException; + throws IllegalStateException, SystemException; + public boolean enlistResource(XAResource xaRes) - throws RollbackException, java.lang.IllegalStateException, SystemException; + throws RollbackException, IllegalStateException, SystemException; + public int getStatus() throws SystemException; + public void registerSynchronization(Synchronization sync) - throws RollbackException, java.lang.IllegalStateException, SystemException; + throws RollbackException, IllegalStateException, SystemException; + public void rollback() - throws java.lang.IllegalStateException, SystemException; + throws IllegalStateException, SystemException; + public void setRollbackOnly() - throws java.lang.IllegalStateException, SystemException; + throws IllegalStateException, SystemException; } diff --git a/libjava/javax/transaction/TransactionManager.java b/libjava/javax/transaction/TransactionManager.java index 9f5f57cb351..e0501afb1c5 100644 --- a/libjava/javax/transaction/TransactionManager.java +++ b/libjava/javax/transaction/TransactionManager.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* TransactionManager.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,23 +43,30 @@ package javax.transaction; * @date May 25, 2001 */ -public abstract interface TransactionManager +public interface TransactionManager { public void begin() throws NotSupportedException, SystemException; + public void commit() throws RollbackException, HeuristicMixedException, - HeuristicRollbackException, java.lang.SecurityException, - java.lang.IllegalStateException, SystemException; + HeuristicRollbackException, SecurityException, + IllegalStateException, SystemException; + public int getStatus() throws SystemException; + public Transaction getTransaction() throws SystemException; + public void resume(Transaction tobj) - throws InvalidTransactionException, java.lang.IllegalStateException, + throws InvalidTransactionException, IllegalStateException, SystemException; + public void rollback() - throws java.lang.IllegalStateException, java.lang.SecurityException, - SystemException; + throws IllegalStateException, SecurityException, SystemException; + public void setRollbackOnly() - throws java.lang.IllegalStateException, SystemException; + throws IllegalStateException, SystemException; + public void setTransactionTimeout(int seconds) throws SystemException; + public Transaction suspend() throws SystemException; } diff --git a/libjava/javax/transaction/TransactionRequiredException.java b/libjava/javax/transaction/TransactionRequiredException.java index e845a9ff0eb..ebc5679d941 100644 --- a/libjava/javax/transaction/TransactionRequiredException.java +++ b/libjava/javax/transaction/TransactionRequiredException.java @@ -1,11 +1,40 @@ -/* Copyright (C) 2001 Free Software Foundation +/* TransactionRequiredException -- + Copyright (C) 2001, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +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 javax.transaction; import java.rmi.RemoteException; diff --git a/libjava/javax/transaction/TransactionRolledbackException.java b/libjava/javax/transaction/TransactionRolledbackException.java index 96dd8dda1b0..ef4f1cc2641 100644 --- a/libjava/javax/transaction/TransactionRolledbackException.java +++ b/libjava/javax/transaction/TransactionRolledbackException.java @@ -1,11 +1,40 @@ -/* Copyright (C) 2001 Free Software Foundation +/* TransactionRolledbackException -- + Copyright (C) 2001, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +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 javax.transaction; import java.rmi.RemoteException; diff --git a/libjava/javax/transaction/UserTransaction.java b/libjava/javax/transaction/UserTransaction.java index eb02a6c4f23..fe8aad78a62 100644 --- a/libjava/javax/transaction/UserTransaction.java +++ b/libjava/javax/transaction/UserTransaction.java @@ -1,11 +1,41 @@ -/* Copyright (C) 2001 Free Software Foundation +/* UserTransaction.java -- + Copyright (C) 2001, 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. */ - This file is part of libgcj. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - package javax.transaction; /** @@ -13,18 +43,22 @@ package javax.transaction; * @date May 25, 2001 */ -public abstract interface UserTransaction +public interface UserTransaction { public void begin() throws NotSupportedException, SystemException; + public void commit() throws RollbackException, HeuristicMixedException, - HeuristicRollbackException, java.lang.SecurityException, - java.lang.IllegalStateException, SystemException; + HeuristicRollbackException, SecurityException, + IllegalStateException, SystemException; + public void rollback() - throws java.lang.IllegalStateException, java.lang.SecurityException, - SystemException; + throws IllegalStateException, SecurityException, SystemException; + public void setRollbackOnly() - throws java.lang.IllegalStateException, SystemException; + throws IllegalStateException, SystemException; + public int getStatus() throws SystemException; + public void setTransactionTimeout(int seconds) throws SystemException; } diff --git a/libjava/javax/transaction/xa/XAException.java b/libjava/javax/transaction/xa/XAException.java index 43ede1d93da..48c7ca8126d 100644 --- a/libjava/javax/transaction/xa/XAException.java +++ b/libjava/javax/transaction/xa/XAException.java @@ -1,11 +1,40 @@ -/* Copyright (C) 2001 Free Software Foundation +/* XAException.java -- + Copyright (C) 2001, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +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 javax.transaction.xa; /** diff --git a/libjava/javax/transaction/xa/XAResource.java b/libjava/javax/transaction/xa/XAResource.java index 226850ce35e..038923fded5 100644 --- a/libjava/javax/transaction/xa/XAResource.java +++ b/libjava/javax/transaction/xa/XAResource.java @@ -1,11 +1,40 @@ -/* Copyright (C) 2001 Free Software Foundation +/* XAResource.java -- + Copyright (C) 2001, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +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 javax.transaction.xa; /** @@ -13,7 +42,7 @@ package javax.transaction.xa; * @date May 25, 2001 */ -public abstract interface XAResource +public interface XAResource { public static final int TMENDRSCAN = 8388608; public static final int TMFAIL = 536870912; diff --git a/libjava/javax/transaction/xa/Xid.java b/libjava/javax/transaction/xa/Xid.java index 2edf0c52c57..d509ccfaf47 100644 --- a/libjava/javax/transaction/xa/Xid.java +++ b/libjava/javax/transaction/xa/Xid.java @@ -1,11 +1,40 @@ -/* Copyright (C) 2001 Free Software Foundation +/* Xid.java -- + Copyright (C) 2001, 2002 Free Software Foundation, Inc. - This file is part of libgcj. +This file is part of GNU Classpath. -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ +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 javax.transaction.xa; /** @@ -13,7 +42,7 @@ package javax.transaction.xa; * @date May 25, 2001 */ -public abstract interface Xid +public interface Xid { public static final int MAXGTRIDSIZE = 64; public static final int MAXBQUALSIZE = 64; diff --git a/libjava/jni.cc b/libjava/jni.cc index 44ea4118f89..b841b4fc481 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -428,13 +428,14 @@ static jint } static jclass -(JNICALL _Jv_JNI_DefineClass) (JNIEnv *env, jobject loader, +(JNICALL _Jv_JNI_DefineClass) (JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize bufLen) { try { loader = unwrap (loader); + jstring sname = JvNewStringUTF (name); jbyteArray bytes = JvNewByteArray (bufLen); jbyte *elts = elements (bytes); @@ -443,7 +444,7 @@ static jclass java::lang::ClassLoader *l = reinterpret_cast (loader); - jclass result = l->defineClass (bytes, 0, bufLen); + jclass result = l->defineClass (sname, bytes, 0, bufLen); return (jclass) wrap_value (env, result); } catch (jthrowable t) diff --git a/libjava/prims.cc b/libjava/prims.cc index 76c25877b7d..2195db161e1 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -397,7 +397,7 @@ _Jv_AllocObject (jclass klass, jint size) // if there really is an interesting finalizer. // Unfortunately, we still have to the dynamic test, since there may // be cni calls to this routine. - // Nore that on IA64 get_finalizer() returns the starting address of the + // Note that on IA64 get_finalizer() returns the starting address of the // function, not a function pointer. Thus this still works. if (klass->vtable->get_finalizer () != java::lang::Object::class$.vtable->get_finalizer ()) @@ -458,8 +458,8 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init) size_t size = (size_t) elements (obj); size += count * sizeof (jobject); - // FIXME: second argument should be "current loader" - jclass klass = _Jv_GetArrayClass (elementClass, 0); + jclass klass = _Jv_GetArrayClass (elementClass, + elementClass->getClassLoaderInternal()); obj = (jobjectArray) _Jv_AllocArray (size, klass); // Cast away const. @@ -920,11 +920,11 @@ _Jv_CreateJavaVM (void* /*vm_args*/) arithexception = new java::lang::ArithmeticException (JvNewStringLatin1 ("/ by zero")); #endif - + no_memory = new java::lang::OutOfMemoryError; - + java::lang::VMThrowable::trace_enabled = 1; - + #ifdef USE_LTDL LTDL_SET_PRELOADED_SYMBOLS (); #endif diff --git a/libjava/resolve.cc b/libjava/resolve.cc index e9fe4ad5af2..e195c333cc8 100644 --- a/libjava/resolve.cc +++ b/libjava/resolve.cc @@ -363,13 +363,6 @@ _Jv_SearchMethodInClass (jclass cls, jclass klass, return 0; } -/* this is installed in place of abstract methods */ -static void -_Jv_abstractMethodError () -{ - throw new java::lang::AbstractMethodError; -} - void _Jv_PrepareClass(jclass klass) { diff --git a/libjava/testsuite/ChangeLog b/libjava/testsuite/ChangeLog index 1e5ce888962..8791dd4ec85 100644 --- a/libjava/testsuite/ChangeLog +++ b/libjava/testsuite/ChangeLog @@ -1,3 +1,40 @@ +2002-12-12 Tom Tromey + + * libjava.loader/loader.exp (gcj_loader_test_one): Use + libjava_prune_warnings. + (gcj_loader_run): Likewise. + * libjava.mauve/mauve.exp (test_mauve): Use + libjava_prune_warnings. + (test_mauve_sim): Likewise. + * libjava.jni/jni.exp (gcj_jni_compile_c_to_so): Use + libjava_prune_warnings. + (gcj_jni_build_header): Likewise. + * lib/libjava.exp (libjava_prune_warnings): New proc. + (gcj_link): Use it. + (test_libjava_from_source): Likewise. + (test_libjava_from_javac): Likewise. + +2002-12-08 Tom Tromey + + Test for PR libgcj/8823: + * libjava.lang/pr8823.java: New file. + * libjava.lang/pr8823.out: New file. + +2002-12-05 Tom Tromey + + * libjava.lang/override.java: New file. + * libjava.lang/override.out: New file. + +2002-12-01 Tom Tromey + + * libjava.jacks/jacks.exp (gcj_jacks_setup_xfail): New function. + (gcj_jacks_parse): Use it; set up xfails. + * libjava.jacks/jacks.xfail: New file. + +2002-12-01 Mark Wielaard + + * libjava.mauve/xfails: Remove Inspector FAILs that now PASS. + 2002-11-21 Tom Tromey For PR java/8676: diff --git a/libjava/testsuite/lib/libjava.exp b/libjava/testsuite/lib/libjava.exp index 3cb6140438d..a807c4c8d60 100644 --- a/libjava/testsuite/lib/libjava.exp +++ b/libjava/testsuite/lib/libjava.exp @@ -10,6 +10,22 @@ if ![info exists tmpdir] { set tmpdir "/tmp" } +# This is like `prune_warnings', but it also prunes away a warning +# from the bytecode front end that we don't care about. +proc libjava_prune_warnings {text} { + set text [prune_warnings $text] + set tlist [split $text \n] + set len [llength $tlist] + for {set i [expr {$len - 1}]} {$i >= 2} {incr i -1} { + if {[string match "*unreachable bytecode*" [lindex $tlist $i]]} { + # Delete this line and the previous two lines. + set tlist [lreplace $tlist [expr {$i - 2}] $i] + incr i -2 + } + } + return [join $tlist \n] +} + # This is like `target_compile' but it does some surgery to work # around stupid DejaGNU bugs. In particular DejaGNU has very poor # quoting, so for instance a `$' will be re-evaluated at spawn time. @@ -421,8 +437,8 @@ proc gcj_link {program main files {options {}}} { eval lappend arguments $options } lappend arguments "additional_flags=--main=$main" - set x [prune_warnings [libjava_tcompile $files $program executable \ - $arguments]] + set x [libjava_prune_warnings \ + [libjava_tcompile $files $program executable $arguments]] if {$x != ""} { verbose "link failure: $x" 2 fail "linking $program" @@ -569,7 +585,7 @@ proc test_libjava_from_source { options srcfile compile_args inpfile resultfile set removeList [list $executable] - set x [prune_warnings \ + set x [libjava_prune_warnings \ [libjava_tcompile $srcfile "$executable" $target $args]] if {[info exists opts(xfail-gcj)]} { setup_xfail *-*-* @@ -683,11 +699,11 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e set jvscan [find_jvscan] verbose "jvscan is $jvscan" set main_name [string trim \ - [prune_warnings \ + [libjava_prune_warnings \ [lindex [local_exec "$jvscan --encoding=UTF-8 $srcfile --print-main" "" "" 300] 1]]] verbose "main name is $main_name" set class_out [string trim \ - [prune_warnings \ + [libjava_prune_warnings \ [lindex [local_exec "$jvscan --encoding=UTF-8 $srcfile --list-class" "" "" 300] 1]]] verbose "class list is $class_out" @@ -765,7 +781,7 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e if {$mode == "compile"} { foreach c_file $class_files { set executable [file rootname [file tail $c_file]].o - set x [prune_warnings \ + set x [libjava_prune_warnings \ [libjava_tcompile $c_file "$executable" $type $args]] lappend removeList $executable if {$x != ""} { @@ -781,7 +797,7 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e set hack "$hack $stupid" } lappend removeList $executable - set x [prune_warnings \ + set x [libjava_prune_warnings \ [libjava_tcompile $hack "$executable" $type $args]] } if {[info exists opts(xfail-byte)]} { diff --git a/libjava/testsuite/libjava.jacks/jacks.exp b/libjava/testsuite/libjava.jacks/jacks.exp index 4e49503ec92..b7f87eb6316 100644 --- a/libjava/testsuite/libjava.jacks/jacks.exp +++ b/libjava/testsuite/libjava.jacks/jacks.exp @@ -1,6 +1,17 @@ # Run the Jacks test suite. # See http://www-124.ibm.com/developerworks/oss/cvs/jikes/~checkout~/jacks/jacks.html +proc gcj_jacks_setup_xfail {ary} { + upvar $ary array + global srcdir + + set fd [open $srcdir/libjava.jacks/jacks.xfail] + while {! [eof $fd]} { + set array([gets $fd]) {} + } + close $fd +} + proc gcj_jacks_write {filename} { global GCJ_UNDER_TEST @@ -29,14 +40,21 @@ proc gcj_jacks_parse {file} { return } + verbose "Reading jacks.xfail" + gcj_jacks_setup_xfail xfails + while {! [eof $fd]} { set line [gets $fd] if {[string match RESULT* $line]} { set linelist [split $line] + set test [lindex $linelist 1] + if {[info exists xfails($test)]} { + setup_xfail "*-*-*" + } if {[lindex $linelist 2] == "PASSED"} { - pass [lindex $linelist 1] + pass $test } else { - fail [lindex $linelist 1] + fail $test } } } diff --git a/libjava/testsuite/libjava.jacks/jacks.xfail b/libjava/testsuite/libjava.jacks/jacks.xfail index 1bb25df7fbf..8e2ebe77f0e 100644 --- a/libjava/testsuite/libjava.jacks/jacks.xfail +++ b/libjava/testsuite/libjava.jacks/jacks.xfail @@ -151,8 +151,12 @@ 8.1.2-enclosing-4 8.1.2-enclosing-5 8.1.3-object-3 -8.1.3-superclass-5 -8.1.3-superclass-6 +8.1.3-superclass-10 +8.1.3-superclass-12 +8.1.3-superclass-13 +8.1.4-superinterface-8 +8.1.4-superinterface-10 +8.1.4-superinterface-11 8.2-accessibility-inherited-member-5 8.8.5.1-example-1 8.8.5.1-example-3 @@ -214,14 +218,9 @@ 8.6-checked-exception-10 8.6-checked-exception-11 8.6-checked-exception-12 -8.6-complete-1 -8.6-complete-4 -8.6-complete-5 8.6-abrupt-1 8.6-abrupt-4 -8.5-inheritance-1 -8.5-inheritance-2 -8.5-inheritance-3 +8.5-inheritance-4 8.5-inheritance-6 8.5.2-non-static-member-usage-2 8.4.6-miranda-2 @@ -263,8 +262,6 @@ 8.4.3-bad-1 8.4.3-bad-2 8.7-abrupt-1 -8.7-complete-1 -8.7-complete-3 5.1.3-dti-1 5.1.3-dti-2 5.1.3-fti-1 @@ -451,7 +448,7 @@ 15.9.1-unqualified-concrete-6 15.9.1-unqualified-concrete-7 15.9.1-unqualified-concrete-10 -15.9.1-unqualified-concrete-14 +15.9.1-unqualified-concrete-15 15.9.1-qualified-concrete-6 15.9.1-qualified-concrete-7 15.9.1-qualified-concrete-10 @@ -459,7 +456,7 @@ 15.9.1-qualified-concrete-14 15.9.1-qualified-concrete-16 15.9.1-qualified-concrete-20 -15.9.1-qualified-concrete-24 +15.9.1-qualified-concrete-23 15.28-primitive-9 15.28-primitive-15 15.28-primitive-16 @@ -604,6 +601,9 @@ 9.1.1-in-interface-3 9.1.1-in-interface-9 9.1.1-in-interface-16 +9.1.2-interface-3 +9.1.2-interface-5 +9.1.2-interface-6 9.1.2-supertype-1 9.2-implicit-2 9.2-implicit-3 @@ -680,6 +680,10 @@ 6.6.2.1-protected-instance-method-6 6.6.2.1-protected-instance-method-7 6.6.2.1-protected-type-2 +6.6.2.1-protected-type-4 +6.6.2.1-protected-type-5 +6.6.2.1-protected-type-7 +6.6.2.1-protected-type-8 6.6.1-8 6.6.1-11 6.6.1-array-2 @@ -707,14 +711,14 @@ 6.5.6.1-local-4 6.5.6.1-field-6 6.5.6.1-explicit-constructor-2 +6.5.4.2-qualified-1 6.5.4.1-simple-6 -6.5.4.1-simple-10 -6.5.4.1-simple-11 +6.5.4.1-simple-8 6.5.1-type-15 6.5.1-type-16 6.5.1-type-19 +6.5.1-typeorpackage-1 6.5.1-typeorpackage-2 -6.5.5.2-type-4 6.5.5.2-type-5 6.5.5.2-type-6 6.5.5.2-type-7 @@ -729,10 +733,9 @@ 6.5.5.1-nested-19 6.5.5.1-nested-20 6.5.5.1-nested-21 +6.5.5.1-nested-22 6.5.5.1-nested-23 6.3-1 -7.4.2-subpackage-1 -7.4.2-subpackage-2 7.5.1-canonical-3 7.5.1-accessible-1 7.5.1-duplicate-4 @@ -740,6 +743,8 @@ 7.5.2-accessible-1 7.5.2-accessible-3 7.5.2-duplicate-3 +7.1-named-5 +7.1-named-6 7.1-named-7 7.6-unnamed-scope-1 4.5.4-static-1 @@ -800,6 +805,7 @@ non-jls-zip-2 14-runtime-jump-1 14-runtime-jump-2 14.3.1-runtime-3 +14.19.2-runtime-try-1 8.1.2-runtime-1 6.6.1-runtime-privateconstructor-1 8.8.3-runtime-inner-4 @@ -825,11 +831,11 @@ non-jls-zip-2 15.11.1-runtime-static-1 15.11.1-runtime-static-2 15.11.1-runtime-static-3 -15.11.1-runtime-static-4 15.12.3-runtime-mode-1 15.12.3-runtime-mode-2 15.12.3-runtime-mode-3 15.12.3-runtime-mode-4 +15.12.3-runtime-mode-5 15.12.3-runtime-mode-6 15.12.4.1-runtime-static-1 15.12.4.1-runtime-static-2 diff --git a/libjava/testsuite/libjava.jni/jni.exp b/libjava/testsuite/libjava.jni/jni.exp index efd8154eb23..2aec4c9bf8b 100644 --- a/libjava/testsuite/libjava.jni/jni.exp +++ b/libjava/testsuite/libjava.jni/jni.exp @@ -15,7 +15,8 @@ proc gcj_jni_compile_c_to_so {file {options {}}} { # Find jni.h. lappend options "additional_flags=-I$srcdir/../include" - set x [prune_warnings [target_compile $file $soname executable $options]] + set x [libjava_prune_warnings \ + [target_compile $file $soname executable $options]] if {$x != ""} { verbose "target_compile failed: $x" 2 fail "$name.c compilation" @@ -30,7 +31,7 @@ proc gcj_jni_compile_c_to_so {file {options {}}} { proc gcj_jni_build_header {file} { set gcjh [find_gcjh] set file [file rootname $file] - set x [string trim [prune_warnings \ + set x [string trim [libjava_prune_warnings \ [lindex [local_exec "$gcjh -jni $file" "" "" 300] 1]]] if {$x != ""} { verbose "local_exec failed: $x" 2 diff --git a/libjava/testsuite/libjava.loader/loader.exp b/libjava/testsuite/libjava.loader/loader.exp index 6864a5f663a..e306a312c83 100644 --- a/libjava/testsuite/libjava.loader/loader.exp +++ b/libjava/testsuite/libjava.loader/loader.exp @@ -12,7 +12,7 @@ proc gcj_loader_test_one {srcfile} { set errname [file rootname [file tail $srcfile]] set args [libjava_arguments link] lappend args "additional_flags=--main=[file rootname [file tail $srcfile]] $srcdir/$subdir/MyLoader.java $objdir/dummy.o" - set x [prune_warnings \ + set x [libjava_prune_warnings \ [libjava_tcompile $srcfile "$executable" executable $args]] if { $x != "" } { @@ -46,8 +46,8 @@ proc gcj_loader_run {} { set args [libjava_arguments compile] lappend args "additional_flags=--resource $objdir/dummy.class" - set x [prune_warnings \ - [libjava_tcompile "$objdir/dummy.class" "$objdir/dummy.o" object $args]] + set x [libjava_prune_warnings \ + [libjava_tcompile "$objdir/dummy.class" "$objdir/dummy.o" object $args]] if { $x != "" } { verbose "resource compilation failed: $x" 2 diff --git a/libjava/testsuite/libjava.mauve/mauve.exp b/libjava/testsuite/libjava.mauve/mauve.exp index a9a1c98d6ac..1ca2884249c 100644 --- a/libjava/testsuite/libjava.mauve/mauve.exp +++ b/libjava/testsuite/libjava.mauve/mauve.exp @@ -154,7 +154,7 @@ proc test_mauve {} { foreach base {DejaGNUTestHarness gnu/testlet/SimpleTestHarness gnu/testlet/TestHarness gnu/testlet/Testlet gnu/testlet/ResourceNotFoundException gnu/testlet/config} { set file $base.class set obj $base.o - set x [prune_warnings \ + set x [libjava_prune_warnings \ [target_compile [pwd]/$file $obj object $compile_args]] if {$x != ""} then { fail "Compile $obj" @@ -180,7 +180,7 @@ proc test_mauve {} { if {! [file exists $obj]} then { verbose "compiling $obj for test of $class" set srcfile [file rootname $obj].class - set x [prune_warnings \ + set x [libjava_prune_warnings \ [target_compile [pwd]/$srcfile $obj object $compile_args]] if {$x != ""} then { fail "Compile $obj for $class" @@ -195,8 +195,9 @@ proc test_mauve {} { continue } - set x [prune_warnings [target_compile [concat $uses($file) $objlist] \ - $Executable executable $link_args]] + set x [libjava_prune_warnings \ + [target_compile [concat $uses($file) $objlist] \ + $Executable executable $link_args]] if {$x != ""} then { set proc_ok 0 fail "Link for $class" @@ -292,7 +293,7 @@ proc test_mauve_sim {} { gnu/testlet/config} { set file $base.class set obj $base.o - set x [prune_warnings \ + set x [libjava_prune_warnings \ [target_compile [pwd]/$file $obj object $compile_args]] if {$x != ""} then { fail "Compile $obj" @@ -321,7 +322,7 @@ proc test_mauve_sim {} { if {! [file exists $obj]} then { verbose "compiling $obj for test of $class" set srcfile [file rootname $obj].class - set x [prune_warnings \ + set x [libjava_prune_warnings \ [target_compile [pwd]/$srcfile $obj object $compile_args]] if {$x != ""} then { fail "Compile $obj for $class" @@ -357,7 +358,7 @@ proc test_mauve_sim {} { return 0 } - set x [prune_warnings \ + set x [libjava_prune_warnings \ [target_compile gnu/testlet/DejaGNUTestHarness.class \ gnu/testlet/DejaGNUTestHarness.o object $compile_args]] if {$x != ""} then { @@ -366,8 +367,9 @@ proc test_mauve_sim {} { continue } - set x [prune_warnings [target_compile [concat $uses($file) $objlist] \ - $Executable executable $link_args]] + set x [libjava_prune_warnings \ + [target_compile [concat $uses($file) $objlist] \ + $Executable executable $link_args]] if {$x != ""} then { set proc_ok 0 fail "Link for $class" diff --git a/libjava/testsuite/libjava.mauve/xfails b/libjava/testsuite/libjava.mauve/xfails index ff8b9a83920..270c28a0378 100644 --- a/libjava/testsuite/libjava.mauve/xfails +++ b/libjava/testsuite/libjava.mauve/xfails @@ -1,12 +1,3 @@ -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 1) -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 2) -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 4) -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 9) -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 10) -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 12) -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 13) -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 14) -FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 15) FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 16) FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 17) FAIL: gnu.testlet.java.beans.Introspector.jdk11: getBeanInfo (number 19) diff --git a/libjava/verify.cc b/libjava/verify.cc index 29f0f321a7f..dbf80d4bf03 100644 --- a/libjava/verify.cc +++ b/libjava/verify.cc @@ -405,7 +405,7 @@ private: using namespace java::lang; java::lang::ClassLoader *loader - = verifier->current_class->getClassLoader(); + = verifier->current_class->getClassLoaderInternal(); // We might see either kind of name. Sigh. if (data.name->data[0] == 'L' && data.name->data[data.name->length - 1] == ';') @@ -458,8 +458,8 @@ private: if (key < reference_type || k.key < reference_type) return key == k.key; - // The `null' type is convertible to any reference type. - // FIXME: is this correct for THIS? + // The `null' type is convertible to any initialized reference + // type. if (key == null_type || k.key == null_type) return true; @@ -571,7 +571,7 @@ private: if (key == reference_type) return type (_Jv_GetArrayClass (data.klass, - data.klass->getClassLoader ())); + data.klass->getClassLoaderInternal())); else verifier->verify_fail ("internal error in type::to_array()"); } @@ -695,7 +695,7 @@ private: while (arraycount > 0) { java::lang::ClassLoader *loader - = verifier->current_class->getClassLoader(); + = verifier->current_class->getClassLoaderInternal(); k = _Jv_GetArrayClass (k, loader); --arraycount; } @@ -1138,6 +1138,19 @@ private: return t; } + // Pop a reference which is guaranteed to be initialized. MATCH + // doesn't have to be a reference type; in this case this acts like + // pop_type. + type pop_init_ref (type match) + { + type t = pop_raw (); + if (t.isreference () && ! t.isinitialized ()) + verify_fail ("initialized reference required"); + else if (! match.compatible (t, this)) + verify_fail ("incompatible type on stack"); + return t; + } + // Pop a reference type or a return address. type pop_ref_or_return () { @@ -2301,42 +2314,42 @@ private: break; case op_iaload: pop_type (int_type); - push_type (require_array_type (pop_type (reference_type), + push_type (require_array_type (pop_init_ref (reference_type), int_type)); break; case op_laload: pop_type (int_type); - push_type (require_array_type (pop_type (reference_type), + push_type (require_array_type (pop_init_ref (reference_type), long_type)); break; case op_faload: pop_type (int_type); - push_type (require_array_type (pop_type (reference_type), + push_type (require_array_type (pop_init_ref (reference_type), float_type)); break; case op_daload: pop_type (int_type); - push_type (require_array_type (pop_type (reference_type), + push_type (require_array_type (pop_init_ref (reference_type), double_type)); break; case op_aaload: pop_type (int_type); - push_type (require_array_type (pop_type (reference_type), + push_type (require_array_type (pop_init_ref (reference_type), reference_type)); break; case op_baload: pop_type (int_type); - require_array_type (pop_type (reference_type), byte_type); + require_array_type (pop_init_ref (reference_type), byte_type); push_type (int_type); break; case op_caload: pop_type (int_type); - require_array_type (pop_type (reference_type), char_type); + require_array_type (pop_init_ref (reference_type), char_type); push_type (int_type); break; case op_saload: pop_type (int_type); - require_array_type (pop_type (reference_type), short_type); + require_array_type (pop_init_ref (reference_type), short_type); push_type (int_type); break; case op_istore: @@ -2387,42 +2400,42 @@ private: case op_iastore: pop_type (int_type); pop_type (int_type); - require_array_type (pop_type (reference_type), int_type); + require_array_type (pop_init_ref (reference_type), int_type); break; case op_lastore: pop_type (long_type); pop_type (int_type); - require_array_type (pop_type (reference_type), long_type); + require_array_type (pop_init_ref (reference_type), long_type); break; case op_fastore: pop_type (float_type); pop_type (int_type); - require_array_type (pop_type (reference_type), float_type); + require_array_type (pop_init_ref (reference_type), float_type); break; case op_dastore: pop_type (double_type); pop_type (int_type); - require_array_type (pop_type (reference_type), double_type); + require_array_type (pop_init_ref (reference_type), double_type); break; case op_aastore: pop_type (reference_type); pop_type (int_type); - require_array_type (pop_type (reference_type), reference_type); + require_array_type (pop_init_ref (reference_type), reference_type); break; case op_bastore: pop_type (int_type); pop_type (int_type); - require_array_type (pop_type (reference_type), byte_type); + require_array_type (pop_init_ref (reference_type), byte_type); break; case op_castore: pop_type (int_type); pop_type (int_type); - require_array_type (pop_type (reference_type), char_type); + require_array_type (pop_init_ref (reference_type), char_type); break; case op_sastore: pop_type (int_type); pop_type (int_type); - require_array_type (pop_type (reference_type), short_type); + require_array_type (pop_init_ref (reference_type), short_type); break; case op_pop: pop32 (); @@ -2760,7 +2773,7 @@ private: invalidate_pc (); break; case op_areturn: - check_return_type (pop_type (reference_type)); + check_return_type (pop_init_ref (reference_type)); invalidate_pc (); break; case op_return: @@ -2842,7 +2855,7 @@ private: // This is only used for verifying the byte for // invokeinterface. nargs -= arg_types[i].depth (); - pop_type (arg_types[i]); + pop_init_ref (arg_types[i]); } if (opcode == op_invokeinterface @@ -2859,7 +2872,15 @@ private: } type raw = pop_raw (); bool ok = false; - if (t.compatible (raw, this)) + if (! is_init && ! raw.isinitialized ()) + { + // This is a failure. + } + else if (is_init && raw.isnull ()) + { + // Another failure. + } + else if (t.compatible (raw, this)) { ok = true; } @@ -2915,7 +2936,7 @@ private: break; case op_arraylength: { - type t = pop_type (reference_type); + type t = pop_init_ref (reference_type); if (! t.isarray () && ! t.isnull ()) verify_fail ("array type expected"); push_type (int_type); @@ -2926,19 +2947,19 @@ private: invalidate_pc (); break; case op_checkcast: - pop_type (reference_type); + pop_init_ref (reference_type); push_type (check_class_constant (get_ushort ())); break; case op_instanceof: - pop_type (reference_type); + pop_init_ref (reference_type); check_class_constant (get_ushort ()); push_type (int_type); break; case op_monitorenter: - pop_type (reference_type); + pop_init_ref (reference_type); break; case op_monitorexit: - pop_type (reference_type); + pop_init_ref (reference_type); break; case op_wide: { @@ -2972,7 +2993,7 @@ private: set_variable (get_ushort (), pop_type (double_type)); break; case op_astore: - set_variable (get_ushort (), pop_type (reference_type)); + set_variable (get_ushort (), pop_init_ref (reference_type)); break; case op_ret: handle_ret_insn (get_short ()); -- cgit v1.2.3