Imported Upstream version 4.2.1.36

Former-commit-id: fb75898888a02f4d3a74cf0a5b841681bc4c7fa8
This commit is contained in:
Xamarin Public Jenkins
2015-09-24 06:06:07 -04:00
committed by Jo Shields
parent 9668de7cb8
commit dd547c45d4
172 changed files with 6570 additions and 11015 deletions

8
external/ikvm/HOWTO vendored
View File

@ -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".

View File

@ -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);

View File

@ -1 +1 @@
a8a055aaac9ad8e98b1c9c47fcd85f5d82ba8ef1
3326c8c8b604536ceedce48c5646eef4d04d2a8f

View File

@ -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);

View File

@ -838,7 +838,7 @@ sealed class IkvmcCompiler
}
else if(s == "-opt:fields")
{
options.removeUnusedFields = true;
options.codegenoptions |= CodeGenOptions.RemoveUnusedFields;
}
else if(s == "-compressresources")
{

View File

@ -1 +1 @@
c27a31eb1803a411aadc8b97ad081614b07dd615
1d6e66a3d816d572409fee7c6c4b27cc07cfb43d

View File

@ -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; }

View File

@ -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

View File

@ -1 +1 @@
9893116e072094e4cdaec2c5e493ef7f7799c5e6
935b3a93896a85d98a39a3ab7e9795dc58c56bdf

View File

@ -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;

View File

@ -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);
}
}
}
}

View File

@ -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();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
07fd7bd567e5b0ae8b3ae9c32741b56f6f363b0a
b11e668d455d97412eca312477103a8e19b9b2b6

File diff suppressed because it is too large Load Diff

View 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());
}
}

View File

