This commit is contained in:
jfrijters 2006-04-10 09:09:09 +00:00
Родитель fb2bae9073
Коммит 69be416b18
29 изменённых файлов: 653 добавлений и 423 удалений

Просмотреть файл

@ -5,6 +5,7 @@ Miguel de Icaza
Chris Laffra
Alan Macek
Jonathan Pierce
KiYun Roe
Stephen Schaub
Brian Sletten
Zoltan Varga

Просмотреть файл

@ -503,6 +503,7 @@
../../classpath/gnu/java/net/BASE64.java
../../classpath/gnu/java/net/CRLFInputStream.java
../../classpath/gnu/java/net/CRLFOutputStream.java
../../classpath/gnu/java/net/DefaultContentHandlerFactory.java
../../classpath/gnu/java/net/EmptyX509TrustManager.java
../../classpath/gnu/java/net/GetLocalHostAction.java
../../classpath/gnu/java/net/HeaderFieldHelper.java
@ -3336,6 +3337,7 @@
../../classpath/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
../../classpath/javax/swing/ComboBoxEditor.java
../../classpath/javax/swing/ComboBoxModel.java
../../classpath/javax/swing/CompatibilityFocusTraversalPolicy.java
../../classpath/javax/swing/ComponentInputMap.java
../../classpath/javax/swing/DebugGraphics.java
../../classpath/javax/swing/DefaultBoundedRangeModel.java
@ -4330,7 +4332,6 @@
../../classpath/org/omg/PortableInterceptor/ObjectReferenceFactory.java
../../classpath/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
../../classpath/org/omg/PortableInterceptor/ObjectReferenceFactoryHolder.java
../../classpath/org/omg/PortableInterceptor/ObjectReferenceFactoryOperations.java
../../classpath/org/omg/PortableInterceptor/ObjectReferenceTemplate.java
../../classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
../../classpath/org/omg/PortableInterceptor/ObjectReferenceTemplateHolder.java

Просмотреть файл

@ -11,7 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ikvmstub", "ikvmstub\ikvmst
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ikvmc", "ikvmc\ikvmc.csproj", "{4CA3F3DF-D2B7-4FA2-874C-BFC4B04286A2}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ikvmc", "ikvmc.csproj", "{4CA3F3DF-D2B7-4FA2-874C-BFC4B04286A2}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject

Просмотреть файл

@ -100,7 +100,7 @@ public class Starter
Console.Error.WriteLine("Saving dynamic assembly...");
try
{
JVM.SaveDebugImage(clazz);
IKVM.Internal.Starter.SaveDebugImage(clazz);
Console.Error.WriteLine("Saving done.");
}
catch(Exception x)
@ -154,12 +154,12 @@ public class Starter
else if(args[i] == "-Xsave")
{
saveAssembly = true;
JVM.PrepareForSaveDebugImage();
IKVM.Internal.Starter.PrepareForSaveDebugImage();
}
else if(args[i] == "-XXsave")
{
saveAssemblyX = true;
JVM.PrepareForSaveDebugImage();
IKVM.Internal.Starter.PrepareForSaveDebugImage();
}
else if(args[i] == "-Xtime")
{
@ -335,7 +335,7 @@ public class Starter
}
if(bootclasspath != null)
{
JVM.SetBootstrapClassLoader(new PathClassLoader(bootclasspath, null));
IKVM.Internal.Starter.SetBootstrapClassLoader(new PathClassLoader(bootclasspath, null));
}
java.lang.Class clazz = java.lang.Class.forName(mainClass, true, java.lang.ClassLoader.getSystemClassLoader());
Method method = FindMainMethod(clazz);
@ -372,7 +372,7 @@ public class Starter
{
if(saveAssemblyX)
{
JVM.SaveDebugImage(clazz);
IKVM.Internal.Starter.SaveDebugImage(clazz);
}
}
}
@ -393,7 +393,7 @@ public class Starter
{
// HACK without this hack, clazz.getDeclaredMethods would throw a NoClassDefFoundError if any
// of the methods in the class had an unloadable parameter type, but we don't want that.
JVM.EnableReflectionOnMethodsWithUnloadableTypeParameters = true;
IKVM.Internal.Starter.EnableReflectionOnMethodsWithUnloadableTypeParameters = true;
try
{
while(clazz != null)
@ -415,7 +415,7 @@ public class Starter
}
finally
{
JVM.EnableReflectionOnMethodsWithUnloadableTypeParameters = false;
IKVM.Internal.Starter.EnableReflectionOnMethodsWithUnloadableTypeParameters = false;
}
}
}

184
ikvmc.csproj Normal file
Просмотреть файл

@ -0,0 +1,184 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{4CA3F3DF-D2B7-4FA2-874C-BFC4B04286A2}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "ikvmc"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Exe"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "ikvmc"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE;STATIC_COMPILER"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "ikvmc\bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE;STATIC_COMPILER"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "ikvmc\bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
/>
<Reference
Name = "ICSharpCode.SharpZipLib"
AssemblyName = "ICSharpCode.SharpZipLib"
HintPath = "..\bin\ICSharpCode.SharpZipLib.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
<Reference
Name = "IKVM.Runtime"
Project = "{F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "ikvmc\AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\BigEndianBinaryReader.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\ByteCode.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\ClassFile.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\ClassLoaderWrapper.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\CodeEmitter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\compiler.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\CompilerClassLoader.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\CoreClasses.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\DynamicClassLoader.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ikvmc\Compiler.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\JavaException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\MemberWrapper.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\profiler.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\remapper.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\TypeWrapper.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\verifier.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "runtime\vm.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

Просмотреть файл

@ -30,7 +30,7 @@ using System.Threading;
using ICSharpCode.SharpZipLib.Zip;
using IKVM.Internal;
class Compiler
class IkvmcCompiler
{
private static string manifestMainClass;
private static ArrayList classes = new ArrayList();

Просмотреть файл

@ -2,7 +2,7 @@
<project name="ikvmc" default="ikvmc">
<target name="ikvmc">
<property overwrite="false" name="signed" value="" />
<property name="defs" value="TRACE" />
<property name="defs" value="TRACE;STATIC_COMPILER" />
<if test="${property::exists('signed')}">
<property name="defs" value="${defs};${signed}" />
</if>
@ -11,7 +11,24 @@
</if>
<csc target="exe" output="../bin/ikvmc.exe" define="${defs}">
<sources>
<include name="*.cs" />
<include name="AssemblyInfo.cs" />
<include name="Compiler.cs" />
<include name="../runtime/BigEndianBinaryReader.cs" />
<include name="../runtime/ByteCode.cs" />
<include name="../runtime/ClassFile.cs" />
<include name="../runtime/ClassLoaderWrapper.cs" />
<include name="../runtime/CodeEmitter.cs" />
<include name="../runtime/compiler.cs" />
<include name="../runtime/CompilerClassLoader.cs" />
<include name="../runtime/CoreClasses.cs" />
<include name="../runtime/DynamicClassLoader.cs" />
<include name="../runtime/JavaException.cs" />
<include name="../runtime/MemberWrapper.cs" />
<include name="../runtime/profiler.cs" />
<include name="../runtime/remapper.cs" />
<include name="../runtime/TypeWrapper.cs" />
<include name="../runtime/verifier.cs" />
<include name="../runtime/vm.cs" />
</sources>
<references>
<include name="../bin/IKVM.Runtime.dll" asis="true" />

Просмотреть файл

@ -1,100 +0,0 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{4CA3F3DF-D2B7-4FA2-874C-BFC4B04286A2}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "ikvmc"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Exe"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "ikvmc"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "IKVM.Runtime"
Project = "{F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
<Reference
Name = "ICSharpCode.SharpZipLib"
AssemblyName = "ICSharpCode.SharpZipLib"
HintPath = "..\bin\ICSharpCode.SharpZipLib.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Compiler.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2003, 2004, 2005 Jeroen Frijters
Copyright (C) 2002, 2003, 2004, 2005, 2006 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

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2004 Jeroen Frijters
Copyright (C) 2002, 2004, 2005 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

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002 Jeroen Frijters
Copyright (C) 2002, 2004, 2005, 2006 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

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2003, 2004, 2005 Jeroen Frijters
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
@ -412,8 +412,9 @@ namespace IKVM.Internal
}
annotations = ReadAnnotations(br, this);
break;
#if STATIC_COMPILER
case "RuntimeInvisibleAnnotations":
if(majorVersion < 49 || !JVM.IsStaticCompiler)
if(majorVersion < 49)
{
goto default;
}
@ -426,6 +427,7 @@ namespace IKVM.Internal
}
}
break;
#endif
case "IKVM.NET.Assembly":
if(br.ReadUInt32() != 2)
{
@ -1124,7 +1126,10 @@ namespace IKVM.Internal
}
catch(RetargetableJavaException x)
{
if(!JVM.IsStaticCompiler && Tracer.ClassLoading.TraceError)
// HACK keep the compiler from warning about unused local
GC.KeepAlive(x);
#if !STATIC_COMPILER
if(Tracer.ClassLoading.TraceError)
{
object cl = classLoader.GetJavaClassLoader();
if(cl != null)
@ -1151,6 +1156,7 @@ namespace IKVM.Internal
Exception m = IKVM.Runtime.Util.MapException(x.ToJava());
Tracer.Error(Tracer.ClassLoading, m.ToString() + Environment.NewLine + m.StackTrace);
}
#endif // !STATIC_COMPILER
return new UnloadableTypeWrapper(name);
}
}
@ -1928,8 +1934,9 @@ namespace IKVM.Internal
}
annotations = ReadAnnotations(br, classFile);
break;
#if STATIC_COMPILER
case "RuntimeInvisibleAnnotations":
if(classFile.MajorVersion < 49 || !JVM.IsStaticCompiler)
if(classFile.MajorVersion < 49)
{
goto default;
}
@ -1942,6 +1949,7 @@ namespace IKVM.Internal
}
}
break;
#endif
default:
br.Skip(br.ReadUInt32());
break;
@ -2066,8 +2074,9 @@ namespace IKVM.Internal
}
break;
}
#if STATIC_COMPILER
case "RuntimeInvisibleAnnotations":
if(classFile.MajorVersion < 49 || !JVM.IsStaticCompiler)
if(classFile.MajorVersion < 49)
{
goto default;
}
@ -2080,6 +2089,7 @@ namespace IKVM.Internal
}
}
break;
#endif
default:
br.Skip(br.ReadUInt32());
break;

