Menu

Java8 Problems

Help
2016-12-18
2016-12-21
  • Jesper Pipping

    Jesper Pipping - 2016-12-18

    Robocode seems to have a problem with Lambdas. When I try to run robocode with a robot that has a lambda passed as a method parameter, it fails with a ClassNotFoundException.

     
  • Jesper Pipping

    Jesper Pipping - 2016-12-18

    Here's a minimal case that shows the behaviour.
    When this is on the classpath and Robocode is loaded, it will display an exception. When a battle is started, the robot will not be available.

    If you comment out the line:

    aLamdbdaMethod(o -> true);
    

    ...and rebuild, robocode will now start without exception and the robot is available to do battle.

     

    Last edit: Jesper Pipping 2016-12-18
  • Jesper Pipping

    Jesper Pipping - 2016-12-18

    This was reproduced using robocode 1.9.2.5, source compiled with Oracle jdk1.8.0_101

     
    • Flemming N. Larsen

      Hi Jesper,

      I just made the first test with your TestBot.java class. I am able to
      compile it without any problem. I was using ECJ.

      First I did a compiler reset Compiler -> Options -> Reset Compiler
      I also adjusted the 'Compiler Options' to support "1.8", which is Java 8:

      -deprecation -g -source 1.8 -encoding UTF-8

      This can be set under Compiler -> Options -> Preferences.

      The 'Compiler Binary' was set to default:
      java -cp compilers/ecj.jar org.eclipse.jdt.internal.compiler.batch.Main

      The 'Compiler Classpath' is automatically set, when the compiler is reset.

      Does this work out for you?

      Best regards,

      • Flemming

      søn. 18. dec. 2016 kl. 20.17 skrev Flemming N. Larsen flemming.n.larsen@gmail.com:

      Hi Jesper,

      I will have a look into this issue. But expect it to take some days due to
      Christmas.

      Regards,
      - Flemming

      søn. 18. dec. 2016 kl. 19.19 skrev Jesper Pipping jesperpi@users.sf.net:

      This was reproduced using robocode 1.9.2.5, source compiled with Oracle
      jdk1.8.0_101


      Java8 Problems
      https://sourceforge.net/p/robocode/discussion/116459/thread/4fb9b1e9/?limit=25#4793


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/robocode/discussion/116459/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
    • Flemming N. Larsen

      Hi Jesper,

      I will have a look into this issue. But expect it to take some days due to
      Christmas.

      Regards,

      • Flemming

      søn. 18. dec. 2016 kl. 19.19 skrev Jesper Pipping jesperpi@users.sf.net:

      This was reproduced using robocode 1.9.2.5, source compiled with Oracle
      jdk1.8.0_101


      Java8 Problems
      https://sourceforge.net/p/robocode/discussion/116459/thread/4fb9b1e9/?limit=25#4793


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/robocode/discussion/116459/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Jesper Pipping

    Jesper Pipping - 2016-12-20

    Thanks Flemming, there's no rush. I will try your suggestions tomorrow and also see if I can more information on the issue

     
  • Jesper Pipping

    Jesper Pipping - 2016-12-20

    Hi Flemming,
    Thanks so much for looking into this!

    I still have the same problem using the bundled ECJ compiler with 1.8 support enabled. Compilation appears to be fine, I end up with a sensible .class file, but an exception is still thrown at class loading time and the robot is unavailable for battle. When the lambda line is commented out, no exception is thrown and the robot is available for battle.

    The ClassNotFoundException is caused by a nullpointer exception in the net.sf.robocode.host.security.ClassAnalyzer.getReferencedClasses(ByteBuffer classFile, Set<string> collection) method. In this method, it appears that constant classes are parsed from the classfile and matched to their details in UTF8, but in this case a constant class is identified but has no UTF8 counterpart in the array of strings. It makes me wonder if there might be a similar problem for anonymous inner classes?</string>

    I have attached a thread dump for each of the exceptions: ClassnotFound and the Nullpointer that caused it. I would be thrilled if you could take a look, but please do not rush on my account.

    Happy Holidays!

     
    • Flemming N. Larsen

      Okay. I will have a deeper look into this. :-)

      Best regards,

      • Flemming

      ons. 21. dec. 2016 kl. 00.27 skrev Jesper Pipping jesperpi@users.sf.net:

      Hi Flemming,
      Thanks so much for looking into this!

      I still have the same problem using the bundled ECJ compiler with 1.8
      support enabled. Compilation appears to be fine, I end up with a sensible
      .class file, but an exception is still thrown at class loading time and the
      robot is unavailable for battle. When the lambda line is commented out, no
      exception is thrown and the robot is available for battle.

      The ClassNotFoundException is caused by a nullpointer exception in the
      net.sf.robocode.host.security.ClassAnalyzer.getReferencedClasses(ByteBuffer
      classFile, Set<string> collection) method. In this method, it appears that
      constant classes are parsed from the classfile and matched to their details
      in UTF8, but in this case a constant class is identified but has no UTF8
      counterpart in the array of strings. It makes me wonder if there might be a
      similar problem for anonymous inner classes?</string>

      I have attached a thread dump for each of the exceptions: ClassnotFound
      and the Nullpointer that caused it. I would be thrilled if you could take a
      look, but please do not rush on my account.

      Happy Holidays!

      Attachments:


      Java8 Problems
      https://sourceforge.net/p/robocode/discussion/116459/thread/4fb9b1e9/?limit=25#57de


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/robocode/discussion/116459/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Flemming N. Larsen

    Hi Jesper,

    I am able to reproduce the problem now, and have created a bug report for it here:
    https://sourceforge.net/p/robocode/bugs/383/

    This bug must be fixed.

     
  • Flemming N. Larsen

    I have made an fix in an early Alpha version for version 1.9.2.6 you can download and try out here:
    http://robocode.net/files/robocode-1.9.2.6-Alpha-setup.jar

     
  • Jesper Pipping

    Jesper Pipping - 2016-12-21

    Thanks Flemming,
    I couldn't get that link to work; but I built it from source, and it seems to solve the problem. Great work! Also thank you so much for creating this great game in the first place :)

    Cheers,
    Jesper

     

Log in to post a comment.