@ -1 +1 @@
98f7816c72a28907d154c1848447b1fda97ef6ca
de318623b06f63349c8a73909bc6fac4716b99ec

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
* 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
@ -25,24 +25,30 @@
package java.lang;
import java.io.*;
import java.lang.reflect.Executable;
import java.lang.annotation.Annotation;
import java.security.AccessControlContext;
import java.util.Properties;
import java.util.PropertyPermission;
import java.util.StringTokenizer;
import java.util.Map;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.AllPermission;
import java.nio.channels.Channel;
import java.nio.channels.spi.SelectorProvider;
import sun.nio.ch.Interruptible;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
import sun.security.util.SecurityConstants;
import sun.reflect.annotation.AnnotationType;
final class StdIO
{
private StdIO() { }
static InputStream in = new BufferedInputStream(new FileInputStream(FileDescriptor.in));
static PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out), 128), true);
static PrintStream err = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err), 128), true);
static PrintStream out = System.newPrintStream(new FileOutputStream(FileDescriptor.out), Props.props.getProperty("sun.stdout.encoding"));
static PrintStream err = System.newPrintStream(new FileOutputStream(FileDescriptor.err), Props.props.getProperty("sun.stderr.encoding"));
}
final class Props
@ -85,6 +91,18 @@ final class Props
*/
public final class System {
/* register the natives via the static initializer.
*
* VM will invoke the initializeSystemClass method to complete
* the initialization for this class separated from clinit.
* Note that to use properties set by the VM, see the constraints
* described in the initializeSystemClass method.
*/
private static native void registerNatives();
static {
//registerNatives();
}
/** Don't let anyone instantiate this class */
private System() {
}
@ -96,10 +114,8 @@ public final class System {
* the host environment or user.
*/
@ikvm.lang.Property(get="get_in")
public final static InputStream in;
static { in = null; }
public final static InputStream in = null;
private static InputStream get_in()
{
return StdIO.in;
@ -131,10 +147,8 @@ public final class System {
* @see java.io.PrintStream#println(java.lang.String)
*/
@ikvm.lang.Property(get="get_out")
public final static PrintStream out;
static { out = null; }
public final static PrintStream out = null;
private static PrintStream get_out()
{
return StdIO.out;
@ -153,9 +167,7 @@ public final class System {
* destination that is typically not continuously monitored.
*/
@ikvm.lang.Property(get="get_err")
public final static PrintStream err;
static { err = null ; }
public final static PrintStream err = null;
private static PrintStream get_err()
{
@ -164,7 +176,7 @@ public final class System {
/* The security manager for the system.
*/
private static volatile SecurityManager security;
private static volatile SecurityManager security = null;
/**
* Reassigns the "standard" input stream.
@ -188,7 +200,7 @@ public final class System {
*/
public static void setIn(InputStream in) {
checkIO();
StdIO.in = in;
setIn0(in);
}
/**
@ -212,7 +224,7 @@ public final class System {
*/
public static void setOut(PrintStream out) {
checkIO();
StdIO.out = out;
setOut0(out);
}
/**
@ -236,10 +248,10 @@ public final class System {
*/
public static void setErr(PrintStream err) {
checkIO();
StdIO.err = err;
setErr0(err);
}
private static volatile Console cons;
private static volatile Console cons = null;
/**
* Returns the unique {@link java.io.Console Console} object associated
* with the current Java virtual machine, if any.
@ -293,6 +305,10 @@ public final class System {
}
}
private static native void setIn0(InputStream in);
private static native void setOut0(PrintStream out);
private static native void setErr0(PrintStream err);
/**
* Sets the System security.
*
@ -576,7 +592,12 @@ public final class System {
* </dl>
*/
//private static native Properties initProperties(Properties props);
@ikvm.lang.Property(get="get_props", set="set_props")
private static Properties props;
private static native Properties initProperties(Properties props);
private static Properties get_props() { return Props.props; }
private static void set_props(Properties value) { Props.props = value; }
/**
* Determines the current system properties.
@ -597,7 +618,7 @@ public final class System {
* <tr><td><code>java.version</code></td>
* <td>Java Runtime Environment version</td></tr>
* <tr><td><code>java.vendor</code></td>
* <td>Java Runtime Environment vendor</td></tr
* <td>Java Runtime Environment vendor</td></tr>
* <tr><td><code>java.vendor.url</code></td>
* <td>Java vendor URL</td></tr>
* <tr><td><code>java.home</code></td>
@ -631,7 +652,10 @@ public final class System {
* <tr><td><code>java.compiler</code></td>
* <td>Name of JIT compiler to use</td></tr>
* <tr><td><code>java.ext.dirs</code></td>
* <td>Path of extension directory or directories</td></tr>
* <td>Path of extension directory or directories
* <b>Deprecated.</b> <i>This property, and the mechanism
* which implements it, may be removed in a future
* release.</i> </td></tr>
* <tr><td><code>os.name</code></td>
* <td>Operating system name</td></tr>
* <tr><td><code>os.arch</code></td>
@ -674,7 +698,7 @@ public final class System {
sm.checkPropertiesAccess();
}
return Props.props;
return props;
}
/**
@ -684,11 +708,20 @@ public final class System {
*
* <p>On UNIX systems, it returns {@code "\n"}; on Microsoft
* Windows systems it returns {@code "\r\n"}.
*
* @return the system-dependent line separator string
* @since 1.7
*/
public static String lineSeparator() {
return Props.lineSeparator;
return lineSeparator;
}
@ikvm.lang.Property(get="get_lineSeparator", set="set_lineSeparator")
private static String lineSeparator;
private static String get_lineSeparator() { return Props.lineSeparator; }
private static void set_lineSeparator(String value) { Props.lineSeparator = value; }
/**
* Sets the system properties to the <code>Properties</code>
* argument.
@ -718,9 +751,9 @@ public final class System {
}
if (props == null) {
props = new Properties();
VMSystemProperties.initProperties(props);
initProperties(props);
}
Props.props = props;
System.props = props;
}
/**
@ -756,7 +789,7 @@ public final class System {
sm.checkPropertyAccess(key);
}
return Props.props.getProperty(key);
return props.getProperty(key);
}
/**
@ -792,7 +825,7 @@ public final class System {
sm.checkPropertyAccess(key);
}
return Props.props.getProperty(key, def);
return props.getProperty(key, def);
}
/**
@ -832,7 +865,7 @@ public final class System {
SecurityConstants.PROPERTY_WRITE_ACTION));
}
return (String) Props.props.setProperty(key, value);
return (String) props.setProperty(key, value);
}
/**
@ -869,7 +902,7 @@ public final class System {
sm.checkPermission(new PropertyPermission(key, "write"));
}
return (String) Props.props.remove(key);
return (String) props.remove(key);
}
private static void checkKey(String key) {
@ -1081,13 +1114,25 @@ public final class System {
*/
@Deprecated
public static void runFinalizersOnExit(boolean value) {
Runtime.getRuntime().runFinalizersOnExit(value);
Runtime.runFinalizersOnExit(value);
}
/**
* Loads a code file with the specified filename from the local file
* system as a dynamic library. The filename
* argument must be a complete path name.
* Loads the native library specified by the filename argument. The filename
* argument must be an absolute path name.
*
* If the filename argument, when stripped of any platform-specific library
* prefix, path, and file extension, indicates a library whose name is,
* for example, L, and a native library called L is statically linked
* with the VM, then the JNI_OnLoad_L function exported by the library
* is invoked rather than attempting to load a dynamic library.
* A filename matching the argument does not have to exist in the
* file system.
* See the JNI Specification for more details.
*
* Otherwise, the filename argument is mapped to a native library image in
* an implementation-dependent manner.
*
* <p>
* The call <code>System.load(name)</code> is effectively equivalent
* to the call:
@ -1099,7 +1144,10 @@ public final class System {
* @exception SecurityException if a security manager exists and its
* <code>checkLink</code> method doesn't allow
* loading of the specified dynamic library
* @exception UnsatisfiedLinkError if the file does not exist.
* @exception UnsatisfiedLinkError if either the filename is not an
* absolute path name, the native library is not statically
* linked with the VM, or the library cannot be mapped to
* a native library image by the host system.
* @exception NullPointerException if <code>filename</code> is
* <code>null</code>
* @see java.lang.Runtime#load(java.lang.String)
@ -1111,9 +1159,16 @@ public final class System {
}
/**
* Loads the system library specified by the <code>libname</code>
* argument. The manner in which a library name is mapped to the
* actual system library is system dependent.
* Loads the native library specified by the <code>libname</code>
* argument. The <code>libname</code> argument must not contain any platform
* specific prefix, file extension or path. If a native library
* called <code>libname</code> is statically linked with the VM, then the
* JNI_OnLoad_<code>libname</code> function exported by the library is invoked.
* See the JNI Specification for more details.
*
* Otherwise, the libname argument is loaded from a system library
* location and mapped to a native library image in an implementation-
* dependent manner.
* <p>
* The call <code>System.loadLibrary(name)</code> is effectively
* equivalent to the call
@ -1125,7 +1180,10 @@ public final class System {
* @exception SecurityException if a security manager exists and its
* <code>checkLink</code> method doesn't allow
* loading of the specified dynamic library
* @exception UnsatisfiedLinkError if the library does not exist.
* @exception UnsatisfiedLinkError if either the libname argument
* contains a file path, the native library is not statically
* linked with the VM, or the library cannot be mapped to a
* native library image by the host system.
* @exception NullPointerException if <code>libname</code> is
* <code>null</code>
* @see java.lang.Runtime#loadLibrary(java.lang.String)
@ -1148,21 +1206,17 @@ public final class System {
* @see java.lang.ClassLoader#findLibrary(java.lang.String)
* @since 1.2
*/
public static String mapLibraryName(String libname) {
if (libname == null) {
throw new NullPointerException();
public static native String mapLibraryName(String libname);
/**
* Create PrintStream for stdout/err based on encoding.
*/
/*private*/ static PrintStream newPrintStream(FileOutputStream fos, String enc) {
if (enc != null) {
try {
return new PrintStream(new BufferedOutputStream(fos, 128), true, enc);
} catch (UnsupportedEncodingException uee) {}
}
if (ikvm.internal.Util.WINDOWS) {
return libname + ".dll";
} else if (ikvm.internal.Util.MACOSX) {
return "lib" + libname + ".jnilib";
} else {
return "lib" + libname + ".so";
}
}
/* returns the class of the caller. */
static Class<?> getCallerClass() {
// NOTE use of more generic Reflection.getCallerClass()
return Reflection.getCallerClass(3);
return new PrintStream(new BufferedOutputStream(fos, 128), true);
}
}

View File

@ -1 +1 @@
0ed6057830f61276302f31aec193002ca38ab39a
1341a0148621a18e4c88e2815a5d0e8f837fa015

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2004-2011 Jeroen Frijters
Copyright (C) 2004-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
@ -24,6 +24,7 @@
package java.lang;
import java.util.Properties;
import cli.System.Diagnostics.FileVersionInfo;
import static ikvm.internal.Util.SafeGetEnvironmentVariable;
final class VMSystemProperties
@ -31,7 +32,7 @@ final class VMSystemProperties
private VMSystemProperties() { }
public static final String SPEC_TITLE = "Java Platform API Specification";
public static final String SPEC_VERSION = "1.7";
public static final String SPEC_VERSION = "1.8";
public static final String SPEC_VENDOR = "Oracle Corporation";
private static String getLibraryPath()
@ -114,11 +115,11 @@ final class VMSystemProperties
private static void initCommonProperties(Properties p)
{
p.setProperty("java.version", "1.7.0");
p.setProperty("java.version", "1.8.0");
p.setProperty("java.vendor", "Jeroen Frijters");
p.setProperty("java.vendor.url", "http://ikvm.net/");
p.setProperty("java.vendor.url.bug", "http://www.ikvm.net/bugs");
p.setProperty("java.vm.specification.version", "1.7");
p.setProperty("java.vm.specification.version", "1.8");
p.setProperty("java.vm.specification.vendor", "Oracle Corporation");
p.setProperty("java.vm.specification.name", "Java Virtual Machine Specification");
p.setProperty("java.vm.version", PropertyConstants.java_vm_version);
@ -129,7 +130,7 @@ final class VMSystemProperties
p.setProperty("java.specification.version", SPEC_VERSION);
p.setProperty("java.specification.vendor", SPEC_VENDOR);
p.setProperty("java.specification.name", SPEC_TITLE);
p.setProperty("java.class.version", "51.0");
p.setProperty("java.class.version", "52.0");
p.setProperty("java.class.path", "");
p.setProperty("java.library.path", getLibraryPath());
try
@ -152,6 +153,13 @@ final class VMSystemProperties
switch(os.get_Platform().Value)
{
case cli.System.PlatformID.Win32NT:
// Windows lies about the version, so we extract the real version from kernel32.dll
FileVersionInfo kernel32 = getKernel32FileVersionInfo();
if (kernel32 != null)
{
major = kernel32.get_ProductMajorPart();
minor = kernel32.get_ProductMinorPart();
}
osname = "Windows NT (unknown)";
switch(major)
{
@ -189,6 +197,23 @@ final class VMSystemProperties
osver = "6.1";
osname = "Windows 7";
break;
case 2:
osver = "6.2";
osname = "Windows 8";
break;
case 3:
osver = "6.3";
osname = "Windows 8.1";
break;
}
break;
case 10:
switch(minor)
{
case 0:
osver = "10.0";
osname = "Windows 10";
break;
}
break;
}
@ -322,12 +347,32 @@ final class VMSystemProperties
p.setProperty("sun.nio.MaxDirectMemorySize", "-1");
p.setProperty("java.awt.graphicsenv", PropertyConstants.java_awt_graphicsenv);
p.setProperty("java.awt.printerjob", "sun.awt.windows.WPrinterJob");
String stdoutEncoding = getStdoutEncoding();
if(stdoutEncoding != null)
{
p.setProperty("sun.stdout.encoding", stdoutEncoding);
}
String stderrEncoding = getStderrEncoding();
if(stderrEncoding != null)
{
p.setProperty("sun.stderr.encoding", stderrEncoding);
}
if(ikvm.internal.Util.MACOSX)
{
p.setProperty("sun.jnu.encoding", "UTF-8");
}
else
{
p.setProperty("sun.jnu.encoding", cli.System.Text.Encoding.get_Default().get_WebName());
}
// TODO
// sun.cpu.isalist:=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
// sun.desktop:=windows
// sun.io.unicode.encoding:=UnicodeLittle
// sun.jnu.encoding:=Cp1252
// sun.management.compiler:=HotSpot Client Compiler
try
{
@ -418,4 +463,7 @@ final class VMSystemProperties
private static native String getVirtualFileSystemRoot();
private static native String getBootClassPath();
private static native String getStdoutEncoding();
private static native String getStderrEncoding();
private static native FileVersionInfo getKernel32FileVersionInfo();
}

Some files were not shown because too many files have changed in this diff Show More