Просмотреть файл

@ -28,7 +28,6 @@ using System.Reflection.Emit;
#endif
using System.IO;
using System.Collections;
using System.Xml;
using System.Diagnostics;
using IKVM.Attributes;
using IKVM.Runtime;
@ -44,7 +43,9 @@ namespace IKVM.Internal
#endif
private static readonly Hashtable typeToTypeWrapper = Hashtable.Synchronized(new Hashtable());
private static ClassLoaderWrapper bootstrapClassLoader;
#if !STATIC_COMPILER
private static ClassLoaderWrapper systemClassLoader;
#endif
private object javaClassLoader;
protected Hashtable types = new Hashtable();
private ArrayList nativeLibraries;
@ -440,6 +441,7 @@ namespace IKVM.Internal
return GetBootstrapClassLoader().LoadClassByDottedNameFast(name, throwClassNotFoundException);
}
#endif
#if !STATIC_COMPILER
// NOTE just like Java does (I think), we take the classloader lock before calling the loadClass method
lock(javaClassLoader)
{
@ -465,6 +467,9 @@ namespace IKVM.Internal
// while we're holding the lock on the class loader object
return RegisterInitiatingLoader(type);
}
#else
return null;
#endif
}
finally
{
@ -844,18 +849,19 @@ namespace IKVM.Internal
internal static ClassLoaderWrapper GetSystemClassLoader()
{
#if STATIC_COMPILER
// during static compilation, we don't have a system class loader
if(JVM.IsStaticCompiler)
{
return GetBootstrapClassLoader();
}
return GetBootstrapClassLoader();
#else
if(systemClassLoader == null)
{
systemClassLoader = GetClassLoaderWrapper(JVM.Library.getSystemClassLoader());
}
return systemClassLoader;
#endif
}
#if !STATIC_COMPILER
internal static ClassLoaderWrapper GetClassLoaderWrapper(object javaClassLoader)
{
if(javaClassLoader == null || GetBootstrapClassLoader().javaClassLoader == javaClassLoader)
@ -873,6 +879,7 @@ namespace IKVM.Internal
return wrapper;
}
}
#endif
// This only returns the wrapper for a Type if that wrapper has already been created, otherwise
// it returns null
@ -932,12 +939,14 @@ namespace IKVM.Internal
typeToTypeWrapper.Add(type, wrapper);
}
#if STATIC_COMPILER
internal static void PublishLibraryImplementationHelperType(Type type)
{
CompiledTypeWrapper typeWrapper = CompiledTypeWrapper.newInstance(type.FullName, type);
SetWrapperForType(type, typeWrapper);
GetBootstrapClassLoader().types[type.FullName] = typeWrapper;
}
#endif // STATIC_COMPILER
internal static TypeWrapper LoadClassCritical(string name)
{

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2004, 2005 Jeroen Frijters
Copyright (C) 2002, 2004, 2005, 2006 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
@ -549,9 +549,11 @@ namespace IKVM.Internal
}
}
#if STATIC_COMPILER
public abstract class CodeEmitter
{
internal abstract void Emit(CountingILGenerator ilgen);
}
#endif
}
#endif

Просмотреть файл

