I'm using swig to translate C++ classes into Java classes. At the moment the main structure works fine, but I have got some problems with const and not-const reference parameters:

I have got within my C++ classes some method signatures like:

void myclass::mymethod(const ublas::matrix<double>& matrix1, ublas::matrix<double>& matrix2)

In the Swig interface I have this defined:

%typemap(in, optimal=1, noblock=1) ublas::matrix<double>& (ublas::matrix<double> l_param) {
    l_param = swig::java::getDoubleMatrixFrom2DArray(jenv, $input);
    $1      = &l_param;

This works for const references but not for non-const references, so can I modify this typemap to handle only const references?
I have tried it with
%typemap(in, optimal=1, noblock=1) const ublas::matrix<double>& (ublas::matrix<double> l_param)

but this does not work and how can I create an own typemap to handle the non-const reference?