Stub package accessible abstract methods in public classes to allow JLS binary compatibility across assembly boundaries.

This commit is contained in:
jfrijters 2007-09-07 12:34:46 +00:00
Родитель 4df0beb760
Коммит b76bd6edd0
1 изменённых файлов: 21 добавлений и 3 удалений

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

@ -4841,10 +4841,21 @@ namespace IKVM.Internal
else
{
if(m.IsAbstract)
{
bool stub = false;
if(!classFile.IsAbstract)
{
// NOTE in the JVM it is apparently legal for a non-abstract class to have abstract methods, but
// the CLR doens't allow this, so we have to emit a method that throws an AbstractMethodError
if(!classFile.IsAbstract)
stub = true;
}
else if(classFile.IsPublic && !classFile.IsFinal && !(m.IsPublic || m.IsProtected))
{
// We have an abstract package accessible method in our public class. To allow a class in another
// assembly to subclass this class, we must fake the abstractness of this method.
stub = true;
}
if(stub)
{
ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator();
TraceHelper.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
@ -6515,9 +6526,16 @@ namespace IKVM.Internal
// we have to generate a method that throws an AbstractMethodError (because the JVM
// allows abstract methods in non-abstract classes)
if(classFile.IsAbstract)
{
if(classFile.IsPublic && !classFile.IsFinal && !(m.IsPublic || m.IsProtected))
{
setModifiers = true;
}
else
{
attribs |= MethodAttributes.Abstract;
}
}
else
{
setModifiers = true;