diff --git a/awt/graphics.cs b/awt/graphics.cs
index 097e7aa4..9a207158 100644
--- a/awt/graphics.cs
+++ b/awt/graphics.cs
@@ -1065,11 +1065,7 @@ namespace ikvm.awt
public override string[] getAvailableFontFamilyNames(Locale locale)
{
-#if WHIDBEY
int language = CultureInfo.GetCultureInfo(locale.toString()).LCID;
-#else
- int language = new CultureInfo(locale.toString()).LCID;
-#endif
return getAvailableFontFamilyNames(language);
}
diff --git a/awt/robot.cs b/awt/robot.cs
index 80a37470..d75757bf 100644
--- a/awt/robot.cs
+++ b/awt/robot.cs
@@ -48,7 +48,6 @@ namespace ikvm.awt
public int getRGBPixel(int x, int y)
{
-#if WHIDBEY
Bitmap bitmap = new Bitmap(1, 1);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen( x, y, 0, 0, new Size(1,1));
@@ -56,14 +55,10 @@ namespace ikvm.awt
Color color = bitmap.GetPixel(0,0);
bitmap.Dispose();
return color.ToArgb();
-#else
- return 0;
-#endif
}
public int[] getRGBPixels(java.awt.Rectangle r)
{
-#if WHIDBEY
int width = r.width;
int height = r.height;
Bitmap bitmap = new Bitmap(width, height);
@@ -80,9 +75,6 @@ namespace ikvm.awt
}
bitmap.Dispose();
return pixels;
-#else
- return null;
-#endif
}
private byte MapKeyCode(int keyCode)
diff --git a/awt/toolkit-0.95.cs b/awt/toolkit-0.95.cs
index c73b7e8d..f5ab96da 100644
--- a/awt/toolkit-0.95.cs
+++ b/awt/toolkit-0.95.cs
@@ -459,7 +459,7 @@ namespace ikvm.awt
public override void beep()
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
Console.Beep();
#endif
}
diff --git a/ikvmc.8.csproj b/ikvmc.8.csproj
index 470bc923..f7e70762 100644
--- a/ikvmc.8.csproj
+++ b/ikvmc.8.csproj
@@ -59,6 +59,7 @@
System
+
System.XML
@@ -79,6 +80,9 @@
Code
+
+ Code
+
Code
@@ -112,6 +116,7 @@
Code
+
Code
@@ -122,12 +127,6 @@
Code
-
-
- {F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}
- IKVM.Runtime.8
-
-
diff --git a/ikvmc/AotTypeWrapper.cs b/ikvmc/AotTypeWrapper.cs
index e9555037..63f4e923 100644
--- a/ikvmc/AotTypeWrapper.cs
+++ b/ikvmc/AotTypeWrapper.cs
@@ -24,15 +24,12 @@
using System;
using System.Collections;
-#if WHIDBEY
using System.Collections.Generic;
-#endif
using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics;
using System.Security;
using System.Security.Permissions;
-using IKVM.Runtime;
using IKVM.Attributes;
using ILGenerator = IKVM.Internal.CountingILGenerator;
diff --git a/ikvmc/Compiler.cs b/ikvmc/Compiler.cs
index 707b49ce..b41eb716 100644
--- a/ikvmc/Compiler.cs
+++ b/ikvmc/Compiler.cs
@@ -96,11 +96,7 @@ class IkvmcCompiler
static int RealMain(string[] args)
{
-#if WHIDBEY
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
-#else
- AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
-#endif
System.Threading.Thread.CurrentThread.Name = "compiler";
Tracer.EnableTraceForDebug();
CompilerOptions options = new CompilerOptions();
@@ -787,205 +783,13 @@ class IkvmcCompiler
{
// make sure all the referenced assemblies are visible (they are loaded with LoadFrom, so
// they end up in the LoadFrom context [unless they happen to be available in one of the probe paths])
-#if WHIDBEY
foreach(Assembly a in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies())
-#else
- foreach(Assembly a in AppDomain.CurrentDomain.GetAssemblies())
-#endif
{
if(args.Name.StartsWith(a.GetName().Name + ", "))
{
return a;
}
}
-#if WHIDBEY
return Assembly.ReflectionOnlyLoad(args.Name);
-#else
- return null;
-#endif
- }
-}
-
-sealed class LZOutputStream : Stream
-{
- private static readonly int[] hashSize = { 499, 997, 2179, 4297 };
- private int[] codes;
- private int[] values;
- private int table_size;
- private int count;
- private int bitOffset;
- private int bitBuffer;
- private int prev = -1;
- private int bits;
- private Stream s;
-
- public LZOutputStream(Stream s)
- {
- this.s = s;
- bitOffset = 0;
- count = 0;
- table_size = 256;
- bits = 9;
- codes = new int[hashSize[0]];
- values = new int[hashSize[0]];
- }
-
- public override void WriteByte(byte b)
- {
- if (prev != -1)
- {
- int c;
- int p = (prev << 8) + b;
- c = p % codes.Length;
- while (true)
- {
- int e = codes[c];
- if (e == 0)
- {
- break;
- }
- if (e == p)
- {
- prev = values[c];
- return;
- }
- c++;
- if(c == codes.Length)
- {
- c = 0;
- }
- }
- outcode(prev);
- if (count < table_size)
- {
- codes[c] = p;
- values[c] = count + 256;
- count++;
- }
- else
- {
- // table is full. Flush and rebuild
- if (bits == 12)
- {
- table_size = 256;
- bits = 9;
- }
- else
- {
- bits++;
- table_size = (1 << bits) - 256;
- }
- count = 0;
- int newsize = hashSize[bits - 9];
- if(codes.Length >= newsize)
- {
- Array.Clear(codes, 0, codes.Length);
- }
- else
- {
- codes = new int[newsize];
- values = new int[newsize];
- }
- }
- }
- prev = b;
- }
-
- public override void Flush()
- {
- bitBuffer |= prev << bitOffset;
- bitOffset += bits + 7;
- while (bitOffset >= 8)
- {
- s.WriteByte((byte)bitBuffer);
- bitBuffer >>= 8;
- bitOffset -= 8;
- }
- prev = -1;
- s.Flush();
- }
-
- private void outcode(int c)
- {
- bitBuffer |= c << bitOffset;
- bitOffset += bits;
- while (bitOffset >= 8)
- {
- s.WriteByte((byte)bitBuffer);
- bitBuffer >>= 8;
- bitOffset -= 8;
- }
- }
-
- public override void Write(byte[] buffer, int off, int len)
- {
- while(--len >= 0)
- {
- WriteByte(buffer[off++]);
- }
- }
-
- public override bool CanRead
- {
- get
- {
- return false;
- }
- }
-
- public override bool CanSeek
- {
- get
- {
- return false;
- }
- }
-
- public override bool CanWrite
- {
- get
- {
- return true;
- }
- }
-
- public override long Length
- {
- get
- {
- throw new NotSupportedException();
- }
- }
-
- public override long Position
- {
- get
- {
- throw new NotSupportedException();
- }
- set
- {
- throw new NotSupportedException();
- }
- }
-
- public override long Seek(long offset, SeekOrigin origin)
- {
- throw new NotSupportedException();
- }
-
- public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
-
- public override int Read(byte[] buffer, int offset, int count)
- {
- throw new NotSupportedException();
- }
-
- public override void Close()
- {
- s.Close();
}
}
diff --git a/ikvmc/CompilerClassLoader.cs b/ikvmc/CompilerClassLoader.cs
index 24411323..c926abc0 100644
--- a/ikvmc/CompilerClassLoader.cs
+++ b/ikvmc/CompilerClassLoader.cs
@@ -34,7 +34,6 @@ using System.Text.RegularExpressions;
using System.Text;
using System.Threading;
using IKVM.Attributes;
-using IKVM.Runtime;
using ILGenerator = IKVM.Internal.CountingILGenerator;
using Label = IKVM.Internal.CountingLabel;
@@ -120,11 +119,7 @@ namespace IKVM.Internal
name.KeyPair = new StrongNameKeyPair(keycontainer);
}
name.Version = new Version(version);
-#if WHIDBEY
assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.ReflectionOnly, assemblyDir);
-#else
- assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Save, assemblyDir);
-#endif
ModuleBuilder moduleBuilder;
moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName, assemblyFile, this.EmitDebugInfo);
if(this.EmitStackTraceInfo)
@@ -383,34 +378,21 @@ namespace IKVM.Internal
if(buf.Length > 0)
{
string name = JVM.MangleResourceName((string)d.Key);
-#if WHIDBEY
- MemoryStream mem = new MemoryStream();
- if(compressedResources)
- {
- mem.WriteByte(1);
- System.IO.Compression.DeflateStream def = new System.IO.Compression.DeflateStream(mem, System.IO.Compression.CompressionMode.Compress, true);
- def.Write(buf, 0, buf.Length);
- def.Close();
- }
- else
- {
- mem.WriteByte(0);
- mem.Write(buf, 0, buf.Length);
- }
- mem.Position = 0;
- moduleBuilder.DefineManifestResource(name, mem, ResourceAttributes.Public);
-#else
+ MemoryStream mem = new MemoryStream();
if(compressedResources)
{
- MemoryStream mem = new MemoryStream();
- LZOutputStream lz = new LZOutputStream(mem);
- lz.Write(buf, 0, buf.Length);
- lz.Flush();
- buf = mem.ToArray();
+ mem.WriteByte(1);
+ System.IO.Compression.DeflateStream def = new System.IO.Compression.DeflateStream(mem, System.IO.Compression.CompressionMode.Compress, true);
+ def.Write(buf, 0, buf.Length);
+ def.Close();
}
- IResourceWriter writer = moduleBuilder.DefineResource(name, "");
- writer.AddResource(compressedResources ? "lz" : "ikvm", buf);
-#endif
+ else
+ {
+ mem.WriteByte(0);
+ mem.Write(buf, 0, buf.Length);
+ }
+ mem.Position = 0;
+ moduleBuilder.DefineManifestResource(name, mem, ResourceAttributes.Public);
}
}
}
@@ -2101,25 +2083,24 @@ namespace IKVM.Internal
internal static int Compile(CompilerOptions options)
{
Tracer.Info(Tracer.Compiler, "JVM.Compile path: {0}, assembly: {1}", options.path, options.assembly);
-#if WHIDBEY
- if(options.runtimeAssembly == null)
+ try
{
- StaticCompiler.runtimeAssembly = Assembly.ReflectionOnlyLoadFrom(typeof(ByteCodeHelper).Assembly.Location);
+ if(options.runtimeAssembly == null)
+ {
+ // HACK based on our assembly name we create the default runtime assembly name
+ Assembly compilerAssembly = typeof(CompilerClassLoader).Assembly;
+ StaticCompiler.runtimeAssembly = Assembly.ReflectionOnlyLoad(compilerAssembly.FullName.Replace(compilerAssembly.GetName().Name, "IKVM.Runtime"));
+ }
+ else
+ {
+ StaticCompiler.runtimeAssembly = Assembly.ReflectionOnlyLoadFrom(options.runtimeAssembly);
+ }
}
- else
+ catch(FileNotFoundException)
{
- StaticCompiler.runtimeAssembly = Assembly.ReflectionOnlyLoadFrom(options.runtimeAssembly);
+ Console.Error.WriteLine("Error: unable to load runtime assembly");
+ return 1;
}
-#else
- if(options.runtimeAssembly == null)
- {
- StaticCompiler.runtimeAssembly = typeof(ByteCodeHelper).Assembly;
- }
- else
- {
- StaticCompiler.runtimeAssembly = Assembly.LoadFrom(options.runtimeAssembly);
- }
-#endif
Tracer.Info(Tracer.Compiler, "Loaded runtime assembly: {0}", StaticCompiler.runtimeAssembly.FullName);
AssemblyName runtimeAssemblyName = StaticCompiler.runtimeAssembly.GetName();
bool allReferencesAreStrongNamed = IsSigned(StaticCompiler.runtimeAssembly);
@@ -2128,37 +2109,17 @@ namespace IKVM.Internal
{
try
{
-#if WHIDBEY
Assembly reference = Assembly.ReflectionOnlyLoadFrom(r);
if(AttributeHelper.IsDefined(reference, StaticCompiler.GetType("IKVM.Attributes.RemappedClassAttribute")))
{
JVM.CoreAssembly = reference;
}
-#else
- AssemblyName name = AssemblyName.GetAssemblyName(r);
- Assembly reference;
- try
- {
- reference = Assembly.Load(name);
- }
- catch(FileNotFoundException)
- {
- // MONOBUG mono fails to use the codebase inside the AssemblyName,
- // so now we try again explicitly loading from the codebase
- reference = Assembly.LoadFrom(name.CodeBase);
- }
-#endif
if(reference == null)
{
Console.Error.WriteLine("Error: reference not found: {0}", r);
return 1;
}
references.Add(reference);
- // HACK if we explictly referenced the core assembly, make sure we register it as such
- if(reference.GetType("java.lang.Object") != null)
- {
- JVM.CoreAssembly = reference;
- }
allReferencesAreStrongNamed &= IsSigned(reference);
Tracer.Info(Tracer.Compiler, "Loaded reference assembly: {0}", reference.FullName);
// if it's an IKVM compiled assembly, make sure that it was compiled
@@ -2227,7 +2188,6 @@ namespace IKVM.Internal
{
return 1;
}
-#if WHIDBEY
// If the "System" assembly wasn't explicitly referenced, load it automatically
bool systemIsLoaded = false;
foreach(Assembly asm in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies())
@@ -2242,7 +2202,6 @@ namespace IKVM.Internal
{
Assembly.ReflectionOnlyLoadFrom(typeof(System.ComponentModel.EditorBrowsableAttribute).Assembly.Location);
}
-#endif
ArrayList assemblyAnnotations = new ArrayList();
Hashtable baseClasses = new Hashtable();
Hashtable h = new Hashtable();
@@ -2424,11 +2383,20 @@ namespace IKVM.Internal
Console.Error.WriteLine("Error: runtime assembly doesn't reference core assembly");
return 1;
}
-#if WHIDBEY
- JVM.CoreAssembly = Assembly.ReflectionOnlyLoadFrom(StaticCompiler.runtimeAssembly.CodeBase + "\\..\\" + coreAssemblyName.Name + ".dll");
-#else
- JVM.CoreAssembly = Assembly.Load(coreAssemblyName);
-#endif
+ try
+ {
+ JVM.CoreAssembly = Assembly.ReflectionOnlyLoad(coreAssemblyName.FullName);
+ }
+ catch(FileNotFoundException)
+ {
+ try
+ {
+ JVM.CoreAssembly = Assembly.ReflectionOnlyLoadFrom(StaticCompiler.runtimeAssembly.CodeBase + "\\..\\" + coreAssemblyName.Name + ".dll");
+ }
+ catch(FileNotFoundException)
+ {
+ }
+ }
if(JVM.CoreAssembly == null)
{
Console.Error.WriteLine("Error: bootstrap classes missing and core assembly not found");
@@ -2436,7 +2404,6 @@ namespace IKVM.Internal
}
loader.AddReference(ClassLoaderWrapper.GetAssemblyClassLoader(JVM.CoreAssembly));
allReferencesAreStrongNamed &= IsSigned(JVM.CoreAssembly);
- StaticCompiler.IssueMessage(Message.AutoAddRef, JVM.CoreAssembly.Location);
// we need to scan again for remapped types, now that we've loaded the core library
ClassLoaderWrapper.LoadRemappedTypes();
}
@@ -2685,7 +2652,6 @@ namespace IKVM.Internal
{
return runtimeAssembly.GetType(name);
}
-#if WHIDBEY
foreach(Assembly asm in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies())
{
Type t = asm.GetType(name, false);
@@ -2696,21 +2662,6 @@ namespace IKVM.Internal
}
// try mscorlib as well
return typeof(object).Assembly.GetType(name, throwOnError);
-#else
- foreach(Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
- {
- Type t = asm.GetType(name, false);
- if(t != null)
- {
- return t;
- }
- }
- if(throwOnError)
- {
- throw new TypeLoadException(name);
- }
- return null;
-#endif
}
private static Hashtable suppressWarnings = new Hashtable();
diff --git a/ikvmc/ikvmc.build b/ikvmc/ikvmc.build
index 4207ee25..6e6ce379 100644
--- a/ikvmc/ikvmc.build
+++ b/ikvmc/ikvmc.build
@@ -16,6 +16,7 @@
+
@@ -27,12 +28,12 @@
+
-
diff --git a/ikvmstub/ikvmstub.cs b/ikvmstub/ikvmstub.cs
index 1cb89847..3d6b21da 100644
--- a/ikvmstub/ikvmstub.cs
+++ b/ikvmstub/ikvmstub.cs
@@ -79,29 +79,8 @@ public class NetExp
}
if(file != null && file.Exists)
{
-#if WHIDBEY
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(CurrentDomain_ReflectionOnlyAssemblyResolve);
assembly = Assembly.ReflectionOnlyLoadFrom(assemblyNameOrPath);
-#else
- try
- {
- // If the same assembly can be found in the "Load" context, we prefer to use that
- // http://blogs.gotdotnet.com/suzcook/permalink.aspx/d5c5e14a-3612-4af1-a9b7-0a144c8dbf16
- // We use AssemblyName.FullName, because otherwise the assembly will be loaded in the
- // "LoadFrom" context using the path inside the AssemblyName object.
- assembly = Assembly.Load(AssemblyName.GetAssemblyName(assemblyNameOrPath).FullName);
- Console.Error.WriteLine("Warning: Assembly loaded from {0} instead", assembly.Location);
- }
- catch
- {
- }
- if(assembly == null)
- {
- // since we're loading the assembly in the LoadFrom context, we need to hook the AssemblyResolve event
- AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
- assembly = Assembly.LoadFrom(assemblyNameOrPath);
- }
-#endif
}
else
{
@@ -160,7 +139,6 @@ public class NetExp
Environment.Exit(rc);
}
-#if WHIDBEY
private static Assembly CurrentDomain_ReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args)
{
foreach(Assembly a in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies())
@@ -185,7 +163,6 @@ public class NetExp
Console.WriteLine("Loading referenced assembly: " + path);
return Assembly.ReflectionOnlyLoadFrom(path);
}
-#endif
private static void WriteClass(java.lang.Class c)
{
@@ -219,7 +196,6 @@ public class NetExp
// NOTE we can't use getClassFromTypeHandle for ReflectionOnly assemblies
// (because Type.TypeHandle is not supported by ReflectionOnly types), but this
// isn't a problem because mscorlib is never loaded in the ReflectionOnly context.
-#if WHIDBEY
if(assembly.ReflectionOnly)
{
c = ikvm.runtime.Util.getFriendlyClassFromType(t);
@@ -228,9 +204,6 @@ public class NetExp
{
c = ikvm.runtime.Util.getClassFromTypeHandle(t.TypeHandle);
}
-#else
- c = ikvm.runtime.Util.getClassFromTypeHandle(t.TypeHandle);
-#endif
if(c != null)
{
AddToExportList(c);
@@ -265,7 +238,6 @@ public class NetExp
private static bool IsGenericType(java.lang.Class c)
{
-#if WHIDBEY
System.Type t = ikvm.runtime.Util.getInstanceTypeFromClass(c);
while(t == null && c.getDeclaringClass() != null)
{
@@ -274,9 +246,6 @@ public class NetExp
t = ikvm.runtime.Util.getInstanceTypeFromClass(c);
}
return t.IsGenericType;
-#else
- return c.getName().IndexOf("$$0060") > 0;
-#endif
}
private static void AddToExportListIfNeeded(java.lang.Class c)
@@ -345,16 +314,4 @@ public class NetExp
}
}
}
-
- private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
- {
- foreach(Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
- {
- if(asm.FullName == args.Name)
- {
- return asm;
- }
- }
- return null;
- }
}
diff --git a/runtime/ByteCodeHelper.cs b/runtime/ByteCodeHelper.cs
index 5003a86c..f8fd069a 100644
--- a/runtime/ByteCodeHelper.cs
+++ b/runtime/ByteCodeHelper.cs
@@ -600,13 +600,13 @@ namespace IKVM.Runtime
#endif
}
-#if !WHIDBEY || COMPACT_FRAMEWORK
+#if COMPACT_FRAMEWORK
private static readonly object volatileLock = new object();
#endif
public static long VolatileRead(ref long v)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
return Interlocked.Read(ref v);
#else
lock(volatileLock)
@@ -618,7 +618,7 @@ namespace IKVM.Runtime
public static void VolatileWrite(ref long v, long newValue)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
Interlocked.Exchange(ref v, newValue);
#else
lock(volatileLock)
@@ -630,7 +630,7 @@ namespace IKVM.Runtime
public static double VolatileRead(ref double v)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
return Interlocked.CompareExchange(ref v, 0.0, 0.0);
#else
lock(volatileLock)
@@ -642,7 +642,7 @@ namespace IKVM.Runtime
public static void VolatileWrite(ref double v, double newValue)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
Interlocked.Exchange(ref v, newValue);
#else
lock(volatileLock)
diff --git a/runtime/ClassFile.cs b/runtime/ClassFile.cs
index 4c4e1087..bf7696c9 100644
--- a/runtime/ClassFile.cs
+++ b/runtime/ClassFile.cs
@@ -25,7 +25,6 @@ using System;
using System.IO;
using System.Collections;
using IKVM.Attributes;
-using IKVM.Runtime;
namespace IKVM.Internal
{
diff --git a/runtime/ClassLoaderWrapper.cs b/runtime/ClassLoaderWrapper.cs
index a9e76b12..080a2597 100644
--- a/runtime/ClassLoaderWrapper.cs
+++ b/runtime/ClassLoaderWrapper.cs
@@ -31,7 +31,6 @@ using System.Collections;
using System.Diagnostics;
using System.Threading;
using IKVM.Attributes;
-using IKVM.Runtime;
namespace IKVM.Internal
{
@@ -958,7 +957,7 @@ namespace IKVM.Internal
{
return GetGenericClassLoaderByName(name);
}
-#if WHIDBEY && STATIC_COMPILER
+#if STATIC_COMPILER
return ClassLoaderWrapper.GetAssemblyClassLoader(Assembly.ReflectionOnlyLoad(name));
#else
return ClassLoaderWrapper.GetAssemblyClassLoader(Assembly.Load(name));
@@ -1303,9 +1302,7 @@ namespace IKVM.Internal
private Assembly assembly;
private AssemblyName[] references;
private AssemblyClassLoader[] delegates;
-#if WHIDBEY
private bool isReflectionOnly;
-#endif // WHIDBEY
private bool[] isJavaModule;
private Module[] modules;
private Hashtable nameMap;
@@ -1323,9 +1320,7 @@ namespace IKVM.Internal
modules = assembly.GetModules(false);
isJavaModule = new bool[modules.Length];
this.hasCustomClassLoader = hasCustomClassLoader;
-#if WHIDBEY
isReflectionOnly = assembly.ReflectionOnly;
-#endif // WHIDBEY
for(int i = 0; i < modules.Length; i++)
{
object[] attr = AttributeHelper.GetJavaModuleAttributes(modules[i]);
@@ -1614,13 +1609,11 @@ namespace IKVM.Internal
try
{
// TODO consider throttling the Load attempts (or caching failure)
-#if WHIDBEY
if(isReflectionOnly)
{
asm = Assembly.ReflectionOnlyLoad(references[i].FullName);
}
else
-#endif
{
asm = Assembly.Load(references[i]);
}
@@ -1680,13 +1673,11 @@ namespace IKVM.Internal
try
{
// TODO consider throttling the Load attempts (or caching failure)
-#if WHIDBEY
if(isReflectionOnly)
{
asm = Assembly.ReflectionOnlyLoad(references[i].FullName);
}
else
-#endif
{
asm = Assembly.Load(references[i]);
}
diff --git a/runtime/DynamicClassLoader.cs b/runtime/DynamicClassLoader.cs
index ba0f14f1..61e4f211 100644
--- a/runtime/DynamicClassLoader.cs
+++ b/runtime/DynamicClassLoader.cs
@@ -42,10 +42,6 @@ namespace IKVM.Internal
sealed class DynamicClassLoader : TypeWrapperFactory
{
-#if !WHIDBEY
- internal static bool arrayConstructionHack;
- internal static readonly object arrayConstructionLock = new object();
-#endif // !WHIDBEY
private static readonly char[] specialCharacters = { '\\', '+', ',', '[', ']', '*', '&', '\u0000' };
private static readonly string specialCharactersString = new String(specialCharacters);
#if !STATIC_COMPILER
@@ -81,16 +77,6 @@ namespace IKVM.Internal
private static Assembly OnTypeResolve(object sender, ResolveEventArgs args)
{
-#if !WHIDBEY
- lock(arrayConstructionLock)
- {
- Tracer.Info(Tracer.ClassLoading, "OnTypeResolve: {0} (arrayConstructionHack = {1})", args.Name, arrayConstructionHack);
- if(arrayConstructionHack)
- {
- return null;
- }
- }
-#endif // !WHIDBEY
TypeWrapper type = (TypeWrapper)Instance.dynamicTypes[args.Name];
if(type == null)
{
diff --git a/runtime/IKVM.Runtime.8.csproj b/runtime/IKVM.Runtime.8.csproj
index 544f980d..88bd16d2 100644
--- a/runtime/IKVM.Runtime.8.csproj
+++ b/runtime/IKVM.Runtime.8.csproj
@@ -113,7 +113,6 @@
Code
-
Code
diff --git a/runtime/JavaException.cs b/runtime/JavaException.cs
index caf6c1bd..62f22248 100644
--- a/runtime/JavaException.cs
+++ b/runtime/JavaException.cs
@@ -23,7 +23,6 @@
*/
using System;
using System.Reflection;
-using IKVM.Runtime;
using IKVM.Internal;
abstract class RetargetableJavaException : ApplicationException
diff --git a/runtime/JniInterface.cs b/runtime/JniInterface.cs
index b00d6e61..740dd973 100644
--- a/runtime/JniInterface.cs
+++ b/runtime/JniInterface.cs
@@ -435,6 +435,7 @@ namespace IKVM.Runtime
ClassLoaderWrapper prevLoader = f.Enter(loader);
try
{
+ // TODO on Whidbey we should be able to use Marshal.GetDelegateForFunctionPointer to call OnLoad
version = ikvm_CallOnLoad(onload, JavaVM.pJavaVM, null);
Tracer.Info(Tracer.Jni, "JNI_OnLoad returned: 0x{0:X8}", version);
}
@@ -473,6 +474,7 @@ namespace IKVM.Runtime
unsafe class VtableBuilder
{
+ // TODO on Whidbey we should use generics to cut down on the number of delegates needed
delegate int pf_int_IntPtr(JNIEnv* pEnv, IntPtr p);
delegate IntPtr pf_IntPtr_IntPtr(JNIEnv* pEnv, IntPtr p);
delegate void pf_void_IntPtr(JNIEnv* pEnv, IntPtr p);
@@ -566,6 +568,7 @@ namespace IKVM.Runtime
{
if(vtableDelegates[i] != null)
{
+ // TODO on Whidbey we can use Marshal.GetFunctionPointerForDelegate
p[i] = JniHelper.ikvm_MarshalDelegate(vtableDelegates[i]);
}
else
diff --git a/runtime/MemberWrapper.cs b/runtime/MemberWrapper.cs
index 57213814..91b07536 100644
--- a/runtime/MemberWrapper.cs
+++ b/runtime/MemberWrapper.cs
@@ -30,7 +30,6 @@ using ILGenerator = IKVM.Internal.CountingILGenerator;
#endif
using System.Diagnostics;
using IKVM.Attributes;
-using IKVM.Runtime;
namespace IKVM.Internal
{
@@ -904,12 +903,7 @@ namespace IKVM.Internal
private static Hashtable cache;
private static ModuleBuilder module;
- private class KeyGen :
-#if WHIDBEY
- IEqualityComparer
-#else
- IHashCodeProvider, IComparer
-#endif
+ private class KeyGen : IEqualityComparer
{
public int GetHashCode(object o)
{
@@ -949,11 +943,7 @@ namespace IKVM.Internal
static NonvirtualInvokeHelper()
{
KeyGen keygen = new KeyGen();
-#if WHIDBEY
cache = new Hashtable(keygen);
-#else
- cache = new Hashtable(keygen, keygen);
-#endif
AssemblyName name = new AssemblyName();
name.Name = "NonvirtualInvoker";
AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(name, JVM.IsSaveDebugImage ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run);
@@ -1366,18 +1356,7 @@ namespace IKVM.Internal
if(field.IsLiteral)
{
ReflectionOnConstant.IssueWarning(field);
-#if WHIDBEY
val = field.GetRawConstantValue();
-#else
- try
- {
- val = field.GetValue(null);
- }
- catch(TargetInvocationException x)
- {
- throw x.InnerException;
- }
-#endif
if(field.FieldType.IsEnum)
{
val = DotNetTypeWrapper.EnumValueFieldWrapper.GetEnumPrimitiveValue(Enum.GetUnderlyingType(field.FieldType), val);
@@ -1580,37 +1559,7 @@ namespace IKVM.Internal
FieldBuilder fb = field as FieldBuilder;
if(fb != null)
{
-#if WHIDBEY
field = DeclaringType.TypeAsTBD.Module.ResolveField(fb.GetToken().Token);
-#else
- // first do a name based lookup as that is much faster than doing a token based lookup
- BindingFlags bindings = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
- if(this.IsStatic)
- {
- bindings |= BindingFlags.Static;
- }
- else
- {
- bindings |= BindingFlags.Instance;
- }
- try
- {
- FieldInfo fi = DeclaringType.TypeAsTBD.GetField(field.Name, bindings);
- // now check that we've got the right field by comparing the tokens
- ModuleBuilder module = DeclaringType.GetClassLoader().GetTypeWrapperFactory().ModuleBuilder;
- if(module.GetFieldToken(fi).Token != fb.GetToken().Token)
- {
- fi = TokenBasedLookup(bindings, fb.GetToken().Token);
- }
- field = fi;
- }
- catch(AmbiguousMatchException)
- {
- // .NET 2.0 will throw this exception if there are multiple fields
- // with the same name (.NET 1.1 will simply return one of them)
- field = TokenBasedLookup(bindings, fb.GetToken().Token);
- }
-#endif
}
}
@@ -1956,7 +1905,6 @@ namespace IKVM.Internal
{
if(constant == null)
{
-#if WHIDBEY
FieldInfo field = GetField();
#if !STATIC_COMPILER
if(field.FieldType.IsEnum && !field.DeclaringType.IsEnum)
@@ -1972,9 +1920,6 @@ namespace IKVM.Internal
{
constant = field.GetRawConstantValue();
}
-#else // WHIDBEY
- constant = GetField().GetValue(null);
-#endif // WHIDBEY
}
return constant;
}
diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs
index 8ea9f1a6..1b0c0246 100644
--- a/runtime/TypeWrapper.cs
+++ b/runtime/TypeWrapper.cs
@@ -23,9 +23,7 @@
*/
using System;
using System.Collections;
-#if WHIDBEY
using System.Collections.Generic;
-#endif
using System.Reflection;
#if !COMPACT_FRAMEWORK
using System.Reflection.Emit;
@@ -35,7 +33,6 @@ using Label = IKVM.Internal.CountingLabel;
using System.Diagnostics;
using System.Security;
using System.Security.Permissions;
-using IKVM.Runtime;
using IKVM.Attributes;
@@ -184,7 +181,6 @@ namespace IKVM.Internal
}
else if(tw.TypeAsTBD.IsEnum)
{
-#if WHIDBEY
if(tw.TypeAsTBD.Assembly.ReflectionOnly)
{
// TODO implement full parsing semantics
@@ -195,7 +191,6 @@ namespace IKVM.Internal
}
return field.GetRawConstantValue();
}
-#endif
return Enum.Parse(tw.TypeAsTBD, val);
}
else if(tw.TypeAsTBD == typeof(Type))
@@ -756,7 +751,7 @@ namespace IKVM.Internal
return IsDefined(type, typeofExceptionIsUnsafeForMappingAttribute);
}
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
// this method compares t1 and t2 by name
// if the type name and assembly name (ignoring the version and strong name) match
// the type are considered the same
@@ -769,7 +764,7 @@ namespace IKVM.Internal
internal static object GetConstantValue(FieldInfo field)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || field.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(field))
@@ -794,7 +789,7 @@ namespace IKVM.Internal
internal static ModifiersAttribute GetModifiersAttribute(Type type)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || type.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(type))
@@ -818,7 +813,7 @@ namespace IKVM.Internal
internal static ExModifiers GetModifiers(MethodBase mb, bool assemblyIsPrivate)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || mb.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(mb))
@@ -899,7 +894,7 @@ namespace IKVM.Internal
internal static ExModifiers GetModifiers(FieldInfo fi, bool assemblyIsPrivate)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || fi.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(fi))
@@ -954,12 +949,10 @@ namespace IKVM.Internal
{
modifiers |= Modifiers.Static;
}
-#if WHIDBEY
if(Array.IndexOf(fi.GetRequiredCustomModifiers(), typeof(System.Runtime.CompilerServices.IsVolatile)) != -1)
{
modifiers |= Modifiers.Volatile;
}
-#endif
return new ExModifiers(modifiers, false);
}
@@ -1164,7 +1157,7 @@ namespace IKVM.Internal
internal static NameSigAttribute GetNameSig(FieldInfo field)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || field.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(field))
@@ -1184,7 +1177,7 @@ namespace IKVM.Internal
internal static NameSigAttribute GetNameSig(MethodBase method)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || method.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(method))
@@ -1202,7 +1195,7 @@ namespace IKVM.Internal
return attr.Length == 1 ? (NameSigAttribute)attr[0] : null;
}
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
internal static T[] DecodeArray(CustomAttributeTypedArgument arg)
{
IList elems = (IList)arg.Value;
@@ -1217,7 +1210,7 @@ namespace IKVM.Internal
internal static ImplementsAttribute GetImplements(Type type)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || type.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(type))
@@ -1237,7 +1230,7 @@ namespace IKVM.Internal
internal static ThrowsAttribute GetThrows(MethodBase mb)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || mb.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(mb))
@@ -1257,7 +1250,7 @@ namespace IKVM.Internal
internal static string[] GetNonNestedInnerClasses(Type t)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || t.Assembly.ReflectionOnly)
{
List list = new List();
@@ -1283,7 +1276,7 @@ namespace IKVM.Internal
internal static string GetNonNestedOuterClasses(Type t)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || t.Assembly.ReflectionOnly)
{
List list = new List();
@@ -1304,7 +1297,7 @@ namespace IKVM.Internal
internal static SignatureAttribute GetSignature(MethodBase mb)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || mb.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(mb))
@@ -1324,7 +1317,7 @@ namespace IKVM.Internal
internal static SignatureAttribute GetSignature(Type type)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || type.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(type))
@@ -1346,7 +1339,7 @@ namespace IKVM.Internal
internal static SignatureAttribute GetSignature(FieldInfo fi)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || fi.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(fi))
@@ -1366,7 +1359,7 @@ namespace IKVM.Internal
internal static InnerClassAttribute GetInnerClass(Type type)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || type.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(type))
@@ -1386,7 +1379,7 @@ namespace IKVM.Internal
internal static RemappedInterfaceMethodAttribute[] GetRemappedInterfaceMethods(Type type)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || type.Assembly.ReflectionOnly)
{
List attrs = new List();
@@ -1409,7 +1402,7 @@ namespace IKVM.Internal
internal static RemappedTypeAttribute GetRemappedType(Type type)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || type.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(type))
@@ -1429,7 +1422,7 @@ namespace IKVM.Internal
internal static RemappedClassAttribute[] GetRemappedClasses(Assembly coreAssembly)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || coreAssembly.ReflectionOnly)
{
List attrs = new List();
@@ -1452,7 +1445,7 @@ namespace IKVM.Internal
internal static string GetAnnotationAttributeType(Type type)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || type.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(type))
@@ -1475,7 +1468,7 @@ namespace IKVM.Internal
internal static bool IsDefined(Module mod, Type attribute)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || mod.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(mod))
@@ -1494,7 +1487,7 @@ namespace IKVM.Internal
internal static bool IsDefined(Assembly asm, Type attribute)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || asm.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(asm))
@@ -1512,7 +1505,7 @@ namespace IKVM.Internal
internal static bool IsDefined(Type type, Type attribute)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || type.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(type))
@@ -1531,7 +1524,7 @@ namespace IKVM.Internal
internal static bool IsDefined(ParameterInfo pi, Type attribute)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || pi.Member.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(pi))
@@ -1550,7 +1543,7 @@ namespace IKVM.Internal
internal static bool IsDefined(MemberInfo member, Type attribute)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || member.DeclaringType.Assembly.ReflectionOnly)
{
foreach(CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(member))
@@ -1574,7 +1567,7 @@ namespace IKVM.Internal
internal static object[] GetJavaModuleAttributes(Module mod)
{
-#if WHIDBEY && !COMPACT_FRAMEWORK
+#if !COMPACT_FRAMEWORK
if(JVM.IsStaticCompiler || mod.Assembly.ReflectionOnly)
{
ArrayList attrs = new ArrayList();
@@ -3031,13 +3024,11 @@ namespace IKVM.Internal
MethodBase mb = mw.GetMethod();
if(mb != null)
{
-#if WHIDBEY
if(mb.DeclaringType.Assembly.ReflectionOnly)
{
// TODO
return null;
}
-#endif // WHIDBEY
object[] attr = mb.GetCustomAttributes(typeof(AnnotationDefaultAttribute), false);
if(attr.Length == 1)
{
@@ -4615,31 +4606,21 @@ namespace IKVM.Internal
#endif
}
}
-#if WHIDBEY
Type[] modreq = Type.EmptyTypes;
if(fld.IsVolatile)
{
modreq = new Type[] { typeof(System.Runtime.CompilerServices.IsVolatile) };
}
- field = typeBuilder.DefineField(isWrappedFinal ? "__<>" + fieldName : fieldName, type, modreq, Type.EmptyTypes, attribs);
-#else // WHIDBEY
// MONOBUG the __<> prefix for wrapped final fields is to work around a bug in mcs 1.1.17
// it crashes when it tries to lookup the property with the same name as the privatescope field
// http://bugzilla.ximian.com/show_bug.cgi?id=79451
- field = typeBuilder.DefineField(isWrappedFinal ? "__<>" + fieldName : fieldName, type, attribs);
-#endif // WHIDBEY
+ field = typeBuilder.DefineField(isWrappedFinal ? "__<>" + fieldName : fieldName, type, modreq, Type.EmptyTypes, attribs);
if(fld.IsTransient)
{
CustomAttributeBuilder transientAttrib = new CustomAttributeBuilder(typeof(NonSerializedAttribute).GetConstructor(Type.EmptyTypes), new object[0]);
field.SetCustomAttribute(transientAttrib);
}
#if STATIC_COMPILER
-#if !WHIDBEY
- if(fld.IsVolatile)
- {
- setModifiers = true;
- }
-#endif // !WHIDBEY
// Instance fields can also have a ConstantValue attribute (and are inlined by the compiler),
// and ikvmstub has to export them, so we have to add a custom attribute.
if(constantValue != null)
@@ -6110,7 +6091,11 @@ namespace IKVM.Internal
private class JniBuilder
{
+#if STATIC_COMPILER
+ private static readonly Type localRefStructType = StaticCompiler.GetType("IKVM.Runtime.JNI.Frame");
+#else
private static readonly Type localRefStructType = JVM.LoadType(typeof(IKVM.Runtime.JNI.Frame));
+#endif
private static readonly MethodInfo jniFuncPtrMethod = localRefStructType.GetMethod("GetFuncPtr");
private static readonly MethodInfo enterLocalRefStruct = localRefStructType.GetMethod("Enter");
private static readonly MethodInfo leaveLocalRefStruct = localRefStructType.GetMethod("Leave");
@@ -6961,9 +6946,7 @@ namespace IKVM.Internal
{
AttributeHelper.SetEditorBrowsableNever((MethodBuilder)method);
}
-#if WHIDBEY
- // TODO apply CompilerGeneratedAttribute
-#endif
+ // TODO on WHIDBEY apply CompilerGeneratedAttribute
}
if(m.DeprecatedAttribute)
{
@@ -7982,7 +7965,7 @@ namespace IKVM.Internal
{
ArrayList methods = new ArrayList();
ArrayList fields = new ArrayList();
- MemberInfo[] members = FilterDuplicates(type.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance));
+ MemberInfo[] members = type.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
foreach(MemberInfo m in members)
{
if(!AttributeHelper.IsHideFromJava(m))
@@ -8488,40 +8471,12 @@ namespace IKVM.Internal
}
}
- private static MemberInfo[] FilterDuplicates(MemberInfo[] members)
- {
-#if !WHIDBEY
- // FXBUG on .NET 1.1 methods that explicitly override another method are returned twice, so we filter them here
- for(int i = 1; i < members.Length; i++)
- {
- MethodBase m1 = members[i] as MethodBase;
- if(m1 != null)
- {
- for(int j = 0; j < i; j++)
- {
- MethodBase m2 = members[j] as MethodBase;
- if(m2 != null && m1.MethodHandle.Value == m2.MethodHandle.Value)
- {
- MemberInfo[] newArray = new MemberInfo[members.Length - 1];
- Array.Copy(members, newArray, i);
- Array.Copy(members, i + 1, newArray, i, newArray.Length - i);
- members = newArray;
- i--;
- break;
- }
- }
- }
- }
-#endif
- return members;
- }
-
protected override void LazyPublishMembers()
{
clinitMethod = type.GetMethod("__", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
ArrayList methods = new ArrayList();
ArrayList fields = new ArrayList();
- MemberInfo[] members = FilterDuplicates(type.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance));
+ MemberInfo[] members = type.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
foreach(MemberInfo m in members)
{
if(!AttributeHelper.IsHideFromJava(m))
@@ -8849,39 +8804,33 @@ namespace IKVM.Internal
internal override object[] GetDeclaredAnnotations()
{
-#if WHIDBEY
if(type.Assembly.ReflectionOnly)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
-#endif // WHIDBEY
return type.GetCustomAttributes(false);
}
internal override object[] GetMethodAnnotations(MethodWrapper mw)
{
MethodBase mb = mw.GetMethod();
-#if WHIDBEY
if(mb.DeclaringType.Assembly.ReflectionOnly)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
-#endif // WHIDBEY
return mb.GetCustomAttributes(false);
}
internal override object[][] GetParameterAnnotations(MethodWrapper mw)
{
MethodBase mb = mw.GetMethod();
-#if WHIDBEY
if(mb.DeclaringType.Assembly.ReflectionOnly)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
-#endif // WHIDBEY
ParameterInfo[] parameters = mb.GetParameters();
int skip = 0;
if(mb.IsStatic && !mw.IsStatic && mw.Name != "")
@@ -8901,25 +8850,21 @@ namespace IKVM.Internal
FieldInfo field = fw.GetField();
if(field != null)
{
-#if WHIDBEY
if (field.DeclaringType.Assembly.ReflectionOnly)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
-#endif // WHIDBEY
return field.GetCustomAttributes(false);
}
GetterFieldWrapper getter = fw as GetterFieldWrapper;
if(getter != null)
{
-#if WHIDBEY
if (getter.GetGetter().DeclaringType.Assembly.ReflectionOnly)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
-#endif // WHIDBEY
return getter.GetGetter().GetCustomAttributes(false);
}
return new object[0];
@@ -10292,7 +10237,6 @@ namespace IKVM.Internal
private AttributeUsageAttribute GetAttributeUsage()
{
-#if WHIDBEY
AttributeTargets validOn = AttributeTargets.All;
bool allowMultiple = false;
bool inherited = true;
@@ -10321,14 +10265,6 @@ namespace IKVM.Internal
attr.AllowMultiple = allowMultiple;
attr.Inherited = inherited;
return attr;
-#else // WHIDBEY
- object[] attr = attributeType.GetCustomAttributes(typeof(AttributeUsageAttribute), false);
- if(attr.Length == 1)
- {
- return (AttributeUsageAttribute)attr[0];
- }
- return new AttributeUsageAttribute(AttributeTargets.All);
-#endif // WHIDBEY
}
#if !STATIC_COMPILER
@@ -10969,11 +10905,7 @@ namespace IKVM.Internal
{
name = "_" + name;
}
-#if WHIDBEY
object val = EnumValueFieldWrapper.GetEnumPrimitiveValue(underlyingType, fields[i].GetRawConstantValue());
-#else
- object val = EnumValueFieldWrapper.GetEnumPrimitiveValue(fields[i].GetValue(null));
-#endif
fieldsList.Add(new ConstantFieldWrapper(this, fieldType, name, fieldType.SigName, Modifiers.Public | Modifiers.Static | Modifiers.Final, fields[i], val, MemberFlags.None));
}
}
@@ -11601,31 +11533,29 @@ namespace IKVM.Internal
internal override object[] GetDeclaredAnnotations()
{
-#if WHIDBEY
if(type.Assembly.ReflectionOnly)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
-#endif
return type.GetCustomAttributes(false);
}
internal override object[] GetFieldAnnotations(FieldWrapper fw)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
internal override object[] GetMethodAnnotations(MethodWrapper mw)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
internal override object[][] GetParameterAnnotations(MethodWrapper mw)
{
- // TODO
+ // TODO on Whidbey this must be implemented
return null;
}
}
@@ -11766,7 +11696,6 @@ namespace IKVM.Internal
internal static Type MakeArrayType(Type type, int dims)
{
-#if WHIDBEY
// NOTE this is not just an optimization, but it is also required to
// make sure that ReflectionOnly types stay ReflectionOnly types
// (in particular instantiations of generic types from mscorlib that
@@ -11776,39 +11705,6 @@ namespace IKVM.Internal
type = type.MakeArrayType();
}
return type;
-#else // WHIDBEY
- string name = type.FullName + "[]";
- for(int i = 1; i < dims; i++)
- {
- name += "[]";
- }
-#if !COMPACT_FRAMEWORK
- ModuleBuilder mb = type.Module as ModuleBuilder;
- if(mb != null)
- {
- // FXBUG ModuleBuilder.GetType() is broken on .NET 1.1, it fires a TypeResolveEvent when
- // you try to construct an array type from an unfinished type. I don't think it should
- // do that. We have to work around that by setting a global flag (yuck) to prevent us
- // from responding to the TypeResolveEvent.
- lock(DynamicClassLoader.arrayConstructionLock)
- {
- DynamicClassLoader.arrayConstructionHack = true;
- try
- {
- return mb.GetType(name);
- }
- finally
- {
- DynamicClassLoader.arrayConstructionHack = false;
- }
- }
- }
- else
-#endif // !COMPACT_FRAMEWORK
- {
- return type.Assembly.GetType(name, true);
- }
-#endif // WHIDBEY
}
}
}
diff --git a/runtime/attributes.cs b/runtime/attributes.cs
index 9fafe607..2c1f4cd2 100644
--- a/runtime/attributes.cs
+++ b/runtime/attributes.cs
@@ -26,6 +26,7 @@ using System.Reflection;
namespace IKVM.Attributes
{
+ [AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Delegate)]
public sealed class SourceFileAttribute : Attribute
{
private string file;
@@ -44,6 +45,7 @@ namespace IKVM.Attributes
}
}
+ [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor)]
public sealed class LineNumberTableAttribute : Attribute
{
private byte[] table;
@@ -367,7 +369,7 @@ namespace IKVM.Attributes
}
}
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Assembly)]
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Assembly)]
public sealed class NoPackagePrefixAttribute : Attribute
{
}
diff --git a/runtime/common.cs b/runtime/common.cs
index e1c7dce4..95f75992 100644
--- a/runtime/common.cs
+++ b/runtime/common.cs
@@ -48,206 +48,6 @@ using jlrField = java.lang.reflect.Field;
namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
{
-#if !WHIDBEY
- class LZInputStream : Stream
- {
- private Stream inp;
- private int[] ptr_tbl;
- private int[] char_tbl;
- private int[] stack;
- private int table_size;
- private int count;
- private int bitoff;
- private int bitbuf;
- private int prev = -1;
- private int bits;
- private int cc;
- private int fc;
- private int sp;
-
- public LZInputStream(Stream inp)
- {
- this.inp = inp;
- bitoff = 0;
- count = 0;
- table_size = 256;
- bits = 9;
- ptr_tbl = new int[table_size];
- char_tbl = new int[table_size];
- stack = new int[table_size];
- sp = 0;
- cc = prev = incode();
- stack[sp++] = cc;
- }
-
- private int read()
- {
- if (sp == 0)
- {
- if (stack.Length != table_size)
- {
- stack = new int[table_size];
- }
- int ic = cc = incode();
- if (cc == -1)
- {
- return -1;
- }
- if (count >= 0 && cc >= count + 256)
- {
- stack[sp++] = fc;
- cc = prev;
- ic = find(prev, fc);
- }
- while (cc >= 256)
- {
- stack[sp++] = char_tbl[cc - 256];
- cc = ptr_tbl[cc - 256];
- }
- stack[sp++] = cc;
- fc = cc;
- if (count >= 0)
- {
- ptr_tbl[count] = prev;
- char_tbl[count] = fc;
- }
- count++;
- if (count == table_size)
- {
- count = -1;
- if (bits == 12)
- {
- table_size = 256;
- bits = 9;
- }
- else
- {
- bits++;
- table_size = (1 << bits) - 256;
- }
- ptr_tbl = null;
- char_tbl = null;
- ptr_tbl = new int[table_size];
- char_tbl= new int[table_size];
- }
- prev = ic;
- }
- return stack[--sp] & 0xFF;
- }
-
- private int find(int p, int c)
- {
- int i;
- for (i = 0; i < count; i++)
- {
- if (ptr_tbl[i] == p && char_tbl[i] == c)
- {
- break;
- }
- }
- return i + 256;
- }
-
- private int incode()
- {
- while (bitoff < bits)
- {
- int v = inp.ReadByte();
- if (v == -1)
- {
- return -1;
- }
- bitbuf |= (v & 0xFF) << bitoff;
- bitoff += 8;
- }
- bitoff -= bits;
- int result = bitbuf;
- bitbuf >>= bits;
- result -= bitbuf << bits;
- return result;
- }
-
- public override int Read(byte[] b, int off, int len)
- {
- int i = 0;
- for (; i < len ; i++)
- {
- int r = read();
- if(r == -1)
- {
- break;
- }
- b[off + i] = (byte)r;
- }
- return i;
- }
-
- public override bool CanRead
- {
- get
- {
- return true;
- }
- }
-
- public override bool CanSeek
- {
- get
- {
- return false;
- }
- }
-
- public override bool CanWrite
- {
- get
- {
- return false;
- }
- }
-
- public override void Flush()
- {
- throw new NotSupportedException();
- }
-
- public override long Length
- {
- get
- {
- throw new NotSupportedException();
- }
- }
-
- public override long Position
- {
- get
- {
- throw new NotSupportedException();
- }
- set
- {
- throw new NotSupportedException();
- }
- }
-
- public override long Seek(long offset, SeekOrigin origin)
- {
- throw new NotSupportedException();
- }
-
- public override void SetLength(long value)
- {
- throw new NotSupportedException();
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- throw new NotSupportedException();
- }
- }
-#endif // !WHIDBEY
-
public class Handler
{
public static Stream ReadResourceFromAssemblyImpl(Assembly asm, string resource)
@@ -260,7 +60,6 @@ namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
{
return asm.GetManifestResourceStream(mangledName);
}
-#if WHIDBEY
Stream s = asm.GetManifestResourceStream(mangledName);
if(s == null)
{
@@ -279,39 +78,6 @@ namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
Tracer.Error(Tracer.ClassLoading, "Resource \"{0}\" in {1} has an unsupported encoding", resource, asm.FullName);
throw new IOException("Unsupported resource encoding for resource " + resource + " found in assembly " + asm.FullName);
}
-#else
- using(Stream s = asm.GetManifestResourceStream(mangledName))
- {
- if(s == null)
- {
- Tracer.Warning(Tracer.ClassLoading, "Resource \"{0}\" not found in {1}", resource, asm.FullName);
- throw new FileNotFoundException("resource " + resource + " not found in assembly " + asm.FullName);
- }
- using(System.Resources.ResourceReader r = new System.Resources.ResourceReader(s))
- {
- foreach(DictionaryEntry de in r)
- {
- if((string)de.Key == "lz")
- {
- Tracer.Info(Tracer.ClassLoading, "Reading compressed resource \"{0}\" from {1}", resource, asm.FullName);
- return new LZInputStream(new MemoryStream((byte[])de.Value));
- }
- else if((string)de.Key == "ikvm")
- {
- Tracer.Info(Tracer.ClassLoading, "Reading resource \"{0}\" from {1}", resource, asm.FullName);
- return new MemoryStream((byte[])de.Value);
- }
- else
- {
- Tracer.Error(Tracer.ClassLoading, "Resource \"{0}\" in {1} has an unsupported encoding", resource, asm.FullName);
- throw new IOException("Unsupported resource encoding " + de.Key + " for resource " + resource + " found in assembly " + asm.FullName);
- }
- }
- Tracer.Error(Tracer.ClassLoading, "Resource \"{0}\" in {1} is invalid", resource, asm.FullName);
- throw new IOException("Invalid resource " + resource + " found in assembly " + asm.FullName);
- }
- }
-#endif
}
public static object LoadClassFromAssembly(Assembly asm, string className)
@@ -326,12 +92,10 @@ namespace IKVM.NativeCode.gnu.java.net.protocol.ikvmres
public static Assembly LoadAssembly(string name)
{
-#if WHIDBEY
if(name.EndsWith("[ReflectionOnly]"))
{
return Assembly.ReflectionOnlyLoad(name.Substring(0, name.Length - 16));
}
-#endif
return Assembly.Load(name);
}
diff --git a/runtime/compiler.cs b/runtime/compiler.cs
index 2da6eb4d..2e2ba3f4 100644
--- a/runtime/compiler.cs
+++ b/runtime/compiler.cs
@@ -29,7 +29,6 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics;
using System.Diagnostics.SymbolStore;
-using IKVM.Runtime;
using IKVM.Attributes;
using IKVM.Internal;
@@ -82,7 +81,7 @@ class ByteCodeHelperMethods
#if STATIC_COMPILER
Type typeofByteCodeHelper = StaticCompiler.GetType("IKVM.Runtime.ByteCodeHelper");
#else
- Type typeofByteCodeHelper = typeof(ByteCodeHelper);
+ Type typeofByteCodeHelper = typeof(IKVM.Runtime.ByteCodeHelper);
#endif
GetClassFromTypeHandle = typeofByteCodeHelper.GetMethod("GetClassFromTypeHandle");
multianewarray = typeofByteCodeHelper.GetMethod("multianewarray");
@@ -3361,10 +3360,7 @@ class Compiler
}
if(type == null
|| !type.IsValueType
-#if WHIDBEY
- || type.StructLayoutAttribute.Pack != 1 || type.StructLayoutAttribute.Size != length
-#endif
- )
+ || type.StructLayoutAttribute.Pack != 1 || type.StructLayoutAttribute.Size != length)
{
// the type that we found doesn't match (must mean we've compiled a Java type with that name),
// so we fall back to the string approach
diff --git a/runtime/netinf.cs b/runtime/netinf.cs
deleted file mode 100644
index 48cf1587..00000000
--- a/runtime/netinf.cs
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- Copyright (C) 2007 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
-
-*/
-
-#if !WHIDBEY
-using System;
-using System.Collections;
-using System.Management;
-using IPAddress = System.Net.IPAddress;
-
-/*
- * This is a .NET 1.1 compatible partial implementation of the .NET 2.0 System.Net.NetworkInformation namespace.
- * It only provides the APIs needed by the NetworkInterface class in openjdk.cs.
- * It uses WMI (through the System.Management assembly) to query the relevant information.
- */
-
-namespace System.Net.NetworkInformation
-{
- enum NetworkInterfaceType
- {
- Unknown = -1,
- Ethernet = 0,
- TokenRing = 1,
- Fddi = 2,
- Loopback = -2,
- Ppp = 3,
- Slip = -3
- }
-
- enum OperationalStatus
- {
- Unknown,
- Up
- }
-
- class UnicastIPAddressInformation
- {
- private IPAddress address;
-
- internal UnicastIPAddressInformation(IPAddress address)
- {
- this.address = address;
- }
-
- internal IPAddress Address
- {
- get
- {
- return address;
- }
- }
- }
-
- class UnicastIPAddressInformationCollection
- {
- private IPAddress[] addresses;
-
- internal UnicastIPAddressInformationCollection(IPAddress[] addresses)
- {
- this.addresses = addresses;
- }
-
- internal UnicastIPAddressInformation this[int index]
- {
- get
- {
- return new UnicastIPAddressInformation(addresses[index]);
- }
- }
-
- internal int Count
- {
- get
- {
- return addresses.Length;
- }
- }
- }
-
- class IPAddressCollection : IEnumerable
- {
- private IPAddress[] addresses;
-
- internal IPAddressCollection(IPAddress[] addresses)
- {
- this.addresses = addresses;
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return addresses.GetEnumerator();
- }
- }
-
- class IPInterfaceProperties
- {
- private UnicastIPAddressInformationCollection addresses;
- internal IPv4InterfaceProperties v4props;
- private IPAddressCollection dnsservers;
- private string dnssuffix;
-
- internal IPInterfaceProperties(IPAddress[] addresses, int mtu, string dnssuffix, IPAddress[] dnsservers)
- {
- this.addresses = new UnicastIPAddressInformationCollection(addresses);
- this.v4props = new IPv4InterfaceProperties(mtu);
- this.dnsservers = new IPAddressCollection(dnsservers);
- this.dnssuffix = dnssuffix;
- }
-
- internal UnicastIPAddressInformationCollection UnicastAddresses
- {
- get
- {
- return addresses;
- }
- }
-
- internal IPv4InterfaceProperties GetIPv4Properties()
- {
- return v4props;
- }
-
- internal IPAddressCollection DnsAddresses
- {
- get
- {
- return dnsservers;
- }
- }
-
- internal string DnsSuffix
- {
- get
- {
- return dnssuffix;
- }
- }
- }
-
- class IPv4InterfaceProperties
- {
- private int mtu;
-
- internal IPv4InterfaceProperties(int mtu)
- {
- this.mtu = mtu;
- }
-
- internal int Mtu
- {
- get
- {
- return mtu;
- }
- }
- }
-
- class PhysicalAddress
- {
- private byte[] mac;
-
- internal PhysicalAddress(byte[] mac)
- {
- this.mac = mac;
- }
-
- internal byte[] GetAddressBytes()
- {
- return mac == null ? null : (byte[])mac.Clone();
- }
- }
-
- class NetworkInterface
- {
- private uint interfaceIndex;
- private string description;
- private IPInterfaceProperties props;
- private NetworkInterfaceType type = NetworkInterfaceType.Unknown;
- private OperationalStatus status = OperationalStatus.Unknown;
- private byte[] mac;
-
- private NetworkInterface(uint interfaceIndex, string description, IPAddress[] addresses, int mtu, byte[] mac, string dnssuffix, IPAddress[] dnsservers)
- {
- this.interfaceIndex = interfaceIndex;
- this.description = description;
- this.props = new IPInterfaceProperties(addresses, mtu, dnssuffix, dnsservers);
- this.mac = mac;
- }
-
- internal static NetworkInterface[] GetAllNetworkInterfaces()
- {
- NetworkInterface[] netif;
- using (ManagementClass mgmt = new ManagementClass("Win32_NetworkAdapterConfiguration"))
- {
- ArrayList ifaces = new ArrayList();
- // loopback isn't reported, so we make it up
- NetworkInterface loopback = new NetworkInterface(0xFFFFFFFF, "Software Loopback Interface 1", new IPAddress[] { IPAddress.Loopback }, -1, new byte[0], "", new IPAddress[0]);
- loopback.type = NetworkInterfaceType.Loopback;
- loopback.status = OperationalStatus.Up;
- ifaces.Add(loopback);
- using (ManagementObjectCollection moc = mgmt.GetInstances())
- {
- foreach (ManagementObject obj in moc)
- {
- PropertyDataCollection props = obj.Properties;
- PropertyData ipaddress = props["IPAddress"];
- string[] addresses = (string[])ipaddress.Value;
- IPAddress[] addr;
- if (addresses != null)
- {
- addr = new IPAddress[addresses.Length];
- for (int i = 0; i < addresses.Length; i++)
- {
- addr[i] = IPAddress.Parse(addresses[i]);
- }
- }
- else
- {
- addr = new IPAddress[0];
- }
- int mtu = -1;
- try
- {
- // TODO this doesn't work, the MTU value is always null
- mtu = (int)(uint)props["MTU"].Value;
- }
- catch
- {
- }
- byte[] mac = null;
- try
- {
- mac = ParseMacAddress((string)props["MACAddress"].Value);
- }
- catch
- {
- }
- string dnssuffix = "";
- try
- {
- dnssuffix = ((string[])props["DNSDomainSuffixSearchOrder"].Value)[0];
- }
- catch
- {
- }
- IPAddress[] dnsservers;
- try
- {
- string[] dnsaddresses = (string[])props["DNSServerSearchOrder"].Value;
- dnsservers = new IPAddress[dnsaddresses.Length];
- for (int i = 0; i < dnsaddresses.Length; i++)
- {
- dnsservers[i] = IPAddress.Parse(dnsaddresses[i]);
- }
- }
- catch
- {
- dnsservers = new IPAddress[0];
- }
- ifaces.Add(new NetworkInterface((uint)props["InterfaceIndex"].Value, (string)props["Description"].Value, addr, mtu, mac, dnssuffix, dnsservers));
- }
- }
- netif = (NetworkInterface[])ifaces.ToArray(typeof(NetworkInterface));
- }
- using (ManagementClass mgmt = new ManagementClass("Win32_NetworkAdapter"))
- {
- using (ManagementObjectCollection moc = mgmt.GetInstances())
- {
- foreach (ManagementObject obj in moc)
- {
- PropertyDataCollection props = obj.Properties;
- uint interfaceIndex = (uint)props["InterfaceIndex"].Value;
- NetworkInterfaceType type = NetworkInterfaceType.Unknown;
- try
- {
- type = (NetworkInterfaceType)(ushort)props["AdapterTypeID"].Value;
- }
- catch
- {
- }
- OperationalStatus status = OperationalStatus.Unknown;
- try
- {
- if ((ushort)props["NetConnectionStatus"].Value == 2)
- {
- status = OperationalStatus.Up;
- }
- }
- catch
- {
- }
- for (int i = 0; i < netif.Length; i++)
- {
- if (netif[i].interfaceIndex == interfaceIndex)
- {
- netif[i].type = type;
- netif[i].status = status;
- break;
- }
- }
- }
- }
- }
- return netif;
- }
-
- private static byte[] ParseMacAddress(string mac)
- {
- string[] split = mac.Split(':');
- byte[] bytes = new byte[split.Length];
- for (int i = 0; i < split.Length; i++)
- {
- const string digits = "0123456789ABCDEF";
- if (split[i].Length != 2)
- {
- return null;
- }
- int d0 = digits.IndexOf(char.ToUpper(split[i][0]));
- int d1 = digits.IndexOf(char.ToUpper(split[i][1]));
- if (d0 == -1 || d1 == -1)
- {
- return null;
- }
- bytes[i] = (byte)(d0 * 16 + d1);
- }
- return bytes;
- }
-
- internal string Description
- {
- get
- {
- return description;
- }
- }
-
- internal NetworkInterfaceType NetworkInterfaceType
- {
- get
- {
- return type;
- }
- }
-
- internal IPInterfaceProperties GetIPProperties()
- {
- return props;
- }
-
- internal OperationalStatus OperationalStatus
- {
- get
- {
- return status;
- }
- }
-
- internal bool SupportsMulticast
- {
- get
- {
- // TODO I don't know how to query this
- return true;
- }
- }
-
- internal PhysicalAddress GetPhysicalAddress()
- {
- return new PhysicalAddress(mac);
- }
- }
-}
-#endif // !WHIDBEY
diff --git a/runtime/openjdk.cs b/runtime/openjdk.cs
index 9b648f33..66f92334 100644
--- a/runtime/openjdk.cs
+++ b/runtime/openjdk.cs
@@ -121,56 +121,11 @@ using ssaGetPropertyAction = sun.security.action.GetPropertyAction;
using sndResolverConfigurationImpl = sun.net.dns.ResolverConfigurationImpl;
#endif
-#if WHIDBEY
sealed class DynamicMethodSupport
{
// MONOBUG as of Mono 1.2.5.1, DynamicMethod is too broken to be used
internal static readonly bool Enabled = Type.GetType("Mono.Runtime") == null;
}
-#else
-sealed class DynamicMethodSupport
-{
- internal static readonly bool Enabled = Environment.Version.Major >= 2 && Type.GetType("Mono.Runtime") == null;
-}
-
-sealed class DynamicMethod
-{
- private static ConstructorInfo ctor1;
- private static ConstructorInfo ctor2;
- private static MethodInfo createMethod;
- private static MethodInfo getILGenMethod;
- private object dm;
-
- static DynamicMethod()
- {
- Type type = Type.GetType("System.Reflection.Emit.DynamicMethod", true);
- ctor1 = type.GetConstructor(new Type[] { typeof(string), typeof(MethodAttributes), typeof(CallingConventions), typeof(Type), typeof(Type[]), typeof(Module), typeof(bool) });
- ctor2 = type.GetConstructor(new Type[] { typeof(string), typeof(Type), typeof(Type[]), typeof(Type) });
- createMethod = type.GetMethod("CreateDelegate", new Type[] { typeof(Type) });
- getILGenMethod = type.GetMethod("GetILGenerator", new Type[0]);
- }
-
- internal DynamicMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Module owner, bool skipVisibility)
- {
- dm = ctor1.Invoke(new object[] { name, attributes, callingConvention, returnType, parameterTypes, owner, skipVisibility });
- }
-
- internal DynamicMethod(string name, Type returnType, Type[] parameterTypes, Type owner)
- {
- dm = ctor2.Invoke(new object[] { name, returnType, parameterTypes, owner });
- }
-
- internal ILGenerator GetILGenerator()
- {
- return (ILGenerator)getILGenMethod.Invoke(dm, null);
- }
-
- internal Delegate CreateDelegate(Type delegateType)
- {
- return (Delegate)createMethod.Invoke(dm, new object[] { delegateType });
- }
-}
-#endif
namespace IKVM.Runtime
{
@@ -4563,11 +4518,7 @@ namespace IKVM.NativeCode.java
#else
try
{
-#if WHIDBEY
System.Net.IPAddress[] addr = System.Net.Dns.GetHostAddresses(hostname);
-#else
- System.Net.IPAddress[] addr = System.Net.Dns.Resolve(hostname).AddressList;
-#endif
ArrayList addresses = new ArrayList();
for (int i = 0; i < addr.Length; i++)
{
@@ -4682,11 +4633,7 @@ namespace IKVM.NativeCode.java
#else
try
{
-#if WHIDBEY
System.Net.IPAddress[] addr = System.Net.Dns.GetHostAddresses(hostname);
-#else
- System.Net.IPAddress[] addr = System.Net.Dns.Resolve(hostname).AddressList;
-#endif
jnInetAddress[] addresses = new jnInetAddress[addr.Length];
for (int i = 0; i < addr.Length; i++)
{
diff --git a/runtime/runtime.build b/runtime/runtime.build
index 9c52cb4d..fbe86f58 100644
--- a/runtime/runtime.build
+++ b/runtime/runtime.build
@@ -52,7 +52,6 @@
-
diff --git a/runtime/tracer.cs b/runtime/tracer.cs
index a86337aa..80c87513 100644
--- a/runtime/tracer.cs
+++ b/runtime/tracer.cs
@@ -27,9 +27,6 @@ using System.Diagnostics;
using System.Collections;
using System.Text.RegularExpressions;
using System.Configuration;
-#if WHIDBEY
-using ConfigurationSettings = System.Configuration.ConfigurationManager;
-#endif
namespace IKVM.Internal
{
@@ -83,7 +80,7 @@ namespace IKVM.Internal
Trace.AutoFlush = true;
Trace.Listeners.Add(new MyTextWriterTraceListener(Console.Error));
/* If the app config file gives some method trace - add it */
- string trace = ConfigurationSettings.AppSettings["Traced Methods"];
+ string trace = ConfigurationManager.AppSettings["Traced Methods"];
if(trace != null)
{
methodtraces.Add(trace);
diff --git a/runtime/verifier.cs b/runtime/verifier.cs
index a7c856ee..d84760c3 100644
--- a/runtime/verifier.cs
+++ b/runtime/verifier.cs
@@ -26,7 +26,6 @@ using System;
using System.IO;
using System.Collections;
using System.Diagnostics;
-using IKVM.Runtime;
using IKVM.Internal;
using InstructionFlags = IKVM.Internal.ClassFile.Method.InstructionFlags;
diff --git a/runtime/vm.cs b/runtime/vm.cs
index fd8f5827..9d25569b 100644
--- a/runtime/vm.cs
+++ b/runtime/vm.cs
@@ -30,7 +30,6 @@ using System.Diagnostics;
using System.Text;
using System.Security;
using System.Security.Permissions;
-using IKVM.Attributes;
using IKVM.Internal;
#if !STATIC_COMPILER && !COMPACT_FRAMEWORK
@@ -182,12 +181,7 @@ namespace IKVM.Internal
{
get
{
-#if WHIDBEY
return Environment.OSVersion.Platform == PlatformID.Unix;
-#else
- PlatformID pid = Environment.OSVersion.Platform;
- return pid != PlatformID.Win32NT && pid != PlatformID.Win32S && pid != PlatformID.Win32Windows && pid != PlatformID.WinCE;
-#endif
}
}
@@ -231,11 +225,7 @@ namespace IKVM.Internal
messageBox = winForms.GetType("System.Windows.Forms.MessageBox");
}
#endif
- new ReflectionPermission(ReflectionPermissionFlag.MemberAccess
-#if !WHIDBEY
- | ReflectionPermissionFlag.TypeInformation
-#endif
- ).Assert();
+ new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Assert();
message = String.Format("****** Critical Failure: {1} ******{0}{0}" +
"PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE{0}{0}" +
(messageBox != null ? "(on Windows you can use Ctrl+C to copy the contents of this message to the clipboard){0}{0}" : "") +
@@ -280,7 +270,7 @@ namespace IKVM.Internal
// with can be different from the one we're compiling against.)
internal static Type LoadType(Type type)
{
-#if WHIDBEY && STATIC_COMPILER
+#if STATIC_COMPILER
return StaticCompiler.GetType(type.FullName);
#else
return type;