BOSTON — A former FBI agent has testified that a man who was allegedly killed by James “Whitey” Bulger predicted his own death if Bulger was to learn he’d been cooperating with the FBI.

Retired agent Gerald Montanari told jurors Monday that Edward “Brian” Halloran had agreed to testify against Bulger and members of his gang, hoping he could get help on a murder charge he faced.

Montanari says Halloran told him that if Bulger or his partner found out he was cooperating, they would “go to any extreme,” even if it meant killing bystanders.

Bulger is charged with opening fire on a car Halloran was in after learning Halloran was talking to the FBI. Halloran and Michael Donahue, an acquaintance, were killed.

Bulger has pleaded not guilty to participating in 19 killings.