Discussion:
[Ikvm-developers] Class.forName and csharp classes
Martin Gerhardy
2017-02-15 10:34:06 UTC
Permalink
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
Martin Gerhardy
2017-02-15 11:22:39 UTC
Permalink
Find a small testcase attached as tgz.

the Makefile contains all the commands that we use to build the assembly and to use it for the executable.

Regards
Martin
Jeroen Frijters
2017-02-17 13:50:33 UTC
Permalink
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:***@bigpoint.net]
> Sent: Wednesday, February 15, 2017 11:34
> To: ikvm-***@lists.sourceforge.net
> 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
Martin Gerhardy
2017-02-17 15:07:35 UTC
Permalink
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 [***@sumatra.nl]
Gesendet: Freitag, 17. Februar 2017 14:50
An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
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:***@bigpoint.net]
> Sent: Wednesday, February 15, 2017 11:34
> To: ikvm-***@lists.sourceforge.net
> 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
Jeroen Frijters
2017-02-17 15:19:39 UTC
Permalink
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:***@bigpoint.net]
> Sent: Friday, February 17, 2017 16:08
> To: Jeroen Frijters <***@sumatra.nl>; ikvm-
> ***@lists.sourceforge.net
> 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 [***@sumatra.nl]
> Gesendet: Freitag, 17. Februar 2017 14:50
> An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
> 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:***@bigpoint.net]
> > Sent: Wednesday, February 15, 2017 11:34
> > To: ikvm-***@lists.sourceforge.net
> > 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
Martin Gerhardy
2017-02-17 15:41:25 UTC
Permalink
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 [***@sumatra.nl]
Gesendet: Freitag, 17. Februar 2017 16:19
An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
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:***@bigpoint.net]
> Sent: Friday, February 17, 2017 16:08
> To: Jeroen Frijters <***@sumatra.nl>; ikvm-
> ***@lists.sourceforge.net
> 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 [***@sumatra.nl]
> Gesendet: Freitag, 17. Februar 2017 14:50
> An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
> 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:***@bigpoint.net]
> > Sent: Wednesday, February 15, 2017 11:34
> > To: ikvm-***@lists.sourceforge.net
> > 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
Jeroen Frijters
2017-02-17 16:50:01 UTC
Permalink
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:***@bigpoint.net]
> Sent: Friday, February 17, 2017 16:41
> To: Jeroen Frijters <***@sumatra.nl>; ikvm-
> ***@lists.sourceforge.net
> 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 [***@sumatra.nl]
> Gesendet: Freitag, 17. Februar 2017 16:19
> An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
> 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:***@bigpoint.net]
> > Sent: Friday, February 17, 2017 16:08
> > To: Jeroen Frijters <***@sumatra.nl>; ikvm-
> > ***@lists.sourceforge.net
> > 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 [***@sumatra.nl]
> > Gesendet: Freitag, 17. Februar 2017 14:50
> > An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
> > 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:***@bigpoint.net]
> > > Sent: Wednesday, February 15, 2017 11:34
> > > To: ikvm-***@lists.sourceforge.net
> > > 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
a***@gmail.com
2017-02-17 17:55:10 UTC
Permalink
Martin,

Would you be willing to create and upload a test case for this into a Git Repository? If you don’t have a GitHub account I can create you a repository to use. I’d like to get this into the set of Unit Tests. In order to do that it would be incredibly helpful for you to create a bare bones example that exhibits the behavior you are seeing. I also didn’t see the versions of tools you were using. That would be helpful as well.

Feel free to contact me directly if you need help setting up the Test Case for this.

>From parts of my memory that could be completely fabricated I remember their being issues in certain versions of .NET when one would attempt to load classes from the Executing Domain that existed in the .exe assembly. I bet if you were to create a new Assembly, create a class in it, then add it to the path, everything would work. Also remember that the JDK after 7 (I believe) has it’s own pseudo Classloader domain-like management. So you might need to use a different classloader when attempting to .forName your new class.

