ikvm-commit Mailing List for IKVM.NET (Page 13)
Brought to you by:
jfrijters
You can subscribe to this list here.
| 2007 |
Jan
(25) |
Feb
(22) |
Mar
(32) |
Apr
(77) |
May
(111) |
Jun
(129) |
Jul
(223) |
Aug
(109) |
Sep
(60) |
Oct
(60) |
Nov
(36) |
Dec
(55) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(23) |
Feb
(76) |
Mar
(42) |
Apr
(49) |
May
(33) |
Jun
(64) |
Jul
(19) |
Aug
(124) |
Sep
(16) |
Oct
|
Nov
(87) |
Dec
(54) |
| 2009 |
Jan
(53) |
Feb
(116) |
Mar
(86) |
Apr
(64) |
May
(101) |
Jun
(99) |
Jul
(105) |
Aug
(63) |
Sep
(20) |
Oct
(110) |
Nov
(102) |
Dec
(36) |
| 2010 |
Jan
(87) |
Feb
(67) |
Mar
(5) |
Apr
(100) |
May
(178) |
Jun
(95) |
Jul
(22) |
Aug
(85) |
Sep
(82) |
Oct
(99) |
Nov
(119) |
Dec
(132) |
| 2011 |
Jan
(130) |
Feb
(18) |
Mar
(114) |
Apr
(8) |
May
(21) |
Jun
(53) |
Jul
(127) |
Aug
(111) |
Sep
(29) |
Oct
(28) |
Nov
(64) |
Dec
(94) |
| 2012 |
Jan
(56) |
Feb
(8) |
Mar
(65) |
Apr
(48) |
May
(22) |
Jun
(52) |
Jul
(73) |
Aug
(38) |
Sep
(18) |
Oct
(59) |
Nov
(16) |
Dec
(21) |
| 2013 |
Jan
(83) |
Feb
(151) |
Mar
(102) |
Apr
(13) |
May
(37) |
Jun
(1) |
Jul
(7) |
Aug
(42) |
Sep
(28) |
Oct
(13) |
Nov
(5) |
Dec
(3) |
| 2014 |
Jan
(3) |
Feb
(39) |
Mar
(11) |
Apr
(40) |
May
(62) |
Jun
(54) |
Jul
(21) |
Aug
(3) |
Sep
|
Oct
(15) |
Nov
(26) |
Dec
(7) |
| 2015 |
Jan
(6) |
Feb
(12) |
Mar
(51) |
Apr
(15) |
May
(7) |
Jun
(41) |
Jul
(2) |
Aug
(8) |
Sep
(5) |
Oct
(6) |
Nov
(11) |
Dec
(1) |
| 2016 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
(2) |
Jul
(19) |
Aug
(2) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Jeroen F. <jfr...@us...> - 2014-06-06 13:43:37
|
Update of /cvsroot/ikvm/ikvm/openjdk/java/lang In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11992 Modified Files: ProcessImpl.java Log Message: Bug fix. Eagerly close the redirected in/outputs when an exception occurs or after the process exits. Index: ProcessImpl.java =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/java/lang/ProcessImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ProcessImpl.java 19 May 2014 12:43:38 -0000 1.17 --- ProcessImpl.java 6 Jun 2014 13:43:35 -0000 1.18 *************** *** 50,53 **** --- 50,55 ---- import cli.System.IAsyncResult; import cli.System.Diagnostics.ProcessStartInfo; + import cli.System.EventArgs; + import cli.System.EventHandler; import cli.System.IO.FileAccess; import cli.System.IO.FileShare; *************** *** 151,156 **** --- 153,167 ---- return new ProcessImpl(cmdarray, environment, dir, stdHandles, redirectErrorStream); + } catch (Throwable t) { + if (f0 != null) + f0.close(); + if (f1 != null) + f1.close(); + if (f2 != null) + f2.close(); + throw t; } finally { // HACK prevent the File[In|Out]putStream objects from closing the streams + // (the System.IO.FileStream will eventually be closed explicitly or by its finalizer) if (f0 != null) cli.System.GC.SuppressFinalize(f0); *************** *** 592,595 **** --- 603,627 ---- throw new IOException(x2.getMessage()); } + + // if any of the handles is redirected to/from a file, + // we need to close the files as soon as the process exits + if (stdHandles[0] instanceof FileStream + || stdHandles[1] instanceof FileStream + || stdHandles[2] instanceof FileStream) { + final Stream s0 = stdHandles[0]; + final Stream s1 = stdHandles[1]; + final Stream s2 = stdHandles[2]; + proc.set_EnableRaisingEvents(true); + proc.add_Exited(new EventHandler(new EventHandler.Method() { + public void Invoke(Object sender, EventArgs e) { + if (s0 instanceof FileStream) + s0.Close(); + if (s1 instanceof FileStream) + s1.Close(); + if (s2 instanceof FileStream) + s2.Close(); + } + })); + } Stream stdin = proc.get_StandardInput().get_BaseStream(); |
|
From: Jeroen F. <jfr...@us...> - 2014-06-06 11:17:40
|
Update of /cvsroot/ikvm/ikvm/runtime/openjdk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv3581 Modified Files: java.lang.cs Log Message: Bug fix. Process exec should support quotes around filename for VFS executables. Index: java.lang.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/openjdk/java.lang.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** java.lang.cs 5 Jun 2014 11:08:57 -0000 1.14 --- java.lang.cs 6 Jun 2014 11:17:38 -0000 1.15 *************** *** 1261,1267 **** public static string mapVfsExecutable(string path) { ! if (VirtualFileSystem.IsVirtualFS(path)) { ! return VirtualFileSystem.MapExecutable(path); } return path; --- 1261,1272 ---- public static string mapVfsExecutable(string path) { ! string unquoted = path; ! if (unquoted.Length > 2 && unquoted[0] == '"' && unquoted[unquoted.Length - 1] == '"') { ! unquoted = unquoted.Substring(1, unquoted.Length - 2); ! } ! if (VirtualFileSystem.IsVirtualFS(unquoted)) ! { ! return VirtualFileSystem.MapExecutable(unquoted); } return path; |
|
From: Jeroen F. <jfr...@us...> - 2014-06-06 09:04:19
|
Update of /cvsroot/ikvm/ikvm/runtime/stubgen In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28391 Modified Files: ClassFileWriter.cs StubGenerator.cs Log Message: Implemented (runtime visible) type annotation rendering in runtime stub generator. Index: StubGenerator.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/stubgen/StubGenerator.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** StubGenerator.cs 3 Jun 2014 12:04:42 -0000 1.12 --- StubGenerator.cs 6 Jun 2014 09:04:17 -0000 1.13 *************** *** 94,97 **** --- 94,98 ---- } AddAnnotations(writer, writer, tw.TypeAsBaseType); + AddTypeAnnotations(writer, writer, tw, tw.GetRawTypeAnnotations()); writer.AddStringAttribute("IKVM.NET.Assembly", GetAssemblyName(tw)); if (tw.TypeAsBaseType.IsDefined(JVM.Import(typeof(ObsoleteAttribute)), false)) *************** *** 220,223 **** --- 221,225 ---- AddAnnotations(writer, m, mw.GetMethod()); AddParameterAnnotations(writer, m, mw.GetMethod()); + AddTypeAnnotations(writer, m, tw, tw.GetMethodRawTypeAnnotations(mw)); } } *************** *** 251,254 **** --- 253,257 ---- } AddAnnotations(writer, f, fw.GetField()); + AddTypeAnnotations(writer, f, tw, tw.GetFieldRawTypeAnnotations(fw)); } } *************** *** 333,336 **** --- 336,476 ---- } + private static void AddTypeAnnotations(ClassFileWriter writer, IAttributeOwner target, TypeWrapper tw, byte[] typeAnnotations) + { + #if !FIRST_PASS && !STUB_GENERATOR + if (typeAnnotations != null) + { + typeAnnotations = (byte[])typeAnnotations.Clone(); + object[] constantPool = tw.GetConstantPool(); + try + { + int pos = 0; + ushort num_annotations = ReadUInt16BE(typeAnnotations, ref pos); + for (int i = 0; i < num_annotations; i++) + { + FixupTypeAnnotationConstantPoolIndexes(writer, typeAnnotations, constantPool, ref pos); + } + } + catch (IndexOutOfRangeException) + { + // if the attribute is malformed, we add it anyway and hope the Java parser will agree and throw the right error + } + target.AddAttribute(new RuntimeVisibleTypeAnnotationsAttribute(writer, typeAnnotations)); + } + #endif + } + + private static void FixupTypeAnnotationConstantPoolIndexes(ClassFileWriter writer, byte[] typeAnnotations, object[] constantPool, ref int pos) + { + switch (typeAnnotations[pos++]) // target_type + { + case 0x00: + case 0x01: + case 0x16: + pos++; + break; + case 0x10: + case 0x11: + case 0x12: + case 0x17: + pos += 2; + break; + case 0x13: + case 0x14: + case 0x15: + break; + default: + throw new IndexOutOfRangeException(); + } + byte path_length = typeAnnotations[pos++]; + pos += path_length * 2; + FixupAnnotationConstantPoolIndexes(writer, typeAnnotations, constantPool, ref pos); + } + + private static void FixupAnnotationConstantPoolIndexes(ClassFileWriter writer, byte[] typeAnnotations, object[] constantPool, ref int pos) + { + FixupConstantPoolIndex(writer, typeAnnotations, constantPool, ref pos); + ushort num_components = ReadUInt16BE(typeAnnotations, ref pos); + for (int i = 0; i < num_components; i++) + { + FixupConstantPoolIndex(writer, typeAnnotations, constantPool, ref pos); + FixupAnnotationComponentValueConstantPoolIndexes(writer, typeAnnotations, constantPool, ref pos); + } + } + + private static void FixupConstantPoolIndex(ClassFileWriter writer, byte[] typeAnnotations, object[] constantPool, ref int pos) + { + ushort index = ReadUInt16BE(typeAnnotations, ref pos); + object item = constantPool[index]; + if (item is int) + { + index = writer.AddInt((int)item); + } + else if (item is long) + { + index = writer.AddLong((long)item); + } + else if (item is float) + { + index = writer.AddFloat((float)item); + } + else if (item is double) + { + index = writer.AddDouble((double)item); + } + else if (item is string) + { + index = writer.AddUtf8((string)item); + } + else + { + throw new IndexOutOfRangeException(); + } + typeAnnotations[pos - 2] = (byte)(index >> 8); + typeAnnotations[pos - 1] = (byte)(index >> 0); + } + + private static void FixupAnnotationComponentValueConstantPoolIndexes(ClassFileWriter writer, byte[] typeAnnotations, object[] constantPool, ref int pos) + { + switch ((char)typeAnnotations[pos++]) // tag + { + case 'B': + case 'C': + case 'D': + case 'F': + case 'I': + case 'J': + case 'S': + case 'Z': + case 's': + case 'c': + FixupConstantPoolIndex(writer, typeAnnotations, constantPool, ref pos); + break; + case 'e': + FixupConstantPoolIndex(writer, typeAnnotations, constantPool, ref pos); + FixupConstantPoolIndex(writer, typeAnnotations, constantPool, ref pos); + break; + case '@': + FixupAnnotationConstantPoolIndexes(writer, typeAnnotations, constantPool, ref pos); + break; + case '[': + ushort num_values = ReadUInt16BE(typeAnnotations, ref pos); + for (int i = 0; i < num_values; i++) + { + FixupAnnotationComponentValueConstantPoolIndexes(writer, typeAnnotations, constantPool, ref pos); + } + break; + default: + throw new IndexOutOfRangeException(); + } + } + + private static ushort ReadUInt16BE(byte[] buf, ref int pos) + { + ushort s = (ushort)((buf[pos] << 8) + buf[pos + 1]); + pos += 2; + return s; + } + #if !FIRST_PASS && !STUB_GENERATOR private static object[] GetAnnotation(CustomAttributeData cad) Index: ClassFileWriter.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/stubgen/ClassFileWriter.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ClassFileWriter.cs 3 Jun 2014 12:04:42 -0000 1.9 --- ClassFileWriter.cs 6 Jun 2014 09:04:17 -0000 1.10 *************** *** 73,76 **** --- 73,81 ---- } + public void WriteBytes(byte[] data) + { + stream.Write(data, 0, data.Length); + } + public void WriteUtf8(string str) { *************** *** 729,732 **** --- 734,755 ---- } + sealed class RuntimeVisibleTypeAnnotationsAttribute : ClassFileAttribute + { + private readonly byte[] data; + + internal RuntimeVisibleTypeAnnotationsAttribute(ClassFileWriter classFile, byte[] data) + : base(classFile.AddUtf8("RuntimeVisibleTypeAnnotations")) + { + this.data = data; + } + + public override void Write(BigEndianStream bes) + { + base.Write(bes); + bes.WriteUInt32((uint)data.Length); + bes.WriteBytes(data); + } + } + sealed class AnnotationDefaultClassFileAttribute : ClassFileAttribute { |
|
From: Jeroen F. <jfr...@us...> - 2014-06-05 12:38:12
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16946 Modified Files: DynamicTypeWrapper.cs TypeWrapper.cs attributes.cs Log Message: Implemented type annotation reflection for statically compiled classes. Index: TypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/TypeWrapper.cs,v retrieving revision 1.469 retrieving revision 1.470 diff -C2 -d -r1.469 -r1.470 *** TypeWrapper.cs 5 Jun 2014 11:08:57 -0000 1.469 --- TypeWrapper.cs 5 Jun 2014 12:38:09 -0000 1.470 *************** *** 81,84 **** --- 81,86 ---- private static ConstructorInfo signatureAttribute; private static ConstructorInfo methodParametersAttribute; + private static ConstructorInfo runtimeVisibleTypeAnnotationsAttribute; + private static ConstructorInfo constantPoolAttribute; private static CustomAttributeBuilder paramArrayAttribute; private static ConstructorInfo nonNestedInnerClassAttribute; *************** *** 108,111 **** --- 110,115 ---- private static readonly Type typeofEnclosingMethodAttribute = JVM.LoadType(typeof(EnclosingMethodAttribute)); private static readonly Type typeofMethodParametersAttribute = JVM.LoadType(typeof(MethodParametersAttribute)); + private static readonly Type typeofRuntimeVisibleTypeAnnotationsAttribute = JVM.LoadType(typeof(RuntimeVisibleTypeAnnotationsAttribute)); + private static readonly Type typeofConstantPoolAttribute = JVM.LoadType(typeof(ConstantPoolAttribute)); private static readonly CustomAttributeBuilder hideFromJavaAttribute = new CustomAttributeBuilder(typeofHideFromJavaAttribute.GetConstructor(Type.EmptyTypes), new object[0]); private static readonly CustomAttributeBuilder hideFromReflection = new CustomAttributeBuilder(typeofHideFromJavaAttribute.GetConstructor(new Type[] { typeofHideFromJavaFlags }), new object[] { HideFromJavaFlags.Reflection | HideFromJavaFlags.StackTrace | HideFromJavaFlags.StackWalk }); *************** *** 875,878 **** --- 879,918 ---- } + internal static void SetRuntimeVisibleTypeAnnotationsAttribute(TypeBuilder tb, byte[] data) + { + if(runtimeVisibleTypeAnnotationsAttribute == null) + { + runtimeVisibleTypeAnnotationsAttribute = typeofRuntimeVisibleTypeAnnotationsAttribute.GetConstructor(new Type[] { Types.Byte.MakeArrayType() }); + } + tb.SetCustomAttribute(new CustomAttributeBuilder(runtimeVisibleTypeAnnotationsAttribute, new object[] { data })); + } + + internal static void SetRuntimeVisibleTypeAnnotationsAttribute(FieldBuilder fb, byte[] data) + { + if(runtimeVisibleTypeAnnotationsAttribute == null) + { + runtimeVisibleTypeAnnotationsAttribute = typeofRuntimeVisibleTypeAnnotationsAttribute.GetConstructor(new Type[] { Types.Byte.MakeArrayType() }); + } + fb.SetCustomAttribute(new CustomAttributeBuilder(runtimeVisibleTypeAnnotationsAttribute, new object[] { data })); + } + + internal static void SetRuntimeVisibleTypeAnnotationsAttribute(MethodBuilder mb, byte[] data) + { + if(runtimeVisibleTypeAnnotationsAttribute == null) + { + runtimeVisibleTypeAnnotationsAttribute = typeofRuntimeVisibleTypeAnnotationsAttribute.GetConstructor(new Type[] { Types.Byte.MakeArrayType() }); + } + mb.SetCustomAttribute(new CustomAttributeBuilder(runtimeVisibleTypeAnnotationsAttribute, new object[] { data })); + } + + internal static void SetConstantPoolAttribute(TypeBuilder tb, object[] constantPool) + { + if(constantPoolAttribute == null) + { + constantPoolAttribute = typeofConstantPoolAttribute.GetConstructor(new Type[] { Types.Object.MakeArrayType() }); + } + tb.SetCustomAttribute(new CustomAttributeBuilder(constantPoolAttribute, new object[] { constantPool })); + } + internal static void SetParamArrayAttribute(ParameterBuilder pb) { *************** *** 1018,1021 **** --- 1058,1089 ---- } + internal static object[] GetConstantPool(Type type) + { + #if !STATIC_COMPILER && !STUB_GENERATOR + object[] attribs = type.GetCustomAttributes(typeof(ConstantPoolAttribute), false); + return attribs.Length == 1 ? ((ConstantPoolAttribute)attribs[0]).constantPool : null; + #else + foreach(CustomAttributeData cad in CustomAttributeData.__GetCustomAttributes(type, typeofConstantPoolAttribute, false)) + { + return DecodeArray<object>(cad.ConstructorArguments[0]); + } + return null; + #endif + } + + internal static byte[] GetRuntimeVisibleTypeAnnotations(MemberInfo member) + { + #if !STATIC_COMPILER && !STUB_GENERATOR + object[] attribs = member.GetCustomAttributes(typeof(RuntimeVisibleTypeAnnotationsAttribute), false); + return attribs.Length == 1 ? ((RuntimeVisibleTypeAnnotationsAttribute)attribs[0]).data : null; + #else + foreach(CustomAttributeData cad in CustomAttributeData.__GetCustomAttributes(member, typeofRuntimeVisibleTypeAnnotationsAttribute, false)) + { + return DecodeArray<byte>(cad.ConstructorArguments[0]); + } + return null; + #endif + } + internal static InnerClassAttribute GetInnerClass(Type type) { *************** *** 5165,5168 **** --- 5233,5258 ---- get { return true; } } + + internal override object[] GetConstantPool() + { + return AttributeHelper.GetConstantPool(type); + } + + internal override byte[] GetRawTypeAnnotations() + { + return AttributeHelper.GetRuntimeVisibleTypeAnnotations(type); + } + + internal override byte[] GetMethodRawTypeAnnotations(MethodWrapper mw) + { + MethodBase mb = mw.GetMethod(); + return mb == null ? null : AttributeHelper.GetRuntimeVisibleTypeAnnotations(mb); + } + + internal override byte[] GetFieldRawTypeAnnotations(FieldWrapper fw) + { + FieldInfo fi = fw.GetField(); + return fi == null ? null : AttributeHelper.GetRuntimeVisibleTypeAnnotations(fi); + } } Index: attributes.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/attributes.cs,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** attributes.cs 3 Jun 2014 09:13:56 -0000 1.47 --- attributes.cs 5 Jun 2014 12:38:09 -0000 1.48 *************** *** 882,885 **** --- 882,958 ---- } + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] + public sealed class ConstantPoolAttribute : Attribute + { + internal readonly object[] constantPool; + + public ConstantPoolAttribute(object[] constantPool) + { + this.constantPool = Decompress(constantPool); + } + + private static object[] Decompress(object[] constantPool) + { + List<object> list = new List<object>(); + foreach (object obj in constantPool) + { + int emptySlots = obj as byte? ?? obj as ushort? ?? 0; + if (emptySlots == 0) + { + list.Add(obj); + } + else + { + for (int i = 0; i < emptySlots; i++) + { + list.Add(null); + } + } + } + return list.ToArray(); + } + + internal static object[] Compress(object[] constantPool, bool[] inUse) + { + int length = constantPool.Length; + while (!inUse[length - 1]) + { + length--; + } + int write = 0; + for (int read = 0; read < length; read++) + { + int start = read; + while (!inUse[read]) + { + read++; + } + int emptySlots = read - start; + if (emptySlots > 255) + { + constantPool[write++] = (ushort)emptySlots; + } + else if (emptySlots > 0) + { + constantPool[write++] = (byte)emptySlots; + } + constantPool[write++] = constantPool[read]; + } + Array.Resize(ref constantPool, write); + return constantPool; + } + } + + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field)] + public sealed class RuntimeVisibleTypeAnnotationsAttribute : Attribute + { + internal readonly byte[] data; + + public RuntimeVisibleTypeAnnotationsAttribute(byte[] data) + { + this.data = data; + } + } + // used in custom modifier for access stubs public static class AccessStub { } Index: DynamicTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DynamicTypeWrapper.cs,v retrieving revision 1.247 retrieving revision 1.248 diff -C2 -d -r1.247 -r1.248 *** DynamicTypeWrapper.cs 5 Jun 2014 11:08:57 -0000 1.247 --- DynamicTypeWrapper.cs 5 Jun 2014 12:38:09 -0000 1.248 *************** *** 932,935 **** --- 932,939 ---- } } + if (classFile.RuntimeVisibleTypeAnnotations != null) + { + AttributeHelper.SetRuntimeVisibleTypeAnnotationsAttribute(typeBuilder, classFile.RuntimeVisibleTypeAnnotations); + } if (wrapper.classLoader.EmitStackTraceInfo) { *************** *** 1638,1641 **** --- 1642,1649 ---- AttributeHelper.SetSignatureAttribute(field, fld.GenericSignature); } + if (fld.RuntimeVisibleTypeAnnotations != null) + { + AttributeHelper.SetRuntimeVisibleTypeAnnotationsAttribute(field, fld.RuntimeVisibleTypeAnnotations); + } } #endif // STATIC_COMPILER *************** *** 2975,2978 **** --- 2983,2990 ---- AttributeHelper.SetMethodParametersAttribute(method, modifiers); } + if (m.RuntimeVisibleTypeAnnotations != null) + { + AttributeHelper.SetRuntimeVisibleTypeAnnotationsAttribute(method, m.RuntimeVisibleTypeAnnotations); + } #else // STATIC_COMPILER if (setModifiers) *************** *** 4518,4521 **** --- 4530,4535 ---- AddAccessStubs(); } + + AddConstantPoolAttributeIfNecessary(classFile, typeBuilder); #endif // STATIC_COMPILER *************** *** 4634,4637 **** --- 4648,4792 ---- #if STATIC_COMPILER + private static void AddConstantPoolAttributeIfNecessary(ClassFile classFile, TypeBuilder typeBuilder) + { + object[] constantPool = null; + bool[] inUse = null; + MarkConstantPoolUsage(classFile, classFile.RuntimeVisibleTypeAnnotations, ref constantPool, ref inUse); + foreach (ClassFile.Method method in classFile.Methods) + { + MarkConstantPoolUsage(classFile, method.RuntimeVisibleTypeAnnotations, ref constantPool, ref inUse); + } + foreach (ClassFile.Field field in classFile.Fields) + { + MarkConstantPoolUsage(classFile, field.RuntimeVisibleTypeAnnotations, ref constantPool, ref inUse); + } + if (constantPool != null) + { + // to save space, we clear out the items that aren't used by the RuntimeVisibleTypeAnnotations and + // use an RLE for the empty slots + AttributeHelper.SetConstantPoolAttribute(typeBuilder, ConstantPoolAttribute.Compress(constantPool, inUse)); + } + } + + private static void MarkConstantPoolUsage(ClassFile classFile, byte[] runtimeVisibleTypeAnnotations, ref object[] constantPool, ref bool[] inUse) + { + if (runtimeVisibleTypeAnnotations != null) + { + if (constantPool == null) + { + constantPool = classFile.GetConstantPool(); + inUse = new bool[constantPool.Length]; + } + try + { + BigEndianBinaryReader br = new BigEndianBinaryReader(runtimeVisibleTypeAnnotations, 0, runtimeVisibleTypeAnnotations.Length); + ushort num_annotations = br.ReadUInt16(); + for (int i = 0; i < num_annotations; i++) + { + MarkConstantPoolUsageForTypeAnnotation(br, inUse); + } + return; + } + catch (ClassFormatError) + { + } + catch (IndexOutOfRangeException) + { + } + // if we fail to parse the annotations (e.g. due to a malformed attribute), we simply keep all the constant pool entries + for (int i = 0; i < inUse.Length; i++) + { + inUse[i] = true; + } + } + } + + private static void MarkConstantPoolUsageForTypeAnnotation(BigEndianBinaryReader br, bool[] inUse) + { + switch (br.ReadByte()) // target_type + { + case 0x00: + case 0x01: + br.ReadByte(); // type_parameter_index + break; + case 0x10: + br.ReadUInt16(); // supertype_index + break; + case 0x11: + case 0x12: + br.ReadByte(); // type_parameter_index + br.ReadByte(); // bound_index + break; + case 0x13: + case 0x14: + case 0x15: + // empty_target + break; + case 0x16: + br.ReadByte(); // formal_parameter_index + break; + case 0x17: + br.ReadUInt16(); // throws_type_index + break; + default: + throw new ClassFormatError(""); + } + byte path_length = br.ReadByte(); + for (int i = 0; i < path_length; i++) + { + br.ReadByte(); // type_path_kind + br.ReadByte(); // type_argument_index + } + MarkConstantPoolUsageForAnnotation(br, inUse); + } + + private static void MarkConstantPoolUsageForAnnotation(BigEndianBinaryReader br, bool[] inUse) + { + ushort type_index = br.ReadUInt16(); + inUse[type_index] = true; + ushort num_components = br.ReadUInt16(); + for (int i = 0; i < num_components; i++) + { + ushort component_name_index = br.ReadUInt16(); + inUse[component_name_index] = true; + MarkConstantPoolUsageForAnnotationComponentValue(br, inUse); + } + } + + private static void MarkConstantPoolUsageForAnnotationComponentValue(BigEndianBinaryReader br, bool[] inUse) + { + switch ((char)br.ReadByte()) // tag + { + case 'B': + case 'C': + case 'D': + case 'F': + case 'I': + case 'J': + case 'S': + case 'Z': + case 's': + case 'c': + inUse[br.ReadUInt16()] = true; + break; + case 'e': + inUse[br.ReadUInt16()] = true; + inUse[br.ReadUInt16()] = true; + break; + case '@': + MarkConstantPoolUsageForAnnotation(br, inUse); + break; + case '[': + ushort num_values = br.ReadUInt16(); + for (int i = 0; i < num_values; i++) + { + MarkConstantPoolUsageForAnnotationComponentValue(br, inUse); + } + break; + default: + throw new ClassFormatError(""); + } + } + private bool EmitInterlockedCompareAndSet(MethodWrapper method, string fieldName, CodeEmitter ilGenerator) { |
|
From: Jeroen F. <jfr...@us...> - 2014-06-05 11:09:00
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11169 Modified Files: BigEndianBinaryReader.cs ClassFile.cs DynamicTypeWrapper.cs TypeWrapper.cs Log Message: Implemented type annotation reflection for dynamically loaded classes. Index: TypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/TypeWrapper.cs,v retrieving revision 1.468 retrieving revision 1.469 diff -C2 -d -r1.468 -r1.469 *** TypeWrapper.cs 3 Jun 2014 12:04:42 -0000 1.468 --- TypeWrapper.cs 5 Jun 2014 11:08:57 -0000 1.469 *************** *** 3350,3353 **** --- 3350,3373 ---- #endif } + + internal virtual object[] GetConstantPool() + { + return null; + } + + internal virtual byte[] GetRawTypeAnnotations() + { + return null; + } + + internal virtual byte[] GetMethodRawTypeAnnotations(MethodWrapper mw) + { + return null; + } + + internal virtual byte[] GetFieldRawTypeAnnotations(FieldWrapper fw) + { + return null; + } } Index: DynamicTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DynamicTypeWrapper.cs,v retrieving revision 1.246 retrieving revision 1.247 diff -C2 -d -r1.246 -r1.247 *** DynamicTypeWrapper.cs 3 Jun 2014 14:28:37 -0000 1.246 --- DynamicTypeWrapper.cs 5 Jun 2014 11:08:57 -0000 1.247 *************** *** 444,447 **** --- 444,451 ---- internal abstract object[] GetFieldAnnotations(int index); internal abstract MethodInfo GetFinalizeMethod(); + internal abstract object[] GetConstantPool(); + internal abstract byte[] GetRawTypeAnnotations(); + internal abstract byte[] GetMethodRawTypeAnnotations(int index); + internal abstract byte[] GetFieldRawTypeAnnotations(int index); } *************** *** 3440,3443 **** --- 3444,3471 ---- return finalizeMethod; } + + internal override object[] GetConstantPool() + { + Debug.Fail("Unreachable code"); + return null; + } + + internal override byte[] GetRawTypeAnnotations() + { + Debug.Fail("Unreachable code"); + return null; + } + + internal override byte[] GetMethodRawTypeAnnotations(int index) + { + Debug.Fail("Unreachable code"); + return null; + } + + internal override byte[] GetFieldRawTypeAnnotations(int index) + { + Debug.Fail("Unreachable code"); + return null; + } } *************** *** 3447,3456 **** private readonly object[][] annotations; private readonly MethodParametersEntry[][] methodParameters; ! private Metadata(string[][] genericMetaData, object[][] annotations, MethodParametersEntry[][] methodParameters) { this.genericMetaData = genericMetaData; this.annotations = annotations; this.methodParameters = methodParameters; } --- 3475,3489 ---- private readonly object[][] annotations; private readonly MethodParametersEntry[][] methodParameters; + private readonly byte[][][] runtimeVisibleTypeAnnotations; + private readonly object[] constantPool; ! private Metadata(string[][] genericMetaData, object[][] annotations, MethodParametersEntry[][] methodParameters, ! byte[][][] runtimeVisibleTypeAnnotations, object[] constantPool) { this.genericMetaData = genericMetaData; this.annotations = annotations; this.methodParameters = methodParameters; + this.runtimeVisibleTypeAnnotations = runtimeVisibleTypeAnnotations; + this.constantPool = constantPool; } *************** *** 3464,3467 **** --- 3497,3501 ---- object[][] annotations = null; MethodParametersEntry[][] methodParameters = null; + byte[][][] runtimeVisibleTypeAnnotations = null; for (int i = 0; i < classFile.Methods.Length; i++) { *************** *** 3522,3525 **** --- 3556,3571 ---- methodParameters[i] = classFile.Methods[i].MethodParameters; } + if (classFile.Methods[i].RuntimeVisibleTypeAnnotations != null) + { + if (runtimeVisibleTypeAnnotations == null) + { + runtimeVisibleTypeAnnotations = new byte[3][][]; + } + if (runtimeVisibleTypeAnnotations[1] == null) + { + runtimeVisibleTypeAnnotations[1] = new byte[classFile.Methods.Length][]; + } + runtimeVisibleTypeAnnotations[1][i] = classFile.Methods[i].RuntimeVisibleTypeAnnotations; + } } for (int i = 0; i < classFile.Fields.Length; i++) *************** *** 3549,3552 **** --- 3595,3610 ---- annotations[4][i] = classFile.Fields[i].Annotations; } + if (classFile.Fields[i].RuntimeVisibleTypeAnnotations != null) + { + if (runtimeVisibleTypeAnnotations == null) + { + runtimeVisibleTypeAnnotations = new byte[3][][]; + } + if (runtimeVisibleTypeAnnotations[2] == null) + { + runtimeVisibleTypeAnnotations[2] = new byte[classFile.Fields.Length][]; + } + runtimeVisibleTypeAnnotations[2][i] = classFile.Fields[i].RuntimeVisibleTypeAnnotations; + } } if (classFile.EnclosingMethod != null) *************** *** 3574,3580 **** annotations[0] = classFile.Annotations; } ! if (genericMetaData != null || annotations != null || methodParameters != null) { ! return new Metadata(genericMetaData, annotations, methodParameters); } return null; --- 3632,3647 ---- annotations[0] = classFile.Annotations; } ! if (classFile.RuntimeVisibleTypeAnnotations != null) { ! if (runtimeVisibleTypeAnnotations == null) ! { ! runtimeVisibleTypeAnnotations = new byte[3][][]; ! } ! runtimeVisibleTypeAnnotations[0] = new byte[1][] { classFile.RuntimeVisibleTypeAnnotations }; ! } ! if (genericMetaData != null || annotations != null || methodParameters != null || runtimeVisibleTypeAnnotations != null) ! { ! object[] constantPool = runtimeVisibleTypeAnnotations == null ? null : classFile.GetConstantPool(); ! return new Metadata(genericMetaData, annotations, methodParameters, runtimeVisibleTypeAnnotations, constantPool); } return null; *************** *** 3671,3674 **** --- 3738,3773 ---- return null; } + + internal static object[] GetConstantPool(Metadata m) + { + return m.constantPool; + } + + internal static byte[] GetRawTypeAnnotations(Metadata m) + { + if (m != null && m.runtimeVisibleTypeAnnotations != null && m.runtimeVisibleTypeAnnotations[0] != null) + { + return m.runtimeVisibleTypeAnnotations[0][0]; + } + return null; + } + + internal static byte[] GetMethodRawTypeAnnotations(Metadata m, int index) + { + if (m != null && m.runtimeVisibleTypeAnnotations != null && m.runtimeVisibleTypeAnnotations[1] != null) + { + return m.runtimeVisibleTypeAnnotations[1][index]; + } + return null; + } + + internal static byte[] GetFieldRawTypeAnnotations(Metadata m, int index) + { + if (m != null && m.runtimeVisibleTypeAnnotations != null && m.runtimeVisibleTypeAnnotations[2] != null) + { + return m.runtimeVisibleTypeAnnotations[2][index]; + } + return null; + } } *************** *** 3809,3812 **** --- 3908,3931 ---- return finalizeMethod; } + + internal override object[] GetConstantPool() + { + return Metadata.GetConstantPool(metadata); + } + + internal override byte[] GetRawTypeAnnotations() + { + return Metadata.GetRawTypeAnnotations(metadata); + } + + internal override byte[] GetMethodRawTypeAnnotations(int index) + { + return Metadata.GetMethodRawTypeAnnotations(metadata, index); + } + + internal override byte[] GetFieldRawTypeAnnotations(int index) + { + return Metadata.GetFieldRawTypeAnnotations(metadata, index); + } } *************** *** 6667,6671 **** return null; } - private Type GetBaseTypeForDefineType() { --- 6786,6789 ---- *************** *** 6759,6762 **** --- 6877,6901 ---- ; } + + + internal override object[] GetConstantPool() + { + return impl.GetConstantPool(); + } + + internal override byte[] GetRawTypeAnnotations() + { + return impl.GetRawTypeAnnotations(); + } + + internal override byte[] GetMethodRawTypeAnnotations(MethodWrapper mw) + { + return impl.GetMethodRawTypeAnnotations(Array.IndexOf(GetMethods(), mw)); + } + + internal override byte[] GetFieldRawTypeAnnotations(FieldWrapper fw) + { + return impl.GetFieldRawTypeAnnotations(Array.IndexOf(GetFields(), fw)); + } } Index: ClassFile.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/ClassFile.cs,v retrieving revision 1.128 retrieving revision 1.129 diff -C2 -d -r1.128 -r1.129 *** ClassFile.cs 3 Jun 2014 14:28:37 -0000 1.128 --- ClassFile.cs 5 Jun 2014 11:08:57 -0000 1.129 *************** *** 84,87 **** --- 84,88 ---- private string[] enclosingMethod; private BootstrapMethod[] bootstrapMethods; + private byte[] runtimeVisibleTypeAnnotations; private static class SupportedVersions *************** *** 488,491 **** --- 489,500 ---- bootstrapMethods = ReadBootstrapMethods(br, this); break; + case "RuntimeVisibleTypeAnnotations": + if(majorVersion < 52) + { + goto default; + } + CreateUtf8ConstantPoolItems(utf8_cp); + runtimeVisibleTypeAnnotations = br.Section(br.ReadUInt32()).ToArray(); + break; case "IKVM.NET.Assembly": if(br.ReadUInt32() != 2) *************** *** 537,540 **** --- 546,560 ---- } + private void CreateUtf8ConstantPoolItems(string[] utf8_cp) + { + for (int i = 0; i < constantpool.Length; i++) + { + if (constantpool[i] == null && utf8_cp[i] != null) + { + constantpool[i] = new ConstantPoolItemUtf8(utf8_cp[i]); + } + } + } + private void CheckDuplicates<T>(T[] members, string msg) where T : IEquatable<T> *************** *** 1260,1263 **** --- 1280,1304 ---- } + internal byte[] RuntimeVisibleTypeAnnotations + { + get + { + return runtimeVisibleTypeAnnotations; + } + } + + internal object[] GetConstantPool() + { + object[] cp = new object[constantpool.Length]; + for (int i = 1; i < cp.Length; i++) + { + if (constantpool[i] != null) + { + cp[i] = constantpool[i].GetRuntimeValue(); + } + } + return cp; + } + internal string IKVMAssemblyAttribute { *************** *** 1398,1401 **** --- 1439,1449 ---- { } + + // this is used for sun.reflect.ConstantPool + // it returns a boxed System.Int32, System.Int64, System.Float, System.Double or a string + internal virtual object GetRuntimeValue() + { + return null; + } } *************** *** 1584,1587 **** --- 1632,1640 ---- } } + + internal override object GetRuntimeValue() + { + return d; + } } *************** *** 1914,1917 **** --- 1967,1975 ---- } } + + internal override object GetRuntimeValue() + { + return v; + } } *************** *** 1937,1940 **** --- 1995,2003 ---- } } + + internal override object GetRuntimeValue() + { + return v; + } } *************** *** 1960,1963 **** --- 2023,2031 ---- } } + + internal override object GetRuntimeValue() + { + return l; + } } *************** *** 2242,2245 **** --- 2310,2330 ---- } + // this is only used to copy strings into "constantpool" when we see a RuntimeVisibleTypeAnnotations attribute, + // because we need a consistent way of exposing constant pool items to the runtime and that case + private sealed class ConstantPoolItemUtf8 : ConstantPoolItem + { + private readonly string str; + + internal ConstantPoolItemUtf8(string str) + { + this.str = str; + } + + internal override object GetRuntimeValue() + { + return str; + } + } + private sealed class ConstantPoolItemLiveObject : ConstantPoolItem { *************** *** 2284,2287 **** --- 2369,2373 ---- protected string signature; protected object[] annotations; + protected byte[] runtimeVisibleTypeAnnotations; internal FieldOrMethod(ClassFile classFile, string[] utf8_cp, BigEndianBinaryReader br) *************** *** 2440,2443 **** --- 2526,2537 ---- } + internal byte[] RuntimeVisibleTypeAnnotations + { + get + { + return runtimeVisibleTypeAnnotations; + } + } + public sealed override int GetHashCode() { *************** *** 2574,2577 **** --- 2668,2679 ---- } break; + case "RuntimeVisibleTypeAnnotations": + if (classFile.MajorVersion < 52) + { + goto default; + } + classFile.CreateUtf8ConstantPoolItems(utf8_cp); + runtimeVisibleTypeAnnotations = br.Section(br.ReadUInt32()).ToArray(); + break; default: br.Skip(br.ReadUInt32()); *************** *** 2924,2927 **** --- 3026,3037 ---- break; } + case "RuntimeVisibleTypeAnnotations": + if (classFile.MajorVersion < 52) + { + goto default; + } + classFile.CreateUtf8ConstantPoolItems(utf8_cp); + runtimeVisibleTypeAnnotations = br.Section(br.ReadUInt32()).ToArray(); + break; default: br.Skip(br.ReadUInt32()); Index: BigEndianBinaryReader.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/BigEndianBinaryReader.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BigEndianBinaryReader.cs 1 May 2012 07:20:51 -0000 1.8 --- BigEndianBinaryReader.cs 5 Jun 2014 11:08:57 -0000 1.9 *************** *** 1,4 **** /* ! Copyright (C) 2002-2012 Jeroen Frijters This software is provided 'as-is', without any express or implied --- 1,4 ---- /* ! Copyright (C) 2002-2014 Jeroen Frijters This software is provided 'as-is', without any express or implied *************** *** 225,227 **** --- 225,234 ---- return i; } + + internal byte[] ToArray() + { + byte[] res = new byte[end - pos]; + Buffer.BlockCopy(buf, pos, res, 0, res.Length); + return res; + } } |
|
From: Jeroen F. <jfr...@us...> - 2014-06-04 14:32:12
|
Update of /cvsroot/ikvm/ikvm/openjdk/java/lang In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv25456/openjdk/java/lang Modified Files: LangHelper.java Log Message: Simplified AnnotationType meta annotation handling. Index: LangHelper.java =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/java/lang/LangHelper.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** LangHelper.java 19 May 2014 12:43:38 -0000 1.20 --- LangHelper.java 4 Jun 2014 14:32:10 -0000 1.21 *************** *** 35,48 **** public class LangHelper { - static native sun.reflect.ConstantPool getConstantPool(Class klass); - static native byte[] getRawClassAnnotations(Class<?> klass); - public static sun.misc.JavaLangAccess getJavaLangAccess() { return new sun.misc.JavaLangAccess() { public sun.reflect.ConstantPool getConstantPool(Class klass) { ! // this returns a special purpose constant pool for use with getRawClassAnnotations only ! // and is only used for meta annotations ! return LangHelper.getConstantPool(klass); } public boolean casAnnotationType(Class<?> klass, AnnotationType oldType, AnnotationType newType) { --- 35,43 ---- public class LangHelper { public static sun.misc.JavaLangAccess getJavaLangAccess() { return new sun.misc.JavaLangAccess() { public sun.reflect.ConstantPool getConstantPool(Class klass) { ! return klass.getConstantPool(); } public boolean casAnnotationType(Class<?> klass, AnnotationType oldType, AnnotationType newType) { *************** *** 56,61 **** } public byte[] getRawClassAnnotations(Class<?> klass) { ! // this only returns the meta annotations Retention and Inherited ! return LangHelper.getRawClassAnnotations(klass); } public byte[] getRawClassTypeAnnotations(Class<?> klass) { --- 51,55 ---- } public byte[] getRawClassAnnotations(Class<?> klass) { ! throw new InternalError(); } public byte[] getRawClassTypeAnnotations(Class<?> klass) { |
|
From: Jeroen F. <jfr...@us...> - 2014-06-04 13:15:08
|
Update of /cvsroot/ikvm/ikvm/openjdk/sun/reflect/annotation In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20575 Added Files: AnnotationType.java Log Message: Prepare for forking. --- NEW FILE: AnnotationType.java --- /* * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package sun.reflect.annotation; import sun.misc.JavaLangAccess; import java.lang.annotation.*; import java.lang.reflect.*; import java.util.*; import java.security.AccessController; import java.security.PrivilegedAction; /** * Represents an annotation type at run time. Used to type-check annotations * and apply member defaults. * * @author Josh Bloch * @since 1.5 */ public class AnnotationType { /** * Member name -> type mapping. Note that primitive types * are represented by the class objects for the corresponding wrapper * types. This matches the return value that must be used for a * dynamic proxy, allowing for a simple isInstance test. */ private final Map<String, Class<?>> memberTypes; /** * Member name -> default value mapping. */ private final Map<String, Object> memberDefaults; /** * Member name -> Method object mapping. This (and its assoicated * accessor) are used only to generate AnnotationTypeMismatchExceptions. */ private final Map<String, Method> members; /** * The retention policy for this annotation type. */ private final RetentionPolicy retention; /** * Whether this annotation type is inherited. */ private final boolean inherited; /** * Returns an AnnotationType instance for the specified annotation type. * * @throw IllegalArgumentException if the specified class object for * does not represent a valid annotation type */ public static AnnotationType getInstance( Class<? extends Annotation> annotationClass) { JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess(); AnnotationType result = jla.getAnnotationType(annotationClass); // volatile read if (result == null) { result = new AnnotationType(annotationClass); // try to CAS the AnnotationType: null -> result if (!jla.casAnnotationType(annotationClass, null, result)) { // somebody was quicker -> read it's result result = jla.getAnnotationType(annotationClass); assert result != null; } } return result; } /** * Sole constructor. * * @param annotationClass the class object for the annotation type * @throw IllegalArgumentException if the specified class object for * does not represent a valid annotation type */ private AnnotationType(final Class<? extends Annotation> annotationClass) { if (!annotationClass.isAnnotation()) throw new IllegalArgumentException("Not an annotation type"); Method[] methods = AccessController.doPrivileged(new PrivilegedAction<Method[]>() { public Method[] run() { // Initialize memberTypes and defaultValues return annotationClass.getDeclaredMethods(); } }); memberTypes = new HashMap<String,Class<?>>(methods.length+1, 1.0f); memberDefaults = new HashMap<String, Object>(0); members = new HashMap<String, Method>(methods.length+1, 1.0f); for (Method method : methods) { if (method.getParameterTypes().length != 0) throw new IllegalArgumentException(method + " has params"); String name = method.getName(); Class<?> type = method.getReturnType(); memberTypes.put(name, invocationHandlerReturnType(type)); members.put(name, method); Object defaultValue = method.getDefaultValue(); if (defaultValue != null) memberDefaults.put(name, defaultValue); } // Initialize retention, & inherited fields. Special treatment // of the corresponding annotation types breaks infinite recursion. if (annotationClass != Retention.class && annotationClass != Inherited.class) { JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess(); Map<Class<? extends Annotation>, Annotation> metaAnnotations = AnnotationParser.parseSelectAnnotations( jla.getRawClassAnnotations(annotationClass), jla.getConstantPool(annotationClass), annotationClass, Retention.class, Inherited.class ); Retention ret = (Retention) metaAnnotations.get(Retention.class); retention = (ret == null ? RetentionPolicy.CLASS : ret.value()); inherited = metaAnnotations.containsKey(Inherited.class); } else { retention = RetentionPolicy.RUNTIME; inherited = false; } } /** * Returns the type that must be returned by the invocation handler * of a dynamic proxy in order to have the dynamic proxy return * the specified type (which is assumed to be a legal member type * for an annotation). */ public static Class<?> invocationHandlerReturnType(Class<?> type) { // Translate primitives to wrappers if (type == byte.class) return Byte.class; if (type == char.class) return Character.class; if (type == double.class) return Double.class; if (type == float.class) return Float.class; if (type == int.class) return Integer.class; if (type == long.class) return Long.class; if (type == short.class) return Short.class; if (type == boolean.class) return Boolean.class; // Otherwise, just return declared type return type; } /** * Returns member types for this annotation type * (member name -> type mapping). */ public Map<String, Class<?>> memberTypes() { return memberTypes; } /** * Returns members of this annotation type * (member name -> associated Method object mapping). */ public Map<String, Method> members() { return members; } /** * Returns the default values for this annotation type * (Member name -> default value mapping). */ public Map<String, Object> memberDefaults() { return memberDefaults; } /** * Returns the retention policy for this annotation type. */ public RetentionPolicy retention() { return retention; } /** * Returns true if this this annotation type is inherited. */ public boolean isInherited() { return inherited; } /** * For debugging. */ public String toString() { return "Annotation Type:\n" + " Member types: " + memberTypes + "\n" + " Member defaults: " + memberDefaults + "\n" + " Retention policy: " + retention + "\n" + " Inherited: " + inherited; } } |
|
From: Jeroen F. <jfr...@us...> - 2014-06-04 13:14:34
|
Update of /cvsroot/ikvm/ikvm/openjdk/sun/reflect/annotation In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20516/annotation Log Message: Directory /cvsroot/ikvm/ikvm/openjdk/sun/reflect/annotation added to the repository |
|
From: Jeroen F. <jfr...@us...> - 2014-06-04 06:45:17
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29361 Modified Files: DotNetTypeWrapper.cs Log Message: Fixed .NET type method parameter reflection to handle methods with parameters without names. Index: DotNetTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DotNetTypeWrapper.cs,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** DotNetTypeWrapper.cs 3 Jun 2014 13:13:15 -0000 1.77 --- DotNetTypeWrapper.cs 4 Jun 2014 06:45:15 -0000 1.78 *************** *** 2803,2809 **** } MethodParametersEntry[] mp = new MethodParametersEntry[parameters.Length]; for (int i = 0; i < mp.Length; i++) { ! mp[i].name = parameters[i].Name; } return mp; --- 2803,2821 ---- } MethodParametersEntry[] mp = new MethodParametersEntry[parameters.Length]; + bool hasName = false; for (int i = 0; i < mp.Length; i++) { ! string name = parameters[i].Name; ! bool empty = String.IsNullOrEmpty(name); ! if (empty) ! { ! name = "arg" + i; ! } ! mp[i].name = name; ! hasName |= !empty; ! } ! if (!hasName) ! { ! return null; } return mp; |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 14:28:39
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28251 Modified Files: ClassFile.cs DynamicTypeWrapper.cs Log Message: Match OpenJDK handling of invalid MethodParameters attribute. Index: DynamicTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DynamicTypeWrapper.cs,v retrieving revision 1.245 retrieving revision 1.246 diff -C2 -d -r1.245 -r1.246 *** DynamicTypeWrapper.cs 3 Jun 2014 12:42:19 -0000 1.245 --- DynamicTypeWrapper.cs 3 Jun 2014 14:28:37 -0000 1.246 *************** *** 6362,6366 **** { string name = null; ! if (parameterNames != null) { name = parameterNames[i]; --- 6362,6366 ---- { string name = null; ! if (parameterNames != null && parameterNames[i] != null) { name = parameterNames[i]; Index: ClassFile.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/ClassFile.cs,v retrieving revision 1.127 retrieving revision 1.128 diff -C2 -d -r1.127 -r1.128 *** ClassFile.cs 3 Jun 2014 12:04:41 -0000 1.127 --- ClassFile.cs 3 Jun 2014 14:28:37 -0000 1.128 *************** *** 2963,2967 **** { ushort name = rdr.ReadUInt16(); ! if(name <= 0 || name >= utf8_cp.Length || utf8_cp[name] == null) { return MethodParametersEntry.Malformed; --- 2963,2967 ---- { ushort name = rdr.ReadUInt16(); ! if(name >= utf8_cp.Length || (name != 0 && utf8_cp[name] == null)) { return MethodParametersEntry.Malformed; *************** *** 2973,2977 **** } } ! return MethodParametersEntry.Malformed; } --- 2973,2977 ---- } } ! throw new ClassFormatError("Invalid MethodParameters method attribute length " + length + " in class file"); } |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 13:13:17
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23392 Modified Files: DotNetTypeWrapper.cs Log Message: Added parameter reflection for Invoke method on (fake) delegate nested interface. Index: DotNetTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DotNetTypeWrapper.cs,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** DotNetTypeWrapper.cs 3 Jun 2014 12:04:41 -0000 1.76 --- DotNetTypeWrapper.cs 3 Jun 2014 13:13:15 -0000 1.77 *************** *** 456,459 **** --- 456,464 ---- get { return true; } } + + internal override MethodParametersEntry[] GetMethodParameters(MethodWrapper mw) + { + return DeclaringTypeWrapper.GetMethodParameters(DeclaringTypeWrapper.GetMethodWrapper(mw.Name, mw.Signature, false)); + } } |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 12:43:31
|
Update of /cvsroot/ikvm/ikvm/openjdk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21421 Modified Files: openjdk.build Log Message: Compile core class library with javac -parameters option to capture all method parameter names. Index: openjdk.build =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/openjdk.build,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** openjdk.build 29 May 2014 13:33:52 -0000 1.108 --- openjdk.build 3 Jun 2014 12:43:29 -0000 1.109 *************** *** 181,184 **** --- 181,185 ---- <arg value="-nowarn" /> <arg value="-implicit:none" /> + <arg value="-parameters" /> <arg line="-cp dummy" /> <arg value="-bootclasspath" /> *************** *** 212,215 **** --- 213,226 ---- <target name="run-nasgen"> + <!-- nasgen doesn't understand the MethodParameters attribute, so we have to recompile the classes it processes without parameters --> + <exec program="javac" useruntimeengine="false"> + <arg value="-XDignore.symbol.file" /> + <arg value="-g" /> + <arg value="-nowarn" /> + <arg value="-implicit:none" /> + <arg value="-cp" /> + <arg path="mscorlib.jar;../runtime/IKVM.Runtime.jar" /> + <arg value="${OpenJDK.dir}/nashorn/src/jdk/nashorn/internal/objects/*.java" /> + </exec> <exec program="java" useruntimeengine="false"> <arg line="-cp ${OpenJDK.dir}/nashorn/buildtools/nasgen/src" /> *************** *** 343,346 **** --- 354,358 ---- <arg value="-nowarn:110" /> <arg value="-w4" /> + <arg value="-noparameterreflection" /> <arg value="-warnaserror" /> <arg value="@response.gen.txt" /> *************** *** 410,413 **** --- 422,426 ---- <arg value="-warnaserror" /> <arg value="-w4" /> + <arg value="-noparameterreflection" /> <arg value="@tools.gen.rsp" /> </exec> |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 12:42:21
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21295/runtime Modified Files: ClassLoaderWrapper.cs DynamicTypeWrapper.cs Log Message: Added (undocumented) -noparameterreflection option ikvmc to disable emitting method parameter reflection metadata, because we want to javac compile core class library with the -parameters option (to get the parameter names of native and abstract methods), but we don't want the reflection info (because the JDK doesn't include it either). Index: ClassLoaderWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/ClassLoaderWrapper.cs,v retrieving revision 1.224 retrieving revision 1.225 diff -C2 -d -r1.224 -r1.225 *** ClassLoaderWrapper.cs 1 May 2014 11:56:28 -0000 1.224 --- ClassLoaderWrapper.cs 3 Jun 2014 12:42:19 -0000 1.225 *************** *** 1496,1499 **** --- 1496,1504 ---- get { return false; } } + + internal virtual bool NoParameterReflection + { + get { return false; } + } #endif } Index: DynamicTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DynamicTypeWrapper.cs,v retrieving revision 1.244 retrieving revision 1.245 diff -C2 -d -r1.244 -r1.245 *** DynamicTypeWrapper.cs 3 Jun 2014 12:04:42 -0000 1.244 --- DynamicTypeWrapper.cs 3 Jun 2014 12:42:19 -0000 1.245 *************** *** 2954,2958 **** AttributeHelper.SetSignatureAttribute(method, m.GenericSignature); } ! if (m.MalformedMethodParameters) { AttributeHelper.SetMethodParametersAttribute(method, null); --- 2954,2962 ---- AttributeHelper.SetSignatureAttribute(method, m.GenericSignature); } ! if (wrapper.GetClassLoader().NoParameterReflection) ! { ! // ignore MethodParameters (except to extract parameter names) ! } ! else if (m.MalformedMethodParameters) { AttributeHelper.SetMethodParametersAttribute(method, null); *************** *** 4587,4591 **** #if STATIC_COMPILER || (classFile.IsPublic && (m.IsPublic || m.IsProtected)) ! || m.MethodParameters != null #endif ) --- 4591,4595 ---- #if STATIC_COMPILER || (classFile.IsPublic && (m.IsPublic || m.IsProtected)) ! || (m.MethodParameters != null && !wrapper.GetClassLoader().NoParameterReflection) #endif ) |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 12:04:44
|
Update of /cvsroot/ikvm/ikvm/runtime/openjdk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv18943/openjdk Modified Files: java.lang.reflect.cs Log Message: - Enabled MethodParameter rendering in runtime stub generator. - Support round tripping malformed MethodParameter attribute in stub generator. - Use new general method parameter interface in ikvmstub. - Added support for method parameter reflection on .NET types. Index: java.lang.reflect.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/openjdk/java.lang.reflect.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** java.lang.reflect.cs 3 Jun 2014 07:15:52 -0000 1.8 --- java.lang.reflect.cs 3 Jun 2014 12:04:42 -0000 1.9 *************** *** 716,725 **** #else MethodWrapper mw = MethodWrapper.FromExecutable(_this); ! ClassFile.Method.MethodParametersEntry[] methodParameters = mw.DeclaringType.GetMethodParameters(mw); if (methodParameters == null) { return null; } ! if (methodParameters == ClassFile.Method.MethodParametersEntry.Malformed) { throw new java.lang.reflect.MalformedParametersException(); --- 716,725 ---- #else MethodWrapper mw = MethodWrapper.FromExecutable(_this); ! MethodParametersEntry[] methodParameters = mw.DeclaringType.GetMethodParameters(mw); if (methodParameters == null) { return null; } ! if (methodParameters == MethodParametersEntry.Malformed) { throw new java.lang.reflect.MalformedParametersException(); |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 09:13:59
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8699 Modified Files: DynamicTypeWrapper.cs TypeWrapper.cs attributes.cs Log Message: Added support for MethodParameters in statically compiled classes. Index: TypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/TypeWrapper.cs,v retrieving revision 1.466 retrieving revision 1.467 diff -C2 -d -r1.466 -r1.467 *** TypeWrapper.cs 3 Jun 2014 07:15:52 -0000 1.466 --- TypeWrapper.cs 3 Jun 2014 09:13:56 -0000 1.467 *************** *** 73,76 **** --- 73,77 ---- private static ConstructorInfo enclosingMethodAttribute; private static ConstructorInfo signatureAttribute; + private static ConstructorInfo methodParametersAttribute; private static CustomAttributeBuilder paramArrayAttribute; private static ConstructorInfo nonNestedInnerClassAttribute; *************** *** 99,102 **** --- 100,104 ---- private static readonly Type typeofNonNestedOuterClassAttribute = JVM.LoadType(typeof(NonNestedOuterClassAttribute)); private static readonly Type typeofEnclosingMethodAttribute = JVM.LoadType(typeof(EnclosingMethodAttribute)); + private static readonly Type typeofMethodParametersAttribute = JVM.LoadType(typeof(MethodParametersAttribute)); private static readonly CustomAttributeBuilder hideFromJavaAttribute = new CustomAttributeBuilder(typeofHideFromJavaAttribute.GetConstructor(Type.EmptyTypes), new object[0]); private static readonly CustomAttributeBuilder hideFromReflection = new CustomAttributeBuilder(typeofHideFromJavaAttribute.GetConstructor(new Type[] { typeofHideFromJavaFlags }), new object[] { HideFromJavaFlags.Reflection | HideFromJavaFlags.StackTrace | HideFromJavaFlags.StackWalk }); *************** *** 857,860 **** --- 859,871 ---- } + internal static void SetMethodParametersAttribute(MethodBuilder mb, Modifiers[] modifiers) + { + if(methodParametersAttribute == null) + { + methodParametersAttribute = typeofMethodParametersAttribute.GetConstructor(new Type[] { typeofModifiers.MakeArrayType() }); + } + mb.SetCustomAttribute(new CustomAttributeBuilder(methodParametersAttribute, new object[] { modifiers })); + } + internal static void SetParamArrayAttribute(ParameterBuilder pb) { *************** *** 985,988 **** --- 996,1014 ---- } + internal static MethodParametersAttribute GetMethodParameters(MethodBase method) + { + #if !STATIC_COMPILER && !STUB_GENERATOR + object[] attribs = method.GetCustomAttributes(typeof(MethodParametersAttribute), false); + return attribs.Length == 1 ? (MethodParametersAttribute)attribs[0] : null; + #else + foreach(CustomAttributeData cad in CustomAttributeData.__GetCustomAttributes(method, typeofMethodParametersAttribute, false)) + { + IList<CustomAttributeTypedArgument> args = cad.ConstructorArguments; + return new MethodParametersAttribute(DecodeArray<Modifiers>(args[0])); + } + return null; + #endif + } + internal static InnerClassAttribute GetInnerClass(Type type) { *************** *** 4956,4959 **** --- 4982,5012 ---- } + internal override ClassFile.Method.MethodParametersEntry[] GetMethodParameters(MethodWrapper mw) + { + MethodBase mb = mw.GetMethod(); + if(mb == null) + { + // delegate constructor + return null; + } + MethodParametersAttribute attr = AttributeHelper.GetMethodParameters(mb); + if(attr == null) + { + return null; + } + if(attr.IsMalformed) + { + return ClassFile.Method.MethodParametersEntry.Malformed; + } + ParameterInfo[] parameters = mb.GetParameters(); + ClassFile.Method.MethodParametersEntry[] mp = new ClassFile.Method.MethodParametersEntry[attr.Modifiers.Length]; + for(int i = 0; i < mp.Length; i++) + { + mp[i].name = i < parameters.Length ? parameters[i].Name : null; + mp[i].flags = (ushort)attr.Modifiers[i]; + } + return mp; + } + internal override object[] GetFieldAnnotations(FieldWrapper fw) { Index: attributes.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/attributes.cs,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** attributes.cs 2 Jun 2014 13:25:40 -0000 1.46 --- attributes.cs 3 Jun 2014 09:13:56 -0000 1.47 *************** *** 861,864 **** --- 861,885 ---- } + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor)] + public sealed class MethodParametersAttribute : Attribute + { + private readonly Modifiers[] modifiers; + + public MethodParametersAttribute(Modifiers[] modifiers) + { + this.modifiers = modifiers; + } + + public Modifiers[] Modifiers + { + get { return modifiers; } + } + + public bool IsMalformed + { + get { return modifiers == null; } + } + } + // used in custom modifier for access stubs public static class AccessStub { } Index: DynamicTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DynamicTypeWrapper.cs,v retrieving revision 1.242 retrieving revision 1.243 diff -C2 -d -r1.242 -r1.243 *** DynamicTypeWrapper.cs 3 Jun 2014 07:15:52 -0000 1.242 --- DynamicTypeWrapper.cs 3 Jun 2014 09:13:56 -0000 1.243 *************** *** 2954,2957 **** --- 2954,2970 ---- AttributeHelper.SetSignatureAttribute(method, m.GenericSignature); } + if (m.MalformedMethodParameters) + { + AttributeHelper.SetMethodParametersAttribute(method, null); + } + else if (m.MethodParameters != null) + { + Modifiers[] modifiers = new Modifiers[m.MethodParameters.Length]; + for (int i = 0; i < modifiers.Length; i++) + { + modifiers[i] = (Modifiers)m.MethodParameters[i].flags; + } + AttributeHelper.SetMethodParametersAttribute(method, modifiers); + } #else // STATIC_COMPILER if (setModifiers) *************** *** 4574,4577 **** --- 4587,4591 ---- #if STATIC_COMPILER || (classFile.IsPublic && (m.IsPublic || m.IsProtected)) + || m.MethodParameters != null #endif ) *************** *** 4579,4584 **** parameterNames = new string[mw.GetParameters().Length]; GetParameterNamesFromMP(m, parameterNames); ! GetParameterNamesFromLVT(m, parameterNames); ! GetParameterNamesFromSig(m.Signature, parameterNames); #if STATIC_COMPILER wrapper.GetParameterNamesFromXml(m.Name, m.Signature, parameterNames); --- 4593,4603 ---- parameterNames = new string[mw.GetParameters().Length]; GetParameterNamesFromMP(m, parameterNames); ! #if STATIC_COMPILER ! if (m.MethodParameters == null) ! #endif ! { ! GetParameterNamesFromLVT(m, parameterNames); ! GetParameterNamesFromSig(m.Signature, parameterNames); ! } #if STATIC_COMPILER wrapper.GetParameterNamesFromXml(m.Name, m.Signature, parameterNames); |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 08:56:32
|
Update of /cvsroot/ikvm/ikvm/awt In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7773 Modified Files: toolkit-0.95.cs Log Message: - Prevent unfocable windows from being activated by mouse click. - Fixed clipboard access to use the right thread. (Based on patch by Maria Papendieck of pure-systems.) Index: toolkit-0.95.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/awt/toolkit-0.95.cs,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** toolkit-0.95.cs 19 May 2014 12:43:29 -0000 1.108 --- toolkit-0.95.cs 3 Jun 2014 08:56:30 -0000 1.109 *************** *** 128,131 **** --- 128,144 ---- } + private const int WM_MOUSEACTIVATE = 0x0021; + private const int MA_NOACTIVATE = 0x0003; + + protected override void WndProc(ref Message m) + { + if (!focusableWindow && m.Msg == WM_MOUSEACTIVATE) + { + m.Result = (IntPtr)MA_NOACTIVATE; + return; + } + base.WndProc(ref m); + } + protected override void OnPaintBackground(PaintEventArgs e) { *************** *** 5301,5305 **** return contents; } ! return new NetClipboardTransferable(Clipboard.GetDataObject()); } } --- 5314,5318 ---- return contents; } ! return new NetClipboardTransferable(NetToolkit.Invoke<IDataObject>(Clipboard.GetDataObject)); } } |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 07:15:54
|
Update of /cvsroot/ikvm/ikvm/runtime/openjdk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1742/openjdk Modified Files: java.lang.reflect.cs Log Message: Implemented method parameter reflection for dynamically loaded classes. Index: java.lang.reflect.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/openjdk/java.lang.reflect.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** java.lang.reflect.cs 27 May 2014 10:07:27 -0000 1.7 --- java.lang.reflect.cs 3 Jun 2014 07:15:52 -0000 1.8 *************** *** 712,716 **** --- 712,735 ---- public static object[] getParameters0(java.lang.reflect.Executable _this) { + #if FIRST_PASS return null; + #else + MethodWrapper mw = MethodWrapper.FromExecutable(_this); + ClassFile.Method.MethodParametersEntry[] methodParameters = mw.DeclaringType.GetMethodParameters(mw); + if (methodParameters == null) + { + return null; + } + if (methodParameters == ClassFile.Method.MethodParametersEntry.Malformed) + { + throw new java.lang.reflect.MalformedParametersException(); + } + java.lang.reflect.Parameter[] parameters = new java.lang.reflect.Parameter[methodParameters.Length]; + for (int i = 0; i < parameters.Length; i++) + { + parameters[i] = new java.lang.reflect.Parameter(methodParameters[i].name, methodParameters[i].flags, _this, i); + } + return parameters; + #endif } |
|
From: Jeroen F. <jfr...@us...> - 2014-06-03 07:14:07
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1655 Modified Files: ClassFile.cs Log Message: Malformed MethodParameters attribute should not throw ClassFormatError. Index: ClassFile.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/ClassFile.cs,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** ClassFile.cs 27 May 2014 12:32:26 -0000 1.125 --- ClassFile.cs 3 Jun 2014 07:14:04 -0000 1.126 *************** *** 2921,2936 **** throw new ClassFormatError("{0} (Duplicate MethodParameters attribute)", classFile.Name); } ! BigEndianBinaryReader rdr = br.Section(br.ReadUInt32()); ! byte parameters_count = rdr.ReadByte(); ! parameters = new MethodParametersEntry[parameters_count]; ! for(int j = 0; j < parameters_count; j++) ! { ! parameters[j].name = classFile.GetConstantPoolUtf8String(utf8_cp, rdr.ReadUInt16()); ! parameters[j].flags = rdr.ReadUInt16(); ! } ! if(!rdr.IsAtEnd) ! { ! throw new ClassFormatError("{0} (MethodParameters attribute has wrong length)", classFile.Name); ! } break; } --- 2921,2925 ---- throw new ClassFormatError("{0} (Duplicate MethodParameters attribute)", classFile.Name); } ! parameters = ReadMethodParameters(br, utf8_cp); break; } *************** *** 2961,2964 **** --- 2950,2979 ---- } + private static MethodParametersEntry[] ReadMethodParameters(BigEndianBinaryReader br, string[] utf8_cp) + { + uint length = br.ReadUInt32(); + if(length > 0) + { + BigEndianBinaryReader rdr = br.Section(length); + byte parameters_count = rdr.ReadByte(); + if(length == 1 + parameters_count * 4) + { + MethodParametersEntry[] parameters = new MethodParametersEntry[parameters_count]; + for(int j = 0; j < parameters_count; j++) + { + ushort name = rdr.ReadUInt16(); + if(name <= 0 || name >= utf8_cp.Length || utf8_cp[name] == null) + { + return MethodParametersEntry.Malformed; + } + parameters[j].name = utf8_cp[name]; + parameters[j].flags = rdr.ReadUInt16(); + } + return parameters; + } + } + return MethodParametersEntry.Malformed; + } + protected override void ValidateSig(ClassFile classFile, string descriptor) { *************** *** 3168,3171 **** --- 3183,3194 ---- } + internal bool MalformedMethodParameters + { + get + { + return parameters == MethodParametersEntry.Malformed; + } + } + internal bool HasJsr { *************** *** 3752,3755 **** --- 3775,3779 ---- internal struct MethodParametersEntry { + internal static readonly MethodParametersEntry[] Malformed = new MethodParametersEntry[0]; internal string name; internal ushort flags; |
|
From: Jeroen F. <jfr...@us...> - 2014-06-02 13:25:42
|
Update of /cvsroot/ikvm/ikvm/ikvmc In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28624/ikvmc Modified Files: CompilerClassLoader.cs Log Message: Fixed PackageListAttribute to be ECMA compliant. Index: CompilerClassLoader.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/ikvmc/CompilerClassLoader.cs,v retrieving revision 1.265 retrieving revision 1.266 diff -C2 -d -r1.265 -r1.266 *** CompilerClassLoader.cs 13 May 2014 14:13:14 -0000 1.265 --- CompilerClassLoader.cs 2 Jun 2014 13:25:40 -0000 1.266 *************** *** 561,566 **** if(options.sharedclassloader == null || options.sharedclassloader[0] == this) { ! string[][] list = packages.ToArray(); ! mb.SetCustomAttribute(new CustomAttributeBuilder(JVM.LoadType(typeof(PackageListAttribute)).GetConstructor(new Type[] { JVM.Import(typeof(string[][])) }), new object[] { list })); // We can't add the resource when we're a module, because a multi-module assembly has a single resource namespace // and since you cannot combine -target:module with -sharedclassloader we don't need an export map --- 561,569 ---- if(options.sharedclassloader == null || options.sharedclassloader[0] == this) { ! ConstructorInfo packageListAttributeCtor = JVM.LoadType(typeof(PackageListAttribute)).GetConstructor(new Type[] { Types.String, Types.String.MakeArrayType() }); ! foreach(object[] args in packages.ToArray()) ! { ! mb.SetCustomAttribute(new CustomAttributeBuilder(packageListAttributeCtor, args)); ! } // We can't add the resource when we're a module, because a multi-module assembly has a single resource namespace // and since you cannot combine -target:module with -sharedclassloader we don't need an export map *************** *** 4141,4148 **** } ! // see PackageListAttribute for the structure of this array ! internal string[][] ToArray() { ! List<string[]> list = new List<string[]>(); // we use an empty string to indicate we don't yet have a jar, // because null is used for packages that were defined from --- 4144,4151 ---- } ! // returns an array of PackageListAttribute constructor argument arrays ! internal object[][] ToArray() { ! List<object[]> list = new List<object[]>(); // we use an empty string to indicate we don't yet have a jar, // because null is used for packages that were defined from *************** *** 4157,4164 **** if (currentList.Count != 0) { ! list.Add(currentList.ToArray()); currentList.Clear(); } - currentList.Add(jar); currentJar = jar; } --- 4160,4166 ---- if (currentList.Count != 0) { ! list.Add(new object[] { currentJar, currentList.ToArray() }); currentList.Clear(); } currentJar = jar; } *************** *** 4167,4171 **** if (currentList.Count != 0) { ! list.Add(currentList.ToArray()); } return list.ToArray(); --- 4169,4173 ---- if (currentList.Count != 0) { ! list.Add(new object[] { currentJar, currentList.ToArray() }); } return list.ToArray(); |
|
From: Jeroen F. <jfr...@us...> - 2014-06-02 11:30:18
|
Update of /cvsroot/ikvm/ikvm/reflect/Writer In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21747/Writer Modified Files: VersionInfo.cs Log Message: Added UniverseOptions.DecodeVersionInfoAttributeBlobs to support decoding CustomAttributeBuilder with blob to extract version info fields. Index: VersionInfo.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/reflect/Writer/VersionInfo.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** VersionInfo.cs 7 Feb 2013 11:58:27 -0000 1.6 --- VersionInfo.cs 2 Jun 2014 11:30:15 -0000 1.7 *************** *** 51,55 **** } ! internal void SetAttribute(CustomAttributeBuilder cab) { Universe u = cab.Constructor.Module.universe; --- 51,55 ---- } ! internal void SetAttribute(AssemblyBuilder asm, CustomAttributeBuilder cab) { Universe u = cab.Constructor.Module.universe; *************** *** 57,89 **** if (copyright == null && type == u.System_Reflection_AssemblyCopyrightAttribute) { ! copyright = (string)cab.GetConstructorArgument(0); } else if (trademark == null && type == u.System_Reflection_AssemblyTrademarkAttribute) { ! trademark = (string)cab.GetConstructorArgument(0); } else if (product == null && type == u.System_Reflection_AssemblyProductAttribute) { ! product = (string)cab.GetConstructorArgument(0); } else if (company == null && type == u.System_Reflection_AssemblyCompanyAttribute) { ! company = (string)cab.GetConstructorArgument(0); } else if (description == null && type == u.System_Reflection_AssemblyDescriptionAttribute) { ! description = (string)cab.GetConstructorArgument(0); } else if (title == null && type == u.System_Reflection_AssemblyTitleAttribute) { ! title = (string)cab.GetConstructorArgument(0); } else if (informationalVersion == null && type == u.System_Reflection_AssemblyInformationalVersionAttribute) { ! informationalVersion = (string)cab.GetConstructorArgument(0); } else if (fileVersion == null && type == u.System_Reflection_AssemblyFileVersionAttribute) { ! fileVersion = (string)cab.GetConstructorArgument(0); } } --- 57,89 ---- if (copyright == null && type == u.System_Reflection_AssemblyCopyrightAttribute) { ! copyright = (string)cab.DecodeBlob(asm).GetConstructorArgument(0); } else if (trademark == null && type == u.System_Reflection_AssemblyTrademarkAttribute) { ! trademark = (string)cab.DecodeBlob(asm).GetConstructorArgument(0); } else if (product == null && type == u.System_Reflection_AssemblyProductAttribute) { ! product = (string)cab.DecodeBlob(asm).GetConstructorArgument(0); } else if (company == null && type == u.System_Reflection_AssemblyCompanyAttribute) { ! company = (string)cab.DecodeBlob(asm).GetConstructorArgument(0); } else if (description == null && type == u.System_Reflection_AssemblyDescriptionAttribute) { ! description = (string)cab.DecodeBlob(asm).GetConstructorArgument(0); } else if (title == null && type == u.System_Reflection_AssemblyTitleAttribute) { ! title = (string)cab.DecodeBlob(asm).GetConstructorArgument(0); } else if (informationalVersion == null && type == u.System_Reflection_AssemblyInformationalVersionAttribute) { ! informationalVersion = (string)cab.DecodeBlob(asm).GetConstructorArgument(0); } else if (fileVersion == null && type == u.System_Reflection_AssemblyFileVersionAttribute) { ! fileVersion = (string)cab.DecodeBlob(asm).GetConstructorArgument(0); } } |
|
From: Jeroen F. <jfr...@us...> - 2014-06-02 11:30:17
|
Update of /cvsroot/ikvm/ikvm/reflect/Emit In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21747/Emit Modified Files: AssemblyBuilder.cs Log Message: Added UniverseOptions.DecodeVersionInfoAttributeBlobs to support decoding CustomAttributeBuilder with blob to extract version info fields. Index: AssemblyBuilder.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/reflect/Emit/AssemblyBuilder.cs,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** AssemblyBuilder.cs 16 Nov 2013 08:50:32 -0000 1.58 --- AssemblyBuilder.cs 2 Jun 2014 11:30:14 -0000 1.59 *************** *** 374,380 **** { // .NET doesn't support copying blob custom attributes into the version info ! if (!cab.HasBlob) { ! versionInfo.SetAttribute(cab); } } --- 374,380 ---- { // .NET doesn't support copying blob custom attributes into the version info ! if (!cab.HasBlob || universe.DecodeVersionInfoAttributeBlobs) { ! versionInfo.SetAttribute(this, cab); } } |
|
From: Jeroen F. <jfr...@us...> - 2014-05-29 13:33:55
|
Update of /cvsroot/ikvm/ikvm/openjdk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv22768 Modified Files: openjdk.build Log Message: Fixed Linux build. Index: openjdk.build =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/openjdk.build,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -d -r1.107 -r1.108 *** openjdk.build 23 May 2014 09:19:18 -0000 1.107 --- openjdk.build 29 May 2014 13:33:52 -0000 1.108 *************** *** 191,195 **** <mkdir dir="rmistubs" /> <property name="VMARGS" value="-J-client -J-Xmx896m -J-Xms128m" /> ! <property name="CLASSPATH" value="mscorlib.jar;System.Xml.jar;${OpenJDK.dir}/jdk/src/share/classes/${pathsep}${OpenJDK.dir}/corba/src/share/classes" /> <property name="OUTPUT" value="rmistubs" /> <property name="ARGS" value="${VMARGS} -nowarn -bootclasspath ${CLASSPATH} -d ${OUTPUT}" /> --- 191,195 ---- <mkdir dir="rmistubs" /> <property name="VMARGS" value="-J-client -J-Xmx896m -J-Xms128m" /> ! <property name="CLASSPATH" value="mscorlib.jar${pathsep}System.Xml.jar${pathsep}${OpenJDK.dir}/jdk/src/share/classes/${pathsep}${OpenJDK.dir}/corba/src/share/classes" /> <property name="OUTPUT" value="rmistubs" /> <property name="ARGS" value="${VMARGS} -nowarn -bootclasspath ${CLASSPATH} -d ${OUTPUT}" /> |
|
From: Jeroen F. <jfr...@us...> - 2014-05-27 12:32:32
|
Update of /cvsroot/ikvm/ikvm/openjdk/ikvm/internal In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27925/openjdk/ikvm/internal Added Files: InterlockedCompareAndSet.java Log Message: Replaced Unsafe cas operations in Class with Interlocked.CompareExchange(). --- NEW FILE: InterlockedCompareAndSet.java --- /* Copyright (C) 2014 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 je...@fr... */ package ikvm.internal; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.CLASS) @Target(ElementType.METHOD) public @interface InterlockedCompareAndSet { String value(); } |
|
From: Jeroen F. <jfr...@us...> - 2014-05-27 12:32:28
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv27925/runtime Modified Files: ClassFile.cs DynamicTypeWrapper.cs Log Message: Replaced Unsafe cas operations in Class with Interlocked.CompareExchange(). Index: DynamicTypeWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/DynamicTypeWrapper.cs,v retrieving revision 1.240 retrieving revision 1.241 diff -C2 -d -r1.240 -r1.241 *** DynamicTypeWrapper.cs 21 May 2014 07:21:21 -0000 1.240 --- DynamicTypeWrapper.cs 27 May 2014 12:32:26 -0000 1.241 *************** *** 4098,4101 **** --- 4098,4106 ---- continue; } + if (m.InterlockedCompareAndSetField != null && EmitInterlockedCompareAndSet(methods[i], m.InterlockedCompareAndSetField, ilGenerator)) + { + ilGenerator.DoEmit(); + continue; + } #endif // see if there exists a "managed JNI" class for this type *************** *** 4460,4463 **** --- 4465,4538 ---- } + #if STATIC_COMPILER + private bool EmitInterlockedCompareAndSet(MethodWrapper method, string fieldName, CodeEmitter ilGenerator) + { + TypeWrapper[] parameters = method.GetParameters(); + if (!method.IsStatic || parameters.Length != 3 || method.ReturnType != PrimitiveTypeWrapper.BOOLEAN) + { + return false; + } + if (parameters[0].IsUnloadable || parameters[0].IsPrimitive || parameters[0].IsNonPrimitiveValueType || parameters[0].IsGhost) + { + return false; + } + if (parameters[1] != parameters[2]) + { + return false; + } + if (parameters[1].IsUnloadable || parameters[1].IsPrimitive || parameters[1].IsNonPrimitiveValueType || parameters[1].IsGhost) + { + return false; + } + FieldWrapper casField = null; + foreach (FieldWrapper fw in parameters[0].GetFields()) + { + if (fw.Name == fieldName) + { + if (casField != null) + { + return false; + } + casField = fw; + } + } + if (casField == null) + { + return false; + } + if (casField.IsStatic) + { + return false; + } + if (casField.IsPropertyAccessor) + { + return false; + } + if (casField.DeclaringType.TypeAsBaseType == typeBuilder.DeclaringType) + { + // allow access to fields in outer class + } + else if (!casField.IsAccessibleFrom(casField.DeclaringType, wrapper, casField.DeclaringType)) + { + return false; + } + casField.Link(); + FieldInfo fi = casField.GetField(); + if (fi == null) + { + return false; + } + ilGenerator.EmitLdarg(0); + ilGenerator.Emit(OpCodes.Ldflda, fi); + ilGenerator.EmitLdarg(2); + ilGenerator.EmitLdarg(1); + ilGenerator.Emit(OpCodes.Call, AtomicReferenceFieldUpdaterEmitter.MakeCompareExchange(casField.FieldTypeWrapper.TypeAsSignatureType)); + ilGenerator.EmitLdarg(1); + ilGenerator.Emit(OpCodes.Ceq); + ilGenerator.Emit(OpCodes.Ret); + return true; + } + #endif + private void AddMethodParameterInfo(ClassFile.Method m, MethodWrapper mw, MethodBuilder mb, out string[] parameterNames) { Index: ClassFile.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/ClassFile.cs,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -d -r1.124 -r1.125 *** ClassFile.cs 19 May 2014 09:09:57 -0000 1.124 --- ClassFile.cs 27 May 2014 12:32:26 -0000 1.125 *************** *** 2679,2682 **** --- 2679,2683 ---- internal string DllExportName; internal int DllExportOrdinal; + internal string InterlockedCompareAndSetField; #endif } *************** *** 2888,2891 **** --- 2889,2911 ---- } } + if(annot[1].Equals("Likvm/internal/InterlockedCompareAndSet;")) + { + string field = null; + for (int j = 2; j < annot.Length; j += 2) + { + if (annot[j].Equals("value") && annot[j + 1] is string) + { + field = (string)annot[j + 1]; + } + } + if (field != null) + { + if (low == null) + { + low = new LowFreqData(); + } + low.InterlockedCompareAndSetField = field; + } + } } break; *************** *** 3057,3060 **** --- 3077,3088 ---- } } + + internal string InterlockedCompareAndSetField + { + get + { + return low == null ? null : low.InterlockedCompareAndSetField; + } + } #endif |
|
From: Jeroen F. <jfr...@us...> - 2014-05-27 10:07:29
|
Update of /cvsroot/ikvm/ikvm/runtime In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19335/runtime Modified Files: JniInterface.cs MemberWrapper.cs Log Message: Replaced MethodWrapper.From[Method|Constructor|MethodOrConstructor] methods with MethodWrapper.FromExecutable(). Index: JniInterface.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/JniInterface.cs,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** JniInterface.cs 27 May 2014 09:44:08 -0000 1.106 --- JniInterface.cs 27 May 2014 10:07:27 -0000 1.107 *************** *** 1693,1697 **** internal static jmethodID FromReflectedMethod(JNIEnv* pEnv, jobject method) { ! return MethodWrapper.FromMethodOrConstructor((java.lang.reflect.Executable)pEnv->UnwrapRef(method)).Cookie; } --- 1693,1697 ---- internal static jmethodID FromReflectedMethod(JNIEnv* pEnv, jobject method) { ! return MethodWrapper.FromExecutable((java.lang.reflect.Executable)pEnv->UnwrapRef(method)).Cookie; } Index: MemberWrapper.cs =================================================================== RCS file: /cvsroot/ikvm/ikvm/runtime/MemberWrapper.cs,v retrieving revision 1.201 retrieving revision 1.202 diff -C2 -d -r1.201 -r1.202 *** MemberWrapper.cs 27 May 2014 09:44:09 -0000 1.201 --- MemberWrapper.cs 27 May 2014 10:07:27 -0000 1.202 *************** *** 564,592 **** #endif // !FIRST_PASS ! internal static MethodWrapper FromMethod(java.lang.reflect.Method method) ! { ! #if FIRST_PASS ! return null; ! #else ! return TypeWrapper.FromClass(method.getDeclaringClass()).GetMethods()[method._slot()]; ! #endif ! } ! ! internal static MethodWrapper FromConstructor(java.lang.reflect.Constructor constructor) { #if FIRST_PASS return null; #else ! return TypeWrapper.FromClass(constructor.getDeclaringClass()).GetMethods()[constructor._slot()]; #endif } - - internal static MethodWrapper FromMethodOrConstructor(java.lang.reflect.Executable methodOrConstructor) - { - java.lang.reflect.Method method = methodOrConstructor as java.lang.reflect.Method; - return method != null - ? FromMethod(method) - : FromConstructor((java.lang.reflect.Constructor)methodOrConstructor); - } #endif // !STATIC_COMPILER && !STUB_GENERATOR --- 564,575 ---- #endif // !FIRST_PASS ! internal static MethodWrapper FromExecutable(java.lang.reflect.Executable executable) { #if FIRST_PASS return null; #else ! return TypeWrapper.FromClass(executable.getDeclaringClass()).GetMethods()[executable._slot()]; #endif } #endif // !STATIC_COMPILER && !STUB_GENERATOR |