Imported Upstream version 4.2.1.36
Former-commit-id: f3008ca867fe7e4b7ae9b9a8844c0ad5798925a9
This commit is contained in:
parent
afe402035c
commit
ea5caba957
@ -84,8 +84,8 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(top_srcdir)/configure $(am__configure_deps) \
|
||||
$(srcdir)/config.h.in mkinstalldirs \
|
||||
$(srcdir)/mono-uninstalled.pc.in COPYING.LIB ChangeLog NEWS \
|
||||
compile config.guess config.rpath config.sub depcomp \
|
||||
install-sh missing ltmain.sh
|
||||
compile config.guess config.rpath config.sub install-sh \
|
||||
missing ltmain.sh
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
|
@ -1 +1 @@
|
||||
2c2c33e9b3b238b9af81df41107a0b6b0127ed10
|
||||
1895650fb1b5a365ada5bcdf3fef86a448da51d2
|
@ -1 +1 @@
|
||||
fa754128cfe42ebd98f8fc68209473d8cc272fc0
|
||||
2317c4f2abf300ae9f452f4dbfd8b9d63c944e1c
|
8
external/ikvm/HOWTO
vendored
8
external/ikvm/HOWTO
vendored
@ -1,11 +1,11 @@
|
||||
IKVM.NET Build Instructions
|
||||
---------------------------
|
||||
|
||||
This IKVM.NET source bundle requires OpenJDK 7u6 b24 sources (and build artifacts).
|
||||
This IKVM.NET source bundle requires OpenJDK 8u45 b14 sources (and build artifacts).
|
||||
|
||||
They can be downloaded from the SourceForge IKVM project, or from:
|
||||
|
||||
http://www.frijters.net/openjdk-7u6-b24-stripped.zip
|
||||
http://www.frijters.net/openjdk-8u45-b14-stripped.zip
|
||||
|
||||
This file should be unzipped in the same directory as where the ikvm directory
|
||||
(that contains this unzipped source bundle) lives.
|
||||
@ -13,8 +13,8 @@ This file should be unzipped in the same directory as where the ikvm directory
|
||||
Download ICSharpCode.SharpZipLib.dll (from http://www.icsharpcode.net/opensource/sharpziplib/
|
||||
or from the ikvmbin-x.y.z.r.zip in the SourceForge IKVM project) and copy it to ikvm/bin.
|
||||
|
||||
Add the bin directory of NAnt 0.85 and JDK 7 to the PATH. It is recommend to use the 64 bit
|
||||
version of Java 7.
|
||||
Add the bin directory of NAnt 0.85 and JDK 8 to the PATH. Java 8 is required to build
|
||||
the Java class library. It is recommend to use the 64 bit version.
|
||||
|
||||
From the ikvm directory run "nant".
|
||||
|
||||
|
6
external/ikvm/awt/native.cs
vendored
6
external/ikvm/awt/native.cs
vendored
@ -566,7 +566,7 @@ namespace IKVM.NativeCode.sun.awt.shell
|
||||
{
|
||||
return;
|
||||
}
|
||||
Marshal.Release(pIDL);
|
||||
Marshal.FreeCoTaskMem(pIDL);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -608,8 +608,8 @@ namespace IKVM.NativeCode.sun.awt.shell
|
||||
return (int)atts[0];
|
||||
}
|
||||
|
||||
[System.Security.SecurityCritical]
|
||||
public static String getFileSystemPath(int csidl)
|
||||
[System.Security.SecuritySafeCritical]
|
||||
public static String getFileSystemPath0(int csidl)
|
||||
{
|
||||
IntPtr pIDL = new IntPtr();
|
||||
int hRes = ShellApi.SHGetSpecialFolderLocation(IntPtr.Zero, (ShellApi.CSIDL)csidl, ref pIDL);
|
||||
|
@ -1 +1 @@
|
||||
a8a055aaac9ad8e98b1c9c47fcd85f5d82ba8ef1
|
||||
3326c8c8b604536ceedce48c5646eef4d04d2a8f
|
12
external/ikvm/ikvmc/AotTypeWrapper.cs
vendored
12
external/ikvm/ikvmc/AotTypeWrapper.cs
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2002-2014 Jeroen Frijters
|
||||
Copyright (C) 2002-2015 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -507,7 +507,7 @@ namespace IKVM.Internal
|
||||
}
|
||||
}
|
||||
|
||||
private static void MapModifiers(MapXml.MapModifiers mapmods, bool isConstructor, out bool setmodifiers, ref MethodAttributes attribs)
|
||||
private static void MapModifiers(MapXml.MapModifiers mapmods, bool isConstructor, out bool setmodifiers, ref MethodAttributes attribs, bool isNewSlot)
|
||||
{
|
||||
setmodifiers = false;
|
||||
Modifiers modifiers = (Modifiers)mapmods;
|
||||
@ -543,6 +543,10 @@ namespace IKVM.Internal
|
||||
// remove NewSlot, because it doesn't make sense on a non-virtual method
|
||||
attribs &= ~MethodAttributes.NewSlot;
|
||||
}
|
||||
else if(((modifiers & (Modifiers.Public | Modifiers.Final)) == Modifiers.Final && isNewSlot && (attribs & MethodAttributes.Virtual) == 0))
|
||||
{
|
||||
// final method that doesn't need to be virtual
|
||||
}
|
||||
else
|
||||
{
|
||||
if((modifiers & Modifiers.Private) == 0)
|
||||
@ -630,7 +634,7 @@ namespace IKVM.Internal
|
||||
}
|
||||
bool setmodifiers = false;
|
||||
MethodAttributes attribs = 0;
|
||||
MapModifiers(constructor.Modifiers, true, out setmodifiers, ref attribs);
|
||||
MapModifiers(constructor.Modifiers, true, out setmodifiers, ref attribs, false);
|
||||
Type returnType;
|
||||
Type[] parameterTypes;
|
||||
MapSignature(constructor.Sig, out returnType, out parameterTypes);
|
||||
@ -683,7 +687,7 @@ namespace IKVM.Internal
|
||||
{
|
||||
bool setmodifiers = false;
|
||||
MethodAttributes attribs = method.MethodAttributes;
|
||||
MapModifiers(method.Modifiers, false, out setmodifiers, ref attribs);
|
||||
MapModifiers(method.Modifiers, false, out setmodifiers, ref attribs, BaseTypeWrapper == null || BaseTypeWrapper.GetMethodWrapper(method.Name, method.Sig, true) == null);
|
||||
if(method.body == null && (attribs & MethodAttributes.Abstract) == 0)
|
||||
{
|
||||
Console.Error.WriteLine("Error: Method {0}.{1}{2} in xml remap file doesn't have a body.", clazz.Name, method.Name, method.Sig);
|
||||
|
2
external/ikvm/ikvmc/Compiler.cs
vendored
2
external/ikvm/ikvmc/Compiler.cs
vendored
@ -838,7 +838,7 @@ sealed class IkvmcCompiler
|
||||
}
|
||||
else if(s == "-opt:fields")
|
||||
{
|
||||
options.removeUnusedFields = true;
|
||||
options.codegenoptions |= CodeGenOptions.RemoveUnusedFields;
|
||||
}
|
||||
else if(s == "-compressresources")
|
||||
{
|
||||
|
@ -1 +1 @@
|
||||
c27a31eb1803a411aadc8b97ad081614b07dd615
|
||||
1d6e66a3d816d572409fee7c6c4b27cc07cfb43d
|
20
external/ikvm/ikvmstub/ikvmstub.cs
vendored
20
external/ikvm/ikvmstub/ikvmstub.cs
vendored
@ -577,6 +577,7 @@ sealed class BootstrapBootstrapClassLoader : ClassLoaderWrapper
|
||||
RegisterInitiatingLoader(new StubTypeWrapper(Modifiers.Public, "java.lang.Enum", javaLangObject, false));
|
||||
RegisterInitiatingLoader(new StubTypeWrapper(Modifiers.Public | Modifiers.Abstract | Modifiers.Interface, "java.lang.annotation.Annotation", null, false));
|
||||
RegisterInitiatingLoader(new StubTypeWrapper(Modifiers.Public | Modifiers.Final, "java.lang.Class", javaLangObject, false));
|
||||
RegisterInitiatingLoader(new StubTypeWrapper(Modifiers.Public | Modifiers.Abstract, "java.lang.invoke.MethodHandle", javaLangObject, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -607,25 +608,6 @@ sealed class StubTypeWrapper : TypeWrapper
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
internal override TypeWrapper[] Interfaces
|
||||
{
|
||||
get { return TypeWrapper.EmptyArray; }
|
||||
}
|
||||
|
||||
internal override TypeWrapper[] InnerClasses
|
||||
{
|
||||
get { return TypeWrapper.EmptyArray; }
|
||||
}
|
||||
|
||||
internal override TypeWrapper DeclaringTypeWrapper
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
internal override void Finish()
|
||||
{
|
||||
}
|
||||
|
||||
internal override bool IsRemapped
|
||||
{
|
||||
get { return remapped; }
|
||||
|
16
external/ikvm/openjdk/FORKED
vendored
16
external/ikvm/openjdk/FORKED
vendored
@ -4,9 +4,9 @@
|
||||
# This file list all forked OpenJDK files in their original OpenJDK location and their forked ikvm/openjdk location.
|
||||
# Each line not starting with # contains a mapping: <original>=<forked>
|
||||
#
|
||||
build/linux-amd64/gensrc/sun/misc/Version.java=sun/misc/Version.java
|
||||
build/linux-amd64/gensrc/sun/nio/ch/SocketOptionRegistry.java=sun/nio/ch/SocketOptionRegistry.java
|
||||
build/linux-amd64/gensrc/sun/nio/cs/StandardCharsets.java=sun/nio/cs/StandardCharsets.java
|
||||
build/linux-x86_64-normal-server-release/jdk/gensrc/sun/misc/Version.java=sun/misc/Version.java
|
||||
build/linux-x86_64-normal-server-release/jdk/gensrc/sun/nio/ch/SocketOptionRegistry.java=sun/nio/ch/SocketOptionRegistry.java
|
||||
build/linux-x86_64-normal-server-release/jdk/gensrc/sun/nio/cs/StandardCharsets.java=sun/nio/cs/StandardCharsets.java
|
||||
jdk/src/macosx/classes/java/lang/ClassLoaderHelper.java=java/lang/ClassLoaderHelper.java
|
||||
jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java=com/sun/imageio/plugins/jpeg/JPEGImageReader.java
|
||||
jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java=com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
|
||||
@ -22,17 +22,16 @@ jdk/src/share/classes/java/awt/image/DataBufferInt.java=java/awt/image/DataBuffe
|
||||
jdk/src/share/classes/java/awt/image/DataBufferShort.java=java/awt/image/DataBufferShort.java
|
||||
jdk/src/share/classes/java/awt/image/DataBufferUShort.java=java/awt/image/DataBufferUShort.java
|
||||
jdk/src/share/classes/java/awt/image/IndexColorModel.java=java/awt/image/IndexColorModel.java
|
||||
jdk/src/share/classes/java/io/FileInputStream.java=java/io/FileInputStream.java
|
||||
jdk/src/share/classes/java/io/FileOutputStream.java=java/io/FileOutputStream.java
|
||||
jdk/src/share/classes/java/io/ObjectStreamClass.java=java/io/ObjectStreamClass.java
|
||||
jdk/src/share/classes/java/io/ObjectStreamField.java=java/io/ObjectStreamField.java
|
||||
jdk/src/share/classes/java/io/RandomAccessFile.java=java/io/RandomAccessFile.java
|
||||
jdk/src/share/classes/java/lang/Class.java=java/lang/Class.java
|
||||
jdk/src/share/classes/java/lang/ClassLoader.java=java/lang/ClassLoader.java
|
||||
jdk/src/share/classes/java/lang/Enum.java=java/lang/Enum.java
|
||||
jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java=../runtime/openjdk/NativeInvokerBytecodeGenerator.cs
|
||||
jdk/src/share/classes/java/lang/management/PlatformComponent.java=java/lang/management/PlatformComponent.java
|
||||
jdk/src/share/classes/java/lang/ref/SoftReference.java=java/lang/ref/SoftReference.java
|
||||
jdk/src/share/classes/java/lang/reflect/Constructor.java=java/lang/reflect/Constructor.java
|
||||
jdk/src/share/classes/java/lang/reflect/Executable.java=java/lang/reflect/Executable.java
|
||||
jdk/src/share/classes/java/lang/reflect/Field.java=java/lang/reflect/Field.java
|
||||
jdk/src/share/classes/java/lang/reflect/Method.java=java/lang/reflect/Method.java
|
||||
jdk/src/share/classes/java/lang/reflect/Proxy.java=java/lang/reflect/Proxy.java
|
||||
@ -41,8 +40,6 @@ jdk/src/share/classes/java/lang/String.java=java/lang/StringHelper.java
|
||||
jdk/src/share/classes/java/lang/System.java=java/lang/System.java
|
||||
jdk/src/share/classes/java/lang/Thread.java=java/lang/Thread.java
|
||||
jdk/src/share/classes/java/lang/Throwable.java=java/lang/ThrowableHelper.java
|
||||
jdk/src/share/classes/java/net/SocketInputStream.java=java/net/SocketInputStream.java
|
||||
jdk/src/share/classes/java/net/SocketOutputStream.java=java/net/SocketOutputStream.java
|
||||
jdk/src/share/classes/java/nio/Bits.java=java/nio/Bits.java
|
||||
jdk/src/share/classes/java/security/AccessController.java=java/security/AccessController.java
|
||||
jdk/src/share/classes/java/security/ProtectionDomain.java=java/security/ProtectionDomain.java
|
||||
@ -53,7 +50,6 @@ jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java=../classpath/j
|
||||
jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java=../classpath/java/util/concurrent/atomic/AtomicLongArray.java
|
||||
jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java=../classpath/java/util/concurrent/atomic/AtomicReference.java
|
||||
jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java=../classpath/java/util/concurrent/atomic/AtomicReferenceArray.java
|
||||
jdk/src/share/classes/java/util/concurrent/ForkJoinPool.java=java/util/concurrent/ForkJoinPool.java
|
||||
jdk/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java=java/util/concurrent/locks/AbstractQueuedSynchronizer.java
|
||||
jdk/src/share/classes/java/util/concurrent/locks/LockSupport.java=java/util/concurrent/locks/LockSupport.java
|
||||
jdk/src/share/classes/sun/awt/EmbeddedFrame.java=sun/awt/EmbeddedFrame.java
|
||||
@ -62,7 +58,6 @@ jdk/src/share/classes/sun/awt/image/ImagingLib.java=sun/awt/image/ImagingLib.jav
|
||||
jdk/src/share/classes/sun/awt/image/IntegerInterleavedRaster.java=sun/awt/image/IntegerInterleavedRaster.java
|
||||
jdk/src/share/classes/sun/awt/image/SunWritableRaster.java=sun/awt/image/SunWritableRaster.java
|
||||
jdk/src/share/classes/sun/awt/image/ToolkitImage.java=sun/awt/image/ToolkitImage.java
|
||||
jdk/src/share/classes/sun/awt/SunToolkit.java=sun/awt/SunToolkit.java
|
||||
jdk/src/share/classes/sun/font/FontManager.java=sun/font/FontManager.java
|
||||
jdk/src/share/classes/sun/font/StrikeCache.java=sun/font/StrikeCache.java
|
||||
jdk/src/share/classes/sun/management/ManagementFactoryHelper.java=sun/management/ManagementFactoryHelper.java
|
||||
@ -99,7 +94,6 @@ jdk/src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java=sun/net/www
|
||||
jdk/src/windows/classes/sun/nio/ch/DefaultSelectorProvider.java=sun/nio/ch/DefaultSelectorProvider.java
|
||||
jdk/src/windows/classes/sun/nio/ch/FileDispatcherImpl.java=sun/nio/ch/FileDispatcherImpl.java
|
||||
jdk/src/windows/classes/sun/nio/ch/Iocp.java=sun/nio/ch/Iocp.java
|
||||
jdk/src/windows/classes/sun/nio/ch/PollArrayWrapper.java=sun/nio/ch/PollArrayWrapper.java
|
||||
jdk/src/windows/classes/sun/nio/ch/SocketDispatcher.java=sun/nio/ch/SocketDispatcher.java
|
||||
jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java=sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
|
||||
jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java=sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java
|
||||
|
@ -1 +1 @@
|
||||
9893116e072094e4cdaec2c5e493ef7f7799c5e6
|
||||
935b3a93896a85d98a39a3ab7e9795dc58c56bdf
|
@ -138,6 +138,7 @@ public final class Winsock
|
||||
public static final int IPV6_ADD_MEMBERSHIP = SocketOptionName.AddMembership;
|
||||
public static final int IPV6_DROP_MEMBERSHIP = SocketOptionName.DropMembership;
|
||||
public static final int IPV6_V6ONLY = 27;
|
||||
public static final int IPV6_TCLASS = 39;
|
||||
|
||||
public static final int SIO_UDP_CONNRESET = 0x9800000C;
|
||||
|
||||
@ -147,6 +148,8 @@ public final class Winsock
|
||||
public static final int FIONREAD = (int)IOControlCode.DataToRead;
|
||||
public static final int FIONBIO = (int)IOControlCode.NonBlockingIO;
|
||||
|
||||
public static final int MAX_PACKET_LEN = 0xFFFF;
|
||||
|
||||
public static int WSAGetLastError()
|
||||
{
|
||||
return lastError;
|
||||
|
451
external/ikvm/openjdk/java/io/FileInputStream.java
vendored
451
external/ikvm/openjdk/java/io/FileInputStream.java
vendored
@ -1,451 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.io;
|
||||
|
||||
import java.nio.channels.FileChannel;
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
import sun.misc.IoTrace;
|
||||
|
||||
|
||||
/**
|
||||
* A <code>FileInputStream</code> obtains input bytes
|
||||
* from a file in a file system. What files
|
||||
* are available depends on the host environment.
|
||||
*
|
||||
* <p><code>FileInputStream</code> is meant for reading streams of raw bytes
|
||||
* such as image data. For reading streams of characters, consider using
|
||||
* <code>FileReader</code>.
|
||||
*
|
||||
* @author Arthur van Hoff
|
||||
* @see java.io.File
|
||||
* @see java.io.FileDescriptor
|
||||
* @see java.io.FileOutputStream
|
||||
* @see java.nio.file.Files#newInputStream
|
||||
* @since JDK1.0
|
||||
*/
|
||||
public
|
||||
class FileInputStream extends InputStream
|
||||
{
|
||||
/* File Descriptor - handle to the open file */
|
||||
private final FileDescriptor fd;
|
||||
|
||||
/* The path of the referenced file (null if the stream is created with a file descriptor) */
|
||||
private final String path;
|
||||
|
||||
private FileChannel channel = null;
|
||||
|
||||
private final Object closeLock = new Object();
|
||||
private volatile boolean closed = false;
|
||||
|
||||
private static final ThreadLocal<Boolean> runningFinalize =
|
||||
new ThreadLocal<>();
|
||||
|
||||
private static boolean isRunningFinalize() {
|
||||
Boolean val;
|
||||
if ((val = runningFinalize.get()) != null)
|
||||
return val.booleanValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>FileInputStream</code> by
|
||||
* opening a connection to an actual file,
|
||||
* the file named by the path name <code>name</code>
|
||||
* in the file system. A new <code>FileDescriptor</code>
|
||||
* object is created to represent this file
|
||||
* connection.
|
||||
* <p>
|
||||
* First, if there is a security
|
||||
* manager, its <code>checkRead</code> method
|
||||
* is called with the <code>name</code> argument
|
||||
* as its argument.
|
||||
* <p>
|
||||
* If the named file does not exist, is a directory rather than a regular
|
||||
* file, or for some other reason cannot be opened for reading then a
|
||||
* <code>FileNotFoundException</code> is thrown.
|
||||
*
|
||||
* @param name the system-dependent file name.
|
||||
* @exception FileNotFoundException if the file does not exist,
|
||||
* is a directory rather than a regular file,
|
||||
* or for some other reason cannot be opened for
|
||||
* reading.
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkRead</code> method denies read access
|
||||
* to the file.
|
||||
* @see java.lang.SecurityManager#checkRead(java.lang.String)
|
||||
*/
|
||||
public FileInputStream(String name) throws FileNotFoundException {
|
||||
this(name != null ? new File(name) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>FileInputStream</code> by
|
||||
* opening a connection to an actual file,
|
||||
* the file named by the <code>File</code>
|
||||
* object <code>file</code> in the file system.
|
||||
* A new <code>FileDescriptor</code> object
|
||||
* is created to represent this file connection.
|
||||
* <p>
|
||||
* First, if there is a security manager,
|
||||
* its <code>checkRead</code> method is called
|
||||
* with the path represented by the <code>file</code>
|
||||
* argument as its argument.
|
||||
* <p>
|
||||
* If the named file does not exist, is a directory rather than a regular
|
||||
* file, or for some other reason cannot be opened for reading then a
|
||||
* <code>FileNotFoundException</code> is thrown.
|
||||
*
|
||||
* @param file the file to be opened for reading.
|
||||
* @exception FileNotFoundException if the file does not exist,
|
||||
* is a directory rather than a regular file,
|
||||
* or for some other reason cannot be opened for
|
||||
* reading.
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkRead</code> method denies read access to the file.
|
||||
* @see java.io.File#getPath()
|
||||
* @see java.lang.SecurityManager#checkRead(java.lang.String)
|
||||
*/
|
||||
public FileInputStream(File file) throws FileNotFoundException {
|
||||
String name = (file != null ? file.getPath() : null);
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkRead(name);
|
||||
}
|
||||
if (name == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
/*
|
||||
if (file.isInvalid()) {
|
||||
throw new FileNotFoundException("Invalid file path");
|
||||
}
|
||||
*/
|
||||
fd = new FileDescriptor();
|
||||
fd.incrementAndGetUseCount();
|
||||
this.path = name;
|
||||
open(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>FileInputStream</code> by using the file descriptor
|
||||
* <code>fdObj</code>, which represents an existing connection to an
|
||||
* actual file in the file system.
|
||||
* <p>
|
||||
* If there is a security manager, its <code>checkRead</code> method is
|
||||
* called with the file descriptor <code>fdObj</code> as its argument to
|
||||
* see if it's ok to read the file descriptor. If read access is denied
|
||||
* to the file descriptor a <code>SecurityException</code> is thrown.
|
||||
* <p>
|
||||
* If <code>fdObj</code> is null then a <code>NullPointerException</code>
|
||||
* is thrown.
|
||||
* <p>
|
||||
* This constructor does not throw an exception if <code>fdObj</code>
|
||||
* is {@link java.io.FileDescriptor#valid() invalid}.
|
||||
* However, if the methods are invoked on the resulting stream to attempt
|
||||
* I/O on the stream, an <code>IOException</code> is thrown.
|
||||
*
|
||||
* @param fdObj the file descriptor to be opened for reading.
|
||||
* @throws SecurityException if a security manager exists and its
|
||||
* <code>checkRead</code> method denies read access to the
|
||||
* file descriptor.
|
||||
* @see SecurityManager#checkRead(java.io.FileDescriptor)
|
||||
*/
|
||||
public FileInputStream(FileDescriptor fdObj) {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (fdObj == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (security != null) {
|
||||
security.checkRead(fdObj);
|
||||
}
|
||||
fd = fdObj;
|
||||
path = null;
|
||||
|
||||
/*
|
||||
* FileDescriptor is being shared by streams.
|
||||
* Ensure that it's GC'ed only when all the streams/channels are done
|
||||
* using it.
|
||||
*/
|
||||
fd.incrementAndGetUseCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the specified file for reading.
|
||||
* @param name the name of the file
|
||||
*/
|
||||
private void open(String name) throws FileNotFoundException
|
||||
{
|
||||
fd.openReadOnly(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a byte of data from this input stream. This method blocks
|
||||
* if no input is yet available.
|
||||
*
|
||||
* @return the next byte of data, or <code>-1</code> if the end of the
|
||||
* file is reached.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public int read() throws IOException {
|
||||
Object traceContext = IoTrace.fileReadBegin(path);
|
||||
int b = 0;
|
||||
try {
|
||||
b = fd.read();
|
||||
} finally {
|
||||
IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a subarray as a sequence of bytes.
|
||||
* @param b the data to be written
|
||||
* @param off the start offset in the data
|
||||
* @param len the number of bytes that are written
|
||||
* @exception IOException If an I/O error has occurred.
|
||||
*/
|
||||
private int readBytes(byte b[], int off, int len) throws IOException
|
||||
{
|
||||
return fd.readBytes(b, off, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads up to <code>b.length</code> bytes of data from this input
|
||||
* stream into an array of bytes. This method blocks until some input
|
||||
* is available.
|
||||
*
|
||||
* @param b the buffer into which the data is read.
|
||||
* @return the total number of bytes read into the buffer, or
|
||||
* <code>-1</code> if there is no more data because the end of
|
||||
* the file has been reached.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public int read(byte b[]) throws IOException {
|
||||
Object traceContext = IoTrace.fileReadBegin(path);
|
||||
int bytesRead = 0;
|
||||
try {
|
||||
bytesRead = readBytes(b, 0, b.length);
|
||||
} finally {
|
||||
IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads up to <code>len</code> bytes of data from this input stream
|
||||
* into an array of bytes. If <code>len</code> is not zero, the method
|
||||
* blocks until some input is available; otherwise, no
|
||||
* bytes are read and <code>0</code> is returned.
|
||||
*
|
||||
* @param b the buffer into which the data is read.
|
||||
* @param off the start offset in the destination array <code>b</code>
|
||||
* @param len the maximum number of bytes read.
|
||||
* @return the total number of bytes read into the buffer, or
|
||||
* <code>-1</code> if there is no more data because the end of
|
||||
* the file has been reached.
|
||||
* @exception NullPointerException If <code>b</code> is <code>null</code>.
|
||||
* @exception IndexOutOfBoundsException If <code>off</code> is negative,
|
||||
* <code>len</code> is negative, or <code>len</code> is greater than
|
||||
* <code>b.length - off</code>
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
Object traceContext = IoTrace.fileReadBegin(path);
|
||||
int bytesRead = 0;
|
||||
try {
|
||||
bytesRead = readBytes(b, off, len);
|
||||
} finally {
|
||||
IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips over and discards <code>n</code> bytes of data from the
|
||||
* input stream.
|
||||
*
|
||||
* <p>The <code>skip</code> method may, for a variety of
|
||||
* reasons, end up skipping over some smaller number of bytes,
|
||||
* possibly <code>0</code>. If <code>n</code> is negative, an
|
||||
* <code>IOException</code> is thrown, even though the <code>skip</code>
|
||||
* method of the {@link InputStream} superclass does nothing in this case.
|
||||
* The actual number of bytes skipped is returned.
|
||||
*
|
||||
* <p>This method may skip more bytes than are remaining in the backing
|
||||
* file. This produces no exception and the number of bytes skipped
|
||||
* may include some number of bytes that were beyond the EOF of the
|
||||
* backing file. Attempting to read from the stream after skipping past
|
||||
* the end will result in -1 indicating the end of the file.
|
||||
*
|
||||
* @param n the number of bytes to be skipped.
|
||||
* @return the actual number of bytes skipped.
|
||||
* @exception IOException if n is negative, if the stream does not
|
||||
* support seek, or if an I/O error occurs.
|
||||
*/
|
||||
public long skip(long n) throws IOException
|
||||
{
|
||||
return fd.skip(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an estimate of the number of remaining bytes that can be read (or
|
||||
* skipped over) from this input stream without blocking by the next
|
||||
* invocation of a method for this input stream. The next invocation might be
|
||||
* the same thread or another thread. A single read or skip of this
|
||||
* many bytes will not block, but may read or skip fewer bytes.
|
||||
*
|
||||
* <p> In some cases, a non-blocking read (or skip) may appear to be
|
||||
* blocked when it is merely slow, for example when reading large
|
||||
* files over slow networks.
|
||||
*
|
||||
* @return an estimate of the number of remaining bytes that can be read
|
||||
* (or skipped over) from this input stream without blocking.
|
||||
* @exception IOException if this file input stream has been closed by calling
|
||||
* {@code close} or an I/O error occurs.
|
||||
*/
|
||||
public int available() throws IOException
|
||||
{
|
||||
return fd.available();
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this file input stream and releases any system resources
|
||||
* associated with the stream.
|
||||
*
|
||||
* <p> If this stream has an associated channel then the channel is closed
|
||||
* as well.
|
||||
*
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*
|
||||
* @revised 1.4
|
||||
* @spec JSR-51
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
synchronized (closeLock) {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
closed = true;
|
||||
}
|
||||
if (channel != null) {
|
||||
/*
|
||||
* Decrement the FD use count associated with the channel
|
||||
* The use count is incremented whenever a new channel
|
||||
* is obtained from this stream.
|
||||
*/
|
||||
fd.decrementAndGetUseCount();
|
||||
channel.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement the FD use count associated with this stream
|
||||
*/
|
||||
int useCount = fd.decrementAndGetUseCount();
|
||||
|
||||
/*
|
||||
* If FileDescriptor is still in use by another stream, the finalizer
|
||||
* will not close it.
|
||||
*/
|
||||
if ((useCount <= 0) || !isRunningFinalize()) {
|
||||
close0();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>FileDescriptor</code>
|
||||
* object that represents the connection to
|
||||
* the actual file in the file system being
|
||||
* used by this <code>FileInputStream</code>.
|
||||
*
|
||||
* @return the file descriptor object associated with this stream.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
* @see java.io.FileDescriptor
|
||||
*/
|
||||
public final FileDescriptor getFD() throws IOException {
|
||||
if (fd != null) return fd;
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique {@link java.nio.channels.FileChannel FileChannel}
|
||||
* object associated with this file input stream.
|
||||
*
|
||||
* <p> The initial {@link java.nio.channels.FileChannel#position()
|
||||
* </code>position<code>} of the returned channel will be equal to the
|
||||
* number of bytes read from the file so far. Reading bytes from this
|
||||
* stream will increment the channel's position. Changing the channel's
|
||||
* position, either explicitly or by reading, will change this stream's
|
||||
* file position.
|
||||
*
|
||||
* @return the file channel associated with this file input stream
|
||||
*
|
||||
* @since 1.4
|
||||
* @spec JSR-51
|
||||
*/
|
||||
public FileChannel getChannel() {
|
||||
synchronized (this) {
|
||||
if (channel == null) {
|
||||
channel = FileChannelImpl.open(fd, path, true, false, this);
|
||||
|
||||
/*
|
||||
* Increment fd's use count. Invoking the channel's close()
|
||||
* method will result in decrementing the use count set for
|
||||
* the channel.
|
||||
*/
|
||||
fd.incrementAndGetUseCount();
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
|
||||
private void close0() throws IOException
|
||||
{
|
||||
fd.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the <code>close</code> method of this file input stream is
|
||||
* called when there are no more references to it.
|
||||
*
|
||||
* @exception IOException if an I/O error occurs.
|
||||
* @see java.io.FileInputStream#close()
|
||||
*/
|
||||
protected void finalize() throws IOException {
|
||||
if ((fd != null) && (fd != FileDescriptor.in)) {
|
||||
|
||||
/*
|
||||
* Finalizer should not release the FileDescriptor if another
|
||||
* stream is still using it. If the user directly invokes
|
||||
* close() then the FileDescriptor is also released.
|
||||
*/
|
||||
runningFinalize.set(Boolean.TRUE);
|
||||
try {
|
||||
close();
|
||||
} finally {
|
||||
runningFinalize.set(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
491
external/ikvm/openjdk/java/io/FileOutputStream.java
vendored
491
external/ikvm/openjdk/java/io/FileOutputStream.java
vendored
@ -1,491 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.io;
|
||||
|
||||
import java.nio.channels.FileChannel;
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
import sun.misc.IoTrace;
|
||||
|
||||
|
||||
/**
|
||||
* A file output stream is an output stream for writing data to a
|
||||
* <code>File</code> or to a <code>FileDescriptor</code>. Whether or not
|
||||
* a file is available or may be created depends upon the underlying
|
||||
* platform. Some platforms, in particular, allow a file to be opened
|
||||
* for writing by only one <tt>FileOutputStream</tt> (or other
|
||||
* file-writing object) at a time. In such situations the constructors in
|
||||
* this class will fail if the file involved is already open.
|
||||
*
|
||||
* <p><code>FileOutputStream</code> is meant for writing streams of raw bytes
|
||||
* such as image data. For writing streams of characters, consider using
|
||||
* <code>FileWriter</code>.
|
||||
*
|
||||
* @author Arthur van Hoff
|
||||
* @see java.io.File
|
||||
* @see java.io.FileDescriptor
|
||||
* @see java.io.FileInputStream
|
||||
* @see java.nio.file.Files#newOutputStream
|
||||
* @since JDK1.0
|
||||
*/
|
||||
public
|
||||
class FileOutputStream extends OutputStream
|
||||
{
|
||||
/**
|
||||
* The system dependent file descriptor.
|
||||
*/
|
||||
private final FileDescriptor fd;
|
||||
|
||||
/**
|
||||
* The path of the referenced file (null if the stream is created with a file descriptor)
|
||||
*/
|
||||
private final String path;
|
||||
|
||||
/**
|
||||
* True if the file is opened for append.
|
||||
*/
|
||||
private final boolean append;
|
||||
|
||||
/**
|
||||
* The associated channel, initalized lazily.
|
||||
*/
|
||||
private FileChannel channel;
|
||||
|
||||
private final Object closeLock = new Object();
|
||||
private volatile boolean closed = false;
|
||||
private static final ThreadLocal<Boolean> runningFinalize =
|
||||
new ThreadLocal<>();
|
||||
|
||||
private static boolean isRunningFinalize() {
|
||||
Boolean val;
|
||||
if ((val = runningFinalize.get()) != null)
|
||||
return val.booleanValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file output stream to write to the file with the
|
||||
* specified name. A new <code>FileDescriptor</code> object is
|
||||
* created to represent this file connection.
|
||||
* <p>
|
||||
* First, if there is a security manager, its <code>checkWrite</code>
|
||||
* method is called with <code>name</code> as its argument.
|
||||
* <p>
|
||||
* If the file exists but is a directory rather than a regular file, does
|
||||
* not exist but cannot be created, or cannot be opened for any other
|
||||
* reason then a <code>FileNotFoundException</code> is thrown.
|
||||
*
|
||||
* @param name the system-dependent filename
|
||||
* @exception FileNotFoundException if the file exists but is a directory
|
||||
* rather than a regular file, does not exist but cannot
|
||||
* be created, or cannot be opened for any other reason
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkWrite</code> method denies write access
|
||||
* to the file.
|
||||
* @see java.lang.SecurityManager#checkWrite(java.lang.String)
|
||||
*/
|
||||
public FileOutputStream(String name) throws FileNotFoundException {
|
||||
this(name != null ? new File(name) : null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file output stream to write to the file with the specified
|
||||
* name. If the second argument is <code>true</code>, then
|
||||
* bytes will be written to the end of the file rather than the beginning.
|
||||
* A new <code>FileDescriptor</code> object is created to represent this
|
||||
* file connection.
|
||||
* <p>
|
||||
* First, if there is a security manager, its <code>checkWrite</code>
|
||||
* method is called with <code>name</code> as its argument.
|
||||
* <p>
|
||||
* If the file exists but is a directory rather than a regular file, does
|
||||
* not exist but cannot be created, or cannot be opened for any other
|
||||
* reason then a <code>FileNotFoundException</code> is thrown.
|
||||
*
|
||||
* @param name the system-dependent file name
|
||||
* @param append if <code>true</code>, then bytes will be written
|
||||
* to the end of the file rather than the beginning
|
||||
* @exception FileNotFoundException if the file exists but is a directory
|
||||
* rather than a regular file, does not exist but cannot
|
||||
* be created, or cannot be opened for any other reason.
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkWrite</code> method denies write access
|
||||
* to the file.
|
||||
* @see java.lang.SecurityManager#checkWrite(java.lang.String)
|
||||
* @since JDK1.1
|
||||
*/
|
||||
public FileOutputStream(String name, boolean append)
|
||||
throws FileNotFoundException
|
||||
{
|
||||
this(name != null ? new File(name) : null, append);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file output stream to write to the file represented by
|
||||
* the specified <code>File</code> object. A new
|
||||
* <code>FileDescriptor</code> object is created to represent this
|
||||
* file connection.
|
||||
* <p>
|
||||
* First, if there is a security manager, its <code>checkWrite</code>
|
||||
* method is called with the path represented by the <code>file</code>
|
||||
* argument as its argument.
|
||||
* <p>
|
||||
* If the file exists but is a directory rather than a regular file, does
|
||||
* not exist but cannot be created, or cannot be opened for any other
|
||||
* reason then a <code>FileNotFoundException</code> is thrown.
|
||||
*
|
||||
* @param file the file to be opened for writing.
|
||||
* @exception FileNotFoundException if the file exists but is a directory
|
||||
* rather than a regular file, does not exist but cannot
|
||||
* be created, or cannot be opened for any other reason
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkWrite</code> method denies write access
|
||||
* to the file.
|
||||
* @see java.io.File#getPath()
|
||||
* @see java.lang.SecurityException
|
||||
* @see java.lang.SecurityManager#checkWrite(java.lang.String)
|
||||
*/
|
||||
public FileOutputStream(File file) throws FileNotFoundException {
|
||||
this(file, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file output stream to write to the file represented by
|
||||
* the specified <code>File</code> object. If the second argument is
|
||||
* <code>true</code>, then bytes will be written to the end of the file
|
||||
* rather than the beginning. A new <code>FileDescriptor</code> object is
|
||||
* created to represent this file connection.
|
||||
* <p>
|
||||
* First, if there is a security manager, its <code>checkWrite</code>
|
||||
* method is called with the path represented by the <code>file</code>
|
||||
* argument as its argument.
|
||||
* <p>
|
||||
* If the file exists but is a directory rather than a regular file, does
|
||||
* not exist but cannot be created, or cannot be opened for any other
|
||||
* reason then a <code>FileNotFoundException</code> is thrown.
|
||||
*
|
||||
* @param file the file to be opened for writing.
|
||||
* @param append if <code>true</code>, then bytes will be written
|
||||
* to the end of the file rather than the beginning
|
||||
* @exception FileNotFoundException if the file exists but is a directory
|
||||
* rather than a regular file, does not exist but cannot
|
||||
* be created, or cannot be opened for any other reason
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkWrite</code> method denies write access
|
||||
* to the file.
|
||||
* @see java.io.File#getPath()
|
||||
* @see java.lang.SecurityException
|
||||
* @see java.lang.SecurityManager#checkWrite(java.lang.String)
|
||||
* @since 1.4
|
||||
*/
|
||||
public FileOutputStream(File file, boolean append)
|
||||
throws FileNotFoundException
|
||||
{
|
||||
String name = (file != null ? file.getPath() : null);
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkWrite(name);
|
||||
}
|
||||
if (name == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
/*
|
||||
if (file.isInvalid()) {
|
||||
throw new FileNotFoundException("Invalid file path");
|
||||
}
|
||||
*/
|
||||
this.fd = new FileDescriptor();
|
||||
this.append = append;
|
||||
this.path = name;
|
||||
fd.incrementAndGetUseCount();
|
||||
open(name, append);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file output stream to write to the specified file
|
||||
* descriptor, which represents an existing connection to an actual
|
||||
* file in the file system.
|
||||
* <p>
|
||||
* First, if there is a security manager, its <code>checkWrite</code>
|
||||
* method is called with the file descriptor <code>fdObj</code>
|
||||
* argument as its argument.
|
||||
* <p>
|
||||
* If <code>fdObj</code> is null then a <code>NullPointerException</code>
|
||||
* is thrown.
|
||||
* <p>
|
||||
* This constructor does not throw an exception if <code>fdObj</code>
|
||||
* is {@link java.io.FileDescriptor#valid() invalid}.
|
||||
* However, if the methods are invoked on the resulting stream to attempt
|
||||
* I/O on the stream, an <code>IOException</code> is thrown.
|
||||
*
|
||||
* @param fdObj the file descriptor to be opened for writing
|
||||
* @exception SecurityException if a security manager exists and its
|
||||
* <code>checkWrite</code> method denies
|
||||
* write access to the file descriptor
|
||||
* @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
|
||||
*/
|
||||
public FileOutputStream(FileDescriptor fdObj) {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (fdObj == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (security != null) {
|
||||
security.checkWrite(fdObj);
|
||||
}
|
||||
this.fd = fdObj;
|
||||
this.path = null;
|
||||
this.append = false;
|
||||
|
||||
/*
|
||||
* FileDescriptor is being shared by streams.
|
||||
* Ensure that it's GC'ed only when all the streams/channels are done
|
||||
* using it.
|
||||
*/
|
||||
fd.incrementAndGetUseCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a file, with the specified name, for overwriting or appending.
|
||||
* @param name name of file to be opened
|
||||
* @param append whether the file is to be opened in append mode
|
||||
*/
|
||||
private void open(String name, boolean append)
|
||||
throws FileNotFoundException {
|
||||
if (append) {
|
||||
fd.openAppend(name);
|
||||
} else {
|
||||
fd.openWriteOnly(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the specified byte to this file output stream.
|
||||
*
|
||||
* @param b the byte to be written.
|
||||
* @param append {@code true} if the write operation first
|
||||
* advances the position to the end of file
|
||||
*/
|
||||
private void write(int b, boolean append) throws IOException {
|
||||
fd.write(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the specified byte to this file output stream. Implements
|
||||
* the <code>write</code> method of <code>OutputStream</code>.
|
||||
*
|
||||
* @param b the byte to be written.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public void write(int b) throws IOException {
|
||||
Object traceContext = IoTrace.fileWriteBegin(path);
|
||||
int bytesWritten = 0;
|
||||
try {
|
||||
write(b, append);
|
||||
bytesWritten = 1;
|
||||
} finally {
|
||||
IoTrace.fileWriteEnd(traceContext, bytesWritten);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a sub array as a sequence of bytes.
|
||||
* @param b the data to be written
|
||||
* @param off the start offset in the data
|
||||
* @param len the number of bytes that are written
|
||||
* @param append {@code true} to first advance the position to the
|
||||
* end of file
|
||||
* @exception IOException If an I/O error has occurred.
|
||||
*/
|
||||
private void writeBytes(byte b[], int off, int len, boolean append)
|
||||
throws IOException {
|
||||
fd.writeBytes(b, off, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes <code>b.length</code> bytes from the specified byte array
|
||||
* to this file output stream.
|
||||
*
|
||||
* @param b the data.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public void write(byte b[]) throws IOException {
|
||||
Object traceContext = IoTrace.fileWriteBegin(path);
|
||||
int bytesWritten = 0;
|
||||
try {
|
||||
writeBytes(b, 0, b.length, append);
|
||||
bytesWritten = b.length;
|
||||
} finally {
|
||||
IoTrace.fileWriteEnd(traceContext, bytesWritten);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes <code>len</code> bytes from the specified byte array
|
||||
* starting at offset <code>off</code> to this file output stream.
|
||||
*
|
||||
* @param b the data.
|
||||
* @param off the start offset in the data.
|
||||
* @param len the number of bytes to write.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
Object traceContext = IoTrace.fileWriteBegin(path);
|
||||
int bytesWritten = 0;
|
||||
try {
|
||||
writeBytes(b, off, len, append);
|
||||
bytesWritten = len;
|
||||
} finally {
|
||||
IoTrace.fileWriteEnd(traceContext, bytesWritten);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this file output stream and releases any system resources
|
||||
* associated with this stream. This file output stream may no longer
|
||||
* be used for writing bytes.
|
||||
*
|
||||
* <p> If this stream has an associated channel then the channel is closed
|
||||
* as well.
|
||||
*
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*
|
||||
* @revised 1.4
|
||||
* @spec JSR-51
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
synchronized (closeLock) {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
closed = true;
|
||||
}
|
||||
|
||||
if (channel != null) {
|
||||
/*
|
||||
* Decrement FD use count associated with the channel
|
||||
* The use count is incremented whenever a new channel
|
||||
* is obtained from this stream.
|
||||
*/
|
||||
fd.decrementAndGetUseCount();
|
||||
channel.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* Decrement FD use count associated with this stream
|
||||
*/
|
||||
int useCount = fd.decrementAndGetUseCount();
|
||||
|
||||
/*
|
||||
* If FileDescriptor is still in use by another stream, the finalizer
|
||||
* will not close it.
|
||||
*/
|
||||
if ((useCount <= 0) || !isRunningFinalize()) {
|
||||
close0();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file descriptor associated with this stream.
|
||||
*
|
||||
* @return the <code>FileDescriptor</code> object that represents
|
||||
* the connection to the file in the file system being used
|
||||
* by this <code>FileOutputStream</code> object.
|
||||
*
|
||||
* @exception IOException if an I/O error occurs.
|
||||
* @see java.io.FileDescriptor
|
||||
*/
|
||||
public final FileDescriptor getFD() throws IOException {
|
||||
if (fd != null) return fd;
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique {@link java.nio.channels.FileChannel FileChannel}
|
||||
* object associated with this file output stream. </p>
|
||||
*
|
||||
* <p> The initial {@link java.nio.channels.FileChannel#position()
|
||||
* </code>position<code>} of the returned channel will be equal to the
|
||||
* number of bytes written to the file so far unless this stream is in
|
||||
* append mode, in which case it will be equal to the size of the file.
|
||||
* Writing bytes to this stream will increment the channel's position
|
||||
* accordingly. Changing the channel's position, either explicitly or by
|
||||
* writing, will change this stream's file position.
|
||||
*
|
||||
* @return the file channel associated with this file output stream
|
||||
*
|
||||
* @since 1.4
|
||||
* @spec JSR-51
|
||||
*/
|
||||
public FileChannel getChannel() {
|
||||
synchronized (this) {
|
||||
if (channel == null) {
|
||||
channel = FileChannelImpl.open(fd, path, false, true, append, this);
|
||||
|
||||
/*
|
||||
* Increment fd's use count. Invoking the channel's close()
|
||||
* method will result in decrementing the use count set for
|
||||
* the channel.
|
||||
*/
|
||||
fd.incrementAndGetUseCount();
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the connection to the file, and ensures that the
|
||||
* <code>close</code> method of this file output stream is
|
||||
* called when there are no more references to this stream.
|
||||
*
|
||||
* @exception IOException if an I/O error occurs.
|
||||
* @see java.io.FileInputStream#close()
|
||||
*/
|
||||
protected void finalize() throws IOException {
|
||||
if (fd != null) {
|
||||
if (fd == FileDescriptor.out || fd == FileDescriptor.err) {
|
||||
flush();
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Finalizer should not release the FileDescriptor if another
|
||||
* stream is still using it. If the user directly invokes
|
||||
* close() then the FileDescriptor is also released.
|
||||
*/
|
||||
runningFinalize.set(Boolean.TRUE);
|
||||
try {
|
||||
close();
|
||||
} finally {
|
||||
runningFinalize.set(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void close0() throws IOException
|
||||
{
|
||||
fd.close();
|
||||
}
|
||||
|
||||
}
|
1191
external/ikvm/openjdk/java/io/RandomAccessFile.java
vendored
1191
external/ikvm/openjdk/java/io/RandomAccessFile.java
vendored
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
||||
07fd7bd567e5b0ae8b3ae9c32741b56f6f363b0a
|
||||
b11e668d455d97412eca312477103a8e19b9b2b6
|
279
external/ikvm/openjdk/java/lang/ClassLoader.java
vendored
279
external/ikvm/openjdk/java/lang/ClassLoader.java
vendored
File diff suppressed because it is too large
Load Diff
85
external/ikvm/openjdk/java/lang/ClassSerializationProxy.java
vendored
Normal file
85
external/ikvm/openjdk/java/lang/ClassSerializationProxy.java
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright (C) 2009-2015 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
jeroen@frijters.net
|
||||
|
||||
*/
|
||||
package java.lang;
|
||||
|
||||
import cli.System.Runtime.Serialization.IObjectReference;
|
||||
import cli.System.Runtime.Serialization.SerializationException;
|
||||
import cli.System.Runtime.Serialization.StreamingContext;
|
||||
|
||||
@cli.System.SerializableAttribute.Annotation
|
||||
final class ClassSerializationProxy implements IObjectReference
|
||||
{
|
||||
private cli.System.Type type;
|
||||
private String sig;
|
||||
|
||||
@cli.System.Security.SecurityCriticalAttribute.Annotation
|
||||
public Object GetRealObject(StreamingContext context)
|
||||
{
|
||||
if (sig != null)
|
||||
{
|
||||
if (sig.length() == 1)
|
||||
{
|
||||
switch (sig.charAt(0))
|
||||
{
|
||||
case 'B':
|
||||
return Byte.TYPE;
|
||||
case 'C':
|
||||
return Character.TYPE;
|
||||
case 'D':
|
||||
return Double.TYPE;
|
||||
case 'F':
|
||||
return Float.TYPE;
|
||||
case 'I':
|
||||
return Integer.TYPE;
|
||||
case 'J':
|
||||
return Long.TYPE;
|
||||
case 'S':
|
||||
return Short.TYPE;
|
||||
case 'Z':
|
||||
return Boolean.TYPE;
|
||||
case 'V':
|
||||
return Void.TYPE;
|
||||
}
|
||||
}
|
||||
String className;
|
||||
if (sig.charAt(0) == 'L')
|
||||
{
|
||||
className = sig.substring(1, sig.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
className = sig;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Class.forName(className, false, Thread.currentThread().getContextClassLoader());
|
||||
}
|
||||
catch (ClassNotFoundException x)
|
||||
{
|
||||
ikvm.runtime.Util.throwException(new SerializationException(x.getMessage(), x));
|
||||
}
|
||||
}
|
||||
return ikvm.runtime.Util.getClassFromTypeHandle(type.get_TypeHandle());
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
98f7816c72a28907d154c1848447b1fda97ef6ca
|
||||
de318623b06f63349c8a73909bc6fac4716b99ec
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user