Java static imports no longer work

Issue #27 resolved
Doug Blank created an issue

This example no longer works:

import static Graphics.*;

public class JavaGraphics {
    public static void main(String[] args) {
        WindowClass window = Window("Testing", 400, 100);
    }
}

JavaGraphics.main(new String[0]);

Error message:

Run filename '/home/dblank/Calico/languages/Java/examples/JavaGraphics.java'!
tried to access class cli.Graphics$$$003CShow$$003Ec__AnonStoreyA from class cli.Graphics

Maybe we just need to rewrite it without the static imports.

Comments (27)

  1. Doug Blank reporter

    This may have to do with having $ in names. From the calico-dev mailing list, some hints:

    • Methods won’t be visible in the converted .dll, because „$“ is an illegal symbol in C# but valid in Java.
    • You can use Retroguard to rename the methods in the jar file before converting to a .NET dll.
  2. Keith O'Hara

    Let me try recreating the *.jar files with my version of ikvm and see if the issue persists. How do you create the jar files again?

  3. Doug Blank reporter

    There is a makefile in the languages/Java/jar file. But I already did that. In fact, I did that before I tested, so that probably caused the problem.

  4. Keith O'Hara

    But I used the ikvm-fork version of ikvm, remember? I tried building the jar, but ran into a .net 2.0 vs. 4.0 snafu:

    ikvmstub.exe -lib:../../../bin/ -lib:/usr/lib/cli/gtk-sharp-2.0/ -lib:/usr/lib/cli/glib-sharp-2.0/ -lib:/usr/lib/cli/atk-sharp-2.0/ -lib:/usr/lib/cli/gdk-sharp-2.0/ -lib:/usr/lib/cli/pango-sharp-2.0/ ../../../modules/Common.dll Error: unable to load assembly '../../../modules/Common.dll' as it depends on a higher version of mscorlib than the one currently loaded

  5. Doug Blank reporter

    Does that mean that we can't just run make? Can you put additional instructions in that directory? Should we include the mono IKVM in Calico git?

  6. Keith O'Hara

    Well you can run make but odds are you will be running a different version of ikvm. I'll add a README with a link to the proper version.

    What do you make of this .Net 4.0 vs. 2.0 problem. Do the modules really need 4.0? I'm totally ignorant of the differences. Except for 4.0 broke ROS support on Windows and Mac OS X.

  7. Doug Blank reporter

    I am ignorant as well. I think that I broke F# and C# in this same manner. I'm going to try to go back to previous versions of both.

    If the IKVM files are cross-domain, we can just add them to the repository. I think we already have some in languages/Java/lib

  8. Keith O'Hara

    I was able to rebuild Graphics and Myro using sdk:2 and they seem OK. I'm having trouble rebuilding Common though.

  9. Doug Blank reporter

    Wait, you have to rebuild the modules/*.dll, just for use in Java? Maybe we can use copies of the DLLs compiled for Java? I would hate to make such a major change minutes before releasing...

  10. Keith O'Hara

    I'm trying to rebuild modules. But I'm getting caught on Common, I'm wrestling with monodevelop to make it use 2.0 rather than 4.0. The other modules have Makefiles I can easily edit.

    I was unable to run ikvmstub on the dll's because of an mscor mismatch.

  11. Keith O'Hara

    OK, I won't rebuild those then. I think we should get this java stuff figured out before the release. What's the rush?

  12. Doug Blank reporter

    Ok, that is very good. I was tracking down some esoteric things that weren't working. But the updated libraries made them work again. So, ok!

  13. Keith O'Hara

    I just finished replacing the jars in java/jars now (they werent' checked in!). I was having trouble rebuilding them with the 2.0 ikvm.

  14. Keith O'Hara

    I'm still getting the java error:

    Run filename '/home/keithohara/gitCalico/languages/Java/examples/JavaGraphics.java'! tried to access class cli.Graphics$$$003CShow$$003Ec__AnonStoreyA from class cli.Graphics

  15. Doug Blank reporter

    I must have been mistaken... I was going back to previous versions using "git checkout XXXX" and something must have been from the older version. I get the error again.

  16. Doug Blank reporter

    My git advice is wrong... it only pulls out particular changes. Do you know how to put yourself back at a point in the git tree?

  17. Log in to comment