Q:

javaout typemap doesn't work for std::vector

When I'm using int everything works fine - 
%immutable S::field;

%typemap(javaout) int S::field {
  //custom code
}

struct S {
  int field;
};

But approach doesn't work for std::vector<int>
%include <std_vector.i>

%immutable S::field;
%template(vector_int) std::vector<int>;

%typemap(javaout) std::vector<int> S::field {
  //custom code
}

struct S {
  std::vector<int> field;
};

Samples were compiled with swig -java -c++ -module sample sample.i

A:

See the Swig docs on structure data members.
The key point is: 

When a structure member is wrapped, it is handled as a pointer, unless the %naturalvar directive is used where it is handled more like a C++ reference.

So the typemap you need to define is
%typemap(javaout) std::vector<int>* S::field {
    //custom code
}

(or %typemap(javaout) std::vector<int>& S::field if you are using %naturalvar).

