Fix compiler errors on Java and C# targets