Peculiar classpath problem (FileNotFoundException), but path looks correct

Johannes Maier <[email protected]> Sun, 10 Dec 2017 04:00:53 -0800 (PST)
Newsgroups gmane.comp.java.robocode
Message-ID <[email protected]>
Hello,

I'm trying to develop a bot with Kotlin using IntelliJ IDEA 2017.3. I have 
got it configured, I can compile, I can build a .jar for my robot which 
works fine; so far, so good!
I'm hitting a wall when trying to run the development version of my robot 
in robocode though. When the Kotlin runtime is missing from the classpath, 
the bot won't even be loaded (and I get errors in the output when starting 
robocode), but that is expected. Now I'm using the following (partly 
generated by IntelliJ) command to start robocode:

"C:\Program Files\Java\jdk1.8.0_66\bin\java"
-Xmx512M
-Dsun.io.useCanonCaches=false
-cp "libs\robocode.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community 
Edition 2017.3\plugins\Kotlin\kotlinc\lib\kotlin-reflect.jar;C:\Program 
Files\JetBrains\IntelliJ IDEA Community Edition 
2017.3\plugins\Kotlin\kotlinc\lib\kotlin-stdlib.jar;C:\Program 
Files\JetBrains\IntelliJ IDEA Community Edition 
2017.3\plugins\Kotlin\kotlinc\lib\kotlin-stdlib-jdk7.jar;C:\Program 
Files\JetBrains\IntelliJ IDEA Community Edition 
2017.3\plugins\Kotlin\kotlinc\lib\kotlin-stdlib-jdk8.jar"
"-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 
2017.3\lib\idea_rt.jar=49977:C:\Program Files\JetBrains\IntelliJ IDEA 
Community Edition 2017.3\bin"
-Dfile.encoding=UTF-8 robocode.Robocode

Using this, I can load the robot just fine, even if it uses the Kotlin 
runtime. No errors until I run it, then I see the following in the output:

java.io.FileNotFoundException: 
D:\projects\bots\Oldur\out\production\Oldur\kotlin\jvm\internal\Intrinsics.class 
(The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at 
sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at 
sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
at 
net.sf.robocode.host.security.RobotClassLoader$1.run(RobotClassLoader.java:166)
at 
net.sf.robocode.host.security.RobotClassLoader$1.run(RobotClassLoader.java:152)
at java.security.AccessController.doPrivileged(Native Method)
at 
net.sf.robocode.host.security.RobotClassLoader.findLocalResource(RobotClassLoader.java:152)
at 
net.sf.robocode.host.security.RobotClassLoader.loadRobotClassLocaly(RobotClassLoader.java:137)
at 
net.sf.robocode.host.security.RobotClassLoader.loadClass(RobotClassLoader.java:98)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at kenran.Oldur.onHitByBullet(Oldur.kt)
at robocode.HitByBulletEvent.dispatch(HitByBulletEvent.java:167)
at robocode.Event$HiddenEventHelper.dispatch(Event.java:259)
at net.sf.robocode.security.HiddenAccess.dispatch(HiddenAccess.java:191)
at net.sf.robocode.host.events.EventManager.dispatch(EventManager.java:422)
at 
net.sf.robocode.host.events.EventManager.processEvents(EventManager.java:376)
at 
net.sf.robocode.host.proxies.BasicRobotProxy.executeImpl(BasicRobotProxy.java:423)
at 
net.sf.robocode.host.proxies.BasicRobotProxy.rescan(BasicRobotProxy.java:336)
at robocode.Robot.scan(Robot.java:776)
at kenran.Oldur.run(Oldur.kt:10)
at 
net.sf.robocode.host.proxies.HostingRobotProxy.callUserCode(HostingRobotProxy.java:274)
at 
net.sf.robocode.host.proxies.HostingRobotProxy.run(HostingRobotProxy.java:221)
at net.sf.robocode.host.proxies.BasicRobotProxy.run(BasicRobotProxy.java:44)
at java.lang.Thread.run(Thread.java:745)

Mind you, the bot is running fine and seems to do everything correctly! 
This just leads to the robot not being able to stop at the end of the 
round... which means I can't use the rumble. I don't understand why 
robocode seems to be looking for the Intrinsics.class file in the place 
it's looking, as it seems to find and use it correctly throughout the 
matches and when loading the robot class in the beginning. Here is the 
output I see in the bot log:

=========================
Round 1 of 10
=========================
SYSTEM: kenran.Oldur 0.05* has died
=========================
Round 2 of 10
=========================
java.lang.IllegalMonitorStateException
at 
java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:151)
at 
java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1261)
at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:457)
at java.util.concurrent.DelayQueue.take(DelayQueue.java:234)
at javax.swing.TimerQueue.run(TimerQueue.java:171)
at java.lang.Thread.run(Thread.java:745)
SYSTEM: This robot has been stopped.  No score will be generated.
SYSTEM: game aborted.


I can work around this issue by just putting the Kotlin runtime classes 
where robocode is looking, but that is kind of unsatisfactory.

As a reference, here is a simple robot that shows this behavior (though I 
of course understand if noone wants to go through the trouble to try it as 
it uses a different language):

class Oldur : AdvancedRobot() {
    override fun run() {
        while (true) {
            scan()
        }
    }

    override fun onScannedRobot(e: ScannedRobotEvent) {
    }

    override fun onHitByBullet(e: HitByBulletEvent) {
    }
}

Two things with this robot that seem strange/buggy to me when running it:
1) If I add a ? behind HitByBulletEvent and thus making it nullable, the 
bot works fine
2) The stack trace always shows the onHitByBullet event as the problem. 
onScannedRobot doesn't seem to have this problem at all, even though it 
also uses a non-nullable event argument.

Any help with this would be greatly appreciated!

-- 
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.