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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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.
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.
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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:
...and rebuild, robocode will now start without exception and the robot is available to do battle.
Last edit: Jesper Pipping 2016-12-18
This was reproduced using robocode 1.9.2.5, source compiled with Oracle jdk1.8.0_101
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,
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,
søn. 18. dec. 2016 kl. 19.19 skrev Jesper Pipping jesperpi@users.sf.net:
Thanks Flemming, there's no rush. I will try your suggestions tomorrow and also see if I can more information on the issue
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!
Okay. I will have a deeper look into this. :-)
Best regards,
ons. 21. dec. 2016 kl. 00.27 skrev Jesper Pipping jesperpi@users.sf.net:
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.
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
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