Re: [Ikvm-developers] RuntimeException when code is referenced
Brought to you by:
jfrijters
From: Yuval E. <Yu...@tr...> - 2012-09-24 07:00:20
|
Sorry, I got it. Just add -target:library and it works just fine. Thanks! Yuval E. -----Original Message----- From: Jeroen Frijters [mailto:je...@su...] Sent: יום ב 24 ספטמבר 2012 08:25 To: Yuval Edelstein; ikv...@li... Subject: RE: RuntimeException when code is referenced Hi, Like a lot of Java code, Javolution makes incorrect assumptions about class loaders (that can break in Java apps as well). Here's the problematic Javolution code in your case: String arrayName = structs.getClass().getName(); String structName = arrayName.substring(2, arrayName.length() - 1); structClass = Reflection.getInstance().getClass(structName); (from http://java.net/projects/javolution/sources/svn/content/trunk/javolution/core-java/src/main/java/javolution/io/Struct.java?rev=97) It completely ignores the notion of class loaders. You already know the workaround. If you separate files, you can also do this: ikvmc -sharedclassloader { build\AggregatorDistributeTools.jar } { z:\3rdParty\Java\Javolution\5.5.1\javolution-5.5.1.jar } Regards, Jeroen > -----Original Message----- > From: Yuval Edelstein [mailto:Yu...@tr...] > Sent: Sunday, September 23, 2012 16:40 > To: ikv...@li... > Subject: [Ikvm-developers] RuntimeException when code is referenced > > Hi, > > I have a jar I developed which depends on Javolution. In order to > provide C# capability I use ikvmc to create dll of my library. > > To do that, I want to compile Javolution to dll using ikvmc, and then > created a dll from myLib.jar, using "-reference" option. > > To test this option I created a main() method within my library and > created an .exe file using my jar, while using > -reference:javolution.dll . > > > > > c:\ikvm-7.1.4532.2\bin\ikvmc.exe build\AggregatorDistributeTools.jar > > - > reference:javolution-5.5.1.dll > > Compilation finished successfully without errors. > > > > One I tried to run the EXE I got the following exception: > > > > Exception in thread "main" java.lang.RuntimeException: Struct class: > com.tradertools.aggregator.tools.data.CppTier not f > > ound > > at javolution.io.Struct.array(Struct.java:544) > > at > com.tradertools.aggregator.tools.data.CppSortedBook.init(CppSortedBook > .j > ava:15) > > at > com.tradertools.aggregator.tools.data.BookWrapper.insertBookData(BookW > ra > pper.java:84) > > at com.tradertools.aggregator.tools.Test.main(Test.java:106) > > > > > > I managed to work around this by compiling my EXE without "-reference" > option, by compiling BOTH jars to one EXE (without dll): > > > c:\ikvm-7.1.4532.2\bin\ikvmc.exe build\AggregatorDistributeTools.jar > z:\3rdParty\Java\Javolution\5.5.1\javolution-5.5.1.jar > > Compilation finished successfully without errors. > > > > Note that com.tradertools.aggregator.tools.data.CppTier class is part > of my code and exists in the jar and exe. > > I used ikvm-7.1.4532.2, on windows 7, .NET 4.0 . > > > > Regards, > > Yuval E. > > |