SACRAMENTO—California judges and their spouses should not hold a financial interest in marijuana enterprises, even though medical and recreational cannabis use is legal in California, a state Supreme Court ethics committee said in a formal opinion Wednesday.

Marijuana remains illegal under federal law, the opinion said, and a judge who has a stake in a related business or nonprofit risks violating canons that require compliance with all laws and avoidance of the appearance of impropriety. Financial ties to marijuana, even indirect ones, may also cast doubt on a judge's ability to act impartially, the committee said.

The ethics opinion “advises that judges have an ongoing responsibility to discover if their investments involve a marijuana business,” San Diego County Superior Court Judge Kenneth So, a committee member, said in a statement that accompanied the publication of the advisory.