A government lawyer says Canada's immigration-detention system may not be perfect but it is constitutional.

He is telling Federal Court it would be a mistake to throw out the law allowing for immigrant detention because problems may occur as a result.

A Jamaican man who was detained for five years before being deported is challenging the constitutionality of immigration laws.

Alvin Brown and his supporters argue that the scheme allows for indefinite detention, amounting to cruel and unusual punishment.

But the government lawyer notes that another judge ruled immigration authorities were not to blame for Brown's long detention.

He argues each case is different and that detainees do have numerous ways to seek redress if they believe their circumstances are unreasonable.