aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/awt/AWTEvent.java25
-rw-r--r--libjava/java/awt/AWTException.java27
-rw-r--r--libjava/java/awt/BorderLayout.java46
-rw-r--r--libjava/java/awt/Color.java90
-rw-r--r--libjava/java/awt/Component.java98
-rw-r--r--libjava/java/awt/Container.java59
-rw-r--r--libjava/java/awt/Dimension.java78
-rw-r--r--libjava/java/awt/Event.java155
-rw-r--r--libjava/java/awt/Font.java90
-rw-r--r--libjava/java/awt/Frame.java59
-rw-r--r--libjava/java/awt/Graphics.java29
-rw-r--r--libjava/java/awt/Image.java29
-rw-r--r--libjava/java/awt/LayoutManager.java20
-rw-r--r--libjava/java/awt/LayoutManager2.java20
-rw-r--r--libjava/java/awt/Menu.java33
-rw-r--r--libjava/java/awt/MenuBar.java47
-rw-r--r--libjava/java/awt/MenuComponent.java15
-rw-r--r--libjava/java/awt/MenuContainer.java27
-rw-r--r--libjava/java/awt/MenuItem.java25
-rw-r--r--libjava/java/awt/Paint.java30
-rw-r--r--libjava/java/awt/PaintContext.java28
-rw-r--r--libjava/java/awt/Point.java65
-rw-r--r--libjava/java/awt/Rectangle.java35
-rw-r--r--libjava/java/awt/Shape.java23
-rw-r--r--libjava/java/awt/TextArea.java49
-rw-r--r--libjava/java/awt/TextComponent.java38
-rw-r--r--libjava/java/awt/Toolkit.java32
-rw-r--r--libjava/java/awt/Transparency.java29
-rw-r--r--libjava/java/awt/Window.java29
-rw-r--r--libjava/java/awt/event/ActionEvent.java35
-rw-r--r--libjava/java/awt/event/ActionListener.java21
-rw-r--r--libjava/java/awt/event/ComponentEvent.java20
-rw-r--r--libjava/java/awt/event/InputEvent.java22
-rw-r--r--libjava/java/awt/event/KeyEvent.java38
-rw-r--r--libjava/java/awt/event/KeyListener.java23
-rw-r--r--libjava/java/awt/event/TextEvent.java20
-rw-r--r--libjava/java/awt/event/TextListener.java22
-rw-r--r--libjava/java/awt/event/WindowAdapter.java27
-rw-r--r--libjava/java/awt/event/WindowEvent.java19
-rw-r--r--libjava/java/awt/event/WindowListener.java27
-rw-r--r--libjava/java/awt/geom/Dimension2D.java36
-rw-r--r--libjava/java/awt/geom/Point2D.java69
-rw-r--r--libjava/java/awt/natToolkit.cc27
-rw-r--r--libjava/java/awt/peer/ComponentPeer.java23
-rw-r--r--libjava/java/awt/peer/ContainerPeer.java15
-rw-r--r--libjava/java/awt/peer/FramePeer.java16
-rw-r--r--libjava/java/awt/peer/WindowPeer.java15
-rw-r--r--libjava/java/io/BufferedInputStream.java168
-rw-r--r--libjava/java/io/BufferedOutputStream.java79
-rw-r--r--libjava/java/io/BufferedReader.java373
-rw-r--r--libjava/java/io/BufferedWriter.java129
-rw-r--r--libjava/java/io/ByteArrayInputStream.java113
-rw-r--r--libjava/java/io/ByteArrayOutputStream.java108
-rw-r--r--libjava/java/io/CharArrayReader.java152
-rw-r--r--libjava/java/io/CharArrayWriter.java122
-rw-r--r--libjava/java/io/CharConversionException.java34
-rw-r--r--libjava/java/io/DataInput.java41
-rw-r--r--libjava/java/io/DataInputStream.java289
-rw-r--r--libjava/java/io/DataOutput.java44
-rw-r--r--libjava/java/io/DataOutputStream.java165
-rw-r--r--libjava/java/io/EOFException.java34
-rw-r--r--libjava/java/io/File.java358
-rw-r--r--libjava/java/io/FileDescriptor.java89
-rw-r--r--libjava/java/io/FileInputStream.java96
-rw-r--r--libjava/java/io/FileNotFoundException.java34
-rw-r--r--libjava/java/io/FileOutputStream.java93
-rw-r--r--libjava/java/io/FileReader.java35
-rw-r--r--libjava/java/io/FileWriter.java44
-rw-r--r--libjava/java/io/FilenameFilter.java26
-rw-r--r--libjava/java/io/FilterInputStream.java75
-rw-r--r--libjava/java/io/FilterOutputStream.java62
-rw-r--r--libjava/java/io/FilterReader.java72
-rw-r--r--libjava/java/io/FilterWriter.java58
-rw-r--r--libjava/java/io/IOException.java34
-rw-r--r--libjava/java/io/InputStream.java104
-rw-r--r--libjava/java/io/InputStreamReader.java160
-rw-r--r--libjava/java/io/InterruptedIOException.java36
-rw-r--r--libjava/java/io/LineNumberInputStream.java143
-rw-r--r--libjava/java/io/LineNumberReader.java245
-rw-r--r--libjava/java/io/OutputStream.java48
-rw-r--r--libjava/java/io/OutputStreamWriter.java162
-rw-r--r--libjava/java/io/PipedInputStream.java242
-rw-r--r--libjava/java/io/PipedOutputStream.java97
-rw-r--r--libjava/java/io/PipedReader.java210
-rw-r--r--libjava/java/io/PipedWriter.java88
-rw-r--r--libjava/java/io/PrintStream.java302
-rw-r--r--libjava/java/io/PrintWriter.java286
-rw-r--r--libjava/java/io/PushbackInputStream.java124
-rw-r--r--libjava/java/io/PushbackReader.java136
-rw-r--r--libjava/java/io/RandomAccessFile.java247
-rw-r--r--libjava/java/io/Reader.java87
-rw-r--r--libjava/java/io/SequenceInputStream.java110
-rw-r--r--libjava/java/io/Serializable.java21
-rw-r--r--libjava/java/io/StreamTokenizer.java447
-rw-r--r--libjava/java/io/StringBufferInputStream.java83
-rw-r--r--libjava/java/io/StringReader.java139
-rw-r--r--libjava/java/io/StringWriter.java80
-rw-r--r--libjava/java/io/SyncFailedException.java34
-rw-r--r--libjava/java/io/UTFDataFormatException.java34
-rw-r--r--libjava/java/io/UnsupportedEncodingException.java32
-rw-r--r--libjava/java/io/Writer.java67
-rw-r--r--libjava/java/io/natFile.cc272
-rw-r--r--libjava/java/io/natFileDescriptorEcos.cc132
-rw-r--r--libjava/java/io/natFileDescriptorPosix.cc315
-rw-r--r--libjava/java/io/natFileDescriptorWin32.cc250
-rw-r--r--libjava/java/io/natFileWin32.cc210
-rw-r--r--libjava/java/lang/AbstractMethodError.java34
-rw-r--r--libjava/java/lang/ArithmeticException.java32
-rw-r--r--libjava/java/lang/ArrayIndexOutOfBoundsException.java37
-rw-r--r--libjava/java/lang/ArrayStoreException.java32
-rw-r--r--libjava/java/lang/Boolean.java98
-rw-r--r--libjava/java/lang/Byte.java144
-rw-r--r--libjava/java/lang/Character.java286
-rw-r--r--libjava/java/lang/Class.h328
-rw-r--r--libjava/java/lang/Class.java180
-rw-r--r--libjava/java/lang/ClassCastException.java32
-rw-r--r--libjava/java/lang/ClassCircularityError.java34
-rw-r--r--libjava/java/lang/ClassFormatError.java34
-rw-r--r--libjava/java/lang/ClassLoader.java377
-rw-r--r--libjava/java/lang/ClassNotFoundException.java57
-rw-r--r--libjava/java/lang/CloneNotSupportedException.java32
-rw-r--r--libjava/java/lang/Cloneable.java23
-rw-r--r--libjava/java/lang/Comparable.java22
-rw-r--r--libjava/java/lang/Compiler.java53
-rw-r--r--libjava/java/lang/Double.java149
-rw-r--r--libjava/java/lang/EcosProcess.java59
-rw-r--r--libjava/java/lang/Error.java34
-rw-r--r--libjava/java/lang/Exception.java32
-rw-r--r--libjava/java/lang/ExceptionInInitializerError.java50
-rw-r--r--libjava/java/lang/Float.java149
-rw-r--r--libjava/java/lang/IllegalAccessError.java34
-rw-r--r--libjava/java/lang/IllegalAccessException.java32
-rw-r--r--libjava/java/lang/IllegalArgumentException.java32
-rw-r--r--libjava/java/lang/IllegalMonitorStateException.java32
-rw-r--r--libjava/java/lang/IllegalStateException.java32
-rw-r--r--libjava/java/lang/IllegalThreadStateException.java32
-rw-r--r--libjava/java/lang/IncompatibleClassChangeError.java34
-rw-r--r--libjava/java/lang/IndexOutOfBoundsException.java32
-rw-r--r--libjava/java/lang/InstantiationError.java34
-rw-r--r--libjava/java/lang/InstantiationException.java32
-rw-r--r--libjava/java/lang/Integer.java350
-rw-r--r--libjava/java/lang/InternalError.java34
-rw-r--r--libjava/java/lang/InterruptedException.java32
-rw-r--r--libjava/java/lang/LinkageError.java34
-rw-r--r--libjava/java/lang/Long.java361
-rw-r--r--libjava/java/lang/Math.java118
-rw-r--r--libjava/java/lang/NegativeArraySizeException.java32
-rw-r--r--libjava/java/lang/NoClassDefFoundError.java34
-rw-r--r--libjava/java/lang/NoSuchFieldError.java34
-rw-r--r--libjava/java/lang/NoSuchFieldException.java32
-rw-r--r--libjava/java/lang/NoSuchMethodError.java34
-rw-r--r--libjava/java/lang/NoSuchMethodException.java32
-rw-r--r--libjava/java/lang/NullPointerException.java32
-rw-r--r--libjava/java/lang/Number.java39
-rw-r--r--libjava/java/lang/NumberFormatException.java32
-rw-r--r--libjava/java/lang/Object.h74
-rw-r--r--libjava/java/lang/Object.java71
-rw-r--r--libjava/java/lang/OutOfMemoryError.java34
-rw-r--r--libjava/java/lang/PosixProcess.java74
-rw-r--r--libjava/java/lang/Process.java30
-rw-r--r--libjava/java/lang/Runnable.java27
-rw-r--r--libjava/java/lang/Runtime.java143
-rw-r--r--libjava/java/lang/RuntimeException.java32
-rw-r--r--libjava/java/lang/SecurityException.java31
-rw-r--r--libjava/java/lang/SecurityManager.java263
-rw-r--r--libjava/java/lang/Short.java145
-rw-r--r--libjava/java/lang/StackOverflowError.java34
-rw-r--r--libjava/java/lang/String.java307
-rw-r--r--libjava/java/lang/StringBuffer.java273
-rw-r--r--libjava/java/lang/StringIndexOutOfBoundsException.java37
-rw-r--r--libjava/java/lang/System.java166
-rw-r--r--libjava/java/lang/Thread.java299
-rw-r--r--libjava/java/lang/ThreadDeath.java35
-rw-r--r--libjava/java/lang/ThreadGroup.java404
-rw-r--r--libjava/java/lang/Throwable.java161
-rw-r--r--libjava/java/lang/UnknownError.java34
-rw-r--r--libjava/java/lang/UnsatisfiedLinkError.java34
-rw-r--r--libjava/java/lang/UnsupportedOperationException.java32
-rw-r--r--libjava/java/lang/VerifyError.java34
-rw-r--r--libjava/java/lang/VirtualMachineError.java39
-rw-r--r--libjava/java/lang/Void.java30
-rw-r--r--libjava/java/lang/dtoa.c904
-rw-r--r--libjava/java/lang/e_acos.c111
-rw-r--r--libjava/java/lang/e_asin.c120
-rw-r--r--libjava/java/lang/e_atan2.c131
-rw-r--r--libjava/java/lang/e_exp.c167
-rw-r--r--libjava/java/lang/e_fmod.c140
-rw-r--r--libjava/java/lang/e_log.c152
-rw-r--r--libjava/java/lang/e_pow.c312
-rw-r--r--libjava/java/lang/e_rem_pio2.c185
-rw-r--r--libjava/java/lang/e_remainder.c80
-rw-r--r--libjava/java/lang/e_scalb.c55
-rw-r--r--libjava/java/lang/e_sqrt.c452
-rw-r--r--libjava/java/lang/fdlibm.h342
-rw-r--r--libjava/java/lang/ieeefp.h115
-rw-r--r--libjava/java/lang/k_cos.c96
-rw-r--r--libjava/java/lang/k_rem_pio2.c320
-rw-r--r--libjava/java/lang/k_sin.c79
-rw-r--r--libjava/java/lang/k_tan.c132
-rw-r--r--libjava/java/lang/mprec.c958
-rw-r--r--libjava/java/lang/mprec.h401
-rw-r--r--libjava/java/lang/natCharacter.cc284
-rw-r--r--libjava/java/lang/natClass.cc1303
-rw-r--r--libjava/java/lang/natClassLoader.cc611
-rw-r--r--libjava/java/lang/natDouble.cc189
-rw-r--r--libjava/java/lang/natEcosProcess.cc25
-rw-r--r--libjava/java/lang/natFloat.cc43
-rw-r--r--libjava/java/lang/natMath.cc263
-rw-r--r--libjava/java/lang/natObject.cc258
-rw-r--r--libjava/java/lang/natPosixProcess.cc209
-rw-r--r--libjava/java/lang/natRuntime.cc210
-rw-r--r--libjava/java/lang/natString.cc848
-rw-r--r--libjava/java/lang/natSystem.cc389
-rw-r--r--libjava/java/lang/natThread.cc334
-rw-r--r--libjava/java/lang/natThrowable.cc93
-rw-r--r--libjava/java/lang/reflect/AccessibleObject.java53
-rw-r--r--libjava/java/lang/reflect/Array.java78
-rw-r--r--libjava/java/lang/reflect/Constructor.java105
-rw-r--r--libjava/java/lang/reflect/Field.java264
-rw-r--r--libjava/java/lang/reflect/InvocationTargetException.java73
-rw-r--r--libjava/java/lang/reflect/Member.java26
-rw-r--r--libjava/java/lang/reflect/Method.java127
-rw-r--r--libjava/java/lang/reflect/Modifier.java141
-rw-r--r--libjava/java/lang/reflect/natArray.cc347
-rw-r--r--libjava/java/lang/reflect/natConstructor.cc53
-rw-r--r--libjava/java/lang/reflect/natField.cc433
-rw-r--r--libjava/java/lang/reflect/natMethod.cc543
-rw-r--r--libjava/java/lang/s_atan.c181
-rw-r--r--libjava/java/lang/s_ceil.c80
-rw-r--r--libjava/java/lang/s_copysign.c82
-rw-r--r--libjava/java/lang/s_cos.c82
-rw-r--r--libjava/java/lang/s_fabs.c73
-rw-r--r--libjava/java/lang/s_floor.c134
-rw-r--r--libjava/java/lang/s_rint.c87
-rw-r--r--libjava/java/lang/s_scalbn.c104
-rw-r--r--libjava/java/lang/s_sin.c132
-rw-r--r--libjava/java/lang/s_tan.c114
-rw-r--r--libjava/java/lang/sf_rint.c80
-rw-r--r--libjava/java/lang/strtod.c720
-rw-r--r--libjava/java/lang/w_acos.c118
-rw-r--r--libjava/java/lang/w_asin.c121
-rw-r--r--libjava/java/lang/w_atan2.c117
-rw-r--r--libjava/java/lang/w_exp.c136
-rw-r--r--libjava/java/lang/w_fmod.c107
-rw-r--r--libjava/java/lang/w_log.c115
-rw-r--r--libjava/java/lang/w_pow.c231
-rw-r--r--libjava/java/lang/w_remainder.c119
-rw-r--r--libjava/java/lang/w_sqrt.c93
-rw-r--r--libjava/java/math/BigInteger.java2204
-rw-r--r--libjava/java/net/BindException.java35
-rw-r--r--libjava/java/net/ConnectException.java35
-rw-r--r--libjava/java/net/ContentHandler.java29
-rw-r--r--libjava/java/net/ContentHandlerFactory.java27
-rw-r--r--libjava/java/net/DatagramPacket.java175
-rw-r--r--libjava/java/net/DatagramSocket.java202
-rw-r--r--libjava/java/net/DatagramSocketImpl.java62
-rw-r--r--libjava/java/net/FileNameMap.java27
-rw-r--r--libjava/java/net/HttpURLConnection.java174
-rw-r--r--libjava/java/net/InetAddress.java256
-rw-r--r--libjava/java/net/JarURLConnection.java301
-rw-r--r--libjava/java/net/MalformedURLException.java35
-rw-r--r--libjava/java/net/MulticastSocket.java134
-rw-r--r--libjava/java/net/NoRouteToHostException.java35
-rw-r--r--libjava/java/net/PlainDatagramSocketImpl.java112
-rw-r--r--libjava/java/net/PlainSocketImpl.java97
-rw-r--r--libjava/java/net/ProtocolException.java35
-rw-r--r--libjava/java/net/ServerSocket.java114
-rw-r--r--libjava/java/net/Socket.java263
-rw-r--r--libjava/java/net/SocketException.java33
-rw-r--r--libjava/java/net/SocketImpl.java76
-rw-r--r--libjava/java/net/SocketImplFactory.java25
-rw-r--r--libjava/java/net/SocketOptions.java40
-rw-r--r--libjava/java/net/URL.java373
-rw-r--r--libjava/java/net/URLClassLoader.java221
-rw-r--r--libjava/java/net/URLConnection.java454
-rw-r--r--libjava/java/net/URLDecoder.java48
-rw-r--r--libjava/java/net/URLEncoder.java71
-rw-r--r--libjava/java/net/URLStreamHandler.java156
-rw-r--r--libjava/java/net/URLStreamHandlerFactory.java27
-rw-r--r--libjava/java/net/UnknownHostException.java34
-rw-r--r--libjava/java/net/UnknownServiceException.java35
-rw-r--r--libjava/java/net/natInetAddress.cc339
-rw-r--r--libjava/java/net/natPlainDatagramSocketImpl.cc632
-rw-r--r--libjava/java/net/natPlainSocketImpl.cc477
-rw-r--r--libjava/java/security/AlgorithmParameterGeneratorSpi.java25
-rw-r--r--libjava/java/security/DigestException.java32
-rw-r--r--libjava/java/security/GeneralSecurityException.java33
-rw-r--r--libjava/java/security/InvalidAlgorithmParameterException.java33
-rw-r--r--libjava/java/security/InvalidKeyException.java32
-rw-r--r--libjava/java/security/InvalidParameterException.java32
-rw-r--r--libjava/java/security/Key.java29
-rw-r--r--libjava/java/security/KeyException.java32
-rw-r--r--libjava/java/security/KeyPair.java41
-rw-r--r--libjava/java/security/KeyPairGenerator.java86
-rw-r--r--libjava/java/security/KeyPairGeneratorSpi.java26
-rw-r--r--libjava/java/security/MessageDigest.java144
-rw-r--r--libjava/java/security/NoSuchAlgorithmException.java22
-rw-r--r--libjava/java/security/NoSuchProviderException.java32
-rw-r--r--libjava/java/security/PrivateKey.java24
-rw-r--r--libjava/java/security/Provider.java53
-rw-r--r--libjava/java/security/PublicKey.java24
-rw-r--r--libjava/java/security/SecureClassLoader.java24
-rw-r--r--libjava/java/security/SecureRandom.java25
-rw-r--r--libjava/java/security/Security.java107
-rw-r--r--libjava/java/security/Signature.java173
-rw-r--r--libjava/java/security/SignatureException.java32
-rw-r--r--libjava/java/security/interfaces/DSAKey.java23
-rw-r--r--libjava/java/security/interfaces/DSAParams.java26
-rw-r--r--libjava/java/security/interfaces/DSAPrivateKey.java28
-rw-r--r--libjava/java/security/interfaces/DSAPublicKey.java28
-rw-r--r--libjava/java/security/interfaces/RSAPrivateCrtKey.java30
-rw-r--r--libjava/java/security/interfaces/RSAPrivateKey.java27
-rw-r--r--libjava/java/security/interfaces/RSAPublicKey.java27
-rw-r--r--libjava/java/security/spec/AlgorithmParameterSpec.java25
-rw-r--r--libjava/java/security/spec/InvalidKeySpecException.java33
-rw-r--r--libjava/java/security/spec/InvalidParameterSpecException.java33
-rw-r--r--libjava/java/security/spec/KeySpec.java25
-rw-r--r--libjava/java/security/spec/RSAPrivateCrtKeySpec.java23
-rw-r--r--libjava/java/security/spec/RSAPrivateKeySpec.java23
-rw-r--r--libjava/java/security/spec/RSAPublicKeySpec.java23
-rw-r--r--libjava/java/text/BreakIterator.java160
-rw-r--r--libjava/java/text/CharacterIterator.java36
-rw-r--r--libjava/java/text/ChoiceFormat.java310
-rw-r--r--libjava/java/text/CollationElementIterator.java79
-rw-r--r--libjava/java/text/CollationKey.java104
-rw-r--r--libjava/java/text/Collator.java135
-rw-r--r--libjava/java/text/DateFormat.java324
-rw-r--r--libjava/java/text/DateFormatSymbols.java283
-rw-r--r--libjava/java/text/DecimalFormat.java986
-rw-r--r--libjava/java/text/DecimalFormatSymbols.java293
-rw-r--r--libjava/java/text/FieldPosition.java65
-rw-r--r--libjava/java/text/Format.java56
-rw-r--r--libjava/java/text/MessageFormat.java544
-rw-r--r--libjava/java/text/NumberFormat.java261
-rw-r--r--libjava/java/text/ParseException.java34
-rw-r--r--libjava/java/text/ParsePosition.java59
-rw-r--r--libjava/java/text/RuleBasedCollator.java366
-rw-r--r--libjava/java/text/SimpleDateFormat.java528
-rw-r--r--libjava/java/text/StringCharacterIterator.java142
-rw-r--r--libjava/java/text/natCollator.cc74
-rw-r--r--libjava/java/util/BitSet.java183
-rw-r--r--libjava/java/util/Calendar.java274
-rw-r--r--libjava/java/util/Collection.java37
-rw-r--r--libjava/java/util/Comparator.java24
-rw-r--r--libjava/java/util/ConcurrentModificationException.java33
-rw-r--r--libjava/java/util/Date.java483
-rw-r--r--libjava/java/util/Dictionary.java34
-rw-r--r--libjava/java/util/EmptyStackException.java27
-rw-r--r--libjava/java/util/Enumeration.java24
-rw-r--r--libjava/java/util/EventListener.java24
-rw-r--r--libjava/java/util/EventObject.java42
-rw-r--r--libjava/java/util/GregorianCalendar.java266
-rw-r--r--libjava/java/util/Hashtable.java398
-rw-r--r--libjava/java/util/Iterator.java25
-rw-r--r--libjava/java/util/List.java47
-rw-r--r--libjava/java/util/ListIterator.java31
-rw-r--r--libjava/java/util/ListResourceBundle.java52
-rw-r--r--libjava/java/util/Locale.java152
-rw-r--r--libjava/java/util/MissingResourceException.java43
-rw-r--r--libjava/java/util/NoSuchElementException.java32
-rw-r--r--libjava/java/util/Observable.java98
-rw-r--r--libjava/java/util/Observer.java24
-rw-r--r--libjava/java/util/Properties.java391
-rw-r--r--libjava/java/util/PropertyResourceBundle.java47
-rw-r--r--libjava/java/util/Random.java148
-rw-r--r--libjava/java/util/ResourceBundle.java207
-rw-r--r--libjava/java/util/SimpleTimeZone.java208
-rw-r--r--libjava/java/util/Stack.java74
-rw-r--r--libjava/java/util/StringTokenizer.java185
-rw-r--r--libjava/java/util/TimeZone.java187
-rw-r--r--libjava/java/util/TooManyListenersException.java32
-rw-r--r--libjava/java/util/Vector.java450
-rw-r--r--libjava/java/util/jar/JarEntry.java39
-rw-r--r--libjava/java/util/jar/JarFile.java56
-rw-r--r--libjava/java/util/jar/JarInputStream.java32
-rw-r--r--libjava/java/util/natGregorianCalendar.cc124
-rw-r--r--libjava/java/util/zip/Adler32.java101
-rw-r--r--libjava/java/util/zip/CRC32.java70
-rw-r--r--libjava/java/util/zip/CheckedInputStream.java80
-rw-r--r--libjava/java/util/zip/CheckedOutputStream.java54
-rw-r--r--libjava/java/util/zip/Checksum.java31
-rw-r--r--libjava/java/util/zip/DataFormatException.java33
-rw-r--r--libjava/java/util/zip/Deflater.java129
-rw-r--r--libjava/java/util/zip/DeflaterOutputStream.java87
-rw-r--r--libjava/java/util/zip/GZIPInputStream.java154
-rw-r--r--libjava/java/util/zip/GZIPOutputStream.java93
-rw-r--r--libjava/java/util/zip/Inflater.java98
-rw-r--r--libjava/java/util/zip/InflaterInputStream.java109
-rw-r--r--libjava/java/util/zip/ZipConstants.java18
-rw-r--r--libjava/java/util/zip/ZipEntry.java160
-rw-r--r--libjava/java/util/zip/ZipException.java33
-rw-r--r--libjava/java/util/zip/ZipFile.java191
-rw-r--r--libjava/java/util/zip/ZipInputStream.java223
-rw-r--r--libjava/java/util/zip/ZipOutputStream.java276
-rw-r--r--libjava/java/util/zip/natDeflater.cc214
-rw-r--r--libjava/java/util/zip/natInflater.cc205
396 files changed, 0 insertions, 52521 deletions
diff --git a/libjava/java/awt/AWTEvent.java b/libjava/java/awt/AWTEvent.java
deleted file mode 100644
index 3d8f6c00c59..00000000000
--- a/libjava/java/awt/AWTEvent.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* A very incomplete placeholder. */
-
-public abstract class AWTEvent extends java.util.EventObject
-{
- protected boolean consumed;
- protected int id;
-
- public int getID() { return id; }
-
- public AWTEvent (Object source, int id)
- {
- super(source);
- this.id = id;
- }
-}
diff --git a/libjava/java/awt/AWTException.java b/libjava/java/awt/AWTException.java
deleted file mode 100644
index 8cc7bff9c2d..00000000000
--- a/libjava/java/awt/AWTException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.awt;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date Tue Apr 4 2000
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class AWTException extends Exception
-{
- public AWTException (String message)
- {
- super (message);
- }
-}
diff --git a/libjava/java/awt/BorderLayout.java b/libjava/java/awt/BorderLayout.java
deleted file mode 100644
index 16700f3fa25..00000000000
--- a/libjava/java/awt/BorderLayout.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* A very incomplete placeholder. */
-
-public class BorderLayout implements LayoutManager2
-{
- int hgap;
- int vgap;
-
- public BorderLayout (int hgap, int vgap)
- {
- this.hgap = hgap;
- this.vgap = vgap;
- }
-
- public void addLayoutComponent (String name, Component comp)
- { /* FIXME */ }
- public void layoutContainer (Container parent)
- { /* FIXME */ }
- public Dimension minimumLayoutSize (Container parent)
- { /* FIXME */ return null; }
- public Dimension preferredLayoutSize (Container parent)
- { /* FIXME */ return null; }
- public void removeLayoutComponent (Component comp)
- { /* FIXME */ }
-
- public void addLayoutComponent (Component comp, Object constraints)
- { /* FIXME */ }
- public float getLayoutAlignmentX (Container target)
- { /* FIXME */ return (float) 0.0; }
- public float getLayoutAlignmentY (Container target)
- { /* FIXME */ return (float) 0.0; }
- public void invalidateLayout (Container target)
- { /* FIXME */ }
- public Dimension maximumLayoutSize (Container target)
- { /* FIXME */ return null; }
-
-}
diff --git a/libjava/java/awt/Color.java b/libjava/java/awt/Color.java
deleted file mode 100644
index 1cc780aa34a..00000000000
--- a/libjava/java/awt/Color.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.awt;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 15, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Stubbed; A very incomplete implementation.
- */
-
-public class Color extends Object implements Paint, java.io.Serializable
-{
- public static final Color white = new Color(0xFFFFFFFF, true);
- public static final Color lightGray = new Color(0xFFC0C0C0, true);
- public static final Color gray = new Color(0xFF808080, true);
- public static final Color darkGray = new Color(0xFF404040, true);
- public static final Color black = new Color(0xFF000000, true);
- public static final Color red = new Color(0xFFFF0000, true);
- public static final Color pink = new Color(0xFFFFAFAF, true);
- public static final Color orange = new Color(0xFFFFC800, true);
- public static final Color yellow = new Color(0xFFFFFF00, true);
- public static final Color green = new Color(0xFF00FF00, true);
- public static final Color magenta = new Color(0xFFFF00FF, true);
- public static final Color cyan = new Color(0xFF00FFFF, true);
- public static final Color blue = new Color(0xFF0000FF, true);
-
- // The internal sRGB representation.
- // Alpha is bits 24-31, if hasalpha is true.
- // Red is bits 16-23; Green is bits 8-15; Blue is bits 0-7.
- private int rgba = 0xFFFFFFFF;
-
- public Color(int rgb)
- {
- this(rgb, false);
- }
-
- public Color(int rgba, boolean hasalpha)
- {
- this.rgba = rgba;
- if (!hasalpha)
- rgba |= 0xFF000000;
- }
-
- public Color(int r, int g, int b)
- {
- this(r, g, b, 0xFF);
- }
-
- public Color(int r, int g, int b, int a)
- {
- rgba = a << 24 | ((r << 16) & 0x00FF0000) | ((g << 8) & 0x0000FF00) |
- (b & 0x000000FF);
- }
-
- public int getRed()
- {
- return (rgba >> 16) & 0xFF;
- }
-
- public int getGreen()
- {
- return (rgba >> 8) & 0xFF;
- }
-
- public int getBlue()
- {
- return rgba & 0xFF;
- }
-
- public int getAlpha()
- {
- return (rgba >> 24) & 0xFF;
- }
-
- public int getRGB()
- {
- return rgba;
- }
-}
diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java
deleted file mode 100644
index 6199a2e7e29..00000000000
--- a/libjava/java/awt/Component.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-import java.awt.event.*;
-//import java.awt.peer.ComponentPeer;
-
-/* A very incomplete placeholder. */
-
-public abstract class Component implements MenuContainer
-{
- Container parent;
- java.awt.peer.ComponentPeer peer;
- int x, y, width, height;
-
- public Container getParent () { return parent; }
-
- /** @deprecated */
- public java.awt.peer.ComponentPeer getPeer () { return peer; }
-
- public void setVisible (boolean b)
- { /* FIXME */ }
-
- public void setSize (Dimension d)
- { setSize(d.width, d.height); }
-
- public void setSize (int width, int height)
- {
- this.width = width; this.height = height;
- if (peer != null)
- peer.setBounds(x, y, width, height);
- }
-
- public void setLocation (int x, int y)
- {
- this.x = x; this.y = y;
- if (peer != null)
- peer.setBounds(x, y, width, height);
- }
-
- public void setLocation (Point pt)
- { setLocation(pt.x, pt.y); }
-
- public void setBounds (int x, int y, int w, int h)
- {
- this.x = x; this.y = y;
- this.width = w; this.height = h;
- if (peer != null)
- peer.setBounds(x, y, w, h);
- }
-
- public void setBounds (Rectangle rect)
- { setBounds(rect.x, rect.y, rect.width, rect.height); }
-
- public Rectangle getBounds ()
- {
- return new Rectangle(x, y, width, height);
- }
-
- public Point getLocation ()
- {
- return new Point(x, y);
- }
-
- public Dimension getSize ()
- {
- return new Dimension(width, height);
- }
-
- public Dimension getMinimumSize ()
- {
- if (peer == null)
- return new Dimension(width, height);
- else
- return peer.getMinimumSize();
- }
-
- public Dimension getPreferredSize ()
- {
- if (peer == null)
- return new Dimension(width, height);
- else
- return peer.getPreferredSize();
- }
-
- public synchronized void addKeyListener (KeyListener listener)
- { /* FIXME */ }
-
- public boolean isFocusTraversable ()
- { /* FIXME */ return false; }
-
- public void addNotify () { }
-}
diff --git a/libjava/java/awt/Container.java b/libjava/java/awt/Container.java
deleted file mode 100644
index 6befa791645..00000000000
--- a/libjava/java/awt/Container.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* A very incomplete placeholder. */
-
-public abstract class Container extends Component
-{
- int componentCount;
- Component[] components;
-
- public Component[] getComponents()
- {
- Component[] result = new Component[componentCount];
- if (componentCount > 0)
- System.arraycopy(components, 0, result, 0, componentCount);
- return result;
- }
-
- public Component getComponent (int n)
- {
- if (n < 0 || n >= componentCount)
- throw new ArrayIndexOutOfBoundsException("no such component");
- return components[n];
- }
-
- public boolean isAncestorOf (Component comp)
- {
- for (;;)
- {
- if (comp == null)
- return false;
- if (comp == this)
- return true;
- comp = comp.getParent();
- }
- }
-
- public Component add (String name, Component comp)
- {
- /* FIXME */
- return comp;
- }
-
- public void addNotify ()
- {
- for (int i = componentCount; --i >= 0; )
- components[i].addNotify();
- }
-
- public void setLayout (LayoutManager layout)
- { /* FIXME */ }
-}
diff --git a/libjava/java/awt/Dimension.java b/libjava/java/awt/Dimension.java
deleted file mode 100644
index 38ba32729cf..00000000000
--- a/libjava/java/awt/Dimension.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary 8, 1999.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct, except that neither toString
- * has not been compared with JDK output.
- */
-
-public class Dimension extends java.awt.geom.Dimension2D
-{
- public int height;
- public int width;
-
- public Dimension () { }
-
- public Dimension (Dimension dim)
- {
- this.width = dim.width;
- this.height = dim.height;
- }
-
- public Dimension (int width, int height)
- {
- this.width = width;
- this.height = height;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof Dimension))
- return false;
- Dimension dim = (Dimension) obj;
- return height == dim.height && width == dim.width;
- }
-
- public Dimension getSize () { return new Dimension(this); }
-
- public void setSize (Dimension dim)
- {
- this.width = dim.width;
- this.height = dim.height;
- }
-
- public void setSize (int width, int height)
- {
- this.width = width;
- this.height = height;
- }
-
- public String toString ()
- {
- return "Dimension[w:"+width+",h:"+height+']';
- }
-
- /* Note: There is no Dimension.hashCode. */
-
- public double getWidth() { return width; }
- public double getHeight() { return height; }
-
- public void setSize (double width, double height)
- {
- this.width = (int) width;
- this.height = (int) height;
- }
-}
diff --git a/libjava/java/awt/Event.java b/libjava/java/awt/Event.java
deleted file mode 100644
index 241e68ee635..00000000000
--- a/libjava/java/awt/Event.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct, except for the paramString()
- * method, which is stubbed.
- */
-
-public class Event
-{
- public static final int SHIFT_MASK = 1,
- CTRL_MASK = 2,
- META_MASK = 4,
- ALT_MASK = 8;
-
- public static final int ACTION_EVENT = 1001,
- BACK_SPACE = 8,
- CAPS_LOCK = 1022,
- DELETE = 127,
- DOWN = 1005,
- END = 1001,
- ENTER = 10,
- ESCAPE = 27,
- F1 = 1008,
- F10 = 1017,
- F11 = 1018,
- F12 = 1019,
- F2 = 1009,
- F3 = 1010,
- F4 = 1011,
- F5 = 1012,
- F6 = 1013,
- F7 = 1014,
- F8 = 1015,
- F9 = 1016,
- GOT_FOCUS = 1004,
- HOME = 1000,
- INSERT = 1025,
- KEY_ACTION = 403,
- KEY_ACTION_RELEASE = 404,
- KEY_PRESS = 401,
- KEY_RELEASE = 402,
- LEFT = 1006,
- LIST_DESELECT = 702,
- LIST_SELECT = 701,
- LOAD_FILE = 1002,
- LOST_FOCUS = 1005,
- MOUSE_DOWN = 501,
- MOUSE_DRAG = 506,
- MOUSE_ENTER = 504,
- MOUSE_EXIT = 505,
- MOUSE_MOVE = 503,
- MOUSE_UP = 502,
- NUM_LOCK = 1023,
- PAUSE = 1024,
- PGDN = 1003,
- PGUP = 1002,
- PRINT_SCREEN = 1020,
- RIGHT = 1007,
- SAVE_FILE = 1003,
- SCROLL_ABSOLUTE = 605,
- SCROLL_BEGIN = 606,
- SCROLL_END = 607,
- SCROLL_LINE_DOWN = 602,
- SCROLL_LINE_UP = 601,
- SCROLL_LOCK = 1021,
- SCROLL_PAGE_DOWN = 604,
- SCROLL_PAGE_UP = 603,
- TAB = 9,
- UP = 1004,
- WINDOW_DEICONIFY = 204,
- WINDOW_DESTROY = 201,
- WINDOW_EXPOSE = 202,
- WINDOW_ICONIFY = 203,
- WINDOW_MOVED = 205;
-
- public Event evt;
- public Object arg;
- public int clickCount;
- public int id;
- public int key;
- public int modifiers;
- public Object target;
- public long when;
- public int x;
- public int y;
-
- public Event (Object target, int id, Object arg)
- {
- this.id = id;
- this.target = target;
- this.arg = arg;
- }
-
- public Event (Object target, long when, int id, int x, int y, int key,
- int modifiers)
- {
- this.target = target;
- this.when = when;
- this.id = id;
- this.x = x;
- this.y = y;
- this.key = key;
- this.modifiers = modifiers;
- }
-
- public Event (Object target, long when, int id, int x, int y, int key,
- int modifiers, Object arg)
- {
- this (target, when, id, x, y, key, modifiers);
- this.arg = arg;
- }
-
- public boolean controlDown ()
- {
- return ((modifiers & CTRL_MASK) == 0 ? false : true);
- }
-
- public boolean metaDown ()
- {
- return ((modifiers & META_MASK) == 0 ? false : true);
- }
-
- protected String paramString ()
- {
- return "Event.paramString() not implemented";
- }
-
- public boolean shiftDown()
- {
- return ((modifiers & SHIFT_MASK) == 0 ? false : true);
- }
-
- public String toString()
- {
- String r = getClass() + "[id=" + id + ",x=" + x + ",y=" + y + "target="
- + ((target == null) ? "null" : target) + "]";
- return r;
- }
-
- public void translate (int x, int y)
- {
- this.x += x;
- this.y += y;
- }
-}
diff --git a/libjava/java/awt/Font.java b/libjava/java/awt/Font.java
deleted file mode 100644
index 9d25342fe7d..00000000000
--- a/libjava/java/awt/Font.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Stubbed; A very incomplete implementation.
- */
-
-public class Font
-{
- // FIXME
-
- public static final int PLAIN = 0;
- public static final int BOLD = 1;
- public static final int ITALIC = 2;
- public static final int ROMAN_BASELINE = 0;
- public static final int CENTER_BASELINE = 1;
- public static final int HANGING_BASELINE = 2;
- protected String name;
- protected int style;
- protected int size;
- protected float pointSize;
-
- public Font(String name, int style, int size)
- {
- this.name = name;
- this.style = style & 0x3; // Only use lowest 2 bits.
- this.size = size;
- pointSize = size; // Assume some subclass can set a different val.
- }
-
- public boolean isPlain()
- {
- if (style == PLAIN)
- return true;
-
- return false;
- }
-
- public boolean isBold()
- {
- if ((style & BOLD) == BOLD)
- return true;
-
- return false;
- }
-
- public boolean isItalic()
- {
- if ((style & ITALIC) == ITALIC)
- return true;
-
- return false;
- }
-
- public String getName()
- {
- return name;
- }
-
- public int getStyle()
- {
- return style;
- }
-
- public int getSize()
- {
- return size;
- }
-
- public float getSize2D()
- {
- return pointSize;
- }
-
- public static Font decode(String str) { return null; } // FIXME
-}
diff --git a/libjava/java/awt/Frame.java b/libjava/java/awt/Frame.java
deleted file mode 100644
index 0d0acf9c380..00000000000
--- a/libjava/java/awt/Frame.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-import java.awt.peer.FramePeer;
-
-/* A very incomplete placeholder. */
-
-public class Frame extends Window implements MenuContainer
-{
- MenuBar menuBar = null;
- String title;
-
- public Frame ()
- { /* FIXME */ }
-
- public Frame (String title)
- {
- this();
- setTitle(title);
- }
-
- public String getTitle () { return title; }
-
- public void setTitle (String title)
- {
- this.title = title;
- if (peer != null)
- ((FramePeer)peer).setTitle(title);
- }
-
- public synchronized void dispose ()
- { /* FIXME */ }
-
- public synchronized void setMenuBar (MenuBar menuBar)
- { this.menuBar = menuBar; }
-
- public synchronized void addNotify ()
- {
- if (peer == null)
- {
- FramePeer fpeer = Toolkit.getDefaultToolkit().createFrame(this);
- // Compiler bug requires cast ??; FIXME?
- peer = (java.awt.peer.ComponentPeer) fpeer;
- if (width + height > 0)
- peer.setBounds(x, y, width, height);
- }
- super.addNotify();
- }
-
- public Font getFont() { return null; } // FIXME
- public boolean postEvent(Event evt) { return false; } // FIXME
- public void remove(MenuComponent comp) { } // FIXME
-}
diff --git a/libjava/java/awt/Graphics.java b/libjava/java/awt/Graphics.java
deleted file mode 100644
index 8b11f812113..00000000000
--- a/libjava/java/awt/Graphics.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.awt;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 15, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Stubbed; A very incomplete placeholder.
- */
-
-public abstract class Graphics extends Object
-{
- protected Graphics()
- {
- super(); // ???
- throw new Error ("java.awt.Graphics: not implemented");
- }
-}
diff --git a/libjava/java/awt/Image.java b/libjava/java/awt/Image.java
deleted file mode 100644
index 75ddd2e9a00..00000000000
--- a/libjava/java/awt/Image.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.awt;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 15, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Stubbed; A very incomplete placeholder.
- */
-
-public abstract class Image extends Object
-{
- public Image()
- {
- super(); // ???
- throw new Error("java.awt.Image: not implemented");
- }
-}
diff --git a/libjava/java/awt/LayoutManager.java b/libjava/java/awt/LayoutManager.java
deleted file mode 100644
index 671596ec371..00000000000
--- a/libjava/java/awt/LayoutManager.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* Status: Believed complete and correct. */
-
-public interface LayoutManager
-{
- public void addLayoutComponent (String name, Component comp);
- public void layoutContainer (Container parent);
- public Dimension minimumLayoutSize (Container parent);
- public Dimension preferredLayoutSize (Container parent);
- public void removeLayoutComponent (Component comp);
-}
diff --git a/libjava/java/awt/LayoutManager2.java b/libjava/java/awt/LayoutManager2.java
deleted file mode 100644
index a79d64e85fa..00000000000
--- a/libjava/java/awt/LayoutManager2.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* Status: Believed complete and correct. */
-
-public interface LayoutManager2 extends LayoutManager
-{
- public void addLayoutComponent (Component comp, Object constraints);
- public float getLayoutAlignmentX (Container target);
- public float getLayoutAlignmentY (Container target);
- public void invalidateLayout (Container target);
- public Dimension maximumLayoutSize (Container target);
-}
diff --git a/libjava/java/awt/Menu.java b/libjava/java/awt/Menu.java
deleted file mode 100644
index af1c4c8dbd4..00000000000
--- a/libjava/java/awt/Menu.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* A very incomplete placeholder. */
-
-public class Menu extends MenuItem implements MenuContainer
-{
- public Menu (String label)
- {
- super(label); // ???
- throw new Error ("java.awt.Menu: not implemented");
- }
-
- public void add (String label)
- { /* FIXME */ }
-
- public synchronized MenuItem add (MenuItem item)
- {
- /* FIXME */
- return item;
- }
-
- public Font getFont() { return null; } // FIXME
- public boolean postEvent(Event evt) { return false; } // FIXME
- public void remove(MenuComponent comp) { } // FIXME
-}
diff --git a/libjava/java/awt/MenuBar.java b/libjava/java/awt/MenuBar.java
deleted file mode 100644
index ce7d3bc368f..00000000000
--- a/libjava/java/awt/MenuBar.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* A very incomplete placeholder. */
-
-public class MenuBar extends MenuComponent implements MenuContainer
-{
- Menu[] menus;
- int count;
-
- public synchronized Menu add (Menu m)
- {
- if (menus == null)
- menus = new Menu[1];
- else if (count == menus.length)
- {
- Menu[] newMenus = new Menu[2 * count];
- System.arraycopy(menus, 0, newMenus, 0, count);
- }
- menus[count++] = m;
- return m;
- }
-
- public void remove (MenuComponent comp)
- {
- for (int i = count; --i >= 0; )
- {
- if (menus[i] == comp)
- {
- System.arraycopy(menus, i, menus, i+1, count-i-1);
- count--;
- // FIXME: destroy peer
- return;
- }
- }
- }
-
- public Font getFont() { return null; } // FIXME
- public boolean postEvent(Event evt) { return false; } // FIXME
-}
diff --git a/libjava/java/awt/MenuComponent.java b/libjava/java/awt/MenuComponent.java
deleted file mode 100644
index e18314dd626..00000000000
--- a/libjava/java/awt/MenuComponent.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* A very incomplete placeholder. */
-
-public abstract class MenuComponent
-{
-}
diff --git a/libjava/java/awt/MenuContainer.java b/libjava/java/awt/MenuContainer.java
deleted file mode 100644
index 295e240cc7b..00000000000
--- a/libjava/java/awt/MenuContainer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public interface MenuContainer
-{
- public Font getFont();
-
- /**
- * @deprected
- */
- public boolean postEvent(Event evt);
-
- public void remove(MenuComponent comp);
-}
-
diff --git a/libjava/java/awt/MenuItem.java b/libjava/java/awt/MenuItem.java
deleted file mode 100644
index 2681a20ee12..00000000000
--- a/libjava/java/awt/MenuItem.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-import java.awt.event.*;
-
-/* A very incomplete placeholder. */
-
-public class MenuItem extends MenuComponent
-{
- public MenuItem (String label)
- {
- throw new Error("java.awt.MenuItem: not implemented");
- }
-
- public synchronized void addActionListener (ActionListener listener)
- {
- /* FIXME */
- }
-}
diff --git a/libjava/java/awt/Paint.java b/libjava/java/awt/Paint.java
deleted file mode 100644
index 0836402ef91..00000000000
--- a/libjava/java/awt/Paint.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.awt;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 15, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Stubbed.
- */
-
-public interface Paint extends Transparency
-{
- // FIXME
- // public PaintContext createContext(ColorModel cm,
- // Rectangle deviceBounds,
- // Rectangle2D userBounds,
- // AffineTransform xform,
- // RenderingHints hints);
-}
diff --git a/libjava/java/awt/PaintContext.java b/libjava/java/awt/PaintContext.java
deleted file mode 100644
index 0b4e6a7b0d7..00000000000
--- a/libjava/java/awt/PaintContext.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.awt;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Partially stubbed.
- */
-
-public interface PaintContext
-{
- public void dispose();
- // FIXME
- // public ColorModel getColorModel();
- // public Raster getRaster(int x, int y, int w, int h);
-}
diff --git a/libjava/java/awt/Point.java b/libjava/java/awt/Point.java
deleted file mode 100644
index df8aba51700..00000000000
--- a/libjava/java/awt/Point.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-import java.awt.geom.Point2D;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date February 8, 1999.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct, except that neither toString
- * nor hashCode have been compared with JDK output.
- */
-
-public class Point extends Point2D implements java.io.Serializable
-{
- public int x;
- public int y;
-
- public Point () { }
-
- public Point (Point p) { this.x = p.x; this.y = p.y; }
-
- public Point (int x, int y) { this.x = x; this.y = y; }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof Point))
- return false;
- Point p = (Point) obj;
- return this.x == p.x && this.y == p.y;
- }
-
- public int hashCode () { return x ^ y; }
-
- public Point getLocation () { return new Point(this); }
-
- public void move (int x, int y) { this.x = x; this.y = y; }
-
- public void setLocation (int x, int y) { this.x = x; this.y = y; }
-
- public void setLocation (Point pt) { this.x = pt.x; this.y = pt.y; }
-
- public void translate (int x, int y) { this.x += x; this.y += y; }
-
- public String toString ()
- {
- return "Point[x:"+x+",y:"+y+']';
- }
-
- public double getX() { return x; }
- public double getY() { return y; }
-
- public void setLocation (double x, double y)
- { this.x = (int) x; this.y = (int) y; }
-
-}
diff --git a/libjava/java/awt/Rectangle.java b/libjava/java/awt/Rectangle.java
deleted file mode 100644
index d6c9c5e48ab..00000000000
--- a/libjava/java/awt/Rectangle.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* Status: Quite imcomplete. */
-
-public class Rectangle implements Shape
-{
- public int x;
- public int y;
- public int width;
- public int height;
-
- public Rectangle () { }
-
- public Rectangle (int width, int height)
- { this.width = width; this.height = height; }
-
- public Rectangle (int x, int y, int width, int height)
- {
- this.x = x; this.y = y;
- this.width = width; this.height = height;
- }
-
- public Rectangle getBounds ()
- {
- return new Rectangle (x, y, width, height);
- }
-}
diff --git a/libjava/java/awt/Shape.java b/libjava/java/awt/Shape.java
deleted file mode 100644
index d0f0e0835da..00000000000
--- a/libjava/java/awt/Shape.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary 8, 1999.
- */
-
-/* Written using "Java Class Libraries", 2nd edition.
- * Status: Believed complete and correct.
- */
-
-public interface Shape
-{
- public Rectangle getBounds ();
-}
diff --git a/libjava/java/awt/TextArea.java b/libjava/java/awt/TextArea.java
deleted file mode 100644
index 09f5cb2e348..00000000000
--- a/libjava/java/awt/TextArea.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-
-/* A very incomplete placeholder. */
-
-public class TextArea extends TextComponent
-{
- public synchronized void append (String str)
- {
- replaceRange(str, length, length);
- }
-
- public synchronized void insert (String str, int pos)
- {
- replaceRange(str, pos, pos);
- }
-
- public synchronized void replaceRange (String str, int start, int end)
- {
- if (length == 0)
- setText (str);
- else
- {
- int len = str.length();
- int delta = len - (end - start);
- int new_length = length + delta;
- if (buffer.length < new_length)
- {
- int new_size = 2 * buffer.length;
- if (new_size < new_length)
- new_size = new_length;
- char[] new_buffer = new char[new_size];
- System.arraycopy(buffer, 0, new_buffer, 0, length);
- buffer = new_buffer;
- }
- if (len != end)
- System.arraycopy(buffer, start, buffer, start + len, len - end);
- str.getChars(0, len, buffer, start);
- length += delta;
- }
- }
-}
diff --git a/libjava/java/awt/TextComponent.java b/libjava/java/awt/TextComponent.java
deleted file mode 100644
index 738cc89c7e8..00000000000
--- a/libjava/java/awt/TextComponent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-import java.awt.event.*;
-
-/* A very incomplete placeholder. */
-
-public class TextComponent extends Component
-{
- char[] buffer;
- int length;
- int caretPosition;
-
- public synchronized String getText ()
- { return new String(buffer, 0, length); }
-
- public synchronized void setText (String text)
- {
- length = text.length();
- if (buffer == null || buffer.length < length)
- buffer = new char[length];
- text.getChars(0, length, buffer, 0);
- }
-
- public synchronized void addTextListener (TextListener listener)
- { /* FIXME */ }
-
- public int getCaretPosition () { return caretPosition; }
-
- public void setCaretPosition (int pos) { caretPosition = pos; }
-
-}
diff --git a/libjava/java/awt/Toolkit.java b/libjava/java/awt/Toolkit.java
deleted file mode 100644
index bd1085a0d74..00000000000
--- a/libjava/java/awt/Toolkit.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-import java.awt.peer.*;
-import java.net.URL;
-
-/* A very incomplete placeholder. */
-
-public abstract class Toolkit
-{
- static Toolkit defaultToolkit;
-
- public static synchronized Toolkit getDefaultToolkit()
- {
- if (defaultToolkit == null)
- init();
- return defaultToolkit;
- }
-
- protected abstract FramePeer createFrame(Frame target);
- public abstract Image getImage(URL url);
-
- private static void init() { }
- // private static native void init();
- // static { init(); }
-}
diff --git a/libjava/java/awt/Transparency.java b/libjava/java/awt/Transparency.java
deleted file mode 100644
index c1190069839..00000000000
--- a/libjava/java/awt/Transparency.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.awt;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 15, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public interface Transparency
-{
- public static final int OPAQUE = 1;
- public static final int BITMASK = 2;
- public static final int TRANSLUCENT = 3;
-
- public int getTransparency();
-}
diff --git a/libjava/java/awt/Window.java b/libjava/java/awt/Window.java
deleted file mode 100644
index 4112861f6c6..00000000000
--- a/libjava/java/awt/Window.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt;
-import java.awt.event.WindowListener;
-
-/* A very incomplete placeholder. */
-
-public class Window extends Container
-{
- public void dispose ()
- { /* FIXME */ }
-
- public synchronized void addWindowListener (WindowListener listener)
- { /* FIXME */ }
-
-
- public void show ()
- {
- addNotify();
- // validate FIXME
- // validate setVisible FIXME
- }
-}
diff --git a/libjava/java/awt/event/ActionEvent.java b/libjava/java/awt/event/ActionEvent.java
deleted file mode 100644
index 109673b3569..00000000000
--- a/libjava/java/awt/event/ActionEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-import java.awt.*;
-
-/* A very incomplete placeholder. */
-
-public class ActionEvent extends AWTEvent
-{
- String actionCommand;
- int modifiers;
-
- public ActionEvent (Object source, int id, String command)
- {
- super(source, id);
- actionCommand = command;
- }
-
- public ActionEvent (Object source, int id, String command, int modifiers)
- {
- super(source, id);
- actionCommand = command;
- this.modifiers = modifiers;
- }
-
- public String getActionCommand () { return actionCommand; }
-
- public int getModifiers () { return modifiers; }
-}
diff --git a/libjava/java/awt/event/ActionListener.java b/libjava/java/awt/event/ActionListener.java
deleted file mode 100644
index 7fb359ff076..00000000000
--- a/libjava/java/awt/event/ActionListener.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary, 1999.
- */
-
-/* Status: Believed complete and correct. */
-
-public interface ActionListener extends java.util.EventListener
-{
- public void actionPerformed (ActionEvent e);
-}
diff --git a/libjava/java/awt/event/ComponentEvent.java b/libjava/java/awt/event/ComponentEvent.java
deleted file mode 100644
index 811f72ca59a..00000000000
--- a/libjava/java/awt/event/ComponentEvent.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-import java.awt.*;
-
-/* A very incomplete placeholder. */
-
-public class ComponentEvent extends AWTEvent
-{
- public ComponentEvent (Object source, int id)
- {
- super(source, id);
- }
-}
diff --git a/libjava/java/awt/event/InputEvent.java b/libjava/java/awt/event/InputEvent.java
deleted file mode 100644
index 76bb1a88c76..00000000000
--- a/libjava/java/awt/event/InputEvent.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-
-/* A very incomplete placeholder. */
-
-public class InputEvent extends ComponentEvent
-{
- InputEvent (Object source, int id) // Not public
- {
- super(source, id);
- }
-
- public void consume ()
- { /* FIXME */ }
-}
diff --git a/libjava/java/awt/event/KeyEvent.java b/libjava/java/awt/event/KeyEvent.java
deleted file mode 100644
index 81bc8676694..00000000000
--- a/libjava/java/awt/event/KeyEvent.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-import java.awt.*;
-
-/* A very incomplete placeholder. */
-
-public class KeyEvent extends InputEvent
-{
- int keyCode;
- char keyChar;
- int modifiers;
-
- public KeyEvent (Component source, int id, long when,
- int modifiers, int keyCode, char keyChar)
- {
- super(source, id);
- this.keyCode = keyCode;
- this.keyChar = keyChar;
- this.modifiers = modifiers;
- }
-
- public int getKeyCode () { return keyCode; }
-
- public char getKeyChar () { return keyChar; }
-
- public void setKeyCode (int keyCode) { this.keyCode = keyCode; }
-
- public void setKeyChar (char keyChar) { this.keyChar = keyChar; }
-
- public void setModifiers (int modifiers) { this.modifiers = modifiers; }
-}
diff --git a/libjava/java/awt/event/KeyListener.java b/libjava/java/awt/event/KeyListener.java
deleted file mode 100644
index e08d67e214e..00000000000
--- a/libjava/java/awt/event/KeyListener.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary, 1999.
- */
-
-/* Status: Believed complete and correct. */
-
-public interface KeyListener extends java.util.EventListener
-{
- public void keyPressed (KeyEvent w);
- public void keyReleased (KeyEvent w);
- public void keyTyped (KeyEvent w);
-}
diff --git a/libjava/java/awt/event/TextEvent.java b/libjava/java/awt/event/TextEvent.java
deleted file mode 100644
index 64b53f80061..00000000000
--- a/libjava/java/awt/event/TextEvent.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-import java.awt.*;
-
-/* A very incomplete placeholder. */
-
-public class TextEvent extends AWTEvent
-{
- public TextEvent (Object source, int id)
- {
- super(source, id);
- }
-}
diff --git a/libjava/java/awt/event/TextListener.java b/libjava/java/awt/event/TextListener.java
deleted file mode 100644
index 45c4da898ee..00000000000
--- a/libjava/java/awt/event/TextListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary, 1999.
- */
-
-/* Status: Believed complete and correct. */
-
-public interface TextListener extends java.util.EventListener
-{
- public void textValueChanged (TextEvent w);
-}
-
diff --git a/libjava/java/awt/event/WindowAdapter.java b/libjava/java/awt/event/WindowAdapter.java
deleted file mode 100644
index caf2b18b48f..00000000000
--- a/libjava/java/awt/event/WindowAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary, 1999.
- */
-
-/* Status: Believed complete and correct. */
-
-public class WindowAdapter implements WindowListener
-{
- public void windowActivated (WindowEvent w) { }
- public void windowClosed (WindowEvent w) { }
- public void windowClosing (WindowEvent w) { }
- public void windowDeactivated (WindowEvent w) { }
- public void windowDeiconified (WindowEvent w) { }
- public void windowIconified (WindowEvent w) { }
- public void windowOpened (WindowEvent w) { }
-}
diff --git a/libjava/java/awt/event/WindowEvent.java b/libjava/java/awt/event/WindowEvent.java
deleted file mode 100644
index ac049212321..00000000000
--- a/libjava/java/awt/event/WindowEvent.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-
-/* A very incomplete placeholder. */
-
-public class WindowEvent extends ComponentEvent
-{
- public WindowEvent (Object source, int id)
- {
- super(source, id);
- }
-}
diff --git a/libjava/java/awt/event/WindowListener.java b/libjava/java/awt/event/WindowListener.java
deleted file mode 100644
index e939ce7dcf6..00000000000
--- a/libjava/java/awt/event/WindowListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.event;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary, 1999.
- */
-
-/* Status: Believed complete and correct. */
-
-public interface WindowListener extends java.util.EventListener
-{
- public void windowActivated (WindowEvent w);
- public void windowClosed (WindowEvent w);
- public void windowClosing (WindowEvent w);
- public void windowDeactivated (WindowEvent w);
- public void windowDeiconified (WindowEvent w);
- public void windowIconified (WindowEvent w);
- public void windowOpened (WindowEvent w);
-}
diff --git a/libjava/java/awt/geom/Dimension2D.java b/libjava/java/awt/geom/Dimension2D.java
deleted file mode 100644
index 0814e03f18f..00000000000
--- a/libjava/java/awt/geom/Dimension2D.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.geom;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary, 1999.
- */
-
-/* Written using online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public abstract class Dimension2D implements Cloneable
-{
- public abstract double getWidth();
- public abstract double getHeight();
-
- public abstract void setSize (double width, double height);
-
- public void setSize (Dimension2D dim)
- {
- setSize(dim.getWidth(), dim.getHeight());
- }
-
- public Object clone ()
- {
- return super.clone();
- }
-}
diff --git a/libjava/java/awt/geom/Point2D.java b/libjava/java/awt/geom/Point2D.java
deleted file mode 100644
index c0f2056a8ca..00000000000
--- a/libjava/java/awt/geom/Point2D.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.geom;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date Fenruary 8, 1999.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct, except that neither toString
- * nor hashCode have been compared with JDK output.
- */
-
-public abstract class Point2D implements Cloneable
-{
- public abstract double getX();
- public abstract double getY();
-
- public abstract void setLocation (double x, double y);
-
- public void setLocation (Point2D pt) { setLocation(pt.getX(), pt.getY()); }
-
- static public double distanceSq (double X1, double Y1, double X2, double Y2)
- {
- X2 -= X1;
- Y2 -= Y1;
- return X2*X2 + Y2*Y2;
- }
-
- static public double distance (double X1, double Y1, double X2, double Y2)
- {
- return Math.sqrt(distance(X1, Y1, X2, Y2));
- }
-
- public double distanceSq (double PX, double PY)
- {
- return distanceSq (getX(), PX, getY(), PY);
- }
-
- public double distance (double PX, double PY)
- {
- return distance (getX(), PX, getY(), PY);
- }
-
- public double distanceSq (Point2D pt)
- {
- return distanceSq (getX(), pt.getX(), getY(), pt.getY());
- }
-
- public double distance (Point2D pt)
- {
- return distance (getX(), pt.getX(), getY(), pt.getY());
- }
-
- public int hashCode() { return (int) getX() ^ (int) getY(); }
-
- public Object clone()
- {
- return super.clone();
- }
-}
diff --git a/libjava/java/awt/natToolkit.cc b/libjava/java/awt/natToolkit.cc
deleted file mode 100644
index b2be56c9fbc..00000000000
--- a/libjava/java/awt/natToolkit.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-/*#define ENABLE_GTK*/
-
-#include <gcj/cni.h>
-#include <java/awt/Toolkit.h>
-#ifdef ENABLE_GTK
-#include <java/awt/peer/GtkToolkit.h>
-#endif
-
-void
-java::awt::Toolkit::init()
-{
-#ifdef ENABLE_GTK
- defaultToolkit = new java::awt::peer::GtkToolkit();
-#else
- JvFail("no awt (graphics) toolkit available");
-#endif
-}
diff --git a/libjava/java/awt/peer/ComponentPeer.java b/libjava/java/awt/peer/ComponentPeer.java
deleted file mode 100644
index 806b9623de2..00000000000
--- a/libjava/java/awt/peer/ComponentPeer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.peer;
-import java.awt.*;
-
-/* A very incomplete placeholder. */
-
-public interface ComponentPeer
-{
- public abstract Toolkit getToolkit ();
-
- public Dimension getMinimumSize ();
-
- public Dimension getPreferredSize ();
-
- public void setBounds (int x, int y, int w, int h);
-}
diff --git a/libjava/java/awt/peer/ContainerPeer.java b/libjava/java/awt/peer/ContainerPeer.java
deleted file mode 100644
index c8e459ac0df..00000000000
--- a/libjava/java/awt/peer/ContainerPeer.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.peer;
-
-/* A very incomplete placeholder. */
-
-public interface ContainerPeer extends ComponentPeer
-{
-}
diff --git a/libjava/java/awt/peer/FramePeer.java b/libjava/java/awt/peer/FramePeer.java
deleted file mode 100644
index e68a17f5267..00000000000
--- a/libjava/java/awt/peer/FramePeer.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.peer;
-
-/* A very incomplete placeholder. */
-
-public interface FramePeer extends WindowPeer
-{
- void setTitle(String title);
-}
diff --git a/libjava/java/awt/peer/WindowPeer.java b/libjava/java/awt/peer/WindowPeer.java
deleted file mode 100644
index 109992d64ed..00000000000
--- a/libjava/java/awt/peer/WindowPeer.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.awt.peer;
-
-/* A very incomplete placeholder. */
-
-public interface WindowPeer extends ContainerPeer
-{
-}
diff --git a/libjava/java/io/BufferedInputStream.java b/libjava/java/io/BufferedInputStream.java
deleted file mode 100644
index 6473854456b..00000000000
--- a/libjava/java/io/BufferedInputStream.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 8, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class BufferedInputStream extends FilterInputStream
-{
- /* Internal buffer array for data. */
- protected byte[] buf;
-
- /* Index one greater than the last valid byte in the buffer. */
- protected int count = 0;
-
- /* The current position in the buffer. */
- protected int pos = 0;
-
- /* The value of pos the last time mark() was called. */
- protected int markpos = -1;
-
- /* The maximum read-ahead allowed before calls to reset() fail. */
- protected int marklimit = 0;
-
- public BufferedInputStream(InputStream in)
- {
- this(in, 2048);
- }
-
- public BufferedInputStream(InputStream in, int size)
- {
- super(in);
- if (size <= 0)
- throw new IllegalArgumentException();
- buf = new byte[size];
- }
-
- public synchronized int available() throws IOException
- {
- return count - pos + super.available();
- }
-
- public void close() throws IOException
- {
- // Free up the array memory.
- buf = null;
- super.close();
- }
-
- public synchronized void mark(int readlimit)
- {
- marklimit = readlimit;
- markpos = pos;
- }
-
- public boolean markSupported()
- {
- return true;
- }
-
- public synchronized int read() throws IOException
- {
- if (pos >= count && !refill())
- return -1; // EOF
-
- if (markpos >= 0 && pos - markpos > marklimit)
- markpos = -1;
-
- return ((int) buf[pos++]) & 0xFF;
- }
-
- public synchronized int read(byte[] b, int off, int len) throws IOException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- if (pos >= count && !refill())
- return -1; // No bytes were read before EOF.
-
- int remain = Math.min(count - pos, len);
- System.arraycopy(buf, pos, b, off, remain);
- pos += remain;
-
- if (markpos >= 0 && pos - markpos > marklimit)
- markpos = -1;
-
- return remain;
- }
-
- public synchronized void reset() throws IOException
- {
- if (markpos < 0)
- throw new IOException();
-
- pos = markpos;
- }
-
- public synchronized long skip(long n) throws IOException
- {
- final long origN = n;
-
- while (n > 0L)
- {
- if (pos >= count && !refill())
- if (n < origN)
- break;
- else
- return -1; // No bytes were read before EOF.
-
- int numread = (int) Math.min((long) (count - pos), n);
- pos += numread;
- n -= numread;
-
- if (markpos >= 0 && pos - markpos > marklimit)
- markpos = -1;
- }
-
- return origN - n;
- }
-
- private boolean refill() throws IOException
- {
- if (markpos < 0)
- count = pos = 0;
- else if (markpos > 0)
- {
- // Shift the marked bytes (if any) to the beginning of the array
- // but don't grow it. This saves space in case a reset is done
- // before we reach the max capacity of this array.
- System.arraycopy(buf, markpos, buf, 0, count - markpos);
- count -= markpos;
- pos -= markpos;
- markpos = 0;
- }
- else if (marklimit >= buf.length) // BTW, markpos == 0
- {
- // Need to grow the buffer now to have room for marklimit bytes.
- // Note that the new buffer is one greater than marklimit.
- // This is so that there will be one byte past marklimit to be read
- // before having to call refill again, thus allowing marklimit to be
- // invalidated. That way refill doesn't have to check marklimit.
- byte[] newbuf = new byte[marklimit + 1];
- System.arraycopy(buf, 0, newbuf, 0, count);
- buf = newbuf;
- }
-
- int numread = super.read(buf, count, buf.length - count);
-
- if (numread < 0) // EOF
- return false;
-
- count += numread;
- return true;
- }
-}
diff --git a/libjava/java/io/BufferedOutputStream.java b/libjava/java/io/BufferedOutputStream.java
deleted file mode 100644
index 262c054e205..00000000000
--- a/libjava/java/io/BufferedOutputStream.java
+++ /dev/null
@@ -1,79 +0,0 @@
-// BufferedOutputStream.java - A buffered stream
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public class BufferedOutputStream extends FilterOutputStream
-{
- public BufferedOutputStream (OutputStream ox)
- {
- this (ox, 512);
- }
-
- public BufferedOutputStream (OutputStream ox, int size)
- {
- super (ox);
- buf = new byte[size];
- }
-
- public synchronized void flush () throws IOException
- {
- out.write(buf, 0, count);
- count = 0;
- out.flush();
- }
-
- public synchronized void write (int b) throws IOException
- {
- // Flush output on overflow though JDK (1.2) doc may infer to flush on fill.
- if (count < buf.length)
- buf[count++] = (byte) b;
- else
- {
- out.write(buf, 0, count);
- count = 0;
- out.write(b);
- }
- }
-
- public synchronized void write (byte[] b, int off, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException
- {
- // Flush output on overflow though JDK (1.2) doc may infer to flush on fill.
-
- // If LEN < 0 then the downstream write will fail for us.
- if (len >= 0 && count + len <= buf.length)
- {
- System.arraycopy(b, off, buf, count, len);
- count += len;
- }
- else
- {
- out.write(buf, 0, count);
- count = 0;
- out.write(b, off, len);
- }
- }
-
- // The buffer.
- protected byte[] buf;
- // Number of valid bytes in BUF.
- protected int count;
-}
diff --git a/libjava/java/io/BufferedReader.java b/libjava/java/io/BufferedReader.java
deleted file mode 100644
index 73601deb593..00000000000
--- a/libjava/java/io/BufferedReader.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 22, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class BufferedReader extends Reader
-{
- Reader in;
- char[] buffer;
- /* Index of current read position. Must be >= 0 and <= limit. */
- /* There is a special case where pos may be equal to limit+1; this
- * is used as an indicator that a readLine was done with a '\r' was
- * the very last char in the buffer. Since we don't want to read-ahead
- * and potentially block, we set pos this way to indicate the situation
- * and deal with it later. Doing it this way rather than having a
- * separate boolean field to indicate the condition has the advantage
- * that it is self-clearing on things like mark/reset.
- */
- int pos;
- /* Limit of valid data in buffer. Must be >= pos and <= buffer.length. */
- /* This can be < pos in the one special case described above. */
- int limit;
-
- /* The value -1 means there is no mark, or the mark has been invalidated.
- Otherwise, markPos is the index in the buffer of the marked position.
- Must be >= 0 and <= pos.
- Note we do not explicitly store the read-limit.
- The implicit read-limit is (buffer.length - markPos), which is
- guaranteed to be >= the read-limit requested in the call to mark. */
- int markPos = -1;
-
- public BufferedReader(Reader in)
- {
- this(in, 8192);
- }
-
- public BufferedReader(Reader in, int size)
- {
- super(in.lock);
- this.in = in;
- buffer = new char[size];
- }
-
- public void close() throws IOException
- {
- synchronized (lock)
- {
- if (in != null)
- in.close();
- in = null;
- buffer = null;
- }
- }
-
- public boolean markSupported()
- {
- return true;
- }
-
- public void mark(int readLimit) throws IOException
- {
- synchronized (lock)
- {
- // In this method we need to be aware of the special case where
- // pos + 1 == limit. This indicates that a '\r' was the last char
- // in the buffer during a readLine. We'll want to maintain that
- // condition after we shift things around and if a larger buffer is
- // needed to track readLimit, we'll have to make it one element
- // larger to ensure we don't invalidate the mark too early, if the
- // char following the '\r' is NOT a '\n'. This is ok because, per
- // the spec, we are not required to invalidate when passing readLimit.
- //
- // Note that if 'pos > limit', then doing 'limit -= pos' will cause
- // limit to be negative. This is the only way limit will be < 0.
-
- if (pos + readLimit > limit)
- {
- char[] old_buffer = buffer;
- int extraBuffSpace = 0;
- if (pos > limit)
- extraBuffSpace = 1;
- if (readLimit + extraBuffSpace > limit)
- buffer = new char[readLimit + extraBuffSpace];
- limit -= pos;
- if (limit >= 0)
- {
- System.arraycopy(old_buffer, pos, buffer, 0, limit);
- pos = 0;
- }
- }
-
- if (limit < 0)
- {
- // Maintain the relationship of 'pos > limit'.
- pos = 1;
- limit = markPos = 0;
- }
- else
- markPos = pos;
- // Now pos + readLimit <= buffer.length. thus if we need to read
- // beyond buffer.length, then we are allowed to invalidate markPos.
- }
- }
-
- public void reset() throws IOException
- {
- synchronized (lock)
- {
- if (markPos < 0)
- throw new IOException("mark never set or invalidated");
-
- // Need to handle the extremely unlikely case where a readLine was
- // done with a '\r' as the last char in the buffer; which was then
- // immediately followed by a mark and a reset with NO intervening
- // read of any sort. In that case, setting pos to markPos would
- // lose that info and a subsequent read would thus not skip a '\n'
- // (if one exists). The value of limit in this rare case is zero.
- // We can assume that if limit is zero for other reasons, then
- // pos is already set to zero and doesn't need to be readjusted.
- if (limit > 0)
- pos = markPos;
- }
- }
-
- public boolean ready() throws IOException
- {
- synchronized (lock)
- {
- return pos < limit || in.ready();
- }
- }
-
- public int read(char[] buf, int offset, int count) throws IOException
- {
- synchronized (lock)
- {
- // Once again, we need to handle the special case of a readLine
- // that has a '\r' at the end of the buffer. In this case, we'll
- // need to skip a '\n' if it is the next char to be read.
- // This special case is indicated by 'pos > limit'.
- boolean retAtEndOfBuffer = false;
-
- int avail = limit - pos;
- if (count > avail)
- {
- if (avail > 0)
- count = avail;
- else // pos >= limit
- {
- if (limit == buffer.length)
- markPos = -1; // read too far - invalidate the mark.
- if (pos > limit)
- {
- // Set a boolean and make pos == limit to simplify things.
- retAtEndOfBuffer = true;
- --pos;
- }
- if (markPos < 0)
- {
- // Optimization: can read directly into buf.
- if (count >= buffer.length && !retAtEndOfBuffer)
- return in.read(buf, offset, count);
- pos = limit = 0;
- }
- avail = in.read(buffer, limit, buffer.length - limit);
- if (retAtEndOfBuffer && avail > 0 && buffer[limit] == '\n')
- {
- --avail;
- limit++;
- }
- if (avail < count)
- {
- if (avail <= 0)
- return avail;
- count = avail;
- }
- limit += avail;
- }
- }
- System.arraycopy(buffer, pos, buf, offset, count);
- pos += count;
- return count;
- }
- }
-
- /* Read more data into the buffer. Update pos and limit appropriately.
- Assumes pos==limit initially. May invalidate the mark if read too much.
- Return number of chars read (never 0), or -1 on eof. */
- private int fill() throws IOException
- {
- // Handle the special case of a readLine that has a '\r' at the end of
- // the buffer. In this case, we'll need to skip a '\n' if it is the
- // next char to be read. This special case is indicated by 'pos > limit'.
- boolean retAtEndOfBuffer = false;
- if (pos > limit)
- {
- retAtEndOfBuffer = true;
- --pos;
- }
-
- if (markPos >= 0 && limit == buffer.length)
- markPos = -1;
- if (markPos < 0)
- pos = limit = 0;
- int count = in.read(buffer, limit, buffer.length - limit);
- if (count > 0)
- limit += count;
-
- if (retAtEndOfBuffer && buffer[pos] == '\n')
- {
- --count;
- pos++;
- }
-
- return count;
- }
-
- public int read() throws IOException
- {
- synchronized (lock)
- {
- if (pos >= limit && fill () <= 0)
- return -1;
- return buffer[pos++];
- }
- }
-
- /* Return the end of the line starting at this.pos and ending at limit.
- * The index returns is *before* any line terminators, or limit
- * if no line terminators were found.
- */
- private int lineEnd(int limit)
- {
- int i = pos;
- for (; i < limit; i++)
- {
- char ch = buffer[i];
- if (ch == '\n' || ch == '\r')
- break;
- }
- return i;
- }
-
- public String readLine() throws IOException
- {
- // Handle the special case where a previous readLine (with no intervening
- // reads/skips) had a '\r' at the end of the buffer.
- // In this case, we'll need to skip a '\n' if it's the next char to be read.
- // This special case is indicated by 'pos > limit'.
- if (pos > limit)
- {
- int ch = read();
- if (ch < 0)
- return null;
- if (ch != '\n')
- --pos;
- }
- int i = lineEnd(limit);
- if (i < limit)
- {
- String str = new String(buffer, pos, i - pos);
- pos = i + 1;
- // If the last char in the buffer is a '\r', we must remember
- // to check if the next char to be read after the buffer is refilled
- // is a '\n'. If so, skip it. To indicate this condition, we set pos
- // to be limit + 1, which normally is never possible.
- if (buffer[i] == '\r')
- if (pos == limit || buffer[pos] == '\n')
- pos++;
- return str;
- }
- StringBuffer sbuf = new StringBuffer(200);
- sbuf.append(buffer, pos, i - pos);
- pos = i;
- // We only want to return null when no characters were read before
- // EOF. So we must keep track of this separately. Otherwise we
- // would treat an empty `sbuf' as an EOF condition, which is wrong
- // when there is just a newline.
- boolean eof = false;
- for (;;)
- {
- int ch = read();
- if (ch < 0)
- {
- eof = true;
- break;
- }
- if (ch == '\n' || ch == '\r')
- {
- // Check here if a '\r' was the last char in the buffer; if so,
- // mark it as in the comment above to indicate future reads
- // should skip a newline that is the next char read after
- // refilling the buffer.
- if (ch == '\r')
- if (pos == limit || buffer[pos] == '\n')
- pos++;
- break;
- }
- i = lineEnd(limit);
- sbuf.append(buffer, pos - 1, i - (pos - 1));
- pos = i;
- }
- return (sbuf.length() == 0 && eof) ? null : sbuf.toString();
- }
-
- public long skip(long count) throws IOException
- {
- if (count <= 0)
- return 0;
- synchronized (lock)
- {
- // Yet again, we need to handle the special case of a readLine
- // that has a '\r' at the end of the buffer. In this case, we need
- // to ignore a '\n' if it is the next char to be read.
- // This special case is indicated by 'pos > limit' (i.e. avail < 0).
- // To simplify things, if we're dealing with the special case for
- // readLine, just read the next char (since the fill method will
- // skip the '\n' for us). By doing this, we'll have to back up pos.
- // That's easier than trying to keep track of whether we've skipped
- // one element or not.
- int ch;
- if (pos > limit)
- if ((ch = read()) < 0)
- return 0;
- else
- --pos;
-
- int avail = limit - pos;
-
- if (count < avail)
- {
- pos += count;
- return count;
- }
-
- pos = limit;
- long todo = count - avail;
- if (todo > buffer.length)
- {
- markPos = -1;
- todo -= in.skip(todo);
- }
- else
- {
- while (todo > 0)
- {
- avail = fill();
- if (avail <= 0)
- break;
- if (avail > todo)
- avail = (int) todo;
- pos += avail;
- todo -= avail;
- }
- }
- return count - todo;
- }
- }
-}
diff --git a/libjava/java/io/BufferedWriter.java b/libjava/java/io/BufferedWriter.java
deleted file mode 100644
index 3112a8adec9..00000000000
--- a/libjava/java/io/BufferedWriter.java
+++ /dev/null
@@ -1,129 +0,0 @@
-// BufferedWriter.java - Filtered character output stream.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-// Why not extend FilterWriter?
-public class BufferedWriter extends Writer
-{
- public BufferedWriter (Writer out)
- {
- this (out, 8192);
- }
-
- public BufferedWriter (Writer ox, int size)
- {
- super (ox);
- out = ox;
- buffer = new char[size];
- count = 0;
- }
-
- public void close () throws IOException
- {
- localFlush ();
- out.close();
- }
-
- public void flush () throws IOException
- {
- localFlush ();
- out.flush();
- }
-
- public void newLine () throws IOException
- {
- write (System.getProperty("line.separator"));
- }
-
- public void write (int oneChar) throws IOException
- {
- synchronized (lock)
- {
- buffer[count++] = (char) oneChar;
- if (count == buffer.length)
- localFlush ();
- }
- }
-
- public void write (char[] buf, int offset, int len) throws IOException
- {
- if (offset < 0 || len < 0 || offset + len > buf.length)
- throw new ArrayIndexOutOfBoundsException ();
-
- synchronized (lock)
- {
- // Bypass buffering if there is too much incoming data.
- if (count + len > buffer.length)
- {
- localFlush ();
- out.write(buf, offset, len);
- }
- else
- {
- System.arraycopy(buf, offset, buffer, count, len);
- count += len;
- if (count == buffer.length)
- localFlush ();
- }
- }
- }
-
- public void write (String str, int offset, int len) throws IOException
- {
- if (offset < 0 || len < 0 || offset + len < str.length())
- throw new ArrayIndexOutOfBoundsException ();
-
- synchronized (lock)
- {
- if (count + len > buffer.length)
- {
- localFlush ();
- out.write(str, offset, len);
- }
- else
- {
- str.getChars(offset, offset + len, buffer, count);
- count += len;
- if (count == buffer.length)
- localFlush ();
- }
- }
- }
-
- private final void localFlush () throws IOException
- {
- if (count > 0)
- {
- synchronized (lock)
- {
- out.write(buffer, 0, count);
- count = 0;
- }
- }
- }
-
- // The downstream writer.
- private Writer out;
- // The character buffer.
- char[] buffer;
- // Number of valid chars in buffer.
- int count;
-}
diff --git a/libjava/java/io/ByteArrayInputStream.java b/libjava/java/io/ByteArrayInputStream.java
deleted file mode 100644
index 97ec6e79818..00000000000
--- a/libjava/java/io/ByteArrayInputStream.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 7, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public class ByteArrayInputStream extends InputStream
-{
- /* An array of bytes provided by the creator of the stream. */
- protected byte[] buf;
-
- /* Position of the next byte in buf to be read. */
- protected int pos;
-
- /* The currently marked position in the stream. */
- protected int mark;
-
- /* The index in buf one greater than the last valid character. */
- protected int count;
-
- public ByteArrayInputStream(byte[] buffer)
- {
- this(buffer, 0, buffer.length);
- }
-
- public ByteArrayInputStream(byte[] buffer, int offset, int length)
- {
- buf = buffer;
-
- count = offset + length;
- if (count > buf.length)
- count = buf.length;
-
- pos = offset;
- // TBD: What should we do if pos is neg. or > count? E.g. throw exc. or:
- // if (pos < 0 || pos > count)
- // pos = 0;
-
- mark = pos;
- }
-
- public synchronized int available()
- {
- return count - pos;
- }
-
- public synchronized void mark(int readAheadLimit)
- {
- // readAheadLimit is ignored per Java Class Lib. book, p.220.
- mark = pos;
- }
-
- public boolean markSupported()
- {
- return true;
- }
-
- public synchronized int read()
- {
- if (pos < 0)
- throw new ArrayIndexOutOfBoundsException(pos);
-
- if (pos < count)
- return ((int) buf[pos++]) & 0xFF;
- return -1;
- }
-
- public synchronized int read(byte[] b, int off, int len)
- {
- /* Don't need to check pos value, arraycopy will check it. */
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- if (pos >= count)
- return -1;
-
- int numBytes = Math.min(count - pos, len);
- System.arraycopy(buf, pos, b, off, numBytes);
- pos += numBytes;
- return numBytes;
- }
-
- public synchronized void reset()
- {
- pos = mark;
- }
-
- public synchronized long skip(long n)
- {
- // Even though the var numBytes is a long, in reality it can never
- // be larger than an int since the result of subtracting 2 positive
- // ints will always fit in an int. Since we have to return a long
- // anyway, numBytes might as well just be a long.
- long numBytes = Math.min((long) (count - pos), n < 0 ? 0L : n);
- pos += numBytes;
- return numBytes;
- }
-}
diff --git a/libjava/java/io/ByteArrayOutputStream.java b/libjava/java/io/ByteArrayOutputStream.java
deleted file mode 100644
index 901312f1337..00000000000
--- a/libjava/java/io/ByteArrayOutputStream.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// ByteArrayOutputStream.java - Write bytes to an array.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public class ByteArrayOutputStream extends OutputStream
-{
- public ByteArrayOutputStream ()
- {
- this (32);
- }
-
- public ByteArrayOutputStream (int size)
- {
- buf = new byte[size];
- count = 0;
- }
-
- public synchronized void reset ()
- {
- count = 0;
- }
-
- public int size ()
- {
- return count;
- }
-
- public synchronized byte[] toByteArray ()
- {
- byte[] ret = new byte[count];
- System.arraycopy(buf, 0, ret, 0, count);
- return ret;
- }
-
- public String toString ()
- {
- return new String (buf, 0, count);
- }
-
- public String toString (String enc) throws UnsupportedEncodingException
- {
- return new String (buf, 0, count, enc);
- }
-
- // This is deprecated in the JCL book.
- public String toString (int hibyte)
- {
- return new String (buf, 0, count, hibyte);
- }
-
- // Resize buffer to accomodate new bytes.
- private void resize (int add)
- {
- if (count + add >= buf.length)
- {
- int newlen = buf.length * 2;
- if (count + add > newlen)
- newlen = count + add;
- byte[] newbuf = new byte[newlen];
- System.arraycopy(buf, 0, newbuf, 0, count);
- buf = newbuf;
- }
- }
-
- public synchronized void write (int oneByte)
- {
- resize (1);
- buf[count++] = (byte) oneByte;
- }
-
- public synchronized void write (byte[] buffer, int offset, int add)
- {
- // If ADD < 0 then arraycopy will throw the appropriate error for
- // us.
- if (add >= 0)
- resize (add);
- System.arraycopy(buffer, offset, buf, count, add);
- count += add;
- }
-
- public synchronized void writeTo (OutputStream out) throws IOException
- {
- out.write(buf, 0, count);
- }
-
- // The byte buffer.
- protected byte[] buf;
- // Number of valid bytes in buffer.
- protected int count;
-}
diff --git a/libjava/java/io/CharArrayReader.java b/libjava/java/io/CharArrayReader.java
deleted file mode 100644
index 195403684c2..00000000000
--- a/libjava/java/io/CharArrayReader.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 16, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public class CharArrayReader extends Reader
-{
- /* An array of chars provided by the creator of the stream. */
- protected char[] buf;
-
- /* Position of the next char in buf to be read. */
- protected int pos;
-
- /* The currently marked position in the stream. */
- protected int markedPos;
-
- /* The index in buf one greater than the last valid character. */
- protected int count;
-
- public CharArrayReader(char[] buffer)
- {
- this(buffer, 0, buffer.length);
- }
-
- public CharArrayReader(char[] buffer, int offset, int length)
- {
- super();
- buf = buffer;
-
- count = offset + length;
- if (count > buf.length)
- count = buf.length;
-
- pos = offset;
- // TBD: What should we do if pos is neg. or > count? E.g. throw exc. or:
- // if (pos < 0 || pos > count)
- // pos = 0;
-
- markedPos = pos;
- }
-
- public void close()
- {
- synchronized (lock)
- {
- buf = null;
- }
- }
-
- public void mark(int readAheadLimit)
- {
- synchronized (lock)
- {
- // readAheadLimit is ignored per Java Class Lib. book, p. 318.
- markedPos = pos;
- }
- }
-
- public boolean markSupported()
- {
- return true;
- }
-
- public int read() throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- if (pos < 0)
- throw new ArrayIndexOutOfBoundsException(pos);
-
- if (pos < count)
- return ((int) buf[pos++]) & 0xFFFF;
- return -1;
- }
- }
-
- public int read(char[] b, int off, int len) throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- /* Don't need to check pos value, arraycopy will check it. */
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- if (pos >= count)
- return -1;
-
- int numChars = Math.min(count - pos, len);
- System.arraycopy(buf, pos, b, off, numChars);
- pos += numChars;
- return numChars;
- }
- }
-
- public boolean ready() throws IOException
- {
- if (buf == null)
- throw new IOException();
-
- return true;
- }
-
- public void reset() throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- pos = markedPos;
- }
- }
-
- public long skip(long n) throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- // Even though the var numChars is a long, in reality it can never
- // be larger than an int since the result of subtracting 2 positive
- // ints will always fit in an int. Since we have to return a long
- // anyway, numChars might as well just be a long.
- long numChars = Math.min((long) (count - pos), n < 0 ? 0L : n);
- pos += numChars;
- return numChars;
- }
- }
-}
diff --git a/libjava/java/io/CharArrayWriter.java b/libjava/java/io/CharArrayWriter.java
deleted file mode 100644
index 5e04d6171b1..00000000000
--- a/libjava/java/io/CharArrayWriter.java
+++ /dev/null
@@ -1,122 +0,0 @@
-// CharArrayWriter.java - Character array output stream.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class CharArrayWriter extends Writer
-{
- public CharArrayWriter ()
- {
- this (32);
- }
-
- public CharArrayWriter (int size)
- {
- super ();
- buf = new char[size];
- }
-
- public void close ()
- {
- // JCL says this does nothing. This seems to violate the Writer
- // contract, in that other methods should still throw and
- // IOException after a close. Still, we just follow JCL.
- }
-
- public void flush ()
- {
- }
-
- public synchronized void reset ()
- {
- count = 0;
- }
-
- public int size ()
- {
- return count;
- }
-
- public char[] toCharArray ()
- {
- char[] nc = new char[count];
- System.arraycopy(buf, 0, nc, 0, count);
- return nc;
- }
-
- public String toString ()
- {
- return new String (buf, 0, count);
- }
-
- public void write (int oneChar)
- {
- synchronized (lock)
- {
- resize (1);
- buf[count++] = (char) oneChar;
- }
- }
-
- public void write (char[] buffer, int offset, int len)
- {
- synchronized (lock)
- {
- if (len >= 0)
- resize (len);
- System.arraycopy(buffer, offset, buf, count, len);
- count += len;
- }
- }
-
- public void write (String str, int offset, int len)
- {
- synchronized (lock)
- {
- if (len >= 0)
- resize (len);
- str.getChars(offset, offset + len, buf, count);
- count += len;
- }
- }
-
- public void writeTo (Writer out) throws IOException
- {
- out.write(buf, 0, count);
- }
-
- private final void resize (int len)
- {
- if (count + len >= buf.length)
- {
- int newlen = buf.length * 2;
- if (count + len > newlen)
- newlen = count + len;
- char[] newbuf = new char[newlen];
- System.arraycopy(buf, 0, newbuf, 0, count);
- buf = newbuf;
- }
- }
-
- // The character buffer.
- protected char[] buf;
- // Number of valid characters in buffer.
- protected int count;
-}
diff --git a/libjava/java/io/CharConversionException.java b/libjava/java/io/CharConversionException.java
deleted file mode 100644
index 938d605d0f9..00000000000
--- a/libjava/java/io/CharConversionException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// CharConversionException.java - Problem converting char to byte encoding.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class CharConversionException extends IOException
-{
- public CharConversionException ()
- {
- super ();
- }
-
- public CharConversionException (String s)
- {
- super (s);
- }
-}
diff --git a/libjava/java/io/DataInput.java b/libjava/java/io/DataInput.java
deleted file mode 100644
index 5930e496979..00000000000
--- a/libjava/java/io/DataInput.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 2, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public interface DataInput
-{
- public boolean readBoolean() throws IOException;
- public byte readByte() throws IOException;
- public char readChar() throws IOException;
- public double readDouble() throws IOException;
- public float readFloat() throws IOException;
- public void readFully(byte[] b)
- throws IOException, NullPointerException;
- public void readFully(byte[] b, int off, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException;
- public int readInt() throws IOException;
- public String readLine() throws IOException;
- public long readLong() throws IOException;
- public short readShort() throws IOException;
- public int readUnsignedByte() throws IOException;
- public int readUnsignedShort() throws IOException;
- public String readUTF() throws IOException;
- public int skipBytes(int n) throws IOException;
-}
diff --git a/libjava/java/io/DataInputStream.java b/libjava/java/io/DataInputStream.java
deleted file mode 100644
index a3dbaa739d2..00000000000
--- a/libjava/java/io/DataInputStream.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 20, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class DataInputStream extends FilterInputStream implements DataInput
-{
- // readLine() hack to ensure that an '\r' not followed by an '\n' is
- // handled correctly. If set, readLine() will ignore the first char it sees
- // if that char is a '\n'
- boolean ignoreInitialNewline = false;
-
- public DataInputStream(InputStream in)
- {
- super(in);
- }
-
- public final int read(byte[] b) throws IOException
- {
- return super.read(b, 0, b.length);
- }
-
- public final int read(byte[] b, int off, int len) throws IOException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- return super.read(b, off, len);
- }
-
- public final boolean readBoolean() throws IOException
- {
- return (readByte() != 0);
- }
-
- public final byte readByte() throws IOException
- {
- int i = read();
- if (i < 0)
- throw new EOFException();
-
- return (byte) i;
- }
-
- public final char readChar() throws IOException
- {
- return (char) ((readByte() << 8) | readUnsignedByte());
- }
-
- public final double readDouble() throws IOException
- {
- return Double.longBitsToDouble(readLong());
- }
-
- public final float readFloat() throws IOException
- {
- return Float.intBitsToFloat(readInt());
- }
-
- public final void readFully(byte[] b) throws IOException
- {
- readFully(b, 0, b.length);
- }
-
- public final void readFully(byte[] b, int off, int len) throws IOException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- while (len > 0)
- {
- // super.read will block until some data is available.
- int numread = super.read(b, off, len);
- if (numread < 0)
- throw new EOFException();
- len -= numread;
- off += numread;
- }
- }
-
- public final int readInt() throws IOException
- {
- int retval = 0;
- for (int i = 0; i < 4; i++)
- retval |= readUnsignedByte() << (24 - i * 8);
-
- return retval;
- }
-
- // Deprecated as of JDK 1.1
- public final String readLine() throws IOException
- {
- StringBuffer strb = new StringBuffer();
-
- readloop: while (true)
- {
- int c = 0;
- char ch = ' ';
- boolean getnext = true;
- while (getnext)
- {
- getnext = false;
- c = read();
- if (c < 0) // got an EOF
- return strb.length() > 0 ? strb.toString() : null;
- ch = (char) c;
- if ((ch &= 0xFF) == '\n')
- // hack to correctly handle '\r\n' sequences
- if (ignoreInitialNewline)
- {
- ignoreInitialNewline = false;
- getnext = true;
- }
- else
- break readloop;
- }
-
- if (ch == '\r')
- {
- // FIXME: The following code tries to adjust the stream back one
- // character if the next char read is '\n'. As a last resort,
- // it tries to mark the position before reading but the bottom
- // line is that it is possible that this method will not properly
- // deal with a '\r' '\n' combination thus not fulfilling the
- // DataInput contract for readLine. It's not a particularly
- // safe approach threadwise since it is unsynchronized and
- // since it might mark an input stream behind the users back.
- // Along the same vein it could try the same thing for
- // ByteArrayInputStream and PushbackInputStream, but that is
- // probably overkill since this is deprecated & BufferedInputStream
- // is the most likely type of input stream.
- //
- // The alternative is to somehow push back the next byte if it
- // isn't a '\n' or to have the reading methods of this class
- // keep track of whether the last byte read was '\r' by readLine
- // and then skip the very next byte if it is '\n'. Either way,
- // this would increase the complexity of the non-deprecated methods
- // and since it is undesirable to make non-deprecated methods
- // less efficient, the following seems like the most reasonable
- // approach.
- int next_c = 0;
- char next_ch = ' ';
- if (in instanceof BufferedInputStream)
- {
- next_c = read();
- next_ch = (char) (next_c & 0xFF);
- if ((next_ch != '\n') && (next_c >= 0))
- {
- BufferedInputStream bin = (BufferedInputStream) in;
- if (bin.pos > 0)
- bin.pos--;
- }
- }
- else if (markSupported())
- {
- next_c = read();
- next_ch = (char) (next_c & 0xFF);
- if ((next_ch != '\n') && (next_c >= 0))
- {
- mark(1);
- if ((read() & 0xFF) != '\n')
- reset();
- }
- }
- // In order to catch cases where 'in' isn't a BufferedInputStream
- // and doesn't support mark() (such as reading from a Socket), set
- // a flag that instructs readLine() to ignore the first character
- // it sees _if_ that character is a '\n'.
- else ignoreInitialNewline = true;
- break;
- }
- strb.append(ch);
- }
-
- return strb.length() > 0 ? strb.toString() : "";
- }
-
- public final long readLong() throws IOException
- {
- long retval = 0L;
- for (int i = 0; i < 8; i++)
- retval |= (long) readUnsignedByte() << (56 - i * 8);
-
- return retval;
- }
-
- public final short readShort() throws IOException
- {
- return (short) ((readByte() << 8) | readUnsignedByte());
- }
-
- public final int readUnsignedByte() throws IOException
- {
- int i = read();
- if (i < 0)
- throw new EOFException();
-
- return (i & 0xFF);
- }
-
- public final int readUnsignedShort() throws IOException
- {
- return (readUnsignedByte() << 8) | readUnsignedByte();
- }
-
- public final String readUTF() throws IOException
- {
- return readUTF(this);
- }
-
- public final static String readUTF(DataInput in) throws IOException
- {
- final int UTFlen = in.readUnsignedShort();
- byte[] buf = new byte[UTFlen];
- StringBuffer strbuf = new StringBuffer();
-
- // This blocks until the entire string is available rather than
- // doing partial processing on the bytes that are available and then
- // blocking. An advantage of the latter is that Exceptions
- // could be thrown earlier. The former is a bit cleaner.
- in.readFully(buf, 0, UTFlen);
- for (int i = 0; i < UTFlen; )
- {
- if ((buf[i] & 0x80) == 0) // bit pattern 0xxxxxxx
- strbuf.append((char) (buf[i++] & 0xFF));
- else if ((buf[i] & 0xE0) == 0xC0) // bit pattern 110xxxxx
- {
- if (i + 1 >= UTFlen || (buf[i+1] & 0xC0) != 0x80)
- throw new UTFDataFormatException();
-
- strbuf.append((char) (((buf[i++] & 0x1F) << 6) |
- (buf[i++] & 0x3F)));
- }
- else if ((buf[i] & 0xF0) == 0xE0) // bit pattern 1110xxxx
- {
- if (i + 2 >= UTFlen ||
- (buf[i+1] & 0xC0) != 0x80 || (buf[i+2] & 0xC0) != 0x80)
- throw new UTFDataFormatException();
-
- strbuf.append((char) (((buf[i++] & 0x0F) << 12) |
- ((buf[i++] & 0x3F) << 6) |
- (buf[i++] & 0x3F)));
- }
- else // must be ((buf[i] & 0xF0) == 0xF0 || (buf[i] & 0xC0) == 0x80)
- throw new UTFDataFormatException(); // bit patterns 1111xxxx or
- // 10xxxxxx
- }
-
- return strbuf.toString();
- }
-
- public final int skipBytes(int n) throws IOException
- {
- // The contract in the Java Lang. Spec. says that this never
- // throws an EOFException and infers that it doesn't block (since
- // it may skip less than the requested number of bytes).
- // BUT, the JCL book specifically says that this method blocks
- // and can throw an EOFException. Finally, the Java 1.2 online
- // doc simply refers to the general contract. As such, we will
- // stick to the contract and assume for now that the JCL book
- // is incorrect.
-
- // Since we're only skipping at most an int number of bytes, the cast
- // of return value to an int is fine.
- if (n > 0)
- {
- n = Math.min(n, available());
- return (int) super.skip((long) n);
- }
-
- return 0;
- }
-}
diff --git a/libjava/java/io/DataOutput.java b/libjava/java/io/DataOutput.java
deleted file mode 100644
index d0def85cdf9..00000000000
--- a/libjava/java/io/DataOutput.java
+++ /dev/null
@@ -1,44 +0,0 @@
-// DataOutput.java - Interface for data output conversions.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public interface DataOutput
-{
- public abstract void write (int b) throws IOException;
- public abstract void write (byte[] b)
- throws IOException, NullPointerException;
- public abstract void write (byte[] b, int off, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException;
- public abstract void writeBoolean (boolean v) throws IOException;
- public abstract void writeByte (int v) throws IOException;
- public abstract void writeShort (int v) throws IOException;
- public abstract void writeChar (int v) throws IOException;
- public abstract void writeInt (int v) throws IOException;
- public abstract void writeLong (long v) throws IOException;
- public abstract void writeFloat (float v) throws IOException;
- public abstract void writeDouble (double v) throws IOException;
- public abstract void writeBytes (String s)
- throws IOException, NullPointerException;
- public abstract void writeChars (String s)
- throws IOException, NullPointerException;
- public abstract void writeUTF (String s)
- throws IOException, NullPointerException;
-}
diff --git a/libjava/java/io/DataOutputStream.java b/libjava/java/io/DataOutputStream.java
deleted file mode 100644
index 6830e1af09e..00000000000
--- a/libjava/java/io/DataOutputStream.java
+++ /dev/null
@@ -1,165 +0,0 @@
-// DataOutputStream.java - Output filter that implements DataOutput
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public class DataOutputStream extends FilterOutputStream implements DataOutput
-{
- public DataOutputStream (OutputStream out)
- {
- super (out);
- written = 0;
- }
-
- public void flush () throws IOException
- {
- out.flush();
- }
-
- public final int size ()
- {
- return written;
- }
-
- public synchronized void write (int b) throws IOException
- {
- out.write(b);
- ++written;
- }
-
- public synchronized void write (byte[] b, int off, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException
- {
- out.write(b, off, len);
- written += len - off;
- }
-
- public final void writeBoolean (boolean v) throws IOException
- {
- write (v ? 1 : 0);
- }
-
- public final void writeByte (int v) throws IOException
- {
- write (v & 0xff);
- }
-
- public final void writeShort (int v) throws IOException
- {
- write ((byte) (0xff & (v >> 8)));
- write ((byte) (0xff & v));
- }
-
- public final void writeChar (int v) throws IOException
- {
- write ((byte) (0xff & (v >> 8)));
- write ((byte) (0xff & v));
- }
-
- public final void writeInt (int v) throws IOException
- {
- write ((byte) (0xff & (v >> 24)));
- write ((byte) (0xff & (v >> 16)));
- write ((byte) (0xff & (v >> 8)));
- write ((byte) (0xff & v));
- }
-
- public final void writeLong (long v) throws IOException
- {
- write ((byte) (0xff & (v >> 56)));
- write ((byte) (0xff & (v >> 48)));
- write ((byte) (0xff & (v >> 40)));
- write ((byte) (0xff & (v >> 32)));
- write ((byte) (0xff & (v >> 24)));
- write ((byte) (0xff & (v >> 16)));
- write ((byte) (0xff & (v >> 8)));
- write ((byte) (0xff & v));
- }
-
- public final void writeFloat (float v) throws IOException
- {
- writeInt (Float.floatToIntBits(v));
- }
-
- public final void writeDouble (double v) throws IOException
- {
- writeLong (Double.doubleToLongBits(v));
- }
-
- public final void writeBytes (String s) throws IOException
- {
- int len = s.length();
- for (int i = 0; i < len; ++i)
- writeByte (s.charAt(i));
- }
-
- public final void writeChars (String s) throws IOException
- {
- int len = s.length();
- for (int i = 0; i < len; ++i)
- writeChar (s.charAt(i));
- }
-
- public final void writeUTF (String s) throws IOException
- {
- int len = s.length();
- int sum = 0;
-
- for (int i = 0; i < len && sum <= 65535; ++i)
- {
- char c = s.charAt(i);
- if (c >= '\u0001' && c <= '\u007f')
- sum += 1;
- else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
- sum += 2;
- else
- sum += 3;
- }
-
- if (sum > 65535)
- throw new UTFDataFormatException ();
-
- writeShort (sum);
-
- for (int i = 0; i < len; ++i)
- {
- char c = s.charAt(i);
- if (c >= '\u0001' && c <= '\u007f')
- write (c);
- else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
- {
- write (0xc0 | (0x1f & (c >> 6)));
- write (0x80 | (0x3f & c));
- }
- else
- {
- // JSL says the first byte should be or'd with 0xc0, but
- // that is a typo. Unicode says 0xe0, and that is what is
- // consistent with DataInputStream.
- write (0xe0 | (0x0f & (c >> 12)));
- write (0x80 | (0x3f & (c >> 6)));
- write (0x80 | (0x3f & c));
- }
- }
- }
-
- // Number of bytes written so far.
- protected int written;
-}
diff --git a/libjava/java/io/EOFException.java b/libjava/java/io/EOFException.java
deleted file mode 100644
index e5ae1f01034..00000000000
--- a/libjava/java/io/EOFException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// EOFException.java - End of file exception
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class EOFException extends IOException
-{
- public EOFException ()
- {
- super ();
- }
-
- public EOFException (String s)
- {
- super (s);
- }
-}
diff --git a/libjava/java/io/File.java b/libjava/java/io/File.java
deleted file mode 100644
index 38bcb9f9c63..00000000000
--- a/libjava/java/io/File.java
+++ /dev/null
@@ -1,358 +0,0 @@
-// File.java - File name
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1; 1.2 functionality missing.
- * A known bug: most calls to the security manager can generate
- * IOException since we use the canonical path.
- */
-
-public class File implements Serializable
-{
- public boolean canRead ()
- {
- return access (checkRead (), READ);
- }
-
- public boolean canWrite ()
- {
- SecurityManager s = System.getSecurityManager();
- String p = safeCanonicalPath ();
- // FIXME: it isn't entirely clear what to do if we can't find the
- // canonical path.
- if (p == null)
- return false;
- if (s != null)
- s.checkWrite(p);
- return access (p, WRITE);
- }
-
- private final native boolean performDelete (String canon);
- public boolean delete ()
- {
- SecurityManager s = System.getSecurityManager();
- String p = safeCanonicalPath ();
- // FIXME: what is right?
- if (p == null)
- return false;
- if (s != null)
- s.checkDelete(p);
- return performDelete (p);
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof File))
- return false;
- File other = (File) obj;
- return path.compareTo(other.path) == 0;
- }
-
- public boolean exists ()
- {
- return access (checkRead (), EXISTS);
- }
-
- public File (String p)
- {
- if (p == null)
- throw new NullPointerException ();
- path = p;
- }
-
- public File (String dirPath, String name)
- {
- if (name == null)
- throw new NullPointerException ();
- if (dirPath != null && dirPath.length() > 0)
- {
- // Try to be smart about the number of separator characters.
- if (dirPath.charAt(dirPath.length() - 1) == separatorChar)
- path = dirPath + name;
- else
- path = dirPath + separatorChar + name;
- }
- else
- path = name;
- }
-
- public File (File dir, String name)
- {
- this (dir == null ? null : dir.path, name);
- }
-
- public String getAbsolutePath ()
- {
- if (isAbsolute ())
- return path;
- return System.getProperty("user.dir") + separatorChar + path;
- }
-
- public native String getCanonicalPath () throws IOException;
-
- public String getName ()
- {
- int last = path.lastIndexOf(separatorChar);
- return path.substring(last + 1);
- }
-
- public String getParent ()
- {
- int last = path.lastIndexOf(separatorChar);
- if (last == -1)
- return null;
- return path.substring(0, last);
- }
-
- public String getPath ()
- {
- return path;
- }
-
- public int hashCode ()
- {
- // FIXME: test.
- return path.hashCode();
- }
-
- public native boolean isAbsolute ();
-
- public boolean isDirectory ()
- {
- return stat (checkRead (), DIRECTORY);
- }
-
- public boolean isFile ()
- {
- return stat (checkRead (), ISFILE);
- }
-
- public long lastModified ()
- {
- return attr (checkRead (), MODIFIED);
- }
-
- public long length ()
- {
- return attr (checkRead (), LENGTH);
- }
-
- private final native String[] performList (String canon,
- FilenameFilter filter);
- public String[] list (FilenameFilter filter)
- {
- return performList (checkRead (), filter);
- }
-
- public String[] list ()
- {
- return performList (checkRead (), null);
- }
-
- public String toString ()
- {
- return path;
- }
-
- private final native boolean performMkdir ();
- public boolean mkdir ()
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- {
- // NOTE: in theory we should use the canonical path. In
- // practice, we can't compute the canonical path until we've
- // made this completely. Lame.
- s.checkWrite(path);
- }
- return performMkdir ();
- }
-
- private static boolean mkdirs (File x)
- {
- if (x.isDirectory())
- return true;
- String p = x.getPath();
- String parent = x.getParent();
- if (parent != null)
- {
- x.setPath(parent);
- if (! mkdirs (x))
- return false;
- x.setPath(p);
- }
- return x.mkdir();
- }
-
- public boolean mkdirs ()
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- {
- // NOTE: in theory we should use the canonical path. In
- // practice, we can't compute the canonical path until we've
- // made this completely. Lame.
- s.checkWrite(path);
- }
-
- if (isDirectory ())
- return false;
- return mkdirs (new File (path));
- }
-
- private static synchronized String nextValue ()
- {
- return Long.toString(counter++, Character.MAX_RADIX);
- }
-
- public static File createTempFile (String prefix, String suffix,
- File directory)
- throws IOException
- {
- FileDescriptor desc = new FileDescriptor ();
-
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkWrite (desc);
-
- if (prefix.length () < 3)
- throw new IllegalArgumentException ();
- if (suffix == null)
- suffix = ".tmp";
-
- // FIXME: filename length varies by architecture and filesystem.
- int max_length = 255;
-
- // Truncation rules.
- // `6' is the number of characters we generate.
- if (prefix.length () + 6 + suffix.length () > max_length)
- {
- int suf_len = 0;
- if (suffix.charAt(0) == '.')
- suf_len = 4;
- suffix = suffix.substring(0, suf_len);
- if (prefix.length () + 6 + suf_len > max_length)
- prefix = prefix.substring(0, max_length - 6 - suf_len);
- }
-
- // We don't care about the name because we set it later.
- File ret = new File ("");
- // How many times should we try? We choose 100.
- for (int i = 0; i < 100; ++i)
- {
- // This is ugly.
- String t = "ZZZZZZ" + nextValue ();
- String l = prefix + t.substring(t.length() - 6) + suffix;
- try
- {
- desc.open (l, FileDescriptor.WRITE | FileDescriptor.EXCL);
- ret.setPath(l);
- return ret;
- }
- catch (IOException _)
- {
- }
- }
-
- throw new IOException ("couldn't make temp file");
- }
-
- public static File createTempFile (String prefix, String suffix)
- throws IOException
- {
- return createTempFile (prefix, suffix, null);
- }
-
- private final native boolean performRenameTo (File dest);
- public boolean renameTo (File dest)
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- {
- // FIXME: JCL doesn't specify which path to check. We check the
- // source since we can canonicalize it.
- s.checkWrite(safeCanonicalPath());
- }
- return performRenameTo (dest);
- }
-
- public static final String pathSeparator
- = System.getProperty("path.separator");
- public static final char pathSeparatorChar = pathSeparator.charAt(0);
- public static final String separator = System.getProperty("file.separator");
- public static final char separatorChar = separator.charAt(0);
-
- private static final String tmpdir = System.getProperty("java.io.tmpdir");
-
- // The path.
- private String path;
-
- // We keep a counter for use by createTempFile. We choose the first
- // value randomly to try to avoid clashes with other VMs.
- private static long counter = Double.doubleToLongBits (Math.random ());
-
- // mkdirs() uses this to avoid repeated allocations.
- private final void setPath (String n)
- {
- path = n;
- }
-
-
- private final String checkRead ()
- {
- SecurityManager s = System.getSecurityManager();
- String p = safeCanonicalPath ();
- if (p == null)
- return null;
- if (s != null)
- s.checkRead(p);
- return p;
- }
-
- // Return canonical path, or null.
- private final String safeCanonicalPath ()
- {
- String p = null;
- try
- {
- p = getCanonicalPath ();
- }
- catch (IOException x)
- {
- // Nothing.
- }
- return p;
- }
-
- // QUERY arguments to access function.
- private final static int READ = 0;
- private final static int WRITE = 1;
- private final static int EXISTS = 2;
-
- // QUERY arguments to stat function.
- private final static int DIRECTORY = 0;
- private final static int ISFILE = 1;
-
- // QUERY arguments to attr function.
- private final static int MODIFIED = 0;
- private final static int LENGTH = 1;
-
- private final native long attr (String p, int query);
- private final native boolean access (String p, int query);
- private final native boolean stat (String p, int query);
-}
diff --git a/libjava/java/io/FileDescriptor.java b/libjava/java/io/FileDescriptor.java
deleted file mode 100644
index 51c6fd6c5b1..00000000000
--- a/libjava/java/io/FileDescriptor.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// FileDescriptor.java - Open file or device
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1
- */
-
-// For now we assume a POSIXy file system. This can be changed later
-// if need be.
-public final class FileDescriptor
-{
- public static final FileDescriptor in = new FileDescriptor (0);
- public static final FileDescriptor out = new FileDescriptor (1);
- public static final FileDescriptor err = new FileDescriptor (2);
-
- public native void sync () throws SyncFailedException;
- public native boolean valid ();
-
-
- // These are mode values for open().
- static final int READ = 1;
- static final int WRITE = 2;
- static final int APPEND = 4;
- // EXCL is used only when making a temp file.
- static final int EXCL = 8;
-
- // These are WHENCE values for seek.
- static final int SET = 0;
- static final int CUR = 1;
-
- // Open a file. MODE is a combination of the above mode flags.
- FileDescriptor (String path, int mode) throws FileNotFoundException
- {
- fd = open (path, mode);
- }
-
- public FileDescriptor ()
- {
- fd = -1;
- }
-
- native int open (String path, int mode) throws FileNotFoundException;
- native void write (int b) throws IOException;
- native void write (byte[] b, int offset, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException;
- native void close () throws IOException;
- native int seek (long pos, int whence) throws IOException;
- native long length () throws IOException;
- native long getFilePointer () throws IOException;
- native int read () throws IOException;
- native int read (byte[] bytes, int offset, int len) throws IOException;
- native int available () throws IOException;
-
-
- // When collected, close.
- protected void finalize () throws IOException
- {
- if (valid ())
- close ();
- }
-
- // Attach to an already-opened file. This is not private because we
- // need access to it from other packages, for instance java.net.
- // Ordinarily that wouldn't work, either, but in our case we know
- // the access comes from C++, where "package private" is translated
- // into "public". Eww.
- FileDescriptor (int desc)
- {
- fd = desc;
- }
-
- // System's notion of file descriptor.
- private int fd;
-}
diff --git a/libjava/java/io/FileInputStream.java b/libjava/java/io/FileInputStream.java
deleted file mode 100644
index e5071e40e89..00000000000
--- a/libjava/java/io/FileInputStream.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 28, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class FileInputStream extends InputStream
-{
- /* Contains the file descriptor for referencing the actual file. */
- private FileDescriptor fd;
-
- public FileInputStream(String name) throws FileNotFoundException
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkRead(name);
- fd = new FileDescriptor(name, FileDescriptor.READ);
- }
-
- public FileInputStream(File file) throws FileNotFoundException
- {
- this(file.getPath());
- }
-
- public FileInputStream(FileDescriptor fdObj)
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkRead(fdObj);
- fd = fdObj;
- }
-
- public int available() throws IOException
- {
- return fd.available();
- }
-
- public void close() throws IOException
- {
- if (fd == null)
- return;
-
- fd.close();
- fd = null;
- }
-
- protected void finalize() throws IOException
- {
- if (fd != null)
- fd.finalize();
- }
-
- public final FileDescriptor getFD() throws IOException
- {
- if (!fd.valid())
- throw new IOException();
- return fd;
- }
-
- public int read() throws IOException
- {
- return fd.read();
- }
-
- public int read(byte[] b) throws IOException
- {
- return fd.read(b, 0, b.length);
- }
-
- public int read(byte[] b, int off, int len) throws IOException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- return fd.read(b, off, len);
- }
-
- public long skip(long n) throws IOException
- {
- return fd.seek(n, FileDescriptor.CUR);
- }
-}
diff --git a/libjava/java/io/FileNotFoundException.java b/libjava/java/io/FileNotFoundException.java
deleted file mode 100644
index 9482b2eefbf..00000000000
--- a/libjava/java/io/FileNotFoundException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// FileNotFoundException.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class FileNotFoundException extends IOException
-{
- public FileNotFoundException ()
- {
- super ();
- }
-
- public FileNotFoundException (String s)
- {
- super (s);
- }
-}
diff --git a/libjava/java/io/FileOutputStream.java b/libjava/java/io/FileOutputStream.java
deleted file mode 100644
index 57af576f89c..00000000000
--- a/libjava/java/io/FileOutputStream.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// FileOutputStream.java - Write bytes to a file.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public class FileOutputStream extends OutputStream
-{
- public FileOutputStream (String path, boolean append)
- throws SecurityException, IOException
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkWrite(path);
- fd = new FileDescriptor (path, (append
- ? FileDescriptor.APPEND
- : FileDescriptor.WRITE));
- }
-
- public FileOutputStream (String path) throws SecurityException, IOException
- {
- this (path, false);
- }
-
- public FileOutputStream (File file) throws SecurityException, IOException
- {
- this (file.getPath(), false);
- }
-
- public FileOutputStream (FileDescriptor fdObj) throws SecurityException
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkWrite(fdObj);
- fd = fdObj;
- }
-
- protected void finalize () throws IOException
- {
- // We don't actually need this, but we include it because it is
- // mentioned in the JCL.
- }
-
- public final FileDescriptor getFD () throws IOException
- {
- if (! fd.valid())
- throw new IOException ();
- return fd;
- }
-
- public void write (int b) throws IOException
- {
- fd.write (b);
- }
-
- public void write (byte[] b) throws IOException, NullPointerException
- {
- fd.write (b, 0, b.length);
- }
-
- public void write (byte[] b, int off, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException ();
- fd.write (b, off, len);
- }
-
- public void close () throws IOException
- {
- if (fd.valid())
- fd.close();
- }
-
- // Instance variables.
- private FileDescriptor fd;
-}
diff --git a/libjava/java/io/FileReader.java b/libjava/java/io/FileReader.java
deleted file mode 100644
index c82ce5b37e2..00000000000
--- a/libjava/java/io/FileReader.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 22, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition.
- * Status: Believed complete and correct.
- */
-
-public class FileReader extends InputStreamReader
-{
- public FileReader(String filename) throws IOException
- {
- super(new FileInputStream(filename));
- }
-
- public FileReader(File file) throws IOException
- {
- super(new FileInputStream(file));
- }
-
- public FileReader(FileDescriptor fd)
- {
- super(new FileInputStream(fd));
- }
-}
diff --git a/libjava/java/io/FileWriter.java b/libjava/java/io/FileWriter.java
deleted file mode 100644
index 5c49e5f853d..00000000000
--- a/libjava/java/io/FileWriter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-// FileWriter.java - Character output to a file.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public class FileWriter extends OutputStreamWriter
-{
- public FileWriter (String fileName) throws IOException
- {
- super (new FileOutputStream (fileName));
- }
-
- public FileWriter (String fileName, boolean append) throws IOException
- {
- super (new FileOutputStream (fileName, append));
- }
-
- public FileWriter (File file) throws IOException
- {
- super (new FileOutputStream (file));
- }
-
- public FileWriter (FileDescriptor fd)
- {
- super (new FileOutputStream (fd));
- }
-}
diff --git a/libjava/java/io/FilenameFilter.java b/libjava/java/io/FilenameFilter.java
deleted file mode 100644
index 05e7fd0dd79..00000000000
--- a/libjava/java/io/FilenameFilter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// FilenameFilter.java - Compute subset of list of file names
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public interface FilenameFilter
-{
- public abstract boolean accept (File dir, String name);
-}
diff --git a/libjava/java/io/FilterInputStream.java b/libjava/java/io/FilterInputStream.java
deleted file mode 100644
index 712be929592..00000000000
--- a/libjava/java/io/FilterInputStream.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 8, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class FilterInputStream extends InputStream
-{
- /* The input stream to be filtered. */
- protected InputStream in;
-
- protected FilterInputStream(InputStream in)
- {
- this.in = in;
- }
-
- public int available() throws IOException
- {
- return in.available();
- }
-
- public void close() throws IOException
- {
- in.close();
- }
-
- public synchronized void mark(int readlimit)
- {
- in.mark(readlimit);
- }
-
- public boolean markSupported()
- {
- return in.markSupported();
- }
-
- public int read() throws IOException
- {
- return in.read();
- }
-
- public int read(byte[] b) throws IOException
- {
- return read(b, 0, b.length);
- }
-
- public int read(byte[] b, int off, int len) throws IOException
- {
- return in.read(b, off, len);
- }
-
- public synchronized void reset() throws IOException
- {
- in.reset();
- }
-
- public long skip(long n) throws IOException
- {
- return in.skip(n);
- }
-}
diff --git a/libjava/java/io/FilterOutputStream.java b/libjava/java/io/FilterOutputStream.java
deleted file mode 100644
index c17ea263052..00000000000
--- a/libjava/java/io/FilterOutputStream.java
+++ /dev/null
@@ -1,62 +0,0 @@
-// FilterOutputStream.java - A filtered stream
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public class FilterOutputStream extends OutputStream
-{
- public void close () throws IOException
- {
- flush ();
- out.close();
- }
-
- public FilterOutputStream (OutputStream ox)
- {
- out = ox;
- }
-
- public void flush () throws IOException
- {
- out.flush();
- }
-
- public void write (int b) throws IOException
- {
- out.write(b);
- }
-
- public void write (byte[] b) throws IOException, NullPointerException
- {
- // Don't do checking here, per Java Lang Spec.
- write (b, 0, b.length);
- }
-
- public void write (byte[] b, int off, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException
- {
- // Don't do checking here, per Java Lang Spec.
- for (int i=0; i < len; i++)
- write (b[off + i]);
- }
-
- // The output stream.
- protected OutputStream out;
-}
diff --git a/libjava/java/io/FilterReader.java b/libjava/java/io/FilterReader.java
deleted file mode 100644
index bce70cc6eda..00000000000
--- a/libjava/java/io/FilterReader.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 15, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public abstract class FilterReader extends Reader
-{
- /* The input stream to be filtered. */
- protected Reader in;
-
- protected FilterReader(Reader in)
- {
- super(in.lock);
- this.in = in;
- }
-
- public void close() throws IOException
- {
- in.close();
- in = null;
- }
-
- public synchronized void mark(int readlimit) throws IOException
- {
- in.mark(readlimit);
- }
-
- public boolean markSupported()
- {
- return in.markSupported();
- }
-
- public int read() throws IOException
- {
- return in.read();
- }
-
- public int read(char[] b, int off, int len) throws IOException
- {
- return in.read(b, off, len);
- }
-
- public boolean ready() throws IOException
- {
- return in.ready();
- }
-
- public synchronized void reset() throws IOException
- {
- in.reset();
- }
-
- public long skip(long n) throws IOException
- {
- return in.skip(n);
- }
-}
diff --git a/libjava/java/io/FilterWriter.java b/libjava/java/io/FilterWriter.java
deleted file mode 100644
index aa6600cab2d..00000000000
--- a/libjava/java/io/FilterWriter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-// FilterWriter.java - Filtered character output stream.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public abstract class FilterWriter extends Writer
-{
- public void close () throws IOException
- {
- out.close();
- }
-
- protected FilterWriter (Writer ox)
- {
- super (ox);
- out = ox;
- }
-
- public void flush () throws IOException
- {
- out.flush();
- }
-
- public void write (int oneChar) throws IOException
- {
- out.write(oneChar);
- }
-
- public void write (char[] buffer, int offset, int count) throws IOException
- {
- out.write(buffer, offset, count);
- }
-
- public void write (String str, int offset, int count) throws IOException
- {
- out.write(str, offset, count);
- }
-
- // Where our writes should go.
- protected Writer out;
-}
diff --git a/libjava/java/io/IOException.java b/libjava/java/io/IOException.java
deleted file mode 100644
index e9b22768243..00000000000
--- a/libjava/java/io/IOException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// IOException.java - Base class for I/O Exceptions
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class IOException extends Exception
-{
- public IOException ()
- {
- super ();
- }
-
- public IOException (String s)
- {
- super (s);
- }
-}
diff --git a/libjava/java/io/InputStream.java b/libjava/java/io/InputStream.java
deleted file mode 100644
index 2da52b1afcd..00000000000
--- a/libjava/java/io/InputStream.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public abstract class InputStream
-{
- public InputStream()
- {
- }
-
- public int available() throws IOException
- {
- return 0;
- }
-
- public void close() throws IOException
- {
- // Do nothing
- }
-
- public void mark(int readlimit)
- {
- // Do nothing
- }
-
- public boolean markSupported()
- {
- return false;
- }
-
- public abstract int read() throws IOException;
-
- public int read(byte[] b) throws IOException
- {
- return read(b, 0, b.length);
- }
-
- public int read(byte[] b, int off, int len) throws IOException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new IndexOutOfBoundsException();
- if (b.length == 0)
- return 0;
-
- int i, ch;
-
- for (i = 0; i < len; ++i)
- try
- {
- if ((ch = read()) < 0)
- return i == 0 ? -1 : i; // EOF
- b[off + i] = (byte) ch;
- }
- catch (IOException ex)
- {
- // Only reading the first byte should cause an IOException.
- if (i == 0)
- throw ex;
- return i;
- }
-
- return i;
- }
-
- public void reset() throws IOException
- {
- throw new IOException("mark/reset not supported");
- }
-
- public long skip(long n) throws IOException
- {
- // Throw away n bytes by reading them into a temp byte[].
- // Limit the temp array to 2Kb so we don't grab too much memory.
- final int buflen = n > 2048 ? 2048 : (int) n;
- byte[] tmpbuf = new byte[buflen];
- final long origN = n;
-
- while (n > 0L)
- {
- int numread = read(tmpbuf, 0, n > buflen ? buflen : (int) n);
- if (numread <= 0)
- break;
- n -= numread;
- }
-
- return origN - n;
- }
-}
diff --git a/libjava/java/io/InputStreamReader.java b/libjava/java/io/InputStreamReader.java
deleted file mode 100644
index 478d8ef5996..00000000000
--- a/libjava/java/io/InputStreamReader.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-import gnu.gcj.convert.*;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 22, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct, but only supports 8859_1.
- */
-
-public class InputStreamReader extends Reader
-{
- BufferedInputStream in;
-
- // Buffer of chars read from in and converted but not consumed.
- char[] work;
- // Next available character (in work buffer) to read.
- int wpos;
- // Last available character (in work buffer) to read.
- int wcount;
-
- BytesToUnicode converter;
-
- public InputStreamReader(InputStream in)
- {
- this(in, BytesToUnicode.getDefaultDecoder());
- }
-
- public InputStreamReader(InputStream in, String enc)
- throws UnsupportedEncodingException
- {
- this(in, BytesToUnicode.getDecoder(enc));
- }
-
- private InputStreamReader(InputStream in, BytesToUnicode decoder)
- {
- this.in = in instanceof BufferedInputStream
- ? (BufferedInputStream) in
- : new BufferedInputStream(in, 250);
- /* Don't need to call super(in) here as long as the lock gets set. */
- this.lock = in;
- converter = decoder;
- converter.setInput(this.in.buf, 0, 0);
- }
-
- public void close() throws IOException
- {
- synchronized (lock)
- {
- if (in != null)
- in.close();
- in = null;
- work = null;
- wpos = wcount = 0;
- }
- }
-
- public String getEncoding() { return converter.getName(); }
-
- public boolean ready() throws IOException
- {
- synchronized (lock)
- {
- if (wpos < wcount)
- return true;
- if (work == null)
- {
- work = new char[100];
- wpos = 0;
- wcount = 0;
- }
- for (;;)
- {
- if (in.available() <= 0)
- return false;
- in.mark(1);
- int b = in.read();
- if (b < 0)
- return true;
- in.reset();
- converter.setInput(in.buf, in.pos, in.count);
- wpos = 0;
- wcount = converter.read(work, 0, work.length);
- in.skip(converter.inpos - in.pos);
- if (wcount > 0)
- return true;
- }
- }
- }
-
- public int read(char buf[], int offset, int length) throws IOException
- {
- synchronized (lock)
- {
- int wavail = wcount - wpos;
- if (wavail > 0)
- {
- if (length > wavail)
- length = wavail;
- System.arraycopy(work, wpos, buf, offset, length);
- wpos += length;
- return length;
- }
- else
- {
- if (length == 0)
- return 0;
- for (;;)
- {
- in.mark(1);
- int b = in.read();
- if (b < 0)
- return -1;
- in.reset();
- converter.setInput(in.buf, in.pos, in.count);
- int count = converter.read (buf, offset, length);
- in.skip(converter.inpos - in.pos);
- if (count > 0)
- return count;
- }
- }
- }
- }
-
- public int read() throws IOException
- {
- synchronized (lock)
- {
- int wavail = wcount - wpos;
- if (wavail > 0)
- return work[wpos++];
- if (work == null)
- {
- work = new char[100];
- wpos = 0;
- wcount = 0;
- }
- else if (wavail == 0)
- {
- wpos = 0;
- wcount = 0;
- }
- int count = read(work, wpos, work.length-wpos);
- if (count <= 0)
- return -1;
- wcount = wpos + count;
- return work[wpos++];
- }
- }
-}
diff --git a/libjava/java/io/InterruptedIOException.java b/libjava/java/io/InterruptedIOException.java
deleted file mode 100644
index 75623824392..00000000000
--- a/libjava/java/io/InterruptedIOException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// InterruptedIOException.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class InterruptedIOException extends IOException
-{
- public InterruptedIOException ()
- {
- super ();
- }
-
- public InterruptedIOException (String s)
- {
- super (s);
- }
-
- public int bytesTransferred = 0;
-}
diff --git a/libjava/java/io/LineNumberInputStream.java b/libjava/java/io/LineNumberInputStream.java
deleted file mode 100644
index cdaa51a00da..00000000000
--- a/libjava/java/io/LineNumberInputStream.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date November 11, 1998.
- * @deprecated
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct. Deprecated in JDK 1.1.
- */
-
-public class LineNumberInputStream extends FilterInputStream
-{
- /* The current line number. */
- private int lineNumber = 0;
-
- /* The line number when the stream was marked. */
- private int markLineNumber = 0;
-
- /* Flag to indicate a '\r' was just read so that an immediately subsequent
- * '\n' can be ignored. */
- private boolean justReadReturnChar = false;
-
- public LineNumberInputStream(InputStream in)
- {
- super(in);
- }
-
- public int available() throws IOException
- {
- // We can only guarantee half the characters that might be available
- // without blocking because "\r\n" is treated as a single character.
- return in.available() / 2;
- }
-
- public int getLineNumber()
- {
- return lineNumber;
- }
-
- public void mark(int readlimit)
- {
- in.mark(readlimit);
- markLineNumber = lineNumber;
- }
-
- public int read() throws IOException
- {
- // Treat "\r\n" as a single character. A '\r' may have been read by
- // a previous call to read so we keep an internal flag to avoid having
- // to read ahead.
-
- int ch = in.read();
-
- if (ch == '\n')
- if (justReadReturnChar)
- {
- ch = in.read();
- justReadReturnChar = false;
- }
- else
- lineNumber++;
- else if (ch == '\r')
- {
- ch = '\n';
- justReadReturnChar = true;
- lineNumber++;
- }
- else
- justReadReturnChar = false;
-
- return ch;
- }
-
- public int read(byte[] b, int off, int len) throws IOException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- // This case always succeeds.
- if (len == 0)
- return 0;
-
- // The simplest, though not necessarily the most time efficient thing
- // to do is simply call read(void) len times. Since this is a deprecated
- // class, that should be ok.
- final int origOff = off;
- while (len-- > 0)
- {
- int ch = read();
- if (ch < 0)
- break;
-
- b[off++] = (byte) ch;
- }
-
- // This is safe since we already know that some bytes were
- // actually requested.
- return off == origOff ? -1 : off - origOff;
- }
-
- public void reset() throws IOException
- {
- in.reset();
- lineNumber = markLineNumber;
- justReadReturnChar = false;
- }
-
- public void setLineNumber(int lineNumber)
- {
- this.lineNumber = lineNumber;
- }
-
- public long skip(long n) throws IOException
- {
- if (n <= 0)
- return 0L;
-
- final long origN = n;
-
- do
- {
- int ch = read();
- if (ch < 0)
- break;
- if (ch == '\n' || ch == '\r')
- lineNumber++;
- }
- while (--n > 0);
-
- return origN - n;
- }
-}
diff --git a/libjava/java/io/LineNumberReader.java b/libjava/java/io/LineNumberReader.java
deleted file mode 100644
index ffdd2b68e2e..00000000000
--- a/libjava/java/io/LineNumberReader.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 22, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- *
- * This implementation has the feature that if '\r' is read, it
- * does not look for a '\n', but immediately returns '\n'.
- * On the next read(), if a '\n' is read, it is skipped.
- * This has the advantage that we do not read (and hang) unnecessarily.
- *
- * This implementation is also minimal in the number of fields it uses.
- */
-
-public class LineNumberReader extends BufferedReader
-{
- /** The current line number. */
- int lineNumber;
-
- public LineNumberReader(Reader in)
- {
- super(in, 8192);
- }
-
- public LineNumberReader(Reader in, int size)
- {
- super(in, size);
- }
-
- public int getLineNumber()
- {
- return lineNumber;
- }
-
- public void setLineNumber(int lineNumber)
- {
- this.lineNumber = lineNumber;
- }
-
- private static int countLines (char[] buffer, int off, int len)
- {
- int count = 0;
- char prev = '\0';
- for (int i = 0; i < len; i++)
- {
- char ch = buffer[i+off];
- if ((ch == '\n' && prev != '\r') || ch == '\r')
- count++;
- prev = ch;
- }
- return count;
- }
-
- public void mark(int readLimit) throws IOException
- {
- synchronized (lock)
- {
- // This is basically the same as BufferedReader.mark.
- // However, if the previous character was a '\r', we need to
- // save that 'r', in case the next character is a '\n'.
- if (pos + readLimit > limit)
- {
- int saveCR = (pos > 0 && buffer[pos-1] == '\r') ? 1 : 0;
- char[] old_buffer = buffer;
- if (readLimit > limit)
- buffer = new char[saveCR + readLimit];
- int copy_start = pos - saveCR;
- limit -= copy_start;
- System.arraycopy(old_buffer, copy_start, buffer, 0, limit);
- pos = saveCR;
- }
- markPos = pos;
- }
- }
-
- public void reset() throws IOException
- {
- synchronized (lock)
- {
- if (markPos < 0)
- throw new IOException("mark never set or invalidated");
- if (markPos > 0 && pos > markPos && buffer[markPos-1] == '\r'
- && buffer[markPos] == '\n')
- lineNumber--;
- lineNumber -= countLines(buffer, pos, markPos);
- pos = markPos;
- }
- }
-
- public int read() throws IOException
- {
- synchronized (lock)
- {
- skipRedundantLF();
- if (pos >= limit)
- {
- if (markPos >= 0 && limit == buffer.length)
- markPos = -1;
- if (markPos <= 0)
- pos = limit = 0;
- int count = in.read(buffer, limit, buffer.length - limit);
- if (count <= 0)
- return -1;
- limit += count;
- }
- char ch = buffer[pos++];
- if (ch == '\r' || ch == '\n')
- {
- lineNumber++;
- return '\n';
- }
- return (int) ch;
- }
- }
-
- public int read(char[] buf, int offset, int count) throws IOException
- {
- if (count <= 0)
- {
- if (count < 0)
- throw new IndexOutOfBoundsException();
- return 0;
- }
- synchronized (lock)
- {
- int first = read();
- if (first < 0)
- return -1;
- int start_offset = offset;
- buf[offset++] = (char) first;
- if (buffer[pos-1] == '\r' && pos < limit && buffer[pos] == '\n')
- pos++;
- count--;
- while (count-- > 0 && pos < limit)
- {
- char ch = buffer[pos++];
- if (ch == '\r')
- {
- lineNumber++;
- ch = '\n';
- if (pos < limit && buffer[pos] == '\n')
- pos++;
- }
- else if (ch == '\n')
- lineNumber++;
- buf[offset++] = ch;
- }
- return offset - start_offset;
- }
- }
-
- private void skipRedundantLF() throws IOException
- {
- if (pos > 0 && buffer[pos-1] == '\r')
- {
- if (pos < limit)
- { // fast case
- if (buffer[pos] == '\n')
- pos++;
- }
- else
- { // use read() to deal with the general case.
- // Set pos and limit to zero to avoid infinite recursion in read.
- // May need to invalidate markPos if we've exceeded the buffer.
- if (pos >= buffer.length)
- markPos = -1;
- pos = limit = 0;
- int ch = read();
- if (ch >= 0 && ch != '\n')
- pos--;
- }
- }
- }
-
- public String readLine() throws IOException
- {
- // BufferedReader.readLine already does this. Shouldn't need to keep
- // track of newlines (since the read method deals with this for us).
- // But if the buffer is large, we may not call the read method at all
- // and super.readLine can't increment lineNumber itself.
- // Though it may seem kludgy, the safest thing to do is to save off
- // lineNumber and increment it explicitly when we're done (iff we
- // ended with a '\n' or '\r' as opposed to EOF).
- //
- // Also, we need to undo the special casing done by BufferedReader.readLine
- // when a '\r' is the last char in the buffer. That situation is marked
- // by 'pos > limit'.
- int tmpLineNumber = lineNumber;
- skipRedundantLF();
- String str = super.readLine();
- if (pos > limit)
- --pos;
-
- int ch;
- if (pos > 0 && ((ch = buffer[pos - 1]) == '\n' || ch == '\r'))
- lineNumber = tmpLineNumber + 1;
-
- return str;
- }
-
- public long skip(long count) throws IOException
- {
- if (count <= 0)
- return 0;
- long to_do = count;
- do
- {
- int ch = read();
- if (ch < 0)
- break;
- to_do--;
- if (ch == '\n' || ch == '\r')
- lineNumber++;
- else
- {
- long fence = pos + to_do;
- if (limit < fence)
- fence = limit;
- int end = pos;
- for (; end < fence; end++)
- {
- char endch = buffer[end];
- if (endch == '\n' || endch == '\r')
- break;
- }
- to_do -= end - pos;
- pos = end;
- }
- }
- while (to_do > 0);
- return count - to_do;
- }
-}
diff --git a/libjava/java/io/OutputStream.java b/libjava/java/io/OutputStream.java
deleted file mode 100644
index 46770394b22..00000000000
--- a/libjava/java/io/OutputStream.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// OutputStream.java - Send output bytes to output sink.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to version 1.1.
- */
-
-public abstract class OutputStream
-{
- public abstract void write (int b) throws IOException;
-
- public void write (byte[] b) throws IOException, NullPointerException
- {
- write (b, 0, b.length);
- }
-
- public void write (byte[] b, int off, int len)
- throws IOException, NullPointerException, IndexOutOfBoundsException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException ();
- for (int i = 0; i < len; ++i)
- write (b[off + i]);
- }
-
- public void flush () throws IOException
- {
- }
-
- public void close () throws IOException
- {
- }
-}
diff --git a/libjava/java/io/OutputStreamWriter.java b/libjava/java/io/OutputStreamWriter.java
deleted file mode 100644
index 2fe64772b5b..00000000000
--- a/libjava/java/io/OutputStreamWriter.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-import gnu.gcj.convert.UnicodeToBytes;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 17, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct, but only supports 8859_1.
- */
-
-public class OutputStreamWriter extends Writer
-{
- BufferedOutputStream out;
-
- UnicodeToBytes converter;
-
- /* Temporary buffer. */
- private char[] work;
- private int wcount;
-
- public String getEncoding() { return converter.getName(); }
-
- private OutputStreamWriter(OutputStream out, UnicodeToBytes encoder)
- {
- this.out = out instanceof BufferedOutputStream
- ? (BufferedOutputStream) out
- : new BufferedOutputStream(out, 250);
- /* Don't need to call super(out) here as long as the lock gets set. */
- this.lock = out;
- this.converter = encoder;
- }
-
- public OutputStreamWriter(OutputStream out, String enc)
- throws UnsupportedEncodingException
- {
- this(out, UnicodeToBytes.getEncoder(enc));
- }
-
- public OutputStreamWriter(OutputStream out)
- {
- this(out, UnicodeToBytes.getDefaultEncoder());
- }
-
- public void close() throws IOException
- {
- synchronized (lock)
- {
- flush();
- if (out != null)
- {
- out.close();
- out = null;
- }
- work = null;
- }
- }
-
- public void flush() throws IOException
- {
- synchronized (lock)
- {
- if (wcount > 0)
- {
- writeChars(work, 0, wcount);
- wcount = 0;
- }
- out.flush();
- }
- }
-
- public void write(char[] buf, int offset, int count)
- throws IOException
- {
- synchronized (lock)
- {
- if (wcount > 0)
- {
- writeChars(work, 0, wcount);
- wcount = 0;
- }
- writeChars(buf, offset, count);
- }
- }
-
- /** Writes characters through to the inferior BufferedOutputStream.
- * Ignores wcount and the work buffer. */
- private void writeChars(char[] buf, int offset, int count)
- throws IOException
- {
- while (count > 0)
- {
- // We must flush if out.count == out.buf.length.
- // It is probably a good idea to flush if out.buf is almost full.
- // This test is an approximation for "almost full".
- if (out.count + count >= out.buf.length)
- {
- out.flush();
- if (out.count != 0)
- throw new IOException("unable to flush output byte buffer");
- }
- converter.setOutput(out.buf, out.count);
- int converted = converter.write(buf, offset, count);
- offset += converted;
- count -= converted;
- out.count = converter.count;
- }
- }
-
- public void write(String str, int offset, int count)
- throws IOException
- {
- synchronized (lock)
- {
- if (work == null)
- work = new char[100];
- int wlength = work.length;
- while (count > 0)
- {
- int size = count;
- if (wcount + size > wlength)
- {
- if (2*wcount > wlength)
- {
- writeChars(work, 0, wcount);
- wcount = 0;
- }
- if (wcount + size > wlength)
- size = wlength - wcount;
- }
- str.getChars(offset, offset+size, work, wcount);
- offset += size;
- count -= size;
- wcount += size;
- }
- }
- }
-
- public void write(int ch) throws IOException
- {
- synchronized (lock)
- {
- if (work == null)
- work = new char[100];
- if (wcount >= work.length)
- {
- writeChars(work, 0, wcount);
- wcount = 0;
- }
- work[wcount++] = (char) ch;
- }
- }
-}
diff --git a/libjava/java/io/PipedInputStream.java b/libjava/java/io/PipedInputStream.java
deleted file mode 100644
index d2dbecbba11..00000000000
--- a/libjava/java/io/PipedInputStream.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 29, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class PipedInputStream extends InputStream
-{
- /* The size of the pipe's circular input buffer. */
- protected static final int PIPE_SIZE = 1024;
-
- /* The circular buffer into which incoming data is placed. */
- protected byte[] buffer;
-
- /* The index in the buffer at which the next byte of data will be stored. */
- protected int in = -1;
-
- /* The index in the buffer at which the next byte of data will be read. */
- protected int out = 0;
-
- /* The output stream this is connected to; used to check for errors. */
- private PipedOutputStream po = null;
-
- /* Flag to indicate that the output stream was closed. */
- private boolean outClosed = false;
-
- public PipedInputStream(PipedOutputStream src) throws IOException
- {
- buffer = new byte[PIPE_SIZE];
- connect(src);
- }
-
- public PipedInputStream()
- {
- buffer = new byte[PIPE_SIZE];
- }
-
- public synchronized int available() throws IOException
- {
- if (in < 0)
- return 0;
-
- if (in > out)
- return in - out;
-
- // Buffer has wrapped around.
- return buffer.length - out + in;
- }
-
- public void close() throws IOException
- {
- buffer = null;
- po = null;
-
- // Mark as empty for available method.
- in = -1;
- }
-
- public void connect(PipedOutputStream src) throws IOException
- {
- if (buffer == null)
- throw new IOException("pipe closed");
-
- if (po != null)
- if (po == src)
- return;
- else
- throw new IOException("pipe already connected");
-
- po = src;
- try
- {
- src.connect(this);
- }
- catch (IOException ex)
- {
- po = null;
- throw ex;
- }
- }
-
- public synchronized int read() throws IOException
- {
- // TBD: Spec says to throw IOException if thread writing to output stream
- // died. What does this really mean? Theoretically, multiple threads
- // could be writing to this object. Do you track the first, last, or
- // all of them?
- if (po == null)
- if (buffer == null)
- throw new IOException("pipe closed");
- else
- throw new IOException("pipe unconnected");
-
- // Block until there's something to read or output stream was closed.
- while (in < 0)
- try
- {
- if (outClosed)
- return -1;
- wait();
- }
- catch (InterruptedException ex)
- {
- throw new InterruptedIOException();
- }
-
- // Let other threads know there's room to write now.
- notifyAll();
-
- int retval = buffer[out++] & 0xFF;
-
- // Wrap back around if at end of the array.
- if (out >= buffer.length)
- out = 0;
-
- // When the last byte available is read, mark the buffer as empty.
- if (out == in)
- {
- in = -1;
- out = 0;
- }
-
- return retval;
- }
-
- public synchronized int read(byte[] b, int off, int len) throws IOException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- // TBD: Spec says to throw IOException if thread writing to output stream
- // died. What does this really mean? Theoretically, multiple threads
- // could be writing to this object. Do you track the first, last, or
- // all of them?
- if (po == null)
- if (buffer == null)
- throw new IOException("pipe closed");
- else
- throw new IOException("pipe unconnected");
-
- // Block until there's something to read or output stream was closed.
- while (in < 0)
- try
- {
- if (outClosed)
- return -1;
- wait();
- }
- catch (InterruptedException ex)
- {
- throw new InterruptedIOException();
- }
-
- // Let other threads know there's room to write now.
- notifyAll();
-
- int numRead;
- len = Math.min(len, available());
- if (in <= out && len >= (numRead = buffer.length - out))
- {
- // Buffer has wrapped around; need to copy in 2 steps.
- // Copy to the end of the buffer first; second copy may be of zero
- // bytes but that is ok. Doing it that way saves having to check
- // later if 'out' has grown to buffer.length.
- System.arraycopy(buffer, out, b, off, numRead);
- len -= numRead;
- off += numRead;
- out = 0;
- }
- else
- numRead = 0;
-
- System.arraycopy(buffer, out, b, off, len);
- numRead += len;
- out += len;
-
- // When the last byte available is read, mark the buffer as empty.
- if (out == in)
- {
- in = -1;
- out = 0;
- }
-
- return numRead;
- }
-
- protected synchronized void receive(int b) throws IOException
- {
- if (buffer == null)
- throw new IOException("pipe closed");
-
- // TBD: Spec says to throw IOException if thread reading from input stream
- // died. What does this really mean? Theoretically, multiple threads
- // could be reading to this object (why else would 'read' be synchronized?).
- // Do you track the first, last, or all of them?
-
- if (b < 0)
- {
- outClosed = true;
- notifyAll(); // In case someone was blocked in a read.
- return;
- }
-
- // Block until there's room in the pipe.
- while (in == out)
- try
- {
- wait();
- }
- catch (InterruptedException ex)
- {
- throw new InterruptedIOException();
- }
-
- // Check if buffer is empty.
- if (in < 0)
- in = 0;
-
- buffer[in++] = (byte) b;
-
- // Wrap back around if at end of the array.
- if (in >= buffer.length)
- in = 0;
-
- // Let other threads know there's something to read when this returns.
- notifyAll();
- }
-}
diff --git a/libjava/java/io/PipedOutputStream.java b/libjava/java/io/PipedOutputStream.java
deleted file mode 100644
index 901fb9e5484..00000000000
--- a/libjava/java/io/PipedOutputStream.java
+++ /dev/null
@@ -1,97 +0,0 @@
-// PipedOutputStream.java - Write bytes to a pipe.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Believed complete and correct.
- */
-
-public class PipedOutputStream extends OutputStream
-{
- public void close () throws IOException
- {
- closed = true;
-
- // Notify PipedInputStream that there is no more data to be had.
- destination.receive(-1);
- }
-
- public void connect (PipedInputStream dest) throws IOException
- {
- if (closed)
- throw new IOException("pipe closed");
-
- if (destination != null)
- if (destination == dest)
- return;
- else
- throw new IOException("pipe already connected");
-
- destination = dest;
- try
- {
- dest.connect(this);
- }
- catch (IOException ex)
- {
- destination = null;
- throw ex;
- }
- }
-
- public synchronized void flush () throws IOException
- {
- // There doesn't seem to be anything to do here.
-
- // TBD: Should this maybe do a notifyAll as a way for the user
- // to wake up the input stream to check for bytes to read? Shouldn't
- // be necessary but if there aren't any bytes, other threads will just
- // go blocak again anyway so it wouldn't hurt.
- }
-
- public PipedOutputStream ()
- {
- closed = false;
- }
-
- public PipedOutputStream (PipedInputStream dest) throws IOException
- {
- closed = false;
- connect (dest);
- }
-
- public void write (int oneByte) throws IOException
- {
- if (closed)
- throw new IOException ();
- destination.receive(oneByte);
- }
-
- public void write (byte[] buffer, int offset, int count) throws IOException
- {
- if (closed)
- throw new IOException ();
- if (offset < 0 || count < 0 || offset + count > buffer.length)
- throw new ArrayIndexOutOfBoundsException ();
- for (int i = 0; i < count; ++i)
- destination.receive (buffer[offset + i]);
- }
-
- // Instance variables.
- private PipedInputStream destination;
- private boolean closed;
-}
diff --git a/libjava/java/io/PipedReader.java b/libjava/java/io/PipedReader.java
deleted file mode 100644
index faac9865cb8..00000000000
--- a/libjava/java/io/PipedReader.java
+++ /dev/null
@@ -1,210 +0,0 @@
-// PipedReader.java - Piped character stream.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class PipedReader extends Reader
-{
- public void close () throws IOException
- {
- closed = true;
- }
-
- public void connect (PipedWriter src) throws IOException
- {
- if (closed)
- throw new IOException ("already closed");
- if (writer != null)
- {
- if (writer == src)
- return;
- throw new IOException ("already connected");
- }
- try
- {
- writer = src;
- writer.connect(this);
- }
- catch (IOException e)
- {
- writer = null;
- throw e;
- }
- }
-
- public PipedReader ()
- {
- super ();
- writer = null;
- closed = false;
- in = -1;
- out = 0;
- pipeBuffer = new char[1024];
- }
-
- public PipedReader (PipedWriter src) throws IOException
- {
- super ();
- closed = false;
- in = -1;
- out = 0;
- pipeBuffer = new char[1024];
- connect (src);
- }
-
- public int read (char buf[], int offset, int count) throws IOException
- {
- if (closed)
- throw new IOException ("closed");
- if (count < 0)
- throw new ArrayIndexOutOfBoundsException ();
- int toCopy = count;
- synchronized (lock)
- {
- while (toCopy > 0)
- {
- // Wait for data in the pipe. If the writer is closed and
- // no data has been copied into the output buffer, return
- // the magic EOF number.
- while (in == -1)
- {
- if (writer.isClosed())
- {
- if (toCopy < count)
- return count - toCopy;
- return -1;
- }
-
- // Note that JCL doesn't say this is the right thing
- // to do. Still, it feels right, and we must deal
- // with an interrupt somehow.
- try
- {
- lock.wait();
- }
- catch (InterruptedException e)
- {
- InterruptedIOException io
- = new InterruptedIOException (e.getMessage());
- io.bytesTransferred = count - toCopy;
- throw io;
- }
- }
- // Now copy some data from pipe into user buffer.
- int len;
- if (in < out)
- len = pipeBuffer.length - out;
- else
- len = in - out;
- len = len > toCopy ? toCopy : len;
- System.arraycopy(pipeBuffer, out, buf, offset, len);
- out += len;
- if (out == pipeBuffer.length)
- out = 0;
- toCopy -= len;
- offset += len;
- // If we've read all the data, then reset so that we know
- // there is nothing left to be read.
- if (in == out)
- in = -1;
- // Tell anybody waiting for space in the buffer.
- lock.notifyAll();
- }
- }
- return count;
- }
-
- void receive (char buf[], int offset, int count) throws IOException
- {
- if (count < 0)
- throw new ArrayIndexOutOfBoundsException ();
- int original = count;
- synchronized (lock)
- {
- while (count > 0)
- {
- // Wait until there is some space in the buffer.
- while (in == out)
- {
- try
- {
- lock.wait();
- }
- catch (InterruptedException e)
- {
- // Turn interrupts into IO interrupts.
- InterruptedIOException io
- = new InterruptedIOException (e.getMessage());
- io.bytesTransferred = original - count;
- throw io;
- }
- }
-
- // Compute destination in the pipe.
- int base, len;
- if (in == -1)
- {
- base = 0;
- len = pipeBuffer.length;
- }
- else if (in < out)
- {
- base = in;
- len = out - in;
- }
- else
- {
- base = in;
- len = pipeBuffer.length - in;
- }
- int copyLen = len > count ? count : len;
- // Copy data and update local state.
- System.arraycopy(buf, offset, pipeBuffer, base, copyLen);
- in = base + copyLen;
- if (in == pipeBuffer.length)
- in = 0;
- count -= copyLen;
- offset += copyLen;
- // Tell anybody waiting for data.
- lock.notifyAll();
- }
- }
- }
-
-
- boolean isClosed ()
- {
- return closed;
- }
-
- // The associated writer.
- private PipedWriter writer;
- // True if this reader has been closed.
- boolean closed;
-
- // Index of next character to overwrite when receive() is called.
- // If -1, then that means the buffer is empty.
- private int in;
- // Index of next character to return from read().
- private int out;
-
- // The pipe buffer itself.
- private char[] pipeBuffer;
-}
diff --git a/libjava/java/io/PipedWriter.java b/libjava/java/io/PipedWriter.java
deleted file mode 100644
index 7efed3976da..00000000000
--- a/libjava/java/io/PipedWriter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-// PipedWriter.java - Piped character stream.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class PipedWriter extends Writer
-{
- public void close () throws IOException
- {
- closed = true;
- }
-
- public void connect (PipedReader sink) throws IOException
- {
- if (closed)
- throw new IOException ("already closed");
- if (reader != null)
- {
- if (reader == sink)
- return;
- throw new IOException ("already connected");
- }
- try
- {
- reader = sink;
- reader.connect(this);
- }
- catch (IOException e)
- {
- reader = null;
- throw e;
- }
- }
-
- public void flush () throws IOException
- {
- // We'll throw an exception if we're closed, but there's nothing
- // else to do here.
- if (closed)
- throw new IOException ("closed");
- }
-
- public PipedWriter ()
- {
- super ();
- closed = false;
- }
-
- public PipedWriter (PipedReader sink) throws IOException
- {
- super ();
- closed = false;
- connect (sink);
- }
-
- public void write (char buffer[], int offset, int count) throws IOException
- {
- if (closed)
- throw new IOException ("closed");
- reader.receive(buffer, offset, count);
- }
-
- boolean isClosed ()
- {
- return closed;
- }
-
- // The associated reader.
- private PipedReader reader;
- private boolean closed;
-}
diff --git a/libjava/java/io/PrintStream.java b/libjava/java/io/PrintStream.java
deleted file mode 100644
index 4df8748e217..00000000000
--- a/libjava/java/io/PrintStream.java
+++ /dev/null
@@ -1,302 +0,0 @@
-// PrintStream.java - Print string representations
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-import gnu.gcj.convert.UnicodeToBytes;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Not finished.
- */
-
-public class PrintStream extends FilterOutputStream
-{
- /* Notice the implementation is quite similar to OutputStreamWriter.
- * This leads to some minor duplication, because neither inherits
- * from the other, and we want to maximize performance. */
-
- public boolean checkError ()
- {
- return error;
- }
-
- public void close ()
- {
- try
- {
- out.close();
- }
- catch (IOException e)
- {
- setError ();
- }
- }
-
- public void flush ()
- {
- try
- {
- out.flush();
- }
- catch (IOException e)
- {
- setError ();
- }
- }
-
- private synchronized void print (String str, boolean println)
- {
- try
- {
- writeChars(str, 0, str.length());
- if (println)
- writeChars(line_separator, 0, line_separator.length);
- if (auto_flush)
- flush();
- }
- catch (IOException e)
- {
- setError ();
- }
- }
-
- private synchronized void print (char[] chars, int pos, int len,
- boolean println)
- {
- try
- {
- writeChars(chars, pos, len);
- if (println)
- writeChars(line_separator, 0, line_separator.length);
- if (auto_flush)
- flush();
- }
- catch (IOException e)
- {
- setError ();
- }
- }
-
- /** Writes characters through to the inferior BufferedOutputStream. */
- private void writeChars(char[] buf, int offset, int count)
- throws IOException
- {
- while (count > 0)
- {
- // We must flush if out.count == out.buf.length.
- // It is probably a good idea to flush if out.buf is almost full.
- // This test is an approximation for "almost full".
- if (out.count + count >= out.buf.length)
- {
- out.flush();
- if (out.count != 0)
- throw new IOException("unable to flush output byte buffer");
- }
- converter.setOutput(out.buf, out.count);
- int converted = converter.write(buf, offset, count);
- offset += converted;
- count -= converted;
- out.count = converter.count;
- }
- }
-
- private void writeChars(String str, int offset, int count)
- throws IOException
- {
- while (count > 0)
- {
- // We must flush if out.count == out.buf.length.
- // It is probably a good idea to flush if out.buf is almost full.
- // This test is an approximation for "almost full".
- if (out.count + count >= out.buf.length)
- {
- out.flush();
- if (out.count != 0)
- throw new IOException("unable to flush output byte buffer");
- }
- converter.setOutput(out.buf, out.count);
- int converted = converter.write(str, offset, count, work);
- offset += converted;
- count -= converted;
- out.count = converter.count;
- }
- }
-
- public void print (boolean bool)
- {
- print(String.valueOf(bool), false);
- }
-
- public void print (int inum)
- {
- print(String.valueOf(inum), false);
- }
-
- public void print (long lnum)
- {
- print(String.valueOf(lnum), false);
- }
-
- public void print (float fnum)
- {
- print(String.valueOf(fnum), false);
- }
-
- public void print (double dnum)
- {
- print(String.valueOf(dnum), false);
- }
-
- public void print (Object obj)
- {
- print(obj == null ? "null" : obj.toString(), false);
- }
-
- public void print (String str)
- {
- print(str == null ? "null" : str, false);
- }
-
- public synchronized void print (char ch)
- {
- work[0] = ch;
- print(work, 0, 1, false);
- }
-
- public void print (char[] charArray)
- {
- print(charArray, 0, charArray.length, false);
- }
-
- public void println ()
- {
- print(line_separator, 0, line_separator.length, false);
- }
-
- public void println (boolean bool)
- {
- print(String.valueOf(bool), true);
- }
-
- public void println (int inum)
- {
- print(String.valueOf(inum), true);
- }
-
- public void println (long lnum)
- {
- print(String.valueOf(lnum), true);
- }
-
- public void println (float fnum)
- {
- print(String.valueOf(fnum), true);
- }
-
- public void println (double dnum)
- {
- print(String.valueOf(dnum), true);
- }
-
- public void println (Object obj)
- {
- print(obj == null ? "null" : obj.toString(), true);
- }
-
- public void println (String str)
- {
- print (str == null ? "null" : str, true);
- }
-
- public synchronized void println (char ch)
- {
- work[0] = ch;
- print(work, 0, 1, true);
- }
-
- public void println (char[] charArray)
- {
- print(charArray, 0, charArray.length, true);
- }
-
- public PrintStream (OutputStream out)
- {
- this(out, false);
- }
-
- public PrintStream (OutputStream out, boolean af)
- {
- super(out);
- if (out instanceof BufferedOutputStream)
- this.out = (BufferedOutputStream) out;
- else
- {
- this.out = new BufferedOutputStream(out, 250);
- /* PrintStream redefines "out". Explicitly reset FilterOutputStream's
- * "out" so that they're referring to the same thing. */
- super.out = this.out;
- }
- converter = UnicodeToBytes.getDefaultEncoder();
- error = false;
- auto_flush = af;
- }
-
- protected void setError ()
- {
- error = true;
- }
-
- public void write (int oneByte)
- {
- try
- {
- out.write(oneByte);
- if (auto_flush && oneByte == '\n')
- out.flush();
- }
- catch (IOException e)
- {
- setError ();
- }
- }
-
- public void write (byte[] buffer, int offset, int count)
- {
- try
- {
- out.write(buffer, offset, count);
- if (auto_flush)
- out.flush();
- }
- catch (IOException e)
- {
- setError ();
- }
- }
-
- BufferedOutputStream out;
- UnicodeToBytes converter;
-
- char[] work = new char[100];
-
- // True if error occurred.
- private boolean error;
- // True if auto-flush.
- private boolean auto_flush;
-
- // Line separator string.
- private static final char[] line_separator
- = System.getProperty("line.separator").toCharArray();
-}
diff --git a/libjava/java/io/PrintWriter.java b/libjava/java/io/PrintWriter.java
deleted file mode 100644
index fab152ba485..00000000000
--- a/libjava/java/io/PrintWriter.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 17, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- * However, should use native methods for conversion.
- */
-
-public class PrintWriter extends Writer
-{
- private boolean autoflush;
- private boolean error;
- Writer out;
-
- public PrintWriter(Writer wr)
- {
- super(wr);
- this.out = wr;
- }
-
- public PrintWriter(Writer wr, boolean autoflush)
- {
- super(wr);
- this.out = wr;
- this.autoflush = autoflush;
- }
-
- public PrintWriter(OutputStream out)
- {
- super();
- this.out = new OutputStreamWriter(out);
- this.lock = this.out;
- }
-
- public PrintWriter(OutputStream out, boolean autoflush)
- {
- this(out);
- this.autoflush = autoflush;
- }
- protected void setError() { error = true; }
-
- public boolean checkError()
- {
- flush();
- return error;
- }
-
- public void flush()
- {
- try
- {
- out.flush();
- }
- catch (IOException ex)
- {
- error = true;
- }
- }
-
- public void close()
- {
- try
- {
- out.close();
- }
- catch (IOException ex)
- {
- error = true;
- }
- }
-
- public void print(String str)
- {
- try
- {
- out.write(str == null ? "null" : str);
- }
- catch (IOException ex)
- {
- error = true;
- }
- }
-
- public void print(char ch)
- {
- write((int) ch);
- }
-
- public void print(char[] charArray)
- {
- write(charArray, 0, charArray.length);
- }
-
- public void print(boolean bool)
- {
- print(bool ? "true" : "false");
- }
-
- public void print(int inum)
- {
- print(Integer.toString(inum));
- }
-
- public void print(long lnum)
- {
- print(Long.toString(lnum));
- }
-
- public void print(float fnum)
- {
- print(Float.toString(fnum));
- }
-
- public void print(double dnum)
- {
- print(Double.toString(dnum));
- }
-
- public void print(Object obj)
- {
- print(obj == null ? "null" : obj.toString());
- }
-
- private static final char[] line_separator
- = System.getProperty("line.separator").toCharArray();
-
- public void println()
- {
- synchronized (lock)
- {
- printlnUnsynchronized();
- }
- }
-
- private void printlnUnsynchronized()
- {
- try
- {
- write(line_separator, 0, line_separator.length);
- if (autoflush)
- out.flush();
- }
- catch (IOException ex)
- {
- error = true;
- }
- }
-
- public void println(boolean bool)
- {
- synchronized (lock)
- {
- print(bool);
- printlnUnsynchronized();
- }
- }
- public void println(int inum)
- {
- synchronized (lock)
- {
- print(inum);
- printlnUnsynchronized();
- }
- }
-
- public void println(long lnum)
- {
- synchronized (lock)
- {
- print(lnum);
- printlnUnsynchronized();
- }
- }
-
- public void println(float fnum)
- {
- synchronized (lock)
- {
- print(fnum);
- printlnUnsynchronized();
- }
- }
-
- public void println(double dnum)
- {
- synchronized (lock)
- {
- print(dnum);
- printlnUnsynchronized();
- }
- }
-
- public void println(Object obj)
- {
- synchronized (lock)
- {
- print(obj);
- printlnUnsynchronized();
- }
- }
-
- public void println(String str)
- {
- synchronized (lock)
- {
- print(str);
- printlnUnsynchronized();
- }
- }
-
- public void println(char ch)
- {
- synchronized (lock)
- {
- print(ch);
- printlnUnsynchronized();
- }
- }
-
- public void println(char[] charArray)
- {
- synchronized (lock)
- {
- print(charArray);
- printlnUnsynchronized();
- }
- }
-
- public void write(int ch)
- {
- try
- {
- out.write(ch);
- }
- catch (IOException ex)
- {
- error = true;
- }
- }
-
- public void write(char[] charArray, int offset, int count)
- {
- try
- {
- out.write(charArray, offset, count);
- }
- catch (IOException ex)
- {
- error = true;
- }
- }
-
- public void write(String str, int offset, int count)
- {
- try
- {
- out.write(str, offset, count);
- }
- catch (IOException ex)
- {
- error = true;
- }
- }
-
- public void write(char[] charArray)
- {
- write(charArray, 0, charArray.length);
- }
-
- public void write(String str)
- {
- write(str, 0, str.length());
- }
-}
diff --git a/libjava/java/io/PushbackInputStream.java b/libjava/java/io/PushbackInputStream.java
deleted file mode 100644
index c104cf2f407..00000000000
--- a/libjava/java/io/PushbackInputStream.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 15, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class PushbackInputStream extends FilterInputStream
-{
- /* Internal buffer array for data. */
- protected byte[] buf;
-
- /* The current position in the buffer. */
- protected int pos;
-
- public PushbackInputStream(InputStream in)
- {
- this(in, 1);
- }
-
- public PushbackInputStream(InputStream in, int size)
- {
- super(in);
- if (size < 0)
- throw new IllegalArgumentException();
- buf = new byte[size];
- pos = buf.length;
- }
-
- public int available() throws IOException
- {
- return pos + super.available();
- }
-
- public void close() throws IOException
- {
- buf = null;
- super.close();
- }
-
- public boolean markSupported()
- {
- return false;
- }
-
- public int read() throws IOException
- {
- if (pos < buf.length)
- return ((int) buf[pos++]) & 0xFF;
-
- return super.read();
- }
-
- public int read(byte[] b, int off, int len) throws IOException
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- int numBytes = Math.min(buf.length - pos, len);
- for (int i = 0; i < numBytes; i++)
- b[off++] = buf[pos++];
-
- // `off' was just incremented to include `numBytes', so we can
- // just pass ithere.
- return numBytes + super.read(b, off, len - numBytes);
- }
-
- public void unread(int b) throws IOException
- {
- if (pos <= 0)
- throw new IOException();
-
- buf[--pos] = (byte) b;
- }
-
- public void unread(byte[] b) throws IOException
- {
- unread(b, 0, b.length);
- }
-
- public void unread(byte[] b, int off, int len) throws IOException
- {
- if (pos < len)
- throw new IOException();
-
- // Note the order that these bytes are being added is the opposite
- // of what would be done if they were added to the buffer one at a time.
- // See the Java Class Libraries book p. 1390.
- System.arraycopy(b, off, buf, pos - len, len);
-
- // Don't put this into the arraycopy above, an exception might be thrown
- // and in that case we don't want to modify pos.
- pos -= len;
- }
-
- // JDK1.2
- public long skip(long n) throws IOException
- {
- final long origN = n;
-
- if (n > 0L)
- {
- int numread = (int) Math.min((long) (buf.length - pos), n);
- pos += numread;
- n -= numread;
- n -= super.skip(n);
- }
-
- return origN - n;
- }
-}
diff --git a/libjava/java/io/PushbackReader.java b/libjava/java/io/PushbackReader.java
deleted file mode 100644
index d5d8d441258..00000000000
--- a/libjava/java/io/PushbackReader.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 16, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class PushbackReader extends FilterReader
-{
- /* Internal buffer array for data. */
- private char[] buf;
-
- /* The current position in the buffer. */
- private int pos;
-
- public PushbackReader(Reader in)
- {
- this(in, 1);
- }
-
- public PushbackReader(Reader in, int size)
- {
- super(in);
- if (size < 0)
- throw new IllegalArgumentException();
- buf = new char[size];
- pos = buf.length;
- }
-
- public void close() throws IOException
- {
- synchronized (lock)
- {
- buf = null;
- super.close();
- }
- }
-
- public boolean markSupported()
- {
- return false;
- }
-
- public int read() throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- if (pos < buf.length)
- return ((int) buf[pos++]) & 0xFFFF;
-
- return super.read();
- }
- }
-
- public int read(char[] b, int off, int len) throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- int numBytes = Math.min(buf.length - pos, len);
- for (int i = 0; i < numBytes; i++)
- b[off++] = buf[pos++];
-
- return numBytes + super.read(b, off, len - numBytes);
- }
- }
-
- public boolean ready() throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- if (buf.length - pos > 0)
- return true;
-
- return super.ready();
- }
- }
-
- public void unread(int b) throws IOException
- {
- synchronized (lock)
- {
- if (buf == null || pos <= 0)
- throw new IOException();
-
- buf[--pos] = (char) b;
- }
- }
-
- public void unread(char[] b) throws IOException
- {
- unread(b, 0, b.length);
- }
-
- public void unread(char[] b, int off, int len) throws IOException
- {
- synchronized (lock)
- {
- if (buf == null || pos < len)
- throw new IOException();
-
- // Note the order that these chars are being added is the opposite
- // of what would be done if they were added to the buffer one at a time.
- // See the Java Class Libraries book p. 1397.
- System.arraycopy(b, off, buf, pos - len, len);
-
- // Don't put this into the arraycopy above, an exception might be thrown
- // and in that case we don't want to modify pos.
- pos -= len;
- }
- }
-}
diff --git a/libjava/java/io/RandomAccessFile.java b/libjava/java/io/RandomAccessFile.java
deleted file mode 100644
index d054afc2033..00000000000
--- a/libjava/java/io/RandomAccessFile.java
+++ /dev/null
@@ -1,247 +0,0 @@
-// RandomAccessFile.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Believe complete and correct to 1.1.
- */
-
-public class RandomAccessFile implements DataOutput, DataInput
-{
- public void close () throws IOException
- {
- fd.close();
- }
-
- public final FileDescriptor getFD () throws IOException
- {
- if (! fd.valid())
- throw new IOException ();
- return fd;
- }
-
- public long getFilePointer () throws IOException
- {
- return fd.getFilePointer();
- }
-
- public long length () throws IOException
- {
- return fd.length();
- }
-
- public RandomAccessFile (String fileName, String mode) throws IOException
- {
- int fdmode;
- if (mode.compareTo ("r") == 0)
- fdmode = FileDescriptor.READ;
- else if (mode.compareTo ("rw") == 0)
- fdmode = FileDescriptor.READ | FileDescriptor.WRITE;
- else
- throw new IllegalArgumentException ("invalid mode: " + mode);
-
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- {
- s.checkRead(fileName);
- if ((fdmode & FileDescriptor.WRITE) != 0)
- s.checkWrite(fileName);
- }
-
- fd = new FileDescriptor (fileName, fdmode);
- out = new DataOutputStream (new FileOutputStream (fd));
- in = new DataInputStream (new FileInputStream (fd));
- }
-
- public RandomAccessFile (File file, String mode) throws IOException
- {
- this (file.getPath(), mode);
- }
-
- public int read () throws IOException
- {
- return in.read();
- }
-
- public int read (byte[] buffer) throws IOException
- {
- return in.read(buffer);
- }
-
- public int read (byte[] buffer, int offset, int count) throws IOException
- {
- return in.read(buffer, offset, count);
- }
-
- public final boolean readBoolean () throws IOException
- {
- return in.readBoolean();
- }
-
- public final byte readByte () throws IOException
- {
- return in.readByte();
- }
-
- public final char readChar () throws IOException
- {
- return in.readChar();
- }
-
- public final double readDouble () throws IOException
- {
- return in.readDouble();
- }
-
- public final float readFloat () throws IOException
- {
- return in.readFloat();
- }
-
- public final void readFully (byte[] buffer) throws IOException
- {
- in.readFully(buffer);
- }
-
- public final void readFully (byte[] buffer, int offset, int count)
- throws IOException
- {
- in.readFully(buffer, offset, count);
- }
-
- public final int readInt () throws IOException
- {
- return in.readInt();
- }
-
- public final String readLine () throws IOException
- {
- return in.readLine();
- }
-
- public final long readLong () throws IOException
- {
- return in.readLong();
- }
-
- public final short readShort () throws IOException
- {
- return in.readShort();
- }
-
- public final int readUnsignedByte () throws IOException
- {
- return in.readUnsignedByte();
- }
-
- public final int readUnsignedShort () throws IOException
- {
- return in.readUnsignedShort();
- }
-
- public final String readUTF () throws IOException
- {
- return in.readUTF();
- }
-
- public void seek (long pos) throws IOException
- {
- fd.seek(pos, FileDescriptor.SET);
- }
-
- public int skipBytes (int count) throws IOException
- {
- return fd.seek(count, FileDescriptor.CUR);
- }
-
- public void write (int oneByte) throws IOException
- {
- out.write(oneByte);
- }
-
- public void write (byte[] buffer) throws IOException
- {
- out.write(buffer);
- }
-
- public void write (byte[] buffer, int offset, int count) throws IOException
- {
- out.write(buffer, offset, count);
- }
-
- public final void writeBoolean (boolean val) throws IOException
- {
- out.writeBoolean(val);
- }
-
- public final void writeByte (int v) throws IOException
- {
- out.writeByte(v);
- }
-
- public final void writeShort (int v) throws IOException
- {
- out.writeShort(v);
- }
-
- public final void writeChar (int v) throws IOException
- {
- out.writeChar(v);
- }
-
- public final void writeInt (int v) throws IOException
- {
- out.writeInt(v);
- }
-
- public final void writeLong (long v) throws IOException
- {
- out.writeLong(v);
- }
-
- public final void writeFloat (float v) throws IOException
- {
- out.writeFloat(v);
- }
-
- public final void writeDouble (double v) throws IOException
- {
- out.writeDouble(v);
- }
-
- public final void writeBytes (String s) throws IOException
- {
- out.writeBytes(s);
- }
-
- public final void writeChars (String s) throws IOException
- {
- out.writeChars(s);
- }
-
- public final void writeUTF (String s) throws IOException
- {
- out.writeUTF(s);
- }
-
-
- // The underlying file.
- private FileDescriptor fd;
- // The corresponding input and output streams.
- private DataOutputStream out;
- private DataInputStream in;
-}
diff --git a/libjava/java/io/Reader.java b/libjava/java/io/Reader.java
deleted file mode 100644
index c8e8f29c6fa..00000000000
--- a/libjava/java/io/Reader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 21, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public abstract class Reader
-{
- protected Object lock;
-
- protected Reader()
- {
- this.lock = this;
- }
-
- protected Reader(Object lock)
- {
- this.lock = lock;
- }
-
- abstract public int read(char buf[], int offset, int count)
- throws IOException;
-
- public int read(char buf[]) throws IOException
- {
- return read(buf, 0, buf.length);
- }
-
- public int read() throws IOException
- {
- char[] buf = new char[1];
- int count = read(buf, 0, 1);
- return count > 0 ? buf[0] : -1;
- }
-
- abstract public void close() throws IOException;
-
- public boolean markSupported()
- {
- return false;
- }
-
- public void mark(int readLimit) throws IOException
- {
- throw new IOException("mark not supported");
- }
-
- public void reset() throws IOException
- {
- throw new IOException("reset not supported");
- }
-
- public boolean ready() throws IOException
- {
- return false;
- }
-
- public long skip(long count) throws IOException
- {
- if (count <= 0)
- return 0;
- int bsize = count > 1024 ? 1024 : (int) count;
- char[] buffer = new char[bsize];
- long todo = count;
- while (todo > 0)
- {
- int skipped = read(buffer, 0, bsize > todo ? (int) todo : bsize);
- if (skipped <= 0)
- break;
- todo -= skipped;
- }
- return count - todo;
- }
-}
diff --git a/libjava/java/io/SequenceInputStream.java b/libjava/java/io/SequenceInputStream.java
deleted file mode 100644
index 054527774ab..00000000000
--- a/libjava/java/io/SequenceInputStream.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-import java.util.Enumeration;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date November 3, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class SequenceInputStream extends InputStream
-{
- /* The handle for the current input stream. */
- private InputStream in;
-
- /* Secondary input stream; not used if constructed w/ enumeration. */
- private InputStream in2;
-
- /* The enum handle; not used if constructed w/ 2 explicit input streams. */
- private Enumeration enum;
-
- public SequenceInputStream(Enumeration e)
- {
- enum = e;
- in = (InputStream) enum.nextElement();
- in2 = null;
- }
-
- public SequenceInputStream(InputStream s1, InputStream s2)
- {
- in = s1;
- in2 = s2;
- }
-
- public int available() throws IOException
- {
- if (in == null)
- return 0;
-
- return in.available();
- }
-
- public void close() throws IOException
- {
- while (in != null)
- {
- in.close();
- in = getNextStream ();
- }
- }
-
- public int read() throws IOException
- {
- int ch = -1;
-
- while (in != null && (ch = in.read()) < 0)
- {
- in.close();
- in = getNextStream();
- }
-
- return ch;
- }
-
- public int read(byte[] b, int off, int len) throws IOException
- {
- int ch = -1;
-
- // The validity of the parameters will be checked by in.read so
- // don't bother doing it here.
- while (in != null && (ch = in.read(b, off, len)) < 0)
- {
- in.close();
- in = getNextStream();
- }
-
- return ch;
- }
-
- private InputStream getNextStream()
- {
- InputStream nextIn = null;
-
- if (enum != null)
- {
- if (enum.hasMoreElements())
- nextIn = (InputStream) enum.nextElement();
- }
- else
- if (in2 != null)
- {
- nextIn = in2;
- in2 = null;
- }
-
- return nextIn;
- }
-}
diff --git a/libjava/java/io/Serializable.java b/libjava/java/io/Serializable.java
deleted file mode 100644
index fab9188d101..00000000000
--- a/libjava/java/io/Serializable.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * Status: Believed complete
- */
-
-public interface Serializable
-{
-}
diff --git a/libjava/java/io/StreamTokenizer.java b/libjava/java/io/StreamTokenizer.java
deleted file mode 100644
index e763cbe7d9a..00000000000
--- a/libjava/java/io/StreamTokenizer.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class StreamTokenizer
-{
- /* A constant indicating that the end of the stream has been read. */
- public static final int TT_EOF = -1;
-
- /* A constant indicating that the end of the line has been read. */
- public static final int TT_EOL = '\n';
-
- /* A constant indicating that a number token has been read. */
- public static final int TT_NUMBER = -2;
-
- /* A constant indicating that a word token has been read. */
- public static final int TT_WORD = -3;
-
- /* Contains the type of the token read resulting from a call to nextToken. */
- public int ttype;
-
- /* The String associated with word and string tokens. */
- public String sval;
-
- /* The numeric value associated with number tokens. */
- public double nval;
-
- /* Indicates whether end-of-line is recognized as a token. */
- private boolean eolSignificant = false;
-
- /* Indicates whether word tokens are automatically made lower case. */
- private boolean lowerCase = false;
-
- /* Indicates whether C++ style comments are recognized and skipped. */
- private boolean slashSlash = false;
-
- /* Indicates whether C style comments are recognized and skipped. */
- private boolean slashStar = false;
-
- /* Attribute tables of each byte from 0x00 to 0xFF. */
- private boolean[] whitespace;
- private boolean[] alphabetic;
- private boolean[] numeric;
- private boolean[] quote;
- private boolean[] comment;
-
- /* The Reader associated with this class. */
- private PushbackReader in;
-
- /* Indicates if a token has been pushed back. */
- private boolean pushedBack = false;
-
- /* Contains the current line number of the reader. */
- private int lineNumber = 1;
-
- // Deprecated in JDK 1.1.
- public StreamTokenizer(InputStream is)
- {
- this(new InputStreamReader(is));
- }
-
- public StreamTokenizer(Reader r)
- {
- in = new PushbackReader(r);
-
- whitespace = new boolean[256];
- alphabetic = new boolean[256];
- numeric = new boolean[256];
- quote = new boolean[256];
- comment = new boolean[256];
- for (int i = 0; i < 256; i++)
- resetChar(i);
-
- whitespaceChars(0x00, 0x20);
- wordChars('A', 'Z');
- wordChars('a', 'z');
- wordChars(0xA0, 0xFF);
- commentChar('/');
- quoteChar('\'');
- quoteChar('"');
- parseNumbers();
- }
-
- public void commentChar(int ch)
- {
- if (ch >= 0 && ch <= 255)
- comment[ch] = true;
- }
-
- public void eolIsSignificant(boolean flag)
- {
- eolSignificant = flag;
- }
-
- public int lineno()
- {
- return lineNumber;
- }
-
- public void lowerCaseMode(boolean flag)
- {
- lowerCase = flag;
- }
-
- private boolean isWhitespace(int ch)
- {
- if (ch >= 0 && ch <= 255)
- return whitespace[ch];
-
- return false;
- }
-
- private boolean isAlphabetic(int ch)
- {
- if (ch >= 0 && ch <= 255)
- return alphabetic[ch];
- else if (ch > 255)
- return true;
-
- return false;
- }
-
- private boolean isNumeric(int ch)
- {
- if (ch >= 0 && ch <= 255)
- return numeric[ch];
-
- return false;
- }
-
- private boolean isQuote(int ch)
- {
- if (ch >= 0 && ch <= 255)
- return quote[ch];
-
- return false;
- }
-
- private boolean isComment(int ch)
- {
- if (ch >= 0 && ch <= 255)
- return comment[ch];
-
- return false;
- }
-
- public int nextToken() throws IOException
- {
- if (pushedBack)
- {
- pushedBack = false;
- return ttype;
- }
-
- sval = null;
- int ch;
-
- // Skip whitespace. Deal with EOL along the way.
- while (isWhitespace(ch = in.read()))
- if (ch == '\n' || ch == '\r')
- {
- lineNumber++;
-
- // Throw away \n if in combination with \r.
- if (ch == '\r' && (ch = in.read()) != '\n')
- {
- if (ch != TT_EOF)
- in.unread(ch);
- }
- if (eolSignificant)
- return (ttype = TT_EOL);
- }
-
- if (ch == TT_EOF)
- ttype = TT_EOF;
- else if (isNumeric(ch))
- {
- if (ch == '-')
- {
- // Read ahead to see if this is an ordinary '-' rather than numeric.
- ch = in.read();
- if (ch != TT_EOF)
- in.unread(ch);
- if (isNumeric(ch) && ch != '-')
- ch = '-';
- else
- return (ttype = '-');
- }
-
- StringBuffer tokbuf = new StringBuffer();
- tokbuf.append((char) ch);
-
- int decCount = 0;
- while (isNumeric(ch = in.read()) && ch != '-')
- if (ch == '.' && decCount++ > 0)
- break;
- else
- tokbuf.append((char) ch);
-
- if (ch != TT_EOF)
- in.unread(ch);
- ttype = TT_NUMBER;
- nval = Double.valueOf(tokbuf.toString()).doubleValue();
- }
- else if (isAlphabetic(ch))
- {
- StringBuffer tokbuf = new StringBuffer();
- tokbuf.append((char) ch);
- while (isAlphabetic(ch = in.read()) || isNumeric(ch))
- tokbuf.append((char) ch);
- if (ch != TT_EOF)
- in.unread(ch);
- ttype = TT_WORD;
- sval = tokbuf.toString();
- if (lowerCase)
- sval.toLowerCase();
- }
- else if (isComment(ch))
- {
- while ((ch = in.read()) != '\n' && ch != '\r' && ch != TT_EOF)
- ;
- if (ch != TT_EOF)
- in.unread(ch);
- return nextToken(); // Recursive, but not too deep in normal cases.
- }
- else if (isQuote(ch))
- {
- ttype = ch;
- StringBuffer tokbuf = new StringBuffer();
- while ((ch = in.read()) != ttype && ch != '\n' && ch != '\r' &&
- ch != TT_EOF)
- {
- if (ch == '\\')
- switch (ch = in.read())
- {
- case 'a': ch = 0x7;
- break;
- case 'b': ch = '\b';
- break;
- case 'f': ch = 0xC;
- break;
- case 'n': ch = '\n';
- break;
- case 'r': ch = '\r';
- break;
- case 't': ch = '\t';
- break;
- case 'v': ch = 0xB;
- break;
- case '\"':
- case '\'':
- case '\\':
- break;
- default:
- int ch1, nextch;
- if ((nextch = ch1 = ch) >= '0' && ch <= '7')
- {
- ch -= '0';
- if ((nextch = in.read()) >= '0' && nextch <= '7')
- {
- ch = ch * 8 + nextch - '0';
- if ((nextch = in.read()) >= '0' && nextch <= '7' &&
- ch1 >= '0' && ch1 <= '3')
- {
- ch = ch * 8 + nextch - '0';
- nextch = in.read();
- }
- }
- }
-
- if (nextch != TT_EOF)
- in.unread(nextch);
- }
-
- tokbuf.append((char) ch);
- }
-
- // Throw away matching quote char.
- if (ch != ttype && ch != TT_EOF)
- in.unread(ch);
-
- sval = tokbuf.toString();
- }
- else
- {
- if (ch == '/')
- if ((ch = in.read()) == '/' && slashSlash)
- {
- while ((ch = in.read()) != '\n' && ch != '\r' && ch != TT_EOF)
- ;
- if (ch != TT_EOF)
- in.unread(ch);
- return nextToken(); // Recursive, but not too deep in normal cases
- }
- else if (ch == '*' && slashStar)
- {
- while (true)
- {
- ch = in.read();
- if (ch == '*')
- {
- if ((ch = in.read()) == '/')
- break;
- else if (ch != TT_EOF)
- in.unread(ch);
- }
- else if (ch == '\n' || ch == '\r')
- {
- lineNumber++;
- if (ch == '\r' && (ch = in.read()) != '\n')
- {
- if (ch != TT_EOF)
- in.unread(ch);
- }
- }
- else if (ch == TT_EOF)
- {
- break;
- }
- }
- return nextToken(); // Recursive, but not too deep in normal cases
- }
- else
- {
- if (ch != TT_EOF)
- in.unread(ch);
- ch = '/';
- }
-
- ttype = ch;
- }
-
- return ttype;
- }
-
- private void resetChar(int ch)
- {
- whitespace[ch] = alphabetic[ch] = numeric[ch] = quote[ch] = comment[ch] =
- false;
- }
-
- public void ordinaryChar(int ch)
- {
- if (ch >= 0 && ch <= 255)
- resetChar(ch);
- }
-
- public void ordinaryChars(int low, int hi)
- {
- if (low < 0)
- low = 0;
- if (hi > 255)
- hi = 255;
- for (int i = low; i <= hi; i++)
- resetChar(i);
- }
-
- public void parseNumbers()
- {
- for (int i = 0; i <= 9; i++)
- numeric['0' + i] = true;
-
- numeric['.'] = true;
- numeric['-'] = true;
- }
-
- public void pushBack()
- {
- // pushBack may cause the lineno method to return an incorrect value
- // if lineno is called before the next call to nextToken.
- pushedBack = true;
- }
-
- public void quoteChar(int ch)
- {
- if (ch >= 0 && ch <= 255)
- quote[ch] = true;
- }
-
- public void resetSyntax()
- {
- ordinaryChars(0x00, 0xFF);
- }
-
- public void slashSlashComments(boolean flag)
- {
- slashSlash = flag;
- }
-
- public void slashStarComments(boolean flag)
- {
- slashStar = flag;
- }
-
- public String toString()
- {
- String tempstr;
- if (ttype == TT_EOF)
- tempstr = "EOF";
- else if (ttype == TT_EOL)
- tempstr = "EOL";
- else if (ttype == TT_WORD)
- tempstr = sval;
- else if (ttype == TT_NUMBER)
- tempstr = "n=" + Double.toString(nval);
- else // must be an ordinary char.
- tempstr = "\'" + (new Character((char) ttype)).toString() + "\'";
-
- return "Token[" + tempstr + "], line " + Integer.toString(lineno());
- }
-
- public void whitespaceChars(int low, int hi)
- {
- if (low < 0)
- low = 0;
- if (hi > 255)
- hi = 255;
- for (int i = low; i <= hi; i++)
- whitespace[i] = true;
- }
-
- public void wordChars(int low, int hi)
- {
- if (low < 0)
- low = 0;
- if (hi > 255)
- hi = 255;
- for (int i = low; i <= hi; i++)
- alphabetic[i] = true;
- }
-}
diff --git a/libjava/java/io/StringBufferInputStream.java b/libjava/java/io/StringBufferInputStream.java
deleted file mode 100644
index 063e19d3fc7..00000000000
--- a/libjava/java/io/StringBufferInputStream.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date November 11, 1998.
- * @deprecated
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct. Deprecated in JDK 1.1.
- */
-
-public class StringBufferInputStream extends InputStream
-{
- /* The String which is the input to this stream. */
- protected String buffer;
-
- /* Position of the next byte in buffer to be read. */
- protected int pos = 0;
-
- /* The length of the String buffer. */
- protected int count;
-
- public StringBufferInputStream(String s)
- {
- buffer = s;
- count = s.length();
- }
-
- public int available()
- {
- return count - pos;
- }
-
- public int read()
- {
- if (pos >= count)
- return -1; // EOF
-
- return ((int) buffer.charAt(pos++)) & 0xFF;
- }
-
- public int read(byte[] b, int off, int len)
- {
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- if (pos >= count)
- return -1; // EOF
-
- int numRead = Math.min(len, count - pos);
- if (numRead < 0)
- return 0;
-
- buffer.getBytes(pos, pos + numRead, b, off);
- pos += numRead;
- return numRead;
- }
-
- public void reset()
- {
- pos = 0;
- }
-
- public long skip(long n)
- {
- if (n < 0)
- return 0L;
-
- long actualSkip = Math.min(n, count - pos);
- pos += actualSkip;
- return actualSkip;
- }
-}
diff --git a/libjava/java/io/StringReader.java b/libjava/java/io/StringReader.java
deleted file mode 100644
index 60a912975af..00000000000
--- a/libjava/java/io/StringReader.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date October 19, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public class StringReader extends Reader
-{
- /* A String provided by the creator of the stream. */
- private String buf;
-
- /* Position of the next char in buf to be read. */
- private int pos;
-
- /* The currently marked position in the stream. */
- private int markedPos;
-
- /* The index in buf one greater than the last valid character. */
- private int count;
-
- public StringReader(String buffer)
- {
- super();
- buf = buffer;
-
- count = buffer.length();
- markedPos = pos = 0;
- }
-
- public void close()
- {
- synchronized (lock)
- {
- buf = null;
- }
- }
-
- public void mark(int readAheadLimit) throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- // readAheadLimit is ignored per Java Class Lib. book, p. 1692.
- markedPos = pos;
- }
- }
-
- public boolean markSupported()
- {
- return true;
- }
-
- public int read() throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- if (pos < count)
- return ((int) buf.charAt(pos++)) & 0xFFFF;
- return -1;
- }
- }
-
- public int read(char[] b, int off, int len) throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- /* Don't need to check pos value, arraycopy will check it. */
- if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
-
- if (pos >= count)
- return -1;
-
- int lastChar = Math.min(count, pos + len);
- buf.getChars(pos, lastChar, b, off);
- int numChars = lastChar - pos;
- pos = lastChar;
- return numChars;
- }
- }
-
- public boolean ready() // TODO12: throws IOException
- {
- // TODO12: The JCL specifically says this returns true even if the
- // reader has been closed, whereas the online 1.2 doc specifically
- // says to throw an IOException if closed.
- return true;
- }
-
- public void reset() throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- pos = markedPos;
- }
- }
-
- public long skip(long n) throws IOException
- {
- synchronized (lock)
- {
- if (buf == null)
- throw new IOException();
-
- // Even though the var numChars is a long, in reality it can never
- // be larger than an int since the result of subtracting 2 positive
- // ints will always fit in an int. Since we have to return a long
- // anyway, numChars might as well just be a long.
- long numChars = Math.min((long) (count - pos), n < 0 ? 0L : n);
- pos += numChars;
- return numChars;
- }
- }
-}
diff --git a/libjava/java/io/StringWriter.java b/libjava/java/io/StringWriter.java
deleted file mode 100644
index 88b0a6ecd44..00000000000
--- a/libjava/java/io/StringWriter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-// StringWriter.java - StringBuffer output stream
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class StringWriter extends Writer
-{
- public void close ()
- {
- // JCL says this does nothing. This seems to violate the Writer
- // contract, in that other methods should still throw and
- // IOException after a close. Still, we just follow JCL.
- }
-
- public void flush ()
- {
- }
-
- public StringBuffer getBuffer ()
- {
- return buffer;
- }
-
- public StringWriter ()
- {
- this (16);
- }
-
- protected StringWriter (int size)
- {
- super ();
- buffer = new StringBuffer (size);
- lock = buffer;
- }
-
- public String toString ()
- {
- return buffer.toString();
- }
-
- public void write (int oneChar)
- {
- buffer.append((char) oneChar);
- }
-
- public void write (char[] chars, int offset, int len)
- {
- buffer.append(chars, offset, len);
- }
-
- public void write (String str)
- {
- buffer.append(str);
- }
-
- public void write (String str, int offset, int len)
- {
- buffer.append(str.substring(offset, offset + len));
- }
-
- // The string buffer.
- private StringBuffer buffer;
-}
diff --git a/libjava/java/io/SyncFailedException.java b/libjava/java/io/SyncFailedException.java
deleted file mode 100644
index 05f4c3dee7b..00000000000
--- a/libjava/java/io/SyncFailedException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// SyncFailedException.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class SyncFailedException extends IOException
-{
- public SyncFailedException ()
- {
- super ();
- }
-
- public SyncFailedException (String s)
- {
- super (s);
- }
-}
diff --git a/libjava/java/io/UTFDataFormatException.java b/libjava/java/io/UTFDataFormatException.java
deleted file mode 100644
index 16445cdcfe5..00000000000
--- a/libjava/java/io/UTFDataFormatException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// UTFDataFormatException.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Complete to 1.1.
- */
-
-public class UTFDataFormatException extends IOException
-{
- public UTFDataFormatException ()
- {
- super ();
- }
-
- public UTFDataFormatException (String s)
- {
- super (s);
- }
-}
diff --git a/libjava/java/io/UnsupportedEncodingException.java b/libjava/java/io/UnsupportedEncodingException.java
deleted file mode 100644
index 8ab868eb787..00000000000
--- a/libjava/java/io/UnsupportedEncodingException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 17, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class UnsupportedEncodingException extends IOException
-{
- public UnsupportedEncodingException ()
- {
- super();
- }
-
- public UnsupportedEncodingException (String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/io/Writer.java b/libjava/java/io/Writer.java
deleted file mode 100644
index 96fa0fb2d0d..00000000000
--- a/libjava/java/io/Writer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.io;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 17, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- * However, write(String, int, int) should be made a native method.
- */
-
-public abstract class Writer
-{
- protected Object lock;
-
- protected Writer ()
- {
- lock = this;
- }
-
- protected Writer (Object lock)
- {
- this.lock = lock;
- }
-
- abstract public void close() throws IOException;
-
- abstract public void flush() throws IOException;
-
- abstract public void write(char[] buf, int offset, int count)
- throws IOException;
-
- public void write(char[] buf) throws IOException
- {
- write(buf, 0, buf.length);
- }
-
- public void write(int ch) throws IOException
- {
- char[] buf = new char[1];
- buf[0] = (char) ch;
- write(buf, 0, 1);
- }
-
- // FIXME - re-write using native code to not require copied buffer.
- public void write (String str, int offset, int count) throws IOException
- {
- char[] buf = new char[count];
- str.getChars(offset, offset + count, buf, 0);
- write(buf, 0, count);
- }
-
- public void write (String str) throws IOException
- {
- write(str, 0, str.length());
- }
-
-}
diff --git a/libjava/java/io/natFile.cc b/libjava/java/io/natFile.cc
deleted file mode 100644
index dd98dc1708a..00000000000
--- a/libjava/java/io/natFile.cc
+++ /dev/null
@@ -1,272 +0,0 @@
-// natFile.cc - Native part of File class.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#ifdef HAVE_DIRENT_H
-#define _POSIX_PTHREAD_SEMANTICS
-#ifndef _REENTRANT
-# define _REENTRANT
-#endif
-#include <dirent.h>
-#endif
-#include <string.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/io/File.h>
-#include <java/io/IOException.h>
-#include <java/util/Vector.h>
-#include <java/lang/String.h>
-#include <java/io/FilenameFilter.h>
-#include <java/lang/System.h>
-
-jboolean
-java::io::File::access (jstring canon, jint query)
-{
- if (! canon)
- return false;
- char buf[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
- JvAssert (query == READ || query == WRITE || query == EXISTS);
-#ifdef HAVE_ACCESS
- int mode;
- if (query == READ)
- mode = R_OK;
- else if (query == WRITE)
- mode = W_OK;
- else
- mode = F_OK;
- return ::access (buf, mode) == 0;
-#else
- return false;
-#endif
-}
-
-jboolean
-java::io::File::stat (jstring canon, jint query)
-{
- if (! canon)
- return false;
- char buf[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
-#ifdef HAVE_STAT
- struct stat sb;
- if (::stat (buf, &sb))
- return false;
-
- JvAssert (query == DIRECTORY || query == ISFILE);
- jboolean r = S_ISDIR (sb.st_mode);
- return query == DIRECTORY ? r : ! r;
-#else
- return false;
-#endif
-}
-
-jlong
-java::io::File::attr (jstring canon, jint query)
-{
- if (! canon)
- return false;
-
- char buf[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
-#ifdef HAVE_STAT
- struct stat sb;
- // FIXME: not sure about return value here.
- if (::stat (buf, &sb))
- return 0;
-
- JvAssert (query == MODIFIED || query == LENGTH);
- // FIXME: time computation is very POSIX-specific -- POSIX and Java
- // have the same Epoch.
- return query == MODIFIED ? (jlong)sb.st_mtime * 1000 : sb.st_size;
-#else
- // There's no good choice here.
- return 23;
-#endif
-}
-
-jstring
-java::io::File::getCanonicalPath (void)
-{
- char buf[MAXPATHLEN], buf2[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
-#ifdef HAVE_REALPATH
- if (realpath (buf, buf2) == NULL)
- _Jv_Throw (new IOException (JvNewStringLatin1 (strerror (errno))));
-
- // FIXME: what encoding to assume for file names? This affects many
- // calls.
- return JvNewStringUTF (buf2);
-#else
- return JvNewStringUTF (buf);
-#endif
-}
-
-jboolean
-java::io::File::isAbsolute (void)
-{
- // FIXME: cpp define name.
- // FIXME: cygwin.
-#ifdef WIN32
- if (path->charAt(0) == '/' || path->charAt(0) == '\\')
- return true;
- if (path->length() < 3)
- return false;
- // Hard-code A-Za-z because Windows (I think) can't use non-ASCII
- // letters as drive names.
- if ((path->charAt(0) < 'a' || path->charAt(0) > 'z')
- && (path->charAt(0) < 'A' || path->charAt(0) > 'Z'))
- return false;
- return (path->charAt(1) == ':'
- && (path->charAt(2) == '/' || path->charAt(2) == '\\'));
-#else
- return path->charAt(0) == '/';
-#endif
-}
-
-#ifdef HAVE_DIRENT_H
-#if defined(__JV_POSIX_THREADS__) && defined(HAVE_READDIR_R)
-
-static struct dirent *
-get_entry (DIR *dir, struct dirent *e)
-{
- struct dirent *r;
- if (readdir_r (dir, e, &r) || r == NULL)
- return NULL;
- return e;
-}
-
-#else /* defined(__JV_POSIX_THREADS__) && defined(HAVE_READDIR_R) */
-
-static struct dirent *
-get_entry (DIR *dir, struct dirent *)
-{
- return readdir (dir);
-}
-
-#endif /* defined(__JV_POSIX_THREADS__) && defined(HAVE_READDIR_R) */
-#endif /* HAVE_DIRENT_H */
-
-jstringArray
-java::io::File::performList (jstring canon, FilenameFilter *filter)
-{
- if (! canon)
- return NULL;
-
-#ifdef HAVE_DIRENT_H
- char buf[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
- DIR *dir = opendir (buf);
- if (! dir)
- return NULL;
-
- java::util::Vector *vec = new java::util::Vector ();
- struct dirent *d, d2;
- while ((d = get_entry (dir, &d2)) != NULL)
- {
- if (! strcmp (d->d_name, ".") || ! strcmp (d->d_name, ".."))
- continue;
-
- jstring name = JvNewStringUTF (d->d_name);
- if (filter && ! filter->accept(this, name))
- continue;
-
- vec->addElement(name);
- }
-
- closedir (dir);
-
- jobjectArray ret = JvNewObjectArray (vec->size(), canon->getClass(),
- NULL);
- vec->copyInto(ret);
- return reinterpret_cast<jstringArray> (ret);
-#else /* HAVE_DIRENT_H */
- return NULL;
-#endif /* HAVE_DIRENT_H */
-}
-
-jboolean
-java::io::File::performMkdir (void)
-{
- char buf[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
-#ifdef HAVE_MKDIR
- return ::mkdir (buf, 0755) == 0;
-#else
- return false;
-#endif
-}
-
-jboolean
-java::io::File::performRenameTo (File *dest)
-{
- char buf[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
- // FIXME?
- buf[total] = '\0';
- char buf2[MAXPATHLEN];
- total = JvGetStringUTFRegion (dest->path, 0, dest->path->length(), buf2);
- // FIXME?
- buf2[total] = '\0';
-
-#ifdef HAVE_RENAME
- return ::rename (buf, buf2) == 0;
-#else
- return false;
-#endif
-}
-
-jboolean
-java::io::File::performDelete (jstring canon)
-{
- char buf[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
-#ifdef HAVE_UNLINK
-#ifdef HAVE_RMDIR
- if (! ::rmdir (buf))
- return true;
-#endif // HAVE_RMDIR
- if (errno == ENOTDIR)
- return ::unlink (buf) == 0;
-#endif // HAVE_UNLINK
- return false;
-}
diff --git a/libjava/java/io/natFileDescriptorEcos.cc b/libjava/java/io/natFileDescriptorEcos.cc
deleted file mode 100644
index b8c1a8d368e..00000000000
--- a/libjava/java/io/natFileDescriptorEcos.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-// natFileDescriptor.cc - Native part of FileDescriptor class.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/io/FileDescriptor.h>
-#include <java/io/SyncFailedException.h>
-#include <java/io/IOException.h>
-#include <java/io/EOFException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/String.h>
-#include <java/io/FileNotFoundException.h>
-
-extern "C" void diag_write_char (char c);
-
-static void
-diag_write (char *data, int len)
-{
- while (len > 0)
- {
- diag_write_char (*data++);
- len--;
- }
-}
-
-#define NO_FSYNC_MESSAGE "sync unsupported"
-
-jboolean
-java::io::FileDescriptor::valid (void)
-{
- return true;
-}
-
-void
-java::io::FileDescriptor::sync (void)
-{
- // Some files don't support fsync. We don't bother reporting these
- // as errors.
-#ifdef HAVE_FSYNC
-#else
- JvThrow (new SyncFailedException (JvNewStringLatin1 (NO_FSYNC_MESSAGE)));
-#endif
-}
-
-jint
-java::io::FileDescriptor::open (jstring path, jint jflags)
-{
- return fd;
-}
-
-void
-java::io::FileDescriptor::write (jint b)
-{
- char d = (char) b;
- ::diag_write (&d, 1);
-}
-
-void
-java::io::FileDescriptor::write (jbyteArray b, jint offset, jint len)
-{
- if (! b)
- JvThrow (new java::lang::NullPointerException);
- if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
- JvThrow (new java::lang::ArrayIndexOutOfBoundsException);
- char *bytes = (char *)elements (b) + offset;
- ::diag_write (bytes, len);
-}
-
-void
-java::io::FileDescriptor::close (void)
-{
-}
-
-jint
-java::io::FileDescriptor::seek (jlong pos, jint whence)
-{
- JvAssert (whence == SET || whence == CUR);
-
- jlong len = length ();
- jlong here = getFilePointer ();
-
- if ((whence == SET && pos > len) || (whence == CUR && here + pos > len))
- JvThrow (new EOFException);
-
- return 0;
-}
-
-jlong
-java::io::FileDescriptor::length (void)
-{
- return 0;
-}
-
-jlong
-java::io::FileDescriptor::getFilePointer (void)
-{
- return 0;
-}
-
-jint
-java::io::FileDescriptor::read (void)
-{
- return 0;
-}
-
-jint
-java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count)
-{
- return 0;
-}
-
-jint
-java::io::FileDescriptor::available (void)
-{
- return 0;
-}
diff --git a/libjava/java/io/natFileDescriptorPosix.cc b/libjava/java/io/natFileDescriptorPosix.cc
deleted file mode 100644
index ab95307c06b..00000000000
--- a/libjava/java/io/natFileDescriptorPosix.cc
+++ /dev/null
@@ -1,315 +0,0 @@
-// natFileDescriptor.cc - Native part of FileDescriptor class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <fcntl.h>
-
-#ifdef HAVE_SYS_IOCTL_H
-#define BSD_COMP /* Get FIONREAD on Solaris2. */
-#include <sys/ioctl.h>
-#endif
-
-// Pick up FIONREAD on Solaris 2.5.
-#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
-#endif
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/io/FileDescriptor.h>
-#include <java/io/SyncFailedException.h>
-#include <java/io/IOException.h>
-#include <java/io/InterruptedIOException.h>
-#include <java/io/EOFException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/String.h>
-#include <java/lang/Thread.h>
-#include <java/io/FileNotFoundException.h>
-
-#define NO_FSYNC_MESSAGE "sync unsupported"
-
-jboolean
-java::io::FileDescriptor::valid (void)
-{
- struct stat sb;
- return ::fstat (fd, &sb) == 0;
-}
-
-void
-java::io::FileDescriptor::sync (void)
-{
- // Some files don't support fsync. We don't bother reporting these
- // as errors.
-#ifdef HAVE_FSYNC
- if (::fsync (fd) && errno != EROFS && errno != EINVAL)
- JvThrow (new SyncFailedException (JvNewStringLatin1 (strerror (errno))));
-#else
- JvThrow (new SyncFailedException (JvNewStringLatin1 (NO_FSYNC_MESSAGE)));
-#endif
-}
-
-jint
-java::io::FileDescriptor::open (jstring path, jint jflags)
-{
- // FIXME: eww.
- char buf[MAXPATHLEN];
- jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
- // FIXME?
- buf[total] = '\0';
- int flags = 0;
-#ifdef O_BINARY
- flags |= O_BINARY;
-#endif
-
- JvAssert ((jflags & READ) || (jflags & WRITE));
- int mode = 0644;
- if ((jflags & READ) && (jflags & WRITE))
- flags |= O_RDWR;
- else if ((jflags & READ))
- flags |= O_RDONLY;
- else
- {
- flags |= O_WRONLY | O_CREAT;
- if ((jflags & APPEND))
- flags |= O_APPEND;
- else
- flags |= O_TRUNC;
-
- if ((jflags & EXCL))
- {
- flags |= O_EXCL;
- // In this case we are making a temp file.
- mode = 0600;
- }
- }
-
- int fd = ::open (buf, flags, mode);
- if (fd == -1)
- {
- char msg[MAXPATHLEN + 200];
- sprintf (msg, "%s: %s", buf, strerror (errno));
- JvThrow (new FileNotFoundException (JvNewStringLatin1 (msg)));
- }
- return fd;
-}
-
-void
-java::io::FileDescriptor::write (jint b)
-{
- jbyte d = (jbyte) b;
- int r = ::write (fd, &d, 1);
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe
- = new InterruptedIOException (JvNewStringLatin1 ("write interrupted"));
- iioe->bytesTransferred = r == -1 ? 0 : r;
- JvThrow (iioe);
- }
- else if (r == -1)
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
- // FIXME: loop if r != 1.
-}
-
-void
-java::io::FileDescriptor::write (jbyteArray b, jint offset, jint len)
-{
- if (! b)
- JvThrow (new java::lang::NullPointerException);
- if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
- JvThrow (new java::lang::ArrayIndexOutOfBoundsException);
- jbyte *bytes = elements (b) + offset;
- int r = ::write (fd, bytes, len);
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe
- = new InterruptedIOException (JvNewStringLatin1 ("write interrupted"));
- iioe->bytesTransferred = r == -1 ? 0 : r;
- JvThrow (iioe);
- }
- else if (r == -1)
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
- // FIXME: loop if r != len.
-}
-
-void
-java::io::FileDescriptor::close (void)
-{
- jint save = fd;
- fd = -1;
- if (::close (save))
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
-}
-
-jint
-java::io::FileDescriptor::seek (jlong pos, jint whence)
-{
- JvAssert (whence == SET || whence == CUR);
-
- jlong len = length ();
- jlong here = getFilePointer ();
-
- if ((whence == SET && pos > len) || (whence == CUR && here + pos > len))
- JvThrow (new EOFException);
-
- off_t r = ::lseek (fd, (off_t) pos, whence == SET ? SEEK_SET : SEEK_CUR);
- if (r == -1)
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
- return r;
-}
-
-jlong
-java::io::FileDescriptor::length (void)
-{
- struct stat sb;
- if (::fstat (fd, &sb))
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
- return sb.st_size;
-}
-
-jlong
-java::io::FileDescriptor::getFilePointer (void)
-{
- off_t r = ::lseek (fd, 0, SEEK_CUR);
- if (r == -1)
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
- return r;
-}
-
-jint
-java::io::FileDescriptor::read (void)
-{
- jbyte b;
- int r = ::read (fd, &b, 1);
- if (r == 0)
- return -1;
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe
- = new InterruptedIOException (JvNewStringLatin1 ("read interrupted"));
- iioe->bytesTransferred = r == -1 ? 0 : r;
- JvThrow (iioe);
- }
- else if (r == -1)
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
- return b & 0xFF;
-}
-
-jint
-java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count)
-{
- if (! buffer)
- JvThrow (new java::lang::NullPointerException);
- jsize bsize = JvGetArrayLength (buffer);
- if (offset < 0 || count < 0 || offset + count > bsize)
- JvThrow (new java::lang::ArrayIndexOutOfBoundsException);
- jbyte *bytes = elements (buffer) + offset;
- int r = ::read (fd, bytes, count);
- if (r == 0)
- return -1;
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe
- = new InterruptedIOException (JvNewStringLatin1 ("read interrupted"));
- iioe->bytesTransferred = r == -1 ? 0 : r;
- JvThrow (iioe);
- }
- else if (r == -1)
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
- return r;
-}
-
-jint
-java::io::FileDescriptor::available (void)
-{
-#if defined (FIONREAD) || defined (HAVE_SELECT) || defined (HAVE_FSTAT)
- long num = 0;
- int r = 0;
- bool num_set = false;
-
-#if defined (FIONREAD)
- r = ::ioctl (fd, FIONREAD, &num);
- if (r == -1 && errno == ENOTTY)
- {
- // If the ioctl doesn't work, we don't care.
- r = 0;
- num = 0;
- }
- else
- num_set = true;
-#elif defined (HAVE_SELECT)
- if (fd < 0)
- {
- errno = EBADF;
- r = -1;
- }
-#endif
-
- if (r == -1)
- {
- posix_error:
- JvThrow (new IOException (JvNewStringLatin1 (strerror (errno))));
- }
-
- // If we didn't get anything, and we have fstat, then see if see if
- // we're reading a regular file. On many systems, FIONREAD does not
- // work on regular files; select() likewise returns a useless
- // result. This is run incorrectly when FIONREAD does work on
- // regular files and we are at the end of the file. However, this
- // case probably isn't very important.
-#if defined (HAVE_FSTAT)
- if (! num_set)
- {
- struct stat sb;
- off_t where;
- if (fstat (fd, &sb) != -1
- && S_ISREG (sb.st_mode)
- && (where = lseek (fd, SEEK_CUR, 0)) != (off_t) -1)
- {
- num = (long) (sb.st_size - where);
- num_set = true;
- }
- }
-#endif /* HAVE_FSTAT */
-
-#if defined (HAVE_SELECT)
- if (! num_set)
- {
- fd_set rd;
- FD_ZERO (&rd);
- FD_SET (fd, &rd);
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- r = ::select (fd + 1, &rd, NULL, NULL, &tv);
- if (r == -1)
- goto posix_error;
- num = r == 0 ? 0 : 1;
- }
-#endif /* HAVE_SELECT */
-
- return (jint) num;
-#else
- JvThrow (new IOException (JvNewStringLatin1 ("unimplemented")));
-#endif
-}
diff --git a/libjava/java/io/natFileDescriptorWin32.cc b/libjava/java/io/natFileDescriptorWin32.cc
deleted file mode 100644
index 0bfd924abf0..00000000000
--- a/libjava/java/io/natFileDescriptorWin32.cc
+++ /dev/null
@@ -1,250 +0,0 @@
-// natFileDescriptorWin32.cc - Native part of FileDescriptor class.
-
-/* Copyright (C) 1998, 1999, 2000 Red Hat, 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. */
-
-// FIXME: In order to support interrupting of IO operations, we
-// need to change to use the windows asynchronous IO functions
-
-#include <config.h>
-
-#include <stdio.h>
-#include <string.h>
-
-#include <windows.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/io/FileDescriptor.h>
-#include <java/io/SyncFailedException.h>
-#include <java/io/IOException.h>
-#include <java/io/InterruptedIOException.h>
-#include <java/io/EOFException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/String.h>
-#include <java/lang/Thread.h>
-#include <java/io/FileNotFoundException.h>
-
-static char *
-winerr (void)
-{
- static LPVOID last = NULL;
- LPVOID old = NULL;
-
- if (last)
- old = last;
-
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &last,
- 0,
- NULL);
-
- if (old)
- LocalFree (old);
-
- return (char *)last;
-}
-
-jboolean
-java::io::FileDescriptor::valid (void) {
- BY_HANDLE_FILE_INFORMATION info;
- return GetFileInformationByHandle ((HANDLE)fd, &info) != 0;
-}
-
-void
-java::io::FileDescriptor::sync (void) {
- if (! FlushFileBuffers ((HANDLE)fd))
- JvThrow (new SyncFailedException (JvNewStringLatin1 (winerr ())));
-}
-
-jint
-java::io::FileDescriptor::open (jstring path, jint jflags) {
-
- HANDLE handle = NULL;
- DWORD access = 0;
- DWORD share = FILE_SHARE_READ;
- DWORD create = OPEN_EXISTING;
- char buf[MAX_PATH] = "";
-
- jsize total = JvGetStringUTFRegion(path, 0, path->length(), buf);
- buf[total] = '\0';
-
- JvAssert((jflags & READ) || (jflags & WRITE));
-
- if ((jflags & READ) && (jflags & WRITE))
- {
- access = GENERIC_READ | GENERIC_WRITE;
- share = 0;
- if (jflags & APPEND)
- create = OPEN_ALWAYS;
- else
- create = CREATE_ALWAYS;
- }
- else if(jflags & READ)
- access = GENERIC_READ;
- else
- {
- access = GENERIC_WRITE;
- share = 0;
- if (jflags & APPEND)
- create = OPEN_ALWAYS;
- else
- create = CREATE_ALWAYS;
- }
-
- handle = CreateFile(buf, access, share, NULL, create, 0, NULL);
-
- if (handle == INVALID_HANDLE_VALUE)
- {
- char msg[MAX_PATH + 1000];
- sprintf (msg, "%s: %s", buf, winerr ());
- JvThrow (new FileNotFoundException (JvNewStringLatin1 (msg)));
- }
-
- return (jint)handle;
-}
-
-void
-java::io::FileDescriptor::write (jint b)
-{
- DWORD bytesWritten;
- jbyte buf = (jbyte)b;
-
- if (WriteFile ((HANDLE)fd, &buf, 1, &bytesWritten, NULL))
- {
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe = new InterruptedIOException (JvNewStringLatin1 ("write interrupted"));
- iioe->bytesTransferred = bytesWritten;
- JvThrow (iioe);
- }
- if (bytesWritten != 1)
- JvThrow (new IOException (JvNewStringLatin1 (winerr ())));
- }
- else
- JvThrow (new IOException (JvNewStringLatin1 (winerr ())));
- // FIXME: loop until bytesWritten == 1
-}
-
-void
-java::io::FileDescriptor::write(jbyteArray b, jint offset, jint len)
-{
- if (! b)
- JvThrow (new java::lang::NullPointerException);
- if(offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
- JvThrow (new java::lang::ArrayIndexOutOfBoundsException);
-
- jbyte *buf = elements (b) + offset;
- DWORD bytesWritten;
- if (WriteFile ((HANDLE)fd, buf, len, &bytesWritten, NULL))
- {
- if (java::lang::Thread::interrupted())
- {
- InterruptedIOException *iioe = new InterruptedIOException (JvNewStringLatin1 ("write interrupted"));
- iioe->bytesTransferred = bytesWritten;
- JvThrow (iioe);
- }
- }
- else
- JvThrow(new IOException (JvNewStringLatin1 (winerr ())));
- // FIXME: loop until bytesWritten == len
-}
-
-void
-java::io::FileDescriptor::close (void)
-{
- HANDLE save = (HANDLE)fd;
- fd = (jint)INVALID_HANDLE_VALUE;
- if (! CloseHandle (save))
- JvThrow (new IOException (JvNewStringLatin1 (winerr ())));
-}
-
-jint
-java::io::FileDescriptor::seek (jlong pos, jint whence)
-{
- JvAssert (whence == SET || whence == CUR);
-
- jlong len = length();
- jlong here = getFilePointer();
-
- if ((whence == SET && pos > len) || (whence == CUR && here + pos > len))
- JvThrow (new EOFException);
-
- LONG high = pos >> 32;
- DWORD low = SetFilePointer ((HANDLE)fd, (DWORD)(0xffffffff & pos), &high, whence == SET ? FILE_BEGIN : FILE_CURRENT);
- if ((low == 0xffffffff) && (GetLastError () != NO_ERROR))
- JvThrow (new IOException (JvNewStringLatin1 (winerr ())));
- return low;
-}
-
-jlong
-java::io::FileDescriptor::getFilePointer(void)
-{
- LONG high = 0;
- DWORD low = SetFilePointer ((HANDLE)fd, 0, &high, FILE_CURRENT);
- if ((low == 0xffffffff) && (GetLastError() != NO_ERROR))
- JvThrow(new IOException (JvNewStringLatin1 (winerr ())));
- return (((jlong)high) << 32L) | (jlong)low;
-}
-
-jlong
-java::io::FileDescriptor::length(void)
-{
- DWORD high;
- DWORD low;
-
- low = GetFileSize ((HANDLE)fd, &high);
- // FIXME: Error checking
- return (((jlong)high) << 32L) | (jlong)low;
-}
-
-jint
-java::io::FileDescriptor::read(void)
-{
- CHAR buf;
- DWORD read;
-
- if (! ReadFile ((HANDLE)fd, &buf, 1, &read, NULL))
- JvThrow (new IOException (JvNewStringLatin1 (winerr ())));
- if (! read)
- return -1;
- else
- return (jint)(buf & 0xff);
-}
-
-jint
-java::io::FileDescriptor::read(jbyteArray buffer, jint offset, jint count)
-{
- if (! buffer)
- JvThrow(new java::lang::NullPointerException);
-
- jsize bsize = JvGetArrayLength (buffer);
- if (offset < 0 || count < 0 || offset + count > bsize)
- JvThrow (new java::lang::ArrayIndexOutOfBoundsException);
-
- jbyte *bytes = elements (buffer) + offset;
-
- DWORD read;
- if (! ReadFile((HANDLE)fd, bytes, count, &read, NULL))
- JvThrow (new IOException (JvNewStringLatin1 (winerr ())));
-
- return (jint)read;
-}
-
-jint
-java::io::FileDescriptor::available(void)
-{
- // FIXME:
- return length() - getFilePointer();
-}
diff --git a/libjava/java/io/natFileWin32.cc b/libjava/java/io/natFileWin32.cc
deleted file mode 100644
index a56845a7134..00000000000
--- a/libjava/java/io/natFileWin32.cc
+++ /dev/null
@@ -1,210 +0,0 @@
-// natFileWin32.cc - Native part of File class.
-
-/* Copyright (C) 1998, 1999 Red Hat, 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. */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <string.h>
-
-#include <windows.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/io/File.h>
-#include <java/io/IOException.h>
-#include <java/util/Vector.h>
-#include <java/lang/String.h>
-#include <java/io/FilenameFilter.h>
-#include <java/lang/System.h>
-
-jboolean
-java::io::File::access (jstring canon, jint query)
-{
- if (! canon)
- return false;
- char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
- JvAssert (query == READ || query == WRITE || query == EXISTS);
-
- // FIXME: Is it possible to differentiate between existing and reading?
- // If the file exists but cannot be read because of the secuirty attributes
- // on an NTFS disk this wont work (it reports it can be read but cant)
- // Could we use something from the security API?
- DWORD attributes = GetFileAttributes (buf);
- if ((query == EXISTS) || (query == READ))
- return (attributes == 0xffffffff) ? false : true;
- else
- return ((attributes != 0xffffffff) && ((attributes & FILE_ATTRIBUTE_READONLY) == 0)) ? true : false;
-}
-
-jboolean
-java::io::File::stat (jstring canon, jint query)
-{
- if (! canon)
- return false;
- char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
- JvAssert (query == DIRECTORY || query == ISFILE);
-
- DWORD attributes = GetFileAttributes (buf);
- if (attributes == 0xffffffff)
- return false;
-
- if (query == DIRECTORY)
- return attributes & FILE_ATTRIBUTE_DIRECTORY ? true : false;
- else
- return attributes & FILE_ATTRIBUTE_DIRECTORY ? false : true;
-}
-
-jlong
-java::io::File::attr (jstring canon, jint query)
-{
- if (! canon)
- return false;
- char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
- JvAssert (query == MODIFIED || query == LENGTH);
-
- WIN32_FILE_ATTRIBUTE_DATA info;
- if (! GetFileAttributesEx(buf, GetFileExInfoStandard, &info))
- return 0;
-
- if (query == LENGTH)
- return ((long long)info.nFileSizeHigh) << 32 | (unsigned long long)info.nFileSizeLow;
- else {
- // FIXME? This is somewhat compiler dependant (the LL constant suffix)
- // The file time as return by windows is the number of 100-nanosecond intervals since January 1, 1601
- return (((((long long)info.ftLastWriteTime.dwHighDateTime) << 32) | ((unsigned long long)info.ftLastWriteTime.dwLowDateTime)) - 116444736000000000LL) / 10000LL;
- }
-}
-
-jstring
-java::io::File::getCanonicalPath (void)
-{
- char buf[MAX_PATH], buf2[MAX_PATH];
- jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
- LPTSTR unused;
- if(!GetFullPathName(buf, MAX_PATH, buf2, &unused))
- _Jv_Throw (new IOException (JvNewStringLatin1 ("GetFullPathName failed")));
-
- // FIXME: what encoding to assume for file names? This affects many
- // calls.
- return JvNewStringUTF(buf2);
-}
-
-jboolean
-java::io::File::isAbsolute (void)
-{
- if (path->charAt(0) == '/' || path->charAt(0) == '\\')
- return true;
- if (path->length() < 3)
- return false;
- // Hard-code A-Za-z because Windows (I think) can't use non-ASCII
- // letters as drive names.
- if ((path->charAt(0) < 'a' || path->charAt(0) > 'z')
- && (path->charAt(0) < 'A' || path->charAt(0) > 'Z'))
- return false;
- return (path->charAt(1) == ':'
- && (path->charAt(2) == '/' || path->charAt(2) == '\\'));
-}
-
-jstringArray
-java::io::File::performList (jstring canon, FilenameFilter *filter)
-{
- if (! canon)
- return NULL;
- char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion (canon, 0, canon->length(), buf);
- // FIXME?
- strcpy(&buf[total], "\\*.*");
-
- WIN32_FIND_DATA data;
- HANDLE handle = FindFirstFile (buf, &data);
- if (handle == INVALID_HANDLE_VALUE)
- return NULL;
-
- java::util::Vector *vec = new java::util::Vector ();
-
- do
- {
- if (strcmp (data.cFileName, ".") && strcmp (data.cFileName, ".."))
- {
- jstring name = JvNewStringUTF (data.cFileName);
- if (! filter || (filter && filter->accept(this, name)))
- vec->addElement (name);
- }
- }
- while (FindNextFile (handle, &data));
-
- if (GetLastError () != ERROR_NO_MORE_FILES)
- return NULL;
-
- FindClose (handle);
-
- jobjectArray ret = JvNewObjectArray (vec->size(), canon->getClass(), NULL);
- vec->copyInto (ret);
- return reinterpret_cast<jstringArray> (ret);
-}
-
-jboolean
-java::io::File::performMkdir (void)
-{
- char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion(path, 0, path->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
- return (CreateDirectory(buf, NULL)) ? true : false;
-}
-
-jboolean
-java::io::File::performRenameTo (File *dest)
-{
- char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion(path, 0, path->length(), buf);
- // FIXME?
- buf[total] = '\0';
- char buf2[MAX_PATH];
- total = JvGetStringUTFRegion(dest->path, 0, dest->path->length(), buf2);
- // FIXME?
- buf2[total] = '\0';
-
- return (MoveFile(buf, buf2)) ? true : false;
-}
-
-jboolean
-java::io::File::performDelete (jstring canon)
-{
- char buf[MAX_PATH];
- jsize total = JvGetStringUTFRegion(canon, 0, canon->length(), buf);
- // FIXME?
- buf[total] = '\0';
-
- DWORD attributes = GetFileAttributes (buf);
- if (attributes == 0xffffffff)
- return false;
-
- if (attributes & FILE_ATTRIBUTE_DIRECTORY)
- return (RemoveDirectory (buf)) ? true : false;
- else
- return (DeleteFile (buf)) ? true : false;
-}
diff --git a/libjava/java/lang/AbstractMethodError.java b/libjava/java/lang/AbstractMethodError.java
deleted file mode 100644
index 782e595a9ba..00000000000
--- a/libjava/java/lang/AbstractMethodError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// AbstractMethodError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class AbstractMethodError extends IncompatibleClassChangeError
-{
- public AbstractMethodError ()
- {
- super ();
- }
-
- public AbstractMethodError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/ArithmeticException.java b/libjava/java/lang/ArithmeticException.java
deleted file mode 100644
index 15278e06a9f..00000000000
--- a/libjava/java/lang/ArithmeticException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ArithmeticException extends RuntimeException
-{
- public ArithmeticException()
- {
- super();
- }
-
- public ArithmeticException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/ArrayIndexOutOfBoundsException.java b/libjava/java/lang/ArrayIndexOutOfBoundsException.java
deleted file mode 100644
index 4b912c22007..00000000000
--- a/libjava/java/lang/ArrayIndexOutOfBoundsException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException
-{
- public ArrayIndexOutOfBoundsException()
- {
- super();
- }
-
- public ArrayIndexOutOfBoundsException(int index)
- {
- this("Array index out of range: " + index);
- }
-
- public ArrayIndexOutOfBoundsException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/ArrayStoreException.java b/libjava/java/lang/ArrayStoreException.java
deleted file mode 100644
index 720308e5acf..00000000000
--- a/libjava/java/lang/ArrayStoreException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ArrayStoreException extends RuntimeException
-{
- public ArrayStoreException()
- {
- super();
- }
-
- public ArrayStoreException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/Boolean.java b/libjava/java/lang/Boolean.java
deleted file mode 100644
index 041f72521eb..00000000000
--- a/libjava/java/lang/Boolean.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 3, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public final class Boolean extends Object implements Serializable
-{
- public static final Boolean FALSE = new Boolean(false);
- public static final Boolean TRUE = new Boolean(true);
-
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public static final Class TYPE = boolean.class;
-
- /* The boolean value of the instance. */
- private boolean value;
-
- public Boolean(boolean boolVal)
- {
- value = boolVal;
- }
-
- public Boolean(String strVal)
- {
- value = (strVal == null ? false : strVal.equalsIgnoreCase("true"));
- }
-
- public boolean booleanValue()
- {
- return value;
- }
-
- public boolean equals(Object obj)
- {
- /* Don't need to compare obj to null as instanceof will do this. */
- if (obj instanceof Boolean)
- return value == ((Boolean) obj).value;
- return false;
- }
-
- public static boolean getBoolean(String property)
- {
- /* TBD: If a security manager exists and it doesn't permit accessing
- * the property, it will throw an exception. Should we catch it?
- */
- try
- {
- String val = System.getProperty(property);
- return val == null ? false : val.equalsIgnoreCase("true");
- }
- catch (SecurityException e)
- {
- return false;
- }
- }
-
- public int hashCode()
- {
- /* These values are from the Java Lang. Spec. (Sec 20.4.7).
- * TBD: They could be made private static final fields but they're only
- * used here (and shouldn't be used anywhere else), though it might be
- * useful to grep on something like JAVA_HASH_* values for us as
- * developers.
- */
- return value ? 1231 : 1237;
- }
-
- public String toString()
- {
- return value ? "true" : "false";
- }
-
- public static Boolean valueOf(String str)
- {
- if (str == null)
- return FALSE;
- else
- /* This returns a Boolean (big B), not a boolean (little b). */
- return str.equalsIgnoreCase("true") ? TRUE : FALSE;
- }
-}
diff --git a/libjava/java/lang/Byte.java b/libjava/java/lang/Byte.java
deleted file mode 100644
index 95db094f420..00000000000
--- a/libjava/java/lang/Byte.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 17, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- * Includes JDK 1.2 methods.
- */
-
-public final class Byte extends Number implements Comparable
-{
- byte value;
-
- public final static byte MIN_VALUE = -128;
- public final static byte MAX_VALUE = 127;
-
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public static final Class TYPE = byte.class;
-
- public Byte(byte value)
- {
- this.value = value;
- }
-
- public Byte(String str)
- throws NumberFormatException
- {
- this.value = parseByte(str, 10);
- }
-
- public byte byteValue()
- {
- return value;
- }
-
- public short shortValue()
- {
- return value;
- }
-
- public int intValue()
- {
- return value;
- }
-
- public long longValue ()
- {
- return value;
- }
-
- public float floatValue ()
- {
- return (float) value;
- }
-
- public double doubleValue ()
- {
- return (double) value;
- }
-
- public static Byte decode(String str)
- throws NumberFormatException
- {
- int i = (Integer.decode(str)).intValue();
- if (i < MIN_VALUE || i > MAX_VALUE)
- throw new NumberFormatException();
- return new Byte((byte) i);
- }
-
- public static byte parseByte(String str, int radix)
- throws NumberFormatException
- {
- int i = Integer.parseInt(str, radix);
- if (i < MIN_VALUE || i > MAX_VALUE)
- throw new NumberFormatException();
- return (byte) i;
- }
-
- public static byte parseByte(String str)
- throws NumberFormatException
- {
- return parseByte(str, 10);
- }
-
- public static Byte valueOf(String str, int radix)
- throws NumberFormatException
- {
- return new Byte(parseByte(str, radix));
- }
-
- public static Byte valueOf(String str)
- throws NumberFormatException
- {
- return valueOf(str, 10);
- }
-
- // Added in JDK 1.2
- public int compareTo(Byte anotherByte)
- {
- return this.value - anotherByte.value;
- }
-
- // Added in JDK 1.2
- public int compareTo(Object o) throws ClassCastException
- {
- if (o instanceof Byte)
- return this.value - ((Byte) o).value;
- else
- throw new ClassCastException();
- }
-
- public boolean equals(Object obj)
- {
- return obj != null && (obj instanceof Byte) && ((Byte)obj).value == value;
- }
-
- // Verified that hashCode is returns plain value (see Boolean_1 test).
- public int hashCode()
- {
- return value;
- }
-
- public String toString()
- {
- return Integer.toString((int) value);
- }
-
- public static String toString(byte value)
- {
- return Integer.toString((int) value);
- }
-}
diff --git a/libjava/java/lang/Character.java b/libjava/java/lang/Character.java
deleted file mode 100644
index 4306afb0881..00000000000
--- a/libjava/java/lang/Character.java
+++ /dev/null
@@ -1,286 +0,0 @@
-// Character.java - Character class.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-import java.io.Serializable;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 10, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1,
- * online API docs for JDK 1.2 beta from http://www.javasoft.com,
- * and The Unicode Standard Version 2.0.
- * Status: Believed complete and correct for JDK 1.1; 1.2 methods
- * unimplemented.
- */
-
-public final class Character implements Serializable, Comparable
-{
- public static final char MIN_VALUE = '\u0000';
- public static final char MAX_VALUE = '\uffff';
-
- public static final int MIN_RADIX = 2;
- public static final int MAX_RADIX = 36;
-
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public static final Class TYPE = char.class;
-
- // Space.
- public static final byte SPACE_SEPARATOR = 12;
- public static final byte LINE_SEPARATOR = 13;
- public static final byte PARAGRAPH_SEPARATOR = 14;
-
- // Letters.
- public static final byte UPPERCASE_LETTER = 1;
- public static final byte LOWERCASE_LETTER = 2;
- public static final byte TITLECASE_LETTER = 3;
- public static final byte MODIFIER_LETTER = 4;
- public static final byte OTHER_LETTER = 5;
-
- // Numbers.
- public static final byte DECIMAL_DIGIT_NUMBER = 9;
- public static final byte LETTER_NUMBER = 10;
- public static final byte OTHER_NUMBER = 11;
-
- // Marks.
- public static final byte NON_SPACING_MARK = 6;
- public static final byte ENCLOSING_MARK = 7;
- public static final byte COMBINING_SPACING_MARK = 8;
-
- // Punctuation.
- public static final byte DASH_PUNCTUATION = 20;
- public static final byte START_PUNCTUATION = 21;
- public static final byte END_PUNCTUATION = 22;
- public static final byte CONNECTOR_PUNCTUATION = 23;
- public static final byte OTHER_PUNCTUATION = 24;
-
- // Symbols.
- public static final byte MATH_SYMBOL = 25;
- public static final byte CURRENCY_SYMBOL = 26;
- public static final byte MODIFIER_SYMBOL = 27;
- public static final byte OTHER_SYMBOL = 28;
-
- // Format controls.
- public static final byte CONTROL = 15;
- // Note: The JCL book says that both FORMAT and PRIVATE_USE are 18.
- // However, FORMAT is actually 16.
- public static final byte FORMAT = 16;
-
- // Others.
- public static final byte UNASSIGNED = 0;
- public static final byte PRIVATE_USE = 18;
- public static final byte SURROGATE = 19;
-
-
- public Character (char ch)
- {
- value = ch;
- }
-
- public char charValue ()
- {
- return value;
- }
-
- // See if a character is a digit. If so, return the corresponding
- // value. Otherwise return -1.
- private static native int digit_value (char ch);
-
- public static int digit (char ch, int radix)
- {
- if (radix < MIN_RADIX || radix > MAX_RADIX)
- return -1;
-
- int d = digit_value (ch);
- if (d == -1)
- {
- if (ch >= 'A' && ch <= 'Z')
- d = ch - 'A' + 10;
- else if (ch >= 'a' && ch <= 'z')
- d = ch - 'a' + 10;
- else
- return -1;
- }
- return d >= radix ? -1 : d;
- }
-
- public boolean equals (Object obj)
- {
- // Don't need to compare OBJ to null as instanceof will do this.
- if (obj instanceof Character)
- return value == ((Character) obj).value;
- return false;
- }
-
- public static char forDigit (int d, int rdx)
- {
- if (d < 0 || d >= rdx || rdx < MIN_RADIX || rdx > MAX_RADIX)
- return '\u0000';
- if (d < 10)
- return (char) ('0' + d);
- // The Java Language Spec says to use lowercase, while the JCL
- // says to use uppercase. We go with the former.
- return (char) ('a' + d - 10);
- }
-
- public static native int getNumericValue (char ch);
- public static native int getType (char ch);
-
- public int hashCode ()
- {
- return value;
- }
-
- public static boolean isDefined (char ch)
- {
- return getType (ch) != UNASSIGNED;
- }
-
- public static boolean isDigit (char ch)
- {
- return digit_value (ch) != -1;
- }
-
- // The JCL book says that the argument here is a Character. That is
- // wrong.
- public static boolean isIdentifierIgnorable (char ch)
- {
- // This information comes from the Unicode Standard. It isn't
- // auto-generated as it doesn't appear in the unidata table.
- return ((ch >= '\u0000' && ch <= '\u0008')
- || (ch >= '\u000e' && ch <= '\u001b')
- // JDK 1.2 docs say that these are ignorable. The Unicode
- // Standard is somewhat ambiguous on this issue.
- || (ch >= '\u007f' && ch <= '\u009f')
- || (ch >= '\u200c' && ch <= '\u200f')
- // JCl says 200a through 200e, but that is a typo. The
- // Unicode standard says the bidi controls are 202a
- // through 202e.
- || (ch >= '\u202a' && ch <= '\u202e')
- || (ch >= '\u206a' && ch <= '\u206f')
- || ch == '\ufeff');
- }
-
- public static boolean isISOControl (char c)
- {
- return ((c >= '\u0000' && c <= '\u001f')
- || (c >= '\u007f' && c <= '\u009f'));
- }
-
- public static boolean isJavaIdentifierPart (char ch)
- {
- if (isIdentifierIgnorable (ch) || isDigit (ch))
- return true;
- int type = getType (ch);
- return (type == COMBINING_SPACING_MARK || type == NON_SPACING_MARK
- || type == CURRENCY_SYMBOL || type == CONNECTOR_PUNCTUATION
- || type == UPPERCASE_LETTER || type == LOWERCASE_LETTER
- || type == TITLECASE_LETTER || type == MODIFIER_LETTER
- || type == OTHER_LETTER || type == LETTER_NUMBER);
- }
-
- public static boolean isJavaIdentifierStart (char ch)
- {
- int type = getType (ch);
- return (type == CURRENCY_SYMBOL || type == CONNECTOR_PUNCTUATION
- || type == UPPERCASE_LETTER || type == LOWERCASE_LETTER
- || type == TITLECASE_LETTER || type == MODIFIER_LETTER
- || type == OTHER_LETTER);
- }
-
- // Deprecated in 1.2.
- public static boolean isJavaLetter (char ch)
- {
- return ch == '$' || ch == '_' || isLetter (ch);
- }
-
- // Deprecated in 1.2.
- public static boolean isJavaLetterOrDigit (char ch)
- {
- return ch == '$' || ch == '_' || isLetterOrDigit (ch);
- }
-
- public static boolean isLetter (char ch)
- {
- int type = getType (ch);
- return (type == UPPERCASE_LETTER || type == LOWERCASE_LETTER
- || type == TITLECASE_LETTER || type == MODIFIER_LETTER
- || type == OTHER_LETTER);
- }
-
- public static boolean isLetterOrDigit (char ch)
- {
- return isDigit (ch) || isLetter (ch);
- }
-
- public static native boolean isLowerCase (char ch);
-
- // Deprecated in JCL.
- public static boolean isSpace (char ch)
- {
- return ch == '\n' || ch == '\t' || ch == '\f' || ch == '\r' || ch == ' ';
- }
-
- public static native boolean isSpaceChar (char ch);
- public static native boolean isTitleCase (char ch);
-
- public static boolean isUnicodeIdentifierPart (char ch)
- {
- if (isIdentifierIgnorable (ch) || isDigit (ch))
- return true;
- int type = getType (ch);
- return (type == CONNECTOR_PUNCTUATION || type == LETTER_NUMBER
- || type == COMBINING_SPACING_MARK || type == NON_SPACING_MARK
- || type == UPPERCASE_LETTER || type == LOWERCASE_LETTER
- || type == TITLECASE_LETTER || type == MODIFIER_LETTER
- || type == OTHER_LETTER);
- }
-
- public static boolean isUnicodeIdentifierStart (char ch)
- {
- return isLetter (ch);
- }
-
- public static native boolean isUpperCase (char ch);
-
- public static boolean isWhitespace (char ch)
- {
- return ((ch >= '\u0009' && ch <= '\r')
- || (ch >= '\u001c' && ch <= '\u001f')
- || (ch != '\u00a0' && ch != '\ufeff' && isSpaceChar (ch)));
- }
-
- public static native char toLowerCase (char ch);
- public static native char toTitleCase (char ch);
- public static native char toUpperCase (char ch);
-
- public String toString ()
- {
- return String.valueOf(value);
- }
-
- public int compareTo (Character anotherCharacter)
- {
- return value - anotherCharacter.value;
- }
-
- public int compareTo (Object o)
- {
- return compareTo ((Character) o);
- }
-
- // Private data.
- private char value;
-}
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h
deleted file mode 100644
index bad71b524b7..00000000000
--- a/libjava/java/lang/Class.h
+++ /dev/null
@@ -1,328 +0,0 @@
-// Class.h - Header file for java.lang.Class. -*- c++ -*-
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-// Written primary using compiler source and Class.java as guides.
-#ifndef __JAVA_LANG_CLASS_H__
-#define __JAVA_LANG_CLASS_H__
-
-#pragma interface
-
-#include <java/lang/Object.h>
-#include <java/lang/String.h>
-#include <java/net/URL.h>
-
-// We declare these here to avoid including gcj/cni.h.
-extern "C" void _Jv_InitClass (jclass klass);
-extern "C" void _Jv_RegisterClasses (jclass *classes);
-
-// This must be predefined with "C" linkage.
-extern "C" void *_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface,
- int meth_idx);
-
-// These are the possible values for the `state' field of the class
-// structure. Note that ordering is important here. Whenever the
-// state changes, one should notify all waiters of this class.
-enum
-{
- JV_STATE_NOTHING = 0, // Set by compiler.
-
- JV_STATE_PRELOADING = 1, // Can do _Jv_FindClass.
- JV_STATE_LOADING = 3, // Has super installed.
- JV_STATE_LOADED = 5, // Is complete.
-
- JV_STATE_COMPILED = 6, // This was a compiled class.
-
- JV_STATE_PREPARED = 7, // Layout & static init done.
- JV_STATE_LINKED = 9, // Strings interned.
-
- JV_STATE_IN_PROGRESS = 10, // <Clinit> running.
- JV_STATE_DONE = 12, //
-
- JV_STATE_ERROR = 14 // must be last.
-};
-
-struct _Jv_Field;
-struct _Jv_VTable;
-
-struct _Jv_Constants
-{
- jint size;
- jbyte *tags;
- _Jv_word *data;
-};
-
-struct _Jv_Method
-{
- _Jv_Utf8Const *name;
- _Jv_Utf8Const *signature;
- _Jv_ushort accflags;
- void *ncode;
- _Jv_Method *getNextMethod ()
- { return this + 1; }
-};
-
-// Interface Dispatch Tables
-union _Jv_IDispatchTable
-{
- struct
- {
- // Index into interface's ioffsets.
- jshort iindex;
- jshort itable_length;
- // Class Interface dispatch table.
- void **itable;
- } cls;
-
- struct
- {
- // Offsets into implementation class itables.
- jshort *ioffsets;
- } iface;
-};
-
-// Used by _Jv_GetInterfaces ()
-struct _Jv_ifaces
-{
- jclass *list;
- jshort len;
- jshort count;
-};
-
-#define JV_PRIMITIVE_VTABLE ((_Jv_VTable *) -1)
-
-#define JV_CLASS(Obj) ((jclass) (*(_Jv_VTable **) Obj)->clas)
-
-class java::lang::Class : public java::lang::Object
-{
-public:
- static jclass forName (jstring className);
- JArray<jclass> *getClasses (void);
-
- java::lang::ClassLoader *getClassLoader (void)
- {
- return loader;
- }
-
- java::lang::reflect::Constructor *getConstructor (JArray<jclass> *);
- JArray<java::lang::reflect::Constructor *> *getConstructors (void);
- java::lang::reflect::Constructor *getDeclaredConstructor (JArray<jclass> *);
- JArray<java::lang::reflect::Constructor *> *getDeclaredConstructors (void);
- java::lang::reflect::Field *getDeclaredField (jstring);
- JArray<java::lang::reflect::Field *> *getDeclaredFields (void);
- java::lang::reflect::Method *getDeclaredMethod (jstring, JArray<jclass> *);
- JArray<java::lang::reflect::Method *> *getDeclaredMethods (void);
-
- JArray<jclass> *getDeclaredClasses (void);
- jclass getDeclaringClass (void);
-
- java::lang::reflect::Field *getField (jstring);
-private:
- jint _getFields (JArray<java::lang::reflect::Field *> *result, jint offset);
- JArray<java::lang::reflect::Constructor *> *_getConstructors (jboolean);
- java::lang::reflect::Field *getField (jstring, jint);
- jint _getMethods (JArray<java::lang::reflect::Method *> *result,
- jint offset);
-public:
- JArray<java::lang::reflect::Field *> *getFields (void);
-
- JArray<jclass> *getInterfaces (void);
-
- void getSignature (java::lang::StringBuffer *buffer);
- static jstring getSignature (JArray<jclass> *, jboolean is_constructor);
- java::lang::reflect::Method *getMethod (jstring, JArray<jclass> *);
- JArray<java::lang::reflect::Method *> *getMethods (void);
-
- inline jint getModifiers (void)
- {
- return accflags;
- }
-
- jstring getName (void);
-
- java::net::URL *getResource (jstring resourceName);
- java::io::InputStream *getResourceAsStream (jstring resourceName);
- JArray<jobject> *getSigners (void);
-
- inline jclass getSuperclass (void)
- {
- return superclass;
- }
-
- inline jboolean isArray (void)
- {
- return name->data[0] == '[';
- }
-
- inline jclass getComponentType (void)
- {
- return isArray () ? (* (jclass *) &methods) : 0;
- }
-
- jboolean isAssignableFrom (jclass cls);
- jboolean isInstance (jobject obj);
- jboolean isInterface (void);
-
- inline jboolean isPrimitive (void)
- {
- return vtable == JV_PRIMITIVE_VTABLE;
- }
-
- jobject newInstance (void);
- jstring toString (void);
-
- // FIXME: this probably shouldn't be public.
- jint size (void)
- {
- return size_in_bytes;
- }
-
- // finalization
- void finalize ();
-
-private:
-
- void checkMemberAccess (jint flags);
-
- void initializeClass (void);
-
- // Friend functions implemented in natClass.cc.
- friend _Jv_Method *_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
- _Jv_Utf8Const *signature);
- friend jboolean _Jv_IsAssignableFrom(jclass, jclass);
- friend void *_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface,
- int method_idx);
-
- inline friend void
- _Jv_InitClass (jclass klass)
- {
- if (klass->state != JV_STATE_DONE)
- klass->initializeClass ();
- }
-
- friend _Jv_Method* _Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *,
- _Jv_Utf8Const*);
- friend jfieldID JvGetFirstInstanceField (jclass);
- friend jint JvNumInstanceFields (jclass);
- friend jfieldID JvGetFirstStaticField (jclass);
- friend jint JvNumStaticFields (jclass);
-
- friend jobject _Jv_AllocObject (jclass, jint);
- friend jobjectArray _Jv_NewObjectArray (jsize, jclass, jobject);
- friend jobject _Jv_NewPrimArray (jclass, jint);
-
- friend jobject _Jv_JNI_ToReflectedField (_Jv_JNIEnv *, jclass, jfieldID,
- jboolean);
- friend jobject _Jv_JNI_ToReflectedMethod (_Jv_JNIEnv *, jclass, jmethodID,
- jboolean);
- friend jfieldID _Jv_FromReflectedField (java::lang::reflect::Field *);
-
- friend jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
- friend jmethodID _Jv_FromReflectedConstructor (java::lang::reflect::Constructor *);
- friend jint JvNumMethods (jclass);
- friend jmethodID JvGetFirstMethod (jclass);
-
- friend class _Jv_PrimClass;
-
- // Friends classes and functions to implement the ClassLoader
- friend class java::lang::ClassLoader;
-
- friend void _Jv_WaitForState (jclass, int);
- friend void _Jv_RegisterClasses (jclass *classes);
- friend void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
- friend void _Jv_UnregisterClass (jclass);
- friend jclass _Jv_FindClass (_Jv_Utf8Const *name,
- java::lang::ClassLoader *loader);
- friend jclass _Jv_FindClassInCache (_Jv_Utf8Const *name,
- java::lang::ClassLoader *loader);
- friend jclass _Jv_FindArrayClass (jclass element,
- java::lang::ClassLoader *loader);
- friend jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
- java::lang::ClassLoader *loader);
-
- friend void _Jv_PrepareCompiledClass (jclass);
- friend void _Jv_PrepareConstantTimeTables (jclass);
- friend jshort _Jv_GetInterfaces (jclass, _Jv_ifaces *);
- friend void _Jv_GenerateITable (jclass, _Jv_ifaces *, jshort *);
- friend jstring _Jv_GetMethodString(jclass, _Jv_Utf8Const *);
- friend jshort _Jv_AppendPartialITable (jclass, jclass, void **, jshort);
- friend jshort _Jv_FindIIndex (jclass *, jshort *, jshort);
-
-#ifdef INTERPRETER
- friend jboolean _Jv_IsInterpretedClass (jclass);
- friend void _Jv_InitField (jobject, jclass, _Jv_Field*);
- friend int _Jv_DetermineVTableIndex (jclass, _Jv_Utf8Const *,
- _Jv_Utf8Const*);
- friend void _Jv_InitField (jobject, jclass, int);
- friend _Jv_word _Jv_ResolvePoolEntry (jclass, int);
- friend _Jv_Method *_Jv_SearchMethodInClass (jclass cls, jclass klass,
- _Jv_Utf8Const *method_name,
- _Jv_Utf8Const *method_signature);
-
- friend void _Jv_PrepareClass (jclass);
-
- friend class _Jv_ClassReader;
- friend class _Jv_InterpClass;
- friend class _Jv_InterpMethod;
- friend class _Jv_InterpMethodInvocation;
-#endif
-
-#ifdef JV_MARKOBJ_DECL
- friend JV_MARKOBJ_DECL;
-#endif
-
- // Chain for class pool.
- jclass next;
- // Name of class.
- _Jv_Utf8Const *name;
- // Access flags for class.
- _Jv_ushort accflags;
- // The superclass, or null for Object.
- jclass superclass;
- // Class constants.
- _Jv_Constants constants;
- // Methods. If this is an array class, then this field holds a
- // pointer to the element type. If this is a primitive class, this
- // is used to cache a pointer to the appropriate array type.
- _Jv_Method *methods;
- // Number of methods. If this class is primitive, this holds the
- // character used to represent this type in a signature.
- jshort method_count;
- // Number of methods in the vtable.
- jshort vtable_method_count;
- // The fields.
- _Jv_Field *fields;
- // Size of instance fields, in bytes.
- jint size_in_bytes;
- // Total number of fields (instance and static).
- jshort field_count;
- // Number of static fields.
- jshort static_field_count;
- // The vtbl for all objects of this class.
- _Jv_VTable *vtable;
- // Interfaces implemented by this class.
- jclass *interfaces;
- // The class loader for this class.
- java::lang::ClassLoader *loader;
- // Number of interfaces.
- jshort interface_count;
- // State of this class.
- jbyte state;
- // The thread which has locked this class. Used during class
- // initialization.
- java::lang::Thread *thread;
- // How many levels of "extends" this class is removed from Object.
- jshort depth;
- // Vector of this class's superclasses, ordered by decreasing depth.
- jclass *ancestors;
- // Interface Dispatch Table.
- _Jv_IDispatchTable *idt;
-};
-
-#endif /* __JAVA_LANG_CLASS_H__ */
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java
deleted file mode 100644
index 0125ab46f04..00000000000
--- a/libjava/java/lang/Class.java
+++ /dev/null
@@ -1,180 +0,0 @@
-// Class.java - Representation of a Java class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.lang;
-import java.io.Serializable;
-import java.io.InputStream;
-import java.lang.reflect.*;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * plus gcj compiler sources (to determine object layout)
- * Status: Sufficient for our purposes, but some methods missing
- * and some not implemented.
- */
-
-public final class Class implements Serializable
-{
- public static native Class forName (String className)
- throws ClassNotFoundException;
- public native Class[] getClasses ();
- public native ClassLoader getClassLoader ();
- public native Class getComponentType ();
-
- public native Constructor getConstructor (Class[] parameterTypes)
- throws NoSuchMethodException, SecurityException;
-
- // This is used to implement getConstructors and
- // getDeclaredConstructors.
- private native Constructor[] _getConstructors (boolean declared)
- throws SecurityException;
-
- public Constructor[] getConstructors () throws SecurityException
- {
- return _getConstructors (false);
- }
-
- public native Constructor getDeclaredConstructor (Class[] parameterTypes)
- throws NoSuchMethodException, SecurityException;
-
- public native Class[] getDeclaredClasses () throws SecurityException;
-
- public Constructor[] getDeclaredConstructors () throws SecurityException
- {
- return _getConstructors (true);
- }
-
- public native Field getDeclaredField (String fieldName)
- throws NoSuchFieldException, SecurityException;
- public native Field[] getDeclaredFields () throws SecurityException;
- public native Method getDeclaredMethod (String methodName,
- Class[] parameterTypes)
- throws NoSuchMethodException, SecurityException;
- public native Method[] getDeclaredMethods () throws SecurityException;
-
- // This is marked as unimplemented in the JCL book.
- public native Class getDeclaringClass ();
-
- private native Field getField (String fieldName, int hash)
- throws NoSuchFieldException, SecurityException;
-
- public Field getField (String fieldName)
- throws NoSuchFieldException, SecurityException
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkMemberAccess (this, java.lang.reflect.Member.DECLARED);
- Field fld = getField(fieldName, fieldName.hashCode());
- if (fld == null)
- throw new NoSuchFieldException(fieldName);
- return fld;
- }
-
- private native Field[] _getFields (Field[] result, int offset);
- public native Field[] getFields () throws SecurityException;
-
- public native Class[] getInterfaces ();
-
- private final native void getSignature (StringBuffer buffer);
- private static final native String getSignature (Class[] parameterTypes,
- boolean is_construtor);
-
- public native Method getMethod (String methodName, Class[] parameterTypes)
- throws NoSuchMethodException, SecurityException;
- private native int _getMethods (Method[] result, int offset);
- public native Method[] getMethods () throws SecurityException;
-
- public native int getModifiers ();
- public native String getName ();
-
- public java.net.URL getResource (String resourceName)
- {
- String name = resourcePath (resourceName);
- ClassLoader loader = getClassLoader ();
- if (loader == null)
- return ClassLoader.getSystemResource (name);
- else
- return loader.getResource (name);
- }
-
- public java.io.InputStream getResourceAsStream (String resourceName)
- {
- String name = resourcePath (resourceName);
- ClassLoader loader = getClassLoader ();
- if (loader == null)
- return ClassLoader.getSystemResourceAsStream (name);
- else
- return loader.getResourceAsStream (name);
- }
-
- private String resourcePath (String resourceName)
- {
- if (resourceName.startsWith ("/"))
- return resourceName.substring (1);
-
- Class c = this;
- while (c.isArray ())
- c = c.getComponentType ();
-
- String packageName = c.getName ().replace ('.', '/');
- int end = packageName.lastIndexOf ('/');
- if (end == -1)
- return resourceName;
- else
- return packageName.substring (0, end+1) + resourceName;
- }
-
- // FIXME: implement. Requires java.security.
- public Object[] getSigners ()
- {
- return null;
- }
-
- public native Class getSuperclass ();
- public native boolean isArray ();
- public native boolean isAssignableFrom (Class cls);
- public native boolean isInstance (Object obj);
- public native boolean isInterface ();
- public native boolean isPrimitive ();
- public native Object newInstance ()
- throws InstantiationException, IllegalAccessException;
-
- public String toString ()
- {
- if (isPrimitive ())
- return getName ();
- return (isInterface () ? "interface " : "class ") + getName ();
- }
-
- // Don't allow new classes to be made.
- private Class ()
- {
- }
-
- // Do a security check.
- private void checkMemberAccess (int flags)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkMemberAccess(this, flags);
- }
-
- // Initialize the class.
- private native void initializeClass ();
-
- // finalization
- protected native void finalize ();
-}
diff --git a/libjava/java/lang/ClassCastException.java b/libjava/java/lang/ClassCastException.java
deleted file mode 100644
index 912e870a2c2..00000000000
--- a/libjava/java/lang/ClassCastException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ClassCastException extends RuntimeException
-{
- public ClassCastException()
- {
- super();
- }
-
- public ClassCastException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/ClassCircularityError.java b/libjava/java/lang/ClassCircularityError.java
deleted file mode 100644
index 21bda92c421..00000000000
--- a/libjava/java/lang/ClassCircularityError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// ClassCircularityError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ClassCircularityError extends LinkageError
-{
- public ClassCircularityError ()
- {
- super ();
- }
-
- public ClassCircularityError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/ClassFormatError.java b/libjava/java/lang/ClassFormatError.java
deleted file mode 100644
index 2af50083151..00000000000
--- a/libjava/java/lang/ClassFormatError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// ClassFormatError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ClassFormatError extends LinkageError
-{
- public ClassFormatError ()
- {
- super ();
- }
-
- public ClassFormatError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java
deleted file mode 100644
index 90f852ef6c9..00000000000
--- a/libjava/java/lang/ClassLoader.java
+++ /dev/null
@@ -1,377 +0,0 @@
-// ClassLoader.java - Define policies for loading Java classes.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.lang;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Stack;
-
-/**
- * The class <code>ClassLoader</code> is intended to be subclassed by
- * applications in order to describe new ways of loading classes,
- * such as over the network.
- *
- * @author Kresten Krab Thorup
- */
-
-public abstract class ClassLoader {
-
- static private ClassLoader system;
- private ClassLoader parent;
-
- public ClassLoader getParent ()
- {
- /* FIXME: security */
- return parent;
- }
-
- public static native ClassLoader getSystemClassLoader ();
-
- /**
- * Creates a <code>ClassLoader</code> with no parent.
- * @exception java.lang.SecurityException if not allowed
- */
- protected ClassLoader()
- {
- this (null);
- }
-
- /**
- * Creates a <code>ClassLoader</code> with the given parent.
- * The parent may be <code>null</code>.
- * The only thing this
- * constructor does, is to call
- * <code>checkCreateClassLoader</code> on the current
- * security manager.
- * @exception java.lang.SecurityException if not allowed
- */
- protected ClassLoader(ClassLoader parent)
- {
- SecurityManager security = System.getSecurityManager ();
- if (security != null)
- security.checkCreateClassLoader ();
- this.parent = parent;
- }
-
- /**
- * Loads and link the class by the given name.
- * @param name the name of the class.
- * @return the class loaded.
- * @see ClassLoader#loadClass(String,boolean)
- * @exception java.lang.ClassNotFoundException
- */
- public Class loadClass(String name)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError
- {
- return loadClass (name, false);
- }
-
- /**
- * Loads the class by the given name. The default implementation
- * will search for the class in the following order (similar to jdk 1.2)
- * <ul>
- * <li> First <code>findLoadedClass</code>.
- * <li> If parent is non-null, <code>parent.loadClass</code>;
- * otherwise <code>findSystemClass</code>.
- * <li> <code>findClass</code>.
- * </ul>
- * If <code>link</code> is true, <code>resolveClass</code> is then
- * called. <p> Normally, this need not be overridden; override
- * <code>findClass</code> instead.
- * @param name the name of the class.
- * @param link if the class should be linked.
- * @return the class loaded.
- * @exception java.lang.ClassNotFoundException
- * @deprecated
- */
- protected Class loadClass(String name, boolean link)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError
- {
- Class c = findLoadedClass (name);
-
- if (c == null)
- {
- try {
- if (parent != null)
- return parent.loadClass (name, link);
- else
- c = findSystemClass (name);
- } catch (ClassNotFoundException ex) {
- /* ignore, we'll try findClass */;
- }
- }
-
- if (c == null)
- c = findClass (name);
-
- if (c == null)
- throw new ClassNotFoundException (name);
-
- if (link)
- resolveClass (c);
-
- return c;
- }
-
- /** Find a class. This should be overridden by subclasses; the
- * default implementation throws ClassNotFoundException.
- *
- * @param name Name of the class to find.
- * @return The class found.
- * @exception java.lang.ClassNotFoundException
- */
- protected Class findClass (String name)
- throws ClassNotFoundException
- {
- throw new ClassNotFoundException ();
- }
-
- /**
- * Defines a class, given the class-data. According to the JVM, this
- * method should not be used; instead use the variant of this method
- * in which the name of the class being defined is specified
- * explicitly.
- * <P>
- * If the name of the class, as specified (implicitly) in the class
- * data, denotes a class which has already been loaded by this class
- * loader, an instance of
- * <code>java.lang.ClassNotFoundException</code> will be thrown.
- *
- * @param data bytes in class file format.
- * @param off offset to start interpreting data.
- * @param len length of data in class file.
- * @return the class defined.
- * @exception java.lang.ClassNotFoundException
- * @exception java.lang.LinkageError
- * @see ClassLoader#defineClass(String,byte[],int,int) */
- protected final Class defineClass(byte[] data, int off, int len)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError
- {
- return defineClass (null, data, off, len);
- }
-
- /**
- * Defines a class, given the class-data. This is preferable
- * over <code>defineClass(byte[],off,len)</code> since it is more
- * secure. If the expected name does not match that of the class
- * file, <code>ClassNotFoundException</code> is thrown. If
- * <code>name</code> denotes the name of an already loaded class, a
- * <code>LinkageError</code> is thrown.
- * <p>
- *
- * FIXME: How do we assure that the class-file data is not being
- * modified, simultaneously with the class loader running!? If this
- * was done in some very clever way, it might break security.
- * Right now I am thinking that defineclass should make sure never to
- * read an element of this array more than once, and that that would
- * assure the ``immutable'' appearance. It is still to be determined
- * if this is in fact how defineClass operates.
- *
- * @param name the expected name.
- * @param data bytes in class file format.
- * @param off offset to start interpreting data.
- * @param len length of data in class file.
- * @return the class defined.
- * @exception java.lang.ClassNotFoundException
- * @exception java.lang.LinkageError
- */
- protected final synchronized Class defineClass(String name,
- byte[] data,
- int off,
- int len)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError
- {
- if (data==null || data.length < off+len || off<0 || len<0)
- throw new ClassFormatError ("arguments to defineClass "
- + "are meaningless");
-
- // as per 5.3.5.1
- if (name != null && findLoadedClass (name) != null)
- throw new java.lang.LinkageError ("class "
- + name
- + " already loaded");
-
- 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);
-
- } catch (java.lang.LinkageError x) {
- throw x; // rethrow
-
- } catch (java.lang.ClassNotFoundException 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 */
- private native Class defineClass0 (String name,
- byte[] data,
- int off,
- int len)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError;
-
-
- /**
- * Link the given class. This will bring the class to a state where
- * the class initializer can be run. Linking involves the following
- * steps:
- * <UL>
- * <LI> Prepare (allocate and internalize) the constant strings that
- * are used in this class.
- * <LI> Allocate storage for static fields, and define the layout
- * of instance fields.
- * <LI> Perform static initialization of ``static final'' int,
- * long, float, double and String fields for which there is a
- * compile-time constant initializer.
- * <LI> Create the internal representation of the ``vtable''.
- * </UL>
- * For <code>gcj</code>-compiled classes, only the first step is
- * performed. The compiler will have done the rest already.
- * <P>
- * This is called by the system automatically,
- * as part of class initialization; there is no reason to ever call
- * this method directly.
- * <P>
- * For historical reasons, this method has a name which is easily
- * misunderstood. Java classes are never ``resolved''. Classes are
- * linked; whereas method and field references are resolved.
- *
- * @param clazz the class to link.
- * @exception java.lang.LinkageError
- */
- protected final void resolveClass(Class clazz)
- throws java.lang.LinkageError
- {
- resolveClass0(clazz);
- }
-
- static void resolveClass0(Class clazz)
- throws java.lang.LinkageError
- {
- synchronized (clazz)
- {
- try {
- linkClass0 (clazz);
- } catch (Throwable x) {
- markClassErrorState0 (clazz);
-
- if (x instanceof Error)
- throw (Error)x;
- else
- throw new java.lang.InternalError
- ("unexpected exception during linking: " + x);
- }
- }
- }
-
- /** Internal method. Calls _Jv_PrepareClass and
- * _Jv_PrepareCompiledClass. This is only called from resolveClass. */
- private static native void linkClass0(Class clazz)
- throws java.lang.LinkageError;
-
- /** Internal method. Marks the given clazz to be in an erroneous
- * state, and calls notifyAll() on the class object. This should only
- * be called when the caller has the lock on the class object. */
- private static native void markClassErrorState0(Class clazz);
-
-
- /**
- * Returns a class found in a system-specific way, typically
- * via the <code>java.class.path</code> system property. Loads the
- * class if necessary.
- *
- * @param name the class to resolve.
- * @return the class loaded.
- * @exception java.lang.LinkageError
- * @exception java.lang.ClassNotFoundException
- */
- protected Class findSystemClass(String name)
- throws java.lang.ClassNotFoundException, java.lang.LinkageError
- {
- return getSystemClassLoader ().loadClass (name);
- }
-
- /*
- * Does currently nothing.
- */
- protected final void setSigners(Class claz, Object[] signers) {
- /* claz.setSigners (signers); */
- }
-
- /**
- * If a class named <code>name</code> was previously loaded using
- * this <code>ClassLoader</code>, then it is returned. Otherwise
- * it returns <code>null</code>. (Unlike the JDK this is native,
- * since we implement the class table internally.)
- * @param name class to find.
- * @return the class loaded, or null.
- */
- protected native Class findLoadedClass(String name);
-
- public static final InputStream getSystemResourceAsStream(String name) {
- return getSystemClassLoader().getResourceAsStream (name);
- }
-
- public static final URL getSystemResource(String name) {
- return getSystemClassLoader().getResource (name);
- }
-
- /**
- * Return an InputStream representing the resource name.
- * This is essentially like
- * <code>getResource(name).openStream()</code>, except
- * it masks out any IOException and returns null on failure.
- * @param name resource to load
- * @return an InputStream, or null
- * @see java.lang.ClassLoader#getResource(String)
- * @see java.io.InputStream
- */
- public InputStream getResourceAsStream(String name)
- {
- try {
- URL res = getResource (name);
- if (res == null) return null;
- return res.openStream ();
- } catch (java.io.IOException x) {
- return null;
- }
- }
-
- /**
- * Return an java.io.URL representing the resouce <code>name</code>.
- * The default implementation just returns <code>null</code>.
- * @param name resource to load
- * @return a URL, or null if there is no such resource.
- * @see java.lang.ClassLoader#getResourceAsBytes(String)
- * @see java.lang.ClassLoader#getResourceAsStream(String)
- * @see java.io.URL
- */
- public URL getResource(String name) {
- return null;
- }
-
-}
-
diff --git a/libjava/java/lang/ClassNotFoundException.java b/libjava/java/lang/ClassNotFoundException.java
deleted file mode 100644
index 0eda3e1777f..00000000000
--- a/libjava/java/lang/ClassNotFoundException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ClassNotFoundException extends Exception
-{
- public ClassNotFoundException()
- {
- super();
- }
-
- // TODO12:
- // public ClassNotFoundException(String msg, Throwable ex)
- // {
- // }
-
- public ClassNotFoundException(String msg)
- {
- super(msg);
- }
-
- // TODO12:
- // public Throwable getException()
- // {
- // }
-
- // TBD: if this needs to be implemented
- // public void printStackTrace()
- // {
- // }
-
- // TBD: if this needs to be implemented
- // public void printStackTrace(PrintStream ps)
- // {
- // }
-
- // TBD: if this needs to be implemented
- // public void printStackTrace(PrintWriter pw)
- // {
- // }
-}
diff --git a/libjava/java/lang/CloneNotSupportedException.java b/libjava/java/lang/CloneNotSupportedException.java
deleted file mode 100644
index 62c0c04c997..00000000000
--- a/libjava/java/lang/CloneNotSupportedException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class CloneNotSupportedException extends Exception
-{
- public CloneNotSupportedException()
- {
- super();
- }
-
- public CloneNotSupportedException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/Cloneable.java b/libjava/java/lang/Cloneable.java
deleted file mode 100644
index 404bff914f9..00000000000
--- a/libjava/java/lang/Cloneable.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public interface Cloneable
-{
-}
diff --git a/libjava/java/lang/Comparable.java b/libjava/java/lang/Comparable.java
deleted file mode 100644
index d153d1050bd..00000000000
--- a/libjava/java/lang/Comparable.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 8, 1998.
- */
-/* Written using online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public interface Comparable
-{
- public int compareTo(Object o) throws ClassCastException;
-}
diff --git a/libjava/java/lang/Compiler.java b/libjava/java/lang/Compiler.java
deleted file mode 100644
index bb0f78495f2..00000000000
--- a/libjava/java/lang/Compiler.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// Compiler.java - Control byte->machine code compiler.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 23, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- */
-
-public final class Compiler
-{
- public static Object command (Object arg)
- {
- // Our implementation defines this to a no-op.
- return null;
- }
-
- public static boolean compileClass (Class oneClass)
- {
- // Never succeed.
- return false;
- }
-
- public static boolean compileClasses (String classNames)
- {
- // Note the incredibly lame interface. Always fail.
- return false;
- }
-
- public static void disable ()
- {
- }
-
- public static void enable ()
- {
- }
-
- // Don't allow new `Compiler's to be made.
- private Compiler ()
- {
- }
-}
diff --git a/libjava/java/lang/Double.java b/libjava/java/lang/Double.java
deleted file mode 100644
index 4613e783752..00000000000
--- a/libjava/java/lang/Double.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Andrew Haley <aph@cygnus.com>
- * @date September 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public final class Double extends Number
-{
- public static final double MIN_VALUE = 5e-324;
- public static final double MAX_VALUE = 1.7976931348623157e+308;
- public static final double NEGATIVE_INFINITY = -1.0d/0.0d;
- public static final double POSITIVE_INFINITY = 1.0d/0.0d;
- public static final double NaN = 0.0d/0.0d;
-
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public static final Class TYPE = double.class;
-
- private double value;
-
- private native static double doubleValueOf (String s)
- throws NumberFormatException;
-
- public Double (double v)
- {
- value = v;
- }
-
- public Double (String s) throws NumberFormatException
- {
- value = valueOf (s).doubleValue ();
- }
-
- public String toString ()
- {
- return toString (value);
- }
-
- public boolean equals (Object obj)
- {
- if (obj == null)
- return false;
-
- if (!(obj instanceof Double))
- return false;
-
- Double d = (Double) obj;
-
- return doubleToLongBits (value) == doubleToLongBits (d.doubleValue ());
- }
-
- public int hashCode ()
- {
- long v = doubleToLongBits (value);
- return (int) (v ^ (v >>> 32));
- }
-
- public int intValue ()
- {
- return (int) value;
- }
-
- public long longValue ()
- {
- return (long) value;
- }
-
- public float floatValue ()
- {
- return (float) value;
- }
-
- public double doubleValue ()
- {
- return value;
- }
-
- public byte byteValue ()
- {
- return (byte) value;
- }
-
- public short shortValue ()
- {
- return (short) value;
- }
-
- native static String toString (double v, boolean isFloat);
-
- public static String toString (double v)
- {
- return toString (v, false);
- }
-
- public static Double valueOf (String s) throws NullPointerException,
- NumberFormatException
- {
- if (s == null)
- throw new NullPointerException ();
-
- return new Double (doubleValueOf (s));
- }
-
- public boolean isNaN ()
- {
- return isNaN (value);
- }
-
- public static boolean isNaN (double v)
- {
- long bits = doubleToLongBits (v);
- long e = bits & 0x7ff0000000000000L;
- long f = bits & 0x000fffffffffffffL;
-
- return e == 0x7ff0000000000000L && f != 0L;
- }
-
- public boolean isInfinite ()
- {
- return isInfinite (value);
- }
-
- public static boolean isInfinite (double v)
- {
- long bits = doubleToLongBits (v);
- long f = bits & 0x7fffffffffffffffL;
-
- return f == 0x7ff0000000000000L;
- }
-
- public static native long doubleToLongBits (double value);
-
- public static native double longBitsToDouble (long bits);
-}
-
diff --git a/libjava/java/lang/EcosProcess.java b/libjava/java/lang/EcosProcess.java
deleted file mode 100644
index 4c200a0de28..00000000000
--- a/libjava/java/lang/EcosProcess.java
+++ /dev/null
@@ -1,59 +0,0 @@
-// EcosProcess.java - Subclass of Process for eCos systems.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date May 11, 1999
- */
-
-// This is entirely internal to our implementation.
-
-// This file is copied to `ConcreteProcess.java' before compilation.
-// Hence the class name apparently does not match the file name.
-final class ConcreteProcess extends Process
-{
- // See natEcosProcess.cc to understand why this is native.
- public native void destroy ();
-
- public int exitValue ()
- {
- return 0;
- }
- public InputStream getErrorStream ()
- {
- return null;
- }
-
- public InputStream getInputStream ()
- {
- return null;
- }
-
- public OutputStream getOutputStream ()
- {
- return null;
- }
-
- public int waitFor () throws InterruptedException
- {
- return 0;
- }
-
- public ConcreteProcess (String[] progarray, String[] envp) throws IOException
- {
- throw new IOException ("eCos processes unimplemented");
- }
-}
diff --git a/libjava/java/lang/Error.java b/libjava/java/lang/Error.java
deleted file mode 100644
index a9f9d80215a..00000000000
--- a/libjava/java/lang/Error.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Error.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class Error extends Throwable
-{
- public Error ()
- {
- super ();
- }
-
- public Error (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/Exception.java b/libjava/java/lang/Exception.java
deleted file mode 100644
index 71df1dd9d3c..00000000000
--- a/libjava/java/lang/Exception.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class Exception extends Throwable
-{
- public Exception()
- {
- super();
- }
-
- public Exception(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/ExceptionInInitializerError.java b/libjava/java/lang/ExceptionInInitializerError.java
deleted file mode 100644
index 5c0144bdfa5..00000000000
--- a/libjava/java/lang/ExceptionInInitializerError.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// ExceptionInInitializerError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ExceptionInInitializerError extends LinkageError
-{
- public ExceptionInInitializerError ()
- {
- super ();
- exception = null;
- }
-
- public ExceptionInInitializerError (String msg)
- {
- super (msg);
- exception = null;
- }
-
- public ExceptionInInitializerError (Throwable e)
- {
- super ();
- exception = e;
- }
-
- public Throwable getException ()
- {
- return exception;
- }
-
- // The exception that caused this error.
- private Throwable exception;
-}
diff --git a/libjava/java/lang/Float.java b/libjava/java/lang/Float.java
deleted file mode 100644
index 63c6fa1e184..00000000000
--- a/libjava/java/lang/Float.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Andrew Haley <aph@cygnus.com>
- * @date September 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public final class Float extends Number
-{
- public static final float MAX_VALUE = 3.4028235e+38f;
- public static final float MIN_VALUE = 1.4e-45f;
- public static final float NEGATIVE_INFINITY = -1.0f/0.0f;
- public static final float POSITIVE_INFINITY = 1.0f/0.0f;
- public static final float NaN = 0.0f/0.0f;
-
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public static final Class TYPE = float.class;
-
- private float value;
-
- public Float (float value)
- {
- this.value = value;
- }
-
- public Float (double value)
- {
- this.value = (float)value;
- }
-
- public Float (String s) throws NumberFormatException
- {
- this.value = valueOf (s).floatValue ();
- }
-
- public String toString ()
- {
- return toString (value);
- }
-
- public boolean equals (Object obj)
- {
- if (obj == null)
- return false;
-
- if (!(obj instanceof Float))
- return false;
-
- Float f = (Float) obj;
-
- return floatToIntBits (value) == floatToIntBits (f.floatValue ());
- }
-
- public int hashCode ()
- {
- return floatToIntBits (value);
- }
-
- public int intValue ()
- {
- return (int) value;
- }
-
- public long longValue ()
- {
- return (long) value;
- }
-
- public float floatValue ()
- {
- return (float) value;
- }
-
- public double doubleValue ()
- {
- return (double) value;
- }
-
- public byte byteValue ()
- {
- return (byte) value;
- }
-
- public short shortValue ()
- {
- return (short) value;
- }
-
- public static String toString (float v)
- {
- return Double.toString ((double) v, true);
- }
-
- public static Float valueOf (String s) throws NullPointerException,
- NumberFormatException
- {
- if (s == null)
- throw new NullPointerException ();
-
- return new Float (Double.valueOf (s).floatValue ());
- }
-
- public boolean isNaN ()
- {
- return isNaN (value);
- }
-
- public static boolean isNaN (float v)
- {
- int bits = floatToIntBits (v);
- int e = bits & 0x7f800000;
- int f = bits & 0x007fffff;
-
- return e == 0x7f800000 && f != 0;
- }
-
- public boolean isInfinite ()
- {
- return isInfinite (value);
- }
-
- public static boolean isInfinite (float v)
- {
- int bits = floatToIntBits (v);
- int f = bits & 0x7fffffff;
-
- return f == 0x7f800000;
- }
-
- public static native int floatToIntBits (float value);
-
- public static native float intBitsToFloat (int bits);
-
-}
-
diff --git a/libjava/java/lang/IllegalAccessError.java b/libjava/java/lang/IllegalAccessError.java
deleted file mode 100644
index a2cf57dea15..00000000000
--- a/libjava/java/lang/IllegalAccessError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// IllegalAccessError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class IllegalAccessError extends IncompatibleClassChangeError
-{
- public IllegalAccessError ()
- {
- super ();
- }
-
- public IllegalAccessError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/IllegalAccessException.java b/libjava/java/lang/IllegalAccessException.java
deleted file mode 100644
index d3618113776..00000000000
--- a/libjava/java/lang/IllegalAccessException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class IllegalAccessException extends Exception
-{
- public IllegalAccessException()
- {
- super();
- }
-
- public IllegalAccessException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/IllegalArgumentException.java b/libjava/java/lang/IllegalArgumentException.java
deleted file mode 100644
index 935092bcf7d..00000000000
--- a/libjava/java/lang/IllegalArgumentException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class IllegalArgumentException extends RuntimeException
-{
- public IllegalArgumentException()
- {
- super();
- }
-
- public IllegalArgumentException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/IllegalMonitorStateException.java b/libjava/java/lang/IllegalMonitorStateException.java
deleted file mode 100644
index 32b50f468c9..00000000000
--- a/libjava/java/lang/IllegalMonitorStateException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class IllegalMonitorStateException extends RuntimeException
-{
- public IllegalMonitorStateException()
- {
- super();
- }
-
- public IllegalMonitorStateException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/IllegalStateException.java b/libjava/java/lang/IllegalStateException.java
deleted file mode 100644
index 90abb524505..00000000000
--- a/libjava/java/lang/IllegalStateException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class IllegalStateException extends RuntimeException
-{
- public IllegalStateException()
- {
- super();
- }
-
- public IllegalStateException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/IllegalThreadStateException.java b/libjava/java/lang/IllegalThreadStateException.java
deleted file mode 100644
index f6b63924180..00000000000
--- a/libjava/java/lang/IllegalThreadStateException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class IllegalThreadStateException extends IllegalArgumentException
-{
- public IllegalThreadStateException()
- {
- super();
- }
-
- public IllegalThreadStateException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/IncompatibleClassChangeError.java b/libjava/java/lang/IncompatibleClassChangeError.java
deleted file mode 100644
index 1477732d22c..00000000000
--- a/libjava/java/lang/IncompatibleClassChangeError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// IncompatibleClassChangeError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class IncompatibleClassChangeError extends LinkageError
-{
- public IncompatibleClassChangeError ()
- {
- super ();
- }
-
- public IncompatibleClassChangeError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/IndexOutOfBoundsException.java b/libjava/java/lang/IndexOutOfBoundsException.java
deleted file mode 100644
index f1175253aef..00000000000
--- a/libjava/java/lang/IndexOutOfBoundsException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class IndexOutOfBoundsException extends RuntimeException
-{
- public IndexOutOfBoundsException()
- {
- super();
- }
-
- public IndexOutOfBoundsException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/InstantiationError.java b/libjava/java/lang/InstantiationError.java
deleted file mode 100644
index 595abaf6fd1..00000000000
--- a/libjava/java/lang/InstantiationError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// InstantiationError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class InstantiationError extends IncompatibleClassChangeError
-{
- public InstantiationError ()
- {
- super ();
- }
-
- public InstantiationError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/InstantiationException.java b/libjava/java/lang/InstantiationException.java
deleted file mode 100644
index 1ea91ba9aee..00000000000
--- a/libjava/java/lang/InstantiationException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class InstantiationException extends Exception
-{
- public InstantiationException()
- {
- super();
- }
-
- public InstantiationException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/Integer.java b/libjava/java/lang/Integer.java
deleted file mode 100644
index feb77851e58..00000000000
--- a/libjava/java/lang/Integer.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 11, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public final class Integer extends Number implements Comparable
-{
- public static final int MAX_VALUE = 0x7FFFFFFF;
- public static final int MIN_VALUE = 0x80000000;
-
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public static final Class TYPE = int.class;
-
- /* The int value of the instance. */
- private int value;
-
- public Integer(int val)
- {
- value = val;
- }
-
- public Integer(String str) throws NumberFormatException
- {
- value = parseInt(str, 10);
- }
-
- public byte byteValue()
- {
- return (byte) value;
- }
-
- public double doubleValue()
- {
- return (double) value;
- }
-
- public float floatValue()
- {
- return (float) value;
- }
-
- public int intValue()
- {
- return value;
- }
-
- public long longValue()
- {
- return value;
- }
-
- public short shortValue()
- {
- return (short) value;
- }
-
- // Added in JDK 1.2
- public int compareTo(Integer anotherInteger)
- {
- if (this.value == anotherInteger.value)
- return 0;
-
- // Returns just -1 or 1 on inequality; doing math might overflow the int.
- if (this.value > anotherInteger.value)
- return 1;
-
- return -1;
- }
-
- // Added in JDK 1.2
- public int compareTo(Object o) throws ClassCastException
- {
- if (!(o instanceof Integer))
- throw new ClassCastException();
-
- return this.compareTo((Integer) o);
- }
-
- public static Integer decode(String str) throws NumberFormatException
- {
- boolean isNeg = false;
- int index = 0;
- int radix = 10;
- final int len;
-
- if (str == null || (len = str.length()) == 0)
- throw new NumberFormatException();
-
- // Negative numbers are always radix 10.
- if (str.charAt(0) == '-')
- {
- radix = 10;
- index++;
- isNeg = true;
- }
- else if (str.charAt(index) == '#')
- {
- radix = 16;
- index++;
- }
- else if (str.charAt(index) == '0')
- {
- // Check if str is just "0"
- if (len == 1)
- return new Integer(0);
-
- index++;
- if (str.charAt(index) == 'x')
- {
- radix = 16;
- index++;
- }
- else
- radix = 8;
- }
-
- if (index >= len)
- throw new NumberFormatException();
-
- return new Integer(parseInt(str, index, len, isNeg, radix));
- }
-
- public boolean equals(Object obj)
- {
- return (obj != null && (obj instanceof Integer)
- && ((Integer) obj).value == value);
- }
-
- public static Integer getInteger(String prop)
- {
- return getInteger(prop, null);
- }
-
- public static Integer getInteger(String prop, int defval)
- {
- Integer val = getInteger(prop, null);
- return val == null ? new Integer(defval) : val;
- }
-
- public static Integer getInteger(String prop, Integer defobj)
- {
- try
- {
- return decode(System.getProperty(prop));
- }
- catch (NumberFormatException ex)
- {
- return defobj;
- }
- }
-
- public int hashCode()
- {
- return value;
- }
-
- public static int parseInt(String str) throws NumberFormatException
- {
- return parseInt(str, 10);
- }
-
- public static int parseInt(String str, int radix) throws NumberFormatException
- {
- final int len;
-
- if (str == null || (len = str.length()) == 0 ||
- radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
- throw new NumberFormatException();
-
- boolean isNeg = false;
- int index = 0;
- if (str.charAt(index) == '-')
- if (len > 1)
- {
- isNeg = true;
- index++;
- }
- else
- throw new NumberFormatException();
-
- return parseInt(str, index, len, isNeg, radix);
- }
-
- private static int parseInt(String str, int index, int len, boolean isNeg,
- int radix) throws NumberFormatException
- {
- int val = 0;
- int digval;
-
- int max = MAX_VALUE / radix;
- // We can't directly write `max = (MAX_VALUE + 1) / radix'.
- // So instead we fake it.
- if (isNeg && MAX_VALUE % radix == radix - 1)
- ++max;
-
- for ( ; index < len; index++)
- {
- if (val < 0 || val > max)
- throw new NumberFormatException();
-
- if ((digval = Character.digit(str.charAt(index), radix)) < 0)
- throw new NumberFormatException();
-
- // Throw an exception for overflow if result is negative.
- // However, we special-case the most negative value.
- val = val * radix + digval;
- if (val < 0 && (! isNeg || val != MIN_VALUE))
- throw new NumberFormatException();
- }
-
- return isNeg ? -(val) : val;
- }
-
- public static String toBinaryString(int num)
- {
- return toUnsignedString(num, 1);
- }
-
- public static String toHexString(int num)
- {
- return toUnsignedString(num, 4);
- }
-
- public static String toOctalString(int num)
- {
- return toUnsignedString(num, 3);
- }
-
- private static String toUnsignedString(int num, int exp)
- {
- // Use an array large enough for a binary number.
- int radix = 1 << exp;
- int mask = radix - 1;
- char[] buffer = new char[32];
- int i = 32;
- do
- {
- buffer[--i] = Character.forDigit(num & mask, radix);
- num = num >>> exp;
- }
- while (num != 0);
-
- return String.valueOf(buffer, i, 32-i);
- }
-
- public String toString()
- {
- return toString(this.value);
- }
-
- public static String toString(int num)
- {
- // Use an arrary large enough for "-2147483648"; i.e. 11 chars.
- char[] buffer = new char[11];
- int i = 11;
- boolean isNeg;
- if (num < 0)
- {
- isNeg = true;
- num = -(num);
- if (num < 0)
- {
- // Must be MIN_VALUE, so handle this special case.
- buffer[--i] = '8';
- num = 214748364;
- }
- }
- else
- isNeg = false;
-
- do
- {
- buffer[--i] = (char) ((int) '0' + (num % 10));
- num /= 10;
- }
- while (num > 0);
-
- if (isNeg)
- buffer[--i] = '-';
-
- return String.valueOf(buffer, i, 11-i);
- }
-
- public static String toString(int num, int radix)
- {
- // Use optimized method for the typical case.
- if (radix == 10 ||
- radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
- return toString(num);
-
- // For negative numbers, print out the absolute value w/ a leading '-'.
- // Use an array large enough for a binary number.
- char[] buffer = new char[33];
- int i = 33;
- boolean isNeg;
- if (num < 0)
- {
- isNeg = true;
- num = -(num);
-
- // When the value is MIN_VALUE, it overflows when made positive
- if (num < 0)
- {
- buffer[--i] = Character.forDigit(-(num + radix) % radix, radix);
- num = -(num / radix);
- }
- }
- else
- isNeg = false;
-
- do
- {
- buffer[--i] = Character.forDigit(num % radix, radix);
- num /= radix;
- }
- while (num > 0);
-
- if (isNeg)
- buffer[--i] = '-';
-
- return String.valueOf(buffer, i, 33-i);
- }
-
- public static Integer valueOf(String str) throws NumberFormatException
- {
- return new Integer(parseInt(str, 10));
- }
-
- public static Integer valueOf(String str, int radix)
- throws NumberFormatException
- {
- return new Integer(parseInt(str, radix));
- }
-}
diff --git a/libjava/java/lang/InternalError.java b/libjava/java/lang/InternalError.java
deleted file mode 100644
index e8e9755a762..00000000000
--- a/libjava/java/lang/InternalError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// InternalError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class InternalError extends VirtualMachineError
-{
- public InternalError ()
- {
- super ();
- }
-
- public InternalError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/InterruptedException.java b/libjava/java/lang/InterruptedException.java
deleted file mode 100644
index adb73c2d79d..00000000000
--- a/libjava/java/lang/InterruptedException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class InterruptedException extends Exception
-{
- public InterruptedException()
- {
- super();
- }
-
- public InterruptedException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/LinkageError.java b/libjava/java/lang/LinkageError.java
deleted file mode 100644
index af380ca4708..00000000000
--- a/libjava/java/lang/LinkageError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// LinkageError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class LinkageError extends Error
-{
- public LinkageError ()
- {
- super ();
- }
-
- public LinkageError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/Long.java b/libjava/java/lang/Long.java
deleted file mode 100644
index 95f426d2206..00000000000
--- a/libjava/java/lang/Long.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public final class Long extends Number implements Comparable
-{
- public static final long MAX_VALUE = 0x7FFFFFFFFFFFFFFFL;
- public static final long MIN_VALUE = 0x8000000000000000L;
-
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public static final Class TYPE = long.class;
-
- /* The long value of the instance. */
- private long value;
-
- public Long(long val)
- {
- value = val;
- }
-
- public Long(String str) throws NumberFormatException
- {
- value = parseLong(str, 10);
- }
-
- public byte byteValue()
- {
- return (byte) value;
- }
-
- public double doubleValue()
- {
- return (double) value;
- }
-
- public float floatValue()
- {
- return (float) value;
- }
-
- public int intValue()
- {
- return (int) value;
- }
-
- public long longValue()
- {
- return value;
- }
-
- public short shortValue()
- {
- return (short) value;
- }
-
- // Added in JDK 1.2
- public int compareTo(Long anotherLong)
- {
- if (this.value == anotherLong.value)
- return 0;
-
- // Returns just -1 or 1 on inequality; doing math might overflow the long.
- if (this.value > anotherLong.value)
- return 1;
-
- return -1;
- }
-
- // Added in JDK 1.2
- public int compareTo(Object o) throws ClassCastException
- {
- if (!(o instanceof Long))
- throw new ClassCastException();
-
- return this.compareTo((Long) o);
- }
-
- // Added in JDK 1.2
- public static Long decode(String str) throws NumberFormatException
- {
- boolean isNeg = false;
- int index = 0;
- int radix = 10;
- final int len;
-
- if (str == null || (len = str.length()) == 0)
- throw new NumberFormatException();
-
- // Negative numbers are always radix 10.
- if (str.charAt(0) == '-')
- {
- radix = 10;
- index++;
- isNeg = true;
- }
- else if (str.charAt(index) == '#')
- {
- radix = 16;
- index++;
- }
- else if (str.charAt(index) == '0')
- {
- // Check if str is just "0"
- if (len == 1)
- return new Long(0L);
-
- index++;
- if (str.charAt(index) == 'x')
- {
- radix = 16;
- index++;
- }
- else
- radix = 8;
- }
-
- if (index >= len)
- throw new NumberFormatException();
-
- return new Long(parseLong(str, index, len, isNeg, radix));
- }
-
- public boolean equals(Object obj)
- {
- return (obj != null && (obj instanceof Long)
- && ((Long) obj).value == value);
- }
-
- public static Long getLong(String prop)
- {
- return getLong(prop, null);
- }
-
- public static Long getLong(String prop, long defval)
- {
- Long val = getLong(prop, null);
- return val == null ? new Long(defval) : val;
- }
-
- public static Long getLong(String prop, Long defobj)
- {
- try
- {
- return decode(System.getProperty(prop));
- }
- catch (NumberFormatException ex)
- {
- return defobj;
- }
- }
-
- public int hashCode()
- {
- return (int)(this.longValue()^(this.longValue()>>>32));
- }
-
- public static long parseLong(String str) throws NumberFormatException
- {
- return parseLong(str, 10);
- }
-
- public static long parseLong(String str, int radix)
- throws NumberFormatException
- {
- final int len;
-
- if (str == null || (len = str.length()) == 0 ||
- radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
- throw new NumberFormatException();
-
- boolean isNeg = false;
- int index = 0;
- if (str.charAt(index) == '-')
- if (len > 1)
- {
- isNeg = true;
- index++;
- }
- else
- throw new NumberFormatException();
-
- return parseLong(str, index, len, isNeg, radix);
- }
-
- private static long parseLong(String str, int index, int len, boolean isNeg,
- int radix) throws NumberFormatException
- {
- long val = 0;
- int digval;
-
- long max = MAX_VALUE / radix;
- // We can't directly write `max = (MAX_VALUE + 1) / radix'.
- // So instead we fake it.
- if (isNeg && MAX_VALUE % radix == radix - 1)
- ++max;
-
- for ( ; index < len; index++)
- {
- if (val < 0 || val > max)
- throw new NumberFormatException();
-
- if ((digval = Character.digit(str.charAt(index), radix)) < 0)
- throw new NumberFormatException();
-
- // Throw an exception for overflow if result is negative.
- // However, we special-case the most negative value.
- val = val * radix + digval;
- if (val < 0 && (! isNeg || val != MIN_VALUE))
- throw new NumberFormatException();
- }
-
- return isNeg ? -(val) : val;
- }
-
- public static String toBinaryString(long num)
- {
- return toUnsignedString(num, 1);
- }
-
- public static String toHexString(long num)
- {
- return toUnsignedString(num, 4);
- }
-
- public static String toOctalString(long num)
- {
- return toUnsignedString(num, 3);
- }
-
- private static String toUnsignedString(long num, int exp)
- {
- // Use an array large enough for a binary number.
- int radix = 1 << exp;
- long mask = radix - 1;
- char[] buffer = new char[64];
- int i = 64;
- do
- {
- buffer[--i] = Character.forDigit((int) (num & mask), radix);
- num = num >>> exp;
- }
- while (num != 0);
-
- return String.valueOf(buffer, i, 64-i);
- }
-
- public String toString()
- {
- return toString(this.value);
- }
-
- public static String toString(long num)
- {
- // Use the Integer toString for efficiency if possible.
- if (num <= Integer.MAX_VALUE && num >= Integer.MIN_VALUE)
- return Integer.toString((int) num);
-
- // Use an arrary large enough for "-9223372036854775808"; i.e. 11 chars.
- char[] buffer = new char[20];
- int i = 20;
- boolean isNeg;
- if (num < 0)
- {
- isNeg = true;
- num = -(num);
- if (num < 0)
- {
- // Must be MIN_VALUE, so handle this special case.
- buffer[--i] = '8';
- num = 922337203685477580L;
- }
- }
- else
- isNeg = false;
-
- do
- {
- buffer[--i] = (char) ((int) '0' + (num % 10));
- num /= 10;
- }
- while (num > 0);
-
- if (isNeg)
- buffer[--i] = '-';
-
- return String.valueOf(buffer, i, 20-i);
- }
-
- public static String toString(long num, int radix)
- {
- // Use optimized method for the typical case.
- if (radix == 10 ||
- radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
- return toString(num);
-
- // Use the Integer toString for efficiency if possible.
- if (num <= Integer.MAX_VALUE && num >= Integer.MIN_VALUE)
- return Integer.toString((int) num, radix);
-
- // For negative numbers, print out the absolute value w/ a leading '-'.
- // Use an array large enough for a binary number.
- char[] buffer = new char[65];
- int i = 65;
- boolean isNeg;
- if (num < 0)
- {
- isNeg = true;
- num = -(num);
-
- // When the value is MIN_VALUE, it overflows when made positive
- if (num < 0)
- {
- buffer[--i] = Character.forDigit((int) (-(num + radix) % radix),
- radix);
- num = -(num / radix);
- }
- }
- else
- isNeg = false;
-
- do
- {
- buffer[--i] = Character.forDigit((int) (num % radix), radix);
- num /= radix;
- }
- while (num > 0);
-
- if (isNeg)
- buffer[--i] = '-';
-
- return String.valueOf(buffer, i, 65-i);
- }
-
- public static Long valueOf(String str) throws NumberFormatException
- {
- return new Long(parseLong(str, 10));
- }
-
- public static Long valueOf(String str, int radix)
- throws NumberFormatException
- {
- return new Long(parseLong(str, radix));
- }
-}
diff --git a/libjava/java/lang/Math.java b/libjava/java/lang/Math.java
deleted file mode 100644
index 0b9ae213c77..00000000000
--- a/libjava/java/lang/Math.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 <aph@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-package java.lang;
-
-import java.util.Random;
-
-public final class Math
-{
- private static Random random_;
-
- public static final double E = 2.7182818284590452354;
- public static final double PI = 3.14159265358979323846;
-
- public static native double sin (double x);
-
- public static native double cos (double x);
-
- public static native double tan (double x);
-
- public static native double asin (double x);
-
- public static native double acos (double x);
-
- public static native double atan (double x);
-
- public static native double atan2(double y, double x);
-
- public static native double exp (double x);
-
- public static native double log (double x);
-
- public static native double sqrt (double x);
-
- public static native double pow (double x, double y);
-
- public static native double IEEEremainder (double x, double y);
-
- public static native double ceil (double x);
-
- public static native double floor (double x);
-
- public static native double rint (double x);
-
- public static native int round (float x);
-
- public static native long round (double x);
-
- public static synchronized double random ()
- {
- if (random_ == null)
- random_ = new Random ();
- return random_.nextDouble ();
- }
-
- public static int abs (int n)
- {
- return (n < 0 ? -n : n);
- }
-
- public static long abs (long n)
- {
- return (n < 0 ? -n : n);
- }
-
- public static native float abs (float x);
-
- public static native double abs (double x);
-
- public static int min (int a, int b)
- {
- return (a < b ? a : b);
- }
-
- public static long min (long a, long b)
- {
- return (a < b ? a : b);
- }
-
- public static native float min (float a, float b);
-
- public static native double min (double a, double b);
-
- public static int max (int a, int b)
- {
- return (a < b ? b : a);
- }
-
- public static long max (long a, long b)
- {
- return (a < b ? b : a);
- }
-
- public static native float max (float a, float b);
-
- public static native double max (double a, double b);
-
- // Don't allow objects to be made.
- private Math ()
- {
- }
-}
-
diff --git a/libjava/java/lang/NegativeArraySizeException.java b/libjava/java/lang/NegativeArraySizeException.java
deleted file mode 100644
index 22f1423cbcd..00000000000
--- a/libjava/java/lang/NegativeArraySizeException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NegativeArraySizeException extends RuntimeException
-{
- public NegativeArraySizeException()
- {
- super();
- }
-
- public NegativeArraySizeException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/NoClassDefFoundError.java b/libjava/java/lang/NoClassDefFoundError.java
deleted file mode 100644
index afb3abb86ee..00000000000
--- a/libjava/java/lang/NoClassDefFoundError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// NoClassDefFoundError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NoClassDefFoundError extends LinkageError
-{
- public NoClassDefFoundError ()
- {
- super ();
- }
-
- public NoClassDefFoundError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/NoSuchFieldError.java b/libjava/java/lang/NoSuchFieldError.java
deleted file mode 100644
index 7835ebd26a0..00000000000
--- a/libjava/java/lang/NoSuchFieldError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// NoSuchFieldError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NoSuchFieldError extends IncompatibleClassChangeError
-{
- public NoSuchFieldError ()
- {
- super ();
- }
-
- public NoSuchFieldError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/NoSuchFieldException.java b/libjava/java/lang/NoSuchFieldException.java
deleted file mode 100644
index 1c959fad255..00000000000
--- a/libjava/java/lang/NoSuchFieldException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NoSuchFieldException extends Exception
-{
- public NoSuchFieldException()
- {
- super();
- }
-
- public NoSuchFieldException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/NoSuchMethodError.java b/libjava/java/lang/NoSuchMethodError.java
deleted file mode 100644
index c266e2ee527..00000000000
--- a/libjava/java/lang/NoSuchMethodError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// NoSuchMethodError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NoSuchMethodError extends IncompatibleClassChangeError
-{
- public NoSuchMethodError ()
- {
- super ();
- }
-
- public NoSuchMethodError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/NoSuchMethodException.java b/libjava/java/lang/NoSuchMethodException.java
deleted file mode 100644
index 87e2132e790..00000000000
--- a/libjava/java/lang/NoSuchMethodException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NoSuchMethodException extends Exception
-{
- public NoSuchMethodException()
- {
- super();
- }
-
- public NoSuchMethodException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/NullPointerException.java b/libjava/java/lang/NullPointerException.java
deleted file mode 100644
index f4b2757892d..00000000000
--- a/libjava/java/lang/NullPointerException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NullPointerException extends RuntimeException
-{
- public NullPointerException()
- {
- super();
- }
-
- public NullPointerException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/Number.java b/libjava/java/lang/Number.java
deleted file mode 100644
index 9fa05662fd5..00000000000
--- a/libjava/java/lang/Number.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public abstract class Number implements Serializable
-{
- public byte byteValue() // Became non-abstract in JDK 1.2
- {
- return (byte) intValue();
- }
-
- public abstract double doubleValue();
- public abstract float floatValue();
- public abstract int intValue();
- public abstract long longValue();
-
- public short shortValue() // Became non-abstract in JDK 1.2
- {
- return (short) intValue();
- }
-}
diff --git a/libjava/java/lang/NumberFormatException.java b/libjava/java/lang/NumberFormatException.java
deleted file mode 100644
index 1b97c758c4d..00000000000
--- a/libjava/java/lang/NumberFormatException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NumberFormatException extends IllegalArgumentException
-{
- public NumberFormatException()
- {
- super();
- }
-
- public NumberFormatException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/Object.h b/libjava/java/lang/Object.h
deleted file mode 100644
index 2ed6d155a2e..00000000000
--- a/libjava/java/lang/Object.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Object.h - Header file for java.lang.Object. -*- c++ -*-
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-#ifndef __JAVA_LANG_OBJECT_H__
-#define __JAVA_LANG_OBJECT_H__
-
-#pragma interface
-
-#include <gcj/javaprims.h>
-
-// This class is mainly here as a kludge to get G++ to allocate
-// vtable pointer as the *first* word of each Object, instead of
-// the second word (following sync_info). Note that various pieces of
-// code know that finalize() is the first method. For instance,
-// Object.java knows this, as does _Jv_AllocObject.
-
-struct _JvObjectPrefix
-{
-protected:
- // This is disguised as the C++ vtbl.
- // _Jv_VTable* vtable;
-
- virtual void finalize () = 0;
-};
-
-class java::lang::Object : public _JvObjectPrefix
-{
-public:
- // Order must match order in Object.java.
- jclass getClass (void);
- virtual jint hashCode (void);
- void notify (void);
- void notifyAll (void);
- void wait (jlong timeout, jint nanos);
- virtual jboolean equals (jobject obj);
- Object (void);
- virtual jstring toString (void);
- void wait (void);
- void wait (jlong timeout);
-
- friend jint _Jv_MonitorEnter (jobject obj);
- friend jint _Jv_MonitorExit (jobject obj);
- friend void _Jv_InitializeSyncMutex (void);
- friend void _Jv_FinalizeObject (jobject obj);
-
-#ifdef JV_MARKOBJ_DECL
- friend JV_MARKOBJ_DECL;
-#endif
-#ifdef JV_MARKARRAY_DECL
- friend JV_MARKARRAY_DECL;
-#endif
-
-protected:
- virtual jobject clone (void);
- virtual void finalize (void);
-
-private:
- // This does not actually refer to a Java object. Instead it is a
- // placeholder for a piece of internal data (the synchronization
- // information).
- jobject sync_info;
-
- // Initialize the sync_info field.
- void sync_init (void);
-};
-
-#endif /* __JAVA_LANG_OBJECT_H__ */
diff --git a/libjava/java/lang/Object.java b/libjava/java/lang/Object.java
deleted file mode 100644
index c644f7c3c87..00000000000
--- a/libjava/java/lang/Object.java
+++ /dev/null
@@ -1,71 +0,0 @@
-// Object.java - The root of all evil.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date September 30, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * plus gcj compiler sources (to determine object layout)
- * Status: Complete to version 1.1
- */
-
-public class Object
-{
- // This must come first. See _JvObjectPrefix in Object.h.
- protected void finalize () throws Throwable
- {
- }
-
- public final native Class getClass ();
- public native int hashCode ();
- public final native void notify ();
- public final native void notifyAll ();
- public final native void wait (long timeout, int nanos)
- throws InterruptedException;
-
- public boolean equals (Object obj)
- {
- return this == obj;
- }
-
- public Object ()
- {
- }
-
- public String toString ()
- {
- return getClass().getName() + '@' + Integer.toHexString(hashCode());
- }
-
- public final void wait () throws InterruptedException
- {
- wait (0, 0);
- }
-
- public final void wait (long timeout) throws InterruptedException
- {
- wait (timeout, 0);
- }
-
- protected native Object clone () throws CloneNotSupportedException;
-
- // This initializes the sync_info member. It is here for
- // completeness (some day we'll be able to auto-generate Object.h).
- private final native void sync_init ();
-
- // Note that we don't mention the sync_info field here. If we do,
- // jc1 will not work correctly.
-}
diff --git a/libjava/java/lang/OutOfMemoryError.java b/libjava/java/lang/OutOfMemoryError.java
deleted file mode 100644
index 81ab753872d..00000000000
--- a/libjava/java/lang/OutOfMemoryError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// OutOfMemoryError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class OutOfMemoryError extends VirtualMachineError
-{
- public OutOfMemoryError ()
- {
- super ();
- }
-
- public OutOfMemoryError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/PosixProcess.java b/libjava/java/lang/PosixProcess.java
deleted file mode 100644
index 36182598b3b..00000000000
--- a/libjava/java/lang/PosixProcess.java
+++ /dev/null
@@ -1,74 +0,0 @@
-// PosixProcess.java - Subclass of Process for POSIX systems.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date May 3, 1999
- */
-
-// This is entirely internal to our implementation.
-
-// This file is copied to `ConcreteProcess.java' before compilation.
-// Hence the class name apparently does not match the file name.
-final class ConcreteProcess extends Process
-{
- public native void destroy ();
- public native int exitValue ();
-
- public InputStream getErrorStream ()
- {
- return errorStream;
- }
-
- public InputStream getInputStream ()
- {
- return inputStream;
- }
-
- public OutputStream getOutputStream ()
- {
- return outputStream;
- }
-
- public native int waitFor () throws InterruptedException;
-
- // This is used for actual initialization, as we can't write a
- // native constructor.
- public native void startProcess (String[] progarray, String[] envp)
- throws IOException;
-
- // This file is copied to `ConcreteProcess.java' before
- // compilation. Hence the constructor name apparently does not
- // match the file name.
- public ConcreteProcess (String[] progarray, String[] envp) throws IOException
- {
- startProcess (progarray, envp);
- }
-
- // The process id. This is cast to a pid_t on the native side.
- private long pid;
-
- // True when child has exited.
- private boolean hasExited;
-
- // The exit status, if the child has exited.
- private int status;
-
- // The streams.
- private InputStream errorStream;
- private InputStream inputStream;
- private OutputStream outputStream;
-}
diff --git a/libjava/java/lang/Process.java b/libjava/java/lang/Process.java
deleted file mode 100644
index 077efe53771..00000000000
--- a/libjava/java/lang/Process.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Process.java - Represent spawned system process.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-import java.io.*;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 23, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- */
-
-public abstract class Process
-{
- abstract public void destroy ();
- abstract public int exitValue ();
- abstract public InputStream getErrorStream ();
- abstract public InputStream getInputStream ();
- abstract public OutputStream getOutputStream ();
- abstract public int waitFor () throws InterruptedException;
-}
diff --git a/libjava/java/lang/Runnable.java b/libjava/java/lang/Runnable.java
deleted file mode 100644
index a5eed31ebae..00000000000
--- a/libjava/java/lang/Runnable.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Runnable.java - Runnable interface.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date August 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Complete.
- */
-
-public interface Runnable
-{
- public abstract void run ();
-}
diff --git a/libjava/java/lang/Runtime.java b/libjava/java/lang/Runtime.java
deleted file mode 100644
index e746c60b384..00000000000
--- a/libjava/java/lang/Runtime.java
+++ /dev/null
@@ -1,143 +0,0 @@
-// Runtime.java - Runtime class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.lang;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.StringTokenizer;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date August 27, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: All 1.1 methods exist. exec() is not fully implemented.
- */
-
-public class Runtime
-{
- public Process exec (String prog) throws IOException
- {
- return exec (prog, null);
- }
-
- public Process exec (String prog, String[] envp) throws IOException
- {
- StringTokenizer st = new StringTokenizer(prog);
- String[] a = new String[st.countTokens ()];
- for (int i = 0; i < a.length; i++)
- a[i] = st.nextToken ();
- return exec (a, envp);
- }
-
- public Process exec (String[] progarray) throws IOException
- {
- return exec (progarray, null);
- }
-
- public Process exec (String[] progarray, String[] envp) throws IOException
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkExec(progarray[0]);
- return new ConcreteProcess (progarray, envp);
- }
-
- private final static void checkExit (int status)
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkExit(status);
- }
-
- public native void exit (int status);
-
- public native long freeMemory ();
- public native void gc ();
-
- // Deprecated in 1.1. We implement what the JCL book says.
- public InputStream getLocalizedInputStream (InputStream in)
- {
- return in;
- }
-
- // Deprecated in 1.1. We implement what the JCL book says.
- public OutputStream getLocalizedOutputStream (OutputStream out)
- {
- return out;
- }
-
- public static Runtime getRuntime ()
- {
- return self;
- }
-
- private final void checkLink (String lib)
- {
- if (lib == null)
- throw new NullPointerException ();
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkLink(lib);
- }
-
- private native void _load (String pathname, boolean do_search);
-
- public void load (String pathname)
- {
- _load (pathname, false);
- }
-
- public void loadLibrary (String libname)
- {
- _load (libname, true);
- }
-
- // This is a helper function for the ClassLoader which can load
- // compiled libraries. Returns true if library (which is just the
- // base name -- path searching is done by this function) was loaded,
- // false otherwise.
- native boolean loadLibraryInternal (String libname);
-
- public native void runFinalization ();
-
- // This method is static in JDK 1.1, but isn't listed as static in
- // the books. It is marked as static in the 1.2 docs.
- public static void runFinalizersOnExit (boolean run)
- {
- // The status we pass to the security check is unspecified.
- checkExit (0);
- self.finalize_on_exit = run;
- }
-
- public native long totalMemory ();
- public native void traceInstructions (boolean on);
- public native void traceMethodCalls (boolean on);
-
- // A helper for the constructor.
- private final native void init ();
-
- // The sole constructor.
- private Runtime ()
- {
- init ();
- }
-
- // Private data.
- private static Runtime self = new Runtime ();
- // FIXME: for now this can't be static. If it is, our compiler will
- // mark it as local, and it will be inaccessible to natRuntime.cc.
- private boolean finalize_on_exit;
-}
diff --git a/libjava/java/lang/RuntimeException.java b/libjava/java/lang/RuntimeException.java
deleted file mode 100644
index 2d71ae63e11..00000000000
--- a/libjava/java/lang/RuntimeException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class RuntimeException extends Exception
-{
- public RuntimeException()
- {
- super();
- }
-
- public RuntimeException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/SecurityException.java b/libjava/java/lang/SecurityException.java
deleted file mode 100644
index d481e2908c1..00000000000
--- a/libjava/java/lang/SecurityException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998. */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class SecurityException extends RuntimeException
-{
- public SecurityException()
- {
- super();
- }
-
- public SecurityException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/SecurityManager.java b/libjava/java/lang/SecurityManager.java
deleted file mode 100644
index 4f1d152e556..00000000000
--- a/libjava/java/lang/SecurityManager.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-// SecurityManager
-
-package java.lang;
-
-/**
- * @author Anthony Green <green@cygnus.com>
- * @date October 5, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- */
-
-import java.io.*;
-import java.net.*;
-
-public abstract class SecurityManager
-{
- protected boolean inCheck = false;
-
- public void checkAccept (String host, int port)
- {
- throw new SecurityException();
- }
-
- public void checkAccess (Thread thrd)
- {
- throw new SecurityException();
- }
-
- public void checkAccess (ThreadGroup thrdGroup)
- {
- throw new SecurityException();
- }
-
- public void checkAwtEventQueueAccess ()
- {
- throw new SecurityException();
- }
-
- public void checkConnect (String host, int prt)
- {
- throw new SecurityException();
- }
-
- public void checkConnect (String host, int prt, Object ctx)
- {
- throw new SecurityException();
- }
-
- public void checkCreateClassLoader ()
- {
- throw new SecurityException();
- }
-
- public void checkDelete (String fileName)
- {
- throw new SecurityException();
- }
-
- public void checkExec (String prog)
- {
- throw new SecurityException();
- }
-
- public void checkExit (int stat)
- {
- throw new SecurityException();
- }
-
- public void checkLink (String lib)
- {
- throw new SecurityException();
- }
-
- public void checkListen (int lport)
- {
- throw new SecurityException();
- }
-
- public void checkMemberAccess (Class cl, int mtype)
- {
- throw new SecurityException();
- }
-
- public void checkMulticast (InetAddress maddr)
- {
- throw new SecurityException();
- }
-
- public void checkMulticast (InetAddress maddr, byte ttl)
- {
- throw new SecurityException();
- }
-
- public void checkPackageAccess (String pkg)
- {
- throw new SecurityException();
- }
-
- public void checkPackageDefinition (String pkg)
- {
- throw new SecurityException();
- }
-
- public void checkPrintJobAccess ()
- {
- throw new SecurityException();
- }
-
- public void checkPropertiesAccess ()
- {
- throw new SecurityException();
- }
-
- public void checkPropertyAccess (String prop)
- {
- throw new SecurityException();
- }
-
- public void checkPropertyAccess (String prop, String defval)
- {
- throw new SecurityException();
- }
-
- public void checkRead (FileDescriptor fd)
- {
- throw new SecurityException();
- }
-
- public void checkRead (String fileName)
- {
- throw new SecurityException();
- }
-
- public void checkRead (String fileName, Object ctx)
- {
- throw new SecurityException();
- }
-
- public void checkSecurityAccess (String action)
- {
- throw new SecurityException();
- }
-
- public void checkSetFactory ()
- {
- throw new SecurityException();
- }
-
- public void checkSystemClipboardAccess ()
- {
- throw new SecurityException();
- }
-
- public boolean checkTopLevelWindow (Object window)
- {
- throw new SecurityException();
- }
-
- public void checkWrite (FileDescriptor fd)
- {
- throw new SecurityException();
- }
-
- public void checkWrite (String fileName)
- {
- throw new SecurityException();
- }
-
- // Note: this method is deprecated in JDK 1.2
- protected /* native */ int classDepth (String className)
- {
- Class[] classStack = getClassContext ();
- for (int i = 0; i < classStack.length; i++)
- if (classStack[i].getName().compareTo(className) == 0)
- return i;
-
- return -1;
- }
-
- // Note: this method is deprecated in JDK 1.2
- protected /* native */ int classLoaderDepth ()
- {
- Class[] classStack = getClassContext ();
- for (int i = 0; i < classStack.length; i++)
- if (classStack[i].getClassLoader() != null)
- return i;
-
- return -1;
- }
-
- protected /* native */ ClassLoader currentClassLoader ()
- {
- Class[] classStack = getClassContext ();
- for (int i = 0; i < classStack.length; i++)
- {
- ClassLoader loader = classStack[i].getClassLoader();
- if (loader != null)
- return loader;
- }
-
- return null;
- }
-
- protected /* native */ Class currentLoadedClass ()
- {
- Class[] classStack = getClassContext ();
- for (int i = 0; i < classStack.length; i++)
- {
- ClassLoader loader = classStack[i].getClassLoader();
- if (loader != null)
- return classStack[i];
- }
-
- return null;
- }
-
- protected /* native */ Class[] getClassContext ()
- {
- return new Class[0];
- }
-
- // Note: this method is deprecated in JDK 1.2
- public boolean getInCheck ()
- {
- return inCheck;
- }
-
- public Object getSecurityContext ()
- {
- // FIXME: This has yet to be implemented.
- return new String("");
- }
-
- public ThreadGroup getThreadGroup ()
- {
- return Thread.currentThread().getThreadGroup();
- }
-
- protected boolean inClass (String className)
- {
- return (classDepth (className) != -1);
- }
-
- protected boolean inClassLoader ()
- {
- return (classLoaderDepth () != -1);
- }
-
- protected SecurityManager ()
- {
- if (System.getSecurityManager () != null)
- throw new SecurityException ();
- }
-}
diff --git a/libjava/java/lang/Short.java b/libjava/java/lang/Short.java
deleted file mode 100644
index a8bd9658284..00000000000
--- a/libjava/java/lang/Short.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 17, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- * Includes JDK 1.2 methods.
- */
-
-public final class Short extends Number implements Comparable
-{
- short value;
-
- public final static short MIN_VALUE = -32768;
- public final static short MAX_VALUE = 32767;
-
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public static final Class TYPE = short.class;
-
- public Short(short value)
- {
- this.value = value;
- }
-
- public Short(String str)
- throws NumberFormatException
- {
- this.value = parseShort(str, 10);
- }
-
- public byte byteValue()
- {
- return (byte) value;
- }
-
- public short shortValue()
- {
- return value;
- }
-
- public int intValue()
- {
- return value;
- }
-
- public long longValue ()
- {
- return value;
- }
-
- public float floatValue ()
- {
- return (float) value;
- }
-
- public double doubleValue ()
- {
- return (double) value;
- }
-
- public static Short decode(String str)
- throws NumberFormatException
- {
- int i = (Integer.decode(str)).intValue();
- if (i < MIN_VALUE || i > MAX_VALUE)
- throw new NumberFormatException();
- return new Short((short) i);
- }
-
- public static short parseShort(String str, int radix)
- throws NumberFormatException
- {
- int i = Integer.parseInt(str, radix);
- if (i < MIN_VALUE || i > MAX_VALUE)
- throw new NumberFormatException();
- return (short) i;
- }
-
- public static short parseShort(String str)
- throws NumberFormatException
- {
- return parseShort(str, 10);
- }
-
- public static Short valueOf(String str, int radix)
- throws NumberFormatException
- {
- return new Short(parseShort(str, radix));
- }
-
- public static Short valueOf(String str)
- throws NumberFormatException
- {
- return valueOf(str, 10);
- }
-
- // Added in JDK 1.2
- public int compareTo(Short anotherShort)
- {
- return this.value - anotherShort.value;
- }
-
- // Added in JDK 1.2
- public int compareTo(Object o) throws ClassCastException
- {
- if (o instanceof Short)
- return this.value - ((Short) o).value;
- else
- throw new ClassCastException();
- }
-
- public boolean equals(Object obj)
- {
- return (obj != null && (obj instanceof Short)
- && ((Short) obj).value == value);
- }
-
- // Verified that hashCode is returns plain value (see Short_1 test).
- public int hashCode()
- {
- return value;
- }
-
- public String toString()
- {
- return Integer.toString((int) value);
- }
-
- public static String toString(short value)
- {
- return Integer.toString((int) value);
- }
-}
diff --git a/libjava/java/lang/StackOverflowError.java b/libjava/java/lang/StackOverflowError.java
deleted file mode 100644
index f4987c18a20..00000000000
--- a/libjava/java/lang/StackOverflowError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// StackOverflowError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class StackOverflowError extends VirtualMachineError
-{
- public StackOverflowError ()
- {
- super ();
- }
-
- public StackOverflowError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/String.java b/libjava/java/lang/String.java
deleted file mode 100644
index 86388a61bfc..00000000000
--- a/libjava/java/lang/String.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-import java.io.UnsupportedEncodingException;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date September 4, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Complete to 1.1, but see FIXMEs. Also see testsuite results.
- */
-
-public final class String
-{
- private Object data;
- private int boffset; // Note this is a byte offset - don't use in Java code!
- private int count;
-
- public String ()
- {
- init();
- }
-
- public String (String value)
- {
- data = value.data;
- boffset = value.boffset;
- count = value.count;
- }
-
- public String (StringBuffer buffer)
- {
- init (buffer.value, 0, buffer.count, true);
- }
-
- public String (char[] data)
- {
- init(data, 0, data.length, false);
- }
-
- public String (char[] data, int offset, int count)
- {
- init(data, offset, count, false);
- }
-
- public String (byte[] byteArray)
- {
- this (byteArray, 0, byteArray.length);
- }
-
- public String (byte[] byteArray, int offset, int count)
- {
- try
- {
- init (byteArray, offset, count,
- System.getProperty("file.encoding", "8859_1"));
- }
- catch (UnsupportedEncodingException x1)
- {
- // Maybe the default encoding is bad.
- try
- {
- init (byteArray, offset, count, "8859_1");
- }
- catch (UnsupportedEncodingException x2)
- {
- // We know this can't happen.
- }
- }
- }
-
- public String (byte[] byteArray, String enc)
- throws UnsupportedEncodingException
- {
- this (byteArray, 0, byteArray.length, enc);
- }
-
- public String (byte[] byteArray, int offset, int count, String enc)
- throws UnsupportedEncodingException
- {
- init (byteArray, offset, count, enc);
- }
-
- public static String copyValueOf(char[] data)
- {
- return copyValueOf (data, 0, data.length);
- }
-
- public static String copyValueOf(char[] data, int offset, int count)
- {
- String r = new String ();
- r.init(data, offset, count, false);
- return r;
- }
-
- /** @deprecated */
- public String (byte[] ascii, int hibyte)
- {
- init(ascii, hibyte, 0, ascii.length);
- }
-
- /** @deprecated */
- public String (byte[] ascii, int hibyte, int offset, int count)
- {
- init(ascii, hibyte, offset, count);
- }
-
- public String toString ()
- {
- // because String is final, we actually get this far on a null reference
- if (this == null)
- throw new NullPointerException();
- return this;
- }
-
- public native boolean equals (Object anObject);
-
- public native int hashCode ();
-
- public int length ()
- {
- return count;
- }
-
- public native char charAt (int index);
-
- public native void getChars (int srcBegin, int srcEnd,
- char[] dst, int dstBegin);
-
- public byte[] getBytes ()
- {
- try
- {
- return getBytes (System.getProperty("file.encoding", "8859_1"));
- }
- catch (UnsupportedEncodingException x)
- {
- // This probably shouldn't happen, but could if file.encoding
- // is somehow changed to a value we don't understand.
- try
- {
- return getBytes ("8859_1");
- }
- catch (UnsupportedEncodingException x2)
- {
- // This really shouldn't happen, because the 8859_1
- // encoding should always be available.
- throw new InternalError ("couldn't find 8859_1 encoder");
- }
- }
- }
-
- public native byte[] getBytes (String enc)
- throws UnsupportedEncodingException;
-
- /** @deprecated */
- public native void getBytes (int srcBegin, int srcEnd,
- byte[] dst, int dstBegin);
-
- public native char[] toCharArray ();
-
- public native boolean equalsIgnoreCase (String anotherString);
-
- public native int compareTo (String anotherString);
-
- public native boolean regionMatches (int toffset,
- String other, int ooffset, int len);
-
- public native boolean regionMatches (boolean ignoreCase, int toffset,
- String other, int ooffset, int len);
-
- public boolean startsWith (String prefix)
- {
- return startsWith (prefix, 0);
- }
-
- public native boolean startsWith (String prefix, int toffset);
-
- public boolean endsWith (String suffix)
- {
- return regionMatches (this.count - suffix.count, suffix, 0, suffix.count);
- }
-
- // No such method specified in the doc, including JDK 1.2.
- // public boolean endsWith (String suffix, int toffset)
- // {
- // return regionMatches (toffset, suffix, 0, suffix.count);
- // }
-
- // The Language Specification, and the JDK 1.2 API docs say that
- // index and lastIndex take an int, while the Class Libraries
- // say they take a char. The former wins ...
-
- public int indexOf (int ch)
- {
- return indexOf (ch, 0);
- }
-
- public native int indexOf (int ch, int fromIndex);
-
- public int indexOf (String str)
- {
- return indexOf (str, 0);
- }
-
- public native int indexOf (String str, int fromIndex);
-
- public int lastIndexOf (int ch)
- {
- return lastIndexOf (ch, count - 1);
- }
-
- public native int lastIndexOf (int ch, int fromIndex);
-
- public int lastIndexOf (String str)
- {
- return lastIndexOf (str, count - str.count);
- }
-
- public int lastIndexOf (String str, int fromIndex)
- {
- if (fromIndex >= count)
- fromIndex = count - str.count;
- for (;; --fromIndex)
- {
- if (fromIndex < 0)
- return -1;
- if (startsWith(str, fromIndex))
- return fromIndex;
- }
- }
-
- public String substring (int beginIndex)
- {
- return substring (beginIndex, count);
- }
-
- public native String substring (int beginIndex, int endIndex);
-
- public native String concat (String str);
-
- public native String replace (char oldChar, char newChar);
-
- public native String toLowerCase ();
-
- public native String toUpperCase ();
-
- public native String trim ();
-
- public static String valueOf (Object obj)
- {
- return obj == null ? "null" : obj.toString();
- }
-
- public static String valueOf (char[] data)
- {
- return valueOf (data, 0, data.length);
- }
-
- public static native String valueOf (char[] data, int offset, int count);
-
- public static String valueOf (boolean b)
- {
- return b ? "true" : "false";
- }
-
- public static native String valueOf (char c);
-
- public static String valueOf (int i)
- {
- return Integer.toString(i);
- }
-
- public static String valueOf (long l)
- {
- return Long.toString(l);
- }
-
- public static String valueOf (float f)
- {
- return Float.toString(f);
- }
-
- public static String valueOf (double d)
- {
- return Double.toString(d);
- }
-
- public native String intern ();
-
- private native void init ();
- private native void init (char[] chars, int offset, int count,
- boolean dont_copy);
- private native void init (byte[] chars, int hibyte, int offset, int count);
- private native void init (byte[] chars, int offset, int count, String enc)
- throws UnsupportedEncodingException;
- private native void unintern ();
- private static native void rehash ();
-}
diff --git a/libjava/java/lang/StringBuffer.java b/libjava/java/lang/StringBuffer.java
deleted file mode 100644
index 7f6e42ec9c9..00000000000
--- a/libjava/java/lang/StringBuffer.java
+++ /dev/null
@@ -1,273 +0,0 @@
-// StringBuffer.java - Growable strings.
-
-/* Copyright (C) 1998, 1999, 2000 Red Hat
-
- 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 java.lang;
-import java.io.Serializable;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 23, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- */
-
-public final class StringBuffer implements Serializable
-{
- public StringBuffer append (boolean bool)
- {
- return append (String.valueOf(bool));
- }
-
- public synchronized StringBuffer append (char ch)
- {
- ensureCapacity (count + 1);
- value[count++] = ch;
- return this;
- }
-
- public StringBuffer append (int inum)
- {
- return append (String.valueOf(inum));
- }
-
- public StringBuffer append (long lnum)
- {
- return append (String.valueOf(lnum));
- }
-
- public StringBuffer append (float fnum)
- {
- return append (String.valueOf(fnum));
- }
-
- public StringBuffer append (double dnum)
- {
- return append (String.valueOf(dnum));
- }
-
- public StringBuffer append (Object obj)
- {
- return append (String.valueOf(obj));
- }
-
- public synchronized StringBuffer append (String str)
- {
- if (str == null)
- str = "null";
- int len = str.length();
- ensureCapacity (count + len);
- str.getChars(0, len, value, count);
- count += len;
- return this;
- }
-
- public StringBuffer append (char[] data)
- {
- return append (data, 0, data.length);
- }
-
- public synchronized StringBuffer append (char[] data, int offset, int count)
- {
- ensureCapacity (this.count + count);
- System.arraycopy(data, offset, value, this.count, count);
- this.count += count;
- return this;
- }
-
- public int capacity ()
- {
- return value.length;
- }
-
- public synchronized char charAt (int index)
- {
- if (index >= count)
- throw new StringIndexOutOfBoundsException (index);
- return value[index];
- }
-
- public synchronized void ensureCapacity (int minimumCapacity)
- {
- if (shared || minimumCapacity > value.length)
- {
- // We don't want to make a larger vector when `shared' is
- // set. If we do, then setLength becomes very inefficient
- // when repeatedly reusing a StringBuffer in a loop.
- int max = (minimumCapacity > value.length
- ? value.length*2+2
- : value.length);
- minimumCapacity = Math.max(minimumCapacity, max);
- char[] nb = new char[minimumCapacity];
- System.arraycopy(value, 0, nb, 0, count);
- value = nb;
- shared = false;
- }
- }
-
- public synchronized void getChars (int srcOffset, int srcEnd,
- char[] dst, int dstOffset)
- {
- if (srcOffset < 0 || srcOffset > srcEnd)
- throw new StringIndexOutOfBoundsException (srcOffset);
- int todo = srcEnd - srcOffset;
- if (srcEnd > count || dstOffset + todo > count)
- throw new StringIndexOutOfBoundsException (srcEnd);
- System.arraycopy(value, srcOffset, dst, dstOffset, todo);
- }
-
- public StringBuffer insert (int offset, boolean bool)
- {
- return insert (offset, bool ? "true" : "false");
- }
-
- public synchronized StringBuffer insert (int offset, char ch)
- {
- if (offset < 0 || offset > count)
- throw new StringIndexOutOfBoundsException (offset);
- ensureCapacity (count+1);
- System.arraycopy(value, offset, value, offset+1, count-offset);
- value[offset] = ch;
- count++;
- return this;
- }
-
- public StringBuffer insert (int offset, int inum)
- {
- return insert (offset, String.valueOf(inum));
- }
-
- public StringBuffer insert (int offset, long lnum)
- {
- return insert (offset, String.valueOf(lnum));
- }
-
- public StringBuffer insert (int offset, float fnum)
- {
- return insert (offset, String.valueOf(fnum));
- }
-
- public StringBuffer insert (int offset, double dnum)
- {
- return insert (offset, String.valueOf(dnum));
- }
-
- public StringBuffer insert (int offset, Object obj)
- {
- return insert (offset, String.valueOf(obj));
- }
-
- public synchronized StringBuffer insert (int offset, String str)
- {
- if (offset < 0 || offset > count)
- throw new StringIndexOutOfBoundsException (offset);
- // Note that using `null' is from JDK 1.2.
- if (str == null)
- str = "null";
- int len = str.length();
- ensureCapacity(count+len);
- System.arraycopy(value, offset, value, offset+len, count-offset);
- str.getChars(0, len, value, offset);
- count += len;
- return this;
- }
-
- public synchronized StringBuffer insert (int offset, char[] data)
- {
- if (offset < 0 || offset > count)
- throw new StringIndexOutOfBoundsException (offset);
- int len = data.length;
- ensureCapacity (count+len);
- System.arraycopy(value, offset, value, offset+len, count-offset);
- System.arraycopy(data, 0, value, offset, len);
- count += len;
- return this;
- }
-
- public int length ()
- {
- return count;
- }
-
- public synchronized StringBuffer reverse ()
- {
- for (int i = 0; i < count / 2; ++i)
- {
- char c = value[i];
- value[i] = value[count - i - 1];
- value[count - i - 1] = c;
- }
- return this;
- }
-
- public synchronized void setCharAt (int index, char ch)
- {
- if (index < 0 || index >= count)
- throw new StringIndexOutOfBoundsException (index);
- // Call ensureCapacity to enforce copy-on-write.
- ensureCapacity (count);
- value[index] = ch;
- }
-
- public synchronized void setLength (int newLength)
- {
- if (newLength < 0)
- throw new StringIndexOutOfBoundsException (newLength);
-
- ensureCapacity (newLength);
- for (int i = count; i < newLength; ++i)
- value[i] = '\0';
- count = newLength;
- }
-
- public StringBuffer ()
- {
- this (16);
- }
-
- public StringBuffer (int capacity)
- {
- count = 0;
- value = new char[capacity];
- shared = false;
- }
-
- public StringBuffer (String str)
- {
- // The documentation is not clear, but experimentation with
- // other implementations indicates that StringBuffer(null)
- // should throw a NullPointerException.
- count = str.length();
- // JLS: The initial capacity of the string buffer is 16 plus the
- // length of the argument string.
- value = new char[count + 16];
- str.getChars(0, count, value, 0);
- shared = false;
- }
-
- public String toString ()
- {
- shared = true;
- return new String (this);
- }
-
- // The buffer. Note that this has permissions set this way so that
- // String can get the value.
- char[] value;
-
- // Index of next available character. Note that this has
- // permissions set this way so that String can get the value.
- int count;
-
- // True if we need to copy the buffer before writing to it again.
- // FIXME: JDK 1.2 doesn't specify this. The new buffer-growing
- // semantics make this less useful in that case, too.
- private boolean shared;
-}
diff --git a/libjava/java/lang/StringIndexOutOfBoundsException.java b/libjava/java/lang/StringIndexOutOfBoundsException.java
deleted file mode 100644
index 9c0c60ff758..00000000000
--- a/libjava/java/lang/StringIndexOutOfBoundsException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class StringIndexOutOfBoundsException extends IndexOutOfBoundsException
-{
- public StringIndexOutOfBoundsException()
- {
- super();
- }
-
- public StringIndexOutOfBoundsException(int index)
- {
- this("String index out of range: " + index);
- }
-
- public StringIndexOutOfBoundsException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/System.java b/libjava/java/lang/System.java
deleted file mode 100644
index b94c259195b..00000000000
--- a/libjava/java/lang/System.java
+++ /dev/null
@@ -1,166 +0,0 @@
-// System.java - System-specific info.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilterInputStream;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.util.Properties;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date August 27, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: 1.1. Some 1.2 methods missing. Properties code not fully
- * implemented.
- */
-
-public final class System
-{
- public static native void arraycopy (Object src, int srcOffset,
- Object dst, int dstOffset,
- int count);
-
- public static native long currentTimeMillis ();
-
- public static void exit (int status)
- {
- Runtime.getRuntime().exit(status);
- }
-
- public static void gc ()
- {
- Runtime.getRuntime().gc();
- }
-
- // Marked deprecated in 1.1. We implement what the JCL book says.
- public static String getenv (String name)
- {
- throw new Error ();
- }
-
- private static native void init_properties ();
-
- public static Properties getProperties ()
- {
- if (secman != null)
- secman.checkPropertiesAccess();
- init_properties ();
- return properties;
- }
-
- public static String getProperty (String property)
- {
- if (secman != null)
- secman.checkPropertyAccess(property);
- init_properties ();
- return properties.getProperty(property);
- }
-
- public static String getProperty (String property, String defval)
- {
- if (secman != null)
- secman.checkPropertyAccess(property, defval);
- init_properties ();
- return properties.getProperty(property, defval);
- }
-
- public static SecurityManager getSecurityManager ()
- {
- return secman;
- }
-
- public static native int identityHashCode (Object obj);
-
- public static void load (String pathname)
- {
- Runtime.getRuntime().load(pathname);
- }
-
- public static void loadLibrary (String libname)
- {
- Runtime.getRuntime().loadLibrary(libname);
- }
-
- public static void runFinalization ()
- {
- Runtime.getRuntime().runFinalization();
- }
-
- // Marked as deprecated in 1.2.
- public static void runFinalizersOnExit (boolean run)
- {
- Runtime.getRuntime().runFinalizersOnExit(run);
- }
-
- private static void checkSetIO ()
- {
- // In 1.1, we are supposed to call checkExec, but the argument is
- // not specified. In 1.2, we are supposed to use checkPermission,
- // which doesn't exist in 1.1.
- if (secman != null)
- secman.checkExec("");
- }
-
- public static native void setErr (PrintStream newErr);
- public static native void setIn (InputStream newIn);
- public static native void setOut (PrintStream newOut);
-
- public static void setProperties (Properties props)
- {
- if (secman != null)
- secman.checkPropertiesAccess();
- // We might not have initialized yet.
- prop_init = true;
- properties = props;
- }
-
- // TODO 1.2.
- // public static String setProperty (String key, String value);
-
- // TODO 1.2.
- // public static String mapLibraryName (String libname);
-
- public static void setSecurityManager (SecurityManager s)
- {
- if (secman != null)
- throw new SecurityException ();
- secman = s;
- }
-
- // Public data.
- public static final InputStream in = new BufferedInputStream (new FileInputStream (FileDescriptor.in));
-
- public static final PrintStream out = new PrintStream (new BufferedOutputStream (new FileOutputStream (FileDescriptor.out)), true);
-
- public static final PrintStream err = new PrintStream (new BufferedOutputStream (new FileOutputStream (FileDescriptor.err)), true);
-
- // Don't allow System objects to be made.
- private System ()
- {
- }
-
- // Private data.
- private static SecurityManager secman = null;
- private static Properties properties = null;
- // This boolean is only required for 1.1 and earlier. After 1.1, a
- // null properties should always be re-initialized.
- private static boolean prop_init = false;
-}
diff --git a/libjava/java/lang/Thread.java b/libjava/java/lang/Thread.java
deleted file mode 100644
index a731b0ab252..00000000000
--- a/libjava/java/lang/Thread.java
+++ /dev/null
@@ -1,299 +0,0 @@
-// Thread.java - Thread class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.lang;
-
-import gnu.gcj.RawData;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date August 24, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Complete to version 1.1, with caveats
- * Known problems:
- * No attempt was made to implement suspend/resume
- * (this could be done in some cases)
- * Various methods which assume a VM are likewise unimplemented
- * We do implement stop() even though it is deprecated.
- */
-
-public class Thread implements Runnable
-{
- public final static int MAX_PRIORITY = 10;
- public final static int MIN_PRIORITY = 1;
- public final static int NORM_PRIORITY = 5;
-
- public static int activeCount ()
- {
- return currentThread().getThreadGroup().activeCount();
- }
-
- public void checkAccess ()
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkAccess(this);
- }
-
- public native int countStackFrames ();
- public static native Thread currentThread ();
- public native void destroy ();
-
- public static void dumpStack ()
- {
- (new Exception ("Stack trace")).printStackTrace ();
- }
-
- public static int enumerate (Thread[] threads)
- {
- return currentThread().group.enumerate(threads);
- }
-
- public final String getName ()
- {
- return name;
- }
-
- public final int getPriority ()
- {
- return priority;
- }
-
- public final ThreadGroup getThreadGroup ()
- {
- return group;
- }
-
- public native void interrupt ();
-
- public static boolean interrupted ()
- {
- return currentThread().isInterrupted (true);
- }
-
- // Check the threads interrupted status. Note that this does not clear the
- // thread's interrupted status (per JDK 1.2 online API documentation).
- public boolean isInterrupted ()
- {
- return interrupt_flag;
- }
-
- public final boolean isAlive ()
- {
- return alive_flag;
- }
-
- public final boolean isDaemon ()
- {
- return daemon_flag;
- }
-
- public final void join () throws InterruptedException
- {
- join (0, 0);
- }
-
- public final void join (long timeout) throws InterruptedException
- {
- join (timeout, 0);
- }
-
- public final native void join (long timeout, int nanos)
- throws InterruptedException;
-
- public final native void resume ();
-
- // This method exists only to avoid a warning from the C++ compiler.
- private static final native void run_ (Object obj);
- private final native void finish_ ();
-
- // Check the thread's interrupted status. If clear_flag is true, the
- // thread's interrupted status is also cleared.
- private boolean isInterrupted (boolean clear_flag)
- {
- boolean r = interrupt_flag;
- if (clear_flag && r)
- {
- // Only clear the flag if we saw it as set. Otherwise this could
- // potentially cause us to miss an interrupt in a race condition,
- // because this method is not synchronized.
- interrupt_flag = false;
- }
- return r;
- }
-
- public void run ()
- {
- if (runnable != null)
- runnable.run();
- }
-
- public final void setDaemon (boolean status)
- {
- checkAccess ();
- if (isAlive ())
- throw new IllegalThreadStateException ();
- daemon_flag = status;
- }
-
- // TODO12:
- // public ClassLoader getContextClassLoader()
- // {
- // }
-
- // TODO12:
- // public void setContextClassLoader(ClassLoader cl)
- // {
- // }
-
- public final void setName (String n)
- {
- checkAccess ();
- // The Class Libraries book says ``threadName cannot be null''. I
- // take this to mean NullPointerException.
- if (n == null)
- throw new NullPointerException ();
- name = n;
- }
-
- public final native void setPriority (int newPriority);
-
- public static void sleep (long timeout) throws InterruptedException
- {
- sleep (timeout, 0);
- }
-
- public static native void sleep (long timeout, int nanos)
- throws InterruptedException;
- public synchronized native void start ();
-
- public final void stop ()
- {
- // Argument doesn't matter, because this is no longer
- // supported.
- stop (null);
- }
-
- public final synchronized native void stop (Throwable e);
- public final native void suspend ();
-
- private final native void initialize_native ();
-
- private final synchronized static String gen_name ()
- {
- String n;
- n = "Thread-" + nextThreadNumber;
- ++nextThreadNumber;
- return n;
- }
-
- public Thread (ThreadGroup g, Runnable r, String n)
- {
- // Note that CURRENT can be null when we are creating the very
- // first thread. That's why we check it below.
- Thread current = currentThread ();
-
- if (g != null)
- {
- // If CURRENT is null, then we are creating the first thread.
- // In this case we don't do the security check.
- if (current != null)
- g.checkAccess();
- }
- else
- g = current.getThreadGroup();
-
- // The Class Libraries book says ``threadName cannot be null''. I
- // take this to mean NullPointerException.
- if (n == null)
- throw new NullPointerException ();
-
- name = n;
- group = g;
- g.add(this);
- runnable = r;
-
- data = null;
- interrupt_flag = false;
- alive_flag = false;
- startable_flag = true;
-
- if (current != null)
- {
- daemon_flag = current.isDaemon();
- priority = current.getPriority();
- }
- else
- {
- daemon_flag = false;
- priority = NORM_PRIORITY;
- }
-
- initialize_native ();
- }
-
- public Thread ()
- {
- this (null, null, gen_name ());
- }
-
- public Thread (Runnable r)
- {
- this (null, r, gen_name ());
- }
-
- public Thread (String n)
- {
- this (null, null, n);
- }
-
- public Thread (ThreadGroup g, Runnable r)
- {
- this (g, r, gen_name ());
- }
-
- public Thread (ThreadGroup g, String n)
- {
- this (g, null, n);
- }
-
- public Thread (Runnable r, String n)
- {
- this (null, r, n);
- }
-
- public String toString ()
- {
- return "Thread[" + name + "," + priority + "," +
- (group == null ? "" : group.getName()) + "]";
- }
-
- public static native void yield ();
-
- // Private data.
- private ThreadGroup group;
- private String name;
- private Runnable runnable;
- private int priority;
- private boolean daemon_flag;
- private boolean interrupt_flag;
- private boolean alive_flag;
- private boolean startable_flag;
-
- // Our native data.
- private RawData data;
-
- // Next thread number to assign.
- private static int nextThreadNumber = 0;
-}
diff --git a/libjava/java/lang/ThreadDeath.java b/libjava/java/lang/ThreadDeath.java
deleted file mode 100644
index d02c2fc9d97..00000000000
--- a/libjava/java/lang/ThreadDeath.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// ThreadDeath.java - Special exception registering Thread death.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date August 26, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Complete to version 1.1
- */
-
-public class ThreadDeath extends Error
-{
- public ThreadDeath ()
- {
- super ();
- }
-
- public ThreadDeath (String message)
- {
- super (message);
- }
-}
diff --git a/libjava/java/lang/ThreadGroup.java b/libjava/java/lang/ThreadGroup.java
deleted file mode 100644
index 73aa0449690..00000000000
--- a/libjava/java/lang/ThreadGroup.java
+++ /dev/null
@@ -1,404 +0,0 @@
-// ThreadGroup.java - ThreadGroup class.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date August 25, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Complete for 1.1. Parts from the JDK 1.0 spec only are
- * not implemented. Parts of the 1.2 spec are also not implemented.
- */
-
-public class ThreadGroup
-{
- public int activeCount ()
- {
- int ac = threads.size();
- Enumeration e = groups.elements();
- while (e.hasMoreElements())
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- ac += g.activeCount();
- }
- return ac;
- }
-
- public int activeGroupCount ()
- {
- int ac = groups.size();
- Enumeration e = groups.elements();
- while (e.hasMoreElements())
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- ac += g.activeGroupCount();
- }
- return ac;
- }
-
- // Deprecated in 1.2.
- public boolean allowThreadSuspension (boolean allow)
- {
- // There is no way for a Java program to determine whether this
- // has any effect whatsoever. We don't need it.
- return true;
- }
-
- public final void checkAccess ()
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkAccess(this);
- }
-
- // This is called to remove a ThreadGroup from our internal list.
- private final void remove (ThreadGroup g)
- {
- groups.removeElement(g);
- if (daemon_flag && groups.size() == 0 && threads.size() == 0)
- {
- // We inline destroy to avoid the access check.
- destroyed_flag = true;
- if (parent != null)
- parent.remove(this);
- }
- }
-
- // This is called by the Thread code to remove a Thread from our
- // internal list.
- final void remove (Thread t)
- {
- threads.removeElement(t);
- if (daemon_flag && groups.size() == 0 && threads.size() == 0)
- {
- // We inline destroy to avoid the access check.
- destroyed_flag = true;
- if (parent != null)
- parent.remove(this);
- }
- }
-
- // This is called by the Thread code to add a Thread to our internal
- // list.
- final void add (Thread t)
- {
- if (destroyed_flag)
- throw new IllegalThreadStateException ();
-
- threads.addElement(t);
- }
-
- // This is a helper that is used to implement the destroy method.
- private final boolean canDestroy ()
- {
- if (! threads.isEmpty())
- return false;
- Enumeration e = groups.elements();
- while (e.hasMoreElements())
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- if (! g.canDestroy())
- return false;
- }
- return true;
- }
-
- public final void destroy ()
- {
- checkAccess ();
- if (! canDestroy ())
- throw new IllegalThreadStateException ();
- destroyed_flag = true;
- if (parent != null)
- parent.remove(this);
- }
-
- // This actually implements enumerate.
- private final int enumerate (Thread[] ts, int next_index, boolean recurse)
- {
- Enumeration e = threads.elements();
- while (e.hasMoreElements() && next_index < ts.length)
- ts[next_index++] = (Thread) e.nextElement();
- if (recurse && next_index != ts.length)
- {
- e = groups.elements();
- while (e.hasMoreElements() && next_index < ts.length)
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- next_index = g.enumerate(ts, next_index, true);
- }
- }
- return next_index;
- }
-
- public int enumerate (Thread[] ts)
- {
- return enumerate (ts, 0, true);
- }
-
- public int enumerate (Thread[] ts, boolean recurse)
- {
- return enumerate (ts, 0, recurse);
- }
-
- // This actually implements enumerate.
- private final int enumerate (ThreadGroup[] ts, int next_index,
- boolean recurse)
- {
- Enumeration e = groups.elements();
- while (e.hasMoreElements() && next_index < ts.length)
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- ts[next_index++] = g;
- if (recurse && next_index != ts.length)
- next_index = g.enumerate(ts, next_index, true);
- }
- return next_index;
- }
-
- public int enumerate (ThreadGroup[] gs)
- {
- return enumerate (gs, 0, true);
- }
-
- public int enumerate (ThreadGroup[] gs, boolean recurse)
- {
- return enumerate (gs, 0, recurse);
- }
-
- public final int getMaxPriority ()
- {
- return maxpri;
- }
-
- public final String getName ()
- {
- return name;
- }
-
- public final ThreadGroup getParent ()
- {
- return parent;
- }
-
- // JDK 1.2.
- // public void interrupt ();
-
- public final boolean isDaemon ()
- {
- return daemon_flag;
- }
-
- public synchronized boolean isDestroyed ()
- {
- return destroyed_flag;
- }
-
- private final void list (String indentation)
- {
- System.out.print(indentation);
- System.out.println(toString ());
- String sub = indentation + " ";
- Enumeration e = threads.elements();
- while (e.hasMoreElements())
- {
- Thread t = (Thread) e.nextElement();
- System.out.print(sub);
- System.out.println(t.toString());
- }
- e = groups.elements();
- while (e.hasMoreElements())
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- g.list(sub);
- }
- }
-
- public void list ()
- {
- list ("");
- }
-
- public final boolean parentOf (ThreadGroup g)
- {
- while (g != null)
- {
- if (this == g)
- return true;
- g = g.parent;
- }
- return false;
- }
-
- // Deprecated in 1.2.
- public final void resume ()
- {
- checkAccess ();
- Enumeration e = threads.elements();
- while (e.hasMoreElements())
- {
- Thread t = (Thread) e.nextElement();
- t.resume();
- }
- e = groups.elements();
- while (e.hasMoreElements())
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- g.resume();
- }
- }
-
- public final void setDaemon (boolean daemon)
- {
- checkAccess ();
- daemon_flag = daemon;
- // FIXME: the docs don't say you are supposed to do this. But
- // they don't say you aren't, either.
- if (groups.size() == 0 && threads.size() == 0)
- destroy ();
- }
-
- public final void setMaxPriority (int pri)
- {
- checkAccess ();
-
- // FIXME: JDK 1.2 behaviour is different: if the newMaxPriority
- // argument is < MIN_PRIORITY or > MAX_PRIORITY an
- // IllegalArgumentException should be thrown.
- if (pri >= Thread.MIN_PRIORITY && pri <= maxpri)
- {
- maxpri = pri;
-
- Enumeration e = groups.elements();
- while (e.hasMoreElements())
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- g.setMaxPriority (maxpri);
- }
- }
- }
-
- // Deprecated in 1.2.
- public final void stop ()
- {
- checkAccess ();
- Enumeration e = threads.elements();
- while (e.hasMoreElements())
- {
- Thread t = (Thread) e.nextElement();
- t.stop();
- }
- e = groups.elements();
- while (e.hasMoreElements())
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- g.stop();
- }
- }
-
- // Deprecated in 1.2.
- public final void suspend ()
- {
- checkAccess ();
- Enumeration e = threads.elements();
- while (e.hasMoreElements())
- {
- Thread t = (Thread) e.nextElement();
- t.suspend();
- }
- e = groups.elements();
- while (e.hasMoreElements())
- {
- ThreadGroup g = (ThreadGroup) e.nextElement();
- g.suspend();
- }
- }
-
- // This constructor appears in the Class Libraries book but in
- // neither the Language Spec nor the 1.2 docs.
- public ThreadGroup ()
- {
- this (Thread.currentThread().getThreadGroup(), null);
- }
-
- public ThreadGroup (String n)
- {
- this (Thread.currentThread().getThreadGroup(), n);
- }
-
- public ThreadGroup (ThreadGroup p, String n)
- {
- checkAccess ();
- if (p == null)
- throw new NullPointerException ();
- if (p.destroyed_flag)
- throw new IllegalArgumentException ();
-
- parent = p;
- name = n;
- maxpri = p.maxpri;
- threads = new Vector ();
- groups = new Vector ();
- daemon_flag = p.daemon_flag;
- destroyed_flag = false;
- p.groups.addElement(this);
- }
-
- // This is the constructor that is used when creating the very first
- // ThreadGroup. We have an arbitrary argument here just to
- // differentiate this constructor from the others.
- ThreadGroup (int dummy)
- {
- parent = null;
- name = "main";
- maxpri = Thread.MAX_PRIORITY;
- threads = new Vector ();
- groups = new Vector ();
- daemon_flag = false;
- destroyed_flag = false;
- }
-
- public String toString ()
- {
- // Language Spec and Class Libraries book disagree a bit here. We
- // follow the Spec, but add "ThreadGroup" per the book. We
- // include "java.lang" based on the list() example in the Class
- // Libraries book.
- return "java.lang.ThreadGroup[name=" + name + ",maxpri=" + maxpri + "]";
- }
-
- public void uncaughtException (Thread thread, Throwable e)
- {
- // FIXME: in 1.2, this has different semantics. In particular if
- // this group has a parent, the exception is passed upwards and
- // not processed locally.
- if (! (e instanceof ThreadDeath))
- {
- e.printStackTrace();
- }
- }
-
- // Private data.
- private ThreadGroup parent;
- private String name;
- private int maxpri;
- private Vector threads;
- private Vector groups;
- private boolean daemon_flag;
- private boolean destroyed_flag;
-}
diff --git a/libjava/java/lang/Throwable.java b/libjava/java/lang/Throwable.java
deleted file mode 100644
index 9892dd2cae4..00000000000
--- a/libjava/java/lang/Throwable.java
+++ /dev/null
@@ -1,161 +0,0 @@
-// Throwable.java - Superclass for all exceptions.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.OutputStreamWriter;
-import java.io.OutputStream;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 30, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Sufficient for compiled code, but methods applicable to
- * bytecode not implemented. JDK 1.1.
- */
-
-/* A CPlusPlusDemangler sits on top of a PrintWriter. All input is
- * passed through the "c++filt" program (part of GNU binutils) which
- * demangles internal symbols to their C++ source form.
- *
- * Closing a CPlusPlusDemangler doesn't close the underlying
- * PrintWriter; it does, however close underlying process and flush
- * all its buffers, so it's possible to guarantee that after a
- * CPlusPlusDemangler has been closed no more will ever be written to
- * the underlying PrintWriter.
- *
- * FIXME: This implictly converts data from the input stream, which is
- * a stream of characters, to a stream of bytes. We need a way of
- * handling Unicode characters in demangled identifiers. */
-
-class CPlusPlusDemangler extends OutputStream
-{
- java.io.OutputStream procOut;
- java.io.InputStream procIn;
- java.lang.Process proc;
- PrintWriter p;
-
- /* The number of bytes written to the underlying PrintWriter. This
- provides a crude but fairly portable way to determine whether or
- not the attempt to exec c++filt worked. */
- public int written = 0;
-
- CPlusPlusDemangler (PrintWriter writer) throws IOException
- {
- p = writer;
- proc = Runtime.getRuntime ().exec ("c++filt");
- procOut = proc.getOutputStream ();
- procIn = proc.getInputStream ();
- }
-
- public void write (int b) throws IOException
- {
- procOut.write (b);
- while (procIn.available () != 0)
- {
- int c = procIn.read ();
- if (c == -1)
- break;
- else
- {
- p.write (c);
- written++;
- }
- }
- }
-
- public void close () throws IOException
- {
- procOut.close ();
- int c;
- while ((c = procIn.read ()) != -1)
- {
- p.write (c);
- written++;
- }
- p.flush ();
- }
-}
-
-public class Throwable implements Serializable
-{
- public native Throwable fillInStackTrace ();
-
- public String getLocalizedMessage ()
- {
- return getMessage ();
- }
-
- public String getMessage ()
- {
- return detailMessage;
- }
-
- public void printStackTrace ()
- {
- printStackTrace (System.err);
- }
-
- public void printStackTrace (PrintStream ps)
- {
- PrintWriter writer = new PrintWriter (ps);
- printStackTrace (writer);
- }
-
- public void printStackTrace (PrintWriter wr)
- {
- try
- {
- CPlusPlusDemangler cPlusPlusFilter = new CPlusPlusDemangler (wr);
- PrintWriter writer = new PrintWriter (cPlusPlusFilter);
- printRawStackTrace (writer);
- writer.close ();
- if (cPlusPlusFilter.written == 0) // The demangler has failed...
- printRawStackTrace (wr);
- }
- catch (Exception e1)
- {
- printRawStackTrace (wr);
- }
- }
-
- public Throwable ()
- {
- detailMessage = null;
- fillInStackTrace ();
- }
-
- public Throwable (String message)
- {
- detailMessage = message;
- fillInStackTrace ();
- }
-
- public String toString ()
- {
- return ((detailMessage == null)
- ? getClass().getName()
- : getClass().getName() + ": " + getMessage ());
- }
-
- private native final void printRawStackTrace (PrintWriter wr);
-
- // Name of this field comes from serialization spec.
- private String detailMessage;
-
- private byte stackTrace[];
-}
diff --git a/libjava/java/lang/UnknownError.java b/libjava/java/lang/UnknownError.java
deleted file mode 100644
index a7d1e20881a..00000000000
--- a/libjava/java/lang/UnknownError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// UnknownError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class UnknownError extends VirtualMachineError
-{
- public UnknownError ()
- {
- super ();
- }
-
- public UnknownError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/UnsatisfiedLinkError.java b/libjava/java/lang/UnsatisfiedLinkError.java
deleted file mode 100644
index 07456422c3e..00000000000
--- a/libjava/java/lang/UnsatisfiedLinkError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// UnsatisfiedLinkError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class UnsatisfiedLinkError extends LinkageError
-{
- public UnsatisfiedLinkError ()
- {
- super ();
- }
-
- public UnsatisfiedLinkError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/UnsupportedOperationException.java b/libjava/java/lang/UnsupportedOperationException.java
deleted file mode 100644
index f321fd08ef9..00000000000
--- a/libjava/java/lang/UnsupportedOperationException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class UnsupportedOperationException extends RuntimeException
-{
- public UnsupportedOperationException()
- {
- super();
- }
-
- public UnsupportedOperationException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/lang/VerifyError.java b/libjava/java/lang/VerifyError.java
deleted file mode 100644
index 0e89e6028e5..00000000000
--- a/libjava/java/lang/VerifyError.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// VerifyError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class VerifyError extends LinkageError
-{
- public VerifyError ()
- {
- super ();
- }
-
- public VerifyError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/VirtualMachineError.java b/libjava/java/lang/VirtualMachineError.java
deleted file mode 100644
index 916842c8562..00000000000
--- a/libjava/java/lang/VirtualMachineError.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// VirtualMachineError.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-/* FIXME: We should consider adding some special error message when this
- * exception is thrown, or maybe if it being caught at top-level. Such
- * a message would direct the user to send a bug report to
- * gcj-bugs@cygnus.com, or something like that. --KKT */
-
-public abstract class VirtualMachineError extends Error
-{
- public VirtualMachineError ()
- {
- super ();
- }
-
- public VirtualMachineError (String msg)
- {
- super (msg);
- }
-}
diff --git a/libjava/java/lang/Void.java b/libjava/java/lang/Void.java
deleted file mode 100644
index 7d5bdfc6201..00000000000
--- a/libjava/java/lang/Void.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date April 18, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Complete.
- */
-
-public final class Void
-{
- // This initialization is seemingly circular, but it is accepted
- // by javac, and is handled specially by gcc.
- public final static Class TYPE = void.class;
-
- // Don't allow Void objects to be made.
- private Void ()
- {
- }
-}
diff --git a/libjava/java/lang/dtoa.c b/libjava/java/lang/dtoa.c
deleted file mode 100644
index e0d4aaaa8ee..00000000000
--- a/libjava/java/lang/dtoa.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/****************************************************************
- *
- * The author of this software is David M. Gay.
- *
- * Copyright (c) 1991 by AT&T.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software and in all copies of the supporting
- * documentation for such software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
- * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- ***************************************************************/
-
-/* Please send bug reports to
- David M. Gay
- AT&T Bell Laboratories, Room 2C-463
- 600 Mountain Avenue
- Murray Hill, NJ 07974-2070
- U.S.A.
- dmg@research.att.com or research!dmg
- */
-
-#include "mprec.h"
-
-static int
-_DEFUN (quorem,
- (b, S),
- _Jv_Bigint * b _AND _Jv_Bigint * S)
-{
- int n;
- long borrow, y;
- unsigned long carry, q, ys;
- unsigned long *bx, *bxe, *sx, *sxe;
-#ifdef Pack_32
- long z;
- unsigned long si, zs;
-#endif
-
- n = S->_wds;
-#ifdef DEBUG
- /*debug*/ if (b->_wds > n)
- /*debug*/ Bug ("oversize b in quorem");
-#endif
- if (b->_wds < n)
- return 0;
- sx = S->_x;
- sxe = sx + --n;
- bx = b->_x;
- bxe = bx + n;
- q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
-#ifdef DEBUG
- /*debug*/ if (q > 9)
- /*debug*/ Bug ("oversized quotient in quorem");
-#endif
- if (q)
- {
- borrow = 0;
- carry = 0;
- do
- {
-#ifdef Pack_32
- si = *sx++;
- ys = (si & 0xffff) * q + carry;
- zs = (si >> 16) * q + (ys >> 16);
- carry = zs >> 16;
- y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend (borrow, y);
- z = (*bx >> 16) - (zs & 0xffff) + borrow;
- borrow = z >> 16;
- Sign_Extend (borrow, z);
- Storeinc (bx, z, y);
-#else
- ys = *sx++ * q + carry;
- carry = ys >> 16;
- y = *bx - (ys & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend (borrow, y);
- *bx++ = y & 0xffff;
-#endif
- }
- while (sx <= sxe);
- if (!*bxe)
- {
- bx = b->_x;
- while (--bxe > bx && !*bxe)
- --n;
- b->_wds = n;
- }
- }
- if (cmp (b, S) >= 0)
- {
- q++;
- borrow = 0;
- carry = 0;
- bx = b->_x;
- sx = S->_x;
- do
- {
-#ifdef Pack_32
- si = *sx++;
- ys = (si & 0xffff) + carry;
- zs = (si >> 16) + (ys >> 16);
- carry = zs >> 16;
- y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend (borrow, y);
- z = (*bx >> 16) - (zs & 0xffff) + borrow;
- borrow = z >> 16;
- Sign_Extend (borrow, z);
- Storeinc (bx, z, y);
-#else
- ys = *sx++ + carry;
- carry = ys >> 16;
- y = *bx - (ys & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend (borrow, y);
- *bx++ = y & 0xffff;
-#endif
- }
- while (sx <= sxe);
- bx = b->_x;
- bxe = bx + n;
- if (!*bxe)
- {
- while (--bxe > bx && !*bxe)
- --n;
- b->_wds = n;
- }
- }
- return q;
-}
-
-#ifdef DEBUG
-#include <stdio.h>
-
-void
-print (_Jv_Bigint * b)
-{
- int i, wds;
- unsigned long *x, y;
- wds = b->_wds;
- x = b->_x+wds;
- i = 0;
- do
- {
- x--;
- fprintf (stderr, "%08x", *x);
- }
- while (++i < wds);
- fprintf (stderr, "\n");
-}
-#endif
-
-/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
- *
- * Inspired by "How to Print Floating-Point Numbers Accurately" by
- * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101].
- *
- * Modifications:
- * 1. Rather than iterating, we use a simple numeric overestimate
- * to determine k = floor(log10(d)). We scale relevant
- * quantities using O(log2(k)) rather than O(k) multiplications.
- * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
- * try to generate digits strictly left to right. Instead, we
- * compute with fewer bits and propagate the carry if necessary
- * when rounding the final digit up. This is often faster.
- * 3. Under the assumption that input will be rounded nearest,
- * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
- * That is, we allow equality in stopping tests when the
- * round-nearest rule will give the same floating-point value
- * as would satisfaction of the stopping test with strict
- * inequality.
- * 4. We remove common factors of powers of 2 from relevant
- * quantities.
- * 5. When converting floating-point integers less than 1e16,
- * we use floating-point arithmetic rather than resorting
- * to multiple-precision integers.
- * 6. When asked to produce fewer than 15 digits, we first try
- * to get by with floating-point arithmetic; we resort to
- * multiple-precision integer arithmetic only if we cannot
- * guarantee that the floating-point calculation has given
- * the correctly rounded result. For k requested digits and
- * "uniformly" distributed input, the probability is
- * something like 10^(k-15) that we must resort to the long
- * calculation.
- */
-
-
-char *
-_DEFUN (_dtoa_r,
- (ptr, _d, mode, ndigits, decpt, sign, rve, float_type),
- struct _Jv_reent *ptr _AND
- double _d _AND
- int mode _AND
- int ndigits _AND
- int *decpt _AND
- int *sign _AND
- char **rve _AND
- int float_type)
-{
- /*
- float_type == 0 for double precision, 1 for float.
-
- Arguments ndigits, decpt, sign are similar to those
- of ecvt and fcvt; trailing zeros are suppressed from
- the returned string. If not null, *rve is set to point
- to the end of the return value. If d is +-Infinity or NaN,
- then *decpt is set to 9999.
-
- mode:
- 0 ==> shortest string that yields d when read in
- and rounded to nearest.
- 1 ==> like 0, but with Steele & White stopping rule;
- e.g. with IEEE P754 arithmetic , mode 0 gives
- 1e23 whereas mode 1 gives 9.999999999999999e22.
- 2 ==> max(1,ndigits) significant digits. This gives a
- return value similar to that of ecvt, except
- that trailing zeros are suppressed.
- 3 ==> through ndigits past the decimal point. This
- gives a return value similar to that from fcvt,
- except that trailing zeros are suppressed, and
- ndigits can be negative.
- 4-9 should give the same return values as 2-3, i.e.,
- 4 <= mode <= 9 ==> same return as mode
- 2 + (mode & 1). These modes are mainly for
- debugging; often they run slower but sometimes
- faster than modes 2-3.
- 4,5,8,9 ==> left-to-right digit generation.
- 6-9 ==> don't try fast floating-point estimate
- (if applicable).
-
- > 16 ==> Floating-point arg is treated as single precision.
-
- Values of mode other than 0-9 are treated as mode 0.
-
- Sufficient space is allocated to the return value
- to hold the suppressed trailing zeros.
- */
-
- int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0,
- k_check, leftright, m2, m5, s2, s5, spec_case, try_quick;
- union double_union d, d2, eps;
- long L;
-#ifndef Sudden_Underflow
- int denorm;
- unsigned long x;
-#endif
- _Jv_Bigint *b, *b1, *delta, *mlo, *mhi, *S;
- double ds;
- char *s, *s0;
-
- d.d = _d;
-
- if (ptr->_result)
- {
- ptr->_result->_k = ptr->_result_k;
- ptr->_result->_maxwds = 1 << ptr->_result_k;
- Bfree (ptr, ptr->_result);
- ptr->_result = 0;
- }
-
- if (word0 (d) & Sign_bit)
- {
- /* set sign for everything, including 0's and NaNs */
- *sign = 1;
- word0 (d) &= ~Sign_bit; /* clear sign bit */
- }
- else
- *sign = 0;
-
-#if defined(IEEE_Arith) + defined(VAX)
-#ifdef IEEE_Arith
- if ((word0 (d) & Exp_mask) == Exp_mask)
-#else
- if (word0 (d) == 0x8000)
-#endif
- {
- /* Infinity or NaN */
- *decpt = 9999;
- s =
-#ifdef IEEE_Arith
- !word1 (d) && !(word0 (d) & 0xfffff) ? "Infinity" :
-#endif
- "NaN";
- if (rve)
- *rve =
-#ifdef IEEE_Arith
- s[3] ? s + 8 :
-#endif
- s + 3;
- return s;
- }
-#endif
-#ifdef IBM
- d.d += 0; /* normalize */
-#endif
- if (!d.d)
- {
- *decpt = 1;
- s = "0";
- if (rve)
- *rve = s + 1;
- return s;
- }
-
- b = d2b (ptr, d.d, &be, &bbits);
-#ifdef Sudden_Underflow
- i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1));
-#else
- if ((i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1))))
- {
-#endif
- d2.d = d.d;
- word0 (d2) &= Frac_mask1;
- word0 (d2) |= Exp_11;
-#ifdef IBM
- if (j = 11 - hi0bits (word0 (d2) & Frac_mask))
- d2.d /= 1 << j;
-#endif
-
- /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
- * log10(x) = log(x) / log(10)
- * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
- * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
- *
- * This suggests computing an approximation k to log10(d) by
- *
- * k = (i - Bias)*0.301029995663981
- * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
- *
- * We want k to be too large rather than too small.
- * The error in the first-order Taylor series approximation
- * is in our favor, so we just round up the constant enough
- * to compensate for any error in the multiplication of
- * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
- * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
- * adding 1e-13 to the constant term more than suffices.
- * Hence we adjust the constant term to 0.1760912590558.
- * (We could get a more accurate k by invoking log10,
- * but this is probably not worthwhile.)
- */
-
- i -= Bias;
-#ifdef IBM
- i <<= 2;
- i += j;
-#endif
-#ifndef Sudden_Underflow
- denorm = 0;
- }
- else
- {
- /* d is denormalized */
-
- i = bbits + be + (Bias + (P - 1) - 1);
- x = i > 32 ? word0 (d) << (64 - i) | word1 (d) >> (i - 32)
- : word1 (d) << (32 - i);
- d2.d = x;
- word0 (d2) -= 31 * Exp_msk1; /* adjust exponent */
- i -= (Bias + (P - 1) - 1) + 1;
- denorm = 1;
- }
-#endif
- ds = (d2.d - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981;
- k = (int) ds;
- if (ds < 0. && ds != k)
- k--; /* want k = floor(ds) */
- k_check = 1;
- if (k >= 0 && k <= Ten_pmax)
- {
- if (d.d < tens[k])
- k--;
- k_check = 0;
- }
- j = bbits - i - 1;
- if (j >= 0)
- {
- b2 = 0;
- s2 = j;
- }
- else
- {
- b2 = -j;
- s2 = 0;
- }
- if (k >= 0)
- {
- b5 = 0;
- s5 = k;
- s2 += k;
- }
- else
- {
- b2 -= k;
- b5 = -k;
- s5 = 0;
- }
- if (mode < 0 || mode > 9)
- mode = 0;
- try_quick = 1;
- if (mode > 5)
- {
- mode -= 4;
- try_quick = 0;
- }
- leftright = 1;
- switch (mode)
- {
- case 0:
- case 1:
- ilim = ilim1 = -1;
- i = 18;
- ndigits = 0;
- break;
- case 2:
- leftright = 0;
- /* no break */
- case 4:
- if (ndigits <= 0)
- ndigits = 1;
- ilim = ilim1 = i = ndigits;
- break;
- case 3:
- leftright = 0;
- /* no break */
- case 5:
- i = ndigits + k + 1;
- ilim = i;
- ilim1 = i - 1;
- if (i <= 0)
- i = 1;
- }
- j = sizeof (unsigned long);
- for (ptr->_result_k = 0; (int) (sizeof (_Jv_Bigint) - sizeof (unsigned long)) + j <= i;
- j <<= 1)
- ptr->_result_k++;
- ptr->_result = Balloc (ptr, ptr->_result_k);
- s = s0 = (char *) ptr->_result;
-
- if (ilim >= 0 && ilim <= Quick_max && try_quick)
- {
- /* Try to get by with floating-point arithmetic. */
-
- i = 0;
- d2.d = d.d;
- k0 = k;
- ilim0 = ilim;
- ieps = 2; /* conservative */
- if (k > 0)
- {
- ds = tens[k & 0xf];
- j = k >> 4;
- if (j & Bletch)
- {
- /* prevent overflows */
- j &= Bletch - 1;
- d.d /= bigtens[n_bigtens - 1];
- ieps++;
- }
- for (; j; j >>= 1, i++)
- if (j & 1)
- {
- ieps++;
- ds *= bigtens[i];
- }
- d.d /= ds;
- }
- else if ((j1 = -k))
- {
- d.d *= tens[j1 & 0xf];
- for (j = j1 >> 4; j; j >>= 1, i++)
- if (j & 1)
- {
- ieps++;
- d.d *= bigtens[i];
- }
- }
- if (k_check && d.d < 1. && ilim > 0)
- {
- if (ilim1 <= 0)
- goto fast_failed;
- ilim = ilim1;
- k--;
- d.d *= 10.;
- ieps++;
- }
- eps.d = ieps * d.d + 7.;
- word0 (eps) -= (P - 1) * Exp_msk1;
- if (ilim == 0)
- {
- S = mhi = 0;
- d.d -= 5.;
- if (d.d > eps.d)
- goto one_digit;
- if (d.d < -eps.d)
- goto no_digits;
- goto fast_failed;
- }
-#ifndef No_leftright
- if (leftright)
- {
- /* Use Steele & White method of only
- * generating digits needed.
- */
- eps.d = 0.5 / tens[ilim - 1] - eps.d;
- for (i = 0;;)
- {
- L = d.d;
- d.d -= L;
- *s++ = '0' + (int) L;
- if (d.d < eps.d)
- goto ret1;
- if (1. - d.d < eps.d)
- goto bump_up;
- if (++i >= ilim)
- break;
- eps.d *= 10.;
- d.d *= 10.;
- }
- }
- else
- {
-#endif
- /* Generate ilim digits, then fix them up. */
- eps.d *= tens[ilim - 1];
- for (i = 1;; i++, d.d *= 10.)
- {
- L = d.d;
- d.d -= L;
- *s++ = '0' + (int) L;
- if (i == ilim)
- {
- if (d.d > 0.5 + eps.d)
- goto bump_up;
- else if (d.d < 0.5 - eps.d)
- {
- while (*--s == '0');
- s++;
- goto ret1;
- }
- break;
- }
- }
-#ifndef No_leftright
- }
-#endif
- fast_failed:
- s = s0;
- d.d = d2.d;
- k = k0;
- ilim = ilim0;
- }
-
- /* Do we have a "small" integer? */
-
- if (be >= 0 && k <= Int_max)
- {
- /* Yes. */
- ds = tens[k];
- if (ndigits < 0 && ilim <= 0)
- {
- S = mhi = 0;
- if (ilim < 0 || d.d <= 5 * ds)
- goto no_digits;
- goto one_digit;
- }
- for (i = 1;; i++)
- {
- L = d.d / ds;
- d.d -= L * ds;
-#ifdef Check_FLT_ROUNDS
- /* If FLT_ROUNDS == 2, L will usually be high by 1 */
- if (d.d < 0)
- {
- L--;
- d.d += ds;
- }
-#endif
- *s++ = '0' + (int) L;
- if (i == ilim)
- {
- d.d += d.d;
- if (d.d > ds || (d.d == ds && L & 1))
- {
- bump_up:
- while (*--s == '9')
- if (s == s0)
- {
- k++;
- *s = '0';
- break;
- }
- ++*s++;
- }
- break;
- }
- if (!(d.d *= 10.))
- break;
- }
- goto ret1;
- }
-
- m2 = b2;
- m5 = b5;
- mhi = mlo = 0;
- if (leftright)
- {
- if (mode < 2)
- {
- i =
-#ifndef Sudden_Underflow
- denorm ? be + (Bias + (P - 1) - 1 + 1) :
-#endif
-#ifdef IBM
- 1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3);
-#else
- 1 + P - bbits;
-#endif
- }
- else
- {
- j = ilim - 1;
- if (m5 >= j)
- m5 -= j;
- else
- {
- s5 += j -= m5;
- b5 += j;
- m5 = 0;
- }
- if ((i = ilim) < 0)
- {
- m2 -= i;
- i = 0;
- }
- }
- b2 += i;
- s2 += i;
- mhi = i2b (ptr, 1);
- }
- if (m2 > 0 && s2 > 0)
- {
- i = m2 < s2 ? m2 : s2;
- b2 -= i;
- m2 -= i;
- s2 -= i;
- }
- if (b5 > 0)
- {
- if (leftright)
- {
- if (m5 > 0)
- {
- mhi = pow5mult (ptr, mhi, m5);
- b1 = mult (ptr, mhi, b);
- Bfree (ptr, b);
- b = b1;
- }
- if ((j = b5 - m5))
- b = pow5mult (ptr, b, j);
- }
- else
- b = pow5mult (ptr, b, b5);
- }
- S = i2b (ptr, 1);
- if (s5 > 0)
- S = pow5mult (ptr, S, s5);
-
- /* Check for special case that d is a normalized power of 2. */
-
- if (mode < 2)
- {
- if (!word1 (d) && !(word0 (d) & Bndry_mask)
-#ifndef Sudden_Underflow
- && word0(d) & Exp_mask
-#endif
- )
- {
- /* The special case */
- b2 += Log2P;
- s2 += Log2P;
- spec_case = 1;
- }
- else
- spec_case = 0;
- }
-
- /* Arrange for convenient computation of quotients:
- * shift left if necessary so divisor has 4 leading 0 bits.
- *
- * Perhaps we should just compute leading 28 bits of S once
- * and for all and pass them and a shift to quorem, so it
- * can do shifts and ors to compute the numerator for q.
- */
-
-#ifdef Pack_32
- if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0x1f))
- i = 32 - i;
-#else
- if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0xf))
- i = 16 - i;
-#endif
- if (i > 4)
- {
- i -= 4;
- b2 += i;
- m2 += i;
- s2 += i;
- }
- else if (i < 4)
- {
- i += 28;
- b2 += i;
- m2 += i;
- s2 += i;
- }
- if (b2 > 0)
- b = lshift (ptr, b, b2);
- if (s2 > 0)
- S = lshift (ptr, S, s2);
- if (k_check)
- {
- if (cmp (b, S) < 0)
- {
- k--;
- b = multadd (ptr, b, 10, 0); /* we botched the k estimate */
- if (leftright)
- mhi = multadd (ptr, mhi, 10, 0);
- ilim = ilim1;
- }
- }
- if (ilim <= 0 && mode > 2)
- {
- if (ilim < 0 || cmp (b, S = multadd (ptr, S, 5, 0)) <= 0)
- {
- /* no digits, fcvt style */
- no_digits:
- k = -1 - ndigits;
- goto ret;
- }
- one_digit:
- *s++ = '1';
- k++;
- goto ret;
- }
- if (leftright)
- {
- if (m2 > 0)
- mhi = lshift (ptr, mhi, m2);
-
- /* Single precision case, */
- if (float_type)
- mhi = lshift (ptr, mhi, 29);
-
- /* Compute mlo -- check for special case
- * that d is a normalized power of 2.
- */
-
- mlo = mhi;
- if (spec_case)
- {
- mhi = Balloc (ptr, mhi->_k);
- Bcopy (mhi, mlo);
- mhi = lshift (ptr, mhi, Log2P);
- }
-
- for (i = 1;; i++)
- {
- dig = quorem (b, S) + '0';
- /* Do we yet have the shortest decimal string
- * that will round to d?
- */
- j = cmp (b, mlo);
- delta = diff (ptr, S, mhi);
- j1 = delta->_sign ? 1 : cmp (b, delta);
- Bfree (ptr, delta);
-#ifndef ROUND_BIASED
- if (j1 == 0 && !mode && !(word1 (d) & 1))
- {
- if (dig == '9')
- goto round_9_up;
- if (j > 0)
- dig++;
- *s++ = dig;
- goto ret;
- }
-#endif
- if (j < 0 || (j == 0 && !mode
-#ifndef ROUND_BIASED
- && !(word1 (d) & 1)
-#endif
- ))
- {
- if (j1 > 0)
- {
- b = lshift (ptr, b, 1);
- j1 = cmp (b, S);
- if ((j1 > 0 || (j1 == 0 && dig & 1))
- && dig++ == '9')
- goto round_9_up;
- }
- *s++ = dig;
- goto ret;
- }
- if (j1 > 0)
- {
- if (dig == '9')
- { /* possible if i == 1 */
- round_9_up:
- *s++ = '9';
- goto roundoff;
- }
- *s++ = dig + 1;
- goto ret;
- }
- *s++ = dig;
- if (i == ilim)
- break;
- b = multadd (ptr, b, 10, 0);
- if (mlo == mhi)
- mlo = mhi = multadd (ptr, mhi, 10, 0);
- else
- {
- mlo = multadd (ptr, mlo, 10, 0);
- mhi = multadd (ptr, mhi, 10, 0);
- }
- }
- }
- else
- for (i = 1;; i++)
- {
- *s++ = dig = quorem (b, S) + '0';
- if (i >= ilim)
- break;
- b = multadd (ptr, b, 10, 0);
- }
-
- /* Round off last digit */
-
- b = lshift (ptr, b, 1);
- j = cmp (b, S);
- if (j > 0 || (j == 0 && dig & 1))
- {
- roundoff:
- while (*--s == '9')
- if (s == s0)
- {
- k++;
- *s++ = '1';
- goto ret;
- }
- ++*s++;
- }
- else
- {
- while (*--s == '0');
- s++;
- }
-ret:
- Bfree (ptr, S);
- if (mhi)
- {
- if (mlo && mlo != mhi)
- Bfree (ptr, mlo);
- Bfree (ptr, mhi);
- }
-ret1:
- Bfree (ptr, b);
- *s = 0;
- *decpt = k + 1;
- if (rve)
- *rve = s;
- return s0;
-}
-
-
-_VOID
-_DEFUN (_dtoa,
- (_d, mode, ndigits, decpt, sign, rve, buf, float_type),
- double _d _AND
- int mode _AND
- int ndigits _AND
- int *decpt _AND
- int *sign _AND
- char **rve _AND
- char *buf _AND
- int float_type)
-{
- struct _Jv_reent reent;
- char *p;
- memset (&reent, 0, sizeof reent);
-
- p = _dtoa_r (&reent, _d, mode, ndigits, decpt, sign, rve, float_type);
- strcpy (buf, p);
-
- return;
-}
diff --git a/libjava/java/lang/e_acos.c b/libjava/java/lang/e_acos.c
deleted file mode 100644
index ee6b168a1c5..00000000000
--- a/libjava/java/lang/e_acos.c
+++ /dev/null
@@ -1,111 +0,0 @@
-
-/* @(#)e_acos.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __ieee754_acos(x)
- * Method :
- * acos(x) = pi/2 - asin(x)
- * acos(-x) = pi/2 + asin(x)
- * For |x|<=0.5
- * acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c)
- * For x>0.5
- * acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
- * = 2asin(sqrt((1-x)/2))
- * = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z)
- * = 2f + (2c + 2s*z*R(z))
- * where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
- * for f so that f+c ~ sqrt(z).
- * For x<-0.5
- * acos(x) = pi - 2asin(sqrt((1-|x|)/2))
- * = pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z)
- *
- * Special cases:
- * if x is NaN, return x itself;
- * if |x|>1, return NaN with invalid signal.
- *
- * Function needed: sqrt
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
-pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
-pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
-pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
-pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
-pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
-pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
-pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
-pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
-qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
-qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
-qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
-qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
-
-#ifdef __STDC__
- double __ieee754_acos(double x)
-#else
- double __ieee754_acos(x)
- double x;
-#endif
-{
- double z,p,q,r,w,s,c,df;
- int32_t hx,ix;
- GET_HIGH_WORD(hx,x);
- ix = hx&0x7fffffff;
- if(ix>=0x3ff00000) { /* |x| >= 1 */
- uint32_t lx;
- GET_LOW_WORD(lx,x);
- if(((ix-0x3ff00000)|lx)==0) { /* |x|==1 */
- if(hx>0) return 0.0; /* acos(1) = 0 */
- else return pi+2.0*pio2_lo; /* acos(-1)= pi */
- }
- return (x-x)/(x-x); /* acos(|x|>1) is NaN */
- }
- if(ix<0x3fe00000) { /* |x| < 0.5 */
- if(ix<=0x3c600000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
- z = x*x;
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
- q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- r = p/q;
- return pio2_hi - (x - (pio2_lo-x*r));
- } else if (hx<0) { /* x < -0.5 */
- z = (one+x)*0.5;
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
- q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- s = __ieee754_sqrt(z);
- r = p/q;
- w = r*s-pio2_lo;
- return pi - 2.0*(s+w);
- } else { /* x > 0.5 */
- z = (one-x)*0.5;
- s = __ieee754_sqrt(z);
- df = s;
- SET_LOW_WORD(df,0);
- c = (z-df*df)/(s+df);
- p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
- q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
- r = p/q;
- w = r*s+c;
- return 2.0*(df+w);
- }
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_asin.c b/libjava/java/lang/e_asin.c
deleted file mode 100644
index 6b131e65a26..00000000000
--- a/libjava/java/lang/e_asin.c
+++ /dev/null
@@ -1,120 +0,0 @@
-
-/* @(#)e_asin.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __ieee754_asin(x)
- * Method :
- * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
- * we approximate asin(x) on [0,0.5] by
- * asin(x) = x + x*x^2*R(x^2)
- * where
- * R(x^2) is a rational approximation of (asin(x)-x)/x^3
- * and its remez error is bounded by
- * |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75)
- *
- * For x in [0.5,1]
- * asin(x) = pi/2-2*asin(sqrt((1-x)/2))
- * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2;
- * then for x>0.98
- * asin(x) = pi/2 - 2*(s+s*z*R(z))
- * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo)
- * For x<=0.98, let pio4_hi = pio2_hi/2, then
- * f = hi part of s;
- * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z)
- * and
- * asin(x) = pi/2 - 2*(s+s*z*R(z))
- * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo)
- * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c))
- *
- * Special cases:
- * if x is NaN, return x itself;
- * if |x|>1, return NaN with invalid signal.
- *
- */
-
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-huge = 1.000e+300,
-pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
-pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
-pio4_hi = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */
- /* coefficient for R(x^2) */
-pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
-pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
-pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
-pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
-pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
-pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
-qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
-qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
-qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
-qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
-
-#ifdef __STDC__
- double __ieee754_asin(double x)
-#else
- double __ieee754_asin(x)
- double x;
-#endif
-{
- double t,w,p,q,c,r,s;
- int32_t hx,ix;
- GET_HIGH_WORD(hx,x);
- ix = hx&0x7fffffff;
- if(ix>= 0x3ff00000) { /* |x|>= 1 */
- uint32_t lx;
- GET_LOW_WORD(lx,x);
- if(((ix-0x3ff00000)|lx)==0)
- /* asin(1)=+-pi/2 with inexact */
- return x*pio2_hi+x*pio2_lo;
- return (x-x)/(x-x); /* asin(|x|>1) is NaN */
- } else if (ix<0x3fe00000) { /* |x|<0.5 */
- if(ix<0x3e400000) { /* if |x| < 2**-27 */
- if(huge+x>one) return x;/* return x with inexact if x!=0*/
- } else
- t = x*x;
- p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
- q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
- w = p/q;
- return x+x*w;
- }
- /* 1> |x|>= 0.5 */
- w = one-fabs(x);
- t = w*0.5;
- p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
- q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
- s = __ieee754_sqrt(t);
- if(ix>=0x3FEF3333) { /* if |x| > 0.975 */
- w = p/q;
- t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
- } else {
- w = s;
- SET_LOW_WORD(w,0);
- c = (t-w*w)/(s+w);
- r = p/q;
- p = 2.0*s*r-(pio2_lo-2.0*c);
- q = pio4_hi-2.0*w;
- t = pio4_hi-(p-q);
- }
- if(hx>0) return t; else return -t;
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_atan2.c b/libjava/java/lang/e_atan2.c
deleted file mode 100644
index c75448db26c..00000000000
--- a/libjava/java/lang/e_atan2.c
+++ /dev/null
@@ -1,131 +0,0 @@
-
-/* @(#)e_atan2.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-
-/* __ieee754_atan2(y,x)
- * Method :
- * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
- * 2. Reduce x to positive by (if x and y are unexceptional):
- * ARG (x+iy) = arctan(y/x) ... if x > 0,
- * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
- *
- * Special cases:
- *
- * ATAN2((anything), NaN ) is NaN;
- * ATAN2(NAN , (anything) ) is NaN;
- * ATAN2(+-0, +(anything but NaN)) is +-0 ;
- * ATAN2(+-0, -(anything but NaN)) is +-pi ;
- * ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2;
- * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ;
- * ATAN2(+-(anything but INF and NaN), -INF) is +-pi;
- * ATAN2(+-INF,+INF ) is +-pi/4 ;
- * ATAN2(+-INF,-INF ) is +-3pi/4;
- * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-tiny = 1.0e-300,
-zero = 0.0,
-pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */
-pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
-pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
-pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
-
-#ifdef __STDC__
- double __ieee754_atan2(double y, double x)
-#else
- double __ieee754_atan2(y,x)
- double y,x;
-#endif
-{
- double z;
- int32_t k,m,hx,hy,ix,iy;
- uint32_t lx,ly;
-
- EXTRACT_WORDS(hx,lx,x);
- ix = hx&0x7fffffff;
- EXTRACT_WORDS(hy,ly,y);
- iy = hy&0x7fffffff;
- if(((ix|((lx|-lx)>>31))>0x7ff00000)||
- ((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */
- return x+y;
- if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */
- m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */
-
- /* when y = 0 */
- if((iy|ly)==0) {
- switch(m) {
- case 0:
- case 1: return y; /* atan(+-0,+anything)=+-0 */
- case 2: return pi+tiny;/* atan(+0,-anything) = pi */
- case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
- }
- }
- /* when x = 0 */
- if((ix|lx)==0) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
-
- /* when x is INF */
- if(ix==0x7ff00000) {
- if(iy==0x7ff00000) {
- switch(m) {
- case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */
- case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */
- case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/
- case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/
- }
- } else {
- switch(m) {
- case 0: return zero ; /* atan(+...,+INF) */
- case 1: return -zero ; /* atan(-...,+INF) */
- case 2: return pi+tiny ; /* atan(+...,-INF) */
- case 3: return -pi-tiny ; /* atan(-...,-INF) */
- }
- }
- }
- /* when y is INF */
- if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
-
- /* compute y/x */
- k = (iy-ix)>>20;
- if(k > 60) z=pi_o_2+0.5*pi_lo; /* |y/x| > 2**60 */
- else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */
- else z=atan(fabs(y/x)); /* safe to do y/x */
- switch (m) {
- case 0: return z ; /* atan(+,+) */
- case 1: {
- uint32_t zh;
- GET_HIGH_WORD(zh,z);
- SET_HIGH_WORD(z,zh ^ 0x80000000);
- }
- return z ; /* atan(-,+) */
- case 2: return pi-(z-pi_lo);/* atan(+,-) */
- default: /* case 3 */
- return (z-pi_lo)-pi;/* atan(-,-) */
- }
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_exp.c b/libjava/java/lang/e_exp.c
deleted file mode 100644
index e11ca8b3856..00000000000
--- a/libjava/java/lang/e_exp.c
+++ /dev/null
@@ -1,167 +0,0 @@
-
-/* @(#)e_exp.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __ieee754_exp(x)
- * Returns the exponential of x.
- *
- * Method
- * 1. Argument reduction:
- * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
- * Given x, find r and integer k such that
- *
- * x = k*ln2 + r, |r| <= 0.5*ln2.
- *
- * Here r will be represented as r = hi-lo for better
- * accuracy.
- *
- * 2. Approximation of exp(r) by a special rational function on
- * the interval [0,0.34658]:
- * Write
- * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
- * We use a special Reme algorithm on [0,0.34658] to generate
- * a polynomial of degree 5 to approximate R. The maximum error
- * of this polynomial approximation is bounded by 2**-59. In
- * other words,
- * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
- * (where z=r*r, and the values of P1 to P5 are listed below)
- * and
- * | 5 | -59
- * | 2.0+P1*z+...+P5*z - R(z) | <= 2
- * | |
- * The computation of exp(r) thus becomes
- * 2*r
- * exp(r) = 1 + -------
- * R - r
- * r*R1(r)
- * = 1 + r + ----------- (for better accuracy)
- * 2 - R1(r)
- * where
- * 2 4 10
- * R1(r) = r - (P1*r + P2*r + ... + P5*r ).
- *
- * 3. Scale back to obtain exp(x):
- * From step 1, we have
- * exp(x) = 2^k * exp(r)
- *
- * Special cases:
- * exp(INF) is INF, exp(NaN) is NaN;
- * exp(-INF) is 0, and
- * for finite argument, only exp(0)=1 is exact.
- *
- * Accuracy:
- * according to an error analysis, the error is always less than
- * 1 ulp (unit in the last place).
- *
- * Misc. info.
- * For IEEE double
- * if x > 7.09782712893383973096e+02 then exp(x) overflow
- * if x < -7.45133219101941108420e+02 then exp(x) underflow
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-one = 1.0,
-halF[2] = {0.5,-0.5,},
-huge = 1.0e+300,
-twom1000= 9.33263618503218878990e-302, /* 2**-1000=0x01700000,0*/
-o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
-u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */
-ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
- -6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */
-ln2LO[2] ={ 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */
- -1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */
-invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
-P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
-
-
-#ifdef __STDC__
- double __ieee754_exp(double x) /* default IEEE double exp */
-#else
- double __ieee754_exp(x) /* default IEEE double exp */
- double x;
-#endif
-{
- double y,hi,lo,c,t;
- int32_t k,xsb;
- uint32_t hx;
-
- GET_HIGH_WORD(hx,x);
- xsb = (hx>>31)&1; /* sign bit of x */
- hx &= 0x7fffffff; /* high word of |x| */
-
- /* filter out non-finite argument */
- if(hx >= 0x40862E42) { /* if |x|>=709.78... */
- if(hx>=0x7ff00000) {
- uint32_t lx;
- GET_LOW_WORD(lx,x);
- if(((hx&0xfffff)|lx)!=0)
- return x+x; /* NaN */
- else return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */
- }
- if(x > o_threshold) return huge*huge; /* overflow */
- if(x < u_threshold) return twom1000*twom1000; /* underflow */
- }
-
- /* argument reduction */
- if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
- if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
- hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
- } else {
- k = invln2*x+halF[xsb];
- t = k;
- hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
- lo = t*ln2LO[0];
- }
- x = hi - lo;
- }
- else if(hx < 0x3e300000) { /* when |x|<2**-28 */
- if(huge+x>one) return one+x;/* trigger inexact */
- }
- else k = 0;
-
- /* x is now in primary range */
- t = x*x;
- c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
- if(k==0) return one-((x*c)/(c-2.0)-x);
- else y = one-((lo-(x*c)/(2.0-c))-hi);
- if(k >= -1021) {
- uint32_t hy;
- GET_HIGH_WORD(hy,y);
- SET_HIGH_WORD(y,hy+(k<<20)); /* add k to y's exponent */
- return y;
- } else {
- uint32_t hy;
- GET_HIGH_WORD(hy,y);
- SET_HIGH_WORD(y,hy+((k+1000)<<20)); /* add k to y's exponent */
- return y*twom1000;
- }
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_fmod.c b/libjava/java/lang/e_fmod.c
deleted file mode 100644
index 1cf09907666..00000000000
--- a/libjava/java/lang/e_fmod.c
+++ /dev/null
@@ -1,140 +0,0 @@
-
-/* @(#)e_fmod.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * __ieee754_fmod(x,y)
- * Return x mod y in exact arithmetic
- * Method: shift and subtract
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double one = 1.0, Zero[] = {0.0, -0.0,};
-#else
-static double one = 1.0, Zero[] = {0.0, -0.0,};
-#endif
-
-#ifdef __STDC__
- double __ieee754_fmod(double x, double y)
-#else
- double __ieee754_fmod(x,y)
- double x,y ;
-#endif
-{
- int32_t n,hx,hy,hz,ix,iy,sx,i;
- uint32_t lx,ly,lz;
-
- EXTRACT_WORDS(hx,lx,x);
- EXTRACT_WORDS(hy,ly,y);
- sx = hx&0x80000000; /* sign of x */
- hx ^=sx; /* |x| */
- hy &= 0x7fffffff; /* |y| */
-
- /* purge off exception values */
- if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */
- ((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */
- return (x*y)/(x*y);
- if(hx<=hy) {
- if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */
- if(lx==ly)
- return Zero[(uint32_t)sx>>31]; /* |x|=|y| return x*0*/
- }
-
- /* determine ix = ilogb(x) */
- if(hx<0x00100000) { /* subnormal x */
- if(hx==0) {
- for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
- } else {
- for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;
- }
- } else ix = (hx>>20)-1023;
-
- /* determine iy = ilogb(y) */
- if(hy<0x00100000) { /* subnormal y */
- if(hy==0) {
- for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
- } else {
- for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;
- }
- } else iy = (hy>>20)-1023;
-
- /* set up {hx,lx}, {hy,ly} and align y to x */
- if(ix >= -1022)
- hx = 0x00100000|(0x000fffff&hx);
- else { /* subnormal x, shift x to normal */
- n = -1022-ix;
- if(n<=31) {
- hx = (hx<<n)|(lx>>(32-n));
- lx <<= n;
- } else {
- hx = lx<<(n-32);
- lx = 0;
- }
- }
- if(iy >= -1022)
- hy = 0x00100000|(0x000fffff&hy);
- else { /* subnormal y, shift y to normal */
- n = -1022-iy;
- if(n<=31) {
- hy = (hy<<n)|(ly>>(32-n));
- ly <<= n;
- } else {
- hy = ly<<(n-32);
- ly = 0;
- }
- }
-
- /* fix point fmod */
- n = ix - iy;
- while(n--) {
- hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
- if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
- else {
- if((hz|lz)==0) /* return sign(x)*0 */
- return Zero[(uint32_t)sx>>31];
- hx = hz+hz+(lz>>31); lx = lz+lz;
- }
- }
- hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
- if(hz>=0) {hx=hz;lx=lz;}
-
- /* convert back to floating value and restore the sign */
- if((hx|lx)==0) /* return sign(x)*0 */
- return Zero[(uint32_t)sx>>31];
- while(hx<0x00100000) { /* normalize x */
- hx = hx+hx+(lx>>31); lx = lx+lx;
- iy -= 1;
- }
- if(iy>= -1022) { /* normalize output */
- hx = ((hx-0x00100000)|((iy+1023)<<20));
- INSERT_WORDS(x,hx|sx,lx);
- } else { /* subnormal output */
- n = -1022 - iy;
- if(n<=20) {
- lx = (lx>>n)|((uint32_t)hx<<(32-n));
- hx >>= n;
- } else if (n<=31) {
- lx = (hx<<(32-n))|(lx>>n); hx = sx;
- } else {
- lx = hx>>(n-32); hx = sx;
- }
- INSERT_WORDS(x,hx|sx,lx);
- x *= one; /* create necessary signal */
- }
- return x; /* exact output */
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_log.c b/libjava/java/lang/e_log.c
deleted file mode 100644
index 093473e1048..00000000000
--- a/libjava/java/lang/e_log.c
+++ /dev/null
@@ -1,152 +0,0 @@
-
-/* @(#)e_log.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __ieee754_log(x)
- * Return the logrithm of x
- *
- * Method :
- * 1. Argument Reduction: find k and f such that
- * x = 2^k * (1+f),
- * where sqrt(2)/2 < 1+f < sqrt(2) .
- *
- * 2. Approximation of log(1+f).
- * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
- * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
- * = 2s + s*R
- * We use a special Reme algorithm on [0,0.1716] to generate
- * a polynomial of degree 14 to approximate R The maximum error
- * of this polynomial approximation is bounded by 2**-58.45. In
- * other words,
- * 2 4 6 8 10 12 14
- * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
- * (the values of Lg1 to Lg7 are listed in the program)
- * and
- * | 2 14 | -58.45
- * | Lg1*s +...+Lg7*s - R(z) | <= 2
- * | |
- * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
- * In order to guarantee error in log below 1ulp, we compute log
- * by
- * log(1+f) = f - s*(f - R) (if f is not too large)
- * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
- *
- * 3. Finally, log(x) = k*ln2 + log(1+f).
- * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
- * Here ln2 is split into two floating point number:
- * ln2_hi + ln2_lo,
- * where n*ln2_hi is always exact for |n| < 2000.
- *
- * Special cases:
- * log(x) is NaN with signal if x < 0 (including -INF) ;
- * log(+INF) is +INF; log(0) is -INF with signal;
- * log(NaN) is that NaN with no signal.
- *
- * Accuracy:
- * according to an error analysis, the error is always less than
- * 1 ulp (unit in the last place).
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
-ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
-two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
-Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
-Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
-Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
-Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
-Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
-Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
-Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-
-#ifdef __STDC__
-static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
-
-#ifdef __STDC__
- double __ieee754_log(double x)
-#else
- double __ieee754_log(x)
- double x;
-#endif
-{
- double hfsq,f,s,z,R,w,t1,t2,dk;
- int32_t k,hx,i,j;
- uint32_t lx;
-
- EXTRACT_WORDS(hx,lx,x);
-
- k=0;
- if (hx < 0x00100000) { /* x < 2**-1022 */
- if (((hx&0x7fffffff)|lx)==0)
- return -two54/zero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 54; x *= two54; /* subnormal number, scale up x */
- GET_HIGH_WORD(hx,x);
- }
- if (hx >= 0x7ff00000) return x+x;
- k += (hx>>20)-1023;
- hx &= 0x000fffff;
- i = (hx+0x95f64)&0x100000;
- SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
- k += (i>>20);
- f = x-1.0;
- if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */
- if(f==zero) {
- if(k==0)
- return zero;
- else {
- dk=(double)k;
- return dk*ln2_hi+dk*ln2_lo;
- }
- }
- R = f*f*(0.5-0.33333333333333333*f);
- if(k==0) return f-R; else {dk=(double)k;
- return dk*ln2_hi-((R-dk*ln2_lo)-f);}
- }
- s = f/(2.0+f);
- dk = (double)k;
- z = s*s;
- i = hx-0x6147a;
- w = z*z;
- j = 0x6b851-hx;
- t1= w*(Lg2+w*(Lg4+w*Lg6));
- t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- i |= j;
- R = t2+t1;
- if(i>0) {
- hfsq=0.5*f*f;
- if(k==0) return f-(hfsq-s*(hfsq+R)); else
- return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
- } else {
- if(k==0) return f-s*(f-R); else
- return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
- }
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_pow.c b/libjava/java/lang/e_pow.c
deleted file mode 100644
index e53a8a287cc..00000000000
--- a/libjava/java/lang/e_pow.c
+++ /dev/null
@@ -1,312 +0,0 @@
-
-/* @(#)e_pow.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __ieee754_pow(x,y) return x**y
- *
- * n
- * Method: Let x = 2 * (1+f)
- * 1. Compute and return log2(x) in two pieces:
- * log2(x) = w1 + w2,
- * where w1 has 53-24 = 29 bit trailing zeros.
- * 2. Perform y*log2(x) = n+y' by simulating muti-precision
- * arithmetic, where |y'|<=0.5.
- * 3. Return x**y = 2**n*exp(y'*log2)
- *
- * Special cases:
- * 1. (anything) ** 0 is 1
- * 2. (anything) ** 1 is itself
- * 3. (anything) ** NAN is NAN
- * 4. NAN ** (anything except 0) is NAN
- * 5. +-(|x| > 1) ** +INF is +INF
- * 6. +-(|x| > 1) ** -INF is +0
- * 7. +-(|x| < 1) ** +INF is +0
- * 8. +-(|x| < 1) ** -INF is +INF
- * 9. +-1 ** +-INF is NAN
- * 10. +0 ** (+anything except 0, NAN) is +0
- * 11. -0 ** (+anything except 0, NAN, odd integer) is +0
- * 12. +0 ** (-anything except 0, NAN) is +INF
- * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF
- * 14. -0 ** (odd integer) = -( +0 ** (odd integer) )
- * 15. +INF ** (+anything except 0,NAN) is +INF
- * 16. +INF ** (-anything except 0,NAN) is +0
- * 17. -INF ** (anything) = -0 ** (-anything)
- * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
- * 19. (-anything except 0 and inf) ** (non-integer) is NAN
- *
- * Accuracy:
- * pow(x,y) returns x**y nearly rounded. In particular
- * pow(integer,integer)
- * always returns the correct integer provided it is
- * representable.
- *
- * Constants :
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-bp[] = {1.0, 1.5,},
-dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
-dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
-zero = 0.0,
-one = 1.0,
-two = 2.0,
-two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */
-huge = 1.0e300,
-tiny = 1.0e-300,
- /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
-L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
-L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
-L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
-L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
-L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
-P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
-lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
-lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
-lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
-ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */
-cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
-cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
-cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
-ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
-ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
-ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
-
-#ifdef __STDC__
- double __ieee754_pow(double x, double y)
-#else
- double __ieee754_pow(x,y)
- double x, y;
-#endif
-{
- double z,ax,z_h,z_l,p_h,p_l;
- double y1,t1,t2,r,s,t,u,v,w;
- int32_t i,j,k,yisint,n;
- int32_t hx,hy,ix,iy;
- uint32_t lx,ly;
-
- EXTRACT_WORDS(hx,lx,x);
- EXTRACT_WORDS(hy,ly,y);
- ix = hx&0x7fffffff; iy = hy&0x7fffffff;
-
- /* y==zero: x**0 = 1 */
- if((iy|ly)==0) return one;
-
- /* +-NaN return x+y */
- if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
- iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
- return x+y;
-
- /* determine if y is an odd int when x < 0
- * yisint = 0 ... y is not an integer
- * yisint = 1 ... y is an odd int
- * yisint = 2 ... y is an even int
- */
- yisint = 0;
- if(hx<0) {
- if(iy>=0x43400000) yisint = 2; /* even integer y */
- else if(iy>=0x3ff00000) {
- k = (iy>>20)-0x3ff; /* exponent */
- if(k>20) {
- j = ly>>(52-k);
- if((uint32_t)(j<<(52-k))==ly) yisint = 2-(j&1);
- } else if(ly==0) {
- j = iy>>(20-k);
- if((j<<(20-k))==iy) yisint = 2-(j&1);
- }
- }
- }
-
- /* special value of y */
- if(ly==0) {
- if (iy==0x7ff00000) { /* y is +-inf */
- if(((ix-0x3ff00000)|lx)==0)
- return y - y; /* inf**+-1 is NaN */
- else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
- return (hy>=0)? y: zero;
- else /* (|x|<1)**-,+inf = inf,0 */
- return (hy<0)?-y: zero;
- }
- if(iy==0x3ff00000) { /* y is +-1 */
- if(hy<0) return one/x; else return x;
- }
- if(hy==0x40000000) return x*x; /* y is 2 */
- if(hy==0x3fe00000) { /* y is 0.5 */
- if(hx>=0) /* x >= +0 */
- return __ieee754_sqrt(x);
- }
- }
-
- ax = fabs(x);
- /* special value of x */
- if(lx==0) {
- if(ix==0x7ff00000||ix==0||ix==0x3ff00000){
- z = ax; /*x is +-0,+-inf,+-1*/
- if(hy<0) z = one/z; /* z = (1/|x|) */
- if(hx<0) {
- if(((ix-0x3ff00000)|yisint)==0) {
- z = (z-z)/(z-z); /* (-1)**non-int is NaN */
- } else if(yisint==1)
- z = -z; /* (x<0)**odd = -(|x|**odd) */
- }
- return z;
- }
- }
-
- /* (x<0)**(non-int) is NaN */
- /* CYGNUS LOCAL: This used to be
- if((((hx>>31)+1)|yisint)==0) return (x-x)/(x-x);
- but ANSI C says a right shift of a signed negative quantity is
- implementation defined. */
- if(((((uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);
-
- /* |y| is huge */
- if(iy>0x41e00000) { /* if |y| > 2**31 */
- if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */
- if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny;
- if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
- }
- /* over/underflow if x is not close to one */
- if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny;
- if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
- /* now |1-x| is tiny <= 2**-20, suffice to compute
- log(x) by x-x^2/2+x^3/3-x^4/4 */
- t = x-1; /* t has 20 trailing zeros */
- w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25));
- u = ivln2_h*t; /* ivln2_h has 21 sig. bits */
- v = t*ivln2_l-w*ivln2;
- t1 = u+v;
- SET_LOW_WORD(t1,0);
- t2 = v-(t1-u);
- } else {
- double s2,s_h,s_l,t_h,t_l;
- n = 0;
- /* take care subnormal number */
- if(ix<0x00100000)
- {ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); }
- n += ((ix)>>20)-0x3ff;
- j = ix&0x000fffff;
- /* determine interval */
- ix = j|0x3ff00000; /* normalize ix */
- if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */
- else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */
- else {k=0;n+=1;ix -= 0x00100000;}
- SET_HIGH_WORD(ax,ix);
-
- /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
- u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
- v = one/(ax+bp[k]);
- s = u*v;
- s_h = s;
- SET_LOW_WORD(s_h,0);
- /* t_h=ax+bp[k] High */
- t_h = zero;
- SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18));
- t_l = ax - (t_h-bp[k]);
- s_l = v*((u-s_h*t_h)-s_h*t_l);
- /* compute log(ax) */
- s2 = s*s;
- r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
- r += s_l*(s_h+s);
- s2 = s_h*s_h;
- t_h = 3.0+s2+r;
- SET_LOW_WORD(t_h,0);
- t_l = r-((t_h-3.0)-s2);
- /* u+v = s*(1+...) */
- u = s_h*t_h;
- v = s_l*t_h+t_l*s;
- /* 2/(3log2)*(s+...) */
- p_h = u+v;
- SET_LOW_WORD(p_h,0);
- p_l = v-(p_h-u);
- z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
- z_l = cp_l*p_h+p_l*cp+dp_l[k];
- /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
- t = (double)n;
- t1 = (((z_h+z_l)+dp_h[k])+t);
- SET_LOW_WORD(t1,0);
- t2 = z_l-(((t1-t)-dp_h[k])-z_h);
- }
-
- s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
- if(((((uint32_t)hx>>31)-1)|(yisint-1))==0)
- s = -one;/* (-ve)**(odd int) */
-
- /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
- y1 = y;
- SET_LOW_WORD(y1,0);
- p_l = (y-y1)*t1+y*t2;
- p_h = y1*t1;
- z = p_l+p_h;
- EXTRACT_WORDS(j,i,z);
- if (j>=0x40900000) { /* z >= 1024 */
- if(((j-0x40900000)|i)!=0) /* if z > 1024 */
- return s*huge*huge; /* overflow */
- else {
- if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */
- }
- } else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */
- if(((j-0xc090cc00)|i)!=0) /* z < -1075 */
- return s*tiny*tiny; /* underflow */
- else {
- if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */
- }
- }
- /*
- * compute 2**(p_h+p_l)
- */
- i = j&0x7fffffff;
- k = (i>>20)-0x3ff;
- n = 0;
- if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
- n = j+(0x00100000>>(k+1));
- k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */
- t = zero;
- SET_HIGH_WORD(t,n&~(0x000fffff>>k));
- n = ((n&0x000fffff)|0x00100000)>>(20-k);
- if(j<0) n = -n;
- p_h -= t;
- }
- t = p_l+p_h;
- SET_LOW_WORD(t,0);
- u = t*lg2_h;
- v = (p_l-(t-p_h))*lg2+t*lg2_l;
- z = u+v;
- w = v-(z-u);
- t = z*z;
- t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
- r = (z*t1)/(t1-two)-(w+z*w);
- z = one-(r-z);
- GET_HIGH_WORD(j,z);
- j += (n<<20);
- if((j>>20)<=0) z = scalbn(z,(int)n); /* subnormal output */
- else SET_HIGH_WORD(z,j);
- return s*z;
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_rem_pio2.c b/libjava/java/lang/e_rem_pio2.c
deleted file mode 100644
index 6d3fd19a48c..00000000000
--- a/libjava/java/lang/e_rem_pio2.c
+++ /dev/null
@@ -1,185 +0,0 @@
-
-/* @(#)e_rem_pio2.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-
-/* __ieee754_rem_pio2(x,y)
- *
- * return the remainder of x rem pi/2 in y[0]+y[1]
- * use __kernel_rem_pio2()
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-/*
- * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
- */
-#ifdef __STDC__
-static const int32_t two_over_pi[] = {
-#else
-static int32_t two_over_pi[] = {
-#endif
-0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62,
-0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A,
-0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129,
-0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,
-0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8,
-0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF,
-0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5,
-0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,
-0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3,
-0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880,
-0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
-};
-
-#ifdef __STDC__
-static const int32_t npio2_hw[] = {
-#else
-static int32_t npio2_hw[] = {
-#endif
-0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C,
-0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C,
-0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A,
-0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C,
-0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB,
-0x404858EB, 0x404921FB,
-};
-
-/*
- * invpio2: 53 bits of 2/pi
- * pio2_1: first 33 bit of pi/2
- * pio2_1t: pi/2 - pio2_1
- * pio2_2: second 33 bit of pi/2
- * pio2_2t: pi/2 - (pio2_1+pio2_2)
- * pio2_3: third 33 bit of pi/2
- * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
- */
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
-half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
-two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
-invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
-pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
-pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */
-pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */
-pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
-pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
-pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
-
-#ifdef __STDC__
- int32_t __ieee754_rem_pio2(double x, double *y)
-#else
- int32_t __ieee754_rem_pio2(x,y)
- double x,y[];
-#endif
-{
- double z,w,t,r,fn;
- double tx[3];
- int32_t i,j,n,ix,hx;
- int e0,nx;
- uint32_t low;
-
- GET_HIGH_WORD(hx,x); /* high word of x */
- ix = hx&0x7fffffff;
- if(ix<=0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */
- {y[0] = x; y[1] = 0; return 0;}
- if(ix<0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */
- if(hx>0) {
- z = x - pio2_1;
- if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */
- y[0] = z - pio2_1t;
- y[1] = (z-y[0])-pio2_1t;
- } else { /* near pi/2, use 33+33+53 bit pi */
- z -= pio2_2;
- y[0] = z - pio2_2t;
- y[1] = (z-y[0])-pio2_2t;
- }
- return 1;
- } else { /* negative x */
- z = x + pio2_1;
- if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */
- y[0] = z + pio2_1t;
- y[1] = (z-y[0])+pio2_1t;
- } else { /* near pi/2, use 33+33+53 bit pi */
- z += pio2_2;
- y[0] = z + pio2_2t;
- y[1] = (z-y[0])+pio2_2t;
- }
- return -1;
- }
- }
- if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */
- t = fabs(x);
- n = (int32_t) (t*invpio2+half);
- fn = (double)n;
- r = t-fn*pio2_1;
- w = fn*pio2_1t; /* 1st round good to 85 bit */
- if(n<32&&ix!=npio2_hw[n-1]) {
- y[0] = r-w; /* quick check no cancellation */
- } else {
- uint32_t high;
- j = ix>>20;
- y[0] = r-w;
- GET_HIGH_WORD(high,y[0]);
- i = j-((high>>20)&0x7ff);
- if(i>16) { /* 2nd iteration needed, good to 118 */
- t = r;
- w = fn*pio2_2;
- r = t-w;
- w = fn*pio2_2t-((t-r)-w);
- y[0] = r-w;
- GET_HIGH_WORD(high,y[0]);
- i = j-((high>>20)&0x7ff);
- if(i>49) { /* 3rd iteration need, 151 bits acc */
- t = r; /* will cover all possible cases */
- w = fn*pio2_3;
- r = t-w;
- w = fn*pio2_3t-((t-r)-w);
- y[0] = r-w;
- }
- }
- }
- y[1] = (r-y[0])-w;
- if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
- else return n;
- }
- /*
- * all other (large) arguments
- */
- if(ix>=0x7ff00000) { /* x is inf or NaN */
- y[0]=y[1]=x-x; return 0;
- }
- /* set z = scalbn(|x|,ilogb(x)-23) */
- GET_LOW_WORD(low,x);
- SET_LOW_WORD(z,low);
- e0 = (int)((ix>>20)-1046); /* e0 = ilogb(z)-23; */
- SET_HIGH_WORD(z, ix - ((int32_t)e0<<20));
- for(i=0;i<2;i++) {
- tx[i] = (double)((int32_t)(z));
- z = (z-tx[i])*two24;
- }
- tx[2] = z;
- nx = 3;
- while(tx[nx-1]==zero) nx--; /* skip zero term */
- n = __kernel_rem_pio2(tx,y,e0,nx,2,two_over_pi);
- if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
- return n;
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_remainder.c b/libjava/java/lang/e_remainder.c
deleted file mode 100644
index 4716d8d05fd..00000000000
--- a/libjava/java/lang/e_remainder.c
+++ /dev/null
@@ -1,80 +0,0 @@
-
-/* @(#)e_remainder.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __ieee754_remainder(x,p)
- * Return :
- * returns x REM p = x - [x/p]*p as if in infinite
- * precise arithmetic, where [x/p] is the (infinite bit)
- * integer nearest x/p (in half way case choose the even one).
- * Method :
- * Based on fmod() return x-[x/p]chopped*p exactlp.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
-
-
-#ifdef __STDC__
- double __ieee754_remainder(double x, double p)
-#else
- double __ieee754_remainder(x,p)
- double x,p;
-#endif
-{
- int32_t hx,hp;
- uint32_t sx,lx,lp;
- double p_half;
-
- EXTRACT_WORDS(hx,lx,x);
- EXTRACT_WORDS(hp,lp,p);
- sx = hx&0x80000000;
- hp &= 0x7fffffff;
- hx &= 0x7fffffff;
-
- /* purge off exception values */
- if((hp|lp)==0) return (x*p)/(x*p); /* p = 0 */
- if((hx>=0x7ff00000)|| /* x not finite */
- ((hp>=0x7ff00000)&& /* p is NaN */
- (((hp-0x7ff00000)|lp)!=0)))
- return (x*p)/(x*p);
-
-
- if (hp<=0x7fdfffff) x = __ieee754_fmod(x,p+p); /* now x < 2p */
- if (((hx-hp)|(lx-lp))==0) return zero*x;
- x = fabs(x);
- p = fabs(p);
- if (hp<0x00200000) {
- if(x+x>p) {
- x-=p;
- if(x+x>=p) x -= p;
- }
- } else {
- p_half = 0.5*p;
- if(x>p_half) {
- x-=p;
- if(x>=p_half) x -= p;
- }
- }
- GET_HIGH_WORD(hx,x);
- SET_HIGH_WORD(x,hx^sx);
- return x;
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_scalb.c b/libjava/java/lang/e_scalb.c
deleted file mode 100644
index 0bb924b43ee..00000000000
--- a/libjava/java/lang/e_scalb.c
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/* @(#)e_scalb.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * __ieee754_scalb(x, fn) is provide for
- * passing various standard test suite. One
- * should use scalbn() instead.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef _SCALB_INT
-#ifdef __STDC__
- double __ieee754_scalb(double x, int fn)
-#else
- double __ieee754_scalb(x,fn)
- double x; int fn;
-#endif
-#else
-#ifdef __STDC__
- double __ieee754_scalb(double x, double fn)
-#else
- double __ieee754_scalb(x,fn)
- double x, fn;
-#endif
-#endif
-{
-#ifdef _SCALB_INT
- return scalbn(x,fn);
-#else
- if (isnan(x)||isnan(fn)) return x*fn;
- if (!finite(fn)) {
- if(fn>0.0) return x*fn;
- else return x/(-fn);
- }
- if (rint(fn)!=fn) return (fn-fn)/(fn-fn);
- if ( fn > 65000.0) return scalbn(x, 65000);
- if (-fn > 65000.0) return scalbn(x,-65000);
- return scalbn(x,(int)fn);
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/e_sqrt.c b/libjava/java/lang/e_sqrt.c
deleted file mode 100644
index 1d566a0847e..00000000000
--- a/libjava/java/lang/e_sqrt.c
+++ /dev/null
@@ -1,452 +0,0 @@
-
-/* @(#)e_sqrt.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __ieee754_sqrt(x)
- * Return correctly rounded sqrt.
- * ------------------------------------------
- * | Use the hardware sqrt if you have one |
- * ------------------------------------------
- * Method:
- * Bit by bit method using integer arithmetic. (Slow, but portable)
- * 1. Normalization
- * Scale x to y in [1,4) with even powers of 2:
- * find an integer k such that 1 <= (y=x*2^(2k)) < 4, then
- * sqrt(x) = 2^k * sqrt(y)
- * 2. Bit by bit computation
- * Let q = sqrt(y) truncated to i bit after binary point (q = 1),
- * i 0
- * i+1 2
- * s = 2*q , and y = 2 * ( y - q ). (1)
- * i i i i
- *
- * To compute q from q , one checks whether
- * i+1 i
- *
- * -(i+1) 2
- * (q + 2 ) <= y. (2)
- * i
- * -(i+1)
- * If (2) is false, then q = q ; otherwise q = q + 2 .
- * i+1 i i+1 i
- *
- * With some algebric manipulation, it is not difficult to see
- * that (2) is equivalent to
- * -(i+1)
- * s + 2 <= y (3)
- * i i
- *
- * The advantage of (3) is that s and y can be computed by
- * i i
- * the following recurrence formula:
- * if (3) is false
- *
- * s = s , y = y ; (4)
- * i+1 i i+1 i
- *
- * otherwise,
- * -i -(i+1)
- * s = s + 2 , y = y - s - 2 (5)
- * i+1 i i+1 i i
- *
- * One may easily use induction to prove (4) and (5).
- * Note. Since the left hand side of (3) contain only i+2 bits,
- * it does not necessary to do a full (53-bit) comparison
- * in (3).
- * 3. Final rounding
- * After generating the 53 bits result, we compute one more bit.
- * Together with the remainder, we can decide whether the
- * result is exact, bigger than 1/2ulp, or less than 1/2ulp
- * (it will never equal to 1/2ulp).
- * The rounding mode can be detected by checking whether
- * huge + tiny is equal to huge, and whether huge - tiny is
- * equal to huge for some floating point number "huge" and "tiny".
- *
- * Special cases:
- * sqrt(+-0) = +-0 ... exact
- * sqrt(inf) = inf
- * sqrt(-ve) = NaN ... with invalid signal
- * sqrt(NaN) = NaN ... with invalid signal for signaling NaN
- *
- * Other methods : see the appended file at the end of the program below.
- *---------------
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double one = 1.0, tiny=1.0e-300;
-#else
-static double one = 1.0, tiny=1.0e-300;
-#endif
-
-#ifdef __STDC__
- double __ieee754_sqrt(double x)
-#else
- double __ieee754_sqrt(x)
- double x;
-#endif
-{
- double z;
- int32_t sign = (int)0x80000000;
- uint32_t r,t1,s1,ix1,q1;
- int32_t ix0,s0,q,m,t,i;
-
- EXTRACT_WORDS(ix0,ix1,x);
-
- /* take care of Inf and NaN */
- if((ix0&0x7ff00000)==0x7ff00000) {
- return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
- sqrt(-inf)=sNaN */
- }
- /* take care of zero */
- if(ix0<=0) {
- if(((ix0&(~sign))|ix1)==0) return x;/* sqrt(+-0) = +-0 */
- else if(ix0<0)
- return (x-x)/(x-x); /* sqrt(-ve) = sNaN */
- }
- /* normalize x */
- m = (ix0>>20);
- if(m==0) { /* subnormal x */
- while(ix0==0) {
- m -= 21;
- ix0 |= (ix1>>11); ix1 <<= 21;
- }
- for(i=0;(ix0&0x00100000)==0;i++) ix0<<=1;
- m -= i-1;
- ix0 |= (ix1>>(32-i));
- ix1 <<= i;
- }
- m -= 1023; /* unbias exponent */
- ix0 = (ix0&0x000fffff)|0x00100000;
- if(m&1){ /* odd m, double x to make it even */
- ix0 += ix0 + ((ix1&sign)>>31);
- ix1 += ix1;
- }
- m >>= 1; /* m = [m/2] */
-
- /* generate sqrt(x) bit by bit */
- ix0 += ix0 + ((ix1&sign)>>31);
- ix1 += ix1;
- q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */
- r = 0x00200000; /* r = moving bit from right to left */
-
- while(r!=0) {
- t = s0+r;
- if(t<=ix0) {
- s0 = t+r;
- ix0 -= t;
- q += r;
- }
- ix0 += ix0 + ((ix1&sign)>>31);
- ix1 += ix1;
- r>>=1;
- }
-
- r = sign;
- while(r!=0) {
- t1 = s1+r;
- t = s0;
- if((t<ix0)||((t==ix0)&&(t1<=ix1))) {
- s1 = t1+r;
- if(((t1&sign)==(uint32_t)sign)&&(s1&sign)==0) s0 += 1;
- ix0 -= t;
- if (ix1 < t1) ix0 -= 1;
- ix1 -= t1;
- q1 += r;
- }
- ix0 += ix0 + ((ix1&sign)>>31);
- ix1 += ix1;
- r>>=1;
- }
-
- /* use floating add to find out rounding direction */
- if((ix0|ix1)!=0) {
- z = one-tiny; /* trigger inexact flag */
- if (z>=one) {
- z = one+tiny;
- if (q1==(uint32_t)0xffffffff) { q1=0; q += 1;}
- else if (z>one) {
- if (q1==(uint32_t)0xfffffffe) q+=1;
- q1+=2;
- } else
- q1 += (q1&1);
- }
- }
- ix0 = (q>>1)+0x3fe00000;
- ix1 = q1>>1;
- if ((q&1)==1) ix1 |= sign;
- ix0 += (m <<20);
- INSERT_WORDS(z,ix0,ix1);
- return z;
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
-
-/*
-Other methods (use floating-point arithmetic)
--------------
-(This is a copy of a drafted paper by Prof W. Kahan
-and K.C. Ng, written in May, 1986)
-
- Two algorithms are given here to implement sqrt(x)
- (IEEE double precision arithmetic) in software.
- Both supply sqrt(x) correctly rounded. The first algorithm (in
- Section A) uses newton iterations and involves four divisions.
- The second one uses reciproot iterations to avoid division, but
- requires more multiplications. Both algorithms need the ability
- to chop results of arithmetic operations instead of round them,
- and the INEXACT flag to indicate when an arithmetic operation
- is executed exactly with no roundoff error, all part of the
- standard (IEEE 754-1985). The ability to perform shift, add,
- subtract and logical AND operations upon 32-bit words is needed
- too, though not part of the standard.
-
-A. sqrt(x) by Newton Iteration
-
- (1) Initial approximation
-
- Let x0 and x1 be the leading and the trailing 32-bit words of
- a floating point number x (in IEEE double format) respectively
-
- 1 11 52 ...widths
- ------------------------------------------------------
- x: |s| e | f |
- ------------------------------------------------------
- msb lsb msb lsb ...order
-
-
- ------------------------ ------------------------
- x0: |s| e | f1 | x1: | f2 |
- ------------------------ ------------------------
-
- By performing shifts and subtracts on x0 and x1 (both regarded
- as integers), we obtain an 8-bit approximation of sqrt(x) as
- follows.
-
- k := (x0>>1) + 0x1ff80000;
- y0 := k - T1[31&(k>>15)]. ... y ~ sqrt(x) to 8 bits
- Here k is a 32-bit integer and T1[] is an integer array containing
- correction terms. Now magically the floating value of y (y's
- leading 32-bit word is y0, the value of its trailing word is 0)
- approximates sqrt(x) to almost 8-bit.
-
- Value of T1:
- static int T1[32]= {
- 0, 1024, 3062, 5746, 9193, 13348, 18162, 23592,
- 29598, 36145, 43202, 50740, 58733, 67158, 75992, 85215,
- 83599, 71378, 60428, 50647, 41945, 34246, 27478, 21581,
- 16499, 12183, 8588, 5674, 3403, 1742, 661, 130,};
-
- (2) Iterative refinement
-
- Apply Heron's rule three times to y, we have y approximates
- sqrt(x) to within 1 ulp (Unit in the Last Place):
-
- y := (y+x/y)/2 ... almost 17 sig. bits
- y := (y+x/y)/2 ... almost 35 sig. bits
- y := y-(y-x/y)/2 ... within 1 ulp
-
-
- Remark 1.
- Another way to improve y to within 1 ulp is:
-
- y := (y+x/y) ... almost 17 sig. bits to 2*sqrt(x)
- y := y - 0x00100006 ... almost 18 sig. bits to sqrt(x)
-
- 2
- (x-y )*y
- y := y + 2* ---------- ...within 1 ulp
- 2
- 3y + x
-
-
- This formula has one division fewer than the one above; however,
- it requires more multiplications and additions. Also x must be
- scaled in advance to avoid spurious overflow in evaluating the
- expression 3y*y+x. Hence it is not recommended uless division
- is slow. If division is very slow, then one should use the
- reciproot algorithm given in section B.
-
- (3) Final adjustment
-
- By twiddling y's last bit it is possible to force y to be
- correctly rounded according to the prevailing rounding mode
- as follows. Let r and i be copies of the rounding mode and
- inexact flag before entering the square root program. Also we
- use the expression y+-ulp for the next representable floating
- numbers (up and down) of y. Note that y+-ulp = either fixed
- point y+-1, or multiply y by nextafter(1,+-inf) in chopped
- mode.
-
- I := FALSE; ... reset INEXACT flag I
- R := RZ; ... set rounding mode to round-toward-zero
- z := x/y; ... chopped quotient, possibly inexact
- If(not I) then { ... if the quotient is exact
- if(z=y) {
- I := i; ... restore inexact flag
- R := r; ... restore rounded mode
- return sqrt(x):=y.
- } else {
- z := z - ulp; ... special rounding
- }
- }
- i := TRUE; ... sqrt(x) is inexact
- If (r=RN) then z=z+ulp ... rounded-to-nearest
- If (r=RP) then { ... round-toward-+inf
- y = y+ulp; z=z+ulp;
- }
- y := y+z; ... chopped sum
- y0:=y0-0x00100000; ... y := y/2 is correctly rounded.
- I := i; ... restore inexact flag
- R := r; ... restore rounded mode
- return sqrt(x):=y.
-
- (4) Special cases
-
- Square root of +inf, +-0, or NaN is itself;
- Square root of a negative number is NaN with invalid signal.
-
-
-B. sqrt(x) by Reciproot Iteration
-
- (1) Initial approximation
-
- Let x0 and x1 be the leading and the trailing 32-bit words of
- a floating point number x (in IEEE double format) respectively
- (see section A). By performing shifs and subtracts on x0 and y0,
- we obtain a 7.8-bit approximation of 1/sqrt(x) as follows.
-
- k := 0x5fe80000 - (x0>>1);
- y0:= k - T2[63&(k>>14)]. ... y ~ 1/sqrt(x) to 7.8 bits
-
- Here k is a 32-bit integer and T2[] is an integer array
- containing correction terms. Now magically the floating
- value of y (y's leading 32-bit word is y0, the value of
- its trailing word y1 is set to zero) approximates 1/sqrt(x)
- to almost 7.8-bit.
-
- Value of T2:
- static int T2[64]= {
- 0x1500, 0x2ef8, 0x4d67, 0x6b02, 0x87be, 0xa395, 0xbe7a, 0xd866,
- 0xf14a, 0x1091b,0x11fcd,0x13552,0x14999,0x15c98,0x16e34,0x17e5f,
- 0x18d03,0x19a01,0x1a545,0x1ae8a,0x1b5c4,0x1bb01,0x1bfde,0x1c28d,
- 0x1c2de,0x1c0db,0x1ba73,0x1b11c,0x1a4b5,0x1953d,0x18266,0x16be0,
- 0x1683e,0x179d8,0x18a4d,0x19992,0x1a789,0x1b445,0x1bf61,0x1c989,
- 0x1d16d,0x1d77b,0x1dddf,0x1e2ad,0x1e5bf,0x1e6e8,0x1e654,0x1e3cd,
- 0x1df2a,0x1d635,0x1cb16,0x1be2c,0x1ae4e,0x19bde,0x1868e,0x16e2e,
- 0x1527f,0x1334a,0x11051,0xe951, 0xbe01, 0x8e0d, 0x5924, 0x1edd,};
-
- (2) Iterative refinement
-
- Apply Reciproot iteration three times to y and multiply the
- result by x to get an approximation z that matches sqrt(x)
- to about 1 ulp. To be exact, we will have
- -1ulp < sqrt(x)-z<1.0625ulp.
-
- ... set rounding mode to Round-to-nearest
- y := y*(1.5-0.5*x*y*y) ... almost 15 sig. bits to 1/sqrt(x)
- y := y*((1.5-2^-30)+0.5*x*y*y)... about 29 sig. bits to 1/sqrt(x)
- ... special arrangement for better accuracy
- z := x*y ... 29 bits to sqrt(x), with z*y<1
- z := z + 0.5*z*(1-z*y) ... about 1 ulp to sqrt(x)
-
- Remark 2. The constant 1.5-2^-30 is chosen to bias the error so that
- (a) the term z*y in the final iteration is always less than 1;
- (b) the error in the final result is biased upward so that
- -1 ulp < sqrt(x) - z < 1.0625 ulp
- instead of |sqrt(x)-z|<1.03125ulp.
-
- (3) Final adjustment
-
- By twiddling y's last bit it is possible to force y to be
- correctly rounded according to the prevailing rounding mode
- as follows. Let r and i be copies of the rounding mode and
- inexact flag before entering the square root program. Also we
- use the expression y+-ulp for the next representable floating
- numbers (up and down) of y. Note that y+-ulp = either fixed
- point y+-1, or multiply y by nextafter(1,+-inf) in chopped
- mode.
-
- R := RZ; ... set rounding mode to round-toward-zero
- switch(r) {
- case RN: ... round-to-nearest
- if(x<= z*(z-ulp)...chopped) z = z - ulp; else
- if(x<= z*(z+ulp)...chopped) z = z; else z = z+ulp;
- break;
- case RZ:case RM: ... round-to-zero or round-to--inf
- R:=RP; ... reset rounding mod to round-to-+inf
- if(x<z*z ... rounded up) z = z - ulp; else
- if(x>=(z+ulp)*(z+ulp) ...rounded up) z = z+ulp;
- break;
- case RP: ... round-to-+inf
- if(x>(z+ulp)*(z+ulp)...chopped) z = z+2*ulp; else
- if(x>z*z ...chopped) z = z+ulp;
- break;
- }
-
- Remark 3. The above comparisons can be done in fixed point. For
- example, to compare x and w=z*z chopped, it suffices to compare
- x1 and w1 (the trailing parts of x and w), regarding them as
- two's complement integers.
-
- ...Is z an exact square root?
- To determine whether z is an exact square root of x, let z1 be the
- trailing part of z, and also let x0 and x1 be the leading and
- trailing parts of x.
-
- If ((z1&0x03ffffff)!=0) ... not exact if trailing 26 bits of z!=0
- I := 1; ... Raise Inexact flag: z is not exact
- else {
- j := 1 - [(x0>>20)&1] ... j = logb(x) mod 2
- k := z1 >> 26; ... get z's 25-th and 26-th
- fraction bits
- I := i or (k&j) or ((k&(j+j+1))!=(x1&3));
- }
- R:= r ... restore rounded mode
- return sqrt(x):=z.
-
- If multiplication is cheaper then the foregoing red tape, the
- Inexact flag can be evaluated by
-
- I := i;
- I := (z*z!=x) or I.
-
- Note that z*z can overwrite I; this value must be sensed if it is
- True.
-
- Remark 4. If z*z = x exactly, then bit 25 to bit 0 of z1 must be
- zero.
-
- --------------------
- z1: | f2 |
- --------------------
- bit 31 bit 0
-
- Further more, bit 27 and 26 of z1, bit 0 and 1 of x1, and the odd
- or even of logb(x) have the following relations:
-
- -------------------------------------------------
- bit 27,26 of z1 bit 1,0 of x1 logb(x)
- -------------------------------------------------
- 00 00 odd and even
- 01 01 even
- 10 10 odd
- 10 00 even
- 11 01 even
- -------------------------------------------------
-
- (4) Special cases (see (4) of Section A).
-
- */
diff --git a/libjava/java/lang/fdlibm.h b/libjava/java/lang/fdlibm.h
deleted file mode 100644
index 228208fedfd..00000000000
--- a/libjava/java/lang/fdlibm.h
+++ /dev/null
@@ -1,342 +0,0 @@
-
-/* @(#)fdlibm.h 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993, 2000 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-
-#include <config.h>
-#include <stdlib.h>
-
-/* CYGNUS LOCAL: Include files. */
-#include "ieeefp.h"
-
-#include "mprec.h"
-
-/* CYGNUS LOCAL: Default to XOPEN_MODE. */
-#define _XOPEN_MODE
-
-#ifdef __STDC__
-#define __P(p) p
-#else
-#define __P(p) ()
-#endif
-
-#ifndef HUGE
-#define HUGE ((float)3.40282346638528860e+38)
-#endif
-
-/*
- * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
- * (one may replace the following line by "#include <values.h>")
- */
-
-#define X_TLOSS 1.41484755040568800000e+16
-
-/* These typedefs are true for the targets running Java. */
-
-#define _IEEE_LIBM
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * ANSI/POSIX
- */
-extern double acos __P((double));
-extern double asin __P((double));
-extern double atan __P((double));
-extern double atan2 __P((double, double));
-extern double cos __P((double));
-extern double sin __P((double));
-extern double tan __P((double));
-
-extern double cosh __P((double));
-extern double sinh __P((double));
-extern double tanh __P((double));
-
-extern double exp __P((double));
-extern double frexp __P((double, int *));
-extern double ldexp __P((double, int));
-extern double log __P((double));
-extern double log10 __P((double));
-extern double modf __P((double, double *));
-
-extern double pow __P((double, double));
-extern double sqrt __P((double));
-
-extern double ceil __P((double));
-extern double fabs __P((double));
-extern double floor __P((double));
-extern double fmod __P((double, double));
-
-extern double erf __P((double));
-extern double erfc __P((double));
-extern double gamma __P((double));
-extern double hypot __P((double, double));
-extern int isnan __P((double));
-extern int finite __P((double));
-extern double j0 __P((double));
-extern double j1 __P((double));
-extern double jn __P((int, double));
-extern double lgamma __P((double));
-extern double y0 __P((double));
-extern double y1 __P((double));
-extern double yn __P((int, double));
-
-extern double acosh __P((double));
-extern double asinh __P((double));
-extern double atanh __P((double));
-extern double cbrt __P((double));
-extern double logb __P((double));
-extern double nextafter __P((double, double));
-extern double remainder __P((double, double));
-
-/* Functions that are not documented, and are not in <math.h>. */
-
-extern double logb __P((double));
-#ifdef _SCALB_INT
-extern double scalb __P((double, int));
-#else
-extern double scalb __P((double, double));
-#endif
-extern double significand __P((double));
-
-/* ieee style elementary functions */
-extern double __ieee754_sqrt __P((double));
-extern double __ieee754_acos __P((double));
-extern double __ieee754_acosh __P((double));
-extern double __ieee754_log __P((double));
-extern double __ieee754_atanh __P((double));
-extern double __ieee754_asin __P((double));
-extern double __ieee754_atan2 __P((double,double));
-extern double __ieee754_exp __P((double));
-extern double __ieee754_cosh __P((double));
-extern double __ieee754_fmod __P((double,double));
-extern double __ieee754_pow __P((double,double));
-extern double __ieee754_lgamma_r __P((double,int *));
-extern double __ieee754_gamma_r __P((double,int *));
-extern double __ieee754_log10 __P((double));
-extern double __ieee754_sinh __P((double));
-extern double __ieee754_hypot __P((double,double));
-extern double __ieee754_j0 __P((double));
-extern double __ieee754_j1 __P((double));
-extern double __ieee754_y0 __P((double));
-extern double __ieee754_y1 __P((double));
-extern double __ieee754_jn __P((int,double));
-extern double __ieee754_yn __P((int,double));
-extern double __ieee754_remainder __P((double,double));
-extern int32_t __ieee754_rem_pio2 __P((double,double*));
-#ifdef _SCALB_INT
-extern double __ieee754_scalb __P((double,int));
-#else
-extern double __ieee754_scalb __P((double,double));
-#endif
-
-/* fdlibm kernel function */
-extern double __kernel_standard __P((double,double,int));
-extern double __kernel_sin __P((double,double,int));
-extern double __kernel_cos __P((double,double));
-extern double __kernel_tan __P((double,double,int));
-extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int32_t*));
-
-/* Undocumented float functions. */
-extern float logbf __P((float));
-#ifdef _SCALB_INT
-extern float scalbf __P((float, int));
-#else
-extern float scalbf __P((float, float));
-#endif
-extern float significandf __P((float));
-
-/*
- * Functions callable from C, intended to support IEEE arithmetic.
- */
-extern double copysign __P((double, double));
-extern int ilogb __P((double));
-extern double rint __P((double));
-extern float rintf __P((float));
-extern double scalbn __P((double, int));
-
-/* ieee style elementary float functions */
-extern float __ieee754_sqrtf __P((float));
-extern float __ieee754_acosf __P((float));
-extern float __ieee754_acoshf __P((float));
-extern float __ieee754_logf __P((float));
-extern float __ieee754_atanhf __P((float));
-extern float __ieee754_asinf __P((float));
-extern float __ieee754_atan2f __P((float,float));
-extern float __ieee754_expf __P((float));
-extern float __ieee754_coshf __P((float));
-extern float __ieee754_fmodf __P((float,float));
-extern float __ieee754_powf __P((float,float));
-extern float __ieee754_lgammaf_r __P((float,int *));
-extern float __ieee754_gammaf_r __P((float,int *));
-extern float __ieee754_log10f __P((float));
-extern float __ieee754_sinhf __P((float));
-extern float __ieee754_hypotf __P((float,float));
-extern float __ieee754_j0f __P((float));
-extern float __ieee754_j1f __P((float));
-extern float __ieee754_y0f __P((float));
-extern float __ieee754_y1f __P((float));
-extern float __ieee754_jnf __P((int,float));
-extern float __ieee754_ynf __P((int,float));
-extern float __ieee754_remainderf __P((float,float));
-extern int32_t __ieee754_rem_pio2f __P((float,float*));
-#ifdef _SCALB_INT
-extern float __ieee754_scalbf __P((float,int));
-#else
-extern float __ieee754_scalbf __P((float,float));
-#endif
-
-/* float versions of fdlibm kernel functions */
-extern float __kernel_sinf __P((float,float,int));
-extern float __kernel_cosf __P((float,float));
-extern float __kernel_tanf __P((float,float,int));
-extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int32_t*));
-
-/* The original code used statements like
- n0 = ((*(int*)&one)>>29)^1; * index of high word *
- ix0 = *(n0+(int*)&x); * high word of x *
- ix1 = *((1-n0)+(int*)&x); * low word of x *
- to dig two 32 bit words out of the 64 bit IEEE floating point
- value. That is non-ANSI, and, moreover, the gcc instruction
- scheduler gets it wrong. We instead use the following macros.
- Unlike the original code, we determine the endianness at compile
- time, not at run time; I don't see much benefit to selecting
- endianness at run time. */
-
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
- #error Must define endianness
-#endif
-#endif
-
-/* A union which permits us to convert between a double and two 32 bit
- ints. */
-
-#ifdef __IEEE_BIG_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
- uint32_t msw;
- uint32_t lsw;
- } parts;
-} ieee_double_shape_type;
-
-#endif
-
-#ifdef __IEEE_LITTLE_ENDIAN
-
-typedef union
-{
- double value;
- struct
- {
- uint32_t lsw;
- uint32_t msw;
- } parts;
-} ieee_double_shape_type;
-
-#endif
-
-/* Get two 32 bit ints from a double. */
-
-#define EXTRACT_WORDS(ix0,ix1,d) \
-do { \
- ieee_double_shape_type ew_u; \
- ew_u.value = (d); \
- (ix0) = ew_u.parts.msw; \
- (ix1) = ew_u.parts.lsw; \
-} while (0)
-
-/* Get the more significant 32 bit int from a double. */
-
-#define GET_HIGH_WORD(i,d) \
-do { \
- ieee_double_shape_type gh_u; \
- gh_u.value = (d); \
- (i) = gh_u.parts.msw; \
-} while (0)
-
-/* Get the less significant 32 bit int from a double. */
-
-#define GET_LOW_WORD(i,d) \
-do { \
- ieee_double_shape_type gl_u; \
- gl_u.value = (d); \
- (i) = gl_u.parts.lsw; \
-} while (0)
-
-/* Set a double from two 32 bit ints. */
-
-#define INSERT_WORDS(d,ix0,ix1) \
-do { \
- ieee_double_shape_type iw_u; \
- iw_u.parts.msw = (ix0); \
- iw_u.parts.lsw = (ix1); \
- (d) = iw_u.value; \
-} while (0)
-
-/* Set the more significant 32 bits of a double from an int. */
-
-#define SET_HIGH_WORD(d,v) \
-do { \
- ieee_double_shape_type sh_u; \
- sh_u.value = (d); \
- sh_u.parts.msw = (v); \
- (d) = sh_u.value; \
-} while (0)
-
-/* Set the less significant 32 bits of a double from an int. */
-
-#define SET_LOW_WORD(d,v) \
-do { \
- ieee_double_shape_type sl_u; \
- sl_u.value = (d); \
- sl_u.parts.lsw = (v); \
- (d) = sl_u.value; \
-} while (0)
-
-/* A union which permits us to convert between a float and a 32 bit
- int. */
-
-typedef union
-{
- float value;
- uint32_t word;
-} ieee_float_shape_type;
-
-/* Get a 32 bit int from a float. */
-
-#define GET_FLOAT_WORD(i,d) \
-do { \
- ieee_float_shape_type gf_u; \
- gf_u.value = (d); \
- (i) = gf_u.word; \
-} while (0)
-
-/* Set a float from a 32 bit int. */
-
-#define SET_FLOAT_WORD(d,i) \
-do { \
- ieee_float_shape_type sf_u; \
- sf_u.word = (i); \
- (d) = sf_u.value; \
-} while (0)
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/libjava/java/lang/ieeefp.h b/libjava/java/lang/ieeefp.h
deleted file mode 100644
index bf0cafc6bd2..00000000000
--- a/libjava/java/lang/ieeefp.h
+++ /dev/null
@@ -1,115 +0,0 @@
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
-
-#ifdef __alpha__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __arm__
-/* ARM always has big-endian words. Within those words the byte ordering
- appears to be big or little endian. Newlib doesn't seem to care about
- the byte ordering within words. */
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __hppa__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#if defined (__sparc) || defined (__sparc__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#if defined(__m68k__) || defined(__mc68000__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#if defined (__H8300__) || defined (__H8300H__)
-#define __IEEE_BIG_ENDIAN
-#define __SMALL_BITFIELDS
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __H8500__
-#define __IEEE_BIG_ENDIAN
-#define __SMALL_BITFIELDS
-#define _DOUBLE_IS_32BITS
-#endif
-
-#ifdef __sh__
-#ifdef __LITTLE_ENDIAN__
-#define __IEEE_LITTLE_ENDIAN
-#else
-#define __IEEE_BIG_ENDIAN
-#endif
-#ifdef __SH3E__
-#define _DOUBLE_IS_32BITS
-#endif
-#endif
-
-#ifdef _AM29K
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __i386__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __i960__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __MIPSEL__
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#ifdef __MIPSEB__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __pj__
-#ifdef __pjl__
-#define __IEEE_LITTLE_ENDIAN
-#else
-#define __IEEE_BIG_ENDIAN
-#endif
-#endif
-
-/* necv70 was __IEEE_LITTLE_ENDIAN. */
-
-#ifdef __W65__
-#define __IEEE_LITTLE_ENDIAN
-#define __SMALL_BITFIELDS
-#define _DOUBLE_IS_32BITS
-#endif
-
-#if defined(__Z8001__) || defined(__Z8002__)
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __m88k__
-#define __IEEE_BIG_ENDIAN
-#endif
-
-#ifdef __v800
-#define __IEEE_LITTLE_ENDIAN
-#endif
-
-#ifdef __PPC__
-#if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX)
-#define __IEEE_BIG_ENDIAN
-#else
-#if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(__WIN32__) && __WIN32__)
-#define __IEEE_LITTLE_ENDIAN
-#endif
-#endif
-#endif
-
-#ifndef __IEEE_BIG_ENDIAN
-#ifndef __IEEE_LITTLE_ENDIAN
-#error Endianess not declared!!
-#endif /* not __IEEE_LITTLE_ENDIAN */
-#endif /* not __IEEE_BIG_ENDIAN */
-
-#endif /* not __IEEE_LITTLE_ENDIAN */
-#endif /* not __IEEE_BIG_ENDIAN */
-
diff --git a/libjava/java/lang/k_cos.c b/libjava/java/lang/k_cos.c
deleted file mode 100644
index acf50a82e83..00000000000
--- a/libjava/java/lang/k_cos.c
+++ /dev/null
@@ -1,96 +0,0 @@
-
-/* @(#)k_cos.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * __kernel_cos( x, y )
- * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
- *
- * Algorithm
- * 1. Since cos(-x) = cos(x), we need only to consider positive x.
- * 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0.
- * 3. cos(x) is approximated by a polynomial of degree 14 on
- * [0,pi/4]
- * 4 14
- * cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x
- * where the remez error is
- *
- * | 2 4 6 8 10 12 14 | -58
- * |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2
- * | |
- *
- * 4 6 8 10 12 14
- * 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then
- * cos(x) = 1 - x*x/2 + r
- * since cos(x+y) ~ cos(x) - sin(x)*y
- * ~ cos(x) - x*y,
- * a correction term is necessary in cos(x) and hence
- * cos(x+y) = 1 - (x*x/2 - (r - x*y))
- * For better accuracy when x > 0.3, let qx = |x|/4 with
- * the last 32 bits mask off, and if x > 0.78125, let qx = 0.28125.
- * Then
- * cos(x+y) = (1-qx) - ((x*x/2-qx) - (r-x*y)).
- * Note that 1-qx and (x*x/2-qx) is EXACT here, and the
- * magnitude of the latter is at least a quarter of x*x/2,
- * thus, reducing the rounding error in the subtraction.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
-C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */
-C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */
-C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */
-C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
-C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
-
-#ifdef __STDC__
- double __kernel_cos(double x, double y)
-#else
- double __kernel_cos(x, y)
- double x,y;
-#endif
-{
- double a,hz,z,r,qx;
- int32_t ix;
- GET_HIGH_WORD(ix,x);
- ix &= 0x7fffffff; /* ix = |x|'s high word*/
- if(ix<0x3e400000) { /* if x < 2**27 */
- if(((int)x)==0) return one; /* generate inexact */
- }
- z = x*x;
- r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6)))));
- if(ix < 0x3FD33333) /* if |x| < 0.3 */
- return one - (0.5*z - (z*r - x*y));
- else {
- if(ix > 0x3fe90000) { /* x > 0.78125 */
- qx = 0.28125;
- } else {
- INSERT_WORDS(qx,ix-0x00200000,0); /* x/4 */
- }
- hz = 0.5*z-qx;
- a = one-qx;
- return a - (hz - (z*r-x*y));
- }
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/k_rem_pio2.c b/libjava/java/lang/k_rem_pio2.c
deleted file mode 100644
index 2f4ca17256c..00000000000
--- a/libjava/java/lang/k_rem_pio2.c
+++ /dev/null
@@ -1,320 +0,0 @@
-
-/* @(#)k_rem_pio2.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
- * double x[],y[]; int e0,nx,prec; int ipio2[];
- *
- * __kernel_rem_pio2 return the last three digits of N with
- * y = x - N*pi/2
- * so that |y| < pi/2.
- *
- * The method is to compute the integer (mod 8) and fraction parts of
- * (2/pi)*x without doing the full multiplication. In general we
- * skip the part of the product that are known to be a huge integer (
- * more accurately, = 0 mod 8 ). Thus the number of operations are
- * independent of the exponent of the input.
- *
- * (2/pi) is represented by an array of 24-bit integers in ipio2[].
- *
- * Input parameters:
- * x[] The input value (must be positive) is broken into nx
- * pieces of 24-bit integers in double precision format.
- * x[i] will be the i-th 24 bit of x. The scaled exponent
- * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0
- * match x's up to 24 bits.
- *
- * Example of breaking a double positive z into x[0]+x[1]+x[2]:
- * e0 = ilogb(z)-23
- * z = scalbn(z,-e0)
- * for i = 0,1,2
- * x[i] = floor(z)
- * z = (z-x[i])*2**24
- *
- *
- * y[] ouput result in an array of double precision numbers.
- * The dimension of y[] is:
- * 24-bit precision 1
- * 53-bit precision 2
- * 64-bit precision 2
- * 113-bit precision 3
- * The actual value is the sum of them. Thus for 113-bit
- * precison, one may have to do something like:
- *
- * long double t,w,r_head, r_tail;
- * t = (long double)y[2] + (long double)y[1];
- * w = (long double)y[0];
- * r_head = t+w;
- * r_tail = w - (r_head - t);
- *
- * e0 The exponent of x[0]
- *
- * nx dimension of x[]
- *
- * prec an integer indicating the precision:
- * 0 24 bits (single)
- * 1 53 bits (double)
- * 2 64 bits (extended)
- * 3 113 bits (quad)
- *
- * ipio2[]
- * integer array, contains the (24*i)-th to (24*i+23)-th
- * bit of 2/pi after binary point. The corresponding
- * floating value is
- *
- * ipio2[i] * 2^(-24(i+1)).
- *
- * External function:
- * double scalbn(), floor();
- *
- *
- * Here is the description of some local variables:
- *
- * jk jk+1 is the initial number of terms of ipio2[] needed
- * in the computation. The recommended value is 2,3,4,
- * 6 for single, double, extended,and quad.
- *
- * jz local integer variable indicating the number of
- * terms of ipio2[] used.
- *
- * jx nx - 1
- *
- * jv index for pointing to the suitable ipio2[] for the
- * computation. In general, we want
- * ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8
- * is an integer. Thus
- * e0-3-24*jv >= 0 or (e0-3)/24 >= jv
- * Hence jv = max(0,(e0-3)/24).
- *
- * jp jp+1 is the number of terms in PIo2[] needed, jp = jk.
- *
- * q[] double array with integral value, representing the
- * 24-bits chunk of the product of x and 2/pi.
- *
- * q0 the corresponding exponent of q[0]. Note that the
- * exponent for q[i] would be q0-24*i.
- *
- * PIo2[] double precision array, obtained by cutting pi/2
- * into 24 bits chunks.
- *
- * f[] ipio2[] in floating point
- *
- * iq[] integer array by breaking up q[] in 24-bits chunk.
- *
- * fq[] final product of x*(2/pi) in fq[0],..,fq[jk]
- *
- * ih integer. If >0 it indicates q[] is >= 0.5, hence
- * it also indicates the *sign* of the result.
- *
- */
-
-
-/*
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
-#else
-static int init_jk[] = {2,3,4,6};
-#endif
-
-#ifdef __STDC__
-static const double PIo2[] = {
-#else
-static double PIo2[] = {
-#endif
- 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
- 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
- 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
- 3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */
- 1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */
- 1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */
- 2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */
- 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
-};
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-zero = 0.0,
-one = 1.0,
-two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
-twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
-
-#ifdef __STDC__
- int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
-#else
- int __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
- double x[], y[]; int e0,nx,prec; int32_t ipio2[];
-#endif
-{
- int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
- double z,fw,f[20],fq[20],q[20];
-
- /* initialize jk*/
- jk = init_jk[prec];
- jp = jk;
-
- /* determine jx,jv,q0, note that 3>q0 */
- jx = nx-1;
- jv = (e0-3)/24; if(jv<0) jv=0;
- q0 = e0-24*(jv+1);
-
- /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
- j = jv-jx; m = jx+jk;
- for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];
-
- /* compute q[0],q[1],...q[jk] */
- for (i=0;i<=jk;i++) {
- for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
- }
-
- jz = jk;
-recompute:
- /* distill q[] into iq[] reversingly */
- for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
- fw = (double)((int32_t)(twon24* z));
- iq[i] = (int32_t)(z-two24*fw);
- z = q[j-1]+fw;
- }
-
- /* compute n */
- z = scalbn(z,(int)q0); /* actual value of z */
- z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */
- n = (int32_t) z;
- z -= (double)n;
- ih = 0;
- if(q0>0) { /* need iq[jz-1] to determine n */
- i = (iq[jz-1]>>(24-q0)); n += i;
- iq[jz-1] -= i<<(24-q0);
- ih = iq[jz-1]>>(23-q0);
- }
- else if(q0==0) ih = iq[jz-1]>>23;
- else if(z>=0.5) ih=2;
-
- if(ih>0) { /* q > 0.5 */
- n += 1; carry = 0;
- for(i=0;i<jz ;i++) { /* compute 1-q */
- j = iq[i];
- if(carry==0) {
- if(j!=0) {
- carry = 1; iq[i] = 0x1000000- j;
- }
- } else iq[i] = 0xffffff - j;
- }
- if(q0>0) { /* rare case: chance is 1 in 12 */
- switch(q0) {
- case 1:
- iq[jz-1] &= 0x7fffff; break;
- case 2:
- iq[jz-1] &= 0x3fffff; break;
- }
- }
- if(ih==2) {
- z = one - z;
- if(carry!=0) z -= scalbn(one,(int)q0);
- }
- }
-
- /* check if recomputation is needed */
- if(z==zero) {
- j = 0;
- for (i=jz-1;i>=jk;i--) j |= iq[i];
- if(j==0) { /* need recomputation */
- for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */
-
- for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */
- f[jx+i] = (double) ipio2[jv+i];
- for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
- q[i] = fw;
- }
- jz += k;
- goto recompute;
- }
- }
-
- /* chop off zero terms */
- if(z==0.0) {
- jz -= 1; q0 -= 24;
- while(iq[jz]==0) { jz--; q0-=24;}
- } else { /* break z into 24-bit if necessary */
- z = scalbn(z,-(int)q0);
- if(z>=two24) {
- fw = (double)((int32_t)(twon24*z));
- iq[jz] = (int32_t)(z-two24*fw);
- jz += 1; q0 += 24;
- iq[jz] = (int32_t) fw;
- } else iq[jz] = (int32_t) z ;
- }
-
- /* convert integer "bit" chunk to floating-point value */
- fw = scalbn(one,(int)q0);
- for(i=jz;i>=0;i--) {
- q[i] = fw*(double)iq[i]; fw*=twon24;
- }
-
- /* compute PIo2[0,...,jp]*q[jz,...,0] */
- for(i=jz;i>=0;i--) {
- for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
- fq[jz-i] = fw;
- }
-
- /* compress fq[] into y[] */
- switch(prec) {
- case 0:
- fw = 0.0;
- for (i=jz;i>=0;i--) fw += fq[i];
- y[0] = (ih==0)? fw: -fw;
- break;
- case 1:
- case 2:
- fw = 0.0;
- for (i=jz;i>=0;i--) fw += fq[i];
- y[0] = (ih==0)? fw: -fw;
- fw = fq[0]-fw;
- for (i=1;i<=jz;i++) fw += fq[i];
- y[1] = (ih==0)? fw: -fw;
- break;
- case 3: /* painful */
- for (i=jz;i>0;i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
- }
- for (i=jz;i>1;i--) {
- fw = fq[i-1]+fq[i];
- fq[i] += fq[i-1]-fw;
- fq[i-1] = fw;
- }
- for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
- if(ih==0) {
- y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
- } else {
- y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
- }
- }
- return n&7;
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/k_sin.c b/libjava/java/lang/k_sin.c
deleted file mode 100644
index b4ad387c589..00000000000
--- a/libjava/java/lang/k_sin.c
+++ /dev/null
@@ -1,79 +0,0 @@
-
-/* @(#)k_sin.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __kernel_sin( x, y, iy)
- * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
- * Input iy indicates whether y is 0. (if iy=0, y assume to be 0).
- *
- * Algorithm
- * 1. Since sin(-x) = -sin(x), we need only to consider positive x.
- * 2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0.
- * 3. sin(x) is approximated by a polynomial of degree 13 on
- * [0,pi/4]
- * 3 13
- * sin(x) ~ x + S1*x + ... + S6*x
- * where
- *
- * |sin(x) 2 4 6 8 10 12 | -58
- * |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2
- * | x |
- *
- * 4. sin(x+y) = sin(x) + sin'(x')*y
- * ~ sin(x) + (1-x*x/2)*y
- * For better accuracy, let
- * 3 2 2 2 2
- * r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
- * then 3 2
- * sin(x) = x + (S1*x + (x *(r-y/2)+y))
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
-S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
-S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
-S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
-S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
-S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
-S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
-
-#ifdef __STDC__
- double __kernel_sin(double x, double y, int iy)
-#else
- double __kernel_sin(x, y, iy)
- double x,y; int iy; /* iy=0 if y is zero */
-#endif
-{
- double z,r,v;
- int32_t ix;
- GET_HIGH_WORD(ix,x);
- ix &= 0x7fffffff; /* high word of x */
- if(ix<0x3e400000) /* |x| < 2**-27 */
- {if((int)x==0) return x;} /* generate inexact */
- z = x*x;
- v = z*x;
- r = S2+z*(S3+z*(S4+z*(S5+z*S6)));
- if(iy==0) return x+v*(S1+z*r);
- else return x-((z*(half*y-v*r)-y)-v*S1);
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/k_tan.c b/libjava/java/lang/k_tan.c
deleted file mode 100644
index a1067a70a0d..00000000000
--- a/libjava/java/lang/k_tan.c
+++ /dev/null
@@ -1,132 +0,0 @@
-
-/* @(#)k_tan.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* __kernel_tan( x, y, k )
- * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854
- * Input x is assumed to be bounded by ~pi/4 in magnitude.
- * Input y is the tail of x.
- * Input k indicates whether tan (if k=1) or
- * -1/tan (if k= -1) is returned.
- *
- * Algorithm
- * 1. Since tan(-x) = -tan(x), we need only to consider positive x.
- * 2. if x < 2^-28 (hx<0x3e300000 0), return x with inexact if x!=0.
- * 3. tan(x) is approximated by a odd polynomial of degree 27 on
- * [0,0.67434]
- * 3 27
- * tan(x) ~ x + T1*x + ... + T13*x
- * where
- *
- * |tan(x) 2 4 26 | -59.2
- * |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2
- * | x |
- *
- * Note: tan(x+y) = tan(x) + tan'(x)*y
- * ~ tan(x) + (1+x*x)*y
- * Therefore, for better accuracy in computing tan(x+y), let
- * 3 2 2 2 2
- * r = x *(T2+x *(T3+x *(...+x *(T12+x *T13))))
- * then
- * 3 2
- * tan(x+y) = x + (T1*x + (x *(r+y)+y))
- *
- * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then
- * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y))
- * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
-pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */
-pio4lo= 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */
-T[] = {
- 3.33333333333334091986e-01, /* 0x3FD55555, 0x55555563 */
- 1.33333333333201242699e-01, /* 0x3FC11111, 0x1110FE7A */
- 5.39682539762260521377e-02, /* 0x3FABA1BA, 0x1BB341FE */
- 2.18694882948595424599e-02, /* 0x3F9664F4, 0x8406D637 */
- 8.86323982359930005737e-03, /* 0x3F8226E3, 0xE96E8493 */
- 3.59207910759131235356e-03, /* 0x3F6D6D22, 0xC9560328 */
- 1.45620945432529025516e-03, /* 0x3F57DBC8, 0xFEE08315 */
- 5.88041240820264096874e-04, /* 0x3F4344D8, 0xF2F26501 */
- 2.46463134818469906812e-04, /* 0x3F3026F7, 0x1A8D1068 */
- 7.81794442939557092300e-05, /* 0x3F147E88, 0xA03792A6 */
- 7.14072491382608190305e-05, /* 0x3F12B80F, 0x32F0A7E9 */
- -1.85586374855275456654e-05, /* 0xBEF375CB, 0xDB605373 */
- 2.59073051863633712884e-05, /* 0x3EFB2A70, 0x74BF7AD4 */
-};
-
-#ifdef __STDC__
- double __kernel_tan(double x, double y, int iy)
-#else
- double __kernel_tan(x, y, iy)
- double x,y; int iy;
-#endif
-{
- double z,r,v,w,s;
- int32_t ix,hx;
- GET_HIGH_WORD(hx,x);
- ix = hx&0x7fffffff; /* high word of |x| */
- if(ix<0x3e300000) /* x < 2**-28 */
- {if((int)x==0) { /* generate inexact */
- uint32_t low;
- GET_LOW_WORD(low,x);
- if(((ix|low)|(iy+1))==0) return one/fabs(x);
- else return (iy==1)? x: -one/x;
- }
- }
- if(ix>=0x3FE59428) { /* |x|>=0.6744 */
- if(hx<0) {x = -x; y = -y;}
- z = pio4-x;
- w = pio4lo-y;
- x = z+w; y = 0.0;
- }
- z = x*x;
- w = z*z;
- /* Break x^5*(T[1]+x^2*T[2]+...) into
- * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
- * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
- */
- r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11]))));
- v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12])))));
- s = z*x;
- r = y + z*(s*(r+v)+y);
- r += T[0]*s;
- w = x+r;
- if(ix>=0x3FE59428) {
- v = (double)iy;
- return (double)(1-((hx>>30)&2))*(v-2.0*(x-(w*w/(w+v)-r)));
- }
- if(iy==1) return w;
- else { /* if allow error up to 2 ulp,
- simply return -1.0/(x+r) here */
- /* compute -1.0/(x+r) accurately */
- double a,t;
- z = w;
- SET_LOW_WORD(z,0);
- v = r-(z - x); /* z+v = r+x */
- t = a = -1.0/w; /* a = -1.0/w */
- SET_LOW_WORD(t,0);
- s = 1.0+t*z;
- return t+a*(s+t*v);
- }
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/mprec.c b/libjava/java/lang/mprec.c
deleted file mode 100644
index 12dd5d2617a..00000000000
--- a/libjava/java/lang/mprec.c
+++ /dev/null
@@ -1,958 +0,0 @@
-/****************************************************************
- *
- * The author of this software is David M. Gay.
- *
- * Copyright (c) 1991 by AT&T.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software and in all copies of the supporting
- * documentation for such software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
- * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- ***************************************************************/
-
-/* Please send bug reports to
- David M. Gay
- AT&T Bell Laboratories, Room 2C-463
- 600 Mountain Avenue
- Murray Hill, NJ 07974-2070
- U.S.A.
- dmg@research.att.com or research!dmg
- */
-
-/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
- *
- * This strtod returns a nearest machine number to the input decimal
- * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
- * broken by the IEEE round-even rule. Otherwise ties are broken by
- * biased rounding (add half and chop).
- *
- * Inspired loosely by William D. Clinger's paper "How to Read Floating
- * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
- *
- * Modifications:
- *
- * 1. We only require IEEE, IBM, or VAX double-precision
- * arithmetic (not IEEE double-extended).
- * 2. We get by with floating-point arithmetic in a case that
- * Clinger missed -- when we're computing d * 10^n
- * for a small integer d and the integer n is not too
- * much larger than 22 (the maximum integer k for which
- * we can represent 10^k exactly), we may be able to
- * compute (d*10^k) * 10^(e-k) with just one roundoff.
- * 3. Rather than a bit-at-a-time adjustment of the binary
- * result in the hard case, we use floating-point
- * arithmetic to determine the adjustment to within
- * one bit; only in really hard cases do we need to
- * compute a second residual.
- * 4. Because of 3., we don't need a large table of powers of 10
- * for ten-to-e (just some small tables, e.g. of 10^k
- * for 0 <= k <= 22).
- */
-
-/*
- * #define IEEE_8087 for IEEE-arithmetic machines where the least
- * significant byte has the lowest address.
- * #define IEEE_MC68k for IEEE-arithmetic machines where the most
- * significant byte has the lowest address.
- * #define Sudden_Underflow for IEEE-format machines without gradual
- * underflow (i.e., that flush to zero on underflow).
- * #define IBM for IBM mainframe-style floating-point arithmetic.
- * #define VAX for VAX-style floating-point arithmetic.
- * #define Unsigned_Shifts if >> does treats its left operand as unsigned.
- * #define No_leftright to omit left-right logic in fast floating-point
- * computation of dtoa.
- * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.
- * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
- * that use extended-precision instructions to compute rounded
- * products and quotients) with IBM.
- * #define ROUND_BIASED for IEEE-format with biased rounding.
- * #define Inaccurate_Divide for IEEE-format with correctly rounded
- * products but inaccurate quotients, e.g., for Intel i860.
- * #define Just_16 to store 16 bits per 32-bit long when doing high-precision
- * integer arithmetic. Whether this speeds things up or slows things
- * down depends on the machine and the number being converted.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <java-assert.h>
-#include "mprec.h"
-
-/* reent.c knows this value */
-#define _Kmax 15
-#include <stdio.h>
-
-_Jv_Bigint *
-_DEFUN (Balloc, (ptr, k), struct _Jv_reent *ptr _AND int k)
-{
- _Jv_Bigint *rv = NULL;
-
- int i = 0;
- int j = 1;
-
- JvAssert ((1 << k) < MAX_BIGNUM_WDS);
-
- while ((ptr->_allocation_map & j) && i < MAX_BIGNUMS)
- i++, j <<= 1;
-
- JvAssert (i < MAX_BIGNUMS);
-
- if (i >= MAX_BIGNUMS)
- return NULL;
-
- ptr->_allocation_map |= j;
- rv = &ptr->_freelist[i];
-
- rv->_k = k;
- rv->_maxwds = 32;
-
- return rv;
-}
-
-
-void
-_DEFUN (Bfree, (ptr, v), struct _Jv_reent *ptr _AND _Jv_Bigint * v)
-{
- long i;
-
- i = v - ptr->_freelist;
-
- JvAssert (i >= 0 && i < MAX_BIGNUMS);
-
- if (i >= 0 && i < MAX_BIGNUMS)
- ptr->_allocation_map &= ~ (1 << i);
-}
-
-
-_Jv_Bigint *
-_DEFUN (multadd, (ptr, b, m, a),
- struct _Jv_reent *ptr _AND
- _Jv_Bigint * b _AND
- int m _AND
- int a)
-{
- int i, wds;
- unsigned long *x, y;
-#ifdef Pack_32
- unsigned long xi, z;
-#endif
- _Jv_Bigint *b1;
-
- wds = b->_wds;
- x = b->_x;
- i = 0;
- do
- {
-#ifdef Pack_32
- xi = *x;
- y = (xi & 0xffff) * m + a;
- z = (xi >> 16) * m + (y >> 16);
- a = (int) (z >> 16);
- *x++ = (z << 16) + (y & 0xffff);
-#else
- y = *x * m + a;
- a = (int) (y >> 16);
- *x++ = y & 0xffff;
-#endif
- }
- while (++i < wds);
- if (a)
- {
- if (wds >= b->_maxwds)
- {
- b1 = Balloc (ptr, b->_k + 1);
- Bcopy (b1, b);
- Bfree (ptr, b);
- b = b1;
- }
- b->_x[wds++] = a;
- b->_wds = wds;
- }
- return b;
-}
-
-_Jv_Bigint *
-_DEFUN (s2b, (ptr, s, nd0, nd, y9),
- struct _Jv_reent * ptr _AND
- _CONST char *s _AND
- int nd0 _AND
- int nd _AND
- unsigned long y9)
-{
- _Jv_Bigint *b;
- int i, k;
- long x, y;
-
- x = (nd + 8) / 9;
- for (k = 0, y = 1; x > y; y <<= 1, k++);
-#ifdef Pack_32
- b = Balloc (ptr, k);
- b->_x[0] = y9;
- b->_wds = 1;
-#else
- b = Balloc (ptr, k + 1);
- b->_x[0] = y9 & 0xffff;
- b->_wds = (b->_x[1] = y9 >> 16) ? 2 : 1;
-#endif
-
- i = 9;
- if (9 < nd0)
- {
- s += 9;
- do
- b = multadd (ptr, b, 10, *s++ - '0');
- while (++i < nd0);
- s++;
- }
- else
- s += 10;
- for (; i < nd; i++)
- b = multadd (ptr, b, 10, *s++ - '0');
- return b;
-}
-
-int
-_DEFUN (hi0bits,
- (x), register unsigned long x)
-{
- register int k = 0;
-
- if (!(x & 0xffff0000))
- {
- k = 16;
- x <<= 16;
- }
- if (!(x & 0xff000000))
- {
- k += 8;
- x <<= 8;
- }
- if (!(x & 0xf0000000))
- {
- k += 4;
- x <<= 4;
- }
- if (!(x & 0xc0000000))
- {
- k += 2;
- x <<= 2;
- }
- if (!(x & 0x80000000))
- {
- k++;
- if (!(x & 0x40000000))
- return 32;
- }
- return k;
-}
-
-int
-_DEFUN (lo0bits, (y), unsigned long *y)
-{
- register int k;
- register unsigned long x = *y;
-
- if (x & 7)
- {
- if (x & 1)
- return 0;
- if (x & 2)
- {
- *y = x >> 1;
- return 1;
- }
- *y = x >> 2;
- return 2;
- }
- k = 0;
- if (!(x & 0xffff))
- {
- k = 16;
- x >>= 16;
- }
- if (!(x & 0xff))
- {
- k += 8;
- x >>= 8;
- }
- if (!(x & 0xf))
- {
- k += 4;
- x >>= 4;
- }
- if (!(x & 0x3))
- {
- k += 2;
- x >>= 2;
- }
- if (!(x & 1))
- {
- k++;
- x >>= 1;
- if (!x & 1)
- return 32;
- }
- *y = x;
- return k;
-}
-
-_Jv_Bigint *
-_DEFUN (i2b, (ptr, i), struct _Jv_reent * ptr _AND int i)
-{
- _Jv_Bigint *b;
-
- b = Balloc (ptr, 1);
- b->_x[0] = i;
- b->_wds = 1;
- return b;
-}
-
-_Jv_Bigint *
-_DEFUN (mult, (ptr, a, b), struct _Jv_reent * ptr _AND _Jv_Bigint * a _AND _Jv_Bigint * b)
-{
- _Jv_Bigint *c;
- int k, wa, wb, wc;
- unsigned long carry, y, z;
- unsigned long *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
-#ifdef Pack_32
- unsigned long z2;
-#endif
-
- if (a->_wds < b->_wds)
- {
- c = a;
- a = b;
- b = c;
- }
- k = a->_k;
- wa = a->_wds;
- wb = b->_wds;
- wc = wa + wb;
- if (wc > a->_maxwds)
- k++;
- c = Balloc (ptr, k);
- for (x = c->_x, xa = x + wc; x < xa; x++)
- *x = 0;
- xa = a->_x;
- xae = xa + wa;
- xb = b->_x;
- xbe = xb + wb;
- xc0 = c->_x;
-#ifdef Pack_32
- for (; xb < xbe; xb++, xc0++)
- {
- if ((y = *xb & 0xffff))
- {
- x = xa;
- xc = xc0;
- carry = 0;
- do
- {
- z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
- carry = z >> 16;
- z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
- carry = z2 >> 16;
- Storeinc (xc, z2, z);
- }
- while (x < xae);
- *xc = carry;
- }
- if ((y = *xb >> 16))
- {
- x = xa;
- xc = xc0;
- carry = 0;
- z2 = *xc;
- do
- {
- z = (*x & 0xffff) * y + (*xc >> 16) + carry;
- carry = z >> 16;
- Storeinc (xc, z, z2);
- z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
- carry = z2 >> 16;
- }
- while (x < xae);
- *xc = z2;
- }
- }
-#else
- for (; xb < xbe; xc0++)
- {
- if (y = *xb++)
- {
- x = xa;
- xc = xc0;
- carry = 0;
- do
- {
- z = *x++ * y + *xc + carry;
- carry = z >> 16;
- *xc++ = z & 0xffff;
- }
- while (x < xae);
- *xc = carry;
- }
- }
-#endif
- for (xc0 = c->_x, xc = xc0 + wc; wc > 0 && !*--xc; --wc);
- c->_wds = wc;
- return c;
-}
-
-_Jv_Bigint *
-_DEFUN (pow5mult,
- (ptr, b, k), struct _Jv_reent * ptr _AND _Jv_Bigint * b _AND int k)
-{
- _Jv_Bigint *b1, *p5, *p51;
- int i;
- static _CONST int p05[3] = {5, 25, 125};
-
- if ((i = k & 3))
- b = multadd (ptr, b, p05[i - 1], 0);
-
- if (!(k >>= 2))
- return b;
- if (!(p5 = ptr->_p5s))
- {
- /* first time */
- p5 = ptr->_p5s = i2b (ptr, 625);
- p5->_next = 0;
- }
- for (;;)
- {
- if (k & 1)
- {
- b1 = mult (ptr, b, p5);
- Bfree (ptr, b);
- b = b1;
- }
- if (!(k >>= 1))
- break;
- if (!(p51 = p5->_next))
- {
- p51 = p5->_next = mult (ptr, p5, p5);
- p51->_next = 0;
- }
- p5 = p51;
- }
- return b;
-}
-
-_Jv_Bigint *
-_DEFUN (lshift, (ptr, b, k), struct _Jv_reent * ptr _AND _Jv_Bigint * b _AND int k)
-{
- int i, k1, n, n1;
- _Jv_Bigint *b1;
- unsigned long *x, *x1, *xe, z;
-
-#ifdef Pack_32
- n = k >> 5;
-#else
- n = k >> 4;
-#endif
- k1 = b->_k;
- n1 = n + b->_wds + 1;
- for (i = b->_maxwds; n1 > i; i <<= 1)
- k1++;
- b1 = Balloc (ptr, k1);
- x1 = b1->_x;
- for (i = 0; i < n; i++)
- *x1++ = 0;
- x = b->_x;
- xe = x + b->_wds;
-#ifdef Pack_32
- if (k &= 0x1f)
- {
- k1 = 32 - k;
- z = 0;
- do
- {
- *x1++ = *x << k | z;
- z = *x++ >> k1;
- }
- while (x < xe);
- if ((*x1 = z))
- ++n1;
- }
-#else
- if (k &= 0xf)
- {
- k1 = 16 - k;
- z = 0;
- do
- {
- *x1++ = *x << k & 0xffff | z;
- z = *x++ >> k1;
- }
- while (x < xe);
- if (*x1 = z)
- ++n1;
- }
-#endif
- else
- do
- *x1++ = *x++;
- while (x < xe);
- b1->_wds = n1 - 1;
- Bfree (ptr, b);
- return b1;
-}
-
-int
-_DEFUN (cmp, (a, b), _Jv_Bigint * a _AND _Jv_Bigint * b)
-{
- unsigned long *xa, *xa0, *xb, *xb0;
- int i, j;
-
- i = a->_wds;
- j = b->_wds;
-#ifdef DEBUG
- if (i > 1 && !a->_x[i - 1])
- Bug ("cmp called with a->_x[a->_wds-1] == 0");
- if (j > 1 && !b->_x[j - 1])
- Bug ("cmp called with b->_x[b->_wds-1] == 0");
-#endif
- if (i -= j)
- return i;
- xa0 = a->_x;
- xa = xa0 + j;
- xb0 = b->_x;
- xb = xb0 + j;
- for (;;)
- {
- if (*--xa != *--xb)
- return *xa < *xb ? -1 : 1;
- if (xa <= xa0)
- break;
- }
- return 0;
-}
-
-_Jv_Bigint *
-_DEFUN (diff, (ptr, a, b), struct _Jv_reent * ptr _AND
- _Jv_Bigint * a _AND _Jv_Bigint * b)
-{
- _Jv_Bigint *c;
- int i, wa, wb;
- long borrow, y; /* We need signed shifts here. */
- unsigned long *xa, *xae, *xb, *xbe, *xc;
-#ifdef Pack_32
- long z;
-#endif
-
- i = cmp (a, b);
- if (!i)
- {
- c = Balloc (ptr, 0);
- c->_wds = 1;
- c->_x[0] = 0;
- return c;
- }
- if (i < 0)
- {
- c = a;
- a = b;
- b = c;
- i = 1;
- }
- else
- i = 0;
- c = Balloc (ptr, a->_k);
- c->_sign = i;
- wa = a->_wds;
- xa = a->_x;
- xae = xa + wa;
- wb = b->_wds;
- xb = b->_x;
- xbe = xb + wb;
- xc = c->_x;
- borrow = 0;
-#ifdef Pack_32
- do
- {
- y = (*xa & 0xffff) - (*xb & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend (borrow, y);
- z = (*xa++ >> 16) - (*xb++ >> 16) + borrow;
- borrow = z >> 16;
- Sign_Extend (borrow, z);
- Storeinc (xc, z, y);
- }
- while (xb < xbe);
- while (xa < xae)
- {
- y = (*xa & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend (borrow, y);
- z = (*xa++ >> 16) + borrow;
- borrow = z >> 16;
- Sign_Extend (borrow, z);
- Storeinc (xc, z, y);
- }
-#else
- do
- {
- y = *xa++ - *xb++ + borrow;
- borrow = y >> 16;
- Sign_Extend (borrow, y);
- *xc++ = y & 0xffff;
- }
- while (xb < xbe);
- while (xa < xae)
- {
- y = *xa++ + borrow;
- borrow = y >> 16;
- Sign_Extend (borrow, y);
- *xc++ = y & 0xffff;
- }
-#endif
- while (!*--xc)
- wa--;
- c->_wds = wa;
- return c;
-}
-
-double
-_DEFUN (ulp, (_x), double _x)
-{
- union double_union x, a;
- register long L;
-
- x.d = _x;
-
- L = (word0 (x) & Exp_mask) - (P - 1) * Exp_msk1;
-#ifndef Sudden_Underflow
- if (L > 0)
- {
-#endif
-#ifdef IBM
- L |= Exp_msk1 >> 4;
-#endif
- word0 (a) = L;
-#ifndef _DOUBLE_IS_32BITS
- word1 (a) = 0;
-#endif
-
-#ifndef Sudden_Underflow
- }
- else
- {
- L = -L >> Exp_shift;
- if (L < Exp_shift)
- {
- word0 (a) = 0x80000 >> L;
-#ifndef _DOUBLE_IS_32BITS
- word1 (a) = 0;
-#endif
- }
- else
- {
- word0 (a) = 0;
- L -= Exp_shift;
-#ifndef _DOUBLE_IS_32BITS
- word1 (a) = L >= 31 ? 1 : 1 << (31 - L);
-#endif
- }
- }
-#endif
- return a.d;
-}
-
-double
-_DEFUN (b2d, (a, e),
- _Jv_Bigint * a _AND int *e)
-{
- unsigned long *xa, *xa0, w, y, z;
- int k;
- union double_union d;
-#ifdef VAX
- unsigned long d0, d1;
-#else
-#define d0 word0(d)
-#define d1 word1(d)
-#endif
-
- xa0 = a->_x;
- xa = xa0 + a->_wds;
- y = *--xa;
-#ifdef DEBUG
- if (!y)
- Bug ("zero y in b2d");
-#endif
- k = hi0bits (y);
- *e = 32 - k;
-#ifdef Pack_32
- if (k < Ebits)
- {
- d0 = Exp_1 | y >> (Ebits - k);
- w = xa > xa0 ? *--xa : 0;
-#ifndef _DOUBLE_IS_32BITS
- d1 = y << (32 - Ebits + k) | w >> (Ebits - k);
-#endif
- goto ret_d;
- }
- z = xa > xa0 ? *--xa : 0;
- if (k -= Ebits)
- {
- d0 = Exp_1 | y << k | z >> (32 - k);
- y = xa > xa0 ? *--xa : 0;
-#ifndef _DOUBLE_IS_32BITS
- d1 = z << k | y >> (32 - k);
-#endif
- }
- else
- {
- d0 = Exp_1 | y;
-#ifndef _DOUBLE_IS_32BITS
- d1 = z;
-#endif
- }
-#else
- if (k < Ebits + 16)
- {
- z = xa > xa0 ? *--xa : 0;
- d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;
- w = xa > xa0 ? *--xa : 0;
- y = xa > xa0 ? *--xa : 0;
- d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;
- goto ret_d;
- }
- z = xa > xa0 ? *--xa : 0;
- w = xa > xa0 ? *--xa : 0;
- k -= Ebits + 16;
- d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
- y = xa > xa0 ? *--xa : 0;
- d1 = w << k + 16 | y << k;
-#endif
-ret_d:
-#ifdef VAX
- word0 (d) = d0 >> 16 | d0 << 16;
- word1 (d) = d1 >> 16 | d1 << 16;
-#else
-#undef d0
-#undef d1
-#endif
- return d.d;
-}
-
-_Jv_Bigint *
-_DEFUN (d2b,
- (ptr, _d, e, bits),
- struct _Jv_reent * ptr _AND
- double _d _AND
- int *e _AND
- int *bits)
-
-{
- union double_union d;
- _Jv_Bigint *b;
- int de, i, k;
- unsigned long *x, y, z;
-#ifdef VAX
- unsigned long d0, d1;
- d.d = _d;
- d0 = word0 (d) >> 16 | word0 (d) << 16;
- d1 = word1 (d) >> 16 | word1 (d) << 16;
-#else
-#define d0 word0(d)
-#define d1 word1(d)
- d.d = _d;
-#endif
-
-#ifdef Pack_32
- b = Balloc (ptr, 1);
-#else
- b = Balloc (ptr, 2);
-#endif
- x = b->_x;
-
- z = d0 & Frac_mask;
- d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
-#ifdef Sudden_Underflow
- de = (int) (d0 >> Exp_shift);
-#ifndef IBM
- z |= Exp_msk11;
-#endif
-#else
- if ((de = (int) (d0 >> Exp_shift)))
- z |= Exp_msk1;
-#endif
-#ifdef Pack_32
-#ifndef _DOUBLE_IS_32BITS
- if ((y = d1))
- {
- if ((k = lo0bits (&y)))
- {
- x[0] = y | z << (32 - k);
- z >>= k;
- }
- else
- x[0] = y;
- i = b->_wds = (x[1] = z) ? 2 : 1;
- }
- else
-#endif
- {
-#ifdef DEBUG
- if (!z)
- Bug ("Zero passed to d2b");
-#endif
- k = lo0bits (&z);
- x[0] = z;
- i = b->_wds = 1;
-#ifndef _DOUBLE_IS_32BITS
- k += 32;
-#endif
- }
-#else
- if (y = d1)
- {
- if (k = lo0bits (&y))
- if (k >= 16)
- {
- x[0] = y | z << 32 - k & 0xffff;
- x[1] = z >> k - 16 & 0xffff;
- x[2] = z >> k;
- i = 2;
- }
- else
- {
- x[0] = y & 0xffff;
- x[1] = y >> 16 | z << 16 - k & 0xffff;
- x[2] = z >> k & 0xffff;
- x[3] = z >> k + 16;
- i = 3;
- }
- else
- {
- x[0] = y & 0xffff;
- x[1] = y >> 16;
- x[2] = z & 0xffff;
- x[3] = z >> 16;
- i = 3;
- }
- }
- else
- {
-#ifdef DEBUG
- if (!z)
- Bug ("Zero passed to d2b");
-#endif
- k = lo0bits (&z);
- if (k >= 16)
- {
- x[0] = z;
- i = 0;
- }
- else
- {
- x[0] = z & 0xffff;
- x[1] = z >> 16;
- i = 1;
- }
- k += 32;
- }
- while (!x[i])
- --i;
- b->_wds = i + 1;
-#endif
-#ifndef Sudden_Underflow
- if (de)
- {
-#endif
-#ifdef IBM
- *e = (de - Bias - (P - 1) << 2) + k;
- *bits = 4 * P + 8 - k - hi0bits (word0 (d) & Frac_mask);
-#else
- *e = de - Bias - (P - 1) + k;
- *bits = P - k;
-#endif
-#ifndef Sudden_Underflow
- }
- else
- {
- *e = de - Bias - (P - 1) + 1 + k;
-#ifdef Pack_32
- *bits = 32 * i - hi0bits (x[i - 1]);
-#else
- *bits = (i + 2) * 16 - hi0bits (x[i]);
-#endif
- }
-#endif
- return b;
-}
-#undef d0
-#undef d1
-
-double
-_DEFUN (ratio, (a, b), _Jv_Bigint * a _AND _Jv_Bigint * b)
-
-{
- union double_union da, db;
- int k, ka, kb;
-
- da.d = b2d (a, &ka);
- db.d = b2d (b, &kb);
-#ifdef Pack_32
- k = ka - kb + 32 * (a->_wds - b->_wds);
-#else
- k = ka - kb + 16 * (a->_wds - b->_wds);
-#endif
-#ifdef IBM
- if (k > 0)
- {
- word0 (da) += (k >> 2) * Exp_msk1;
- if (k &= 3)
- da.d *= 1 << k;
- }
- else
- {
- k = -k;
- word0 (db) += (k >> 2) * Exp_msk1;
- if (k &= 3)
- db.d *= 1 << k;
- }
-#else
- if (k > 0)
- word0 (da) += k * Exp_msk1;
- else
- {
- k = -k;
- word0 (db) += k * Exp_msk1;
- }
-#endif
- return da.d / db.d;
-}
-
-
-_CONST double
- tens[] =
-{
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
- 1e20, 1e21, 1e22, 1e23, 1e24
-
-};
-
-#if !defined(_DOUBLE_IS_32BITS) && !defined(__v800)
-_CONST double bigtens[] =
-{1e16, 1e32, 1e64, 1e128, 1e256};
-
-_CONST double tinytens[] =
-{1e-16, 1e-32, 1e-64, 1e-128, 1e-256};
-#else
-_CONST double bigtens[] =
-{1e16, 1e32};
-
-_CONST double tinytens[] =
-{1e-16, 1e-32};
-#endif
-
-
diff --git a/libjava/java/lang/mprec.h b/libjava/java/lang/mprec.h
deleted file mode 100644
index 4baac323ad3..00000000000
--- a/libjava/java/lang/mprec.h
+++ /dev/null
@@ -1,401 +0,0 @@
-/****************************************************************
- *
- * The author of this software is David M. Gay.
- *
- * Copyright (c) 1991, 2000 by AT&T.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software and in all copies of the supporting
- * documentation for such software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
- * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- ***************************************************************/
-
-/* Please send bug reports to
- David M. Gay
- AT&T Bell Laboratories, Room 2C-463
- 600 Mountain Avenue
- Murray Hill, NJ 07974-2070
- U.S.A.
- dmg@research.att.com or research!dmg
- */
-
-#include <config.h>
-#include "ieeefp.h"
-
-#include <math.h>
-// #include <float.h>
-// #include <errno.h>
-
-#if defined HAVE_STDINT_H
-#include <stdint.h>
-#elif defined HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-
-#if defined HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#if defined HAVE_SYS_CONFIG_H
-#include <sys/config.h>
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* ISO C9X int type declarations */
-
-#if !defined HAVE_INT32_DEFINED && defined HAVE_BSD_INT32_DEFINED
-typedef u_int32_t uint32_t;
-#endif
-
-#if !defined HAVE_BSD_INT32_DEFINED && !defined HAVE_INT32_DEFINED
-// FIXME -- this could have problems with systems that don't define SI to be 4
-typedef int int32_t __attribute__((mode(SI)));
-
-/* This is a blatant hack: on Solaris 2.5, pthread.h defines uint32_t
- in pthread.h, which we sometimes include. We protect our
- definition the same way Solaris 2.5 does, to avoid redefining it. */
-# ifndef _UINT32_T
-typedef unsigned int uint32_t __attribute__((mode(SI)));
-# endif
-#endif
-
- /* These typedefs are true for the targets running Java. */
-
-#ifdef __IEEE_LITTLE_ENDIAN
-#define IEEE_8087
-#endif
-
-#ifdef __IEEE_BIG_ENDIAN
-#define IEEE_MC68k
-#endif
-
-#ifdef __Z8000__
-#define Just_16
-#endif
-
-#ifdef DEBUG
-#include "stdio.h"
-#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
-#endif
-
-
-#ifdef Unsigned_Shifts
-#define Sign_Extend(a,b) if (b < 0) a |= (uint32_t)0xffff0000;
-#else
-#define Sign_Extend(a,b) /*no-op*/
-#endif
-
-#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
-Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
-#endif
-
-/* If we are going to examine or modify specific bits in a double using
- the word0 and/or word1 macros, then we must wrap the double inside
- a union. This is necessary to avoid undefined behavior according to
- the ANSI C spec. */
-union double_union
-{
- double d;
- uint32_t i[2];
-};
-
-#ifdef IEEE_8087
-#define word0(x) (x.i[1])
-#define word1(x) (x.i[0])
-#else
-#define word0(x) (x.i[0])
-#define word1(x) (x.i[1])
-#endif
-
-/* The following definition of Storeinc is appropriate for MIPS processors.
- * An alternative that might be better on some machines is
- * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
- */
-#if defined(IEEE_8087) + defined(VAX)
-#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
-((unsigned short *)a)[0] = (unsigned short)c, a++)
-#else
-#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
-((unsigned short *)a)[1] = (unsigned short)c, a++)
-#endif
-
-/* #define P DBL_MANT_DIG */
-/* Ten_pmax = floor(P*log(2)/log(5)) */
-/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
-/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
-/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
-
-#if defined(IEEE_8087) + defined(IEEE_MC68k)
-#if defined (_DOUBLE_IS_32BITS)
-#define Exp_shift 23
-#define Exp_shift1 23
-#define Exp_msk1 ((uint32_t)0x00800000L)
-#define Exp_msk11 ((uint32_t)0x00800000L)
-#define Exp_mask ((uint32_t)0x7f800000L)
-#define P 24
-#define Bias 127
-#if 0
-#define IEEE_Arith /* it is, but the code doesn't handle IEEE singles yet */
-#endif
-#define Emin (-126)
-#define Exp_1 ((uint32_t)0x3f800000L)
-#define Exp_11 ((uint32_t)0x3f800000L)
-#define Ebits 8
-#define Frac_mask ((uint32_t)0x007fffffL)
-#define Frac_mask1 ((uint32_t)0x007fffffL)
-#define Ten_pmax 10
-#define Sign_bit ((uint32_t)0x80000000L)
-#define Ten_pmax 10
-#define Bletch 2
-#define Bndry_mask ((uint32_t)0x007fffffL)
-#define Bndry_mask1 ((uint32_t)0x007fffffL)
-#define LSB 1
-#define Sign_bit ((uint32_t)0x80000000L)
-#define Log2P 1
-#define Tiny0 0
-#define Tiny1 1
-#define Quick_max 5
-#define Int_max 6
-#define Infinite(x) (word0(x) == ((uint32_t)0x7f800000L))
-#undef word0
-#undef word1
-
-#define word0(x) (x.i[0])
-#define word1(x) 0
-#else
-
-#define Exp_shift 20
-#define Exp_shift1 20
-#define Exp_msk1 ((uint32_t)0x100000L)
-#define Exp_msk11 ((uint32_t)0x100000L)
-#define Exp_mask ((uint32_t)0x7ff00000L)
-#define P 53
-#define Bias 1023
-#define IEEE_Arith
-#define Emin (-1022)
-#define Exp_1 ((uint32_t)0x3ff00000L)
-#define Exp_11 ((uint32_t)0x3ff00000L)
-#define Ebits 11
-#define Frac_mask ((uint32_t)0xfffffL)
-#define Frac_mask1 ((uint32_t)0xfffffL)
-#define Ten_pmax 22
-#define Bletch 0x10
-#define Bndry_mask ((uint32_t)0xfffffL)
-#define Bndry_mask1 ((uint32_t)0xfffffL)
-#define LSB 1
-#define Sign_bit ((uint32_t)0x80000000L)
-#define Log2P 1
-#define Tiny0 0
-#define Tiny1 1
-#define Quick_max 14
-#define Int_max 14
-#define Infinite(x) (word0(x) == ((uint32_t)0x7ff00000L)) /* sufficient test for here */
-#endif
-
-#else
-#undef Sudden_Underflow
-#define Sudden_Underflow
-#ifdef IBM
-#define Exp_shift 24
-#define Exp_shift1 24
-#define Exp_msk1 ((uint32_t)0x1000000L)
-#define Exp_msk11 ((uint32_t)0x1000000L)
-#define Exp_mask ((uint32_t)0x7f000000L)
-#define P 14
-#define Bias 65
-#define Exp_1 ((uint32_t)0x41000000L)
-#define Exp_11 ((uint32_t)0x41000000L)
-#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
-#define Frac_mask ((uint32_t)0xffffffL)
-#define Frac_mask1 ((uint32_t)0xffffffL)
-#define Bletch 4
-#define Ten_pmax 22
-#define Bndry_mask ((uint32_t)0xefffffL)
-#define Bndry_mask1 ((uint32_t)0xffffffL)
-#define LSB 1
-#define Sign_bit ((uint32_t)0x80000000L)
-#define Log2P 4
-#define Tiny0 ((uint32_t)0x100000L)
-#define Tiny1 0
-#define Quick_max 14
-#define Int_max 15
-#else /* VAX */
-#define Exp_shift 23
-#define Exp_shift1 7
-#define Exp_msk1 0x80
-#define Exp_msk11 ((uint32_t)0x800000L)
-#define Exp_mask ((uint32_t)0x7f80L)
-#define P 56
-#define Bias 129
-#define Exp_1 ((uint32_t)0x40800000L)
-#define Exp_11 ((uint32_t)0x4080L)
-#define Ebits 8
-#define Frac_mask ((uint32_t)0x7fffffL)
-#define Frac_mask1 ((uint32_t)0xffff007fL)
-#define Ten_pmax 24
-#define Bletch 2
-#define Bndry_mask ((uint32_t)0xffff007fL)
-#define Bndry_mask1 ((uint32_t)0xffff007fL)
-#define LSB ((uint32_t)0x10000L)
-#define Sign_bit ((uint32_t)0x8000L)
-#define Log2P 1
-#define Tiny0 0x80
-#define Tiny1 0
-#define Quick_max 15
-#define Int_max 15
-#endif
-#endif
-
-#ifndef IEEE_Arith
-#define ROUND_BIASED
-#endif
-
-#ifdef RND_PRODQUOT
-#define rounded_product(a,b) a = rnd_prod(a, b)
-#define rounded_quotient(a,b) a = rnd_quot(a, b)
-#ifdef KR_headers
-extern double rnd_prod(), rnd_quot();
-#else
-extern double rnd_prod(double, double), rnd_quot(double, double);
-#endif
-#else
-#define rounded_product(a,b) a *= b
-#define rounded_quotient(a,b) a /= b
-#endif
-
-#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
-#define Big1 ((uint32_t)0xffffffffL)
-
-#ifndef Just_16
-/* When Pack_32 is not defined, we store 16 bits per 32-bit long.
- * This makes some inner loops simpler and sometimes saves work
- * during multiplications, but it often seems to make things slightly
- * slower. Hence the default is now to store 32 bits per long.
- */
-
-#ifndef Pack_32
-#if SIZEOF_VOID_P != 8
-#define Pack_32
-#endif
-#endif
-#endif
-
-
-#define MAX_BIGNUMS 16
-#define MAX_BIGNUM_WDS 32
-
-struct _Jv_Bigint
-{
- struct _Jv_Bigint *_next;
- int _k, _maxwds, _sign, _wds;
- unsigned long _x[MAX_BIGNUM_WDS];
-};
-
-
-#define _PTR void *
-#define _AND ,
-#define _NOARGS void
-#define _CONST const
-#define _VOLATILE volatile
-#define _SIGNED signed
-#define _DOTS , ...
-#define _VOID void
-#define _EXFUN(name, proto) name proto
-#define _DEFUN(name, arglist, args) name(args)
-#define _DEFUN_VOID(name) name(_NOARGS)
-#define _CAST_VOID (void)
-
-
-struct _Jv_reent
-{
- /* local copy of errno */
- int _errno;
-
- /* used by mprec routines */
- struct _Jv_Bigint *_result;
- int _result_k;
- struct _Jv_Bigint *_p5s;
-
- struct _Jv_Bigint _freelist[MAX_BIGNUMS];
- int _allocation_map;
-
- int num;
-};
-
-
-typedef struct _Jv_Bigint _Jv_Bigint;
-
-#define Balloc _Jv_Balloc
-#define Bfree _Jv_Bfree
-#define multadd _Jv_multadd
-#define s2b _Jv_s2b
-#define lo0bits _Jv_lo0bits
-#define hi0bits _Jv_hi0bits
-#define i2b _Jv_i2b
-#define mult _Jv_mult
-#define pow5mult _Jv_pow5mult
-#define lshift _Jv_lshift
-#define cmp _Jv__mcmp
-#define diff _Jv__mdiff
-#define ulp _Jv_ulp
-#define b2d _Jv_b2d
-#define d2b _Jv_d2b
-#define ratio _Jv_ratio
-
-#define tens _Jv__mprec_tens
-#define bigtens _Jv__mprec_bigtens
-#define tinytens _Jv__mprec_tinytens
-
-#define _dtoa _Jv_dtoa
-#define _dtoa_r _Jv_dtoa_r
-#define _strtod_r _Jv_strtod_r
-
-extern double _EXFUN(_strtod_r, (struct _Jv_reent *ptr, const char *s00, char **se));
-extern char* _EXFUN(_dtoa_r, (struct _Jv_reent *ptr, double d,
- int mode, int ndigits, int *decpt, int *sign,
- char **rve, int float_type));
-void _EXFUN(_dtoa, (double d, int mode, int ndigits, int *decpt, int *sign,
- char **rve, char *buf, int float_type));
-
-double _EXFUN(ulp,(double x));
-double _EXFUN(b2d,(_Jv_Bigint *a , int *e));
-_Jv_Bigint * _EXFUN(Balloc,(struct _Jv_reent *p, int k));
-void _EXFUN(Bfree,(struct _Jv_reent *p, _Jv_Bigint *v));
-_Jv_Bigint * _EXFUN(multadd,(struct _Jv_reent *p, _Jv_Bigint *, int, int));
-_Jv_Bigint * _EXFUN(s2b,(struct _Jv_reent *, const char*, int, int, unsigned long));
-_Jv_Bigint * _EXFUN(i2b,(struct _Jv_reent *,int));
-_Jv_Bigint * _EXFUN(mult, (struct _Jv_reent *, _Jv_Bigint *, _Jv_Bigint *));
-_Jv_Bigint * _EXFUN(pow5mult, (struct _Jv_reent *, _Jv_Bigint *, int k));
-int _EXFUN(hi0bits,(unsigned long));
-int _EXFUN(lo0bits,(unsigned long *));
-_Jv_Bigint * _EXFUN(d2b,(struct _Jv_reent *p, double d, int *e, int *bits));
-_Jv_Bigint * _EXFUN(lshift,(struct _Jv_reent *p, _Jv_Bigint *b, int k));
-_Jv_Bigint * _EXFUN(diff,(struct _Jv_reent *p, _Jv_Bigint *a, _Jv_Bigint *b));
-int _EXFUN(cmp,(_Jv_Bigint *a, _Jv_Bigint *b));
-
-double _EXFUN(ratio,(_Jv_Bigint *a, _Jv_Bigint *b));
-#define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(long) + 2*sizeof(int))
-
-#if defined(_DOUBLE_IS_32BITS) && defined(__v800)
-#define n_bigtens 2
-#else
-#define n_bigtens 5
-#endif
-
-extern _CONST double tinytens[];
-extern _CONST double bigtens[];
-extern _CONST double tens[];
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/libjava/java/lang/natCharacter.cc b/libjava/java/lang/natCharacter.cc
deleted file mode 100644
index 14e0ebf2b7f..00000000000
--- a/libjava/java/lang/natCharacter.cc
+++ /dev/null
@@ -1,284 +0,0 @@
-// natCharacter.cc - Native part of Character class.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/lang/Character.h>
-
-#include <java-chartables.h>
-
-
-
-#define asize(x) ((sizeof (x)) / sizeof (x[0]))
-
-static jchar
-to_lower_title (jchar ch)
-{
- for (unsigned int i = 0; i < asize (title_to_upper_table); ++i)
- {
- // We can assume that the entries in the two tables are
- // parallel. This is checked in the script.
- if (title_to_upper_table[i][1] == ch
- || title_to_upper_table[i][0] == ch)
- return title_to_lower_table[i][1];
- }
- return ch;
-}
-
-static jchar
-to_upper_title (jchar ch)
-{
- for (unsigned int i = 0; i < asize (title_to_lower_table); ++i)
- {
- // We can assume that the entries in the two tables are
- // parallel. This is checked in the script.
- if (title_to_lower_table[i][1] == ch
- || title_to_lower_table[i][0] == ch)
- return title_to_upper_table[i][1];
- }
- return ch;
-}
-
-jboolean
-java::lang::Character::isTitleCase (jchar ch)
-{
- for (unsigned int i = 0; i < asize (title_to_lower_table); ++i)
- {
- if (title_to_lower_table[i][0] == ch)
- return true;
- }
- return false;
-}
-
-jchar
-java::lang::Character::toTitleCase (jchar ch)
-{
- // Both titlecase mapping tables have the same length. This is
- // checked in the chartables script.
- for (unsigned int i = 0; i < asize (title_to_lower_table); ++i)
- {
- if (title_to_lower_table[i][0] == ch)
- return ch;
- if (title_to_lower_table[i][1] == ch)
- return title_to_lower_table[i][0];
- if (title_to_upper_table[i][1] == ch)
- return title_to_upper_table[i][0];
- }
- return toUpperCase (ch);
-}
-
-#ifdef COMPACT_CHARACTER
-
-static int
-table_search (const jchar table[][2], int table_len, jchar ch)
-{
- int low, high, i, old;
-
- low = 0;
- high = table_len;
- i = high / 2;
-
- while (true)
- {
- if (ch < table[i][0])
- high = i;
- else if (ch > table[i][1])
- low = i;
- else
- return i;
-
- old = i;
- i = (high + low) / 2;
- if (i == old)
- break;
- }
-
- return -1;
-}
-
-jint
-java::lang::Character::digit_value (jchar ch)
-{
- int index = table_search (digit_table, asize (digit_table), ch);
- if (index == -1)
- return -1;
-
- jchar base = digit_table[index][0];
- // Tamil doesn't have a digit `0'. So we special-case it here.
- if (base == TAMIL_DIGIT_ONE)
- return ch - base + 1;
- return ch - base;
-}
-
-jint
-java::lang::Character::getNumericValue (jchar ch)
-{
- jint d = digit (ch, 36);
- if (d != -1)
- return d;
-
- for (unsigned int i = 0; i < asize (numeric_table); ++i)
- {
- if (numeric_table[i] == ch)
- return numeric_value[i];
- }
-
- return -1;
-}
-
-jint
-java::lang::Character::getType (jchar ch)
-{
- int index = table_search (all_table, asize (all_table), ch);
- if (index != -1)
- return category_table[index];
- return UNASSIGNED;
-}
-
-jboolean
-java::lang::Character::isLowerCase (jchar ch)
-{
- if (ch >= 0x2000 && ch <= 0x2fff)
- return false;
- if (table_search (lower_case_table, asize (lower_case_table), ch) != -1)
- return true;
-
- int low, high, i, old;
-
- low = 0;
- high = asize (lower_anomalous_table);
- i = high / 2;
-
- while (true)
- {
- if (ch < lower_anomalous_table[i])
- high = i;
- else if (ch > lower_anomalous_table[i])
- low = i;
- else
- return true;
-
- old = i;
- i = (high + low) / 2;
- if (i == old)
- break;
- }
-
- return false;
-}
-
-jboolean
-java::lang::Character::isSpaceChar (jchar ch)
-{
- return table_search (space_table, asize (space_table), ch) != -1;
-}
-
-jboolean
-java::lang::Character::isUpperCase (jchar ch)
-{
- if (ch >= 0x2000 && ch <= 0x2fff)
- return false;
- return table_search (upper_case_table, asize (upper_case_table), ch) != -1;
-}
-
-jchar
-java::lang::Character::toLowerCase (jchar ch)
-{
- int index = table_search (upper_case_table, asize (upper_case_table), ch);
- if (index == -1)
- return to_lower_title (ch);
- return (jchar) (ch - upper_case_table[index][0]
- + upper_case_map_table[index]);
-}
-
-jchar
-java::lang::Character::toUpperCase (jchar ch)
-{
- int index = table_search (lower_case_table, asize (lower_case_table), ch);
- if (index == -1)
- return to_upper_title (ch);
- return (jchar) (ch - lower_case_table[index][0]
- + lower_case_map_table[index]);
-}
-
-#else /* COMPACT_CHARACTER */
-
-jint
-java::lang::Character::digit_value (jchar ch)
-{
- if (type_table[ch] == DECIMAL_DIGIT_NUMBER)
- return attribute_table[ch];
- return -1;
-}
-
-jint
-java::lang::Character::getNumericValue (jchar ch)
-{
- jint d = digit (ch, 36);
- if (d != -1)
- return d;
-
- // Some characters require two attributes. We special-case them here.
- if (ch >= ROMAN_START && ch <= ROMAN_END)
- return secondary_attribute_table[ch - ROMAN_START];
- if (type_table[ch] == LETTER_NUMBER || type_table[ch] == OTHER_NUMBER)
- return attribute_table[ch];
- return -1;
-}
-
-jint
-java::lang::Character::getType (jchar ch)
-{
- return type_table[ch];
-}
-
-jboolean
-java::lang::Character::isLowerCase (jchar ch)
-{
- if (ch >= 0x2000 && ch <= 0x2fff)
- return false;
- return type_table[ch] == LOWERCASE_LETTER;
-}
-
-jboolean
-java::lang::Character::isSpaceChar (jchar ch)
-{
- return (type_table[ch] == SPACE_SEPARATOR
- || type_table[ch] == LINE_SEPARATOR
- || type_table[ch] == PARAGRAPH_SEPARATOR);
-}
-
-jboolean
-java::lang::Character::isUpperCase (jchar ch)
-{
- if (ch >= 0x2000 && ch <= 0x2fff)
- return false;
- return type_table[ch] == UPPERCASE_LETTER;
-}
-
-jchar
-java::lang::Character::toLowerCase (jchar ch)
-{
- if (type_table[ch] == UPPERCASE_LETTER)
- return attribute_table[ch];
- return to_lower_title (ch);
-}
-
-jchar
-java::lang::Character::toUpperCase (jchar ch)
-{
- if (type_table[ch] == LOWERCASE_LETTER)
- return attribute_table[ch];
- return to_upper_title (ch);
-}
-
-#endif /* COMPACT_CHARACTER */
diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc
deleted file mode 100644
index 32849927226..00000000000
--- a/libjava/java/lang/natClass.cc
+++ /dev/null
@@ -1,1303 +0,0 @@
-// natClass.cc - Implementation of java.lang.Class native methods.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <limits.h>
-#include <string.h>
-
-#pragma implementation "Class.h"
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java-threads.h>
-
-#include <java/lang/Class.h>
-#include <java/lang/ClassLoader.h>
-#include <java/lang/String.h>
-#include <java/lang/reflect/Modifier.h>
-#include <java/lang/reflect/Member.h>
-#include <java/lang/reflect/Method.h>
-#include <java/lang/reflect/Field.h>
-#include <java/lang/reflect/Constructor.h>
-#include <java/lang/AbstractMethodError.h>
-#include <java/lang/ArrayStoreException.h>
-#include <java/lang/ClassCastException.h>
-#include <java/lang/ClassNotFoundException.h>
-#include <java/lang/ExceptionInInitializerError.h>
-#include <java/lang/IllegalAccessException.h>
-#include <java/lang/IllegalAccessError.h>
-#include <java/lang/IncompatibleClassChangeError.h>
-#include <java/lang/InstantiationException.h>
-#include <java/lang/NoClassDefFoundError.h>
-#include <java/lang/NoSuchFieldException.h>
-#include <java/lang/NoSuchMethodError.h>
-#include <java/lang/NoSuchMethodException.h>
-#include <java/lang/Thread.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/System.h>
-#include <java/lang/SecurityManager.h>
-#include <java/lang/StringBuffer.h>
-#include <gcj/method.h>
-
-#include <java-cpool.h>
-
-
-
-#define CloneableClass _CL_Q34java4lang9Cloneable
-extern java::lang::Class CloneableClass;
-#define ObjectClass _CL_Q34java4lang6Object
-extern java::lang::Class ObjectClass;
-#define ErrorClass _CL_Q34java4lang5Error
-extern java::lang::Class ErrorClass;
-#define ClassClass _CL_Q34java4lang5Class
-extern java::lang::Class ClassClass;
-#define MethodClass _CL_Q44java4lang7reflect6Method
-extern java::lang::Class MethodClass;
-#define FieldClass _CL_Q44java4lang7reflect5Field
-extern java::lang::Class FieldClass;
-#define ConstructorClass _CL_Q44java4lang7reflect11Constructor
-extern java::lang::Class ConstructorClass;
-
-// Some constants we use to look up the class initializer.
-static _Jv_Utf8Const *void_signature = _Jv_makeUtf8Const ("()V", 3);
-static _Jv_Utf8Const *clinit_name = _Jv_makeUtf8Const ("<clinit>", 8);
-static _Jv_Utf8Const *init_name = _Jv_makeUtf8Const ("<init>", 6);
-static _Jv_Utf8Const *finit_name = _Jv_makeUtf8Const ("$finit$", 7);
-
-
-
-jclass
-java::lang::Class::forName (jstring className)
-{
- if (! className)
- JvThrow (new java::lang::NullPointerException);
-
-#if 0
- // FIXME: should check syntax of CLASSNAME and throw
- // IllegalArgumentException on failure.
-
- // FIXME: should use class loader from calling method.
- jclass klass = _Jv_FindClass (className, NULL);
-#else
- jsize length = _Jv_GetStringUTFLength (className);
- char buffer[length];
- _Jv_GetStringUTFRegion (className, 0, length, buffer);
-
- // FIXME: should check syntax of CLASSNAME and throw
- // IllegalArgumentException on failure.
- _Jv_Utf8Const *name = _Jv_makeUtf8Const (buffer, length);
-
- // FIXME: should use class loader from calling method.
- jclass klass = (buffer[0] == '['
- ? _Jv_FindClassFromSignature (name->data, NULL)
- : _Jv_FindClass (name, NULL));
-#endif
- if (! klass)
- JvThrow (new java::lang::ClassNotFoundException (className));
-
- return klass;
-}
-
-java::lang::reflect::Constructor *
-java::lang::Class::getConstructor (JArray<jclass> *param_types)
-{
- jstring partial_sig = getSignature (param_types, true);
- jint hash = partial_sig->hashCode ();
-
- int i = isPrimitive () ? 0 : method_count;
- while (--i >= 0)
- {
- // FIXME: access checks.
- if (_Jv_equalUtf8Consts (methods[i].name, init_name)
- && _Jv_equal (methods[i].signature, partial_sig, hash))
- {
- // Found it. For getConstructor, the constructor must be
- // public.
- using namespace java::lang::reflect;
- if (! Modifier::isPublic(methods[i].accflags))
- break;
- Constructor *cons = new Constructor ();
- cons->offset = (char *) (&methods[i]) - (char *) methods;
- cons->declaringClass = this;
- return cons;
- }
- }
- JvThrow (new java::lang::NoSuchMethodException);
-}
-
-JArray<java::lang::reflect::Constructor *> *
-java::lang::Class::_getConstructors (jboolean declared)
-{
- // FIXME: this method needs access checks.
-
- int numConstructors = 0;
- int max = isPrimitive () ? 0 : method_count;
- int i;
- for (i = max; --i >= 0; )
- {
- _Jv_Method *method = &methods[i];
- if (method->name == NULL
- || ! _Jv_equalUtf8Consts (method->name, init_name))
- continue;
- if (! declared
- && ! java::lang::reflect::Modifier::isPublic(method->accflags))
- continue;
- numConstructors++;
- }
- JArray<java::lang::reflect::Constructor *> *result
- = (JArray<java::lang::reflect::Constructor *> *)
- JvNewObjectArray (numConstructors, &ConstructorClass, NULL);
- java::lang::reflect::Constructor** cptr = elements (result);
- for (i = 0; i < max; i++)
- {
- _Jv_Method *method = &methods[i];
- if (method->name == NULL
- || ! _Jv_equalUtf8Consts (method->name, init_name))
- continue;
- if (! declared
- && ! java::lang::reflect::Modifier::isPublic(method->accflags))
- continue;
- java::lang::reflect::Constructor *cons
- = new java::lang::reflect::Constructor ();
- cons->offset = (char *) method - (char *) methods;
- cons->declaringClass = this;
- *cptr++ = cons;
- }
- return result;
-}
-
-java::lang::reflect::Constructor *
-java::lang::Class::getDeclaredConstructor (JArray<jclass> *param_types)
-{
- jstring partial_sig = getSignature (param_types, true);
- jint hash = partial_sig->hashCode ();
-
- int i = isPrimitive () ? 0 : method_count;
- while (--i >= 0)
- {
- // FIXME: access checks.
- if (_Jv_equalUtf8Consts (methods[i].name, init_name)
- && _Jv_equal (methods[i].signature, partial_sig, hash))
- {
- // Found it.
- using namespace java::lang::reflect;
- Constructor *cons = new Constructor ();
- cons->offset = (char *) (&methods[i]) - (char *) methods;
- cons->declaringClass = this;
- return cons;
- }
- }
- JvThrow (new java::lang::NoSuchMethodException);
-}
-
-java::lang::reflect::Field *
-java::lang::Class::getField (jstring name, jint hash)
-{
- java::lang::reflect::Field* rfield;
- for (int i = 0; i < field_count; i++)
- {
- _Jv_Field *field = &fields[i];
- if (! _Jv_equal (field->name, name, hash))
- continue;
- if (! (field->getModifiers() & java::lang::reflect::Modifier::PUBLIC))
- continue;
- rfield = new java::lang::reflect::Field ();
- rfield->offset = (char*) field - (char*) fields;
- rfield->declaringClass = this;
- rfield->name = name;
- return rfield;
- }
- jclass superclass = getSuperclass();
- if (superclass == NULL)
- return NULL;
- rfield = superclass->getField(name, hash);
- for (int i = 0; i < interface_count && rfield == NULL; ++i)
- rfield = interfaces[i]->getField (name, hash);
- return rfield;
-}
-
-java::lang::reflect::Field *
-java::lang::Class::getDeclaredField (jstring name)
-{
- java::lang::SecurityManager *s = java::lang::System::getSecurityManager();
- if (s != NULL)
- s->checkMemberAccess (this, java::lang::reflect::Member::DECLARED);
- int hash = name->hashCode();
- for (int i = 0; i < field_count; i++)
- {
- _Jv_Field *field = &fields[i];
- if (! _Jv_equal (field->name, name, hash))
- continue;
- java::lang::reflect::Field* rfield = new java::lang::reflect::Field ();
- rfield->offset = (char*) field - (char*) fields;
- rfield->declaringClass = this;
- rfield->name = name;
- return rfield;
- }
- JvThrow (new java::lang::NoSuchFieldException (name));
-}
-
-JArray<java::lang::reflect::Field *> *
-java::lang::Class::getDeclaredFields (void)
-{
- java::lang::SecurityManager *s = java::lang::System::getSecurityManager();
- if (s != NULL)
- s->checkMemberAccess (this, java::lang::reflect::Member::DECLARED);
- JArray<java::lang::reflect::Field *> *result
- = (JArray<java::lang::reflect::Field *> *)
- JvNewObjectArray (field_count, &FieldClass, NULL);
- java::lang::reflect::Field** fptr = elements (result);
- for (int i = 0; i < field_count; i++)
- {
- _Jv_Field *field = &fields[i];
- java::lang::reflect::Field* rfield = new java::lang::reflect::Field ();
- rfield->offset = (char*) field - (char*) fields;
- rfield->declaringClass = this;
- *fptr++ = rfield;
- }
- return result;
-}
-
-void
-java::lang::Class::getSignature (java::lang::StringBuffer *buffer)
-{
- if (isPrimitive())
- buffer->append((jchar) method_count);
- else
- {
- jstring name = getName();
- if (name->charAt(0) != '[')
- buffer->append((jchar) 'L');
- buffer->append(name);
- if (name->charAt(0) != '[')
- buffer->append((jchar) ';');
- }
-}
-
-// This doesn't have to be native. It is an implementation detail
-// only called from the C++ code, though, so maybe this is clearer.
-jstring
-java::lang::Class::getSignature (JArray<jclass> *param_types,
- jboolean is_constructor)
-{
- java::lang::StringBuffer *buf = new java::lang::StringBuffer ();
- buf->append((jchar) '(');
- jclass *v = elements (param_types);
- for (int i = 0; i < param_types->length; ++i)
- v[i]->getSignature(buf);
- buf->append((jchar) ')');
- if (is_constructor)
- buf->append((jchar) 'V');
- return buf->toString();
-}
-
-java::lang::reflect::Method *
-java::lang::Class::getDeclaredMethod (jstring name,
- JArray<jclass> *param_types)
-{
- jstring partial_sig = getSignature (param_types, false);
- jint p_len = partial_sig->length();
- _Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
- int i = isPrimitive () ? 0 : method_count;
- while (--i >= 0)
- {
- // FIXME: access checks.
- if (_Jv_equalUtf8Consts (methods[i].name, utf_name)
- && _Jv_equaln (methods[i].signature, partial_sig, p_len))
- {
- // Found it.
- using namespace java::lang::reflect;
- Method *rmethod = new Method ();
- rmethod->offset = (char*) (&methods[i]) - (char*) methods;
- rmethod->declaringClass = this;
- return rmethod;
- }
- }
- JvThrow (new java::lang::NoSuchMethodException);
-}
-
-JArray<java::lang::reflect::Method *> *
-java::lang::Class::getDeclaredMethods (void)
-{
- int numMethods = 0;
- int max = isPrimitive () ? 0 : method_count;
- int i;
- for (i = max; --i >= 0; )
- {
- _Jv_Method *method = &methods[i];
- if (method->name == NULL
- || _Jv_equalUtf8Consts (method->name, clinit_name)
- || _Jv_equalUtf8Consts (method->name, init_name)
- || _Jv_equalUtf8Consts (method->name, finit_name))
- continue;
- numMethods++;
- }
- JArray<java::lang::reflect::Method *> *result
- = (JArray<java::lang::reflect::Method *> *)
- JvNewObjectArray (numMethods, &MethodClass, NULL);
- java::lang::reflect::Method** mptr = elements (result);
- for (i = 0; i < max; i++)
- {
- _Jv_Method *method = &methods[i];
- if (method->name == NULL
- || _Jv_equalUtf8Consts (method->name, clinit_name)
- || _Jv_equalUtf8Consts (method->name, init_name)
- || _Jv_equalUtf8Consts (method->name, finit_name))
- continue;
- java::lang::reflect::Method* rmethod
- = new java::lang::reflect::Method ();
- rmethod->offset = (char*) method - (char*) methods;
- rmethod->declaringClass = this;
- *mptr++ = rmethod;
- }
- return result;
-}
-
-jstring
-java::lang::Class::getName (void)
-{
- char buffer[name->length + 1];
- memcpy (buffer, name->data, name->length);
- buffer[name->length] = '\0';
- return _Jv_NewStringUTF (buffer);
-}
-
-JArray<jclass> *
-java::lang::Class::getClasses (void)
-{
- // Until we have inner classes, it always makes sense to return an
- // empty array.
- JArray<jclass> *result
- = (JArray<jclass> *) JvNewObjectArray (0, &ClassClass, NULL);
- return result;
-}
-
-JArray<jclass> *
-java::lang::Class::getDeclaredClasses (void)
-{
- checkMemberAccess (java::lang::reflect::Member::DECLARED);
- // Until we have inner classes, it always makes sense to return an
- // empty array.
- JArray<jclass> *result
- = (JArray<jclass> *) JvNewObjectArray (0, &ClassClass, NULL);
- return result;
-}
-
-jclass
-java::lang::Class::getDeclaringClass (void)
-{
- // Until we have inner classes, it makes sense to always return
- // NULL.
- return NULL;
-}
-
-jint
-java::lang::Class::_getFields (JArray<java::lang::reflect::Field *> *result,
- jint offset)
-{
- int count = 0;
- for (int i = 0; i < field_count; i++)
- {
- _Jv_Field *field = &fields[i];
- if (! (field->getModifiers() & java::lang::reflect::Modifier::PUBLIC))
- continue;
- ++count;
-
- if (result != NULL)
- {
- java::lang::reflect::Field *rfield
- = new java::lang::reflect::Field ();
- rfield->offset = (char *) field - (char *) fields;
- rfield->declaringClass = this;
- rfield->name = _Jv_NewStringUtf8Const (field->name);
- (elements (result))[offset + i] = rfield;
- }
- }
- jclass superclass = getSuperclass();
- if (superclass != NULL)
- {
- int s_count = superclass->_getFields (result, offset);
- count += s_count;
- offset += s_count;
- }
- for (int i = 0; i < interface_count; ++i)
- {
- int f_count = interfaces[i]->_getFields (result, offset);
- count += f_count;
- offset += f_count;
- }
- return count;
-}
-
-JArray<java::lang::reflect::Field *> *
-java::lang::Class::getFields (void)
-{
- using namespace java::lang::reflect;
-
- int count = _getFields (NULL, 0);
-
- JArray<java::lang::reflect::Field *> *result
- = ((JArray<java::lang::reflect::Field *> *)
- JvNewObjectArray (count, &FieldClass, NULL));
-
- _getFields (result, 0);
-
- return result;
-}
-
-JArray<jclass> *
-java::lang::Class::getInterfaces (void)
-{
- jobjectArray r = JvNewObjectArray (interface_count, getClass (), NULL);
- jobject *data = elements (r);
- for (int i = 0; i < interface_count; ++i)
- data[i] = interfaces[i];
- return reinterpret_cast<JArray<jclass> *> (r);
-}
-
-java::lang::reflect::Method *
-java::lang::Class::getMethod (jstring name, JArray<jclass> *param_types)
-{
- jstring partial_sig = getSignature (param_types, false);
- jint p_len = partial_sig->length();
- _Jv_Utf8Const *utf_name = _Jv_makeUtf8Const (name);
- for (Class *klass = this; klass; klass = klass->getSuperclass())
- {
- int i = klass->isPrimitive () ? 0 : klass->method_count;
- while (--i >= 0)
- {
- // FIXME: access checks.
- if (_Jv_equalUtf8Consts (klass->methods[i].name, utf_name)
- && _Jv_equaln (klass->methods[i].signature, partial_sig, p_len))
- {
- // Found it.
- using namespace java::lang::reflect;
-
- // Method must be public.
- if (! Modifier::isPublic (klass->methods[i].accflags))
- break;
-
- Method *rmethod = new Method ();
- rmethod->offset = ((char *) (&klass->methods[i])
- - (char *) klass->methods);
- rmethod->declaringClass = klass;
- return rmethod;
- }
- }
- }
- JvThrow (new java::lang::NoSuchMethodException);
-}
-
-// This is a very slow implementation, since it re-scans all the
-// methods we've already listed to make sure we haven't duplicated a
-// method. It also over-estimates the required size, so we have to
-// shrink the result array later.
-jint
-java::lang::Class::_getMethods (JArray<java::lang::reflect::Method *> *result,
- jint offset)
-{
- jint count = 0;
-
- // First examine all local methods
- for (int i = isPrimitive () ? 0 : method_count; --i >= 0; )
- {
- _Jv_Method *method = &methods[i];
- if (method->name == NULL
- || _Jv_equalUtf8Consts (method->name, clinit_name)
- || _Jv_equalUtf8Consts (method->name, init_name)
- || _Jv_equalUtf8Consts (method->name, finit_name))
- continue;
- // Only want public methods.
- if (! java::lang::reflect::Modifier::isPublic (method->accflags))
- continue;
-
- // This is where we over-count the slots required if we aren't
- // filling the result for real.
- if (result != NULL)
- {
- jboolean add = true;
- java::lang::reflect::Method **mp = elements (result);
- // If we already have a method with this name and signature,
- // then ignore this one. This can happen with virtual
- // methods.
- for (int j = 0; j < offset; ++j)
- {
- _Jv_Method *meth_2 = _Jv_FromReflectedMethod (mp[j]);
- if (_Jv_equalUtf8Consts (method->name, meth_2->name)
- && _Jv_equalUtf8Consts (method->signature,
- meth_2->signature))
- {
- add = false;
- break;
- }
- }
- if (! add)
- continue;
- }
-
- if (result != NULL)
- {
- using namespace java::lang::reflect;
- Method *rmethod = new Method ();
- rmethod->offset = (char *) method - (char *) methods;
- rmethod->declaringClass = this;
- Method **mp = elements (result);
- mp[offset + count] = rmethod;
- }
- ++count;
- }
- offset += count;
-
- // Now examine superclasses.
- if (getSuperclass () != NULL)
- {
- jint s_count = getSuperclass()->_getMethods (result, offset);
- offset += s_count;
- count += s_count;
- }
-
- // Finally, examine interfaces.
- for (int i = 0; i < interface_count; ++i)
- {
- int f_count = interfaces[i]->_getMethods (result, offset);
- count += f_count;
- offset += f_count;
- }
-
- return count;
-}
-
-JArray<java::lang::reflect::Method *> *
-java::lang::Class::getMethods (void)
-{
- using namespace java::lang::reflect;
-
- // FIXME: security checks.
-
- // This will overestimate the size we need.
- jint count = _getMethods (NULL, 0);
-
- JArray<Method *> *result
- = ((JArray<Method *> *) JvNewObjectArray (count, &MethodClass, NULL));
-
- // When filling the array for real, we get the actual count. Then
- // we resize the array.
- jint real_count = _getMethods (result, 0);
-
- if (real_count != count)
- {
- JArray<Method *> *r2
- = ((JArray<Method *> *) JvNewObjectArray (real_count, &MethodClass,
- NULL));
-
- Method **destp = elements (r2);
- Method **srcp = elements (result);
-
- for (int i = 0; i < real_count; ++i)
- *destp++ = *srcp++;
-
- result = r2;
- }
-
- return result;
-}
-
-jboolean
-java::lang::Class::isAssignableFrom (jclass klass)
-{
- // Arguments may not have been initialized, given ".class" syntax.
- _Jv_InitClass (this);
- _Jv_InitClass (klass);
- return _Jv_IsAssignableFrom (this, klass);
-}
-
-inline jboolean
-java::lang::Class::isInstance (jobject obj)
-{
- if (! obj || isPrimitive ())
- return false;
- _Jv_InitClass (this);
- return _Jv_IsAssignableFrom (this, JV_CLASS (obj));
-}
-
-inline jboolean
-java::lang::Class::isInterface (void)
-{
- return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
-}
-
-jobject
-java::lang::Class::newInstance (void)
-{
- // FIXME: do accessibility checks here. There currently doesn't
- // seem to be any way to do these.
- // FIXME: we special-case one check here just to pass a Plum Hall
- // test. Once access checking is implemented, remove this.
- if (this == &ClassClass)
- JvThrow (new java::lang::IllegalAccessException);
-
- if (isPrimitive ()
- || isInterface ()
- || isArray ()
- || java::lang::reflect::Modifier::isAbstract(accflags))
- JvThrow (new java::lang::InstantiationException);
-
- _Jv_InitClass (this);
-
- _Jv_Method *meth = _Jv_GetMethodLocal (this, init_name, void_signature);
- if (! meth)
- JvThrow (new java::lang::NoSuchMethodException);
-
- jobject r = JvAllocObject (this);
- ((void (*) (jobject)) meth->ncode) (r);
- return r;
-}
-
-void
-java::lang::Class::finalize (void)
-{
-#ifdef INTERPRETER
- JvAssert (_Jv_IsInterpretedClass (this));
- _Jv_UnregisterClass (this);
-#endif
-}
-
-// This implements the initialization process for a class. From Spec
-// section 12.4.2.
-void
-java::lang::Class::initializeClass (void)
-{
- // jshort-circuit to avoid needless locking.
- if (state == JV_STATE_DONE)
- return;
-
- // Step 1.
- _Jv_MonitorEnter (this);
-
- if (state < JV_STATE_LINKED)
- {
-#ifdef INTERPRETER
- if (_Jv_IsInterpretedClass (this))
- {
- // this can throw exceptions, so exit the monitor as a precaution.
- _Jv_MonitorExit (this);
- java::lang::ClassLoader::resolveClass0 (this);
- _Jv_MonitorEnter (this);
- }
- else
-#endif
- {
- _Jv_PrepareCompiledClass (this);
- }
- }
-
- if (state <= JV_STATE_LINKED)
- _Jv_PrepareConstantTimeTables (this);
-
- // Step 2.
- java::lang::Thread *self = java::lang::Thread::currentThread();
- // FIXME: `self' can be null at startup. Hence this nasty trick.
- self = (java::lang::Thread *) ((long) self | 1);
- while (state == JV_STATE_IN_PROGRESS && thread && thread != self)
- wait ();
-
- // Steps 3 & 4.
- if (state == JV_STATE_DONE || state == JV_STATE_IN_PROGRESS || thread == self)
- {
- _Jv_MonitorExit (this);
- return;
- }
-
- // Step 5.
- if (state == JV_STATE_ERROR)
- {
- _Jv_MonitorExit (this);
- JvThrow (new java::lang::NoClassDefFoundError);
- }
-
- // Step 6.
- thread = self;
- state = JV_STATE_IN_PROGRESS;
- _Jv_MonitorExit (this);
-
- // Step 7.
- if (! isInterface () && superclass)
- {
- try
- {
- superclass->initializeClass ();
- }
- catch (java::lang::Throwable *except)
- {
- // Caught an exception.
- _Jv_MonitorEnter (this);
- state = JV_STATE_ERROR;
- notifyAll ();
- _Jv_MonitorExit (this);
- throw except;
- }
- }
-
- // Steps 8, 9, 10, 11.
- try
- {
- _Jv_Method *meth = _Jv_GetMethodLocal (this, clinit_name,
- void_signature);
- if (meth)
- ((void (*) (void)) meth->ncode) ();
- }
- catch (java::lang::Throwable *except)
- {
- if (! ErrorClass.isInstance(except))
- {
- try
- {
- except = new ExceptionInInitializerError (except);
- }
- catch (java::lang::Throwable *t)
- {
- except = t;
- }
- }
- _Jv_MonitorEnter (this);
- state = JV_STATE_ERROR;
- notifyAll ();
- _Jv_MonitorExit (this);
- JvThrow (except);
- }
-
- _Jv_MonitorEnter (this);
- state = JV_STATE_DONE;
- notifyAll ();
- _Jv_MonitorExit (this);
-}
-
-
-
-//
-// Some class-related convenience functions.
-//
-
-// Find a method declared in the class. If it is not declared locally
-// (or if it is inherited), return NULL.
-_Jv_Method *
-_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
- _Jv_Utf8Const *signature)
-{
- for (int i = 0; i < klass->method_count; ++i)
- {
- if (_Jv_equalUtf8Consts (name, klass->methods[i].name)
- && _Jv_equalUtf8Consts (signature, klass->methods[i].signature))
- return &klass->methods[i];
- }
- return NULL;
-}
-
-_Jv_Method *
-_Jv_LookupDeclaredMethod (jclass klass, _Jv_Utf8Const *name,
- _Jv_Utf8Const *signature)
-{
- for (; klass; klass = klass->getSuperclass())
- {
- _Jv_Method *meth = _Jv_GetMethodLocal (klass, name, signature);
-
- if (meth)
- return meth;
- }
-
- return NULL;
-}
-
-// NOTE: MCACHE_SIZE should be a power of 2 minus one.
-#define MCACHE_SIZE 1023
-
-struct _Jv_mcache
-{
- jclass klass;
- _Jv_Method *method;
-};
-
-static _Jv_mcache method_cache[MCACHE_SIZE + 1];
-
-static void *
-_Jv_FindMethodInCache (jclass klass,
- _Jv_Utf8Const *name,
- _Jv_Utf8Const *signature)
-{
- int index = name->hash & MCACHE_SIZE;
- _Jv_mcache *mc = method_cache + index;
- _Jv_Method *m = mc->method;
-
- if (mc->klass == klass
- && m != NULL // thread safe check
- && _Jv_equalUtf8Consts (m->name, name)
- && _Jv_equalUtf8Consts (m->signature, signature))
- return mc->method->ncode;
- return NULL;
-}
-
-static void
-_Jv_AddMethodToCache (jclass klass,
- _Jv_Method *method)
-{
- _Jv_MonitorEnter (&ClassClass);
-
- int index = method->name->hash & MCACHE_SIZE;
-
- method_cache[index].method = method;
- method_cache[index].klass = klass;
-
- _Jv_MonitorExit (&ClassClass);
-}
-
-void *
-_Jv_LookupInterfaceMethod (jclass klass, _Jv_Utf8Const *name,
- _Jv_Utf8Const *signature)
-{
- using namespace java::lang::reflect;
-
- void *ncode = _Jv_FindMethodInCache (klass, name, signature);
- if (ncode != 0)
- return ncode;
-
- for (; klass; klass = klass->getSuperclass())
- {
- _Jv_Method *meth = _Jv_GetMethodLocal (klass, name, signature);
- if (! meth)
- continue;
-
- if (Modifier::isStatic(meth->accflags))
- JvThrow (new java::lang::IncompatibleClassChangeError
- (_Jv_GetMethodString (klass, meth->name)));
- if (Modifier::isAbstract(meth->accflags))
- JvThrow (new java::lang::AbstractMethodError
- (_Jv_GetMethodString (klass, meth->name)));
- if (! Modifier::isPublic(meth->accflags))
- JvThrow (new java::lang::IllegalAccessError
- (_Jv_GetMethodString (klass, meth->name)));
-
- _Jv_AddMethodToCache (klass, meth);
-
- return meth->ncode;
- }
- JvThrow (new java::lang::IncompatibleClassChangeError);
- return NULL; // Placate compiler.
-}
-
-// Fast interface method lookup by index.
-void *
-_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, int method_idx)
-{
- _Jv_IDispatchTable *cldt = klass->idt;
- int idx = iface->idt->iface.ioffsets[cldt->cls.iindex] + method_idx;
- return cldt->cls.itable[idx];
-}
-
-inline jboolean
-_Jv_IsAssignableFrom (jclass target, jclass source)
-{
- if (target == &ObjectClass
- || source == target
- || (source->ancestors != NULL
- && source->ancestors[source->depth - target->depth] == target))
- return true;
-
- // If target is array, so must source be.
- if (target->isArray ())
- {
- if (! source->isArray())
- return false;
- return _Jv_IsAssignableFrom(target->getComponentType(),
- source->getComponentType());
- }
-
- if (target->isInterface())
- {
- _Jv_IDispatchTable *cl_idt = source->idt;
- _Jv_IDispatchTable *if_idt = target->idt;
- if (if_idt == NULL)
- return false; // No class implementing TARGET has been loaded.
- jshort cl_iindex = cl_idt->cls.iindex;
- if (cl_iindex <= if_idt->iface.ioffsets[0])
- {
- jshort offset = if_idt->iface.ioffsets[cl_iindex];
- if (offset < cl_idt->cls.itable_length
- && cl_idt->cls.itable[offset] == target)
- return true;
- }
- }
-
- return false;
-}
-
-jboolean
-_Jv_IsInstanceOf(jobject obj, jclass cl)
-{
- return (obj ? _Jv_IsAssignableFrom (cl, JV_CLASS (obj)) : false);
-}
-
-void *
-_Jv_CheckCast (jclass c, jobject obj)
-{
- if (obj != NULL && ! _Jv_IsAssignableFrom(c, JV_CLASS (obj)))
- JvThrow (new java::lang::ClassCastException);
- return obj;
-}
-
-void
-_Jv_CheckArrayStore (jobject arr, jobject obj)
-{
- if (obj)
- {
- JvAssert (arr != NULL);
- jclass elt_class = (JV_CLASS (arr))->getComponentType();
- jclass obj_class = JV_CLASS (obj);
- if (! _Jv_IsAssignableFrom (elt_class, obj_class))
- JvThrow (new java::lang::ArrayStoreException);
- }
-}
-
-#define INITIAL_IOFFSETS_LEN 4
-#define INITIAL_IFACES_LEN 4
-
-// Generate tables for constant-time assignment testing and interface
-// method lookup. This implements the technique described by Per Bothner
-// <per@bothner.com> on the java-discuss mailing list on 1999-09-02:
-// http://sourceware.cygnus.com/ml/java-discuss/1999-q3/msg00377.html
-void
-_Jv_PrepareConstantTimeTables (jclass klass)
-{
- if (klass->isPrimitive () || klass->isInterface ())
- return;
-
- // Short-circuit in case we've been called already.
- if ((klass->idt != NULL) || klass->depth != 0)
- return;
-
- // Calculate the class depth and ancestor table. The depth of a class
- // is how many "extends" it is removed from Object. Thus the depth of
- // java.lang.Object is 0, but the depth of java.io.FilterOutputStream
- // is 2. Depth is defined for all regular and array classes, but not
- // interfaces or primitive types.
-
- jclass klass0 = klass;
- while (klass0 != &ObjectClass)
- {
- klass0 = klass0->superclass;
- klass->depth++;
- }
-
- // We do class member testing in constant time by using a small table
- // of all the ancestor classes within each class. The first element is
- // a pointer to the current class, and the rest are pointers to the
- // classes ancestors, ordered from the current class down by decreasing
- // depth. We do not include java.lang.Object in the table of ancestors,
- // since it is redundant.
-
- klass->ancestors = (jclass *) _Jv_Malloc (klass->depth * sizeof (jclass));
- klass0 = klass;
- for (int index = 0; index < klass->depth; index++)
- {
- klass->ancestors[index] = klass0;
- klass0 = klass0->superclass;
- }
-
- if (java::lang::reflect::Modifier::isAbstract (klass->accflags))
- return;
-
- klass->idt =
- (_Jv_IDispatchTable *) _Jv_Malloc (sizeof (_Jv_IDispatchTable));
-
- _Jv_ifaces ifaces;
-
- ifaces.count = 0;
- ifaces.len = INITIAL_IFACES_LEN;
- ifaces.list = (jclass *) _Jv_Malloc (ifaces.len * sizeof (jclass *));
-
- int itable_size = _Jv_GetInterfaces (klass, &ifaces);
-
- if (ifaces.count > 0)
- {
- klass->idt->cls.itable =
- (void **) _Jv_Malloc (itable_size * sizeof (void *));
- klass->idt->cls.itable_length = itable_size;
-
- jshort *itable_offsets =
- (jshort *) _Jv_Malloc (ifaces.count * sizeof (jshort));
-
- _Jv_GenerateITable (klass, &ifaces, itable_offsets);
-
- jshort cls_iindex =
- _Jv_FindIIndex (ifaces.list, itable_offsets, ifaces.count);
-
- for (int i=0; i < ifaces.count; i++)
- {
- ifaces.list[i]->idt->iface.ioffsets[cls_iindex] =
- itable_offsets[i];
- }
-
- klass->idt->cls.iindex = cls_iindex;
-
- _Jv_Free (ifaces.list);
- _Jv_Free (itable_offsets);
- }
- else
- {
- klass->idt->cls.iindex = SHRT_MAX;
- }
-}
-
-// Return index of item in list, or -1 if item is not present.
-jshort
-_Jv_IndexOf (void *item, void **list, jshort list_len)
-{
- for (int i=0; i < list_len; i++)
- {
- if (list[i] == item)
- return i;
- }
- return -1;
-}
-
-// Find all unique interfaces directly or indirectly implemented by klass.
-// Returns the size of the interface dispatch table (itable) for klass, which
-// is the number of unique interfaces plus the total number of methods that
-// those interfaces declare. May extend ifaces if required.
-jshort
-_Jv_GetInterfaces (jclass klass, _Jv_ifaces *ifaces)
-{
- jshort result = 0;
-
- for (int i=0; i < klass->interface_count; i++)
- {
- jclass iface = klass->interfaces[i];
- if (_Jv_IndexOf (iface, (void **) ifaces->list, ifaces->count) == -1)
- {
- if (ifaces->count + 1 >= ifaces->len)
- {
- /* Resize ifaces list */
- ifaces->len = ifaces->len * 2;
- ifaces->list = (jclass *) _Jv_Realloc (ifaces->list,
- ifaces->len * sizeof(jclass));
- }
- ifaces->list[ifaces->count] = iface;
- ifaces->count++;
-
- result += _Jv_GetInterfaces (klass->interfaces[i], ifaces);
- }
- }
-
- if (klass->isInterface())
- {
- result += klass->method_count + 1;
- }
- else
- {
- if (klass->superclass)
- {
- result += _Jv_GetInterfaces (klass->superclass, ifaces);
- }
- }
- return result;
-}
-
-// Fill out itable in klass, resolving method declarations in each ifaces.
-// itable_offsets is filled out with the position of each iface in itable,
-// such that itable[itable_offsets[n]] == ifaces.list[n].
-void
-_Jv_GenerateITable (jclass klass, _Jv_ifaces *ifaces, jshort *itable_offsets)
-{
- void **itable = klass->idt->cls.itable;
- jshort itable_pos = 0;
-
- for (int i=0; i < ifaces->count; i++)
- {
- jclass iface = ifaces->list[i];
- itable_offsets[i] = itable_pos;
- itable_pos = _Jv_AppendPartialITable (klass, iface, itable,
- itable_pos);
-
- /* Create interface dispatch table for iface */
- if (iface->idt == NULL)
- {
- iface->idt =
- (_Jv_IDispatchTable *) _Jv_Malloc (sizeof (_Jv_IDispatchTable));
-
- // The first element of ioffsets is its length (itself included).
- jshort *ioffsets =
- (jshort *) _Jv_Malloc (INITIAL_IOFFSETS_LEN * sizeof (jshort));
- ioffsets[0] = INITIAL_IOFFSETS_LEN;
- for (int i=1; i < INITIAL_IOFFSETS_LEN; i++)
- ioffsets[i] = -1;
-
- iface->idt->iface.ioffsets = ioffsets;
- }
- }
-}
-
-// Format method name for use in error messages.
-jstring
-_Jv_GetMethodString (jclass klass, _Jv_Utf8Const *name)
-{
- jstring r = JvNewStringUTF (klass->name->data);
- r = r->concat (JvNewStringUTF ("."));
- r = r->concat (JvNewStringUTF (name->data));
- return r;
-}
-
-void
-_Jv_ThrowNoSuchMethodError ()
-{
- JvThrow (new java::lang::NoSuchMethodError ());
-}
-
-// Each superinterface of a class (i.e. each interface that the class
-// directly or indirectly implements) has a corresponding "Partial
-// Interface Dispatch Table" whose size is (number of methods + 1) words.
-// The first word is a pointer to the interface (i.e. the java.lang.Class
-// instance for that interface). The remaining words are pointers to the
-// actual methods that implement the methods declared in the interface,
-// in order of declaration.
-//
-// Append partial interface dispatch table for "iface" to "itable", at
-// position itable_pos.
-// Returns the offset at which the next partial ITable should be appended.
-jshort
-_Jv_AppendPartialITable (jclass klass, jclass iface, void **itable,
- jshort pos)
-{
- using namespace java::lang::reflect;
-
- itable[pos++] = (void *) iface;
- _Jv_Method *meth;
-
- for (int j=0; j < iface->method_count; j++)
- {
- meth = NULL;
- for (jclass cl = klass; cl; cl = cl->getSuperclass())
- {
- meth = _Jv_GetMethodLocal (cl, iface->methods[j].name,
- iface->methods[j].signature);
-
- if (meth)
- break;
- }
-
- if (meth && (meth->name->data[0] == '<'))
- {
- // leave a placeholder in the itable for hidden init methods.
- itable[pos] = NULL;
- }
- else if (meth)
- {
- if (Modifier::isStatic(meth->accflags))
- JvThrow (new java::lang::IncompatibleClassChangeError
- (_Jv_GetMethodString (klass, meth->name)));
- if (Modifier::isAbstract(meth->accflags))
- JvThrow (new java::lang::AbstractMethodError
- (_Jv_GetMethodString (klass, meth->name)));
- if (! Modifier::isPublic(meth->accflags))
- JvThrow (new java::lang::IllegalAccessError
- (_Jv_GetMethodString (klass, meth->name)));
-
- itable[pos] = meth->ncode;
- }
- else
- {
- // The method doesn't exist in klass. Binary compatibility rules
- // permit this, so we delay the error until runtime using a pointer
- // to a method which throws an exception.
- itable[pos] = (void *) _Jv_ThrowNoSuchMethodError;
- }
- pos++;
- }
-
- return pos;
-}
-
-static _Jv_Mutex_t iindex_mutex;
-bool iindex_mutex_initialized = false;
-
-// We need to find the correct offset in the Class Interface Dispatch
-// Table for a given interface. Once we have that, invoking an interface
-// method just requires combining the Method's index in the interface
-// (known at compile time) to get the correct method. Doing a type test
-// (cast or instanceof) is the same problem: Once we have a possible Partial
-// Interface Dispatch Table, we just compare the first element to see if it
-// matches the desired interface. So how can we find the correct offset?
-// Our solution is to keep a vector of candiate offsets in each interface
-// (idt->iface.ioffsets), and in each class we have an index
-// (idt->cls.iindex) used to select the correct offset from ioffsets.
-//
-// Calculate and return iindex for a new class.
-// ifaces is a vector of num interfaces that the class implements.
-// offsets[j] is the offset in the interface dispatch table for the
-// interface corresponding to ifaces[j].
-// May extend the interface ioffsets if required.
-jshort
-_Jv_FindIIndex (jclass *ifaces, jshort *offsets, jshort num)
-{
- int i;
- int j;
-
- // Acquire a global lock to prevent itable corruption in case of multiple
- // classes that implement an intersecting set of interfaces being linked
- // simultaneously. We can assume that the mutex will be initialized
- // single-threaded.
- if (! iindex_mutex_initialized)
- {
- _Jv_MutexInit (&iindex_mutex);
- iindex_mutex_initialized = true;
- }
-
- _Jv_MutexLock (&iindex_mutex);
-
- for (i=1;; i++) /* each potential position in ioffsets */
- {
- for (j=0;; j++) /* each iface */
- {
- if (j >= num)
- goto found;
- if (i > ifaces[j]->idt->iface.ioffsets[0])
- continue;
- int ioffset = ifaces[j]->idt->iface.ioffsets[i];
- /* We can potentially share this position with another class. */
- if (ioffset >= 0 && ioffset != offsets[j])
- break; /* Nope. Try next i. */
- }
- }
- found:
- for (j = 0; j < num; j++)
- {
- int len = ifaces[j]->idt->iface.ioffsets[0];
- if (i >= len)
- {
- /* Resize ioffsets. */
- int newlen = 2 * len;
- if (i >= newlen)
- newlen = i + 3;
- jshort *old_ioffsets = ifaces[j]->idt->iface.ioffsets;
- jshort *new_ioffsets = (jshort *) _Jv_Realloc (old_ioffsets,
- newlen * sizeof(jshort));
- new_ioffsets[0] = newlen;
-
- while (len < newlen)
- new_ioffsets[len++] = -1;
-
- ifaces[j]->idt->iface.ioffsets = new_ioffsets;
- }
- ifaces[j]->idt->iface.ioffsets[i] = offsets[j];
- }
-
- _Jv_MutexUnlock (&iindex_mutex);
-
- return i;
-}
diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc
deleted file mode 100644
index 896873a6a6e..00000000000
--- a/libjava/java/lang/natClassLoader.cc
+++ /dev/null
@@ -1,611 +0,0 @@
-// natClassLoader.cc - Implementation of java.lang.ClassLoader native methods.
-
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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: Kresten Krab Thorup <krab@gnu.org> */
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java-threads.h>
-#include <java-interp.h>
-
-#include <java/lang/Character.h>
-#include <java/lang/Thread.h>
-#include <java/lang/ClassLoader.h>
-#include <gnu/gcj/runtime/VMClassLoader.h>
-#include <java/lang/InternalError.h>
-#include <java/lang/IllegalAccessError.h>
-#include <java/lang/LinkageError.h>
-#include <java/lang/ClassFormatError.h>
-#include <java/lang/NoClassDefFoundError.h>
-#include <java/lang/ClassNotFoundException.h>
-#include <java/lang/ClassCircularityError.h>
-#include <java/lang/IncompatibleClassChangeError.h>
-#include <java/lang/reflect/Modifier.h>
-#include <java/lang/Runtime.h>
-
-#define CloneableClass _CL_Q34java4lang9Cloneable
-extern java::lang::Class CloneableClass;
-#define ObjectClass _CL_Q34java4lang6Object
-extern java::lang::Class ObjectClass;
-#define ClassClass _CL_Q34java4lang5Class
-extern java::lang::Class ClassClass;
-#define VMClassLoaderClass _CL_Q34java4lang17VMClassLoader
-extern java::lang::Class VMClassLoader;
-#define ClassLoaderClass _CL_Q34java4lang11ClassLoader
-extern java::lang::Class ClassLoaderClass;
-
-/////////// java.lang.ClassLoader native methods ////////////
-
-java::lang::ClassLoader *
-java::lang::ClassLoader::getSystemClassLoader (void)
-{
- JvSynchronize sync (&ClassLoaderClass);
- if (! system)
- system = gnu::gcj::runtime::VMClassLoader::getVMClassLoader ();
- return system;
-}
-
-java::lang::Class *
-java::lang::ClassLoader::defineClass0 (jstring name,
- jbyteArray data,
- jint offset,
- jint length)
-{
-#ifdef INTERPRETER
- jclass klass;
- klass = (jclass) JvAllocObject (&ClassClass, sizeof (_Jv_InterpClass));
-
- // synchronize on the class, so that it is not
- // attempted initialized until we're done loading.
- _Jv_MonitorEnter (klass);
-
- // record which is the defining loader
- klass->loader = this;
-
- // register that we are the initiating loader...
- if (name != 0)
- {
- _Jv_Utf8Const * name2 = _Jv_makeUtf8Const (name);
-
- _Jv_VerifyClassName (name2);
-
- klass->name = name2;
- }
-
- try
- {
- _Jv_DefineClass (klass, data, offset, length);
- }
- catch (java::lang::Throwable *ex)
- {
- klass->state = JV_STATE_ERROR;
- klass->notifyAll ();
-
- _Jv_UnregisterClass (klass);
-
- _Jv_MonitorExit (klass);
-
- // FIXME: Here we may want to test that EX does
- // indeed represent a valid exception. That is,
- // anything but ClassNotFoundException,
- // or some kind of Error.
-
- JvThrow (ex);
- }
-
- // if everything proceeded sucessfully, we're loaded.
- JvAssert (klass->state == JV_STATE_LOADED);
-
- // if an exception is generated, this is initially missed.
- // however, we come back here in handleException0 below...
- _Jv_MonitorExit (klass);
-
- return klass;
-
-#else // INTERPRETER
-
- return 0;
-#endif
-}
-
-void
-_Jv_WaitForState (jclass klass, int state)
-{
- if (klass->state >= state)
- return;
-
- _Jv_MonitorEnter (klass) ;
-
- if (state == JV_STATE_LINKED)
- {
- // Must call _Jv_PrepareCompiledClass while holding the class
- // mutex.
- _Jv_PrepareCompiledClass (klass);
- _Jv_MonitorExit (klass);
- return;
- }
-
- java::lang::Thread *self = java::lang::Thread::currentThread();
-
- // this is similar to the strategy for class initialization.
- // if we already hold the lock, just leave.
- while (klass->state <= state
- && klass->thread
- && klass->thread != self)
- klass->wait ();
-
- _Jv_MonitorExit (klass);
-
- if (klass->state == JV_STATE_ERROR)
- {
- _Jv_Throw (new java::lang::LinkageError ());
- }
-}
-
-// Finish linking a class. Only called from ClassLoader::resolveClass.
-void
-java::lang::ClassLoader::linkClass0 (java::lang::Class *klass)
-{
- if (klass->state >= JV_STATE_LINKED)
- return;
-
-#ifdef INTERPRETER
- if (_Jv_IsInterpretedClass (klass))
- {
- _Jv_PrepareClass (klass);
- }
-#endif
-
- _Jv_PrepareCompiledClass (klass);
-}
-
-void
-java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass)
-{
- klass->state = JV_STATE_ERROR;
- klass->notifyAll ();
-}
-
-
-/** this is the only native method in VMClassLoader, so
- we define it here. */
-jclass
-gnu::gcj::runtime::VMClassLoader::findSystemClass (jstring name)
-{
- _Jv_Utf8Const *name_u = _Jv_makeUtf8Const (name);
- jclass klass = _Jv_FindClassInCache (name_u, 0);
-
- if (! klass)
- {
- // Turn `gnu.pkg.quux' into `gnu-pkg-quux'. Then search for a
- // module named (eg, on Linux) `gnu-pkg-quux.so', followed by
- // `gnu-pkg.so' and `gnu.so'. If loading one of these causes
- // the class to appear in the cache, then use it.
- jstring so_base_name = name->replace ('.', '-');
-
- while (! klass && so_base_name && so_base_name->length() > 0)
- {
- 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);
- }
- }
-
- 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
- lives in resolve.cc which is entirely conditionally compiled.
- */
-void
-_Jv_PrepareCompiledClass(jclass klass)
-{
- if (klass->state >= JV_STATE_LINKED)
- return;
-
- // Short-circuit, so that mutually dependent classes are ok.
- klass->state = JV_STATE_LINKED;
-
- _Jv_Constants *pool = &klass->constants;
- for (int index = 1; index < pool->size; ++index)
- {
- if (pool->tags[index] == JV_CONSTANT_Class)
- {
- _Jv_Utf8Const *name = pool->data[index].utf8;
-
- jclass found;
- if (name->data[0] == '[')
- found = _Jv_FindClassFromSignature (&name->data[0],
- klass->loader);
- else
- found = _Jv_FindClass (name, klass->loader);
-
- if (! found)
- {
- jstring str = _Jv_NewStringUTF (name->data);
- JvThrow (new java::lang::ClassNotFoundException (str));
- }
-
- pool->data[index].clazz = found;
- pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
- }
-
- else if (pool->tags[index] == JV_CONSTANT_String)
- {
- jstring str;
- str = _Jv_NewStringUtf8Const (pool->data[index].utf8);
- pool->data[index].o = str;
- pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
- }
- }
-
- klass->notifyAll ();
-}
-
-
-//
-// A single class can have many "initiating" class loaders,
-// and a single "defining" class loader. The Defining
-// class loader is what is returned from Class.getClassLoader()
-// and is used when loading dependent classes during resolution.
-// The set of initiating class loaders are used to ensure
-// safety of linking, and is maintained in the hash table
-// "initiated_classes". A defining classloader is by definition also
-// initiating, so we only store classes in this table, if they have more
-// than one class loader associated.
-//
-
-
-// Size of local hash table.
-#define HASH_LEN 1013
-
-// Hash function for Utf8Consts.
-#define HASH_UTF(Utf) (((Utf)->hash) % HASH_LEN)
-
-struct _Jv_LoaderInfo {
- _Jv_LoaderInfo *next;
- java::lang::Class *klass;
- java::lang::ClassLoader *loader;
-};
-
-static _Jv_LoaderInfo *initiated_classes[HASH_LEN];
-static jclass loaded_classes[HASH_LEN];
-
-// This is the root of a linked list of classes
-
-
-
-jclass
-_Jv_FindClassInCache (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
-{
- _Jv_MonitorEnter (&ClassClass);
- jint hash = HASH_UTF (name);
-
- // first, if LOADER is a defining loader, then it is also initiating
- jclass klass;
- for (klass = loaded_classes[hash]; klass; klass = klass->next)
- {
- if (loader == klass->loader && _Jv_equalUtf8Consts (name, klass->name))
- break;
- }
-
- // otherwise, it may be that the class in question was defined
- // by some other loader, but that the loading was initiated by
- // the loader in question.
- if (!klass)
- {
- _Jv_LoaderInfo *info;
- for (info = initiated_classes[hash]; info; info = info->next)
- {
- if (loader == info->loader
- && _Jv_equalUtf8Consts (name, info->klass->name))
- {
- klass = info->klass;
- break;
- }
- }
- }
-
- _Jv_MonitorExit (&ClassClass);
-
- return klass;
-}
-
-void
-_Jv_UnregisterClass (jclass the_class)
-{
- _Jv_MonitorEnter (&ClassClass);
- jint hash = HASH_UTF(the_class->name);
-
- jclass *klass = &(loaded_classes[hash]);
- for ( ; *klass; klass = &((*klass)->next))
- {
- if (*klass == the_class)
- {
- *klass = (*klass)->next;
- break;
- }
- }
-
- _Jv_LoaderInfo **info = &(initiated_classes[hash]);
- for ( ; ; info = &((*info)->next))
- {
- while (*info && (*info)->klass == the_class)
- {
- *info = (*info)->next;
- }
-
- if (*info == NULL)
- break;
- }
-
- _Jv_MonitorExit (&ClassClass);
-}
-
-void
-_Jv_RegisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
-{
- _Jv_LoaderInfo *info = new _Jv_LoaderInfo; // non-gc alloc!
- jint hash = HASH_UTF(klass->name);
-
- _Jv_MonitorEnter (&ClassClass);
- info->loader = loader;
- info->klass = klass;
- info->next = initiated_classes[hash];
- initiated_classes[hash] = info;
- _Jv_MonitorExit (&ClassClass);
-
-}
-
-// This function is called many times during startup, before main() is
-// run. We do our runtime initialization here the very first time we
-// are called. At that point in time we know for certain we are
-// running single-threaded, so we don't need to lock when modifying
-// `init'. CLASSES is NULL-terminated.
-void
-_Jv_RegisterClasses (jclass *classes)
-{
- static bool init = false;
-
- if (! init)
- {
- init = true;
- _Jv_InitThreads ();
- _Jv_InitGC ();
- _Jv_InitializeSyncMutex ();
- }
-
- JvSynchronize sync (&ClassClass);
- for (; *classes; ++classes)
- {
- jclass klass = *classes;
- jint hash = HASH_UTF (klass->name);
- klass->next = loaded_classes[hash];
- loaded_classes[hash] = klass;
-
- // registering a compiled class causes
- // it to be immediately "prepared".
- if (klass->state == JV_STATE_NOTHING)
- klass->state = JV_STATE_COMPILED;
- }
-}
-
-void
-_Jv_RegisterClass (jclass klass)
-{
- jclass classes[2];
- classes[0] = klass;
- classes[1] = NULL;
- _Jv_RegisterClasses (classes);
-}
-
-jclass
-_Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
-{
- jclass klass = _Jv_FindClassInCache (name, loader);
-
- if (! klass)
- {
- jstring sname = _Jv_NewStringUTF (name->data);
-
- if (loader)
- {
- // Load using a user-defined loader, jvmspec 5.3.2
- klass = loader->loadClass(sname, false);
-
- // If "loader" delegated the loadClass operation to another
- // loader, explicitly register that it is also an initiating
- // loader of the given class.
- if (klass && (klass->getClassLoader () != loader))
- _Jv_RegisterInitiatingLoader (klass, loader);
- }
- else
- {
- java::lang::ClassLoader *sys = java::lang::ClassLoader::system;
- if (sys == NULL)
- {
- _Jv_InitClass (&ClassLoaderClass);
- sys = java::lang::ClassLoader::getSystemClassLoader ();
- }
-
- // Load using the bootstrap loader jvmspec 5.3.1.
- klass = sys->loadClass (sname, false);
-
- // Register that we're an initiating loader.
- if (klass)
- _Jv_RegisterInitiatingLoader (klass, 0);
- }
- }
- else
- {
- // we need classes to be in the hash while
- // we're loading, so that they can refer to themselves.
- _Jv_WaitForState (klass, JV_STATE_LOADED);
- }
-
- return klass;
-}
-
-jclass
-_Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
- java::lang::ClassLoader *loader)
-{
- jclass ret = (jclass) JvAllocObject (&ClassClass);
-
- ret->next = NULL;
- ret->name = name;
- ret->accflags = 0;
- ret->superclass = superclass;
- ret->constants.size = 0;
- ret->constants.tags = NULL;
- ret->constants.data = NULL;
- ret->methods = NULL;
- ret->method_count = 0;
- ret->vtable_method_count = 0;
- ret->fields = NULL;
- ret->size_in_bytes = 0;
- ret->field_count = 0;
- ret->static_field_count = 0;
- ret->vtable = NULL;
- ret->interfaces = NULL;
- ret->loader = loader;
- ret->interface_count = 0;
- ret->state = JV_STATE_NOTHING;
- ret->thread = NULL;
- ret->depth = 0;
- ret->ancestors = NULL;
- ret->idt = NULL;
-
- _Jv_RegisterClass (ret);
-
- return ret;
-}
-
-jclass
-_Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader)
-{
- _Jv_Utf8Const *array_name;
- int len;
- if (element->isPrimitive())
- {
- // For primitive types the array is cached in the class.
- jclass ret = (jclass) element->methods;
- if (ret)
- return ret;
- len = 3;
- }
- else
- len = element->name->length + 5;
-
- {
- char signature[len];
- int index = 0;
- signature[index++] = '[';
- // Compute name of array class to see if we've already cached it.
- if (element->isPrimitive())
- {
- signature[index++] = (char) element->method_count;
- }
- else
- {
- size_t length = element->name->length;
- const char *const name = element->name->data;
- if (name[0] != '[')
- signature[index++] = 'L';
- memcpy (&signature[index], name, length);
- index += length;
- if (name[0] != '[')
- signature[index++] = ';';
- }
- array_name = _Jv_makeUtf8Const (signature, index);
- }
-
- jclass array_class = _Jv_FindClassInCache (array_name, element->loader);
-
- if (! array_class)
- {
- // Create new array class.
- array_class = _Jv_NewClass (array_name, &ObjectClass, element->loader);
-
- // Note that `vtable_method_count' doesn't include the initial
- // NULL slot.
- int dm_count = ObjectClass.vtable_method_count + 1;
-
- // Create a new vtable by copying Object's vtable (except the
- // class pointer, of course). Note that we allocate this as
- // unscanned memory -- the vtables are handled specially by the
- // GC.
- int size = (sizeof (_Jv_VTable) +
- ((dm_count - 1) * sizeof (void *)));
- _Jv_VTable *vtable = (_Jv_VTable *) _Jv_AllocBytes (size);
- vtable->clas = array_class;
- memcpy (vtable->method, ObjectClass.vtable->method,
- dm_count * sizeof (void *));
- array_class->vtable = vtable;
- array_class->vtable_method_count = ObjectClass.vtable_method_count;
-
- // Stash the pointer to the element type.
- array_class->methods = (_Jv_Method *) element;
-
- // Register our interfaces.
- // FIXME: for JDK 1.2 we need Serializable.
- static jclass interfaces[] = { &CloneableClass };
- array_class->interfaces = interfaces;
- array_class->interface_count = 1;
-
- // Generate the interface dispatch table.
- _Jv_PrepareConstantTimeTables (array_class);
-
- // as per vmspec 5.3.3.2
- array_class->accflags = element->accflags;
-
- // FIXME: initialize other Class instance variables,
- // e.g. `fields'.
-
- // say this class is initialized and ready to go!
- array_class->state = JV_STATE_DONE;
-
- // vmspec, section 5.3.3 describes this
- if (element->loader != loader)
- _Jv_RegisterInitiatingLoader (array_class, loader);
- }
-
- // For primitive types, point back at this array.
- if (element->isPrimitive())
- element->methods = (_Jv_Method *) array_class;
-
- return array_class;
-}
-
-
diff --git a/libjava/java/lang/natDouble.cc b/libjava/java/lang/natDouble.cc
deleted file mode 100644
index 86ccdef5b3b..00000000000
--- a/libjava/java/lang/natDouble.cc
+++ /dev/null
@@ -1,189 +0,0 @@
-// natDouble.cc - Implementation of java.lang.Double native methods.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-/* AIX requires this to be the first thing in the file. */
-#ifndef __GNUC__
-# if HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-# endif
-# endif
-# endif
-#endif
-
-#include <stdlib.h>
-
-#include <gcj/cni.h>
-#include <java/lang/String.h>
-#include <java/lang/Double.h>
-#include <java/lang/NumberFormatException.h>
-#include <jvm.h>
-
-#include <stdio.h>
-#include <string.h>
-
-#include "mprec.h"
-
-union u
-{
- jlong l;
- jdouble d;
-};
-
-jlong
-java::lang::Double::doubleToLongBits(jdouble value)
-{
- union u u;
- u.d = value;
-
- jlong e = u.l & 0x7ff0000000000000LL;
- jlong f = u.l & 0x000fffffffffffffLL;
-
- if (e == 0x7ff0000000000000LL && f != 0L)
- u.l = 0x7ff8000000000000LL;
-
- return u.l;
-}
-
-jdouble
-java::lang::Double::longBitsToDouble(jlong bits)
-{
- union u u;
- u.l = bits;
- return u.d;
-}
-
-jstring
-java::lang::Double::toString(jdouble value, jboolean isFloat)
-{
- if (isNaN (value))
- return JvNewStringLatin1 ("NaN", sizeof ("NaN") - 1);
-
- if (value == POSITIVE_INFINITY)
- return JvNewStringLatin1 ("Infinity", sizeof ("Infinity") - 1);
-
- if (value == NEGATIVE_INFINITY)
- return JvNewStringLatin1 ("-Infinity", sizeof ("-Infinity") - 1);
-
- char buffer[50], result[50];
- int decpt, sign;
-
- _dtoa (value, 0, 20, &decpt, &sign, NULL, buffer, (int)isFloat);
-
- value = fabs (value);
-
- char *s = buffer;
- char *d = result;
-
- if (sign)
- *d++ = '-';
-
- if (value >= 1e-3 && value < 1e7 || value == 0)
- {
- if (decpt <= 0)
- *d++ = '0';
- else
- {
- for (int i = 0; i < decpt; i++)
- if (*s)
- *d++ = *s++;
- else
- *d++ = '0';
- }
-
- *d++ = '.';
-
- if (*s == 0)
- {
- *d++ = '0';
- decpt++;
- }
-
- while (decpt++ < 0)
- *d++ = '0';
-
- while (*s)
- *d++ = *s++;
-
- *d = 0;
-
- return JvNewStringLatin1 (result, strlen (result));
- }
-
- *d++ = *s++;
- decpt--;
- *d++ = '.';
-
- if (*s == 0)
- *d++ = '0';
-
- while (*s)
- *d++ = *s++;
-
- *d++ = 'E';
-
- if (decpt < 0)
- {
- *d++ = '-';
- decpt = -decpt;
- }
-
- {
- char exp[4];
- char *e = exp + sizeof exp;
-
- *--e = 0;
- do
- {
- *--e = '0' + decpt % 10;
- decpt /= 10;
- }
- while (decpt > 0);
-
- while (*e)
- *d++ = *e++;
- }
-
- *d = 0;
-
- return JvNewStringLatin1 (result, strlen (result));
-}
-
-jdouble
-java::lang::Double::doubleValueOf(jstring str)
-{
- int length = str->length();
- // Note that UTF can expand 3x.
-
-#ifdef HAVE_ALLOCA
- char *data = (char *) alloca (3 * length + 1);
-#else
-#error --- need an alternate implementation here ---
-#endif
-
- data[_Jv_GetStringUTFRegion (str, 0, length, data)] = 0;
-
- struct _Jv_reent reent;
- memset (&reent, 0, sizeof reent);
-
- double val = _strtod_r (&reent, data, NULL);
-
- if (reent._errno)
- _Jv_Throw (new NumberFormatException);
-
- return val;
-}
diff --git a/libjava/java/lang/natEcosProcess.cc b/libjava/java/lang/natEcosProcess.cc
deleted file mode 100644
index 9cfb19e702d..00000000000
--- a/libjava/java/lang/natEcosProcess.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// natEcosProcess.cc - Native side of eCos processes.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-// The configury system needs this file to exist, since we can't
-// really conditionally link files (an autoconf bug). To avoid having
-// an empty translation unit, we make a single method native. FIXME.
-
-#include <config.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java/lang/ConcreteProcess.h>
-
-void
-java::lang::ConcreteProcess::destroy (void)
-{
-}
diff --git a/libjava/java/lang/natFloat.cc b/libjava/java/lang/natFloat.cc
deleted file mode 100644
index f19a1d597d1..00000000000
--- a/libjava/java/lang/natFloat.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// natFloat.cc - Implementation of java.lang.Float native methods.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <java/lang/Float.h>
-#include <jvm.h>
-
-union u
-{
- jint l;
- jfloat d;
-};
-
-jint
-java::lang::Float::floatToIntBits(jfloat value)
-{
- union u u;
- u.d = value;
- jint e = u.l & 0x7f800000;
- jint f = u.l & 0x007fffff;
-
- if (e == 0x7f800000 && f != 0)
- u.l = 0x7fc00000;
-
- return u.l;
-}
-
-jfloat
-java::lang::Float::intBitsToFloat(jint bits)
-{
- union u u;
- u.l = bits;
- return u.d;
-}
-
diff --git a/libjava/java/lang/natMath.cc b/libjava/java/lang/natMath.cc
deleted file mode 100644
index 8e2f644e7c9..00000000000
--- a/libjava/java/lang/natMath.cc
+++ /dev/null
@@ -1,263 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 <aph@cygnus.com>
- * @date Tue Sep 22 1998 */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-#include <config.h>
-
-#include <java/lang/String.h>
-#include <java/lang/Float.h>
-#include <java/lang/Double.h>
-#include <java/lang/Integer.h>
-#include <java/lang/Long.h>
-#include <java/lang/Math.h>
-#include <gcj/array.h>
-
-#include "fdlibm.h"
-
-jdouble java::lang::Math::cos(jdouble x)
-{
- return (jdouble)::cos((double)x);
-}
-
-jdouble java::lang::Math::sin(jdouble x)
-{
- return (jdouble)::sin((double)x);
-}
-
-jdouble java::lang::Math::tan(jdouble x)
-{
- return (jdouble)::tan((double)x);
-}
-
-jdouble java::lang::Math::asin(jdouble x)
-{
- return (jdouble)::asin((double)x);
-}
-
-jdouble java::lang::Math::acos(jdouble x)
-{
- return (jdouble)::acos((double)x);
-}
-
-jdouble java::lang::Math::atan(jdouble x)
-{
- return (jdouble)::atan((double)x);
-}
-
-jdouble java::lang::Math::atan2(jdouble y, jdouble x)
-{
- return (jdouble)::atan2((double)y, (double)x);
-}
-
-jdouble java::lang::Math::log(jdouble x)
-{
- return (jdouble)::log((double)x);
-}
-
-jdouble java::lang::Math::exp(jdouble x)
-{
- return (jdouble)::exp((double)x);
-}
-
-jdouble java::lang::Math::sqrt(jdouble x)
-{
- return (jdouble)::sqrt((double)x);
-}
-
-jdouble java::lang::Math::pow(jdouble y, jdouble x)
-{
- return (jdouble)::pow((double)y, (double)x);
-}
-
-jdouble java::lang::Math::IEEEremainder(jdouble y, jdouble x)
-{
- return (jdouble)::__ieee754_remainder((double)y, (double)x);
-}
-
-jdouble java::lang::Math::abs(jdouble x)
-{
- return (jdouble)::fabs((double)x);
-}
-
-jfloat java::lang::Math::abs(jfloat x)
-{
- return (jfloat)::fabsf((float)x);
-}
-
-jdouble java::lang::Math::rint(jdouble x)
-{
- return (jdouble)::rint((double)x);
-}
-
-jint java::lang::Math::round(jfloat x)
-{
- if (x != x)
- return 0;
- if (x <= (jfloat)java::lang::Integer::MIN_VALUE)
- return java::lang::Integer::MIN_VALUE;
- if (x >= (jfloat)java::lang::Integer::MAX_VALUE)
- return java::lang::Integer::MAX_VALUE;
-
- return (jint)::rintf((float)x);
-}
-
-jlong java::lang::Math::round(jdouble x)
-{
- if (x != x)
- return 0;
- if (x <= (jdouble)java::lang::Long::MIN_VALUE)
- return java::lang::Long::MIN_VALUE;
- if (x >= (jdouble)java::lang::Long::MAX_VALUE)
- return java::lang::Long::MAX_VALUE;
-
- return (jlong)::rint((double)x);
-}
-
-jdouble java::lang::Math::floor(jdouble x)
-{
- return (jdouble)::floor((double)x);
-}
-
-jdouble java::lang::Math::ceil(jdouble x)
-{
- return (jdouble)::ceil((double)x);
-}
-
-static inline int
-floatToIntBits (jfloat value)
-{
- union {
- jint l;
- jfloat d;
- } u;
- u.d = value;
- return u.l;
-}
-
-static inline bool
-isNaN (jint bits)
-{
- jint e = bits & 0x7f800000;
- jint f = bits & 0x007fffff;
-
- return e == 0x7f800000 && f != 0;
-}
-
-jfloat
-java::lang::Math::min(jfloat a, jfloat b)
-{
- jint abits = floatToIntBits (a);
- jint bbits = floatToIntBits (b);
-
- if (isNaN (abits) || isNaN (bbits))
- return java::lang::Float::NaN;
-
- if (abits >= 0) // a is +ve
- return bbits < 0 ? b // a is +ve, b is -ve.
- // a and b are both +ve, so compare magnitudes: the number with
- // the smallest magnitude is the smallest
- : (abits < bbits ? a : b);
- else // a is -ve
- return bbits >= 0 ? a // a is -ve, b is +ve.
- // a and b are both -ve, so compare magnitudes: the number with
- // the biggest magnitude is the smallest
- : (abits > bbits ? a : b);
-}
-
-jfloat
-java::lang::Math::max(jfloat a, jfloat b)
-{
- jint abits = floatToIntBits (a);
- jint bbits = floatToIntBits (b);
-
- if (isNaN (abits) || isNaN (bbits))
- return java::lang::Float::NaN;
-
- if (abits >= 0) // a is +ve
- return bbits < 0 ? a // a is +ve, b is -ve.
- // a and b are both +ve, so compare magnitudes: the number with
- // the smallest magnitude is the smallest
- : (abits > bbits ? a : b);
- else // a is -ve
- return bbits >= 0 ? b // a is -ve, b is +ve.
- // a and b are both -ve, so compare magnitudes: the number with
- // the biggest magnitude is the smallest
- : (abits < bbits ? a : b);
-}
-
-static inline jlong
-doubleToLongBits (jdouble value)
-{
- union {
- jlong l;
- jdouble d;
- } u;
- u.d = value;
- return u.l;
-}
-
-static inline bool
-isNaN (jlong bits)
-{
- jlong e = bits & 0x7ff0000000000000LL;
- jlong f = bits & 0x000fffffffffffffLL;
-
- return e == 0x7ff0000000000000LL && f != 0LL;
-}
-
-
-jdouble
-java::lang::Math::min(jdouble a, jdouble b)
-{
- jlong abits = doubleToLongBits (a);
- jlong bbits = doubleToLongBits (b);
-
- if (isNaN (abits) || isNaN (bbits))
- return java::lang::Double::NaN;
-
- if (abits >= 0LL) // a is +ve
- return bbits < 0LL ? b // a is +ve, b is -ve.
- // a and b are both +ve, so compare magnitudes: the number with
- // the smallest magnitude is the smallest
- : (abits < bbits ? a : b);
- else // a is -ve
- return bbits >= 0LL ? a // a is -ve, b is +ve.
- // a and b are both -ve, so compare magnitudes: the number with
- // the biggest magnitude is the smallest
- : (abits > bbits ? a : b);
-}
-
-jdouble
-java::lang::Math::max(jdouble a, jdouble b)
-{
- jlong abits = doubleToLongBits (a);
- jlong bbits = doubleToLongBits (b);
-
- if (isNaN (abits) || isNaN (bbits))
- return java::lang::Double::NaN;
-
- if (abits >= 0LL) // a is +ve
- return bbits < 0LL ? a // a is +ve, b is -ve.
- // a and b are both +ve, so compare magnitudes: the number with
- // the smallest magnitude is the smallest
- : (abits > bbits ? a : b);
- else // a is -ve
- return bbits >= 0LL ? b // a is -ve, b is +ve.
- // a and b are both -ve, so compare magnitudes: the number with
- // the biggest magnitude is the smallest
- : (abits < bbits ? a : b);
-}
-
diff --git a/libjava/java/lang/natObject.cc b/libjava/java/lang/natObject.cc
deleted file mode 100644
index 25b29660ae0..00000000000
--- a/libjava/java/lang/natObject.cc
+++ /dev/null
@@ -1,258 +0,0 @@
-// natObject.cc - Implementation of the Object class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <string.h>
-
-#pragma implementation "Object.h"
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/lang/Object.h>
-#include <java-threads.h>
-#include <java/lang/CloneNotSupportedException.h>
-#include <java/lang/IllegalArgumentException.h>
-#include <java/lang/IllegalMonitorStateException.h>
-#include <java/lang/InterruptedException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/Class.h>
-#include <java/lang/Cloneable.h>
-#include <java/lang/Thread.h>
-
-#define CloneableClass _CL_Q34java4lang9Cloneable
-extern java::lang::Class CloneableClass;
-
-
-
-// This is used to represent synchronization information.
-struct _Jv_SyncInfo
-{
-#if defined (_Jv_HaveCondDestroy) || defined (_Jv_HaveMutexDestroy)
- // We only need to keep track of initialization state if we can
- // possibly finalize this object.
- bool init;
-#endif
- _Jv_ConditionVariable_t condition;
- _Jv_Mutex_t mutex;
-};
-
-
-
-jclass
-java::lang::Object::getClass (void)
-{
- _Jv_VTable **dt = (_Jv_VTable **) this;
- return (*dt)->clas;
-}
-
-jint
-java::lang::Object::hashCode (void)
-{
- return _Jv_HashCode (this);
-}
-
-jobject
-java::lang::Object::clone (void)
-{
- jclass klass = getClass ();
- jobject r;
- jint size;
-
- // We also clone arrays here. If we put the array code into
- // __JArray, then we'd have to figure out a way to find the array
- // vtbl when creating a new array class. This is easier, if uglier.
- if (klass->isArray())
- {
- __JArray *array = (__JArray *) this;
- jclass comp = getClass()->getComponentType();
- jint eltsize;
- if (comp->isPrimitive())
- {
- r = _Jv_NewPrimArray (comp, array->length);
- eltsize = comp->size();
- }
- else
- {
- r = _Jv_NewObjectArray (array->length, comp, NULL);
- eltsize = sizeof (jobject);
- }
- // We can't use sizeof on __JArray because we must account for
- // alignment of the element type.
- size = (_Jv_GetArrayElementFromElementType (array, comp) - (char *) array
- + array->length * eltsize);
- }
- else
- {
- if (! CloneableClass.isAssignableFrom(klass))
- JvThrow (new CloneNotSupportedException);
-
- size = klass->size();
- r = JvAllocObject (klass, size);
- }
-
- memcpy ((void *) r, (void *) this, size);
- return r;
-}
-
-
-//
-// Synchronization code.
-//
-
-// This global is used to make sure that only one thread sets an
-// object's `sync_info' field.
-static _Jv_Mutex_t sync_mutex;
-
-// This macro is used to see if synchronization initialization is
-// needed.
-#if defined (_Jv_HaveCondDestroy) || defined (_Jv_HaveMutexDestroy)
-# define INIT_NEEDED(Obj) (! (Obj)->sync_info \
- || ! ((_Jv_SyncInfo *) ((Obj)->sync_info))->init)
-#else
-# define INIT_NEEDED(Obj) (! (Obj)->sync_info)
-#endif
-
-#if defined (_Jv_HaveCondDestroy) || defined (_Jv_HaveMutexDestroy)
-// If we have to run a destructor for a sync_info member, then this
-// function is registered as a finalizer for the sync_info.
-static void
-finalize_sync_info (jobject obj)
-{
- _Jv_SyncInfo *si = (_Jv_SyncInfo *) obj;
-#if defined (_Jv_HaveCondDestroy)
- _Jv_CondDestroy (&si->condition);
-#endif
-#if defined (_Jv_HaveMutexDestroy)
- _Jv_MutexDestroy (&si->mutex);
-#endif
- si->init = false;
-}
-#endif
-
-// This is called to initialize the sync_info element of an object.
-void
-java::lang::Object::sync_init (void)
-{
- _Jv_MutexLock (&sync_mutex);
- // Check again to see if initialization is needed now that we have
- // the lock.
- if (INIT_NEEDED (this))
- {
- // We assume there are no pointers in the sync_info
- // representation.
- _Jv_SyncInfo *si;
- // We always create a new sync_info, even if there is already
- // one available. Any given object can only be finalized once.
- // If we get here and sync_info is not null, then it has already
- // been finalized. So if we just reinitialize the old one,
- // we'll never be able to (re-)destroy the mutex and/or
- // condition variable.
- si = (_Jv_SyncInfo *) _Jv_AllocBytesChecked (sizeof (_Jv_SyncInfo));
- _Jv_MutexInit (&si->mutex);
- _Jv_CondInit (&si->condition);
-#if defined (_Jv_HaveCondDestroy) || defined (_Jv_HaveMutexDestroy)
- // Register a finalizer.
- si->init = true;
- _Jv_RegisterFinalizer (si, finalize_sync_info);
-#endif
- sync_info = (jobject) si;
- }
- _Jv_MutexUnlock (&sync_mutex);
-}
-
-void
-java::lang::Object::notify (void)
-{
- if (INIT_NEEDED (this))
- sync_init ();
- _Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info;
- if (_Jv_CondNotify (&si->condition, &si->mutex))
- JvThrow (new IllegalMonitorStateException(JvNewStringLatin1
- ("current thread not owner")));
-}
-
-void
-java::lang::Object::notifyAll (void)
-{
- if (INIT_NEEDED (this))
- sync_init ();
- _Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info;
- if (_Jv_CondNotifyAll (&si->condition, &si->mutex))
- JvThrow (new IllegalMonitorStateException(JvNewStringLatin1
- ("current thread not owner")));
-}
-
-void
-java::lang::Object::wait (jlong timeout, jint nanos)
-{
- if (INIT_NEEDED (this))
- sync_init ();
- if (timeout < 0 || nanos < 0 || nanos > 999999)
- JvThrow (new IllegalArgumentException);
- _Jv_SyncInfo *si = (_Jv_SyncInfo *) sync_info;
- switch (_Jv_CondWait (&si->condition, &si->mutex, timeout, nanos))
- {
- case _JV_NOT_OWNER:
- JvThrow (new IllegalMonitorStateException (JvNewStringLatin1
- ("current thread not owner")));
- case _JV_INTERRUPTED:
- if (Thread::interrupted ())
- JvThrow (new InterruptedException);
- }
-}
-
-//
-// Some runtime code.
-//
-
-// This function is called at system startup to initialize the
-// `sync_mutex'.
-void
-_Jv_InitializeSyncMutex (void)
-{
- _Jv_MutexInit (&sync_mutex);
-}
-
-jint
-_Jv_MonitorEnter (jobject obj)
-{
- if (! obj)
- JvThrow (new java::lang::NullPointerException);
- if (INIT_NEEDED (obj))
- obj->sync_init ();
- _Jv_SyncInfo *si = (_Jv_SyncInfo *) obj->sync_info;
- return _Jv_MutexLock (&si->mutex);
-}
-
-jint
-_Jv_MonitorExit (jobject obj)
-{
- JvAssert (obj);
- JvAssert (! INIT_NEEDED (obj));
- _Jv_SyncInfo *si = (_Jv_SyncInfo *) obj->sync_info;
- if (_Jv_MutexUnlock (&si->mutex))
- JvThrow (new java::lang::IllegalMonitorStateException);
- return 0;
-}
-
-void
-_Jv_FinalizeObject (jobject obj)
-{
- // Ignore exceptions. From section 12.6 of the Java Language Spec.
- try
- {
- obj->finalize ();
- }
- catch (java::lang::Throwable *t)
- {
- // Ignore.
- }
-}
diff --git a/libjava/java/lang/natPosixProcess.cc b/libjava/java/lang/natPosixProcess.cc
deleted file mode 100644
index 63e141a64c2..00000000000
--- a/libjava/java/lang/natPosixProcess.cc
+++ /dev/null
@@ -1,209 +0,0 @@
-// natPosixProcess.cc - Native side of POSIX process code.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java/lang/ConcreteProcess.h>
-#include <java/lang/IllegalThreadStateException.h>
-#include <java/lang/InterruptedException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/Thread.h>
-#include <java/io/FileDescriptor.h>
-#include <java/io/FileInputStream.h>
-#include <java/io/FileOutputStream.h>
-#include <java/io/IOException.h>
-
-extern char **environ;
-
-void
-java::lang::ConcreteProcess::destroy (void)
-{
- if (! hasExited)
- {
- // Really kill it.
- kill ((pid_t) pid, SIGKILL);
- }
-}
-
-jint
-java::lang::ConcreteProcess::exitValue (void)
-{
- if (! hasExited)
- {
- int wstat;
- pid_t r = waitpid ((pid_t) pid, &wstat, WNOHANG);
- if (r == -1)
- {
- jstring x = JvNewStringLatin1 (strerror (errno));
- _Jv_Throw (new IllegalThreadStateException (x));
- }
-
- hasExited = true;
- // Just use the raw status. FIXME: what is right?
- status = wstat;
- }
-
- return status;
-}
-
-jint
-java::lang::ConcreteProcess::waitFor (void)
-{
- if (! hasExited)
- {
- int wstat;
- int r = waitpid ((pid_t) pid, &wstat, 0);
-
- if (r != -1)
- {
- hasExited = true;
- // Just use the raw status. FIXME: what is right?
- status = wstat;
- }
-
- if (java::lang::Thread::interrupted())
- _Jv_Throw (new InterruptedException (JvNewStringLatin1 ("wait interrupted")));
- }
-
- return status;
-}
-
-static char *
-new_string (jstring string)
-{
- jsize s = _Jv_GetStringUTFLength (string);
- char *buf = (char *) _Jv_Malloc (s + 1);
- _Jv_GetStringUTFRegion (string, 0, s, buf);
- buf[s] = '\0';
- return buf;
-}
-
-void
-java::lang::ConcreteProcess::startProcess (jstringArray progarray,
- jstringArray envp)
-{
- using namespace java::io;
-
- hasExited = false;
-
- if (! progarray)
- _Jv_Throw (new NullPointerException);
-
- // Transform arrays to native form.
- // FIXME: we use malloc here. We shouldn't. If an exception is
- // thrown we will leak memory.
- char **args = (char **) _Jv_Malloc ((progarray->length + 1)
- * sizeof (char *));
- char **env = NULL;
-
- // FIXME: GC will fail here if _Jv_Malloc throws an exception.
- // That's because we have to manually free the contents, but we
- jstring *elts = elements (progarray);
- for (int i = 0; i < progarray->length; ++i)
- args[i] = new_string (elts[i]);
- args[progarray->length] = NULL;
-
- if (envp)
- {
- env = (char **) _Jv_Malloc ((envp->length + 1) * sizeof (char *));
- elts = elements (envp);
- for (int i = 0; i < envp->length; ++i)
- env[i] = new_string (elts[i]);
- env[envp->length] = NULL;
- }
-
- // Create pipes for I/O.
- int inp[2], outp[2], errp[2];
-
- if (pipe (inp)
- || pipe (outp)
- || pipe (errp))
- {
- ioerror:
- // FIXME.
- _Jv_Free (args);
- if (env)
- _Jv_Free (env);
- _Jv_Throw (new IOException (JvNewStringLatin1 (strerror (errno))));
- }
-
- // We create the streams before forking. Otherwise if we had an
- // error while creating the streams we would have run the child with
- // no way to communicate with it.
- errorStream = new FileInputStream (new FileDescriptor (errp[0]));
- inputStream = new FileInputStream (new FileDescriptor (inp[0]));
- outputStream = new FileOutputStream (new FileDescriptor (outp[1]));
-
- // We don't use vfork() because that would cause the local
- // environment to be set by the child.
- if ((pid = (jlong) fork ()) == -1)
- goto ioerror;
-
- if (pid == 0)
- {
- // Child process, so remap descriptors and exec.
-
- if (envp)
- {
- // preserve PATH unless specified explicitly
- char *path_val = getenv ("PATH");
- environ = env;
- if (getenv ("PATH") == NULL)
- {
- char *path_env = (char *) _Jv_Malloc (strlen (path_val) + 5 + 1);
- strcpy (path_env, "PATH=");
- strcat (path_env, path_val);
- putenv (path_env);
- }
- }
-
- // We ignore errors from dup2 because they should never occur.
- dup2 (outp[0], 0);
- dup2 (inp[1], 1);
- dup2 (errp[1], 2);
-
- close (inp[0]);
- close (inp[1]);
- close (errp[0]);
- close (errp[1]);
- close (outp[0]);
- close (outp[1]);
-
- execvp (args[0], args);
- // FIXME: should throw an IOException if execvp() fails. Not trivial,
- // because _Jv_Throw won't work from child process
- _exit (127);
- }
-
- // Parent. Close extra file descriptors and mark ours as
- // close-on-exec.
- close (outp[0]);
- close (inp[1]);
- close (errp[1]);
-
- fcntl (outp[1], F_SETFD, 1);
- fcntl (inp[0], F_SETFD, 1);
- fcntl (errp[0], F_SETFD, 1);
-}
diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc
deleted file mode 100644
index ad45066c261..00000000000
--- a/libjava/java/lang/natRuntime.cc
+++ /dev/null
@@ -1,210 +0,0 @@
-// natRuntime.cc - Implementation of native side of Runtime class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <stdlib.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/lang/Runtime.h>
-#include <java/lang/UnknownError.h>
-#include <java/lang/UnsatisfiedLinkError.h>
-
-#include <jni.h>
-
-#ifdef USE_LTDL
-#include <ltdl.h>
-
-/* FIXME: we don't always need this. The next libtool will let us use
- AC_LTDL_PREOPEN to see if we do. */
-const lt_dlsymlist lt_preloaded_symbols[1] = { { 0, 0 } };
-
-// We keep track of all the libraries loaded by this application. For
-// now we use them to look up symbols for JNI. `libraries_size' holds
-// the total size of the buffer. `libraries_count' is the number of
-// items which are in use.
-static int libraries_size;
-static int libraries_count;
-static lt_dlhandle *libraries;
-
-static void
-add_library (lt_dlhandle lib)
-{
- if (libraries_count == libraries_size)
- {
- int ns = libraries_size * 2;
- if (ns == 0)
- ns = 10;
- lt_dlhandle *n = (lt_dlhandle *) _Jv_Malloc (ns * sizeof (lt_dlhandle));
- if (libraries)
- {
- memcpy (n, libraries, libraries_size * sizeof (lt_dlhandle));
- _Jv_Free (libraries);
- }
- libraries = n;
- libraries_size = ns;
- for (int i = libraries_count; i < libraries_size; ++i)
- libraries[i] = NULL;
- }
-
- libraries[libraries_count++] = lib;
-}
-
-void *
-_Jv_FindSymbolInExecutable (const char *symname)
-{
- for (int i = 0; i < libraries_count; ++i)
- {
- void *r = lt_dlsym (libraries[i], symname);
- if (r)
- return r;
- }
-
- return lt_dlsym (NULL, symname);
-}
-
-#endif /* USE_LTDL */
-
-void
-java::lang::Runtime::exit (jint status)
-{
- checkExit (status);
-
- // Make status right for Unix. This is perhaps strange.
- if (status < 0 || status > 255)
- status = 255;
-
- if (finalize_on_exit)
- _Jv_RunAllFinalizers ();
-
- ::exit (status);
-}
-
-jlong
-java::lang::Runtime::freeMemory (void)
-{
- return _Jv_GCFreeMemory ();
-}
-
-void
-java::lang::Runtime::gc (void)
-{
- _Jv_RunGC ();
-}
-
-void
-java::lang::Runtime::_load (jstring path, jboolean do_search)
-{
- JvSynchronize sync (this);
- checkLink (path);
- using namespace java::lang;
-#ifdef USE_LTDL
- jint len = _Jv_GetStringUTFLength (path);
- char buf[len + 1 + 3];
- int offset = 0;
-#ifndef WIN32
- // On Unix boxes, prefix library name with `lib', for loadLibrary.
- if (do_search)
- {
- strcpy (buf, "lib");
- offset = 3;
- }
-#endif
- jsize total = JvGetStringUTFRegion (path, 0, path->length(), &buf[offset]);
- buf[offset + total] = '\0';
- // FIXME: make sure path is absolute.
- lt_dlhandle h = do_search ? lt_dlopenext (buf) : lt_dlopen (buf);
- if (h == NULL)
- {
- const char *msg = lt_dlerror ();
- jstring str = path->concat (JvNewStringLatin1 (": "));
- str = str->concat (JvNewStringLatin1 (msg));
- _Jv_Throw (new UnsatisfiedLinkError (str));
- }
-
- add_library (h);
-
- void *onload = lt_dlsym (h, "JNI_OnLoad");
- if (onload != NULL)
- {
- JavaVM *vm = _Jv_GetJavaVM ();
- if (vm == NULL)
- {
- // FIXME: what?
- return;
- }
- jint vers = ((jint (*) (JavaVM *, void *)) onload) (vm, NULL);
- if (vers != JNI_VERSION_1_1 && vers != JNI_VERSION_1_2)
- {
- // FIXME: unload the library.
- _Jv_Throw (new UnsatisfiedLinkError (JvNewStringLatin1 ("unrecognized version from JNI_OnLoad")));
- }
- }
-#else
- _Jv_Throw (new UnknownError
- (JvNewStringLatin1 (do_search
- ? "Runtime.loadLibrary not implemented"
- : "Runtime.load not implemented")));
-#endif /* USE_LTDL */
-}
-
-jboolean
-java::lang::Runtime::loadLibraryInternal (jstring lib)
-{
- JvSynchronize sync (this);
- using namespace java::lang;
-#ifdef USE_LTDL
- jint len = _Jv_GetStringUTFLength (lib);
- char buf[len + 1];
- jsize total = JvGetStringUTFRegion (lib, 0, lib->length(), buf);
- buf[total] = '\0';
- // FIXME: make sure path is absolute.
- lt_dlhandle h = lt_dlopenext (buf);
- if (h != NULL)
- add_library (h);
- return h != NULL;
-#else
- return false;
-#endif /* USE_LTDL */
-}
-
-void
-java::lang::Runtime::init (void)
-{
- finalize_on_exit = false;
-#ifdef USE_LTDL
- lt_dlinit ();
-#endif
-}
-
-void
-java::lang::Runtime::runFinalization (void)
-{
- _Jv_RunFinalizers ();
-}
-
-jlong
-java::lang::Runtime::totalMemory (void)
-{
- return _Jv_GCTotalMemory ();
-}
-
-void
-java::lang::Runtime::traceInstructions (jboolean)
-{
- // Do nothing.
-}
-
-void
-java::lang::Runtime::traceMethodCalls (jboolean)
-{
- // Do nothing.
-}
diff --git a/libjava/java/lang/natString.cc b/libjava/java/lang/natString.cc
deleted file mode 100644
index 3a39f238f49..00000000000
--- a/libjava/java/lang/natString.cc
+++ /dev/null
@@ -1,848 +0,0 @@
-// natString.cc - Implementation of java.lang.String native methods.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <string.h>
-#include <stdlib.h>
-
-#include <gcj/cni.h>
-#include <java/lang/Character.h>
-#include <java/lang/String.h>
-#include <java/lang/IndexOutOfBoundsException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/StringIndexOutOfBoundsException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/io/ByteArrayOutputStream.h>
-#include <java/io/OutputStreamWriter.h>
-#include <java/io/ByteArrayInputStream.h>
-#include <java/io/InputStreamReader.h>
-#include <gnu/gcj/convert/UnicodeToBytes.h>
-#include <gnu/gcj/convert/BytesToUnicode.h>
-#include <jvm.h>
-
-static jstring* strhash = NULL;
-static int strhash_count = 0; /* Number of slots used in strhash. */
-static int strhash_size = 0; /* Number of slots available in strhash.
- * Assumed be power of 2! */
-
-#define DELETED_STRING ((jstring)(~0))
-#define SET_STRING_IS_INTERNED(STR) /* nothing */
-
-/* Find a slot where the string with elements DATA, length LEN,
- and hash HASH should go in the strhash table of interned strings. */
-jstring*
-_Jv_StringFindSlot (jchar* data, jint len, jint hash)
-{
- JvSynchronize sync (&StringClass);
-
- int start_index = hash & (strhash_size - 1);
- int deleted_index = -1;
-
- register int index = start_index;
- /* step must be non-zero, and relatively prime with strhash_size. */
- int step = 8 * hash + 7;
- for (;;)
- {
- register jstring* ptr = &strhash[index];
- if (*ptr == NULL)
- {
- if (deleted_index >= 0)
- return (&strhash[deleted_index]);
- else
- return ptr;
- }
- else if (*ptr == DELETED_STRING)
- deleted_index = index;
- else if ((*ptr)->length() == len
- && memcmp(JvGetStringChars(*ptr), data, 2*len) == 0)
- return (ptr);
- index = (index + step) & (strhash_size - 1);
- JvAssert (index != start_index);
- }
-}
-
-/* Calculate a hash code for the string starting at PTR at given LENGTH.
- This uses the same formula as specified for java.lang.String.hash. */
-
-static jint
-hashChars (jchar* ptr, jint length)
-{
- register jchar* limit = ptr + length;
- jint hash = 0;
- // Updated specification from
- // http://www.javasoft.com/docs/books/jls/clarify.html.
- while (ptr < limit)
- hash = (31 * hash) + *ptr++;
- return hash;
-}
-
-jint
-java::lang::String::hashCode()
-{
- return hashChars(JvGetStringChars(this), length());
-}
-
-jstring*
-_Jv_StringGetSlot (jstring str)
-{
- jchar* data = JvGetStringChars(str);
- int length = str->length();
- return _Jv_StringFindSlot(data, length, hashChars (data, length));
-}
-
-void
-java::lang::String::rehash()
-{
- JvSynchronize sync (&StringClass);
-
- if (strhash == NULL)
- {
- strhash_size = 1024;
- strhash = (jstring *) _Jv_AllocBytes (strhash_size * sizeof (jstring));
- memset (strhash, 0, strhash_size * sizeof (jstring));
- }
- else
- {
- register int i = strhash_size;
- register jstring* ptr = strhash + i;
- strhash_size *= 2;
- strhash = (jstring *) _Jv_AllocBytes (strhash_size * sizeof (jstring));
- memset (strhash, 0, strhash_size * sizeof (jstring));
-
- while (--i >= 0)
- {
- --ptr;
- if (*ptr == NULL || *ptr == DELETED_STRING)
- continue;
-
- /* This is faster equivalent of
- * *__JvGetInternSlot(*ptr) = *ptr; */
- jint hash = (*ptr)->hashCode();
- jint index = hash & (strhash_size - 1);
- jint step = 8 * hash + 7;
- for (;;)
- {
- if (strhash[index] == NULL)
- {
- strhash[index] = *ptr;
- break;
- }
- index = (index + step) & (strhash_size - 1);
- }
- }
- }
-}
-
-jstring
-java::lang::String::intern()
-{
- JvSynchronize sync (&StringClass);
- if (4 * strhash_count >= 3 * strhash_size)
- rehash();
- jstring* ptr = _Jv_StringGetSlot(this);
- if (*ptr != NULL && *ptr != DELETED_STRING)
- return *ptr;
- SET_STRING_IS_INTERNED(this);
- strhash_count++;
- *ptr = this;
- return this;
-}
-
-/* Called by String fake finalizer. */
-void
-java::lang::String::unintern()
-{
- JvSynchronize sync (&StringClass);
- jstring* ptr = _Jv_StringGetSlot(this);
- if (*ptr == NULL || *ptr == DELETED_STRING)
- return;
- *ptr = DELETED_STRING;
- strhash_count--;
-}
-
-jstring
-_Jv_NewStringUTF (const char *bytes)
-{
- int size = strlen (bytes);
- unsigned char *p = (unsigned char *) bytes;
-
- int length = _Jv_strLengthUtf8 ((char *) p, size);
- if (length < 0)
- return NULL;
-
- jstring jstr = JvAllocString (length);
- jchar *chrs = JvGetStringChars (jstr);
-
- p = (unsigned char *) bytes;
- unsigned char *limit = p + size;
- while (p < limit)
- *chrs++ = UTF8_GET (p, limit);
-
- return jstr;
-}
-
-jstring
-_Jv_NewStringUtf8Const (Utf8Const* str)
-{
- jchar *chrs;
- jchar buffer[100];
- jstring jstr;
- register unsigned char* data = (unsigned char*) str->data;
- register unsigned char* limit = data + str->length;
- int length = _Jv_strLengthUtf8(str->data, str->length);
-
- if (length <= (int) (sizeof(buffer) / sizeof(jchar)))
- {
- jstr = NULL;
- chrs = buffer;
- }
- else
- {
- jstr = JvAllocString(length);
- chrs = JvGetStringChars(jstr);
- }
-
- while (data < limit)
- *chrs++ = UTF8_GET(data, limit);
- chrs -= length;
-
- JvSynchronize sync (&StringClass);
- if (4 * strhash_count >= 3 * strhash_size)
- java::lang::String::rehash();
- int hash = str->hash;
- jstring* ptr = _Jv_StringFindSlot (chrs, length, hash);
- if (*ptr != NULL && *ptr != DELETED_STRING)
- return *ptr;
- strhash_count++;
- if (jstr == NULL)
- {
- jstr = JvAllocString(length);
- chrs = JvGetStringChars(jstr);
- memcpy (chrs, buffer, sizeof(jchar)*length);
- }
- *ptr = jstr;
- SET_STRING_IS_INTERNED(jstr);
- return jstr;
-}
-
-jsize
-_Jv_GetStringUTFLength (jstring string)
-{
- register jsize len = 0;
- register jchar *ptr = JvGetStringChars (string);
- register jsize i = string->length();
- while (--i >= 0)
- {
- register jchar ch = *ptr++;
- if (ch > 0 && ch <= 0x7F)
- len += 1;
- else if (ch <= 0x7FF)
- len += 2;
- else
- len += 3;
- }
- return len;
-}
-
-// Not sure this quite matches GetStringUTFRegion.
-// null-termination of result? len? throw exception?
-jsize
-_Jv_GetStringUTFRegion (jstring str, jsize start, jsize len, char *buf)
-{
- register jchar *sptr = JvGetStringChars (str) + start;
- register jsize i = len;
- register char *dptr = buf;
- while (--i >= 0)
- {
- jchar ch = *sptr++;
- if (ch > 0 && ch <= 0x7F)
- *dptr++ = (char) ch;
- else if (ch <= 0x7FF)
- {
- *dptr++ = (char) (0xC0 + ((ch >> 6) & 0x1F));
- *dptr++ = (char) (0x80 + (ch & 0x3F));
- }
- else
- {
- *dptr++ = (char) (0xE0 + ((ch >> 12) & 0xF));
- *dptr++ = (char) (0x80 + ((ch >> 6) & 0x3F));
- *dptr++ = (char) (0x80 + (ch & 0x3F));
- }
- }
- return dptr - buf;
-}
-
-jstring
-_Jv_AllocString(jsize len)
-{
- jsize sz = sizeof(java::lang::String) + len * sizeof(jchar);
-
- jstring obj = (jstring) JvAllocObject(&StringClass, sz);
-
- obj->data = obj;
- obj->boffset = sizeof(java::lang::String);
- obj->count = len;
- return obj;
-}
-
-jstring
-_Jv_NewString(const jchar *chars, jsize len)
-{
- jstring str = _Jv_AllocString(len);
- jchar* data = JvGetStringChars (str);
- while (--len >= 0)
- *data++ = *chars++;
- return str;
-}
-
-jstring
-_Jv_NewStringLatin1(const char *bytes, jsize len)
-{
- jstring str = JvAllocString(len);
- jchar* data = JvGetStringChars (str);
- while (--len >= 0)
- *data++ = *(unsigned char*)bytes++;
- return str;
-}
-
-void
-java::lang::String::init ()
-{
- count = 0;
- boffset = sizeof(java::lang::String);
- data = this;
-}
-
-void
-java::lang::String::init(jcharArray chars, jint offset, jint count,
- jboolean dont_copy)
-{
- if (! chars)
- JvThrow (new NullPointerException);
- jsize data_size = JvGetArrayLength (chars);
- if (offset < 0 || count < 0 || offset + count < 0
- || offset + count > data_size)
- JvThrow (new StringIndexOutOfBoundsException());
- jcharArray array;
- jchar *pdst;
- if (! dont_copy)
- {
- array = JvNewCharArray(count);
- pdst = elements (array);
- memcpy (pdst, elements (chars) + offset, count * sizeof (jchar));
- }
- else
- {
- JvAssert (offset == 0);
- array = chars;
- pdst = elements (array);
- }
-
- data = array;
- boffset = (char *) pdst - (char *) array;
- this->count = count;
-}
-
-void
-java::lang::String::init(jbyteArray ascii, jint hibyte, jint offset,
- jint count)
-{
- if (! ascii)
- JvThrow (new NullPointerException);
- jsize data_size = JvGetArrayLength (ascii);
- if (offset < 0 || count < 0 || offset + count < 0
- || offset + count > data_size)
- JvThrow (new java::lang::StringIndexOutOfBoundsException());
- jcharArray array = JvNewCharArray(count);
- jbyte *psrc = elements (ascii) + offset;
- jchar *pdst = elements (array);
- data = array;
- boffset = (char *) pdst - (char *) array;
- this->count = count;
- hibyte = (hibyte & 0xff) << 8;
- while (-- count >= 0)
- {
- *pdst++ = hibyte | (*psrc++ & 0xff);
- }
-}
-
-void
-java::lang::String::init (jbyteArray bytes, jint offset, jint count,
- jstring encoding)
-{
- if (! bytes)
- JvThrow (new NullPointerException);
- jsize data_size = JvGetArrayLength (bytes);
- if (offset < 0 || count < 0 || offset + count < 0
- || offset + count > data_size)
- JvThrow (new StringIndexOutOfBoundsException);
- jcharArray array = JvNewCharArray (count);
- gnu::gcj::convert::BytesToUnicode *converter
- = gnu::gcj::convert::BytesToUnicode::getDecoder(encoding);
- jint outpos = 0;
- int avail = count;
- converter->setInput(bytes, offset, offset+count);
- while (converter->inpos < converter->inlength)
- {
- int done = converter->read(array, outpos, avail);
- if (done == 0)
- {
- jint new_size = 2 * (outpos + avail);
- jcharArray new_array = JvNewCharArray (new_size);
- memcpy (elements (new_array), elements (array),
- outpos * sizeof(jchar));
- array = new_array;
- avail = new_size - outpos;
- }
- else
- {
- outpos += done;
- avail -= done;
- }
- }
- this->data = array;
- this->boffset = (char *) elements (array) - (char *) array;
- this->count = outpos;
-}
-
-jboolean
-java::lang::String::equals(jobject anObject)
-{
- if (anObject == NULL)
- return false;
- if (anObject == this)
- return true;
- if (anObject->getClass() != &StringClass)
- return false;
- jstring other = (jstring) anObject;
- if (count != other->count)
- return false;
- /* if both are interned, return false. */
- register jint i = count;
- register jchar *xptr = JvGetStringChars (this);
- register jchar *yptr = JvGetStringChars (other);
- while (--i >= 0)
- {
- if (*xptr++ != *yptr++)
- return false;
- }
- return true;
-}
-
-jchar
-java::lang::String::charAt(jint i)
-{
- if (i < 0 || i >= count)
- JvThrow (new java::lang::StringIndexOutOfBoundsException());
- return JvGetStringChars(this)[i];
-}
-
-void
-java::lang::String::getChars(jint srcBegin, jint srcEnd,
- jcharArray dst, jint dstBegin)
-{
- jint dst_length = JvGetArrayLength (dst);
- if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count
- || dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
- JvThrow (new java::lang::StringIndexOutOfBoundsException());
- register jchar *dPtr = elements (dst) + dstBegin;
- register jchar *sPtr = JvGetStringChars (this) + srcBegin;
- register jint i = srcEnd-srcBegin;
- while (--i >= 0)
- *dPtr++ = *sPtr++;
-}
-
-jbyteArray
-java::lang::String::getBytes (jstring enc)
-{
- jint todo = length();
- jint buflen = todo;
- jbyteArray buffer = JvNewByteArray(todo);
- jint bufpos = 0;
- jint offset = 0;
- gnu::gcj::convert::UnicodeToBytes *converter
- = gnu::gcj::convert::UnicodeToBytes::getEncoder(enc);
- while (todo > 0)
- {
- converter->setOutput(buffer, bufpos);
- int converted = converter->write(this, offset, todo, NULL);
- bufpos = converter->count;
- if (converted == 0)
- {
- buflen *= 2;
- jbyteArray newbuffer = JvNewByteArray(buflen);
- memcpy (elements (newbuffer), elements (buffer), bufpos);
- buffer = newbuffer;
- }
- else
- {
- offset += converted;
- todo -= converted;
- }
- }
- if (bufpos == buflen)
- return buffer;
- jbyteArray result = JvNewByteArray(bufpos);
- memcpy (elements (result), elements (buffer), bufpos);
- return result;
-}
-
-void
-java::lang::String::getBytes(jint srcBegin, jint srcEnd,
- jbyteArray dst, jint dstBegin)
-{
- jint dst_length = JvGetArrayLength (dst);
- if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count
- || dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
- JvThrow (new java::lang::StringIndexOutOfBoundsException());
- register jbyte *dPtr = elements (dst) + dstBegin;
- register jchar *sPtr = JvGetStringChars (this) + srcBegin;
- register jint i = srcEnd-srcBegin;
- while (--i >= 0)
- *dPtr++ = (jbyte) *sPtr++;
-}
-
-jcharArray
-java::lang::String::toCharArray()
-{
- jcharArray array = JvNewCharArray(count);
- register jchar *dPtr = elements (array);
- register jchar *sPtr = JvGetStringChars (this);
- register jint i = count;
- while (--i >= 0)
- *dPtr++ = *sPtr++;
- return array;
-}
-
-jboolean
-java::lang::String::equalsIgnoreCase (jstring anotherString)
-{
- if (anotherString == NULL || count != anotherString->count)
- return false;
- register jchar *tptr = JvGetStringChars (this);
- register jchar *optr = JvGetStringChars (anotherString);
- register jint i = count;
- while (--i >= 0)
- {
- jchar tch = *tptr++;
- jchar och = *optr++;
- if (tch != och
- && (java::lang::Character::toLowerCase (tch)
- != java::lang::Character::toLowerCase (och))
- && (java::lang::Character::toUpperCase (tch)
- != java::lang::Character::toUpperCase (och)))
- return false;
- }
- return true;
-}
-
-jboolean
-java::lang::String::regionMatches (jint toffset,
- jstring other, jint ooffset, jint len)
-{
- if (toffset < 0 || ooffset < 0
- || toffset + len > count
- || ooffset + len > other->count)
- return false;
- register jchar *tptr = JvGetStringChars (this) + toffset;
- register jchar *optr = JvGetStringChars (other) + ooffset;
- register jint i = len;
- while (--i >= 0)
- {
- if (*tptr++ != *optr++)
- return false;
- }
- return true;
-}
-
-jint
-java::lang::String::compareTo (jstring anotherString)
-{
- register jchar *tptr = JvGetStringChars (this);
- register jchar *optr = JvGetStringChars (anotherString);
- jint tlen = this->count;
- jint olen = anotherString->count;
- register jint i = tlen > olen ? olen : tlen;
- while (--i >= 0)
- {
- jchar tch = *tptr++;
- jchar och = *optr++;
- if (tch != och)
- return (jint) tch - (jint) och;
- }
- return tlen - olen;
-}
-
-jboolean
-java::lang::String::regionMatches (jboolean ignoreCase, jint toffset,
- jstring other, jint ooffset, jint len)
-{
- if (toffset < 0 || ooffset < 0
- || toffset + len > count
- || ooffset + len > other->count)
- return false;
- register jchar *tptr = JvGetStringChars (this) + toffset;
- register jchar *optr = JvGetStringChars (other) + ooffset;
- register jint i = len;
- if (ignoreCase)
- while (--i >= 0)
- {
- jchar tch = *tptr++;
- jchar och = *optr++;
- if ((java::lang::Character::toLowerCase (tch)
- != java::lang::Character::toLowerCase (och))
- && (java::lang::Character::toUpperCase (tch)
- != java::lang::Character::toUpperCase (och)))
- return false;
- }
- else
- while (--i >= 0)
- {
- jchar tch = *tptr++;
- jchar och = *optr++;
- if (tch != och)
- return false;
- }
- return true;
-}
-
-jboolean
-java::lang::String::startsWith (jstring prefix, jint toffset)
-{
- register jint i = prefix->count;
- if (toffset < 0 || toffset + i > count)
- return false;
- register jchar *xptr = JvGetStringChars (this) + toffset;
- register jchar *yptr = JvGetStringChars (prefix);
- while (--i >= 0)
- {
- if (*xptr++ != *yptr++)
- return false;
- }
- return true;
-}
-
-jint
-java::lang::String::indexOf (jint ch, jint fromIndex)
-{
- if (fromIndex < 0)
- fromIndex = 0;
- register jchar *ptr = JvGetStringChars(this);
- for (;; ++fromIndex)
- {
- if (fromIndex >= count)
- return -1;
- if (ptr[fromIndex] == ch)
- return fromIndex;
- }
-}
-
-jint
-java::lang::String::indexOf (jstring s, jint fromIndex)
-{
- const jchar *const xchars = JvGetStringChars(s);
- const jchar *const ychars = JvGetStringChars(this) + fromIndex;
-
- const int xlength = s->length ();
- const int ylength = length () - fromIndex;
-
- int i = 0;
- int j = 0;
-
- while (i < ylength && j < xlength)
- {
- if (xchars[j] != ychars[i])
- {
- i = i - j + 1;
- j = 0;
- }
- else
- i++, j++;
- }
-
- if (j >= xlength)
- return fromIndex + i - xlength;
- else
- return -1;
-}
-
-jint
-java::lang::String::lastIndexOf (jint ch, jint fromIndex)
-{
- if (fromIndex >= count)
- fromIndex = count - 1;
- register jchar *ptr = JvGetStringChars(this);
- for (;; --fromIndex)
- {
- if (fromIndex < 0)
- return -1;
- if (ptr[fromIndex] == ch)
- return fromIndex;
- }
-}
-
-jstring
-java::lang::String::substring (jint beginIndex, jint endIndex)
-{
- if (beginIndex < 0 || endIndex > count || beginIndex > endIndex)
- JvThrow (new StringIndexOutOfBoundsException());
- if (beginIndex == 0 && endIndex == count)
- return this;
- jint newCount = endIndex - beginIndex;
- if (newCount <= 8) // Optimization, mainly for GC.
- return JvNewString(JvGetStringChars(this) + beginIndex, newCount);
- jstring s = new String();
- s->data = data;
- s->count = newCount;
- s->boffset = boffset + sizeof(jchar) * beginIndex;
- return s;
-}
-
-jstring
-java::lang::String::concat(jstring str)
-{
- jint str_count = str->count;
- if (str_count == 0)
- return this;
- jstring result = JvAllocString(count + str_count);
- register jchar *dstPtr = JvGetStringChars(result);
- register jchar *srcPtr = JvGetStringChars(this);
- register jint i = count;
- while (--i >= 0)
- *dstPtr++ = *srcPtr++;
- srcPtr = JvGetStringChars(str);
- i = str->count;
- while (--i >= 0)
- *dstPtr++ = *srcPtr++;
- return result;
-}
-
-jstring
-java::lang::String::replace (jchar oldChar, jchar newChar)
-{
- jint i;
- jchar* chrs = JvGetStringChars (this);
- for (i = 0; ; i++)
- {
- if (i == count)
- return this;
- if (chrs[i] == oldChar)
- break;
- }
- jstring result = JvAllocString (count);
- jchar *dPtr = JvGetStringChars (result);
- for (int j = 0; j < i; j++)
- *dPtr++ = chrs[j];
- for (; i < count; i++)
- {
- jchar ch = chrs[i];
- if (ch == oldChar)
- ch = newChar;
- *dPtr++ = ch;
- }
- return result;
-}
-
-jstring
-java::lang::String::toLowerCase ()
-{
- jint i;
- jchar* chrs = JvGetStringChars(this);
- jchar ch;
- for (i = 0; ; i++)
- {
- if (i == count)
- return this;
- jchar origChar = chrs[i];
- ch = java::lang::Character::toLowerCase(origChar);
- if (ch != origChar)
- break;
- }
- jstring result = JvAllocString(count);
- jchar *dPtr = JvGetStringChars (result);
- for (int j = 0; j < i; j++)
- *dPtr++ = chrs[j];
- *dPtr++ = ch; i++;
- for (; i < count; i++)
- {
- *dPtr++ = java::lang::Character::toLowerCase(chrs[i]);
- }
- return result;
-}
-
-jstring
-java::lang::String::toUpperCase ()
-{
- jint i;
- jchar* chrs = JvGetStringChars(this);
- jchar ch;
- for (i = 0; ; i++)
- {
- if (i == count)
- return this;
- jchar origChar = chrs[i];
- ch = java::lang::Character::toUpperCase(origChar);
- if (ch != origChar)
- break;
- }
- jstring result = JvAllocString(count);
- jchar *dPtr = JvGetStringChars (result);
- for (int j = 0; j < i; j++)
- *dPtr++ = chrs[j];
- *dPtr++ = ch; i++;
- for (; i < count; i++)
- {
- *dPtr++ = java::lang::Character::toUpperCase(chrs[i]);
- }
- return result;
-}
-
-jstring
-java::lang::String::trim ()
-{
- jchar* chrs = JvGetStringChars(this);
- if (count == 0 || (chrs[0] > ' ' && chrs[count-1] > ' '))
- return this;
- jint preTrim = 0;
- for (;; preTrim++)
- {
- if (preTrim == count)
- return new String();
- if (chrs[preTrim] > ' ')
- break;
- }
- jint endTrim = count;
- while (chrs[endTrim-1] <= ' ')
- endTrim--;
- return substring(preTrim, endTrim);
-}
-
-jstring
-java::lang::String::valueOf(jcharArray data, jint offset, jint count)
-{
- jint data_length = JvGetArrayLength (data);
- if (offset < 0 || count < 0 || offset+count > data_length)
- JvThrow (new java::lang::IndexOutOfBoundsException());
- register jstring result = JvAllocString(count);
- register jchar *sPtr = elements (data) + offset;
- register jchar *dPtr = JvGetStringChars(result);
- while (--count >= 0)
- *dPtr++ = *sPtr++;
- return result;
-}
-
-jstring
-java::lang::String::valueOf(jchar c)
-{
- register jstring result = JvAllocString(1);
- JvGetStringChars (result)[0] = c;
- return result;
-}
diff --git a/libjava/java/lang/natSystem.cc b/libjava/java/lang/natSystem.cc
deleted file mode 100644
index 66448b7d5df..00000000000
--- a/libjava/java/lang/natSystem.cc
+++ /dev/null
@@ -1,389 +0,0 @@
-// natSystem.cc - Native code implementing System class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#ifdef HAVE_GETPWUID_R
-#define _POSIX_PTHREAD_SEMANTICS
-#ifndef _REENTRANT
-#define _REENTRANT
-#endif
-#endif
-
-#include <string.h>
-#include <time.h>
-#include <stdlib.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-#include <errno.h>
-
-#ifdef HAVE_UNAME
-#include <sys/utsname.h>
-#endif
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java-props.h>
-#include <java/lang/System.h>
-#include <java/lang/Class.h>
-#include <java/lang/ArrayStoreException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/util/Properties.h>
-#include <java/io/PrintStream.h>
-#include <java/io/InputStream.h>
-
-#define SystemClass _CL_Q34java4lang6System
-extern java::lang::Class SystemClass;
-
-
-
-#if defined (ECOS)
-extern "C" unsigned long long _clock (void);
-#endif
-
-void
-java::lang::System::setErr (java::io::PrintStream *newErr)
-{
- checkSetIO ();
- // This violates `final' semantics. Oh well.
- err = newErr;
-}
-
-void
-java::lang::System::setIn (java::io::InputStream *newIn)
-{
- checkSetIO ();
- // This violates `final' semantics. Oh well.
- in = newIn;
-}
-
-void
-java::lang::System::setOut (java::io::PrintStream *newOut)
-{
- checkSetIO ();
- // This violates `final' semantics. Oh well.
- out = newOut;
-}
-
-void
-java::lang::System::arraycopy (jobject src, jint src_offset,
- jobject dst, jint dst_offset,
- jint count)
-{
- if (! src || ! dst)
- _Jv_Throw (new NullPointerException);
-
- jclass src_c = src->getClass();
- jclass dst_c = dst->getClass();
- jclass src_comp = src_c->getComponentType();
- jclass dst_comp = dst_c->getComponentType();
-
- if (! src_c->isArray() || ! dst_c->isArray()
- || src_comp->isPrimitive() != dst_comp->isPrimitive()
- || (src_comp->isPrimitive() && src_comp != dst_comp))
- _Jv_Throw (new ArrayStoreException);
-
- __JArray *src_a = (__JArray *) src;
- __JArray *dst_a = (__JArray *) dst;
- if (src_offset < 0 || dst_offset < 0 || count < 0
- || src_offset + count > src_a->length
- || dst_offset + count > dst_a->length)
- _Jv_Throw (new ArrayIndexOutOfBoundsException);
-
- // Do-nothing cases.
- if ((src == dst && src_offset == dst_offset)
- || ! count)
- return;
-
- // If both are primitive, we can optimize trivially. If DST
- // components are always assignable from SRC components, then we
- // will never need to raise an error, and thus can do the
- // optimization. If source and destinations are the same, then we
- // know that the assignability premise always holds.
- const bool prim = src_comp->isPrimitive();
- if (prim || dst_comp->isAssignableFrom(src_comp) || src == dst)
- {
- const size_t size = (prim ? src_comp->size()
- : sizeof elements((jobjectArray)src)[0]);
-
- char *src_elts = _Jv_GetArrayElementFromElementType (src, src_comp);
- src_elts += size * src_offset;
-
- char *dst_elts = _Jv_GetArrayElementFromElementType (dst, dst_comp);
- dst_elts += size * dst_offset;
-
-#if HAVE_MEMMOVE
- // We don't bother trying memcpy. It can't be worth the cost of
- // the check.
- // Don't cast to (void*), as memmove may expect (char*)
- memmove (dst_elts, src_elts, count * size);
-#else
- bcopy (src_elts, dst_elts, count * size);
-#endif
- }
- else
- {
- jobject *src_elts = elements ((jobjectArray) src_a) + src_offset;
- jobject *dst_elts = elements ((jobjectArray) dst_a) + dst_offset;
-
- for (int i = 0; i < count; ++i)
- {
- if (*src_elts
- && ! dst_comp->isAssignableFrom((*src_elts)->getClass()))
- _Jv_Throw (new ArrayStoreException);
- *dst_elts++ = *src_elts++;
- }
- }
-}
-
-jlong
-java::lang::System::currentTimeMillis (void)
-{
- jlong r;
-
-#if defined (HAVE_GETTIMEOFDAY)
- struct timeval tv;
- gettimeofday (&tv, NULL);
- r = (jlong) tv.tv_sec * 1000 + tv.tv_usec / 1000;
-#elif defined (HAVE_TIME)
- r = time (NULL) * 1000;
-#elif defined (HAVE_FTIME)
- struct timeb t;
- ftime (&t);
- r = t.time * 1000 + t.millitm;
-#elif defined (ECOS)
- r = _clock();
-#else
- // In the absence of any function, time remains forever fixed.
- r = 23;
-#endif
-
- return r;
-}
-
-jint
-java::lang::System::identityHashCode (jobject obj)
-{
- return _Jv_HashCode (obj);
-}
-
-#ifndef DEFAULT_FILE_ENCODING
-#define DEFAULT_FILE_ENCODING "8859_1"
-#endif
-static char *default_file_encoding = DEFAULT_FILE_ENCODING;
-
-#if HAVE_GETPWUID_R
-/* Use overload resolution to find out the signature of getpwuid_r. */
-
- /* This is Posix getpwuid_r. */
-template <typename T_uid, typename T_passwd, typename T_buf, typename T_len>
-static inline int
-getpwuid_adaptor(int (*getpwuid_r)(T_uid user_id, T_passwd *pwd_r,
- T_buf *buf_r, T_len len_r,
- T_passwd **pwd_entry_ptr),
- uid_t user_id, struct passwd *pwd_r,
- char *buf_r, size_t len_r, struct passwd **pwd_entry)
-{
- return getpwuid_r (user_id, pwd_r, buf_r, len_r, pwd_entry);
-}
-
-/* This is used on HPUX 10.20 */
-template <typename T_uid, typename T_passwd, typename T_buf, typename T_len>
-static inline int
-getpwuid_adaptor(int (*getpwuid_r)(T_uid user_id, T_passwd *pwd_r,
- T_buf *buf_r, T_len len_r),
- uid_t user_id, struct passwd *pwd_r,
- char *buf_r, size_t len_r, struct passwd **pwd_entry)
-{
- return getpwuid_r (user_id, pwd_r, buf_r, len_r);
-}
-
-/* This is used on IRIX 5.2. */
-template <typename T_uid, typename T_passwd, typename T_buf, typename T_len>
-static inline int
-getpwuid_adaptor(T_passwd * (*getpwuid_r)(T_uid user_id, T_passwd *pwd_r,
- T_buf *buf_r, T_len len_r),
- uid_t user_id, struct passwd *pwd_r,
- char *buf_r, size_t len_r, struct passwd **pwd_entry)
-{
- *pwd_entry = getpwuid_r (user_id, pwd_r, buf_r, len_r);
- return (*pwd_entry == NULL) ? errno : 0;
-}
-#endif
-
-void
-java::lang::System::init_properties (void)
-{
- {
- // We only need to synchronize around this gatekeeper.
- JvSynchronize sync (&SystemClass);
- if (prop_init)
- return;
- prop_init = true;
- }
-
- properties = new java::util::Properties ();
- // A convenience define.
-#define SET(Prop,Val) \
- properties->put(JvNewStringLatin1 (Prop), JvNewStringLatin1 (Val))
-
- // A mixture of the Java Product Versioning Specification
- // (introduced in 1.2), and earlier versioning properties.
- SET ("java.version", VERSION);
- SET ("java.vendor", "Free Software Foundation");
- SET ("java.vendor.url", "http://sourceware.cygnus.com/java/");
- SET ("java.class.version", GCJVERSION);
- SET ("java.vm.specification.version", "1.1");
- SET ("java.vm.specification.name", "Java(tm) Virtual Machine Specification");
- SET ("java.vm.specification.vendor", "Sun Microsystems Inc.");
- SET ("java.vm.version", GCJVERSION);
- SET ("java.vm.vendor", "Free Software Foundation");
- SET ("java.vm.name", "libgcj");
- SET ("java.specification.version", "1.1");
- SET ("java.specification.name", "Java(tm) Language Specification");
- SET ("java.specification.vendor", "Sun Microsystems Inc.");
-
- // FIXME: how to set this given location-independence?
- // SET ("java.home", "FIXME");
-
- SET ("file.encoding", default_file_encoding);
-
-#ifdef WIN32
- SET ("file.separator", "\\");
- SET ("path.separator", ";");
- SET ("line.separator", "\r\n");
- SET ("java.io.tmpdir", "C:\\temp");
-#else
- // Unix.
- SET ("file.separator", "/");
- SET ("path.separator", ":");
- SET ("line.separator", "\n");
- // FIXME: look at getenv("TMPDIR");
- SET ("java.io.tmpdir", "/tmp");
-#endif
-
-#ifdef HAVE_UNAME
- struct utsname u;
- if (! uname (&u))
- {
- SET ("os.name", u.sysname);
- SET ("os.arch", u.machine);
- SET ("os.version", u.release);
- }
- else
- {
- SET ("os.name", "unknown");
- SET ("os.arch", "unknown");
- SET ("os.version", "unknown");
- }
-#endif /* HAVE_UNAME */
-
- char *classpath = ::getenv("CLASSPATH");
- // FIXME: find libgcj.zip and append its path?
- if (classpath != NULL)
- SET ("java.class.path", classpath);
- else
- SET ("java.class.path", ".");
-
-#ifndef NO_GETUID
-#ifdef HAVE_PWD_H
- uid_t user_id = getuid ();
- struct passwd *pwd_entry;
-
-#ifdef HAVE_GETPWUID_R
- struct passwd pwd_r;
- size_t len_r = 200;
- char *buf_r = (char *) _Jv_AllocBytes (len_r);
-
- while (buf_r != NULL)
- {
- int r = getpwuid_adaptor (getpwuid_r, user_id, &pwd_r,
- buf_r, len_r, &pwd_entry);
- if (r == 0)
- break;
- else if (r != ERANGE)
- {
- pwd_entry = NULL;
- break;
- }
- len_r *= 2;
- buf_r = (char *) _Jv_AllocBytes (len_r);
- }
-#else
- pwd_entry = getpwuid (user_id);
-#endif /* HAVE_GETPWUID_R */
-
- if (pwd_entry != NULL)
- {
- SET ("user.name", pwd_entry->pw_name);
- SET ("user.home", pwd_entry->pw_dir);
- }
-#endif /* HAVE_PWD_H */
-#endif /* NO_GETUID */
-
-#ifdef HAVE_GETCWD
-#ifdef HAVE_UNISTD_H
- /* Use getcwd to set "user.dir". */
- int buflen = 250;
- char *buffer = (char *) malloc (buflen);
- while (buffer != NULL)
- {
- if (getcwd (buffer, buflen) != NULL)
- {
- SET ("user.dir", buffer);
- break;
- }
- if (errno != ERANGE)
- break;
- buflen = 2 * buflen;
- buffer = (char *) realloc (buffer, buflen);
- }
- if (buffer != NULL)
- free (buffer);
-#endif /* HAVE_UNISTD_H */
-#endif /* HAVE_GETCWD */
-
- // Set some properties according to whatever was compiled in with
- // `-D'.
- for (int i = 0; _Jv_Compiler_Properties[i]; ++i)
- {
- const char *s, *p;
- // Find the `='.
- for (s = p = _Jv_Compiler_Properties[i]; *s && *s != '='; ++s)
- ;
- jstring name = JvNewStringLatin1 (p, s - p);
- jstring val = JvNewStringLatin1 (*s == '=' ? s + 1 : s);
- properties->put (name, val);
- }
-
- // Set the system properties from the user's environment.
- if (_Jv_Environment_Properties)
- {
- size_t i = 0;
-
- while (_Jv_Environment_Properties[i].key)
- {
- SET (_Jv_Environment_Properties[i].key,
- _Jv_Environment_Properties[i].value);
- i++;
- }
- }
-}
diff --git a/libjava/java/lang/natThread.cc b/libjava/java/lang/natThread.cc
deleted file mode 100644
index 7a5e9004c64..00000000000
--- a/libjava/java/lang/natThread.cc
+++ /dev/null
@@ -1,334 +0,0 @@
-// natThread.cc - Native part of Thread class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <stdlib.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java-threads.h>
-
-#include <java/lang/Thread.h>
-#include <java/lang/ThreadGroup.h>
-#include <java/lang/IllegalArgumentException.h>
-#include <java/lang/UnsupportedOperationException.h>
-#include <java/lang/IllegalThreadStateException.h>
-#include <java/lang/InterruptedException.h>
-#include <java/lang/NullPointerException.h>
-#include <gnu/gcj/RawData.h>
-
-#include <jni.h>
-
-#ifdef ENABLE_JVMPI
-#include <jvmpi.h>
-#endif
-
-
-
-// This structure is used to represent all the data the native side
-// needs. An object of this type is assigned to the `data' member of
-// the Thread class.
-struct natThread
-{
- // These are used to interrupt sleep and join calls. We can share a
- // condition variable here since it only ever gets notified when the thread
- // exits.
- _Jv_Mutex_t join_mutex;
- _Jv_ConditionVariable_t join_cond;
-
- // This is private data for the thread system layer.
- _Jv_Thread_t *thread;
-
- // Each thread has its own JNI object.
- JNIEnv *jni_env;
-};
-
-// This is called from the constructor to initialize the native side
-// of the Thread.
-void
-java::lang::Thread::initialize_native (void)
-{
- // FIXME: this must interact with the GC in some logical way. At
- // the very least we must register a finalizer to clean up. This
- // isn't easy to do. If the Thread object resurrects itself in its
- // own finalizer then we will need to reinitialize this structure at
- // any "interesting" point.
- natThread *nt = (natThread *) _Jv_AllocBytes (sizeof (natThread));
- data = reinterpret_cast<gnu::gcj::RawData *> (nt);
- _Jv_MutexInit (&nt->join_mutex);
- _Jv_CondInit (&nt->join_cond);
- _Jv_ThreadInitData (&nt->thread, this);
- // FIXME: if JNI_ENV is set we will want to free it. It is
- // malloc()d.
- nt->jni_env = NULL;
-}
-
-jint
-java::lang::Thread::countStackFrames (void)
-{
- // NOTE: This is deprecated in JDK 1.2.
- JvFail ("java::lang::Thread::countStackFrames unimplemented");
- return 0;
-}
-
-java::lang::Thread *
-java::lang::Thread::currentThread (void)
-{
- return _Jv_ThreadCurrent ();
-}
-
-void
-java::lang::Thread::destroy (void)
-{
- // NOTE: This is marked as unimplemented in the JDK 1.2
- // documentation.
- JvFail ("java::lang::Thread::destroy unimplemented");
-}
-
-void
-java::lang::Thread::interrupt (void)
-{
- natThread *nt = (natThread *) data;
- _Jv_ThreadInterrupt (nt->thread);
-}
-
-void
-java::lang::Thread::join (jlong millis, jint nanos)
-{
- if (millis < 0 || nanos < 0 || nanos > 999999)
- _Jv_Throw (new IllegalArgumentException);
-
- Thread *current = currentThread ();
-
- // Here `NT' is the native structure for the thread we are trying to join.
- natThread *nt = (natThread *) data;
-
- // Now wait for: (1) an interrupt, (2) the thread to exit, or (3)
- // the timeout to occur.
- _Jv_MutexLock (&nt->join_mutex);
- if (! isAlive ())
- {
- _Jv_MutexUnlock (&nt->join_mutex);
- return;
- }
- _Jv_CondWait (&nt->join_cond, &nt->join_mutex, millis, nanos);
- _Jv_MutexUnlock (&nt->join_mutex);
-
- if (current->isInterrupted (true))
- _Jv_Throw (new InterruptedException);
-}
-
-void
-java::lang::Thread::resume (void)
-{
- checkAccess ();
- JvFail ("java::lang::Thread::resume unimplemented");
-}
-
-void
-java::lang::Thread::setPriority (jint newPriority)
-{
- checkAccess ();
- if (newPriority < MIN_PRIORITY || newPriority > MAX_PRIORITY)
- _Jv_Throw (new IllegalArgumentException);
-
- jint gmax = group->getMaxPriority();
- if (newPriority > gmax)
- newPriority = gmax;
-
- priority = newPriority;
- natThread *nt = (natThread *) data;
- _Jv_ThreadSetPriority (nt->thread, priority);
-}
-
-void
-java::lang::Thread::sleep (jlong millis, jint nanos)
-{
- if (millis < 0 || nanos < 0 || nanos > 999999)
- _Jv_Throw (new IllegalArgumentException);
-
- if (millis == 0 && nanos == 0)
- ++nanos;
-
- Thread *current = currentThread ();
-
- // We use a condition variable to implement sleeping so that an
- // interrupt can wake us up.
- natThread *nt = (natThread *) current->data;
- _Jv_MutexLock (&nt->join_mutex);
- _Jv_CondWait (&nt->join_cond, &nt->join_mutex, millis, nanos);
- _Jv_MutexUnlock (&nt->join_mutex);
-
- if (current->isInterrupted (true))
- _Jv_Throw (new InterruptedException);
-}
-
-void
-java::lang::Thread::finish_ ()
-{
- natThread *nt = (natThread *) data;
-
- group->remove (this);
-
-#ifdef ENABLE_JVMPI
- if (_Jv_JVMPI_Notify_THREAD_END)
- {
- JVMPI_Event event;
-
- event.event_type = JVMPI_EVENT_THREAD_END;
- event.env_id = _Jv_GetCurrentJNIEnv ();
-
- _Jv_DisableGC ();
- (*_Jv_JVMPI_Notify_THREAD_END) (&event);
- _Jv_EnableGC ();
- }
-#endif
-
- group = NULL;
-
- // Signal any threads that are waiting to join() us.
- _Jv_MutexLock (&nt->join_mutex);
- alive_flag = false;
- _Jv_CondNotifyAll (&nt->join_cond, &nt->join_mutex);
- _Jv_MutexUnlock (&nt->join_mutex);
-}
-
-void
-java::lang::Thread::run_ (jobject obj)
-{
- java::lang::Thread *thread = (java::lang::Thread *) obj;
- try
- {
-#ifdef ENABLE_JVMPI
- if (_Jv_JVMPI_Notify_THREAD_START)
- {
- JVMPI_Event event;
-
- jstring thread_name = thread->getName ();
- jstring group_name = NULL, parent_name = NULL;
- java::lang::ThreadGroup *group = thread->getThreadGroup ();
-
- if (group)
- {
- group_name = group->getName ();
- group = group->getParent ();
-
- if (group)
- parent_name = group->getName ();
- }
-
- int thread_len = thread_name ? JvGetStringUTFLength (thread_name) : 0;
- int group_len = group_name ? JvGetStringUTFLength (group_name) : 0;
- int parent_len = parent_name ? JvGetStringUTFLength (parent_name) : 0;
-
- char thread_chars[thread_len + 1];
- char group_chars[group_len + 1];
- char parent_chars[parent_len + 1];
-
- if (thread_name)
- JvGetStringUTFRegion (thread_name, 0,
- thread_name->length(), thread_chars);
- if (group_name)
- JvGetStringUTFRegion (group_name, 0,
- group_name->length(), group_chars);
- if (parent_name)
- JvGetStringUTFRegion (parent_name, 0,
- parent_name->length(), parent_chars);
-
- thread_chars[thread_len] = '\0';
- group_chars[group_len] = '\0';
- parent_chars[parent_len] = '\0';
-
- event.event_type = JVMPI_EVENT_THREAD_START;
- event.env_id = NULL;
- event.u.thread_start.thread_name = thread_chars;
- event.u.thread_start.group_name = group_chars;
- event.u.thread_start.parent_name = parent_chars;
- event.u.thread_start.thread_id = (jobjectID) thread;
- event.u.thread_start.thread_env_id = _Jv_GetCurrentJNIEnv ();
-
- _Jv_DisableGC ();
- (*_Jv_JVMPI_Notify_THREAD_START) (&event);
- _Jv_EnableGC ();
- }
-#endif
-
- thread->run ();
- }
- catch (java::lang::Throwable *t)
- {
- // Uncaught exceptions are forwarded to the ThreadGroup. If
- // this results in an uncaught exception, that is ignored.
- try
- {
- thread->group->uncaughtException (thread, t);
- }
- catch (java::lang::Throwable *f)
- {
- // Nothing.
- }
- }
-
- thread->finish_ ();
-}
-
-void
-java::lang::Thread::start (void)
-{
- JvSynchronize sync (this);
-
- // Its illegal to re-start() a thread, even if its dead.
- if (!startable_flag)
- _Jv_Throw (new IllegalThreadStateException);
-
- alive_flag = true;
- startable_flag = false;
- natThread *nt = (natThread *) data;
- _Jv_ThreadStart (this, nt->thread, (_Jv_ThreadStartFunc *) &run_);
-}
-
-void
-java::lang::Thread::stop (java::lang::Throwable *)
-{
- _Jv_Throw (new UnsupportedOperationException
- (JvNewStringLatin1 ("java::lang::Thread::stop unimplemented")));
-}
-
-void
-java::lang::Thread::suspend (void)
-{
- checkAccess ();
- _Jv_Throw (new UnsupportedOperationException
- (JvNewStringLatin1 ("java::lang::Thread::suspend unimplemented")));
-}
-
-void
-java::lang::Thread::yield (void)
-{
- _Jv_ThreadYield ();
-}
-
-JNIEnv *
-_Jv_GetCurrentJNIEnv ()
-{
- java::lang::Thread *t = _Jv_ThreadCurrent ();
- if (t == NULL)
- return NULL;
- return ((natThread *) t->data)->jni_env;
-}
-
-void
-_Jv_SetCurrentJNIEnv (JNIEnv *env)
-{
- java::lang::Thread *t = _Jv_ThreadCurrent ();
- JvAssert (t != NULL);
- ((natThread *) t->data)->jni_env = env;
-}
diff --git a/libjava/java/lang/natThrowable.cc b/libjava/java/lang/natThrowable.cc
deleted file mode 100644
index bbe18c20ca3..00000000000
--- a/libjava/java/lang/natThrowable.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-// natThrowable.cc - Superclass for all exceptions.
-
-/* Copyright (C) 2000 Red Hat 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 <aph@cygnus.com>
- * @date Jan 6 2000
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/lang/Object.h>
-#include <java-threads.h>
-#include <java/lang/Throwable.h>
-#include <java/io/PrintStream.h>
-#include <java/io/PrintWriter.h>
-#include <java/io/IOException.h>
-
-#include <sys/types.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <unistd.h>
-
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>
-#endif
-
-#include <name-finder.h>
-
-/* 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::Throwable *
-java::lang::Throwable::fillInStackTrace (void)
-{
-#ifdef HAVE_BACKTRACE
- void *p[128];
-
- // We subtract 1 from the number of elements because we don't want
- // to include the call to fillInStackTrace in the trace.
- int n = backtrace (p, 128) - 1;
-
- // ??? Might this cause a problem if the byte array isn't aligned?
- stackTrace = JvNewByteArray (n * sizeof p[0]);
- memcpy (elements (stackTrace), p+1, (n * sizeof p[0]));
-#endif
-
- return this;
-}
-
-void
-java::lang::Throwable::printRawStackTrace (java::io::PrintWriter *wr)
-{
- wr->println (toString ());
-#ifdef HAVE_BACKTRACE
- if (!stackTrace)
- return;
-
- void **p = (void **)elements (stackTrace);
- int depth = stackTrace->length / sizeof p[0];
-
- _Jv_name_finder finder (_Jv_ThisExecutable ());
-
- for (int i = 0; i < depth; i++)
- {
- bool found = finder.lookup (p[i]);
- wr->print (JvNewStringLatin1 (" at "));
- wr->print (JvNewStringLatin1 (finder.hex));
- if (found)
- {
- wr->print (JvNewStringLatin1 (": "));
- wr->print (JvNewStringLatin1 (finder.method_name));
- wr->print (JvNewStringLatin1 (" ("));
- wr->print (JvNewStringLatin1 (finder.file_name));
- wr->print (JvNewStringLatin1 (")"));
- }
- wr->println ();
- }
-#endif /* HAVE_BACKTRACE */
-}
diff --git a/libjava/java/lang/reflect/AccessibleObject.java b/libjava/java/lang/reflect/AccessibleObject.java
deleted file mode 100644
index 5ba5887e4e2..00000000000
--- a/libjava/java/lang/reflect/AccessibleObject.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// AccessibleObject.java - Base for reflection objects.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang.reflect;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- */
-/* Written using JDK 1.2 beta docs.
- * Status: Believed complete and correct.
- */
-
-public class AccessibleObject
-{
- protected AccessibleObject ()
- {
- flag = false;
- }
-
- boolean isAccessible ()
- {
- return flag;
- }
-
- static void setAccessible (AccessibleObject[] array, boolean flag)
- {
- checkPermission ();
- for (int i = 0; i < array.length; ++i)
- array[i].flag = flag;
- }
-
- void setAccessible (boolean flag)
- {
- checkPermission ();
- this.flag = flag;
- }
-
- private static final void checkPermission ()
- {
- SecurityManager sm = System.getSecurityManager();
- // FIXME: sm.checkPermission(ReflectPermission ("suppressAccessChecks"))
- }
-
- private boolean flag;
-}
diff --git a/libjava/java/lang/reflect/Array.java b/libjava/java/lang/reflect/Array.java
deleted file mode 100644
index cd90db8f071..00000000000
--- a/libjava/java/lang/reflect/Array.java
+++ /dev/null
@@ -1,78 +0,0 @@
-// FileDescriptor.java - Open file or device
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.lang.reflect;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date january 12, 1999
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
- * Status: Believe complete and correct.
- */
-
-public final class Array
-{
- Array () { }
-
- public static native Object newInstance(Class componentType, int length);
- public static native Object newInstance(Class elementType, int[] dimensions);
- public static native int getLength (Object array);
-
- public static native Object get (Object array, int index);
- public static native char getChar (Object array, int index);
- public static native byte getByte (Object array, int index);
- public static native short getShort (Object array, int index);
- public static native int getInt (Object array, int index);
- public static native long getLong (Object array, int index);
- public static native float getFloat (Object array, int index);
- public static native double getDouble (Object array, int index);
- public static native boolean getBoolean (Object array, int index);
-
- private static native Class getElementType (Object array, int index);
-
- private static native void set (Object array, int index,
- Object value, Class elType);
-
- public static void set (Object array, int index, Object value)
- {
- Class elType = getElementType(array, index);
- if (! elType.isPrimitive())
- set(array, index, value, elType);
- else if (value instanceof Byte)
- setByte(array, index, ((Byte) value).byteValue());
- else if (value instanceof Short)
- setShort (array, index, ((Short) value).shortValue());
- else if (value instanceof Integer)
- setInt(array, index, ((Integer) value).intValue());
- else if (value instanceof Long)
- setLong(array, index, ((Long) value).longValue());
- else if (value instanceof Float)
- setFloat(array, index, ((Float) value).floatValue());
- else if (value instanceof Double)
- setDouble(array, index, ((Double) value).doubleValue());
- else if (value instanceof Character)
- setChar(array, index, ((Character) value).charValue());
- else if (value instanceof Boolean)
- setBoolean(array, index, ((Boolean) value).booleanValue());
- else
- throw new IllegalArgumentException();
- }
-
- public static native void setByte (Object array, int index, byte value);
- public static native void setShort (Object array, int index, short value);
- public static native void setInt (Object array, int index, int value);
- public static native void setLong (Object array, int index, long value);
- public static native void setFloat (Object array, int index, float value);
- public static native void setDouble (Object array, int index, double value);
- public static native void setChar (Object array, int index, char value);
- public static native void setBoolean(Object array, int index, boolean value);
-}
diff --git a/libjava/java/lang/reflect/Constructor.java b/libjava/java/lang/reflect/Constructor.java
deleted file mode 100644
index 3556aaeb580..00000000000
--- a/libjava/java/lang/reflect/Constructor.java
+++ /dev/null
@@ -1,105 +0,0 @@
-// Constructor.java - Represents a constructor for a class.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang.reflect;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Incomplete: needs a private constructor, and
- * newInstance() needs to be written.
- */
-
-public final class Constructor extends AccessibleObject implements Member
-{
- public boolean equals (Object obj)
- {
- if (! (obj instanceof Constructor))
- return false;
- Constructor c = (Constructor) obj;
- return declaringClass == c.declaringClass && offset == c.offset;
- }
-
- public Class getDeclaringClass ()
- {
- return declaringClass;
- }
-
- public Class[] getExceptionTypes ()
- {
- return (Class[]) exception_types.clone();
- }
-
- public native int getModifiers ();
-
- public String getName ()
- {
- return declaringClass.getName();
- }
-
- public Class[] getParameterTypes ()
- {
- if (parameter_types == null)
- getType ();
- return (Class[]) parameter_types.clone();
- }
-
- public int hashCode ()
- {
- // FIXME.
- return getName().hashCode() + declaringClass.getName().hashCode();
- }
-
- // Update cached values from method descriptor in class.
- private native void getType ();
-
- public native Object newInstance (Object[] args)
- throws InstantiationException, IllegalAccessException,
- IllegalArgumentException, InvocationTargetException;
-
- public String toString ()
- {
- if (parameter_types == null)
- getType ();
- StringBuffer b = new StringBuffer ();
- b.append(Modifier.toString(getModifiers()));
- b.append(" ");
- b.append(getName());
- b.append("(");
- for (int i = 0; i < parameter_types.length; ++i)
- {
- b.append(parameter_types[i].toString());
- if (i < parameter_types.length - 1)
- b.append(",");
- }
- b.append(")");
- return b.toString();
- }
-
- // Can't create these.
- private Constructor ()
- {
- }
-
- // Declaring class.
- private Class declaringClass;
-
- // Exception types.
- private Class[] exception_types;
- // Parameter types.
- private Class[] parameter_types;
-
- // Offset in bytes from the start of declaringClass's methods array.
- private int offset;
-}
diff --git a/libjava/java/lang/reflect/Field.java b/libjava/java/lang/reflect/Field.java
deleted file mode 100644
index d0d4164083e..00000000000
--- a/libjava/java/lang/reflect/Field.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang.reflect;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date September 1998; February 1999.
- */
-/* Status: Mostly implemented.
- * However, access checks are not implemented. See natField.cc for
- * _Jv_CheckFieldAccessibility as well as the missing getCaller.
- * Note that the idea is to have to compiler convert calls to
- * setXXX(...) and getXXX(...) to setXXX(CALLER, ...) and getXXX(CALLER, ...),
- * where CALLER is reference to the class that contains the calls to
- * setXXX or getXXX. This is easy for the compiler, and replaces
- * expensive stack and table searching with a constant.
- */
-
-public final class Field extends AccessibleObject implements Member
-{
- private Class declaringClass;
-
- // This is filled in by getName.
- private String name;
-
- // Offset in bytes from the start of declaringClass's fields array.
- private int offset;
-
- public boolean equals (Object fld)
- {
- if (! (fld instanceof Field))
- return false;
- Field f = (Field) fld;
- return declaringClass == f.declaringClass && offset == f.offset;
- }
-
- public Class getDeclaringClass ()
- {
- return declaringClass;
- }
-
- public native String getName ();
-
- public native Class getType ();
-
- public native int getModifiers ();
-
- public int hashCode()
- {
- return (declaringClass.hashCode() ^ offset);
- }
-
- // The idea is that the compiler will magically translate
- // fld.getShort(obj) to fld.getShort(THISCLASS, obj).
- // This makes checking assessiblity more efficient,
- // since we don't have to do any stack-walking.
-
- public boolean getBoolean (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return getBoolean(null, obj);
- }
- public char getChar (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return getChar(null, obj);
- }
-
- public byte getByte (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return getByte(null, obj);
- }
-
- public short getShort (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return getShort(null, obj);
- }
-
- public int getInt (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return getInt(null, obj);
- }
-
- public long getLong (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return getLong(null, obj);
- }
-
- public float getFloat (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return getFloat(null, obj);
- }
-
- public double getDouble (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return getDouble(null, obj);
- }
-
- public Object get (Object obj)
- throws IllegalArgumentException, IllegalAccessException
- {
- return get(null, obj);
- }
-
- private native boolean getBoolean (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- private native char getChar (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- private native byte getByte (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- private native short getShort (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- private native int getInt (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- private native long getLong (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- private native float getFloat (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- private native double getDouble (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- public native Object get (Class caller, Object obj)
- throws IllegalArgumentException, IllegalAccessException;
-
- public void setByte (Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setByte(null, obj, b);
- }
-
- public void setShort (Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException
- {
- setShort(null, obj, s);
- }
-
- public void setInt (Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException
- {
- setInt(null, obj, i);
- }
-
- public void setLong (Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException
- {
- setLong(null, obj, l);
- }
-
- public void setFloat (Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException
- {
- setFloat(null, obj, f);
- }
-
- public void setDouble (Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException
- {
- setDouble(null, obj, d);
- }
-
- public void setChar (Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException
- {
- setChar(null, obj, c);
- }
-
- public void setBoolean (Object obj, boolean b)
- throws IllegalArgumentException, IllegalAccessException
- {
- setBoolean(null, obj, b);
- }
-
- public native void setByte (Class caller, Object obj, byte b)
- throws IllegalArgumentException, IllegalAccessException;
-
- public native void setShort (Class caller, Object obj, short s)
- throws IllegalArgumentException, IllegalAccessException;
-
- public native void setInt (Class caller, Object obj, int i)
- throws IllegalArgumentException, IllegalAccessException;
-
- public native void setLong (Class caller, Object obj, long l)
- throws IllegalArgumentException, IllegalAccessException;
-
- public native void setFloat (Class caller, Object obj, float f)
- throws IllegalArgumentException, IllegalAccessException;
-
- public native void setDouble (Class caller, Object obj, double d)
- throws IllegalArgumentException, IllegalAccessException;
-
- public native void setChar (Class caller, Object obj, char c)
- throws IllegalArgumentException, IllegalAccessException;
-
- public native void setBoolean (Class caller, Object obj, boolean b)
- throws IllegalArgumentException, IllegalAccessException;
-
- private native void set (Class caller, Object obj, Object val, Class type)
- throws IllegalArgumentException, IllegalAccessException;
-
- public void set (Object object, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- set(null, object, value);
- }
-
- public void set (Class caller, Object object, Object value)
- throws IllegalArgumentException, IllegalAccessException
- {
- Class type = getType();
- if (! type.isPrimitive())
- set(caller, object, value, type);
- else if (value instanceof Byte)
- setByte(caller, object, ((Byte) value).byteValue());
- else if (value instanceof Short)
- setShort (caller, object, ((Short) value).shortValue());
- else if (value instanceof Integer)
- setInt(caller, object, ((Integer) value).intValue());
- else if (value instanceof Long)
- setLong(caller, object, ((Long) value).longValue());
- else if (value instanceof Float)
- setFloat(caller, object, ((Float) value).floatValue());
- else if (value instanceof Double)
- setDouble(caller, object, ((Double) value).doubleValue());
- else if (value instanceof Character)
- setChar(caller, object, ((Character) value).charValue());
- else if (value instanceof Boolean)
- setBoolean(caller, object, ((Boolean) value).booleanValue());
- else
- throw new IllegalArgumentException();
- }
-
- public String toString ()
- {
- StringBuffer sbuf = new StringBuffer ();
- int mods = getModifiers();
- if (mods != 0)
- Modifier.toString(mods, sbuf);
- sbuf.append(getType());
- sbuf.append(' ');
- sbuf.append(getDeclaringClass());
- sbuf.append('.');
- sbuf.append(getName());
- return sbuf.toString();
- }
-}
diff --git a/libjava/java/lang/reflect/InvocationTargetException.java b/libjava/java/lang/reflect/InvocationTargetException.java
deleted file mode 100644
index 3d59506c2e4..00000000000
--- a/libjava/java/lang/reflect/InvocationTargetException.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// InvocationTargetException.java - Wrapper exception for reflection.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang.reflect;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Believed complete and correct.
- */
-
-public class InvocationTargetException extends Exception
-{
- public Throwable getTargetException ()
- {
- return target;
- }
-
- protected InvocationTargetException ()
- {
- super ();
- target = null;
- }
-
- public InvocationTargetException (Throwable exception)
- {
- super ();
- target = exception;
- }
-
- public InvocationTargetException (Throwable exception, String msg)
- {
- super (msg);
- target = exception;
- }
-
- // This is from JDK 1.2.
- public void printStackTrace ()
- {
- if (target != null)
- target.printStackTrace();
- }
-
- // This is from JDK 1.2.
- public void printStackTrace (PrintStream s)
- {
- if (target != null)
- target.printStackTrace(s);
- }
-
- // This is from JDK 1.2.
- public void printStackTrace (PrintWriter wr)
- {
- if (target != null)
- target.printStackTrace(wr);
- }
-
- // The wrapped exception. The name is specified by the
- // serialization spec.
- private Throwable target;
-}
diff --git a/libjava/java/lang/reflect/Member.java b/libjava/java/lang/reflect/Member.java
deleted file mode 100644
index 43b14acce19..00000000000
--- a/libjava/java/lang/reflect/Member.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.lang.reflect;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date September 27, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition.
- * Status: Believed complete and correct.
- */
-
-public interface Member
-{
- public static final int PUBLIC = 0;
- public static final int DECLARED = 1;
- public Class getDeclaringClass ();
- public int getModifiers ();
- public String getName();
-}
diff --git a/libjava/java/lang/reflect/Method.java b/libjava/java/lang/reflect/Method.java
deleted file mode 100644
index beefbe79c14..00000000000
--- a/libjava/java/lang/reflect/Method.java
+++ /dev/null
@@ -1,127 +0,0 @@
-// Method.java - Represent method of class or interface.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.lang.reflect;
-
-import gnu.gcj.RawData;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Complete, but not correct: access checks aren't done.
- */
-
-public final class Method extends AccessibleObject implements Member
-{
- public boolean equals (Object obj)
- {
- if (! (obj instanceof Method))
- return false;
- Method m = (Method) obj;
- return declaringClass == m.declaringClass && offset == m.offset;
- }
-
- public Class getDeclaringClass ()
- {
- return declaringClass;
- }
-
- public Class[] getExceptionTypes ()
- {
- return (Class[]) exception_types.clone();
- }
-
- public native int getModifiers ();
-
- public native String getName ();
-
- private native void getType ();
-
- public Class[] getParameterTypes ()
- {
- if (parameter_types == null)
- getType();
- return (Class[]) parameter_types.clone();
- }
-
- public Class getReturnType ()
- {
- if (return_type == null)
- getType();
- return return_type;
- }
-
- public int hashCode ()
- {
- // FIXME.
- return name.hashCode() + declaringClass.getName().hashCode();
- }
-
- public native Object invoke (Object obj, Object[] args)
- throws IllegalAccessException, IllegalArgumentException,
- InvocationTargetException;
-
- public String toString ()
- {
- if (parameter_types == null)
- getType ();
-
- StringBuffer b = new StringBuffer ();
- b.append(Modifier.toString(getModifiers()));
- b.append(" ");
- b.append(return_type.toString());
- b.append(" ");
- b.append(declaringClass.toString());
- b.append(".");
- b.append(name);
- b.append("(");
- for (int i = 0; i < parameter_types.length; ++i)
- {
- b.append(parameter_types[i].toString());
- if (i < parameter_types.length - 1)
- b.append(",");
- }
- b.append(")");
- if (exception_types.length > 0)
- {
- b.append(" throws ");
- for (int i = 0; i < exception_types.length; ++i)
- {
- b.append(exception_types[i].toString());
- if (i < exception_types.length - 1)
- b.append(",");
- }
- }
- return b.toString();
- }
-
- private Method ()
- {
- }
-
- // Declaring class.
- private Class declaringClass;
-
- // Exception types.
- private Class[] exception_types;
- // Name cache. (Initially null.)
- private String name;
- // Parameter types.
- private Class[] parameter_types;
- // Return type.
- private Class return_type;
-
- // Offset in bytes from the start of declaringClass's methods array.
- private int offset;
-}
diff --git a/libjava/java/lang/reflect/Modifier.java b/libjava/java/lang/reflect/Modifier.java
deleted file mode 100644
index 14b0da3f095..00000000000
--- a/libjava/java/lang/reflect/Modifier.java
+++ /dev/null
@@ -1,141 +0,0 @@
-// Modifier.java - Process modifier values.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 Tom Tromey <tromey@cygnus.com>
- * @date October 1, 1998
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct to version 1.2.
- */
-
-package java.lang.reflect;
-
-public class Modifier
-{
- public static final int PUBLIC = 0x001;
- public static final int PRIVATE = 0x002;
- public static final int PROTECTED = 0x004;
- public static final int STATIC = 0x008;
- public static final int FINAL = 0x010;
- public static final int SYNCHRONIZED = 0x020;
- public static final int VOLATILE = 0x040;
- public static final int TRANSIENT = 0x080;
- public static final int NATIVE = 0x100;
- public static final int INTERFACE = 0x200;
- public static final int ABSTRACT = 0x400;
- public static final int STRICT = 0x800;
-
- // This is only used by the C++ code, so it is not public.
- static final int ALL_FLAGS = 0x7ff;
-
- public static boolean isAbstract (int mod)
- {
- return (mod & ABSTRACT) != 0;
- }
-
- public static boolean isFinal (int mod)
- {
- return (mod & FINAL) != 0;
- }
-
- public static boolean isInterface (int mod)
- {
- return (mod & INTERFACE) != 0;
- }
-
- public static boolean isNative (int mod)
- {
- return (mod & NATIVE) != 0;
- }
-
- public static boolean isPrivate (int mod)
- {
- return (mod & PRIVATE) != 0;
- }
-
- public static boolean isProtected (int mod)
- {
- return (mod & PROTECTED) != 0;
- }
-
- public static boolean isPublic (int mod)
- {
- return (mod & PUBLIC) != 0;
- }
-
- public static boolean isStatic (int mod)
- {
- return (mod & STATIC) != 0;
- }
-
- public static boolean isStrict (int mod)
- {
- return (mod & STRICT) != 0;
- }
-
- public static boolean isSynchronized (int mod)
- {
- return (mod & SYNCHRONIZED) != 0;
- }
-
- public static boolean isTransient (int mod)
- {
- return (mod & TRANSIENT) != 0;
- }
-
- public static boolean isVolatile (int mod)
- {
- return (mod & VOLATILE) != 0;
- }
-
- public static String toString (int mod)
- {
- StringBuffer r = new StringBuffer ();
- toString(mod, r);
- return r.toString();
- }
-
- static void toString (int mod, StringBuffer r)
- {
- if (isPublic (mod))
- r.append("public ");
- if (isProtected (mod))
- r.append("protected ");
- if (isPrivate (mod))
- r.append("private ");
- if (isAbstract (mod))
- r.append("abstract ");
- if (isStatic (mod))
- r.append("static ");
- if (isFinal (mod))
- r.append("final ");
- if (isTransient (mod))
- r.append("transient ");
- if (isVolatile (mod))
- r.append("volatile ");
- if (isNative (mod))
- r.append("native ");
- if (isSynchronized (mod))
- r.append("synchronized ");
- if (isInterface (mod))
- r.append("interface ");
- if (isStrict (mod))
- r.append("strict ");
-
- // Trim trailing space.
- int l = r.length();
- if (l > 0)
- r.setLength(l - 1);
- }
-}
diff --git a/libjava/java/lang/reflect/natArray.cc b/libjava/java/lang/reflect/natArray.cc
deleted file mode 100644
index fd9536889dc..00000000000
--- a/libjava/java/lang/reflect/natArray.cc
+++ /dev/null
@@ -1,347 +0,0 @@
-// natField.cc - Implementation of java.lang.reflect.Field native methods.
-
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <stdlib.h>
-
-#include <jvm.h>
-#include <gcj/cni.h>
-#include <java/lang/reflect/Array.h>
-#include <java/lang/IllegalArgumentException.h>
-#include <java/lang/Byte.h>
-#include <java/lang/Short.h>
-#include <java/lang/Integer.h>
-#include <java/lang/Long.h>
-#include <java/lang/Float.h>
-#include <java/lang/Double.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Character.h>
-
-jobject
-java::lang::reflect::Array::newInstance (jclass componentType, jint length)
-{
- if (componentType->isPrimitive())
- {
- // We could check for this in _Jv_NewPrimArray, but that seems
- // like needless overhead when the only real route to this
- // problem is here.
- if (componentType == JvPrimClass (void))
- throw new java::lang::IllegalArgumentException ();
- return _Jv_NewPrimArray (componentType, length);
- }
- else
- return JvNewObjectArray (length, componentType, NULL);
-
-}
-
-jobject
-java::lang::reflect::Array::newInstance (jclass componentType, jintArray dimensions)
-{
- jint ndims = dimensions->length;
- if (ndims == 0)
- return componentType->newInstance ();
- jint* dims = elements (dimensions);
- if (ndims == 1)
- return newInstance (componentType, dims[0]);
- jclass arrayType = componentType;
- for (int i = 0; i < ndims; i++) // FIXME 2nd arg should
- // be "current" loader
- arrayType = _Jv_FindArrayClass (arrayType, 0);
-
- return _Jv_NewMultiArray (arrayType, ndims, dims);
-}
-
-jint
-java::lang::reflect::Array::getLength (jobject array)
-{
- jclass arrayType = array->getClass();
- if (! arrayType->isArray ())
- JvThrow (new java::lang::IllegalArgumentException());
- return ((__JArray*) array)->length;
-}
-
-jclass
-java::lang::reflect::Array::getElementType (jobject array, jint index)
-{
- jclass arrayType = array->getClass();
- if (! arrayType->isArray ())
- JvThrow (new java::lang::IllegalArgumentException());
- jint length = ((__JArray*) array)->length;
- if ((_Jv_uint) index >= (_Jv_uint) length)
- _Jv_ThrowBadArrayIndex(index);
- return arrayType->getComponentType ();
-}
-
-jboolean
-java::lang::reflect::Array::getBoolean (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (boolean))
- return elements ((jbooleanArray) array) [index];
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-jchar
-java::lang::reflect::Array::getChar (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (char))
- return elements ((jcharArray) array) [index];
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-jbyte
-java::lang::reflect::Array::getByte (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (byte))
- return elements ((jbyteArray) array) [index];
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-jshort
-java::lang::reflect::Array::getShort (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (short))
- return elements ((jshortArray) array) [index];
- if (elementType == JvPrimClass (byte))
- return elements ((jbyteArray) array) [index];
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-jint
-java::lang::reflect::Array::getInt (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (int))
- return elements ((jintArray) array) [index];
- if (elementType == JvPrimClass (short))
- return elements ((jshortArray) array) [index];
- if (elementType == JvPrimClass (byte))
- return elements ((jbyteArray) array) [index];
- if (elementType == JvPrimClass (char))
- return elements ((jcharArray) array) [index];
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-jlong
-java::lang::reflect::Array::getLong (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (long))
- return elements ((jlongArray) array) [index];
- if (elementType == JvPrimClass (int))
- return elements ((jintArray) array) [index];
- if (elementType == JvPrimClass (short))
- return elements ((jshortArray) array) [index];
- if (elementType == JvPrimClass (byte))
- return elements ((jbyteArray) array) [index];
- if (elementType == JvPrimClass (char))
- return elements ((jcharArray) array) [index];
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-jfloat
-java::lang::reflect::Array::getFloat (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (float))
- return elements ((jfloatArray) array) [index];
- if (elementType == JvPrimClass (long))
- return elements ((jlongArray) array) [index];
- if (elementType == JvPrimClass (int))
- return elements ((jintArray) array) [index];
- if (elementType == JvPrimClass (short))
- return elements ((jshortArray) array) [index];
- if (elementType == JvPrimClass (byte))
- return elements ((jbyteArray) array) [index];
- if (elementType == JvPrimClass (char))
- return elements ((jcharArray) array) [index];
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-jdouble
-java::lang::reflect::Array::getDouble (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (double))
- return elements ((jdoubleArray) array) [index];
- if (elementType == JvPrimClass (float))
- return elements ((jfloatArray) array) [index];
- if (elementType == JvPrimClass (long))
- return elements ((jlongArray) array) [index];
- if (elementType == JvPrimClass (int))
- return elements ((jintArray) array) [index];
- if (elementType == JvPrimClass (short))
- return elements ((jshortArray) array) [index];
- if (elementType == JvPrimClass (byte))
- return elements ((jbyteArray) array) [index];
- if (elementType == JvPrimClass (char))
- return elements ((jcharArray) array) [index];
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-jobject
-java::lang::reflect::Array::get (jobject array, jint index)
-{
- jclass elementType = getElementType (array, index);
- if (! elementType->isPrimitive ())
- return elements ((jobjectArray) array) [index];
- if (elementType == JvPrimClass (double))
- return new java::lang::Double (elements ((jdoubleArray) array) [index]);
- if (elementType == JvPrimClass (float))
- return new java::lang::Float (elements ((jfloatArray) array) [index]);
- if (elementType == JvPrimClass (long))
- return new java::lang::Long (elements ((jlongArray) array) [index]);
- if (elementType == JvPrimClass (int))
- return new java::lang::Integer (elements ((jintArray) array) [index]);
- if (elementType == JvPrimClass (short))
- return new java::lang::Short (elements ((jshortArray) array) [index]);
- if (elementType == JvPrimClass (byte))
- return new java::lang::Byte (elements ((jbyteArray) array) [index]);
- if (elementType == JvPrimClass (char))
- return new java::lang::Character (elements ((jcharArray) array) [index]);
- if (elementType == JvPrimClass (boolean))
- if (elements ((jbooleanArray) array) [index])
- return java::lang::Boolean::TRUE;
- else
- return java::lang::Boolean::FALSE;
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::setChar (jobject array, jint index, jchar value)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (char))
- elements ((jcharArray) array) [index] = value;
- else if (elementType == JvPrimClass (int))
- elements ((jintArray) array) [index] = value;
- else if (elementType == JvPrimClass (long))
- elements ((jlongArray) array) [index] = value;
- else if (elementType == JvPrimClass (float))
- elements ((jfloatArray) array) [index] = value;
- else if (elementType == JvPrimClass (double))
- elements ((jdoubleArray) array) [index] = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::setByte (jobject array, jint index, jbyte value)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (byte))
- elements ((jbyteArray) array) [index] = value;
- else if (elementType == JvPrimClass (short))
- elements ((jshortArray) array) [index] = value;
- else if (elementType == JvPrimClass (int))
- elements ((jintArray) array) [index] = value;
- else if (elementType == JvPrimClass (long))
- elements ((jlongArray) array) [index] = value;
- else if (elementType == JvPrimClass (float))
- elements ((jfloatArray) array) [index] = value;
- else if (elementType == JvPrimClass (double))
- elements ((jdoubleArray) array) [index] = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::setShort (jobject array, jint index, jshort value)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (short))
- elements ((jshortArray) array) [index] = value;
- else if (elementType == JvPrimClass (int))
- elements ((jintArray) array) [index] = value;
- else if (elementType == JvPrimClass (long))
- elements ((jlongArray) array) [index] = value;
- else if (elementType == JvPrimClass (float))
- elements ((jfloatArray) array) [index] = value;
- else if (elementType == JvPrimClass (double))
- elements ((jdoubleArray) array) [index] = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::setInt (jobject array, jint index, jint value)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (int))
- elements ((jintArray) array) [index] = value;
- else if (elementType == JvPrimClass (long))
- elements ((jlongArray) array) [index] = value;
- else if (elementType == JvPrimClass (float))
- elements ((jfloatArray) array) [index] = value;
- else if (elementType == JvPrimClass (double))
- elements ((jdoubleArray) array) [index] = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::setLong (jobject array, jint index, jlong value)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (long))
- elements ((jlongArray) array) [index] = value;
- else if (elementType == JvPrimClass (float))
- elements ((jfloatArray) array) [index] = value;
- else if (elementType == JvPrimClass (double))
- elements ((jdoubleArray) array) [index] = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::setFloat (jobject array, jint index, jfloat value)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (float))
- elements ((jfloatArray) array) [index] = value;
- else if (elementType == JvPrimClass (double))
- elements ((jdoubleArray) array) [index] = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::setDouble (jobject array, jint index, jdouble value)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (double))
- elements ((jdoubleArray) array) [index] = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::setBoolean (jobject array,
- jint index, jboolean value)
-{
- jclass elementType = getElementType (array, index);
- if (elementType == JvPrimClass (boolean))
- elements ((jbooleanArray) array) [index] = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Array::set (jobject array, jint index,
- jobject value, jclass elType)
-{
- if (! _Jv_IsInstanceOf (value, elType))
- JvThrow (new java::lang::IllegalArgumentException ());
- elements ((jobjectArray) array) [index] = value;
-}
diff --git a/libjava/java/lang/reflect/natConstructor.cc b/libjava/java/lang/reflect/natConstructor.cc
deleted file mode 100644
index 48f5aa345d1..00000000000
--- a/libjava/java/lang/reflect/natConstructor.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// natConstructor.cc - Native code for Constructor class.
-
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java/lang/reflect/Constructor.h>
-#include <java/lang/reflect/Method.h>
-#include <java/lang/reflect/InvocationTargetException.h>
-#include <java/lang/reflect/Modifier.h>
-#include <java/lang/InstantiationException.h>
-#include <gcj/method.h>
-
-jint
-java::lang::reflect::Constructor::getModifiers ()
-{
- return _Jv_FromReflectedConstructor (this)->accflags;
-}
-
-void
-java::lang::reflect::Constructor::getType ()
-{
- _Jv_GetTypesFromSignature (_Jv_FromReflectedConstructor (this),
- declaringClass,
- &parameter_types,
- NULL);
-}
-
-jobject
-java::lang::reflect::Constructor::newInstance (jobjectArray args)
-{
- if (parameter_types == NULL)
- getType ();
-
- using namespace java::lang::reflect;
- if (Modifier::isAbstract (declaringClass->getModifiers()))
- JvThrow (new InstantiationException);
-
- jmethodID meth = _Jv_FromReflectedConstructor (this);
- // In the constructor case the return type is the type of the
- // constructor.
- return _Jv_CallAnyMethodA (NULL, declaringClass, meth, true,
- parameter_types, args);
-}
diff --git a/libjava/java/lang/reflect/natField.cc b/libjava/java/lang/reflect/natField.cc
deleted file mode 100644
index 761324385f9..00000000000
--- a/libjava/java/lang/reflect/natField.cc
+++ /dev/null
@@ -1,433 +0,0 @@
-// natField.cc - Implementation of java.lang.reflect.Field native methods.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <stdlib.h>
-
-#include <jvm.h>
-#include <java/lang/reflect/Field.h>
-#include <java/lang/reflect/Modifier.h>
-#include <java/lang/IllegalArgumentException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/Byte.h>
-#include <java/lang/Short.h>
-#include <java/lang/Integer.h>
-#include <java/lang/Long.h>
-#include <java/lang/Float.h>
-#include <java/lang/Double.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Character.h>
-
-jint
-java::lang::reflect::Field::getModifiers ()
-{
- return _Jv_FromReflectedField (this)->getModifiers ();
-}
-
-jstring
-java::lang::reflect::Field::getName ()
-{
- if (name == NULL)
- name = _Jv_NewStringUtf8Const (_Jv_FromReflectedField (this)->name);
- return name;
-}
-
-jclass
-java::lang::reflect::Field::getType ()
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- if (! fld->isResolved())
- {
- JvSynchronize sync (declaringClass);
- if (! fld->isResolved())
- {
- fld->type
- = _Jv_FindClassFromSignature(((Utf8Const*) (fld->type))->data,
- declaringClass->getClassLoader());
- fld->flags &= ~_Jv_FIELD_UNRESOLVED_FLAG;
- }
- }
- return fld->type;
-}
-
-static void
-_Jv_CheckFieldAccessibility (jfieldID /*fld*/, jclass /*caller*/)
-{
-#if 0
- if (caller == NULL)
- caller = getCaller();
-#endif
-#if 0
- _Jv_ushort flags = fld->getModifiers();
- check accesss;
-#endif
-}
-
-static void*
-getAddr (java::lang::reflect::Field* field, jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (field);
- _Jv_ushort flags = fld->getModifiers();
- if (! (flags & java::lang::reflect::Modifier::PUBLIC)
- && ! field->isAccessible ())
- _Jv_CheckFieldAccessibility (fld, caller);
- if (flags & java::lang::reflect::Modifier::STATIC)
- {
- jclass fldClass = field->getDeclaringClass ();
- JvInitClass(fldClass);
- return fld->u.addr;
- }
- else
- {
- if (obj == NULL)
- _Jv_Throw (new java::lang::NullPointerException ());
- if (! _Jv_IsInstanceOf (obj, field->getDeclaringClass()))
- JvThrow (new java::lang::IllegalArgumentException ());
- return (void*) ((char*) obj + fld->getOffset ());
- }
-}
-
-static jboolean
-getBoolean (jclass cls, void* addr)
-{
- if (cls == JvPrimClass (boolean))
- return * (jboolean *) addr;
- _Jv_Throw (new java::lang::IllegalArgumentException());
-}
-
-static jchar
-getChar (jclass cls, void* addr)
-{
- if (cls == JvPrimClass (char))
- return * (jchar *) addr;
- _Jv_Throw (new java::lang::IllegalArgumentException());
-}
-
-static jbyte
-getByte (jclass cls, void* addr)
-{
- if (cls == JvPrimClass (byte))
- return * (jbyte *) addr;
- _Jv_Throw (new java::lang::IllegalArgumentException());
-}
-
-static jshort
-getShort (jclass cls, void* addr)
-{
- if (cls == JvPrimClass (short))
- return * (jshort *) addr;
- if (cls == JvPrimClass (byte))
- return * (jbyte *) addr;
- _Jv_Throw (new java::lang::IllegalArgumentException());
-}
-
-static jint
-getInt (jclass cls, void* addr)
-{
- if (cls == JvPrimClass (int))
- return * (jint *) addr;
- if (cls == JvPrimClass (short))
- return * (jshort *) addr;
- if (cls == JvPrimClass (char))
- return * (jchar *) addr;
- if (cls == JvPrimClass (byte))
- return * (jbyte *) addr;
- _Jv_Throw (new java::lang::IllegalArgumentException());
-}
-
-static jlong
-getLong (jclass cls, void* addr)
-{
- if (cls == JvPrimClass (long))
- return * (jlong *) addr;
- return ::getInt(cls, addr);
-}
-
-static jfloat
-getFloat (jclass cls, void* addr)
-{
- if (cls == JvPrimClass (float))
- return * (jfloat *) addr;
- if (cls == JvPrimClass (long))
- return * (jlong *) addr;
- return ::getInt(cls, addr);
-}
-
-static jdouble
-getDouble (jclass cls, void* addr)
-{
- if (cls == JvPrimClass (double))
- return * (jdouble *) addr;
- if (cls == JvPrimClass (float))
- return * (jfloat *) addr;
- if (cls == JvPrimClass (long))
- return * (jlong *) addr;
- return ::getInt(cls, addr);
-}
-
-jboolean
-java::lang::reflect::Field::getBoolean (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- return ::getBoolean (fld->type, getAddr (this, caller, obj));
-}
-
-jchar
-java::lang::reflect::Field::getChar (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- return ::getChar (fld->type, getAddr (this, caller, obj));
-}
-
-jbyte
-java::lang::reflect::Field::getByte (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- return ::getByte (fld->type, getAddr (this, caller, obj));
-}
-
-jshort
-java::lang::reflect::Field::getShort (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- return ::getShort (fld->type, getAddr (this, caller, obj));
-}
-
-jint
-java::lang::reflect::Field::getInt (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- return ::getInt (fld->type, getAddr (this, caller, obj));
-}
-
-jlong
-java::lang::reflect::Field::getLong (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- return ::getLong (fld->type, getAddr (this, caller, obj));
-}
-
-jfloat
-java::lang::reflect::Field::getFloat (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- return ::getFloat (fld->type, getAddr (this, caller, obj));
-}
-
-jdouble
-java::lang::reflect::Field::getDouble (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- return ::getDouble (fld->type, getAddr (this, caller, obj));
-}
-
-jobject
-java::lang::reflect::Field::get (jclass caller, jobject obj)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- void* addr = getAddr (this, caller, obj);
- if (! fld->type->isPrimitive ())
- return * (jobject*) addr;
- if (fld->type == JvPrimClass (double))
- return new java::lang::Double (* (jdouble*) addr);
- if (fld->type == JvPrimClass (float))
- return new java::lang::Float (* (jfloat*) addr);
- if (fld->type == JvPrimClass (long))
- return new java::lang::Long (* (jlong*) addr);
- if (fld->type == JvPrimClass (int))
- return new java::lang::Integer (* (jint*) addr);
- if (fld->type == JvPrimClass (short))
- return new java::lang::Short (* (jshort*) addr);
- if (fld->type == JvPrimClass (byte))
- return new java::lang::Byte (* (jbyte*) addr);
- if (fld->type == JvPrimClass (char))
- return new java::lang::Character (* (jchar*) addr);
- if (fld->type == JvPrimClass (boolean))
- if (* (jboolean*) addr)
- return java::lang::Boolean::TRUE;
- else
- return java::lang::Boolean::FALSE;
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-static void
-setBoolean (jclass type, void *addr, jboolean value)
-{
- if (type == JvPrimClass (boolean))
- * (jboolean *) addr = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-static void
-setChar (jclass type, void *addr, jchar value)
-{
- if (type == JvPrimClass (char))
- * (jchar *) addr = value;
- else if (type == JvPrimClass (int))
- * (jint *) addr = value;
- else if (type == JvPrimClass (long))
- * (jlong *) addr = value;
- else if (type == JvPrimClass (float))
- * (jfloat *) addr = value;
- else if (type == JvPrimClass (double))
- * (jdouble *) addr = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-static void
-setByte (jclass type, void *addr, jbyte value)
-{
- if (type == JvPrimClass (byte))
- * (jbyte *) addr = value;
- else if (type == JvPrimClass (short))
- * (jshort *) addr = value;
- else if (type == JvPrimClass (int))
- * (jint *) addr = value;
- else if (type == JvPrimClass (long))
- * (jlong *) addr = value;
- else if (type == JvPrimClass (float))
- * (jfloat *) addr = value;
- else if (type == JvPrimClass (double))
- * (jdouble *) addr = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-static void
-setShort (jclass type, void *addr, jshort value)
-{
- if (type == JvPrimClass (short))
- * (jshort *) addr = value;
- else if (type == JvPrimClass (int))
- * (jint *) addr = value;
- else if (type == JvPrimClass (long))
- * (jlong *) addr = value;
- else if (type == JvPrimClass (float))
- * (jfloat *) addr = value;
- else if (type == JvPrimClass (double))
- * (jdouble *) addr = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-static void
-setInt (jclass type, void *addr, jint value)
-{
- if (type == JvPrimClass (int))
- * (jint *) addr = value;
- else if (type == JvPrimClass (long))
- * (jlong *) addr = value;
- else if (type == JvPrimClass (float))
- * (jfloat *) addr = value;
- else if (type == JvPrimClass (double))
- * (jdouble *) addr = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-static void
-setLong (jclass type, void *addr, jlong value)
-{
- if (type == JvPrimClass (long))
- * (jlong *) addr = value;
- else if (type == JvPrimClass (float))
- * (jfloat *) addr = value;
- else if (type == JvPrimClass (double))
- * (jdouble *) addr = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-static void
-setFloat (jclass type, void *addr, jfloat value)
-{
- if (type == JvPrimClass (float))
- * (jfloat *) addr = value;
- else if (type == JvPrimClass (double))
- * (jdouble *) addr = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-static void
-setDouble (jclass type, void *addr, jdouble value)
-{
- if (type == JvPrimClass (double))
- * (jdouble *) addr = value;
- else
- JvThrow (new java::lang::IllegalArgumentException());
-}
-
-void
-java::lang::reflect::Field::setBoolean (jclass caller, jobject obj, jboolean b)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- ::setBoolean (fld->type, getAddr (this, caller, obj), b);
-}
-
-void
-java::lang::reflect::Field::setChar (jclass caller, jobject obj, jchar c)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- ::setChar (fld->type, getAddr (this, caller, obj), c);
-}
-
-void
-java::lang::reflect::Field::setByte (jclass caller, jobject obj, jbyte b)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- ::setByte (fld->type, getAddr (this, caller, obj), b);
-}
-
-void
-java::lang::reflect::Field::setShort (jclass caller, jobject obj, jshort s)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- ::setShort (fld->type, getAddr (this, caller, obj), s);
-}
-
-void
-java::lang::reflect::Field::setInt (jclass caller, jobject obj, jint i)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- ::setInt (fld->type, getAddr (this, caller, obj), i);
-}
-
-void
-java::lang::reflect::Field::setLong (jclass caller, jobject obj, jlong l)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- ::setLong (fld->type, getAddr (this, caller, obj), l);
-}
-void
-java::lang::reflect::Field::setFloat (jclass caller, jobject obj, jfloat f)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- ::setFloat (fld->type, getAddr (this, caller, obj), f);
-}
-
-void
-java::lang::reflect::Field::setDouble (jclass caller, jobject obj, jdouble d)
-{
- jfieldID fld = _Jv_FromReflectedField (this);
- ::setDouble (fld->type, getAddr (this, caller, obj), d);
-}
-
-void
-java::lang::reflect::Field::set (jclass caller, jobject object, jobject value, jclass type)
-{
- if (! _Jv_IsInstanceOf (value, type))
- JvThrow (new java::lang::IllegalArgumentException ());
- void* addr = getAddr (this, caller, object);
- * (jobject*) addr = value;
-}
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc
deleted file mode 100644
index 345637ef119..00000000000
--- a/libjava/java/lang/reflect/natMethod.cc
+++ /dev/null
@@ -1,543 +0,0 @@
-// natMethod.cc - Native code for Method class.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <jni.h>
-
-#include <java/lang/reflect/Method.h>
-#include <java/lang/reflect/Constructor.h>
-#include <java/lang/reflect/InvocationTargetException.h>
-#include <java/lang/reflect/Modifier.h>
-
-#include <java/lang/Void.h>
-#include <java/lang/Byte.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Character.h>
-#include <java/lang/Short.h>
-#include <java/lang/Integer.h>
-#include <java/lang/Long.h>
-#include <java/lang/Float.h>
-#include <java/lang/Double.h>
-#include <java/lang/IllegalArgumentException.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/Class.h>
-#include <gcj/method.h>
-#include <gnu/gcj/RawData.h>
-
-#define ObjectClass _CL_Q34java4lang6Object
-extern java::lang::Class ObjectClass;
-#define ClassClass _CL_Q34java4lang5Class
-extern java::lang::Class ClassClass;
-
-#include <stdlib.h>
-
-#include <ffi.h>
-
-#define VoidClass _CL_Q34java4lang4Void
-extern java::lang::Class VoidClass;
-#define ByteClass _CL_Q34java4lang4Byte
-extern java::lang::Class ByteClass;
-#define ShortClass _CL_Q34java4lang5Short
-extern java::lang::Class ShortClass;
-#define CharacterClass _CL_Q34java4lang9Character
-extern java::lang::Class CharacterClass;
-#define IntegerClass _CL_Q34java4lang7Integer
-extern java::lang::Class IntegerClass;
-#define LongClass _CL_Q34java4lang4Long
-extern java::lang::Class LongClass;
-#define FloatClass _CL_Q34java4lang5Float
-extern java::lang::Class FloatClass;
-#define DoubleClass _CL_Q34java4lang6Double
-extern java::lang::Class DoubleClass;
-
-struct cpair
-{
- jclass prim;
- jclass wrap;
-};
-
-// This is used to determine when a primitive widening conversion is
-// allowed.
-static cpair primitives[] =
-{
-#define VOID 0
- { JvPrimClass (void), &VoidClass },
- { JvPrimClass (byte), &ByteClass },
-#define SHORT 2
- { JvPrimClass (short), &ShortClass },
-#define CHAR 3
- { JvPrimClass (char), &CharacterClass },
- { JvPrimClass (int), &IntegerClass },
- { JvPrimClass (long), &LongClass },
- { JvPrimClass (float), &FloatClass },
- { JvPrimClass (double), &DoubleClass },
- { NULL, NULL }
-};
-
-static jboolean
-can_widen (jclass from, jclass to)
-{
- int fromx = -1, tox = -1;
-
- for (int i = 0; primitives[i].prim; ++i)
- {
- if (primitives[i].wrap == from)
- fromx = i;
- if (primitives[i].prim == to)
- tox = i;
- }
-
- // Can't handle a miss.
- if (fromx == -1 || tox == -1)
- return false;
- // Can't handle Void arguments.
- if (fromx == VOID || tox == VOID)
- return false;
- // Special-case short/char conversions.
- if ((fromx == SHORT && tox == CHAR) || (fromx == CHAR && tox == SHORT))
- return false;
-
- return fromx <= tox;
-}
-
-static ffi_type *
-get_ffi_type (jclass klass)
-{
- // A special case.
- if (klass == NULL)
- return &ffi_type_pointer;
-
- ffi_type *r;
- if (klass == JvPrimClass (byte))
- r = &ffi_type_sint8;
- else if (klass == JvPrimClass (short))
- r = &ffi_type_sint16;
- else if (klass == JvPrimClass (int))
- r = &ffi_type_sint32;
- else if (klass == JvPrimClass (long))
- r = &ffi_type_sint64;
- else if (klass == JvPrimClass (float))
- r = &ffi_type_float;
- else if (klass == JvPrimClass (double))
- r = &ffi_type_double;
- else if (klass == JvPrimClass (boolean))
- {
- // On some platforms a bool is a byte, on others an int.
- if (sizeof (jboolean) == sizeof (jbyte))
- r = &ffi_type_sint8;
- else
- {
- JvAssert (sizeof (jboolean) == sizeof (jint));
- r = &ffi_type_sint32;
- }
- }
- else if (klass == JvPrimClass (char))
- r = &ffi_type_uint16;
- else
- {
- JvAssert (! klass->isPrimitive());
- r = &ffi_type_pointer;
- }
-
- return r;
-}
-
-jobject
-java::lang::reflect::Method::invoke (jobject obj, jobjectArray args)
-{
- if (parameter_types == NULL)
- getType ();
-
- jmethodID meth = _Jv_FromReflectedMethod (this);
- if (! java::lang::reflect::Modifier::isStatic(meth->accflags))
- {
- jclass k = obj ? obj->getClass() : NULL;
- if (! obj)
- JvThrow (new java::lang::NullPointerException);
- if (! declaringClass->isAssignableFrom(k))
- JvThrow (new java::lang::IllegalArgumentException);
- // FIXME: access checks.
-
- // Find the possibly overloaded method based on the runtime type
- // of the object.
- meth = _Jv_LookupDeclaredMethod (k, meth->name, meth->signature);
- }
-
- return _Jv_CallAnyMethodA (obj, return_type, meth, false,
- parameter_types, args);
-}
-
-jint
-java::lang::reflect::Method::getModifiers ()
-{
- return _Jv_FromReflectedMethod (this)->accflags;
-}
-
-jstring
-java::lang::reflect::Method::getName ()
-{
- if (name == NULL)
- name = _Jv_NewStringUtf8Const (_Jv_FromReflectedMethod (this)->name);
- return name;
-}
-
-/* Internal method to set return_type and parameter_types fields. */
-
-void
-java::lang::reflect::Method::getType ()
-{
- _Jv_GetTypesFromSignature (_Jv_FromReflectedMethod (this),
- declaringClass,
- &parameter_types,
- &return_type);
-}
-
-void
-_Jv_GetTypesFromSignature (jmethodID method,
- jclass declaringClass,
- JArray<jclass> **arg_types_out,
- jclass *return_type_out)
-{
-
- _Jv_Utf8Const* sig = method->signature;
- java::lang::ClassLoader *loader = declaringClass->getClassLoader();
- char *ptr = sig->data;
- int numArgs = 0;
- /* First just count the number of parameters. */
- for (; ; ptr++)
- {
- switch (*ptr)
- {
- case 0:
- case ')':
- case 'V':
- break;
- case '[':
- case '(':
- continue;
- case 'B':
- case 'C':
- case 'D':
- case 'F':
- case 'S':
- case 'I':
- case 'J':
- case 'Z':
- numArgs++;
- continue;
- case 'L':
- numArgs++;
- do
- ptr++;
- while (*ptr != ';' && ptr[1] != '\0');
- continue;
- }
- break;
- }
-
- JArray<jclass> *args = (JArray<jclass> *)
- JvNewObjectArray (numArgs, &ClassClass, NULL);
- jclass* argPtr = elements (args);
- for (ptr = sig->data; *ptr != '\0'; ptr++)
- {
- int num_arrays = 0;
- jclass type;
- for (; *ptr == '['; ptr++)
- num_arrays++;
- switch (*ptr)
- {
- default:
- return;
- case ')':
- argPtr = return_type_out;
- continue;
- case '(':
- continue;
- case 'V':
- case 'B':
- case 'C':
- case 'D':
- case 'F':
- case 'S':
- case 'I':
- case 'J':
- case 'Z':
- type = _Jv_FindClassFromSignature(ptr, loader);
- break;
- case 'L':
- type = _Jv_FindClassFromSignature(ptr, loader);
- do
- ptr++;
- while (*ptr != ';' && ptr[1] != '\0');
- break;
- }
-
- // FIXME: 2'nd argument should be "current loader"
- while (--num_arrays >= 0)
- type = _Jv_FindArrayClass (type, 0);
- // ARGPTR can be NULL if we are processing the return value of a
- // call from Constructor.
- if (argPtr)
- *argPtr++ = type;
- }
- *arg_types_out = args;
-}
-
-// This is a very rough analog of the JNI CallNonvirtual<type>MethodA
-// functions. It handles both Methods and Constructors, and it can
-// handle any return type. In the Constructor case, the `obj'
-// argument is unused and should be NULL; also, the `return_type' is
-// the class that the constructor will construct. RESULT is a pointer
-// to a `jvalue' (see jni.h); for a void method this should be NULL.
-// This function returns an exception (if one was thrown), or NULL if
-// the call went ok.
-jthrowable
-_Jv_CallAnyMethodA (jobject obj,
- jclass return_type,
- jmethodID meth,
- jboolean is_constructor,
- JArray<jclass> *parameter_types,
- jvalue *args,
- jvalue *result)
-{
- JvAssert (! is_constructor || ! obj);
- JvAssert (! is_constructor || ! return_type);
-
- // See whether call needs an object as the first argument. A
- // constructor does need a `this' argument, but it is one we create.
- jboolean needs_this = false;
- if (is_constructor
- || ! java::lang::reflect::Modifier::isStatic(meth->accflags))
- needs_this = true;
-
- int param_count = parameter_types->length;
- if (needs_this)
- ++param_count;
-
- ffi_type *rtype;
- // A constructor itself always returns void.
- if (is_constructor || return_type == JvPrimClass (void))
- rtype = &ffi_type_void;
- else
- rtype = get_ffi_type (return_type);
- ffi_type **argtypes = (ffi_type **) alloca (param_count
- * sizeof (ffi_type *));
-
- jclass *paramelts = elements (parameter_types);
-
- // FIXME: at some point the compiler is going to add extra arguments
- // to some functions. In particular we are going to do this for
- // handling access checks in reflection. We must add these hidden
- // arguments here.
-
- // Special case for the `this' argument of a constructor. Note that
- // the JDK 1.2 docs specify that the new object must be allocated
- // before argument conversions are done.
- if (is_constructor)
- {
- // FIXME: must special-case String, arrays, maybe others here.
- obj = JvAllocObject (return_type);
- }
-
- int i = 0;
- int size = 0;
- if (needs_this)
- {
- // The `NULL' type is `Object'.
- argtypes[i++] = get_ffi_type (NULL);
- size += sizeof (jobject);
- }
-
- for (int arg = 0; i < param_count; ++i, ++arg)
- {
- argtypes[i] = get_ffi_type (paramelts[arg]);
- if (paramelts[arg]->isPrimitive())
- size += paramelts[arg]->size();
- else
- size += sizeof (jobject);
- }
-
- ffi_cif cif;
- if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, param_count,
- rtype, argtypes) != FFI_OK)
- {
- // FIXME: throw some kind of VirtualMachineError here.
- }
-
- char *p = (char *) alloca (size);
- void **values = (void **) alloca (param_count * sizeof (void *));
-
- i = 0;
- if (needs_this)
- {
- values[i] = p;
- memcpy (p, &obj, sizeof (jobject));
- p += sizeof (jobject);
- ++i;
- }
-
- for (int arg = 0; i < param_count; ++i, ++arg)
- {
- int tsize;
- if (paramelts[arg]->isPrimitive())
- tsize = paramelts[arg]->size();
- else
- tsize = sizeof (jobject);
-
- // Copy appropriate bits from the jvalue into the ffi array.
- // FIXME: we could do this copying all in one loop, above, by
- // over-allocating a bit.
- values[i] = p;
- memcpy (p, &args[arg], tsize);
- p += tsize;
- }
-
- // FIXME: initialize class here.
-
- using namespace java::lang;
- using namespace java::lang::reflect;
-
- Throwable *ex = NULL;
-
- try
- {
- ffi_call (&cif, (void (*) (...)) meth->ncode, result, values);
- }
- catch (Throwable *ex2)
- {
- // FIXME: this is wrong for JNI. But if we just return the
- // exception, then the non-JNI cases won't be able to
- // distinguish it from exceptions we might generate ourselves.
- // Sigh.
- ex = new InvocationTargetException (ex2);
- }
-
- if (is_constructor)
- result->l = obj;
-
- return ex;
-}
-
-// This is another version of _Jv_CallAnyMethodA, but this one does
-// more checking and is used by the reflection (and not JNI) code.
-jobject
-_Jv_CallAnyMethodA (jobject obj,
- jclass return_type,
- jmethodID meth,
- jboolean is_constructor,
- JArray<jclass> *parameter_types,
- jobjectArray args)
-{
- // FIXME: access checks.
-
- if (parameter_types->length != args->length)
- JvThrow (new java::lang::IllegalArgumentException);
-
- int param_count = parameter_types->length;
-
- jclass *paramelts = elements (parameter_types);
- jobject *argelts = elements (args);
- jvalue argvals[param_count];
-
-#define COPY(Where, What, Type) \
- do { \
- Type val = (What); \
- memcpy ((Where), &val, sizeof (Type)); \
- } while (0)
-
- for (int i = 0; i < param_count; ++i)
- {
- jclass k = argelts[i] ? argelts[i]->getClass() : NULL;
- if (paramelts[i]->isPrimitive())
- {
- if (! argelts[i]
- || ! k
- || ! can_widen (k, paramelts[i]))
- JvThrow (new java::lang::IllegalArgumentException);
- }
- else
- {
- if (argelts[i] && ! paramelts[i]->isAssignableFrom (k))
- JvThrow (new java::lang::IllegalArgumentException);
- }
-
- java::lang::Number *num = (java::lang::Number *) argelts[i];
- if (paramelts[i] == JvPrimClass (byte))
- COPY (&argvals[i], num->byteValue(), jbyte);
- else if (paramelts[i] == JvPrimClass (short))
- COPY (&argvals[i], num->shortValue(), jshort);
- else if (paramelts[i] == JvPrimClass (int))
- COPY (&argvals[i], num->intValue(), jint);
- else if (paramelts[i] == JvPrimClass (long))
- COPY (&argvals[i], num->longValue(), jlong);
- else if (paramelts[i] == JvPrimClass (float))
- COPY (&argvals[i], num->floatValue(), jfloat);
- else if (paramelts[i] == JvPrimClass (double))
- COPY (&argvals[i], num->doubleValue(), jdouble);
- else if (paramelts[i] == JvPrimClass (boolean))
- COPY (&argvals[i],
- ((java::lang::Boolean *) argelts[i])->booleanValue(),
- jboolean);
- else if (paramelts[i] == JvPrimClass (char))
- COPY (&argvals[i],
- ((java::lang::Character *) argelts[i])->charValue(),
- jchar);
- else
- {
- JvAssert (! paramelts[i]->isPrimitive());
- COPY (&argvals[i], argelts[i], jobject);
- }
- }
-
- jvalue ret_value;
- java::lang::Throwable *ex = _Jv_CallAnyMethodA (obj,
- return_type,
- meth,
- is_constructor,
- parameter_types,
- argvals,
- &ret_value);
-
- if (ex)
- JvThrow (ex);
-
- jobject r;
-#define VAL(Wrapper, Field) (new Wrapper (ret_value.Field))
- if (is_constructor)
- r = ret_value.l;
- else if (return_type == JvPrimClass (byte))
- r = VAL (java::lang::Byte, b);
- else if (return_type == JvPrimClass (short))
- r = VAL (java::lang::Short, s);
- else if (return_type == JvPrimClass (int))
- r = VAL (java::lang::Integer, i);
- else if (return_type == JvPrimClass (long))
- r = VAL (java::lang::Long, j);
- else if (return_type == JvPrimClass (float))
- r = VAL (java::lang::Float, f);
- else if (return_type == JvPrimClass (double))
- r = VAL (java::lang::Double, d);
- else if (return_type == JvPrimClass (boolean))
- r = VAL (java::lang::Boolean, z);
- else if (return_type == JvPrimClass (char))
- r = VAL (java::lang::Character, c);
- else if (return_type == JvPrimClass (void))
- r = NULL;
- else
- {
- JvAssert (return_type == NULL || ! return_type->isPrimitive());
- r = ret_value.l;
- }
-
- return r;
-}
diff --git a/libjava/java/lang/s_atan.c b/libjava/java/lang/s_atan.c
deleted file mode 100644
index 2ee74585423..00000000000
--- a/libjava/java/lang/s_atan.c
+++ /dev/null
@@ -1,181 +0,0 @@
-
-/* @(#)s_atan.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-
-/*
-FUNCTION
- <<atan>>, <<atanf>>---arc tangent
-
-INDEX
- atan
-INDEX
- atanf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double atan(double <[x]>);
- float atanf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double atan(<[x]>);
- double <[x]>;
-
- float atanf(<[x]>);
- float <[x]>;
-
-DESCRIPTION
-
-<<atan>> computes the inverse tangent (arc tangent) of the input value.
-
-<<atanf>> is identical to <<atan>>, save that it operates on <<floats>>.
-
-RETURNS
-@ifinfo
-<<atan>> returns a value in radians, in the range of -pi/2 to pi/2.
-@end ifinfo
-@tex
-<<atan>> returns a value in radians, in the range of $-\pi/2$ to $\pi/2$.
-@end tex
-
-PORTABILITY
-<<atan>> is ANSI C. <<atanf>> is an extension.
-
-*/
-
-/* atan(x)
- * Method
- * 1. Reduce x to positive by atan(x) = -atan(-x).
- * 2. According to the integer k=4t+0.25 chopped, t=x, the argument
- * is further reduced to one of the following intervals and the
- * arctangent of t is evaluated by the corresponding formula:
- *
- * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
- * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
- * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
- * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
- * [39/16,INF] atan(x) = atan(INF) + atan( -1/t )
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double atanhi[] = {
-#else
-static double atanhi[] = {
-#endif
- 4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
- 7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */
- 9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */
- 1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */
-};
-
-#ifdef __STDC__
-static const double atanlo[] = {
-#else
-static double atanlo[] = {
-#endif
- 2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */
- 3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */
- 1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */
- 6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */
-};
-
-#ifdef __STDC__
-static const double aT[] = {
-#else
-static double aT[] = {
-#endif
- 3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */
- -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */
- 1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */
- -1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */
- 9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */
- -7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */
- 6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */
- -5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */
- 4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */
- -3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */
- 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
-};
-
-#ifdef __STDC__
- static const double
-#else
- static double
-#endif
-one = 1.0,
-huge = 1.0e300;
-
-#ifdef __STDC__
- double atan(double x)
-#else
- double atan(x)
- double x;
-#endif
-{
- double w,s1,s2,z;
- int32_t ix,hx,id;
-
- GET_HIGH_WORD(hx,x);
- ix = hx&0x7fffffff;
- if(ix>=0x44100000) { /* if |x| >= 2^66 */
- uint32_t low;
- GET_LOW_WORD(low,x);
- if(ix>0x7ff00000||
- (ix==0x7ff00000&&(low!=0)))
- return x+x; /* NaN */
- if(hx>0) return atanhi[3]+atanlo[3];
- else return -atanhi[3]-atanlo[3];
- } if (ix < 0x3fdc0000) { /* |x| < 0.4375 */
- if (ix < 0x3e200000) { /* |x| < 2^-29 */
- if(huge+x>one) return x; /* raise inexact */
- }
- id = -1;
- } else {
- x = fabs(x);
- if (ix < 0x3ff30000) { /* |x| < 1.1875 */
- if (ix < 0x3fe60000) { /* 7/16 <=|x|<11/16 */
- id = 0; x = (2.0*x-one)/(2.0+x);
- } else { /* 11/16<=|x|< 19/16 */
- id = 1; x = (x-one)/(x+one);
- }
- } else {
- if (ix < 0x40038000) { /* |x| < 2.4375 */
- id = 2; x = (x-1.5)/(one+1.5*x);
- } else { /* 2.4375 <= |x| < 2^66 */
- id = 3; x = -1.0/x;
- }
- }}
- /* end of argument reduction */
- z = x*x;
- w = z*z;
- /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
- s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10])))));
- s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9]))));
- if (id<0) return x - x*(s1+s2);
- else {
- z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
- return (hx<0)? -z:z;
- }
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_ceil.c b/libjava/java/lang/s_ceil.c
deleted file mode 100644
index 250373b40d1..00000000000
--- a/libjava/java/lang/s_ceil.c
+++ /dev/null
@@ -1,80 +0,0 @@
-
-/* @(#)s_ceil.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * ceil(x)
- * Return x rounded toward -inf to integral value
- * Method:
- * Bit twiddling.
- * Exception:
- * Inexact flag raised if x not equal to ceil(x).
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double huge = 1.0e300;
-#else
-static double huge = 1.0e300;
-#endif
-
-#ifdef __STDC__
- double ceil(double x)
-#else
- double ceil(x)
- double x;
-#endif
-{
- int32_t i0,i1,j0;
- uint32_t i,j;
- EXTRACT_WORDS(i0,i1,x);
- j0 = ((i0>>20)&0x7ff)-0x3ff;
- if(j0<20) {
- if(j0<0) { /* raise inexact if x != 0 */
- if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
- if(i0<0) {i0=0x80000000;i1=0;}
- else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}
- }
- } else {
- i = (0x000fffff)>>j0;
- if(((i0&i)|i1)==0) return x; /* x is integral */
- if(huge+x>0.0) { /* raise inexact flag */
- if(i0>0) i0 += (0x00100000)>>j0;
- i0 &= (~i); i1=0;
- }
- }
- } else if (j0>51) {
- if(j0==0x400) return x+x; /* inf or NaN */
- else return x; /* x is integral */
- } else {
- i = ((uint32_t)(0xffffffff))>>(j0-20);
- if((i1&i)==0) return x; /* x is integral */
- if(huge+x>0.0) { /* raise inexact flag */
- if(i0>0) {
- if(j0==20) i0+=1;
- else {
- j = i1 + (1<<(52-j0));
- if(j<(uint32_t)i1) i0+=1; /* got a carry */
- i1 = j;
- }
- }
- i1 &= (~i);
- }
- }
- INSERT_WORDS(x,i0,i1);
- return x;
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_copysign.c b/libjava/java/lang/s_copysign.c
deleted file mode 100644
index 4804df130dc..00000000000
--- a/libjava/java/lang/s_copysign.c
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/* @(#)s_copysign.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
-<<copysign>>, <<copysignf>>---sign of <[y]>, magnitude of <[x]>
-
-INDEX
- copysign
-INDEX
- copysignf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double copysign (double <[x]>, double <[y]>);
- float copysignf (float <[x]>, float <[y]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double copysign (<[x]>, <[y]>)
- double <[x]>;
- double <[y]>;
-
- float copysignf (<[x]>, <[y]>)
- float <[x]>;
- float <[y]>;
-
-DESCRIPTION
-<<copysign>> constructs a number with the magnitude (absolute value)
-of its first argument, <[x]>, and the sign of its second argument,
-<[y]>.
-
-<<copysignf>> does the same thing; the two functions differ only in
-the type of their arguments and result.
-
-RETURNS
-<<copysign>> returns a <<double>> with the magnitude of
-<[x]> and the sign of <[y]>.
-<<copysignf>> returns a <<float>> with the magnitude of
-<[x]> and the sign of <[y]>.
-
-PORTABILITY
-<<copysign>> is not required by either ANSI C or the System V Interface
-Definition (Issue 2).
-
-*/
-
-/*
- * copysign(double x, double y)
- * copysign(x,y) returns a value with the magnitude of x and
- * with the sign bit of y.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double copysign(double x, double y)
-#else
- double copysign(x,y)
- double x,y;
-#endif
-{
- uint32_t hx,hy;
- GET_HIGH_WORD(hx,x);
- GET_HIGH_WORD(hy,y);
- SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
- return x;
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_cos.c b/libjava/java/lang/s_cos.c
deleted file mode 100644
index be1538d4c0b..00000000000
--- a/libjava/java/lang/s_cos.c
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/* @(#)s_cos.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* cos(x)
- * Return cosine function of x.
- *
- * kernel function:
- * __kernel_sin ... sine function on [-pi/4,pi/4]
- * __kernel_cos ... cosine function on [-pi/4,pi/4]
- * __ieee754_rem_pio2 ... argument reduction routine
- *
- * Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- * in [-pi/4 , +pi/4], and let n = k mod 4.
- * We have
- *
- * n sin(x) cos(x) tan(x)
- * ----------------------------------------------------------
- * 0 S C T
- * 1 C -S -1/T
- * 2 -S -C T
- * 3 -C S -1/T
- * ----------------------------------------------------------
- *
- * Special cases:
- * Let trig be any of sin, cos, or tan.
- * trig(+-INF) is NaN, with signals;
- * trig(NaN) is that NaN;
- *
- * Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double cos(double x)
-#else
- double cos(x)
- double x;
-#endif
-{
- double y[2],z=0.0;
- int32_t n,ix;
-
- /* High word of x. */
- GET_HIGH_WORD(ix,x);
-
- /* |x| ~< pi/4 */
- ix &= 0x7fffffff;
- if(ix <= 0x3fe921fb) return __kernel_cos(x,z);
-
- /* cos(Inf or NaN) is NaN */
- else if (ix>=0x7ff00000) return x-x;
-
- /* argument reduction needed */
- else {
- n = __ieee754_rem_pio2(x,y);
- switch(n&3) {
- case 0: return __kernel_cos(y[0],y[1]);
- case 1: return -__kernel_sin(y[0],y[1],1);
- case 2: return -__kernel_cos(y[0],y[1]);
- default:
- return __kernel_sin(y[0],y[1],1);
- }
- }
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_fabs.c b/libjava/java/lang/s_fabs.c
deleted file mode 100644
index dfee33fecdb..00000000000
--- a/libjava/java/lang/s_fabs.c
+++ /dev/null
@@ -1,73 +0,0 @@
-
-/* @(#)s_fabs.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
- <<fabs>>, <<fabsf>>---absolute value (magnitude)
-INDEX
- fabs
-INDEX
- fabsf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double fabs(double <[x]>);
- float fabsf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double fabs(<[x]>)
- double <[x]>;
-
- float fabsf(<[x]>)
- float <[x]>;
-
-DESCRIPTION
-<<fabs>> and <<fabsf>> calculate
-@tex
-$|x|$,
-@end tex
-the absolute value (magnitude) of the argument <[x]>, by direct
-manipulation of the bit representation of <[x]>.
-
-RETURNS
-The calculated value is returned. No errors are detected.
-
-PORTABILITY
-<<fabs>> is ANSI.
-<<fabsf>> is an extension.
-
-*/
-
-/*
- * fabs(x) returns the absolute value of x.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double fabs(double x)
-#else
- double fabs(x)
- double x;
-#endif
-{
- uint32_t high;
- GET_HIGH_WORD(high,x);
- SET_HIGH_WORD(x,high&0x7fffffff);
- return x;
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_floor.c b/libjava/java/lang/s_floor.c
deleted file mode 100644
index 77e39cb7de0..00000000000
--- a/libjava/java/lang/s_floor.c
+++ /dev/null
@@ -1,134 +0,0 @@
-
-/* @(#)s_floor.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
-<<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling
-INDEX
- floor
-INDEX
- floorf
-INDEX
- ceil
-INDEX
- ceilf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double floor(double <[x]>);
- float floorf(float <[x]>);
- double ceil(double <[x]>);
- float ceilf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double floor(<[x]>)
- double <[x]>;
- float floorf(<[x]>)
- float <[x]>;
- double ceil(<[x]>)
- double <[x]>;
- float ceilf(<[x]>)
- float <[x]>;
-
-DESCRIPTION
-<<floor>> and <<floorf>> find
-@tex
-$\lfloor x \rfloor$,
-@end tex
-the nearest integer less than or equal to <[x]>.
-<<ceil>> and <<ceilf>> find
-@tex
-$\lceil x\rceil$,
-@end tex
-the nearest integer greater than or equal to <[x]>.
-
-RETURNS
-<<floor>> and <<ceil>> return the integer result as a double.
-<<floorf>> and <<ceilf>> return the integer result as a float.
-
-PORTABILITY
-<<floor>> and <<ceil>> are ANSI.
-<<floorf>> and <<ceilf>> are extensions.
-
-
-*/
-
-/*
- * floor(x)
- * Return x rounded toward -inf to integral value
- * Method:
- * Bit twiddling.
- * Exception:
- * Inexact flag raised if x not equal to floor(x).
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double huge = 1.0e300;
-#else
-static double huge = 1.0e300;
-#endif
-
-#ifdef __STDC__
- double floor(double x)
-#else
- double floor(x)
- double x;
-#endif
-{
- int32_t i0,i1,j0;
- uint32_t i,j;
- EXTRACT_WORDS(i0,i1,x);
- j0 = ((i0>>20)&0x7ff)-0x3ff;
- if(j0<20) {
- if(j0<0) { /* raise inexact if x != 0 */
- if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
- if(i0>=0) {i0=i1=0;}
- else if(((i0&0x7fffffff)|i1)!=0)
- { i0=0xbff00000;i1=0;}
- }
- } else {
- i = (0x000fffff)>>j0;
- if(((i0&i)|i1)==0) return x; /* x is integral */
- if(huge+x>0.0) { /* raise inexact flag */
- if(i0<0) i0 += (0x00100000)>>j0;
- i0 &= (~i); i1=0;
- }
- }
- } else if (j0>51) {
- if(j0==0x400) return x+x; /* inf or NaN */
- else return x; /* x is integral */
- } else {
- i = ((uint32_t)(0xffffffff))>>(j0-20);
- if((i1&i)==0) return x; /* x is integral */
- if(huge+x>0.0) { /* raise inexact flag */
- if(i0<0) {
- if(j0==20) i0+=1;
- else {
- j = i1+(1<<(52-j0));
- if(j<(uint32_t)i1) i0 +=1 ; /* got a carry */
- i1=j;
- }
- }
- i1 &= (~i);
- }
- }
- INSERT_WORDS(x,i0,i1);
- return x;
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_rint.c b/libjava/java/lang/s_rint.c
deleted file mode 100644
index 5d3f8114e2b..00000000000
--- a/libjava/java/lang/s_rint.c
+++ /dev/null
@@ -1,87 +0,0 @@
-
-/* @(#)s_rint.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
- * rint(x)
- * Return x rounded to integral value according to the prevailing
- * rounding mode.
- * Method:
- * Using floating addition.
- * Exception:
- * Inexact flag raised if x not equal to rint(x).
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-TWO52[2]={
- 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
- -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
-};
-
-#ifdef __STDC__
- double rint(double x)
-#else
- double rint(x)
- double x;
-#endif
-{
- int32_t i0,j0,sx;
- uint32_t i,i1;
- double t;
- volatile double w;
- EXTRACT_WORDS(i0,i1,x);
- sx = (i0>>31)&1;
- j0 = ((i0>>20)&0x7ff)-0x3ff;
- if(j0<20) {
- if(j0<0) {
- if(((i0&0x7fffffff)|i1)==0) return x;
- i1 |= (i0&0x0fffff);
- i0 &= 0xfffe0000;
- i0 |= ((i1|-i1)>>12)&0x80000;
- SET_HIGH_WORD(x,i0);
- w = TWO52[sx]+x;
- t = w-TWO52[sx];
- GET_HIGH_WORD(i0,t);
- SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
- return t;
- } else {
- i = (0x000fffff)>>j0;
- if(((i0&i)|i1)==0) return x; /* x is integral */
- i>>=1;
- if(((i0&i)|i1)!=0) {
- if(j0==19) i1 = 0x40000000; else
- i0 = (i0&(~i))|((0x20000)>>j0);
- }
- }
- } else if (j0>51) {
- if(j0==0x400) return x+x; /* inf or NaN */
- else return x; /* x is integral */
- } else {
- i = ((uint32_t)(0xffffffff))>>(j0-20);
- if((i1&i)==0) return x; /* x is integral */
- i>>=1;
- if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));
- }
- INSERT_WORDS(x,i0,i1);
- w = TWO52[sx]+x;
- return w-TWO52[sx];
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_scalbn.c b/libjava/java/lang/s_scalbn.c
deleted file mode 100644
index 36ee88981ba..00000000000
--- a/libjava/java/lang/s_scalbn.c
+++ /dev/null
@@ -1,104 +0,0 @@
-
-/* @(#)s_scalbn.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
-<<scalbn>>, <<scalbnf>>---scale by integer
-INDEX
- scalbn
-INDEX
- scalbnf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double scalbn(double <[x]>, int <[y]>);
- float scalbnf(float <[x]>, int <[y]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double scalbn(<[x]>,<[y]>)
- double <[x]>;
- int <[y]>;
- float scalbnf(<[x]>,<[y]>)
- float <[x]>;
- int <[y]>;
-
-DESCRIPTION
-<<scalbn>> and <<scalbnf>> scale <[x]> by <[n]>, returning <[x]> times
-2 to the power <[n]>. The result is computed by manipulating the
-exponent, rather than by actually performing an exponentiation or
-multiplication.
-
-RETURNS
-<[x]> times 2 to the power <[n]>.
-
-PORTABILITY
-Neither <<scalbn>> nor <<scalbnf>> is required by ANSI C or by the System V
-Interface Definition (Issue 2).
-
-*/
-
-/*
- * scalbn (double x, int n)
- * scalbn(x,n) returns x* 2**n computed by exponent
- * manipulation rather than by actually performing an
- * exponentiation or a multiplication.
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
-twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
-huge = 1.0e+300,
-tiny = 1.0e-300;
-
-#ifdef __STDC__
- double scalbn (double x, int n)
-#else
- double scalbn (x,n)
- double x; int n;
-#endif
-{
- int32_t k,hx,lx;
- EXTRACT_WORDS(hx,lx,x);
- k = (hx&0x7ff00000)>>20; /* extract exponent */
- if (k==0) { /* 0 or subnormal x */
- if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
- x *= two54;
- GET_HIGH_WORD(hx,x);
- k = ((hx&0x7ff00000)>>20) - 54;
- if (n< -50000) return tiny*x; /*underflow*/
- }
- if (k==0x7ff) return x+x; /* NaN or Inf */
- k = k+n;
- if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */
- if (k > 0) /* normal result */
- {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
- if (k <= -54) {
- if (n > 50000) /* in case integer overflow in n+k */
- return huge*copysign(huge,x); /*overflow*/
- else return tiny*copysign(tiny,x); /*underflow*/
- }
- k += 54; /* subnormal result */
- SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
- return x*twom54;
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_sin.c b/libjava/java/lang/s_sin.c
deleted file mode 100644
index d315455549c..00000000000
--- a/libjava/java/lang/s_sin.c
+++ /dev/null
@@ -1,132 +0,0 @@
-
-/* @(#)s_sin.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
- <<sin>>, <<sinf>>, <<cos>>, <<cosf>>---sine or cosine
-INDEX
-sin
-INDEX
-sinf
-INDEX
-cos
-INDEX
-cosf
-ANSI_SYNOPSIS
- #include <math.h>
- double sin(double <[x]>);
- float sinf(float <[x]>);
- double cos(double <[x]>);
- float cosf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double sin(<[x]>)
- double <[x]>;
- float sinf(<[x]>)
- float <[x]>;
-
- double cos(<[x]>)
- double <[x]>;
- float cosf(<[x]>)
- float <[x]>;
-
-DESCRIPTION
- <<sin>> and <<cos>> compute (respectively) the sine and cosine
- of the argument <[x]>. Angles are specified in radians.
-
- <<sinf>> and <<cosf>> are identical, save that they take and
- return <<float>> values.
-
-
-RETURNS
- The sine or cosine of <[x]> is returned.
-
-PORTABILITY
- <<sin>> and <<cos>> are ANSI C.
- <<sinf>> and <<cosf>> are extensions.
-
-QUICKREF
- sin ansi pure
- sinf - pure
-*/
-
-/* sin(x)
- * Return sine function of x.
- *
- * kernel function:
- * __kernel_sin ... sine function on [-pi/4,pi/4]
- * __kernel_cos ... cose function on [-pi/4,pi/4]
- * __ieee754_rem_pio2 ... argument reduction routine
- *
- * Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- * in [-pi/4 , +pi/4], and let n = k mod 4.
- * We have
- *
- * n sin(x) cos(x) tan(x)
- * ----------------------------------------------------------
- * 0 S C T
- * 1 C -S -1/T
- * 2 -S -C T
- * 3 -C S -1/T
- * ----------------------------------------------------------
- *
- * Special cases:
- * Let trig be any of sin, cos, or tan.
- * trig(+-INF) is NaN, with signals;
- * trig(NaN) is that NaN;
- *
- * Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double sin(double x)
-#else
- double sin(x)
- double x;
-#endif
-{
- double y[2],z=0.0;
- int32_t n,ix;
-
- /* High word of x. */
- GET_HIGH_WORD(ix,x);
-
- /* |x| ~< pi/4 */
- ix &= 0x7fffffff;
- if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0);
-
- /* sin(Inf or NaN) is NaN */
- else if (ix>=0x7ff00000) return x-x;
-
- /* argument reduction needed */
- else {
- n = __ieee754_rem_pio2(x,y);
- switch(n&3) {
- case 0: return __kernel_sin(y[0],y[1],1);
- case 1: return __kernel_cos(y[0],y[1]);
- case 2: return -__kernel_sin(y[0],y[1],1);
- default:
- return -__kernel_cos(y[0],y[1]);
- }
- }
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/s_tan.c b/libjava/java/lang/s_tan.c
deleted file mode 100644
index 20995fcbdee..00000000000
--- a/libjava/java/lang/s_tan.c
+++ /dev/null
@@ -1,114 +0,0 @@
-
-/* @(#)s_tan.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-
-/*
-
-FUNCTION
- <<tan>>, <<tanf>>---tangent
-
-INDEX
-tan
-INDEX
-tanf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double tan(double <[x]>);
- float tanf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double tan(<[x]>)
- double <[x]>;
-
- float tanf(<[x]>)
- float <[x]>;
-
-
-DESCRIPTION
-<<tan>> computes the tangent of the argument <[x]>.
-Angles are specified in radians.
-
-<<tanf>> is identical, save that it takes and returns <<float>> values.
-
-RETURNS
-The tangent of <[x]> is returned.
-
-PORTABILITY
-<<tan>> is ANSI. <<tanf>> is an extension.
-*/
-
-/* tan(x)
- * Return tangent function of x.
- *
- * kernel function:
- * __kernel_tan ... tangent function on [-pi/4,pi/4]
- * __ieee754_rem_pio2 ... argument reduction routine
- *
- * Method.
- * Let S,C and T denote the sin, cos and tan respectively on
- * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
- * in [-pi/4 , +pi/4], and let n = k mod 4.
- * We have
- *
- * n sin(x) cos(x) tan(x)
- * ----------------------------------------------------------
- * 0 S C T
- * 1 C -S -1/T
- * 2 -S -C T
- * 3 -C S -1/T
- * ----------------------------------------------------------
- *
- * Special cases:
- * Let trig be any of sin, cos, or tan.
- * trig(+-INF) is NaN, with signals;
- * trig(NaN) is that NaN;
- *
- * Accuracy:
- * TRIG(x) returns trig(x) nearly rounded
- */
-
-#include "fdlibm.h"
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double tan(double x)
-#else
- double tan(x)
- double x;
-#endif
-{
- double y[2],z=0.0;
- int32_t n,ix;
-
- /* High word of x. */
- GET_HIGH_WORD(ix,x);
-
- /* |x| ~< pi/4 */
- ix &= 0x7fffffff;
- if(ix <= 0x3fe921fb) return __kernel_tan(x,z,1);
-
- /* tan(Inf or NaN) is NaN */
- else if (ix>=0x7ff00000) return x-x; /* NaN */
-
- /* argument reduction needed */
- else {
- n = __ieee754_rem_pio2(x,y);
- return __kernel_tan(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even
- -1 -- n odd */
- }
-}
-
-#endif /* _DOUBLE_IS_32BITS */
diff --git a/libjava/java/lang/sf_rint.c b/libjava/java/lang/sf_rint.c
deleted file mode 100644
index f442072874e..00000000000
--- a/libjava/java/lang/sf_rint.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* sf_rint.c -- float version of s_rint.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include "fdlibm.h"
-
-#ifdef __STDC__
-static const float
-#else
-static float
-#endif
-TWO23[2]={
- 8.3886080000e+06, /* 0x4b000000 */
- -8.3886080000e+06, /* 0xcb000000 */
-};
-
-#ifdef __STDC__
- float rintf(float x)
-#else
- float rintf(x)
- float x;
-#endif
-{
- int32_t i0,j0,sx;
- uint32_t i,i1;
- float w,t;
- GET_FLOAT_WORD(i0,x);
- sx = (i0>>31)&1;
- j0 = ((i0>>23)&0xff)-0x7f;
- if(j0<23) {
- if(j0<0) {
- if((i0&0x7fffffff)==0) return x;
- i1 = (i0&0x07fffff);
- i0 &= 0xfff00000;
- i0 |= ((i1|-i1)>>9)&0x400000;
- SET_FLOAT_WORD(x,i0);
- w = TWO23[sx]+x;
- t = w-TWO23[sx];
- GET_FLOAT_WORD(i0,t);
- SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31));
- return t;
- } else {
- i = (0x007fffff)>>j0;
- if((i0&i)==0) return x; /* x is integral */
- i>>=1;
- if((i0&i)!=0) i0 = (i0&(~i))|((0x100000)>>j0);
- }
- } else {
- if(j0==0x80) return x+x; /* inf or NaN */
- else return x; /* x is integral */
- }
- SET_FLOAT_WORD(x,i0);
- w = TWO23[sx]+x;
- return w-TWO23[sx];
-}
-
-#ifdef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double rint(double x)
-#else
- double rint(x)
- double x;
-#endif
-{
- return (double) rintf((float) x);
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/strtod.c b/libjava/java/lang/strtod.c
deleted file mode 100644
index e0e8e74828b..00000000000
--- a/libjava/java/lang/strtod.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
-FUNCTION
- <<strtod>>, <<strtodf>>---string to double or float
-
-INDEX
- strtod
-INDEX
- _strtod_r
-INDEX
- strtodf
-
-ANSI_SYNOPSIS
- #include <stdlib.h>
- double strtod(const char *<[str]>, char **<[tail]>);
- float strtodf(const char *<[str]>, char **<[tail]>);
-
- double _strtod_r(void *<[reent]>,
- const char *<[str]>, char **<[tail]>);
-
-TRAD_SYNOPSIS
- #include <stdlib.h>
- double strtod(<[str]>,<[tail]>)
- char *<[str]>;
- char **<[tail]>;
-
- float strtodf(<[str]>,<[tail]>)
- char *<[str]>;
- char **<[tail]>;
-
- double _strtod_r(<[reent]>,<[str]>,<[tail]>)
- char *<[reent]>;
- char *<[str]>;
- char **<[tail]>;
-
-DESCRIPTION
- The function <<strtod>> parses the character string <[str]>,
- producing a substring which can be converted to a double
- value. The substring converted is the longest initial
- subsequence of <[str]>, beginning with the first
- non-whitespace character, that has the format:
- .[+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>]
- The substring contains no characters if <[str]> is empty, consists
- entirely of whitespace, or if the first non-whitespace
- character is something other than <<+>>, <<->>, <<.>>, or a
- digit. If the substring is empty, no conversion is done, and
- the value of <[str]> is stored in <<*<[tail]>>>. Otherwise,
- the substring is converted, and a pointer to the final string
- (which will contain at least the terminating null character of
- <[str]>) is stored in <<*<[tail]>>>. If you want no
- assignment to <<*<[tail]>>>, pass a null pointer as <[tail]>.
- <<strtodf>> is identical to <<strtod>> except for its return type.
-
- This implementation returns the nearest machine number to the
- input decimal string. Ties are broken by using the IEEE
- round-even rule.
-
- The alternate function <<_strtod_r>> is a reentrant version.
- The extra argument <[reent]> is a pointer to a reentrancy structure.
-
-RETURNS
- <<strtod>> returns the converted substring value, if any. If
- no conversion could be performed, 0 is returned. If the
- correct value is out of the range of representable values,
- plus or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is
- stored in errno. If the correct value would cause underflow, 0
- is returned and <<ERANGE>> is stored in errno.
-
-Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
-<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
-*/
-
-/****************************************************************
- *
- * The author of this software is David M. Gay.
- *
- * Copyright (c) 1991 by AT&T.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software and in all copies of the supporting
- * documentation for such software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
- * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- ***************************************************************/
-
-/* Please send bug reports to
- David M. Gay
- AT&T Bell Laboratories, Room 2C-463
- 600 Mountain Avenue
- Murray Hill, NJ 07974-2070
- U.S.A.
- dmg@research.att.com or research!dmg
- */
-
-#include <string.h>
-#include <float.h>
-#include <errno.h>
-#include "mprec.h"
-
-double
-_DEFUN (_strtod_r, (ptr, s00, se),
- struct _Jv_reent *ptr _AND
- _CONST char *s00 _AND
- char **se)
-{
- int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e1, esign, i, j,
- k, nd, nd0, nf, nz, nz0, sign;
- int digits = 0; /* Number of digits found in fraction part. */
- long e;
- _CONST char *s, *s0, *s1;
- double aadj, aadj1, adj;
- long L;
- unsigned long y, z;
- union double_union rv, rv0;
-
- _Jv_Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
- sign = nz0 = nz = 0;
- rv.d = 0.;
- for (s = s00;; s++)
- switch (*s)
- {
- case '-':
- sign = 1;
- /* no break */
- case '+':
- if (*++s)
- goto break2;
- /* no break */
- case 0:
- s = s00;
- goto ret;
- case '\t':
- case '\n':
- case '\v':
- case '\f':
- case '\r':
- case ' ':
- continue;
- default:
- goto break2;
- }
-break2:
- if (*s == '0')
- {
- digits++;
- nz0 = 1;
- while (*++s == '0')
- digits++;
- if (!*s)
- goto ret;
- }
- s0 = s;
- y = z = 0;
- for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
- {
- digits++;
- if (nd < 9)
- y = 10 * y + c - '0';
- else if (nd < 16)
- z = 10 * z + c - '0';
- }
- nd0 = nd;
- if (c == '.')
- {
- c = *++s;
- if (!nd)
- {
- for (; c == '0'; c = *++s)
- {
- digits++;
- nz++;
- }
- if (c > '0' && c <= '9')
- {
- digits++;
- s0 = s;
- nf += nz;
- nz = 0;
- goto have_dig;
- }
- goto dig_done;
- }
- for (; c >= '0' && c <= '9'; c = *++s)
- {
- digits++;
- have_dig:
- nz++;
- if (c -= '0')
- {
- nf += nz;
- for (i = 1; i < nz; i++)
- if (nd++ < 9)
- y *= 10;
- else if (nd <= DBL_DIG + 1)
- z *= 10;
- if (nd++ < 9)
- y = 10 * y + c;
- else if (nd <= DBL_DIG + 1)
- z = 10 * z + c;
- nz = 0;
- }
- }
- }
-dig_done:
- e = 0;
- if (c == 'e' || c == 'E')
- {
- if (!nd && !nz && !nz0)
- {
- s = s00;
- goto ret;
- }
- s00 = s;
- esign = 0;
- switch (c = *++s)
- {
- case '-':
- esign = 1;
- case '+':
- c = *++s;
- }
- if (c >= '0' && c <= '9')
- {
- while (c == '0')
- c = *++s;
- if (c > '0' && c <= '9')
- {
- e = c - '0';
- s1 = s;
- while ((c = *++s) >= '0' && c <= '9')
- e = 10 * e + c - '0';
- if (s - s1 > 8)
- /* Avoid confusion from exponents
- * so large that e might overflow.
- */
- e = 9999999L;
- if (esign)
- e = -e;
- }
- else
- {
- /* No exponent after an 'E' : that's an error. */
- ptr->_errno = EINVAL;
- e = 0;
- goto ret;
- }
- }
- else
- s = s00;
- }
- if (!nd)
- {
- if (!nz && !nz0)
- s = s00;
- goto ret;
- }
- e1 = e -= nf;
-
- /* Now we have nd0 digits, starting at s0, followed by a
- * decimal point, followed by nd-nd0 digits. The number we're
- * after is the integer represented by those digits times
- * 10**e */
-
- if (!nd0)
- nd0 = nd;
- k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
- rv.d = y;
- if (k > 9)
- rv.d = tens[k - 9] * rv.d + z;
- bd0 = 0;
- if (nd <= DBL_DIG
-#ifndef RND_PRODQUOT
- && FLT_ROUNDS == 1
-#endif
- )
- {
- if (!e)
- goto ret;
- if (e > 0)
- {
- if (e <= Ten_pmax)
- {
-#ifdef VAX
- goto vax_ovfl_check;
-#else
- /* rv.d = */ rounded_product (rv.d, tens[e]);
- goto ret;
-#endif
- }
- i = DBL_DIG - nd;
- if (e <= Ten_pmax + i)
- {
- /* A fancier test would sometimes let us do
- * this for larger i values.
- */
- e -= i;
- rv.d *= tens[i];
-#ifdef VAX
- /* VAX exponent range is so narrow we must
- * worry about overflow here...
- */
- vax_ovfl_check:
- word0 (rv) -= P * Exp_msk1;
- /* rv.d = */ rounded_product (rv.d, tens[e]);
- if ((word0 (rv) & Exp_mask)
- > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P))
- goto ovfl;
- word0 (rv) += P * Exp_msk1;
-#else
- /* rv.d = */ rounded_product (rv.d, tens[e]);
-#endif
- goto ret;
- }
- }
-#ifndef Inaccurate_Divide
- else if (e >= -Ten_pmax)
- {
- /* rv.d = */ rounded_quotient (rv.d, tens[-e]);
- goto ret;
- }
-#endif
- }
- e1 += nd - k;
-
- /* Get starting approximation = rv.d * 10**e1 */
-
- if (e1 > 0)
- {
- if ((i = e1 & 15))
- rv.d *= tens[i];
-
- if (e1 &= ~15)
- {
- if (e1 > DBL_MAX_10_EXP)
- {
- ovfl:
- ptr->_errno = ERANGE;
-
- /* Force result to IEEE infinity. */
- word0 (rv) = Exp_mask;
- word1 (rv) = 0;
-
- if (bd0)
- goto retfree;
- goto ret;
- }
- if (e1 >>= 4)
- {
- for (j = 0; e1 > 1; j++, e1 >>= 1)
- if (e1 & 1)
- rv.d *= bigtens[j];
- /* The last multiplication could overflow. */
- word0 (rv) -= P * Exp_msk1;
- rv.d *= bigtens[j];
- if ((z = word0 (rv) & Exp_mask)
- > Exp_msk1 * (DBL_MAX_EXP + Bias - P))
- goto ovfl;
- if (z > Exp_msk1 * (DBL_MAX_EXP + Bias - 1 - P))
- {
- /* set to largest number */
- /* (Can't trust DBL_MAX) */
- word0 (rv) = Big0;
-#ifndef _DOUBLE_IS_32BITS
- word1 (rv) = Big1;
-#endif
- }
- else
- word0 (rv) += P * Exp_msk1;
- }
-
- }
- }
- else if (e1 < 0)
- {
- e1 = -e1;
- if ((i = e1 & 15))
- rv.d /= tens[i];
- if (e1 &= ~15)
- {
- e1 >>= 4;
- if (e1 >= 1 << n_bigtens)
- goto undfl;
- for (j = 0; e1 > 1; j++, e1 >>= 1)
- if (e1 & 1)
- rv.d *= tinytens[j];
- /* The last multiplication could underflow. */
- rv0.d = rv.d;
- rv.d *= tinytens[j];
- if (!rv.d)
- {
- rv.d = 2. * rv0.d;
- rv.d *= tinytens[j];
- if (!rv.d)
- {
- undfl:
- rv.d = 0.;
- ptr->_errno = ERANGE;
- if (bd0)
- goto retfree;
- goto ret;
- }
-#ifndef _DOUBLE_IS_32BITS
- word0 (rv) = Tiny0;
- word1 (rv) = Tiny1;
-#else
- word0 (rv) = Tiny1;
-#endif
- /* The refinement below will clean
- * this approximation up.
- */
- }
- }
- }
-
- /* Now the hard part -- adjusting rv to the correct value.*/
-
- /* Put digits into bd: true value = bd * 10^e */
-
- bd0 = s2b (ptr, s0, nd0, nd, y);
-
- for (;;)
- {
- bd = Balloc (ptr, bd0->_k);
- Bcopy (bd, bd0);
- bb = d2b (ptr, rv.d, &bbe, &bbbits); /* rv.d = bb * 2^bbe */
- bs = i2b (ptr, 1);
-
- if (e >= 0)
- {
- bb2 = bb5 = 0;
- bd2 = bd5 = e;
- }
- else
- {
- bb2 = bb5 = -e;
- bd2 = bd5 = 0;
- }
- if (bbe >= 0)
- bb2 += bbe;
- else
- bd2 -= bbe;
- bs2 = bb2;
-#ifdef Sudden_Underflow
-#ifdef IBM
- j = 1 + 4 * P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
-#else
- j = P + 1 - bbbits;
-#endif
-#else
- i = bbe + bbbits - 1; /* logb(rv.d) */
- if (i < Emin) /* denormal */
- j = bbe + (P - Emin);
- else
- j = P + 1 - bbbits;
-#endif
- bb2 += j;
- bd2 += j;
- i = bb2 < bd2 ? bb2 : bd2;
- if (i > bs2)
- i = bs2;
- if (i > 0)
- {
- bb2 -= i;
- bd2 -= i;
- bs2 -= i;
- }
- if (bb5 > 0)
- {
- bs = pow5mult (ptr, bs, bb5);
- bb1 = mult (ptr, bs, bb);
- Bfree (ptr, bb);
- bb = bb1;
- }
- if (bb2 > 0)
- bb = lshift (ptr, bb, bb2);
- if (bd5 > 0)
- bd = pow5mult (ptr, bd, bd5);
- if (bd2 > 0)
- bd = lshift (ptr, bd, bd2);
- if (bs2 > 0)
- bs = lshift (ptr, bs, bs2);
- delta = diff (ptr, bb, bd);
- dsign = delta->_sign;
- delta->_sign = 0;
- i = cmp (delta, bs);
- if (i < 0)
- {
- /* Error is less than half an ulp -- check for
- * special case of mantissa a power of two.
- */
- if (dsign || word1 (rv) || word0 (rv) & Bndry_mask)
- break;
- delta = lshift (ptr, delta, Log2P);
- if (cmp (delta, bs) > 0)
- goto drop_down;
- break;
- }
- if (i == 0)
- {
- /* exactly half-way between */
- if (dsign)
- {
- if ((word0 (rv) & Bndry_mask1) == Bndry_mask1
- && word1 (rv) == 0xffffffff)
- {
- /*boundary case -- increment exponent*/
- word0 (rv) = (word0 (rv) & Exp_mask)
- + Exp_msk1
-#ifdef IBM
- | Exp_msk1 >> 4
-#endif
- ;
-#ifndef _DOUBLE_IS_32BITS
- word1 (rv) = 0;
-#endif
- break;
- }
- }
- else if (!(word0 (rv) & Bndry_mask) && !word1 (rv))
- {
- drop_down:
- /* boundary case -- decrement exponent */
-#ifdef Sudden_Underflow
- L = word0 (rv) & Exp_mask;
-#ifdef IBM
- if (L < Exp_msk1)
-#else
- if (L <= Exp_msk1)
-#endif
- goto undfl;
- L -= Exp_msk1;
-#else
- L = (word0 (rv) & Exp_mask) - Exp_msk1;
-#endif
- word0 (rv) = L | Bndry_mask1;
-#ifndef _DOUBLE_IS_32BITS
- word1 (rv) = 0xffffffff;
-#endif
-#ifdef IBM
- goto cont;
-#else
- break;
-#endif
- }
-#ifndef ROUND_BIASED
- if (!(word1 (rv) & LSB))
- break;
-#endif
- if (dsign)
- rv.d += ulp (rv.d);
-#ifndef ROUND_BIASED
- else
- {
- rv.d -= ulp (rv.d);
-#ifndef Sudden_Underflow
- if (!rv.d)
- goto undfl;
-#endif
- }
-#endif
- break;
- }
- if ((aadj = ratio (delta, bs)) <= 2.)
- {
- if (dsign)
- aadj = aadj1 = 1.;
- else if (word1 (rv) || word0 (rv) & Bndry_mask)
- {
-#ifndef Sudden_Underflow
- if (word1 (rv) == Tiny1 && !word0 (rv))
- goto undfl;
-#endif
- aadj = 1.;
- aadj1 = -1.;
- }
- else
- {
- /* special case -- power of FLT_RADIX to be */
- /* rounded down... */
-
- if (aadj < 2. / FLT_RADIX)
- aadj = 1. / FLT_RADIX;
- else
- aadj *= 0.5;
- aadj1 = -aadj;
- }
- }
- else
- {
- aadj *= 0.5;
- aadj1 = dsign ? aadj : -aadj;
-#ifdef Check_FLT_ROUNDS
- switch (FLT_ROUNDS)
- {
- case 2: /* towards +infinity */
- aadj1 -= 0.5;
- break;
- case 0: /* towards 0 */
- case 3: /* towards -infinity */
- aadj1 += 0.5;
- }
-#else
- if (FLT_ROUNDS == 0)
- aadj1 += 0.5;
-#endif
- }
- y = word0 (rv) & Exp_mask;
-
- /* Check for overflow */
-
- if (y == Exp_msk1 * (DBL_MAX_EXP + Bias - 1))
- {
- rv0.d = rv.d;
- word0 (rv) -= P * Exp_msk1;
- adj = aadj1 * ulp (rv.d);
- rv.d += adj;
- if ((word0 (rv) & Exp_mask) >=
- Exp_msk1 * (DBL_MAX_EXP + Bias - P))
- {
- if (word0 (rv0) == Big0 && word1 (rv0) == Big1)
- goto ovfl;
-#ifdef _DOUBLE_IS_32BITS
- word0 (rv) = Big1;
-#else
- word0 (rv) = Big0;
- word1 (rv) = Big1;
-#endif
- goto cont;
- }
- else
- word0 (rv) += P * Exp_msk1;
- }
- else
- {
-#ifdef Sudden_Underflow
- if ((word0 (rv) & Exp_mask) <= P * Exp_msk1)
- {
- rv0.d = rv.d;
- word0 (rv) += P * Exp_msk1;
- adj = aadj1 * ulp (rv.d);
- rv.d += adj;
-#ifdef IBM
- if ((word0 (rv) & Exp_mask) < P * Exp_msk1)
-#else
- if ((word0 (rv) & Exp_mask) <= P * Exp_msk1)
-#endif
- {
- if (word0 (rv0) == Tiny0
- && word1 (rv0) == Tiny1)
- goto undfl;
- word0 (rv) = Tiny0;
- word1 (rv) = Tiny1;
- goto cont;
- }
- else
- word0 (rv) -= P * Exp_msk1;
- }
- else
- {
- adj = aadj1 * ulp (rv.d);
- rv.d += adj;
- }
-#else
- /* Compute adj so that the IEEE rounding rules will
- * correctly round rv.d + adj in some half-way cases.
- * If rv.d * ulp(rv.d) is denormalized (i.e.,
- * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
- * trouble from bits lost to denormalization;
- * example: 1.2e-307 .
- */
- if (y <= (P - 1) * Exp_msk1 && aadj >= 1.)
- {
- aadj1 = (double) (int) (aadj + 0.5);
- if (!dsign)
- aadj1 = -aadj1;
- }
- adj = aadj1 * ulp (rv.d);
- rv.d += adj;
-#endif
- }
- z = word0 (rv) & Exp_mask;
- if (y == z)
- {
- /* Can we stop now? */
- L = aadj;
- aadj -= L;
- /* The tolerances below are conservative. */
- if (dsign || word1 (rv) || word0 (rv) & Bndry_mask)
- {
- if (aadj < .4999999 || aadj > .5000001)
- break;
- }
- else if (aadj < .4999999 / FLT_RADIX)
- break;
- }
- cont:
- Bfree (ptr, bb);
- Bfree (ptr, bd);
- Bfree (ptr, bs);
- Bfree (ptr, delta);
- }
-retfree:
- Bfree (ptr, bb);
- Bfree (ptr, bd);
- Bfree (ptr, bs);
- Bfree (ptr, bd0);
- Bfree (ptr, delta);
-ret:
- if (se)
- *se = (char *) s;
- if (digits == 0)
- ptr->_errno = EINVAL;
- return sign ? -rv.d : rv.d;
-}
-
diff --git a/libjava/java/lang/w_acos.c b/libjava/java/lang/w_acos.c
deleted file mode 100644
index c9ca99c4041..00000000000
--- a/libjava/java/lang/w_acos.c
+++ /dev/null
@@ -1,118 +0,0 @@
-
-/* @(#)w_acos.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
- <<acos>>, <<acosf>>---arc cosine
-
-INDEX
- acos
-INDEX
- acosf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double acos(double <[x]>);
- float acosf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double acos(<[x]>)
- double <[x]>;
-
- float acosf(<[x]>)
- float <[x]>;
-
-
-
-DESCRIPTION
-
- <<acos>> computes the inverse cosine (arc cosine) of the input value.
- Arguments to <<acos>> must be in the range @minus{}1 to 1.
-
- <<acosf>> is identical to <<acos>>, except that it performs
- its calculations on <<floats>>.
-
-RETURNS
- @ifinfo
- <<acos>> and <<acosf>> return values in radians, in the range of 0 to pi.
- @end ifinfo
- @tex
- <<acos>> and <<acosf>> return values in radians, in the range of <<0>> to $\pi$.
- @end tex
-
- If <[x]> is not between @minus{}1 and 1, the returned value is NaN
- (not a number) the global variable <<errno>> is set to <<EDOM>>, and a
- <<DOMAIN error>> message is sent as standard error output.
-
- You can modify error handling for these functions using <<matherr>>.
-
-
-QUICKREF ANSI SVID POSIX RENTRANT
- acos y,y,y,m
- acosf n,n,n,m
-
-MATHREF
- acos, [-1,1], acos(arg),,,
- acos, NAN, arg,DOMAIN,EDOM
-
-MATHREF
- acosf, [-1,1], acosf(arg),,,
- acosf, NAN, argf,DOMAIN,EDOM
-
-*/
-
-/*
- * wrap_acos(x)
- */
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double acos(double x) /* wrapper acos */
-#else
- double acos(x) /* wrapper acos */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_acos(x);
-#else
- double z;
- struct exception exc;
- z = __ieee754_acos(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(fabs(x)>1.0) {
- /* acos(|x|>1) */
- exc.type = DOMAIN;
- exc.name = "acos";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
- return z;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/w_asin.c b/libjava/java/lang/w_asin.c
deleted file mode 100644
index f6cb271d392..00000000000
--- a/libjava/java/lang/w_asin.c
+++ /dev/null
@@ -1,121 +0,0 @@
-
-/* @(#)w_asin.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-
-/*
-FUNCTION
- <<asin>>, <<asinf>>---arc sine
-
-INDEX
- asin
-INDEX
- asinf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double asin(double <[x]>);
- float asinf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double asin(<[x]>)
- double <[x]>;
-
- float asinf(<[x]>)
- float <[x]>;
-
-
-DESCRIPTION
-
-<<asin>> computes the inverse sine (arc sine) of the argument <[x]>.
-Arguments to <<asin>> must be in the range @minus{}1 to 1.
-
-<<asinf>> is identical to <<asin>>, other than taking and
-returning floats.
-
-You can modify error handling for these routines using <<matherr>>.
-
-RETURNS
-@ifinfo
-<<asin>> returns values in radians, in the range of -pi/2 to pi/2.
-@end ifinfo
-@tex
-<<asin>> returns values in radians, in the range of $-\pi/2$ to $\pi/2$.
-@end tex
-
-If <[x]> is not in the range @minus{}1 to 1, <<asin>> and <<asinf>>
-return NaN (not a number), set the global variable <<errno>> to
-<<EDOM>>, and issue a <<DOMAIN error>> message.
-
-You can change this error treatment using <<matherr>>.
-
-QUICKREF ANSI SVID POSIX RENTRANT
- asin y,y,y,m
- asinf n,n,n,m
-
-MATHREF
- asin, -1<=arg<=1, asin(arg),,,
- asin, NAN, arg,EDOM, DOMAIN
-
-MATHREF
- asinf, -1<=arg<=1, asin(arg),,,
- asinf, NAN, arg,EDOM, DOMAIN
-
-
-*/
-
-/*
- * wrapper asin(x)
- */
-
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double asin(double x) /* wrapper asin */
-#else
- double asin(x) /* wrapper asin */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_asin(x);
-#else
- double z;
- struct exception exc;
- z = __ieee754_asin(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(fabs(x)>1.0) {
- /* asin(|x|>1) */
- exc.type = DOMAIN;
- exc.name = "asin";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0;
- if(_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
- return z;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/w_atan2.c b/libjava/java/lang/w_atan2.c
deleted file mode 100644
index 91742c72b91..00000000000
--- a/libjava/java/lang/w_atan2.c
+++ /dev/null
@@ -1,117 +0,0 @@
-
-/* @(#)w_atan2.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- *
- */
-
-/*
-FUNCTION
- <<atan2>>, <<atan2f>>---arc tangent of y/x
-
-INDEX
- atan2
-INDEX
- atan2f
-
-ANSI_SYNOPSIS
- #include <math.h>
- double atan2(double <[y]>,double <[x]>);
- float atan2f(float <[y]>,float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double atan2(<[y]>,<[x]>);
- double <[y]>;
- double <[x]>;
-
- float atan2f(<[y]>,<[x]>);
- float <[y]>;
- float <[x]>;
-
-DESCRIPTION
-
-<<atan2>> computes the inverse tangent (arc tangent) of <[y]>/<[x]>.
-<<atan2>> produces the correct result even for angles near
-@ifinfo
-pi/2 or -pi/2
-@end ifinfo
-@tex
-$\pi/2$ or $-\pi/2$
-@end tex
-(that is, when <[x]> is near 0).
-
-<<atan2f>> is identical to <<atan2>>, save that it takes and returns
-<<float>>.
-
-RETURNS
-<<atan2>> and <<atan2f>> return a value in radians, in the range of
-@ifinfo
--pi to pi.
-@end ifinfo
-@tex
-$-\pi$ to $\pi$.
-@end tex
-
-If both <[x]> and <[y]> are 0.0, <<atan2>> causes a <<DOMAIN>> error.
-
-You can modify error handling for these functions using <<matherr>>.
-
-PORTABILITY
-<<atan2>> is ANSI C. <<atan2f>> is an extension.
-
-
-*/
-
-/*
- * wrapper atan2(y,x)
- */
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double atan2(double y, double x) /* wrapper atan2 */
-#else
- double atan2(y,x) /* wrapper atan2 */
- double y,x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_atan2(y,x);
-#else
- double z;
- struct exception exc;
- z = __ieee754_atan2(y,x);
- if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z;
- if(x==0.0&&y==0.0) {
- /* atan2(+-0,+-0) */
- exc.arg1 = y;
- exc.arg2 = x;
- exc.type = DOMAIN;
- exc.name = "atan2";
- exc.err = 0;
- exc.retval = 0.0;
- if(_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
- return z;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/w_exp.c b/libjava/java/lang/w_exp.c
deleted file mode 100644
index ae792a84642..00000000000
--- a/libjava/java/lang/w_exp.c
+++ /dev/null
@@ -1,136 +0,0 @@
-
-/* @(#)w_exp.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
- <<exp>>, <<expf>>---exponential
-INDEX
- exp
-INDEX
- expf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double exp(double <[x]>);
- float expf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double exp(<[x]>);
- double <[x]>;
-
- float expf(<[x]>);
- float <[x]>;
-
-DESCRIPTION
- <<exp>> and <<expf>> calculate the exponential of <[x]>, that is,
- @ifinfo
- e raised to the power <[x]> (where e
- @end ifinfo
- @tex
- $e^x$ (where $e$
- @end tex
- is the base of the natural system of logarithms, approximately 2.71828).
-
- You can use the (non-ANSI) function <<matherr>> to specify
- error handling for these functions.
-
-RETURNS
- On success, <<exp>> and <<expf>> return the calculated value.
- If the result underflows, the returned value is <<0>>. If the
- result overflows, the returned value is <<HUGE_VAL>>. In
- either case, <<errno>> is set to <<ERANGE>>.
-
-PORTABILITY
- <<exp>> is ANSI C. <<expf>> is an extension.
-
-*/
-
-/*
- * wrapper exp(x)
- */
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
-u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
-
-#ifdef __STDC__
- double exp(double x) /* wrapper exp */
-#else
- double exp(x) /* wrapper exp */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_exp(x);
-#else
- double z;
- struct exception exc;
- z = __ieee754_exp(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(finite(x)) {
- if(x>o_threshold) {
- /* exp(finite) overflow */
-#ifndef HUGE_VAL
-#define HUGE_VAL inf
- double inf = 0.0;
-
- SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
-#endif
- exc.type = OVERFLOW;
- exc.name = "exp";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else if(x<u_threshold) {
- /* exp(finite) underflow */
- exc.type = UNDERFLOW;
- exc.name = "exp";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
- }
- return z;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/w_fmod.c b/libjava/java/lang/w_fmod.c
deleted file mode 100644
index b6b36cb76ab..00000000000
--- a/libjava/java/lang/w_fmod.c
+++ /dev/null
@@ -1,107 +0,0 @@
-
-/* @(#)w_fmod.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
-<<fmod>>, <<fmodf>>---floating-point remainder (modulo)
-
-INDEX
-fmod
-INDEX
-fmodf
-
-ANSI_SYNOPSIS
-#include <math.h>
-double fmod(double <[x]>, double <[y]>)
-float fmodf(float <[x]>, float <[y]>)
-
-TRAD_SYNOPSIS
-#include <math.h>
-double fmod(<[x]>, <[y]>)
-double (<[x]>, <[y]>);
-
-float fmodf(<[x]>, <[y]>)
-float (<[x]>, <[y]>);
-
-DESCRIPTION
-The <<fmod>> and <<fmodf>> functions compute the floating-point
-remainder of <[x]>/<[y]> (<[x]> modulo <[y]>).
-
-RETURNS
-The <<fmod>> function returns the value
-@ifinfo
-<[x]>-<[i]>*<[y]>,
-@end ifinfo
-@tex
-$x-i\times y$,
-@end tex
-for the largest integer <[i]> such that, if <[y]> is nonzero, the
-result has the same sign as <[x]> and magnitude less than the
-magnitude of <[y]>.
-
-<<fmod(<[x]>,0)>> returns NaN, and sets <<errno>> to <<EDOM>>.
-
-You can modify error treatment for these functions using <<matherr>>.
-
-PORTABILITY
-<<fmod>> is ANSI C. <<fmodf>> is an extension.
-*/
-
-/*
- * wrapper fmod(x,y)
- */
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double fmod(double x, double y) /* wrapper fmod */
-#else
- double fmod(x,y) /* wrapper fmod */
- double x,y;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_fmod(x,y);
-#else
- double z;
- struct exception exc;
- z = __ieee754_fmod(x,y);
- if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
- if(y==0.0) {
- /* fmod(x,0) */
- exc.type = DOMAIN;
- exc.name = "fmod";
- exc.arg1 = x;
- exc.arg2 = y;
- exc.err = 0;
- if (_LIB_VERSION == _SVID_)
- exc.retval = x;
- else
- exc.retval = 0.0/0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
- return z;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/w_log.c b/libjava/java/lang/w_log.c
deleted file mode 100644
index dcc8b9762ec..00000000000
--- a/libjava/java/lang/w_log.c
+++ /dev/null
@@ -1,115 +0,0 @@
-
-/* @(#)w_log.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
- <<log>>, <<logf>>---natural logarithms
-
-INDEX
- log
-INDEX
- logf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double log(double <[x]>);
- float logf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double log(<[x]>);
- double <[x]>;
-
- float logf(<[x]>);
- float <[x]>;
-
-DESCRIPTION
-Return the natural logarithm of <[x]>, that is, its logarithm base e
-(where e is the base of the natural system of logarithms, 2.71828@dots{}).
-<<log>> and <<logf>> are identical save for the return and argument types.
-
-You can use the (non-ANSI) function <<matherr>> to specify error
-handling for these functions.
-
-RETURNS
-Normally, returns the calculated value. When <[x]> is zero, the
-returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>.
-When <[x]> is negative, the returned value is <<-HUGE_VAL>> and
-<<errno>> is set to <<EDOM>>. You can control the error behavior via
-<<matherr>>.
-
-PORTABILITY
-<<log>> is ANSI, <<logf>> is an extension.
-*/
-
-/*
- * wrapper log(x)
- */
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double log(double x) /* wrapper log */
-#else
- double log(x) /* wrapper log */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_log(x);
-#else
- double z;
- struct exception exc;
- z = __ieee754_log(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z;
-#ifndef HUGE_VAL
-#define HUGE_VAL inf
- double inf = 0.0;
-
- SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
-#endif
- exc.name = "log";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = x;
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if(x==0.0) {
- /* log(0) */
- exc.type = SING;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- } else {
- /* log(x<0) */
- exc.type = DOMAIN;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/lang/w_pow.c b/libjava/java/lang/w_pow.c
deleted file mode 100644
index 3df099a1714..00000000000
--- a/libjava/java/lang/w_pow.c
+++ /dev/null
@@ -1,231 +0,0 @@
-
-
-/* @(#)w_pow.c 5.2 93/10/01 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
- <<pow>>, <<powf>>---x to the power y
-INDEX
- pow
-INDEX
- powf
-
-
-ANSI_SYNOPSIS
- #include <math.h>
- double pow(double <[x]>, double <[y]>);
- float pow(float <[x]>, float <[y]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double pow(<[x]>, <[y]>);
- double <[x]>, <[y]>;
-
- float pow(<[x]>, <[y]>);
- float <[x]>, <[y]>;
-
-DESCRIPTION
- <<pow>> and <<powf>> calculate <[x]> raised to the exp1.0nt <[y]>.
- @tex
- (That is, $x^y$.)
- @end tex
-
-RETURNS
- On success, <<pow>> and <<powf>> return the value calculated.
-
- When the argument values would produce overflow, <<pow>>
- returns <<HUGE_VAL>> and set <<errno>> to <<ERANGE>>. If the
- argument <[x]> passed to <<pow>> or <<powf>> is a negative
- noninteger, and <[y]> is also not an integer, then <<errno>>
- is set to <<EDOM>>. If <[x]> and <[y]> are both 0, then
- <<pow>> and <<powf>> return <<1>>.
-
- You can modify error handling for these functions using <<matherr>>.
-
-PORTABILITY
- <<pow>> is ANSI C. <<powf>> is an extension. */
-
-/*
- * wrapper pow(x,y) return x**y
- */
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double pow(double x, double y) /* wrapper pow */
-#else
- double pow(x,y) /* wrapper pow */
- double x,y;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_pow(x,y);
-#else
- double z;
-#ifndef HUGE_VAL
-#define HUGE_VAL inf
- double inf = 0.0;
-
- SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
-#endif
- struct exception exc;
- z=__ieee754_pow(x,y);
- if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
- if(isnan(x)) {
- if(y==0.0) {
- /* pow(NaN,0.0) */
- /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
- exc.type = DOMAIN;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- exc.retval = x;
- if (_LIB_VERSION == _IEEE_ ||
- _LIB_VERSION == _POSIX_) exc.retval = 1.0;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
- return z;
- }
- if(x==0.0){
- if(y==0.0) {
- /* pow(0.0,0.0) */
- /* error only if _LIB_VERSION == _SVID_ */
- exc.type = DOMAIN;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- exc.retval = 0.0;
- if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
- if(finite(y)&&y<0.0) {
- /* 0**neg */
- exc.type = DOMAIN;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- if (_LIB_VERSION == _SVID_)
- exc.retval = 0.0;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
- return z;
- }
- if(!finite(z)) {
- if(finite(x)&&finite(y)) {
- if(isnan(z)) {
- /* neg**non-integral */
- exc.type = DOMAIN;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- if (_LIB_VERSION == _SVID_)
- exc.retval = 0.0;
- else
- exc.retval = 0.0/0.0; /* X/Open allow NaN */
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else {
- /* pow(x,y) overflow */
- exc.type = OVERFLOW;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- if (_LIB_VERSION == _SVID_) {
- exc.retval = HUGE;
- y *= 0.5;
- if(x<0.0&&rint(y)!=y) exc.retval = -HUGE;
- } else {
- exc.retval = HUGE_VAL;
- y *= 0.5;
- if(x<0.0&&rint(y)!=y) exc.retval = -HUGE_VAL;
- }
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
- }
- }
- if(z==0.0&&finite(x)&&finite(y)) {
- /* pow(x,y) underflow */
- exc.type = UNDERFLOW;
- exc.name = "pow";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- exc.retval = 0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- }
- return z;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/libjava/java/lang/w_remainder.c b/libjava/java/lang/w_remainder.c
deleted file mode 100644
index a06be0e7b30..00000000000
--- a/libjava/java/lang/w_remainder.c
+++ /dev/null
@@ -1,119 +0,0 @@
-
-/* @(#)w_remainder.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
-<<rint>>, <<rintf>>, <<remainder>>, <<remainderf>>---round and remainder
-INDEX
- rint
-INDEX
- rintf
-INDEX
- remainder
-INDEX
- remainderf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double rint(double <[x]>);
- float rintf(float <[x]>);
- double remainder(double <[x]>, double <[y]>);
- float remainderf(float <[x]>, float <[y]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double rint(<[x]>)
- double <[x]>;
- float rintf(<[x]>)
- float <[x]>;
- double remainder(<[x]>,<[y]>)
- double <[x]>, <[y]>;
- float remainderf(<[x]>,<[y]>)
- float <[x]>, <[y]>;
-
-DESCRIPTION
-<<rint>> and <<rintf>> returns their argument rounded to the nearest
-integer. <<remainder>> and <<remainderf>> find the remainder of
-<[x]>/<[y]>; this value is in the range -<[y]>/2 .. +<[y]>/2.
-
-RETURNS
-<<rint>> and <<remainder>> return the integer result as a double.
-
-PORTABILITY
-<<rint>> and <<remainder>> are System V release 4. <<rintf>> and
-<<remainderf>> are extensions.
-
-*/
-
-/*
- * wrapper remainder(x,p)
- */
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double remainder(double x, double y) /* wrapper remainder */
-#else
- double remainder(x,y) /* wrapper remainder */
- double x,y;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_remainder(x,y);
-#else
- double z;
- struct exception exc;
- z = __ieee754_remainder(x,y);
- if(_LIB_VERSION == _IEEE_ || isnan(y)) return z;
- if(y==0.0) {
- /* remainder(x,0) */
- exc.type = DOMAIN;
- exc.name = "remainder";
- exc.err = 0;
- exc.arg1 = x;
- exc.arg2 = y;
- exc.retval = 0.0/0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
- return z;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/libjava/java/lang/w_sqrt.c b/libjava/java/lang/w_sqrt.c
deleted file mode 100644
index 23a793ce74a..00000000000
--- a/libjava/java/lang/w_sqrt.c
+++ /dev/null
@@ -1,93 +0,0 @@
-
-/* @(#)w_sqrt.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/*
-FUNCTION
- <<sqrt>>, <<sqrtf>>---positive square root
-
-INDEX
- sqrt
-INDEX
- sqrtf
-
-ANSI_SYNOPSIS
- #include <math.h>
- double sqrt(double <[x]>);
- float sqrtf(float <[x]>);
-
-TRAD_SYNOPSIS
- #include <math.h>
- double sqrt(<[x]>);
- float sqrtf(<[x]>);
-
-DESCRIPTION
- <<sqrt>> computes the positive square root of the argument.
- You can modify error handling for this function with
- <<matherr>>.
-
-RETURNS
- On success, the square root is returned. If <[x]> is real and
- positive, then the result is positive. If <[x]> is real and
- negative, the global value <<errno>> is set to <<EDOM>> (domain error).
-
-
-PORTABILITY
- <<sqrt>> is ANSI C. <<sqrtf>> is an extension.
-*/
-
-/*
- * wrapper sqrt(x)
- */
-
-#include "fdlibm.h"
-#include <errno.h>
-
-#ifndef _DOUBLE_IS_32BITS
-
-#ifdef __STDC__
- double sqrt(double x) /* wrapper sqrt */
-#else
- double sqrt(x) /* wrapper sqrt */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_sqrt(x);
-#else
- struct exception exc;
- double z;
- z = __ieee754_sqrt(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(x<0.0) {
- exc.type = DOMAIN;
- exc.name = "sqrt";
- exc.err = 0;
- exc.arg1 = exc.arg2 = x;
- if (_LIB_VERSION == _SVID_)
- exc.retval = 0.0;
- else
- exc.retval = 0.0/0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return exc.retval;
- } else
- return z;
-#endif
-}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/libjava/java/math/BigInteger.java b/libjava/java/math/BigInteger.java
deleted file mode 100644
index 738680a42c4..00000000000
--- a/libjava/java/math/BigInteger.java
+++ /dev/null
@@ -1,2204 +0,0 @@
-// BigInteger.java -- an arbitrary-precision integer
-
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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 java.math;
-import gnu.gcj.math.*;
-import java.util.Random;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date December 20, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998) and
- * "Applied Cryptography, Second Edition" by Bruce Schneier (Wiley, 1996).
-
- *
- * Based primarily on IntNum.java BitOps.java by Per Bothner <per@bothner.com>
- * (found in Kawa 1.6.62).
- *
- * Status: Believed complete and correct.
- */
-
-public class BigInteger extends Number implements Comparable
-{
- /** All integers are stored in 2's-complement form.
- * If words == null, the ival is the value of this BigInteger.
- * Otherwise, the first ival elements of words make the value
- * of this BigInteger, stored in little-endian order, 2's-complement form. */
- private int ival;
- private int[] words;
-
-
- /** We pre-allocate integers in the range minFixNum..maxFixNum. */
- private static final int minFixNum = -100;
- private static final int maxFixNum = 1024;
- private static final int numFixNum = maxFixNum-minFixNum+1;
- private static final BigInteger[] smallFixNums = new BigInteger[numFixNum];
-
- static {
- for (int i = numFixNum; --i >= 0; )
- smallFixNums[i] = new BigInteger(i + minFixNum);
- }
-
- // JDK1.2
- public static final BigInteger ZERO = smallFixNums[-minFixNum];
-
- // JDK1.2
- public static final BigInteger ONE = smallFixNums[1 - minFixNum];
-
- /* Rounding modes: */
- private static final int FLOOR = 1;
- private static final int CEILING = 2;
- private static final int TRUNCATE = 3;
- private static final int ROUND = 4;
-
- /** When checking the probability of primes, it is most efficient to
- * first check the factoring of small primes, so we'll use this array.
- */
- private static final int[] primes =
- { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
- 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,
- 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
- 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251 };
-
- private BigInteger()
- {
- }
-
- /* Create a new (non-shared) BigInteger, and initialize to an int. */
- private BigInteger(int value)
- {
- ival = value;
- }
-
- public BigInteger(String val, int radix)
- {
- BigInteger result = valueOf(val, radix);
- this.ival = result.ival;
- this.words = result.words;
- }
-
- public BigInteger(String val)
- {
- this(val, 10);
- }
-
- /* Create a new (non-shared) BigInteger, and initialize from a byte array. */
- public BigInteger(byte[] val)
- {
- if (val == null || val.length < 1)
- throw new NumberFormatException();
-
- words = byteArrayToIntArray(val, val[0] < 0 ? -1 : 0);
- BigInteger result = make(words, words.length);
- this.ival = result.ival;
- this.words = result.words;
- }
-
- public BigInteger(int signum, byte[] magnitude)
- {
- if (magnitude == null || signum > 1 || signum < -1)
- throw new NumberFormatException();
-
- if (signum == 0)
- {
- int i;
- for (i = magnitude.length - 1; i >= 0 && magnitude[i] == 0; --i)
- ;
- if (i >= 0)
- throw new NumberFormatException();
- return;
- }
-
- // Magnitude is always positive, so don't ever pass a sign of -1.
- words = byteArrayToIntArray(magnitude, 0);
- BigInteger result = make(words, words.length);
- this.ival = result.ival;
- this.words = result.words;
-
- if (signum < 0)
- setNegative();
- }
-
- public BigInteger(int numBits, Random rnd)
- {
- if (numBits < 0)
- throw new IllegalArgumentException();
-
- // Result is always positive so tack on an extra zero word, it will be
- // canonicalized out later if necessary.
- int nwords = numBits / 32 + 2;
- words = new int[nwords];
- words[--nwords] = 0;
- words[--nwords] = rnd.nextInt() >>> (numBits % 32);
- while (--nwords >= 0)
- words[nwords] = rnd.nextInt();
-
- BigInteger result = make(words, words.length);
- this.ival = result.ival;
- this.words = result.words;
- }
-
- public BigInteger(int bitLength, int certainty, Random rnd)
- {
- this(bitLength, rnd);
-
- // Keep going until we find a probable prime.
- while (true)
- {
- if (isProbablePrime(certainty))
- return;
-
- BigInteger next = new BigInteger(bitLength, rnd);
- this.ival = next.ival;
- this.words = next.words;
- }
- }
-
- /** Return a (possibly-shared) BigInteger with a given long value. */
- private static BigInteger make(long value)
- {
- if (value >= minFixNum && value <= maxFixNum)
- return smallFixNums[(int)value - minFixNum];
- int i = (int) value;
- if ((long)i == value)
- return new BigInteger(i);
- BigInteger result = alloc(2);
- result.ival = 2;
- result.words[0] = i;
- result.words[1] = (int) (value >> 32);
- return result;
- }
-
- // FIXME: Could simply rename 'make' method above as valueOf while
- // changing all instances of 'make'. Don't do this until this class
- // is done as the Kawa class this is based on has 'make' methods
- // with other parameters; wait to see if they are used in BigInteger.
- public static BigInteger valueOf(long val)
- {
- return make(val);
- }
-
- /** Make a canonicalized BigInteger from an array of words.
- * The array may be reused (without copying). */
- private static BigInteger make(int[] words, int len)
- {
- if (words == null)
- return make(len);
- len = BigInteger.wordsNeeded(words, len);
- if (len <= 1)
- return len == 0 ? ZERO : make(words[0]);
- BigInteger num = new BigInteger();
- num.words = words;
- num.ival = len;
- return num;
- }
-
- /** Convert a big-endian byte array to a little-endian array of words. */
- private static int[] byteArrayToIntArray(byte[] bytes, int sign)
- {
- // Determine number of words needed.
- int[] words = new int[(bytes.length + 3) / 4 + 1];
- int nwords = words.length;
-
- // For simplicity, tack on an extra word of sign at the front,
- // it will be canonicalized out later. */
- words[--nwords] = sign;
-
- // Create a int out of modulo 4 high order bytes.
- int bptr = 0;
- int word = sign;
- for (int i = bytes.length % 4; i > 0; --i, bptr++)
- word = (word << 8) | (((int) bytes[bptr]) & 0xff);
- words[--nwords] = word;
-
- // Elements remaining in byte[] are a multiple of 4.
- while (nwords > 0)
- words[--nwords] = bytes[bptr++] << 24 |
- (((int) bytes[bptr++]) & 0xff) << 16 |
- (((int) bytes[bptr++]) & 0xff) << 8 |
- (((int) bytes[bptr++]) & 0xff);
- return words;
- }
-
- /** Allocate a new non-shared BigInteger.
- * @param nwords number of words to allocate
- */
- private static BigInteger alloc(int nwords)
- {
- if (nwords <= 1)
- return new BigInteger();
- BigInteger result = new BigInteger();
- result.words = new int[nwords];
- return result;
- }
-
- /** Change words.length to nwords.
- * We allow words.length to be upto nwords+2 without reallocating.
- */
- private void realloc(int nwords)
- {
- if (nwords == 0)
- {
- if (words != null)
- {
- if (ival > 0)
- ival = words[0];
- words = null;
- }
- }
- else if (words == null
- || words.length < nwords
- || words.length > nwords + 2)
- {
- int[] new_words = new int [nwords];
- if (words == null)
- {
- new_words[0] = ival;
- ival = 1;
- }
- else
- {
- if (nwords < ival)
- ival = nwords;
- System.arraycopy(words, 0, new_words, 0, ival);
- }
- words = new_words;
- }
- }
-
- private final boolean isNegative()
- {
- return (words == null ? ival : words[ival - 1]) < 0;
- }
-
- public int signum()
- {
- int top = words == null ? ival : words[ival-1];
- if (top == 0 && words == null)
- return 0;
- return top < 0 ? -1 : 1;
- }
-
- private static int compareTo(BigInteger x, BigInteger y)
- {
- if (x.words == null && y.words == null)
- return x.ival < y.ival ? -1 : x.ival > y.ival ? 1 : 0;
- boolean x_negative = x.isNegative();
- boolean y_negative = y.isNegative();
- if (x_negative != y_negative)
- return x_negative ? -1 : 1;
- int x_len = x.words == null ? 1 : x.ival;
- int y_len = y.words == null ? 1 : y.ival;
- if (x_len != y_len)
- return (x_len > y_len) != x_negative ? 1 : -1;
- return MPN.cmp(x.words, y.words, x_len);
- }
-
- // JDK1.2
- public int compareTo(Object obj)
- {
- if (obj instanceof BigInteger)
- return compareTo(this, (BigInteger) obj);
- throw new ClassCastException();
- }
-
- public int compareTo(BigInteger val)
- {
- return compareTo(this, val);
- }
-
- public BigInteger min(BigInteger val)
- {
- return compareTo(this, val) < 0 ? this : val;
- }
-
- public BigInteger max(BigInteger val)
- {
- return compareTo(this, val) > 0 ? this : val;
- }
-
- private final boolean isOdd()
- {
- int low = words == null ? ival : words[0];
- return (low & 1) != 0;
- }
-
- private final boolean isZero()
- {
- return words == null && ival == 0;
- }
-
- private final boolean isOne()
- {
- return words == null && ival == 1;
- }
-
- private final boolean isMinusOne()
- {
- return words == null && ival == -1;
- }
-
- /** Calculate how many words are significant in words[0:len-1].
- * Returns the least value x such that x>0 && words[0:x-1]==words[0:len-1],
- * when words is viewed as a 2's complement integer.
- */
- private static int wordsNeeded(int[] words, int len)
- {
- int i = len;
- if (i > 0)
- {
- int word = words[--i];
- if (word == -1)
- {
- while (i > 0 && (word = words[i - 1]) < 0)
- {
- i--;
- if (word != -1) break;
- }
- }
- else
- {
- while (word == 0 && i > 0 && (word = words[i - 1]) >= 0) i--;
- }
- }
- return i + 1;
- }
-
- private BigInteger canonicalize()
- {
- if (words != null
- && (ival = BigInteger.wordsNeeded(words, ival)) <= 1)
- {
- if (ival == 1)
- ival = words[0];
- words = null;
- }
- if (words == null && ival >= minFixNum && ival <= maxFixNum)
- return smallFixNums[(int) ival - minFixNum];
- return this;
- }
-
- /** Add two ints, yielding a BigInteger. */
- private static final BigInteger add(int x, int y)
- {
- return BigInteger.make((long) x + (long) y);
- }
-
- /** Add a BigInteger and an int, yielding a new BigInteger. */
- private static BigInteger add(BigInteger x, int y)
- {
- if (x.words == null)
- return BigInteger.add(x.ival, y);
- BigInteger result = new BigInteger(0);
- result.setAdd(x, y);
- return result.canonicalize();
- }
-
- /** Set this to the sum of x and y.
- * OK if x==this. */
- private void setAdd(BigInteger x, int y)
- {
- if (x.words == null)
- {
- set((long) x.ival + (long) y);
- return;
- }
- int len = x.ival;
- realloc(len + 1);
- long carry = y;
- for (int i = 0; i < len; i++)
- {
- carry += ((long) x.words[i] & 0xffffffffL);
- words[i] = (int) carry;
- carry >>= 32;
- }
- if (x.words[len - 1] < 0)
- carry--;
- words[len] = (int) carry;
- ival = wordsNeeded(words, len + 1);
- }
-
- /** Destructively add an int to this. */
- private final void setAdd(int y)
- {
- setAdd(this, y);
- }
-
- /** Destructively set the value of this to a long. */
- private final void set(long y)
- {
- int i = (int) y;
- if ((long) i == y)
- {
- ival = i;
- words = null;
- }
- else
- {
- realloc(2);
- words[0] = i;
- words[1] = (int) (y >> 32);
- ival = 2;
- }
- }
-
- /** Destructively set the value of this to the given words.
- * The words array is reused, not copied. */
- private final void set(int[] words, int length)
- {
- this.ival = length;
- this.words = words;
- }
-
- /** Destructively set the value of this to that of y. */
- private final void set(BigInteger y)
- {
- if (y.words == null)
- set(y.ival);
- else if (this != y)
- {
- realloc(y.ival);
- System.arraycopy(y.words, 0, words, 0, y.ival);
- ival = y.ival;
- }
- }
-
- /** Add two BigIntegers, yielding their sum as another BigInteger. */
- private static BigInteger add(BigInteger x, BigInteger y, int k)
- {
- if (x.words == null && y.words == null)
- return BigInteger.make((long) k * (long) y.ival + (long) x.ival);
- if (k != 1)
- {
- if (k == -1)
- y = BigInteger.neg(y);
- else
- y = BigInteger.times(y, BigInteger.make(k));
- }
- if (x.words == null)
- return BigInteger.add(y, x.ival);
- if (y.words == null)
- return BigInteger.add(x, y.ival);
- // Both are big
- int len;
- if (y.ival > x.ival)
- { // Swap so x is longer then y.
- BigInteger tmp = x; x = y; y = tmp;
- }
- BigInteger result = alloc(x.ival + 1);
- int i = y.ival;
- long carry = MPN.add_n(result.words, x.words, y.words, i);
- long y_ext = y.words[i - 1] < 0 ? 0xffffffffL : 0;
- for (; i < x.ival; i++)
- {
- carry += ((long) x.words[i] & 0xffffffffL) + y_ext;;
- result.words[i] = (int) carry;
- carry >>>= 32;
- }
- if (x.words[i - 1] < 0)
- y_ext--;
- result.words[i] = (int) (carry + y_ext);
- result.ival = i+1;
- return result.canonicalize();
- }
-
- public BigInteger add(BigInteger val)
- {
- return add(this, val, 1);
- }
-
- public BigInteger subtract(BigInteger val)
- {
- return add(this, val, -1);
- }
-
- private static final BigInteger times(BigInteger x, int y)
- {
- if (y == 0)
- return ZERO;
- if (y == 1)
- return x;
- int[] xwords = x.words;
- int xlen = x.ival;
- if (xwords == null)
- return BigInteger.make((long) xlen * (long) y);
- boolean negative;
- BigInteger result = BigInteger.alloc(xlen + 1);
- if (xwords[xlen - 1] < 0)
- {
- negative = true;
- negate(result.words, xwords, xlen);
- xwords = result.words;
- }
- else
- negative = false;
- if (y < 0)
- {
- negative = !negative;
- y = -y;
- }
- result.words[xlen] = MPN.mul_1(result.words, xwords, xlen, y);
- result.ival = xlen + 1;
- if (negative)
- result.setNegative();
- return result.canonicalize();
- }
-
- private static final BigInteger times(BigInteger x, BigInteger y)
- {
- if (y.words == null)
- return times(x, y.ival);
- if (x.words == null)
- return times(y, x.ival);
- boolean negative = false;
- int[] xwords;
- int[] ywords;
- int xlen = x.ival;
- int ylen = y.ival;
- if (x.isNegative())
- {
- negative = true;
- xwords = new int[xlen];
- negate(xwords, x.words, xlen);
- }
- else
- {
- negative = false;
- xwords = x.words;
- }
- if (y.isNegative())
- {
- negative = !negative;
- ywords = new int[ylen];
- negate(ywords, y.words, ylen);
- }
- else
- ywords = y.words;
- // Swap if x is shorter then y.
- if (xlen < ylen)
- {
- int[] twords = xwords; xwords = ywords; ywords = twords;
- int tlen = xlen; xlen = ylen; ylen = tlen;
- }
- BigInteger result = BigInteger.alloc(xlen+ylen);
- MPN.mul(result.words, xwords, xlen, ywords, ylen);
- result.ival = xlen+ylen;
- if (negative)
- result.setNegative();
- return result.canonicalize();
- }
-
- public BigInteger multiply(BigInteger y)
- {
- return times(this, y);
- }
-
- private static void divide(long x, long y,
- BigInteger quotient, BigInteger remainder,
- int rounding_mode)
- {
- boolean xNegative, yNegative;
- if (x < 0)
- {
- xNegative = true;
- if (x == Long.MIN_VALUE)
- {
- divide(BigInteger.make(x), BigInteger.make(y),
- quotient, remainder, rounding_mode);
- return;
- }
- x = -x;
- }
- else
- xNegative = false;
-
- if (y < 0)
- {
- yNegative = true;
- if (y == Long.MIN_VALUE)
- {
- if (rounding_mode == TRUNCATE)
- { // x != Long.Min_VALUE implies abs(x) < abs(y)
- if (quotient != null)
- quotient.set(0);
- if (remainder != null)
- remainder.set(x);
- }
- else
- divide(BigInteger.make(x), BigInteger.make(y),
- quotient, remainder, rounding_mode);
- return;
- }
- y = -y;
- }
- else
- yNegative = false;
-
- long q = x / y;
- long r = x % y;
- boolean qNegative = xNegative ^ yNegative;
-
- boolean add_one = false;
- if (r != 0)
- {
- switch (rounding_mode)
- {
- case TRUNCATE:
- break;
- case CEILING:
- case FLOOR:
- if (qNegative == (rounding_mode == FLOOR))
- add_one = true;
- break;
- case ROUND:
- add_one = r > ((y - (q & 1)) >> 1);
- break;
- }
- }
- if (quotient != null)
- {
- if (add_one)
- q++;
- if (qNegative)
- q = -q;
- quotient.set(q);
- }
- if (remainder != null)
- {
- // The remainder is by definition: X-Q*Y
- if (add_one)
- {
- // Subtract the remainder from Y.
- r = y - r;
- // In this case, abs(Q*Y) > abs(X).
- // So sign(remainder) = -sign(X).
- xNegative = ! xNegative;
- }
- else
- {
- // If !add_one, then: abs(Q*Y) <= abs(X).
- // So sign(remainder) = sign(X).
- }
- if (xNegative)
- r = -r;
- remainder.set(r);
- }
- }
-
- /** Divide two integers, yielding quotient and remainder.
- * @param x the numerator in the division
- * @param y the denominator in the division
- * @param quotient is set to the quotient of the result (iff quotient!=null)
- * @param remainder is set to the remainder of the result
- * (iff remainder!=null)
- * @param rounding_mode one of FLOOR, CEILING, TRUNCATE, or ROUND.
- */
- private static void divide(BigInteger x, BigInteger y,
- BigInteger quotient, BigInteger remainder,
- int rounding_mode)
- {
- if ((x.words == null || x.ival <= 2)
- && (y.words == null || y.ival <= 2))
- {
- long x_l = x.longValue();
- long y_l = y.longValue();
- if (x_l != Long.MIN_VALUE && y_l != Long.MIN_VALUE)
- {
- divide(x_l, y_l, quotient, remainder, rounding_mode);
- return;
- }
- }
-
- boolean xNegative = x.isNegative();
- boolean yNegative = y.isNegative();
- boolean qNegative = xNegative ^ yNegative;
-
- int ylen = y.words == null ? 1 : y.ival;
- int[] ywords = new int[ylen];
- y.getAbsolute(ywords);
- while (ylen > 1 && ywords[ylen - 1] == 0) ylen--;
-
- int xlen = x.words == null ? 1 : x.ival;
- int[] xwords = new int[xlen+2];
- x.getAbsolute(xwords);
- while (xlen > 1 && xwords[xlen-1] == 0) xlen--;
-
- int qlen, rlen;
-
- int cmpval = MPN.cmp(xwords, xlen, ywords, ylen);
- if (cmpval < 0) // abs(x) < abs(y)
- { // quotient = 0; remainder = num.
- int[] rwords = xwords; xwords = ywords; ywords = rwords;
- rlen = xlen; qlen = 1; xwords[0] = 0;
- }
- else if (cmpval == 0) // abs(x) == abs(y)
- {
- xwords[0] = 1; qlen = 1; // quotient = 1
- ywords[0] = 0; rlen = 1; // remainder = 0;
- }
- else if (ylen == 1)
- {
- qlen = xlen;
- // Need to leave room for a word of leading zeros if dividing by 1
- // and the dividend has the high bit set. It might be safe to
- // increment qlen in all cases, but it certainly is only necessary
- // in the following case.
- if (ywords[0] == 1 && xwords[xlen-1] < 0)
- qlen++;
- rlen = 1;
- ywords[0] = MPN.divmod_1(xwords, xwords, xlen, ywords[0]);
- }
- else // abs(x) > abs(y)
- {
- // Normalize the denominator, i.e. make its most significant bit set by
- // shifting it normalization_steps bits to the left. Also shift the
- // numerator the same number of steps (to keep the quotient the same!).
-
- int nshift = MPN.count_leading_zeros(ywords[ylen - 1]);
- if (nshift != 0)
- {
- // Shift up the denominator setting the most significant bit of
- // the most significant word.
- MPN.lshift(ywords, 0, ywords, ylen, nshift);
-
- // Shift up the numerator, possibly introducing a new most
- // significant word.
- int x_high = MPN.lshift(xwords, 0, xwords, xlen, nshift);
- xwords[xlen++] = x_high;
- }
-
- if (xlen == ylen)
- xwords[xlen++] = 0;
- MPN.divide(xwords, xlen, ywords, ylen);
- rlen = ylen;
- if (remainder != null || rounding_mode != TRUNCATE)
- {
- if (nshift == 0)
- System.arraycopy(xwords, 0, ywords, 0, rlen);
- else
- MPN.rshift(ywords, xwords, 0, rlen, nshift);
- }
-
- qlen = xlen + 1 - ylen;
- if (quotient != null)
- {
- for (int i = 0; i < qlen; i++)
- xwords[i] = xwords[i+ylen];
- }
- }
-
- // Now the quotient is in xwords, and the remainder is in ywords.
-
- boolean add_one = false;
- if (rlen > 1 || ywords[0] != 0)
- { // Non-zero remainder i.e. in-exact quotient.
- switch (rounding_mode)
- {
- case TRUNCATE:
- break;
- case CEILING:
- case FLOOR:
- if (qNegative == (rounding_mode == FLOOR))
- add_one = true;
- break;
- case ROUND:
- // int cmp = compareTo(remainder<<1, abs(y));
- BigInteger tmp = remainder == null ? new BigInteger() : remainder;
- tmp.set(ywords, rlen);
- tmp = shift(tmp, 1);
- if (yNegative)
- tmp.setNegative();
- int cmp = compareTo(tmp, y);
- // Now cmp == compareTo(sign(y)*(remainder<<1), y)
- if (yNegative)
- cmp = -cmp;
- add_one = (cmp == 1) || (cmp == 0 && (xwords[0]&1) != 0);
- }
- }
- if (quotient != null)
- {
- quotient.set(xwords, qlen);
- if (qNegative)
- {
- if (add_one) // -(quotient + 1) == ~(quotient)
- quotient.setInvert();
- else
- quotient.setNegative();
- }
- else if (add_one)
- quotient.setAdd(1);
- }
- if (remainder != null)
- {
- // The remainder is by definition: X-Q*Y
- remainder.set(ywords, rlen);
- if (add_one)
- {
- // Subtract the remainder from Y:
- // abs(R) = abs(Y) - abs(orig_rem) = -(abs(orig_rem) - abs(Y)).
- BigInteger tmp;
- if (y.words == null)
- {
- tmp = remainder;
- tmp.set(yNegative ? ywords[0] + y.ival : ywords[0] - y.ival);
- }
- else
- tmp = BigInteger.add(remainder, y, yNegative ? 1 : -1);
- // Now tmp <= 0.
- // In this case, abs(Q) = 1 + floor(abs(X)/abs(Y)).
- // Hence, abs(Q*Y) > abs(X).
- // So sign(remainder) = -sign(X).
- if (xNegative)
- remainder.setNegative(tmp);
- else
- remainder.set(tmp);
- }
- else
- {
- // If !add_one, then: abs(Q*Y) <= abs(X).
- // So sign(remainder) = sign(X).
- if (xNegative)
- remainder.setNegative();
- }
- }
- }
-
- public BigInteger divide(BigInteger val)
- {
- if (val.isZero())
- throw new ArithmeticException("divisor is zero");
-
- BigInteger quot = new BigInteger();
- divide(this, val, quot, null, TRUNCATE);
- return quot.canonicalize();
- }
-
- public BigInteger remainder(BigInteger val)
- {
- if (val.isZero())
- throw new ArithmeticException("divisor is zero");
-
- BigInteger rem = new BigInteger();
- divide(this, val, null, rem, TRUNCATE);
- return rem.canonicalize();
- }
-
- public BigInteger[] divideAndRemainder(BigInteger val)
- {
- if (val.isZero())
- throw new ArithmeticException("divisor is zero");
-
- BigInteger[] result = new BigInteger[2];
- result[0] = new BigInteger();
- result[1] = new BigInteger();
- divide(this, val, result[0], result[1], TRUNCATE);
- result[0].canonicalize();
- result[1].canonicalize();
- return result;
- }
-
- public BigInteger mod(BigInteger m)
- {
- if (m.isNegative() || m.isZero())
- throw new ArithmeticException("non-positive modulus");
-
- BigInteger rem = new BigInteger();
- divide(this, m, null, rem, FLOOR);
- return rem.canonicalize();
- }
-
- /** Calculate power for BigInteger exponents.
- * @param y exponent assumed to be non-negative. */
- private BigInteger pow(BigInteger y)
- {
- if (isOne())
- return this;
- if (isMinusOne())
- return y.isOdd () ? this : ONE;
- if (y.words == null && y.ival >= 0)
- return pow(y.ival);
-
- // Assume exponent is non-negative.
- if (isZero())
- return this;
-
- // Implemented by repeated squaring and multiplication.
- BigInteger pow2 = this;
- BigInteger r = null;
- for (;;) // for (i = 0; ; i++)
- {
- // pow2 == x**(2**i)
- // prod = x**(sum(j=0..i-1, (y>>j)&1))
- if (y.isOdd())
- r = r == null ? pow2 : times(r, pow2); // r *= pow2
- y = BigInteger.shift(y, -1);
- if (y.isZero())
- break;
- // pow2 *= pow2;
- pow2 = times(pow2, pow2);
- }
- return r == null ? ONE : r;
- }
-
- /** Calculate the integral power of a BigInteger.
- * @param exponent the exponent (must be non-negative)
- */
- public BigInteger pow(int exponent)
- {
- if (exponent <= 0)
- {
- if (exponent == 0)
- return ONE;
- else
- throw new ArithmeticException("negative exponent");
- }
- if (isZero())
- return this;
- int plen = words == null ? 1 : ival; // Length of pow2.
- int blen = ((bitLength() * exponent) >> 5) + 2 * plen;
- boolean negative = isNegative() && (exponent & 1) != 0;
- int[] pow2 = new int [blen];
- int[] rwords = new int [blen];
- int[] work = new int [blen];
- getAbsolute(pow2); // pow2 = abs(this);
- int rlen = 1;
- rwords[0] = 1; // rwords = 1;
- for (;;) // for (i = 0; ; i++)
- {
- // pow2 == this**(2**i)
- // prod = this**(sum(j=0..i-1, (exponent>>j)&1))
- if ((exponent & 1) != 0)
- { // r *= pow2
- MPN.mul(work, pow2, plen, rwords, rlen);
- int[] temp = work; work = rwords; rwords = temp;
- rlen += plen;
- while (rwords[rlen - 1] == 0) rlen--;
- }
- exponent >>= 1;
- if (exponent == 0)
- break;
- // pow2 *= pow2;
- MPN.mul(work, pow2, plen, pow2, plen);
- int[] temp = work; work = pow2; pow2 = temp; // swap to avoid a copy
- plen *= 2;
- while (pow2[plen - 1] == 0) plen--;
- }
- if (rwords[rlen - 1] < 0)
- rlen++;
- if (negative)
- negate(rwords, rwords, rlen);
- return BigInteger.make(rwords, rlen);
- }
-
- private static final int[] euclidInv(int a, int b, int prevDiv)
- {
- // Storage for return values, plus one slot for a temp int (see below).
- int[] xy;
-
- if (b == 0)
- throw new ArithmeticException("not invertible");
- else if (b == 1)
- {
- // Success: values are indeed invertible!
- // Bottom of the recursion reached; start unwinding.
- xy = new int[3];
- xy[0] = -prevDiv;
- xy[1] = 1;
- return xy;
- }
-
- xy = euclidInv(b, a % b, a / b); // Recursion happens here.
-
- // xy[2] is just temp storage for intermediate results in the following
- // calculation. This saves us a bit of space over having an int
- // allocated at every level of this recursive method.
- xy[2] = xy[0];
- xy[0] = xy[2] * -prevDiv + xy[1];
- xy[1] = xy[2];
- return xy;
- }
-
- private static final BigInteger[]
- euclidInv(BigInteger a, BigInteger b, BigInteger prevDiv)
- {
- // FIXME: This method could be more efficient memory-wise and should be
- // modified as such since it is recursive.
-
- // Storage for return values, plus one slot for a temp int (see below).
- BigInteger[] xy;
-
- if (b.isZero())
- throw new ArithmeticException("not invertible");
- else if (b.isOne())
- {
- // Success: values are indeed invertible!
- // Bottom of the recursion reached; start unwinding.
- xy = new BigInteger[3];
- xy[0] = neg(prevDiv);
- xy[1] = ONE;
- return xy;
- }
-
- // Recursion happens in the following conditional!
-
- // If a just contains an int, then use integer math for the rest.
- if (a.words == null)
- {
- int[] xyInt = euclidInv(b.ival, a.ival % b.ival, a.ival / b.ival);
- xy = new BigInteger[3];
- xy[0] = new BigInteger(xyInt[0]);
- xy[1] = new BigInteger(xyInt[1]);
- }
- else
- {
- BigInteger rem = new BigInteger();
- BigInteger quot = new BigInteger();
- divide(a, b, quot, rem, FLOOR);
- xy = euclidInv(b, rem, quot);
- }
-
- // xy[2] is just temp storage for intermediate results in the following
- // calculation. This saves us a bit of space over having a BigInteger
- // allocated at every level of this recursive method.
- xy[2] = xy[0];
- xy[0] = add(xy[1], times(xy[2], prevDiv), -1);
- xy[1] = xy[2];
- return xy;
- }
-
- public BigInteger modInverse(BigInteger y)
- {
- if (y.isNegative() || y.isZero())
- throw new ArithmeticException("non-positive modulo");
-
- // Degenerate cases.
- if (y.isOne())
- return ZERO;
- else if (isOne())
- return ONE;
-
- // Use Euclid's algorithm as in gcd() but do this recursively
- // rather than in a loop so we can use the intermediate results as we
- // unwind from the recursion.
- // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference.
- BigInteger result = new BigInteger();
- int xval = ival;
- int yval = y.ival;
- boolean swapped = false;
-
- if (y.words == null)
- {
- // The result is guaranteed to be less than the modulus, y (which is
- // an int), so simplify this by working with the int result of this
- // modulo y. Also, if this is negative, make it positive via modulo
- // math. Note that BigInteger.mod() must be used even if this is
- // already an int as the % operator would provide a negative result if
- // this is negative, BigInteger.mod() never returns negative values.
- if (words != null || isNegative())
- xval = mod(y).ival;
-
- // Swap values so x > y.
- if (yval > xval)
- {
- int tmp = xval; xval = yval; yval = tmp;
- swapped = true;
- }
- // Normally, the result is in the 2nd element of the array, but
- // if originally x < y, then x and y were swapped and the result
- // is in the 1st element of the array.
- result.ival =
- euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1];
-
- // Result can't be negative, so make it positive by adding the
- // original modulus, y.ival (not the possibly "swapped" yval).
- if (result.ival < 0)
- result.ival += y.ival;
- }
- else
- {
- BigInteger x = this;
-
- // As above, force this to be a positive value via modulo math.
- if (isNegative())
- x = mod(y);
-
- // Swap values so x > y.
- if (x.compareTo(y) < 0)
- {
- BigInteger tmp = x; x = y; y = tmp;
- swapped = true;
- }
- // As above (for ints), result will be in the 2nd element unless
- // the original x and y were swapped.
- BigInteger rem = new BigInteger();
- BigInteger quot = new BigInteger();
- divide(x, y, quot, rem, FLOOR);
- result = euclidInv(y, rem, quot)[swapped ? 0 : 1];
-
- // Result can't be negative, so make it positive by adding the
- // original modulus, y (which is now x if they were swapped).
- if (result.isNegative())
- result = add(result, swapped ? x : y, 1);
- }
-
- return result;
- }
-
- public BigInteger modPow(BigInteger exponent, BigInteger m)
- {
- if (m.isNegative() || m.isZero())
- throw new ArithmeticException("non-positive modulo");
-
- if (exponent.isNegative())
- return modInverse(m);
- if (exponent.isOne())
- return mod(m);
-
- // To do this naively by first raising this to the power of exponent
- // and then performing modulo m would be extremely expensive, especially
- // for very large numbers. The solution is found in Number Theory
- // where a combination of partial powers and modulos can be done easily.
- //
- // We'll use the algorithm for Additive Chaining which can be found on
- // p. 244 of "Applied Cryptography, Second Edition" by Bruce Schneier.
- BigInteger s, t, u;
- int i;
-
- s = ONE;
- t = this;
- u = exponent;
-
- while (!u.isZero())
- {
- if (u.and(ONE).isOne())
- s = times(s, t).mod(m);
- u = u.shiftRight(1);
- t = times(t, t).mod(m);
- }
-
- return s;
- }
-
- /** Calculate Greatest Common Divisor for non-negative ints. */
- private static final int gcd(int a, int b)
- {
- // Euclid's algorithm, copied from libg++.
- if (b > a)
- {
- int tmp = a; a = b; b = tmp;
- }
- for(;;)
- {
- if (b == 0)
- return a;
- else if (b == 1)
- return b;
- else
- {
- int tmp = b;
- b = a % b;
- a = tmp;
- }
- }
- }
-
- public BigInteger gcd(BigInteger y)
- {
- int xval = ival;
- int yval = y.ival;
- if (words == null)
- {
- if (xval == 0)
- return BigInteger.abs(y);
- if (y.words == null
- && xval != Integer.MIN_VALUE && yval != Integer.MIN_VALUE)
- {
- if (xval < 0)
- xval = -xval;
- if (yval < 0)
- yval = -yval;
- return BigInteger.make(BigInteger.gcd(xval, yval));
- }
- xval = 1;
- }
- if (y.words == null)
- {
- if (yval == 0)
- return BigInteger.abs(this);
- yval = 1;
- }
- int len = (xval > yval ? xval : yval) + 1;
- int[] xwords = new int[len];
- int[] ywords = new int[len];
- getAbsolute(xwords);
- y.getAbsolute(ywords);
- len = MPN.gcd(xwords, ywords, len);
- BigInteger result = new BigInteger(0);
- result.ival = len;
- result.words = xwords;
- return result.canonicalize();
- }
-
- public boolean isProbablePrime(int certainty)
- {
- /** We'll use the Rabin-Miller algorithm for doing a probabilistic
- * primality test. It is fast, easy and has faster decreasing odds of a
- * composite passing than with other tests. This means that this
- * method will actually have a probability much greater than the
- * 1 - .5^certainty specified in the JCL (p. 117), but I don't think
- * anyone will complain about better performance with greater certainty.
- *
- * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied
- * Cryptography, Second Edition" by Bruce Schneier.
- */
-
- // First rule out small prime factors and assure the number is odd.
- for (int i = 0; i < primes.length; i++)
- {
- if (words == null && ival == primes[i])
- return true;
- if (remainder(make(primes[i])).isZero())
- return false;
- }
-
- // Now perform the Rabin-Miller test.
- // NB: I know that this can be simplified programatically, but
- // I have tried to keep it as close as possible to the algorithm
- // as written in the Schneier book for reference purposes.
-
- // Set b to the number of times 2 evenly divides (this - 1).
- // I.e. 2^b is the largest power of 2 that divides (this - 1).
- BigInteger pMinus1 = add(this, -1);
- int b = pMinus1.getLowestSetBit();
-
- // Set m such that this = 1 + 2^b * m.
- BigInteger m = pMinus1.divide(make(2L << b - 1));
-
- Random rand = new Random();
- while (certainty-- > 0)
- {
- // Pick a random number greater than 1 and less than this.
- // The algorithm says to pick a small number to make the calculations
- // go faster, but it doesn't say how small; we'll use 2 to 1024.
- int a = rand.nextInt();
- a = (a < 0 ? -a : a) % 1023 + 2;
-
- BigInteger z = make(a).modPow(m, this);
- if (z.isOne() || z.equals(pMinus1))
- continue; // Passes the test; may be prime.
-
- int i;
- for (i = 0; i < b; )
- {
- if (z.isOne())
- return false;
- i++;
- if (z.equals(pMinus1))
- break; // Passes the test; may be prime.
-
- z = z.modPow(make(2), this);
- }
-
- if (i == b && !z.equals(pMinus1))
- return false;
- }
- return true;
- }
-
- private void setInvert()
- {
- if (words == null)
- ival = ~ival;
- else
- {
- for (int i = ival; --i >= 0; )
- words[i] = ~words[i];
- }
- }
-
- private void setShiftLeft(BigInteger x, int count)
- {
- int[] xwords;
- int xlen;
- if (x.words == null)
- {
- if (count < 32)
- {
- set((long) x.ival << count);
- return;
- }
- xwords = new int[1];
- xwords[0] = x.ival;
- xlen = 1;
- }
- else
- {
- xwords = x.words;
- xlen = x.ival;
- }
- int word_count = count >> 5;
- count &= 31;
- int new_len = xlen + word_count;
- if (count == 0)
- {
- realloc(new_len);
- for (int i = xlen; --i >= 0; )
- words[i+word_count] = xwords[i];
- }
- else
- {
- new_len++;
- realloc(new_len);
- int shift_out = MPN.lshift(words, word_count, xwords, xlen, count);
- count = 32 - count;
- words[new_len-1] = (shift_out << count) >> count; // sign-extend.
- }
- ival = new_len;
- for (int i = word_count; --i >= 0; )
- words[i] = 0;
- }
-
- private void setShiftRight(BigInteger x, int count)
- {
- if (x.words == null)
- set(count < 32 ? x.ival >> count : x.ival < 0 ? -1 : 0);
- else if (count == 0)
- set(x);
- else
- {
- boolean neg = x.isNegative();
- int word_count = count >> 5;
- count &= 31;
- int d_len = x.ival - word_count;
- if (d_len <= 0)
- set(neg ? -1 : 0);
- else
- {
- if (words == null || words.length < d_len)
- realloc(d_len);
- if (count == 0)
- System.arraycopy(x.words, word_count, words, 0, d_len);
- else
- MPN.rshift(words, x.words, word_count, d_len, count);
- ival = d_len;
- if (neg)
- words[ival-1] |= -1 << (32 - count);
- }
- }
- }
-
- private void setShift(BigInteger x, int count)
- {
- if (count > 0)
- setShiftLeft(x, count);
- else
- setShiftRight(x, -count);
- }
-
- private static BigInteger shift(BigInteger x, int count)
- {
- if (x.words == null)
- {
- if (count <= 0)
- return make(count > -32 ? x.ival >> (-count) : x.ival < 0 ? -1 : 0);
- if (count < 32)
- return make((long) x.ival << count);
- }
- if (count == 0)
- return x;
- BigInteger result = new BigInteger(0);
- result.setShift(x, count);
- return result.canonicalize();
- }
-
- public BigInteger shiftLeft(int n)
- {
- return shift(this, n);
- }
-
- public BigInteger shiftRight(int n)
- {
- return shift(this, -n);
- }
-
- private void format(int radix, StringBuffer buffer)
- {
- if (words == null)
- buffer.append(Integer.toString(ival, radix));
- else if (ival <= 2)
- buffer.append(Long.toString(longValue(), radix));
- else
- {
- boolean neg = isNegative();
- int[] work;
- if (neg || radix != 16)
- {
- work = new int[ival];
- getAbsolute(work);
- }
- else
- work = words;
- int len = ival;
-
- int buf_size = len * (MPN.chars_per_word(radix) + 1);
- if (radix == 16)
- {
- if (neg)
- buffer.append('-');
- int buf_start = buffer.length();
- for (int i = len; --i >= 0; )
- {
- int word = work[i];
- for (int j = 8; --j >= 0; )
- {
- int hex_digit = (word >> (4 * j)) & 0xF;
- // Suppress leading zeros:
- if (hex_digit > 0 || buffer.length() > buf_start)
- buffer.append(Character.forDigit(hex_digit, 16));
- }
- }
- }
- else
- {
- int i = buffer.length();
- for (;;)
- {
- int digit = MPN.divmod_1(work, work, len, radix);
- buffer.append(Character.forDigit(digit, radix));
- while (len > 0 && work[len-1] == 0) len--;
- if (len == 0)
- break;
- }
- if (neg)
- buffer.append('-');
- /* Reverse buffer. */
- int j = buffer.length() - 1;
- while (i < j)
- {
- char tmp = buffer.charAt(i);
- buffer.setCharAt(i, buffer.charAt(j));
- buffer.setCharAt(j, tmp);
- i++; j--;
- }
- }
- }
- }
-
- public String toString()
- {
- return toString(10);
- }
-
- public String toString(int radix)
- {
- if (words == null)
- return Integer.toString(ival, radix);
- else if (ival <= 2)
- return Long.toString(longValue(), radix);
- int buf_size = ival * (MPN.chars_per_word(radix) + 1);
- StringBuffer buffer = new StringBuffer(buf_size);
- format(radix, buffer);
- return buffer.toString();
- }
-
- public int intValue()
- {
- if (words == null)
- return ival;
- return words[0];
- }
-
- public long longValue()
- {
- if (words == null)
- return ival;
- if (ival == 1)
- return words[0];
- return ((long)words[1] << 32) + ((long)words[0] & 0xffffffffL);
- }
-
- public int hashCode()
- {
- // FIXME: May not match hashcode of JDK.
- return words == null ? ival : (words[0] + words[ival - 1]);
- }
-
- /* Assumes x and y are both canonicalized. */
- private static boolean equals(BigInteger x, BigInteger y)
- {
- if (x.words == null && y.words == null)
- return x.ival == y.ival;
- if (x.words == null || y.words == null || x.ival != y.ival)
- return false;
- for (int i = x.ival; --i >= 0; )
- {
- if (x.words[i] != y.words[i])
- return false;
- }
- return true;
- }
-
- /* Assumes this and obj are both canonicalized. */
- public boolean equals(Object obj)
- {
- if (obj == null || ! (obj instanceof BigInteger))
- return false;
- return BigInteger.equals(this, (BigInteger) obj);
- }
-
- private static BigInteger valueOf(String s, int radix)
- throws NumberFormatException
- {
- int len = s.length();
- // Testing (len < MPN.chars_per_word(radix)) would be more accurate,
- // but slightly more expensive, for little practical gain.
- if (len <= 15 && radix <= 16)
- return BigInteger.make(Long.parseLong(s, radix));
-
- int byte_len = 0;
- byte[] bytes = new byte[len];
- boolean negative = false;
- for (int i = 0; i < len; i++)
- {
- char ch = s.charAt(i);
- if (ch == '-')
- negative = true;
- else if (ch == '_' || (byte_len == 0 && (ch == ' ' || ch == '\t')))
- continue;
- else
- {
- int digit = Character.digit(ch, radix);
- if (digit < 0)
- break;
- bytes[byte_len++] = (byte) digit;
- }
- }
- return valueOf(bytes, byte_len, negative, radix);
- }
-
- private static BigInteger valueOf(byte[] digits, int byte_len,
- boolean negative, int radix)
- {
- int chars_per_word = MPN.chars_per_word(radix);
- int[] words = new int[byte_len / chars_per_word + 1];
- int size = MPN.set_str(words, digits, byte_len, radix);
- if (size == 0)
- return ZERO;
- if (words[size-1] < 0)
- words[size++] = 0;
- if (negative)
- negate(words, words, size);
- return make(words, size);
- }
-
- public double doubleValue()
- {
- if (words == null)
- return (double) ival;
- if (ival <= 2)
- return (double) longValue();
- if (isNegative())
- return BigInteger.neg(this).roundToDouble(0, true, false);
- else
- return roundToDouble(0, false, false);
- }
-
- public float floatValue()
- {
- return (float) doubleValue();
- }
-
- /** Return true if any of the lowest n bits are one.
- * (false if n is negative). */
- private boolean checkBits(int n)
- {
- if (n <= 0)
- return false;
- if (words == null)
- return n > 31 || ((ival & ((1 << n) - 1)) != 0);
- int i;
- for (i = 0; i < (n >> 5) ; i++)
- if (words[i] != 0)
- return true;
- return (n & 31) != 0 && (words[i] & ((1 << (n & 31)) - 1)) != 0;
- }
-
- /** Convert a semi-processed BigInteger to double.
- * Number must be non-negative. Multiplies by a power of two, applies sign,
- * and converts to double, with the usual java rounding.
- * @param exp power of two, positive or negative, by which to multiply
- * @param neg true if negative
- * @param remainder true if the BigInteger is the result of a truncating
- * division that had non-zero remainder. To ensure proper rounding in
- * this case, the BigInteger must have at least 54 bits. */
- private double roundToDouble(int exp, boolean neg, boolean remainder)
- {
- // Compute length.
- int il = bitLength();
-
- // Exponent when normalized to have decimal point directly after
- // leading one. This is stored excess 1023 in the exponent bit field.
- exp += il - 1;
-
- // Gross underflow. If exp == -1075, we let the rounding
- // computation determine whether it is minval or 0 (which are just
- // 0x0000 0000 0000 0001 and 0x0000 0000 0000 0000 as bit
- // patterns).
- if (exp < -1075)
- return neg ? -0.0 : 0.0;
-
- // gross overflow
- if (exp > 1023)
- return neg ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
-
- // number of bits in mantissa, including the leading one.
- // 53 unless it's denormalized
- int ml = (exp >= -1022 ? 53 : 53 + exp + 1022);
-
- // Get top ml + 1 bits. The extra one is for rounding.
- long m;
- int excess_bits = il - (ml + 1);
- if (excess_bits > 0)
- m = ((words == null) ? ival >> excess_bits
- : MPN.rshift_long(words, ival, excess_bits));
- else
- m = longValue() << (- excess_bits);
-
- // Special rounding for maxval. If the number exceeds maxval by
- // any amount, even if it's less than half a step, it overflows.
- if (exp == 1023 && ((m >> 1) == (1L << 53) - 1))
- {
- if (remainder || checkBits(il - ml))
- return neg ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
- else
- return neg ? - Double.MAX_VALUE : Double.MAX_VALUE;
- }
-
- // Normal round-to-even rule: round up if the bit dropped is a one, and
- // the bit above it or any of the bits below it is a one.
- if ((m & 1) == 1
- && ((m & 2) == 2 || remainder || checkBits(excess_bits)))
- {
- m += 2;
- // Check if we overflowed the mantissa
- if ((m & (1L << 54)) != 0)
- {
- exp++;
- // renormalize
- m >>= 1;
- }
- // Check if a denormalized mantissa was just rounded up to a
- // normalized one.
- else if (ml == 52 && (m & (1L << 53)) != 0)
- exp++;
- }
-
- // Discard the rounding bit
- m >>= 1;
-
- long bits_sign = neg ? (1L << 63) : 0;
- exp += 1023;
- long bits_exp = (exp <= 0) ? 0 : ((long)exp) << 52;
- long bits_mant = m & ~(1L << 52);
- return Double.longBitsToDouble(bits_sign | bits_exp | bits_mant);
- }
-
- /** Copy the abolute value of this into an array of words.
- * Assumes words.length >= (this.words == null ? 1 : this.ival).
- * Result is zero-extended, but need not be a valid 2's complement number.
- */
-
- private void getAbsolute(int[] words)
- {
- int len;
- if (this.words == null)
- {
- len = 1;
- words[0] = this.ival;
- }
- else
- {
- len = this.ival;
- for (int i = len; --i >= 0; )
- words[i] = this.words[i];
- }
- if (words[len - 1] < 0)
- negate(words, words, len);
- for (int i = words.length; --i > len; )
- words[i] = 0;
- }
-
- /** Set dest[0:len-1] to the negation of src[0:len-1].
- * Return true if overflow (i.e. if src is -2**(32*len-1)).
- * Ok for src==dest. */
- private static boolean negate(int[] dest, int[] src, int len)
- {
- long carry = 1;
- boolean negative = src[len-1] < 0;
- for (int i = 0; i < len; i++)
- {
- carry += ((long) (~src[i]) & 0xffffffffL);
- dest[i] = (int) carry;
- carry >>= 32;
- }
- return (negative && dest[len-1] < 0);
- }
-
- /** Destructively set this to the negative of x.
- * It is OK if x==this.*/
- private void setNegative(BigInteger x)
- {
- int len = x.ival;
- if (x.words == null)
- {
- if (len == Integer.MIN_VALUE)
- set(- (long) len);
- else
- set(-len);
- return;
- }
- realloc(len + 1);
- if (BigInteger.negate(words, x.words, len))
- words[len++] = 0;
- ival = len;
- }
-
- /** Destructively negate this. */
- private final void setNegative()
- {
- setNegative(this);
- }
-
- private static BigInteger abs(BigInteger x)
- {
- return x.isNegative() ? neg(x) : x;
- }
-
- public BigInteger abs()
- {
- return abs(this);
- }
-
- private static BigInteger neg(BigInteger x)
- {
- if (x.words == null && x.ival != Integer.MIN_VALUE)
- return make(- x.ival);
- BigInteger result = new BigInteger(0);
- result.setNegative(x);
- return result.canonicalize();
- }
-
- public BigInteger negate()
- {
- return BigInteger.neg(this);
- }
-
- /** Calculates ceiling(log2(this < 0 ? -this : this+1))
- * See Common Lisp: the Language, 2nd ed, p. 361.
- */
- public int bitLength()
- {
- if (words == null)
- return MPN.intLength(ival);
- else
- return MPN.intLength(words, ival);
- }
-
- public byte[] toByteArray()
- {
- // Determine number of bytes needed. The method bitlength returns
- // the size without the sign bit, so add one bit for that and then
- // add 7 more to emulate the ceil function using integer math.
- byte[] bytes = new byte[(bitLength() + 1 + 7) / 8];
- int nbytes = bytes.length;
-
- int wptr = 0;
- int word;
-
- // Deal with words array until one word or less is left to process.
- // If BigInteger is an int, then it is in ival and nbytes will be <= 4.
- while (nbytes > 4)
- {
- word = words[wptr++];
- for (int i = 4; i > 0; --i, word >>= 8)
- bytes[--nbytes] = (byte) word;
- }
-
- // Deal with the last few bytes. If BigInteger is an int, use ival.
- word = (words == null) ? ival : words[wptr];
- for ( ; nbytes > 0; word >>= 8)
- bytes[--nbytes] = (byte) word;
-
- return bytes;
- }
-
- /** Return the boolean opcode (for bitOp) for swapped operands.
- * I.e. bitOp(swappedOp(op), x, y) == bitOp(op, y, x).
- */
- private static int swappedOp(int op)
- {
- return
- "\000\001\004\005\002\003\006\007\010\011\014\015\012\013\016\017"
- .charAt(op);
- }
-
- /** Do one the the 16 possible bit-wise operations of two BigIntegers. */
- private static BigInteger bitOp(int op, BigInteger x, BigInteger y)
- {
- switch (op)
- {
- case 0: return ZERO;
- case 1: return x.and(y);
- case 3: return x;
- case 5: return y;
- case 15: return make(-1);
- }
- BigInteger result = new BigInteger();
- setBitOp(result, op, x, y);
- return result.canonicalize();
- }
-
- /** Do one the the 16 possible bit-wise operations of two BigIntegers. */
- private static void setBitOp(BigInteger result, int op,
- BigInteger x, BigInteger y)
- {
- if (y.words == null) ;
- else if (x.words == null || x.ival < y.ival)
- {
- BigInteger temp = x; x = y; y = temp;
- op = swappedOp(op);
- }
- int xi;
- int yi;
- int xlen, ylen;
- if (y.words == null)
- {
- yi = y.ival;
- ylen = 1;
- }
- else
- {
- yi = y.words[0];
- ylen = y.ival;
- }
- if (x.words == null)
- {
- xi = x.ival;
- xlen = 1;
- }
- else
- {
- xi = x.words[0];
- xlen = x.ival;
- }
- if (xlen > 1)
- result.realloc(xlen);
- int[] w = result.words;
- int i = 0;
- // Code for how to handle the remainder of x.
- // 0: Truncate to length of y.
- // 1: Copy rest of x.
- // 2: Invert rest of x.
- int finish = 0;
- int ni;
- switch (op)
- {
- case 0: // clr
- ni = 0;
- break;
- case 1: // and
- for (;;)
- {
- ni = xi & yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- if (yi < 0) finish = 1;
- break;
- case 2: // andc2
- for (;;)
- {
- ni = xi & ~yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- if (yi >= 0) finish = 1;
- break;
- case 3: // copy x
- ni = xi;
- finish = 1; // Copy rest
- break;
- case 4: // andc1
- for (;;)
- {
- ni = ~xi & yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- if (yi < 0) finish = 2;
- break;
- case 5: // copy y
- for (;;)
- {
- ni = yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- break;
- case 6: // xor
- for (;;)
- {
- ni = xi ^ yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- finish = yi < 0 ? 2 : 1;
- break;
- case 7: // ior
- for (;;)
- {
- ni = xi | yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- if (yi >= 0) finish = 1;
- break;
- case 8: // nor
- for (;;)
- {
- ni = ~(xi | yi);
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- if (yi >= 0) finish = 2;
- break;
- case 9: // eqv [exclusive nor]
- for (;;)
- {
- ni = ~(xi ^ yi);
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- finish = yi >= 0 ? 2 : 1;
- break;
- case 10: // c2
- for (;;)
- {
- ni = ~yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- break;
- case 11: // orc2
- for (;;)
- {
- ni = xi | ~yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- if (yi < 0) finish = 1;
- break;
- case 12: // c1
- ni = ~xi;
- finish = 2;
- break;
- case 13: // orc1
- for (;;)
- {
- ni = ~xi | yi;
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- if (yi >= 0) finish = 2;
- break;
- case 14: // nand
- for (;;)
- {
- ni = ~(xi & yi);
- if (i+1 >= ylen) break;
- w[i++] = ni; xi = x.words[i]; yi = y.words[i];
- }
- if (yi < 0) finish = 2;
- break;
- default:
- case 15: // set
- ni = -1;
- break;
- }
- // Here i==ylen-1; w[0]..w[i-1] have the correct result;
- // and ni contains the correct result for w[i+1].
- if (i+1 == xlen)
- finish = 0;
- switch (finish)
- {
- case 0:
- if (i == 0 && w == null)
- {
- result.ival = ni;
- return;
- }
- w[i++] = ni;
- break;
- case 1: w[i] = ni; while (++i < xlen) w[i] = x.words[i]; break;
- case 2: w[i] = ni; while (++i < xlen) w[i] = ~x.words[i]; break;
- }
- result.ival = i;
- }
-
- /** Return the logical (bit-wise) "and" of a BigInteger and an int. */
- private static BigInteger and(BigInteger x, int y)
- {
- if (x.words == null)
- return BigInteger.make(x.ival & y);
- if (y >= 0)
- return BigInteger.make(x.words[0] & y);
- int len = x.ival;
- int[] words = new int[len];
- words[0] = x.words[0] & y;
- while (--len > 0)
- words[len] = x.words[len];
- return BigInteger.make(words, x.ival);
- }
-
- /** Return the logical (bit-wise) "and" of two BigIntegers. */
- public BigInteger and(BigInteger y)
- {
- if (y.words == null)
- return and(this, y.ival);
- else if (words == null)
- return and(y, ival);
-
- BigInteger x = this;
- if (ival < y.ival)
- {
- BigInteger temp = this; x = y; y = temp;
- }
- int i;
- int len = y.isNegative() ? x.ival : y.ival;
- int[] words = new int[len];
- for (i = 0; i < y.ival; i++)
- words[i] = x.words[i] & y.words[i];
- for ( ; i < len; i++)
- words[i] = x.words[i];
- return BigInteger.make(words, len);
- }
-
- /** Return the logical (bit-wise) "(inclusive) or" of two BigIntegers. */
- public BigInteger or(BigInteger y)
- {
- return bitOp(7, this, y);
- }
-
- /** Return the logical (bit-wise) "exclusive or" of two BigIntegers. */
- public BigInteger xor(BigInteger y)
- {
- return bitOp(6, this, y);
- }
-
- /** Return the logical (bit-wise) negation of a BigInteger. */
- public BigInteger not()
- {
- return bitOp(12, this, ZERO);
- }
-
- public BigInteger andNot(BigInteger val)
- {
- return and(val.not());
- }
-
- public BigInteger clearBit(int n)
- {
- if (n < 0)
- throw new ArithmeticException();
-
- return and(ONE.shiftLeft(n).not());
- }
-
- public BigInteger setBit(int n)
- {
- if (n < 0)
- throw new ArithmeticException();
-
- return or(ONE.shiftLeft(n));
- }
-
- public boolean testBit(int n)
- {
- if (n < 0)
- throw new ArithmeticException();
-
- return !and(ONE.shiftLeft(n)).isZero();
- }
-
- public BigInteger flipBit(int n)
- {
- if (n < 0)
- throw new ArithmeticException();
-
- return xor(ONE.shiftLeft(n));
- }
-
- public int getLowestSetBit()
- {
- if (isZero())
- return -1;
-
- if (words == null)
- return MPN.findLowestBit(ival);
- else
- return MPN.findLowestBit(words);
- }
-
- // bit4count[I] is number of '1' bits in I.
- private static final byte[] bit4_count = { 0, 1, 1, 2, 1, 2, 2, 3,
- 1, 2, 2, 3, 2, 3, 3, 4};
-
- private static int bitCount(int i)
- {
- int count = 0;
- while (i != 0)
- {
- count += bit4_count[i & 15];
- i >>>= 4;
- }
- return count;
- }
-
- private static int bitCount(int[] x, int len)
- {
- int count = 0;
- while (--len >= 0)
- count += bitCount(x[len]);
- return count;
- }
-
- /** Count one bits in a BigInteger.
- * If argument is negative, count zero bits instead. */
- public int bitCount()
- {
- int i, x_len;
- int[] x_words = words;
- if (x_words == null)
- {
- x_len = 1;
- i = bitCount(ival);
- }
- else
- {
- x_len = ival;
- i = bitCount(x_words, x_len);
- }
- return isNegative() ? x_len * 32 - i : i;
- }
-}
diff --git a/libjava/java/net/BindException.java b/libjava/java/net/BindException.java
deleted file mode 100644
index 3e3255c7e1f..00000000000
--- a/libjava/java/net/BindException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// BindException.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class BindException extends SocketException
-{
- public BindException()
- {
- super();
- }
-
- public BindException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/net/ConnectException.java b/libjava/java/net/ConnectException.java
deleted file mode 100644
index 449056fc791..00000000000
--- a/libjava/java/net/ConnectException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// ConnectException.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class ConnectException extends SocketException
-{
- public ConnectException()
- {
- super();
- }
-
- public ConnectException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/net/ContentHandler.java b/libjava/java/net/ContentHandler.java
deleted file mode 100644
index 59bdb1e6370..00000000000
--- a/libjava/java/net/ContentHandler.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// ContentHandler.java - Superclass of classes that read from a URLConnection.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-import java.io.IOException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public abstract class ContentHandler
-{
- public abstract Object getContent(URLConnection urlc) throws IOException;
-}
diff --git a/libjava/java/net/ContentHandlerFactory.java b/libjava/java/net/ContentHandlerFactory.java
deleted file mode 100644
index d2727611d9c..00000000000
--- a/libjava/java/net/ContentHandlerFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// ContentHandlerFactory.java - Abstract Content Handler factory.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public abstract interface ContentHandlerFactory
-{
- public ContentHandler createContentHandler(String mimetype);
-}
diff --git a/libjava/java/net/DatagramPacket.java b/libjava/java/net/DatagramPacket.java
deleted file mode 100644
index d2abb7fa9a2..00000000000
--- a/libjava/java/net/DatagramPacket.java
+++ /dev/null
@@ -1,175 +0,0 @@
-// DatagramPacket.java - Represents packets in a connectionless protocol.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date April 28, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public final class DatagramPacket
-{
- private byte[] buffer;
- private int offset;
- private int length;
- private InetAddress address;
- private int port;
-
- // JDK1.2
- public DatagramPacket(byte[] buf, int offset, int length)
- {
- // FIXME: We can't currently rely on NullPointerException being
- // thrown when we invoke a method on a null object.
- if (buf == null)
- throw new NullPointerException("Null buffer");
- if (offset < 0)
- throw new IllegalArgumentException("Invalid offset: " + offset);
- if (length < 0)
- throw new IllegalArgumentException("Invalid length: " + length);
- if (offset + length > buf.length)
- throw new IllegalArgumentException("Potential buffer overflow - offset: "
- + offset + " length: " + length);
-
- buffer = buf;
- this.offset = offset;
- this.length = length;
- this.address = null;
- this.port = -1;
- }
-
- public DatagramPacket(byte[] buf, int length)
- {
- this(buf, 0, length);
- }
-
- // JDK1.2
- public DatagramPacket(byte[] buf, int offset, int length,
- InetAddress address, int port)
- {
- // FIXME: We can't currently rely on NullPointerException being
- // thrown when we invoke a method on a null object.
- if (buf == null)
- throw new NullPointerException("Null buffer");
- if (offset < 0)
- throw new IllegalArgumentException("Invalid offset: " + offset);
- if (length < 0)
- throw new IllegalArgumentException("Invalid length: " + length);
- if (offset + length > buf.length)
- throw new IllegalArgumentException("Potential buffer overflow - offset: "
- + offset + " length: " + length);
- if (port < 0 || port > 65535)
- throw new IllegalArgumentException("Invalid port: " + port);
- if (address == null)
- throw new NullPointerException("Null address");
-
- buffer = buf;
- this.offset = offset;
- this.length = length;
- this.address = address;
- this.port = port;
- }
-
- public DatagramPacket(byte[] buf, int length, InetAddress address, int port)
- {
- this(buf, 0, length, address, port);
- }
-
- public synchronized InetAddress getAddress()
- {
- return address;
- }
-
- public synchronized int getPort()
- {
- return port;
- }
-
- public synchronized byte[] getData()
- {
- return buffer;
- }
-
- // JDK1.2
- public synchronized int getOffset()
- {
- return offset;
- }
-
- public synchronized int getLength()
- {
- return length;
- }
-
- public synchronized void setAddress(InetAddress iaddr)
- {
- if (iaddr == null)
- throw new NullPointerException("Null address");
-
- address = iaddr;
- }
-
- public synchronized void setPort(int iport)
- {
- if (iport < 0 || iport > 65535)
- throw new IllegalArgumentException("Invalid port: " + iport);
-
- port = iport;
- }
-
- public synchronized void setData(byte[] buf)
- {
- // This form of setData requires setLength to be called separately
- // and subsequently.
- if (buf == null)
- throw new NullPointerException("Null buffer");
-
- buffer = buf;
- }
-
- // JDK1.2
- public synchronized void setData(byte[] buf, int offset, int length)
- {
- // This form of setData must be used if offset is to be changed.
-
- // FIXME: We can't currently rely on NullPointerException being
- // thrown when we invoke a method on a null object.
- if (buf == null)
- throw new NullPointerException("Null buffer");
- if (offset < 0)
- throw new IllegalArgumentException("Invalid offset: " + offset);
- if (length < 0)
- throw new IllegalArgumentException("Invalid length: " + length);
- if (offset + length > buf.length)
- throw new IllegalArgumentException("Potential buffer overflow - offset: "
- + offset + " length: " + length);
-
- buffer = buf;
- this.offset = offset;
- this.length = length;
- }
-
- public synchronized void setLength(int length)
- {
- if (length < 0)
- throw new IllegalArgumentException("Invalid length: " + length);
- if (offset + length > buffer.length)
- throw new IllegalArgumentException("Potential buffer overflow - offset: "
- + offset + " length: " + length);
-
- this.length = length;
- }
-}
diff --git a/libjava/java/net/DatagramSocket.java b/libjava/java/net/DatagramSocket.java
deleted file mode 100644
index 334e003f71f..00000000000
--- a/libjava/java/net/DatagramSocket.java
+++ /dev/null
@@ -1,202 +0,0 @@
-// DatagramSocket.java
-
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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 java.net;
-import java.io.IOException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date May 3, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class DatagramSocket
-{
- DatagramSocketImpl impl;
-
- public DatagramSocket() throws SocketException
- {
- this(0, ServerSocket.ANY_IF);
- }
-
- public DatagramSocket(int port) throws SocketException
- {
- this(port, ServerSocket.ANY_IF);
- }
-
- public DatagramSocket(int port, InetAddress laddr) throws SocketException
- {
- if (port < 0 || port > 65535)
- throw new IllegalArgumentException("Invalid port: " + port);
-
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkListen(port);
-
- String propVal = System.getProperty("impl.prefix");
- if (propVal == null || propVal.equals(""))
- impl = new PlainDatagramSocketImpl();
- else
- try
- {
- impl = (DatagramSocketImpl) Class.forName("java.net." + propVal +
- "DatagramSocketImpl").newInstance();
- }
- catch (Exception e)
- {
- System.err.println("Could not instantiate class: java.net." +
- propVal + "DatagramSocketImpl");
- impl = new PlainDatagramSocketImpl();
- }
- impl.create();
-
- // For multicasting, set the socket to be reused (Stevens pp. 195-6).
- if (this instanceof MulticastSocket)
- impl.setOption(SocketOptions.SO_REUSEADDR, new Boolean(true));
-
- impl.bind(port, laddr == null ? ServerSocket.ANY_IF : laddr);
- }
-
- public void close()
- {
- impl.close();
- }
-
- public InetAddress getLocalAddress()
- {
- SecurityManager s = System.getSecurityManager();
- // FIXME: JCL p. 510 says this should call checkConnect. But what
- // string should be used as the hostname? Maybe this is just a side
- // effect of calling InetAddress.getLocalHost.
- //
- // And is getOption with SO_BINDADDR the right way to get the address?
- // Doesn't seem to be since this method doesn't throw a SocketException
- // and SO_BINADDR can throw one.
- //
- // Also see RETURNS section in JCL p. 510 about returning any local
- // addr "if the current execution context is not allowed to connect to
- // the network interface that is actually bound to this datagram socket."
- // How is that done? via InetAddress.getLocalHost? But that throws
- // an UnknownHostException and this method doesn't.
- //
- // if (s != null)
- // s.checkConnect("localhost", -1);
- try
- {
- return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR);
- }
- catch (SocketException ex)
- {
- }
-
- try
- {
- return InetAddress.getLocalHost();
- }
- catch (UnknownHostException ex)
- {
- // FIXME: This should never happen, so how can we avoid this construct?
- return null;
- }
- }
-
- public int getLocalPort()
- {
- return impl.getLocalPort();
- }
-
- public synchronized int getSoTimeout() throws SocketException
- {
- Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT);
- if (timeout instanceof Integer)
- return ((Integer)timeout).intValue();
- else
- return 0;
- }
-
- public synchronized void receive(DatagramPacket p) throws IOException
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkAccept(p.getAddress().getHostAddress(), p.getPort());
-
- impl.receive(p);
- }
-
- public void send(DatagramPacket p) throws IOException
- {
- // JDK1.2: Don't do security checks if socket is connected; see jdk1.2 api.
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- {
- InetAddress addr = p.getAddress();
- if (addr.isMulticastAddress())
- s.checkMulticast(addr);
- else
- s.checkConnect(addr.getHostAddress(), p.getPort());
- }
-
- // FIXME: if this is a subclass of MulticastSocket, use getTTL for TTL val.
- impl.send(p);
- }
-
- public synchronized void setSoTimeout(int timeout) throws SocketException
- {
- if (timeout < 0)
- throw new IllegalArgumentException("Invalid timeout: " + timeout);
-
- impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
- }
-
- // JDK1.2
- // public void connect(InetAddress address, int port)
- // {
- // }
-
- // JDK1.2
- // public void disconnect()
- // {
- // }
-
- // JDK1.2
- // public InetAddress getInetAddress()
- // {
- // }
-
- // JDK1.2
- // public int getPort()
- // {
- // }
-
- // JDK1.2
- // public int getReceiveBufferSize() throws SocketException
- // {
- // }
-
- // JDK1.2
- // public int getSendBufferSize() throws SocketException
- // {
- // }
-
- // JDK1.2
- // public void setReceiveBufferSize(int size) throws SocketException
- // {
- // }
-
- // JDK1.2
- // public void setSendBufferSize(int size) throws SocketException
- // {
- // }
-}
diff --git a/libjava/java/net/DatagramSocketImpl.java b/libjava/java/net/DatagramSocketImpl.java
deleted file mode 100644
index 0d1cab7904e..00000000000
--- a/libjava/java/net/DatagramSocketImpl.java
+++ /dev/null
@@ -1,62 +0,0 @@
-// DatagramSocketImpl.java - Abstract datagram socket implementation.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-import java.io.IOException;
-import java.io.FileDescriptor;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date May 3, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public abstract class DatagramSocketImpl implements SocketOptions
-{
- protected int localPort;
- protected FileDescriptor fd;
-
- public DatagramSocketImpl()
- {
- }
-
- protected abstract void bind(int lport, InetAddress laddr)
- throws SocketException;
- protected abstract void close();
- protected abstract void create() throws SocketException;
- protected abstract int peek(InetAddress i) throws IOException;
- protected abstract void send(DatagramPacket p) throws IOException;
- protected abstract void receive(DatagramPacket p) throws IOException;
- protected abstract void setTTL(byte ttl) throws IOException;
- protected abstract byte getTTL() throws IOException;
- protected abstract void setTimeToLive(int ttl) throws IOException;
- protected abstract int getTimeToLive() throws IOException;
- protected abstract void join(InetAddress inetaddr) throws IOException;
- protected abstract void leave(InetAddress inetaddr) throws IOException;
-
- public abstract Object getOption(int optID) throws SocketException;
- public abstract void setOption(int optID, Object value)
- throws SocketException;
-
- protected FileDescriptor getFileDescriptor()
- {
- return fd;
- }
-
- protected int getLocalPort()
- {
- return localPort;
- }
-}
diff --git a/libjava/java/net/FileNameMap.java b/libjava/java/net/FileNameMap.java
deleted file mode 100644
index cc70aa221da..00000000000
--- a/libjava/java/net/FileNameMap.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// FileNameMap.java - Abstract interface to map from a File Name to MIME type.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public abstract interface FileNameMap
-{
- public String getContentTypeFor(String fileName);
-}
diff --git a/libjava/java/net/HttpURLConnection.java b/libjava/java/net/HttpURLConnection.java
deleted file mode 100644
index 673cc8aa2b0..00000000000
--- a/libjava/java/net/HttpURLConnection.java
+++ /dev/null
@@ -1,174 +0,0 @@
-// HttpURLConnection.java - Subclass of communications links using
-// Hypertext Transfer Protocol.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-import java.io.*;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 29, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public abstract class HttpURLConnection extends URLConnection
-{
- /* HTTP Success Response Codes */
- public static final int HTTP_OK = 200;
- public static final int HTTP_CREATED = 201;
- public static final int HTTP_ACCEPTED = 202;
- public static final int HTTP_NOT_AUTHORITATIVE = 203;
- public static final int HTTP_NO_CONTENT = 204;
- public static final int HTTP_RESET = 205;
- public static final int HTTP_PARTIAL = 206;
-
- /* HTTP Redirection Response Codes */
- public static final int HTTP_MULT_CHOICE = 300;
- public static final int HTTP_MOVED_PERM = 301;
- public static final int HTTP_MOVED_TEMP = 302;
- public static final int HTTP_SEE_OTHER = 303;
- public static final int HTTP_NOT_MODIFIED = 304;
- public static final int HTTP_USE_PROXY = 305;
-
- /* HTTP Client Error Response Codes */
- public static final int HTTP_BAD_REQUEST = 400;
- public static final int HTTP_UNAUTHORIZED = 401;
- public static final int HTTP_PAYMENT_REQUIRED = 402;
- public static final int HTTP_FORBIDDEN = 403;
- public static final int HTTP_NOT_FOUND = 404;
- public static final int HTTP_BAD_METHOD = 405;
- public static final int HTTP_NOT_ACCEPTABLE = 406;
- public static final int HTTP_PROXY_AUTH = 407;
- public static final int HTTP_CLIENT_TIMEOUT = 408;
- public static final int HTTP_CONFLICT = 409;
- public static final int HTTP_GONE = 410;
- public static final int HTTP_LENGTH_REQUIRED = 411;
- public static final int HTTP_PRECON_FAILED = 412;
- public static final int HTTP_ENTITY_TOO_LARGE = 413;
- public static final int HTTP_REQ_TOO_LONG = 414;
- public static final int HTTP_UNSUPPORTED_TYPE = 415;
-
- /* HTTP Server Error Response Codes */
- public static final int HTTP_SERVER_ERROR = 500;
- public static final int HTTP_INTERNAL_ERROR = 501;
- public static final int HTTP_BAD_GATEWAY = 502;
- public static final int HTTP_UNAVAILABLE = 503;
- public static final int HTTP_GATEWAY_TIMEOUT = 504;
- public static final int HTTP_VERSION = 505;
-
- protected String method = "GET";
- protected int responseCode = -1;
- protected String responseMessage;
-
- static boolean followRedirects = true;
-
- protected HttpURLConnection(URL url)
- {
- super(url);
- }
-
- public abstract void disconnect();
-
- public abstract boolean usingProxy();
-
- public static void setFollowRedirects(boolean set)
- {
- // Throw an exception if an extant security mgr precludes
- // setting the factory.
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkSetFactory();
-
- followRedirects = set;
- }
-
- public static boolean getFollowRedirects()
- {
- return followRedirects;
- }
-
- public void setRequestMethod(String method) throws ProtocolException
- {
- if (connected)
- throw new ProtocolException("Already connected");
-
- if (method.equals("GET") || method.equals("POST") ||
- method.equals("HEAD") || method.equals("OPTIONS") ||
- method.equals("PUT") || method.equals("DELETE") ||
- method.equals("TRACE"))
- this.method = method;
- else
- throw new ProtocolException("Invalid HTTP request method");
- }
-
- public String getRequestMethod()
- {
- return method;
- }
-
- public int getResponseCode() throws IOException
- {
- getResponseVals();
- return responseCode;
- }
-
- public String getResponseMessage() throws IOException
- {
- getResponseVals();
- return responseMessage;
- }
-
- private void getResponseVals() throws IOException
- {
- // Response is the first header received from the connection.
- String respField = getHeaderField(0);
- if (! respField.startsWith("HTTP/"))
- {
- // Set to default values on failure.
- responseCode = -1;
- responseMessage = null;
- return;
- }
-
- int firstSpc, nextSpc;
- firstSpc = respField.indexOf(' ');
- nextSpc = respField.indexOf(' ', firstSpc + 1);
- responseMessage = respField.substring(nextSpc + 1);
- String codeStr = respField.substring(firstSpc + 1, nextSpc);
- try
- {
- responseCode = Integer.parseInt(codeStr);
- }
- catch (NumberFormatException e)
- {
- // Set to default values on failure.
- responseCode = -1;
- responseMessage = null;
- }
- if (responseCode == HTTP_NOT_FOUND)
- throw new FileNotFoundException(url.toString());
- else if (responseCode >= 400)
- throw new IOException(url.toString() + " " + respField);
- }
-
- // TODO12: public Permission getPermission() throws IOException
- // {
- // }
-
- // TODO12: public InputStream getErrorStream()
- // {
- // }
-}
diff --git a/libjava/java/net/InetAddress.java b/libjava/java/net/InetAddress.java
deleted file mode 100644
index 1a1aeced22a..00000000000
--- a/libjava/java/net/InetAddress.java
+++ /dev/null
@@ -1,256 +0,0 @@
-// INetAddress.java -- An Internet Protocol (IP) address.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Per Bothner
- * @date January 6, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * (The latter turns out to have some errors ...)
- * Status: Believed complete and correct.
- */
-
-public final class InetAddress
-{
- String hostname;
- byte[] address;
-
- InetAddress (byte[] address, String hostname)
- {
- this.address = address;
- this.hostname = hostname;
- }
-
- public boolean isMulticastAddress ()
- {
- int len = address.length;
- if (len == 4)
- return (address[0] & 0xF0) == 0xE0;
- if (len == 16)
- return address[0] == (byte) 0xFF;
- return false;
- }
-
- public String getHostName ()
- {
- if (hostname == null)
- lookup (null, this, false);
- return hostname;
- }
-
- public byte[] getAddress ()
- {
- // An experiment shows that JDK1.2 returns a different byte array each
- // time. This makes sense, in terms of security.
- return (byte[]) address.clone();
- }
-
- /* Helper function due to a CNI limitation. */
- private static InetAddress[] allocArray (int count)
- {
- return new InetAddress[count];
- }
-
- /* Helper function due to a CNI limitation. */
- private static SecurityException checkConnect (String hostname)
- {
- SecurityManager s = System.getSecurityManager();
- if (s == null)
- return null;
- try
- {
- s.checkConnect(hostname, -1);
- return null;
- }
- catch (SecurityException ex)
- {
- return ex;
- }
- }
-
- public String getHostAddress ()
- {
- StringBuffer sbuf = new StringBuffer(40);
- int len = address.length;
- int i = 0;
- if (len == 16)
- { // An IPv6 address.
- for (; ; i += 2)
- {
- if (i >= 16)
- return sbuf.toString();
- int x = ((address[i] & 0xFF) << 8) | (address[i+1] & 0xFF);
- boolean empty = sbuf.length() == 0;
- if (empty)
- {
- if (i == 10 && x == 0xFFFF)
- { // IPv4-mapped IPv6 address.
- sbuf.append(":FFFF:");
- break; // Continue as IPv4 address;
- }
- else if (i == 12)
- { // IPv4-compatible IPv6 address.
- sbuf.append(':');
- break; // Continue as IPv4 address.
- }
- else if (i > 0)
- sbuf.append("::");
- }
- else
- sbuf.append(':');
- if (x != 0 || i >= 14)
- sbuf.append(Integer.toHexString(x).toUpperCase());
- }
- }
- for ( ; ; )
- {
- sbuf.append(address[i] & 0xFF);
- i++;
- if (i == len)
- break;
- sbuf.append('.');
- }
- return sbuf.toString();
- }
-
- public int hashCode()
- {
- // There hashing algorithm is not specified, but a simple experiment
- // shows that it is equal to the address, as a 32-bit big-endian integer.
- int hash = 0;
- int len = address.length;
- int i = len > 4 ? len - 4 : 0;
- for ( ; i < len; i++)
- hash = (hash << 8) | (address[i] & 0xFF);
- return hash;
- }
-
- public boolean equals (Object obj)
- {
- if (obj == null || ! (obj instanceof InetAddress))
- return false;
- // "The Java Class Libraries" 2nd edition says "If a machine has
- // multiple names instances of InetAddress for different name of
- // that same machine are not equal. This is because they have
- // different host names." This violates the description in the
- // JDK 1.2 API documentation. A little experiementation
- // shows that the latter is correct.
- byte[] addr1 = address;
- byte[] addr2 = ((InetAddress) obj).address;
- if (addr1.length != addr2.length)
- return false;
- for (int i = addr1.length; --i >= 0; )
- if (addr1[i] != addr2[i])
- return false;
- return true;
- }
-
- public String toString()
- {
- return getHostName()+'/'+getHostAddress();
- }
-
- /** If host is a valid numeric IP address, return the numeric address.
- * Otherwise, return null. */
- private static native byte[] aton (String host);
-
- private static native InetAddress[] lookup
- (String hostname, InetAddress addr, boolean all);
-
- public static InetAddress getByName (String host)
- throws UnknownHostException
- {
- if (host == null)
- return getLocalHost();
- byte[] address = aton(host);
- if (address != null)
- return new InetAddress(address, null);
- InetAddress iaddr = new InetAddress(null, host);
- lookup(host, iaddr, false);
- return iaddr;
- }
-
- public static InetAddress[] getAllByName (String host)
- throws UnknownHostException
- {
- byte[] address = aton(host);
- if (address != null)
- {
- InetAddress[] result = new InetAddress[1];
- result[0] = new InetAddress(address, null);
- return result;
- }
- return lookup(host, null, true);
- }
-
- private static final byte[] localhostAddress = { 127, 0, 0, 1 };
-
- private static native String getLocalHostname ();
-
- private static InetAddress localhost = null;
-
- public static InetAddress getLocalHost() throws UnknownHostException
- {
- SecurityManager s = System.getSecurityManager();
- // Experimentation shows that JDK1.2 does cache the result.
- // However, if there is a security manager, and the cached result
- // is other than "localhost", we need to check again.
- if (localhost == null
- || (s != null && localhost.address != localhostAddress))
- getLocalHost(s);
- return localhost;
- }
-
- private static synchronized void getLocalHost(SecurityManager s)
- throws UnknownHostException
- {
- // Check the localhost cache again, now that we've synchronized.
- if (s == null && localhost != null)
- return;
- String hostname = getLocalHostname();
- if (s != null)
- {
- // "The Java Class Libraries" suggests that if the security
- // manager disallows getting the local host name, then
- // we use the loopback host.
- // However, the JDK 1.2 API claims to throw SecurityException,
- // which seems to suggest SecurityException is *not* caught.
- // In this case, experimentation shows that former is correct.
- try
- {
- // This is wrong, if the name returned from getLocalHostname()
- // is not a fully qualified name. FIXME.
- s.checkConnect(hostname, -1);
- }
- catch (SecurityException ex)
- {
- hostname = null;
- }
- }
- if (hostname != null)
- {
- try
- {
- localhost = new InetAddress(null, null);
- lookup(hostname, localhost, false);
- }
- catch (Exception ex)
- {
- }
- }
- if (localhost == null)
- localhost = new InetAddress (localhostAddress, "localhost");
- }
-}
diff --git a/libjava/java/net/JarURLConnection.java b/libjava/java/net/JarURLConnection.java
deleted file mode 100644
index 86a7291ac37..00000000000
--- a/libjava/java/net/JarURLConnection.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-import java.net.*;
-import java.io.*;
-import java.util.jar.*;
-import java.util.zip.*;
-import java.util.Vector;
-import java.util.Hashtable;
-
-/**
- * @author Kresten Krab Thorup <krab@gnu.org>
- * @date Aug 10, 1999.
- */
-
-
-public abstract class JarURLConnection extends URLConnection
-{
- // three different ways to say the same thing
- private final URL jarFileURL;
-
- /** The connection to the jar file itself. A JarURLConnection
- * can represent an entry in a jar file or an entire jar file. In
- * either case this describes just the jar file itself. */
- protected URLConnection jarFileURLConnection;
-
- // If this is a connection to a jar file element this is set, otherwose null.
- private final String element;
-
- // Cached JarURLConnection's
- static Hashtable conn_cache = new Hashtable();
-
- public URL getJarFileURL ()
- {
- return jarFileURL;
- }
-
- public String getEntryName ()
- {
- return element;
- }
-
- public JarURLConnection(URL url)
- throws MalformedURLException
- {
- super(url);
-
- String spec = url.getFile();
- int bang = spec.indexOf ("!/", 0);
- if (bang == -1)
- throw new MalformedURLException (url + ": No `!/' in spec.");
-
- // Extact the url for the jar itself.
- jarFileURL = new URL(spec.substring (0, bang));
-
- // Get the name of the element, if any.
- element = (bang+2==spec.length() ? null : spec.substring (bang+2));
- }
-
- public synchronized void connect() throws IOException
- {
- // Call is ignored if already connected.
- if (connected)
- return;
-
- if (getUseCaches())
- {
- jarFileURLConnection = (URLConnection) conn_cache.get (jarFileURL);
-
- if (jarFileURLConnection == null)
- {
- jarFileURLConnection = jarFileURL.openConnection ();
- jarFileURLConnection.setUseCaches (true);
- jarFileURLConnection.connect ();
- conn_cache.put (jarFileURL, jarFileURLConnection);
- }
- }
- else
- {
- jarFileURLConnection = jarFileURL.openConnection ();
- jarFileURLConnection.connect ();
- }
-
- connected = true;
- }
-
- public InputStream getInputStream() throws IOException
- {
- if (!connected)
- connect();
-
- if (! doInput)
- throw new ProtocolException("Can't open InputStream if doInput is false");
-
- if (element == null)
- {
- // This is a JarURLConnection for the entire jar file.
-
- InputStream jar_is = new BufferedInputStream(jarFileURLConnection.getInputStream ());
- return new JarInputStream(jar_is);
- }
-
- // Reaching this point, we're looking for an element of a jar file.
-
- JarFile jarfile = null;
-
- try
- {
- jarfile = getJarFile ();
- }
- catch (java.io.IOException x)
- {
- /* ignore */
- }
-
- if (jarfile != null)
- {
- // this is the easy way...
- return jarfile.getInputStream (jarfile.getEntry (element));
- }
- else
- {
- // If the jar file is not local, ...
- JarInputStream zis = new JarInputStream(jarFileURLConnection.getInputStream ());
-
- // This is hideous, we're doing a linear search...
- for (ZipEntry ent = zis.getNextEntry ();
- ent != null;
- ent = zis.getNextEntry ())
- {
- if (element.equals (ent.getName ()))
- {
- int size = (int)ent.getSize();
- byte[] data = new byte[size];
- zis.read (data, 0, size);
- return new ByteArrayInputStream (data);
- }
- }
- }
-
- return null;
- }
-
- public JarEntry getJarEntry (String name)
- throws java.io.IOException
- {
- JarFile jarfile = null;
-
- if (! doInput)
- throw new ProtocolException("Can't open JarEntry if doInput is false");
-
- try
- {
- jarfile = getJarFile ();
- }
- catch (java.io.IOException x)
- {
- /* ignore */
- }
-
- if (jarfile == null)
- {
- JarInputStream zis = new JarInputStream(jarFileURLConnection.getInputStream ());
-
- // This is hideous, we're doing a linear search for the thing...
- for (ZipEntry ent = zis.getNextEntry ();
- ent != null;
- ent = zis.getNextEntry ())
- {
- if (element.equals (ent.getName ()))
- {
- return new JarEntry (ent);
- }
- }
- }
-
- else
- {
- return jarfile.getJarEntry (element);
- }
-
- return null;
- }
-
- public abstract JarFile getJarFile() throws java.io.IOException;
-
-
- // Steal and borrow from protocol/file/Connection.java
-
- private Hashtable hdrHash = new Hashtable();
- private Vector hdrVec = new Vector();
- private boolean gotHeaders = false;
-
- // Override default method in URLConnection.
- public String getHeaderField(String name)
- {
- try
- {
- getHeaders();
- }
- catch (IOException x)
- {
- return null;
- }
- return (String) hdrHash.get(name.toLowerCase());
- }
-
- // Override default method in URLConnection.
- public String getHeaderField(int n)
- {
- try
- {
- getHeaders();
- }
- catch (IOException x)
- {
- return null;
- }
- if (n < hdrVec.size())
- return getField((String) hdrVec.elementAt(n));
-
- return null;
- }
-
- // Override default method in URLConnection.
- public String getHeaderFieldKey(int n)
- {
- try
- {
- getHeaders();
- }
- catch (IOException x)
- {
- return null;
- }
- if (n < hdrVec.size())
- return getKey((String) hdrVec.elementAt(n));
-
- return null;
- }
-
- private String getKey(String str)
- {
- if (str == null)
- return null;
- int index = str.indexOf(':');
- if (index >= 0)
- return str.substring(0, index);
- else
- return null;
- }
-
- private String getField(String str)
- {
- if (str == null)
- return null;
- int index = str.indexOf(':');
- if (index >= 0)
- return str.substring(index + 1).trim();
- else
- return str;
- }
-
- private void getHeaders() throws IOException
- {
- if (gotHeaders)
- return;
- gotHeaders = true;
-
- connect();
-
- // Yes, it is overkill to use the hash table and vector here since
- // we're only putting one header in the file, but in case we need
- // 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;
-
- if (element == null)
- len = jarFileURLConnection.getContentLength ();
- else
- len = getJarEntry (element).getSize ();
-
- String line = "Content-length: " + len;
- hdrVec.addElement(line);
-
- // The key will never be null in this scenario since we build up the
- // headers ourselves. If we ever rely on getting a header from somewhere
- // else, then we may have to check if the result of getKey() is null.
- String key = getKey(line);
- hdrHash.put(key.toLowerCase(), Long.toString(len));
- }
-
-}
diff --git a/libjava/java/net/MalformedURLException.java b/libjava/java/net/MalformedURLException.java
deleted file mode 100644
index 5ea6480b780..00000000000
--- a/libjava/java/net/MalformedURLException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// MalformedURLException.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class MalformedURLException extends java.io.IOException
-{
- public MalformedURLException()
- {
- super();
- }
-
- public MalformedURLException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java
deleted file mode 100644
index ad2bb969aa4..00000000000
--- a/libjava/java/net/MulticastSocket.java
+++ /dev/null
@@ -1,134 +0,0 @@
-// MulticastSocket.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-import java.io.IOException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date May 18, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class MulticastSocket extends DatagramSocket
-{
- // FIXME: the local addr bound to the multicast socket can be reused;
- // unlike unicast sockets. It binds to any available network interface.
- // See p.1159 JCL book.
-
- public MulticastSocket() throws IOException
- {
- super(0, null);
- }
-
- public MulticastSocket(int port) throws IOException
- {
- super(port, null);
- }
-
- public InetAddress getInterface() throws SocketException
- {
- // FIXME: Is it possible that an InetAddress wasn't returned from getOption?
- return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF);
- }
-
- // Deprecated in JDK1.2
- public byte getTTL() throws IOException
- {
- // Use getTTL here rather than getTimeToLive in case we're using an impl
- // other than the default PlainDatagramSocketImpl and it doesn't have
- // getTimeToLive yet.
- return impl.getTTL();
- }
-
- // JDK1.2
- public int getTimeToLive() throws IOException
- {
- return impl.getTimeToLive();
- }
-
- public void setInterface(InetAddress inf) throws SocketException
- {
- impl.setOption(SocketOptions.IP_MULTICAST_IF, inf);
- }
-
- // Deprecated in JDK1.2
- public void setTTL(byte ttl) throws IOException
- {
- // Use setTTL here rather than setTimeToLive in case we're using an impl
- // other than the default PlainDatagramSocketImpl and it doesn't have
- // setTimeToLive yet.
- impl.setTTL(ttl);
- }
-
- // JDK1.2
- public void setTimeToLive(int ttl) throws IOException
- {
- if (ttl <= 0 || ttl > 255)
- throw new IllegalArgumentException("Invalid ttl: " + ttl);
-
- impl.setTimeToLive(ttl);
- }
-
- public void joinGroup(InetAddress mcastaddr) throws IOException
- {
- // FIXME: We can't currently rely on NullPointerException being
- // thrown when we invoke a method on a null object.
- if (mcastaddr == null)
- throw new NullPointerException("Null address");
- if (! mcastaddr.isMulticastAddress())
- throw new IOException("Not a Multicast address");
-
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkMulticast(mcastaddr);
-
- impl.join(mcastaddr);
- }
-
- public void leaveGroup(InetAddress mcastaddr) throws IOException
- {
- // FIXME: We can't currently rely on NullPointerException being
- // thrown when we invoke a method on a null object.
- if (mcastaddr == null)
- throw new NullPointerException("Null address");
- if (! mcastaddr.isMulticastAddress())
- throw new IOException("Not a Multicast address");
-
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkMulticast(mcastaddr);
-
- impl.leave(mcastaddr);
- }
-
- public synchronized void send(DatagramPacket p, byte ttl) throws IOException
- {
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- {
- InetAddress addr = p.getAddress();
- if (addr.isMulticastAddress())
- s.checkMulticast(addr, ttl);
- else
- s.checkConnect(addr.getHostAddress(), p.getPort());
- }
-
- int oldttl = impl.getTimeToLive();
- impl.setTimeToLive(((int) ttl) & 0xFF);
- impl.send(p);
- impl.setTimeToLive(oldttl);
- }
-}
diff --git a/libjava/java/net/NoRouteToHostException.java b/libjava/java/net/NoRouteToHostException.java
deleted file mode 100644
index cb1c5f8bad9..00000000000
--- a/libjava/java/net/NoRouteToHostException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// NoRouteToHostException.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class NoRouteToHostException extends SocketException
-{
- public NoRouteToHostException()
- {
- super();
- }
-
- public NoRouteToHostException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/net/PlainDatagramSocketImpl.java b/libjava/java/net/PlainDatagramSocketImpl.java
deleted file mode 100644
index 9a290dcd0f8..00000000000
--- a/libjava/java/net/PlainDatagramSocketImpl.java
+++ /dev/null
@@ -1,112 +0,0 @@
-// PlainDatagramSocketImpl.java - Implementation of DatagramSocketImpl.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-import java.io.IOException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date May 3, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-class PlainDatagramSocketImpl extends DatagramSocketImpl
-{
- // These fields are mirrored for use in native code to avoid cpp conflicts
- // when the #defines in system header files are the same as the public fields.
- static final int _Jv_TCP_NODELAY_ = SocketOptions.TCP_NODELAY,
- _Jv_SO_BINDADDR_ = SocketOptions.SO_BINDADDR,
- _Jv_SO_REUSEADDR_ = SocketOptions.SO_REUSEADDR,
- _Jv_IP_MULTICAST_IF_ = SocketOptions.IP_MULTICAST_IF,
- _Jv_SO_LINGER_ = SocketOptions.SO_LINGER,
- _Jv_SO_TIMEOUT_ = SocketOptions.SO_TIMEOUT,
- _Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
- _Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF;
-
- int fnum = -1;
-
- // FIXME: Is this necessary? Could it help w/ DatagramSocket.getLocalAddress?
- // InetAddress address;
-
- // localAddress cache
- InetAddress localAddress;
-
- // 'timeout' is set/read by setOption/getOption.
- int timeout = 0;
-
- // FIXME: Probably should have bind (and create?) calls from DatagramSocket
- // constuctor. If so, then same change should be made to the corresponding
- // Socket (non-datagram) classes. This allows the implementation more
- // complete control over how the socket is set up and used (e.g. connect,
- // setting options, etc.).
- public PlainDatagramSocketImpl()
- {
- }
-
- protected native void bind(int lport, InetAddress laddr)
- throws SocketException;
- protected native void create() throws SocketException;
- protected native int peek(InetAddress i) throws IOException;
- protected native void setTimeToLive(int ttl) throws IOException;
- protected native int getTimeToLive() throws IOException;
- protected native void send(DatagramPacket p) throws IOException;
- protected native void receive(DatagramPacket p) throws IOException;
- public native void setOption(int optID, Object value) throws SocketException;
- public native Object getOption(int optID) throws SocketException;
- private native void mcastGrp(InetAddress inetaddr, boolean join)
- throws IOException;
-
- protected void close()
- {
- // FIXME: The close method in each of the DatagramSocket* classes does
- // not throw an IOException. The issue is that FileDescriptor.close()
- // in natFileDescriptorPosix.cc can throw one, so we have to catch
- // it here. It seems that FileDescriptor.close is properly throwing
- // the IOException on errors since many of the java.io classes depend
- // on that. This probably requires a bit more research but for now,
- // we'll catch the IOException here.
- try
- {
- fd.close();
- }
- catch (IOException e)
- {
- System.err.println("PlainDatagramSocketImpl.close: Error closing - " +
- e.getMessage());
- }
- }
-
- // Deprecated in JDK 1.2.
- protected byte getTTL() throws IOException
- {
- return (byte) getTimeToLive();
- }
-
- // Deprecated in JDK 1.2.
- protected void setTTL(byte ttl) throws IOException
- {
- setTimeToLive(((int) ttl) & 0xFF);
- }
-
- protected void join(InetAddress inetaddr) throws IOException
- {
- mcastGrp(inetaddr, true);
- }
-
- protected void leave(InetAddress inetaddr) throws IOException
- {
- mcastGrp(inetaddr, false);
- }
-}
diff --git a/libjava/java/net/PlainSocketImpl.java b/libjava/java/net/PlainSocketImpl.java
deleted file mode 100644
index df9d4387d44..00000000000
--- a/libjava/java/net/PlainSocketImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-// PlainSocketImpl.java - Implementation of SocketImpl.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-import java.io.*;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date February 22, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-class PlainSocketImpl extends SocketImpl
-{
- // These fields are mirrored for use in native code to avoid cpp conflicts
- // when the #defines in system header files are the same as the public fields.
- static final int _Jv_TCP_NODELAY_ = SocketOptions.TCP_NODELAY,
- _Jv_SO_BINDADDR_ = SocketOptions.SO_BINDADDR,
- _Jv_SO_REUSEADDR_ = SocketOptions.SO_REUSEADDR,
- _Jv_IP_MULTICAST_IF_ = SocketOptions.IP_MULTICAST_IF,
- _Jv_SO_LINGER_ = SocketOptions.SO_LINGER,
- _Jv_SO_TIMEOUT_ = SocketOptions.SO_TIMEOUT,
- _Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
- _Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF;
-
- int fnum = -1;
-
- // This value is set/read by setOption/getOption.
- int timeout = 0;
-
- // localAddress cache
- InetAddress localAddress;
-
- public native void setOption(int optID, Object value) throws SocketException;
-
- public native Object getOption(int optID) throws SocketException;
-
- protected native void create (boolean stream) throws IOException;
-
- protected void connect (String host, int port) throws IOException
- {
- connect(InetAddress.getByName(host), port);
- }
-
- protected native void connect (InetAddress host, int port)
- throws IOException;
-
- protected native void bind (InetAddress host, int port) throws IOException;
-
- protected native void listen (int backlog) throws IOException;
-
- private native void accept (PlainSocketImpl s) throws IOException;
- protected void accept (SocketImpl s) throws IOException
- {
- accept((PlainSocketImpl) s);
- }
-
- private InputStream in;
- private OutputStream out;
-
- protected InputStream getInputStream() throws IOException
- {
- // FIXME: TODO - Implement class SocketInputStream timeouts in read();
- if (in == null)
- in = new FileInputStream (fd);
- return in;
- }
-
- protected OutputStream getOutputStream() throws IOException
- {
- if (out == null)
- out = new FileOutputStream (fd);
- return out;
- }
-
- protected int available () throws IOException
- {
- return in.available();
- }
-
- protected void close () throws IOException
- {
- fd.close();
- }
-}
diff --git a/libjava/java/net/ProtocolException.java b/libjava/java/net/ProtocolException.java
deleted file mode 100644
index 2263457d805..00000000000
--- a/libjava/java/net/ProtocolException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// ProtocolException.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class ProtocolException extends java.io.IOException
-{
- public ProtocolException()
- {
- super();
- }
-
- public ProtocolException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java
deleted file mode 100644
index bc1b072fa2d..00000000000
--- a/libjava/java/net/ServerSocket.java
+++ /dev/null
@@ -1,114 +0,0 @@
-// ServerSocket.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 Per Bothner <bothner@cygnus.com>
- * @date January 6, 1999.
- */
-
-/** Written using on-line Java Platform 1.2 API Specification.
- * Status: I believe all methods are implemented.
- */
-
-package java.net;
-import java.io.*;
-
-public class ServerSocket
-{
- static SocketImplFactory factory;
- SocketImpl impl;
-
- static final byte[] zeros = {0,0,0,0};
- /* dummy InetAddress, used to bind socket to any (all) network interfaces */
- static final InetAddress ANY_IF = new InetAddress(zeros, null);
-
- public ServerSocket (int port)
- throws java.io.IOException
- {
- this(port, 50);
- }
-
- public ServerSocket (int port, int backlog)
- throws java.io.IOException
- {
- this(port, backlog, ANY_IF);
- }
-
- public ServerSocket (int port, int backlog, InetAddress bindAddr)
- throws java.io.IOException
- {
- if (factory == null)
- this.impl = new PlainSocketImpl();
- else
- this.impl = factory.createSocketImpl();
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkListen(port);
- impl.create(true);
- impl.bind(bindAddr == null ? ANY_IF : bindAddr, port);
- impl.listen(backlog);
- }
-
- public InetAddress getInetAddress()
- {
- return impl.getInetAddress();
- }
-
- public int getLocalPort()
- {
- return impl.getLocalPort();
- }
-
- public Socket accept () throws IOException
- {
- Socket s = new Socket(Socket.factory == null ? new PlainSocketImpl()
- : Socket.factory.createSocketImpl());
- implAccept (s);
- return s;
- }
-
- protected final void implAccept (Socket s) throws IOException
- {
- impl.accept(s.impl);
- }
-
- public void close () throws IOException
- {
- impl.close();
- }
-
- public synchronized void setSoTimeout (int timeout) throws SocketException
- {
- if (timeout < 0)
- throw new IllegalArgumentException("Invalid timeout: " + timeout);
-
- impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
- }
-
- public synchronized int getSoTimeout () throws SocketException
- {
- Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT);
- if (timeout instanceof Integer)
- return ((Integer)timeout).intValue();
- else
- return 0;
- }
-
- public String toString ()
- {
- return "ServerSocket" + impl.toString();
- }
-
- public static synchronized void setSocketFactory (SocketImplFactory fac)
- throws IOException
- {
- factory = fac;
- }
-}
diff --git a/libjava/java/net/Socket.java b/libjava/java/net/Socket.java
deleted file mode 100644
index 34ea165e51a..00000000000
--- a/libjava/java/net/Socket.java
+++ /dev/null
@@ -1,263 +0,0 @@
-// Socket.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 Per Bothner <bothner@cygnus.com>
- * @date January 6, 1999.
- */
-
-/** Written using on-line Java Platform 1.2 API Specification.
- * Status: I believe all methods are implemented.
- */
-
-package java.net;
-import java.io.*;
-
-public class Socket
-{
- static SocketImplFactory factory;
- SocketImpl impl;
-
- protected Socket ()
- {
- }
-
- protected Socket (SocketImpl impl) throws SocketException
- {
- this.impl = impl;
- }
-
- public Socket (String host, int port)
- throws UnknownHostException, IOException
- {
- this(factory == null ? new PlainSocketImpl() : factory.createSocketImpl());
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkConnect(host, port);
- impl.create(true);
- // FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port,
- // i.e. '0' and if localAddr is unspecified, use getLocalAddress() as
- // that default. JDK 1.2 doc infers not to do a bind.
- impl.connect(host, port);
- }
-
- public Socket (InetAddress address, int port)
- throws IOException
- {
- this(factory == null ? new PlainSocketImpl() : factory.createSocketImpl());
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkConnect(address.getHostName(), port);
- impl.create(true);
- // FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port,
- // i.e. '0' and if localAddr is unspecified, use getLocalAddress() as
- // that default. JDK 1.2 doc infers not to do a bind.
- impl.connect(address, port);
- }
-
- public Socket (String host, int port,
- InetAddress localAddr, int localPort) throws IOException
- {
- this(factory == null ? new PlainSocketImpl() : factory.createSocketImpl());
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkConnect(host, port);
- impl.create(true);
- // FIXME: JCL p. 1587 says if localAddr is null, use getLocalAddress().
- impl.bind(localAddr, localPort);
- impl.connect(host, port);
- }
-
- public Socket (InetAddress address, int port,
- InetAddress localAddr, int localPort) throws IOException
- {
- this(factory == null ? new PlainSocketImpl() : factory.createSocketImpl());
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkConnect(address.getHostName(), port);
- impl.create(true);
- // FIXME: JCL p. 1587 says if localAddr is null, use getLocalAddress().
- impl.bind(localAddr, localPort);
- impl.connect(address, port);
- }
-
- /**
- * @deprecated Use DatagramSocket instead for UDP transport.
- */
- public Socket (String host, int port, boolean stream) throws IOException
- {
- impl = factory == null ? new PlainSocketImpl()
- : factory.createSocketImpl();
- impl.create(stream);
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkConnect(host, port);
- // FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port,
- // i.e. '0' and if localAddr is unspecified, use getLocalAddress() as
- // that default. JDK 1.2 doc infers not to do a bind.
- impl.connect(host, port);
- }
-
- /**
- * @deprecated Use DatagramSocket instead for UDP transport.
- */
- public Socket (InetAddress host, int port, boolean stream) throws IOException
- {
- impl = factory == null ? new PlainSocketImpl()
- : factory.createSocketImpl();
- impl.create(stream);
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkConnect(host.getHostName(), port);
- // FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port,
- // i.e. '0' and if localAddr is unspecified, use getLocalAddress() as
- // that default. JDK 1.2 doc infers not to do a bind.
- impl.connect(host, port);
- }
-
- public InetAddress getInetAddress ()
- {
- return impl.getInetAddress();
- }
-
- public InetAddress getLocalAddress ()
- {
- // FIXME: see note in DatagramSocket.java about checkConnect() and security
- try
- {
- return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR);
- }
- catch (SocketException x)
- {
- // (hopefully) shouldn't happen
- System.err.println(x);
- throw new java.lang.InternalError("Error in PlainSocketImpl.getOption");
- }
- }
-
- public int getPort ()
- {
- return impl.getPort();
- }
-
- public int getLocalPort ()
- {
- return impl.getLocalPort();
- }
-
- public InputStream getInputStream () throws IOException
- {
- return impl.getInputStream();
- }
-
- public OutputStream getOutputStream () throws IOException
- {
- return impl.getOutputStream();
- }
-
- public void setTcpNoDelay (boolean on) throws SocketException
- {
- impl.setOption( SocketOptions.TCP_NODELAY, new Boolean(on) );
- }
-
- public boolean getTcpNoDelay() throws SocketException
- {
- Boolean bool = (Boolean)impl.getOption( SocketOptions.TCP_NODELAY );
- return bool.booleanValue();
- }
-
- public void setSoLinger(boolean on, int linger) throws SocketException
- {
- if ( on && (linger >= 0) )
- {
- if (linger > 65535)
- linger = 65535;
- impl.setOption( SocketOptions.SO_LINGER, new Integer(linger) );
- }
- else if ( on && (linger < 0) )
- throw new IllegalArgumentException("SO_LINGER must be >= 0");
- else
- impl.setOption( SocketOptions.SO_LINGER, new Boolean(false) );
- }
-
- public int getSoLinger() throws SocketException
- {
- Object linger = impl.getOption(SocketOptions.SO_LINGER);
- if (linger instanceof Integer)
- return ((Integer)linger).intValue();
- else
- return -1;
- }
-
- public synchronized void setSoTimeout (int timeout) throws SocketException
- {
- if (timeout < 0)
- throw new IllegalArgumentException("Invalid timeout: " + timeout);
-
- impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
- }
-
- public synchronized int getSoTimeout () throws SocketException
- {
- Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT);
- if (timeout instanceof Integer)
- return ((Integer)timeout).intValue();
- else
- return 0;
- }
-
- // JDK1.2
- public void setSendBufferSize (int size) throws SocketException
- {
- if (size <= 0)
- throw new IllegalArgumentException("Invalid buffer size: " + size);
-
- impl.setOption(SocketOptions.SO_SNDBUF, new Integer(size));
- }
-
- // JDK1.2
- public int getSendBufferSize () throws SocketException
- {
- Integer buf = (Integer)impl.getOption(SocketOptions.SO_SNDBUF);
- return buf.intValue();
- }
-
- // JDK1.2
- public void setReceiveBufferSize (int size) throws SocketException
- {
- if (size <= 0)
- throw new IllegalArgumentException("Invalid buffer size: " + size);
-
- impl.setOption(SocketOptions.SO_RCVBUF, new Integer(size));
- }
-
- // JDK1.2
- public int getReceiveBufferSize () throws SocketException
- {
- Integer buf = (Integer)impl.getOption(SocketOptions.SO_RCVBUF);
- return buf.intValue();
- }
-
- public synchronized void close () throws IOException
- {
- impl.close();
- }
-
- public String toString ()
- {
- return "Socket" + impl.toString();
- }
-
- public static synchronized void setSocketImplFactory (SocketImplFactory fac)
- throws IOException
- {
- factory = fac;
- }
-}
diff --git a/libjava/java/net/SocketException.java b/libjava/java/net/SocketException.java
deleted file mode 100644
index 847cdc9048d..00000000000
--- a/libjava/java/net/SocketException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// SocketException.java - Base class for networking exceptions
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Per Bothner
- * @date January 6, 1999.
- */
-
-/** Written using on-line Java Platform 1.2 API Specification.
- * Believed complete and correct.
- */
-
-public class SocketException extends java.io.IOException
-{
- public SocketException ()
- {
- super();
- }
-
- public SocketException (String s)
- {
- super(s);
- }
-}
diff --git a/libjava/java/net/SocketImpl.java b/libjava/java/net/SocketImpl.java
deleted file mode 100644
index d902a30e40a..00000000000
--- a/libjava/java/net/SocketImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-// SocketImpl.java - Abstract socket implementation.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-import java.io.*;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date January 6, 1999.
- */
-
-/** Written using on-line Java Platform 1.2 API Specification.
- * Believed complete and correct.
- */
-
-public abstract class SocketImpl implements SocketOptions
-{
- protected InetAddress address;
-
- protected FileDescriptor fd;
-
- protected int localport;
-
- protected int port;
-
- public SocketImpl ()
- {
- }
-
- protected abstract void create (boolean stream) throws IOException;
-
- protected abstract void connect (String host, int port) throws IOException;
-
- protected abstract void connect (InetAddress host, int port)
- throws IOException;
-
- protected abstract void bind (InetAddress host, int port) throws IOException;
-
- protected abstract void listen (int backlog) throws IOException;
-
- protected abstract void accept (SocketImpl s) throws IOException;
-
- protected abstract InputStream getInputStream() throws IOException;
-
- protected abstract OutputStream getOutputStream() throws IOException;
-
- protected abstract int available () throws IOException;
-
- protected abstract void close () throws IOException;
-
- protected FileDescriptor getFileDescriptor () { return fd; }
-
- protected InetAddress getInetAddress () { return address; }
-
- protected int getPort () { return port; }
-
- protected int getLocalPort () { return localport; }
-
- public abstract Object getOption(int optID) throws SocketException;
-
- public abstract void setOption(int optID, Object value)
- throws SocketException;
-
- public String toString ()
- {
- return "[addr=" + address.toString() + ",port=" + Integer.toString(port) +
- ",localport=" + Integer.toString(localport) + "]";
- }
-}
diff --git a/libjava/java/net/SocketImplFactory.java b/libjava/java/net/SocketImplFactory.java
deleted file mode 100644
index defce2e02cb..00000000000
--- a/libjava/java/net/SocketImplFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// SocketImplFactory.java - Abstract socket implementation factory.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date January 6, 1999.
- */
-
-/** Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public abstract interface SocketImplFactory
-{
- public SocketImpl createSocketImpl ();
-}
diff --git a/libjava/java/net/SocketOptions.java b/libjava/java/net/SocketOptions.java
deleted file mode 100644
index d0e00d9ec08..00000000000
--- a/libjava/java/net/SocketOptions.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// SocketOptions.java - Interface for get/set socket options.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date May 3, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public abstract interface SocketOptions
-{
- public static final int TCP_NODELAY = 0x1;
- public static final int SO_BINDADDR = 0xF;
- public static final int SO_REUSEADDR = 0x4;
- public static final int IP_MULTICAST_IF = 0x10;
- public static final int SO_LINGER = 0x80;
- public static final int SO_TIMEOUT = 0x1006;
-
- // JDK1.2
- public static final int SO_SNDBUF = 0x1001;
-
- // JDK1.2
- public static final int SO_RCVBUF = 0x1002;
-
- public void setOption(int optID, Object value) throws SocketException;
- public Object getOption(int optID) throws SocketException;
-}
diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java
deleted file mode 100644
index f80a52f5878..00000000000
--- a/libjava/java/net/URL.java
+++ /dev/null
@@ -1,373 +0,0 @@
-// URL.java - A Uniform Resource Locator.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-import java.io.*;
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 4, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public final class URL implements Serializable
-{
- private String protocol;
- private String host;
- private int port = -1; // Initialize for constructor using context.
- private String file;
- private String ref;
- private URLStreamHandler handler;
- private static Hashtable handlers = new Hashtable();
- private static URLStreamHandlerFactory factory;
-
- public URL(String protocol, String host, int port, String file)
- throws MalformedURLException
- {
- this(protocol, host, port, file, null);
- }
-
- public URL(String protocol, String host, String file)
- throws MalformedURLException
- {
- this(protocol, host, -1, file, null);
- }
-
- // JDK1.2
- public URL(String protocol, String host, int port, String file,
- URLStreamHandler handler) throws MalformedURLException
- {
- if (protocol == null)
- throw new MalformedURLException("null protocol");
- this.protocol = protocol;
-
- if (handler != null)
- {
- // TODO12: Need SecurityManager.checkPermission and
- // TODO12: java.net.NetPermission from JDK 1.2 to be implemented.
- // Throw an exception if an extant security mgr precludes
- // specifying a StreamHandler.
- //
- // SecurityManager s = System.getSecurityManager();
- // if (s != null)
- // s.checkPermission(NetPermission("specifyStreamHandler"));
-
- this.handler = handler;
- }
- else
- this.handler = setURLStreamHandler(protocol);
-
- if (this.handler == null)
- throw new MalformedURLException("Handler for protocol not found");
-
- this.host = host;
-
- this.port = port;
-
- int hashAt = file.indexOf('#');
- if (hashAt < 0)
- {
- this.file = file;
- this.ref = null;
- }
- else
- {
- this.file = file.substring(0, hashAt);
- this.ref = file.substring(hashAt + 1);
- }
- }
-
- public URL(String spec) throws MalformedURLException
- {
- this((URL) null, spec, (URLStreamHandler) null);
- }
-
- public URL(URL context, String spec) throws MalformedURLException
- {
- this(context, spec, (URLStreamHandler) null);
- }
-
- // JDK1.2
- public URL(URL context, String spec, URLStreamHandler handler)
- throws MalformedURLException
- {
- /* A protocol is defined by the doc as the substring before a ':'
- * as long as the ':' occurs before any '/'.
- *
- * If context is null, then spec must be an absolute URL.
- *
- * The relative URL need not specify all the components of a URL.
- * If the protocol, host name, or port number is missing, the value
- * is inherited from the context. A bare file component is appended
- * to the context's file. The optional anchor is not inherited.
- */
-
- // If this is an absolute URL, then ignore context completely.
- // An absolute URL must have chars prior to "://" but cannot have a colon
- // right after the "://". The second colon is for an optional port value
- // and implies that the host from the context is used if available.
- int colon;
- if ((colon = spec.indexOf("://", 1)) > 0 &&
- ! spec.regionMatches(colon, "://:", 0, 4))
- context = null;
-
- int slash;
- if ((colon = spec.indexOf(':')) > 0 &&
- (colon < (slash = spec.indexOf('/')) || slash < 0))
- {
- // Protocol specified in spec string.
- protocol = spec.substring(0, colon);
- if (context != null && context.protocol.equals(protocol))
- {
- // The 1.2 doc specifically says these are copied to the new URL.
- host = context.host;
- port = context.port;
- file = context.file;
- }
- }
- else if (context != null)
- {
- // Protocol NOT specified in spec string.
- // Use context fields (except ref) as a foundation for relative URLs.
- colon = -1;
- protocol = context.protocol;
- host = context.host;
- port = context.port;
- file = context.file;
- }
- else // Protocol NOT specified in spec. and no context available.
- throw new
- MalformedURLException("Absolute URL required with null context");
-
- if (handler != null)
- {
- // TODO12: Need SecurityManager.checkPermission and
- // TODO12: java.net.NetPermission from JDK 1.2 to be implemented.
- // Throw an exception if an extant security mgr precludes
- // specifying a StreamHandler.
- //
- // SecurityManager s = System.getSecurityManager();
- // if (s != null)
- // s.checkPermission(NetPermission("specifyStreamHandler"));
-
- this.handler = handler;
- }
- else
- this.handler = setURLStreamHandler(protocol);
-
- if (this.handler == null)
- throw new MalformedURLException("Handler for protocol not found");
-
- // JDK 1.2 doc for parseURL specifically states that any '#' ref
- // is to be excluded by passing the 'limit' as the indexOf the '#'
- // if one exists, otherwise pass the end of the string.
- int hashAt = spec.indexOf('#', colon + 1);
- this.handler.parseURL(this, spec, colon + 1,
- hashAt < 0 ? spec.length() : hashAt);
- if (hashAt >= 0)
- ref = spec.substring(hashAt + 1);
- }
-
- public boolean equals(Object obj)
- {
- if (obj == null || ! (obj instanceof URL))
- return false;
-
- URL uObj = (URL) obj;
-
- // This comparison is very conservative. It assumes that any
- // field can be null.
- return (port == uObj.port
- && ((protocol == null && uObj.protocol == null)
- || (protocol != null && protocol.equals(uObj.protocol)))
- && ((host == null && uObj.host == null)
- || (host != null && host.equals(uObj.host)))
- && ((file == null && uObj.file == null)
- || (file != null && file.equals(uObj.file)))
- && ((ref == null && uObj.ref == null)
- || (ref != null && ref.equals(uObj.ref))));
- }
-
- public final Object getContent() throws IOException
- {
- return openConnection().getContent();
- }
-
- public String getFile()
- {
- return file;
- }
-
- public String getHost()
- {
- return host;
- }
-
- public int getPort()
- {
- return port;
- }
-
- public String getProtocol()
- {
- return protocol;
- }
-
- public String getRef()
- {
- return ref;
- }
-
- public int hashCode()
- {
- // JCL book says this is computed using (only) the hashcodes of the
- // protocol, host and file fields. Empirical evidence indicates this
- // is probably XOR in JDK 1.1. In JDK 1.2 it seems to be a sum including
- // the port.
- //
- // JDK 1.2 online doc infers that host could be null because it
- // explicitly states that file cannot be null but is silent on host.
- // A simple example with protocol "http" (hashcode 3213448), host null,
- // file "/" (hashcode 47) produced a hashcode (3213494) which appeared
- // to be the sum of the two hashcodes plus the port. Another example
- // using "/index.html" for file bore this out; as well as "#" for file
- // (which was reduced to "" with a hashcode of zero). A "" host also
- // causes the port number and the two hashcodes to be summed.
-
- return (protocol.hashCode() + ((host == null) ? 0 : host.hashCode()) +
- port + file.hashCode());
- }
-
- public URLConnection openConnection() throws IOException
- {
- return handler.openConnection(this);
- }
-
- public final InputStream openStream() throws IOException
- {
- return openConnection().getInputStream();
- }
-
- public boolean sameFile(URL other)
- {
- // This comparison is very conservative. It assumes that any
- // field can be null.
- return (other != null
- && port == other.port
- && ((protocol == null && other.protocol == null)
- || (protocol != null && protocol.equals(other.protocol)))
- && ((host == null && other.host == null)
- || (host != null && host.equals(other.host)))
- && ((file == null && other.file == null)
- || (file != null && file.equals(other.file))));
- }
-
- protected void set(String protocol, String host, int port, String file,
- String ref)
- {
- // TBD: Theoretically, a poorly written StreamHandler could pass an
- // invalid protocol. It will cause the handler to be set to null
- // thus overriding a valid handler. Callers of this method should
- // be aware of this.
- this.handler = setURLStreamHandler(protocol);
- this.protocol = protocol;
- this.port = port;
- this.host = host;
- this.file = file;
- this.ref = ref;
- }
-
- public static synchronized void
- setURLStreamHandlerFactory(URLStreamHandlerFactory fac)
- {
- if (factory != null)
- throw new Error("URLStreamHandlerFactory already set");
-
- // Throw an exception if an extant security mgr precludes
- // setting the factory.
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkSetFactory();
- factory = fac;
- }
-
- public String toExternalForm()
- {
- // Identical to toString().
- return handler.toExternalForm(this);
- }
-
- public String toString()
- {
- // Identical to toExternalForm().
- return handler.toExternalForm(this);
- }
-
- private URLStreamHandler setURLStreamHandler(String protocol)
- {
- URLStreamHandler handler;
-
- // See if a handler has been cached for this protocol.
- if ((handler = (URLStreamHandler) handlers.get(protocol)) != null)
- return handler;
-
- // If a non-default factory has been set, use it to find the protocol.
- if (factory != null)
- handler = factory.createURLStreamHandler(protocol);
-
- // Non-default factory may have returned null or a factory wasn't set.
- // Use the default search algorithm to find a handler for this protocol.
- if (handler == null)
- {
- // Get the list of packages to check and append our default handler
- // to it, along with the JDK specified default as a last resort.
- // Except in very unusual environments the JDK specified one shouldn't
- // ever be needed (or available).
- String propVal = System.getProperty("java.protocol.handler.pkgs");
- propVal = (propVal == null) ? "" : (propVal + "|");
- propVal = propVal + "gnu.gcj.protocol|sun.net.www.protocol";
-
- StringTokenizer pkgPrefix = new StringTokenizer(propVal, "|");
- do
- {
- String facName = pkgPrefix.nextToken() + "." + protocol +
- ".Handler";
- try
- {
- handler =
- (URLStreamHandler) Class.forName(facName).newInstance();
- }
- catch (Exception e)
- {
- // Can't instantiate; handler still null, go on to next element.
- }
- } while ((handler == null ||
- ! (handler instanceof URLStreamHandler)) &&
- pkgPrefix.hasMoreTokens());
- }
-
- // Update the hashtable with the new protocol handler.
- if (handler != null)
- if (handler instanceof URLStreamHandler)
- handlers.put(protocol, handler);
- else
- handler = null;
-
- return handler;
- }
-}
diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java
deleted file mode 100644
index 8e467ad6b80..00000000000
--- a/libjava/java/net/URLClassLoader.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-import java.io.*;
-import java.util.jar.*;
-import java.util.Vector;
-
-public class URLClassLoader extends ClassLoader
-{
- // The URLStreamHandlerFactory
- URLStreamHandlerFactory factory = null;
-
- // `path' contains simply the URL's we're using for the searching.
- private Vector path;
-
- // If path[n] is a zip/jar, then this holds a JarURLConnection for that thing,
- // otherwise, path[n] is null.
- private Vector info;
-
- private URLStreamHandler getHandler0 (String protocol)
- {
- if (factory != null)
- return factory.createURLStreamHandler(protocol);
- else
- return null;
- }
-
- public URLClassLoader (URL[] urls)
- {
- this (urls, null, null);
- }
-
- public URLClassLoader (URL[] urls, ClassLoader parent)
- {
- this (urls, parent, null);
- }
-
- public URLClassLoader (URL[] urls, ClassLoader parent,
- URLStreamHandlerFactory fac)
- {
- super (parent);
-
- factory = fac;
-
- if (urls == null || urls.length == 0)
- {
- path = new Vector (1);
- info = new Vector (1);
- return;
- }
-
- path = new Vector (urls.length);
- info = new Vector (urls.length);
-
- for (int i = 0; i < urls.length; i++)
- {
- URL u = urls[i];
-
- // If it is a jar url, then we'll search it as is.
- if (! u.getProtocol ().equals ("jar"))
- {
- String f = u.getFile ();
-
- // 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
- {
- u = new URL ("jar", "", -1, (u.toExternalForm ())+"!/",
- getHandler0 ("jar"));
- }
- catch (MalformedURLException x)
- {
- /* ignore */
- }
- }
- }
-
- path.insertElementAt (u, i);
-
- if (u.getProtocol ().equals ("jar"))
- {
- JarURLConnection conn = null;
- try
- {
- conn = (JarURLConnection) u.openConnection ();
- }
- catch (java.io.IOException x)
- {
- /* ignore */
- }
- info.insertElementAt (conn, i);
- }
- else
- {
- info.insertElementAt (null, i);
- }
- }
- }
-
- public URL getResource (String name)
- {
- 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.getJarEntry (name) != null)
- return new URL(u, name, getHandler0 (u.getProtocol()));
- }
- else
- {
- URL p = new URL (u, name, getHandler0 (u.getProtocol()));
-
- 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;
- }
- }
-
- return null;
- }
-
- /** IN jdk 1.2 this method is not overridden, but we gain performance
- by doing so.
- */
-
- public InputStream getResourceAsStream (String name)
- {
- for (int i = 0; i < path.size(); i++)
- {
- URL u = (URL)path.elementAt (i);
-
- try {
- JarURLConnection conn = (JarURLConnection) info.elementAt (i);
-
- if (conn != null)
- {
- JarFile file = conn.getJarFile ();
- JarEntry ent = file.getJarEntry (name);
- if (ent != null)
- return file.getInputStream(ent);
- }
- else
- {
- InputStream is = new URL(u, name, getHandler0 (u.getProtocol())).openStream();
- if (is != null)
- return is;
- }
-
- // if we get an exception ... try the next path element
- } catch (IOException x) {
- continue;
- }
- }
-
- return null;
- }
-
- // and finally, we can implement our class loader functionality.
- protected Class findClass (String name)
- throws ClassNotFoundException
- {
- if (name == null)
- throw new ClassNotFoundException ("null");
-
- try
- {
- InputStream is = getResourceAsStream (name.replace ('.', '/') + ".class");
-
- if (is == null)
- throw new ClassNotFoundException (name);
-
- // Here we have to rely on available() to provide the length of
- // the class; which might not be exactly right in some cases...
-
- int len = is.available ();
- byte[] data = new byte[len];
-
- 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;
- }
-
- return defineClass (name, data, 0, len);
- }
- catch (java.io.IOException x)
- {
- throw new ClassNotFoundException(name);
- }
- }
-
-}
-
diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java
deleted file mode 100644
index 4ddc10c53d3..00000000000
--- a/libjava/java/net/URLConnection.java
+++ /dev/null
@@ -1,454 +0,0 @@
-// URLConnection.java - Superclass of all communications links between
-// an application and a URL.
-
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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 java.net;
-
-import java.io.*;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-import gnu.gcj.io.MimeTypes;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: One guessContentTypeFrom... methods not implemented.
- * getContent method assumes content type from response; see comment there.
- */
-
-public abstract class URLConnection
-{
- protected URL url;
- protected boolean doInput = true;
- protected boolean doOutput = false;
- protected boolean allowUserInteraction;
- protected boolean useCaches;
- protected long ifModifiedSince = 0L;
- protected boolean connected = false;
- private static boolean defaultAllowUserInteraction = false;
- private static boolean defaultUseCaches = true;
- private static FileNameMap fileNameMap; // Set by the URLConnection subclass.
- private static ContentHandlerFactory factory;
- private static ContentHandler contentHandler;
- private static Hashtable handlers = new Hashtable();
- private static Locale locale;
- private static SimpleDateFormat dateFormat1, dateFormat2, dateFormat3;
- private static boolean dateformats_initialized = false;
-
- protected URLConnection(URL url)
- {
- this.url = url;
- allowUserInteraction = defaultAllowUserInteraction;
- useCaches = defaultUseCaches;
- }
-
- public abstract void connect() throws IOException;
-
- public URL getURL()
- {
- return url;
- }
-
- public int getContentLength()
- {
- return getHeaderFieldInt("content-length", -1);
- }
-
- public String getContentType()
- {
- return getHeaderField("content-type");
- }
-
- public String getContentEncoding()
- {
- return getHeaderField("content-encoding");
- }
-
- public long getExpiration()
- {
- return getHeaderFieldDate("expiration", 0L);
- }
-
- public long getDate()
- {
- return getHeaderFieldDate("date", 0L);
- }
-
- public long getLastModified()
- {
- return getHeaderFieldDate("last-modified", 0L);
- }
-
- public String getHeaderField(int n)
- {
- // Subclasses for specific protocols override this.
- return null;
- }
-
- public String getHeaderField(String name)
- {
- // Subclasses for specific protocols override this.
- return null;
- }
-
- public int getHeaderFieldInt(String name, int val)
- {
- String str = getHeaderField(name);
- try
- {
- if (str != null)
- val = Integer.parseInt(str);
- }
- catch (NumberFormatException e)
- {
- ; // Do nothing; val is the default.
- }
- return val;
- }
-
- public long getHeaderFieldDate(String name, long val)
- {
- if (! dateformats_initialized)
- initializeDateFormats();
- String str = getHeaderField(name);
- if (str != null)
- {
- Date date;
- if ((date = dateFormat1.parse(str, new ParsePosition(0))) != null)
- val = date.getTime();
- else if ((date = dateFormat2.parse(str, new ParsePosition(0))) != null)
- val = date.getTime();
- else if ((date = dateFormat3.parse(str, new ParsePosition(0))) != null)
- val = date.getTime();
- }
- return val;
- }
-
- public String getHeaderFieldKey(int n)
- {
- // Subclasses for specific protocols override this.
- return null;
- }
-
- public Object getContent() throws IOException
- {
- // FIXME: Doc indicates that other criteria should be applied as
- // heuristics to determine the true content type, e.g. see
- // guessContentTypeFromName() and guessContentTypeFromStream methods
- // as well as FileNameMap class & fileNameMap field & get/set methods.
- String cType = getContentType();
- contentHandler = setContentHandler(cType);
- if (contentHandler == null)
- return getInputStream();
-
- return contentHandler.getContent(this);
- }
-
-// TODO12: public Permission getPermission() throws IOException
-// {
-// // Subclasses may override this.
-// return java.security.AllPermission;
-// }
-
- public InputStream getInputStream() throws IOException
- {
- // Subclasses for specific protocols override this.
- throw new UnknownServiceException("Protocol " + url.getProtocol() +
- " does not support input.");
- }
-
- public OutputStream getOutputStream() throws IOException
- {
- // Subclasses for specific protocols override this.
- throw new UnknownServiceException("Protocol " + url.getProtocol() +
- " does not support output.");
- }
-
- public String toString()
- {
- return this.getClass().getName() + ":" + url.toString();
- }
-
- public void setDoInput(boolean doinput)
- {
- if (connected)
- throw new IllegalAccessError("Already connected");
-
- doInput = doinput;
- }
-
- public boolean getDoInput()
- {
- return doInput;
- }
-
- public void setDoOutput(boolean dooutput)
- {
- if (connected)
- throw new IllegalAccessError("Already connected");
-
- doOutput = dooutput;
- if (doOutput)
- doInput = false;
- }
-
- public boolean getDoOutput()
- {
- return doOutput;
- }
-
- public void setAllowUserInteraction(boolean allowuserinteraction)
- {
- if (connected)
- throw new IllegalAccessError("Already connected");
-
- allowUserInteraction = allowuserinteraction;
- }
-
- public boolean getAllowUserInteraction()
- {
- return allowUserInteraction;
- }
-
- public static void
- setDefaultAllowUserInteraction(boolean defaultallowuserinteraction)
- {
- defaultAllowUserInteraction = defaultallowuserinteraction;
- }
-
- public static boolean getDefaultAllowUserInteraction()
- {
- return defaultAllowUserInteraction;
- }
-
- public void setUseCaches(boolean usecaches)
- {
- if (connected)
- throw new IllegalAccessError("Already connected");
-
- useCaches = usecaches;
- }
-
- public boolean getUseCaches()
- {
- return useCaches;
- }
-
- public void setIfModifiedSince(long ifmodifiedsince)
- {
- if (connected)
- throw new IllegalAccessError("Already connected");
-
- ifModifiedSince = ifmodifiedsince;
- }
-
- public long getIfModifiedSince()
- {
- return ifModifiedSince;
- }
-
- public boolean getDefaultUseCaches()
- {
- return defaultUseCaches;
- }
-
- public void setDefaultUseCaches(boolean defaultusecaches)
- {
- defaultUseCaches = defaultusecaches;
- }
-
- public void setRequestProperty(String key, String value)
- {
- // Do nothing unless overridden by subclasses that support setting
- // header fields in the request.
- }
-
- public String getRequestProperty(String key)
- {
- // Overridden by subclasses that support reading header fields from the
- // request.
- return null;
- }
-
- public static void setDefaultRequestProperty(String key, String value)
- {
- // Do nothing unless overridden by subclasses that support setting
- // default request properties.
- }
-
- public static String getDefaultRequestProperty(String key)
- {
- // Overridden by subclasses that support default request properties.
- return null;
- }
-
- public static void setContentHandlerFactory(ContentHandlerFactory fac)
- {
- if (factory != null)
- throw new Error("ContentHandlerFactory already set");
-
- // Throw an exception if an extant security mgr precludes
- // setting the factory.
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkSetFactory();
- factory = fac;
- }
-
- protected static String guessContentTypeFromName(String fname)
- {
- int dot = fname.lastIndexOf (".");
-
- if (dot != -1)
- {
- if (dot == fname.length())
- return ("application/octet-stream");
- else
- fname = fname.substring (dot + 1);
- }
-
- String type = MimeTypes.getMimeTypeFromExtension (fname);
-
- if (type == null)
- return("application/octet-stream");
-
- return(type);
- }
-
-// TODO: public static String guessContentTypeFromStream(InputStream is)
-// throws IOException
-// {
-// }
-
-// TODO12: protected void parseURL(URL u, String spec, int start, int limit)
-
- // JDK1.2
- public static FileNameMap getFileNameMap()
- {
- return fileNameMap;
- }
-
- // JDK1.2
- public static void setFileNameMap(FileNameMap map)
- {
- // Throw an exception if an extant security mgr precludes
- // setting the factory.
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkSetFactory();
-
- fileNameMap = map;
- }
-
- private ContentHandler setContentHandler(String contentType)
- {
- ContentHandler handler;
-
- // No content type so just handle it as the default.
- if (contentType == null || contentType == "")
- return null;
-
- // See if a handler has been cached for this content type.
- // For efficiency, if a content type has been searched for but not
- // found, it will be in the hash table but as the contentType String
- // instead of a ContentHandler.
- if ((handler = (ContentHandler) handlers.get(contentType)) != null)
- if (handler instanceof ContentHandler)
- return handler;
- else
- return null;
-
- // If a non-default factory has been set, use it to find the content type.
- if (factory != null)
- handler = factory.createContentHandler(contentType);
-
- // Non-default factory may have returned null or a factory wasn't set.
- // Use the default search algorithm to find a handler for this content type.
- if (handler == null)
- {
- // Get the list of packages to check and append our default handler
- // to it, along with the JDK specified default as a last resort.
- // Except in very unusual environments the JDK specified one shouldn't
- // ever be needed (or available).
- String propVal = System.getProperty("java.content.handler.pkgs");
- propVal = (propVal == null) ? "" : (propVal + "|");
- propVal = propVal + "gnu.gcj.content|sun.net.www.content";
-
- // Replace the '/' character in the content type with '.' and
- // all other non-alphabetic, non-numeric characters with '_'.
- StringTokenizer pkgPrefix = new StringTokenizer(propVal, "|");
- char[] cArray = contentType.toCharArray();
- for (int i = 0; i < cArray.length; i++)
- {
- if (cArray[i] == '/')
- cArray[i] = '.';
- else if (! ((cArray[i] >= 'A' && cArray[i] <= 'Z') ||
- (cArray[i] >= 'a' && cArray[i] <= 'z') ||
- (cArray[i] >= '0' && cArray[i] <= '9')))
- cArray[i] = '_';
- }
- String contentClass = new String(cArray);
-
- // See if a class of this content type exists in any of the packages.
- do
- {
- String facName = pkgPrefix.nextToken() + "." + contentClass;
- try
- {
- handler =
- (ContentHandler) Class.forName(facName).newInstance();
- }
- catch (Exception e)
- {
- // Can't instantiate; handler still null, go on to next element.
- }
- } while ((handler == null ||
- ! (handler instanceof ContentHandler)) &&
- pkgPrefix.hasMoreTokens());
- }
-
- // Update the hashtable with the new content handler.
- if (handler != null && handler instanceof ContentHandler)
- {
- handlers.put(contentType, handler);
- return handler;
- }
-
- // For efficiency on subsequent searches, put a dummy entry in the hash
- // table for content types that don't have a non-default ContentHandler.
- handlers.put(contentType, contentType);
- return null;
- }
-
- // We don't put these in a static initializer, because it creates problems
- // with initializer co-dependency: SimpleDateFormat's constructors eventually
- // depend on URLConnection (via the java.text.*Symbols classes).
- private synchronized void initializeDateFormats()
- {
- if (dateformats_initialized)
- return;
- locale = new Locale("En", "Us", "Unix");
- dateFormat1 = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
- locale);
- dateFormat2 = new SimpleDateFormat("EEEE, dd-MMM-yy hh:mm:ss 'GMT'",
- locale);
- dateFormat3 = new SimpleDateFormat("EEE MMM d hh:mm:ss yyyy", locale);
- dateformats_initialized = true;
- }
-}
diff --git a/libjava/java/net/URLDecoder.java b/libjava/java/net/URLDecoder.java
deleted file mode 100644
index 5059a962db7..00000000000
--- a/libjava/java/net/URLDecoder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// URLDecoder.java - Provides a method for decoding strings according to
-// application/x-www-form-urlencoded MIME type.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-import java.io.UnsupportedEncodingException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date April 22, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public class URLDecoder
-{
- // This method, per the JCL, is conservative in that it encodes
- // some "allowable" characters as % triplets.
- public static String decode(String s) throws Exception
- {
- String str = s.replace('+', ' ');
- String result = "";
- int i;
- int start = 0;
- while ((i = str.indexOf('%', start)) >= 0)
- {
- result = result + str.substring(start, i) +
- (char) Integer.parseInt(str.substring(i + 1, i + 3), 16);
- start = i + 3;
- }
-
- if (start < str.length())
- result = result + str.substring(start);
-
- return result;
- }
-}
diff --git a/libjava/java/net/URLEncoder.java b/libjava/java/net/URLEncoder.java
deleted file mode 100644
index 6590dcf8feb..00000000000
--- a/libjava/java/net/URLEncoder.java
+++ /dev/null
@@ -1,71 +0,0 @@
-// URLEncoder.java - Provides a method for encoding strings according to
-// application/x-www-form-urlencoded MIME type.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-import java.io.UnsupportedEncodingException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date April 22, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class URLEncoder
-{
- // This method, per the JCL, is conservative in that it encodes
- // some "allowable" characters as % triplets.
- public static String encode(String s)
- {
- // Get the bytes in ISO-Latin-1 (i.e. 8859_1) per the JCL.
- // Even though it is the default in most cases, it's specified here
- // just in case System.getProperty("file.encoding") is not "8859_1".
- String result = "";
- try
- {
- byte[] buf = s.getBytes("8859_1");
- int start = 0;
- for (int i = 0; i < buf.length; i++)
- // For efficiency, check the byte in order of most likely
- // possibility so as to minimize the number of comparisons.
- // Hence, exclude all the alphanumeric & allowed special chars first.
- if ((buf[i] >= 'a' && buf[i] <= 'z') ||
- (buf[i] >= 'A' && buf[i] <= 'Z') ||
- (buf[i] >= '0' && buf[i] <= '9') ||
- buf[i] == '-' || buf[i] == '_' || buf[i] == '.' || buf[i] == '*')
- ; // This is the most likely case so exclude first for efficiency.
- else if (buf[i] == ' ')
- buf[i] = (byte) '+'; // Replace space char with plus symbol.
- else
- {
- result = result + new String(buf, start, i - start, "8859_1") +
- "%" + Integer.toHexString(((int) buf[i]) & 0xFF);
- start = i + 1;
- }
-
- // Append remainder of allowable chars from the string, if any.
- if (start < buf.length)
- result = result +
- new String(buf, start, buf.length - start, "8859_1");
- }
- catch (UnsupportedEncodingException ex)
- {
- // This should never happen as "8859_1" is the default encoding.
- return s;
- }
-
- return result;
- }
-}
diff --git a/libjava/java/net/URLStreamHandler.java b/libjava/java/net/URLStreamHandler.java
deleted file mode 100644
index 0060b4ea688..00000000000
--- a/libjava/java/net/URLStreamHandler.java
+++ /dev/null
@@ -1,156 +0,0 @@
-// URLStreamHandler.java - Superclass of all stream protocol handlers.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 4, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public abstract class URLStreamHandler
-{
- protected abstract URLConnection openConnection(URL u)
- throws java.io.IOException;
-
- protected void parseURL(URL u, String spec, int start, int limit)
- {
- String host = u.getHost();
- int port = u.getPort();
- String file = u.getFile();
-
- /* TBD: The JDK 1.2 doc specifically says that limit is the position
- * to stop parsing at and that it will be either the end of the string
- * or the position of '#'; thus the doc infers that this method does
- * not set the ref.
- */
- if (spec.regionMatches (start, "//", 0, 2))
- {
- int hostEnd;
- int colon;
-
- start += 2;
- int slash = spec.indexOf('/', start);
- if (slash >= 0)
- hostEnd = slash;
- else
- hostEnd = limit;
-
- host = spec.substring (start, hostEnd);
-
- // Look for optional port number. It is valid for the non-port
- // part of the host name to be null (e.g. a URL "http://:80").
- // TBD: JDK 1.2 in this case sets host to null rather than "";
- // this is undocumented and likely an unintended side effect in 1.2
- // so we'll be simple here and stick with "". Note that
- // "http://" or "http:///" produce a "" host in JDK 1.2.
- if ((colon = host.indexOf(':')) >= 0)
- {
- try
- {
- port = Integer.parseInt(host.substring(colon + 1));
- }
- catch (NumberFormatException e)
- {
- ; // Ignore invalid port values; port is already set to u's
- // port.
- }
- host = host.substring(0, colon);
- }
- file = null;
- start = hostEnd;
- }
- else if (host == null)
- host = "";
-
- if (start < limit && spec.charAt(start) == '/')
- {
- // This is an absolute path name; ignore any file context.
- file = spec.substring(start, limit);
- }
- else if (file == null || file.length() <= 0)
- {
- // No file context available; just spec for file.
- file = "/" + spec.substring(start, limit);
- }
- else if (start < limit)
- {
- // Context is available, but only override it if there is a new file.
- // FIXME: unsure to what extent `/` and File.separatorChar
- // can mix in URLs. Ignore File.separatorChar for now.
- file = file.substring(0, file.lastIndexOf('/'))
- + "/" + spec.substring(start, limit);
- }
-
- int index;
-
- // Replace "/./" with "/". This probably isn't very efficient in
- // the general case, but it's probably not bad most of the time.
- while ((index = file.indexOf("/./")) >= 0)
- file = file.substring(0, index) + file.substring(index + 2);
-
- // Process "/../" correctly. This probably isn't very efficient in
- // the general case, but it's probably not bad most of the time.
- while ((index = file.indexOf("/../")) >= 0)
- {
- // Strip of the previous directory - if it exists.
- int previous = file.lastIndexOf('/', index - 1);
- if (previous >= 0)
- file = file.substring(0, previous) + file.substring(index + 3);
- else
- file = file.substring(index + 3);
- }
-
- u.set(u.getProtocol(), host, port, file, u.getRef());
- }
-
- protected void setURL(URL u, String protocol, String host, int port,
- String file, String ref)
- {
- u.set(protocol, host, port, file, ref);
- }
-
- protected String toExternalForm(URL u)
- {
- String resStr, host, file, ref;
- int port;
-
- resStr = u.getProtocol() + ":";
- host = u.getHost();
- port = u.getPort();
- file = u.getFile();
- ref = u.getRef();
-
- // JDK 1.2 online doc infers that host could be null because it
- // explicitly states that file cannot be null, but is silent on host.
- //
- // Note that this produces different results from JDK 1.2 as JDK 1.2
- // ignores a non-default port if host is null or "". That is inconsistent
- // with the spec since the result of this method is spec'ed so it can be
- // used to construct a new URL that is equivalent to the original.
- if (host == null)
- host = "";
- if (port >= 0 || ! (host.length() == 0))
- resStr = resStr + "//" + host + (port < 0 ? "" : ":" + port);
-
- resStr = resStr + file;
-
- if (ref != null)
- resStr = resStr + "#" + ref;
-
- return resStr;
- }
-}
diff --git a/libjava/java/net/URLStreamHandlerFactory.java b/libjava/java/net/URLStreamHandlerFactory.java
deleted file mode 100644
index a1b85bbcd64..00000000000
--- a/libjava/java/net/URLStreamHandlerFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// URLStreamHandlerFactory.java - Abstract URL Stream Handler factory.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public abstract interface URLStreamHandlerFactory
-{
- public URLStreamHandler createURLStreamHandler(String protocol);
-}
diff --git a/libjava/java/net/UnknownHostException.java b/libjava/java/net/UnknownHostException.java
deleted file mode 100644
index 12936e06761..00000000000
--- a/libjava/java/net/UnknownHostException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// UnknownHostException.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Per Bothner
- * @date January 6, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public class UnknownHostException extends java.io.IOException
-{
- public UnknownHostException ()
- {
- super();
- }
-
- public UnknownHostException (String host)
- {
- super(host);
- }
-}
diff --git a/libjava/java/net/UnknownServiceException.java b/libjava/java/net/UnknownServiceException.java
deleted file mode 100644
index 20b00bd3676..00000000000
--- a/libjava/java/net/UnknownServiceException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// UnknownServiceException.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.net;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 5, 1999.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class UnknownServiceException extends java.io.IOException
-{
- public UnknownServiceException()
- {
- super();
- }
-
- public UnknownServiceException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/net/natInetAddress.cc b/libjava/java/net/natInetAddress.cc
deleted file mode 100644
index a25e643957b..00000000000
--- a/libjava/java/net/natInetAddress.cc
+++ /dev/null
@@ -1,339 +0,0 @@
-// natInetAddress.cc
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT)
-# define _REENTRANT 1
-#endif
-
-#ifdef USE_WINSOCK
-
-#include <windows.h>
-#include <winsock.h>
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif /* MAXHOSTNAMELEN */
-
-#else
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <errno.h>
-
-#include <sys/param.h>
-#include <sys/types.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-
-#endif /* USE_WINSOCK */
-
-#include <gcj/cni.h>
-#include <jvm.h>
-#include <java/net/InetAddress.h>
-#include <java/net/UnknownHostException.h>
-#include <java/lang/SecurityException.h>
-
-#if defined(HAVE_UNAME) && ! defined(HAVE_GETHOSTNAME)
-#include <sys/utsname.h>
-#endif
-
-#ifndef HAVE_GETHOSTNAME_DECL
-extern "C" int gethostname (char *name, int namelen);
-#endif
-
-#ifdef DISABLE_JAVA_NET
-
-jbyteArray
-java::net::InetAddress::aton (jstring)
-{
- return NULL;
-}
-
-JArray<java::net::InetAddress*> *
-java::net::InetAddress::lookup (jstring, java::net::InetAddress *, jboolean)
-{
- return NULL;
-}
-
-jstring
-java::net::InetAddress::getLocalHostname ()
-{
- return NULL;
-}
-
-#else /* DISABLE_JAVA_NET */
-
-jbyteArray
-java::net::InetAddress::aton (jstring host)
-{
- char *hostname;
- char buf[100];
- int len = JvGetStringUTFLength(host);
- if (len < 100)
- hostname = buf;
- else
- hostname = (char*) _Jv_AllocBytesChecked (len+1);
- JvGetStringUTFRegion (host, 0, host->length(), hostname);
- buf[len] = '\0';
- char* bytes = NULL;
- int blen = 0;
-#ifdef HAVE_INET_ATON
- struct in_addr laddr;
- if (inet_aton (hostname, &laddr))
- {
- bytes = (char*) &laddr;
- blen = 4;
- }
-#elif defined(HAVE_INET_ADDR)
-#if ! HAVE_IN_ADDR_T
- typedef jint in_addr_t;
-#endif
- in_addr_t laddr = inet_addr (hostname);
- if (laddr != (in_addr_t)(-1))
- {
- bytes = (char*) &laddr;
- blen = 4;
- }
-#endif
-#ifdef HAVE_INET_PTON
- char inet6_addr[16];
- if (len == 0 && inet_pton (AF_INET6, hostname, inet6_addr) > 0)
- {
- bytes = inet6_addr;
- blen = 16;
- }
-#endif
- if (blen == 0)
- return NULL;
- jbyteArray result = JvNewByteArray (blen);
- memcpy (elements (result), bytes, blen);
- return result;
-}
-
-
-JArray<java::net::InetAddress*> *
-java::net::InetAddress::lookup (jstring host, java::net::InetAddress* iaddr,
- jboolean all)
-{
- struct hostent *hptr = NULL;
-#if defined (HAVE_GETHOSTBYNAME_R) || defined (HAVE_GETHOSTBYADDR_R)
- struct hostent hent_r;
-#if HAVE_STRUCT_HOSTENT_DATA
- struct hostent_data fixed_buffer, *buffer_r = &fixed_buffer;
-#else
-#if defined (__GLIBC__)
- // FIXME: in glibc, gethostbyname_r returns NETDB_INTERNAL to herr and
- // ERANGE to errno if the buffer size is too small, rather than what is
- // expected here. We work around this by setting a bigger buffer size and
- // hoping that it is big enough.
- char fixed_buffer[1024];
-#else
- char fixed_buffer[200];
-#endif
- char *buffer_r = fixed_buffer;
- int size_r = sizeof (fixed_buffer);
-#endif
-#endif
-
- if (host != NULL)
- {
- char *hostname;
- char buf[100];
- int len = JvGetStringUTFLength(host);
- if (len < 100)
- hostname = buf;
- else
- hostname = (char*) _Jv_AllocBytesChecked (len+1);
- JvGetStringUTFRegion (host, 0, host->length(), hostname);
- buf[len] = '\0';
-#ifdef HAVE_GETHOSTBYNAME_R
- while (true)
- {
- int ok;
-#if HAVE_STRUCT_HOSTENT_DATA
- ok = ! gethostbyname_r (hostname, &hent_r, buffer_r);
-#else
- int herr = 0;
-#ifdef GETHOSTBYNAME_R_RETURNS_INT
- ok = ! gethostbyname_r (hostname, &hent_r, buffer_r, size_r,
- &hptr, &herr);
-#else
- hptr = gethostbyname_r (hostname, &hent_r, buffer_r, size_r, &herr);
- ok = hptr != NULL;
-#endif /* GETHOSTNAME_R_RETURNS_INT */
- if (! ok && herr == ERANGE)
- {
- size_r *= 2;
- buffer_r = (char *) _Jv_AllocBytesChecked (size_r);
- }
- else
-#endif /* HAVE_STRUCT_HOSTENT_DATA */
- break;
- }
-#else
- // FIXME: this is insufficient if some other piece of code calls
- // this gethostbyname.
- JvSynchronize sync (java::net::InetAddress::localhostAddress);
- hptr = gethostbyname (hostname);
-#endif /* HAVE_GETHOSTBYNAME_R */
- }
- else
- {
- jbyteArray bytes = iaddr->address;
- char *chars = (char*) elements (bytes);
- int len = bytes->length;
- int type;
- char *val;
- if (len == 4)
- {
- val = chars;
- type = AF_INET;
- }
-#ifdef HAVE_INET6
- else if (len == 16)
- {
- val = (char *) &chars;
- type = AF_INET6;
- }
-#endif /* HAVE_INET6 */
- else
- JvFail ("unrecognized size");
-
-#ifdef HAVE_GETHOSTBYADDR_R
- while (true)
- {
- int ok;
-#if HAVE_STRUCT_HOSTENT_DATA
- ok = ! gethostbyaddr_r (val, len, type, &hent_r, buffer_r);
-#else
- int herr = 0;
-#ifdef GETHOSTBYADDR_R_RETURNS_INT
- ok = ! gethostbyaddr_r (val, len, type, &hent_r,
- buffer_r, size_r, &hptr, &herr);
-#else
- hptr = gethostbyaddr_r (val, len, type, &hent_r,
- buffer_r, size_r, &herr);
- ok = hptr != NULL;
-#endif /* GETHOSTBYADDR_R_RETURNS_INT */
- if (! ok && herr == ERANGE)
- {
- size_r *= 2;
- buffer_r = (char *) _Jv_AllocBytesChecked (size_r);
- }
- else
-#endif /* HAVE_STRUCT_HOSTENT_DATA */
- break;
- }
-#else /* HAVE_GETHOSTBYADDR_R */
- // FIXME: this is insufficient if some other piece of code calls
- // this gethostbyaddr.
- JvSynchronize sync (java::net::InetAddress::localhostAddress);
- hptr = gethostbyaddr (val, len, type);
-#endif /* HAVE_GETHOSTBYADDR_R */
- }
- if (hptr != NULL)
- {
- if (!all)
- host = JvNewStringUTF (hptr->h_name);
- java::lang::SecurityException *ex = checkConnect (host);
- if (ex != NULL)
- {
- if (iaddr == NULL || iaddr->address == NULL)
- JvThrow (ex);
- hptr = NULL;
- }
- }
- if (hptr == NULL)
- {
- if (iaddr != NULL && iaddr->address != NULL)
- {
- iaddr->hostname = iaddr->getHostAddress();
- return NULL;
- }
- else
- JvThrow (new java::net::UnknownHostException(host));
- }
- int count;
- if (all)
- {
- char** ptr = hptr->h_addr_list;
- count = 0;
- while (*ptr++) count++;
- }
- else
- count = 1;
- JArray<java::net::InetAddress*> *result;
- java::net::InetAddress** iaddrs;
- if (all)
- {
- result = java::net::InetAddress::allocArray (count);
- iaddrs = elements (result);
- }
- else
- {
- result = NULL;
- iaddrs = &iaddr;
- }
-
- for (int i = 0; i < count; i++)
- {
- if (iaddrs[i] == NULL)
- iaddrs[i] = new java::net::InetAddress (NULL, NULL);
- if (iaddrs[i]->hostname == NULL)
- iaddrs[i]->hostname = host;
- if (iaddrs[i]->address == NULL)
- {
- char *bytes = hptr->h_addr_list[i];
- iaddrs[i]->address = JvNewByteArray (hptr->h_length);
- memcpy (elements (iaddrs[i]->address), bytes, hptr->h_length);
- }
- }
- return result;
-}
-
-jstring
-java::net::InetAddress::getLocalHostname ()
-{
- char *chars;
-#ifdef HAVE_GETHOSTNAME
- char buffer[MAXHOSTNAMELEN];
- if (gethostname (buffer, MAXHOSTNAMELEN))
- return NULL;
- chars = buffer;
-#elif HAVE_UNAME
- struct utsname stuff;
- if (uname (&stuff) != 0)
- return NULL;
- chars = stuff.nodename;
-#else
- return NULL;
-#endif
- // It is admittedly non-optimal to convert the hostname to Unicode
- // only to convert it back in getByName, but simplicity wins. Note
- // that unless there is a SecurityManager, we only get called once
- // anyway, thanks to the InetAddress.localhost cache.
- return JvNewStringUTF (chars);
-}
-
-#endif /* DISABLE_JAVA_NET */
diff --git a/libjava/java/net/natPlainDatagramSocketImpl.cc b/libjava/java/net/natPlainDatagramSocketImpl.cc
deleted file mode 100644
index 94383f8309d..00000000000
--- a/libjava/java/net/natPlainDatagramSocketImpl.cc
+++ /dev/null
@@ -1,632 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-#ifdef USE_WINSOCK
-#include <windows.h>
-#include <winsock.h>
-#include <errno.h>
-#include <string.h>
-#ifndef ENOPROTOOPT
-#define ENOPROTOOPT 109
-#endif
-#else /* USE_WINSOCK */
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#include <sys/time.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#include <errno.h>
-#include <string.h>
-#endif /* USE_WINSOCK */
-
-#if HAVE_BSTRING_H
-// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
-#include <bstring.h>
-#endif
-
-#include <gcj/cni.h>
-#include <java/io/IOException.h>
-#include <java/io/FileDescriptor.h>
-#include <java/io/InterruptedIOException.h>
-#include <java/net/BindException.h>
-#include <java/net/SocketException.h>
-#include <java/net/PlainDatagramSocketImpl.h>
-#include <java/net/InetAddress.h>
-#include <java/net/DatagramPacket.h>
-#include <java/lang/InternalError.h>
-#include <java/lang/Object.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Integer.h>
-
-#define BooleanClass _CL_Q34java4lang7Boolean
-extern java::lang::Class BooleanClass;
-#define IntegerClass _CL_Q34java4lang7Integer
-extern java::lang::Class IntegerClass;
-
-#ifdef DISABLE_JAVA_NET
-
-void
-java::net::PlainDatagramSocketImpl::create ()
-{
- JvThrow (new SocketException (JvNewStringLatin1 ("DatagramSocketImpl.create: unimplemented")));
-}
-
-void
-java::net::PlainDatagramSocketImpl::bind (jint, java::net::InetAddress *)
-{
- JvThrow (new BindException (JvNewStringLatin1 ("DatagramSocketImpl.bind: unimplemented")));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *)
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("DatagramSocketImpl.peek: unimplemented")));
-}
-
-void
-java::net::PlainDatagramSocketImpl::send (java::net::DatagramPacket *)
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("DatagramSocketImpl.send: unimplemented")));
-}
-
-void
-java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *)
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("DatagramSocketImpl.receive: unimplemented")));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setTimeToLive (jint)
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("DatagramSocketImpl.setTimeToLive: unimplemented")));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::getTimeToLive ()
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("DatagramSocketImpl.getTimeToLive: unimplemented")));
-}
-
-void
-java::net::PlainDatagramSocketImpl::mcastGrp (java::net::InetAddress *,
- jboolean)
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("DatagramSocketImpl.mcastGrp: unimplemented")));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setOption (jint, java::lang::Object *)
-{
- JvThrow (new SocketException (JvNewStringLatin1 ("DatagramSocketImpl.setOption: unimplemented")));
-}
-
-java::lang::Object *
-java::net::PlainDatagramSocketImpl::getOption (jint)
-{
- JvThrow (new SocketException (JvNewStringLatin1 ("DatagramSocketImpl.getOption: unimplemented")));
-}
-
-#else /* DISABLE_JAVA_NET */
-
-#ifndef HAVE_SOCKLEN_T
-typedef int socklen_t;
-#endif
-
-union SockAddr
-{
- struct sockaddr_in address;
-#ifdef HAVE_INET6
- struct sockaddr_in6 address6;
-#endif
-};
-
-union McastReq
-{
-#if HAVE_STRUCT_IP_MREQ
- struct ip_mreq mreq;
-#endif
-#ifdef HAVE_INET6
- struct ipv6_mreq mreq6;
-#endif
-};
-
-union InAddr
-{
- struct in_addr addr;
-#ifdef HAVE_INET6
- struct in6_addr addr6;
-#endif
-};
-
-
-// FIXME: routines here and/or in natPlainSocketImpl.cc could throw
-// NoRouteToHostException; also consider UnknownHostException, ConnectException.
-
-void
-java::net::PlainDatagramSocketImpl::create ()
-{
- int sock = ::socket (AF_INET, SOCK_DGRAM, 0);
- if (sock < 0)
- {
- char* strerr = strerror (errno);
- JvThrow (new java::net::SocketException (JvNewStringUTF (strerr)));
- }
- fnum = sock;
- fd = new java::io::FileDescriptor (sock);
-}
-
-void
-java::net::PlainDatagramSocketImpl::bind (jint lport,
- java::net::InetAddress *host)
-{
- // FIXME: prob. need to do a setsockopt with SO_BROADCAST to allow multicast.
- union SockAddr u;
- struct sockaddr *ptr = (struct sockaddr *) &u.address;
- // FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
- jbyteArray haddress = host->address;
- jbyte *bytes = elements (haddress);
- int len = haddress->length;
-
- if (len == 4)
- {
- u.address.sin_family = AF_INET;
- if (host != NULL)
- memcpy (&u.address.sin_addr, bytes, len);
- else
- u.address.sin_addr.s_addr = htonl (INADDR_ANY);
- len = sizeof (struct sockaddr_in);
- u.address.sin_port = htons (lport);
- }
-#ifdef HAVE_INET6
- else if (len == 16)
- {
- u.address6.sin6_family = AF_INET6;
- memcpy (&u.address6.sin6_addr, bytes, len);
- len = sizeof (struct sockaddr_in6);
- u.address6.sin6_port = htons (lport);
- }
-#endif
- else
- goto error;
- if (::bind (fnum, ptr, len) == 0)
- {
- socklen_t addrlen = sizeof(u);
- if (lport != 0)
- localPort = lport;
- else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
- localPort = ntohs (u.address.sin_port);
- else
- goto error;
- return;
- }
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::net::BindException (JvNewStringUTF (strerr)));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *i)
-{
- // FIXME: Deal with Multicast and if the socket is connected.
- union SockAddr u;
- socklen_t addrlen = sizeof(u);
- ssize_t retlen =
- ::recvfrom (fnum, (char *) NULL, 0, MSG_PEEK, (sockaddr*) &u,
- &addrlen);
- if (retlen < 0)
- goto error;
- // FIXME: Deal with Multicast addressing and if the socket is connected.
- jbyteArray raddr;
- jint rport;
- if (u.address.sin_family == AF_INET)
- {
- raddr = JvNewByteArray (4);
- memcpy (elements (raddr), &u.address.sin_addr, 4);
- rport = ntohs (u.address.sin_port);
- }
-#ifdef HAVE_INET6
- else if (u.address.sin_family == AF_INET6)
- {
- raddr = JvNewByteArray (16);
- memcpy (elements (raddr), &u.address6.sin6_addr, 16);
- rport = ntohs (u.address6.sin6_port);
- }
-#endif
- else
- goto error;
- i->address = raddr;
- return rport;
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
-}
-
-void
-java::net::PlainDatagramSocketImpl::send (java::net::DatagramPacket *p)
-{
- // FIXME: Deal with Multicast and if the socket is connected.
- jint rport = p->getPort();
- union SockAddr u;
- jbyteArray haddress = p->getAddress()->address;
- jbyte *bytes = elements (haddress);
- int len = haddress->length;
- struct sockaddr *ptr = (struct sockaddr *) &u.address;
- jbyte *dbytes = elements (p->getData());
- if (len == 4)
- {
- u.address.sin_family = AF_INET;
- memcpy (&u.address.sin_addr, bytes, len);
- len = sizeof (struct sockaddr_in);
- u.address.sin_port = htons (rport);
- }
-#ifdef HAVE_INET6
- else if (len == 16)
- {
- u.address6.sin6_family = AF_INET6;
- memcpy (&u.address6.sin6_addr, bytes, len);
- len = sizeof (struct sockaddr_in6);
- u.address6.sin6_port = htons (rport);
- }
-#endif
- else
- goto error;
- if (::sendto (fnum, (char *) dbytes, p->getLength(), 0, ptr, len) >= 0)
- return;
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
-}
-
-void
-java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *p)
-{
- // FIXME: Deal with Multicast and if the socket is connected.
- union SockAddr u;
- socklen_t addrlen = sizeof(u);
- jbyte *dbytes = elements (p->getData());
- ssize_t retlen = 0;
-
- // Do timeouts via select since SO_RCVTIMEO is not always available.
- if (timeout > 0)
- {
- fd_set rset;
- struct timeval tv;
- FD_ZERO(&rset);
- FD_SET(fnum, &rset);
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000;
- int retval;
- if ((retval = select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
- goto error;
- else if (retval == 0)
- JvThrow (new java::io::InterruptedIOException ());
- }
-
- retlen =
- ::recvfrom (fnum, (char *) dbytes, p->getLength(), 0, (sockaddr*) &u,
- &addrlen);
- if (retlen < 0)
- goto error;
- // FIXME: Deal with Multicast addressing and if the socket is connected.
- jbyteArray raddr;
- jint rport;
- if (u.address.sin_family == AF_INET)
- {
- raddr = JvNewByteArray (4);
- memcpy (elements (raddr), &u.address.sin_addr, 4);
- rport = ntohs (u.address.sin_port);
- }
-#ifdef HAVE_INET6
- else if (u.address.sin_family == AF_INET6)
- {
- raddr = JvNewByteArray (16);
- memcpy (elements (raddr), &u.address6.sin6_addr, 16);
- rport = ntohs (u.address6.sin6_port);
- }
-#endif
- else
- goto error;
- p->setAddress (new InetAddress (raddr, NULL));
- p->setPort (rport);
- p->setLength ((jint) retlen);
- return;
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setTimeToLive (jint ttl)
-{
- // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
- char val = (char) ttl;
- socklen_t val_len = sizeof(val);
- if (::setsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, val_len) == 0)
- return;
-
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::getTimeToLive ()
-{
- // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
- char val;
- socklen_t val_len = sizeof(val);
- if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, &val_len) == 0)
- return ((int) val) & 0xFF;
-
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
-}
-
-void
-java::net::PlainDatagramSocketImpl::mcastGrp (java::net::InetAddress *inetaddr,
- jboolean join)
-{
- union McastReq u;
- jbyteArray haddress = inetaddr->address;
- jbyte *bytes = elements (haddress);
- int len = haddress->length;
- int level, opname;
- const char *ptr;
- if (0)
- ;
-#if HAVE_STRUCT_IP_MREQ
- else if (len == 4)
- {
- level = IPPROTO_IP;
- opname = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
- memcpy (&u.mreq.imr_multiaddr, bytes, len);
- // FIXME: If a non-default interface is set, use it; see Stevens p. 501.
- // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
- u.mreq.imr_interface.s_addr = htonl (INADDR_ANY);
- len = sizeof (struct ip_mreq);
- ptr = (const char *) &u.mreq;
- }
-#endif
-#ifdef HAVE_INET6
- else if (len == 16)
- {
- level = IPPROTO_IPV6;
- opname = join ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP;
- memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
- // FIXME: If a non-default interface is set, use it; see Stevens p. 501.
- // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
- u.mreq6.ipv6mr_interface = 0;
- len = sizeof (struct ipv6_mreq);
- ptr = (const char *) &u.mreq6;
- }
-#endif
- else
- goto error;
- if (::setsockopt (fnum, level, opname, ptr, len) == 0)
- return;
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setOption (jint optID,
- java::lang::Object *value)
-{
- int val;
- socklen_t val_len = sizeof (val);
-
- if (_Jv_IsInstanceOf (value, &BooleanClass))
- {
- java::lang::Boolean *boolobj =
- static_cast<java::lang::Boolean *> (value);
- val = boolobj->booleanValue() ? 1 : 0;
- }
- else if (_Jv_IsInstanceOf (value, &IntegerClass))
- {
- java::lang::Integer *intobj =
- static_cast<java::lang::Integer *> (value);
- val = (int) intobj->intValue();
- }
- // Else assume value to be an InetAddress for use with IP_MULTICAST_IF.
-
- switch (optID)
- {
- case _Jv_TCP_NODELAY_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("TCP_NODELAY not valid for UDP")));
- return;
- case _Jv_SO_LINGER_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("SO_LINGER not valid for UDP")));
- return;
- case _Jv_SO_SNDBUF_ :
- case _Jv_SO_RCVBUF_ :
-#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
- int opt;
- optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
- if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
- goto error;
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported")));
-#endif
- return;
- case _Jv_SO_REUSEADDR_ :
-#if defined(SO_REUSEADDR)
- if (::setsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
- val_len) != 0)
- goto error;
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("SO_REUSEADDR not supported")));
-#endif
- return;
- case _Jv_SO_BINDADDR_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("SO_BINDADDR: read only option")));
- return;
- case _Jv_IP_MULTICAST_IF_ :
- union InAddr u;
- jbyteArray haddress;
- jbyte *bytes;
- int len;
- int level, opname;
- const char *ptr;
-
- haddress = ((java::net::InetAddress *) value)->address;
- bytes = elements (haddress);
- len = haddress->length;
- if (len == 4)
- {
- level = IPPROTO_IP;
- opname = IP_MULTICAST_IF;
- memcpy (&u.addr, bytes, len);
- len = sizeof (struct in_addr);
- ptr = (const char *) &u.addr;
- }
-#ifdef HAVE_INET6
- else if (len == 16)
- {
- level = IPPROTO_IPV6;
- opname = IPV6_MULTICAST_IF;
- memcpy (&u.addr6, bytes, len);
- len = sizeof (struct in6_addr);
- ptr = (const char *) &u.addr6;
- }
-#endif
- else
- goto error;
- if (::setsockopt (fnum, level, opname, ptr, len) != 0)
- goto error;
- return;
- case _Jv_SO_TIMEOUT_ :
- timeout = val;
- return;
- default :
- errno = ENOPROTOOPT;
- }
-
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::net::SocketException (JvNewStringUTF (strerr)));
-}
-
-java::lang::Object *
-java::net::PlainDatagramSocketImpl::getOption (jint optID)
-{
- int val;
- socklen_t val_len = sizeof(val);
- union SockAddr u;
- socklen_t addrlen = sizeof(u);
-
- switch (optID)
- {
- case _Jv_TCP_NODELAY_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("TCP_NODELAY not valid for UDP")));
- break;
-
- case _Jv_SO_LINGER_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("SO_LINGER not valid for UDP")));
- break;
- case _Jv_SO_RCVBUF_ :
- case _Jv_SO_SNDBUF_ :
-#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
- int opt;
- optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
- if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
- goto error;
- else
- return new java::lang::Integer (val);
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported")));
-#endif
- break;
- case _Jv_SO_BINDADDR_:
- // cache the local address
- if (localAddress == NULL)
- {
- jbyteArray laddr;
- if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != 0)
- goto error;
- if (u.address.sin_family == AF_INET)
- {
- laddr = JvNewByteArray (4);
- memcpy (elements (laddr), &u.address.sin_addr, 4);
- }
-#ifdef HAVE_INET6
- else if (u.address.sin_family == AF_INET6)
- {
- laddr = JvNewByteArray (16);
- memcpy (elements (laddr), &u.address6.sin6_addr, 16);
- }
-#endif
- else
- goto error;
- localAddress = new java::net::InetAddress (laddr, NULL);
- }
- return localAddress;
- break;
- case _Jv_SO_REUSEADDR_ :
-#if defined(SO_REUSEADDR)
- if (::getsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
- &val_len) != 0)
- goto error;
- return new java::lang::Boolean (val != 0);
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("SO_REUSEADDR not supported")));
-#endif
- break;
- case _Jv_IP_MULTICAST_IF_ :
-#ifdef HAVE_INET_NTOA
- struct in_addr inaddr;
- socklen_t inaddr_len;
- char *bytes;
-
- inaddr_len = sizeof(inaddr);
- if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
- &inaddr_len) != 0)
- goto error;
-
- bytes = inet_ntoa (inaddr);
-
- return java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
-#else
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("IP_MULTICAST_IF: not available - no inet_ntoa()")));
-#endif
- break;
- case _Jv_SO_TIMEOUT_ :
- return new java::lang::Integer (timeout);
- break;
- default :
- errno = ENOPROTOOPT;
- }
-
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::net::SocketException (JvNewStringUTF (strerr)));
-}
-
-#endif /* DISABLE_JAVA_NET */
diff --git a/libjava/java/net/natPlainSocketImpl.cc b/libjava/java/net/natPlainSocketImpl.cc
deleted file mode 100644
index 52187461f49..00000000000
--- a/libjava/java/net/natPlainSocketImpl.cc
+++ /dev/null
@@ -1,477 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-
-#ifndef DISABLE_JAVA_NET
-#ifdef USE_WINSOCK
-#include <windows.h>
-#include <winsock.h>
-#include <errno.h>
-#include <string.h>
-#ifndef ENOPROTOOPT
-#define ENOPROTOOPT 109
-#endif
-#else /* USE_WINSOCK */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <errno.h>
-#include <string.h>
-#endif /* USE_WINSOCK */
-#endif /* DISABLE_JAVA_NET */
-
-#if HAVE_BSTRING_H
-// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
-#include <bstring.h>
-#endif
-
-#include <gcj/cni.h>
-#include <gcj/javaprims.h>
-#include <java/io/IOException.h>
-#include <java/io/FileDescriptor.h>
-#include <java/io/InterruptedIOException.h>
-#include <java/net/BindException.h>
-#include <java/net/ConnectException.h>
-#include <java/net/PlainSocketImpl.h>
-#include <java/net/InetAddress.h>
-#include <java/net/SocketException.h>
-#include <java/lang/InternalError.h>
-#include <java/lang/Object.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Class.h>
-#include <java/lang/Integer.h>
-
-#define BooleanClass _CL_Q34java4lang7Boolean
-extern java::lang::Class BooleanClass;
-
-#ifdef DISABLE_JAVA_NET
-
-void
-java::net::PlainSocketImpl::create (jboolean)
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("SocketImpl.create: unimplemented")));
-}
-
-void
-java::net::PlainSocketImpl::bind (java::net::InetAddress *, jint)
-{
- JvThrow (new BindException (JvNewStringLatin1 ("SocketImpl.bind: unimplemented")));
-}
-
-void
-java::net::PlainSocketImpl::connect (java::net::InetAddress *, jint)
-{
- JvThrow (new ConnectException (JvNewStringLatin1 ("SocketImpl.connect: unimplemented")));
-}
-
-void
-java::net::PlainSocketImpl::listen (jint)
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("SocketImpl.listen: unimplemented")));
-}
-
-void
-java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *)
-{
- JvThrow (new java::io::IOException (JvNewStringLatin1 ("SocketImpl.accept: unimplemented")));
-}
-
-void
-java::net::PlainSocketImpl::setOption (jint, java::lang::Object *)
-{
- JvThrow (new SocketException (JvNewStringLatin1 ("SocketImpl.setOption: unimplemented")));
-}
-
-java::lang::Object *
-java::net::PlainSocketImpl::getOption (jint)
-{
- JvThrow (new SocketException (JvNewStringLatin1 ("SocketImpl.getOption: unimplemented")));
-}
-
-#else /* DISABLE_JAVA_NET */
-
-#ifndef HAVE_SOCKLEN_T
-typedef int socklen_t;
-#endif
-
-union SockAddr
-{
- struct sockaddr_in address;
-#ifdef HAVE_INET6
- struct sockaddr_in6 address6;
-#endif
-};
-
-void
-java::net::PlainSocketImpl::create (jboolean stream)
-{
- int sock = ::socket (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
- if (sock < 0)
- {
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
- }
- fnum = sock;
- fd = new java::io::FileDescriptor (sock);
-}
-
-void
-java::net::PlainSocketImpl::bind (java::net::InetAddress *host, jint lport)
-{
- union SockAddr u;
- struct sockaddr *ptr = (struct sockaddr *) &u.address;
- jbyteArray haddress = host->address;
- jbyte *bytes = elements (haddress);
- int len = haddress->length;
- int i = 1;
-
- if (len == 4)
- {
- u.address.sin_family = AF_INET;
- if (host != NULL)
- memcpy (&u.address.sin_addr, bytes, len);
- else
- u.address.sin_addr.s_addr = htonl (INADDR_ANY);
- len = sizeof (struct sockaddr_in);
- u.address.sin_port = htons (lport);
- }
-#ifdef HAVE_INET6
- else if (len == 16)
- {
- u.address6.sin6_family = AF_INET6;
- memcpy (&u.address6.sin6_addr, bytes, len);
- len = sizeof (struct sockaddr_in6);
- u.address6.sin6_port = htons (lport);
- }
-#endif
- else
- goto error;
-
- // Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT.
- ::setsockopt(fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i));
-
- if (::bind (fnum, ptr, len) == 0)
- {
- address = host;
- socklen_t addrlen = sizeof(u);
- if (lport != 0)
- localport = lport;
- else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
- localport = ntohs (u.address.sin_port);
- else
- goto error;
- return;
- }
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::net::BindException (JvNewStringUTF (strerr)));
-}
-
-void
-java::net::PlainSocketImpl::connect (java::net::InetAddress *host, jint rport)
-{
- union SockAddr u;
- socklen_t addrlen = sizeof(u);
- jbyteArray haddress = host->address;
- jbyte *bytes = elements (haddress);
- int len = haddress->length;
- struct sockaddr *ptr = (struct sockaddr *) &u.address;
- if (len == 4)
- {
- u.address.sin_family = AF_INET;
- memcpy (&u.address.sin_addr, bytes, len);
- len = sizeof (struct sockaddr_in);
- u.address.sin_port = htons (rport);
- }
-#ifdef HAVE_INET6
- else if (len == 16)
- {
- u.address6.sin6_family = AF_INET6;
- memcpy (&u.address6.sin6_addr, bytes, len);
- len = sizeof (struct sockaddr_in6);
- u.address6.sin6_port = htons (rport);
- }
-#endif
- else
- goto error;
- if (::connect (fnum, ptr, len) != 0)
- goto error;
- address = host;
- port = rport;
- // A bind may not have been done on this socket; if so, set localport now.
- if (localport == 0)
- if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
- localport = ntohs (u.address.sin_port);
- else
- goto error;
- return;
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::net::ConnectException (JvNewStringUTF (strerr)));
-}
-
-void
-java::net::PlainSocketImpl::listen (jint backlog)
-{
- if (::listen (fnum, backlog) != 0)
- {
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
- }
-}
-
-void
-java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
-{
- union SockAddr u;
- socklen_t addrlen = sizeof(u);
- int new_socket = 0;
-
- // Do timeouts via select since SO_RCVTIMEO is not always available.
- if (timeout > 0)
- {
- fd_set rset;
- struct timeval tv;
- FD_ZERO(&rset);
- FD_SET(fnum, &rset);
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000;
- int retval;
- if ((retval = select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
- goto error;
- else if (retval == 0)
- JvThrow (new java::io::InterruptedIOException (
- JvNewStringUTF("Accept timed out")));
- }
-
- new_socket = ::accept (fnum, (sockaddr*) &u, &addrlen);
- if (new_socket < 0)
- goto error;
- jbyteArray raddr;
- jint rport;
- if (u.address.sin_family == AF_INET)
- {
- raddr = JvNewByteArray (4);
- memcpy (elements (raddr), &u.address.sin_addr, 4);
- rport = ntohs (u.address.sin_port);
- }
-#ifdef HAVE_INET6
- else if (u.address.sin_family == AF_INET6)
- {
- raddr = JvNewByteArray (16);
- memcpy (elements (raddr), &u.address6.sin6_addr, 16);
- rport = ntohs (u.address6.sin6_port);
- }
-#endif
- else
- goto error;
- s->fnum = new_socket;
- s->localport = localport;
- s->address = new InetAddress (raddr, NULL);
- s->port = rport;
- s->fd = new java::io::FileDescriptor (new_socket);
- return;
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::io::IOException (JvNewStringUTF (strerr)));
-}
-
-void
-java::net::PlainSocketImpl::setOption (jint optID, java::lang::Object *value)
-{
- int val;
- socklen_t val_len = sizeof (val);
-
- if (_Jv_IsInstanceOf (value, &BooleanClass))
- {
- java::lang::Boolean *boolobj =
- static_cast<java::lang::Boolean *> (value);
- if (boolobj->booleanValue())
- val = 1;
- else
- {
- if (optID == _Jv_SO_LINGER_)
- val = -1;
- else
- val = 0;
- }
- }
- else // assume value is an Integer
- {
- java::lang::Integer *intobj =
- static_cast<java::lang::Integer *> (value);
- val = (int) intobj->intValue();
- }
-
- switch (optID)
- {
- case _Jv_TCP_NODELAY_ :
-#ifdef TCP_NODELAY
- if (::setsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
- val_len) != 0)
- goto error;
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("TCP_NODELAY not supported")));
-#endif /* TCP_NODELAY */
- return;
- case _Jv_SO_LINGER_ :
-#ifdef SO_LINGER
- struct linger l_val;
- l_val.l_onoff = (val != -1);
- l_val.l_linger = val;
- if (::setsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
- sizeof(l_val)) != 0)
- goto error;
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("SO_LINGER not supported")));
-#endif /* SO_LINGER */
- return;
- case _Jv_SO_SNDBUF_ :
- case _Jv_SO_RCVBUF_ :
-#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
- int opt;
- optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
- if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
- goto error;
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported")));
-#endif
- return;
- case _Jv_SO_BINDADDR_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("SO_BINDADDR: read only option")));
- return;
- case _Jv_IP_MULTICAST_IF_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP")));
- return;
- case _Jv_SO_REUSEADDR_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("SO_REUSEADDR: not valid for TCP")));
- return;
- case _Jv_SO_TIMEOUT_ :
- timeout = val;
- return;
- default :
- errno = ENOPROTOOPT;
- }
-
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::net::SocketException (JvNewStringUTF (strerr)));
-}
-
-java::lang::Object *
-java::net::PlainSocketImpl::getOption (jint optID)
-{
- int val;
- socklen_t val_len = sizeof(val);
- union SockAddr u;
- socklen_t addrlen = sizeof(u);
- struct linger l_val;
- socklen_t l_val_len = sizeof(l_val);
-
- switch (optID)
- {
-#ifdef TCP_NODELAY
- case _Jv_TCP_NODELAY_ :
- if (::getsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
- &val_len) != 0)
- goto error;
- else
- return new java::lang::Boolean (val != 0);
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("TCP_NODELAY not supported")));
-#endif
- break;
-
- case _Jv_SO_LINGER_ :
-#ifdef SO_LINGER
- if (::getsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
- &l_val_len) != 0)
- goto error;
- if (l_val.l_onoff)
- return new java::lang::Integer (l_val.l_linger);
- else
- return new java::lang::Boolean ((__java_boolean)false);
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("SO_LINGER not supported")));
-#endif
- break;
- case _Jv_SO_RCVBUF_ :
- case _Jv_SO_SNDBUF_ :
-#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
- int opt;
- optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
- if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
- goto error;
- else
- return new java::lang::Integer (val);
-#else
- JvThrow (new java::lang::InternalError (
- JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported")));
-#endif
- break;
- case _Jv_SO_BINDADDR_:
- // cache the local address
- if (localAddress == NULL)
- {
- jbyteArray laddr;
- if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != 0)
- goto error;
- if (u.address.sin_family == AF_INET)
- {
- laddr = JvNewByteArray (4);
- memcpy (elements (laddr), &u.address.sin_addr, 4);
- }
-#ifdef HAVE_INET6
- else if (u.address.sin_family == AF_INET6)
- {
- laddr = JvNewByteArray (16);
- memcpy (elements (laddr), &u.address6.sin6_addr, 16);
- }
-#endif
- else
- goto error;
- localAddress = new java::net::InetAddress (laddr, NULL);
- }
- return localAddress;
- break;
- case _Jv_IP_MULTICAST_IF_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP")));
- break;
- case _Jv_SO_REUSEADDR_ :
- JvThrow (new java::net::SocketException (
- JvNewStringUTF ("SO_REUSEADDR: not valid for TCP")));
- break;
- case _Jv_SO_TIMEOUT_ :
- return new java::lang::Integer (timeout);
- break;
- default :
- errno = ENOPROTOOPT;
- }
-
- error:
- char* strerr = strerror (errno);
- JvThrow (new java::net::SocketException (JvNewStringUTF (strerr)));
-}
-
-#endif /* DISABLE_JAVA_NET */
diff --git a/libjava/java/security/AlgorithmParameterGeneratorSpi.java b/libjava/java/security/AlgorithmParameterGeneratorSpi.java
deleted file mode 100644
index 476e1bb40f0..00000000000
--- a/libjava/java/security/AlgorithmParameterGeneratorSpi.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
- */
-
-// JDK1.2
-public abstract class AlgorithmParameterGeneratorSpi
-{
- // FIXME: Stubbed.
-}
diff --git a/libjava/java/security/DigestException.java b/libjava/java/security/DigestException.java
deleted file mode 100644
index 8c6b2db8af8..00000000000
--- a/libjava/java/security/DigestException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public class DigestException extends GeneralSecurityException
-{
- public DigestException()
- {
- super();
- }
-
- public DigestException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/GeneralSecurityException.java b/libjava/java/security/GeneralSecurityException.java
deleted file mode 100644
index 9d30737285a..00000000000
--- a/libjava/java/security/GeneralSecurityException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public class GeneralSecurityException extends Exception
-{
- public GeneralSecurityException()
- {
- super();
- }
-
- public GeneralSecurityException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/InvalidAlgorithmParameterException.java b/libjava/java/security/InvalidAlgorithmParameterException.java
deleted file mode 100644
index 35063a961c2..00000000000
--- a/libjava/java/security/InvalidAlgorithmParameterException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 2, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public class InvalidAlgorithmParameterException extends GeneralSecurityException
-{
- public InvalidAlgorithmParameterException()
- {
- super();
- }
-
- public InvalidAlgorithmParameterException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/InvalidKeyException.java b/libjava/java/security/InvalidKeyException.java
deleted file mode 100644
index 3a9a69aade1..00000000000
--- a/libjava/java/security/InvalidKeyException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public class InvalidKeyException extends KeyException
-{
- public InvalidKeyException()
- {
- super();
- }
-
- public InvalidKeyException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/InvalidParameterException.java b/libjava/java/security/InvalidParameterException.java
deleted file mode 100644
index 5ece0126b57..00000000000
--- a/libjava/java/security/InvalidParameterException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public class InvalidParameterException extends IllegalArgumentException
-{
- public InvalidParameterException()
- {
- super();
- }
-
- public InvalidParameterException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/Key.java b/libjava/java/security/Key.java
deleted file mode 100644
index c8598db4c92..00000000000
--- a/libjava/java/security/Key.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public interface Key extends Serializable
-{
- // FIXME: need to set this at some point when serialization is implemented.
- public static final long serialVersionUID = 0;
-
- public String getAlgorithm();
- public String getFormat();
- public byte[] getEncoded();
-}
diff --git a/libjava/java/security/KeyException.java b/libjava/java/security/KeyException.java
deleted file mode 100644
index 634d8ce772e..00000000000
--- a/libjava/java/security/KeyException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public class KeyException extends GeneralSecurityException
-{
- public KeyException()
- {
- super();
- }
-
- public KeyException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/KeyPair.java b/libjava/java/security/KeyPair.java
deleted file mode 100644
index b8b29347333..00000000000
--- a/libjava/java/security/KeyPair.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 9, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public class KeyPair /* FIXME: implements serializable */
-{
- public KeyPair (PublicKey publicKey, PrivateKey privateKey)
- {
- this.publicKey = publicKey;
- this.privateKey = privateKey;
- }
-
- public PublicKey getPublic ()
- {
- return publicKey;
- }
-
- public PrivateKey getPrivate ()
- {
- return privateKey;
- }
-
- // The keys.
- private PublicKey publicKey;
- private PrivateKey privateKey;
-}
diff --git a/libjava/java/security/KeyPairGenerator.java b/libjava/java/security/KeyPairGenerator.java
deleted file mode 100644
index 7954c3270ac..00000000000
--- a/libjava/java/security/KeyPairGenerator.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 10, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Partially implemented to the 1.1 spec.
- * It is known not to comply with the 1.2 spec.
- */
-
-public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
-{
- protected KeyPairGenerator(String algorithm)
- {
- name = algorithm;
- }
-
- public static KeyPairGenerator getInstance(String algorithm)
- throws NoSuchAlgorithmException
- {
- String name = "KeyPairGenerator." + algorithm;
- Provider[] provs = Security.getProviders();
- for (int i = 0; i < provs.length; ++i)
- {
- String val = provs[i].getProperty(name);
- if (val != null)
- {
- try
- {
- return (KeyPairGenerator) Class.forName(val).newInstance();
- }
- catch (Throwable _)
- {
- // We just ignore failures.
- }
- }
- }
-
- throw new NoSuchAlgorithmException(algorithm);
- }
-
- public static KeyPairGenerator getInstance(String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- String name = "KeyPairGenerator." + algorithm;
- Provider p = Security.getProvider(provider);
- if (p == null)
- throw new NoSuchProviderException(provider);
- String val = p.getProperty(name);
- if (val != null)
- {
- try
- {
- return (KeyPairGenerator) Class.forName(val).newInstance();
- }
- catch (Throwable _)
- {
- // Nothing.
- }
- }
-
- throw new NoSuchAlgorithmException(algorithm);
- }
-
- public String getAlgorithm()
- {
- return name;
- }
-
- public abstract void initialize(int strength, SecureRandom random);
- public abstract KeyPair generateKeyPair();
-
- // Algorithm name.
- private String name;
-}
diff --git a/libjava/java/security/KeyPairGeneratorSpi.java b/libjava/java/security/KeyPairGeneratorSpi.java
deleted file mode 100644
index 46520b4aea9..00000000000
--- a/libjava/java/security/KeyPairGeneratorSpi.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Partially implemented.
- */
-
-// JDK1.2
-public abstract class KeyPairGeneratorSpi
-{
- public abstract void initialize(int keysize, SecureRandom random);
- public abstract KeyPair generateKeyPair();
-}
diff --git a/libjava/java/security/MessageDigest.java b/libjava/java/security/MessageDigest.java
deleted file mode 100644
index 04546cdde19..00000000000
--- a/libjava/java/security/MessageDigest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-// MessageDigest.java
-
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 11, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.1 API Specification.
- * Status: Believed complete and correct to 1.1 spec.
- * It is known not to comply with the 1.2 spec.
- */
-
-public abstract class MessageDigest
-{
- protected MessageDigest (String algorithm)
- {
- name = algorithm;
- }
-
- public static MessageDigest getInstance (String algorithm)
- throws NoSuchAlgorithmException
- {
- String name = "MessageDigest." + algorithm;
- Provider[] provs = Security.getProviders ();
- for (int i = 0; i < provs.length; ++i)
- {
- String val = provs[i].getProperty (name);
- if (val != null)
- {
- try
- {
- return (MessageDigest) Class.forName(val).newInstance ();
- }
- catch (Throwable _)
- {
- // We just ignore failures.
- }
- }
- }
-
- throw new NoSuchAlgorithmException (algorithm);
- }
-
- public static MessageDigest getInstance (String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- String name = "MessageDigest." + algorithm;
- Provider p = Security.getProvider (provider);
- if (p == null)
- throw new NoSuchProviderException (provider);
- String val = p.getProperty (name);
- if (val != null)
- {
- try
- {
- return (MessageDigest) Class.forName(val).newInstance ();
- }
- catch (Throwable _)
- {
- // Nothing.
- }
- }
-
- throw new NoSuchAlgorithmException (algorithm);
- }
-
- public void update (byte input)
- {
- engineUpdate (input);
- }
-
- public void update (byte[] input, int offset, int len)
- {
- engineUpdate (input, offset, len);
- }
-
- public void update (byte[] input)
- {
- engineUpdate (input, 0, input.length);
- }
-
- public byte[] digest ()
- {
- return engineDigest ();
- }
-
- public byte[] digest (byte[] input)
- {
- update (input);
- return engineDigest ();
- }
-
- public String toString ()
- {
- // There is no spec for this.
- return "[MessageDigest: " + name + "]";
- }
-
- public static boolean isEqual (byte[] digesta, byte[] digestb)
- {
- if (digesta == digestb)
- return true;
- if (digesta.length != digestb.length)
- return false;
- for (int i = digesta.length - 1; i >= 0; --i)
- if (digesta[i] != digestb[i])
- return false;
- return true;
- }
-
- public void reset ()
- {
- engineReset ();
- }
-
- public final String getAlgorithm ()
- {
- return name;
- }
-
- protected abstract void engineUpdate (byte input);
- protected abstract void engineUpdate (byte input[], int offset, int len);
- protected abstract byte[] engineDigest ();
- protected abstract void engineReset ();
-
- public Object clone() throws CloneNotSupportedException
- {
- return super.clone ();
- }
-
- // Algorithm name.
- private String name;
-}
diff --git a/libjava/java/security/NoSuchAlgorithmException.java b/libjava/java/security/NoSuchAlgorithmException.java
deleted file mode 100644
index d51bf32d832..00000000000
--- a/libjava/java/security/NoSuchAlgorithmException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.security;
-
-public class NoSuchAlgorithmException extends Exception
-{
- public NoSuchAlgorithmException()
- {
- super();
- }
-
- public NoSuchAlgorithmException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/NoSuchProviderException.java b/libjava/java/security/NoSuchProviderException.java
deleted file mode 100644
index d7d0c853efa..00000000000
--- a/libjava/java/security/NoSuchProviderException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 4, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public class NoSuchProviderException extends GeneralSecurityException
-{
- public NoSuchProviderException()
- {
- super();
- }
-
- public NoSuchProviderException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/PrivateKey.java b/libjava/java/security/PrivateKey.java
deleted file mode 100644
index 13b9be34b4d..00000000000
--- a/libjava/java/security/PrivateKey.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public interface PrivateKey extends Key
-{
- // This interface contains no methods or constants. It merely serves
- // to group (and provide type safety for) all private key interfaces.
-}
diff --git a/libjava/java/security/Provider.java b/libjava/java/security/Provider.java
deleted file mode 100644
index ac2cd7864b5..00000000000
--- a/libjava/java/security/Provider.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-import java.util.Properties;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Partially implemented.
- */
-
-public abstract class Provider extends Properties
-{
- // FIXME: Check the following property values against specs!
- protected Provider(String name, double version, String info)
- {
- super();
- put("java.security.Provider.Name", name);
- put("java.security.Provider.Version", Double.toString(version));
- put("java.security.Provider.Info", info);
- }
-
- public String getName()
- {
- return getProperty("java.security.Provider.Name");
- }
-
- public double getVersion()
- {
- return Double.valueOf(getProperty("java.security.Provider.Version")).doubleValue();
- }
-
- public String getInfo()
- {
- return getProperty("java.security.Provider.Info");
- }
-
- public String toString()
- {
- // FIXME: Check this string against the spec.
- return getName() + " " + getProperty("java.security.Provider.Version");
- }
-}
diff --git a/libjava/java/security/PublicKey.java b/libjava/java/security/PublicKey.java
deleted file mode 100644
index 5c30c627e31..00000000000
--- a/libjava/java/security/PublicKey.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public interface PublicKey extends Key
-{
- // This interface contains no methods or constants. It merely serves
- // to group (and provide type safety for) all private key interfaces.
-}
diff --git a/libjava/java/security/SecureClassLoader.java b/libjava/java/security/SecureClassLoader.java
deleted file mode 100644
index f49f8ac214c..00000000000
--- a/libjava/java/security/SecureClassLoader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.security;
-
-// JDK1.2
-public class SecureClassLoader extends ClassLoader
-{
- public SecureClassLoader ()
- {
- this (null);
- }
-
- public SecureClassLoader (ClassLoader parent)
- {
- super (parent);
- }
-}
-
diff --git a/libjava/java/security/SecureRandom.java b/libjava/java/security/SecureRandom.java
deleted file mode 100644
index 6f396dce1e3..00000000000
--- a/libjava/java/security/SecureRandom.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-import java.util.Random;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
- */
-
-public class SecureRandom extends Random
-{
- // FIXME: Stubbed.
-}
diff --git a/libjava/java/security/Security.java b/libjava/java/security/Security.java
deleted file mode 100644
index 87a0088281b..00000000000
--- a/libjava/java/security/Security.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.Vector;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 8, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Still missing the deprecated getAlgorithmProperty method.
- */
-
-public final class Security
-{
- public static int insertProviderAt (Provider provider, int position)
- {
- SecurityManager sm = System.getSecurityManager ();
- if (sm != null)
- {
- // FIXME: need SecurityPermission.
- // sm.checkSecurityAccess ("insertProvider." + provider.getName ());
- }
- if (providers.indexOf (provider) != -1)
- return -1;
- if (position > providers.size ())
- position = providers.size ();
- providers.insertElementAt (provider, position);
- return providers.indexOf (provider);
- }
-
- public static int addProvider (Provider provider)
- {
- return insertProviderAt (provider, providers.size ());
- }
-
- public static void removeProvider (String name)
- {
- SecurityManager sm = System.getSecurityManager ();
- if (sm != null)
- {
- // FIXME: need SecurityPermission.
- // sm.checkSecurityAccess ("removeProvider." + name);
- }
- Provider p = getProvider (name);
- if (p != null)
- providers.removeElement (p);
- }
-
- public static Provider[] getProviders ()
- {
- Provider[] r = new Provider[providers.size ()];
- providers.copyInto (r);
- return r;
- }
-
- public static Provider getProvider (String name)
- {
- Enumeration e = providers.elements ();
- while (e.hasMoreElements ())
- {
- Provider p = (Provider) e.nextElement ();
- if (name.equals (p.getName ()))
- return p;
- }
- return null;
- }
-
- public static String getProperty (String key)
- {
- SecurityManager sm = System.getSecurityManager ();
- if (sm != null)
- {
- // FIXME: need SecurityPermission.
- // sm.checkSecurityAccess ("getProperty." + key);
- }
- return props.getProperty (key);
- }
-
- public static void setProperty (String key, String value)
- {
- SecurityManager sm = System.getSecurityManager ();
- if (sm != null)
- {
- // FIXME: need SecurityPermission.
- // sm.checkSecurityAccess ("setProperty." + key);
- }
- props.setProperty (key, value);
- }
-
- // The providers we list.
- private static Vector providers = new Vector ();
-
- // Security propertiesl
- private static Properties props = new Properties ();
-}
diff --git a/libjava/java/security/Signature.java b/libjava/java/security/Signature.java
deleted file mode 100644
index 760f62551d8..00000000000
--- a/libjava/java/security/Signature.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 11, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.1 API Specification.
- * Status: Believed complete and correct to 1.1 spec.
- * It is known not to comply with the 1.2 spec.
- */
-
-public abstract class Signature
-{
- protected Signature (String name)
- {
- state = UNINITIALIZED;
- this.name = name;
- }
-
- public static Signature getInstance (String algorithm)
- throws NoSuchAlgorithmException
- {
- String name = "Signature." + algorithm;
- Provider[] provs = Security.getProviders ();
- for (int i = 0; i < provs.length; ++i)
- {
- String val = provs[i].getProperty (name);
- if (val != null)
- {
- try
- {
- return (Signature) Class.forName(val).newInstance ();
- }
- catch (Throwable _)
- {
- // We just ignore failures.
- }
- }
- }
-
- throw new NoSuchAlgorithmException (algorithm);
- }
-
- public static Signature getInstance (String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- String name = "Signature." + algorithm;
- Provider p = Security.getProvider (provider);
- if (p == null)
- throw new NoSuchProviderException (provider);
- String val = p.getProperty (name);
- if (val != null)
- {
- try
- {
- return (Signature) Class.forName(val).newInstance ();
- }
- catch (Throwable _)
- {
- // Nothing.
- }
- }
-
- throw new NoSuchAlgorithmException (algorithm);
- }
-
- public final void initVerify (PublicKey publicKey)
- throws InvalidKeyException
- {
- engineInitVerify (publicKey);
- }
-
- public final void initSign (PrivateKey privateKey)
- throws InvalidKeyException
- {
- engineInitSign (privateKey);
- }
-
- public final byte[] sign ()
- throws SignatureException
- {
- return engineSign ();
- }
-
- public final boolean verify (byte[] signature)
- throws SignatureException
- {
- return engineVerify (signature);
- }
-
- public final void update (byte b)
- throws SignatureException
- {
- engineUpdate (b);
- }
-
- public final void update (byte[] data)
- throws SignatureException
- {
- engineUpdate (data, 0, data.length);
- }
-
- public final void update (byte[] data, int off, int len)
- throws SignatureException
- {
- engineUpdate (data, off, len);
- }
-
- public final String getAlgorithm ()
- {
- return name;
- }
-
- public String toString ()
- {
- // There is no spec for this. FIXME: this is a bad choice.
- return name + "; state = " + state;
- }
-
- public final void setParameter (String param, Object value)
- throws InvalidParameterException
- {
- engineSetParameter (param, value);
- }
-
- public final Object getParameter (String param)
- throws InvalidParameterException
- {
- return engineGetParameter (param);
- }
-
- protected abstract void engineInitVerify (PublicKey publicKey)
- throws InvalidKeyException;
- protected abstract void engineInitSign (PrivateKey privateKey)
- throws InvalidKeyException;
- protected abstract void engineUpdate (byte b)
- throws SignatureException;
- protected abstract void engineUpdate (byte[] b, int off, int len)
- throws SignatureException;
- protected abstract byte[] engineSign ()
- throws SignatureException;
- protected abstract boolean engineVerify (byte[] sigBytes)
- throws SignatureException;
- protected abstract void engineSetParameter (String param, Object value)
- throws InvalidParameterException;
- protected abstract Object engineGetParameter (String param)
- throws InvalidParameterException;
-
- public Object clone() throws CloneNotSupportedException
- {
- return super.clone ();
- }
-
- protected static final int UNINITIALIZED = 0;
- protected static final int SIGN = 2;
- protected static final int VERIFY = 3;
-
- // Current state.
- protected int state;
-
- // Name of this object.
- private String name;
-}
diff --git a/libjava/java/security/SignatureException.java b/libjava/java/security/SignatureException.java
deleted file mode 100644
index dc1c87a6317..00000000000
--- a/libjava/java/security/SignatureException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/**
- * Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public class SignatureException extends GeneralSecurityException
-{
- public SignatureException()
- {
- super();
- }
-
- public SignatureException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/interfaces/DSAKey.java b/libjava/java/security/interfaces/DSAKey.java
deleted file mode 100644
index 3920d7b455a..00000000000
--- a/libjava/java/security/interfaces/DSAKey.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.interfaces;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public interface DSAKey
-{
- public DSAParams getParams();
-}
diff --git a/libjava/java/security/interfaces/DSAParams.java b/libjava/java/security/interfaces/DSAParams.java
deleted file mode 100644
index 8483bd5cd2c..00000000000
--- a/libjava/java/security/interfaces/DSAParams.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.interfaces;
-import java.math.BigInteger;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public interface DSAParams
-{
- public BigInteger getP();
- public BigInteger getQ();
- public BigInteger getG();
-}
diff --git a/libjava/java/security/interfaces/DSAPrivateKey.java b/libjava/java/security/interfaces/DSAPrivateKey.java
deleted file mode 100644
index a2cb583884a..00000000000
--- a/libjava/java/security/interfaces/DSAPrivateKey.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.interfaces;
-import java.security.PrivateKey;
-import java.math.BigInteger;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public interface DSAPrivateKey extends DSAKey, PrivateKey
-{
- // FIXME: need to set this at some point when serialization is implemented.
- public static final long serialVersionUID = 0;
-
- public BigInteger getX();
-}
diff --git a/libjava/java/security/interfaces/DSAPublicKey.java b/libjava/java/security/interfaces/DSAPublicKey.java
deleted file mode 100644
index 7cab0708263..00000000000
--- a/libjava/java/security/interfaces/DSAPublicKey.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.interfaces;
-import java.security.PublicKey;
-import java.math.BigInteger;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-public interface DSAPublicKey extends DSAKey, PublicKey
-{
- // FIXME: need to set this at some point when serialization is implemented.
- public static final long serialVersionUID = 0;
-
- public BigInteger getY();
-}
diff --git a/libjava/java/security/interfaces/RSAPrivateCrtKey.java b/libjava/java/security/interfaces/RSAPrivateCrtKey.java
deleted file mode 100644
index cca294ab4a3..00000000000
--- a/libjava/java/security/interfaces/RSAPrivateCrtKey.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.interfaces;
-import java.math.BigInteger;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface RSAPrivateCrtKey extends RSAPrivateKey
-{
- public BigInteger getPublicExponent();
- public BigInteger getPrimeP();
- public BigInteger getPrimeQ();
- public BigInteger getPrimeExponentP();
- public BigInteger getPrimeExponentQ();
- public BigInteger getCrtCoefficient();
-}
diff --git a/libjava/java/security/interfaces/RSAPrivateKey.java b/libjava/java/security/interfaces/RSAPrivateKey.java
deleted file mode 100644
index 4c16b05e248..00000000000
--- a/libjava/java/security/interfaces/RSAPrivateKey.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.interfaces;
-import java.security.PrivateKey;
-import java.math.BigInteger;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface RSAPrivateKey extends PrivateKey
-{
- public BigInteger getModulus();
- public BigInteger getPrivateExponent();
-}
diff --git a/libjava/java/security/interfaces/RSAPublicKey.java b/libjava/java/security/interfaces/RSAPublicKey.java
deleted file mode 100644
index 0bee88df91c..00000000000
--- a/libjava/java/security/interfaces/RSAPublicKey.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.interfaces;
-import java.security.PublicKey;
-import java.math.BigInteger;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface RSAPublicKey extends PublicKey
-{
- public BigInteger getModulus();
- public BigInteger getPublicExponent();
-}
diff --git a/libjava/java/security/spec/AlgorithmParameterSpec.java b/libjava/java/security/spec/AlgorithmParameterSpec.java
deleted file mode 100644
index 5781623b746..00000000000
--- a/libjava/java/security/spec/AlgorithmParameterSpec.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.spec;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface AlgorithmParameterSpec
-{
- // This interface contains no methods or constants. Its only purpose is
- // to group (and provide type safety for) all key specifications.
-}
diff --git a/libjava/java/security/spec/InvalidKeySpecException.java b/libjava/java/security/spec/InvalidKeySpecException.java
deleted file mode 100644
index 632fd251e7a..00000000000
--- a/libjava/java/security/spec/InvalidKeySpecException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.spec;
-import java.security.GeneralSecurityException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public class InvalidKeySpecException extends GeneralSecurityException
-{
- public InvalidKeySpecException()
- {
- super();
- }
-
- public InvalidKeySpecException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/spec/InvalidParameterSpecException.java b/libjava/java/security/spec/InvalidParameterSpecException.java
deleted file mode 100644
index 1e2aff5c3f6..00000000000
--- a/libjava/java/security/spec/InvalidParameterSpecException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.spec;
-import java.security.GeneralSecurityException;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public class InvalidParameterSpecException extends GeneralSecurityException
-{
- public InvalidParameterSpecException()
- {
- super();
- }
-
- public InvalidParameterSpecException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/security/spec/KeySpec.java b/libjava/java/security/spec/KeySpec.java
deleted file mode 100644
index 75e50f9f656..00000000000
--- a/libjava/java/security/spec/KeySpec.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.spec;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 1, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface KeySpec
-{
- // This interface contains no methods or constants. Its only purpose is
- // to group (and provide type safety for) all key specifications.
-}
diff --git a/libjava/java/security/spec/RSAPrivateCrtKeySpec.java b/libjava/java/security/spec/RSAPrivateCrtKeySpec.java
deleted file mode 100644
index 6a31163c09e..00000000000
--- a/libjava/java/security/spec/RSAPrivateCrtKeySpec.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.spec;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
- */
-
-// JDK1.2
-public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec
-{
-}
diff --git a/libjava/java/security/spec/RSAPrivateKeySpec.java b/libjava/java/security/spec/RSAPrivateKeySpec.java
deleted file mode 100644
index 4f38a2d0ba5..00000000000
--- a/libjava/java/security/spec/RSAPrivateKeySpec.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.spec;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 7, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
- */
-
-// JDK1.2
-public class RSAPrivateKeySpec implements KeySpec
-{
-}
diff --git a/libjava/java/security/spec/RSAPublicKeySpec.java b/libjava/java/security/spec/RSAPublicKeySpec.java
deleted file mode 100644
index 0bdcd22922e..00000000000
--- a/libjava/java/security/spec/RSAPublicKeySpec.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.security.spec;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date February 10, 2000.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Stubbed.
- */
-
-// JDK1.2
-public class RSAPublicKeySpec implements KeySpec
-{
-}
diff --git a/libjava/java/text/BreakIterator.java b/libjava/java/text/BreakIterator.java
deleted file mode 100644
index 5832695bb9d..00000000000
--- a/libjava/java/text/BreakIterator.java
+++ /dev/null
@@ -1,160 +0,0 @@
-// BreakIterator.java - Iterate over logical breaks in text.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-import java.io.Serializable;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 19, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct to 1.1.
- */
-
-public abstract class BreakIterator implements Cloneable, Serializable
-{
- // The value was discovered by writing a test program.
- public static final int DONE = -1;
-
- protected BreakIterator ()
- {
- }
-
- public abstract int current ();
- public abstract int first ();
- public abstract int following (int pos);
-
- public static synchronized Locale[] getAvailableLocales ()
- {
- // FIXME.
- return null;
- }
-
- private static BreakIterator getInstance (String type, Locale loc)
- {
- String className;
- try
- {
- ResourceBundle res
- = ResourceBundle.getBundle("gnu.gcj.text.LocaleData", loc);
- className = res.getString(type);
- }
- catch (MissingResourceException x)
- {
- return null;
- }
- try
- {
- Class k = Class.forName(className);
- return (BreakIterator) k.newInstance();
- }
- catch (ClassNotFoundException x1)
- {
- return null;
- }
- catch (InstantiationException x2)
- {
- return null;
- }
- catch (IllegalAccessException x3)
- {
- return null;
- }
- }
-
- public static BreakIterator getCharacterInstance ()
- {
- return getCharacterInstance (Locale.getDefault());
- }
-
- public static BreakIterator getCharacterInstance (Locale loc)
- {
- BreakIterator r = getInstance ("CharacterIterator", loc);
- if (r == null)
- r = new gnu.gcj.text.CharacterBreakIterator ();
- return r;
- }
-
- public static BreakIterator getLineInstance ()
- {
- return getLineInstance (Locale.getDefault());
- }
-
- public static BreakIterator getLineInstance (Locale loc)
- {
- BreakIterator r = getInstance ("LineIterator", loc);
- if (r == null)
- r = new gnu.gcj.text.LineBreakIterator ();
- return r;
- }
-
- public static BreakIterator getSentenceInstance ()
- {
- return getSentenceInstance (Locale.getDefault());
- }
-
- public static BreakIterator getSentenceInstance (Locale loc)
- {
- BreakIterator r = getInstance ("SentenceIterator", loc);
- if (r == null)
- r = new gnu.gcj.text.SentenceBreakIterator ();
- return r;
- }
-
- public abstract CharacterIterator getText ();
-
- public static BreakIterator getWordInstance ()
- {
- return getWordInstance (Locale.getDefault());
- }
-
- public static BreakIterator getWordInstance (Locale loc)
- {
- BreakIterator r = getInstance ("WordIterator", loc);
- if (r == null)
- r = new gnu.gcj.text.WordBreakIterator ();
- return r;
- }
-
- public boolean isBoundary (int pos)
- {
- if (pos == 0)
- return true;
- return following (pos - 1) == pos;
- }
-
- public abstract int last ();
- public abstract int next ();
- public abstract int next (int n);
-
- public int preceding (int pos)
- {
- if (following (pos) == DONE)
- last ();
- while (previous () >= pos)
- ;
- return current ();
- }
-
- public abstract int previous ();
-
- public void setText (String newText)
- {
- setText (new StringCharacterIterator (newText));
- }
-
- public abstract void setText (CharacterIterator newText);
-}
diff --git a/libjava/java/text/CharacterIterator.java b/libjava/java/text/CharacterIterator.java
deleted file mode 100644
index a10ee4ad332..00000000000
--- a/libjava/java/text/CharacterIterator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// CharacterIterator.java - Protocol for iterating over Unicode characters.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 22, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct to 1.1.
- */
-
-public interface CharacterIterator extends Cloneable
-{
- public abstract Object clone ();
- public abstract char current ();
- public abstract char first ();
- public abstract int getBeginIndex ();
- public abstract int getEndIndex ();
- public abstract int getIndex ();
- public abstract char last ();
- public abstract char next ();
- public abstract char previous ();
- public abstract char setIndex (int idx);
-
- public static final char DONE = '\uffff';
-}
diff --git a/libjava/java/text/ChoiceFormat.java b/libjava/java/text/ChoiceFormat.java
deleted file mode 100644
index 92b697c273f..00000000000
--- a/libjava/java/text/ChoiceFormat.java
+++ /dev/null
@@ -1,310 +0,0 @@
-// ChoiceFormat.java - Formatter for `switch'-like string substitution.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-import java.util.Vector;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 9, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Believed complete and correct to 1.1.
- */
-
-public class ChoiceFormat extends NumberFormat
-{
- // Note: we assume the same kind of quoting rules apply here.
- // This isn't explicitly documented. But for instance we accept
- // '#' as a literal hash in a format string.
- public void applyPattern (String newPattern)
- {
- int index = 0, max = newPattern.length();
- Vector stringVec = new Vector ();
- Vector limitVec = new Vector ();
- StringBuffer buf = new StringBuffer ();
-
- while (true)
- {
- // Find end of double.
- int dstart = index;
- while (index < max)
- {
- char c = newPattern.charAt(index);
- if (c == '#' || c == '\u2064' || c == '<')
- break;
- ++index;
- }
-
- if (index == max)
- throw new IllegalArgumentException ("unexpected end of text");
- Double d = new Double (newPattern.substring(dstart, index));
-
- if (newPattern.charAt(index) == '<')
- d = new Double (nextDouble (d.doubleValue()));
-
- limitVec.addElement(d);
-
- // Scan text.
- ++index;
- buf.setLength(0);
- while (index < max)
- {
- char c = newPattern.charAt(index);
- if (c == '\'' && index < max + 1
- && newPattern.charAt(index + 1) == '\'')
- {
- buf.append(c);
- ++index;
- }
- else if (c == '\'' && index < max + 2)
- {
- buf.append(newPattern.charAt(index + 1));
- index += 2;
- }
- else if (c == '|')
- break;
- else
- buf.append(c);
- ++index;
- }
-
- stringVec.addElement(buf.toString());
- if (index == max)
- break;
- ++index;
- }
-
- strings = new String[stringVec.size()];
- stringVec.copyInto(strings);
-
- limits = new double[limitVec.size()];
- for (int i = 0; i < limits.length; ++i)
- {
- Double d = (Double) limitVec.elementAt(i);
- limits[i] = d.doubleValue();
- }
- }
-
- public ChoiceFormat (String newPattern)
- {
- super ();
- applyPattern (newPattern);
- }
-
- public ChoiceFormat (double[] limits, String[] strings)
- {
- super ();
- setChoices (limits, strings);
- }
-
- public Object clone ()
- {
- return new ChoiceFormat (limits, strings);
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof ChoiceFormat))
- return false;
- ChoiceFormat cf = (ChoiceFormat) obj;
- if (limits.length != cf.limits.length)
- return false;
- for (int i = limits.length - 1; i >= 0; --i)
- {
- if (limits[i] != cf.limits[i]
- || !strings[i].equals(cf.strings[i]))
- return false;
- }
- return true;
- }
-
- public StringBuffer format (long num, StringBuffer appendBuf,
- FieldPosition pos)
- {
- return format ((double) num, appendBuf, pos);
- }
-
- public StringBuffer format (double num, StringBuffer appendBuf,
- FieldPosition pos)
- {
- if (limits.length == 0)
- return appendBuf;
-
- int index = 0;
- if (! Double.isNaN(num) && num >= limits[0])
- {
- for (; index < limits.length - 1; ++index)
- {
- if (limits[index] <= num
- && index != limits.length - 2
- && num < limits[index + 1])
- break;
- }
- }
-
- return appendBuf.append(strings[index]);
- }
-
- public Object[] getFormats ()
- {
- return (Object[]) strings.clone();
- }
-
- public double[] getLimits ()
- {
- return (double[]) limits.clone();
- }
-
- public int hashCode ()
- {
- int hash = 0;
- for (int i = 0; i < limits.length; ++i)
- {
- long v = Double.doubleToLongBits(limits[i]);
- hash ^= (v ^ (v >>> 32));
- hash ^= strings[i].hashCode();
- }
- return hash;
- }
-
- public static final double nextDouble (double d)
- {
- return nextDouble (d, true);
- }
-
- public static double nextDouble (double d, boolean next)
- {
- if (Double.isInfinite(d) || Double.isNaN(d))
- return d;
-
- long bits = Double.doubleToLongBits(d);
-
- long mantMask = (1L << mantissaBits) - 1;
- long mantissa = bits & mantMask;
-
- long expMask = (1L << exponentBits) - 1;
- long exponent = (bits >>> mantissaBits) & expMask;
-
- if (next ^ (bits < 0)) // Increment magnitude
- {
- if (mantissa == (1L << mantissaBits) - 1)
- {
- mantissa = 0L;
- exponent++;
-
- // Check for absolute overflow.
- if (exponent >= (1L << mantissaBits))
- return (bits > 0) ? Double.POSITIVE_INFINITY
- : Double.NEGATIVE_INFINITY;
- }
- else
- mantissa++;
- }
- else // Decrement magnitude
- {
- if (exponent == 0L && mantissa == 0L)
- {
- // The only case where there is a change of sign
- return next ? Double.MIN_VALUE : -Double.MIN_VALUE;
- }
- else
- {
- if (mantissa == 0L)
- {
- mantissa = (1L << mantissaBits) - 1;
- exponent--;
- }
- else
- mantissa--;
- }
- }
-
- long result = bits < 0 ? 1 : 0;
- result = (result << exponentBits) | exponent;
- result = (result << mantissaBits) | mantissa;
- return Double.longBitsToDouble(result);
- }
-
- public Number parse (String sourceStr, ParsePosition pos)
- {
- int index = pos.getIndex();
- for (int i = 0; i < limits.length; ++i)
- {
- if (sourceStr.startsWith(strings[i], index))
- {
- pos.setIndex(index + strings[i].length());
- return new Double (limits[i]);
- }
- }
- pos.setErrorIndex(index);
- return new Double (Double.NaN);
- }
-
- public static final double previousDouble (double d)
- {
- return nextDouble (d, false);
- }
-
- public void setChoices (double[] limits, String[] strings)
- {
- if (limits == null || strings == null)
- throw new NullPointerException ();
- if (limits.length != strings.length)
- throw new IllegalArgumentException ();
- this.strings = (String[]) strings.clone();
- this.limits = (double[]) limits.clone();
- }
-
- private final void quoteString (StringBuffer dest, String text)
- {
- int max = text.length();
- for (int i = 0; i < max; ++i)
- {
- char c = text.charAt(i);
- if (c == '\'')
- {
- dest.append(c);
- dest.append(c);
- }
- else if (c == '#' || c == '|' || c == '\u2064' || c == '<')
- {
- dest.append('\'');
- dest.append(c);
- dest.append('\'');
- }
- else
- dest.append(c);
- }
- }
-
- public String toPattern ()
- {
- StringBuffer result = new StringBuffer ();
- for (int i = 0; i < limits.length; ++i)
- {
- result.append(limits[i]);
- result.append('#');
- quoteString (result, strings[i]);
- }
- return result.toString();
- }
-
- // Formats and limits.
- private String[] strings;
- private double[] limits;
-
- // Number of mantissa bits in double.
- private static final int mantissaBits = 52;
- // Number of exponent bits in a double.
- private static final int exponentBits = 11;
-}
diff --git a/libjava/java/text/CollationElementIterator.java b/libjava/java/text/CollationElementIterator.java
deleted file mode 100644
index 96732f7b2e3..00000000000
--- a/libjava/java/text/CollationElementIterator.java
+++ /dev/null
@@ -1,79 +0,0 @@
-// CollationElementIterator.java - Iterate over decomposed characters.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 25, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Believed complete and correct to JDK 1.1.
- */
-
-public final class CollationElementIterator
-{
- public static final int NULLORDER = 0xffffffff;
-
- public int next ()
- {
- if (index == text.length())
- return NULLORDER;
- return collator.ceiNext(this);
- }
-
- // This one returns int while the others return short.
- public static final int primaryOrder (int order)
- {
- // From the JDK 1.2 spec.
- return order >>> 16;
- }
-
- public void reset ()
- {
- index = 0;
- }
-
- public static final short secondaryOrder (int order)
- {
- // From the JDK 1.2 spec.
- return (order >>> 8) & 255;
- }
-
- public static final short tertiaryOrder (int order)
- {
- // From the JDK 1.2 spec.
- return order & 255;
- }
-
- // Non-public constructor.
- CollationElementIterator (String text, RuleBasedCollator collator)
- {
- this.text = text;
- this.index = 0;
- this.lookahead_set = false;
- this.lookahead = 0;
- this.collator = collator;
- }
-
- // Text over which we iterate.
- String text;
-
- // Index of next character to examine in TEXT.
- int index;
-
- // A piece of lookahead.
- boolean lookahead_set;
- int lookahead;
-
- // The RuleBasedCollator which created this object.
- RuleBasedCollator collator;
-}
diff --git a/libjava/java/text/CollationKey.java b/libjava/java/text/CollationKey.java
deleted file mode 100644
index 725b66a8138..00000000000
--- a/libjava/java/text/CollationKey.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// CollationKey.java - Sort key for locale-sensitive String.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 25, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public final class CollationKey
-{
- public int compareTo (CollationKey target)
- {
- int max = Math.min(key.length, target.key.length);
-
- for (int i = 0; i < max; ++i)
- {
- if (key[i] != target.key[i])
- return key[i] - target.key[i];
- }
-
- return key.length - target.key.length;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof CollationKey))
- return false;
-
- CollationKey ck = (CollationKey) obj;
-
- if (key.length != ck.key.length)
- return false;
-
- for (int i = 0; i < key.length; ++i)
- if (key[i] != ck.key[i])
- return false;
-
- return true;
- }
-
- public String getSourceString ()
- {
- return originalText;
- }
-
- public int hashCode ()
- {
- // We just follow BitSet instead of thinking up something new.
- long h = originalText.hashCode();
- for (int i = key.length - 1; i >= 0; --i)
- h ^= key[i] * (i + 1);
- return (int) ((h >> 32) ^ h);
- }
-
- public byte[] toByteArray ()
- {
- byte[] r = new byte[4 * key.length];
- int off = 0;
- for (int i = 0; i < key.length; ++i)
- {
- r[off++] = (byte) ((key[i] >>> 24) & 255);
- r[off++] = (byte) ((key[i] >>> 16) & 255);
- r[off++] = (byte) ((key[i] >>> 8) & 255);
- r[off++] = (byte) ((key[i] ) & 255);
- }
- return r;
- }
-
- CollationKey (CollationElementIterator iter, String originalText,
- int strength)
- {
- this.originalText = originalText;
-
- // Compute size of required array.
- int size = 0;
- while (RuleBasedCollator.next(iter, strength)
- != CollationElementIterator.NULLORDER)
- ++size;
-
- iter.reset();
- key = new int[size];
- for (int i = 0; i < size; i++)
- key[i] = RuleBasedCollator.next(iter, strength);
- }
-
- // Original string.
- private String originalText;
-
- // Collation key.
- private int[] key;
-}
diff --git a/libjava/java/text/Collator.java b/libjava/java/text/Collator.java
deleted file mode 100644
index 30b746ef599..00000000000
--- a/libjava/java/text/Collator.java
+++ /dev/null
@@ -1,135 +0,0 @@
-// Collator.java - Locale-sensitive string comparison.
-
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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 java.text;
-
-import java.io.Serializable;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 18, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Mostly complete, but parts stubbed out. Look for FIXME.
- */
-
-public abstract class Collator implements Cloneable, Serializable
-{
- public static final int NO_DECOMPOSITION = 0;
- public static final int CANONICAL_DECOMPOSITION = 1;
- public static final int FULL_DECOMPOSITION = 2;
-
- public static final int PRIMARY = 0;
- public static final int SECONDARY = 1;
- public static final int TERTIARY = 2;
- public static final int IDENTICAL = 3;
-
- protected Collator ()
- {
- strength = TERTIARY;
- decmp = CANONICAL_DECOMPOSITION;
- }
-
- public abstract int compare (String source, String target);
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof Collator))
- return false;
- Collator c = (Collator) obj;
- return decmp == c.decmp && strength == c.strength;
- }
-
- public boolean equals (String source, String target)
- {
- return compare (source, target) == 0;
- }
-
- public Object clone ()
- {
- return super.clone ();
- }
-
- public static synchronized Locale[] getAvailableLocales ()
- {
- // FIXME.
- return null;
- }
-
- public abstract CollationKey getCollationKey (String source);
-
- public synchronized int getDecomposition ()
- {
- return decmp;
- }
-
- public static Collator getInstance ()
- {
- return getInstance (Locale.getDefault());
- }
-
- public static Collator getInstance (Locale loc)
- {
- ResourceBundle res;
- String pattern;
- try
- {
- res = ResourceBundle.getBundle("gnu.gcj.text.LocaleData", loc);
- pattern = res.getString("collatorRule");
- }
- catch (MissingResourceException x)
- {
- return null;
- }
- try
- {
- return new RuleBasedCollator (pattern);
- }
- catch (ParseException x)
- {
- return null;
- }
- }
-
- public synchronized int getStrength ()
- {
- return strength;
- }
-
- public abstract int hashCode ();
-
- public synchronized void setDecomposition (int mode)
- {
- if (mode != NO_DECOMPOSITION
- && mode != CANONICAL_DECOMPOSITION
- && mode != FULL_DECOMPOSITION)
- throw new IllegalArgumentException ();
- decmp = mode;
- }
-
- public synchronized void setStrength (int strength)
- {
- if (strength != PRIMARY && strength != SECONDARY
- && strength != TERTIARY && strength != IDENTICAL)
- throw new IllegalArgumentException ();
- this.strength = strength;
- }
-
- // Decompose a single character and append results to the buffer.
- protected native final void decomposeCharacter (char c, StringBuffer buf);
-
- // These names are fixed by the serialization spec.
- protected int decmp;
- protected int strength;
-}
diff --git a/libjava/java/text/DateFormat.java b/libjava/java/text/DateFormat.java
deleted file mode 100644
index ee2178cd68f..00000000000
--- a/libjava/java/text/DateFormat.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.text;
-
-import java.util.*;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Mostly complete; search for FIXME to see omissions.
- */
-
-public abstract class DateFormat extends Format implements Cloneable
-{
- protected Calendar calendar;
- protected NumberFormat numberFormat;
-
- // (Values determined using a test program.)
- public final static int FULL = 0;
- public final static int LONG = 1;
- public final static int MEDIUM = 2;
- public final static int SHORT = 3;
- public final static int DEFAULT = MEDIUM;
-
- public final static int ERA_FIELD = 0;
- public final static int YEAR_FIELD = 1;
- public final static int MONTH_FIELD = 2;
- public final static int DATE_FIELD = 3;
- public final static int HOUR_OF_DAY1_FIELD = 4;
- public final static int HOUR_OF_DAY0_FIELD = 5;
- public final static int MINUTE_FIELD = 6;
- public final static int SECOND_FIELD = 7;
- public final static int MILLISECOND_FIELD = 8;
- public final static int DAY_OF_WEEK_FIELD = 9;
- public final static int DAY_OF_YEAR_FIELD = 10;
- public final static int DAY_OF_WEEK_IN_MONTH_FIELD = 11;
- public final static int WEEK_OF_YEAR_FIELD = 12;
- public final static int WEEK_OF_MONTH_FIELD = 13;
- public final static int AM_PM_FIELD = 14;
- public final static int HOUR1_FIELD = 15;
- public final static int HOUR0_FIELD = 16;
- public final static int TIMEZONE_FIELD = 17;
-
- protected DateFormat ()
- {
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof DateFormat))
- return false;
- DateFormat d = (DateFormat) obj;
- return calendar.equals(d.calendar) && numberFormat.equals(d.numberFormat);
- }
-
- public Object clone ()
- {
- // We know the superclass just call's Object's generic cloner.
- return super.clone ();
- }
-
- public final StringBuffer format (Object obj,
- StringBuffer buf, FieldPosition pos)
- {
- if (obj instanceof Number)
- return format (new Date(((Number) obj).longValue()), buf, pos);
- return format ((Date) obj, buf, pos);
- }
-
- public final String format (Date date)
- {
- StringBuffer sb = new StringBuffer ();
- format (date, sb, new FieldPosition (MONTH_FIELD));
- return sb.toString();
- }
-
- public abstract StringBuffer format (Date date,
- StringBuffer buf, FieldPosition pos);
-
- public static Locale[] getAvailableLocales ()
- {
- return null; // FIXME
- }
-
- public Calendar getCalendar ()
- {
- return calendar;
- }
-
- private static final DateFormat computeInstance (int style, Locale loc,
- boolean use_date,
- boolean use_time)
- {
- return computeInstance (style, style, loc, use_date, use_time);
- }
-
- private static final DateFormat computeInstance (int dateStyle,
- int timeStyle,
- Locale loc,
- boolean use_date,
- boolean use_time)
- {
- ResourceBundle res;
- try
- {
- res = ResourceBundle.getBundle("gnu.gcj.text.LocaleData", loc);
- }
- catch (MissingResourceException x)
- {
- res = null;
- }
-
- String pattern = null;
- if (use_date)
- {
- String name, def;
- switch (dateStyle)
- {
- case FULL:
- name = "fullDateFormat";
- def = "EEEE MMMM d, yyyy G";
- break;
- case LONG:
- name = "longDateFormat";
- def = "MMMM d, yyyy";
- break;
- case MEDIUM:
- name = "mediumDateFormat";
- def = "d-MMM-yy";
- break;
- case SHORT:
- name = "shortDateFormat";
- def = "M/d/yy";
- break;
- default:
- throw new IllegalArgumentException ();
- }
- try
- {
- pattern = res == null ? def : res.getString(name);
- }
- catch (MissingResourceException x)
- {
- pattern = def;
- }
- }
-
- if (use_time)
- {
- if (pattern == null)
- pattern = "";
- else
- pattern += " ";
-
- String name, def;
- switch (timeStyle)
- {
- case FULL:
- name = "fullTimeFormat";
- def = "h:mm:ss;S 'o''clock' a z";
- break;
- case LONG:
- name = "longTimeFormat";
- def = "h:mm:ss a z";
- break;
- case MEDIUM:
- name = "mediumTimeFormat";
- def = "h:mm:ss a";
- break;
- case SHORT:
- name = "shortTimeFormat";
- def = "h:mm a";
- break;
- default:
- throw new IllegalArgumentException ();
- }
-
- String s;
- try
- {
- s = res == null ? def : res.getString(name);
- }
- catch (MissingResourceException x)
- {
- s = def;
- }
- pattern += s;
- }
-
- return new SimpleDateFormat (pattern, loc);
- }
-
- public static final DateFormat getDateInstance ()
- {
- return getDateInstance (DEFAULT, Locale.getDefault());
- }
-
- public static final DateFormat getDateInstance (int style)
- {
- return getDateInstance (style, Locale.getDefault());
- }
-
- public static final DateFormat getDateInstance (int style, Locale loc)
- {
- return computeInstance (style, loc, true, false);
- }
-
- public static final DateFormat getDateTimeInstance ()
- {
- return getDateTimeInstance (DEFAULT, DEFAULT, Locale.getDefault());
- }
-
- public static final DateFormat getDateTimeInstance (int style)
- {
- return getDateTimeInstance (style, style, Locale.getDefault());
- }
-
- public static final DateFormat getDateTimeInstance (int dateStyle,
- int timeStyle)
- {
- return getDateTimeInstance (dateStyle, timeStyle, Locale.getDefault());
- }
-
- public static final DateFormat getDateTimeInstance (int dateStyle,
- int timeStyle,
- Locale loc)
- {
- return computeInstance (dateStyle, timeStyle, loc, true, true);
- }
-
- public static final DateFormat getInstance ()
- {
- // JCL book says SHORT.
- return getDateTimeInstance (SHORT, SHORT, Locale.getDefault());
- }
-
- public NumberFormat getNumberFormat ()
- {
- return numberFormat;
- }
-
- public static final DateFormat getTimeInstance ()
- {
- return getTimeInstance (DEFAULT, Locale.getDefault());
- }
-
- public static final DateFormat getTimeInstance (int style)
- {
- return getTimeInstance (style, Locale.getDefault());
- }
-
- public static final DateFormat getTimeInstance (int style, Locale loc)
- {
- return computeInstance (style, loc, false, true);
- }
-
- public TimeZone getTimeZone ()
- {
- return calendar.getTimeZone();
- }
-
- public int hashCode ()
- {
- int hash = calendar.hashCode();
- if (numberFormat != null)
- hash ^= numberFormat.hashCode();
- return hash;
- }
-
- public boolean isLenient ()
- {
- return calendar.isLenient();
- }
-
- public Date parse (String source) throws ParseException
- {
- ParsePosition pos = new ParsePosition(0);
- Date result = parse (source, pos);
- if (result == null)
- {
- int index = pos.getErrorIndex();
- if (index < 0)
- index = pos.getIndex();
- throw new ParseException("invalid Date syntax", index);
- }
- return result;
- }
-
- public abstract Date parse (String source, ParsePosition pos);
-
- public Object parseObject (String source, ParsePosition pos)
- {
- return parse(source, pos);
- }
-
- public void setCalendar (Calendar calendar)
- {
- this.calendar = calendar;
- }
-
- public void setLenient (boolean lenient)
- {
- calendar.setLenient(lenient);
- }
-
- public void setNumberFormat (NumberFormat numberFormat)
- {
- this.numberFormat = numberFormat;
- }
-
- public void setTimeZone (TimeZone timeZone)
- {
- calendar.setTimeZone(timeZone);
- }
-}
diff --git a/libjava/java/text/DateFormatSymbols.java b/libjava/java/text/DateFormatSymbols.java
deleted file mode 100644
index 91b1292ef27..00000000000
--- a/libjava/java/text/DateFormatSymbols.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.text;
-
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
- * Status: Believed complete and correct.
- */
-
-public class DateFormatSymbols extends Object
- implements java.io.Serializable, Cloneable
-{
- private String[] ampms;
- private String[] eras;
- private String localPatternChars;
- private String[] months;
- private String[] shortMonths;
- private String[] shortWeekdays;
- private String[] weekdays;
- private String[][] zoneStrings;
-
- private static final String[] ampmsDefault = {"AM", "PM" };
- private static final String[] erasDefault = {"BC", "AD" };
- // localPatternCharsDefault is used by SimpleDateFormat.
- protected static final String localPatternCharsDefault
- = "GyMdkHmsSEDFwWahKz";
- private static final String[] monthsDefault = {
- "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December", ""
- };
- private static final String[] shortMonthsDefault = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""
- };
- private static final String[] shortWeekdaysDefault = {
- "", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
- private static final String[] weekdaysDefault = {
- "", "Sunday", "Monday", "Tuesday",
- "Wednesday", "Thursday", "Friday", "Saturday"
- };
-
- private static String[][] zoneStringsDefault = {
- { "PST", "Pacific Standard Time", "PST",
- /**/ "Pacific Daylight Time", "PDT", "San Francisco" },
- { "MST", "Mountain Standard Time", "MST",
- /**/ "Mountain Daylight Time", "MDT", "Denver" },
- { "PNT", "Mountain Standard Time", "MST",
- /**/ "Mountain Standard Time", "MST", "Phoenix" },
- { "CST", "Central Standard Time", "CST",
- /**/ "Central Daylight Time", "CDT", "Chicago" },
- { "EST", "Eastern Standard Time", "EST",
- /**/ "Eastern Daylight Time", "EDT", "Boston" },
- { "IET", "Eastern Standard Time", "EST",
- /**/ "Eastern Standard Time", "EST", "Indianapolis" },
- { "PRT", "Atlantic Standard Time", "AST",
- /**/ "Atlantic Daylight Time", "ADT", "Halifax" },
- { "HST", "Hawaii Standard Time", "HST",
- /**/ "Hawaii Daylight Time", "HDT", "Honolulu" },
- { "AST", "Alaska Standard Time", "AST",
- /**/ "Alaska Daylight Time", "ADT", "Anchorage" }
- };
-
- private final Object safeGetResource (ResourceBundle res,
- String key, Object def)
- {
- if (res != null)
- {
- try
- {
- return res.getObject(key);
- }
- catch (MissingResourceException x)
- {
- }
- }
- return def;
- }
-
- public DateFormatSymbols (Locale locale)
- {
- ResourceBundle res;
- try
- {
- res = ResourceBundle.getBundle("gnu.gcj.text.LocaleData", locale);
- }
- catch (MissingResourceException x)
- {
- res = null;
- }
- ampms = (String[]) safeGetResource (res, "ampm", ampmsDefault);
- eras = (String[]) safeGetResource (res, "eras", erasDefault);
- localPatternChars = (String) safeGetResource (res, "datePatternChars",
- localPatternCharsDefault);
- months = (String[]) safeGetResource (res, "months", monthsDefault);
- shortMonths = (String[]) safeGetResource (res, "shortMonths",
- shortMonthsDefault);
- shortWeekdays = (String[]) safeGetResource (res, "shortWeekdays",
- shortWeekdaysDefault);
- weekdays = (String[]) safeGetResource (res, "weekdays", weekdaysDefault);
- zoneStrings = (String[][]) safeGetResource (res, "zoneStrings",
- zoneStringsDefault);
- }
-
- public DateFormatSymbols ()
- {
- this (Locale.getDefault());
- }
-
- // Copy constructor.
- private DateFormatSymbols (DateFormatSymbols old)
- {
- ampms = old.ampms;
- eras = old.eras;
- localPatternChars = old.localPatternChars;
- months = old.months;
- shortMonths = old.shortMonths;
- shortWeekdays = old.shortWeekdays;
- weekdays = old.weekdays;
- zoneStrings = old.zoneStrings;
- }
-
- public String[] getAmPmStrings()
- {
- return ampms;
- }
-
- public String[] getEras()
- {
- return eras;
- }
-
-
- public String getLocalPatternChars()
- {
- return localPatternChars;
- }
-
- public String[] getMonths ()
- {
- return months;
- }
-
- public String[] getShortMonths ()
- {
- return shortMonths;
- }
-
- public String[] getShortWeekdays ()
- {
- return shortWeekdays;
- }
-
- public String[] getWeekdays ()
- {
- return weekdays;
- }
-
- public String[] [] getZoneStrings ()
- {
- return zoneStrings;
- }
-
- public void setAmPmStrings (String[] value)
- {
- ampms = value;
- }
-
- public void setEras (String[] value)
- {
- eras = value;
- }
-
- public void setLocalPatternChars (String value)
- {
- localPatternChars = value;
- }
-
- public void setMonths (String[] value)
- {
- months = value;
- }
-
- public void setShortMonths (String[] value)
- {
- shortMonths = value;
- }
-
- public void setShortWeekdays (String[] value)
- {
- shortWeekdays = value;
- }
-
- public void setWeekdays (String[] value)
- {
- weekdays = value;
- }
-
- public void setZoneStrings (String[][] value)
- {
- zoneStrings = value;
- }
-
- /* Does a "deep" equality test - recurses into arrays. */
- protected static boolean equals (Object x, Object y)
- {
- if (x == y)
- return true;
- if (x == null || y == null)
- return false;
- if (! (x instanceof Object[]) || ! (y instanceof Object[]))
- return x.equals(y);
- Object[] xa = (Object[]) x;
- Object[] ya = (Object[]) y;
- if (xa.length != ya.length)
- return false;
- for (int i = xa.length; --i >= 0; )
- {
- if (! equals(xa[i], ya[i]))
- return false;
- }
- return true;
- }
-
- private static int hashCode (Object x)
- {
- if (x == null)
- return 0;
- if (! (x instanceof Object[]))
- return x.hashCode();
- Object[] xa = (Object[]) x;
- int hash = 0;
- for (int i = 0; i < xa.length; i++)
- hash = 37 * hashCode(xa[i]);
- return hash;
- }
-
- public boolean equals (Object obj)
- {
- if (obj == null || ! (obj instanceof DateFormatSymbols))
- return false;
- DateFormatSymbols other = (DateFormatSymbols) obj;
- return (equals(ampms, other.ampms)
- && equals(eras, other.eras)
- && equals(localPatternChars, other.localPatternChars)
- && equals(months, other.months)
- && equals(shortMonths, other.shortMonths)
- && equals(shortWeekdays, other.shortWeekdays)
- && equals(weekdays, other.weekdays)
- && equals(zoneStrings, other.zoneStrings));
- }
-
- public Object clone ()
- {
- return new DateFormatSymbols (this);
- }
-
- public int hashCode ()
- {
- return (hashCode(ampms)
- ^ hashCode(eras)
- ^ hashCode(localPatternChars)
- ^ hashCode(months)
- ^ hashCode(shortMonths)
- ^ hashCode(shortWeekdays)
- ^ hashCode(weekdays)
- ^ hashCode(zoneStrings));
- }
-}
diff --git a/libjava/java/text/DecimalFormat.java b/libjava/java/text/DecimalFormat.java
deleted file mode 100644
index 9e7513eebaa..00000000000
--- a/libjava/java/text/DecimalFormat.java
+++ /dev/null
@@ -1,986 +0,0 @@
-// DecimalFormat.java - Localized number formatting.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 4, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Believed complete and correct to 1.2, except serialization.
- * Note however that the docs are very unclear about how format parsing
- * should work. No doubt there are problems here.
- */
-
-public class DecimalFormat extends NumberFormat
-{
- // This is a helper for applyPatternWithSymbols. It reads a prefix
- // or a suffix. It can cause some side-effects.
- private final int scanFix (String pattern, int index, StringBuffer buf,
- String patChars, DecimalFormatSymbols syms,
- boolean is_suffix)
- {
- int len = pattern.length();
- buf.setLength(0);
- boolean multiplierSet = false;
- while (index < len)
- {
- char c = pattern.charAt(index);
- if (c == '\'' && index + 1 < len
- && pattern.charAt(index + 1) == '\'')
- {
- buf.append(c);
- ++index;
- }
- else if (c == '\'' && index + 2 < len
- && pattern.charAt(index + 2) == '\'')
- {
- buf.append(pattern.charAt(index + 1));
- index += 2;
- }
- else if (c == '\u00a4')
- {
- if (index + 1 < len && pattern.charAt(index + 1) == '\u00a4')
- {
- buf.append(syms.getInternationalCurrencySymbol());
- ++index;
- }
- else
- buf.append(syms.getCurrencySymbol());
- }
- else if (is_suffix && c == syms.getPercent())
- {
- if (multiplierSet)
- throw new IllegalArgumentException ("multiplier already set " +
- "- index: " + index);
- multiplierSet = true;
- multiplier = 100;
- buf.append(c);
- }
- else if (is_suffix && c == syms.getPerMill())
- {
- if (multiplierSet)
- throw new IllegalArgumentException ("multiplier already set " +
- "- index: " + index);
- multiplierSet = true;
- multiplier = 1000;
- buf.append(c);
- }
- else if (patChars.indexOf(c) != -1)
- {
- // This is a pattern character.
- break;
- }
- else
- buf.append(c);
- ++index;
- }
-
- return index;
- }
-
- // A helper which reads a number format.
- private final int scanFormat (String pattern, int index,
- String patChars, DecimalFormatSymbols syms,
- boolean is_positive)
- {
- int max = pattern.length();
-
- int countSinceGroup = 0;
- int zeroCount = 0;
- boolean saw_group = false;
-
- //
- // Scan integer part.
- //
- while (index < max)
- {
- char c = pattern.charAt(index);
-
- if (c == syms.getDigit())
- {
- if (zeroCount > 0)
- throw new IllegalArgumentException ("digit mark following " +
- "zero - index: " + index);
- ++countSinceGroup;
- }
- else if (c == syms.getZeroDigit())
- {
- ++zeroCount;
- ++countSinceGroup;
- }
- else if (c == syms.getGroupingSeparator())
- {
- countSinceGroup = 0;
- saw_group = true;
- }
- else
- break;
-
- ++index;
- }
-
- // We can only side-effect when parsing the positive format.
- if (is_positive)
- {
- groupingUsed = saw_group;
- groupingSize = (byte) countSinceGroup;
- minimumIntegerDigits = zeroCount;
- }
-
- // Early termination.
- if (index == max || pattern.charAt(index) == syms.getGroupingSeparator())
- {
- if (is_positive)
- decimalSeparatorAlwaysShown = false;
- return index;
- }
-
- if (pattern.charAt(index) == syms.getDecimalSeparator())
- {
- ++index;
-
- //
- // Scan fractional part.
- //
- int hashCount = 0;
- zeroCount = 0;
- while (index < max)
- {
- char c = pattern.charAt(index);
- if (c == syms.getZeroDigit())
- {
- if (hashCount > 0)
- throw new IllegalArgumentException ("zero mark " +
- "following digit - index: " + index);
- ++zeroCount;
- }
- else if (c == syms.getDigit())
- {
- ++hashCount;
- }
- else if (c != syms.getExponential()
- && c != syms.getPatternSeparator()
- && patChars.indexOf(c) != -1)
- throw new IllegalArgumentException ("unexpected special " +
- "character - index: " + index);
- else
- break;
-
- ++index;
- }
-
- if (is_positive)
- {
- maximumFractionDigits = hashCount + zeroCount;
- minimumFractionDigits = zeroCount;
- }
-
- if (index == max)
- return index;
- }
-
- if (pattern.charAt(index) == syms.getExponential())
- {
- //
- // Scan exponential format.
- //
- zeroCount = 0;
- ++index;
- while (index < max)
- {
- char c = pattern.charAt(index);
- if (c == syms.getZeroDigit())
- ++zeroCount;
- else if (c == syms.getDigit())
- {
- if (zeroCount > 0)
- throw new
- IllegalArgumentException ("digit mark following zero " +
- "in exponent - index: " +
- index);
- }
- else if (patChars.indexOf(c) != -1)
- throw new IllegalArgumentException ("unexpected special " +
- "character - index: " +
- index);
- else
- break;
-
- ++index;
- }
-
- if (is_positive)
- {
- useExponentialNotation = true;
- minExponentDigits = (byte) zeroCount;
- }
- }
-
- return index;
- }
-
- // This helper function creates a string consisting of all the
- // characters which can appear in a pattern and must be quoted.
- private final String patternChars (DecimalFormatSymbols syms)
- {
- StringBuffer buf = new StringBuffer ();
- buf.append(syms.getDecimalSeparator());
- buf.append(syms.getDigit());
- buf.append(syms.getExponential());
- buf.append(syms.getGroupingSeparator());
- // Adding this one causes pattern application to fail.
- // Of course, omitting is causes toPattern to fail.
- // ... but we already have bugs there. FIXME.
- // buf.append(syms.getMinusSign());
- buf.append(syms.getPatternSeparator());
- buf.append(syms.getPercent());
- buf.append(syms.getPerMill());
- buf.append(syms.getZeroDigit());
- buf.append('\u00a4');
- return buf.toString();
- }
-
- private final void applyPatternWithSymbols (String pattern,
- DecimalFormatSymbols syms)
- {
- // Initialize to the state the parser expects.
- negativePrefix = "";
- negativeSuffix = "";
- positivePrefix = "";
- positiveSuffix = "";
- decimalSeparatorAlwaysShown = false;
- groupingSize = 0;
- minExponentDigits = 0;
- multiplier = 1;
- useExponentialNotation = false;
- groupingUsed = false;
- maximumFractionDigits = 0;
- maximumIntegerDigits = 309;
- minimumFractionDigits = 0;
- minimumIntegerDigits = 1;
-
- StringBuffer buf = new StringBuffer ();
- String patChars = patternChars (syms);
-
- int max = pattern.length();
- int index = scanFix (pattern, 0, buf, patChars, syms, false);
- positivePrefix = buf.toString();
-
- index = scanFormat (pattern, index, patChars, syms, true);
-
- index = scanFix (pattern, index, buf, patChars, syms, true);
- positiveSuffix = buf.toString();
-
- if (index == pattern.length())
- {
- // No negative info.
- negativePrefix = null;
- negativeSuffix = null;
- }
- else
- {
- if (pattern.charAt(index) != syms.getPatternSeparator())
- throw new IllegalArgumentException ("separator character " +
- "expected - index: " + index);
-
- index = scanFix (pattern, index + 1, buf, patChars, syms, false);
- negativePrefix = buf.toString();
-
- // We parse the negative format for errors but we don't let
- // it side-effect this object.
- index = scanFormat (pattern, index, patChars, syms, false);
-
- index = scanFix (pattern, index, buf, patChars, syms, true);
- negativeSuffix = buf.toString();
-
- if (index != pattern.length())
- throw new IllegalArgumentException ("end of pattern expected " +
- "- index: " + index);
- }
- }
-
- public void applyLocalizedPattern (String pattern)
- {
- // JCL p. 638 claims this throws a ParseException but p. 629
- // contradicts this. Empirical tests with patterns of "0,###.0"
- // and "#.#.#" corroborate the p. 629 statement that an
- // IllegalArgumentException is thrown.
- applyPatternWithSymbols (pattern, symbols);
- }
-
- public void applyPattern (String pattern)
- {
- // JCL p. 638 claims this throws a ParseException but p. 629
- // contradicts this. Empirical tests with patterns of "0,###.0"
- // and "#.#.#" corroborate the p. 629 statement that an
- // IllegalArgumentException is thrown.
- applyPatternWithSymbols (pattern, nonLocalizedSymbols);
- }
-
- public Object clone ()
- {
- return new DecimalFormat (this);
- }
-
- private DecimalFormat (DecimalFormat dup)
- {
- decimalSeparatorAlwaysShown = dup.decimalSeparatorAlwaysShown;
- groupingSize = dup.groupingSize;
- minExponentDigits = dup.minExponentDigits;
- multiplier = dup.multiplier;
- negativePrefix = dup.negativePrefix;
- negativeSuffix = dup.negativeSuffix;
- positivePrefix = dup.positivePrefix;
- positiveSuffix = dup.positiveSuffix;
- symbols = (DecimalFormatSymbols) dup.symbols.clone();
- useExponentialNotation = dup.useExponentialNotation;
- }
-
- public DecimalFormat ()
- {
- this ("#,##0.###");
- }
-
- public DecimalFormat (String pattern)
- {
- this (pattern, new DecimalFormatSymbols ());
- }
-
- public DecimalFormat (String pattern, DecimalFormatSymbols symbols)
- {
- this.symbols = symbols;
- applyPattern (pattern);
- }
-
- private final boolean equals (String s1, String s2)
- {
- if (s1 == null || s2 == null)
- return s1 == s2;
- return s1.equals(s2);
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof DecimalFormat))
- return false;
- DecimalFormat dup = (DecimalFormat) obj;
- return (decimalSeparatorAlwaysShown == dup.decimalSeparatorAlwaysShown
- && groupingSize == dup.groupingSize
- && minExponentDigits == dup.minExponentDigits
- && multiplier == dup.multiplier
- && equals(negativePrefix, dup.negativePrefix)
- && equals(negativeSuffix, dup.negativeSuffix)
- && equals(positivePrefix, dup.positivePrefix)
- && equals(positiveSuffix, dup.positiveSuffix)
- && symbols.equals(dup.symbols)
- && useExponentialNotation == dup.useExponentialNotation);
- }
-
- public StringBuffer format (double number, StringBuffer dest,
- FieldPosition fieldPos)
- {
- // A very special case.
- if (Double.isNaN(number))
- {
- dest.append(symbols.getNaN());
- if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD)
- {
- int index = dest.length();
- fieldPos.setBeginIndex(index - symbols.getNaN().length());
- fieldPos.setEndIndex(index);
- }
- return dest;
- }
-
- boolean is_neg = number < 0;
- if (is_neg)
- {
- if (negativePrefix != null)
- dest.append(negativePrefix);
- else
- {
- dest.append(symbols.getMinusSign());
- dest.append(positivePrefix);
- }
- number = - number;
- }
- else
- dest.append(positivePrefix);
-
- int integerBeginIndex = dest.length();
- int integerEndIndex = 0;
- if (Double.isInfinite (number))
- {
- dest.append(symbols.getInfinity());
- integerEndIndex = dest.length();
- }
- else
- {
- number *= multiplier;
-
- // Compute exponent.
- long exponent = 0;
- double baseNumber;
- if (useExponentialNotation)
- {
- exponent = (long) (Math.log(number) / Math.log(10));
- if (minimumIntegerDigits > 0)
- exponent -= minimumIntegerDigits - 1;
- baseNumber = (long) (number / Math.pow(10.0, exponent));
- }
- else
- baseNumber = number;
-
- // Round to the correct number of digits.
- baseNumber += 5 * Math.pow(10.0, - maximumFractionDigits - 1);
-
- int index = dest.length();
- double intPart = Math.floor(baseNumber);
- int count = 0;
- while (count < maximumIntegerDigits
- && (intPart > 0 || count < minimumIntegerDigits))
- {
- long dig = (long) (intPart % 10);
- intPart = Math.floor(intPart / 10);
-
- // Append group separator if required.
- if (groupingUsed && count > 0 && count % groupingSize == 0)
- dest.insert(index, symbols.getGroupingSeparator());
-
- dest.insert(index, (char) (symbols.getZeroDigit() + dig));
-
- ++count;
- }
-
- integerEndIndex = dest.length();
-
- int decimal_index = integerEndIndex;
- int consecutive_zeros = 0;
- int total_digits = 0;
-
- // Strip integer part from NUMBER.
- double fracPart = baseNumber - Math.floor(baseNumber);
- for (count = 0;
- count < maximumFractionDigits
- && (fracPart != 0 || count < minimumFractionDigits);
- ++count)
- {
- ++total_digits;
- fracPart *= 10;
- long dig = (long) fracPart;
- if (dig == 0)
- ++consecutive_zeros;
- else
- consecutive_zeros = 0;
- dest.append((char) (symbols.getZeroDigit() + dig));
-
- // Strip integer part from FRACPART.
- fracPart = fracPart - Math.floor (fracPart);
- }
-
- // Strip extraneous trailing `0's. We can't always detect
- // these in the loop.
- int extra_zeros = Math.min (consecutive_zeros,
- total_digits - minimumFractionDigits);
- if (extra_zeros > 0)
- {
- dest.setLength(dest.length() - extra_zeros);
- total_digits -= extra_zeros;
- }
-
- // If required, add the decimal symbol.
- if (decimalSeparatorAlwaysShown
- || total_digits > 0)
- {
- dest.insert(decimal_index, symbols.getDecimalSeparator());
- if (fieldPos != null && fieldPos.getField() == FRACTION_FIELD)
- {
- fieldPos.setBeginIndex(decimal_index + 1);
- fieldPos.setEndIndex(dest.length());
- }
- }
-
- // Finally, print the exponent.
- if (useExponentialNotation)
- {
- dest.append(symbols.getExponential());
- dest.append(exponent < 0 ? '-' : '+');
- index = dest.length();
- for (count = 0;
- exponent > 0 || count < minExponentDigits;
- ++count)
- {
- long dig = exponent % 10;
- exponent /= 10;
- dest.insert(index, (char) (symbols.getZeroDigit() + dig));
- }
- }
- }
-
- if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD)
- {
- fieldPos.setBeginIndex(integerBeginIndex);
- fieldPos.setEndIndex(integerEndIndex);
- }
-
- dest.append((is_neg && negativeSuffix != null)
- ? negativeSuffix
- : positiveSuffix);
- return dest;
- }
-
- public StringBuffer format (long number, StringBuffer dest,
- FieldPosition fieldPos)
- {
- // If using exponential notation, we just format as a double.
- if (useExponentialNotation)
- return format ((double) number, dest, fieldPos);
-
- boolean is_neg = number < 0;
- if (is_neg)
- {
- if (negativePrefix != null)
- dest.append(negativePrefix);
- else
- {
- dest.append(symbols.getMinusSign());
- dest.append(positivePrefix);
- }
- number = - number;
- }
- else
- dest.append(positivePrefix);
-
- int integerBeginIndex = dest.length();
- int index = dest.length();
- int count = 0;
- while (count < maximumIntegerDigits
- && (number > 0 || count < minimumIntegerDigits))
- {
- long dig = number % 10;
- number /= 10;
- // NUMBER and DIG will be less than 0 if the original number
- // was the most negative long.
- if (dig < 0)
- {
- dig = - dig;
- number = - number;
- }
-
- // Append group separator if required.
- if (groupingUsed && count > 0 && count % groupingSize == 0)
- dest.insert(index, symbols.getGroupingSeparator());
-
- dest.insert(index, (char) (symbols.getZeroDigit() + dig));
-
- ++count;
- }
-
- if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD)
- {
- fieldPos.setBeginIndex(integerBeginIndex);
- fieldPos.setEndIndex(dest.length());
- }
-
- if (decimalSeparatorAlwaysShown || minimumFractionDigits > 0)
- {
- dest.append(symbols.getDecimalSeparator());
- if (fieldPos != null && fieldPos.getField() == FRACTION_FIELD)
- {
- fieldPos.setBeginIndex(dest.length());
- fieldPos.setEndIndex(dest.length() + minimumFractionDigits);
- }
- }
-
- for (count = 0; count < minimumFractionDigits; ++count)
- dest.append(symbols.getZeroDigit());
-
- dest.append((is_neg && negativeSuffix != null)
- ? negativeSuffix
- : positiveSuffix);
- return dest;
- }
-
- public DecimalFormatSymbols getDecimalFormatSymbols ()
- {
- return symbols;
- }
-
- public int getGroupingSize ()
- {
- return groupingSize;
- }
-
- public int getMultiplier ()
- {
- return multiplier;
- }
-
- public String getNegativePrefix ()
- {
- return negativePrefix;
- }
-
- public String getNegativeSuffix ()
- {
- return negativeSuffix;
- }
-
- public String getPositivePrefix ()
- {
- return positivePrefix;
- }
-
- public String getPositiveSuffix ()
- {
- return positiveSuffix;
- }
-
- public int hashCode ()
- {
- int hash = (negativeSuffix.hashCode() ^ negativePrefix.hashCode()
- ^positivePrefix.hashCode() ^ positiveSuffix.hashCode());
- // FIXME.
- return hash;
- }
-
- public boolean isDecimalSeparatorAlwaysShown ()
- {
- return decimalSeparatorAlwaysShown;
- }
-
- public Number parse (String str, ParsePosition pos)
- {
- // Our strategy is simple: copy the text into a buffer,
- // translating or omitting locale-specific information. Then
- // let Double or Long convert the number for us.
-
- boolean is_neg = false;
- int index = pos.getIndex();
- StringBuffer buf = new StringBuffer ();
-
- // We have to check both prefixes, because one might be empty.
- // We want to pick the longest prefix that matches.
- boolean got_pos = str.startsWith(positivePrefix, index);
- String np = (negativePrefix != null
- ? negativePrefix
- : positivePrefix + symbols.getMinusSign());
- boolean got_neg = str.startsWith(np, index);
-
- if (got_pos && got_neg)
- {
- // By checking this way, we preserve ambiguity in the case
- // where the negative format differs only in suffix. We
- // check this again later.
- if (np.length() > positivePrefix.length())
- {
- is_neg = true;
- index += np.length();
- }
- else
- index += positivePrefix.length();
- }
- else if (got_neg)
- {
- is_neg = true;
- index += np.length();
- }
- else if (got_pos)
- index += positivePrefix.length();
- else
- {
- pos.setErrorIndex (index);
- return null;
- }
-
- // FIXME: handle Inf and NaN.
-
- // FIXME: do we have to respect minimum/maxmimum digit stuff?
- // What about leading zeros? What about multiplier?
-
- int start_index = index;
- int max = str.length();
- char zero = symbols.getZeroDigit();
- int last_group = -1;
- boolean int_part = true;
- boolean exp_part = false;
- for (; index < max; ++index)
- {
- char c = str.charAt(index);
-
- // FIXME: what about grouping size?
- if (groupingUsed && c == symbols.getGroupingSeparator())
- {
- if (last_group != -1
- && (index - last_group) % groupingSize != 0)
- {
- pos.setErrorIndex(index);
- return null;
- }
- last_group = index;
- }
- else if (c >= zero && c <= zero + 9)
- {
- buf.append((char) (c - zero + '0'));
- exp_part = false;
- }
- else if (parseIntegerOnly)
- break;
- else if (c == symbols.getDecimalSeparator())
- {
- if (last_group != -1
- && (index - last_group) % groupingSize != 0)
- {
- pos.setErrorIndex(index);
- return null;
- }
- buf.append('.');
- int_part = false;
- }
- else if (c == symbols.getExponential())
- {
- buf.append('E');
- int_part = false;
- exp_part = true;
- }
- else if (exp_part
- && (c == '+' || c == '-' || c == symbols.getMinusSign()))
- {
- // For exponential notation.
- buf.append(c);
- }
- else
- break;
- }
-
- if (index == start_index)
- {
- // Didn't see any digits.
- pos.setErrorIndex(index);
- return null;
- }
-
- // Check the suffix. We must do this before converting the
- // buffer to a number to handle the case of a number which is
- // the most negative Long.
- boolean got_pos_suf = str.startsWith(positiveSuffix, index);
- String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix);
- boolean got_neg_suf = str.startsWith(ns, index);
- if (is_neg)
- {
- if (! got_neg_suf)
- {
- pos.setErrorIndex(index);
- return null;
- }
- }
- else if (got_pos && got_neg && got_neg_suf)
- {
- is_neg = true;
- }
- else if (got_pos != got_pos_suf && got_neg != got_neg_suf)
- {
- pos.setErrorIndex(index);
- return null;
- }
-
- String suffix = is_neg ? ns : positiveSuffix;
- if (is_neg)
- buf.insert(0, '-');
-
- String t = buf.toString();
- Number result = null;
- try
- {
- result = new Long (t);
- }
- catch (NumberFormatException x1)
- {
- try
- {
- result = new Double (t);
- }
- catch (NumberFormatException x2)
- {
- }
- }
- if (result == null)
- {
- pos.setErrorIndex(index);
- return null;
- }
-
- pos.setIndex(index + suffix.length());
-
- return result;
- }
-
- public void setDecimalFormatSymbols (DecimalFormatSymbols newSymbols)
- {
- symbols = newSymbols;
- }
-
- public void setDecimalSeparatorAlwaysShown (boolean newValue)
- {
- decimalSeparatorAlwaysShown = newValue;
- }
-
- public void setGroupingSize (int groupSize)
- {
- groupingSize = (byte) groupSize;
- }
-
- public void setMaximumFractionDigits (int newValue)
- {
- maximumFractionDigits = Math.min(newValue, 340);
- }
-
- public void setMaximumIntegerDigits (int newValue)
- {
- maximumIntegerDigits = Math.min(newValue, 309);
- }
-
- public void setMinimumFractionDigits (int newValue)
- {
- minimumFractionDigits = Math.min(newValue, 340);
- }
-
- public void setMinimumIntegerDigits (int newValue)
- {
- minimumIntegerDigits = Math.min(newValue, 309);
- }
-
- public void setMultiplier (int newValue)
- {
- multiplier = newValue;
- }
-
- public void setNegativePrefix (String newValue)
- {
- negativePrefix = newValue;
- }
-
- public void setNegativeSuffix (String newValue)
- {
- negativeSuffix = newValue;
- }
-
- public void setPositivePrefix (String newValue)
- {
- positivePrefix = newValue;
- }
-
- public void setPositiveSuffix (String newValue)
- {
- positiveSuffix = newValue;
- }
-
- private final void quoteFix (StringBuffer buf, String text, String patChars)
- {
- int len = text.length();
- for (int index = 0; index < len; ++index)
- {
- char c = text.charAt(index);
- if (patChars.indexOf(c) != -1)
- {
- buf.append('\'');
- buf.append(c);
- buf.append('\'');
- }
- else
- buf.append(c);
- }
- }
-
- private final String computePattern (DecimalFormatSymbols syms)
- {
- StringBuffer mainPattern = new StringBuffer ();
- // We have to at least emit a zero for the minimum number of
- // digits. Past that we need hash marks up to the grouping
- // separator (and one beyond).
- int total_digits = Math.max(minimumIntegerDigits,
- groupingUsed ? groupingSize + 1: 0);
- for (int i = 0; i < total_digits - minimumIntegerDigits; ++i)
- mainPattern.append(syms.getDigit());
- for (int i = total_digits - minimumIntegerDigits; i < total_digits; ++i)
- mainPattern.append(syms.getZeroDigit());
- // Inserting the gropuing operator afterwards is easier.
- if (groupingUsed)
- mainPattern.insert(mainPattern.length() - groupingSize,
- syms.getGroupingSeparator());
- // See if we need decimal info.
- if (minimumFractionDigits > 0 || maximumFractionDigits > 0
- || decimalSeparatorAlwaysShown)
- mainPattern.append(syms.getDecimalSeparator());
- for (int i = 0; i < minimumFractionDigits; ++i)
- mainPattern.append(syms.getZeroDigit());
- for (int i = minimumFractionDigits; i < maximumFractionDigits; ++i)
- mainPattern.append(syms.getDigit());
- if (useExponentialNotation)
- {
- mainPattern.append(syms.getExponential());
- for (int i = 0; i < minExponentDigits; ++i)
- mainPattern.append(syms.getZeroDigit());
- if (minExponentDigits == 0)
- mainPattern.append(syms.getDigit());
- }
-
- String main = mainPattern.toString();
- String patChars = patternChars (syms);
- mainPattern.setLength(0);
-
- quoteFix (mainPattern, positivePrefix, patChars);
- mainPattern.append(main);
- quoteFix (mainPattern, positiveSuffix, patChars);
-
- if (negativePrefix != null)
- {
- quoteFix (mainPattern, negativePrefix, patChars);
- mainPattern.append(main);
- quoteFix (mainPattern, negativeSuffix, patChars);
- }
-
- return mainPattern.toString();
- }
-
- public String toLocalizedPattern ()
- {
- return computePattern (symbols);
- }
-
- public String toPattern ()
- {
- return computePattern (nonLocalizedSymbols);
- }
-
- // These names are fixed by the serialization spec.
- private boolean decimalSeparatorAlwaysShown;
- private byte groupingSize;
- private byte minExponentDigits;
- private int multiplier;
- private String negativePrefix;
- private String negativeSuffix;
- private String positivePrefix;
- private String positiveSuffix;
- private DecimalFormatSymbols symbols;
- private boolean useExponentialNotation;
-
- // The locale-independent pattern symbols happen to be the same as
- // the US symbols.
- private static final DecimalFormatSymbols nonLocalizedSymbols
- = new DecimalFormatSymbols (Locale.US);
-}
diff --git a/libjava/java/text/DecimalFormatSymbols.java b/libjava/java/text/DecimalFormatSymbols.java
deleted file mode 100644
index 1d51fbdb42f..00000000000
--- a/libjava/java/text/DecimalFormatSymbols.java
+++ /dev/null
@@ -1,293 +0,0 @@
-// DecimalFormatSymbols.java - Symbols used to format numbers.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-import java.io.Serializable;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 24, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Believed complete and correct to 1.2, except serialization.
- */
-
-public final class DecimalFormatSymbols implements Cloneable, Serializable
-{
- public Object clone ()
- {
- return new DecimalFormatSymbols (this);
- }
-
- private DecimalFormatSymbols (DecimalFormatSymbols orig)
- {
- this.currencySymbol = orig.currencySymbol;
- this.decimalSeparator = orig.decimalSeparator;
- this.digit = orig.digit;
- this.exponential = orig.exponential;
- this.groupingSeparator = orig.groupingSeparator;
- this.infinity = orig.infinity;
- this.intlCurrencySymbol = orig.intlCurrencySymbol;
- this.minusSign = orig.minusSign;
- this.NaN = orig.NaN;
- this.patternSeparator = orig.patternSeparator;
- this.percent = orig.percent;
- this.perMill = orig.perMill;
- this.zeroDigit = orig.zeroDigit;
- }
-
- public DecimalFormatSymbols ()
- {
- this (Locale.getDefault());
- }
-
- private final String safeGetString (ResourceBundle bundle,
- String name, String def)
- {
- if (bundle != null)
- {
- try
- {
- return bundle.getString(name);
- }
- catch (MissingResourceException x)
- {
- }
- }
- return def;
- }
-
- public final char safeGetChar (ResourceBundle bundle,
- String name, char def)
- {
- String r = null;
- if (bundle != null)
- {
- try
- {
- r = bundle.getString(name);
- }
- catch (MissingResourceException x)
- {
- }
- }
- if (r == null || r.length() < 1)
- return def;
- return r.charAt(0);
- }
-
- public DecimalFormatSymbols (Locale loc)
- {
- ResourceBundle res;
- try
- {
- res = ResourceBundle.getBundle("gnu.gcj.text.LocaleData", loc);
- }
- catch (MissingResourceException x)
- {
- res = null;
- }
- currencySymbol = safeGetString (res, "currencySymbol", "$");
- decimalSeparator = safeGetChar (res, "decimalSeparator", '.');
- digit = safeGetChar (res, "digit", '#');
- exponential = safeGetChar (res, "exponential", 'E');
- groupingSeparator = safeGetChar (res, "groupingSeparator", ',');
- infinity = safeGetString (res, "infinity", "\u221e");
- // FIXME: default?
- intlCurrencySymbol = safeGetString (res, "intlCurrencySymbol", "$");
- minusSign = safeGetChar (res, "minusSign", '-');
- NaN = safeGetString (res, "NaN", "\ufffd");
- patternSeparator = safeGetChar (res, "patternSeparator", ';');
- percent = safeGetChar (res, "percent", '%');
- perMill = safeGetChar (res, "perMill", '\u2030');
- zeroDigit = safeGetChar (res, "zeroDigit", '0');
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof DecimalFormatSymbols))
- return false;
- DecimalFormatSymbols dfs = (DecimalFormatSymbols) obj;
- return (currencySymbol.equals(dfs.currencySymbol)
- && decimalSeparator == dfs.decimalSeparator
- && digit == dfs.digit
- && exponential == dfs.exponential
- && groupingSeparator == dfs.groupingSeparator
- && infinity.equals(dfs.infinity)
- && intlCurrencySymbol.equals(dfs.intlCurrencySymbol)
- && minusSign == dfs.minusSign
- && NaN.equals(dfs.NaN)
- && patternSeparator == dfs.patternSeparator
- && percent == dfs.percent
- && perMill == dfs.perMill
- && zeroDigit == dfs.zeroDigit);
- }
-
- public String getCurrencySymbol ()
- {
- return currencySymbol;
- }
-
- public char getDecimalSeparator ()
- {
- return decimalSeparator;
- }
-
- public char getDigit ()
- {
- return digit;
- }
-
- // This is our own extension.
- char getExponential ()
- {
- return exponential;
- }
-
- public char getGroupingSeparator ()
- {
- return groupingSeparator;
- }
-
- public String getInfinity ()
- {
- return infinity;
- }
-
- public String getInternationalCurrencySymbol ()
- {
- return intlCurrencySymbol;
- }
-
- public char getMinusSign ()
- {
- return minusSign;
- }
-
- public String getNaN ()
- {
- return NaN;
- }
-
- public char getPatternSeparator ()
- {
- return patternSeparator;
- }
-
- public char getPercent ()
- {
- return percent;
- }
-
- public char getPerMill ()
- {
- return perMill;
- }
-
- public char getZeroDigit ()
- {
- return zeroDigit;
- }
-
- public int hashCode ()
- {
- // Compute based on zero digit, grouping separator, and decimal
- // separator -- JCL book. This probably isn't a very good hash
- // code.
- return zeroDigit << 16 + groupingSeparator << 8 + decimalSeparator;
- }
-
- public void setCurrenySymbol (String currency)
- {
- currencySymbol = currency;
- }
-
- public void setDecimalSeparator (char decimalSep)
- {
- decimalSeparator = decimalSep;
- }
-
- public void setDigit (char digit)
- {
- this.digit = digit;
- }
-
- // This is our own extension.
- void setExponential (char exp)
- {
- exponential = exp;
- }
-
- public void setGroupingSeparator (char groupSep)
- {
- groupingSeparator = groupSep;
- }
-
- public void setInfinity (String infinity)
- {
- this.infinity = infinity;
- }
-
- public void setInternationalCurrencySymbol (String currency)
- {
- intlCurrencySymbol = currency;
- }
-
- public void setMinusSign (char minusSign)
- {
- this.minusSign = minusSign;
- }
-
- public void setNaN (String nan)
- {
- NaN = nan;
- }
-
- public void setPatternSeparator (char patternSep)
- {
- patternSeparator = patternSep;
- }
-
- public void setPercent (char percent)
- {
- this.percent = percent;
- }
-
- public void setPerMill (char perMill)
- {
- this.perMill = perMill;
- }
-
- public void setZeroDigit (char zeroDigit)
- {
- this.zeroDigit = zeroDigit;
- }
-
- // The names of the instance variables are fixed by the
- // serialization spec.
- private String currencySymbol;
- private char decimalSeparator;
- private char digit;
- private char exponential;
- private char groupingSeparator;
- private String infinity;
- private String intlCurrencySymbol;
- private char minusSign;
- private String NaN;
- private char patternSeparator;
- private char percent;
- private char perMill;
- private char zeroDigit;
-}
diff --git a/libjava/java/text/FieldPosition.java b/libjava/java/text/FieldPosition.java
deleted file mode 100644
index c149e0eabb6..00000000000
--- a/libjava/java/text/FieldPosition.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.text;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- * Includes JDK 1.2 methods.
- */
-
-public class FieldPosition
-{
- int field;
- int beginIndex;
- int endIndex;
-
- public FieldPosition (int field)
- {
- this.field = field;
- }
-
- public int getField ()
- {
- return field;
- }
-
- public int getBeginIndex ()
- {
- return beginIndex;
- }
-
- public int getEndIndex ()
- {
- return endIndex;
- }
-
- public void setBeginIndex (int index)
- {
- beginIndex = index;
- }
-
- public void setEndIndex (int index)
- {
- endIndex = index;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof FieldPosition))
- return false;
- FieldPosition other = (FieldPosition) obj;
- return (field == other.field
- && beginIndex == other.beginIndex && endIndex == other.endIndex);
- }
-}
diff --git a/libjava/java/text/Format.java b/libjava/java/text/Format.java
deleted file mode 100644
index 8360415729b..00000000000
--- a/libjava/java/text/Format.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.text;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public abstract class Format implements java.io.Serializable, Cloneable
-{
- public Format ()
- {
- }
-
- public abstract StringBuffer format (Object obj,
- StringBuffer sbuf, FieldPosition pos);
-
- public final String format (Object obj)
- {
- StringBuffer sbuf = new StringBuffer();
- format(obj, sbuf, new FieldPosition(0));
- return sbuf.toString();
- }
-
- public abstract Object parseObject (String source, ParsePosition pos);
-
- public Object parseObject (String source) throws ParseException
- {
- ParsePosition pos = new ParsePosition(0);
- Object result = parseObject (source, pos);
- if (result == null)
- {
- int index = pos.getErrorIndex();
- if (index < 0)
- index = pos.getIndex();
- throw new ParseException("parseObject failed", index);
- }
- return result;
- }
-
- public Object clone ()
- {
- return super.clone ();
- }
-}
diff --git a/libjava/java/text/MessageFormat.java b/libjava/java/text/MessageFormat.java
deleted file mode 100644
index 7109fcf7d04..00000000000
--- a/libjava/java/text/MessageFormat.java
+++ /dev/null
@@ -1,544 +0,0 @@
-// MessageFormat.java - Localized message formatting.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-import java.util.Date;
-import java.util.Locale;
-import java.util.Vector;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 3, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Believed complete and correct to 1.2, except serialization.
- * and parsing.
- */
-
-final class MessageFormatElement
-{
- // Argument number.
- int argNumber;
- // Formatter to be used. This is the format set by setFormat.
- Format setFormat;
- // Formatter to be used based on the type.
- Format format;
-
- // Argument will be checked to make sure it is an instance of this
- // class.
- Class formatClass;
-
- // Formatter type.
- String type;
- // Formatter style.
- String style;
-
- // Text to follow this element.
- String trailer;
-
- // FIXME: shouldn't need this.
- Class forName (String name)
- {
- try
- {
- return Class.forName (name);
- }
- catch (ClassNotFoundException x)
- {
- }
- return null;
- }
-
- // Recompute the locale-based formatter.
- void setLocale (Locale loc)
- {
- if (type == null)
- ;
- else if (type.equals("number"))
- {
- // FIXME: named class literal.
- // formatClass = Number.class;
- formatClass = forName ("java.lang.Number");
-
- if (style == null)
- format = NumberFormat.getInstance(loc);
- else if (style.equals("currency"))
- format = NumberFormat.getCurrencyInstance(loc);
- else if (style.equals("percent"))
- format = NumberFormat.getPercentInstance(loc);
- else if (style.equals("integer"))
- {
- NumberFormat nf = NumberFormat.getNumberInstance(loc);
- nf.setMaximumFractionDigits(0);
- nf.setGroupingUsed(false);
- format = nf;
- }
- else
- {
- format = NumberFormat.getNumberInstance(loc);
- DecimalFormat df = (DecimalFormat) format;
- try
- {
- df.applyPattern(style);
- }
- catch (ParseException x)
- {
- throw new IllegalArgumentException (x.getMessage());
- }
- }
- }
- else if (type.equals("time") || type.equals("date"))
- {
- // FIXME: named class literal.
- // formatClass = Date.class;
- formatClass = forName ("java.util.Date");
-
- int val = DateFormat.DEFAULT;
- if (style == null)
- ;
- if (style.equals("short"))
- val = DateFormat.SHORT;
- else if (style.equals("medium"))
- val = DateFormat.MEDIUM;
- else if (style.equals("long"))
- val = DateFormat.LONG;
- else if (style.equals("full"))
- val = DateFormat.FULL;
-
- if (type.equals("time"))
- format = DateFormat.getTimeInstance(val, loc);
- else
- format = DateFormat.getDateInstance(val, loc);
-
- if (style != null && val == DateFormat.DEFAULT)
- {
- SimpleDateFormat sdf = (SimpleDateFormat) format;
- sdf.applyPattern(style);
- }
- }
- else if (type.equals("choice"))
- {
- // FIXME: named class literal.
- // formatClass = Number.class;
- formatClass = forName ("java.lang.Number");
-
- if (style == null)
- throw new
- IllegalArgumentException ("style required for choice format");
- format = new ChoiceFormat (style);
- }
- }
-}
-
-public class MessageFormat extends Format
-{
- // Helper that returns the text up to the next format opener. The
- // text is put into BUFFER. Returns index of character after end of
- // string. Throws IllegalArgumentException on error.
- private static final int scanString (String pat, int index,
- StringBuffer buffer)
- {
- int max = pat.length();
- buffer.setLength(0);
- for (; index < max; ++index)
- {
- char c = pat.charAt(index);
- if (c == '\'' && index + 2 < max && pat.charAt(index + 2) == '\'')
- {
- buffer.append(pat.charAt(index + 1));
- index += 2;
- }
- else if (c == '\'' && index + 1 < max
- && pat.charAt(index + 1) == '\'')
- {
- buffer.append(c);
- ++index;
- }
- else if (c == '{')
- break;
- else if (c == '}')
- throw new IllegalArgumentException ();
- else
- buffer.append(c);
- }
- return index;
- }
-
- // This helper retrieves a single part of a format element. Returns
- // the index of the terminating character.
- private static final int scanFormatElement (String pat, int index,
- StringBuffer buffer,
- char term)
- {
- int max = pat.length();
- buffer.setLength(0);
- int brace_depth = 1;
-
- for (; index < max; ++index)
- {
- char c = pat.charAt(index);
- if (c == '\'' && index + 2 < max && pat.charAt(index + 2) == '\'')
- {
- buffer.append(c);
- buffer.append(pat.charAt(index + 1));
- buffer.append(c);
- index += 2;
- }
- else if (c == '\'' && index + 1 < max
- && pat.charAt(index + 1) == '\'')
- {
- buffer.append(c);
- ++index;
- }
- else if (c == '{')
- {
- buffer.append(c);
- ++brace_depth;
- }
- else if (c == '}')
- {
- if (--brace_depth == 0)
- break;
- buffer.append(c);
- }
- // Check for TERM after braces, because TERM might be `}'.
- else if (c == term)
- break;
- else
- buffer.append(c);
- }
- return index;
- }
-
- // This is used to parse a format element and whatever non-format
- // text might trail it.
- private static final int scanFormat (String pat, int index,
- StringBuffer buffer, Vector elts,
- Locale locale)
- {
- MessageFormatElement mfe = new MessageFormatElement ();
- elts.addElement(mfe);
-
- int max = pat.length();
-
- // Skip the opening `{'.
- ++index;
-
- // Fetch the argument number.
- index = scanFormatElement (pat, index, buffer, ',');
- try
- {
- mfe.argNumber = Integer.parseInt(buffer.toString());
- }
- catch (NumberFormatException nfx)
- {
- throw new IllegalArgumentException ();
- }
-
- // Extract the element format.
- if (index < max && pat.charAt(index) == ',')
- {
- index = scanFormatElement (pat, index + 1, buffer, ',');
- mfe.type = buffer.toString();
-
- // Extract the style.
- if (index < max && pat.charAt(index) == ',')
- {
- index = scanFormatElement (pat, index + 1, buffer, '}');
- mfe.style = buffer.toString ();
- }
- }
-
- // Advance past the last terminator.
- if (index >= max || pat.charAt(index) != '}')
- throw new IllegalArgumentException ();
- ++index;
-
- // Now fetch trailing string.
- index = scanString (pat, index, buffer);
- mfe.trailer = buffer.toString ();
-
- mfe.setLocale(locale);
-
- return index;
- }
-
- public void applyPattern (String newPattern)
- {
- pattern = newPattern;
-
- StringBuffer tempBuffer = new StringBuffer ();
-
- int index = scanString (newPattern, 0, tempBuffer);
- leader = tempBuffer.toString();
-
- Vector elts = new Vector ();
- while (index < newPattern.length())
- index = scanFormat (newPattern, index, tempBuffer, elts, locale);
-
- elements = new MessageFormatElement[elts.size()];
- elts.copyInto(elements);
- }
-
- public Object clone ()
- {
- MessageFormat c = new MessageFormat ();
- c.setLocale(locale);
- c.applyPattern(pattern);
- return (Object) c;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof MessageFormat))
- return false;
- MessageFormat mf = (MessageFormat) obj;
- return (pattern.equals(mf.pattern)
- && locale.equals(mf.locale));
- }
-
- public static String format (String pattern, Object arguments[])
- {
- MessageFormat mf = new MessageFormat (pattern);
- StringBuffer sb = new StringBuffer ();
- FieldPosition fp = new FieldPosition (NumberFormat.INTEGER_FIELD);
- return mf.format(arguments, sb, fp).toString();
- }
-
- public final StringBuffer format (Object arguments[], StringBuffer appendBuf,
- FieldPosition ignore)
- {
- appendBuf.append(leader);
-
- for (int i = 0; i < elements.length; ++i)
- {
- if (elements[i].argNumber >= arguments.length)
- throw new IllegalArgumentException ();
- Object thisArg = arguments[elements[i].argNumber];
-
- Format formatter = null;
- if (elements[i].setFormat != null)
- formatter = elements[i].setFormat;
- else if (elements[i].format != null)
- {
- if (elements[i].formatClass != null
- && ! elements[i].formatClass.isInstance(thisArg))
- throw new IllegalArgumentException ();
- formatter = elements[i].format;
- }
- else if (thisArg instanceof Number)
- formatter = NumberFormat.getInstance(locale);
- else if (thisArg instanceof Date)
- formatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale);
- else
- appendBuf.append(thisArg);
-
- if (formatter != null)
- {
- // Special-case ChoiceFormat.
- if (formatter instanceof ChoiceFormat)
- {
- StringBuffer buf = new StringBuffer ();
- // FIXME: don't actually know what is correct here.
- // Can a sub-format refer to any argument, or just
- // the single argument passed to it? Must test
- // against JDK.
- formatter.format(thisArg, buf, ignore);
- MessageFormat mf = new MessageFormat ();
- mf.setLocale(locale);
- mf.applyPattern(buf.toString());
- formatter = mf;
- }
- formatter.format(thisArg, appendBuf, ignore);
- }
-
- appendBuf.append(elements[i].trailer);
- }
-
- return appendBuf;
- }
-
- public final StringBuffer format (Object singleArg, StringBuffer appendBuf,
- FieldPosition ignore)
- {
- Object[] args = new Object[1];
- args[0] = singleArg;
- return format (args, appendBuf, ignore);
- }
-
- public Format[] getFormats ()
- {
- Format[] f = new Format[elements.length];
- for (int i = elements.length - 1; i >= 0; --i)
- f[i] = elements[i].setFormat;
- return f;
- }
-
- public Locale getLocale ()
- {
- return locale;
- }
-
- public int hashCode ()
- {
- // FIXME: not a very good hash.
- return pattern.hashCode() + locale.hashCode();
- }
-
- private MessageFormat ()
- {
- }
-
- public MessageFormat (String pattern)
- {
- locale = Locale.getDefault();
- applyPattern (pattern);
- }
-
- public Object[] parse (String sourceStr, ParsePosition pos)
- {
- // Check initial text.
- int index = pos.getIndex();
- if (! sourceStr.startsWith(leader, index))
- {
- pos.setErrorIndex(index);
- return null;
- }
- index += leader.length();
-
- Vector results = new Vector (elements.length, 1);
- // Now check each format.
- for (int i = 0; i < elements.length; ++i)
- {
- Format formatter = null;
- if (elements[i].setFormat != null)
- formatter = elements[i].setFormat;
- else if (elements[i].format != null)
- formatter = elements[i].format;
-
- Object value = null;
- if (formatter instanceof ChoiceFormat)
- {
- // We must special-case a ChoiceFormat because it might
- // have recursive formatting.
- ChoiceFormat cf = (ChoiceFormat) formatter;
- String[] formats = (String[]) cf.getFormats();
- double[] limits = (double[]) cf.getLimits();
- MessageFormat subfmt = new MessageFormat ();
- subfmt.setLocale(locale);
- ParsePosition subpos = new ParsePosition (index);
-
- int j;
- for (j = 0; value == null && j < limits.length; ++j)
- {
- subfmt.applyPattern(formats[j]);
- subpos.setIndex(index);
- value = subfmt.parse(sourceStr, subpos);
- }
- if (value != null)
- {
- index = subpos.getIndex();
- value = new Double (limits[j]);
- }
- }
- else if (formatter != null)
- {
- pos.setIndex(index);
- value = formatter.parseObject(sourceStr, pos);
- if (value != null)
- index = pos.getIndex();
- }
- else
- {
- // We have a String format. This can lose in a number
- // of ways, but we give it a shot.
- int next_index = sourceStr.indexOf(elements[i].trailer, index);
- if (next_index == -1)
- {
- pos.setErrorIndex(index);
- return null;
- }
- value = sourceStr.substring(index, next_index);
- index = next_index;
- }
-
- if (value == null
- || ! sourceStr.startsWith(elements[i].trailer, index))
- {
- pos.setErrorIndex(index);
- return null;
- }
-
- if (elements[i].argNumber >= results.size())
- results.setSize(elements[i].argNumber + 1);
- results.setElementAt(value, elements[i].argNumber);
-
- index += elements[i].trailer.length();
- }
-
- Object[] r = new Object[results.size()];
- results.copyInto(r);
- return r;
- }
-
- public Object[] parse (String sourceStr) throws ParseException
- {
- ParsePosition pp = new ParsePosition (0);
- Object[] r = parse (sourceStr, pp);
- if (r == null)
- throw new ParseException ("couldn't parse string", pp.getErrorIndex());
- return r;
- }
-
- public Object parseObject (String sourceStr, ParsePosition pos)
- {
- return parse (sourceStr, pos);
- }
-
- public void setFormat (int variableNum, Format newFormat)
- {
- elements[variableNum].setFormat = newFormat;
- }
-
- public void setFormats (Format[] newFormats)
- {
- if (newFormats.length < elements.length)
- throw new IllegalArgumentException ();
- int len = Math.min(newFormats.length, elements.length);
- for (int i = 0; i < len; ++i)
- elements[i].setFormat = newFormats[i];
- }
-
- public void setLocale (Locale loc)
- {
- locale = loc;
- if (elements != null)
- {
- for (int i = 0; i < elements.length; ++i)
- elements[i].setLocale(loc);
- }
- }
-
- public String toPattern ()
- {
- return pattern;
- }
-
- // The pattern string.
- private String pattern;
- // The locale.
- private Locale locale;
- // Variables.
- private MessageFormatElement[] elements;
- // Leader text.
- private String leader;
-}
diff --git a/libjava/java/text/NumberFormat.java b/libjava/java/text/NumberFormat.java
deleted file mode 100644
index 3a30010b073..00000000000
--- a/libjava/java/text/NumberFormat.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.text;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.MissingResourceException;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 4, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Believed complete and correct to 1.2, except serialization
- * and getAvailableLocales.
- */
-
-public abstract class NumberFormat extends Format implements Cloneable
-{
- public static final int INTEGER_FIELD = 0;
- public static final int FRACTION_FIELD = 1;
-
- public final String format (long number)
- {
- StringBuffer sbuf = new StringBuffer(50);
- format (number, sbuf, null);
- return sbuf.toString();
- }
-
- public final StringBuffer format (Object obj, StringBuffer sbuf,
- FieldPosition pos)
- {
- if (obj instanceof Number)
- return format(((Number) obj).doubleValue(), sbuf, pos);
- else
- throw new IllegalArgumentException
- ("Cannot format given Object as a Number");
- }
-
- public abstract StringBuffer format (double number,
- StringBuffer sbuf, FieldPosition pos);
-
- public abstract StringBuffer format (long number,
- StringBuffer sbuf, FieldPosition pos);
-
- public Object clone ()
- {
- // We know the superclass just uses Object's generic cloner.
- // Why not just inherit? Because the online docs specify that
- // this method exists for this class.
- return super.clone ();
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof NumberFormat))
- return false;
- NumberFormat nf = (NumberFormat) obj;
- return (groupingUsed == nf.groupingUsed
- && maximumFractionDigits == nf.maximumFractionDigits
- && maximumIntegerDigits == nf.maximumIntegerDigits
- && minimumFractionDigits == nf.minimumFractionDigits
- && minimumIntegerDigits == nf.minimumIntegerDigits
- && parseIntegerOnly == nf.parseIntegerOnly);
- }
-
- public static Locale[] getAvailableLocales ()
- {
- // FIXME.
- return null;
- }
-
- private static final NumberFormat computeInstance (Locale loc,
- String resource,
- String def)
- {
- ResourceBundle res;
- try
- {
- res = ResourceBundle.getBundle("gnu.gcj.text.LocaleData", loc);
- }
- catch (MissingResourceException x)
- {
- res = null;
- }
- String fmt;
- try
- {
- fmt = res == null ? def : res.getString(resource);
- }
- catch (MissingResourceException x)
- {
- fmt = def;
- }
- DecimalFormatSymbols dfs = new DecimalFormatSymbols (loc);
- return new DecimalFormat (fmt, dfs);
- }
-
- public static final NumberFormat getCurrencyInstance ()
- {
- return getCurrencyInstance (Locale.getDefault());
- }
-
- public static NumberFormat getCurrencyInstance (Locale loc)
- {
- return computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)");
- }
-
- public static final NumberFormat getInstance ()
- {
- return getInstance (Locale.getDefault());
- }
-
- public static NumberFormat getInstance (Locale loc)
- {
- // For now always return a number instance.
- return getNumberInstance (loc);
- }
-
- public int getMaximumFractionDigits ()
- {
- return maximumFractionDigits;
- }
-
- public int getMaximumIntegerDigits ()
- {
- return maximumIntegerDigits;
- }
-
- public int getMinimumFractionDigits ()
- {
- return minimumFractionDigits;
- }
-
- public int getMinimumIntegerDigits ()
- {
- return minimumIntegerDigits;
- }
-
- public static final NumberFormat getNumberInstance ()
- {
- return getNumberInstance (Locale.getDefault());
- }
-
- public static NumberFormat getNumberInstance (Locale loc)
- {
- return computeInstance (loc, "numberFormat", "#,##0.###");
- }
-
- public static final NumberFormat getPercentInstance ()
- {
- return getPercentInstance (Locale.getDefault());
- }
-
- public static NumberFormat getPercentInstance (Locale loc)
- {
- return computeInstance (loc, "percentFormat", "#,##0%");
- }
-
- public int hashCode ()
- {
- int hash = super.hashCode();
- hash ^= (maximumFractionDigits + maximumIntegerDigits
- + minimumFractionDigits + minimumIntegerDigits);
- if (groupingUsed)
- hash ^= 0xf0f0;
- if (parseIntegerOnly)
- hash ^= 0x0f0f;
- return hash;
- }
-
- public boolean isGroupingUsed ()
- {
- return groupingUsed;
- }
-
- public boolean isParseIntegerOnly ()
- {
- return parseIntegerOnly;
- }
-
- public NumberFormat ()
- {
- }
-
- public abstract Number parse (String sourceStr, ParsePosition pos);
-
- public Number parse (String sourceStr) throws ParseException
- {
- ParsePosition pp = new ParsePosition (0);
- Number r = parse (sourceStr, pp);
- if (r == null)
- {
- int index = pp.getErrorIndex();
- if (index < 0)
- index = pp.getIndex();
- throw new ParseException ("couldn't parse number", index);
- }
- return r;
- }
-
- public final Object parseObject (String sourceStr, ParsePosition pos)
- {
- return parse (sourceStr, pos);
- }
-
- public void setGroupingUsed (boolean newValue)
- {
- groupingUsed = newValue;
- }
-
- public void setMaximumFractionDigits (int newValue)
- {
- maximumFractionDigits = newValue;
- }
-
- public void setMaximumIntegerDigits (int newValue)
- {
- maximumIntegerDigits = newValue;
- }
-
- public void setMinimumFractionDigits (int newValue)
- {
- minimumFractionDigits = newValue;
- }
-
- public void setMinimumIntegerDigits (int newValue)
- {
- minimumIntegerDigits = newValue;
- }
-
- public void setParseIntegerOnly (boolean value)
- {
- parseIntegerOnly = value;
- }
-
- public final String format (double number)
- {
- StringBuffer sbuf = new StringBuffer(50);
- format (number, sbuf, null);
- return sbuf.toString();
- }
-
- // These field names are fixed by the serialization spec.
- // FIXME: serialization spec also mentions `byte' versions of the
- // min/max fields. We have no use for those, so for now they are
- // omitted.
- protected boolean groupingUsed;
- protected int maximumFractionDigits;
- protected int maximumIntegerDigits;
- protected int minimumFractionDigits;
- protected int minimumIntegerDigits;
- protected boolean parseIntegerOnly;
-}
diff --git a/libjava/java/text/ParseException.java b/libjava/java/text/ParseException.java
deleted file mode 100644
index 7a654393aec..00000000000
--- a/libjava/java/text/ParseException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.text;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class ParseException extends Exception
-{
- private int errorOffset;
-
- public ParseException (String msg, int errorOffset)
- {
- super(msg);
- this.errorOffset = errorOffset;
- }
-
- public int getErrorOffset ()
- {
- return errorOffset;
- }
-}
diff --git a/libjava/java/text/ParsePosition.java b/libjava/java/text/ParsePosition.java
deleted file mode 100644
index 55f7f8bb123..00000000000
--- a/libjava/java/text/ParsePosition.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.text;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- * Includes JDK 1.2 methods.
- */
-
-public class ParsePosition
-{
- int index;
- int errorIndex;
-
- public ParsePosition (int index)
- {
- this.index = index;
- errorIndex = -1;
- }
-
- public int getIndex ()
- {
- return index;
- }
-
- public void setIndex (int index)
- {
- this.index = index;
- }
-
- public int getErrorIndex ()
- {
- return errorIndex;
- }
-
- public void setErrorIndex (int ei)
- {
- errorIndex = ei;
- }
-
- public boolean equals (Object obj)
- {
- if (obj != null || ! (obj instanceof ParsePosition))
- return false;
- ParsePosition other = (ParsePosition) obj;
- return index == other.index && errorIndex == other.errorIndex;
- }
-}
diff --git a/libjava/java/text/RuleBasedCollator.java b/libjava/java/text/RuleBasedCollator.java
deleted file mode 100644
index c70dbcefe44..00000000000
--- a/libjava/java/text/RuleBasedCollator.java
+++ /dev/null
@@ -1,366 +0,0 @@
-// RuleBasedCollator.java - Concrete class for locale-based string compare.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date March 25, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-class RBCElement
-{
- String key;
- char relation;
-
- RBCElement (String key, char relation)
- {
- this.key = key;
- this.relation = relation;
- }
-}
-
-public class RuleBasedCollator extends Collator
-{
- public Object clone ()
- {
- return new RuleBasedCollator (this);
- }
-
- // A helper for CollationElementIterator.next().
- int ceiNext (CollationElementIterator cei)
- {
- if (cei.lookahead_set)
- {
- cei.lookahead_set = false;
- return cei.lookahead;
- }
-
- int save = cei.index;
- int max = cei.text.length();
- String s = null;
-
- // It is possible to have a case where `abc' has a mapping, but
- // neither `ab' nor `abd' do. In this case we must treat `abd' as
- // nothing special.
- boolean found = false;
-
- int i;
- for (i = save + 1; i <= max; ++i)
- {
- s = cei.text.substring(save, i);
- if (prefixes.get(s) == null)
- break;
- found = true;
- }
- // Assume s != null.
-
- Object obj = map.get(s);
- // The special case.
- while (found && obj == null && s.length() > 1)
- {
- --i;
- s = cei.text.substring(save, i);
- obj = map.get(s);
- }
-
- // Update state.
- cei.index = i;
-
- if (obj == null)
- {
- // This idea, and the values, come from JDK.
- // assert (s.length() == 1)
- cei.lookahead_set = true;
- cei.lookahead = s.charAt(0) << 8;
- return 0x7fff << 16;
- }
-
- return ((Integer) obj).intValue();
- }
-
- // A helper for compareTo() that returns the next character that has
- // a nonzero ordering at the indicated strength. This is also used
- // in CollationKey.
- static final int next (CollationElementIterator iter, int strength)
- {
- while (true)
- {
- int os = iter.next();
- if (os == CollationElementIterator.NULLORDER)
- return os;
- int c = 0;
- switch (strength)
- {
- case PRIMARY:
- c = os & ~0xffff;
- break;
- case SECONDARY:
- c = os & ~0x00ff;
- break;
- case TERTIARY:
- case IDENTICAL:
- c = os;
- break;
- }
- if (c != 0)
- return c;
- }
- }
-
- public int compare (String source, String target)
- {
- CollationElementIterator cs, ct;
-
- cs = new CollationElementIterator (source, this);
- ct = new CollationElementIterator (target, this);
-
- while (true)
- {
- int os = next (cs, strength);
- int ot = next (ct, strength);
-
- if (os == CollationElementIterator.NULLORDER
- && ot == CollationElementIterator.NULLORDER)
- break;
- else if (os == CollationElementIterator.NULLORDER)
- {
- // Source string is shorter, so return "less than".
- return -1;
- }
- else if (ot == CollationElementIterator.NULLORDER)
- {
- // Target string is shorter, so return "greater than".
- return 1;
- }
-
- if (os != ot)
- return os - ot;
- }
-
- return 0;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof RuleBasedCollator) || ! super.equals(obj))
- return false;
- RuleBasedCollator rbc = (RuleBasedCollator) obj;
- // FIXME: this is probably wrong. Instead we should compare maps
- // directly.
- return (frenchAccents == rbc.frenchAccents
- && rules.equals(rbc.rules));
- }
-
- public CollationElementIterator getCollationElementIterator (String source)
- {
- StringBuffer expand = new StringBuffer (source.length());
- int max = source.length();
- for (int i = 0; i < max; ++i)
- decomposeCharacter (source.charAt(i), expand);
- return new CollationElementIterator (expand.toString(), this);
- }
-
- public CollationKey getCollationKey (String source)
- {
- return new CollationKey (getCollationElementIterator (source), source,
- strength);
- }
-
- public String getRules ()
- {
- return rules;
- }
-
- public int hashCode ()
- {
- return (frenchAccents ? 1231 : 1237
- ^ rules.hashCode()
- ^ map.hashCode()
- ^ prefixes.hashCode());
- }
-
- private final boolean is_special (char c)
- {
- // Rules from JCL book.
- return ((c >= 0x0009 && c <= 0x000d)
- || (c >= 0x0020 && c <= 0x002f)
- || (c >= 0x003a && c <= 0x0040)
- || (c >= 0x005b && c <= 0x0060)
- || (c >= 0x007b && c <= 0x007e));
- }
-
- private final int text_argument (String rules, int index,
- StringBuffer result)
- {
- result.setLength(0);
- int len = rules.length();
- while (index < len)
- {
- char c = rules.charAt(index);
- if (c == '\'' && index + 2 < len
- && rules.charAt(index + 2) == '\''
- && is_special (rules.charAt(index + 1)))
- index += 2;
- else if (is_special (c) || Character.isWhitespace(c))
- return index;
- result.append(c);
- ++index;
- }
- return index;
- }
-
- public RuleBasedCollator (String rules) throws ParseException
- {
- this.rules = rules;
- this.frenchAccents = false;
-
- // We keep each rule in order in a vector. At the end we traverse
- // the vector and compute collation values from it.
- int insertion_index = 0;
- Vector vec = new Vector ();
-
- StringBuffer argument = new StringBuffer ();
-
- int len = rules.length();
- for (int index = 0; index < len; ++index)
- {
- char c = rules.charAt(index);
-
- // Just skip whitespace.
- if (Character.isWhitespace(c))
- continue;
-
- // Modifier.
- if (c == '@')
- {
- frenchAccents = true;
- continue;
- }
-
- // Check for relation or reset operator.
- if (! (c == '<' || c == ';' || c == ',' || c == '=' || c == '&'))
- throw new ParseException ("invalid character", index);
-
- ++index;
- while (index < len)
- {
- if (! Character.isWhitespace(rules.charAt(index)))
- break;
- ++index;
- }
- if (index == len)
- throw new ParseException ("missing argument", index);
-
- int save = index;
- index = text_argument (rules, index, argument);
- if (argument.length() == 0)
- throw new ParseException ("invalid character", save);
- String arg = argument.toString();
- int item_index = vec.indexOf(arg);
- if (c != '&')
- {
- // If the argument already appears in the vector, then we
- // must remove it in order to re-order.
- if (item_index != -1)
- {
- vec.removeElementAt(item_index);
- if (insertion_index >= item_index)
- --insertion_index;
- }
- RBCElement r = new RBCElement (arg, c);
- vec.insertElementAt(r, insertion_index);
- ++insertion_index;
- }
- else
- {
- // Reset.
- if (item_index == -1)
- throw
- new ParseException ("argument to reset not previously seen",
- save);
- insertion_index = item_index + 1;
- }
-
- // Ugly: in this case the resulting INDEX comes from
- // text_argument, which returns the index of the next
- // character we should examine.
- --index;
- }
-
- // Now construct a hash table that maps strings onto their
- // collation values.
- int primary = 0;
- int secondary = 0;
- int tertiary = 0;
- this.map = new Hashtable ();
- this.prefixes = new Hashtable ();
- Enumeration e = vec.elements();
- while (e.hasMoreElements())
- {
- RBCElement r = (RBCElement) e.nextElement();
- switch (r.relation)
- {
- case '<':
- ++primary;
- secondary = 0;
- tertiary = 0;
- break;
- case ';':
- ++secondary;
- tertiary = 0;
- break;
- case ',':
- ++tertiary;
- break;
- case '=':
- break;
- }
- // This must match CollationElementIterator.
- map.put(r.key, new Integer (primary << 16
- | secondary << 8 | tertiary));
-
- // Make a map of all lookaheads we might need.
- for (int i = r.key.length() - 1; i >= 1; --i)
- prefixes.put(r.key.substring(0, i), Boolean.TRUE);
- }
- }
-
- // This is a helper for clone.
- private RuleBasedCollator (RuleBasedCollator other)
- {
- frenchAccents = other.frenchAccents;
- rules = other.rules;
- decmp = other.decmp;
- strength = other.strength;
- map = other.map;
- prefixes = other.prefixes;
- }
-
- // True if we are using French-style accent ordering.
- private boolean frenchAccents;
-
- // It's easier to just save the rules than to try to recreate them.
- private String rules;
-
- // This maps strings onto collation values.
- private Hashtable map;
- // An entry in this hash means that more lookahead is required for
- // the prefix string.
- private Hashtable prefixes;
-}
diff --git a/libjava/java/text/SimpleDateFormat.java b/libjava/java/text/SimpleDateFormat.java
deleted file mode 100644
index 08ed3175c56..00000000000
--- a/libjava/java/text/SimpleDateFormat.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.text;
-
-import java.util.*;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: parse is not implemented.
- */
-
-public class SimpleDateFormat extends DateFormat
-{
- private Date defaultCenturyStart;
- private DateFormatSymbols formatData;
- private String pattern;
-
- public SimpleDateFormat ()
- {
- this("dd/MM/yy HH:mm", Locale.getDefault());
- }
-
- public SimpleDateFormat (String pattern)
- {
- this(pattern, Locale.getDefault());
- }
-
- public SimpleDateFormat (String pattern, Locale locale)
- {
- this.pattern = pattern;
- this.calendar = Calendar.getInstance(locale);
- this.numberFormat = NumberFormat.getInstance(locale);
- numberFormat.setGroupingUsed(false);
- this.formatData = new DateFormatSymbols (locale);
- }
-
- public SimpleDateFormat (String pattern, DateFormatSymbols formatData)
- {
- this.pattern = pattern;
- this.formatData = formatData;
- this.calendar = Calendar.getInstance();
- this.numberFormat = NumberFormat.getInstance();
- numberFormat.setGroupingUsed(false);
- }
-
- public Date get2DigitYearStart()
- {
- return defaultCenturyStart;
- }
-
- public void set2DigitYearStart(Date startDate)
- {
- defaultCenturyStart = startDate;
- }
-
- public DateFormatSymbols getDateFormatSymbols ()
- {
- return formatData;
- }
-
- public void setDateFormatSymbols (DateFormatSymbols value)
- {
- formatData = value;
- }
-
- public String toPattern ()
- {
- return pattern;
- }
-
- public void applyPattern (String pattern)
- {
- this.pattern = pattern;
- }
-
- private String applyLocalizedPattern (String pattern,
- String oldChars, String newChars)
- {
- int len = pattern.length();
- StringBuffer buf = new StringBuffer(len);
- boolean quoted = false;
- for (int i = 0; i < len; i++)
- {
- char ch = pattern.charAt(i);
- if (ch == '\'')
- quoted = ! quoted;
- if (! quoted)
- {
- int j = oldChars.indexOf(ch);
- if (j >= 0)
- ch = newChars.charAt(j);
- }
- buf.append(ch);
- }
- return buf.toString();
- }
-
- public void applyLocalizedPattern (String pattern)
- {
- String localChars = formatData.getLocalPatternChars();
- String standardChars = DateFormatSymbols.localPatternCharsDefault;
- pattern = applyLocalizedPattern (pattern, localChars, standardChars);
- applyPattern(pattern);
- }
-
- public String toLocalizedPattern ()
- {
- String localChars = formatData.getLocalPatternChars();
- String standardChars = DateFormatSymbols.localPatternCharsDefault;
- return applyLocalizedPattern (pattern, standardChars, localChars);
- }
-
- private final void append (StringBuffer buf, int value, int numDigits)
- {
- numberFormat.setMinimumIntegerDigits(numDigits);
- numberFormat.format(value, buf, null);
- }
-
- public StringBuffer format (Date date, StringBuffer buf, FieldPosition pos)
- {
- Calendar calendar = (Calendar) this.calendar.clone();
- calendar.setTime(date);
- int len = pattern.length();
- int quoteStart = -1;
- for (int i = 0; i < len; i++)
- {
- char ch = pattern.charAt(i);
- if (ch == '\'')
- {
- // We must do a little lookahead to see if we have two
- // single quotes embedded in quoted text.
- if (i < len - 1 && pattern.charAt(i + 1) == '\'')
- {
- ++i;
- buf.append(ch);
- }
- else
- quoteStart = quoteStart < 0 ? i : -1;
- }
- // From JCL: any characters in the pattern that are not in
- // the ranges of [a..z] and [A..Z] are treated as quoted
- // text.
- else if (quoteStart != -1
- || ((ch < 'a' || ch > 'z')
- && (ch < 'A' || ch > 'Z')))
- buf.append(ch);
- else
- {
- int first = i;
- int value;
- while (++i < len && pattern.charAt(i) == ch) ;
- int count = i - first; // Number of repetions of ch in pattern.
- int beginIndex = buf.length();
- int field;
- i--; // Skip all but last instance of ch in pattern.
- switch (ch)
- {
- case 'd':
- append(buf, calendar.get(Calendar.DATE), count);
- field = DateFormat.DATE_FIELD;
- break;
- case 'D':
- append(buf, calendar.get(Calendar.DAY_OF_YEAR), count);
- field = DateFormat.DAY_OF_YEAR_FIELD;
- break;
- case 'F':
- append(buf, calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH),count);
- field = DateFormat.DAY_OF_WEEK_IN_MONTH_FIELD;
- break;
- case 'E':
- value = calendar.get(calendar.DAY_OF_WEEK);
- buf.append(count <= 3 ? formatData.getShortWeekdays()[value]
- : formatData.getWeekdays()[value]);
- field = DateFormat.DAY_OF_WEEK_FIELD;
- break;
- case 'w':
- append(buf, calendar.get(Calendar.WEEK_OF_YEAR), count);
- field = DateFormat.WEEK_OF_YEAR_FIELD;
- break;
- case 'W':
- append(buf, calendar.get(Calendar.WEEK_OF_MONTH), count);
- field = DateFormat.WEEK_OF_MONTH_FIELD;
- break;
- case 'M':
- value = calendar.get(Calendar.MONTH);
- if (count <= 2)
- append(buf, value + 1, count);
- else
- buf.append(count <= 3 ? formatData.getShortMonths()[value]
- : formatData.getMonths()[value]);
- field = DateFormat.MONTH_FIELD;
- break;
- case 'y':
- value = calendar.get(Calendar.YEAR);
- append(buf, count <= 2 ? value % 100 : value, count);
- field = DateFormat.YEAR_FIELD;
- break;
- case 'K':
- append(buf, calendar.get(Calendar.HOUR), count);
- field = DateFormat.HOUR0_FIELD;
- break;
- case 'h':
- value = ((calendar.get(Calendar.HOUR) + 11) % 12) + 1;
- append(buf, value, count);
- field = DateFormat.HOUR1_FIELD;
- break;
- case 'H':
- append(buf, calendar.get(Calendar.HOUR_OF_DAY), count);
- field = DateFormat.HOUR_OF_DAY0_FIELD;
- break;
- case 'k':
- value = ((calendar.get(Calendar.HOUR_OF_DAY) + 23) % 24) + 1;
- append(buf, value, count);
- field = DateFormat.HOUR_OF_DAY1_FIELD;
- break;
- case 'm':
- append(buf, calendar.get(Calendar.MINUTE), count);
- field = DateFormat.MINUTE_FIELD;
- break;
- case 's':
- append(buf, calendar.get(Calendar.SECOND), count);
- field = DateFormat.SECOND_FIELD;
- break;
- case 'S':
- append(buf, calendar.get(Calendar.MILLISECOND), count);
- field = DateFormat.MILLISECOND_FIELD;
- break;
- case 'a':
- value = calendar.get(calendar.AM_PM);
- buf.append(formatData.getAmPmStrings()[value]);
- field = DateFormat.AM_PM_FIELD;
- break;
- case 'z':
- String zoneID = calendar.getTimeZone().getID();
- String[][] zoneStrings = formatData.getZoneStrings();
- int zoneCount = zoneStrings.length;
- for (int j = 0; j < zoneCount; j++)
- {
- String[] strings = zoneStrings[j];
- if (zoneID.equals(strings[0]))
- {
- j = count > 3 ? 2 : 1;
- if (calendar.get(Calendar.DST_OFFSET) != 0)
- j+=2;
- zoneID = strings[j];
- break;
- }
- }
- buf.append(zoneID);
- field = DateFormat.TIMEZONE_FIELD;
- break;
- default:
- // Note that the JCL is actually somewhat
- // contradictory here. It defines the pattern letters
- // to be a particular list, but also says that a
- // pattern containing an invalid pattern letter must
- // throw an exception. It doesn't describe what an
- // invalid pattern letter might be, so we just assume
- // it is any letter in [a-zA-Z] not explicitly covered
- // above.
- throw new RuntimeException("bad format string");
- }
- if (pos != null && field == pos.getField())
- {
- pos.setBeginIndex(beginIndex);
- pos.setEndIndex(buf.length());
- }
- }
- }
- return buf;
- }
-
- private final boolean expect (String source, ParsePosition pos,
- char ch)
- {
- int x = pos.getIndex();
- boolean r = x < source.length() && source.charAt(x) == ch;
- if (r)
- pos.setIndex(x + 1);
- else
- pos.setErrorIndex(x);
- return r;
- }
-
- public Date parse (String source, ParsePosition pos)
- {
- int fmt_index = 0;
- int fmt_max = pattern.length();
-
- calendar.clear();
- int quote_start = -1;
- for (; fmt_index < fmt_max; ++fmt_index)
- {
- char ch = pattern.charAt(fmt_index);
- if (ch == '\'')
- {
- int index = pos.getIndex();
- if (fmt_index < fmt_max - 1
- && pattern.charAt(fmt_index + 1) == '\'')
- {
- if (! expect (source, pos, ch))
- return null;
- ++fmt_index;
- }
- else
- quote_start = quote_start < 0 ? fmt_index : -1;
- continue;
- }
-
- if (quote_start != -1
- || ((ch < 'a' || ch > 'z')
- && (ch < 'A' || ch > 'Z')))
- {
- if (! expect (source, pos, ch))
- return null;
- continue;
- }
-
- // We've arrived at a potential pattern character in the
- // pattern.
- int first = fmt_index;
- while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch)
- ;
- int count = fmt_index - first;
- --fmt_index;
-
- // We can handle most fields automatically: most either are
- // numeric or are looked up in a string vector. In some cases
- // we need an offset. When numeric, `offset' is added to the
- // resulting value. When doing a string lookup, offset is the
- // initial index into the string array.
- int calendar_field;
- boolean is_numeric = true;
- String[] match = null;
- int offset = 0;
- int zone_number = 0;
- switch (ch)
- {
- case 'd':
- calendar_field = Calendar.DATE;
- break;
- case 'D':
- calendar_field = Calendar.DAY_OF_YEAR;
- break;
- case 'F':
- calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH;
- break;
- case 'E':
- is_numeric = false;
- offset = 1;
- calendar_field = Calendar.DAY_OF_WEEK;
- match = (count <= 3
- ? formatData.getShortWeekdays()
- : formatData.getWeekdays());
- break;
- case 'w':
- calendar_field = Calendar.WEEK_OF_YEAR;
- break;
- case 'W':
- calendar_field = Calendar.WEEK_OF_MONTH;
- break;
- case 'M':
- calendar_field = Calendar.MONTH;
- if (count <= 2)
- ;
- else
- {
- is_numeric = false;
- match = (count <= 3
- ? formatData.getShortMonths()
- : formatData.getMonths());
- }
- break;
- case 'y':
- calendar_field = Calendar.YEAR;
- if (count <= 2)
- offset = 1900;
- break;
- case 'K':
- calendar_field = Calendar.HOUR;
- break;
- case 'h':
- calendar_field = Calendar.HOUR;
- offset = -1;
- break;
- case 'H':
- calendar_field = Calendar.HOUR_OF_DAY;
- break;
- case 'k':
- calendar_field = Calendar.HOUR_OF_DAY;
- offset = -1;
- break;
- case 'm':
- calendar_field = Calendar.MINUTE;
- break;
- case 's':
- calendar_field = Calendar.SECOND;
- break;
- case 'S':
- calendar_field = Calendar.MILLISECOND;
- break;
- case 'a':
- is_numeric = false;
- calendar_field = Calendar.AM_PM;
- match = formatData.getAmPmStrings();
- break;
- case 'z':
- // We need a special case for the timezone, because it
- // uses a different data structure than the other cases.
- is_numeric = false;
- calendar_field = Calendar.DST_OFFSET;
- String[][] zoneStrings = formatData.getZoneStrings();
- int zoneCount = zoneStrings.length;
- int index = pos.getIndex();
- boolean found_zone = false;
- for (int j = 0; j < zoneCount; j++)
- {
- String[] strings = zoneStrings[j];
- int k;
- for (k = 1; k < strings.length; ++k)
- {
- if (source.startsWith(strings[k], index))
- break;
- }
- if (k != strings.length)
- {
- if (k > 2)
- ; // FIXME: dst.
- zone_number = 0; // FIXME: dst.
- // FIXME: raw offset to SimpleTimeZone const.
- calendar.setTimeZone(new SimpleTimeZone (1, strings[0]));
- pos.setIndex(index + strings[k].length());
- break;
- }
- }
- if (! found_zone)
- {
- pos.setErrorIndex(pos.getIndex());
- return null;
- }
- break;
- default:
- pos.setErrorIndex(pos.getIndex());
- return null;
- }
-
- // Compute the value we should assign to the field.
- int value;
- if (is_numeric)
- {
- numberFormat.setMinimumIntegerDigits(count);
- Number n = numberFormat.parse(source, pos);
- if (pos == null || ! (n instanceof Long))
- return null;
- value = n.intValue() + offset;
- }
- else if (match != null)
- {
- int index = pos.getIndex();
- int i;
- for (i = offset; i < match.length; ++i)
- {
- if (source.startsWith(match[i], index))
- break;
- }
- if (i == match.length)
- {
- pos.setErrorIndex(index);
- return null;
- }
- pos.setIndex(index + match[i].length());
- value = i;
- }
- else
- value = zone_number;
-
- // Assign the value and move on.
- try
- {
- calendar.set(calendar_field, value);
- }
- // FIXME: what exception is thrown on an invalid
- // non-lenient set?
- catch (IllegalArgumentException x)
- {
- pos.setErrorIndex(pos.getIndex());
- return null;
- }
- }
-
- return calendar.getTime();
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof SimpleDateFormat) || ! super.equals(obj) )
- return false;
- SimpleDateFormat other = (SimpleDateFormat) obj;
- return (DateFormatSymbols.equals(pattern, other.pattern)
- && DateFormatSymbols.equals(formatData, other.formatData)
- && DateFormatSymbols.equals(defaultCenturyStart,
- other.defaultCenturyStart));
- }
-
- public Object clone ()
- {
- // We know the superclass just call's Object's generic cloner.
- return super.clone ();
- }
-
- public int hashCode ()
- {
- int hash = super.hashCode();
- if (pattern != null)
- hash ^= pattern.hashCode();
- return hash;
- }
-}
diff --git a/libjava/java/text/StringCharacterIterator.java b/libjava/java/text/StringCharacterIterator.java
deleted file mode 100644
index c41ce4100fd..00000000000
--- a/libjava/java/text/StringCharacterIterator.java
+++ /dev/null
@@ -1,142 +0,0 @@
-// StringCharacterIterator.java - Iterate over string of Unicode characters.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.text;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date February 22, 1999
- */
-/* Written using "Java Class Libraries", 2nd edition, plus online
- * API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct to 1.1.
- */
-
-public final class StringCharacterIterator implements CharacterIterator
-{
- public Object clone ()
- {
- return (Object) new StringCharacterIterator (text, begin, end, pos);
- }
-
- public char current ()
- {
- // This follows JDK 1.2 semantics and not 1.1 semantics.
- // In 1.1 we would throw an exception if begin==end.
- return (pos < end) ? text.charAt(pos) : CharacterIterator.DONE;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof StringCharacterIterator))
- return false;
- StringCharacterIterator sci = (StringCharacterIterator) obj;
- // The spec says "the same text". We take this to mean equals,
- // not ==.
- return (pos == sci.pos
- && begin == sci.begin
- && end == sci.end
- && text.equals(sci.text));
- }
-
- public char first ()
- {
- pos = begin;
- return current ();
- }
-
- public int getBeginIndex ()
- {
- return begin;
- }
-
- public int getEndIndex ()
- {
- return end;
- }
-
- public int getIndex ()
- {
- return pos;
- }
-
- public int hashCode ()
- {
- // FIXME: this is a terrible hash code. Find a better one.
- return text.hashCode() + pos + begin + end;
- }
-
- public char last ()
- {
- pos = end;
- return current ();
- }
-
- public char next ()
- {
- if (pos == end)
- return CharacterIterator.DONE;
- ++pos;
- return current ();
- }
-
- public char previous ()
- {
- if (pos == begin)
- return CharacterIterator.DONE;
- --pos;
- return current ();
- }
-
- public char setIndex (int idx)
- {
- // In 1.1 we would throw an error if `idx == end'.
- if (idx < begin || idx > end)
- throw new IllegalArgumentException ();
- pos = idx;
- return current ();
- }
-
- public StringCharacterIterator (String text)
- {
- // FIXME: remove check for null once we have compiler/runtime
- // support for NullPointerException.
- this (text, 0, text == null ? 0 : text.length(), 0);
- }
- public StringCharacterIterator (String text, int pos)
- {
- // FIXME: remove check for null once we have compiler/runtime
- // support for NullPointerException.
- this (text, 0, text == null ? 0 : text.length(), pos);
- }
- public StringCharacterIterator (String text, int begin, int end, int pos)
- {
- if (text == null)
- throw new NullPointerException ();
- if (begin < 0 || begin > end || end > text.length()
- // In 1.1 we would also throw if `pos == end'.
- || pos < begin || pos > end)
- throw new IllegalArgumentException ();
-
- this.text = text;
- this.begin = begin;
- this.end = end;
- this.pos = pos;
- }
-
- // String to iterate over.
- private String text;
- // Current position.
- private int pos;
- // Start position in string.
- private int begin;
- // End position in string.
- private int end;
-}
diff --git a/libjava/java/text/natCollator.cc b/libjava/java/text/natCollator.cc
deleted file mode 100644
index 676a4a41a23..00000000000
--- a/libjava/java/text/natCollator.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-// natCollator.cc - Native code for collation.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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. */
-
-// Written by Tom Tromey <tromey@cygnus.com>.
-
-#include <config.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java/text/Collator.h>
-#include <java/lang/StringBuffer.h>
-
-#include <java-chardecomp.h>
-
-void
-java::text::Collator::decomposeCharacter (jchar c,
- java::lang::StringBuffer *buf)
-{
- if (decmp == NO_DECOMPOSITION)
- {
- buf->append(c);
- return;
- }
-
- const struct decomp_entry *base;
- int high;
-
- if (decmp == FULL_DECOMPOSITION)
- {
- base = full_decomposition;
- high = sizeof (full_decomposition) / sizeof (struct decomp_entry);
- }
- else
- {
- base = canonical_decomposition;
- high = sizeof (canonical_decomposition) / sizeof (struct decomp_entry);
- }
-
- // FIXME: this is probably a bit slow for the task at hand.
- int i = high / 2;
- int low = 0;
- while (true)
- {
- if (c < base[i].key)
- high = i;
- else if (c > base[i].key)
- low = i;
- else
- break;
-
- int old = i;
- i = (high + low) / 2;
- if (i == old)
- {
- // Not in table, so it expands to itself.
- buf->append(c);
- return;
- }
- }
-
- for (int j = 0; base[i].value[j] != '\0'; j += 2)
- {
- jchar x = (base[i].value[j] << 8) | (base[i].value[j + 1]);
- buf->append (x);
- }
-}
diff --git a/libjava/java/util/BitSet.java b/libjava/java/util/BitSet.java
deleted file mode 100644
index 1a9e51b0285..00000000000
--- a/libjava/java/util/BitSet.java
+++ /dev/null
@@ -1,183 +0,0 @@
-// BitSet - A vector of bits.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-import java.io.Serializable;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 23, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * hashCode algorithm taken from JDK 1.2 docs.
- */
-
-public final class BitSet implements Cloneable, Serializable
-{
- public void and (BitSet bs)
- {
- if (bs == null)
- throw new NullPointerException ();
- int max = Math.min(bits.length, bs.bits.length);
- int i;
- for (i = 0; i < max; ++i)
- bits[i] &= bs.bits[i];
- for ( ; i < bits.length; ++i)
- bits[i] = 0;
- }
-
- public BitSet ()
- {
- this (64);
- }
-
- public BitSet (int nbits)
- {
- if (nbits < 0)
- throw new NegativeArraySizeException ();
- int length = nbits / 64;
- if (nbits % 64 != 0)
- ++length;
- bits = new long[length];
- }
-
- public void clear (int pos)
- {
- if (pos < 0)
- throw new IndexOutOfBoundsException ();
- int bit = pos % 64;
- int offset = pos / 64;
- ensure (offset);
- bits[offset] &= ~ (1L << bit);
- }
-
- public Object clone ()
- {
- BitSet bs = new BitSet (bits.length * 64);
- System.arraycopy(bits, 0, bs.bits, 0, bits.length);
- return bs;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof BitSet))
- return false;
- BitSet bs = (BitSet) obj;
- int max = Math.min(bits.length, bs.bits.length);
- int i;
- for (i = 0; i < max; ++i)
- if (bits[i] != bs.bits[i])
- return false;
- // If one is larger, check to make sure all extra bits are 0.
- for (int j = i; j < bits.length; ++j)
- if (bits[j] != 0)
- return false;
- for (int j = i; j < bs.bits.length; ++j)
- if (bs.bits[j] != 0)
- return false;
- return true;
- }
-
- public boolean get (int pos)
- {
- if (pos < 0)
- throw new IndexOutOfBoundsException ();
-
- int bit = pos % 64;
- int offset = pos / 64;
-
- if (offset >= bits.length)
- return false;
-
- return (bits[offset] & (1L << bit)) == 0 ? false : true;
- }
-
- public int hashCode ()
- {
- long h = 1234;
- for (int i = bits.length - 1; i >= 0; --i)
- h ^= bits[i] * (i + 1);
- return (int) ((h >> 32) ^ h);
- }
-
- public void or (BitSet bs)
- {
- if (bs == null)
- throw new NullPointerException ();
- ensure (bs.bits.length - 1);
- int i;
- for (i = 0; i < bs.bits.length; ++i)
- bits[i] |= bs.bits[i];
- }
-
- public void set (int pos)
- {
- if (pos < 0)
- throw new IndexOutOfBoundsException ();
- int bit = pos % 64;
- int offset = pos / 64;
- ensure (offset);
- bits[offset] |= 1L << bit;
- }
-
- public int size ()
- {
- return bits.length * 64;
- }
-
- public String toString ()
- {
- StringBuffer result = new StringBuffer ("{");
- boolean first = true;
- for (int i = 0; i < bits.length; ++i)
- {
- int bit = 1;
- long word = bits[i];
- for (int j = 0; j < 64; ++j)
- {
- if ((word & bit) != 0)
- {
- if (! first)
- result.append(", ");
- result.append(64 * i + j);
- first = false;
- }
- bit <<= 1;
- }
- }
-
- return result.append("}").toString();
- }
-
- public void xor (BitSet bs)
- {
- if (bs == null)
- throw new NullPointerException ();
- ensure (bs.bits.length - 1);
- int i;
- for (i = 0; i < bs.bits.length; ++i)
- bits[i] ^= bs.bits[i];
- }
-
- // Make sure the vector is big enough.
- private final void ensure (int lastElt)
- {
- if (lastElt + 1 > bits.length)
- {
- long[] nd = new long[lastElt + 1];
- System.arraycopy(bits, 0, nd, 0, bits.length);
- bits = nd;
- }
- }
-
- // The actual bits.
- private long[] bits;
-}
diff --git a/libjava/java/util/Calendar.java b/libjava/java/util/Calendar.java
deleted file mode 100644
index b5eaa4d39d6..00000000000
--- a/libjava/java/util/Calendar.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1.
- * Status: Unimplemented: getAvailableLocales.
- * No Locale knowledge.
- */
-
-public abstract class Calendar implements java.io.Serializable, Cloneable
-{
- public final static int JANUARY = 0;
- public final static int FEBRUARY = 1;
- public final static int MARCH = 2;
- public final static int APRIL = 3;
- public final static int MAY = 4;
- public final static int JUNE = 5;
- public final static int JULY = 6;
- public final static int AUGUST = 7;
- public final static int SEPTEMBER = 8;
- public final static int OCTOBER = 9;
- public final static int NOVEMBER = 10;
- public final static int DECEMBER = 11;
- public final static int UNDECIMBER = 12;
-
- public final static int SUNDAY = 1;
- public final static int MONDAY = 2;
- public final static int TUESDAY = 3;
- public final static int WEDNESDAY = 4;
- public final static int THURSDAY = 5;
- public final static int FRIDAY = 6;
- public final static int SATURDAY = 7;
-
- public final static int AM = 0;
- public final static int PM = 1;
-
- public final static int FIELD_COUNT = 17;
-
- // These constants are not docuemnted, but were determined using
- // a simple test program.
- public final static int ERA = 0;
- public final static int YEAR = 1;
- public final static int MONTH = 2;
- public final static int WEEK_OF_YEAR = 3;
- public final static int WEEK_OF_MONTH = 4;
- public final static int DATE = 5;
- public final static int DAY_OF_MONTH = 5;
- public final static int DAY_OF_YEAR = 6;
- public final static int DAY_OF_WEEK = 7;
- public final static int DAY_OF_WEEK_IN_MONTH = 8;
- public final static int AM_PM = 9;
- public final static int HOUR = 10;
- public final static int HOUR_OF_DAY = 11;
- public final static int MINUTE = 12;
- public final static int SECOND = 13;
- public final static int MILLISECOND = 14;
- public final static int ZONE_OFFSET = 15;
- public final static int DST_OFFSET = 16;
-
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
- protected boolean areFieldsSet;
- protected int[] fields;
- private int firstDayOfWeek;
- protected boolean[] isSet;
- protected boolean isTimeSet;
- private boolean lenient;
- private int minimalDaysInFirstWeek;
- private int nextStamp;
- //private int serialVersionOnStream;
- protected long time;
- private TimeZone zone;
-
- protected Calendar ()
- {
- this (null, null);
- }
-
- protected Calendar (TimeZone zone, Locale loc)
- {
- fields = new int[FIELD_COUNT];
- isSet = new boolean[FIELD_COUNT];
- firstDayOfWeek = SUNDAY; // Locale-dependent. FIXME.
- this.zone = zone != null ? zone : TimeZone.getDefault();
- }
-
- public Object clone ()
- {
- try
- {
- return super.clone();
- }
- catch (CloneNotSupportedException ex)
- {
- throw new RuntimeException("internal error - "+ex);
- }
- }
-
- public String toString ()
- {
- // We have much latitude in how we implement this.
- return ("areFieldsSet " + areFieldsSet
- + "; fields " + fields
- + "; firstDayOfWeek " + firstDayOfWeek
- + "; isSet " + isSet
- + "; isTimeSet " + isTimeSet
- + "; lenient " + lenient
- + "; minimalDaysInFirstWeek " + minimalDaysInFirstWeek
- + "; nextStamp " + nextStamp
- + "; time " + time
- + "; zone " + zone);
- }
-
- public static Calendar getInstance ()
- {
- return new GregorianCalendar ();
- }
-
- public static Calendar getInstance (TimeZone zone)
- {
- return new GregorianCalendar (zone);
- }
-
- public static Calendar getInstance (Locale locale)
- {
- return new GregorianCalendar (locale);
- }
-
- public static Calendar getInstance (TimeZone zone, Locale locale)
- {
- return new GregorianCalendar (zone, locale);
- }
-
- public boolean isLenient() { return lenient; }
- public void setLenient (boolean lenient) { this.lenient = lenient; }
-
- public int getFirstDayOfWeek ()
- {
- return firstDayOfWeek;
- }
-
- public void setFirstDayOfWeek (int value)
- {
- firstDayOfWeek = value;
- }
-
- public int getMinimalDaysInFirstWeek ()
- {
- return minimalDaysInFirstWeek;
- }
-
- public void setMinimalDaysInFirstWeek (int value)
- {
- minimalDaysInFirstWeek = value;
- }
-
- public TimeZone getTimeZone ()
- {
- return zone;
- }
-
- public void setTimeZone (TimeZone tz)
- {
- zone = tz;
- }
-
- abstract public void add(int fld, int amount);
- abstract public void roll (int fld, boolean up);
-
- public final void set (int year, int month, int date)
- {
- set(YEAR, year);
- set(MONTH, month);
- set(DATE, date);
- }
-
- public final void set (int year, int month, int date, int hour, int minute)
- {
- set(year, month, date);
- set(HOUR_OF_DAY, hour);
- set(MINUTE, minute);
- }
-
- public final void set (int year, int month, int date,
- int hour, int minute, int second)
- {
- set(year, month, date, hour, minute);
- set(SECOND, second);
- }
-
- public final void set (int fld, int value)
- {
- if (! areFieldsSet) computeFields();
- fields[fld] = value;
- isTimeSet = false;
- }
-
- public final void clear (int fld)
- {
- fields[fld] = 0;
- isSet[fld] = false;
- areFieldsSet = false;
- }
-
- public final void clear ()
- {
- for (int fld = FIELD_COUNT; --fld >= 0; )
- {
- fields[fld] = 0;
- isSet[fld] = false;
- }
- areFieldsSet = false;
- }
-
- protected void complete()
- {
- if (!isTimeSet) computeTime();
- if (!areFieldsSet) computeFields();
- }
-
- protected abstract void computeFields();
- protected abstract void computeTime();
-
- protected final int internalGet (int fld) { return fields[fld]; }
-
- public final int get(int fld)
- {
- complete();
- return fields[fld];
- }
-
- public abstract boolean after (Object cal);
- public abstract boolean before (Object cal);
- public abstract boolean equals (Object obj);
-
- protected long getTimeInMillis()
- {
- if (!isTimeSet) computeTime();
- return time;
- }
-
- public final Date getTime() { return new Date(getTimeInMillis()); }
-
- public final void setTime (Date date)
- {
- setTimeInMillis(date.getTime());
- }
-
- protected void setTimeInMillis (long millis)
- {
- time = millis;
- isTimeSet = true;
- clear();
- }
-
- abstract public int getMaximum(int fld);
- abstract public int getMinimum(int fld);
- abstract public int getGreatestMinimum(int fld);
- abstract public int getLeastMaximum(int fld);
-
- public final boolean isSet(int fld) { return isSet[fld]; }
-}
diff --git a/libjava/java/util/Collection.java b/libjava/java/util/Collection.java
deleted file mode 100644
index 46da71b1dc7..00000000000
--- a/libjava/java/util/Collection.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface Collection
-{
- public int size();
- public boolean isEmpty();
- public boolean contains(Object o);
- public Iterator iterator();
- public Object[] toArray();
- public Object[] toArray(Object[] a);
- public boolean add(Object o);
- public boolean remove(Object o);
- public boolean containsAll(Collection c);
- public boolean addAll(Collection c);
- public boolean removeAll(Collection c);
- public boolean retainAll(Collection c);
- public void clear();
- public boolean equals(Object o);
- public int hashCode();
-}
diff --git a/libjava/java/util/Comparator.java b/libjava/java/util/Comparator.java
deleted file mode 100644
index 8f114ee79b0..00000000000
--- a/libjava/java/util/Comparator.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface Comparator
-{
- public int compare(Object o1, Object o2);
- public boolean equals(Object obj);
-}
diff --git a/libjava/java/util/ConcurrentModificationException.java b/libjava/java/util/ConcurrentModificationException.java
deleted file mode 100644
index 6849fcc87bc..00000000000
--- a/libjava/java/util/ConcurrentModificationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-/* Added in JDK 1.2 */
-public class ConcurrentModificationException extends RuntimeException
-{
- public ConcurrentModificationException()
- {
- super();
- }
-
- public ConcurrentModificationException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/Date.java b/libjava/java/util/Date.java
deleted file mode 100644
index 6a8a7654938..00000000000
--- a/libjava/java/util/Date.java
+++ /dev/null
@@ -1,483 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-import java.text.*;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * "The Java Language Specification", ISBN 0-201-63451-1,
- * and O'Reilly's "Java in a Nutshell".
- * Status: Need to re-write toString().
- * Missing: ToGMTString and toLocaleString.
- * Serialization spec: Specifies readObject/writeObject.
- */
-
-public class Date implements java.io.Serializable, Cloneable
-{
- private long millis;
-
- public Date() { millis = System.currentTimeMillis(); }
-
- public Date(long millis) { this.millis = millis; }
-
- public Date(int year, int month, int date, int hours,
- int minutes, int seconds)
- {
- setTime(year, month, date, hours, minutes, seconds);
- }
-
- public Date(int year, int month, int date, int hours, int minutes)
- {
- setTime(year, month, date, hours, minutes, 0);
- }
-
- public Date(int year, int month, int date)
- {
- setTime(year, month, date, 0, 0, 0);
- }
-
- public Date (String s) { this(parse(s)); }
-
- private static int skipParens(String string, int offset)
- {
- int len = string.length();
- int p = 0;
- int i;
-
- for (i = offset; i < len; ++i)
- {
- if (string.charAt(i) == '(')
- ++p;
- else if (string.charAt(i) == ')')
- {
- --p;
- if (p == 0)
- return i + 1;
- // If we've encounted unbalanced parens, just return the
- // leftover one as an ordinary character. It will be
- // caught later in parsing and cause an
- // IllegalArgumentException.
- if (p < 0)
- return i;
- }
- }
-
- // Not sure what to do if `p != 0' here.
- return i;
- }
-
- private static int parseTz(String tok, char sign)
- throws IllegalArgumentException
- {
- int num;
-
- try
- {
- // parseInt doesn't handle '+' so strip off sign.
- num = Integer.parseInt(tok.substring(1));
- }
- catch (NumberFormatException ex)
- {
- throw new IllegalArgumentException(tok);
- }
-
- // Convert hours to minutes.
- if (num < 24)
- num *= 60;
- else
- num = (num / 100) * 60 + num % 100;
-
- return sign == '-' ? -num : num;
- }
-
- private static int parseMonth(String tok)
- {
- // Initialize strings for month names.
- // We could possibly use the fields of DateFormatSymbols but that is
- // localized and thus might not match the English words specified.
- String months[] = { "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY",
- "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER",
- "NOVEMBER", "DECEMBER" };
-
- int i;
- for (i = 0; i < 12; i++)
- if (months[i].startsWith(tok))
- return i;
-
- // Return -1 if not found.
- return -1;
- }
-
- private static boolean parseDayOfWeek(String tok)
- {
- // Initialize strings for days of the week names.
- // We could possibly use the fields of DateFormatSymbols but that is
- // localized and thus might not match the English words specified.
- String daysOfWeek[] = { "SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY",
- "THURSDAY", "FRIDAY", "SATURDAY" };
-
- int i;
- for (i = 0; i < 7; i++)
- if (daysOfWeek[i].startsWith(tok))
- return true;
-
- return false;
- }
-
- public static long parse(String string)
- {
- // Initialize date/time fields before parsing begins.
- int year = -1;
- int month = -1;
- int day = -1;
- int hour = -1;
- int minute = -1;
- int second = -1;
- int timezone = 0;
- boolean localTimezone = true;
-
- // Trim out any nested stuff in parentheses now to make parsing easier.
- StringBuffer buf = new StringBuffer();
- int off = 0;
- int openParenOffset, tmpMonth;
- while ((openParenOffset = string.indexOf('(', off)) >= 0)
- {
- // Copy part of string leading up to open paren.
- buf.append(string.substring(off, openParenOffset));
- off = skipParens(string, openParenOffset);
- }
- buf.append(string.substring(off));
-
- // Make all chars upper case to simplify comparisons later.
- // Also ignore commas; treat them as delimiters.
- StringTokenizer strtok =
- new StringTokenizer(buf.toString().toUpperCase(), " \t\n\r,");
-
- while (strtok.hasMoreTokens())
- {
- String tok = strtok.nextToken();
- char firstch = tok.charAt(0);
- if ((firstch == '+' || firstch == '-') && year >= 0)
- {
- timezone = parseTz(tok, firstch);
- localTimezone = false;
- }
- else if (firstch >= '0' && firstch <= '9')
- {
- while (tok != null && tok.length() > 0)
- {
- // A colon or slash may be valid in the number.
- // Find the first of these before calling parseInt.
- int colon = tok.indexOf(':');
- int slash = tok.indexOf('/');
- int hyphen = tok.indexOf('-');
- // We choose tok.length initially because it makes
- // processing simpler.
- int punctOffset = tok.length();
- if (colon >= 0)
- punctOffset = Math.min(punctOffset, colon);
- if (slash >= 0)
- punctOffset = Math.min(punctOffset, slash);
- if (hyphen >= 0)
- punctOffset = Math.min(punctOffset, hyphen);
- // Following code relies on -1 being the exceptional
- // case.
- if (punctOffset == tok.length())
- punctOffset = -1;
-
- int num;
- try
- {
- num = Integer.parseInt(punctOffset < 0 ? tok :
- tok.substring(0, punctOffset));
- }
- catch (NumberFormatException ex)
- {
- throw new IllegalArgumentException(tok);
- }
-
- // TBD: Spec says year can be followed by a slash. That might
- // make sense if using YY/MM/DD formats, but it would fail in
- // that format for years <= 70. Also, what about 1900? That
- // is interpreted as the year 3800; seems that the comparison
- // should be num >= 1900 rather than just > 1900.
- // What about a year of 62 - 70? (61 or less could be a (leap)
- // second). 70/MM/DD cause an exception but 71/MM/DD is ok
- // even though there's no ambiguity in either case.
- // For the parse method, the spec as written seems too loose.
- // Until shown otherwise, we'll follow the spec as written.
- if (num > 70 && (punctOffset < 0 || punctOffset == slash))
- year = num > 1900 ? num - 1900 : num;
- else if (punctOffset > 0 && punctOffset == colon)
- {
- if (hour < 0)
- hour = num;
- else
- minute = num;
- }
- else if (punctOffset > 0 && punctOffset == slash)
- {
- if (month < 0)
- month = num - 1;
- else
- day = num;
- }
- else if (hour >= 0 && minute < 0)
- minute = num;
- else if (minute >= 0 && second < 0)
- second = num;
- else if (day < 0)
- day = num;
- else
- throw new IllegalArgumentException(tok);
-
- // Advance string if there's more to process in this token.
- if (punctOffset < 0 || punctOffset + 1 >= tok.length())
- tok = null;
- else
- tok = tok.substring(punctOffset + 1);
- }
- }
- else if (firstch >= 'A' && firstch <= 'Z')
- {
- if (tok.equals("AM"))
- {
- if (hour < 1 || hour > 12)
- throw new IllegalArgumentException(tok);
- if (hour == 12)
- hour = 0;
- }
- else if (tok.equals("PM"))
- {
- if (hour < 1 || hour > 12)
- throw new IllegalArgumentException(tok);
- if (hour < 12)
- hour += 12;
- }
- else if (parseDayOfWeek(tok))
- ; // Ignore it; throw the token away.
- else if (tok.equals("UT") || tok.equals("UTC") || tok.equals("GMT"))
- localTimezone = false;
- else if (tok.startsWith("UT") || tok.startsWith("GMT"))
- {
- int signOffset = 3;
- if (tok.charAt(1) == 'T' && tok.charAt(2) != 'C')
- signOffset = 2;
-
- char sign = tok.charAt(signOffset);
- if (sign != '+' && sign != '-')
- throw new IllegalArgumentException(tok);
-
- timezone = parseTz(tok.substring(signOffset), sign);
- localTimezone = false;
- }
- else if ((tmpMonth = parseMonth(tok)) >= 0)
- month = tmpMonth;
- else if (tok.length() == 3 && tok.charAt(2) == 'T')
- {
- // Convert timezone offset from hours to minutes.
- char ch = tok.charAt(0);
- if (ch == 'E')
- timezone = -5 * 60;
- else if (ch == 'C')
- timezone = -6 * 60;
- else if (ch == 'M')
- timezone = -7 * 60;
- else if (ch == 'P')
- timezone = -8 * 60;
- else
- throw new IllegalArgumentException(tok);
-
- // Shift 60 minutes for Daylight Savings Time.
- if (tok.charAt(1) == 'D')
- timezone += 60;
- else if (tok.charAt(1) != 'S')
- throw new IllegalArgumentException(tok);
-
- localTimezone = false;
- }
- else
- throw new IllegalArgumentException(tok);
- }
- else
- throw new IllegalArgumentException(tok);
- }
-
- // Unspecified minutes and seconds should default to 0.
- if (minute < 0)
- minute = 0;
- if (second < 0)
- second = 0;
-
- // Throw exception if any other fields have not been recognized and set.
- if (year < 0 || month < 0 || day < 0 || hour < 0)
- throw new IllegalArgumentException("Missing field");
-
- // Return the time in either local time or relative to GMT as parsed.
- // If no time-zone was specified, get the local one (in minutes) and
- // convert to milliseconds before adding to the UTC.
- return UTC(year, month, day, hour, minute, second) + (localTimezone ?
- new Date(year, month, day).getTimezoneOffset() * 60 * 1000:
- -timezone * 60 * 1000);
- }
-
- public boolean after (Date when) { return this.millis > when.millis; }
- public boolean before (Date when) { return this.millis < when.millis; }
-
- public boolean equals(Object obj)
- {
- return (obj != null && obj instanceof Date
- && ((Date)obj).millis == this.millis);
- }
-
- public long getTime() { return millis; }
-
- public int hashCode()
- {
- return (int)(millis^(millis>>>32));
- }
-
- private void setTime(int year, int month, int date,
- int hours, int minutes, int seconds)
- {
- Calendar cal = new GregorianCalendar(year+1900, month, date,
- hours, minutes, seconds);
- millis = cal.getTimeInMillis();
- }
-
- public void setTime(long millis) { this.millis = millis; }
-
- private int getField (int fld)
- {
- Calendar cal = new GregorianCalendar();
- cal.setTime(this);
- return cal.get(fld);
- }
-
- public int getYear ()
- {
- return getField(Calendar.YEAR) - 1900;
- }
-
- public int getMonth ()
- {
- return getField(Calendar.MONTH);
- }
-
- public int getDate ()
- {
- return getField(Calendar.DATE);
- }
-
- public int getDay ()
- {
- return getField(Calendar.DAY_OF_WEEK) - 1;
- }
-
- public int getHours ()
- {
- return getField(Calendar.HOUR_OF_DAY);
- }
-
- public int getMinutes ()
- {
- return getField(Calendar.MINUTE);
- }
-
- public int getSeconds ()
- {
- return getField(Calendar.SECOND);
- }
-
- private void setField (int fld, int value)
- {
- Calendar cal = new GregorianCalendar();
- cal.setTime(this);
- cal.set(fld, value);
- millis = cal.getTimeInMillis();
- }
-
- public void setYear (int year)
- {
- setField(Calendar.YEAR, 1900 + year);
- }
-
- public void setMonth (int month)
- {
- setField(Calendar.MONTH, month);
- }
-
- public void setDate (int date)
- {
- setField(Calendar.DATE, date);
- }
-
- public void setHours (int hours)
- {
- setField(Calendar.HOUR_OF_DAY, hours);
- }
-
- public void setMinutes (int minutes)
- {
- setField(Calendar.MINUTE, minutes);
- }
-
- public void setSeconds (int seconds)
- {
- setField(Calendar.SECOND, seconds);
- }
-
- public int getTimezoneOffset ()
- {
- Calendar cal = new GregorianCalendar();
- cal.setTime(this);
- return - (cal.get(Calendar.ZONE_OFFSET)
- + cal.get(Calendar.DST_OFFSET)/(60*1000));
- }
-
- public String toString ()
- {
- // This is slow, but does it matter? There is no particularly
- // fast way to do it, because we need the timezone offset, which
- // we don't store. Unix ctime() doesn't provide this information.
- SimpleDateFormat fmt = new SimpleDateFormat ("E MMM dd HH:mm:ss z yyyy",
- Locale.US);
- fmt.setTimeZone(TimeZone.getDefault());
- return fmt.format(this);
- }
-
- public String toGMTString ()
- {
- // This method is deprecated. We don't care if it is very slow.
- SimpleDateFormat fmt = new SimpleDateFormat ("d MMM yyyy HH:mm:ss 'GMT'",
- Locale.US);
- fmt.setTimeZone(TimeZone.zoneGMT);
- return fmt.format(this);
- }
-
- public String toLocaleString ()
- {
- // This method is deprecated. We don't care if it is very slow.
- DateFormat fmt = DateFormat.getDateTimeInstance();
- fmt.setTimeZone(TimeZone.getDefault());
- return fmt.format(this);
- }
-
- public static long UTC (int year, int month, int date,
- int hours, int minutes, int seconds)
- {
- GregorianCalendar cal = new GregorianCalendar (TimeZone.zoneGMT);
- cal.set(year+1900, month, date, hours, minutes, seconds);
- return cal.getTimeInMillis();
- }
-}
diff --git a/libjava/java/util/Dictionary.java b/libjava/java/util/Dictionary.java
deleted file mode 100644
index f127cc050fd..00000000000
--- a/libjava/java/util/Dictionary.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 31, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-/* The JDK 1.2 beta doc indicates that Dictionary is obsolete and that the
- * new java.util.Map interface should be used instead.
- */
-public abstract class Dictionary
-{
- public abstract Enumeration elements();
- public abstract Object get(Object key) throws NullPointerException;
- public abstract boolean isEmpty();
- public abstract Enumeration keys();
- public abstract Object put(Object key, Object elem)
- throws NullPointerException;
- public abstract Object remove(Object key) throws NullPointerException;
- public abstract int size();
-}
diff --git a/libjava/java/util/EmptyStackException.java b/libjava/java/util/EmptyStackException.java
deleted file mode 100644
index 234f3ff7c76..00000000000
--- a/libjava/java/util/EmptyStackException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class EmptyStackException extends RuntimeException
-{
- public EmptyStackException()
- {
- super();
- }
-}
diff --git a/libjava/java/util/Enumeration.java b/libjava/java/util/Enumeration.java
deleted file mode 100644
index 6f7299bc072..00000000000
--- a/libjava/java/util/Enumeration.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1.
- * Status: Believed complete and correct
- */
-
-public interface Enumeration
-{
- public boolean hasMoreElements();
- public Object nextElement() throws NoSuchElementException;
-}
diff --git a/libjava/java/util/EventListener.java b/libjava/java/util/EventListener.java
deleted file mode 100644
index 969f324238b..00000000000
--- a/libjava/java/util/EventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// EventListener.java - Listen for events from event source.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Believed complete and correct.
- */
-
-public interface EventListener
-{
-}
diff --git a/libjava/java/util/EventObject.java b/libjava/java/util/EventObject.java
deleted file mode 100644
index ee6a7f64657..00000000000
--- a/libjava/java/util/EventObject.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// EventObject.java - Represent events fired by objects.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Believed complete, but not fully correct.
- */
-
-public class EventObject implements java.io.Serializable
-{
- public EventObject (Object source)
- {
- this.source = source;
- }
-
- public Object getSource ()
- {
- return source;
- }
-
- public String toString ()
- {
- // FIXME.
- return getSource().toString();
- }
-
- // Source of the event.
- protected transient Object source;
-}
diff --git a/libjava/java/util/GregorianCalendar.java b/libjava/java/util/GregorianCalendar.java
deleted file mode 100644
index d293790976b..00000000000
--- a/libjava/java/util/GregorianCalendar.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1.
- * Status: "leniency" is not handled, and neither is roll-over in
- * add and roll. This is partly because of unclear specification.
- * hashCode has no spec.
- */
-
-public class GregorianCalendar extends Calendar {
- public static final int BC = 0;
- public static final int AD = 1;
-
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
- // Value from a simple test program (getGregorianChange.getTime()).
- long gregorianCutover = -12219292800000L;
-
- private final static int[] mins = {
- 0 /* ERA */,
- 1 /* YEAR */,
- 0 /* MONTH */,
- 0 /* WEEK_OF_YEAR */,
- 0 /* WEEK_OF_MONTH */,
- 1 /* DATE */,
- 1 /* DAY_OF_YEAR */,
- 1 /* DAY_OF_WEEK */,
- -1 /* DAY_OF_WEEK_IN_MONTH */,
- 0 /* AM_PM */,
- 0 /* HOUR */,
- 0 /* HOUR_OF_DAY */,
- 0 /* MINUTE */,
- 0 /* SECOND */,
- 0 /* MILLISECOND */,
- -43200000 /* ZONE_OFFSET */,
- 0 /* DST_OFFSET */
- };
-
- private final static int[] maxs = {
- 1 /* ERA */,
- 5000000 /* YEAR */,
- 11 /* MONTH */,
- 54 /* WEEK_OF_YEAR */,
- 6 /* WEEK_OF_MONTH */,
- 31 /* DATE */,
- 366 /* DAY_OF_YEAR */,
- 7 /* DAY_OF_WEEK */,
- 6 /* DAY_OF_WEEK_IN_MONTH */,
- 1 /* AM_PM */,
- 12 /* HOUR */,
- 23 /* HOUR_OF_DAY */,
- 59 /* MINUTE */,
- 59 /* SECOND */,
- 999 /* MILLISECOND */,
- 43200000 /* ZONE_OFFSET */,
- 3600000 /* DST_OFFSET */
- };
-
- private final static int[] leastMaximums = {
- 1 /* ERA */,
- 5000000 /* YEAR */,
- 11 /* MONTH */,
- 53 /* WEEK_OF_YEAR */,
- 6 /* WEEK_OF_MONTH */,
- 28 /* DATE */,
- 365 /* DAY_OF_YEAR */,
- 7 /* DAY_OF_WEEK */,
- 4 /* DAY_OF_WEEK_IN_MONTH */,
- 1 /* AM_PM */,
- 11 /* HOUR */,
- 23 /* HOUR_OF_DAY */,
- 59 /* MINUTE */,
- 59 /* SECOND */,
- 999 /* MILLISECOND */,
- 43200000 /* ZONE_OFFSET */,
- 3600000 /* DST_OFFSET */
- };
-
- public GregorianCalendar ()
- {
- this(null, null);
- }
-
- public GregorianCalendar (TimeZone zone)
- {
- this (zone, null);
- }
-
- public GregorianCalendar (Locale locale)
- {
- this (null, locale);
- }
-
- public GregorianCalendar (TimeZone zone, Locale locale)
- {
- super (zone, locale);
- setDefaultTime ();
- }
-
- public GregorianCalendar (int year, int month, int date)
- {
- this((TimeZone) null);
- setDefaultTime ();
- set (year, month, date);
- }
-
- public GregorianCalendar (int year, int month, int date,
- int hour, int minute)
- {
- this((TimeZone) null);
- setDefaultTime ();
- set (year, month, date, hour, minute);
- }
-
- public GregorianCalendar (int year, int month, int date,
- int hour, int minute, int second)
- {
- this((TimeZone) null);
- setDefaultTime ();
- set (year, month, date, hour, minute, second);
- }
-
- private final void setDefaultTime ()
- {
- setTimeInMillis (System.currentTimeMillis());
- }
-
- public int getMinimum(int calfield) { return mins[calfield]; }
- public int getGreatestMinimum(int calfield) { return mins[calfield]; }
- public int getMaximum(int calfield) { return maxs[calfield]; }
- public int getLeastMaximum(int calfield) { return leastMaximums[calfield]; }
-
- protected native void computeFields();
-
- protected native void computeTime();
-
- public void add (int fld, int amount)
- {
- if (fld >= ZONE_OFFSET)
- throw new IllegalArgumentException("bad field to add");
- fields[fld] += amount;
- adjust(fld);
- }
-
- public void roll (int fld, boolean up)
- {
- if (fld >= ZONE_OFFSET)
- throw new IllegalArgumentException("bad field to roll");
-
- int old = fields[fld];
- if (up)
- {
- fields[fld] = old == getMaximum(fld) ? getMinimum(fld)
- : old + 1;
- }
- else
- {
- fields[fld] = old == getMinimum(fld) ? getMaximum(fld)
- : old - 1;
- }
- }
-
- private void adjust (int fld)
- {
- int value = fields[fld];
- int radix = maxs[fld] + 1;
- switch (fld)
- {
- case MONTH:
- case SECOND:
- case MILLISECOND:
- if (value >= radix)
- {
- int next = value / radix;
- fields[fld] = value - radix * next;
- fields[fld - 1] += next;
- adjust(fld - 1);
- }
- else if (value < 0) // min[fld]
- {
- int next = (value - radix - 1) / radix;
- fields[fld] = value - radix * next;
- fields[fld - 1] += next;
- adjust(fld - 1);
- }
- break;
- }
- }
-
- public final Date getGregorianChange() { return new Date(gregorianCutover); }
- public void setGregorianChange (Date date)
- { gregorianCutover = date.getTime(); }
-
- public boolean isLeapYear(int year)
- {
- if ((year % 4) != 0)
- return false;
- if ((year % 100) != 0 || (year % 400) == 0)
- return true;
- // year divisible by 100 but not 400.
- GregorianCalendar date = new GregorianCalendar(year, FEBRUARY, 28);
- return gregorianCutover < date.getTimeInMillis();
- }
-
- public boolean after (Object cal)
- {
- return cal instanceof Calendar
- && getTimeInMillis() > ((Calendar) cal).getTimeInMillis();
- }
-
- public boolean before (Object cal)
- {
- return cal instanceof Calendar
- && getTimeInMillis() < ((Calendar) cal).getTimeInMillis();
- }
-
- public boolean equals (Object obj)
- {
- if (obj == null || ! (obj instanceof GregorianCalendar))
- return false;
- GregorianCalendar other = (GregorianCalendar) obj;
-
- for (int i = FIELD_COUNT; --i >= 0; )
- {
- boolean set = isSet[i];
- if (set != other.isSet[i]
- || (set && fields[i] != other.fields[i]))
- return false;
- }
- if (areFieldsSet != other.areFieldsSet
- || isTimeSet != other.isTimeSet
- || (isTimeSet && time != other.time)
- || getFirstDayOfWeek() != other.getFirstDayOfWeek()
- || getMinimalDaysInFirstWeek() != other.getMinimalDaysInFirstWeek()
- || isLenient() != other.isLenient()
- || ! getTimeZone().equals(other.getTimeZone()))
- return false;
- return true;
- }
-
- public int hashCode ()
- {
- int hashcode = 0;
- for (int i = FIELD_COUNT; --i >= 0; )
- {
- if (isSet[i])
- hashcode += 37 * fields[i];
- }
- if (isTimeSet)
- hashcode += 89 * time;
- return hashcode;
- }
-}
diff --git a/libjava/java/util/Hashtable.java b/libjava/java/util/Hashtable.java
deleted file mode 100644
index 5d5284469db..00000000000
--- a/libjava/java/util/Hashtable.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 24, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-class HashtableEntry
-{
- public Object key;
- public Object value;
- public HashtableEntry nextEntry = null;
-
- public HashtableEntry(Object key, Object value)
- {
- this.key = key;
- this.value = value;
- }
-}
-
-class HashtableEnumeration implements Enumeration
-{
- // TBD: Enumeration is not safe if new elements are put in the table as
- // this could cause a rehash and we'd completely lose our place. Even
- // without a rehash, it is undetermined if a new element added would
- // appear in the enumeration. The spec says nothing about this, but
- // the "Java Class Libraries" book infers that modifications to the
- // hashtable during enumeration causes indeterminate results. Don't do it!
- // A safer way would be to make a copy of the table (e.g. into a vector)
- // but this is a fair bit more expensive.
- private HashtableEntry[] bucket;
- private int bucketIndex;
- private HashtableEntry elem;
- private int enumCount;
- private int size;
- private boolean values;
-
- public HashtableEnumeration(HashtableEntry[] bkt, int sz, boolean isValues)
- {
- bucket = bkt;
- bucketIndex = -1;
- enumCount = 0;
- elem = null;
- size = sz;
- values = isValues;
- }
-
- public boolean hasMoreElements()
- {
- return enumCount < size;
- }
-
- public Object nextElement()
- {
- if (!hasMoreElements())
- throw new NoSuchElementException();
-
- // Find next element
- if (elem != null) // In the middle of a bucket
- elem = elem.nextEntry;
- while (elem == null) // Find the next non-empty bucket
- elem = bucket[++bucketIndex];
-
- enumCount++;
- return values ? elem.value : elem.key;
- }
-}
-
-// TBD: The algorithm used here closely reflects what is described in
-// the "Java Class Libraries" book. The "Java Language Spec" is much
-// less specific about the implementation. Because of this freedom
-// provided by the actual spec, hash table algorithms should be
-// investigated to see if there is a better alternative to this one.
-
-// TODO12:
-// public class Hashtable extends Dictionary
-// implements Map, Cloneable, Serializable
-
-public class Hashtable extends Dictionary implements Cloneable, Serializable
-{
- private HashtableEntry bucket[];
- private float loadFactor;
- private int hsize = 0;
-
- public Hashtable()
- {
- // The "Java Class Libraries" book (p. 919) says that initial size in this
- // case is 101 (a prime number to increase the odds of even distribution).
- this(101, 0.75F);
- }
-
- public Hashtable(int initialSize)
- {
- this(initialSize, 0.75F);
- }
-
- public Hashtable(int initialSize, float loadFactor)
- {
- if (initialSize < 0 || loadFactor <= 0.0 || loadFactor > 1.0)
- throw new IllegalArgumentException();
-
- bucket = new HashtableEntry[initialSize];
- this.loadFactor = loadFactor;
- }
-
- // TODO12:
- // public Hashtable(Map t)
- // {
- // }
-
- public synchronized void clear()
- {
- // Aid the GC by nulling out the entries in the hash table.
- for (int i = 0; i < bucket.length; i++)
- {
- HashtableEntry elem = bucket[i];
- bucket[i] = null; // May already be null.
- while (elem != null)
- {
- HashtableEntry next = elem.nextEntry;
- elem.nextEntry = null; // May already be null.
- elem = next;
- }
- }
- hsize = 0;
- }
-
- public synchronized Object clone()
- {
- // New hashtable will have same initialCapacity and loadFactor.
- Hashtable newTable = new Hashtable(bucket.length, loadFactor);
-
- HashtableEntry newElem, prev = null;
- for (int i = 0; i < bucket.length; i++)
- for (HashtableEntry elem = bucket[i]; elem != null; elem = elem.nextEntry)
- {
- // An easy but expensive method is newTable.put(elem.key, elem.value);
- // Since the hash tables are the same size, the buckets and collisions
- // will be the same in the new one, so we can just clone directly.
- // This is much cheaper than using put.
- newElem = new HashtableEntry(elem.key, elem.value);
- if (newTable.bucket[i] == null)
- prev = newTable.bucket[i] = newElem;
- else
- prev = prev.nextEntry = newElem;
- }
-
- newTable.hsize = this.hsize;
- return newTable;
- }
-
- public synchronized boolean contains(Object value) throws NullPointerException
- {
- // An exception is thrown here according to the JDK 1.2 doc.
- if (value == null)
- throw new NullPointerException();
-
- for (int i = 0; i < bucket.length; i++)
- for (HashtableEntry elem = bucket[i]; elem != null; elem = elem.nextEntry)
- if (elem.value.equals(value))
- return true;
-
- return false;
- }
-
- public synchronized boolean containsKey(Object key)
- {
- // The Map interface mandates that we throw this.
- if (key == null)
- throw new NullPointerException ();
-
- for (HashtableEntry elem = bucket[Math.abs(key.hashCode()
- % bucket.length)];
- elem != null; elem = elem.nextEntry)
- if (elem.key.equals(key))
- return true;
-
- return false;
- }
-
- public synchronized Enumeration elements()
- {
- return new HashtableEnumeration(bucket, hsize, true);
- }
-
- public synchronized Object get(Object key)
- {
- // The Dictionary interface mandates that get() throw a
- // NullPointerException if key is null.
- if (key == null)
- throw new NullPointerException ();
-
- for (HashtableEntry elem = bucket[Math.abs (key.hashCode()
- % bucket.length)];
- elem != null; elem = elem.nextEntry)
- if (elem.key.equals(key))
- return elem.value;
-
- return null;
- }
-
- public boolean isEmpty()
- {
- return this.hsize <= 0;
- }
-
- public synchronized Enumeration keys()
- {
- return new HashtableEnumeration(bucket, hsize, false);
- }
-
- public synchronized Object put(Object key, Object value)
- throws NullPointerException
- {
- if (key == null || value == null)
- throw new NullPointerException();
-
- HashtableEntry prevElem = null;
- final int index = Math.abs(key.hashCode() % bucket.length);
-
- for (HashtableEntry elem = bucket[index]; elem != null;
- prevElem = elem, elem = elem.nextEntry)
- if (elem.key.equals(key))
- {
- // Update with the new value and then return the old one.
- Object oldVal = elem.value;
- elem.value = value;
- return oldVal;
- }
-
- // At this point, we know we need to add a new element.
- HashtableEntry newElem = new HashtableEntry(key, value);
- if (bucket[index] == null)
- bucket[index] = newElem;
- else
- prevElem.nextEntry = newElem;
-
- if (++hsize > loadFactor * bucket.length)
- rehash();
-
- return null;
- }
-
- protected void rehash()
- {
- // Create a new table which is twice the size (plus one) of the old.
- // One is added to make the new array length odd so it thus has at least
- // a (small) possibility of being a prime number.
- HashtableEntry oldBucket[] = bucket;
- bucket = new HashtableEntry[bucket.length * 2 + 1];
-
- // Copy over each entry into the new table
- HashtableEntry elem;
- for (int i = 0; i < oldBucket.length; i++)
- for (elem = oldBucket[i]; elem != null; elem = elem.nextEntry)
- {
- // Calling put(elem.key, elem.value); would seem like the easy way
- // but it is dangerous since put increases 'hsize' and calls rehash!
- // This could become infinite recursion under the right
- // circumstances. Instead, we'll add the element directly; this is a
- // bit more efficient than put since the data is already verified.
- final int index = Math.abs(elem.key.hashCode() % bucket.length);
- HashtableEntry newElem = new HashtableEntry(elem.key, elem.value);
- if (bucket[index] == null)
- bucket[index] = newElem;
- else
- {
- // Since this key can't already be in the table, just add this
- // in at the top of the bucket.
- newElem.nextEntry = bucket[index];
- bucket[index] = newElem;
- }
- }
- }
-
- public synchronized Object remove(Object key)
- {
- // TBD: Hmm, none of the various docs say to throw an exception here.
- if (key == null)
- return null;
-
- Object retval;
- HashtableEntry prevElem = null;
- final int index = Math.abs(key.hashCode() % bucket.length);
-
- for (HashtableEntry elem = bucket[index]; elem != null;
- prevElem = elem, elem = elem.nextEntry)
- if (elem.key.equals(key))
- {
- retval = elem.value;
- if (prevElem == null)
- bucket[index] = elem.nextEntry;
- else
- prevElem.nextEntry = elem.nextEntry;
- --hsize;
- return retval;
- }
-
- return null;
- }
-
- public int size()
- {
- return this.hsize;
- }
-
- public synchronized String toString()
- {
- // Following the Java Lang Spec 21.5.4 (p. 636).
-
- Enumeration keys = keys();
- Enumeration values = elements();
-
- // Prepend first element with open bracket
- StringBuffer result = new StringBuffer("{");
-
- // add first element if one exists
- // TBD: Seems like it is more efficient to catch the exception than
- // to call hasMoreElements each time around.
- try
- {
- result.append(keys.nextElement().toString() + "=" +
- values.nextElement().toString());
- }
- catch (NoSuchElementException ex)
- {
- }
-
- // Prepend subsequent elements with ", "
- try
- {
- while (true)
- result.append(", " + keys.nextElement().toString() + "=" +
- values.nextElement().toString());
- }
- catch (NoSuchElementException ex)
- {
- }
-
- // Append last element with closing bracket
- result.append("}");
- return result.toString();
- }
-
- // TODO12:
- // public Set entrySet()
- // {
- // }
-
- // TODO12:
- // public Set keySet()
- // {
- // }
-
- // Since JDK 1.2:
- // This method is identical to contains but is part of the 1.2 Map interface.
- // TBD: Should contains return containsValue instead? Depends on which
- // will be called more typically.
- public synchronized boolean containsValue(Object value)
- {
- return this.contains(value);
- }
-
- // TODO12:
- // public boolean equals(Object o)
- // {
- // }
-
- // TODO12:
- // public boolean hashCode()
- // {
- // }
-
- // TODO12:
- // public void putAll(Map t)
- // {
- // }
-
- // TODO12:
- // public Collection values()
- // {
- // }
-}
diff --git a/libjava/java/util/Iterator.java b/libjava/java/util/Iterator.java
deleted file mode 100644
index f6942fefa19..00000000000
--- a/libjava/java/util/Iterator.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface Iterator
-{
- public boolean hasNext();
- public Object next();
- public void remove();
-}
diff --git a/libjava/java/util/List.java b/libjava/java/util/List.java
deleted file mode 100644
index ea69217553e..00000000000
--- a/libjava/java/util/List.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface List extends Collection
-{
- public int size();
- public boolean isEmpty();
- public boolean contains(Object o);
- public Iterator iterator();
- public Object[] toArray();
- public Object[] toArray(Object[] a);
- public boolean add(Object o);
- public boolean remove(Object o);
- public boolean containsAll(Collection c);
- public boolean addAll(Collection c);
- public boolean addAll(int index, Collection c);
- public boolean removeAll(Collection c);
- public boolean retainAll(Collection c);
- public void clear();
- public boolean equals(Object o);
- public int hashCode();
- public Object get(int index);
- public Object set(int index, Object element);
- public void add(int index, Object element);
- public Object remove(int index);
- public int indexOf(Object o);
- public int lastIndexOf(Object o);
- public ListIterator listIterator();
- public ListIterator listIterator(int index);
- public List subList(int fromIndex, int toIndex);
-}
diff --git a/libjava/java/util/ListIterator.java b/libjava/java/util/ListIterator.java
deleted file mode 100644
index 8250e2ab01a..00000000000
--- a/libjava/java/util/ListIterator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface ListIterator extends Iterator
-{
- public boolean hasNext();
- public Object next();
- public boolean hasPrevious();
- public Object previous();
- public int nextIndex();
- public int previousIndex();
- public void remove();
- public void set(Object o);
- public void add(Object o);
-}
diff --git a/libjava/java/util/ListResourceBundle.java b/libjava/java/util/ListResourceBundle.java
deleted file mode 100644
index c6d6e78f4e2..00000000000
--- a/libjava/java/util/ListResourceBundle.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Anthony Green <green@cygnus.com>
- * @date November 26, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1. */
-
-public abstract class ListResourceBundle extends ResourceBundle
-{
- public final Object handleGetObject(String key)
- {
- Object a[][] = getContents();
-
- for (int i = 0; i < a.length; i++)
- {
- if (key.compareTo((String) a[i][0]) == 0)
- return a[i][1];
- }
- throw new MissingResourceException("can't find handle",
- getClass().getName(),
- key);
- }
-
- public Enumeration getKeys()
- {
- Object a[][] = getContents();
-
- Vector keys = new Vector(a.length);
-
- for (int i = 0; i < a.length; i++)
- keys.addElement(a[i][0]);
-
- return keys.elements();
- }
-
- protected abstract Object[][] getContents();
-
- public ListResourceBundle()
- {
- }
-}
diff --git a/libjava/java/util/Locale.java b/libjava/java/util/Locale.java
deleted file mode 100644
index e427e2ed43a..00000000000
--- a/libjava/java/util/Locale.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1.
- * Status: None of the getDisplayXXX or getISO3XXX methods are implemented.
- */
-public final class Locale implements java.io.Serializable, Cloneable
-{
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
- private String country;
- private int hashcode;
- private String language;
- private String variant;
- private static Locale defaultLocale;
-
- // These are as specified in the JDK 1.2 AP documentation
-
-
- // LANGUAGE constants ... country-neutral
- public static final Locale CHINESE = new Locale ("zh", "");
- public static final Locale ENGLISH = new Locale ("en", "");
- public static final Locale FRENCH = new Locale ("fr", "");
- public static final Locale GERMAN = new Locale ("de", "");
- public static final Locale ITALIAN = new Locale ("it", "");
- public static final Locale JAPANESE = new Locale ("ja", "");
- public static final Locale KOREAN = new Locale ("ko", "");
-
- // COUNTRY constants ... countries can be multi-lingual
- public static final Locale CANADA = new Locale ("en", "CA");
- public static final Locale CANADA_FRENCH = new Locale ("fr", "CA");
- public static final Locale FRANCE = new Locale ("fr", "FR");
- public static final Locale GERMANY = new Locale ("de", "DE");
- public static final Locale ITALY = new Locale ("it", "IT");
- public static final Locale JAPAN = new Locale ("ja", "JP");
- public static final Locale KOREA = new Locale ("ko", "KR");
- public static final Locale UK = new Locale ("en", "GB");
- public static final Locale US = new Locale ("en", "US");
-
- // Chinese has multiple scripts and political bodies
- public static final Locale SIMPLIFIED_CHINESE = new Locale ("zh", "CN");
- public static final Locale TRADITIONAL_CHINESE = new Locale ("zh", "TW");
- public static final Locale PRC = SIMPLIFIED_CHINESE;
- public static final Locale TAIWAN = TRADITIONAL_CHINESE;
- public static final Locale CHINA = PRC;
-
- public Locale (String languageCode, String countryCode)
- {
- this (languageCode, countryCode, "");
- }
-
- public Locale (String languageCode, String countryCode,
- String variantCode)
- {
- // We must explicitly check the arguments.
- if (languageCode == null || countryCode == null
- || variantCode == null)
- throw new NullPointerException ();
- language = languageCode.toLowerCase();
- country = countryCode.toUpperCase();
- variant = variantCode.toUpperCase();
- hashcode = (languageCode.hashCode()
- ^ countryCode.hashCode()
- ^ variantCode.hashCode());
- }
-
- public Object clone ()
- {
- return (Object) new Locale (language, country, variant);
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof Locale))
- return false;
- Locale loc = (Locale) obj;
- return (language.equals(loc.language)
- && country.equals(loc.country)
- && variant.equals(loc.variant));
- }
-
- public String getCountry ()
- {
- return country;
- }
-
- public String getLanguage ()
- {
- return language;
- }
-
- public String getVariant ()
- {
- return variant;
- }
-
- public int hashCode ()
- {
- return hashcode;
- }
-
- private static synchronized Locale setDefault()
- {
- if (defaultLocale != null)
- return defaultLocale;
- String language = System.getProperty("user.language");
- String country = System.getProperty("user.region");
- defaultLocale = new Locale (language == null ? "en" : language,
- country == null ? "" : country);
- return defaultLocale;
- }
-
- public static Locale getDefault ()
- {
- return defaultLocale == null ? setDefault() : defaultLocale;
- }
-
- public static void setDefault (Locale newLocale)
- {
- defaultLocale = newLocale;
- }
-
- public String toString ()
- {
- StringBuffer result = new StringBuffer(20);
- result.append(language);
- if (country.length() > 0)
- {
- result.append('_');
- result.append(country);
- if (variant.length() > 0)
- {
- result.append('_');
- result.append(variant);
- }
- }
- return result.toString();
- }
-}
diff --git a/libjava/java/util/MissingResourceException.java b/libjava/java/util/MissingResourceException.java
deleted file mode 100644
index 5fe24a024b3..00000000000
--- a/libjava/java/util/MissingResourceException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class MissingResourceException extends RuntimeException
-{
- private String className;
- private String key;
-
- public MissingResourceException(String msg, String cName, String k)
- {
- super(msg);
- className = cName;
- key = k;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public String getKey()
- {
- return key;
- }
-}
-
diff --git a/libjava/java/util/NoSuchElementException.java b/libjava/java/util/NoSuchElementException.java
deleted file mode 100644
index eb8f27d8efb..00000000000
--- a/libjava/java/util/NoSuchElementException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NoSuchElementException extends RuntimeException
-{
- public NoSuchElementException()
- {
- super();
- }
-
- public NoSuchElementException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/Observable.java b/libjava/java/util/Observable.java
deleted file mode 100644
index 1a205c15363..00000000000
--- a/libjava/java/util/Observable.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class Observable
-{
- /* tracks whether this object has changed */
- private boolean changed;
-
- /* list of the Observers registered as interested in this Observable */
- private Vector observerVec;
-
- /* TBD: This might be better implemented as an Observer[]
- * but that would mean writing more code rather than making use of
- * the existing Vector class (this also implies a larger text code
- * space in resulting executables). The tradeoff is one of speed
- * (manipulating the Observer[] directly) vs. size/reuse. In the future,
- * we may decide to make the tradeoff and reimplement with an Observer[].
- */
-
- public Observable()
- {
- changed = false;
- observerVec = new Vector();
- }
-
- public synchronized void addObserver(Observer obs)
- {
- // JDK 1.2 spec says not to add this if it is already there
- if (!observerVec.contains(obs))
- observerVec.addElement(obs);
- }
-
- protected synchronized void clearChanged()
- {
- changed = false;
- }
-
- public synchronized int countObservers()
- {
- return observerVec.size();
- }
-
- public synchronized void deleteObserver(Observer obs)
- {
- observerVec.removeElement(obs);
- }
-
- public synchronized void deleteObservers()
- {
- observerVec.removeAllElements();
- }
-
- public synchronized boolean hasChanged()
- {
- return changed;
- }
-
- public void notifyObservers()
- {
- notifyObservers(null);
- }
-
- public void notifyObservers(Object arg)
- {
- if (changed)
- {
- /* The JDK 1.2 spec states that though the order of notification
- * is unspecified in subclasses, in Observable it is in the order
- * of registration.
- */
- for (int i = 0, numObs = observerVec.size(); i < numObs; i++)
- ((Observer) (observerVec.elementAt(i))).update(this, arg);
- changed = false;
- }
- }
-
- protected synchronized void setChanged()
- {
- changed = true;
- }
-}
diff --git a/libjava/java/util/Observer.java b/libjava/java/util/Observer.java
deleted file mode 100644
index 3dc86ae7512..00000000000
--- a/libjava/java/util/Observer.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public interface Observer
-{
- public void update(Observable observed, Object arg);
-}
diff --git a/libjava/java/util/Properties.java b/libjava/java/util/Properties.java
deleted file mode 100644
index 2f7a25159b7..00000000000
--- a/libjava/java/util/Properties.java
+++ /dev/null
@@ -1,391 +0,0 @@
-// Properties - Property list representation.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.util;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.PushbackReader;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 26, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * Status: Complete to JDK 1.2.
- */
-
-public class Properties extends Hashtable
-{
- protected Properties defaults;
-
- public String getProperty (String propName)
- {
- return getProperty (propName, null);
- }
-
- public String getProperty (String propName, String defVal)
- {
- String r = (String) get (propName);
- if (r == null)
- {
- if (defaults != null)
- r = defaults.getProperty(propName, defVal);
- else
- r = defVal;
- }
- return r;
- }
-
- public Object setProperty (String key, String value)
- {
- return put (key, value);
- }
-
- public void list (PrintStream out)
- {
- Enumeration e = propertyNames ();
- while (e.hasMoreElements())
- {
- String key = (String) e.nextElement();
- String value = getProperty(key);
- if (value != null)
- {
- if (value.length() > 40)
- {
- // JDK compatibility.
- value = value.substring(0, 37) + "...";
- }
- out.print(key);
- out.print("=");
- out.println(value);
- }
- }
- }
-
- public void list (PrintWriter writer)
- {
- Enumeration e = propertyNames ();
- while (e.hasMoreElements())
- {
- String key = (String) e.nextElement();
- String value = getProperty(key);
- if (value != null)
- {
- if (value.length() > 40)
- {
- // JDK compatibility.
- value = value.substring(0, 37) + "...";
- }
- writer.print(key);
- writer.print("=");
- writer.println(value);
- }
- }
- }
-
- private final boolean skip_ws (PushbackReader reader) throws IOException
- {
- while (true)
- {
- int c = reader.read();
- if (c == -1)
- return false;
- // FIXME: we use our own definition of whitespace.
- // Character.isWhitespace includes newlines, which we don't
- // want. Character.isSpaceChar doesn't include \t.
- if (c != ' ' && c != '\t')
- {
- reader.unread(c);
- return true;
- }
- }
- }
-
- // Note: this method needs to be rewritten for JDK 1.2.
- // We rather arbitrarily decide that an EOF in the middle of a line
- // means that the whole line should be ignored. The spec doesn't
- // specifically address this, but this interpretation seems valid.
- public synchronized void load (InputStream in) throws IOException
- {
- PushbackReader reader = new PushbackReader (new InputStreamReader (in));
-
- StringBuffer key = new StringBuffer ();
- StringBuffer value = new StringBuffer ();
-
- nextLine:
- while (true)
- {
- key.setLength(0);
- value.setLength(0);
-
- // Skip leading whitespace.
- if (! skip_ws (reader))
- return;
-
- // Read key until key terminator.
- boolean first_char = true;
- int c;
- while (true)
- {
- c = reader.read();
- if (c == -1)
- return;
- if (c == '\\')
- {
- first_char = false;
- c = reader.read();
- if (c == -1)
- return;
- }
-
- // If we found a comment, just read to end of line and
- // then keep going.
- if (first_char == true && (c == '#' || c == '!'))
- {
- while (c != -1 && c != '\r' && c != '\n')
- c = reader.read();
- if (c == -1)
- return;
- continue nextLine;
- }
-
- if (c == '\r' || c == '\n')
- {
- if (first_char)
- continue nextLine;
- reader.unread(c);
- break;
- }
- // FIXME: again, our own definition of whitespace.
- if (c == ' ' || c == '\t' || c == ':' || c == '=')
- break;
-
- first_char = false;
- key.append((char) c);
- }
-
- // Found end of key. Skip whitespace. If the terminator
- // was whitespace, also skip a single instance of a "real"
- // terminator, and then more whitespace.
- if (! skip_ws (reader))
- return;
- if (c != ':' && c != '=')
- {
- c = reader.read();
- if (c == -1)
- return;
- if (c == ':' || c == '=')
- {
- // Skip more whitespace.
- if (! skip_ws (reader))
- return;
- }
- else
- reader.unread(c);
- }
-
- // Now read the value.
- while (true)
- {
- c = reader.read();
- if (c == -1)
- return;
- if (c == '\r' || c == '\n')
- break;
- if (c == '\\')
- {
- c = reader.read();
- switch (c)
- {
- case -1:
- return;
- case 't':
- c = '\t';
- break;
- case 'r':
- c = '\r';
- break;
- case 'n':
- c = '\n';
- break;
- case 'u':
- c = 0;
- for (int i = 0; i < 4; ++i)
- {
- int x = reader.read();
- if (x == -1)
- return;
- int d = Character.digit((char) x, 16);
- // We follow JDK here: invalid characters
- // are treated as terminators.
- if (d == -1)
- {
- value.append((char) c);
- c = x;
- break;
- }
- c <<= 4;
- c |= d;
- }
- break;
- default:
- // Nothing.
- }
- }
- value.append((char) c);
- }
-
- put (key.toString(), value.toString());
- }
- }
-
- public Properties ()
- {
- defaults = null;
- }
-
- public Properties (Properties defs)
- {
- defaults = defs;
- }
-
- private final void addHashEntries (Hashtable base)
- {
- if (defaults != null)
- defaults.addHashEntries(base);
- Enumeration keys = keys ();
- while (keys.hasMoreElements())
- base.put(keys.nextElement(), base);
- }
-
- public Enumeration propertyNames ()
- {
- // We make a new Hashtable that holds all the keys. Then we
- // return an enumeration for this hash. We do this because we
- // don't want modifications to be reflected in the enumeration
- // (per JCL), and because there doesn't seem to be a
- // particularly better way to ensure that duplicates are
- // ignored.
- Hashtable t = new Hashtable ();
- addHashEntries (t);
- return t.keys();
- }
-
- public synchronized void save (OutputStream out, String comment)
- {
- try
- {
- store (out, comment);
- }
- catch (IOException _)
- {
- }
- }
-
- public synchronized void store (OutputStream out, String comment)
- throws IOException
- {
- // Use a buffer because writing a single string through
- // OutputStreamWriter is fairly expensive.
- BufferedWriter output
- = new BufferedWriter (new OutputStreamWriter (out));
- String newline = System.getProperty("line.separator");
-
- if (comment != null)
- {
- // We just lose if COMMENT contains a newline. This is
- // what JDK 1.1 does.
- output.write("#");
- output.write(comment);
- output.write(newline);
- }
- output.write("# ");
- output.write(new Date().toString());
- output.write(newline);
-
- Enumeration keys = keys ();
- while (keys.hasMoreElements())
- {
- String key = (String) keys.nextElement();
- String value = (String) get (key);
-
- // FIXME: JCL says that the key can contain many Unicode
- // characters. But it also doesn't say we should encode
- // it in any way.
- // FIXME: if key contains ':', '=', or whitespace, must
- // quote it here. Note that JDK 1.1 does not do this.
- output.write(key);
- output.write("=");
-
- boolean leading = true;
- for (int i = 0; i < value.length(); ++i)
- {
- boolean new_lead = false;
- char c = value.charAt(i);
- switch (c)
- {
- case '\n':
- output.write("\\n");
- break;
- case '\r':
- output.write("\\r");
- break;
- case '\t':
- output.write("\\t");
- break;
- case '\\':
- output.write("\\\\");
- break;
-
- case '#':
- case '!':
- case '=':
- case ':':
- output.write("\\");
- output.write(c);
- break;
-
- case ' ':
- new_lead = leading;
- if (leading)
- output.write("\\");
- output.write(c);
- break;
-
- default:
- if (c < '\u0020' || c > '\u007e')
- {
- output.write("\\u");
- output.write(Character.forDigit(c >>> 12, 16));
- output.write(Character.forDigit((c >>> 8) & 0xff,
- 16));
- output.write(Character.forDigit((c >>> 4) & 0xff,
- 16));
- output.write(Character.forDigit(c & 0xff, 16));
- }
- else
- output.write(c);
- }
- leading = new_lead;
- }
- output.write(newline);
- }
-
- output.flush();
- }
-}
diff --git a/libjava/java/util/PropertyResourceBundle.java b/libjava/java/util/PropertyResourceBundle.java
deleted file mode 100644
index 4171ddd29d2..00000000000
--- a/libjava/java/util/PropertyResourceBundle.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util;
-
-import java.io.InputStream;
-import java.io.IOException;
-import gnu.gcj.util.EnumerationChain;
-
-/**
- * @author Anthony Green <green@cygnus.com>
- * @date April 29, 1999.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1. */
-
-public class PropertyResourceBundle extends ResourceBundle
-{
- private Properties properties;
-
- public PropertyResourceBundle (InputStream pstream) throws IOException
- {
- // Initialize and load our Properties.
- properties = new Properties();
- properties.load(pstream);
- }
-
- public Enumeration getKeys()
- {
- if (parent == null)
- return properties.propertyNames();
- else
- return new EnumerationChain (properties.propertyNames(),
- parent.getKeys ());
- }
-
- public Object handleGetObject (String key)
- {
- return properties.getProperty(key);
- }
-}
diff --git a/libjava/java/util/Random.java b/libjava/java/util/Random.java
deleted file mode 100644
index e4bac59cad3..00000000000
--- a/libjava/java/util/Random.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-/* This class is completely specified by the spec to ensure absolute
- * portability between all implementations of Java
- */
-public class Random implements Serializable
-{
- /* Used by next() to hold the state of the pseudorandom number generator */
- protected long seed;
-
- /* Used by nextGaussian() to hold a precomputed value */
- /* to be delivered by that method the next time it is called */
- protected double nextNextGaussian;
-
- /* Used by nextGaussian() to keep track of whether it is has precomputed */
- /* and stashed away the next value to be delivered by that method */
- protected boolean haveNextNextGaussian = false;
-
- public Random()
- {
- this(System.currentTimeMillis());
- }
-
- public Random(long seed)
- {
- setSeed(seed);
- }
-
- protected synchronized int next(int bits)
- {
- seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
- return (int)(seed >>> (48 - bits));
- }
-
- // JDK1.2
- public boolean nextBoolean()
- {
- return next(1) != 0;
- }
-
- /* The method nextBytes() is not fully specified in the published specs.
- * At first I implemented it simply via:
- * for (int i = 0; i < buf.length; i++)
- * buf[i] = (byte)next(8);
- * but a simple test did not yield the same results as the std implementation.
- * There seemed to be a relationship where each i byte above was at pos 4*i+3
- * in the std. For efficiency, by reducing calls to the expensive math
- * routines, the std probably was calling next(32) once rather than next(8)
- * 4 times. Changing the algorithm to the one below based on that assumption
- * then yielded identical results to the std.
- */
- public void nextBytes(byte[] buf)
- {
- int randInt = 0;
-
- for (int i = 0; i < buf.length; i++)
- {
- int shift = (i % 4) * 8;
- if (shift == 0)
- randInt = next(32);
- buf[i] = (byte) (randInt >> shift);
- }
- }
-
- public double nextDouble()
- {
- return (((long)next(26) << 27) + next(27)) / (double)(1L << 53);
- }
-
- public float nextFloat()
- {
- return next(24) / ((float)(1 << 24));
- }
-
- public synchronized double nextGaussian()
- {
- if (haveNextNextGaussian)
- {
- haveNextNextGaussian = false;
- return nextNextGaussian;
- }
- else
- {
- double v1, v2, s;
- do
- {
- v1 = 2 * nextDouble() - 1; // between -1.0 and 1.0
- v2 = 2 * nextDouble() - 1; // between -1.0 and 1.0
- s = v1 * v1 + v2 * v2;
- } while (s >= 1);
- double norm = Math.sqrt(-2 * Math.log(s)/s);
- nextNextGaussian = v2 * norm;
- haveNextNextGaussian = true;
- return v1 * norm;
- }
- }
-
- public int nextInt()
- {
- return next(32);
- }
-
- // JDK1.2
- public int nextInt(int n)
- {
- if (n <= 0)
- throw new IllegalArgumentException("n must be positive");
-
- int bits, val;
- do
- {
- bits = next(31);
- val = bits % n;
- } while (bits - val + (n-1) < 0);
- return val;
- }
-
- public long nextLong()
- {
- return ((long)next(32) << 32) + next(32);
- }
-
- public synchronized void setSeed(long seed)
- {
- this.seed = (seed ^ 0x5DEECE66DL) & ((1L << 48) - 1);
- haveNextNextGaussian = false;
- }
-}
diff --git a/libjava/java/util/ResourceBundle.java b/libjava/java/util/ResourceBundle.java
deleted file mode 100644
index 6cec4c227a0..00000000000
--- a/libjava/java/util/ResourceBundle.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-import java.io.InputStream;
-
-/**
- * @author Anthony Green <green@cygnus.com>
- * @date November 26, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1. */
-
-public abstract class ResourceBundle
-{
- protected ResourceBundle parent;
-
- // This is used to cache resource bundles.
- private static Hashtable resource_cache = new Hashtable ();
-
- public ResourceBundle ()
- {
- }
-
- public final String getString (String key) throws MissingResourceException
- {
- return (String) getObject(key);
- }
-
- public final String[] getStringArray (String key)
- throws MissingResourceException
- {
- return (String[]) getObject(key);
- }
-
- public final Object getObject(String key) throws MissingResourceException
- {
- Object result;
-
- try
- {
- return handleGetObject (key);
- }
- catch (MissingResourceException ex)
- {
- if (parent != null)
- return parent.getObject(key);
- else
- throw ex;
- }
- }
-
- public static final ResourceBundle getBundle(String baseName)
- throws MissingResourceException
- {
- return getBundle(baseName, Locale.getDefault());
- }
-
- // Start searching with the name bundleName. Continue searching by
- // stripping off the '_' delimited tails until the search name is
- // the same as stopHere.
- private static final ResourceBundle trySomeGetBundle (String bundleName,
- String stopHere)
- {
- Class rbc;
- ResourceBundle needs_parent = null, r, result = null;
-
- while (true)
- {
- try
- {
- rbc = Class.forName(bundleName);
- r = null;
- try
- {
- r = (ResourceBundle) rbc.newInstance();
- }
- catch (IllegalAccessException ex)
- {
- // Fall through
- }
- catch (InstantiationException ex)
- {
- // Fall through
- }
- if (r != null)
- {
- if (result == null)
- result = r;
- if (needs_parent != null)
- {
- // We've been through the loop one or more times
- // already. Set the parent and keep going.
- needs_parent.setParent(r);
- }
- needs_parent = r;
- }
- }
- catch (ClassNotFoundException ex)
- {
- // Fall through.
- }
-
- // Look for a properties file.
- {
- InputStream i =
- ClassLoader.getSystemResourceAsStream (bundleName.replace ('.', '/')
- + ".properties");
- if (i != null)
- {
- try {
- return new PropertyResourceBundle (i);
- } catch (java.io.IOException e) {
- // The docs don't appear to define what happens in
- // this case, but it seems like continuing the
- // search is a reasonable thing to do.
- }
- }
- }
-
- if (bundleName.equals(stopHere))
- return result;
- else
- {
- int last = bundleName.lastIndexOf('_');
-
- // No more underscores?
- if (last == -1)
- return result;
-
- // Loop around, testing this new shorter name.
- bundleName = bundleName.substring(0, last);
- }
- }
- }
-
- // Search for bundles, but stop at baseName_language (if required).
- // This is synchronized so that the cache works correctly.
- private static final synchronized ResourceBundle
- partialGetBundle (String baseName, Locale locale, boolean langStop)
- {
- ResourceBundle rb;
-
- // Explicitly invoke locale.toString() to force a
- // NullPointerException when required.
- String bundleName = baseName + "_" + locale.toString();
-
- // Check the cache.
- Object obj = resource_cache.get(bundleName);
- if (obj != null)
- return (ResourceBundle) obj;
-
- String stopHere = (baseName
- + (langStop ? ("_" + locale.getLanguage()) : ""));
-
-
- rb = trySomeGetBundle(bundleName, stopHere);
- if (rb != null)
- resource_cache.put(bundleName, rb);
-
- return rb;
- }
-
- public static final ResourceBundle getBundle (String baseName,
- Locale locale)
- throws MissingResourceException
- {
- ResourceBundle rb;
- Class rbc;
-
- if (baseName == null)
- throw new NullPointerException ();
-
- rb = partialGetBundle(baseName, locale, false);
- if (rb != null)
- return rb;
-
- // Finally, try the default locale.
- if (! locale.equals(Locale.getDefault()))
- {
- rb = partialGetBundle(baseName, Locale.getDefault(), true);
- if (rb != null)
- return rb;
- }
-
- throw new MissingResourceException("can't load bundle",
- baseName,
- "bundle");
- }
-
- protected void setParent(ResourceBundle parent)
- {
- this.parent = parent;
- }
-
- protected abstract Object handleGetObject(String key)
- throws MissingResourceException;
-
- public abstract Enumeration getKeys();
-}
diff --git a/libjava/java/util/SimpleTimeZone.java b/libjava/java/util/SimpleTimeZone.java
deleted file mode 100644
index 64f9c505a50..00000000000
--- a/libjava/java/util/SimpleTimeZone.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
- * Status: Does not know how to figure out if daylight savings time
- * is in effect; hence only correct for zones without DST.
- * No known spec for hashCode.
- */
-
-public class SimpleTimeZone extends TimeZone
-{
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
-
- int dstSavings = 60 * 60 * 1000;
-
- int rawOffset;
-
- // int serialVersionOnStream;
-
- int startDay;
- int startDayOfWeek;
- int startMode; /// Seems to be JDK 1.2 only.
-
- int startMonth;
-
- int startTime;
-
- int startYear;
-
- int endDay;
-
- int endDayOfWeek;
-
- int endMode; // Seems to be JDK 1.2 only.
-
- int endMonth;
-
- int endTime;
-
- // byte[] monthLength;
-
- boolean useDaylight;
-
- public SimpleTimeZone (int rawOffset, String ID)
- {
- setID(ID);
- this.rawOffset = rawOffset;
- }
-
- public SimpleTimeZone (int rawOffset, String ID,
- int startMonth, int startDay,
- int startDayOfWeek, int startTime,
- int endMonth, int endDay,
- int endDayOfWeek, int endTime)
- {
- this(rawOffset, ID);
- setStartRule (startMonth, startDay, startDayOfWeek, startTime);
- setEndRule (endMonth, endDay, endDayOfWeek, endTime);
- }
-
- public int getRawOffset() { return rawOffset; }
- public void setRawOffset (int offsetMillis) { rawOffset = offsetMillis; }
-
- public int getOffset (int era, int year, int month, int day,
- int dayOfWeek, int millis)
- {
- int offset = getRawOffset();
- if (useDaylight)
- {
- if (startYear != 0
- && (year < startYear || era == GregorianCalendar.BC))
- return offset;
- boolean midYearSummer = startMonth < endMonth;
- if (midYearSummer ? (month < startMonth || month > endMonth)
- : (month < startMonth && month > endMonth))
- return offset; // Definitely not DST.
- if (midYearSummer ? (month > startMonth && month < endMonth)
- : (month > startMonth || month < endMonth))
- return offset + dstSavings; // Definitely DST.
- // Now it gets more complicated. Bail for now.
- throw new Error("not implemented - SimpleTimeZone.getOffset");
- }
- return offset;
- }
-
- public boolean useDaylightTime() { return useDaylight; }
-
- public boolean inDaylightTime(Date date)
- {
- if (! useDaylight)
- return false;
- throw new Error("not implemented - SimpleTimeZone.inDaylightTime");
- }
-
- public int getDSTSavings () { return dstSavings; }
-
- public void setDSTSavings (int millisSavedDuringDST)
- { dstSavings = millisSavedDuringDST; }
-
- public void setStartRule (int month, int dayOfWeekInMonth,
- int dayOfWeek, int time)
- {
- this.startMonth = month;
- this.startDay = dayOfWeekInMonth;
- this.startDayOfWeek = dayOfWeek;
- this.startTime = time;
- this.useDaylight = true;
- }
-
- public void setEndRule (int month, int dayOfWeekInMonth,
- int dayOfWeek, int time)
- {
- this.endMonth = month;
- this.endDay = dayOfWeekInMonth;
- this.endDayOfWeek = dayOfWeek;
- this.endTime = time;
- this.useDaylight = true;
- }
-
- public void setStartYear (int year)
- {
- this.startYear = startYear;
- }
-
- public boolean hasSameRules (TimeZone other)
- {
- if (this == other)
- return true;
- if (! (other instanceof SimpleTimeZone))
- return false;
- SimpleTimeZone o = (SimpleTimeZone) other;
- if (rawOffset != o.rawOffset)
- return false;
- if (useDaylight != o.useDaylight)
- return false;
- if (! useDaylight)
- return true;
- return startDay == o.startDay
- && startDayOfWeek == o.startDayOfWeek
- && startMonth == o.startMonth
- && startTime == o.startTime
- && endDay == o.endDay
- && endDayOfWeek == o.endDayOfWeek
- && endMonth == o.endMonth
- && endTime == o.endTime
- && startYear == o.startYear
- && startMode == o.startMode
- && endMode == o.endMode;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof SimpleTimeZone))
- return false;
- SimpleTimeZone other = (SimpleTimeZone) obj;
- return getID() == other.getID() && hasSameRules(other);
- }
-
- public Object clone ()
- {
- // We know the superclass just call's Object's generic cloner.
- return super.clone ();
- }
-
- public String toString ()
- {
- // The docs don't say much about how we might implement this.
- // We choose a debugging implementation.
- return ("dstSavings " + dstSavings
- + "; rawOffset " + rawOffset
- + "; startDay " + startDay
- + "; startDayOfWeek " + startDayOfWeek
- + "; startMode " + startMode
- + "; startMonth " + startMonth
- + "; startTime " + startTime
- + "; startYear " + startYear
- + "; endDay " + endDay
- + "; endDayOfWeek " + endDayOfWeek
- + "; endMode " + endMode
- + "; endMonth " + endMonth
- + "; endTime " + endTime
- + "; useDaylight " + useDaylight);
- }
-
- public int hashCode ()
- {
- // FIXME - this does not folow any spec (since none is public)!
- int hash = rawOffset;
- if (useDaylight)
- hash += dstSavings + startYear + startMode + endMode
- + startDay + startDayOfWeek + startMonth + startTime
- + endDay + endDayOfWeek + endMonth + endTime;
- return hash;
- }
-}
diff --git a/libjava/java/util/Stack.java b/libjava/java/util/Stack.java
deleted file mode 100644
index c7cb1c05753..00000000000
--- a/libjava/java/util/Stack.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 20, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public class Stack extends Vector
-{
- // Could use Vector methods internally for the following methods
- // but have used Vector fields directly for efficiency (i.e. this
- // often reduces out duplicate bounds checking).
-
- public boolean empty()
- {
- return elementCount == 0;
- }
-
- public synchronized Object peek()
- {
- if (elementCount == 0)
- throw new EmptyStackException();
-
- return elementData[elementCount - 1];
- }
-
- public synchronized Object pop()
- {
- if (elementCount == 0)
- throw new EmptyStackException();
-
- Object obj = elementData[--elementCount];
-
- // Set topmost element to null to assist the gc in cleanup
- elementData[elementCount] = null;
- return obj;
- }
-
- public Object push(Object obj)
- {
- // When growing the Stack, use the Vector routines in case more
- // memory is needed.
- // Note: spec indicates that this method *always* returns obj passed in!
-
- addElement(obj);
- return obj;
- }
-
- public synchronized int search(Object obj)
- {
- // Return the position of obj on the stack as measured from the top;
- // i.e. the top element is 1, the next element down is 2, etc.
- // If obj is not on the stack, return -1
-
- for (int i = elementCount-1; i >=0; --i)
- if (elementData[i].equals(obj))
- return elementCount - i;
-
- return -1;
- }
-}
diff --git a/libjava/java/util/StringTokenizer.java b/libjava/java/util/StringTokenizer.java
deleted file mode 100644
index b55c8f7714c..00000000000
--- a/libjava/java/util/StringTokenizer.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 24, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public class StringTokenizer implements Enumeration
-{
- /* String to be parsed */
- private String inputString;
-
- /* String to be parsed put into a char array for efficient access */
- private char[] chArray;
-
- /* Set of delimiter characters for separating tokens */
- private String delimiters;
-
- /* Whether delimiters in this instance are treated as tokens themselves */
- private boolean returnDelimiters;
-
- /* Index into the input string to start parsing for the next token */
- private int inputStringIndex;
-
- public StringTokenizer(String str)
- {
- this(str, " \t\n\r", false);
- }
-
- public StringTokenizer(String str, String delims)
- {
- this(str, delims, false);
- }
-
- public StringTokenizer(String str, String delims, boolean retDelim)
- {
- inputString = str;
- delimiters = delims;
- returnDelimiters = retDelim;
- inputStringIndex = 0;
-
- // Work on a copy of the remaining string in a char array
- // to gain efficiency of using primitives
- chArray = new char[inputString.length()];
- inputString.getChars(0, inputString.length(), chArray, 0);
- }
-
- public int countTokens()
- {
- int count = 0;
- int delimiterCount = 0;
- boolean tokenFound = false; // Set when a non-delimiter is found
- int offset = inputStringIndex;
-
- // Note for efficiency, we count up the delimiters rather than check
- // returnDelimiters every time we encounter one. That way, we can
- // just do the conditional once at the end of the method
- while (offset < chArray.length)
- {
- if (isDelimiter(chArray[offset++]))
- {
- if (tokenFound)
- {
- // Got to the end of a token
- count++;
- tokenFound = false;
- }
-
- delimiterCount++; // Increment for this delimiter
- }
- else
- {
- tokenFound = true;
-
- // Get to the end of the token
- while (offset < chArray.length && !isDelimiter(chArray[offset]))
- offset++;
- }
- }
-
- // Make sure to count the last token
- if (tokenFound)
- count++;
-
- // if counting delmiters add them into the token count
- return returnDelimiters ? count + delimiterCount : count;
- }
-
- public boolean hasMoreElements()
- {
- return hasMoreTokens();
- }
-
- public boolean hasMoreTokens()
- {
- int offset = inputStringIndex;
-
- while (offset < chArray.length)
- if (!isDelimiter(chArray[offset++]) || returnDelimiters)
- {
- // update the current position with the start of the next token
- inputStringIndex = --offset;
-
- return true;
- }
-
- return false;
- }
-
- public Object nextElement()
- {
- return nextToken();
- }
-
- public String nextToken()
- {
- int offset = inputStringIndex;
- int startSubstr = -1;
-
- // Make sure we have more chars left to parse
- // and then find the start of the next token
- while (offset < chArray.length && startSubstr < 0)
- {
- // Find the start of the token; skipping initial delimiters
- if (!isDelimiter(chArray[offset++]))
- startSubstr = offset - 1;
- else if (returnDelimiters)
- {
- // The single char delimiter is treated as a token
- inputStringIndex = offset; // update the current position
-
- return inputString.substring(offset - 1, inputStringIndex);
- }
- }
-
- // Now look for the end of the token
- while (offset < chArray.length)
- {
- if (isDelimiter(chArray[offset++]))
- {
- // Found the end of token
- inputStringIndex = offset - 1; // update the current position
-
- return inputString.substring(startSubstr, inputStringIndex);
- }
- }
-
- // Got to the end of the string without finding the start of a token
- if (startSubstr < 0)
- throw new NoSuchElementException();
-
- // Got to the end of the string before a delimiter
- inputStringIndex = offset; // update the current position
-
- return inputString.substring(startSubstr, inputStringIndex);
- }
-
- public String nextToken(String delims)
- {
- // First replace with new set of delimiters
- delimiters = delims;
-
- return nextToken();
- }
-
- // This private method could be inlined but the other methods are
- // more readable this way, so we'll take the hit on efficiency.
- private boolean isDelimiter(char ch)
- {
- return delimiters.indexOf(ch) >= 0;
- }
-}
diff --git a/libjava/java/util/TimeZone.java b/libjava/java/util/TimeZone.java
deleted file mode 100644
index 02296d9471c..00000000000
--- a/libjava/java/util/TimeZone.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
- * Status: getAvailableIDs, getDefault, getTimeZone only know about GMT.
- */
-
-public abstract class TimeZone implements java.io.Serializable, Cloneable
-{
- public static final int SHORT = 0;
- public static final int LONG = 1;
-
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
- String ID;
-
- static final TimeZone zoneGMT = new SimpleTimeZone(0, "GMT");
-
- private static TimeZone zoneDefault;
-
- public TimeZone ()
- {
- }
-
- public abstract int getOffset (int era, int year, int month,
- int day, int dayOfWeek, int milliseconds);
-
- public abstract void setRawOffset (int offsetMillis);
-
- public abstract int getRawOffset ();
-
- public String getID () { return ID; }
-
- public void setID (String ID) { this.ID = ID; }
-
- public final String getDisplayName()
- {
- return ID; // FIXME
- }
-
- // public final String getDisplayName (Local locale) { ... } FIXME
-
- public final String getDisplayName (boolean daylight, int style)
- {
- return ID; // FIXME
- }
-
- /*
- public final String getDisplayName (boolean daylight, int style, Locale locale)
- {
- return ID; // FIXME
- }
- */
-
- public abstract boolean useDaylightTime();
-
- public abstract boolean inDaylightTime (Date date);
-
- public static synchronized TimeZone getTimeZone (String ID)
- {
- int i;
- for (i = 0; i < tzIDs.length; ++i)
- {
- if (ID.equals(tzIDs[i]))
- break;
- }
- if (i == tzIDs.length)
- return null;
-
- if (timeZones[i] == null)
- {
- if (ID.equals("GMT"))
- timeZones[i] = zoneGMT;
- else
- timeZones[i] = new SimpleTimeZone (rawOffsets[i], tzIDs[i]);
- }
-
- return timeZones[i];
- }
-
- public static String[] getAvailableIDs()
- {
- return (String[]) tzIDs.clone();
- }
-
- public static String[] getAvailableIDs(int rawOffset)
- {
- int first, last;
-
- for (first = 0; first < rawOffsets.length; ++first)
- {
- if (rawOffset == rawOffsets[first])
- break;
- }
- if (first == rawOffsets.length)
- return new String[0];
- for (last = first + 1; last < rawOffsets.length; ++last)
- {
- if (rawOffset != rawOffsets[last])
- break;
- }
-
- String[] r = new String[last - first];
- for (int i = first; i < last; ++i)
- {
- r[i - first] = tzIDs[i];
- }
-
- return r;
- }
-
- private static synchronized TimeZone setDefault()
- {
- if (zoneDefault == null)
- {
- try
- {
- String id = System.getProperty("user.timezone");
- if (id != null && ! id.equals("GMT"))
- zoneDefault = getTimeZone(id);
- }
- catch (Exception ex)
- {
- }
- if (zoneDefault == null)
- zoneDefault = zoneGMT;
- }
- return zoneDefault;
- }
-
- public static TimeZone getDefault()
- {
- return zoneDefault == null ? setDefault() : zoneDefault;
- }
-
- public static void setDefault (TimeZone zone) { zoneDefault = zone; }
-
- public boolean hasSameRules (TimeZone other)
- {
- return this == other;
- }
-
- public Object clone ()
- {
- // Just use Object's generic cloner.
- return super.clone ();
- }
-
- // Names of timezones. This array is kept in parallel with
- // rawOffsets. This list comes from the JCL 1.1 book.
- private static final String[] tzIDs =
- {
- "MIT", "HST", "AST", "PST", "PNT",
- "MST", "CST", "EST", "IET", "PRT",
- "CNT", "AGT", "BET", "CAT", "GMT",
- "ECT", "EET", "ART", "EAT", "MET",
- "NET", "PLT", "IST", "BST", "VST",
- "CTT", "JST", "ACT", "AET", "SST",
- "NST"
- };
- // This holds raw offsets in milliseconds.
- // 3600000 == 60 * 60 * 1000
- private static final int[] rawOffsets =
- {
- -11 * 3600000, -10 * 3600000, -9 * 3600000, -8 * 3600000, -7 * 3600000,
- -7 * 3600000, -6 * 3600000, -5 * 3600000, -5 * 3600000, -4 * 3600000,
- -35 * 360000, -3 * 3600000, -3 * 3600000, -1 * 3600000, 0,
- 1 * 3600000, 1 * 3600000, 2 * 3600000, 3 * 3600000, 35 * 360000,
- 4 * 3600000, 5 * 3600000, 55 * 360000, 6 * 3600000, 7 * 3600000,
- 8 * 3600000, 9 * 3600000, 95 * 360000, 10 * 3600000, 11 * 3600000,
- 12 * 3600000
- };
- // This caches all the corresponding zone objects.
- private static TimeZone[] timeZones = new TimeZone[tzIDs.length];
-}
diff --git a/libjava/java/util/TooManyListenersException.java b/libjava/java/util/TooManyListenersException.java
deleted file mode 100644
index c171aa5fd44..00000000000
--- a/libjava/java/util/TooManyListenersException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class TooManyListenersException extends Exception
-{
- public TooManyListenersException()
- {
- super();
- }
-
- public TooManyListenersException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/Vector.java b/libjava/java/util/Vector.java
deleted file mode 100644
index 737c5b498f6..00000000000
--- a/libjava/java/util/Vector.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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 java.util;
-
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 17, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-class VectorEnumeration implements Enumeration
-{
- private int enumIndex;
- private Vector enumVec;
-
- public VectorEnumeration(Vector vec)
- {
- enumVec = vec;
- enumIndex = 0;
- }
-
- public boolean hasMoreElements()
- {
- return enumIndex < enumVec.size();
- }
-
- public Object nextElement()
- {
- if (!hasMoreElements())
- throw new NoSuchElementException();
-
- return enumVec.elementData[enumIndex++];
- }
-}
-
-// TODO12:
-// public class Vector extends AbstractList
-// implements List, Cloneable, Serializable
-
-public class Vector implements Cloneable, Serializable
-{
- /* The size of the increment to use when growing this vector.
- The default of 0 means to double the capacity when growing. */
- protected int capacityIncrement;
-
- /* The number of elements currently in elementData */
- protected int elementCount;
-
- /* The buffer in which elements of this vector are stored */
- protected Object[] elementData;
-
- public Vector()
- {
- this(10, 0);
- }
-
- public Vector(int initCap)
- {
- this(initCap, 0);
- }
-
- public Vector(int initCap, int capIncrement)
- {
- if (initCap < 0)
- throw new IllegalArgumentException ();
- elementData = new Object[initCap];
- capacityIncrement = capIncrement;
- elementCount = 0;
- }
-
- public final synchronized void addElement(Object obj)
- {
- // Make sure there's room for a new element
- if (elementCount == elementData.length)
- ensureCapacity(elementCount+1);
-
- elementData[elementCount++] = obj;
- }
-
- public final int capacity()
- {
- return elementData.length;
- }
-
- public synchronized Object clone()
- {
- // New vector needs to have same size, capacity and capacityIncrement
- Vector newVec = new Vector(elementData.length, capacityIncrement);
-
- System.arraycopy(elementData, 0, newVec.elementData, 0, elementCount);
- newVec.elementCount = elementCount;
- return newVec;
- }
-
- public final boolean contains(Object obj)
- {
- for (int i = 0; i < elementCount; i++)
- {
- if (obj == null
- ? elementData[i] == null
- : obj.equals(elementData[i]))
- return true;
- }
-
- return false;
- }
-
- public final synchronized void copyInto(Object[] objArray)
- {
- System.arraycopy(elementData, 0, objArray, 0, elementCount);
- }
-
- public final synchronized Object elementAt(int idx)
- {
- if (idx < 0 || idx >= size())
- throw new ArrayIndexOutOfBoundsException();
-
- return elementData[idx];
- }
-
- public final synchronized Enumeration elements()
- {
- return new VectorEnumeration(this);
- }
-
- public final synchronized void ensureCapacity(int minCap)
- {
- // Increasing the vector could make it much larger than minCap;
- // e.g. if minCap is just larger than the vector, size may double.
- // If someone cares about this possibility they should set capacityIncrement
- if (minCap > elementData.length)
- {
- // Increase the vector; double it if capacityIncrement is zero
- int newSize = elementData.length;
- newSize +=
- (capacityIncrement > 0) ? capacityIncrement : elementData.length;
-
- // Make sure newSize is at least minCap
- if (newSize < minCap)
- newSize = minCap;
-
- Object[] newArray = new Object[newSize];
- System.arraycopy(elementData, 0, newArray, 0, elementCount);
- elementData = newArray;
- }
- }
-
- public final synchronized Object firstElement()
- {
- if (elementCount == 0)
- throw new NoSuchElementException();
-
- return elementData[0];
- }
-
- public final int indexOf(Object obj)
- {
- return indexOf(obj, 0);
- }
-
- public final synchronized int indexOf(Object obj, int idx)
- {
- if (idx < 0)
- throw new IllegalArgumentException ();
- for (int i = idx; i < elementCount; i++)
- {
- if (obj == null
- ? elementData[i] == null
- : obj.equals(elementData[i]))
- return i;
- }
-
- return -1;
- }
-
- public final synchronized void insertElementAt(Object obj, int idx)
- {
- if (idx < 0 || idx > size())
- throw new ArrayIndexOutOfBoundsException();
- else if (idx == size()) // Spec says just use addElement()
- addElement(obj);
- else
- {
- // Make sure there's room for a new element
- if (elementCount == elementData.length)
- ensureCapacity(elementCount+1);
-
- // Shift the existing elements up and increment elementCount
- for (int i = elementCount++; i > idx; --i)
- elementData[i] = elementData[i-1];
-
- elementData[idx] = obj;
- }
- }
-
- public final boolean isEmpty()
- {
- return elementCount == 0;
- }
-
- public final synchronized Object lastElement()
- {
- if (elementCount == 0)
- throw new NoSuchElementException();
-
- return elementData[elementCount - 1];
- }
-
- public final int lastIndexOf(Object obj)
- {
- return lastIndexOf(obj, size()-1);
- }
-
- public final synchronized int lastIndexOf(Object obj, int idx)
- {
- if (idx < 0)
- throw new IllegalArgumentException ();
- for (int i = idx; i >= 0; --i)
- {
- if (obj == null
- ? elementData[i] == null
- : obj.equals(elementData[i]))
- return i;
- }
-
- return -1;
- }
-
- public final synchronized void removeAllElements()
- {
- // Remove elements now to assist the gc in early cleanup
- for (int i = elementCount-1; i >= 0; --i)
- elementData[i] = null;
- elementCount = 0;
- }
-
- public final synchronized boolean removeElement(Object obj)
- {
- for (int i = 0; i < elementCount; i++)
- {
- if (obj == null
- ? elementData[i] == null
- : obj.equals(elementData[i]))
- {
- int j;
-
- // Decrement count first to ensure we don't walk off end of array
- --elementCount;
-
- for (j = i; j < elementCount; j++)
- elementData[j] = elementData[j+1];
-
- // At this point, j was incrememented and points to old last element
- // Remove element now to assist the gc in early cleanup
- elementData[j] = null;
- return true;
- }
- }
-
- return false;
- }
-
- public final synchronized void removeElementAt(int idx)
- {
- int i;
-
- if (idx < 0 || idx >= size())
- throw new ArrayIndexOutOfBoundsException();
-
- // Decrement count first to ensure we don't walk off the end of the array
- --elementCount;
-
- for (i = idx; i < elementCount; i++)
- elementData[i] = elementData[i+1];
-
- // At this point, i was incrememented and now points to the old last element
- // Remove element now to assist the gc in early cleanup
- elementData[i] = null;
- }
-
- public final synchronized void setElementAt(Object obj, int idx)
- {
- if (idx < 0 || idx >= size())
- throw new ArrayIndexOutOfBoundsException();
-
- elementData[idx] = obj;
- }
-
- public final synchronized void setSize(int newSize)
- {
- if (newSize < 0)
- throw new ArrayIndexOutOfBoundsException();
-
- // Java Lang Spec p. 658 says to remove the excess elements and discard
- // when new size is smaller than old size.
- // When truncating, we could alternatively just reset elementCount instead
- // of freeing up the memory if the spec hadn't specified. The spec makes
- // sense though; if someone cares enough to call a setSize() function
- // they probably are doing so to free memory.
- if (newSize < elementCount)
- {
- elementCount = newSize;
- trimToSize();
- }
- else if (newSize > elementCount) // Skip == case
- {
- // TBD: ensureCapacity() may create a vector much larger than newSize;
- // do we want to make the vector exactly newSize? Spec is unclear.
- ensureCapacity(newSize);
-
- // Make sure to null out new elements of grown vector
- for (int i = elementCount; i < newSize; i++)
- elementData[i] = null;
- elementCount = newSize;
- }
- }
-
- public final int size()
- {
- return elementCount;
- }
-
- public final synchronized String toString()
- {
- // Following the Java Lang Spec p. 656
-
- // Prepend first element with open bracket
- StringBuffer result = new StringBuffer("[");
-
- if (elementCount > 0) // add first element if one exists
- result.append(elementData[0].toString());
-
- // Prepend subsequent elements with ", "
- for (int i = 1; i < elementCount; i++)
- result.append(", ").append(elementData[i].toString());
-
- // Append last element with closing bracket
- result.append("]");
- return result.toString();
- }
-
- public final synchronized void trimToSize()
- {
- // Give up excess storage capacity to save memory
- //
- // Don't bother checking for the case where size() == the capacity of the
- // vector since that is a much less likely case; it's more efficient to
- // not do the check and lose a bit of performance in that infrequent case
- Object[] newArray = new Object[elementCount];
- System.arraycopy(elementData, 0, newArray, 0, elementCount);
- elementData = newArray;
- }
-
- // TODO12:
- // public Vector(Collection c)
- // {
- // }
-
- // TODO12:
- // public public boolean add(Object o)
- // {
- // }
-
- // TODO12:
- // public void add(int index, Object element)
- // {
- // }
-
- // TODO12:
- // public boolean addAll(Collection c)
- // {
- // }
-
- // TODO12:
- // public boolean addAll(int index, Collection c)
- // {
- // }
-
- // TODO12:
- // public void clear()
- // {
- // }
-
- // TODO12:
- // public boolean containsAll(Collection c)
- // {
- // }
-
- // TODO12:
- // public boolean equals(Object o)
- // {
- // }
-
- // TODO12:
- // public int hashCode()
- // {
- // }
-
- // TODO12:
- // public Object get(int index)
- // {
- // }
-
- // TODO12:
- // public boolean remove(Object o)
- // {
- // }
-
- // TODO12:
- // public Object remove(int index)
- // {
- // }
-
- // TODO12:
- // public boolean removeAll(Collection c)
- // {
- // }
-
- // TODO12:
- // public boolean retainAll(Collection c)
- // {
- // }
-
- // TODO12:
- // public Object set(int index, Object element)
- // {
- // }
-
- // TODO12:
- // public Object[] toArray()
- // {
- // }
-
- // TODO12:
- // public Object[] toArray(Object[] a)
- // {
- // }
-}
diff --git a/libjava/java/util/jar/JarEntry.java b/libjava/java/util/jar/JarEntry.java
deleted file mode 100644
index eaebd1ad7d5..00000000000
--- a/libjava/java/util/jar/JarEntry.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.jar;
-
-import java.util.zip.*;
-
-/**
- * Does not implement the security and manifest methods.
- *
- * @author Kresten Krab Thorup <krab@gnu.org>
- * @date August 10, 1999.
- */
-
-public class JarEntry extends ZipEntry
-{
- ZipEntry zip;
-
- public JarEntry (ZipEntry ent)
- {
- super (ent);
- }
-
- public JarEntry (JarEntry ent)
- {
- super (ent);
- }
-
- public JarEntry (String name)
- {
- super (name);
- }
-
-}
diff --git a/libjava/java/util/jar/JarFile.java b/libjava/java/util/jar/JarFile.java
deleted file mode 100644
index b36338c218b..00000000000
--- a/libjava/java/util/jar/JarFile.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.jar;
-
-import java.util.zip.*;
-import java.io.File;
-
-/**
- * Does not implement any of the security. Just a place holder, so
- * that I can implement URLClassLoader.
- *
- * @author Kresten Krab Thorup <krab@gnu.org>
- * @date August 10, 1999.
- */
-
-public class JarFile extends ZipFile
-{
- private boolean verify;
-
- public JarFile (String file) throws java.io.IOException
- {
- super (file);
- }
-
- public JarFile (File file) throws java.io.IOException
- {
- super (file);
- }
-
- public JarFile (String file, boolean verify) throws java.io.IOException
- {
- super (file);
- this.verify = verify;
- }
-
- public JarFile (File file, boolean verify) throws java.io.IOException
- {
- super (file);
- this.verify = verify;
- }
-
- public JarEntry getJarEntry (String name)
- {
- ZipEntry ent = getEntry(name);
- if (ent == null)
- return null;
- else
- return new JarEntry(ent);
- }
-}
diff --git a/libjava/java/util/jar/JarInputStream.java b/libjava/java/util/jar/JarInputStream.java
deleted file mode 100644
index 33daf61c5fb..00000000000
--- a/libjava/java/util/jar/JarInputStream.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.jar;
-
-import java.util.zip.*;
-
-/**
- * Does not implement any of the security. Just a place holder, so
- * that I can implement URLClassLoader.
- *
- * @author Kresten Krab Thorup <krab@gnu.org>
- * @date August 10, 1999.
- */
-
-public class JarInputStream extends ZipInputStream
-{
- public JarEntry getNextJarEntry () throws java.io.IOException
- {
- return new JarEntry (getNextEntry ());
- }
-
- public JarInputStream (java.io.InputStream is)
- {
- super(is);
- }
-}
diff --git a/libjava/java/util/natGregorianCalendar.cc b/libjava/java/util/natGregorianCalendar.cc
deleted file mode 100644
index af0d4e7eef4..00000000000
--- a/libjava/java/util/natGregorianCalendar.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- 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. */
-
-#include <config.h>
-
-// We want to make sure to pick up the POSIX `_r' functions. Some
-// systems, such as Solaris 2.6, require this define in order to
-// declare the functions in the appropriate header.
-#if defined (HAVE_GMTIME_R) || defined (HAVE_LOCALTIME_R)
-# define _POSIX_PTHREAD_SEMANTICS
-# ifndef _REENTRANT
-# define _REENTRANT
-# endif /* _REENTRANT */
-#endif
-
-#ifdef ECOS
-#include <string.h>
-#endif
-
-#include <gcj/cni.h>
-#include <java/util/TimeZone.h>
-#include <java/util/GregorianCalendar.h>
-#include <time.h>
-
-void
-java::util::GregorianCalendar::computeTime ()
-{
- struct tm tim;
- tim.tm_sec = elements(fields)[SECOND];
- tim.tm_min = elements(fields)[MINUTE];
- tim.tm_hour = elements(fields)[HOUR_OF_DAY];
- tim.tm_mday = elements(fields)[DATE];
- tim.tm_mon = elements(fields)[MONTH];
- tim.tm_year = elements(fields)[YEAR] - 1900;
- tim.tm_isdst = 0; // FIXME
-#ifndef ECOS
- // FIXME: None of the standard C library access to the ECOS calendar
- // is yet available.
- time_t t = mktime (&tim);
-#else
- time_t t = 0;
-#endif
-
- // Adjust for local timezone (introduced by mktime) and our
- // timezone.
-#if defined (STRUCT_TM_HAS_GMTOFF)
- t += tim.tm_gmtoff;
-#elif defined (HAVE_TIMEZONE)
- t -= timezone;
-#endif
- java::util::TimeZone *zone = getTimeZone ();
- t += zone->getRawOffset();
-
- // Adjust for milliseconds.
- time = t * (jlong) 1000 + elements(fields)[MILLISECOND];
-
- isTimeSet = true;
-}
-
-void
-java::util::GregorianCalendar::computeFields ()
-{
- time_t t = time / 1000;
- int millis = time % 1000;
- if (t < 0 && millis != 0)
- {
- t--;
- millis = t - 1000 * t;
- }
- elements(fields)[MILLISECOND] = millis;
- struct tm tim;
- java::util::TimeZone *zone = getTimeZone ();
-
- // FIXME: None of the standard C library access to the ECOS calendar
- // is yet available.
-#ifdef ECOS
- memset (&tim, 0, sizeof tim);
-#else
- if (zone->getRawOffset() == 0 || ! zone->useDaylightTime())
- {
-#if defined(__JV_POSIX_THREADS__) && defined(HAVE_GMTIME_R)
- gmtime_r (&t, &tim);
-#else
- // Get global lock (because gmtime uses a global buffer). FIXME
- tim = *(struct tm*) gmtime (&t);
- // Release global lock. FIXME
-#endif
- }
- else
- {
-#if defined(__JV_POSIX_THREADS__) && defined(HAVE_LOCALTIME_R)
- localtime_r (&t, &tim);
-#else
- // Get global lock (because localtime uses a global buffer). FIXME
- tim = *(struct tm*) localtime (&t);
- // Release global lock. FIXME
-#endif
- }
-#endif /* ECOS */
- elements(fields)[SECOND] = tim.tm_sec;
- elements(fields)[MINUTE] = tim.tm_min;
- elements(fields)[HOUR_OF_DAY] = tim.tm_hour;
- elements(fields)[AM_PM] = tim.tm_hour < 12 ? AM : PM;
- elements(fields)[HOUR] = tim.tm_hour % 12;
- elements(fields)[DATE] = tim.tm_mday;
- elements(fields)[MONTH] = tim.tm_mon;
- elements(fields)[YEAR] = 1900 + tim.tm_year;
- elements(fields)[DAY_OF_WEEK] = tim.tm_wday + 1;
- elements(fields)[DAY_OF_WEEK_IN_MONTH] = ((tim.tm_mday - 1) / 7) + 1;
- elements(fields)[DAY_OF_YEAR] = tim.tm_yday + 1;
- elements(fields)[WEEK_OF_MONTH]
- = (tim.tm_mday + 6 + (5 - tim.tm_wday + getFirstDayOfWeek()) % 7) / 7;
- elements(fields)[WEEK_OF_YEAR]
- = (tim.tm_yday + 7 + (5 - tim.tm_wday + getFirstDayOfWeek()) % 7) / 7;
- elements(fields)[ERA] = AD;
- elements(fields)[DST_OFFSET] = tim.tm_isdst <= 0 ? 0 : 60*60*1000;
- elements(fields)[ZONE_OFFSET] = getTimeZone()->getRawOffset();
- areFieldsSet = true;
-}
diff --git a/libjava/java/util/zip/Adler32.java b/libjava/java/util/zip/Adler32.java
deleted file mode 100644
index fc9596cdf12..00000000000
--- a/libjava/java/util/zip/Adler32.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-/**
- * @author Per Bothner
- * @date April 6, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * The actual Adler32 algorithm is taken from RFC 1950.
- * Status: Believed complete and correct.
- */
-
-public class Adler32 implements Checksum
-{
- private static int BASE = 65521; /* largest prime smaller than 65536 */
-
- int s1;
- int s2;
-
- public Adler32 ()
- {
- reset();
- }
-
- public void reset () { s1 = 1; s2 = 0; }
-
- public void update (int bval)
- {
- s1 = (s1 + (bval & 0xFF)) % BASE;
- s2 = (s1 + s2) % BASE;
- }
-
- public void update (byte[] buffer)
- {
- update(buffer, 0, buffer.length);
- }
-
- public void update (byte[] buf, int off, int len)
- {
- int s1 = this.s1;
- int s2 = this.s2;
- while (len > 0)
- {
- // We can defer the modulo operation.
- int n = 4000;
- if (n > len)
- n = len;
- len -= n;
- while (--n >= 0)
- {
- s1 = s1 + (buf[off++] & 0xFF);
- s2 = s2 + s1;
- }
- s1 %= BASE;
- s2 %= BASE;
- }
- this.s1 = s1;
- this.s2 = s2;
- }
-
- public long getValue()
- {
- return ((long) s2 << 16) + s1;
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/libjava/java/util/zip/CRC32.java b/libjava/java/util/zip/CRC32.java
deleted file mode 100644
index 535cf184c72..00000000000
--- a/libjava/java/util/zip/CRC32.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-/**
- * @author Per Bothner
- * @date April 1, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * The actual CRC32 algorithm is taken from RFC 1952.
- * Status: Believed complete and correct.
- */
-
-public class CRC32 implements Checksum
-{
- int crc = 0;
-
- static int[] crc_table = make_crc_table();
-
- /* Make the table for a fast CRC. */
- static int[] make_crc_table ()
- {
- int[] crc_table = new int[256];
- for (int n = 0; n < 256; n++)
- {
- int c = n;
- for (int k = 8; --k >= 0; )
- {
- if ((c & 1) != 0)
- c = 0xedb88320 ^ (c >>> 1);
- else
- c = c >>> 1;
- }
- crc_table[n] = c;
- }
- return crc_table;
- }
-
- public long getValue ()
- {
- return (long) crc & 0xffffffffL;
- }
-
- public void reset () { crc = 0; }
-
- public void update (int bval)
- {
- int c = ~crc;
- c = crc_table[(c ^ bval) & 0xff] ^ (c >>> 8);
- crc = ~c;
- }
-
- public void update (byte[] buf, int off, int len)
- {
- int c = ~crc;
- while (--len >= 0)
- c = crc_table[(c ^ buf[off++]) & 0xff] ^ (c >>> 8);
- crc = ~c;
- }
- public void update (byte[] buf) { update(buf, 0, buf.length); }
-}
diff --git a/libjava/java/util/zip/CheckedInputStream.java b/libjava/java/util/zip/CheckedInputStream.java
deleted file mode 100644
index fce050d2a73..00000000000
--- a/libjava/java/util/zip/CheckedInputStream.java
+++ /dev/null
@@ -1,80 +0,0 @@
-// CheckedInputStream.java - Compute checksum of data being read.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-import java.io.FilterInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class CheckedInputStream extends FilterInputStream
-{
- public CheckedInputStream (InputStream in, Checksum sum)
- {
- super (in);
- this.sum = sum;
- }
-
- public Checksum getChecksum ()
- {
- return sum;
- }
-
- public int read () throws IOException
- {
- int x = in.read();
- if (x != -1)
- sum.update(x);
- return x;
- }
-
- public int read (byte[] buf, int off, int len) throws IOException
- {
- int r = in.read(buf, off, len);
- if (r != -1)
- sum.update(buf, off, r);
- return r;
- }
-
- public long skip (long n) throws IOException
- {
- if (n == 0)
- return 0;
-
- int min = (int) Math.min(n, 1024);
- byte[] buf = new byte[min];
-
- long s = 0;
- while (n > 0)
- {
- int r = in.read(buf, 0, min);
- if (r == -1)
- break;
- n -= r;
- s += r;
- sum.update(buf, 0, r);
- }
-
- return s;
- }
-
- // The checksum object.
- private Checksum sum;
-}
diff --git a/libjava/java/util/zip/CheckedOutputStream.java b/libjava/java/util/zip/CheckedOutputStream.java
deleted file mode 100644
index a6323037cd7..00000000000
--- a/libjava/java/util/zip/CheckedOutputStream.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// CheckedOutputStream.java - Compute checksum of data being written.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-import java.io.FilterOutputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class CheckedOutputStream extends FilterOutputStream
-{
- public CheckedOutputStream (OutputStream out, Checksum cksum)
- {
- super (out);
- this.sum = cksum;
- }
-
- public Checksum getChecksum ()
- {
- return sum;
- }
-
- public void write (int bval) throws IOException
- {
- out.write(bval);
- sum.update(bval);
- }
-
- public void write (byte[] buf, int off, int len) throws IOException
- {
- out.write(buf, off, len);
- sum.update(buf, off, len);
- }
-
- // The checksum object.
- private Checksum sum;
-}
diff --git a/libjava/java/util/zip/Checksum.java b/libjava/java/util/zip/Checksum.java
deleted file mode 100644
index e37d1834e04..00000000000
--- a/libjava/java/util/zip/Checksum.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-/**
- * @author Per Bothner
- * @date January 9, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public interface Checksum
-{
- public long getValue ();
-
- public void reset ();
-
- public void update (int bval);
-
- public void update (byte[] buf, int off, int len);
-}
diff --git a/libjava/java/util/zip/DataFormatException.java b/libjava/java/util/zip/DataFormatException.java
deleted file mode 100644
index 10d1616cdd6..00000000000
--- a/libjava/java/util/zip/DataFormatException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// DataFormatException.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.util.zip;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Believed complete and correct.
- */
-
-public class DataFormatException extends Exception
-{
- public DataFormatException ()
- {
- super();
- }
-
- public DataFormatException (String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/zip/Deflater.java b/libjava/java/util/zip/Deflater.java
deleted file mode 100644
index 6cf82a79550..00000000000
--- a/libjava/java/util/zip/Deflater.java
+++ /dev/null
@@ -1,129 +0,0 @@
-// Deflater.java - Compress a data stream.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-import gnu.gcj.RawData;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class Deflater
-{
- public static final int BEST_COMPRESSION = 9;
- public static final int BEST_SPEED = 1;
- public static final int DEFAULT_COMPRESSION = -1;
- public static final int NO_COMPRESSION = 0;
-
- public static final int DEFAULT_STRATEGY = 0;
- public static final int FILTERED = 1;
- public static final int HUFFMAN_ONLY = 2;
-
- public static final int DEFLATED = 8;
-
- public int deflate (byte[] buf)
- {
- return deflate (buf, 0, buf.length);
- }
-
- public native int deflate (byte[] buf, int off, int len);
- public native void init (int level, boolean noHeader);
- public native void update ();
-
- public Deflater ()
- {
- this (DEFAULT_COMPRESSION, false);
- }
-
- public Deflater (int lvl)
- {
- this (lvl, false);
- }
-
- public Deflater (int lvl, boolean noHeader)
- {
- this.strategy = DEFAULT_STRATEGY;
- init (lvl, noHeader);
- setLevel (lvl);
- }
-
- public native void end ();
-
- protected void finalize ()
- {
- end ();
- }
-
- public native void finish ();
-
- public synchronized boolean finished ()
- {
- return is_finished;
- }
-
- public native int getAdler ();
- public native int getTotalIn ();
- public native int getTotalOut ();
- public native boolean needsInput ();
- public native void reset ();
-
- public void setDictionary (byte[] buf)
- {
- setDictionary (buf, 0, buf.length);
- }
-
- public native void setDictionary (byte[] buf, int off, int len);
-
- public void setInput (byte[] buf)
- {
- setInput (buf, 0, buf.length);
- }
-
- public native void setInput (byte[] buf, int off, int len);
-
- public synchronized void setLevel (int lvl)
- {
- if (lvl != -1 && (lvl < 0 || lvl > 9))
- throw new IllegalArgumentException ();
- level = (lvl == -1) ? 6 : lvl;
- update ();
- }
-
- public synchronized void setStrategy (int stgy)
- {
- if (stgy != DEFAULT_STRATEGY && stgy != FILTERED
- && stgy != HUFFMAN_ONLY)
- throw new IllegalArgumentException ();
- strategy = stgy;
- update ();
- }
-
- // Compression level.
- private int level;
-
- // Compression strategy.
- private int strategy;
-
- // The zlib stream.
- private RawData zstream;
-
- // True if finished.
- private boolean is_finished;
-
- // `Flush' flag to pass to next call to deflate.
- private int flush_flag;
-}
diff --git a/libjava/java/util/zip/DeflaterOutputStream.java b/libjava/java/util/zip/DeflaterOutputStream.java
deleted file mode 100644
index 410d8868106..00000000000
--- a/libjava/java/util/zip/DeflaterOutputStream.java
+++ /dev/null
@@ -1,87 +0,0 @@
-// DeflaterOutputStream.java - Output filter for compressing.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-import java.io.FilterOutputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class DeflaterOutputStream extends FilterOutputStream
-{
- public void close () throws IOException
- {
- finish ();
- out.close();
- }
-
- protected void deflate () throws IOException
- {
- while (true)
- {
- int len = def.deflate(buf, 0, buf.length);
- if (len == 0 || len == -1)
- break;
- out.write(buf, 0, len);
- }
- }
-
- public DeflaterOutputStream (OutputStream out)
- {
- this (out, new Deflater (), 512);
- }
-
- public DeflaterOutputStream (OutputStream out, Deflater defl)
- {
- this (out, defl, 512);
- }
-
- public DeflaterOutputStream(OutputStream out, Deflater defl, int bufsize)
- {
- super (out);
- buf = new byte[bufsize];
- def = defl;
- }
-
- public void finish () throws IOException
- {
- def.finish();
- deflate ();
- }
-
- public void write (int bval) throws IOException
- {
- byte[] b = new byte[1];
- b[0] = (byte) bval;
- write (b, 0, 1);
- }
-
- public void write (byte[] buf, int off, int len) throws IOException
- {
- def.setInput (buf, off, len);
- deflate ();
- }
-
- // The retrieval buffer.
- protected byte[] buf;
-
- // Deflater used to compress data.
- protected Deflater def;
-}
diff --git a/libjava/java/util/zip/GZIPInputStream.java b/libjava/java/util/zip/GZIPInputStream.java
deleted file mode 100644
index bea5eb38b1d..00000000000
--- a/libjava/java/util/zip/GZIPInputStream.java
+++ /dev/null
@@ -1,154 +0,0 @@
-// GZIPInputStream.java - Input tiler for reading gzip file.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class GZIPInputStream extends InflaterInputStream
-{
- public static final int GZIP_MAGIC = 0x8b1f;
-
- public void close () throws IOException
- {
- // Nothing to do here.
- super.close();
- }
-
- public GZIPInputStream (InputStream istream) throws IOException
- {
- this (istream, 512);
- }
-
- private final int eof_read () throws IOException
- {
- int r = in.read();
- if (r == -1)
- throw new ZipException ("gzip header corrupted");
- return r & 0xff;
- }
-
- public GZIPInputStream (InputStream istream, int readsize)
- throws IOException
- {
- super (istream, new Inflater (true), readsize);
-
- // NOTE: header reading code taken from zlib's gzio.c.
-
- // Read the magic number.
- int magic = eof_read () | (eof_read () << 8);
- if (magic != GZIP_MAGIC)
- throw new ZipException ("gzip header corrupted");
-
- int method = eof_read ();
- int flags = eof_read ();
- // Test from zlib.
- if (method != Z_DEFLATED || (flags & RESERVED) != 0)
- throw new ZipException ("gzip header corrupted");
-
- // Discard time, xflags, OS code.
- for (int i = 0; i < 6; ++i)
- eof_read ();
-
- // Skip the extra field.
- if ((flags & EXTRA_FIELD) != 0)
- {
- int len = eof_read () | (eof_read () << 8);
- while (len-- != 0)
- eof_read ();
- }
-
- if ((flags & ORIG_NAME) != 0)
- {
- while (true)
- {
- int c = eof_read ();
- if (c == 0)
- break;
- }
- }
-
- if ((flags & COMMENT) != 0)
- {
- while (true)
- {
- int c = eof_read ();
- if (c == 0)
- break;
- }
- }
-
- if ((flags & HEAD_CRC) != 0)
- {
- // FIXME: consider checking CRC of the header.
- eof_read ();
- eof_read ();
- }
-
- crc = new CRC32 ();
- }
-
- public int read (byte[] buf, int off, int len) throws IOException
- {
- if (eos)
- return -1;
- int r = super.read(buf, off, len);
- if (r == -1)
- {
- eos = true;
- int header_crc = read4 ();
- if (crc.getValue() != header_crc)
- throw new ZipException ("corrupted gzip file");
- // Read final `ISIZE' field.
- // FIXME: should we check this length?
- read4 ();
- return -1;
- }
- crc.update(buf, off, r);
- return r;
- }
-
- private final int read4 () throws IOException
- {
- int byte0 = in.read();
- int byte1 = in.read();
- int byte2 = in.read();
- int byte3 = in.read();
- if (byte3 < 0)
- throw new ZipException (".zip archive ended prematurely");
- return ((byte3 & 0xFF) << 24) + ((byte2 & 0xFF) << 16)
- + ((byte1 & 0xFF) << 8) + (byte0 & 0xFF);
- }
-
- // Checksum used by this input stream.
- protected CRC32 crc;
-
- // Indicates whether end-of-stream has been reached.
- protected boolean eos;
-
- // Some constants from zlib.
- static final int Z_DEFLATED = 8;
- static final int HEAD_CRC = 0x02;
- static final int EXTRA_FIELD = 0x04;
- static final int ORIG_NAME = 0x08;
- static final int COMMENT = 0x10;
- static final int RESERVED = 0xe0;
-}
diff --git a/libjava/java/util/zip/GZIPOutputStream.java b/libjava/java/util/zip/GZIPOutputStream.java
deleted file mode 100644
index be117273cde..00000000000
--- a/libjava/java/util/zip/GZIPOutputStream.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// GZIPOutputStream.java - Create a file in gzip format.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class GZIPOutputStream extends DeflaterOutputStream
-{
- public void close () throws IOException
- {
- finish ();
- out.close ();
- }
-
- public void finish () throws IOException
- {
- super.finish();
- put4 ((int) crc.getValue());
- put4 (def.getTotalIn());
- }
-
- public GZIPOutputStream (OutputStream out) throws IOException
- {
- this (out, 512);
- }
-
- public GZIPOutputStream (OutputStream out, int readsize) throws IOException
- {
- super (out, new Deflater (Deflater.DEFAULT_COMPRESSION, true), readsize);
-
- put2 (GZIPInputStream.GZIP_MAGIC);
- out.write (GZIPInputStream.Z_DEFLATED);
- // No flags for now.
- out.write (0);
- // No time either.
- put2 (0);
- put2 (0);
- // No xflags either.
- out.write (0);
- // FIXME: unknown OS.
- out.write (255);
-
- crc = new CRC32 ();
- }
-
- public synchronized void write (byte[] buf) throws IOException
- {
- write (buf, 0, buf.length);
- }
-
- public synchronized void write (byte[] buf, int off, int len)
- throws IOException
- {
- super.write(buf, off, len);
- crc.update(buf, off, len);
- }
-
- private final void put2 (int i) throws IOException
- {
- out.write (i);
- out.write (i >> 8);
- }
-
- private final void put4 (int i) throws IOException
- {
- out.write (i);
- out.write (i >> 8);
- out.write (i >> 16);
- out.write (i >> 24);
- }
-
- // Checksum used by this stream.
- protected CRC32 crc;
-}
diff --git a/libjava/java/util/zip/Inflater.java b/libjava/java/util/zip/Inflater.java
deleted file mode 100644
index dc2e24dec1e..00000000000
--- a/libjava/java/util/zip/Inflater.java
+++ /dev/null
@@ -1,98 +0,0 @@
-// Inflater.java - Decompress a data stream.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-import gnu.gcj.RawData;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class Inflater
-{
- public native void end ();
-
- protected void finalize ()
- {
- end ();
- }
-
- public synchronized boolean finished ()
- {
- return is_finished;
- }
-
- public native int getAdler ();
- public native int getRemaining ();
- public native int getTotalIn ();
- public native int getTotalOut ();
-
- public int inflate (byte[] buf) throws DataFormatException
- {
- return inflate (buf, 0, buf.length);
- }
-
- public native int inflate (byte[] buf, int off, int len)
- throws DataFormatException;
-
- private native void init (boolean noHeader);
-
- public Inflater ()
- {
- this (false);
- }
-
- public Inflater (boolean noHeader)
- {
- init (noHeader);
- }
-
- public synchronized boolean needsDictionary ()
- {
- return dict_needed;
- }
-
- public synchronized boolean needsInput ()
- {
- return getRemaining () == 0;
- }
-
- public native void reset ();
-
- public void setDictionary (byte[] buf)
- {
- setDictionary (buf, 0, buf.length);
- }
-
- public native void setDictionary (byte[] buf, int off, int len);
-
- public void setInput (byte[] buf)
- {
- setInput (buf, 0, buf.length);
- }
-
- public native void setInput (byte[] buf, int off, int len);
-
- // The zlib stream.
- private RawData zstream;
-
- // True if finished.
- private boolean is_finished;
-
- // True if dictionary needed.
- private boolean dict_needed;
-}
diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java
deleted file mode 100644
index c5840e7a5fa..00000000000
--- a/libjava/java/util/zip/InflaterInputStream.java
+++ /dev/null
@@ -1,109 +0,0 @@
-// InflaterInputStream.java - Input stream filter for decompressing.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-import java.io.FilterInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class InflaterInputStream extends FilterInputStream
-{
- protected void fill () throws IOException
- {
- len = in.read(buf, 0, buf.length);
- if (len != -1)
- inf.setInput(buf, 0, len);
- }
-
- public InflaterInputStream (InputStream in)
- {
- this (in, new Inflater (), 512);
- }
-
- public InflaterInputStream (InputStream in, Inflater infl)
- {
- this (in, infl, 512);
- }
-
- public InflaterInputStream (InputStream in, Inflater infl, int bufsize)
- {
- super (in);
- this.inf = infl;
- this.buf = new byte[bufsize];
- }
-
- public int read () throws IOException
- {
- byte[] buf = new byte[1];
- int r = read (buf, 0, 1);
- if (r != -1)
- r = buf[0] & 0xff;
- return r;
- }
-
- public int read (byte[] buf, int off, int len) throws IOException
- {
- if (inf.finished())
- return -1;
- if (inf.needsInput())
- fill ();
- if (inf.needsDictionary())
- return -1;
- try
- {
- return inf.inflate(buf, off, len);
- }
- catch (DataFormatException dfe)
- {
- throw new ZipException (dfe.getMessage());
- }
- }
-
- public long skip (long n) throws IOException
- {
- if (n == 0)
- return 0;
-
- int min = (int) Math.min(n, 1024);
- byte[] buf = new byte[min];
-
- long s = 0;
- while (n > 0)
- {
- int r = read (buf, 0, min);
- if (r == -1)
- break;
- n -= r;
- s += r;
- }
-
- return s;
- }
-
- // Buffer for delivering uncompressed data to inflater.
- protected byte[] buf;
-
- // Inflater used to decompress data.
- protected Inflater inf;
-
- // Number of read bytes in buf.
- protected int len;
-}
diff --git a/libjava/java/util/zip/ZipConstants.java b/libjava/java/util/zip/ZipConstants.java
deleted file mode 100644
index 3e3cd8a1c37..00000000000
--- a/libjava/java/util/zip/ZipConstants.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-interface ZipConstants
-{
- // Size in bytes of local file header, including signature.
- public static final int LOCAL_FILE_HEADER_SIZE = 30;
-
- // Size in bytes of the "end of central directory" record, with signature.
- public static final int END_CENTRAL_DIR_SIZE = 22;
-}
diff --git a/libjava/java/util/zip/ZipEntry.java b/libjava/java/util/zip/ZipEntry.java
deleted file mode 100644
index 39df164e2b3..00000000000
--- a/libjava/java/util/zip/ZipEntry.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-
-/**
- * @author Per Bothner
- * @date January 6, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class ZipEntry implements ZipConstants
-{
- // These values were determined using a simple test program.
- public static final int STORED = 0;
- public static final int DEFLATED = 8;
-
- String comment;
- long compressedSize = -1;
- long crc = -1;
- byte[] extra;
- int method = -1;
- String name;
- long size = -1;
- long time = -1;
- long relativeOffset = -1;
-
- ZipEntry next;
-
- public ZipEntry (String name)
- {
- if (name == null)
- throw new NullPointerException ();
- if (name.length() > 65535)
- throw new IllegalArgumentException ();
- this.name = name;
- }
-
- public ZipEntry (ZipEntry ent)
- {
- comment = ent.comment;
- compressedSize = ent.compressedSize;
- crc = ent.crc;
- extra = ent.extra;
- method = ent.method;
- size = ent.size;
- time = ent.time;
- relativeOffset = ent.relativeOffset;
- }
-
- public String getComment () { return comment; }
-
- public long getCompressedSize () { return compressedSize; }
-
- public long getCrc () { return crc; }
-
- public byte[] getExtra() { return extra; }
-
- public int getMethod () { return method; }
-
- public String getName () { return name; }
-
- public long getSize () { return size; }
-
- public long getTime () { return time; }
-
- public boolean isDirectory ()
- {
- if (name != null)
- {
- int nlen = name.length();
- if (nlen > 0 && name.charAt(nlen-1) == '/')
- return true;
- }
- return false;
- }
-
- public void setComment (String comment)
- {
- if (comment != null && comment.length() > 65535)
- throw new IllegalArgumentException ();
- this.comment = comment;
- }
-
- public void setCrc (long crc)
- {
- if (crc < 0 || crc > 0xffffffffL)
- throw new IllegalArgumentException ();
- this.crc = crc;
- }
-
- public void setExtra (byte[] extra)
- {
- if (extra != null && extra.length > 65535)
- throw new IllegalArgumentException ();
- this.extra = extra;
- }
-
- public void setMethod (int method)
- {
- if (method != DEFLATED && method != STORED)
- throw new IllegalArgumentException ();
- this.method = method;
- }
-
- public void setSize (long size)
- {
- if (size < 0 || size > 0xffffffffL)
- throw new IllegalArgumentException ();
- this.size = size;
- }
-
- public void setTime (long time)
- {
- this.time = time;
- }
-
- private final static short[] daysToMonthStart = {
- //Jan Feb Mar Apr May Jun Jul
- 0, 31, 31+28, 2*31+28, 2*31+28+30, 3*31+28+30, 3*31+28+2*30,
- // Aug Sep Oct Nov Dec
- 4*31+28+2*30, 5*31+28+2*30, 5*31+28+3*30, 6*31+28+3*30, 6*31+28+4*30};
-
- /** Convert a DOS-style type value to milliseconds since 1970. */
- static long timeFromDOS (int date, int time)
- {
- int sec = 2 * (time & 0x1f);
- int min = (time >> 5) & 0x3f;
- int hrs = (time >> 11) & 0x1f;
- int day = date & 0x1f;
- int mon = ((date >> 5) & 0xf) - 1;
- int year = ((date >> 9) & 0x7f) + 10; /* Since 1970. */
-
- // Guard against invalid or missing date causing IndexOutOfBoundsException.
- if (mon < 0 || mon > 11)
- return -1;
-
- long mtime = (((hrs * 60) + min) * 60 + sec) * 1000;
-
- // Leap year calculations are rather trivial in this case ...
- int days = 365 * year + ((year+1)>>2);
- days += daysToMonthStart[mon];
- if ((year & 3) == 0 && mon > 1)
- days++;
- days += day;
- return (days * 24*60*60L + ((hrs * 60) + min) * 60 + sec) * 1000L;
- }
-
- public String toString () { return name; }
-}
diff --git a/libjava/java/util/zip/ZipException.java b/libjava/java/util/zip/ZipException.java
deleted file mode 100644
index a4a119c7480..00000000000
--- a/libjava/java/util/zip/ZipException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// ZipException.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.util.zip;
-
-/**
- * @author Per Bothner
- * @date January 9, 1999.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Believed complete and correct.
- */
-
-public class ZipException extends java.io.IOException
-{
- public ZipException ()
- {
- super();
- }
-
- public ZipException (String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/zip/ZipFile.java b/libjava/java/util/zip/ZipFile.java
deleted file mode 100644
index f6e576a5222..00000000000
--- a/libjava/java/util/zip/ZipFile.java
+++ /dev/null
@@ -1,191 +0,0 @@
-// ZipFile.java - Read contents of a ZIP file.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-import java.io.*;
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class ZipFile implements ZipConstants
-{
- public ZipFile (String fname) throws IOException
- {
- file = new RandomAccessFile(fname, "r");
- name = fname;
- readDirectory ();
- }
-
- public ZipFile (File f) throws IOException
- {
- file = new RandomAccessFile(f, "r");
- name = f.getName();
- readDirectory ();
- }
-
- void readDirectory () throws IOException
- {
- long size = file.length ();
- if (size < ZipConstants.END_CENTRAL_DIR_SIZE)
- throw new ZipException ("zipfile too short");
- // We do not handle a "zipfile comment", which the appnote says can
- // be at the end of a .zip file. We could handle this by seeking
- // to the beginning and reading forwards.
- file.seek(size - ZipConstants.END_CENTRAL_DIR_SIZE);
- if (file.read() != 'P'
- || file.read() != 'K'
- || file.read() != '\005'
- || file.read() != '\006')
- throw new ZipException("not a valid zipfile");
- file.skipBytes(6);
- numEntries = readu2();
- int dir_size = read4 (); // Read "size of the central directory".
- file.seek(size - (dir_size + ZipConstants.END_CENTRAL_DIR_SIZE));
-
- ZipEntry last = null;
- for (int i = 0; i < numEntries; i++)
- {
- file.skipBytes(10);
- int method = readu2();
- int modtime = readu2();
- int moddate = readu2();
- int crc = read4();
- int compressedSize = read4();
- int uncompressedSize = read4();
- int filenameLength = readu2();
- int extraLength = readu2();
- int commentLength = readu2();
- int diskNumberStart = readu2();
- int intAttributes = readu2();
- int extAttributes = read4();
- int relativeOffset = read4();
- byte[] bname = new byte[filenameLength];
- file.readFully(bname);
- ZipEntry entry = new ZipEntry(new String(bname, "8859_1"));
- if (extraLength > 0)
- {
- byte[] bextra = new byte[extraLength];
- file.readFully(bextra);
- entry.extra = bextra;
- }
- if (commentLength > 0)
- {
- byte[] bcomment = new byte[commentLength];
- file.readFully(bcomment);
- entry.comment = new String(bcomment, "8859_1");
- }
- entry.compressedSize = compressedSize;
- entry.size = uncompressedSize;
- entry.crc = (long) crc & 0xffffffffL;
- entry.method = method;
- entry.relativeOffset = relativeOffset;
- entry.time = ZipEntry.timeFromDOS(moddate, modtime);
- if (last == null)
- entries = entry;
- else
- last.next = entry;
- last = entry;
- }
- }
-
- public java.util.Enumeration entries()
- {
- return new ZipEnumeration(this);
- }
-
- public void close() throws IOException
- {
- file.close();
- entries = null;
- numEntries = 0;
- }
-
- public ZipEntry getEntry(String name)
- {
- for (ZipEntry entry = entries; entry != null; entry = entry.next)
- {
- if (name.equals(entry.getName()))
- return entry;
- }
- return null;
- }
-
- public InputStream getInputStream(ZipEntry ze) throws IOException
- {
- byte[] buffer = new byte[(int) ze.getSize()];
-
- /* Read the size of the extra field, and skip to the start of the
- data. */
- file.seek (ze.relativeOffset + ZipConstants.LOCAL_FILE_HEADER_SIZE - 2);
- int extraFieldLength = readu2();
- file.skipBytes (ze.getName().length() + extraFieldLength);
-
- file.readFully(buffer);
-
- InputStream is = new ByteArrayInputStream (buffer);
- if (ze.getMethod() == ZipEntry.DEFLATED)
- is = new InflaterInputStream (is);
- return is;
- }
-
- public String getName () { return name; }
-
- private int readu2 () throws IOException
- {
- int byte0 = file.read();
- int byte1 = file.read();
- if (byte0 < 0 || byte1 < 0)
- throw new ZipException (".zip archive ended prematurely");
- return ((byte1 & 0xFF) << 8) | (byte0 & 0xFF);
- }
-
- private int read4 () throws IOException
- {
- int byte0 = file.read();
- int byte1 = file.read();
- int byte2 = file.read();
- int byte3 = file.read();
- if (byte3 < 0)
- throw new ZipException (".zip archive ended prematurely");
- return ((byte3 & 0xFF) << 24) + ((byte2 & 0xFF) << 16)
- + ((byte1 & 0xFF) << 8) + (byte0 & 0xFF);
- }
-
- ZipEntry entries;
- int numEntries;
- RandomAccessFile file;
- String name;
-}
-
-class ZipEnumeration implements java.util.Enumeration
-{
- ZipEntry entry;
-
- ZipEnumeration (ZipFile zfile)
- {
- entry = zfile.entries;
- }
-
- public boolean hasMoreElements ()
- {
- return entry != null;
- }
-
- public Object nextElement ()
- {
- ZipEntry cur = entry;
- if (cur == null)
- throw new java.util.NoSuchElementException();
- entry = cur.next;
- return cur;
- }
-}
diff --git a/libjava/java/util/zip/ZipInputStream.java b/libjava/java/util/zip/ZipInputStream.java
deleted file mode 100644
index df0ef03d588..00000000000
--- a/libjava/java/util/zip/ZipInputStream.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- 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 java.util.zip;
-import java.io.*;
-
-/**
- * @author Per Bothner
- * @date May 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Quite incomplete, but can read uncompressed .zip archives.
- */
-
-// JDK1.2 has "protected ZipEntry createZipEntry(String)" but is very
-// vague about what the method does. FIXME.
-// We do not calculate the CRC and compare it with the specified value;
-// we probably should. FIXME.
-
-
-public class ZipInputStream extends InflaterInputStream implements ZipConstants
-{
- public ZipInputStream (InputStream in)
- {
- super (in, new Inflater (true));
- }
-
- public ZipEntry getNextEntry () throws IOException
- {
- if (current != null)
- closeEntry();
- if (in.read() != 'P'
- || in.read() != 'K')
- return null;
- int code = in.read();
- while (code == '\001')
- {
- code = in.read();
- if (code != '\002')
- return null;
- in.skip(16);
- int size = read4();
- in.skip(4);
- int fname_length = readu2();
- int extra_length = readu2();
- int fcomment_length = readu2();
- in.skip(12+fname_length+extra_length+fcomment_length+size);
- if (in.read() != 'P' || in.read() != 'K')
- return null;
- code = in.read();
- }
- if (code == '\005')
- {
- if (in.read() != '\006')
- return null;
- in.skip(16);
- int comment_size = readu2();
- in.skip(comment_size);
- if (in.read() != 'P' || in.read() != 'K')
- return null;
- code = in.read();
- }
- if (code != '\003'
- || in.read() != '\004')
- return null;
- int ex_version = readu2();
- current_flags = readu2();
- int method = readu2();
- int modtime = readu2();
- int moddate = readu2();
- int crc = read4();
- int compressedSize = read4();
- int uncompressedSize = read4();
- int filenameLength = readu2();
- int extraLength = readu2();
- byte[] bname = new byte[filenameLength];
- readFully(bname);
- ZipEntry entry = new ZipEntry(new String(bname, "8859_1"));
- if (extraLength > 0)
- {
- byte[] bextra = new byte[extraLength];
- readFully(bextra);
- entry.extra = bextra;
- }
- entry.compressedSize = compressedSize;
- entry.size = uncompressedSize;
- entry.crc = (long) crc & 0xffffffffL;
- entry.method = method;
- entry.time = ZipEntry.timeFromDOS(moddate, modtime);
- current = entry;
- avail = uncompressedSize;
- compressed_bytes = compressedSize;
- return entry;
- }
-
- // We override fill to let us control how much data gets read from
- // the underlying input stream. This lets us avoid having to push
- // back data.
- protected void fill () throws IOException
- {
- int count = buf.length;
- if (count > compressed_bytes)
- count = compressed_bytes;
- len = in.read(buf, 0, count);
- if (len != -1)
- {
- compressed_bytes -= len;
- inf.setInput(buf, 0, len);
- }
- }
-
- public int read (byte[] b, int off, int len) throws IOException
- {
- if (len > avail)
- len = avail;
- int count;
- if (current.method == Deflater.DEFLATED)
- count = super.read(b, off, len);
- else
- count = in.read(b, off, len);
- if (count == -1 || avail == 0)
- {
- inf.reset();
- count = -1;
- }
- else
- avail -= count;
- return count;
- }
-
- public long skip (long n) throws IOException
- {
- if (n > avail)
- n = avail;
- long count;
- if (current.method == Deflater.DEFLATED)
- count = super.skip(n);
- else
- count = in.skip(n);
- avail = avail - (int) count;
- return count;
- }
-
- private void readFully (byte[] b) throws IOException
- {
- int off = 0;
- int len = b.length;
- while (len > 0)
- {
- int count = in.read(b, off, len);
- if (count <= 0)
- throw new EOFException(".zip archive ended prematurely");
- off += count;
- len -= count;
- }
- }
-
- private int readu2 () throws IOException
- {
- int byte0 = in.read();
- int byte1 = in.read();
- if (byte0 < 0 || byte1 < 0)
- throw new EOFException(".zip archive ended prematurely");
- return ((byte1 & 0xFF) << 8) | (byte0 & 0xFF);
- }
-
- private int read4 () throws IOException
- {
- int byte0 = in.read();
- int byte1 = in.read();
- int byte2 = in.read();
- int byte3 = in.read();
- if (byte3 < 0)
- throw new EOFException(".zip archive ended prematurely");
- return ((byte3 & 0xFF) << 24) + ((byte2 & 0xFF) << 16)
- + ((byte1 & 0xFF) << 8) + (byte0 & 0xFF);
- }
-
- public void closeEntry () throws IOException
- {
- if (current != null)
- {
- if (avail > 0)
- skip (avail);
- if ((current_flags & 8) != 0)
- {
- int sig = read4();
- if (sig != 0x04034b50)
- throw new ZipException("bad/missing magic number at end of .zip entry");
- int crc = read4();
- int compressedSize = read4();
- int uncompressedSize = read4();
- if (current.compressedSize != compressedSize
- || current.size != uncompressedSize
- || current.crc != crc)
- throw new ZipException("bad data descriptor at end of .zip entry");
- }
- current = null;
- avail = 0;
- }
- }
-
- public void close () throws IOException
- {
- current = null;
- super.close();
- }
-
- private ZipEntry current;
- private int current_flags;
- // Number of uncompressed bytes to be read.
- private int avail;
- // Number of bytes we can read from underlying stream.
- private int compressed_bytes;
-}
diff --git a/libjava/java/util/zip/ZipOutputStream.java b/libjava/java/util/zip/ZipOutputStream.java
deleted file mode 100644
index afd5664ca28..00000000000
--- a/libjava/java/util/zip/ZipOutputStream.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- 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 java.util.zip;
-import java.io.*;
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class ZipOutputStream extends DeflaterOutputStream
- implements ZipConstants
-{
- public static final int STORED = 0;
- public static final int DEFLATED = 8;
-
- public void close () throws IOException
- {
- finish ();
- out.close();
- }
-
- public void closeEntry () throws IOException
- {
- int uncompressed_size = def.getTotalIn();
- int compressed_size = def.getTotalOut();
- long crc = filter.getChecksum().getValue();
-
- bytes_written += compressed_size;
-
- bytes_written += put4 (0x08074b50);
- if (current.getCrc() == -1 || current.getCompressedSize() == -1
- || current.getSize() == -1)
- {
- current.setCrc(crc);
- current.compressedSize = compressed_size;
- current.setSize(uncompressed_size);
- }
- else
- {
- if (current.getCrc() != crc
- || current.getCompressedSize() != compressed_size
- || current.getSize() != uncompressed_size)
- throw new ZipException ("zip entry field incorrect");
- }
- bytes_written += put4 ((int) (current.getCrc()));
- bytes_written += put4 ((int) (current.getCompressedSize()));
- bytes_written += put4 ((int) (current.getSize()));
-
- current.next = chain;
- chain = current;
- current = null;
- filter = null;
- }
-
- public void finish () throws IOException
- {
- if (current != null)
- closeEntry ();
-
- // Write the central directory.
- long offset = bytes_written;
- int count = 0;
- int bytes = 0;
- while (chain != null)
- {
- bytes += write_entry (chain, false);
- ++count;
- chain = chain.next;
- }
-
- // Write the end of the central directory record.
- put4 (0x06054b50);
- // Disk number.
- put2 (0);
- // Another disk number.
- put2 (0);
- put2 (count);
- put4 (bytes);
- put4 ((int) offset);
-
- byte[] c = comment.getBytes("8859_1");
- put2 (c.length);
- out.write(c);
- out.write((byte) 0);
- }
-
- // Helper for finish and putNextEntry.
- private int write_entry (ZipEntry entry, boolean is_local)
- throws IOException
- {
- long offset = bytes_written;
-
- int bytes = put4 (is_local ? 0x04034b50 : 0x02014b50);
- if (! is_local)
- bytes += put_version ();
- bytes += put_version ();
-
- boolean crc_after = false;
- if (is_local
- && (entry.getCrc() == -1 || entry.getCompressedSize() == -1
- || entry.getSize() == -1))
- crc_after = true;
- // For the bits field we always indicate `normal' compression,
- // even if that isn't true.
- bytes += put2 (crc_after ? (1 << 3) : 0);
- bytes += put2 (entry.method);
-
- bytes += put2(0); // time - FIXME
- bytes += put2(0); // date - FIXME
-
- if (crc_after)
- {
- // CRC, compressedSize, and Size are always 0 in this header.
- // The actual values are given after the entry.
- bytes += put4 (0);
- bytes += put4 (0);
- bytes += put4 (0);
- }
- else
- {
- bytes += put4 ((int) (entry.getCrc()));
- bytes += put4 ((int) (entry.getCompressedSize()));
- bytes += put4 ((int) (entry.getSize()));
- }
-
- byte[] name = entry.name.getBytes("8859_1");
- bytes += put2 (name.length);
- bytes += put2 (entry.extra == null ? 0 : entry.extra.length);
-
- byte[] comment = null;
- if (! is_local)
- {
- if (entry.getComment() == null)
- bytes += put2 (0);
- else
- {
- comment = entry.getComment().getBytes("8859_1");
- bytes += put2 (comment.length);
- }
-
- // Disk number start.
- bytes += put2 (0);
- // Internal file attributes.
- bytes += put2 (0);
- // External file attributes.
- bytes += put2 (0);
- // Relative offset of local header.
- bytes += put2 ((int) offset);
- }
-
- out.write (name);
- out.write ((byte) 0);
- bytes += name.length + 1;
- if (entry.extra != null)
- {
- out.write(entry.extra);
- out.write((byte) 0);
- bytes += entry.extra.length + 1;
- }
- if (comment != null)
- {
- out.write(comment);
- out.write((byte) 0);
- bytes += comment.length + 1;
- }
-
- bytes_written += bytes;
- return bytes;
- }
-
- public void putNextEntry (ZipEntry entry) throws IOException
- {
- if (current != null)
- closeEntry ();
-
- if (entry.method < 0 )
- entry.method = method;
- if (entry.method == STORED)
- {
- if (entry.getSize() == -1 || entry.getCrc() == -1)
- throw new ZipException ("required entry not set");
- // Just in case.
- entry.compressedSize = entry.getSize();
- }
- write_entry (entry, true);
- current = entry;
- int compr = (method == STORED) ? Deflater.NO_COMPRESSION : level;
- def.reset();
- def.setLevel(compr);
- filter = new CheckedOutputStream (new DeflaterOutputStream (out, def),
- new CRC32 ());
- }
-
- public void setLevel (int level)
- {
- if (level != Deflater.DEFAULT_COMPRESSION
- && (level < Deflater.NO_COMPRESSION
- || level > Deflater.BEST_COMPRESSION))
- throw new IllegalArgumentException ();
- this.level = level;
- }
-
- public void setMethod (int method)
- {
- if (method != DEFLATED && method != STORED)
- throw new IllegalArgumentException ();
- this.method = method;
- }
-
- public void setComment (String comment)
- {
- if (comment.length() > 65535)
- throw new IllegalArgumentException ();
- this.comment = comment;
- }
-
- public synchronized void write (byte[] buf, int off, int len)
- throws IOException
- {
- if (filter == null)
- throw new ZipException ("no open zip entry");
- filter.write(buf, off, len);
- }
-
- public ZipOutputStream (OutputStream out)
- {
- super (out);
- def = new Deflater (level, true);
- }
-
- private int put2 (int i) throws IOException
- {
- out.write (i);
- out.write (i >> 8);
- return 2;
- }
-
- private int put4 (int i) throws IOException
- {
- out.write (i);
- out.write (i >> 8);
- out.write (i >> 16);
- out.write (i >> 24);
- return 4;
- }
-
- private int put_version () throws IOException
- {
- // FIXME: for now we assume Unix, and we ignore the version
- // number.
- return put2 (3 << 8);
- }
-
- // The entry we are currently writing, or null if we've called
- // closeEntry.
- private ZipEntry current;
- // The chain of entries which have been written to this file.
- private ZipEntry chain;
- // The output stream to which data should be sent.
- private CheckedOutputStream filter;
-
- private int method = DEFLATED;
- private int level = Deflater.DEFAULT_COMPRESSION;
- private String comment = "";
- private long bytes_written;
-
- // The Deflater we use.
- private Deflater def;
-}
diff --git a/libjava/java/util/zip/natDeflater.cc b/libjava/java/util/zip/natDeflater.cc
deleted file mode 100644
index 8ef6cf66d6e..00000000000
--- a/libjava/java/util/zip/natDeflater.cc
+++ /dev/null
@@ -1,214 +0,0 @@
-// natDeflater.cc - Implementation of Deflater native methods.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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. */
-
-// Written by Tom Tromey <tromey@cygnus.com>
-
-#include <config.h>
-
-#include <zlib.h>
-#include <stdlib.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java/util/zip/Deflater.h>
-#include <java/util/zip/DataFormatException.h>
-
-#include <java/lang/InternalError.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-
-extern void *_Jv_ZMalloc (void *, uInt nitems, uInt size);
-extern void _Jv_ZFree (void *, void *addr);
-
-
-
-jint
-java::util::zip::Deflater::deflate (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- if (len == 0)
- return 0;
-
- s->next_out = (Bytef *) (elements (buf) + off);
- s->avail_out = len;
-
- switch (::deflate (s, flush_flag))
- {
- case Z_STREAM_END:
- is_finished = true;
- if (s->avail_out == (unsigned int) len)
- return -1;
- break;
-
- case Z_STREAM_ERROR:
- case Z_BUF_ERROR:
- // FIXME?
- _Jv_Throw (new java::lang::InternalError);
- break;
-
- case Z_OK:
- break;
- }
-
- return len - s->avail_out;
-}
-
-void
-java::util::zip::Deflater::end ()
-{
- JvSynchronize sync (this);
- // Just ignore errors.
- deflateEnd ((z_streamp) zstream);
- _Jv_Free (zstream);
- zstream = NULL;
-}
-
-void
-java::util::zip::Deflater::finish ()
-{
- JvSynchronize sync (this);
- flush_flag = Z_FINISH;
-}
-
-jint
-java::util::zip::Deflater::getAdler ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->adler;
-}
-
-jint
-java::util::zip::Deflater::getTotalIn ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->total_in;
-}
-
-jint
-java::util::zip::Deflater::getTotalOut ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->total_out;
-}
-
-jboolean
-java::util::zip::Deflater::needsInput ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->avail_in == 0;
-}
-
-void
-java::util::zip::Deflater::reset ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- // Just ignore errors.
- deflateReset (s);
- flush_flag = 0;
-}
-
-void
-java::util::zip::Deflater::setDictionary (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- // Ignore errors.
- deflateSetDictionary (s, (Bytef *) (elements (buf) + off), len);
-}
-
-void
-java::util::zip::Deflater::setInput (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- s->next_in = (Bytef *) (elements (buf) + off);
- s->avail_in = len;
-}
-
-void
-java::util::zip::Deflater::update ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- int strat = Z_DEFAULT_STRATEGY;
- switch (strategy)
- {
- case DEFAULT_STRATEGY:
- strat = Z_DEFAULT_STRATEGY;
- break;
- case FILTERED:
- strat = Z_FILTERED;
- break;
- case HUFFMAN_ONLY:
- strat = Z_HUFFMAN_ONLY;
- break;
- default:
- JvFail ("unexpected strategy");
- }
-
- // Ignore errors.
- deflateParams (s, level, strat);
-}
-
-void
-java::util::zip::Deflater::init (jint level, jboolean no_header)
-{
- z_stream_s *stream = (z_stream_s *) _Jv_Malloc (sizeof (z_stream_s));
- stream->next_in = Z_NULL;
- stream->avail_in = 0;
- stream->zalloc = _Jv_ZMalloc;
- stream->zfree = _Jv_ZFree;
- stream->opaque = NULL;
-
- // Handle NO_HEADER using undocumented zlib feature.
- int wbits = MAX_WBITS;
- if (no_header)
- wbits = - wbits;
-
-#define DEFAULT_MEM_LEVEL 8
- if (deflateInit2 (stream, level, Z_DEFLATED, wbits,
- DEFAULT_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK)
- {
- jstring msg = NULL;
- if (stream->msg != NULL)
- msg = JvNewStringLatin1 (stream->msg);
- _Jv_Throw (new java::lang::InternalError (msg));
- }
-
- zstream = reinterpret_cast<gnu::gcj::RawData *> (stream);
- is_finished = false;
- flush_flag = 0;
-}
diff --git a/libjava/java/util/zip/natInflater.cc b/libjava/java/util/zip/natInflater.cc
deleted file mode 100644
index 312027a2d8c..00000000000
--- a/libjava/java/util/zip/natInflater.cc
+++ /dev/null
@@ -1,205 +0,0 @@
-// natInflater.cc - Implementation of Inflater native methods.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- 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. */
-
-// Written by Tom Tromey <tromey@cygnus.com>
-
-#include <config.h>
-
-#include <zlib.h>
-#include <stdlib.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java/util/zip/Inflater.h>
-#include <java/util/zip/DataFormatException.h>
-
-#include <java/lang/InternalError.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/OutOfMemoryError.h>
-
-
-
-// A couple of helper functions used to interface with zlib's
-// allocation.
-
-void *
-_Jv_ZMalloc (void *, uInt nitems, uInt size)
-{
- return _Jv_Malloc (nitems * size);
-}
-
-void
-_Jv_ZFree (void *, void *addr)
-{
- _Jv_Free (addr);
-}
-
-
-
-void
-java::util::zip::Inflater::end ()
-{
- JvSynchronize sync (this);
- // Just ignore errors.
- inflateEnd ((z_streamp) zstream);
- _Jv_Free (zstream);
- zstream = NULL;
-}
-
-jint
-java::util::zip::Inflater::getAdler ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->adler;
-}
-
-jint
-java::util::zip::Inflater::getRemaining ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->avail_in;
-}
-
-jint
-java::util::zip::Inflater::getTotalIn ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->total_in;
-}
-
-jint
-java::util::zip::Inflater::getTotalOut ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->total_out;
-}
-
-jint
-java::util::zip::Inflater::inflate (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- if (len == 0)
- return 0;
-
- s->next_out = (Bytef *) (elements (buf) + off);
- s->avail_out = len;
-
- switch (::inflate (s, Z_SYNC_FLUSH))
- {
- case Z_STREAM_END:
- is_finished = true;
- if (s->avail_out == (unsigned int) len)
- return -1;
- break;
-
- case Z_NEED_DICT:
- dict_needed = true;
- break;
-
- case Z_DATA_ERROR:
- _Jv_Throw (new java::util::zip::DataFormatException);
- break;
-
- case Z_MEM_ERROR:
- _Jv_Throw (new java::lang::OutOfMemoryError);
- break;
-
- case Z_BUF_ERROR:
- // FIXME?
- _Jv_Throw (new java::lang::InternalError);
- break;
-
- case Z_OK:
- break;
- }
-
- return len - s->avail_out;
-}
-
-void
-java::util::zip::Inflater::reset ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- // Just ignore errors.
- inflateReset (s);
-}
-
-void
-java::util::zip::Inflater::setDictionary (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- // Ignore errors.
- inflateSetDictionary (s, (Bytef *) (elements (buf) + off), len);
- dict_needed = false;
-}
-
-void
-java::util::zip::Inflater::setInput (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- s->next_in = (Bytef *) (elements (buf) + off);
- s->avail_in = len;
-}
-
-void
-java::util::zip::Inflater::init (jboolean no_header)
-{
- z_stream_s *stream = (z_stream_s *) _Jv_Malloc (sizeof (z_stream_s));
- stream->next_in = Z_NULL;
- stream->avail_in = 0;
- stream->zalloc = _Jv_ZMalloc;
- stream->zfree = _Jv_ZFree;
- stream->opaque = NULL;
-
- // Handle NO_HEADER using undocumented zlib feature.
- int wbits = MAX_WBITS;
- if (no_header)
- wbits = - wbits;
-
- if (inflateInit2 (stream, wbits) != Z_OK)
- {
- jstring msg = NULL;
- if (stream->msg != NULL)
- msg = JvNewStringLatin1 (stream->msg);
- _Jv_Throw (new java::lang::InternalError (msg));
- }
-
- zstream = reinterpret_cast<gnu::gcj::RawData *> (stream);
- is_finished = false;
- dict_needed = false;
-}