Re: [Ikvm-developers] Class.forName and csharp classes
Brought to you by:
jfrijters
|
From: Jeroen F. <je...@su...> - 2017-02-17 16:50:11
|
Hi Martin,
The exe is automatically part of the boot class loader (when it is run in the normal way). I don't know what else could be the problem.
Regards,
Jeroen
> -----Original Message-----
> From: Martin Gerhardy [mailto:M.G...@bi...]
> Sent: Friday, February 17, 2017 16:41
> To: Jeroen Frijters <je...@su...>; ikvm-
> dev...@li...
> Subject: AW: Class.forName and csharp classes
>
> Hi Jeroen
>
> maybe I am misisng something, but the csharp class is part of the exe,
> the dll (converted jar) is trying to load a class from the exe - do I
> have to add the exe to the classloader in the csharp application? Isn't
> that implicitly the case? Or do I have to create another dll for my
> csharp stuff and just reference it from a minimal exe?
>
> Can you give an example on how to do that? Thanks again for helping me.
>
> Regards
> Martin
> ________________________________________
> Von: Jeroen Frijters [je...@su...]
> Gesendet: Freitag, 17. Februar 2017 16:19
> An: Martin Gerhardy; ikv...@li...
> Betreff: RE: Class.forName and csharp classes
>
> Hi Martin,
>
> In that case it is probably simply a class loader issue. The class
> loader you use for Class.forName() must be able to see the assembly. The
> easiest solution is to add the assembly to the boot class loader with
> the ikvm.runtime.Startup.addBootClassPathAssembly() method.
>
> Regards,
> Jeroen
>
> > -----Original Message-----
> > From: Martin Gerhardy [mailto:M.G...@bi...]
> > Sent: Friday, February 17, 2017 16:08
> > To: Jeroen Frijters <je...@su...>; ikvm-
> > dev...@li...
> > Subject: AW: Class.forName and csharp classes
> >
> > Hi Jeroen,
> >
> > thanks for the answer - I tried both:
> >
> > ---------------------------
> > using System.Diagnostics;
> > using System;
> >
> > [assembly: IKVM.Attributes.NoPackagePrefixAttribute]
> > namespace foo
> > {
> > class Foo
> > {
> > public Foo()
> > {
> > }
> > }
> >
> > class MainClass
> > {
> > public static void Main (string[] args)
> > {
> > Console.WriteLine("starting up...");
> > Launcher.main("foo.Foo");
> > }
> > }
> > }
> > ---------------------------
> >
> >
> > package foo;
> >
> > public class Launcher {
> > public static void main(final String name) {
> > try {
> > System.err.println("Starting up and trying to
> > load " + name);
> > final Class<?> forName = Class.forName("cli." +
> name);
> > System.out.println("Finished loading " +
> forName);
> > } catch (final ClassNotFoundException e) {
> > e.printStackTrace();
> > }
> > }
> > }
> >
> > ---------------------------
> >
> > Neither works - neither the additional cli. namespace prefix nor
> > adding the attribute (Not sure if I did that one correctly)
> >
> > Compiling with the commands:
> > ikvmc -classloader:ikvm.runtime.ClassPathAssemblyClassLoader -
> > assemblyattributes:$(BIN)/AssemblyInfo.class -target:library $<
> > mcs -target:exe -main:foo.MainClass -
> > r:System.dll,IKVM.Runtime.dll,IKVM.OpenJDK.Core.dll,$(NAME).dll -
> > out:proof-of-concept.exe GuiceRepro.cs AssemblyInfo.cs
> >
> >
> >
> > Regards
> > Martin
> >
> > ________________________________________
> > Von: Jeroen Frijters [je...@su...]
> > Gesendet: Freitag, 17. Februar 2017 14:50
> > An: Martin Gerhardy; ikv...@li...
> > Betreff: RE: Class.forName and csharp classes
> >
> > Hi Martin,
> >
> > Did you take into account that the C# classes get a "cli." prefix in
> > Java (by default)?
> >
> > You can apply the IKVM.Attributes.NoPackagePrefixAttribute to the
> > class or assembly to disable this.
> >
> > Regards,
> > Jeroen
> >
> > > -----Original Message-----
> > > From: Martin Gerhardy [mailto:M.G...@bi...]
> > > Sent: Wednesday, February 15, 2017 11:34
> > > To: ikv...@li...
> > > Subject: [Ikvm-developers] Class.forName and csharp classes
> > >
> > > Hi,
> > >
> > > we are converting a deserialization jar via ikvm into a dll and bind
> > > a csharp class via guice to some of the serialized classes. The java
> > > code contains a call for Class.forName for that class. As our
> > > injected class is a csharp class, this doesn't work. Is there any
> > > way to work around this? (In the sense the Class.forName also finds
> > > csharp
> > > classes?)
> > >
> > > Regards
> > > Martin
|