You've already forked linux-packaging-mono
Imported Upstream version 4.2.1.36
Former-commit-id: fb75898888a02f4d3a74cf0a5b841681bc4c7fa8
This commit is contained in:
committed by
Jo Shields
parent
9668de7cb8
commit
dd547c45d4
1029
external/ikvm/runtime/openjdk/NativeInvokerBytecodeGenerator.cs
vendored
Normal file
1029
external/ikvm/runtime/openjdk/NativeInvokerBytecodeGenerator.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
191
external/ikvm/runtime/openjdk/java.io.cs
vendored
191
external/ikvm/runtime/openjdk/java.io.cs
vendored
@@ -185,6 +185,105 @@ static class Java_java_io_FileDescriptor
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_io_FileInputStream
|
||||
{
|
||||
public static void open0(object _this, string name, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.openReadOnly(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static int read0(object _this, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return fd.read();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static int readBytes(object _this, byte[] b, int off, int len, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return fd.readBytes(b, off, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static long skip(object _this, long n, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return fd.skip(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static int available(object _this, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return fd.available();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void close0(object _this, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.close();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void initIDs()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_io_FileOutputStream
|
||||
{
|
||||
public static void open0(object _this, string name, bool append, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
if (append)
|
||||
{
|
||||
fd.openAppend(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd.openWriteOnly(name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void write(object _this, int b, bool append, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.write(b);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void writeBytes(object _this, byte[] b, int off, int len, bool append, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.writeBytes(b, off, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void close0(object _this, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.close();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void initIDs()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_io_ObjectInputStream
|
||||
{
|
||||
public static void bytesToFloats(byte[] src, int srcpos, float[] dst, int dstpos, int nfloats)
|
||||
@@ -667,6 +766,98 @@ static class Java_java_io_ObjectStreamClass
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_io_RandomAccessFile
|
||||
{
|
||||
public static void open0(object _this, string name, int mode, [In] java.io.FileDescriptor fd, [In] int O_RDWR)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
if ((mode & O_RDWR) == O_RDWR)
|
||||
{
|
||||
fd.openReadWrite(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd.openReadOnly(name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static int read0(object _this, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return fd.read();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static int readBytes(object _this, byte[] b, int off, int len, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return fd.readBytes(b, off, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void write0(object _this, int b, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.write(b);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void writeBytes(object _this, byte[] b, int off, int len, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.writeBytes(b, off, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static long getFilePointer(object _this, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return fd.getFilePointer();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void seek0(object _this, long pos, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.seek(pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static long length(object _this, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
return fd.length();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setLength(object _this, long newLength, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.setLength(newLength);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void close0(object _this, [In] java.io.FileDescriptor fd)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
fd.close();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void initIDs()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_io_WinNTFileSystem
|
||||
{
|
||||
internal const int ACCESS_READ = 0x04;
|
||||
|
73
external/ikvm/runtime/openjdk/java.lang.cs
vendored
73
external/ikvm/runtime/openjdk/java.lang.cs
vendored
@@ -34,7 +34,7 @@ using IKVM.Internal;
|
||||
|
||||
static class Java_java_lang_Class
|
||||
{
|
||||
public static java.lang.Class forName0(string name, bool initialize, java.lang.ClassLoader loader)
|
||||
public static java.lang.Class forName0(string name, bool initialize, java.lang.ClassLoader loader, java.lang.Class caller)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
@@ -80,6 +80,11 @@ static class Java_java_lang_Class
|
||||
throw x.ToJava();
|
||||
}
|
||||
}
|
||||
java.security.ProtectionDomain pd;
|
||||
if (loader != null && caller != null && (pd = getProtectionDomain0(caller)) != null)
|
||||
{
|
||||
loader.checkPackageAccess(tw.ClassObject, pd);
|
||||
}
|
||||
if (initialize && !tw.IsArray)
|
||||
{
|
||||
try
|
||||
@@ -538,13 +543,14 @@ static class Java_java_lang_Class
|
||||
throw new ClassFormatError(wrapper.Name);
|
||||
}
|
||||
MethodWrapper[] methods = wrapper.GetMethods();
|
||||
List<java.lang.reflect.Method> list = new List<java.lang.reflect.Method>();
|
||||
List<java.lang.reflect.Method> list = new List<java.lang.reflect.Method>(methods.Length);
|
||||
for (int i = 0; i < methods.Length; i++)
|
||||
{
|
||||
// we don't want to expose "hideFromReflection" methods (one reason is that it would
|
||||
// mess up the serialVersionUID computation)
|
||||
if (!methods[i].IsHideFromReflection
|
||||
&& methods[i].Name != "<clinit>" && methods[i].Name != "<init>"
|
||||
&& !methods[i].IsConstructor
|
||||
&& !methods[i].IsClassInitializer
|
||||
&& (!publicOnly || methods[i].IsPublic))
|
||||
{
|
||||
list.Add((java.lang.reflect.Method)methods[i].ToMethodOrConstructor(false));
|
||||
@@ -590,7 +596,7 @@ static class Java_java_lang_Class
|
||||
// we don't want to expose "hideFromReflection" methods (one reason is that it would
|
||||
// mess up the serialVersionUID computation)
|
||||
if (!methods[i].IsHideFromReflection
|
||||
&& methods[i].Name == "<init>"
|
||||
&& methods[i].IsConstructor
|
||||
&& (!publicOnly || methods[i].IsPublic))
|
||||
{
|
||||
list.Add((java.lang.reflect.Constructor)methods[i].ToMethodOrConstructor(false));
|
||||
@@ -1168,6 +1174,65 @@ static class Java_java_lang_StrictMath
|
||||
|
||||
static class Java_java_lang_System
|
||||
{
|
||||
public static void registerNatives()
|
||||
{
|
||||
}
|
||||
|
||||
public static void setIn0(object @in)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
java.lang.StdIO.@in = (java.io.InputStream)@in;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setOut0(object @out)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
java.lang.StdIO.@out = (java.io.PrintStream)@out;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setErr0(object err)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
java.lang.StdIO.err = (java.io.PrintStream)err;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static object initProperties(object props)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
java.lang.VMSystemProperties.initProperties((java.util.Properties)props);
|
||||
return props;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string mapLibraryName(string libname)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
if (libname == null)
|
||||
{
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
if (ikvm.@internal.Util.WINDOWS)
|
||||
{
|
||||
return libname + ".dll";
|
||||
}
|
||||
else if (ikvm.@internal.Util.MACOSX)
|
||||
{
|
||||
return "lib" + libname + ".jnilib";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "lib" + libname + ".so";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void arraycopy(object src, int srcPos, object dest, int destPos, int length)
|
||||
{
|
||||
IKVM.Runtime.ByteCodeHelper.arraycopy(src, srcPos, dest, destPos, length);
|
||||
|
166
external/ikvm/runtime/openjdk/java.lang.invoke.cs
vendored
166
external/ikvm/runtime/openjdk/java.lang.invoke.cs
vendored
@@ -22,6 +22,7 @@
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
@@ -30,6 +31,26 @@ using IKVM.Internal;
|
||||
using java.lang.invoke;
|
||||
using jlClass = java.lang.Class;
|
||||
|
||||
static class Java_java_lang_invoke_DirectMethodHandle
|
||||
{
|
||||
// this is called from DirectMethodHandle.makeAllocator() via a map.xml prologue patch
|
||||
public static DirectMethodHandle makeStringAllocator(MemberName member)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
// we cannot construct strings via the standard two-pass approach (allocateObject followed by constructor invocation),
|
||||
// so we special case string construction here (to call our static factory method instead)
|
||||
if (member.getDeclaringClass() == CoreClasses.java.lang.String.Wrapper.ClassObject)
|
||||
{
|
||||
MethodType mt = member.getMethodType().changeReturnType(CoreClasses.java.lang.String.Wrapper.ClassObject);
|
||||
return new DirectMethodHandle(mt, DirectMethodHandle._preparedLambdaForm(mt, MethodTypeForm.LF_INVSTATIC), member, null);
|
||||
}
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_lang_invoke_MethodHandle
|
||||
{
|
||||
public static object invokeExact(MethodHandle thisObject, object[] args)
|
||||
@@ -76,36 +97,64 @@ static class Java_java_lang_invoke_MethodHandle
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_lang_invoke_MethodHandleNatives
|
||||
static class Java_java_lang_invoke_MethodHandleImpl
|
||||
{
|
||||
// called from Lookup.revealDirect() (instead of MethodHandle.internalMemberName()) via map.xml replace-method-call
|
||||
public static MemberName internalMemberName(MethodHandle mh)
|
||||
// hooked up via map.xml (as a replacement for makePairwiseConvertByEditor)
|
||||
public static MethodHandle makePairwiseConvert(MethodHandle target, MethodType srcType, bool strict, bool monobox)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
MemberName mn = mh.internalMemberName();
|
||||
if (mn.isStatic() && mn.getName() == "<init>")
|
||||
object[] convSpecs = MethodHandleImpl.computeValueConversions(srcType, target.type(), strict, monobox);
|
||||
List<LambdaForm.Name> names = new List<LambdaForm.Name>();
|
||||
names.Add(new LambdaForm.Name(0, LambdaForm.BasicType.L_TYPE));
|
||||
for (int i = 0; i < srcType.parameterCount(); i++)
|
||||
{
|
||||
// HACK since we convert String constructors into static methods, we have to undo that here
|
||||
// Note that the MemberName we return is only used for a security check and by InfoFromMemberName (a MethodHandleInfo implementation),
|
||||
// so we don't need to make it actually invokable.
|
||||
MemberName alt = new MemberName();
|
||||
typeof(MemberName).GetField("clazz", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(alt, mn.getDeclaringClass());
|
||||
typeof(MemberName).GetField("name", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(alt, mn.getName());
|
||||
typeof(MemberName).GetField("type", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(alt, mn.getMethodType().changeReturnType(typeof(void)));
|
||||
int flags = mn._flags();
|
||||
flags -= MethodHandleNatives.Constants.MN_IS_METHOD;
|
||||
flags += MethodHandleNatives.Constants.MN_IS_CONSTRUCTOR;
|
||||
flags &= ~(MethodHandleNatives.Constants.MN_REFERENCE_KIND_MASK << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT);
|
||||
flags |= MethodHandleNatives.Constants.REF_newInvokeSpecial << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT;
|
||||
flags &= ~MethodHandleNatives.Constants.ACC_STATIC;
|
||||
alt._flags(flags);
|
||||
return alt;
|
||||
names.Add(new LambdaForm.Name(i + 1, LambdaForm.BasicType.basicType(srcType.parameterType(i))));
|
||||
}
|
||||
return mn;
|
||||
LambdaForm.Name[] invokeArgs = new LambdaForm.Name[srcType.parameterCount()];
|
||||
for (int i = 0; i < invokeArgs.Length; i++)
|
||||
{
|
||||
object convSpec = convSpecs[i];
|
||||
if (convSpec == null)
|
||||
{
|
||||
invokeArgs[i] = names[i + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
LambdaForm.Name temp = new LambdaForm.Name(convSpec as MethodHandle ?? MethodHandleImpl.Lazy.MH_castReference.bindTo(convSpec), names[i + 1]);
|
||||
names.Add(temp);
|
||||
invokeArgs[i] = temp;
|
||||
}
|
||||
}
|
||||
names.Add(new LambdaForm.Name(target, invokeArgs));
|
||||
if (convSpecs[convSpecs.Length - 1] != null)
|
||||
{
|
||||
object convSpec = convSpecs[convSpecs.Length - 1];
|
||||
if (convSpec != java.lang.Void.TYPE)
|
||||
{
|
||||
names.Add(new LambdaForm.Name(convSpec as MethodHandle ?? MethodHandleImpl.Lazy.MH_castReference.bindTo(convSpec), names[names.Count - 1]));
|
||||
}
|
||||
}
|
||||
if (target.type().returnType() == java.lang.Void.TYPE && srcType.returnType() != java.lang.Void.TYPE)
|
||||
{
|
||||
names.Add(new LambdaForm.Name(LambdaForm.constantZero(LambdaForm.BasicType.basicType(srcType.returnType()))));
|
||||
}
|
||||
LambdaForm form = new LambdaForm("PairwiseConvert", srcType.parameterCount() + 1, names.ToArray(), srcType.returnType() == java.lang.Void.TYPE ? LambdaForm.VOID_RESULT : LambdaForm.LAST_RESULT, false);
|
||||
return new LightWeightMethodHandle(srcType, form);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_lang_invoke_MethodHandleNatives
|
||||
{
|
||||
// called from map.xml as a replacement for Class.isInstance() in java.lang.invoke.MethodHandleImpl.castReference()
|
||||
public static bool Class_isInstance(java.lang.Class clazz, object obj)
|
||||
{
|
||||
TypeWrapper tw = TypeWrapper.FromClass(clazz);
|
||||
// handle the type system hole that is caused by arrays being both derived from cli.System.Array and directly from java.lang.Object
|
||||
return tw.IsInstance(obj) || (tw == CoreClasses.cli.System.Object.Wrapper && obj is Array);
|
||||
}
|
||||
|
||||
public static void init(MemberName self, object refObj)
|
||||
{
|
||||
@@ -151,6 +200,10 @@ static class Java_java_lang_invoke_MethodHandleNatives
|
||||
{
|
||||
flags |= MethodHandleNatives.Constants.REF_invokeStatic << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT;
|
||||
}
|
||||
else if (mw.IsConstructor && !wantSpecial)
|
||||
{
|
||||
flags |= MethodHandleNatives.Constants.REF_newInvokeSpecial << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT;
|
||||
}
|
||||
else if (mw.IsPrivate || mw.IsFinal || mw.IsConstructor || wantSpecial)
|
||||
{
|
||||
flags |= MethodHandleNatives.Constants.REF_invokeSpecial << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT;
|
||||
@@ -174,16 +227,11 @@ static class Java_java_lang_invoke_MethodHandleNatives
|
||||
{
|
||||
parameters1[i] = mw.GetParameters()[i].ClassObject;
|
||||
}
|
||||
MethodType mt = MethodType.methodType(typeof(string), parameters1);
|
||||
typeof(MemberName).GetField("type", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(self, mt);
|
||||
self.vmtarget = CreateMemberNameDelegate(mw, null, false, mt);
|
||||
flags -= MethodHandleNatives.Constants.REF_invokeSpecial << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT;
|
||||
flags += MethodHandleNatives.Constants.REF_invokeStatic << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT;
|
||||
flags -= MethodHandleNatives.Constants.MN_IS_CONSTRUCTOR;
|
||||
flags += MethodHandleNatives.Constants.MN_IS_METHOD;
|
||||
flags += MethodHandleNatives.Constants.ACC_STATIC;
|
||||
MethodType mt = MethodType.methodType(PrimitiveTypeWrapper.VOID.ClassObject, parameters1);
|
||||
self._type(mt);
|
||||
self._flags(flags);
|
||||
self._clazz(mw.DeclaringType.ClassObject);
|
||||
self.vmtarget = CreateMemberNameDelegate(mw, null, false, self.getMethodType().changeReturnType(CoreClasses.java.lang.String.Wrapper.ClassObject));
|
||||
return;
|
||||
}
|
||||
self._flags(flags);
|
||||
@@ -311,8 +359,7 @@ static class Java_java_lang_invoke_MethodHandleNatives
|
||||
}
|
||||
if (mw.IsConstructor && mw.DeclaringType == CoreClasses.java.lang.String.Wrapper)
|
||||
{
|
||||
typeof(MemberName).GetField("type", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(self, self.getMethodType().changeReturnType(typeof(string)));
|
||||
self.vmtarget = CreateMemberNameDelegate(mw, caller, false, self.getMethodType());
|
||||
self.vmtarget = CreateMemberNameDelegate(mw, caller, false, self.getMethodType().changeReturnType(CoreClasses.java.lang.String.Wrapper.ClassObject));
|
||||
}
|
||||
else if (!mw.IsConstructor || invokeSpecial || newInvokeSpecial)
|
||||
{
|
||||
@@ -340,16 +387,6 @@ static class Java_java_lang_invoke_MethodHandleNatives
|
||||
{
|
||||
self._flags(self._flags() | MemberName.CALLER_SENSITIVE);
|
||||
}
|
||||
if (mw.IsConstructor && mw.DeclaringType == CoreClasses.java.lang.String.Wrapper)
|
||||
{
|
||||
int flags = self._flags();
|
||||
flags -= MethodHandleNatives.Constants.REF_invokeSpecial << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT;
|
||||
flags += MethodHandleNatives.Constants.REF_invokeStatic << MethodHandleNatives.Constants.MN_REFERENCE_KIND_SHIFT;
|
||||
flags -= MethodHandleNatives.Constants.MN_IS_CONSTRUCTOR;
|
||||
flags += MethodHandleNatives.Constants.MN_IS_METHOD;
|
||||
flags += MethodHandleNatives.Constants.ACC_STATIC;
|
||||
self._flags(flags);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ResolveField(MemberName self)
|
||||
@@ -470,7 +507,7 @@ static class Java_java_lang_invoke_MethodHandleNatives
|
||||
MethodWrapper[] methods = TypeWrapper.FromClass(defc).GetMethods();
|
||||
for (int i = skip, len = Math.Min(results.Length, methods.Length - skip); i < len; i++)
|
||||
{
|
||||
if (!methods[i].IsConstructor && methods[i].Name != StringConstants.CLINIT)
|
||||
if (!methods[i].IsConstructor && !methods[i].IsClassInitializer)
|
||||
{
|
||||
results[i - skip] = new MemberName((java.lang.reflect.Method)methods[i].ToMethodOrConstructor(true), false);
|
||||
}
|
||||
@@ -608,7 +645,7 @@ static partial class MethodHandleUtil
|
||||
return args;
|
||||
}
|
||||
|
||||
private static Type[] GetParameterTypes(Type thisType, MethodBase mb)
|
||||
internal static Type[] GetParameterTypes(Type thisType, MethodBase mb)
|
||||
{
|
||||
ParameterInfo[] pi = mb.GetParameters();
|
||||
Type[] args = new Type[pi.Length + 1];
|
||||
@@ -1027,25 +1064,7 @@ static partial class MethodHandleUtil
|
||||
|
||||
internal void Ldarg(int i)
|
||||
{
|
||||
i += firstArg;
|
||||
if (i >= packedArgPos)
|
||||
{
|
||||
ilgen.EmitLdarga(packedArgPos);
|
||||
int fieldPos = i - packedArgPos;
|
||||
Type type = packedArgType;
|
||||
while (fieldPos >= MaxArity || (fieldPos == MaxArity - 1 && IsPackedArgsContainer(type.GetField("t8").FieldType)))
|
||||
{
|
||||
FieldInfo field = type.GetField("t8");
|
||||
type = field.FieldType;
|
||||
ilgen.Emit(OpCodes.Ldflda, field);
|
||||
fieldPos -= MaxArity - 1;
|
||||
}
|
||||
ilgen.Emit(OpCodes.Ldfld, type.GetField("t" + (1 + fieldPos)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ilgen.EmitLdarg(i);
|
||||
}
|
||||
LoadPackedArg(ilgen, i, firstArg, packedArgPos, packedArgType);
|
||||
}
|
||||
|
||||
internal void LoadCallerID()
|
||||
@@ -1232,5 +1251,28 @@ static partial class MethodHandleUtil
|
||||
}
|
||||
return type.voidAdapter;
|
||||
}
|
||||
|
||||
internal static void LoadPackedArg(CodeEmitter ilgen, int index, int firstArg, int packedArgPos, Type packedArgType)
|
||||
{
|
||||
index += firstArg;
|
||||
if (index >= packedArgPos)
|
||||
{
|
||||
ilgen.EmitLdarga(packedArgPos);
|
||||
int fieldPos = index - packedArgPos;
|
||||
Type type = packedArgType;
|
||||
while (fieldPos >= MaxArity || (fieldPos == MaxArity - 1 && IsPackedArgsContainer(type.GetField("t8").FieldType)))
|
||||
{
|
||||
FieldInfo field = type.GetField("t8");
|
||||
type = field.FieldType;
|
||||
ilgen.Emit(OpCodes.Ldflda, field);
|
||||
fieldPos -= MaxArity - 1;
|
||||
}
|
||||
ilgen.Emit(OpCodes.Ldfld, type.GetField("t" + (1 + fieldPos)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ilgen.EmitLdarg(index);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
216
external/ikvm/runtime/openjdk/java.net.SocketInputStream.cs
vendored
Normal file
216
external/ikvm/runtime/openjdk/java.net.SocketInputStream.cs
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 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.
|
||||
*/
|
||||
#if !FIRST_PASS
|
||||
using Winsock = ikvm.@internal.Winsock;
|
||||
using java.net;
|
||||
#endif
|
||||
|
||||
static class Java_java_net_SocketInputStream
|
||||
{
|
||||
public static int socketRead0(object _this, java.io.FileDescriptor fd, byte[] b, int off, int len, int timeout)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
// [IKVM] this method is a direct port of the native code in openjdk6-b18\jdk\src\windows\native\java\net\SocketInputStream.c
|
||||
System.Net.Sockets.Socket socket = null;
|
||||
int nread;
|
||||
|
||||
if (fd == null)
|
||||
{
|
||||
throw new SocketException("socket closed");
|
||||
}
|
||||
socket = fd.getSocket();
|
||||
if (socket == null)
|
||||
{
|
||||
throw new SocketException("Socket closed");
|
||||
}
|
||||
|
||||
if (timeout != 0)
|
||||
{
|
||||
if (timeout <= 5000 || !net_util_md.isRcvTimeoutSupported)
|
||||
{
|
||||
int ret = net_util_md.NET_Timeout(socket, timeout);
|
||||
|
||||
if (ret <= 0)
|
||||
{
|
||||
if (ret == 0)
|
||||
{
|
||||
throw new SocketTimeoutException("Read timed out");
|
||||
}
|
||||
else
|
||||
{
|
||||
// [IKVM] the OpenJDK native code is broken and always throws this exception on any failure of NET_Timeout
|
||||
throw new SocketException("socket closed");
|
||||
}
|
||||
}
|
||||
|
||||
/*check if the socket has been closed while we were in timeout*/
|
||||
if (fd.getSocket() == null)
|
||||
{
|
||||
throw new SocketException("Socket Closed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nread = Winsock.recv(socket, b, off, len, 0);
|
||||
if (nread > 0)
|
||||
{
|
||||
// ok
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nread < 0)
|
||||
{
|
||||
/*
|
||||
* Recv failed.
|
||||
*/
|
||||
switch (Winsock.WSAGetLastError())
|
||||
{
|
||||
case Winsock.WSAEINTR:
|
||||
throw new SocketException("socket closed");
|
||||
|
||||
case Winsock.WSAECONNRESET:
|
||||
case Winsock.WSAESHUTDOWN:
|
||||
/*
|
||||
* Connection has been reset - Windows sometimes reports
|
||||
* the reset as a shutdown error.
|
||||
*/
|
||||
throw new sun.net.ConnectionResetException();
|
||||
|
||||
case Winsock.WSAETIMEDOUT:
|
||||
throw new SocketTimeoutException("Read timed out");
|
||||
|
||||
default:
|
||||
throw net_util_md.NET_ThrowCurrent("recv failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
return nread;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_net_SocketOutputStream
|
||||
{
|
||||
public static void socketWrite0(object _this, java.io.FileDescriptor fd, byte[] data, int off, int len)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
// [IKVM] this method is a direct port of the native code in openjdk6-b18\jdk\src\windows\native\java\net\SocketOutputStream.c
|
||||
const int MAX_BUFFER_LEN = 2048;
|
||||
System.Net.Sockets.Socket socket;
|
||||
int buflen = 65536; // MAX_HEAP_BUFFER_LEN
|
||||
int n;
|
||||
|
||||
if (fd == null)
|
||||
{
|
||||
throw new SocketException("socket closed");
|
||||
}
|
||||
else
|
||||
{
|
||||
socket = fd.getSocket();
|
||||
}
|
||||
if (data == null)
|
||||
{
|
||||
throw new java.lang.NullPointerException("data argument");
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
int loff = 0;
|
||||
int chunkLen = java.lang.Math.min(buflen, len);
|
||||
int llen = chunkLen;
|
||||
int retry = 0;
|
||||
|
||||
while (llen > 0)
|
||||
{
|
||||
n = Winsock.send(socket, data, off + loff, llen, 0);
|
||||
if (n > 0)
|
||||
{
|
||||
llen -= n;
|
||||
loff += n;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Due to a bug in Windows Sockets (observed on NT and Windows
|
||||
* 2000) it may be necessary to retry the send. The issue is that
|
||||
* on blocking sockets send/WSASend is supposed to block if there
|
||||
* is insufficient buffer space available. If there are a large
|
||||
* number of threads blocked on write due to congestion then it's
|
||||
* possile to hit the NT/2000 bug whereby send returns WSAENOBUFS.
|
||||
* The workaround we use is to retry the send. If we have a
|
||||
* large buffer to send (>2k) then we retry with a maximum of
|
||||
* 2k buffer. If we hit the issue with <=2k buffer then we backoff
|
||||
* for 1 second and retry again. We repeat this up to a reasonable
|
||||
* limit before bailing out and throwing an exception. In load
|
||||
* conditions we've observed that the send will succeed after 2-3
|
||||
* attempts but this depends on network buffers associated with
|
||||
* other sockets draining.
|
||||
*/
|
||||
if (Winsock.WSAGetLastError() == Winsock.WSAENOBUFS)
|
||||
{
|
||||
if (llen > MAX_BUFFER_LEN)
|
||||
{
|
||||
buflen = MAX_BUFFER_LEN;
|
||||
chunkLen = MAX_BUFFER_LEN;
|
||||
llen = MAX_BUFFER_LEN;
|
||||
continue;
|
||||
}
|
||||
if (retry >= 30)
|
||||
{
|
||||
throw new SocketException("No buffer space available - exhausted attempts to queue buffer");
|
||||
}
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
retry++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send failed - can be caused by close or write error.
|
||||
*/
|
||||
if (Winsock.WSAGetLastError() == Winsock.WSAENOTSOCK)
|
||||
{
|
||||
throw new SocketException("Socket closed");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw net_util_md.NET_ThrowCurrent("socket write error");
|
||||
}
|
||||
}
|
||||
len -= chunkLen;
|
||||
off += chunkLen;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
}
|
||||
}
|
43
external/ikvm/runtime/openjdk/java.net.cs
vendored
43
external/ikvm/runtime/openjdk/java.net.cs
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2007-2013 Jeroen Frijters
|
||||
Copyright (C) 2007-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
|
||||
@@ -28,6 +28,36 @@ using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Security;
|
||||
|
||||
static class Java_java_net_AbstractPlainDatagramSocketImpl
|
||||
{
|
||||
public static void init()
|
||||
{
|
||||
}
|
||||
|
||||
public static int dataAvailable(object _this)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
try
|
||||
{
|
||||
java.net.AbstractPlainDatagramSocketImpl obj = (java.net.AbstractPlainDatagramSocketImpl)_this;
|
||||
if (obj.fd != null)
|
||||
{
|
||||
return obj.fd.getSocket().Available;
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
}
|
||||
throw new java.net.SocketException("Socket closed");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_net_DatagramPacket
|
||||
{
|
||||
public static void init()
|
||||
@@ -436,6 +466,7 @@ static class Java_java_net_NetworkInterface
|
||||
int lo = 0;
|
||||
int ppp = 0;
|
||||
int sl = 0;
|
||||
int wlan = 0;
|
||||
int net = 0;
|
||||
for (int i = 0; i < ifaces.Length; i++)
|
||||
{
|
||||
@@ -465,6 +496,9 @@ static class Java_java_net_NetworkInterface
|
||||
case NetworkInterfaceType.Slip:
|
||||
name = "sl" + sl++;
|
||||
break;
|
||||
case NetworkInterfaceType.Wireless80211:
|
||||
name = "wlan" + wlan++;
|
||||
break;
|
||||
default:
|
||||
name = "net" + net++;
|
||||
break;
|
||||
@@ -480,6 +514,13 @@ static class Java_java_net_NetworkInterface
|
||||
IPAddress addr = uipaic[j].Address;
|
||||
if (addr.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
if (ifaces[i].OperationalStatus != OperationalStatus.Up)
|
||||
{
|
||||
// HACK on Windows, OpenJDK seems to only return IPv4 addresses for interfaces that are up.
|
||||
// This is possibly the result of their usage of the (legacy) Win32 API GetIpAddrTable.
|
||||
// Not doing this filtering causes some OpenJDK tests to fail.
|
||||
continue;
|
||||
}
|
||||
java.net.Inet4Address address = new java.net.Inet4Address(null, addr.GetAddressBytes());
|
||||
java.net.InterfaceAddress binding = new java.net.InterfaceAddress();
|
||||
short mask = 32;
|
||||
|
339
external/ikvm/runtime/openjdk/java.util.cs
vendored
Normal file
339
external/ikvm/runtime/openjdk/java.util.cs
vendored
Normal file
@@ -0,0 +1,339 @@
|
||||
/*
|
||||
Copyright (C) 2007-2013 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
|
||||
|
||||
*/
|
||||
using System;
|
||||
|
||||
static class Java_java_util_TimeZone
|
||||
{
|
||||
private static string GetCurrentTimeZoneID()
|
||||
{
|
||||
#if NET_4_0
|
||||
return TimeZoneInfo.Local.Id;
|
||||
#else
|
||||
// we don't want a static dependency on System.Core (to be able to run on .NET 2.0)
|
||||
Type typeofTimeZoneInfo = Type.GetType("System.TimeZoneInfo, System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
|
||||
if (typeofTimeZoneInfo != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (string)typeofTimeZoneInfo.GetProperty("Id").GetValue(typeofTimeZoneInfo.GetProperty("Local").GetValue(null, null), null);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
// older Mono versions did not wrap the exception in a TargetInvocationExcception,
|
||||
// so we check both x and x.InnerException
|
||||
if (typeofTimeZoneInfo.Assembly.GetType("System.TimeZoneNotFoundException").IsInstanceOfType(x)
|
||||
|| typeofTimeZoneInfo.Assembly.GetType("System.TimeZoneNotFoundException").IsInstanceOfType(x.InnerException))
|
||||
{
|
||||
// MONOBUG Mono's TimeZoneInfo.Local property throws a TimeZoneNotFoundException on Windows
|
||||
// (https://bugzilla.novell.com/show_bug.cgi?id=622524)
|
||||
return TimeZone.CurrentTimeZone.StandardName;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// HACK this is very lame and probably won't work on localized windows versions
|
||||
return TimeZone.CurrentTimeZone.StandardName;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string getSystemTimeZoneID(string javaHome)
|
||||
{
|
||||
// (the switch was generated from the contents of $JAVA_HOME/lib/tzmappings)
|
||||
switch (GetCurrentTimeZoneID())
|
||||
{
|
||||
case "Romance":
|
||||
case "Romance Standard Time":
|
||||
return "Europe/Paris";
|
||||
case "Warsaw":
|
||||
return "Europe/Warsaw";
|
||||
case "Central Europe":
|
||||
case "Central Europe Standard Time":
|
||||
case "Prague Bratislava":
|
||||
return "Europe/Prague";
|
||||
case "W. Central Africa Standard Time":
|
||||
return "Africa/Luanda";
|
||||
case "FLE":
|
||||
case "FLE Standard Time":
|
||||
return "Europe/Helsinki";
|
||||
case "GFT":
|
||||
case "GFT Standard Time":
|
||||
case "GTB":
|
||||
case "GTB Standard Time":
|
||||
return "Europe/Athens";
|
||||
case "Israel":
|
||||
case "Israel Standard Time":
|
||||
return "Asia/Jerusalem";
|
||||
case "Arab":
|
||||
case "Arab Standard Time":
|
||||
return "Asia/Riyadh";
|
||||
case "Arabic Standard Time":
|
||||
return "Asia/Baghdad";
|
||||
case "E. Africa":
|
||||
case "E. Africa Standard Time":
|
||||
return "Africa/Nairobi";
|
||||
case "Saudi Arabia":
|
||||
case "Saudi Arabia Standard Time":
|
||||
return "Asia/Riyadh";
|
||||
case "Iran":
|
||||
case "Iran Standard Time":
|
||||
return "Asia/Tehran";
|
||||
case "Afghanistan":
|
||||
case "Afghanistan Standard Time":
|
||||
return "Asia/Kabul";
|
||||
case "India":
|
||||
case "India Standard Time":
|
||||
return "Asia/Calcutta";
|
||||
case "Myanmar Standard Time":
|
||||
return "Asia/Rangoon";
|
||||
case "Nepal Standard Time":
|
||||
return "Asia/Katmandu";
|
||||
case "Sri Lanka":
|
||||
case "Sri Lanka Standard Time":
|
||||
return "Asia/Colombo";
|
||||
case "Beijing":
|
||||
case "China":
|
||||
case "China Standard Time":
|
||||
return "Asia/Shanghai";
|
||||
case "AUS Central":
|
||||
case "AUS Central Standard Time":
|
||||
return "Australia/Darwin";
|
||||
case "Cen. Australia":
|
||||
case "Cen. Australia Standard Time":
|
||||
return "Australia/Adelaide";
|
||||
case "Vladivostok":
|
||||
case "Vladivostok Standard Time":
|
||||
return "Asia/Vladivostok";
|
||||
case "West Pacific":
|
||||
case "West Pacific Standard Time":
|
||||
return "Pacific/Guam";
|
||||
case "E. South America":
|
||||
case "E. South America Standard Time":
|
||||
return "America/Sao_Paulo";
|
||||
case "Greenland Standard Time":
|
||||
return "America/Godthab";
|
||||
case "Newfoundland":
|
||||
case "Newfoundland Standard Time":
|
||||
return "America/St_Johns";
|
||||
case "Pacific SA":
|
||||
case "Pacific SA Standard Time":
|
||||
return "America/Santiago";
|
||||
case "SA Western":
|
||||
case "SA Western Standard Time":
|
||||
return "America/Caracas";
|
||||
case "SA Pacific":
|
||||
case "SA Pacific Standard Time":
|
||||
return "America/Bogota";
|
||||
case "US Eastern":
|
||||
case "US Eastern Standard Time":
|
||||
return "America/Indianapolis";
|
||||
case "Central America Standard Time":
|
||||
return "America/Regina";
|
||||
case "Mexico":
|
||||
case "Mexico Standard Time":
|
||||
return "America/Mexico_City";
|
||||
case "Canada Central":
|
||||
case "Canada Central Standard Time":
|
||||
return "America/Regina";
|
||||
case "US Mountain":
|
||||
case "US Mountain Standard Time":
|
||||
return "America/Phoenix";
|
||||
case "GMT":
|
||||
case "GMT Standard Time":
|
||||
return "Europe/London";
|
||||
case "Ekaterinburg":
|
||||
case "Ekaterinburg Standard Time":
|
||||
return "Asia/Yekaterinburg";
|
||||
case "West Asia":
|
||||
case "West Asia Standard Time":
|
||||
return "Asia/Karachi";
|
||||
case "Central Asia":
|
||||
case "Central Asia Standard Time":
|
||||
return "Asia/Dhaka";
|
||||
case "N. Central Asia Standard Time":
|
||||
return "Asia/Novosibirsk";
|
||||
case "Bangkok":
|
||||
case "Bangkok Standard Time":
|
||||
return "Asia/Bangkok";
|
||||
case "North Asia Standard Time":
|
||||
return "Asia/Krasnoyarsk";
|
||||
case "SE Asia":
|
||||
case "SE Asia Standard Time":
|
||||
return "Asia/Bangkok";
|
||||
case "North Asia East Standard Time":
|
||||
return "Asia/Ulaanbaatar";
|
||||
case "Singapore":
|
||||
case "Singapore Standard Time":
|
||||
return "Asia/Singapore";
|
||||
case "Taipei":
|
||||
case "Taipei Standard Time":
|
||||
return "Asia/Taipei";
|
||||
case "W. Australia":
|
||||
case "W. Australia Standard Time":
|
||||
return "Australia/Perth";
|
||||
case "Korea":
|
||||
case "Korea Standard Time":
|
||||
return "Asia/Seoul";
|
||||
case "Tokyo":
|
||||
case "Tokyo Standard Time":
|
||||
return "Asia/Tokyo";
|
||||
case "Yakutsk":
|
||||
case "Yakutsk Standard Time":
|
||||
return "Asia/Yakutsk";
|
||||
case "Central European":
|
||||
case "Central European Standard Time":
|
||||
return "Europe/Belgrade";
|
||||
case "W. Europe":
|
||||
case "W. Europe Standard Time":
|
||||
return "Europe/Berlin";
|
||||
case "Tasmania":
|
||||
case "Tasmania Standard Time":
|
||||
return "Australia/Hobart";
|
||||
case "AUS Eastern":
|
||||
case "AUS Eastern Standard Time":
|
||||
return "Australia/Sydney";
|
||||
case "E. Australia":
|
||||
case "E. Australia Standard Time":
|
||||
return "Australia/Brisbane";
|
||||
case "Sydney Standard Time":
|
||||
return "Australia/Sydney";
|
||||
case "Central Pacific":
|
||||
case "Central Pacific Standard Time":
|
||||
return "Pacific/Guadalcanal";
|
||||
case "Dateline":
|
||||
case "Dateline Standard Time":
|
||||
return "GMT-1200";
|
||||
case "Fiji":
|
||||
case "Fiji Standard Time":
|
||||
return "Pacific/Fiji";
|
||||
case "Samoa":
|
||||
case "Samoa Standard Time":
|
||||
return "Pacific/Apia";
|
||||
case "Hawaiian":
|
||||
case "Hawaiian Standard Time":
|
||||
return "Pacific/Honolulu";
|
||||
case "Alaskan":
|
||||
case "Alaskan Standard Time":
|
||||
return "America/Anchorage";
|
||||
case "Pacific":
|
||||
case "Pacific Standard Time":
|
||||
return "America/Los_Angeles";
|
||||
case "Mexico Standard Time 2":
|
||||
return "America/Chihuahua";
|
||||
case "Mountain":
|
||||
case "Mountain Standard Time":
|
||||
return "America/Denver";
|
||||
case "Central":
|
||||
case "Central Standard Time":
|
||||
return "America/Chicago";
|
||||
case "Eastern":
|
||||
case "Eastern Standard Time":
|
||||
return "America/New_York";
|
||||
case "E. Europe":
|
||||
case "E. Europe Standard Time":
|
||||
return "Europe/Minsk";
|
||||
case "Egypt":
|
||||
case "Egypt Standard Time":
|
||||
return "Africa/Cairo";
|
||||
case "South Africa":
|
||||
case "South Africa Standard Time":
|
||||
return "Africa/Harare";
|
||||
case "Atlantic":
|
||||
case "Atlantic Standard Time":
|
||||
return "America/Halifax";
|
||||
case "SA Eastern":
|
||||
case "SA Eastern Standard Time":
|
||||
return "America/Buenos_Aires";
|
||||
case "Mid-Atlantic":
|
||||
case "Mid-Atlantic Standard Time":
|
||||
return "Atlantic/South_Georgia";
|
||||
case "Azores":
|
||||
case "Azores Standard Time":
|
||||
return "Atlantic/Azores";
|
||||
case "Cape Verde Standard Time":
|
||||
return "Atlantic/Cape_Verde";
|
||||
case "Russian":
|
||||
case "Russian Standard Time":
|
||||
return "Europe/Moscow";
|
||||
case "New Zealand":
|
||||
case "New Zealand Standard Time":
|
||||
return "Pacific/Auckland";
|
||||
case "Tonga Standard Time":
|
||||
return "Pacific/Tongatapu";
|
||||
case "Arabian":
|
||||
case "Arabian Standard Time":
|
||||
return "Asia/Muscat";
|
||||
case "Caucasus":
|
||||
case "Caucasus Standard Time":
|
||||
return "Asia/Yerevan";
|
||||
case "Greenwich":
|
||||
case "Greenwich Standard Time":
|
||||
return "GMT";
|
||||
case "Central Brazilian Standard Time":
|
||||
return "America/Manaus";
|
||||
case "Central Standard Time (Mexico)":
|
||||
return "America/Mexico_City";
|
||||
case "Georgian Standard Time":
|
||||
return "Asia/Tbilisi";
|
||||
case "Mountain Standard Time (Mexico)":
|
||||
return "America/Chihuahua";
|
||||
case "Namibia Standard Time":
|
||||
return "Africa/Windhoek";
|
||||
case "Pacific Standard Time (Mexico)":
|
||||
return "America/Tijuana";
|
||||
case "Western Brazilian Standard Time":
|
||||
return "America/Rio_Branco";
|
||||
case "Azerbaijan Standard Time":
|
||||
return "Asia/Baku";
|
||||
case "Jordan Standard Time":
|
||||
return "Asia/Amman";
|
||||
case "Middle East Standard Time":
|
||||
return "Asia/Beirut";
|
||||
default:
|
||||
// this means fall back to GMT offset
|
||||
return getSystemGMTOffsetID();
|
||||
}
|
||||
}
|
||||
|
||||
public static string getSystemGMTOffsetID()
|
||||
{
|
||||
TimeSpan sp = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
|
||||
int hours = sp.Hours;
|
||||
int mins = sp.Minutes;
|
||||
if (hours >= 0 && mins >= 0)
|
||||
{
|
||||
return String.Format("GMT+{0:D2}:{1:D2}", hours, mins);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format("GMT-{0:D2}:{1:D2}", -hours, -mins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
359
external/ikvm/runtime/openjdk/java.util.prefs.cs
vendored
Normal file
359
external/ikvm/runtime/openjdk/java.util.prefs.cs
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
Copyright (C) 2007-2013 Jeroen Frijters
|
||||
Copyright (C) 2009 Volker Berlin (i-net software)
|
||||
|
||||
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
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
|
||||
static class Java_java_util_prefs_FileSystemPreferences
|
||||
{
|
||||
public static int chmod(string filename, int permission)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int[] lockFile0(string filename, int permission, bool shared)
|
||||
{
|
||||
// TODO
|
||||
return new int[] { 1, 0 };
|
||||
}
|
||||
|
||||
public static int unlockFile0(int fd)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_java_util_prefs_WindowsPreferences
|
||||
{
|
||||
// HACK we currently support only 16 handles at a time
|
||||
private static readonly Microsoft.Win32.RegistryKey[] keys = new Microsoft.Win32.RegistryKey[16];
|
||||
|
||||
private static Microsoft.Win32.RegistryKey MapKey(int hKey)
|
||||
{
|
||||
switch (hKey)
|
||||
{
|
||||
case unchecked((int)0x80000001):
|
||||
return Microsoft.Win32.Registry.CurrentUser;
|
||||
case unchecked((int)0x80000002):
|
||||
return Microsoft.Win32.Registry.LocalMachine;
|
||||
default:
|
||||
return keys[hKey - 1];
|
||||
}
|
||||
}
|
||||
|
||||
private static int AllocHandle(Microsoft.Win32.RegistryKey key)
|
||||
{
|
||||
lock (keys)
|
||||
{
|
||||
if (key != null)
|
||||
{
|
||||
for (int i = 0; i < keys.Length; i++)
|
||||
{
|
||||
if (keys[i] == null)
|
||||
{
|
||||
keys[i] = key;
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static string BytesToString(byte[] bytes)
|
||||
{
|
||||
int len = bytes.Length;
|
||||
if (bytes[len - 1] == 0)
|
||||
{
|
||||
len--;
|
||||
}
|
||||
return Encoding.ASCII.GetString(bytes, 0, len);
|
||||
}
|
||||
|
||||
private static byte[] StringToBytes(string str)
|
||||
{
|
||||
if (str.Length == 0 || str[str.Length - 1] != 0)
|
||||
{
|
||||
str += '\u0000';
|
||||
}
|
||||
return Encoding.ASCII.GetBytes(str);
|
||||
}
|
||||
|
||||
public static int[] WindowsRegOpenKey(int hKey, byte[] subKey, int securityMask)
|
||||
{
|
||||
// writeable = DELETE == 0x10000 || KEY_SET_VALUE == 2 || KEY_CREATE_SUB_KEY == 4 || KEY_WRITE = 0x20006;
|
||||
// !writeable : KEY_ENUMERATE_SUB_KEYS == 8 || KEY_READ == 0x20019 || KEY_QUERY_VALUE == 1
|
||||
bool writable = (securityMask & 0x10006) != 0;
|
||||
Microsoft.Win32.RegistryKey resultKey = null;
|
||||
int error = 0;
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.RegistryKey parent = MapKey(hKey);
|
||||
// HACK we check if we can write in the system preferences
|
||||
// we want not user registry virtualization for compatibility
|
||||
if (writable && parent.Name.StartsWith("HKEY_LOCAL_MACHINE", StringComparison.Ordinal) && UACVirtualization.Enabled)
|
||||
{
|
||||
resultKey = parent.OpenSubKey(BytesToString(subKey), false);
|
||||
if (resultKey != null)
|
||||
{
|
||||
// error only if key exists
|
||||
resultKey.Close();
|
||||
error = 5;
|
||||
resultKey = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resultKey = parent.OpenSubKey(BytesToString(subKey), writable);
|
||||
}
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
error = 5;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
error = 5;
|
||||
}
|
||||
return new int[] { AllocHandle(resultKey), error };
|
||||
}
|
||||
|
||||
public static int WindowsRegCloseKey(int hKey)
|
||||
{
|
||||
keys[hKey - 1].Close();
|
||||
lock (keys)
|
||||
{
|
||||
keys[hKey - 1] = null;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int[] WindowsRegCreateKeyEx(int hKey, byte[] subKey)
|
||||
{
|
||||
Microsoft.Win32.RegistryKey resultKey = null;
|
||||
int error = 0;
|
||||
int disposition = -1;
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.RegistryKey key = MapKey(hKey);
|
||||
string name = BytesToString(subKey);
|
||||
resultKey = key.OpenSubKey(name);
|
||||
disposition = 2;
|
||||
if (resultKey == null)
|
||||
{
|
||||
resultKey = key.CreateSubKey(name);
|
||||
disposition = 1;
|
||||
}
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
error = 5;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
error = 5;
|
||||
}
|
||||
return new int[] { AllocHandle(resultKey), error, disposition };
|
||||
}
|
||||
|
||||
public static int WindowsRegDeleteKey(int hKey, byte[] subKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
MapKey(hKey).DeleteSubKey(BytesToString(subKey), false);
|
||||
return 0;
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
public static int WindowsRegFlushKey(int hKey)
|
||||
{
|
||||
MapKey(hKey).Flush();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static byte[] WindowsRegQueryValueEx(int hKey, byte[] valueName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string value = MapKey(hKey).GetValue(BytesToString(valueName)) as string;
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return StringToBytes(value);
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int WindowsRegSetValueEx(int hKey, byte[] valueName, byte[] data)
|
||||
{
|
||||
if (valueName == null || data == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
try
|
||||
{
|
||||
MapKey(hKey).SetValue(BytesToString(valueName), BytesToString(data));
|
||||
return 0;
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
public static int WindowsRegDeleteValue(int hKey, byte[] valueName)
|
||||
{
|
||||
try
|
||||
{
|
||||
MapKey(hKey).DeleteValue(BytesToString(valueName));
|
||||
return 0;
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
return 2; //ERROR_FILE_NOT_FOUND
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
return 5; //ERROR_ACCESS_DENIED
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return 5; //ERROR_ACCESS_DENIED
|
||||
}
|
||||
}
|
||||
|
||||
public static int[] WindowsRegQueryInfoKey(int hKey)
|
||||
{
|
||||
int[] result = new int[5] { -1, -1, -1, -1, -1 };
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.RegistryKey key = MapKey(hKey);
|
||||
result[0] = key.SubKeyCount;
|
||||
result[1] = 0;
|
||||
result[2] = key.ValueCount;
|
||||
foreach (string s in key.GetSubKeyNames())
|
||||
{
|
||||
result[3] = Math.Max(result[3], s.Length);
|
||||
}
|
||||
foreach (string s in key.GetValueNames())
|
||||
{
|
||||
result[4] = Math.Max(result[4], s.Length);
|
||||
}
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
result[1] = 5;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
result[1] = 5;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static byte[] WindowsRegEnumKeyEx(int hKey, int subKeyIndex, int maxKeyLength)
|
||||
{
|
||||
try
|
||||
{
|
||||
return StringToBytes(MapKey(hKey).GetSubKeyNames()[subKeyIndex]);
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] WindowsRegEnumValue(int hKey, int valueIndex, int maxValueNameLength)
|
||||
{
|
||||
try
|
||||
{
|
||||
return StringToBytes(MapKey(hKey).GetValueNames()[valueIndex]);
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class UACVirtualization
|
||||
{
|
||||
private enum TOKEN_INFORMATION_CLASS
|
||||
{
|
||||
TokenVirtualizationEnabled = 24
|
||||
}
|
||||
|
||||
[DllImport("advapi32.dll")]
|
||||
private static extern int GetTokenInformation(
|
||||
IntPtr TokenHandle,
|
||||
TOKEN_INFORMATION_CLASS TokenInformationClass,
|
||||
out int TokenInformation,
|
||||
int TokenInformationLength,
|
||||
out int ReturnLength);
|
||||
|
||||
internal static bool Enabled
|
||||
{
|
||||
[SecuritySafeCritical]
|
||||
get
|
||||
{
|
||||
OperatingSystem os = Environment.OSVersion;
|
||||
if (os.Platform != PlatformID.Win32NT || os.Version.Major < 6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int enabled, length;
|
||||
return GetTokenInformation(WindowsIdentity.GetCurrent().Token, TOKEN_INFORMATION_CLASS.TokenVirtualizationEnabled, out enabled, 4, out length) != 0
|
||||
&& enabled != 0;
|
||||
}
|
||||
}
|
||||
}
|
61
external/ikvm/runtime/openjdk/misc.cs
vendored
61
external/ikvm/runtime/openjdk/misc.cs
vendored
@@ -197,17 +197,6 @@ static class Java_sun_invoke_anon_AnonymousClassLoader
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_sun_invoke_util_ValueConversions
|
||||
{
|
||||
// called from map.xml as a replacement for Class.isInstance() in sun.invoke.util.ValueConversions.castReference()
|
||||
public static bool Class_isInstance(java.lang.Class clazz, object obj)
|
||||
{
|
||||
TypeWrapper tw = TypeWrapper.FromClass(clazz);
|
||||
// handle the type system hole that is caused by arrays being both derived from cli.System.Array and directly from java.lang.Object
|
||||
return tw.IsInstance(obj) || (tw == CoreClasses.cli.System.Object.Wrapper && obj is Array);
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_sun_invoke_util_VerifyAccess
|
||||
{
|
||||
// called from map.xml as a replacement for Class.getClassLoader() in sun.invoke.util.VerifyAccess.isTypeVisible()
|
||||
@@ -311,6 +300,9 @@ static class Java_sun_security_provider_NativeSeedGenerator
|
||||
{
|
||||
RNGCryptoServiceProvider csp = new RNGCryptoServiceProvider();
|
||||
csp.GetBytes(result);
|
||||
#if NET_4_0
|
||||
csp.Dispose();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
catch (CryptographicException)
|
||||
@@ -359,27 +351,22 @@ static class Java_com_sun_java_util_jar_pack_NativeUnpack
|
||||
|
||||
static class Java_com_sun_security_auth_module_NTSystem
|
||||
{
|
||||
public static void getCurrent(object thisObj, bool debug)
|
||||
public static void getCurrent(object thisObj, bool debug, ref string userName, ref string domain, ref string domainSID, ref string userSID, ref string[] groupIDs, ref string primaryGroupID)
|
||||
{
|
||||
WindowsIdentity id = WindowsIdentity.GetCurrent();
|
||||
string[] name = id.Name.Split('\\');
|
||||
SetField(thisObj, "userName", name[1]);
|
||||
SetField(thisObj, "domain", name[0]);
|
||||
SetField(thisObj, "domainSID", id.User.AccountDomainSid.Value);
|
||||
SetField(thisObj, "userSID", id.User.Value);
|
||||
userName = name[1];
|
||||
domain = name[0];
|
||||
domainSID = id.User.AccountDomainSid.Value;
|
||||
userSID = id.User.Value;
|
||||
string[] groups = new string[id.Groups.Count];
|
||||
for (int i = 0; i < groups.Length; i++)
|
||||
{
|
||||
groups[i] = id.Groups[i].Value;
|
||||
}
|
||||
SetField(thisObj, "groupIDs", groups);
|
||||
groupIDs = groups;
|
||||
// HACK it turns out that Groups[0] is the primary group, but AFAIK this is not documented anywhere
|
||||
SetField(thisObj, "primaryGroupID", groups[0]);
|
||||
}
|
||||
|
||||
private static void SetField(object thisObj, string field, object value)
|
||||
{
|
||||
thisObj.GetType().GetField(field, BindingFlags.NonPublic | BindingFlags.Instance).SetValue(thisObj, value);
|
||||
primaryGroupID = groups[0];
|
||||
}
|
||||
|
||||
public static long getImpersonationToken0(object thisObj)
|
||||
@@ -547,6 +534,7 @@ static class Java_java_awt_SplashScreen
|
||||
public static String _getImageFileName(long splashPtr) { return null; }
|
||||
public static String _getImageJarName(long splashPtr) { return null; }
|
||||
public static bool _setImageData(long splashPtr, byte[] data) { return false; }
|
||||
public static float _getScaleFactor(long SplashPtr) { return 1; }
|
||||
}
|
||||
|
||||
static class Java_java_awt_TextArea
|
||||
@@ -618,3 +606,30 @@ static class Java_java_awt_image_SampleModel
|
||||
{
|
||||
public static void initIDs() { }
|
||||
}
|
||||
|
||||
static class Java_sun_net_ExtendedOptionsImpl
|
||||
{
|
||||
public static void init()
|
||||
{
|
||||
}
|
||||
|
||||
public static void setFlowOption(java.io.FileDescriptor fd, object f)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
throw new java.lang.UnsupportedOperationException();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void getFlowOption(java.io.FileDescriptor fd, object f)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
throw new java.lang.UnsupportedOperationException();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool flowSupported()
|
||||
{
|
||||
// We don't support this. Solaris only functionality.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
23
external/ikvm/runtime/openjdk/sun.misc.cs
vendored
23
external/ikvm/runtime/openjdk/sun.misc.cs
vendored
@@ -733,6 +733,24 @@ static class Java_sun_misc_Unsafe
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_sun_misc_URLClassPath
|
||||
{
|
||||
public static java.net.URL[] getLookupCacheURLs(java.lang.ClassLoader loader)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int[] getLookupCacheForClassLoader(java.lang.ClassLoader loader, string name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool knownToNotExist0(java.lang.ClassLoader loader, string className)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static class Java_sun_misc_Version
|
||||
{
|
||||
public static string getJvmSpecialVersion()
|
||||
@@ -803,4 +821,9 @@ static class Java_sun_misc_VMSupport
|
||||
{
|
||||
return props;
|
||||
}
|
||||
|
||||
public static string getVMTemporaryDirectory()
|
||||
{
|
||||
return System.IO.Path.GetTempPath();
|
||||
}
|
||||
}
|
||||
|
51
external/ikvm/runtime/openjdk/sun.nio.ch.cs
vendored
51
external/ikvm/runtime/openjdk/sun.nio.ch.cs
vendored
@@ -646,6 +646,10 @@ namespace IKVM.NativeCode.sun.nio.ch
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
if (level == global::ikvm.@internal.Winsock.IPPROTO_IPV6 && opt == global::ikvm.@internal.Winsock.IPV6_TCLASS)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
System.Net.Sockets.SocketOptionLevel sol = (System.Net.Sockets.SocketOptionLevel)level;
|
||||
System.Net.Sockets.SocketOptionName son = (System.Net.Sockets.SocketOptionName)opt;
|
||||
try
|
||||
@@ -678,9 +682,13 @@ namespace IKVM.NativeCode.sun.nio.ch
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setIntOption0(FileDescriptor fd, bool mayNeedConversion, int level, int opt, int arg)
|
||||
public static void setIntOption0(FileDescriptor fd, bool mayNeedConversion, int level, int opt, int arg, bool isIPv6)
|
||||
{
|
||||
#if !FIRST_PASS
|
||||
if (level == global::ikvm.@internal.Winsock.IPPROTO_IPV6 && opt == global::ikvm.@internal.Winsock.IPV6_TCLASS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
System.Net.Sockets.SocketOptionLevel sol = (System.Net.Sockets.SocketOptionLevel)level;
|
||||
System.Net.Sockets.SocketOptionName son = (System.Net.Sockets.SocketOptionName)opt;
|
||||
if (mayNeedConversion)
|
||||
@@ -998,8 +1006,7 @@ namespace IKVM.NativeCode.sun.nio.ch
|
||||
{
|
||||
if (useExclBind)
|
||||
{
|
||||
// TODO enable this after we merge OpenJDK 7u40
|
||||
//global::java.net.net_util_md.setExclusiveBind(fd.getSocket());
|
||||
global::java.net.net_util_md.setExclusiveBind(fd.getSocket());
|
||||
}
|
||||
fd.getSocket().Bind(new System.Net.IPEndPoint(global::java.net.SocketUtil.getAddressFromInetAddress(addr, preferIPv6), port));
|
||||
}
|
||||
@@ -1076,6 +1083,44 @@ namespace IKVM.NativeCode.sun.nio.ch
|
||||
{
|
||||
throw new global::java.net.SocketException("Socket is closed");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static int poll(FileDescriptor fd, int events, long timeout)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return 0;
|
||||
#else
|
||||
System.Net.Sockets.SelectMode selectMode;
|
||||
switch (events)
|
||||
{
|
||||
case global::sun.nio.ch.Net.POLLCONN:
|
||||
case global::sun.nio.ch.Net.POLLOUT:
|
||||
selectMode = System.Net.Sockets.SelectMode.SelectWrite;
|
||||
break;
|
||||
case global::sun.nio.ch.Net.POLLIN:
|
||||
selectMode = System.Net.Sockets.SelectMode.SelectRead;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
int microSeconds = timeout >= Int32.MaxValue / 1000 ? Int32.MaxValue : (int)(timeout * 1000);
|
||||
try
|
||||
{
|
||||
if (fd.getSocket().Poll(microSeconds, selectMode))
|
||||
{
|
||||
return events;
|
||||
}
|
||||
}
|
||||
catch (System.Net.Sockets.SocketException x)
|
||||
{
|
||||
throw new global::java.net.SocketException(x.Message);
|
||||
}
|
||||
catch (System.ObjectDisposedException)
|
||||
{
|
||||
throw new global::java.net.SocketException("Socket is closed");
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user