The European Union's top advocate says Poland has violated EU law with legislation in 2018 that lowered the retirement age for top court judges and forced many of them out of their jobs.

In his opinion, Advocate General Evgeni Tanchev said Thursday the Polish law that lowered the retirement age to 65 and ousted almost 30 Supreme Court judges violated judicial independence and the principle that they cannot be removed.

He recommended that the EU Court of Justice rule that the legislation is contrary to EU law. The ruling is expected with weeks.

Under heavy criticism from the EU and from experts at home, Poland's right-wing government waived the regulations and reinstated the judges, but the EU believes the case should be considered in the interest of its justice regulations.