Re: Exchanging strings was: Windows Phone
Jaroslav Tulach <[email protected]> Tue, 17 Mar 2015 09:34:57 +0200
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <CAM6-voGUY1iG+P8NjZPBwb5H6U_MU4N+zv=iThp7=zBmX7jrhQ@mail.gmail.com> |
2015-03-16 8:50 GMT+02:00 Jeroen Frijters <[email protected]>: > You should also remove this line from ./ikvm/openjdk/map.xml: > > <implements > class="cli.System.Runtime.Serialization.ISerializable" /> > > and the GetObjectData method from these two classes: > > ./ikvm/openjdk/java/lang/Class.java > ./ikvm/openjdk/java/lang/Enum.java > > Thanks for your advice. I made one further step, but now the system cannot find System String class. That surprises me, I thought it is core .Net class provided by mscorlib. Here is the error and below is diff with my changes to remove the serialization. -jt System.TypeInitializationException was unhandled by user code HResult=-2146233036 Message=The type initializer for 'java.lang.StringHelper' threw an exception. Source=IKVM.OpenJDK.Core TypeName=java.lang.StringHelper StackTrace: at java.lang.StringHelper.getChars(String , Int32 , Int32 , Char[] , Int32 ) at java.lang.String.instancehelper_getChars(String this, Int32 srcBegin, Int32 srcEnd, Char[] dst, Int32 dstBegin) at java.lang.AbstractStringBuilder.append(String ) at java.lang.StringBuilder.append(String str) at cz.xelfi.test.Plus.add(Int32 one, Int32 two) at App1.MainPage.scriptNotifies(Object sender, NotifyEventArgs args) InnerException: System.IO.FileNotFoundException HResult=-2147024894 Message=Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. Source=IKVM.OpenJDK.Core FileName=System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 StackTrace: at java.lang.System.nanoTime() at java.lang.StringHelper..cctor() InnerException: Index: openjdk/map.xml =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/map.xml,v retrieving revision 1.91 diff -u -r1.91 map.xml --- openjdk/map.xml 29 Aug 2012 11:54:35 -0000 1.91 +++ openjdk/map.xml 17 Mar 2015 07:28:12 -0000 @@ -1395,7 +1395,6 @@ </class> <!-- Here we are adding/replacing methods to existing classes --> <class name="java.lang.Class"> - <implements class="cli.System.Runtime.Serialization.ISerializable" /> <field name="typeWrapper" sig="Lcli.IKVM.Internal.TypeWrapper;" modifiers=""> <attribute type="IKVM.Attributes.HideFromJavaAttribute" sig="()V" /> </field> @@ -1427,7 +1426,6 @@ </method> </class> <class name="java.lang.Enum"> - <implements class="cli.System.Runtime.Serialization.ISerializable" /> </class> <class name="java.lang.Thread"> <field name="parkLock" sig="Ljava.lang.Object;" modifiers="" /> Index: openjdk/openjdk.build =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/openjdk.build,v retrieving revision 1.91.2.1 diff -u -r1.91.2.1 openjdk.build --- openjdk/openjdk.build 31 Oct 2012 12:35:37 -0000 1.91.2.1 +++ openjdk/openjdk.build 17 Mar 2015 07:28:12 -0000 @@ -203,6 +203,7 @@ <arg value="-removeassertions" /> <arg value="-target:library" /> <arg value="-sharedclassloader" /> + <arg value="-noautoserialization" /> <arg value="-r:mscorlib.dll" /> <arg value="-r:System.dll" /> <arg value="-r:System.Core.dll" unless="${SkipSystemCoreDependency}" /> Index: openjdk/java/lang/Class.java =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/java/lang/Class.java,v retrieving revision 1.16 diff -u -r1.16 Class.java --- openjdk/java/lang/Class.java 23 May 2012 10:00:03 -0000 1.16 +++ openjdk/java/lang/Class.java 17 Mar 2015 07:28:16 -0000 @@ -211,18 +211,6 @@ this.type = type; } - // We use custom serialization, because we want to deserialize a via proxy that properly resolves the Class singletons. - // Note that we don't implement ISerializable in this source, but in map.xml to avoid it being visible to Java code. - // We don't have a security demand, because the information exposed is harmless. - @cli.IKVM.Attributes.HideFromJavaAttribute.Annotation - @cli.System.Security.SecurityCriticalAttribute.Annotation - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue("type", type); - info.AddValue("sig", type == null ? getSigName() : null); - info.SetType(ikvm.runtime.Util.getInstanceTypeFromClass(ClassSerializationProxy.class)); - } - private native String getSigName(); // [IKVM] this provides an implicit conversion operator from System.Type to java.lang.Class Index: openjdk/java/lang/Enum.java =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/java/lang/Enum.java,v retrieving revision 1.5 diff -u -r1.5 Enum.java --- openjdk/java/lang/Enum.java 19 Jun 2011 12:14:33 -0000 1.5 +++ openjdk/java/lang/Enum.java 17 Mar 2015 07:28:16 -0000 @@ -258,17 +258,6 @@ private void readObjectNoData() throws ObjectStreamException { throw new InvalidObjectException("can't deserialize enum"); } - - // [IKVM] .NET serialization support starts here - // Note that we don't have a security demand, because the info is harmless. - @cli.IKVM.Attributes.HideFromJavaAttribute.Annotation - @cli.System.Security.SecurityCriticalAttribute.Annotation - public final void GetObjectData(SerializationInfo info, StreamingContext context) - { - info.AddValue("enumType", getDeclaringClass()); - info.AddValue("name", name); - info.SetType(ikvm.runtime.Util.getInstanceTypeFromClass(EnumSerializationProxy.class)); - } } @cli.System.SerializableAttribute.Annotation > > > -----Original Message----- > > From: Jaroslav Tulach [mailto:[email protected]] > > Sent: Sunday, March 15, 2015 18:49 > > To: Jeroen Frijters > > Subject: Re: [Ikvm-developers] Exchanging strings was: Windows Phone > > > > Thanks a lot, I think I made some progress. I managed to pass over > > String, but I am failing to load StringHelper: > > > > System.TypeInitializationException was unhandled by user code > > HResult=-2146233036 > > Message=The type initializer for 'java.lang.StringHelper' threw an > > exception. > > Source=IKVM.OpenJDK.Core > > TypeName=java.lang.StringHelper > > StackTrace: > > at java.lang.StringHelper.getChars(String , Int32 , Int32 , > > Char[] , Int32 ) > > at java.lang.String.instancehelper_getChars(String this, Int32 > > srcBegin, Int32 srcEnd, Char[] dst, Int32 dstBegin) > > at java.lang.AbstractStringBuilder.append(String ) > > at java.lang.StringBuilder.append(String str) > > at cz.xelfi.test.Plus.add(Int32 one, Int32 two) > > at App1.MainPage.scriptNotifies(Object sender, NotifyEventArgs > > args) > > InnerException: System.TypeLoadException > > HResult=-2146233054 > > Message=Could not load type > > 'System.Runtime.Serialization.ISerializable' from assembly 'mscorlib, > > Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. > > Source=IKVM.OpenJDK.Core > > TypeName=System.Runtime.Serialization.ISerializable > > StackTrace: > > at java.lang.StringHelper..cctor() > > InnerException: > > > > It is true that > > $ grep -r Serializable openjdk/IKVM.OpenJDK.Core.dll > > > > yield something. But I am not yet sure how the reference to Serializable > > got there... > > -jt > > > > > > > > 2015-03-15 9:37 GMT+02:00 Jeroen Frijters <[email protected] > > <mailto:[email protected]> >: > > > > > > Around line 198 is this bit where ikvmc is invoked: > > > > <exec program="${project::get-base- > > directory()}/../bin/ikvmc.exe" useruntimeengine="true"> > > <arg value="-version:${VERSION}" /> > > <arg value="${signoption}" /> > > <arg value="-compressresources" /> > > <arg value="-opt:fields" /> > > <arg value="-strictfinalfieldsemantics" /> > > <arg value="-removeassertions" /> > > <arg value="-target:library" /> > > <arg value="-sharedclassloader" /> > > <arg value="-r:mscorlib.dll" /> > > <arg value="-r:System.dll" /> > > <arg value="-r:System.Core.dll" > > unless="${SkipSystemCoreDependency}" /> > > <arg value="-r:IKVM.Runtime.dll" /> > > <!-- we already know that the JNI assembly is not > > available, so suppress the warning --> > > <arg value="-nowarn:110" /> > > <arg value="-warnaserror" /> > > <arg value="@response.gen.txt" /> > > </exec> > > > > Here you can add an <arg value="-noautoserialization" /> line > > (above the @reponse.gen.txt arg). > > > > Regards, > > Jeroen > > > > > -----Original Message----- > > > From: Jaroslav Tulach [mailto:[email protected] > > <mailto:[email protected]> ] > > > > > Sent: Saturday, March 14, 2015 21:41 > > > To: Jeroen Frijters > > > Subject: Re: [Ikvm-developers] Exchanging strings was: Windows > > Phone > > > > > > If you rebuild IKVM from source you can add the ikvmc - > > > noautoserialization option to the compilation of the OpenJDK > > assemblies > > > (/ikvm/openjdk/openjdk.build), that should solve this particular > > issue. > > > > > > > > > > > > What is the best way to add -noautoserialization to the ikvm > > build? Or > > > even simpler question: what file, what line is doing the build of > > the > > > right .dll? My primary assumption would be openjdk/openjdk.build, > > but > > > > > > $ grep -i openjdk.*dll openjdk/openjdk.build > > > > > > <exec program="${peverify}" commandline="-nologo > > IKVM.OpenJDK.Beans.dll" > > > /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.Charsets.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > IKVM.OpenJDK.Corba.dll" > > > /> > > > > > > <exec program="${peverify}" commandline="-nologo > > IKVM.OpenJDK.Core.dll" > > > /> > > > > > > <exec program="${peverify}" commandline="-nologo > > IKVM.OpenJDK.Jdbc.dll" > > > /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.Management.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > IKVM.OpenJDK.Media.dll" > > > /> > > > > > > <exec program="${peverify}" commandline="-nologo > > IKVM.OpenJDK.Misc.dll" > > > /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.Naming.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.Remoting.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.Security.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.SwingAWT.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > IKVM.OpenJDK.Text.dll" > > > /> > > > > > > <exec program="${peverify}" commandline="-nologo > > IKVM.OpenJDK.Util.dll" > > > /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.XML.API.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.XML.Bind.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.XML.Crypto.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.XML.Parse.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.XML.Transform.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.XML.WebServices.dll" /> > > > > > > <exec program="${peverify}" commandline="-nologo > > > IKVM.OpenJDK.XML.XPath.dll" /> > > > > > > <include name="IKVM.OpenJDK.*.dll" /> > > > > > > <arg value="../bin/IKVM.OpenJDK.Core.dll" /> > > > > > > <arg value="-r:../bin/IKVM.OpenJDK.Tools.dll" /> > > > > > > <arg value="-r:../bin/IKVM.OpenJDK.Tools.dll" /> > > > > > > <arg value="-r:../bin/IKVM.OpenJDK.Tools.dll" /> > > > > > > > > > probably the "exec" lines are not the right ones. Include line is > > not > > > the right one either. So probably the <arg with OpenJDK.Core">. > > But the > > > OpenJDK.Core.dll is used as a parameter to ikvmstub - that is not > > the > > > one either. > > > > > > Please tell me where I should put the -noautoserialization. > > Thanks. > > > -jt > > > > > > > > > > > > Regards, > > > Jeroen > > > > > > > -----Original Message----- > > > > From: Jaroslav Tulach [mailto:[email protected] > > <mailto:[email protected]> > > > <mailto:[email protected] > > <mailto:[email protected]> > ] > > > > Sent: Wednesday, March 4, 2015 6:15 > > > > > > To: [email protected] <mailto:ikvm- > > [email protected]> <mailto:ikvm- <mailto:ikvm-> > > > [email protected] > > <mailto:[email protected]> > > > > > Subject: [Ikvm-developers] Exchanging strings was: > > Windows Phone > > > > > > > > 2015-02-18 9:32 GMT+01:00 Jeroen Frijters > > <[email protected] <mailto:[email protected]> > > > <mailto:[email protected] <mailto:[email protected]> > > > > > <mailto:[email protected] <mailto:[email protected]> > > <mailto:[email protected] <mailto:[email protected]> > > >: > > > > > > > > > > > > > > > > > Jaroslav Tulach wrote: > > > > > > I don't know, but Windows Phone is not > > supported out of > > > the box > > > > by > > > > > > IKVM. > > > > > > > > > > > > > > > > > > > > It means that the code I ship depends on features > > that > > > aren't > > > > available on the Windows Phone .NET runtime. If you avoid > > these > > > features > > > > it might work (as you apparently found), but it is not > > > "supported" (i.e. > > > > intended by me to work). > > > > > > > > > > > > > > > > Thanks Jeroen, I did some more testing. I can call my > > > > > > > > public static int add(int one, int two) { > > > > return one + two; > > > > } > > > > > > > > method in my class from my Windows 8 phone application > > and > > > display the > > > > result. However if I try anything more complex: > > > > > > > > public static int add(int one, int two) { > > > > WeakReference<Integer> oneRef = new > > WeakReference<>(one); > > > > WeakReference<Integer> twoRef = new > > WeakReference<>(two); > > > > return oneRef.get() + twoRef.get(); > > > > } > > > > > > > > > > > > or even something like concatenating strings: > > > > > > > > public static String add(String one, String two) { > > > > return one + two; > > > > } > > > > > > > > I get > > > > > > > > System.TypeLoadException was unhandled by user code > > > > > > HResult=-2146233054 <tel:2146233054> <tel:2146233054 > > <tel:2146233054> > > > > > > > Message=Could not load type > > > > 'System.Runtime.Serialization.ISerializable' from > > assembly > > > 'mscorlib, > > > > Version=4.0.0.0, Culture=neutral, > > > PublicKeyToken=7cec85d7bea7798e'. > > > > Source=plus > > > > TypeName=System.Runtime.Serialization.ISerializable > > > > StackTrace: > > > > at test.Plus.add(Int32 one, Int32 two) > > > > at App1.MainPage.scriptNotifies(Object sender, > > > NotifyEventArgs > > > > args) > > > > InnerException: > > > > > > > > > > > > Googling around I found that ISerializable is not > > supported on > > > the > > > > Windows Phone platform: > > > > > > > > ---- > > > > > > > > > > > gsssrao <https://github.com/gsssrao> commented on Dec > 17 > > 2014 > > > > > > > > > <https://github.com/nicolaspanel/libsvm.net/issues/16#issuecomment- > > > > 67330870> > > > > > > > > The Windows phone does not support the whole of .NET > > framework, > > > the list > > > > of supported APIs are: > > > > http://msdn.microsoft.com/en- > > > us/library/jj207211%28v=vs.105%29.aspx > > > > <http://msdn.microsoft.com/en- > > > us/library/jj207211%28v=vs.105%29.aspx> > > > > > > > > So, you get the error: > > > > Could not load type > > 'System.Runtime.Serialization.ISerializable' > > > from > > > > assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, > > > > PublicKeyToken=7cec85d7bea7798e' > > > > > > > > The ISerializable and SerializationInfo are not present > > in > > > Windows phone > > > > .NET API. > > > > The Namespace for Windows phone is: > > > > http://msdn.microsoft.com/en- > > > > us/library/system.runtime.serialization(v=vs.105).aspx > > > > <http://msdn.microsoft.com/en- > > > > us/library/system.runtime.serialization(v=vs.105).aspx> > > > > For .NET framework is: > > > > http://msdn.microsoft.com/en- > > > > us/library/System.Runtime.Serialization(v=vs.110).aspx > > > > <http://msdn.microsoft.com/en- > > > > us/library/System.Runtime.Serialization(v=vs.110).aspx> > > > > > > > > > > > --- > > > > > > > > Naïve approach to use -noautoserialization as parameter > > to > > > ikvmc.exe > > > > didn't help. I guess I am stuck. > > > > > > > > What would be your advice for my next step? Thanks. > > > > > > > > -jt > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Ikvm-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ikvm-developers