@ -21,7 +21,7 @@
jeroen@frijters.net
*/
#if !NO_STATIC_COMPILER && !COMPACT_FRAMEWORK
#if STATIC_COMPILER && !COMPACT_FRAMEWORK
using System;
using System.Reflection;
using System.Reflection.Emit;
@ -247,7 +247,7 @@ namespace IKVM.Internal
internal void Save()
{
Tracer.Info(Tracer.Compiler, "CompilerClassLoader.Save...");
FinishAll();
FinishAll(false);
ModuleBuilder.CreateGlobalFunctions();
@ -1756,36 +1756,80 @@ namespace IKVM.Internal
}
}
public class CompilerOptions
class CompilerOptions
{
public string path;
public string keyfilename;
public string keycontainer;
public string version;
public string fileversion;
public bool targetIsModule;
public string assembly;
public string mainClass;
public ApartmentState apartment;
public PEFileKinds target;
public bool guessFileKind;
public byte[][] classes;
public string[] references;
public bool nojni;
public Hashtable resources;
public string[] classesToExclude;
public string remapfile;
public Hashtable props;
public bool noglobbing;
public bool nostacktraceinfo;
public bool removeUnusedFields;
public bool compressedResources;
public bool strictFinalFieldSemantics;
public string runtimeAssembly;
public string[] privatePackages;
internal string path;
internal string keyfilename;
internal string keycontainer;
internal string version;
internal string fileversion;
internal bool targetIsModule;
internal string assembly;
internal string mainClass;
internal ApartmentState apartment;
internal PEFileKinds target;
internal bool guessFileKind;
internal byte[][] classes;
internal string[] references;
internal bool nojni;
internal Hashtable resources;
internal string[] classesToExclude;
internal string remapfile;
internal Hashtable props;
internal bool noglobbing;
internal bool nostacktraceinfo;
internal bool removeUnusedFields;
internal bool compressedResources;
internal bool strictFinalFieldSemantics;
internal string runtimeAssembly;
internal string[] privatePackages;
}
public class AotCompiler
class StaticCompiler
{
internal static Assembly runtimeAssembly;
internal static Type GetType(string name)
{
return GetType(name, true);
}
internal static Type GetType(string name, bool throwOnError)
{
if(runtimeAssembly.GetType(name) != null)
{
return runtimeAssembly.GetType(name);
}
#if WHIDBEY
foreach(Assembly asm in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies())
{
Type t = asm.GetType(name, false);
if(t != null)
{
return t;
}
}
// 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
}
}
class AotCompiler
{
private static bool IsSigned(Assembly asm)
{
@ -1793,29 +1837,34 @@ namespace IKVM.Internal
return key != null && key.Length != 0;
}
public static int Compile(CompilerOptions options)
internal static int Compile(CompilerOptions options)
{
Tracer.Info(Tracer.Compiler, "JVM.Compile path: {0}, assembly: {1}", options.path, options.assembly);
JVM.IsStaticCompiler = true;
JVM.NoJniStubs = options.nojni;
JVM.NoStackTraceInfo = options.nostacktraceinfo;
JVM.StrictFinalFieldSemantics = options.strictFinalFieldSemantics;
Assembly runtimeAssembly;
#if WHIDBEY
if(options.runtimeAssembly == null)
{
runtimeAssembly = typeof(JVM).Assembly;
Assembly.ReflectionOnlyLoadFrom(runtimeAssembly.Location);
Assembly.ReflectionOnlyLoadFrom(typeof(ByteCodeHelper).Assembly.Location);
}
else
{
runtimeAssembly = Assembly.ReflectionOnlyLoadFrom(options.runtimeAssembly);
}
#else
runtimeAssembly = typeof(JVM).Assembly;
if(options.runtimeAssembly == null)
{
StaticCompiler.runtimeAssembly = typeof(ByteCodeHelper).Assembly;
}
else
{
StaticCompiler.runtimeAssembly = Assembly.LoadFrom(options.runtimeAssembly);
}
#endif
AssemblyName runtimeAssemblyName = runtimeAssembly.GetName();
bool allReferencesAreStrongNamed = IsSigned(runtimeAssembly);
Tracer.Info(Tracer.Compiler, "Loaded runtime assembly: {0}", StaticCompiler.runtimeAssembly.FullName);
AssemblyName runtimeAssemblyName = StaticCompiler.runtimeAssembly.GetName();
bool allReferencesAreStrongNamed = IsSigned(StaticCompiler.runtimeAssembly);
foreach(string r in options.references)
{
try
@ -1834,6 +1883,11 @@ namespace IKVM.Internal
Console.Error.WriteLine("Error: reference not found: {0}", r);
return 1;
}
// 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
@ -1842,7 +1896,7 @@ namespace IKVM.Internal
{
if(asmref.Name == runtimeAssemblyName.Name)
{
if(IsSigned(runtimeAssembly))
if(IsSigned(StaticCompiler.runtimeAssembly))
{
if(asmref.FullName != runtimeAssemblyName.FullName)
{
@ -2048,11 +2102,11 @@ namespace IKVM.Internal
return 1;
}
if(runtimeAssembly.GetType("gnu.classpath.Pointer") != null)
if(StaticCompiler.runtimeAssembly.GetType("gnu.classpath.Pointer") != null)
{
ClassLoaderWrapper.PublishLibraryImplementationHelperType(JVM.LoadType(typeof(gnu.classpath.Pointer)));
}
if(runtimeAssembly.GetType("ikvm.internal.LibraryVMInterface") != null)
if(StaticCompiler.runtimeAssembly.GetType("ikvm.internal.LibraryVMInterface") != null)
{
ClassLoaderWrapper.PublishLibraryImplementationHelperType(JVM.LoadType(typeof(ikvm.@internal.LibraryVMInterface)));
}
@ -2199,4 +2253,4 @@ namespace IKVM.Internal
}
}
}
#endif //!NO_STATIC_COMPILER && !COMPACT_FRAMEWORK
#endif // STATIC_COMPILER && !COMPACT_FRAMEWORK

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2004, 2005 Jeroen Frijters
Copyright (C) 2004, 2005, 2006 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -24,22 +24,22 @@
namespace IKVM.Internal
{
public sealed class CoreClasses
internal sealed class CoreClasses
{
public sealed class java
internal sealed class java
{
public sealed class lang
internal sealed class lang
{
public sealed class Object
internal sealed class Object
{
private Object() {}
// NOTE we have a dummy static initializer, to make sure we don't get the beforeFieldInit attribute
// (we don't want the classes to be loaded prematurely, because they might not be available then)
static Object() {}
public static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.Object");
internal static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.Object");
}
public sealed class String
internal sealed class String
{
private String() {}
// NOTE we have a dummy static initializer, to make sure we don't get the beforeFieldInit attribute
@ -48,22 +48,22 @@ namespace IKVM.Internal
internal static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.String");
}
public sealed class Class
internal sealed class Class
{
private Class() {}
// NOTE we have a dummy static initializer, to make sure we don't get the beforeFieldInit attribute
// (we don't want the classes to be loaded prematurely, because they might not be available then)
static Class() {}
public static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.Class");
internal static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.Class");
}
public sealed class Throwable
internal sealed class Throwable
{
private Throwable() {}
// NOTE we have a dummy static initializer, to make sure we don't get the beforeFieldInit attribute
// (we don't want the classes to be loaded prematurely, because they might not be available then)
static Throwable() {}
public static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.Throwable");
internal static readonly TypeWrapper Wrapper = ClassLoaderWrapper.LoadClassCritical("java.lang.Throwable");
}
}
}

Просмотреть файл

@ -79,10 +79,15 @@ namespace IKVM.Internal
{
type.Finish();
}
#if !STATIC_COMPILER
catch(RetargetableJavaException x)
{
throw x.ToJava();
}
#endif // !STATIC_COMPILER
finally
{
}
// NOTE We used to remove the type from the hashtable here, but that creates a race condition if
// another thread also fires the OnTypeResolve event while we're baking the type.
// I really would like to remove the type from the hashtable, but at the moment I don't see
@ -125,10 +130,9 @@ namespace IKVM.Internal
Debug.Assert(!dynamicTypes.ContainsKey(type.TypeAsTBD.FullName));
dynamicTypes.Add(type.TypeAsTBD.FullName, type);
types[f.Name] = type;
if (!JVM.IsStaticCompiler)
{
type.SetClassObject(JVM.Library.newClass(type, protectionDomain));
}
#if !STATIC_COMPILER
type.SetClassObject(JVM.Library.newClass(type, protectionDomain));
#endif
}
else
{
@ -171,9 +175,9 @@ namespace IKVM.Internal
}
}
internal static void FinishAll()
internal static void FinishAll(bool forDebug)
{
JVM.FinishingForDebugSave = true;
JVM.FinishingForDebugSave = forDebug;
while(dynamicTypes.Count > 0)
{
ArrayList l = new ArrayList(dynamicTypes.Values);
@ -187,9 +191,10 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
internal static void SaveDebugImage(object mainClass)
{
FinishAll();
FinishAll(true);
TypeWrapper mainTypeWrapper = TypeWrapper.FromClass(mainClass);
mainTypeWrapper.Finish();
Type mainType = mainTypeWrapper.TypeAsTBD;
@ -205,6 +210,7 @@ namespace IKVM.Internal
}
}
}
#endif
internal static void RegisterForSaveDebug(AssemblyBuilder ab)
{
@ -272,10 +278,9 @@ namespace IKVM.Internal
// FXBUG the 1.1 CLR doesn't like type names that end with a period.
if(nameClashHash.ContainsKey(name) || name.EndsWith("."))
{
if(JVM.IsStaticCompiler)
{
Tracer.Warning(Tracer.Compiler, "Class name clash: {0}", name);
}
#if STATIC_COMPILER
Tracer.Warning(Tracer.Compiler, "Class name clash: {0}", name);
#endif
return name + "/" + instanceId;
}
else

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002 Jeroen Frijters
Copyright (C) 2002, 2004, 2005 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

Просмотреть файл

@ -68,11 +68,6 @@
Name = "System"
AssemblyName = "System"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
</References>
</Build>
<Files>
@ -127,11 +122,6 @@
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CompilerClassLoader.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CoreClasses.cs"
SubType = "Code"
@ -167,11 +157,6 @@
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "remapper.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "tracer.cs"
SubType = "Code"

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2003, 2004 Jeroen Frijters
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
@ -36,7 +36,9 @@ abstract class RetargetableJavaException : ApplicationException
{
}
#if !STATIC_COMPILER
internal abstract Exception ToJava();
#endif
}
// NOTE this is not a Java exception, but instead it wraps a Java exception that
@ -50,10 +52,12 @@ class ClassLoadingException : RetargetableJavaException
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return InnerException;
}
#endif
}
class LinkageError : RetargetableJavaException
@ -66,10 +70,12 @@ class LinkageError : RetargetableJavaException
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newLinkageError(Message);
}
#endif
}
class VerifyError : LinkageError
@ -86,10 +92,12 @@ class VerifyError : LinkageError
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newVerifyError(Message);
}
#endif
}
class ClassNotFoundException : RetargetableJavaException
@ -98,10 +106,12 @@ class ClassNotFoundException : RetargetableJavaException
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newClassNotFoundException(Message);
}
#endif
}
class ClassCircularityError : LinkageError
@ -110,10 +120,12 @@ class ClassCircularityError : LinkageError
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newClassCircularityError(Message);
}
#endif
}
class NoClassDefFoundError : LinkageError
@ -122,10 +134,12 @@ class NoClassDefFoundError : LinkageError
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newNoClassDefFoundError(Message);
}
#endif
}
class IncompatibleClassChangeError : LinkageError
@ -134,10 +148,12 @@ class IncompatibleClassChangeError : LinkageError
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newIncompatibleClassChangeError(Message);
}
#endif
}
class IllegalAccessError : IncompatibleClassChangeError
@ -146,10 +162,12 @@ class IllegalAccessError : IncompatibleClassChangeError
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newIllegalAccessError(Message);
}
#endif
}
internal class ClassFormatError : LinkageError
@ -159,10 +177,12 @@ internal class ClassFormatError : LinkageError
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newClassFormatError(Message);
}
#endif
}
internal class UnsupportedClassVersionError : ClassFormatError
@ -172,10 +192,12 @@ internal class UnsupportedClassVersionError : ClassFormatError
{
}
#if !STATIC_COMPILER
internal override Exception ToJava()
{
return JVM.Library.newUnsupportedClassVersionError(Message);
}
#endif
}
sealed class JavaException
@ -191,6 +213,7 @@ sealed class JavaException
return String.Format(s, args);
}
#if !STATIC_COMPILER
internal static Exception IllegalAccessError(string s, params object[] args)
{
return JVM.Library.newIllegalAccessError(Format(s, args));
@ -302,4 +325,5 @@ sealed class JavaException
{
return JVM.Library.newIllegalMonitorStateException();
}
#endif // !STATIC_COMPILER
}

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2003, 2004, 2005 Jeroen Frijters
Copyright (C) 2002, 2003, 2004, 2005, 2006 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

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2003, 2004, 2005 Jeroen Frijters
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
@ -300,6 +300,7 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
[HideFromJava]
internal override object Invoke(object obj, object[] args, bool nonVirtual)
{
@ -309,6 +310,7 @@ namespace IKVM.Internal
ResolveGhostMethod();
return InvokeImpl(ghostMethod, wrapper, args, nonVirtual);
}
#endif // !STATIC_COMPILER
}
internal static MethodWrapper Create(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
@ -547,6 +549,7 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
[HideFromJava]
internal virtual object Invoke(object obj, object[] args, bool nonVirtual)
{
@ -892,6 +895,7 @@ namespace IKVM.Internal
return args;
}
}
#endif // !STATIC_COMPILER
#if !COMPACT_FRAMEWORK
internal static OpCode SimpleOpCodeToOpCode(SimpleOpCode opc)
@ -1142,6 +1146,7 @@ namespace IKVM.Internal
Debug.Assert(fieldType != null, this.DeclaringType.Name + "::" + this.Name + " (" + this.Signature+ ")");
}
#if !STATIC_COMPILER
// NOTE used (thru IKVM.Runtime.Util.GetFieldConstantValue) by ikvmstub to find out if the
// field is a constant (and if it is, to get its value)
internal object GetConstant()
@ -1187,6 +1192,7 @@ namespace IKVM.Internal
}
return null;
}
#endif // !STATIC_COMPILER
internal static FieldWrapper FromCookie(IntPtr cookie)
{
@ -1279,6 +1285,7 @@ namespace IKVM.Internal
Debug.Assert(field != null);
}
#if !STATIC_COMPILER
internal virtual void SetValue(object obj, object val)
{
AssertLinked();
@ -1302,6 +1309,7 @@ namespace IKVM.Internal
throw JavaException.IllegalAccessException(x.Message);
}
}
#endif // !STATIC_COMPILER
internal virtual object GetValue(object obj)
{
@ -1311,6 +1319,9 @@ namespace IKVM.Internal
{
LookupField();
}
#if STATIC_COMPILER
return field.GetValue(null);
#else
// FieldInfo.IsLiteral is expensive, so we have our own flag
// TODO we might be able to ensure that we always use ConstantFieldWrapper for literal fields,
// in that case the we could simply remove the check altogether.
@ -1325,6 +1336,7 @@ namespace IKVM.Internal
val = fieldType.GhostRefField.GetValue(val);
}
return val;
#endif // STATIC_COMPILER
}
}
@ -1679,6 +1691,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Call, setter);
}
#if !STATIC_COMPILER
internal override object GetValue(object obj)
{
// We're MemberFlags.HideFromReflection, so we should never be called
@ -1690,6 +1703,7 @@ namespace IKVM.Internal
// We're MemberFlags.HideFromReflection, so we should never be called
throw new InvalidOperationException();
}
#endif // !STATIC_COMPILER
}
#endif
@ -1733,6 +1747,7 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
internal override object GetValue(object obj)
{
// We're MemberFlags.HideFromReflection, so we should never be called
@ -1744,5 +1759,6 @@ namespace IKVM.Internal
// We're MemberFlags.HideFromReflection, so we should never be called
throw new InvalidOperationException();
}
#endif // !STATIC_COMPILER
}
}