Take a Java disassembler and see what your .NET CLR class is being turned into as well.

I hope to take a look at your sample test case and get this working for you. If you have any issues getting it somewhere online let me know asap and I’ll help.

Regards,

Andrew

{givenname}.{surname}@duelingcoders.com
{givenname}.{surname}@gmail.com


From: Martin Gerhardy
Sent: Friday, February 17, 2017 10:42 AM
To: Jeroen Frijters; ikvm-***@lists.sourceforge.net
Subject: Re: [Ikvm-developers] 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 [***@sumatra.nl]
Gesendet: Freitag, 17. Februar 2017 16:19
An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
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:***@bigpoint.net]
> Sent: Friday, February 17, 2017 16:08
> To: Jeroen Frijters <***@sumatra.nl>; ikvm-
> ***@lists.sourceforge.net
> 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 [***@sumatra.nl]
> Gesendet: Freitag, 17. Februar 2017 14:50
> An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
> 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:***@bigpoint.net]
> > Sent: Wednesday, February 15, 2017 11:34
> > To: ikvm-***@lists.sourceforge.net
> > 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
Martin Gerhardy
2017-02-17 19:20:24 UTC
Permalink
Hi

Thanks for that offer - I put up a github repo at https://github.com/mgerhardy/ikvm-class-for-name

Quick and dirty - also the compiled class files if disassembling them is needed.

There is a makefile included that shows the used commandlines that are/were used to create the binaries.

Again - thanks a lot for all your help

Regards
Martin

________________________________
Von: ***@gmail.com [***@gmail.com]
Gesendet: Freitag, 17. Februar 2017 18:55
An: Martin Gerhardy; Jeroen Frijters; ikvm-***@lists.sourceforge.net
Betreff: RE: [Ikvm-developers] Class.forName and csharp classes

Martin,

Would you be willing to create and upload a test case for this into a Git Repository? If you don’t have a GitHub account I can create you a repository to use. I’d like to get this into the set of Unit Tests. In order to do that it would be incredibly helpful for you to create a bare bones example that exhibits the behavior you are seeing. I also didn’t see the versions of tools you were using. That would be helpful as well.

Feel free to contact me directly if you need help setting up the Test Case for this.

>From parts of my memory that could be completely fabricated I remember their being issues in certain versions of .NET when one would attempt to load classes from the Executing Domain that existed in the .exe assembly. I bet if you were to create a new Assembly, create a class in it, then add it to the path, everything would work. Also remember that the JDK after 7 (I believe) has it’s own pseudo Classloader domain-like management. So you might need to use a different classloader when attempting to .forName your new class.

Take a Java disassembler and see what your .NET CLR class is being turned into as well.

I hope to take a look at your sample test case and get this working for you. If you have any issues getting it somewhere online let me know asap and I’ll help.

Regards,

Andrew

{givenname}.{surname}@duelingcoders.com
{givenname}.{surname}@gmail.com


From: Martin Gerhardy<mailto:***@bigpoint.net>
Sent: Friday, February 17, 2017 10:42 AM
To: Jeroen Frijters<mailto:***@sumatra.nl>; ikvm-***@lists.sourceforge.net<mailto:ikvm-***@lists.sourceforge.net>
Subject: Re: [Ikvm-developers] 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 [***@sumatra.nl]
Gesendet: Freitag, 17. Februar 2017 16:19
An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
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:***@bigpoint.net]
> Sent: Friday, February 17, 2017 16:08
> To: Jeroen Frijters <***@sumatra.nl>; ikvm-
> ***@lists.sourceforge.net
> 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 [***@sumatra.nl]
> Gesendet: Freitag, 17. Februar 2017 14:50
> An: Martin Gerhardy; ikvm-***@lists.sourceforge.net
> 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:***@bigpoint.net]
> > Sent: Wednesday, February 15, 2017 11:34
> > To: ikvm-***@lists.sourceforge.net
> > 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
Loading...