This commit is contained in:
jfrijters 2004-12-08 11:07:21 +00:00
Родитель bd6b0a0aee
Коммит a94d5f94a0
2 изменённых файлов: 35 добавлений и 39 удалений

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

@ -33,7 +33,6 @@ using IKVM.Internal;
class Compiler
{
private static string manifestMainClass;
private static int itemsProcessed;
private static ArrayList classes = new ArrayList();
private static Hashtable resources = new Hashtable();
@ -403,11 +402,6 @@ class Compiler
}
}
}
if(itemsProcessed == 0)
{
Console.Error.WriteLine("Error: at least one class or jar must be specified");
return 1;
}
if(assemblyname == null)
{
string basename = outputfile == null ? defaultAssemblyName : new FileInfo(outputfile).Name;
@ -473,7 +467,6 @@ class Compiler
if(ze.Name.ToLower().EndsWith(".class"))
{
classes.Add(ReadFromZip(zf, ze));
itemsProcessed++;
}
else
{
@ -501,7 +494,6 @@ class Compiler
else
{
resources.Add(ze.Name, ReadFromZip(zf, ze));
itemsProcessed++;
}
}
}
@ -521,7 +513,6 @@ class Compiler
{
byte[] b = new byte[fs.Length];
fs.Read(b, 0, b.Length);
itemsProcessed++;
classes.Add(b);
}
break;
@ -555,7 +546,6 @@ class Compiler
string name = file.Substring(baseDir.FullName.Length);
name = name.Replace('\\', '/');
resources.Add(name, b);
itemsProcessed++;
}
}
catch(UnauthorizedAccessException)

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

@ -2076,38 +2076,44 @@ namespace IKVM.Internal
Console.Error.WriteLine("Loading class {0} failed due to:", s);
Console.Error.WriteLine(x);
}
if(s == mainClass && wrapper != null)
{
MethodWrapper mw = wrapper.GetMethodWrapper(new MethodDescriptor("main", "([Ljava.lang.String;)V"), false);
if(mw == null)
{
Console.Error.WriteLine("Error: main method not found");
return;
}
mw.Link();
MethodBuilder method = mw.GetMethod() as MethodBuilder;
if(method == null)
{
Console.Error.WriteLine("Error: redirected main method not supported");
return;
}
Type apartmentAttributeType = null;
if(apartment == ApartmentState.STA)
{
apartmentAttributeType = typeof(STAThreadAttribute);
}
else if(apartment == ApartmentState.MTA)
{
apartmentAttributeType = typeof(MTAThreadAttribute);
}
loader.SetMain(method, target, props, noglobbing, apartmentAttributeType);
mainClass = null;
}
}
if(mainClass != null)
{
Console.Error.WriteLine("Error: main class not found");
return;
TypeWrapper wrapper = loader.LoadClassByDottedNameFast(mainClass);
if(wrapper == null)
{
Console.Error.WriteLine("Error: main class not found");
return;
}
MethodWrapper mw = wrapper.GetMethodWrapper(new MethodDescriptor("main", "([Ljava.lang.String;)V"), false);
if(mw == null)
{
Console.Error.WriteLine("Error: main method not found");
return;
}
mw.Link();
MethodInfo method = mw.GetMethod() as MethodInfo;
if(method == null)
{
Console.Error.WriteLine("Error: redirected main method not supported");
return;
}
if(method.DeclaringType.Assembly != loader.ModuleBuilder.Assembly
&& (!method.IsPublic || !method.DeclaringType.IsPublic))
{
Console.Error.WriteLine("Error: external main method must be public and in a public class");
return;
}
Type apartmentAttributeType = null;
if(apartment == ApartmentState.STA)
{
apartmentAttributeType = typeof(STAThreadAttribute);
}
else if(apartment == ApartmentState.MTA)
{
apartmentAttributeType = typeof(MTAThreadAttribute);
}
loader.SetMain(method, target, props, noglobbing, apartmentAttributeType);
}
compilationPhase1 = false;
if(map != null)