Просмотреть файл

@ -129,35 +129,6 @@ namespace IKVM.Internal
ilgen.MarkLabel(ok);
}
}
class StaticCompiler
{
internal static Type GetType(string name)
{
#if WHIDBEY
foreach(Assembly asm in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies())
{
Type t = asm.GetType(name, false);
if(t != null)
{
return t;
}
}
// try mscorlib as well
return typeof(object).Assembly.GetType(name, true);
#else
foreach(Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
{
Type t = asm.GetType(name, false);
if(t != null)
{
return t;
}
}
throw new TypeLoadException(name);
#endif
}
}
#endif
class AttributeHelper
@ -264,7 +235,7 @@ namespace IKVM.Internal
throw new NotImplementedException();
}
}
#if !NO_STATIC_COMPILER && !COMPACT_FRAMEWORK
#if STATIC_COMPILER && !COMPACT_FRAMEWORK
private static void SetPropertiesAndFields(Attribute attrib, IKVM.Internal.MapXml.Attribute attr)
{
Type t = attrib.GetType();
@ -507,18 +478,12 @@ namespace IKVM.Internal
#endif
#if !COMPACT_FRAMEWORK
#if STATIC_COMPILER
internal static void SetEditorBrowsableNever(MethodBuilder mb)
{
if(editorBrowsableNever == null)
{
if(JVM.IsStaticCompiler)
{
editorBrowsableNever = new CustomAttributeBuilder(StaticCompiler.GetType("System.ComponentModel.EditorBrowsableAttribute").GetConstructor(new Type[] { StaticCompiler.GetType("System.ComponentModel.EditorBrowsableState") }), new object[] { (int)System.ComponentModel.EditorBrowsableState.Never });
}
else
{
editorBrowsableNever = new CustomAttributeBuilder(typeof(System.ComponentModel.EditorBrowsableAttribute).GetConstructor(new Type[] { typeof(System.ComponentModel.EditorBrowsableState) }), new object[] { System.ComponentModel.EditorBrowsableState.Never });
}
editorBrowsableNever = new CustomAttributeBuilder(StaticCompiler.GetType("System.ComponentModel.EditorBrowsableAttribute").GetConstructor(new Type[] { StaticCompiler.GetType("System.ComponentModel.EditorBrowsableState") }), new object[] { (int)System.ComponentModel.EditorBrowsableState.Never });
}
mb.SetCustomAttribute(editorBrowsableNever);
}
@ -527,17 +492,11 @@ namespace IKVM.Internal
{
if(editorBrowsableNever == null)
{
if(JVM.IsStaticCompiler)
{
editorBrowsableNever = new CustomAttributeBuilder(StaticCompiler.GetType("System.ComponentModel.EditorBrowsableAttribute").GetConstructor(new Type[] { StaticCompiler.GetType("System.ComponentModel.EditorBrowsableState") }), new object[] { (int)System.ComponentModel.EditorBrowsableState.Never });
}
else
{
editorBrowsableNever = new CustomAttributeBuilder(typeof(System.ComponentModel.EditorBrowsableAttribute).GetConstructor(new Type[] { typeof(System.ComponentModel.EditorBrowsableState) }), new object[] { System.ComponentModel.EditorBrowsableState.Never });
}
editorBrowsableNever = new CustomAttributeBuilder(StaticCompiler.GetType("System.ComponentModel.EditorBrowsableAttribute").GetConstructor(new Type[] { StaticCompiler.GetType("System.ComponentModel.EditorBrowsableState") }), new object[] { (int)System.ComponentModel.EditorBrowsableState.Never });
}
pb.SetCustomAttribute(editorBrowsableNever);
}
#endif // STATIC_COMPILER
internal static void SetDeprecatedAttribute(MethodBase mb)
{
@ -621,7 +580,7 @@ namespace IKVM.Internal
CustomAttributeBuilder cab = new CustomAttributeBuilder(typeofHideFromReflectionAttribute.GetConstructor(Type.EmptyTypes), new object[0]);
pb.SetCustomAttribute(cab);
}
#endif
#endif // !COMPACT_FRAMEWORK
internal static bool IsHideFromReflection(MethodInfo mi)
{
@ -1414,7 +1373,7 @@ namespace IKVM.Internal
HasStaticInitializer = 4
}
public abstract class TypeWrapper
internal abstract class TypeWrapper
{
private readonly string name; // java name (e.g. java.lang.Object)
private readonly Modifiers modifiers;
@ -1422,7 +1381,9 @@ namespace IKVM.Internal
private MethodWrapper[] methods;
private FieldWrapper[] fields;
private readonly TypeWrapper baseWrapper;
#if !STATIC_COMPILER
private object classObject;
#endif
internal static readonly TypeWrapper[] EmptyArray = new TypeWrapper[0];
internal const Modifiers UnloadableModifiersHack = Modifiers.Final | Modifiers.Interface | Modifiers.Private;
internal const Modifiers VerifierTypeModifiersHack = Modifiers.Final | Modifiers.Interface;
@ -1438,6 +1399,7 @@ namespace IKVM.Internal
this.baseWrapper = baseWrapper;
}
#if !STATIC_COMPILER
internal void SetClassObject(object classObject)
{
this.classObject = classObject;
@ -1465,6 +1427,7 @@ namespace IKVM.Internal
{
return (TypeWrapper)JVM.Library.getWrapperFromClass(classObject);
}
#endif // !STATIC_COMPILER
public override string ToString()
{
@ -2569,6 +2532,7 @@ namespace IKVM.Internal
return null;
}
#if !STATIC_COMPILER
internal virtual object GetAnnotationDefault(MethodWrapper mw)
{
MethodBase mb = mw.GetMethod();
@ -2582,6 +2546,7 @@ namespace IKVM.Internal
}
return null;
}
#endif
#if !COMPACT_FRAMEWORK
internal virtual Annotation Annotation
@ -2596,12 +2561,15 @@ namespace IKVM.Internal
class UnloadableTypeWrapper : TypeWrapper
{
#if STATIC_COMPILER
private static Hashtable warningHashtable;
#endif
internal UnloadableTypeWrapper(string name)
: base(TypeWrapper.UnloadableModifiersHack, name, null)
{
if(JVM.IsStaticCompiler && name != "<verifier>")
#if STATIC_COMPILER
if(name != "<verifier>")
{
if(warningHashtable == null)
{
@ -2619,6 +2587,7 @@ namespace IKVM.Internal
Console.Error.WriteLine("Warning: class \"{0}\" not found", name);
}
}
#endif
}
internal override ClassLoaderWrapper GetClassLoader()
@ -3137,7 +3106,9 @@ namespace IKVM.Internal
private Hashtable classCache = new Hashtable();
private FieldInfo classObjectField;
private MethodBuilder clinitMethod;
#if STATIC_COMPILER
private AnnotationBuilder annotationBuilder;
#endif
internal JavaTypeImpl(ClassFile f, DynamicTypeWrapper wrapper)
{
@ -3154,17 +3125,14 @@ namespace IKVM.Internal
ClassFile.Method m = classFile.Methods[i];
if(m.IsClassInitializer)
{
if(JVM.IsStaticCompiler)
{
if(!IsSideEffectFreeStaticInitializer(m))
{
hasclinit = true;
}
}
else
#if STATIC_COMPILER
if(!IsSideEffectFreeStaticInitializer(m))
{
hasclinit = true;
}
#else
hasclinit = true;
#endif
}
MemberFlags flags = MemberFlags.None;
if(m.IsInternal)
@ -3204,7 +3172,8 @@ namespace IKVM.Internal
baseMethodsArray = new ArrayList(baseMethods);
AddMirandaMethods(methodsArray, baseMethodsArray, wrapper);
}
if(wrapper.IsPublic && JVM.IsStaticCompiler)
#if STATIC_COMPILER
if(wrapper.IsPublic)
{
TypeWrapper baseTypeWrapper = wrapper.BaseTypeWrapper;
while(baseTypeWrapper != null && !baseTypeWrapper.IsPublic)
@ -3218,6 +3187,7 @@ namespace IKVM.Internal
baseTypeWrapper = baseTypeWrapper.BaseTypeWrapper;
}
}
#endif
if(methodsArray != null)
{
this.methods = (MethodWrapper[])methodsArray.ToArray(typeof(MethodWrapper));
@ -3244,12 +3214,14 @@ namespace IKVM.Internal
fields[i] = FieldWrapper.Create(wrapper, null, null, fld.Name, fld.Signature, new ExModifiers(fld.Modifiers, fld.IsInternal));
}
}
if(!wrapper.IsInterface && wrapper.IsPublic && JVM.IsStaticCompiler)
#if STATIC_COMPILER
if(!wrapper.IsInterface && wrapper.IsPublic)
{
ArrayList fieldsArray = new ArrayList(fields);
AddAccessStubFields(fieldsArray, wrapper);
fields = (FieldWrapper[])fieldsArray.ToArray(typeof(FieldWrapper));
}
#endif
wrapper.SetFields(fields);
// from now on we shouldn't be throwing any exceptions (to be precise, after we've
@ -3478,11 +3450,13 @@ namespace IKVM.Internal
clinitMethod = typeBuilder.DefineMethod("__<clinit>", attribs, null, null);
clinitMethod.GetILGenerator().Emit(OpCodes.Ret);
}
if(JVM.IsStaticCompiler && f.IsAnnotation)
#if STATIC_COMPILER
if(f.IsAnnotation)
{
annotationBuilder = new AnnotationBuilder(this);
((AotTypeWrapper)wrapper).SetAnnotation(annotationBuilder);
}
#endif
}
catch(Exception x)
{
@ -4097,7 +4071,7 @@ namespace IKVM.Internal
if(mb is ConstructorBuilder)
{
ILGenerator ilGenerator = ((ConstructorBuilder)mb).GetILGenerator();
Tracer.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
TraceHelper.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
if(basehasclinit && m.IsClassInitializer && !classFile.IsInterface)
{
hasclinit = true;
@ -4116,7 +4090,7 @@ namespace IKVM.Internal
if(!classFile.IsAbstract)
{
ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator();
Tracer.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
TraceHelper.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
EmitHelper.Throw(ilGenerator, "java.lang.AbstractMethodError", classFile.Name + "." + m.Name + m.Signature);
}
}
@ -4130,18 +4104,17 @@ namespace IKVM.Internal
try
{
ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator();
Tracer.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
TraceHelper.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
// do we have a native implementation in map.xml?
if(wrapper.EmitMapXmlMethodBody(ilGenerator, classFile, m))
{
continue;
}
// see if there exists a IKVM.NativeCode class for this type
Type nativeCodeType = Type.GetType("IKVM.NativeCode." + classFile.Name.Replace('$', '+'));
if(nativeCodeType != null)
{
nativeCodeType = JVM.LoadType(nativeCodeType);
}
Type nativeCodeType = null;
#if STATIC_COMPILER
nativeCodeType = StaticCompiler.GetType("IKVM.NativeCode." + classFile.Name.Replace('$', '+'), false);
#endif
MethodInfo nativeMethod = null;
TypeWrapper[] args = methods[i].GetParameters();
if(nativeCodeType != null)
@ -4220,7 +4193,7 @@ namespace IKVM.Internal
{
MethodBuilder mbld = (MethodBuilder)mb;
ILGenerator ilGenerator = mbld.GetILGenerator();
Tracer.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
TraceHelper.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
if(wrapper.EmitMapXmlMethodBody(ilGenerator, classFile, m))
{
continue;
@ -4275,9 +4248,10 @@ namespace IKVM.Internal
TypeWrapper[] interfaces = wrapper.Interfaces;
for(int i = 0; i < interfaces.Length; i++)
{
#if STATIC_COMPILER
// if we implement a ghost interface, add an implicit conversion to the ghost reference value type
// TODO do this for indirectly implemented interfaces (interfaces implemented by interfaces) as well
if(JVM.IsStaticCompiler && interfaces[i].IsGhost && wrapper.IsPublic)
if(interfaces[i].IsGhost && wrapper.IsPublic)
{
MethodBuilder mb = typeBuilder.DefineMethod("op_Implicit", MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.SpecialName, interfaces[i].TypeAsSignatureType, new Type[] { wrapper.TypeAsSignatureType });
ILGenerator ilgen = mb.GetILGenerator();
@ -4289,6 +4263,7 @@ namespace IKVM.Internal
ilgen.Emit(OpCodes.Ldobj, interfaces[i].TypeAsSignatureType);
ilgen.Emit(OpCodes.Ret);
}
#endif
interfaces[i].ImplementInterfaceMethodStubs(typeBuilder, wrapper, doneSet);
}
// if any of our base classes has an incomplete interface implementation we need to look through all
@ -4331,10 +4306,11 @@ namespace IKVM.Internal
}
}
#if STATIC_COMPILER
// If we're an interface that has public/protected fields, we create an inner class
// to expose these fields to C# (which stubbornly refuses to see fields in interfaces).
TypeBuilder tbFields = null;
if(JVM.IsStaticCompiler && classFile.IsInterface && classFile.IsPublic && !wrapper.IsGhost && classFile.Fields.Length > 0)
if(classFile.IsInterface && classFile.IsPublic && !wrapper.IsGhost && classFile.Fields.Length > 0)
{
// TODO handle name clash
tbFields = typeBuilder.DefineNestedType("__Fields", TypeAttributes.Class | TypeAttributes.NestedPublic | TypeAttributes.Sealed);
@ -4372,7 +4348,7 @@ namespace IKVM.Internal
wrapper.EmitMapXmlMetadata(typeBuilder, classFile, fields, methods);
TypeBuilder enumBuilder = null;
if(JVM.IsStaticCompiler || DynamicClassLoader.IsSaveDebugImage)
if(true)
{
// NOTE in Whidbey we can (and should) use CompilerGeneratedAttribute to mark Synthetic types
if(classFile.IsInternal || (classFile.Modifiers & (Modifiers.Synthetic | Modifiers.Annotation | Modifiers.Enum)) != 0)
@ -4424,12 +4400,14 @@ namespace IKVM.Internal
}
}
}
#endif // STATIC_COMPILER
Type type;
Profiler.Enter("TypeBuilder.CreateType");
try
{
type = typeBuilder.CreateType();
#if STATIC_COMPILER
if(tbFields != null)
{
tbFields.CreateType();
@ -4442,6 +4420,7 @@ namespace IKVM.Internal
{
annotationBuilder.Finish(this);
}
#endif
}
finally
{
@ -4464,6 +4443,29 @@ namespace IKVM.Internal
}
}
class TraceHelper
{
private readonly static MethodInfo methodIsTracedMethod = typeof(Tracer).GetMethod("IsTracedMethod");
private readonly static MethodInfo methodMethodInfo = typeof(Tracer).GetMethod("MethodInfo");
internal static void EmitMethodTrace(ILGenerator ilgen, string tracemessage)
{
if(Tracer.IsTracedMethod(tracemessage))
{
Label label = ilgen.DefineLabel();
#if STATIC_COMPILER
// TODO this should be a boolean field test instead of a call to Tracer.IsTracedMessage
ilgen.Emit(OpCodes.Ldstr, tracemessage);
ilgen.Emit(OpCodes.Call, methodIsTracedMethod);
ilgen.Emit(OpCodes.Brfalse_S, label);
#endif
ilgen.Emit(OpCodes.Ldstr, tracemessage);
ilgen.Emit(OpCodes.Call, methodMethodInfo);
ilgen.MarkLabel(label);
}
}
}
private bool IsValidAnnotationElementType(string type)
{
if(type[0] == '[')
@ -4785,7 +4787,8 @@ namespace IKVM.Internal
ilGenerator.BeginExceptionBlock();
}
string sig = m.Signature.Replace('.', '/');
FieldBuilder methodPtr = typeBuilder.DefineField(JNI.METHOD_PTR_FIELD_PREFIX + m.Name + sig, typeof(IntPtr), FieldAttributes.Static | FieldAttributes.PrivateScope);
// TODO use/unify JNI.METHOD_PTR_FIELD_PREFIX
FieldBuilder methodPtr = typeBuilder.DefineField("__<jniptr>" + m.Name + sig, typeof(IntPtr), FieldAttributes.Static | FieldAttributes.PrivateScope);
LocalBuilder localRefStruct = ilGenerator.DeclareLocal(localRefStructType);
ilGenerator.Emit(OpCodes.Ldloca, localRefStruct);
ilGenerator.Emit(OpCodes.Initobj, localRefStructType);
@ -5434,11 +5437,13 @@ namespace IKVM.Internal
ilgen.MarkLabel(skip);
ilgen.Emit(OpCodes.Ret);
}
if(JVM.IsStaticCompiler && classFile.Methods[index].AnnotationDefault != null)
#if STATIC_COMPILER
if(classFile.Methods[index].AnnotationDefault != null)
{
CustomAttributeBuilder cab = new CustomAttributeBuilder(typeof(AnnotationDefaultAttribute).GetConstructor(new Type[] { typeof(object) }), new object[] { classFile.Methods[index].AnnotationDefault });
CustomAttributeBuilder cab = new CustomAttributeBuilder(JVM.LoadType(typeof(AnnotationDefaultAttribute)).GetConstructor(new Type[] { typeof(object) }), new object[] { classFile.Methods[index].AnnotationDefault });
mb.SetCustomAttribute(cab);
}
#endif
}
wrapper.AddParameterNames(classFile, m, mb);
method = mb;
@ -6196,6 +6201,7 @@ namespace IKVM.Internal
return impl.GetEnclosingMethod();
}
#if !STATIC_COMPILER
internal override object[] GetDeclaredAnnotations()
{
object[] annotations = impl.GetDeclaredAnnotations();
@ -6220,9 +6226,10 @@ namespace IKVM.Internal
Debug.Fail("Unreachable code");
return null;
}
#endif
}
#if !NO_STATIC_COMPILER
#if STATIC_COMPILER
class AotTypeWrapper : DynamicTypeWrapper
{
private FieldInfo ghostRefField;
@ -7220,7 +7227,7 @@ namespace IKVM.Internal
}
}
}
#endif // !NO_STATIC_COMPILER
#endif // STATIC_COMPILER
#endif // !COMPACT_FRAMEWORK
class CompiledTypeWrapper : TypeWrapper
@ -7879,6 +7886,7 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
[HideFromJava]
internal override object Invoke(object obj, object[] args, bool nonVirtual)
{
@ -7909,6 +7917,7 @@ namespace IKVM.Internal
}
return InvokeImpl(mb, obj, args, nonVirtual);
}
#endif // !STATIC_COMPILER
internal string GetGenericSignature()
{
@ -8544,12 +8553,14 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
[HideFromJava]
internal override object Invoke(object obj, object[] args, bool nonVirtual)
{
// TODO map exceptions
return Delegate.CreateDelegate(DeclaringType.TypeAsTBD, args[0], "Invoke");
}
#endif // !STATIC_COMPILER
}
private class ByRefMethodWrapper : SmartMethodWrapper
@ -8615,6 +8626,7 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
[HideFromJava]
internal override object Invoke(object obj, object[] args, bool nonVirtual)
{
@ -8641,6 +8653,7 @@ namespace IKVM.Internal
}
}
}
#endif // !STATIC_COMPILER
}
internal static bool IsVisible(Type type)
@ -8664,11 +8677,13 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
[HideFromJava]
internal override object Invoke(object obj, object[] args, bool nonVirtual)
{
return Enum.ToObject(DeclaringType.TypeAsTBD, ((IConvertible)args[0]).ToInt64(null));
}
#endif // !STATIC_COMPILER
}
internal class EnumValueFieldWrapper : FieldWrapper
@ -8719,6 +8734,7 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
internal override void SetValue(object obj, object val)
{
// NOTE even though the field is final, JNI reflection can still be used to set its value!
@ -8726,6 +8742,7 @@ namespace IKVM.Internal
FieldInfo f = DeclaringType.TypeAsTBD.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)[0];
f.SetValue(obj, val);
}
#endif // !STATIC_COMPILER
// this method takes a boxed Enum and returns its value as a boxed primitive
// of the subset of Java primitives (i.e. byte, short, int, long)
@ -8762,10 +8779,12 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
internal override object GetValue(object obj)
{
return GetEnumPrimitiveValue(obj);
}
#endif // !STATIC_COMPILER
}
internal override Assembly Assembly
@ -8792,6 +8811,7 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
[HideFromJava]
internal override object Invoke(object obj, object[] args, bool nonVirtual)
{
@ -8801,6 +8821,7 @@ namespace IKVM.Internal
}
return obj;
}
#endif // !STATIC_COMPILER
}
protected override void LazyPublishMembers()
@ -9032,11 +9053,13 @@ namespace IKVM.Internal
}
#endif
#if !STATIC_COMPILER
[HideFromJava]
internal override object Invoke(object obj, object[] args, bool nonVirtual)
{
return m.Invoke(obj, args, nonVirtual);
}
#endif // !STATIC_COMPILER
}
private bool MakeMethodDescriptor(MethodBase mb, out string name, out string sig)

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2003, 2004 Jeroen Frijters
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
@ -60,19 +60,19 @@ namespace IKVM.Attributes
this.table = table;
}
internal class LineNumberWriter
public class LineNumberWriter
{
private System.IO.MemoryStream stream;
private int prevILOffset;
private int prevLineNum;
private int count;
internal LineNumberWriter(int estimatedCount)
public LineNumberWriter(int estimatedCount)
{
stream = new System.IO.MemoryStream(estimatedCount * 2);
}
internal void AddMapping(int ilOffset, int linenumber)
public void AddMapping(int ilOffset, int linenumber)
{
if(count == 0)
{
@ -129,7 +129,7 @@ namespace IKVM.Attributes
count++;
}
internal int Count
public int Count
{
get
{
@ -137,7 +137,7 @@ namespace IKVM.Attributes
}
}
internal int LineNo
public int LineNo
{
get
{
@ -145,7 +145,7 @@ namespace IKVM.Attributes
}
}
internal byte[] ToArray()
public byte[] ToArray()
{
return stream.ToArray();
}

Просмотреть файл

@ -21,7 +21,7 @@
jeroen@frijters.net
*/
#if !NO_STATIC_COMPILER && !COMPACT_FRAMEWORK
#if STATIC_COMPILER && !COMPACT_FRAMEWORK
using System;
using System.Xml.Serialization;
@ -101,7 +101,7 @@ namespace IKVM.Internal.MapXml
{
Debug.Assert(Class == null && type != null);
Type[] argTypes = ClassLoaderWrapper.GetBootstrapClassLoader().ArgTypeListFromSig(Sig);
ConstructorInfo ci = JVM.LoadType(Type.GetType(type, true)).GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.Standard, argTypes, null);
ConstructorInfo ci = StaticCompiler.GetType(type).GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.Standard, argTypes, null);
if(ci == null)
{
throw new InvalidOperationException("Missing .ctor: " + type + "..ctor" + Sig);
@ -190,10 +190,10 @@ namespace IKVM.Internal.MapXml
argTypes = new Type[types.Length];
for(int i = 0; i < types.Length; i++)
{
argTypes[i] = JVM.LoadType(Type.GetType(types[i]));
argTypes[i] = StaticCompiler.GetType(types[i]);
}
}
MethodInfo mi = JVM.LoadType(Type.GetType(type, true)).GetMethod(Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, null, argTypes, null);
MethodInfo mi = StaticCompiler.GetType(type).GetMethod(Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, null, argTypes, null);
if(mi == null)
{
throw new InvalidOperationException("Missing method: " + type + "." + Name + Sig);
@ -272,7 +272,7 @@ namespace IKVM.Internal.MapXml
}
else
{
typeType = JVM.LoadType(Type.GetType(type, true));
typeType = StaticCompiler.GetType(type);
}
}
}
@ -355,7 +355,7 @@ namespace IKVM.Internal.MapXml
if(typeType == null)
{
Debug.Assert(type != null);
typeType = JVM.LoadType(Type.GetType(type, true));
typeType = StaticCompiler.GetType(type);
}
ilgen.Emit(opcode, typeType);
}
@ -514,7 +514,7 @@ namespace IKVM.Internal.MapXml
Debug.Assert(Class == null ^ type == null);
if(type != null)
{
typeType = JVM.LoadType(Type.GetType(type, true));
typeType = StaticCompiler.GetType(type);
}
else
{
@ -924,7 +924,7 @@ namespace IKVM.Internal.MapXml
Type type;
if(@catch.type != null)
{
type = JVM.LoadType(Type.GetType(@catch.type, true));
type = StaticCompiler.GetType(@catch.type);
}
else
{

Просмотреть файл

@ -27,7 +27,27 @@
</if>
<csc target="library" output="../bin/IKVM.Runtime.dll" define="${defs}" optimize="true" unsafe="true">
<sources>
<include name="*.cs" />
<include name="AssemblyInfo.cs" />
<include name="attributes.cs" />
<include name="BigEndianBinaryReader.cs" />
<include name="ByteCode.cs" />
<include name="ByteCodeHelper.cs" />
<include name="ClassFile.cs" />
<include name="ClassLoaderWrapper.cs" />
<include name="classpath.cs" />
<include name="CodeEmitter.cs" />
<include name="compiler.cs" />
<include name="CoreClasses.cs" />
<include name="DynamicClassLoader.cs" />
<include name="ExceptionHelper.cs" />
<include name="JavaException.cs" />
<include name="JniInterface.cs" />
<include name="MemberWrapper.cs" />
<include name="profiler.cs" />
<include name="tracer.cs" />
<include name="TypeWrapper.cs" />
<include name="verifier.cs" />
<include name="vm.cs" />
</sources>
</csc>
</target>

Просмотреть файл

@ -48,9 +48,6 @@ namespace IKVM.Internal
// public readonly static TraceSwitch Methods = new TraceSwitch("methods", "Method Trace");
private readonly static Hashtable allTraceSwitches = new Hashtable();
private readonly static MethodInfo methodIsTracedMethod = typeof(Tracer).GetMethod("IsTracedMethod");
private readonly static MethodInfo methodMethodInfo = typeof(Tracer).GetMethod("MethodInfo");
private readonly static ArrayList methodtraces = new ArrayList();
private class MyTextWriterTraceListener : TextWriterTraceListener
@ -204,25 +201,6 @@ namespace IKVM.Internal
WriteLine(message, p);
}
}
[Conditional("TRACE")]
internal static void EmitMethodTrace(ILGenerator ilgen, string tracemessage)
{
if(IsTracedMethod(tracemessage))
{
Label label = ilgen.DefineLabel();
if(JVM.IsStaticCompiler)
{
// TODO this should be a boolean field test instead of a call to Tracer.IsTracedMessage
ilgen.Emit(OpCodes.Ldstr, tracemessage);
ilgen.Emit(OpCodes.Call, methodIsTracedMethod);
ilgen.Emit(OpCodes.Brfalse_S, label);
}
ilgen.Emit(OpCodes.Ldstr, tracemessage);
ilgen.Emit(OpCodes.Call, methodMethodInfo);
ilgen.MarkLabel(label);
}
}
#else
public const int Compiler = 0;
public const int FxBug = 0;

