« Return to Thread: Robocode Security Error

Robocode Security Error

by asherbaig :: Rate this Message:

Reply to Author | View in Thread

Hi,
I have problem with my newly created robot for which what i did is
create class named as KeyStrokeConfig inside robocode manager.And for
my Sprobot i made changes in it.Please see keyStrokeConfig.java and
Sprobot.java.Now when i try to run my game and try to play with
Sprobot it gives me this error


Rebuilding robot database.
multiplayer.MprobotTest: Got an error with this class:
java.lang.IllegalStateException: Can't overwrite cause
multiplayer.MprobotTest2: Got an error with this class:
java.lang.IllegalStateException: Can't overwrite cause
multiplayer.MprobotTest3: Got an error with this class:
java.lang.IllegalStateException: Can't overwrite cause
sample.Uniteam3aTest: Got an error with this class:
java.lang.IllegalStateException: Can't overwrite cause
Preparing battle...
----------------------

Let the games begin!
Testing value10
Preparing battle...
Round 1 cleaning up.
----------------------
Round 1 initializing..java.security.AccessControlException: Preventing
Robot Loader from access to the internal Robocode pakage: robocode.manager
java.security.AccessControlException: Preventing Robot Loader from
access to the internal Robocode pakage: robocode.manager
        at
robocode.security.RobocodeSecurityManager.checkPackageAccess(RobocodeSecurityManager.java:559)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:273)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
        at
robocode.security.RobocodeClassLoader.loadClass(RobocodeClassLoader.java:116)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at singleplayer.Sprobot.<init>(Sprobot.java:26)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at robocode.battle.Battle.unsafeLoadRobots(Battle.java:1435)
        at robocode.battle.Battle$UnsafeLoadRobotsThread.run(Battle.java:1679)
java.security.AccessControlException: Preventing Robot Loader from
access to the internal Robocode pakage: robocode.manager
java.security.AccessControlException: Preventing Robot Loader from
access to the internal Robocode pakage: robocode.manager
        at
robocode.security.RobocodeSecurityManager.checkPackageAccess(RobocodeSecurityManager.java:559)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:273)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
        at
robocode.security.RobocodeClassLoader.loadClass(RobocodeClassLoader.java:116)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at singleplayer.Sprobot.<init>(Sprobot.java:26)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at robocode.battle.Battle.unsafeLoadRobots(Battle.java:1435)
        at robocode.battle.Battle$UnsafeLoadRobotsThread.run(Battle.java:1679)
..



Here are KeyStrokeConfig,java

package robocode.manager;

public class KeyStrokeConfig {
       
        public
        int UpKey=0x26;
        int DownKey=0x28;
        int RightKey=0x27;
        int LeftKey=0x25;
        int FirePower1Key=0x4A;
        int FirePower2Key=0x48;
        int FirePower3Key=0x47;
        int GunRightKey=0x55;
        int GunLeftKey=0x49;
       
       
        public void setKeysValues(int upKey,int downKey,
        int rightKey,
        int leftKey,
        int firePower1Key,
        int firePower2Key,
        int firePower3Key,
        int gunRightKey,
        int gunLeftKey)
        {
                UpKey=upKey;
                DownKey=downKey;
                RightKey=rightKey;
                LeftKey=leftKey;
                FirePower1Key=firePower1Key;
                FirePower2Key=firePower2Key;
                FirePower3Key=firePower3Key;
                GunRightKey=gunRightKey;
                GunLeftKey=gunLeftKey;
               
        }
        public int getRightKey()
        {
                return RightKey;
        }

        public int getDownKey()
        {
                return DownKey;
        }
        public int getUpKey()
        {
                return UpKey;
                }
        public int getleftKey()
        {
                return LeftKey;
        }
        public int getFirePower1Key()
        {
                return FirePower1Key;
        }
        public int getFirePower2Key()
        {
                return FirePower2Key;
        }
        public int getFirePower3Key()
        {
                return FirePower3Key;
        }
        public int getGunRightKey()
        {
                return GunRightKey;
        }
        public int getGunleftKey()
        {
                return GunLeftKey;
        }

}


Here is my Sprobot.java

package singleplayer;
import robocode.AdvancedRobot;
import robocode.manager.RobocodeManager;
import robocode.manager.*;

