1

I am planning on hosting a little tournament.

The competitors will each provide a Java class implementing an interface which will accept a GameState for Connect Four, and return a move.

How do I prevent a team from finding the other team's class(via reflection) and messing with their methods to fight an easy opponent?

Cruncher
  • 7,641
  • 1
  • 31
  • 65
  • Why don't you tell inside the rules of your tournament that using reflection is forbidden ? – Julien Sep 04 '13 at 17:10
  • 1
    @Julien That's the fallback. But life is about learning. There's something more elegant about preventing something, then just telling them they can't do it. Banks don't just say "You're not allowed to rob us". They prevent you from robbing them. – Cruncher Sep 04 '13 at 17:14
  • 1
    @Dev to be fair, I searched the exact string of this title before posting and that didn't come up. It showed up afterwards. Does SO just like setting people up? – Cruncher Sep 04 '13 at 17:16
  • 1
    @Cruncher I'm not passing judgement, just informing, the downvote was not from me, I don't usually downvote for duplicates unless its a painfully obvious one. – Dev Sep 04 '13 at 17:18
  • [OSGi](http://en.wikipedia.org/wiki/OSGi) to have real modules? Some containers are felix and equinox. – Joop Eggen Sep 04 '13 at 18:16

2 Answers2

7

This is a very hard problem, and is similar in nature to the security sandbox imposed on Java applets.

Sun (and now Oracle) tried for many years to do this right, they still have yet to succeed.

You should assume that any code that runs has a way around your security measures. If you want to make it hard for the code to interfere with other running programs, you should make the opponents communicate over a socket instead of in-process and perhaps run them on different virtual machines.

Steven Schlansker
  • 37,580
  • 14
  • 81
  • 100
0

According to this question, you can at least manage to keep a private object in your tournament arbiter program safe from view.

Community
  • 1
  • 1
clwhisk
  • 1,805
  • 1
  • 18
  • 17