battlecode / battlecode-server-2017

Official Battlecode game engine.
http://www.battlecode.org/
GNU Affero General Public License v3.0
23 stars 10 forks source link

Kotlin support #420

Closed Pear0 closed 7 years ago

Pear0 commented 7 years ago

I've added support for most Kotlin features in this merge. The notable exception is delegated properties which rely on kotlin/reflect/KProperty because @kazimuth asked that it be disabled.

I chose to add Kotlin as a dependency for three reasons.

  1. It means the kotlin.* package can be marked off-limits for all player code.
  2. It ties a specific version to the server which will make auditing it significantly easier.
  3. If kotlin.jvm.internal.Intrinsics is not bytecode counted but provided by the player, it opens an attack vector where player code can be run without being counted.

I also re-implemented some of the Java instrumenter tests for Kotlin and added tests to assert the correct bytecode counting of Intrinsics vs. the rest of the Kotlin stdlib.

I feel like I have a pretty good grasp on the custom class loader and instrumentation, but if someone more experienced with the battlecode source looked over my changes, especially to those files, that would be great.

Pear0 commented 7 years ago

This merge is for #402.

kazimuth commented 7 years ago

Looks great, thank you for your work!

muandrew commented 7 years ago

Thanks!