Просмотреть файл

@ -1,5 +1,5 @@
/*
Copyright (C) 2002, 2003, 2004, 2005 Jeroen Frijters
Copyright (C) 2002, 2003, 2004, 2005, 2006 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
@ -2480,10 +2480,12 @@ class MethodAnalyzer
if(classFile.GetConstantPoolConstantType(instructions[i].Arg1) == ClassFile.ConstantType.Class)
{
TypeWrapper tw = classFile.GetConstantPoolClassType(instructions[i].Arg1);
if(tw.IsUnloadable && JVM.DisableDynamicBinding)
#if STATIC_COMPILER
if(tw.IsUnloadable)
{
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
}
#endif
}
break;
case NormalizedByteCode.__new:
@ -2491,10 +2493,9 @@ class MethodAnalyzer
TypeWrapper tw = classFile.GetConstantPoolClassType(instructions[i].Arg1);
if(tw.IsUnloadable)
{
if(JVM.DisableDynamicBinding)
{
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
}
#if STATIC_COMPILER
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
#endif
}
else if(!tw.IsAccessibleFrom(wrapper))
{
@ -2512,10 +2513,9 @@ class MethodAnalyzer
TypeWrapper tw = classFile.GetConstantPoolClassType(instructions[i].Arg1);
if(tw.IsUnloadable)
{
if(JVM.DisableDynamicBinding)
{
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
}
#if STATIC_COMPILER
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
#endif
}
else if(!tw.IsAccessibleFrom(wrapper))
{
@ -2549,10 +2549,9 @@ class MethodAnalyzer
}
else if(tw.IsUnloadable)
{
if(JVM.DisableDynamicBinding)
{
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
}
#if STATIC_COMPILER
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
#endif
}
else
{
@ -2571,10 +2570,9 @@ class MethodAnalyzer
TypeWrapper tw = stack.PopArrayType();
if(tw.IsUnloadable)
{
if(JVM.DisableDynamicBinding)
{
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
}
#if STATIC_COMPILER
instructions[i].SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(tw.Name));
#endif
}
else
{
@ -2915,37 +2913,34 @@ class MethodAnalyzer
if(cpi.GetClassType().IsUnloadable || (thisType != null && thisType.IsUnloadable))
{
if(JVM.DisableDynamicBinding)
#if STATIC_COMPILER
instr.SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(cpi.GetClassType().Name));
#else
switch(invoke)
{
instr.SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(cpi.GetClassType().Name));
}
else
{
switch(invoke)
{
case NormalizedByteCode.__invokeinterface:
instr.PatchOpCode(NormalizedByteCode.__dynamic_invokeinterface);
break;
case NormalizedByteCode.__invokestatic:
instr.PatchOpCode(NormalizedByteCode.__dynamic_invokestatic);
break;
case NormalizedByteCode.__invokevirtual:
instr.PatchOpCode(NormalizedByteCode.__dynamic_invokevirtual);
break;
case NormalizedByteCode.__invokespecial:
if(isnew)
{
instr.PatchOpCode(NormalizedByteCode.__dynamic_invokespecial);
}
else
{
instr.SetHardError(HardError.LinkageError, AllocErrorMessage("Base class no longer loadable"));
}
break;
default:
throw new InvalidOperationException();
}
case NormalizedByteCode.__invokeinterface:
instr.PatchOpCode(NormalizedByteCode.__dynamic_invokeinterface);
break;
case NormalizedByteCode.__invokestatic:
instr.PatchOpCode(NormalizedByteCode.__dynamic_invokestatic);
break;
case NormalizedByteCode.__invokevirtual:
instr.PatchOpCode(NormalizedByteCode.__dynamic_invokevirtual);
break;
case NormalizedByteCode.__invokespecial:
if(isnew)
{
instr.PatchOpCode(NormalizedByteCode.__dynamic_invokespecial);
}
else
{
instr.SetHardError(HardError.LinkageError, AllocErrorMessage("Base class no longer loadable"));
}
break;
default:
throw new InvalidOperationException();
}
#endif
}
else if(cpi.GetClassType().IsInterface != (invoke == NormalizedByteCode.__invokeinterface))
{
@ -3081,11 +3076,9 @@ class MethodAnalyzer
}
else if(cpi.GetClassType().IsUnloadable || (thisType != null && thisType.IsUnloadable))
{
if(JVM.DisableDynamicBinding)
{
instr.SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(cpi.GetClassType().Name));
return;
}
#if STATIC_COMPILER
instr.SetHardError(HardError.NoClassDefFoundError, AllocErrorMessage(cpi.GetClassType().Name));
#else
switch(instr.NormalizedOpCode)
{
case NormalizedByteCode.__getstatic:
@ -3103,6 +3096,7 @@ class MethodAnalyzer
default:
throw new InvalidOperationException();
}
#endif
return;
}
else

Просмотреть файл

@ -33,8 +33,46 @@ using System.Security.Permissions;
using IKVM.Attributes;
using IKVM.Internal;
#if !STATIC_COMPILER
namespace IKVM.Internal
{
public sealed class Starter
{
private Starter() {}
public static void PrepareForSaveDebugImage()
{
DynamicClassLoader.PrepareForSaveDebugImage();
}
public static void SaveDebugImage(object mainClass)
{
DynamicClassLoader.SaveDebugImage(mainClass);
}
public static void SetBootstrapClassLoader(object classLoader)
{
ClassLoaderWrapper.GetBootstrapClassLoader().SetJavaClassLoader(classLoader);
}
public static bool EnableReflectionOnMethodsWithUnloadableTypeParameters
{
get
{
return JVM.EnableReflectionOnMethodsWithUnloadableTypeParameters;
}
set
{
JVM.EnableReflectionOnMethodsWithUnloadableTypeParameters = value;
}
}
}
}
#endif // !STATIC_COMPILER
namespace IKVM.Runtime
{
#if !STATIC_COMPILER
public sealed class Startup
{
private Startup()
@ -332,21 +370,29 @@ namespace IKVM.Runtime
return IKVM.Internal.JVM.Library.mapException(x);
}
}
#endif
}
namespace IKVM.Internal
{
public class JVM
class JVM
{
#if STATIC_COMPILER
internal const bool IsStaticCompiler = true;
#else
internal const bool IsStaticCompiler = false;
#endif
private static bool debug = System.Diagnostics.Debugger.IsAttached;
private static bool noJniStubs;
private static bool isStaticCompiler;
private static bool isIkvmStub;
private static bool noStackTraceInfo;
private static bool compilationPhase1;
private static string sourcePath;
private static bool enableReflectionOnMethodsWithUnloadableTypeParameters;
#if !STATIC_COMPILER
private static ikvm.@internal.LibraryVMInterface lib;
#endif
private static bool strictFinalFieldSemantics;
private static bool finishingForDebugSave;
private static Assembly coreAssembly;
@ -431,6 +477,7 @@ namespace IKVM.Internal
{
get
{
#if !STATIC_COMPILER
if(coreAssembly == null)
{
object lib = Library;
@ -439,6 +486,7 @@ namespace IKVM.Internal
coreAssembly = lib.GetType().Assembly;
}
}
#endif
return coreAssembly;
}
set
@ -447,16 +495,11 @@ namespace IKVM.Internal
}
}
#if !STATIC_COMPILER
internal static ikvm.@internal.LibraryVMInterface Library
{
get
{
#if WHIDBEY
if(JVM.IsStaticCompiler)
{
return null;
}
#endif
if(lib == null)
{
foreach(Assembly asm in UnsafeGetAssemblies())
@ -474,7 +517,7 @@ namespace IKVM.Internal
break;
}
}
if(lib == null && !IsStaticCompiler)
if(lib == null)
{
JVM.CriticalFailure("Unable to find java.lang.LibraryVMInterfaceImpl", null);
}
@ -482,7 +525,8 @@ namespace IKVM.Internal
return lib;
}
}
#endif
#endif // STATIC_COMPILER
#endif // COMPACT_FRAMEWORK
public static void SetIkvmStubMode()
{
@ -562,14 +606,6 @@ namespace IKVM.Internal
}
}
internal static bool DisableDynamicBinding
{
get
{
return isStaticCompiler;
}
}
internal static bool IsIkvmStub
{
get
@ -578,18 +614,6 @@ namespace IKVM.Internal
}
}
internal static bool IsStaticCompiler
{
get
{
return isStaticCompiler;
}
set
{
isStaticCompiler = value;
}
}
internal static bool IsStaticCompilerPhase1
{
get
@ -660,23 +684,6 @@ namespace IKVM.Internal
return sb.ToString();
}
#if !COMPACT_FRAMEWORK
public static void PrepareForSaveDebugImage()
{
DynamicClassLoader.PrepareForSaveDebugImage();
}
public static void SaveDebugImage(object mainClass)
{
DynamicClassLoader.SaveDebugImage(mainClass);
}
#endif
public static void SetBootstrapClassLoader(object classLoader)
{
ClassLoaderWrapper.GetBootstrapClassLoader().SetJavaClassLoader(classLoader);
}
internal static void CriticalFailure(string message, Exception x)
{
try