This commit is contained in:
jfrijters 2006-08-04 13:13:22 +00:00
Родитель 513a5b6437
Коммит 46d900b234
5 изменённых файлов: 31 добавлений и 103 удалений

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

@ -75,7 +75,7 @@ public final class StubGenerator
f.AddStringAttribute("Signature", genericSignature);
}
f.AddStringAttribute("IKVM.NET.Assembly", getAssemblyName(c));
if(isClassDeprecated(c))
if(isClassDeprecated(VMClass.getWrapper(c)))
{
f.AddAttribute(new DeprecatedAttribute(f));
}
@ -171,7 +171,7 @@ public final class StubGenerator
});
m.AddAttribute(code);
AddExceptions(f, m, constructors[i].getExceptionTypes());
if(isConstructorDeprecated(constructors[i]))
if(isMethodDeprecated(constructors[i].methodCookie))
{
m.AddAttribute(new DeprecatedAttribute(f));
}
@ -229,7 +229,7 @@ public final class StubGenerator
Class retType = methods[i].getReturnType();
FieldOrMethod m = f.AddMethod(mods, methods[i].getName(), MakeSig(args, retType));
AddExceptions(f, m, methods[i].getExceptionTypes());
if(isMethodDeprecated(methods[i]))
if(isMethodDeprecated(methods[i].methodCookie))
{
m.AddAttribute(new DeprecatedAttribute(f));
}
@ -256,10 +256,10 @@ public final class StubGenerator
((mods & (Modifiers.Static | Modifiers.Final)) == (Modifiers.Static | Modifiers.Final) &&
fields[i].getName().equals("serialVersionUID") && fields[i].getType() == java.lang.Long.TYPE))
{
// we use the IKVM runtime API to get constant value
// NOTE we can't use Field.get() because that will run the static initializer and
// also won't allow us to see the difference between constants and blank final fields.
Object constantValue = getFieldConstantValue(fields[i]);
// also won't allow us to see the difference between constants and blank final fields,
// so we use a "native" method.
Object constantValue = getFieldConstantValue(fields[i].impl.fieldCookie);
Class fieldType = fields[i].getType();
if(fields[i].isEnumConstant())
{
@ -270,7 +270,7 @@ public final class StubGenerator
mods |= Modifiers.Synthetic;
}
FieldOrMethod fld = f.AddField(mods, fields[i].getName(), ClassToSig(fieldType), constantValue);
if(isFieldDeprecated(fields[i]))
if(isFieldDeprecated(fields[i].impl.fieldCookie))
{
fld.AddAttribute(new DeprecatedAttribute(f));
}
@ -297,11 +297,10 @@ public final class StubGenerator
}
private static native String getAssemblyName(Class c);
private static native boolean isClassDeprecated(Class c);
private static native boolean isFieldDeprecated(java.lang.reflect.Field f);
private static native boolean isMethodDeprecated(java.lang.reflect.Method m);
private static native boolean isConstructorDeprecated(java.lang.reflect.Constructor c);
private static native Object getFieldConstantValue(java.lang.reflect.Field f);
private static native boolean isClassDeprecated(Object wrapper);
private static native boolean isFieldDeprecated(Object fieldCookie);
private static native boolean isMethodDeprecated(Object methodCookie);
private static native Object getFieldConstantValue(Object fieldCookie);
private static void AddExceptions(ClassFileWriter f, FieldOrMethod m, Class[] exceptions)
{

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

@ -28,7 +28,6 @@ using System.Text;
using System.Collections;
using ICSharpCode.SharpZipLib.Zip;
using IKVM.Attributes;
using IKVM.Internal;
public class NetExp
{
@ -38,7 +37,7 @@ public class NetExp
public static void Main(string[] args)
{
Tracer.EnableTraceForDebug();
IKVM.Internal.Tracer.EnableTraceForDebug();
if(args.Length != 1)
{
Console.Error.WriteLine(IKVM.Runtime.Startup.GetVersionAndCopyrightInfo());

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

@ -44,12 +44,12 @@
<target name="clean">
<delete failonerror="false">
<fileset>
<includes name="IKVM.GNU.Classpath.jar" />
<includes name="japi1.diff" />
<includes name="japi2.diff" />
<includes name="${REFERENCE_API_NAME}.japi" />
<includes name="IKVM-${IKVM_VERSION}.japi" />
<includes name="../bin/japize.exe" />
<include name="IKVM.GNU.Classpath.jar" />
<include name="japi1.diff" />
<include name="japi2.diff" />
<include name="${REFERENCE_API_NAME}.japi" />
<include name="IKVM-${IKVM_VERSION}.japi" />
<include name="../bin/japize.exe" />
</fileset>
</delete>
</target>

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

@ -1643,29 +1643,29 @@ namespace IKVM.NativeCode.ikvm.@internal
return TypeWrapper.FromClass(c).Assembly.FullName;
}
public static bool isClassDeprecated(object c)
public static object getFieldConstantValue(object fieldWrapper)
{
return IKVM.Runtime.Util.IsClassDeprecated(c);
return ((FieldWrapper)fieldWrapper).GetConstant();
}
public static bool isFieldDeprecated(object f)
public static bool isFieldDeprecated(object fieldWrapper)
{
return IKVM.Runtime.Util.IsFieldDeprecated(f);
FieldInfo fi = ((FieldWrapper)fieldWrapper).GetField();
return fi != null && AttributeHelper.IsDefined(fi, typeof(ObsoleteAttribute));
}
public static bool isMethodDeprecated(object m)
public static bool isMethodDeprecated(object methodWrapper)
{
return IKVM.Runtime.Util.IsMethodDeprecated(m);
MethodBase mb = ((MethodWrapper)methodWrapper).GetMethod();
return mb != null && AttributeHelper.IsDefined(mb, typeof(ObsoleteAttribute));
}
public static bool isConstructorDeprecated(object c)
public static bool isClassDeprecated(object wrapper)
{
return IKVM.Runtime.Util.IsConstructorDeprecated(c);
}
public static object getFieldConstantValue(object f)
{
return IKVM.Runtime.Util.GetFieldConstantValue(f);
Type type = ((TypeWrapper)wrapper).TypeAsTBD;
// we need to check type for null, because ReflectionOnly
// generated delegate inner interfaces don't really exist
return type != null && AttributeHelper.IsDefined(type, typeof(ObsoleteAttribute));
}
}
}

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

@ -296,76 +296,6 @@ namespace IKVM.Runtime
return wrapper.TypeAsBaseType;
}
private static FieldWrapper GetFieldWrapperFromField(object field)
{
if(field == null)
{
throw new ArgumentNullException("field");
}
if(field.GetType().FullName != "java.lang.reflect.Field")
{
throw new ArgumentException("field");
}
return (FieldWrapper)IKVM.Internal.JVM.Library.getWrapperFromField(field);
}
public static object GetFieldConstantValue(object field)
{
return GetFieldWrapperFromField(field).GetConstant();
}
public static bool IsFieldDeprecated(object field)
{
FieldInfo fi = GetFieldWrapperFromField(field).GetField();
return fi != null && AttributeHelper.IsDefined(fi, typeof(ObsoleteAttribute));
}
public static bool IsMethodDeprecated(object method)
{
if(method == null)
{
throw new ArgumentNullException("method");
}
if(method.GetType().FullName != "java.lang.reflect.Method")
{
throw new ArgumentException("method");
}
MethodWrapper mw = (MethodWrapper)IKVM.Internal.JVM.Library.getWrapperFromMethodOrConstructor(method);
MethodBase mb = mw.GetMethod();
return mb != null && AttributeHelper.IsDefined(mb, typeof(ObsoleteAttribute));
}
public static bool IsConstructorDeprecated(object constructor)
{
if(constructor == null)
{
throw new ArgumentNullException("constructor");
}
if(constructor.GetType().FullName != "java.lang.reflect.Constructor")
{
throw new ArgumentException("constructor");
}
MethodWrapper mw = (MethodWrapper)IKVM.Internal.JVM.Library.getWrapperFromMethodOrConstructor(constructor);
MethodBase mb = mw.GetMethod();
return mb != null && AttributeHelper.IsDefined(mb, typeof(ObsoleteAttribute));
}
public static bool IsClassDeprecated(object clazz)
{
if(clazz == null)
{
throw new ArgumentNullException("clazz");
}
if(clazz.GetType().FullName != "java.lang.Class")
{
throw new ArgumentException("clazz");
}
TypeWrapper wrapper = TypeWrapper.FromClass(clazz);
// HACK we need to check TypeAsTBD for null, because ReflectionOnly
// generated delegate inner interfaces don't really exist
return wrapper.TypeAsTBD != null && AttributeHelper.IsDefined(wrapper.TypeAsTBD, typeof(ObsoleteAttribute));
}
[HideFromJava]
public static Exception MapException(Exception x)
{