import java.awt.*;
import java.awt.event.KeyEvent;


public class Sprobot extends AdvancedRobot {
       
        public RobocodeManager manager;
                // Move direction: 1 = move forward, 0 = stand still, -1 = move backward
                int moveDirection;

                // Turn direction: 1 = turn right, 0 = no turning, -1 = turn left
                int turnDirection;

                // Amount of pixels/units to move
                double moveAmount;
               
                // Fire power, where 0 = don't fire
                int firePower;
                int firePower2;
                String sr;
                KeyStrokeConfig keyconfig= new KeyStrokeConfig();
               
                // Called when the robot must run
                public void run() {

                        // Sets the colors of the robot
                        // body = black, gun = white, radar = red
                        setColors(Color.BLACK, Color.BLACK, Color.YELLOW);

                        // Loop forever
                        for (;;) {
                                // Sets the robot to move forward, backward or stop moving depending
                                // on the move direction and amount of pixels to move
                                setAhead(moveAmount * moveDirection);

                                // Decrement the amount of pixels to move until we reach 0 pixels
                                // This way the robot will automatically stop if the mouse wheel
                                // has stopped it's rotation
                                moveAmount = Math.max(0, moveAmount - 1);

                                // Sets the robot to turn right or turn left (at maximum speed) or
                                // stop turning depending on the turn direction
                                setTurnRight(45 * turnDirection); // degrees

                       

                                // Fire the gun with the specified fire power, unless the fire
power = 0
                                if (firePower > 0) {
                                        setFire(firePower);
                                }

                                // Execute all pending set-statements
                                execute();

                                // Next turn is processed in this loop..
                        }
                }

               
                public void onKeyPressed(KeyEvent e) {
                                               
                        if(e.getKeyCode()==keyconfig.getUpKey())
                        {
                                moveDirection = 1;
                                moveAmount = Double.POSITIVE_INFINITY;
                        }
                        if(e.getKeyCode()==keyconfig.getDownKey())
                        {
                                moveDirection = -1;
                                moveAmount = Double.POSITIVE_INFINITY;
                        }
                        if(e.getKeyCode()==keyconfig.getleftKey())
                        {
                                turnDirection = -1;
                        }
                        if(e.getKeyCode()==keyconfig.getRightKey())
                        {
                                turnDirection = 1;
                        }
                        if(e.getKeyCode()==keyconfig.getFirePower1Key())
                        {
                                firePower = 3;
                                setBulletColor(Color.RED);
                        }
                        if(e.getKeyCode()==keyconfig.getFirePower2Key())
                        {
                                firePower = 2;
                                setBulletColor(Color.YELLOW);
                        }
                        if(e.getKeyCode()==keyconfig.getFirePower3Key())
                        {
                                firePower = 1;
                                setBulletColor(Color.BLUE);
                        }
                        if(e.getKeyCode()==keyconfig.getGunleftKey())
                        {
                                char c = e.getKeyChar();
                                if (c == 'u') {
                                setTurnGunLeft(90);
                                }
                        }
                        if(e.getKeyCode()==keyconfig.getGunRightKey())
                        {
                                        char d = e.getKeyChar();
                                        if (d == 'u') {
                                        setTurnGunRight(90);
                                        }
                        }
                        }
                               
                public void onKeyReleased(KeyEvent e) {
                        if(e.getKeyCode()==keyconfig.getUpKey())
                        {
                       
                        }
                        if(e.getKeyCode()==keyconfig.getDownKey())
                        {
                                moveDirection = 0;
                        }
                        if(e.getKeyCode()==keyconfig.getleftKey())
                        {
                                turnDirection = 0;
                        }
                        if(e.getKeyCode()==keyconfig.getRightKey())
                        {
                               
                        }
                        if(e.getKeyCode()==keyconfig.getFirePower1Key())
                        {
                                firePower = 0;
                        }
                        if(e.getKeyCode()==keyconfig.getFirePower2Key())
                        {
                                firePower = 0;
                       
                        }
                        if(e.getKeyCode()==keyconfig.getFirePower3Key())
                        {
                                firePower = 0;
                       
                        }
                       
                }
                }


 « Return to Thread: Robocode Security Error